"use strict";var e=require("obsidian"),t=require("fs");class C extends e.Events{trigger(e,...t){super.trigger(e,...t)}on(e,t,C){return super.on(e,t,C)}}const i=["pinned","expanded","active-node","inactive-node","connected-active-node","hover","unhover","connected-hover","protected","filtered","hard-filtered"],H=function(e){return`${e.configDir}/plugins/juggl/`};class n{constructor(e,t){this.id=e,this.storeId=t}toString(){return`${this.storeId}:${this.id}`}toId(){return this.toString()}static fromId(e){const t=e.split(":"),C=t[0],i=t.slice(1).join(":");return new n(i,C)}static fromNode(e){return n.fromId(e.id())}static fromNodes(e){return e.map((e=>n.fromNode(e)))}static fromFile(e){return new n(e.name,"core")}static toId(e,t){return new n(e,t).toId()}}const V=function(e){return[].concat(...e.map((e=>{const t=(e=e.slice(1)).split("/"),C=[];for(const e in t){const i=t.slice(0,parseInt(e)+1).join("-");C.push(`tag-${i}`)}return C})))},r=async function(t,C,i,H){H||(H=n.toId(t.name,"core"));const r=C.app.metadataCache.getFileCache(t),L="md"===t.extension?t.basename:t.name,o=function(t,C){if(t){const i=[];if(["png","jpg","jpeg","gif","bmp","svg","tiff"].contains(t.extension)?i.push("image"):["mp3","webm","wav","m4a","ogg","3gp","flac"].contains(t.extension)?i.push("audio"):["mp4","webm","ogv"].contains(t.extension)?i.push("video"):"pdf"===t.extension&&i.push("pdf"),"md"===t.extension){i.push("note");const H=C.getFileCache(t);if(H?.frontmatter){if("image"in H.frontmatter&&i.push("image"),"tags"in H.frontmatter){const t=e.parseFrontMatterTags(H.frontmatter);t&&i.push(...V(t))}if("cssclass"in H.frontmatter){const t=e.parseFrontMatterStringArray(H.frontmatter,"cssclass");t&&i.push(...t)}}H?.tags&&i.push(...V(H.tags.map((e=>e.tag))))}else i.push("file");return i}return["dangling"]}(t,C.app.metadataCache).join(" "),a={id:H,name:L,path:t.path};if(["png","jpg","jpeg","gif","bmp","svg","tiff"].contains(t.extension))try{a.resource_url=`http://localhost:${C.settings.imgServerPort}/${encodeURI(t.path)}`}catch{}i.readContent&&"md"==t.extension&&(a.content=await C.app.vault.cachedRead(t));const M=r?.frontmatter;return M&&Object.keys(M).forEach((e=>{if("position"!==e)if("image"===e){const t=M[e];try{new URL(t),a[e]=t}catch{try{a[e]=`http://localhost:${C.settings.imgServerPort}/${encodeURI(t)}`}catch{}}}else a[e]=M[e]})),{group:"nodes",data:a,classes:o}},L=function(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")},o=function(e,t,C,i,H,n){const V=t[e.position.start.line];let r={id:C,source:i,target:H,context:V,edgeCount:1,line:e.position.start.line,start:e.position.start.col,end:e.position.end.col};const o=e.original.split("|");o.length>1&&(r.alias=o.slice(1).join().slice(0,-2));let a="";const M=function(e,t,C){const i=new RegExp(`^${L(C)} (publishedIn) (\\d\\d\\d\\d) (\\[\\[([^\\]\\r\\n]+?)\\]\\],? *)+$`).exec(t);if(null!==i)return{class:"type-publishedIn",isInline:!1,properties:{year:i[2],context:"",type:"publishedIn"}};const H=new RegExp(`^${L(C)} ([^\\W\\d]\\w*) (\\[\\[([^\\]\\r\\n]+?)\\]\\],? *)+$`).exec(t),n=e.original.split("|");let V=null;return n.length>1&&(V=n.slice(1).join().slice(0,-2)),null!==H?{class:`type-${H[1]}`,isInline:!1,properties:{alias:V,context:"",type:H[1]}}:null}(e,V,n);return null===M?a=`${a} inline`:(r={...M.properties,...r},a=`${a} ${M.class}`),{group:"edges",data:r,classes:a}};class a extends e.Component{constructor(e){super(),this.plugin=e,this.events=new C,this.metadata=e.app.metadataCache,this.vault=e.app.vault}getEvents(e){return this.events}async createEdges(t,C,i,H){if("md"!==t.extension)return[];const n=this.metadata.getFileCache(t);if(!n)return[];const V={},r=(await this.vault.cachedRead(t)).split("\n");if(e.iterateCacheRefs(n,(e=>{const H=this.getOtherId(e,t.path).toId();if(i.$id(H).length>0){const t=`${C}->${H}`,i=t in V?V[t].length+1:1,n=o(e,r,`${t}${i}`,C,H,this.plugin.settings.typedLinkPrefix);t in V?V[t].push(n):V[t]=[n]}})),H.settings.mergeEdges){const e=[];for(const t of Object.keys(V)){const C=V[t];let i=null,H=0;for(const t of C)" inline"===t.classes?i?(i.data.context+=`\n \n---\n\n${t.data.context}`,H+=1):(i=t,H=1):e.push(t);i&&(i.data.edgeCount=H,e.push(i))}return e}return[].concat(...Object.values(V))}async connectNodes(e,t,C){const i=[];for(const H of t){const t=n.fromNode(H);if(t.storeId===this.storeId()){const H=this.getFile(t);if(H){const n=t.toId();i.push(...await this.createEdges(H,n,e,C))}}}for(const H of e.difference(t)){const e=n.fromNode(H);if(e.storeId===this.storeId()){const H=this.getFile(e);if(H){const n=e.toId();i.push(...await this.createEdges(H,n,t,C))}}}return i}getOtherId(t,C){const i=e.getLinkpath(t.link),H=this.metadata.getFirstLinkpathDest(i,C);return new n(H?H.name:i,this.storeId())}async getNodeFromLink(t,C,i){const H=e.getLinkpath(t.link),V=this.metadata.getFirstLinkpathDest(H,C);return V?await r(V,this.plugin,i.settings):function(e){return{group:"nodes",data:{id:n.toId(e,"core"),name:e},classes:"dangling"}}(H)}getFile(e){return this.metadata.getFirstLinkpathDest(e.id,"")}async fillWithBacklinks(e,t,C){if("core"===t.storeId){const i=this.getFile(t).path,H=this.metadata.resolvedLinks;for(const t of Object.keys(H))if(i in H[t]){const i=this.vault.getAbstractFileByPath(t),H=n.fromFile(i).toId();H in e||(e[H]=await r(i,this.plugin,C.settings))}}}async getNeighbourhood(t,C){const i={};for(const H of t)if(H.storeId===this.storeId()){const t=this.getFile(H);if(null===t)continue;const n=this.metadata.getFileCache(t);if(null===n)continue;H.toId()in i||(i[H.toId()]=await r(t,this.plugin,C.settings));const V={};e.iterateCacheRefs(n,(e=>{const H=this.getOtherId(e,t.path).toId();H in i||(V[H]=this.getNodeFromLink(e,t.path,C))}));for(const e of Object.keys(V))e in i||(i[e]=await V[e]);await this.fillWithBacklinks(i,H,C)}return Object.values(i)}storeId(){return"core"}get(e,t){const C=this.getFile(e);if(null===C)return null;return null===this.metadata.getFileCache(C)?(console.log("returning empty cache",e,t),null):Promise.resolve(r(C,this.plugin,t.settings))}async refreshNode(e,t){const C=e.toId();let i,H=t.viz.$id(C);if(null===this.getFile(e))return void(H&&(H.remove(),t.onGraphChanged(!0,!0)));if(H.length>0&&H.hasClass("expanded"))i=await t.expand(H,!0,!1);else{const n=await this.get(e,t);t.mergeToGraph([n],!0,!1),H=t.viz.$id(C);const V=await t.buildEdges(H);i=t.mergeToGraph(V,!0,!1)}(H.connectedEdges().difference(i.merged).remove().length>0||i.added.length>0)&&t.onGraphChanged(!0,!0)}onload(){super.onload();const t=this;this.registerEvent(this.metadata.on("changed",(e=>{t.plugin.activeGraphs().forEach((async C=>{await t.refreshNode(n.fromFile(e),C)}))}))),this.registerEvent(this.vault.on("rename",((C,i)=>{if(C instanceof e.TFile){const e=n.fromFile(C),H=n.fromPath(i);t.plugin.activeGraphs().forEach((async C=>{setTimeout((async()=>{C.viz.$id(H.toId()).remove(),await t.refreshNode(e,C)}),500)}))}}))),this.registerEvent(this.vault.on("delete",(C=>{C instanceof e.TFile&&t.plugin.activeGraphs().forEach((e=>{e.viz.$id(n.fromFile(C).toId()).remove()}))})))}}function M(){}function s(e){return e()}function l(){return Object.create(null)}function d(e){e.forEach(s)}function u(e){return"function"==typeof e}function A(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}let c,h;function m(e,t){e.appendChild(t)}function f(e,t,C){e.insertBefore(t,C||null)}function p(e){e.parentNode.removeChild(e)}function g(e,t){for(let C=0;Ce.removeEventListener(t,C,i)}function x(e,t,C){null==C?e.removeAttribute(t):e.getAttribute(t)!==C&&e.setAttribute(t,C)}function O(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function k(e,t){e.value=null==t?"":t}function E(e,t,C,i){e.style.setProperty(t,C,i?"important":"")}function P(e,t){for(let C=0;C{$.delete(e),i&&(C&&e.d(1),i())})),e.o(t)}}function q(e){e&&e.c()}function Q(e,t,C,i){const{fragment:H,on_mount:n,on_destroy:V,after_update:r}=e.$$;H&&H.m(t,C),i||I((()=>{const t=n.map(s).filter(u);V?V.push(...t):d(t),e.$$.on_mount=[]})),r.forEach(I)}function K(e,t){const C=e.$$;null!==C.fragment&&(d(C.on_destroy),C.fragment&&C.fragment.d(t),C.on_destroy=C.fragment=null,C.ctx=[])}function J(e,t){-1===e.$$.dirty[0]&&(_.push(e),F||(F=!0,R.then(G)),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const n=i.length?i[0]:C;return o.ctx&&H(o.ctx[t],o.ctx[t]=n)&&(!o.skip_bound&&o.bound[t]&&o.bound[t](n),a&&J(e,t)),C})):[],o.update(),a=!0,d(o.before_update),o.fragment=!!i&&i(o.ctx),t.target){if(t.hydrate){const e=function(e){return Array.from(e.childNodes)}(t.target);o.fragment&&o.fragment.l(e),e.forEach(p)}else o.fragment&&o.fragment.c();t.intro&&Y(e.$$.fragment),Q(e,t.target,t.anchor,t.customElement),G()}T(L)}class te{$destroy(){K(this,1),this.$destroy=M}$on(e,t){const C=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return C.push(t),()=>{const e=C.indexOf(t);-1!==e&&C.splice(e,1)}}$set(e){var t;this.$$set&&(t=e,0!==Object.keys(t).length)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const Ce=function(e){return`${e.configDir}/plugins/juggl/graph.css`},ie=["ellipse","rectangle","triangle","diamond","pentagon","hexagon","tag","rhomboid","star","vee","round-rectangle","round-triangle","round-diamond","round-pentagon","round-hexagon","round-tag"],He="\n/* For a full overview of styling options, see https://js.cytoscape.org/#style */\n",ne=function(e){const t=document.createElement("div");t.addClass("graph-view",e),document.body.appendChild(t);const C=getComputedStyle(t).getPropertyValue("color");return t.detach(),C};class Ve{constructor(e){this.defaultSheet=this.getDefaultStylesheet(),this.yamlModifySheet="\n\n\nnode[title] {\n label: data(title);\n}\n\nnode[color] {\n background-color: data(color);\n}\n\nnode[shape] {\n shape: data(shape);\n}\n\nnode[width] {\n width: data(width);\n}\n\nnode[height] {\n width: data(height);\n}\n\nnode[image] {\n background-image: data(image);\n}\n",this.plugin=e}async getStylesheet(e){const C=this.plugin.vault.adapter.getFullPath(Ce(this.plugin.vault));let i="";try{i=await t.promises.readFile(C,"utf-8").catch((async e=>{if("ENOENT"===e.code){const e=He;return await t.promises.writeFile(C,e),e}throw e}))}catch(e){console.log("Couldn't load user stylesheet. This is probably because we are on mobile"),console.log(e)}let H="";"settings"in this.plugin&&(H=this.styleGroupsToSheet(this.plugin.settings.globalStyleGroups,"global"));const n=this.styleGroupsToSheet(e.settings.styleGroups,"local");return this.defaultSheet+H+i+n+this.yamlModifySheet}colorToRGBA(e){const t=document.createElement("canvas");t.width=t.height=1;const C=t.getContext("2d");C.clearRect(0,0,1,1),C.fillStyle="#000",C.fillStyle=e;const i=C.fillStyle;if(C.fillStyle="#fff",C.fillStyle=e,i!==C.fillStyle)return;C.fillRect(0,0,1,1);const H=[...C.getImageData(0,0,1,1).data];return`rgb(${H[0]}, ${H[1]}, ${H[2]})`}styleGroupsToSheet(e,t){let C="";const i=new DOMParser;for(const[H,n]of e.entries())if(n.show){let e="";if(n.icon&&n.icon.path){const t=``,C=i.parseFromString(t,"text/xml").documentElement.outerHTML;e=`background-image: url('data:image/svg+xml,${encodeURIComponent(C)}');`}const V=Math.max(Math.min(n.size,1),Math.sqrt(n.size));C+=`\nnode.${t}-${H} {\n background-color: ${n.color};\n shape: ${n.shape};\n background-fit: contain;\n ${e} \n width: mapData(degree, 0, 60, ${5*n.size}, ${35*n.size});\n height: mapData(degree, 0, 60, ${5*n.size}, ${35*n.size});\n font-size: mapData(degree, 0, 60, ${5*V}, ${11*V});\n text-max-width: mapData(degree, 0, 60, ${Math.round(65*V)}px, ${Math.round(100*V)}px);\n} \n`}else C+=`\nnode.${t}-${H} {\n display: none;\n}\n`;return C}getDefaultStylesheet(){let e=getComputedStyle(document.body).getPropertyValue("--text");e=e.replace("BlinkMacSystemFont,",""),0===e.length&&(e="Helvetica Neue");const t=ne("color-fill"),C=ne("color-fill-highlight"),i=ne("color-circle"),H=ne("color-line"),n=ne("color-line-highlight"),V=ne("color-text");return`\nnode {\n background-color: ${t};\n color: ${V};\n font-family: ${e};\n text-valign: bottom;\n shape: ellipse;\n border-width: 0;\n text-wrap: wrap;\n min-zoomed-font-size: 8;\n}\n\nnode[name] {\n label: data(name);\n}\nnode[degree] {\n width: mapData(degree, 0, 60, 5, 35);\n height: mapData(degree, 0, 60, 5, 35);\n font-size: mapData(degree, 0, 60, 5, 11);\n text-opacity: mapData(degree, 0, 60, 0.7, 1);\n text-max-width: mapData(degree, 0, 60, 65px, 100px);\n}\n\nnode:selected {\n background-blacken: 0.3;\n font-weight: bold;\n \n}\nnode:selected[degree] {\n border-width: mapData(degree, 0, 60, 1, 3);\n}\n\n.dangling {\n background-color: ${ne("color-fill-unresolved")};\n}\n\n.image {\n shape: round-rectangle;\n width: 50;\n height: 50;\n background-opacity: 0;\n background-image: data(resource_url);\n background-image-crossorigin: anonymous;\n background-image-opacity: 1;\n background-fit: contain;\n font-size: 0;\n background-clip: node;\n}\n\n.image.note {\n font-size: mapData(degree, 0, 60, 5, 11);\n}\n\nedge {\n line-color: ${H};\n loop-sweep: -50deg;\n loop-direction: -45deg;\n width: 0.70;\n \n target-arrow-shape: vee;\n target-arrow-fill: filled;\n target-arrow-color: ${H};\n \n arrow-scale: 0.55;\n\n font-size: 6;\n font-family: ${e};\n color: ${V};\n curve-style: straight;\n\n}\n\nedge[edgeCount] {\n width: mapData(edgeCount, 1, 50, 0.55, 3);\n arrow-scale: mapData(edgeCount, 1, 50, 0.35, 1.5);\n}\n\nedge:selected {\n width: 0.7;\n font-weight: bold;\n line-color: ${n};\n}\n\n:loop {\n display: none;\n}\n\nedge[type] {\n label: data(type);\n}\n.inactive-node,\n.unhover {\n opacity: 0.3;\n}\nnode.active-node,\nnode.hover {\n background-color: ${C};\n font-weight: bold;\n border-width: 0.4;\n border-color: ${i};\n opacity: 1;\n}\nedge.hover,\nedge.connected-active-node,\nedge.connected-hover {\n width: 1;\n opacity: 1;\n}\nedge.hover,\nedge.connected-hover {\n font-weight: bold;\n line-color: ${n}; \n target-arrow-color: ${n};\n}\n\nnode.pinned {\n border-style: dotted;\n border-width: 2;\n}\nnode.protected {\n ghost: yes;\n ghost-offset-x: 1px;\n ghost-offset-y: 1px;\n ghost-opacity: 0.5;\n}\nnode.hard-filtered,\nnode.filtered {\n display: none;\n}\n`}}function re(e){let t,C,i,H,n,V,r,L,o,a,s,l;return{c(){t=v("h3"),t.textContent="Appearance",C=S(),i=v("p"),H=Z("You can style the graph with css. This is done in the "),n=Z(e[0]),V=Z(" file.\n See "),r=v("a"),r.textContent="this page",L=Z(" for help with styling."),o=S(),a=v("button"),a.textContent="Open graph.css in default editor.",x(r,"href","https://publish.obsidian.md/semantic-obsidian/Node+styling")},m(M,d){f(M,t,d),f(M,C,d),f(M,i,d),m(i,H),m(i,n),m(i,V),m(i,r),m(i,L),f(M,o,d),f(M,a,d),s||(l=w(a,"click",e[1]),s=!0)},p:M,i:M,o:M,d(e){e&&p(t),e&&p(C),e&&p(i),e&&p(o),e&&p(a),s=!1,l()}}}function Le(e,t,C){let{plugin:i}=t,H=Ce(i.vault);return e.$$set=e=>{"plugin"in e&&C(2,i=e.plugin)},[H,async function(){let e=i.vault.adapter.getFullPath(H);try{const t=require("electron").shell,{promises:C}=require("fs");await C.writeFile(e,He,{flag:"wx"}).catch((e=>{})),await t.openPath(e)}catch(e){console.log("Couldn't open graph.css. This is probably because we are on mobile."),console.log(e)}},i]}class oe extends te{constructor(e){super(),ee(this,e,Le,re,A,{plugin:2})}}function ae(e){let t,C,i,H,n,V;return{c(){var e,n;t=v("script"),i=S(),H=v("div"),x(t,"type","text/javascript"),e=t.src,n=C="https://ko-fi.com/widgets/widget_2.js",c||(c=document.createElement("a")),c.href=n,e!==c.href&&x(t,"src","https://ko-fi.com/widgets/widget_2.js")},m(C,r){m(document.head,t),f(C,i,r),f(C,H,r),e[2](H),n||(V=w(t,"load",e[1]),n=!0)},p:M,i:M,o:M,d(C){p(t),C&&p(i),C&&p(H),e[2](null),n=!1,V()}}}function Me(e,t,C){let i;return[i,()=>{kofiwidget2.init("Support Juggl development!","#29abe0","B0B23OPUE"),C(0,i.innerHTML=kofiwidget2.getHTML(),i)},function(e){B[e?"unshift":"push"]((()=>{i=e,C(0,i)}))}]}class se extends te{constructor(e){super(),ee(this,e,Me,ae,A,{})}}const le=["force-directed","circle","grid","hierarchy","cola"],de={filter:"",color:"black",shape:"ellipse",icon:{name:"No icon",path:"",color:"white"},showInPane:!0,show:!0,size:1},ue={splitDirection:"vertical",typedLinkPrefix:"-",useImgServer:!1,imgServerPort:3837,debug:!1,globalStyleGroups:[],globalGraphRibbon:!0,graphSettings:{animateLayout:!0,autoAddNodes:!0,autoExpand:!1,autoZoom:!1,coreStore:"Obsidian",expandInitial:!0,fdgdLayout:"d3-force",filter:"",height:"100%",hoverEdges:!1,layout:"force-directed",limit:1e4,mergeEdges:!0,metaKeyHover:!1,mode:"workspace",navigator:!0,openWithShift:!1,readContent:!0,styleGroups:[],toolbar:!0,width:"100%",zoomSpeed:1},embedSettings:{animateLayout:!0,autoAddNodes:!1,autoExpand:!1,autoZoom:!1,coreStore:"Obsidian",expandInitial:!0,fdgdLayout:"cola",filter:"",height:"400px",hoverEdges:!1,layout:"force-directed",limit:1e3,mergeEdges:!0,metaKeyHover:!1,mode:"local",navigator:!1,openWithShift:!1,readContent:!0,styleGroups:[],toolbar:!1,width:"100%",zoomSpeed:1},globalGraphSettings:{animateLayout:!0,autoAddNodes:!0,autoExpand:!1,autoZoom:!1,coreStore:"Obsidian",expandInitial:!1,fdgdLayout:"cola",filter:"-class:dangling -class:file",height:"100%",width:"100%",limit:1e4,hoverEdges:!1,layout:"force-directed",mergeEdges:!0,metaKeyHover:!1,mode:"workspace",navigator:!0,openWithShift:!1,readContent:!1,styleGroups:[],toolbar:!0,zoomSpeed:1}};class Ae extends e.PluginSettingTab{constructor(e,t){super(e,t),this.plugin=t}display(){const{containerEl:t}=this;t.empty(),t.createEl("h3"),t.createEl("h3",{text:"Juggl"}),new se({target:t});const C=document.createElement("a");C.href="https://juggl.io",C.target="_blank",C.innerHTML="the documentation";const i=document.createElement("a");i.href="https://discord.gg/sAmSGpaPgM",i.target="_blank",i.innerHTML="the Discord server";const H=document.createElement("p");H.innerHTML="Check out "+C.outerHTML+" for documentation on how to use the plugin.
Join "+i.outerHTML+" for help, nice discussion and insight into development.",t.appendChild(H),new oe({target:t,props:{plugin:this.plugin}}),t.createEl("h3"),t.createEl("h3",{text:"Extensions"}),new e.Setting(t).setName("Use navigator").setDesc("Use the navigator overview in the bottom-right corner. Disabling could improve performance.").addToggle((e=>{e.setValue(this.plugin.settings.graphSettings.navigator).onChange((e=>{this.plugin.settings.globalGraphSettings.navigator=e,this.plugin.settings.graphSettings.navigator=e,this.plugin.saveData(this.plugin.settings)}))})),new e.Setting(t).setName("Default mode").setDesc("The default mode to open the Advanced Graph View in.").addDropdown((e=>{e.addOption("local","Local Mode"),e.addOption("workspace","Workspace Mode"),e.setValue(this.plugin.settings.graphSettings.mode).onChange((e=>{this.plugin.settings.graphSettings.mode=e,this.plugin.saveData(this.plugin.settings)}))})),new e.Setting(t).setName("Force-directed algorithm").setDesc("The default force-directed graph drawing algorithm to use. Cola is nice, but unstable in some use cases. Obsidian uses D3").addDropdown((e=>{e.addOption("cola","Cola"),e.addOption("d3-force","D3"),e.setValue(this.plugin.settings.graphSettings.fdgdLayout).onChange((e=>{this.plugin.settings.graphSettings.fdgdLayout=e,this.plugin.settings.embedSettings.fdgdLayout=e,this.plugin.settings.globalGraphSettings.fdgdLayout=e,this.plugin.saveData(this.plugin.settings)}))})),new e.Setting(t).setName("Global Graph Icon").setDesc("Show the Global Graph Icon on the left ribbon.").addToggle((e=>{e.setValue(this.plugin.settings.globalGraphRibbon).onChange((e=>{this.plugin.settings.globalGraphRibbon=e,this.plugin.saveData(this.plugin.settings),this.plugin.setGlobalIcon()}))})),new e.Setting(t).setName("Require ⌘/ctrl for preview hovers").setDesc("When set to true, you will need to hold down ⌘ (mac) or ctrl (windows) to show preview hovers of notes.").addToggle((e=>{e.setValue(this.plugin.settings.graphSettings.metaKeyHover).onChange((e=>{this.plugin.settings.graphSettings.metaKeyHover=e,this.plugin.settings.globalGraphSettings.metaKeyHover=e,this.plugin.settings.embedSettings.metaKeyHover=e,this.plugin.saveData(this.plugin.settings)}))})),t.createEl("h4",{text:"Workspace mode"}),new e.Setting(t).setName("Automatically add nodes").setDesc("This will automatically add nodes to the graph whenever a note is opened.").addToggle((e=>{e.setValue(this.plugin.settings.graphSettings.autoAddNodes).onChange((e=>{this.plugin.settings.graphSettings.autoAddNodes=e,this.plugin.saveData(this.plugin.settings)}))})),new e.Setting(t).setName("Automatically zoom on active nodes").setDesc("This will automatically keep fitting the viewport on the currently active node. In particular, this happens when you open a file.").addToggle((e=>{e.setValue(this.plugin.settings.graphSettings.autoZoom).onChange((e=>{this.plugin.settings.graphSettings.autoZoom=e,this.plugin.settings.globalGraphSettings.autoZoom=e,this.plugin.saveData(this.plugin.settings)}))})),t.createEl("h3",{text:"Advanced"}),new e.Setting(t).setName("Zoom speed").setDesc("Speed with which zooming in and out happens. A value of 1 is recommended, but can be too quick for some mice.").addSlider((e=>{e.setDynamicTooltip().setLimits(.01,1.5,.01).setValue(this.plugin.settings.graphSettings.zoomSpeed).onChange((e=>{this.plugin.settings.graphSettings.zoomSpeed=e,this.plugin.settings.embedSettings.zoomSpeed=e,this.plugin.settings.globalGraphSettings.zoomSpeed=e,this.plugin.saveData(this.plugin.settings)}))})),new e.Setting(t).setName("Hover on edges").setDesc("Hover on edges to show what they are connected to.").addToggle((e=>{e.setValue(this.plugin.settings.graphSettings.hoverEdges).onChange((e=>{this.plugin.settings.graphSettings.hoverEdges=e,this.plugin.settings.embedSettings.hoverEdges=e,this.plugin.settings.globalGraphSettings.hoverEdges=e,this.plugin.saveData(this.plugin.settings)}))})),new e.Setting(t).setName("Open with shift").setDesc("Only opens file when clicking on a node when shift is pressed.").addToggle((e=>{e.setValue(this.plugin.settings.graphSettings.openWithShift).onChange((e=>{this.plugin.settings.graphSettings.openWithShift=e,this.plugin.settings.embedSettings.openWithShift=e,this.plugin.settings.globalGraphSettings.openWithShift=e,this.plugin.saveData(this.plugin.settings)}))})),new e.Setting(t).setName("Typed links prefix").setDesc("Prefix to use for typed links. Default is '-'. Requires a server restart.").addText((e=>{e.setPlaceholder("").setValue(this.plugin.settings.typedLinkPrefix).onChange((e=>{this.plugin.settings.typedLinkPrefix=e,this.plugin.saveData(this.plugin.settings)}))})),new e.Setting(t).setName("Render images in graph").setDesc("This will show image attachments in your vault as images in the graph. Requires reloading Juggl. WARNING: On Windows this will trigger your firewall!").addToggle((e=>{e.setValue(this.plugin.settings.useImgServer).onChange((e=>{this.plugin.settings.useImgServer=e,this.plugin.saveData(this.plugin.settings)}))})),new e.Setting(t).setName("Image server port").setDesc("Set the port of the image server. If you use multiple vaults, these need to be set differently. Default 3837.").addText((e=>{e.setValue(this.plugin.settings.imgServerPort+"").setPlaceholder("3837").onChange((e=>{this.plugin.settings.imgServerPort=parseInt(e.trim()),this.plugin.saveData(this.plugin.settings)}))})),new e.Setting(t).setName("Debug").setDesc("Enable debug mode, which prints a lot of stuff in the developers console.").addToggle((e=>{e.setValue(this.plugin.settings.debug).onChange((e=>{this.plugin.settings.debug=e,this.plugin.saveData(this.plugin.settings)}))}))}}var ce="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function he(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function me(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(C){var i=Object.getOwnPropertyDescriptor(e,C);Object.defineProperty(t,C,i.get?i:{enumerable:!0,get:function(){return e[C]}})})),t}function fe(e){var t={exports:{}};return e(t,t.exports),t.exports}var pe=/^\s+|\s+$/g,ge=/^[-+]0x[0-9a-f]+$/i,ve=/^0b[01]+$/i,ye=/^0o[0-7]+$/i,Ze=parseInt,Se="object"==typeof ce&&ce&&ce.Object===Object&&ce,be="object"==typeof self&&self&&self.Object===Object&&self,we=Se||be||Function("return this")(),xe=Object.prototype.toString,Oe=Math.max,ke=Math.min,Ee=function(){return we.Date.now()};function Pe(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Te(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==xe.call(e)}(e))return NaN;if(Pe(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Pe(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(pe,"");var C=ve.test(e);return C||ye.test(e)?Ze(e.slice(2),C?2:8):ge.test(e)?NaN:+e}var _e=function(e,t,C){var i,H,n,V,r,L,o=0,a=!1,M=!1,s=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function l(t){var C=i,n=H;return i=H=void 0,o=t,V=e.apply(n,C)}function d(e){return o=e,r=setTimeout(A,t),a?l(e):V}function u(e){var C=e-L;return void 0===L||C>=t||C<0||M&&e-o>=n}function A(){var e=Ee();if(u(e))return c(e);r=setTimeout(A,function(e){var C=t-(e-L);return M?ke(C,n-(e-o)):C}(e))}function c(e){return r=void 0,s&&i?l(e):(i=H=void 0,V)}function h(){var e=Ee(),C=u(e);if(i=arguments,H=this,L=e,C){if(void 0===r)return d(L);if(M)return r=setTimeout(A,t),l(L)}return void 0===r&&(r=setTimeout(A,t)),V}return t=Te(t)||0,Pe(C)&&(a=!!C.leading,n=(M="maxWait"in C)?Oe(Te(C.maxWait)||0,t):n,s="trailing"in C?!!C.trailing:s),h.cancel=function(){void 0!==r&&clearTimeout(r),o=0,i=L=H=r=void 0},h.flush=function(){return void 0===r?V:c(Ee())},h},Be=fe((function(e,t){(function(){var t,C,i,H,n,V,r,L,o,a,M,s,l,d,u;i=Math.floor,a=Math.min,C=function(e,t){return et?1:0},o=function(e,t,H,n,V){var r;if(null==H&&(H=0),null==V&&(V=C),H<0)throw new Error("lo must be non-negative");for(null==n&&(n=e.length);HC;0<=C?t++:t--)o.push(t);return o}.apply(this).reverse()).length;nu;0<=u?++s:--s)A.push(n(e,i));return A},d=function(e,t,i,H){var n,V,r;for(null==H&&(H=C),n=e[i];i>t&&H(n,V=e[r=i-1>>1])<0;)e[i]=V,i=r;return e[i]=n},u=function(e,t,i){var H,n,V,r,L;for(null==i&&(i=C),n=e.length,L=t,V=e[t],H=2*t+1;Ht?1:0},ft=null!=Object.assign?Object.assign.bind(Object):function(e){for(var t=arguments,C=1;C255)return;t.push(Math.floor(n))}var V=i[1]||i[2]||i[3],r=i[1]&&i[2]&&i[3];if(V&&!r)return;var L=C[4];if(void 0!==L){if((L=parseFloat(L))<0||L>1)return;t.push(L)}}return t}(e)||function(e){var t,C,i,H,n,V,r,L;function o(e,t,C){return C<0&&(C+=1),C>1&&(C-=1),C<1/6?e+6*(t-e)*C:C<.5?t:C<2/3?e+(t-e)*(2/3-C)*6:e}var a=new RegExp("^hsl[a]?\\(((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?)))\\s*,\\s*((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))[%])\\s*,\\s*((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))[%])(?:\\s*,\\s*((?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))))?\\)$").exec(e);if(a){if((C=parseInt(a[1]))<0?C=(360- -1*C%360)%360:C>360&&(C%=360),C/=360,(i=parseFloat(a[2]))<0||i>100)return;if(i/=100,(H=parseFloat(a[3]))<0||H>100)return;if(H/=100,void 0!==(n=a[4])&&((n=parseFloat(n))<0||n>1))return;if(0===i)V=r=L=Math.round(255*H);else{var M=H<.5?H*(1+i):H+i-H*i,s=2*H-M;V=Math.round(255*o(s,M,C+1/3)),r=Math.round(255*o(s,M,C)),L=Math.round(255*o(s,M,C-1/3))}t=[V,r,L,n]}return t}(e)},gt={transparent:[0,0,0,0],aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],grey:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},vt=function(e){for(var t=e.map,C=e.keys,i=C.length,H=0;H1&&void 0!==arguments[1]?arguments[1]:9261,i=C;!(t=e.next()).done;)i=i*Ot+t.value|0;return i},Et=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9261;return t*Ot+e|0},Pt=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5381;return(t<<5)+t+e|0},Tt=function(e){return 2097152*e[0]+e[1]},_t=function(e,t){return[Et(e[0],t[0]),Pt(e[1],t[1])]},Bt=function(e,t){var C={value:0,done:!1},i=0,H=e.length;return kt({next:function(){return i=0&&(e[i]!==t||(e.splice(i,1),!C));i--);},CC=function(e){e.splice(0,e.length)},iC=function(e,t,C){return C&&(t=At(C,t)),e[t]},HC=function(e,t,C,i){C&&(t=At(C,t)),e[t]=i},nC="undefined"!=typeof Map?Map:function(){function e(){ze(this,e),this._obj={}}return Ge(e,[{key:"set",value:function(e,t){return this._obj[e]=t,this}},{key:"delete",value:function(e){return this._obj[e]=void 0,this}},{key:"clear",value:function(){this._obj={}}},{key:"has",value:function(e){return void 0!==this._obj[e]}},{key:"get",value:function(e){return this._obj[e]}}]),e}(),VC=function(){function e(t){if(ze(this,e),this._obj=Object.create(null),this.size=0,null!=t){var C;C=null!=t.instanceString&&t.instanceString()===this.instanceString()?t.toArray():t;for(var i=0;i2&&void 0!==arguments[2])||arguments[2];if(void 0!==e&&void 0!==t&&ot(e)){var i=t.group;if(null==i&&(i=t.data&&null!=t.data.source&&null!=t.data.target?"edges":"nodes"),"nodes"===i||"edges"===i){this.length=1,this[0]=this;var H=this._private={cy:e,single:!0,data:t.data||{},position:t.position||{x:0,y:0},autoWidth:void 0,autoHeight:void 0,autoPadding:void 0,compoundBoundsClean:!1,listeners:[],group:i,style:{},rstyle:{},styleCxts:[],styleKeys:{},removed:!0,selected:!!t.selected,selectable:void 0===t.selectable||!!t.selectable,locked:!!t.locked,grabbed:!1,grabbable:void 0===t.grabbable||!!t.grabbable,pannable:void 0===t.pannable?"edges"===i:!!t.pannable,active:!1,classes:new rC,animation:{current:[],queue:[]},rscratch:{},scratch:t.scratch||{},edges:[],children:[],parent:null,traversalCache:{},backgrounding:!1,bbCache:null,bbCacheShift:{x:0,y:0},bodyBounds:null,overlayBounds:null,labelBounds:{all:null,source:null,target:null,main:null},arrowBounds:{source:null,target:null,"mid-source":null,"mid-target":null}};if(null==H.position.x&&(H.position.x=0),null==H.position.y&&(H.position.y=0),t.renderedPosition){var n=t.renderedPosition,V=e.pan(),r=e.zoom();H.position={x:(n.x-V.x)/r,y:(n.y-V.y)/r}}var L=[];Ct(t.classes)?L=t.classes:et(t.classes)&&(L=t.classes.split(/\s+/));for(var o=0,a=L.length;o0;){var p=c.pop(),g=u(p),v=p.id();if(M[v]=g,g!==1/0)for(var y=p.neighborhood().intersect(l),Z=0;Z0)for(C.unshift(t);a[H];){var n=a[H];C.unshift(n.edge),C.unshift(n.node),H=(i=n.node).id()}return V.spawn(C)}}}},lC={kruskal:function(e){e=e||function(e){return 1};for(var t=this.byGroup(),C=t.nodes,i=t.edges,H=C.length,n=new Array(H),V=C,r=function(e){for(var t=0;t0;){if(L=u.pop(),o=L.id(),A.delete(o),p++,o===M){for(var g=[],v=H,y=M,Z=h[y];g.unshift(v),null!=Z&&g.unshift(Z),null!=(v=c[y]);)Z=h[y=v.id()];return{found:!0,distance:s[o],path:this.spawn(g),steps:p}}d[o]=!0;for(var S=L._private.edges,b=0;bS&&(l[Z]=S,c[Z]=y,h[Z]=f),!H){var b=y*o+v;!H&&l[b]>S&&(l[b]=S,c[b]=v,h[b]=f)}}}for(var w=0;w1&&void 0!==arguments[1]?arguments[1]:n,i=c(e),H=[],V=i;;){if(null==V)return t.spawn();var L=A(V),o=L.edge,a=L.pred;if(H.unshift(V[0]),V.same(C)&&H.length>0)break;null!=o&&H.unshift(o),V=a}return r.spawn(H)},hasNegativeWeightCycle:d,negativeWeightCycles:[]}}},fC=Math.sqrt(2),pC=function(e,t,C){0===C.length&&Ut("Karger-Stein must be run on a connected (sub)graph");for(var i=C[e],H=i[1],n=i[2],V=t[H],r=t[n],L=C,o=L.length-1;o>=0;o--){var a=L[o],M=a[1],s=a[2];(t[M]===V&&t[s]===r||t[M]===r&&t[s]===V)&&L.splice(o,1)}for(var l=0;li;){var H=Math.floor(Math.random()*t.length);t=pC(H,e,t),C--}return t},vC={kargerStein:function(){var e=this,t=this.byGroup(),C=t.nodes,i=t.edges;i.unmergeBy((function(e){return e.isLoop()}));var H=C.length,n=i.length,V=Math.ceil(Math.pow(Math.log(H)/Math.LN2,2)),r=Math.floor(H/fC);if(!(H<2)){for(var L=[],o=0;o0?1:e<0?-1:0},OC=function(e,t){return Math.sqrt(kC(e,t))},kC=function(e,t){var C=t.x-e.x,i=t.y-e.y;return C*C+i*i},EC=function(e){for(var t=e.length,C=0,i=0;i=e.x1&&e.y2>=e.y1)return{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,w:e.x2-e.x1,h:e.y2-e.y1};if(null!=e.w&&null!=e.h&&e.w>=0&&e.h>=0)return{x1:e.x1,y1:e.y1,x2:e.x1+e.w,y2:e.y1+e.h,w:e.w,h:e.h}}},DC=function(e,t,C){e.x1=Math.min(e.x1,t),e.x2=Math.max(e.x2,t),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,C),e.y2=Math.max(e.y2,C),e.h=e.y2-e.y1},NC=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e.x1-=t,e.x2+=t,e.y1-=t,e.y2+=t,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},RC=function(e){var t,C,i,H,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0];if(1===n.length)t=C=i=H=n[0];else if(2===n.length)t=i=n[0],H=C=n[1];else if(4===n.length){var V=$e(n,4);t=V[0],C=V[1],i=V[2],H=V[3]}return e.x1-=H,e.x2+=C,e.y1-=t,e.y2+=i,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},FC=function(e,t){e.x1=t.x1,e.y1=t.y1,e.x2=t.x2,e.y2=t.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1},IC=function(e,t){return!(e.x1>t.x2)&&(!(t.x1>e.x2)&&(!(e.x2t.y2)&&!(t.y1>e.y2)))))))},zC=function(e,t,C){return e.x1<=t&&t<=e.x2&&e.y1<=C&&C<=e.y2},jC=function(e,t){return zC(e,t.x1,t.y1)&&zC(e,t.x2,t.y2)},GC=function(e,t,C,i,H,n,V){var r,L=Li(H,n),o=H/2,a=n/2,M=i-a-V;if((r=Ci(e,t,C,i,C-o+L-V,M,C+o-L+V,M,!1)).length>0)return r;var s=C+o+V;if((r=Ci(e,t,C,i,s,i-a+L-V,s,i+a-L+V,!1)).length>0)return r;var l=i+a+V;if((r=Ci(e,t,C,i,C-o+L-V,l,C+o-L+V,l,!1)).length>0)return r;var d,u=C-o-V;if((r=Ci(e,t,C,i,u,i-a+L-V,u,i+a-L+V,!1)).length>0)return r;var A=C-o+L,c=i-a+L;if((d=ei(e,t,C,i,A,c,L+V)).length>0&&d[0]<=A&&d[1]<=c)return[d[0],d[1]];var h=C+o-L,m=i-a+L;if((d=ei(e,t,C,i,h,m,L+V)).length>0&&d[0]>=h&&d[1]<=m)return[d[0],d[1]];var f=C+o-L,p=i+a-L;if((d=ei(e,t,C,i,f,p,L+V)).length>0&&d[0]>=f&&d[1]>=p)return[d[0],d[1]];var g=C-o+L,v=i+a-L;return(d=ei(e,t,C,i,g,v,L+V)).length>0&&d[0]<=g&&d[1]>=v?[d[0],d[1]]:[]},WC=function(e,t,C,i,H,n,V){var r=V,L=Math.min(C,H),o=Math.max(C,H),a=Math.min(i,n),M=Math.max(i,n);return L-r<=e&&e<=o+r&&a-r<=t&&t<=M+r},$C=function(e,t,C,i,H,n,V,r,L){var o=Math.min(C,V,H)-L,a=Math.max(C,V,H)+L,M=Math.min(i,r,n)-L,s=Math.max(i,r,n)+L;return!(ea||ts)},UC=function(e,t,C,i,H,n,V,r){var L=[];!function(e,t,C,i,H){var n,V,r,L,o,a,M,s;0===e&&(e=1e-5),r=-27*(i/=e)+(t/=e)*(9*(C/=e)-t*t*2),n=(V=(3*C-t*t)/9)*V*V+(r/=54)*r,H[1]=0,M=t/3,n>0?(o=(o=r+Math.sqrt(n))<0?-Math.pow(-o,1/3):Math.pow(o,1/3),a=(a=r-Math.sqrt(n))<0?-Math.pow(-a,1/3):Math.pow(a,1/3),H[0]=-M+o+a,M+=(o+a)/2,H[4]=H[2]=-M,M=Math.sqrt(3)*(-a+o)/2,H[3]=M,H[5]=-M):(H[5]=H[3]=0,0===n?(s=r<0?-Math.pow(-r,1/3):Math.pow(r,1/3),H[0]=2*s-M,H[4]=H[2]=-(s+M)):(L=(V=-V)*V*V,L=Math.acos(r/Math.sqrt(L)),s=2*Math.sqrt(V),H[0]=-M+s*Math.cos(L/3),H[2]=-M+s*Math.cos((L+2*Math.PI)/3),H[4]=-M+s*Math.cos((L+4*Math.PI)/3)))}(1*C*C-4*C*H+2*C*V+4*H*H-4*H*V+V*V+i*i-4*i*n+2*i*r+4*n*n-4*n*r+r*r,9*C*H-3*C*C-3*C*V-6*H*H+3*H*V+9*i*n-3*i*i-3*i*r-6*n*n+3*n*r,3*C*C-6*C*H+C*V-C*e+2*H*H+2*H*e-V*e+3*i*i-6*i*n+i*r-i*t+2*n*n+2*n*t-r*t,1*C*H-C*C+C*e-H*e+i*n-i*i+i*t-n*t,L);for(var o=[],a=0;a<6;a+=2)Math.abs(L[a+1])<1e-7&&L[a]>=0&&L[a]<=1&&o.push(L[a]);o.push(1),o.push(0);for(var M,s,l,d=-1,u=0;u=0?lL?(e-H)*(e-H)+(t-n)*(t-n):o-M},XC=function(e,t,C){for(var i,H,n,V,r=0,L=0;L=e&&e>=n||i<=e&&e<=n))continue;(e-i)/(n-i)*(V-H)+H>t&&r++}return r%2!=0},qC=function(e,t,C,i,H,n,V,r,L){var o,a=new Array(C.length);null!=r[0]?(o=Math.atan(r[1]/r[0]),r[0]<0?o+=Math.PI/2:o=-o-Math.PI/2):o=r;for(var M,s=Math.cos(-o),l=Math.sin(-o),d=0;d0){var u=KC(a,-L);M=QC(u)}else M=a;return XC(e,t,M)},QC=function(e){for(var t,C,i,H,n,V,r,L,o=new Array(e.length/2),a=0;a=0&&d<=1&&A.push(d),u>=0&&u<=1&&A.push(u),0===A.length)return[];var c=A[0]*r[0]+e,h=A[0]*r[1]+t;return A.length>1?A[0]==A[1]?[c,h]:[c,h,A[1]*r[0]+e,A[1]*r[1]+t]:[c,h]},ti=function(e,t,C){return t<=e&&e<=C||C<=e&&e<=t?e:e<=t&&t<=C||C<=t&&t<=e?t:C},Ci=function(e,t,C,i,H,n,V,r,L){var o=e-H,a=C-e,M=V-H,s=t-n,l=i-t,d=r-n,u=M*s-d*o,A=a*s-l*o,c=d*a-M*l;if(0!==c){var h=u/c,m=A/c,f=-.001;return f<=h&&h<=1.001&&f<=m&&m<=1.001||L?[e+h*a,t+h*l]:[]}return 0===u||0===A?ti(e,C,V)===V?[V,r]:ti(e,C,H)===H?[H,n]:ti(H,V,C)===C?[C,i]:[]:[]},ii=function(e,t,C,i,H,n,V,r){var L,o,a,M,s,l,d=[],u=new Array(C.length),A=!0;if(null==n&&(A=!1),A){for(var c=0;c0){var h=KC(u,-r);o=QC(h)}else o=u}else o=C;for(var m=0;mo&&(o=t)},M=function(e){return L[e]},s=0;s0?m.edgesTo(h)[0]:h.edgesTo(m)[0];var p=i(f);h=h.id(),s[h]>s[A]+p&&(s[h]=s[A]+p,l.nodes.indexOf(h)<0?l.push(h):l.updateItem(h),o[h]=0,L[h]=[]),s[h]==s[A]+p&&(o[h]=o[h]+o[A],L[h].push(A))}else for(var g=0;g0;){for(var S=C.pop(),b=0;b0&&V.push(C[r]);0!==V.length&&H.push(i.collection(V))}return H}(a,L,t,i);return m=function(e){for(var t=0;t5&&void 0!==arguments[5]?arguments[5]:xi,V=i,r=0;r=2?_i(e,t,C,0,Ei,Pi):_i(e,t,C,0,ki)},squaredEuclidean:function(e,t,C){return _i(e,t,C,0,Ei)},manhattan:function(e,t,C){return _i(e,t,C,0,ki)},max:function(e,t,C){return _i(e,t,C,-1/0,Ti)}};function Di(e,t,C,i,H,n){var V;return V=tt(e)?e:Bi[e]||Bi.euclidean,0===t&&tt(e)?V(H,n):V(t,C,i,H,n)}Bi["squared-euclidean"]=Bi.squaredEuclidean,Bi.squaredeuclidean=Bi.squaredEuclidean;var Ni=eC({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),Ri=function(e){return Ni(e)},Fi=function(e,t,C,i,H){var n="kMedoids"!==H?function(e){return C[e]}:function(e){return i[e](C)},V=C,r=t;return Di(e,i.length,n,(function(e){return i[e](t)}),V,r)},Ii=function(e,t,C){for(var i=C.length,H=new Array(i),n=new Array(i),V=new Array(t),r=null,L=0;LC)return!1}return!0},Wi=function(e,t,C){for(var i=0;iH&&(H=t[L][o],n=o);V[n].push(e[L])}for(var a=0;a=H.threshold||"dendrogram"===H.mode&&1===e.length)return!1;var l,d=t[V],u=t[i[V]];l="dendrogram"===H.mode?{left:d,right:u,key:d.key}:{value:d.value.concat(u.value),key:d.key},e[d.index]=l,e.splice(u.index,1),t[d.key]=l;for(var A=0;AC[u.key][c.key]&&(n=C[u.key][c.key])):"max"===H.linkage?(n=C[d.key][c.key],C[d.key][c.key]1&&void 0!==arguments[1]?arguments[1]:0,C=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],H=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];arguments.length>3&&void 0!==arguments[3]&&!arguments[3]?(C0&&e.splice(0,t)):e=e.slice(t,C);for(var n=0,V=e.length-1;V>=0;V--){var r=e[V];H?isFinite(r)||(e[V]=-1/0,n++):e.splice(V,1)}i&&e.sort((function(e,t){return e-t}));var L=e.length,o=Math.floor(L/2);return L%2!=0?e[o+1+n]:(e[o-1+n]+e[o+n])/2}(e):"mean"===t?function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,C=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,i=0,H=0,n=t;n1&&void 0!==arguments[1]?arguments[1]:0,C=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,i=1/0,H=t;H1&&void 0!==arguments[1]?arguments[1]:0,C=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,i=-1/0,H=t;HV&&(n=L,V=t[H*e+L])}n>0&&i.push(n)}for(var o=0;o=S?(b=S,S=x,w=O):x>b&&(b=x);for(var k=0;k0?1:0;v[g%o.minIterations*t+D]=N,B+=N}if(B>0&&(g>=o.minIterations-1||g==o.maxIterations-1)){for(var R=0,F=0;F0&&i.push(H);return i}(t,n,V),j=function(e,t,C){for(var i=oH(e,t,C),H=0;HL&&(r=o,L=a)}C[H]=n[r]}return oH(e,t,C)}(t,i,z),G={},W=0;W1||V>1)&&(o=!0),a[t]=[],e.outgoers().forEach((function(e){e.isEdge()&&a[t].push(e.id())}))}else M[t]=[void 0,e.target().id()]})):L.forEach((function(e){var t=e.id();e.isNode()?(e.degree(!0)%2&&(C?i?o=!0:i=t:C=t),a[t]=[],e.connectedEdges().forEach((function(e){return a[t].push(e.id())}))):M[t]=[e.source().id(),e.target().id()]}));var s={found:!1,trail:void 0};if(o)return s;if(i&&C)if(r){if(H&&i!=H)return s;H=i}else{if(H&&i!=H&&C!=H)return s;H||(H=i)}else H||(H=L[0].id());var l=function(e){for(var t,C,i,H=e,n=[e];a[H].length;)t=a[H].shift(),C=M[t][0],H!=(i=M[t][1])?(a[i]=a[i].filter((function(e){return e!=t})),H=i):r||H==C||(a[C]=a[C].filter((function(e){return e!=t})),H=C),n.unshift(t),n.unshift(H);return n},d=[],u=[];for(u=l(H);1!=u.length;)0==a[u[0]].length?(d.unshift(L.getElementById(u.shift())),d.unshift(L.getElementById(u.shift()))):u=l(u.shift()).concat(u);for(var A in d.unshift(L.getElementById(u.shift())),a)if(a[A].length)return s;return s.found=!0,s.trail=this.spawn(d,!0),s}},dH=function(){var e=this,t={},C=0,i=0,H=[],n=[],V={},r=function r(L,o,a){L===a&&(i+=1),t[o]={id:C,low:C++,cutVertex:!1};var M,s,l,d,u=e.getElementById(o).connectedEdges().intersection(e);0===u.size()?H.push(e.spawn(e.getElementById(o))):u.forEach((function(C){M=C.source().id(),s=C.target().id(),(l=M===o?s:M)!==a&&(d=C.id(),V[d]||(V[d]=!0,n.push({x:o,y:l,edge:C})),l in t?t[o].low=Math.min(t[o].low,t[l].id):(r(L,l,o),t[o].low=Math.min(t[o].low,t[l].low),t[o].id<=t[l].low&&(t[o].cutVertex=!0,function(C,i){for(var V=n.length-1,r=[],L=e.spawn();n[V].x!=C||n[V].y!=i;)r.push(n.pop().edge),V--;r.push(n.pop().edge),r.forEach((function(C){var i=C.connectedNodes().intersection(e);L.merge(C),i.forEach((function(C){var i=C.id(),H=C.connectedEdges().intersection(e);L.merge(C),t[i].cutVertex?L.merge(H.filter((function(e){return e.isLoop()}))):L.merge(H)}))})),H.push(L)}(o,l))))}))};e.forEach((function(e){if(e.isNode()){var C=e.id();C in t||(i=0,r(C,C),t[C].cutVertex=i>1)}}));var L=Object.keys(t).filter((function(e){return t[e].cutVertex})).map((function(t){return e.getElementById(t)}));return{cut:e.spawn(L),components:H}},uH=function(){var e=this,t={},C=0,i=[],H=[],n=e.spawn(e),V=function V(r){if(H.push(r),t[r]={index:C,low:C++,explored:!1},e.getElementById(r).connectedEdges().intersection(e).forEach((function(e){var C=e.target().id();C!==r&&(C in t||V(C),t[C].explored||(t[r].low=Math.min(t[r].low,t[C].low)))})),t[r].index===t[r].low){for(var L=e.spawn();;){var o=H.pop();if(L.merge(e.getElementById(o)),t[o].low=t[r].index,t[o].explored=!0,o===r)break}var a=L.edgesWith(L),M=L.merge(a);i.push(M),n=n.difference(M)}};return e.forEach((function(e){if(e.isNode()){var C=e.id();C in t||V(C)}})),{cut:n,components:i}},AH={};[aC,sC,lC,uC,cC,mC,vC,si,di,Ai,hi,wi,Qi,nH,MH,lH,{hopcroftTarjanBiconnected:dH,htbc:dH,htb:dH,hopcroftTarjanBiconnectedComponents:dH},{tarjanStronglyConnected:uH,tsc:uH,tscc:uH,tarjanStronglyConnectedComponents:uH}].forEach((function(e){ft(AH,e)})); /*! Embeddable Minimum Strictly-Compliant Promises/A+ 1.1.1 Thenable Copyright (c) 2013-2014 Ralf S. Engelschall (http://engelschall.com) Licensed under The MIT License (http://opensource.org/licenses/MIT) */ var cH=function e(t){if(!(this instanceof e))return new e(t);this.id="Thenable/1.0.7",this.state=0,this.fulfillValue=void 0,this.rejectReason=void 0,this.onFulfilled=[],this.onRejected=[],this.proxy={then:this.then.bind(this)},"function"==typeof t&&t.call(this,this.fulfill.bind(this),this.reject.bind(this))};cH.prototype={fulfill:function(e){return hH(this,1,"fulfillValue",e)},reject:function(e){return hH(this,2,"rejectReason",e)},then:function(e,t){var C=this,i=new cH;return C.onFulfilled.push(pH(e,i,"fulfill")),C.onRejected.push(pH(t,i,"reject")),mH(C),i.proxy}};var hH=function(e,t,C,i){return 0===e.state&&(e.state=t,e[C]=i,mH(e)),e},mH=function(e){1===e.state?fH(e,"onFulfilled",e.fulfillValue):2===e.state&&fH(e,"onRejected",e.rejectReason)},fH=function(e,t,C){if(0!==e[t].length){var i=e[t];e[t]=[];var H=function(){for(var e=0;e0:void 0}},clearQueue:function(){return function(){var e=this,t=void 0!==e.length?e:[e];if(!(this._private.cy||this).styleEnabled())return this;for(var C=0;C0&&this.spawn(i).updateStyle().emit("class"),t},addClass:function(e){return this.toggleClass(e,!0)},hasClass:function(e){var t=this[0];return null!=t&&t._private.classes.has(e)},toggleClass:function(e,t){Ct(e)||(e=e.match(/\S+/g)||[]);for(var C=this,i=void 0===t,H=[],n=0,V=C.length;n0&&this.spawn(H).updateStyle().emit("class"),C},removeClass:function(e){return this.toggleClass(e,!1)},flashClass:function(e,t){var C=this;if(null==t)t=250;else if(0===t)return C;return C.addClass(e),setTimeout((function(){C.removeClass(e)}),t),C}};kH.className=kH.classNames=kH.classes;var EH={metaChar:"[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",boolOp:"\\?|\\!|\\^",string:"\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'",number:ht,meta:"degree|indegree|outdegree",separator:"\\s*,\\s*",descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$",group:"node|edge|\\*",directedEdge:"\\s+->\\s+",undirectedEdge:"\\s+<->\\s+"};EH.variable="(?:[\\w-]|(?:\\\\"+EH.metaChar+"))+",EH.value=EH.string+"|"+EH.number,EH.className=EH.variable,EH.id=EH.variable,function(){var e,t,C;for(e=EH.comparatorOp.split("|"),C=0;C=0||"="!==t&&(EH.comparatorOp+="|\\!"+t)}();var PH=0,TH=1,_H=2,BH=3,DH=4,NH=5,RH=6,FH=7,IH=8,zH=9,jH=10,GH=11,WH=12,$H=13,UH=14,YH=15,XH=16,qH=17,QH=18,KH=19,JH=20,en=[{selector:":selected",matches:function(e){return e.selected()}},{selector:":unselected",matches:function(e){return!e.selected()}},{selector:":selectable",matches:function(e){return e.selectable()}},{selector:":unselectable",matches:function(e){return!e.selectable()}},{selector:":locked",matches:function(e){return e.locked()}},{selector:":unlocked",matches:function(e){return!e.locked()}},{selector:":visible",matches:function(e){return e.visible()}},{selector:":hidden",matches:function(e){return!e.visible()}},{selector:":transparent",matches:function(e){return e.transparent()}},{selector:":grabbed",matches:function(e){return e.grabbed()}},{selector:":free",matches:function(e){return!e.grabbed()}},{selector:":removed",matches:function(e){return e.removed()}},{selector:":inside",matches:function(e){return!e.removed()}},{selector:":grabbable",matches:function(e){return e.grabbable()}},{selector:":ungrabbable",matches:function(e){return!e.grabbable()}},{selector:":animated",matches:function(e){return e.animated()}},{selector:":unanimated",matches:function(e){return!e.animated()}},{selector:":parent",matches:function(e){return e.isParent()}},{selector:":childless",matches:function(e){return e.isChildless()}},{selector:":child",matches:function(e){return e.isChild()}},{selector:":orphan",matches:function(e){return e.isOrphan()}},{selector:":nonorphan",matches:function(e){return e.isChild()}},{selector:":compound",matches:function(e){return e.isNode()?e.isParent():e.source().isParent()||e.target().isParent()}},{selector:":loop",matches:function(e){return e.isLoop()}},{selector:":simple",matches:function(e){return e.isSimple()}},{selector:":active",matches:function(e){return e.active()}},{selector:":inactive",matches:function(e){return!e.active()}},{selector:":backgrounding",matches:function(e){return e.backgrounding()}},{selector:":nonbackgrounding",matches:function(e){return!e.backgrounding()}}].sort((function(e,t){return function(e,t){return-1*mt(e,t)}(e.selector,t.selector)})),tn=function(){for(var e,t={},C=0;C0&&o.edgeCount>0)return Xt("The selector `"+e+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(o.edgeCount>1)return Xt("The selector `"+e+"` is invalid because it uses multiple edge selectors"),!1;1===o.edgeCount&&Xt("The selector `"+e+"` is deprecated. Edge selectors do not take effect on changes to source and target nodes after an edge is added, for performance reasons. Use a class or data selector on edges instead, updating the class or data of an edge when your app detects a change in source or target nodes.")}return!0},toString:function(){if(null!=this.toStringCache)return this.toStringCache;for(var e=function(e){return null==e?"":e},t=function(t){return et(t)?'"'+t+'"':e(t)},C=function(e){return" "+e+" "},i=function(i,n){var V=i.type,r=i.value;switch(V){case PH:var L=e(r);return L.substring(0,L.length-1);case BH:var o=i.field,a=i.operator;return"["+o+C(e(a))+t(r)+"]";case NH:var M=i.operator,s=i.field;return"["+e(M)+s+"]";case DH:return"["+i.field+"]";case RH:var l=i.operator;return"[["+i.field+C(e(l))+t(r)+"]]";case FH:return r;case IH:return"#"+r;case zH:return"."+r;case qH:case YH:return H(i.parent,n)+C(">")+H(i.child,n);case QH:case XH:return H(i.ancestor,n)+" "+H(i.descendant,n);case KH:var d=H(i.left,n),u=H(i.subject,n),A=H(i.right,n);return d+(d.length>0?" ":"")+u+A;case JH:return""}},H=function(e,t){return e.checks.reduce((function(C,H,n){return C+(t===e&&0===n?"$":"")+i(H,t)}),"")},n="",V=0;V1&&V=0&&(t=t.replace("!",""),a=!0),t.indexOf("@")>=0&&(t=t.replace("@",""),o=!0),(V||L||o)&&(H=V||r?""+e:"",n=""+C),o&&(e=H=H.toLowerCase(),C=n=n.toLowerCase()),t){case"*=":i=H.indexOf(n)>=0;break;case"$=":i=H.indexOf(n,H.length-n.length)>=0;break;case"^=":i=0===H.indexOf(n);break;case"=":i=e===C;break;case">":M=!0,i=e>C;break;case">=":M=!0,i=e>=C;break;case"<":M=!0,i=e0;){var o=H.shift();t(o),n.add(o.id()),V&&i(H,n,o)}return e}function gn(e,t,C){if(C.isParent())for(var i=C._private.children,H=0;H1&&void 0!==arguments[1])||arguments[1];return pn(this,e,t,gn)},fn.forEachUp=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return pn(this,e,t,vn)},fn.forEachUpAndDown=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return pn(this,e,t,yn)},fn.ancestors=fn.parents,(cn=hn={data:xH.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),removeData:xH.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:xH.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:xH.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),rscratch:xH.data({field:"rscratch",allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:xH.removeData({field:"rscratch",triggerEvent:!1}),id:function(){var e=this[0];if(e)return e._private.data.id}}).attr=cn.data,cn.removeAttr=cn.removeData;var Zn,Sn,bn=hn,wn={};function xn(e){return function(t){var C=this;if(void 0===t&&(t=!0),0!==C.length&&C.isNode()&&!C.removed()){for(var i=0,H=C[0],n=H._private.edges,V=0;Vt})),minIndegree:On("indegree",(function(e,t){return et})),minOutdegree:On("outdegree",(function(e,t){return et}))}),ft(wn,{totalDegree:function(e){for(var t=0,C=this.nodes(),i=0;i0,a=o;o&&(L=L[0]);var M=a?L.position():{x:0,y:0};return H={x:r.x-M.x,y:r.y-M.y},void 0===e?H:H[e]}for(var s=0;s0,A=u;u&&(d=d[0]);var c=A?d.position():{x:0,y:0};void 0!==t?l.position(e,t+c[e]):void 0!==H&&l.position({x:H.x+c.x,y:H.y+c.y})}}else if(!n)return;return this}},Zn.modelPosition=Zn.point=Zn.position,Zn.modelPositions=Zn.points=Zn.positions,Zn.renderedPoint=Zn.renderedPosition,Zn.relativePoint=Zn.relativePosition;var Pn,Tn,_n=Sn;Pn=Tn={},Tn.renderedBoundingBox=function(e){var t=this.boundingBox(e),C=this.cy(),i=C.zoom(),H=C.pan(),n=t.x1*i+H.x,V=t.x2*i+H.x,r=t.y1*i+H.y,L=t.y2*i+H.y;return{x1:n,x2:V,y1:r,y2:L,w:V-n,h:L-r}},Tn.dirtyCompoundBoundsCache=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.cy();return t.styleEnabled()&&t.hasCompoundNodes()?(this.forEachUp((function(t){if(t.isParent()){var C=t._private;C.compoundBoundsClean=!1,C.bbCache=null,e||t.emitAndNotify("bounds")}})),this):this},Tn.updateCompoundBounds=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.cy();if(!t.styleEnabled()||!t.hasCompoundNodes())return this;if(!e&&t.batching())return this;function C(e){if(e.isParent()){var t=e._private,C=e.children(),i="include"===e.pstyle("compound-sizing-wrt-labels").value,H={width:{val:e.pstyle("min-width").pfValue,left:e.pstyle("min-width-bias-left"),right:e.pstyle("min-width-bias-right")},height:{val:e.pstyle("min-height").pfValue,top:e.pstyle("min-height-bias-top"),bottom:e.pstyle("min-height-bias-bottom")}},n=C.boundingBox({includeLabels:i,includeOverlays:!1,useCache:!1}),V=t.position;0!==n.w&&0!==n.h||((n={w:e.pstyle("width").pfValue,h:e.pstyle("height").pfValue}).x1=V.x-n.w/2,n.x2=V.x+n.w/2,n.y1=V.y-n.h/2,n.y2=V.y+n.h/2);var r=H.width.left.value;"px"===H.width.left.units&&H.width.val>0&&(r=100*r/H.width.val);var L=H.width.right.value;"px"===H.width.right.units&&H.width.val>0&&(L=100*L/H.width.val);var o=H.height.top.value;"px"===H.height.top.units&&H.height.val>0&&(o=100*o/H.height.val);var a=H.height.bottom.value;"px"===H.height.bottom.units&&H.height.val>0&&(a=100*a/H.height.val);var M=c(H.width.val-n.w,r,L),s=M.biasDiff,l=M.biasComplementDiff,d=c(H.height.val-n.h,o,a),u=d.biasDiff,A=d.biasComplementDiff;t.autoPadding=function(e,t,C,i){if("%"!==C.units)return"px"===C.units?C.pfValue:0;switch(i){case"width":return e>0?C.pfValue*e:0;case"height":return t>0?C.pfValue*t:0;case"average":return e>0&&t>0?C.pfValue*(e+t)/2:0;case"min":return e>0&&t>0?e>t?C.pfValue*t:C.pfValue*e:0;case"max":return e>0&&t>0?e>t?C.pfValue*e:C.pfValue*t:0;default:return 0}}(n.w,n.h,e.pstyle("padding"),e.pstyle("padding-relative-to").value),t.autoWidth=Math.max(n.w,H.width.val),V.x=(-s+n.x1+n.x2+l)/2,t.autoHeight=Math.max(n.h,H.height.val),V.y=(-u+n.y1+n.y2+A)/2}function c(e,t,C){var i=0,H=0,n=t+C;return e>0&&n>0&&(i=t/n*e,H=C/n*e),{biasDiff:i,biasComplementDiff:H}}}for(var i=0;ie.x2?i:e.x2,e.y1=Ce.y2?H:e.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1)},Nn=function(e,t){return null==t?e:Dn(e,t.x1,t.y1,t.x2,t.y2)},Rn=function(e,t,C){return iC(e,t,C)},Fn=function(e,t,C){if(!t.cy().headless()){var i,H,n=t._private,V=n.rstyle,r=V.arrowWidth/2;if("none"!==t.pstyle(C+"-arrow-shape").value){"source"===C?(i=V.srcX,H=V.srcY):"target"===C?(i=V.tgtX,H=V.tgtY):(i=V.midX,H=V.midY);var L=n.arrowBounds=n.arrowBounds||{},o=L[C]=L[C]||{};o.x1=i-r,o.y1=H-r,o.x2=i+r,o.y2=H+r,o.w=o.x2-o.x1,o.h=o.y2-o.y1,NC(o,1),Dn(e,o.x1,o.y1,o.x2,o.y2)}}},In=function(e,t,C){if(!t.cy().headless()){var i;i=C?C+"-":"";var H=t._private,n=H.rstyle;if(t.pstyle(i+"label").strValue){var V,r,L,o,a=t.pstyle("text-halign"),M=t.pstyle("text-valign"),s=Rn(n,"labelWidth",C),l=Rn(n,"labelHeight",C),d=Rn(n,"labelX",C),u=Rn(n,"labelY",C),A=t.pstyle(i+"text-margin-x").pfValue,c=t.pstyle(i+"text-margin-y").pfValue,h=t.isEdge(),m=t.pstyle(i+"text-rotation"),f=t.pstyle("text-outline-width").pfValue,p=t.pstyle("text-border-width").pfValue/2,g=t.pstyle("text-background-padding").pfValue,v=l,y=s,Z=y/2,S=v/2;if(h)V=d-Z,r=d+Z,L=u-S,o=u+S;else{switch(a.value){case"left":V=d-y,r=d;break;case"center":V=d-Z,r=d+Z;break;case"right":V=d,r=d+y}switch(M.value){case"top":L=u-v,o=u;break;case"center":L=u-S,o=u+S;break;case"bottom":L=u,o=u+v}}V+=A-Math.max(f,p)-g-2,r+=A+Math.max(f,p)+g+2,L+=c-Math.max(f,p)-g-2,o+=c+Math.max(f,p)+g+2;var b=C||"main",w=H.labelBounds,x=w[b]=w[b]||{};x.x1=V,x.y1=L,x.x2=r,x.y2=o,x.w=r-V,x.h=o-L;var O=h&&"autorotate"===m.strValue,k=null!=m.pfValue&&0!==m.pfValue;if(O||k){var E=O?Rn(H.rstyle,"labelAngle",C):m.pfValue,P=Math.cos(E),T=Math.sin(E),_=(V+r)/2,B=(L+o)/2;if(!h){switch(a.value){case"left":_=r;break;case"right":_=V}switch(M.value){case"top":B=o;break;case"bottom":B=L}}var D=function(e,t){return{x:(e-=_)*P-(t-=B)*T+_,y:e*T+t*P+B}},N=D(V,L),R=D(V,o),F=D(r,L),I=D(r,o);V=Math.min(N.x,R.x,F.x,I.x),r=Math.max(N.x,R.x,F.x,I.x),L=Math.min(N.y,R.y,F.y,I.y),o=Math.max(N.y,R.y,F.y,I.y)}var z=b+"Rot",j=w[z]=w[z]||{};j.x1=V,j.y1=L,j.x2=r,j.y2=o,j.w=r-V,j.h=o-L,Dn(e,V,L,r,o),Dn(H.labelBounds.all,V,L,r,o)}return e}},zn=function(e){var t=0,C=function(e){return(e?1:0)<(i=S[1].x)){var b=C;C=i,i=b}if(H>(n=S[1].y)){var w=H;H=n,n=w}Dn(s,C-p,H-p,i+p,n+p)}}else if("bezier"===Z||"unbundled-bezier"===Z||"segments"===Z||"taxi"===Z){var x;switch(Z){case"bezier":case"unbundled-bezier":x=A.bezierPts;break;case"segments":case"taxi":x=A.linePts}if(null!=x)for(var O=0;O(i=P.x)){var T=C;C=i,i=T}if((H=E.y)>(n=P.y)){var _=H;H=n,n=_}Dn(s,C-=p,H-=p,i+=p,n+=p)}if(a&&t.includeEdges&&u&&(Fn(s,e,"mid-source"),Fn(s,e,"mid-target"),Fn(s,e,"source"),Fn(s,e,"target")),a&&"yes"===e.pstyle("ghost").value){var B=e.pstyle("ghost-offset-x").pfValue,D=e.pstyle("ghost-offset-y").pfValue;Dn(s,s.x1+B,s.y1+D,s.x2+B,s.y2+D)}var N=l.bodyBounds=l.bodyBounds||{};FC(N,s),RC(N,c),NC(N,1),a&&(C=s.x1,i=s.x2,H=s.y1,n=s.y2,Dn(s,C-f,H-f,i+f,n+f));var R=l.overlayBounds=l.overlayBounds||{};FC(R,s),RC(R,c),NC(R,1);var F=l.labelBounds=l.labelBounds||{};null!=F.all?((L=F.all).x1=1/0,L.y1=1/0,L.x2=-1/0,L.y2=-1/0,L.w=0,L.h=0):F.all=BC(),a&&t.includeLabels&&(t.includeMainLabels&&In(s,e,null),u&&(t.includeSourceLabels&&In(s,e,"source"),t.includeTargetLabels&&In(s,e,"target")))}return s.x1=Bn(s.x1),s.y1=Bn(s.y1),s.x2=Bn(s.x2),s.y2=Bn(s.y2),s.w=Bn(s.x2-s.x1),s.h=Bn(s.y2-s.y1),s.w>0&&s.h>0&&m&&(RC(s,c),NC(s,1)),s}(e,Wn),i.bbCache=C,i.bbCachePosKey=V):C=i.bbCache,!n){var a=e.isNode();C=BC(),(t.includeNodes&&a||t.includeEdges&&!a)&&(t.includeOverlays?Nn(C,i.overlayBounds):Nn(C,i.bodyBounds)),t.includeLabels&&(t.includeMainLabels&&(!H||t.includeSourceLabels&&t.includeTargetLabels)?Nn(C,i.labelBounds.all):(t.includeMainLabels&&Nn(C,i.labelBounds.mainRot),t.includeSourceLabels&&Nn(C,i.labelBounds.sourceRot),t.includeTargetLabels&&Nn(C,i.labelBounds.targetRot))),C.w=C.x2-C.x1,C.h=C.y2-C.y1}return C},Wn={includeNodes:!0,includeEdges:!0,includeLabels:!0,includeMainLabels:!0,includeSourceLabels:!0,includeTargetLabels:!0,includeOverlays:!0,useCache:!0},$n=zn(Wn),Un=eC(Wn);Tn.boundingBox=function(e){var t;if(1!==this.length||null==this[0]._private.bbCache||this[0]._private.styleDirty||void 0!==e&&void 0!==e.useCache&&!0!==e.useCache){t=BC();var C=Un(e=e||Wn),i=this;if(i.cy().styleEnabled())for(var H=0;H0&&void 0!==arguments[0]?arguments[0]:LV,t=arguments.length>1?arguments[1]:void 0,C=0;C=0;r--)V(r);return this},aV.removeAllListeners=function(){return this.removeListener("*")},aV.emit=aV.trigger=function(e,t,C){var i=this.listeners,H=i.length;return this.emitting++,Ct(t)||(t=[t]),lV(this,(function(e,n){null!=C&&(i=[{event:n.event,type:n.type,namespace:n.namespace,callback:C}],H=i.length);for(var V=function(C){var H=i[C];if(H.type===n.type&&(!H.namespace||H.namespace===n.namespace||".*"===H.namespace)&&e.eventMatches(e.context,H,n)){var V=[n];null!=t&&function(e,t){for(var C=0;C1&&!i){var H=this.length-1,n=this[H],V=n._private.data.id;this[H]=void 0,this[e]=n,C.set(V,{ele:n,index:e})}return this.length--,this},unmergeOne:function(e){e=e[0];var t=this._private,C=e._private.data.id,i=t.map.get(C);if(!i)return this;var H=i.index;return this.unmergeAt(H),this},unmerge:function(e){var t=this._private.cy;if(!e)return this;if(e&&et(e)){var C=e;e=t.mutableElements().filter(C)}for(var i=0;i=0;t--){e(this[t])&&this.unmergeAt(t)}return this},map:function(e,t){for(var C=[],i=this,H=0;Hi&&(i=r,C=V)}return{value:i,ele:C}},min:function(e,t){for(var C,i=1/0,H=this,n=0;n=0&&H1&&void 0!==arguments[1])||arguments[1],C=this[0],i=C.cy();if(i.styleEnabled()&&C){this.cleanStyle();var H=C._private.style[e];return null!=H?H:t?i.style().getDefaultProperty(e):null}},numericStyle:function(e){var t=this[0];if(t.cy().styleEnabled()&&t){var C=t.pstyle(e);return void 0!==C.pfValue?C.pfValue:C.value}},numericStyleUnits:function(e){var t=this[0];if(t.cy().styleEnabled())return t?t.pstyle(e).units:void 0},renderedStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var C=this[0];return C?t.style().getRenderedStyle(C,e):void 0},style:function(e,t){var C=this.cy();if(!C.styleEnabled())return this;var i=C.style();if(it(e)){var H=e;i.applyBypass(this,H,false),this.emitAndNotify("style")}else if(et(e)){if(void 0===t){var n=this[0];return n?i.getStylePropertyValue(n,e):void 0}i.applyBypass(this,e,t,false),this.emitAndNotify("style")}else if(void 0===e){var V=this[0];return V?i.getRawStyle(V):void 0}return this},removeStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var C=t.style(),i=this;if(void 0===e)for(var H=0;H0&&t.push(a[0]),t.push(r[0])}return this.spawn(t,!0).filter(e)}),"neighborhood"),closedNeighborhood:function(e){return this.neighborhood().add(this).filter(e)},openNeighborhood:function(e){return this.neighborhood(e)}}),NV.neighbourhood=NV.neighborhood,NV.closedNeighbourhood=NV.closedNeighborhood,NV.openNeighbourhood=NV.openNeighborhood,ft(NV,{source:mn((function(e){var t,C=this[0];return C&&(t=C._private.source||C.cy().collection()),t&&e?t.filter(e):t}),"source"),target:mn((function(e){var t,C=this[0];return C&&(t=C._private.target||C.cy().collection()),t&&e?t.filter(e):t}),"target"),sources:zV({attr:"source"}),targets:zV({attr:"target"})}),ft(NV,{edgesWith:mn(jV(),"edgesWith"),edgesTo:mn(jV({thisIsSrc:!0}),"edgesTo")}),ft(NV,{connectedEdges:mn((function(e){for(var t=[],C=0;C0);return n},component:function(){var e=this[0];return e.cy().mutableElements().components(e)[0]}}),NV.componentsOf=NV.components;var WV=function(e,t){var C=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(void 0!==e){var i=new nC,H=!1;if(t){if(t.length>0&&it(t[0])&&!rt(t[0])){H=!0;for(var n=[],V=new rC,r=0,L=t.length;r0&&void 0!==arguments[0])||arguments[0],i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],H=this,n=H.cy(),V=n._private,r=[],L=[],o=0,a=H.length;o0){for(var _=e.length===H.length?H:new WV(n,e),B=0;B<_.length;B++){var D=_[B];D.isNode()||(D.parallelEdges().clearTraversalCache(),D.source().clearTraversalCache(),D.target().clearTraversalCache())}(V.hasCompoundNodes?n.collection().merge(_).merge(_.connectedNodes()).merge(_.parent()):_).dirtyCompoundBoundsCache().dirtyBoundingBoxCache().updateStyle(C),C?_.emitAndNotify("add"):i&&_.emit("add")}return H},$V.removed=function(){var e=this[0];return e&&e._private.removed},$V.inside=function(){var e=this[0];return e&&!e._private.removed},$V.remove=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],C=this,i=[],H={},n=C._private.cy;function V(e){for(var t=e._private.edges,C=0;C0&&(e?b.emitAndNotify("remove"):t&&b.emit("remove"));for(var w=0;wM&&Math.abs(r.v)>M;);return n?function(e){return o[e*(o.length-1)|0]}:a}}(),XV=function(e,t,C,i){var H=function(e,t,C,i){var H=4,n=.001,V=1e-7,r=10,L=11,o=1/(L-1),a="undefined"!=typeof Float32Array;if(4!==arguments.length)return!1;for(var M=0;M<4;++M)if("number"!=typeof arguments[M]||isNaN(arguments[M])||!isFinite(arguments[M]))return!1;e=Math.min(e,1),C=Math.min(C,1),e=Math.max(e,0),C=Math.max(C,0);var s=a?new Float32Array(L):new Array(L);function l(e,t){return 1-3*t+3*e}function d(e,t){return 3*t-6*e}function u(e){return 3*e}function A(e,t,C){return((l(t,C)*e+d(t,C))*e+u(t))*e}function c(e,t,C){return 3*l(t,C)*e*e+2*d(t,C)*e+u(t)}function h(t,i){for(var n=0;n0?H=L:i=L}while(Math.abs(n)>V&&++o=n?h(t,r):0===a?r:f(t,i,i+o)}var g=!1;function v(){g=!0,e===t&&C===i||m()}var y=function(H){return g||v(),e===t&&C===i?H:0===H?0:1===H?1:A(p(H),t,i)};y.getControlPoints=function(){return[{x:e,y:t},{x:C,y:i}]};var Z="generateBezier("+[e,t,C,i]+")";return y.toString=function(){return Z},y}(e,t,C,i);return function(e,t,C){return e+(t-e)*H(C)}},qV={linear:function(e,t,C){return e+(t-e)*C},ease:XV(.25,.1,.25,1),"ease-in":XV(.42,0,1,1),"ease-out":XV(0,0,.58,1),"ease-in-out":XV(.42,0,.58,1),"ease-in-sine":XV(.47,0,.745,.715),"ease-out-sine":XV(.39,.575,.565,1),"ease-in-out-sine":XV(.445,.05,.55,.95),"ease-in-quad":XV(.55,.085,.68,.53),"ease-out-quad":XV(.25,.46,.45,.94),"ease-in-out-quad":XV(.455,.03,.515,.955),"ease-in-cubic":XV(.55,.055,.675,.19),"ease-out-cubic":XV(.215,.61,.355,1),"ease-in-out-cubic":XV(.645,.045,.355,1),"ease-in-quart":XV(.895,.03,.685,.22),"ease-out-quart":XV(.165,.84,.44,1),"ease-in-out-quart":XV(.77,0,.175,1),"ease-in-quint":XV(.755,.05,.855,.06),"ease-out-quint":XV(.23,1,.32,1),"ease-in-out-quint":XV(.86,0,.07,1),"ease-in-expo":XV(.95,.05,.795,.035),"ease-out-expo":XV(.19,1,.22,1),"ease-in-out-expo":XV(1,0,0,1),"ease-in-circ":XV(.6,.04,.98,.335),"ease-out-circ":XV(.075,.82,.165,1),"ease-in-out-circ":XV(.785,.135,.15,.86),spring:function(e,t,C){if(0===C)return qV.linear;var i=YV(e,t,C);return function(e,t,C){return e+(t-e)*i(C)}},"cubic-bezier":XV};function QV(e,t,C,i,H){if(1===i)return C;if(t===C)return C;var n=H(t,C,i);return null==e||((e.roundValue||e.color)&&(n=Math.round(n)),void 0!==e.min&&(n=Math.max(n,e.min)),void 0!==e.max&&(n=Math.min(n,e.max))),n}function KV(e,t){return null!=e.pfValue||null!=e.value?null==e.pfValue||null!=t&&"%"===t.type.units?e.value:e.pfValue:e}function JV(e,t,C,i,H){var n=null!=H?H.type:null;C<0?C=0:C>1&&(C=1);var V=KV(e,H),r=KV(t,H);if(Ht(V)&&Ht(r))return QV(n,V,r,C,i);if(Ct(V)&&Ct(r)){for(var L=[],o=0;o0?("spring"===M&&s.push(V.duration),V.easingImpl=qV[M].apply(null,s)):V.easingImpl=qV[M]}var l,d=V.easingImpl;if(l=0===V.duration?1:(C-L)/V.duration,V.applying&&(l=V.progress),l<0?l=0:l>1&&(l=1),null==V.delay){var u=V.startPosition,A=V.position;if(A&&H&&!e.locked()){var c={};tr(u.x,A.x)&&(c.x=JV(u.x,A.x,l,d)),tr(u.y,A.y)&&(c.y=JV(u.y,A.y,l,d)),e.position(c)}var h=V.startPan,m=V.pan,f=n.pan,p=null!=m&&i;p&&(tr(h.x,m.x)&&(f.x=JV(h.x,m.x,l,d)),tr(h.y,m.y)&&(f.y=JV(h.y,m.y,l,d)),e.emit("pan"));var g=V.startZoom,v=V.zoom,y=null!=v&&i;y&&(tr(g,v)&&(n.zoom=_C(n.minZoom,JV(g,v,l,d),n.maxZoom)),e.emit("zoom")),(p||y)&&e.emit("viewport");var Z=V.style;if(Z&&Z.length>0&&H){for(var S=0;S=0;t--){(0,e[t])()}e.splice(0,e.length)},a=n.length-1;a>=0;a--){var M=n[a],s=M._private;s.stopped?(n.splice(a,1),s.hooked=!1,s.playing=!1,s.started=!1,o(s.frames)):(s.playing||s.applying)&&(s.playing&&s.applying&&(s.applying=!1),s.started||Cr(0,M,e),er(t,M,e,C),s.applying&&(s.applying=!1),o(s.frames),null!=s.step&&s.step(e),M.completed()&&(n.splice(a,1),s.hooked=!1,s.playing=!1,s.started=!1,o(s.completes)),r=!0)}return C||0!==n.length||0!==V.length||i.push(t),r}for(var n=!1,V=0;V0?t.notify("draw",C):t.notify("draw")),C.unmerge(i),t.emit("step")}var Hr={animate:xH.animate(),animation:xH.animation(),animated:xH.animated(),clearQueue:xH.clearQueue(),delay:xH.delay(),delayAnimation:xH.delayAnimation(),stop:xH.stop(),addToAnimationPool:function(e){this.styleEnabled()&&this._private.aniEles.merge(e)},stopAnimationLoop:function(){this._private.animationsRunning=!1},startAnimationLoop:function(){var e=this;if(e._private.animationsRunning=!0,e.styleEnabled()){var t=e.renderer();t&&t.beforeRender?t.beforeRender((function(t,C){ir(C,e)}),t.beforeRenderPriorities.animations):function t(){e._private.animationsRunning&&wt((function(C){ir(C,e),t()}))}()}}},nr={qualifierCompare:function(e,t){return null==e||null==t?null==e&&null==t:e.sameText(t)},eventMatches:function(e,t,C){var i=t.qualifier;return null==i||e!==C.target&&rt(C.target)&&i.matches(C.target)},addEventFields:function(e,t){t.cy=e,t.target=e},callbackContext:function(e,t,C){return null!=t.qualifier?C.target:e}},Vr=function(e){return et(e)?new dn(e):e},rr={createEmitter:function(){var e=this._private;return e.emitter||(e.emitter=new oV(nr,this)),this},emitter:function(){return this._private.emitter},on:function(e,t,C){return this.emitter().on(e,Vr(t),C),this},removeListener:function(e,t,C){return this.emitter().removeListener(e,Vr(t),C),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},one:function(e,t,C){return this.emitter().one(e,Vr(t),C),this},once:function(e,t,C){return this.emitter().one(e,Vr(t),C),this},emit:function(e,t){return this.emitter().emit(e,t),this},emitAndNotify:function(e,t){return this.emit(e),this.notify(e,t),this}};xH.eventAliasesOn(rr);var Lr={png:function(e){return e=e||{},this._private.renderer.png(e)},jpg:function(e){var t=this._private.renderer;return(e=e||{}).bg=e.bg||"#fff",t.jpg(e)}};Lr.jpeg=Lr.jpg;var or={layout:function(e){var t=this;if(null!=e)if(null!=e.name){var C=e.name,i=t.extension("layout",C);if(null!=i){var H;H=et(e.eles)?t.$(e.eles):null!=e.eles?e.eles:t.$();var n=new i(ft({},e,{cy:t,eles:H}));return n}Ut("No such layout `"+C+"` found. Did you forget to import it and `cytoscape.use()` it?")}else Ut("A `name` must be specified to make a layout");else Ut("Layout options must be specified to make a layout")}};or.createLayout=or.makeLayout=or.layout;var ar={notify:function(e,t){var C=this._private;if(this.batching()){C.batchNotifications=C.batchNotifications||{};var i=C.batchNotifications[e]=C.batchNotifications[e]||this.collection();null!=t&&i.merge(t)}else if(C.notificationsEnabled){var H=this.renderer();!this.destroyed()&&H&&H.notify(e,t)}},notifications:function(e){var t=this._private;return void 0===e?t.notificationsEnabled:(t.notificationsEnabled=!!e,this)},noNotifications:function(e){this.notifications(!1),e(),this.notifications(!0)},batching:function(){return this._private.batchCount>0},startBatch:function(){var e=this._private;return null==e.batchCount&&(e.batchCount=0),0===e.batchCount&&(e.batchStyleEles=this.collection(),e.batchNotifications={}),e.batchCount++,this},endBatch:function(){var e=this._private;if(0===e.batchCount)return this;if(e.batchCount--,0===e.batchCount){e.batchStyleEles.updateStyle();var t=this.renderer();Object.keys(e.batchNotifications).forEach((function(C){var i=e.batchNotifications[C];i.empty()?t.notify(C):t.notify(C,i)}))}return this},batch:function(e){return this.startBatch(),e(),this.endBatch(),this},batchData:function(e){var t=this;return this.batch((function(){for(var C=Object.keys(e),i=0;i0;)t.removeChild(t.childNodes[0]);e._private.renderer=null,e.mutableElements().forEach((function(e){var t=e._private;t.rscratch={},t.rstyle={},t.animation.current=[],t.animation.queue=[]}))},onRender:function(e){return this.on("render",e)},offRender:function(e){return this.off("render",e)}};sr.invalidateDimensions=sr.resize;var lr={collection:function(e,t){return et(e)?this.$(e):Vt(e)?e.collection():Ct(e)?new WV(this,e,t):new WV(this)},nodes:function(e){var t=this.$((function(e){return e.isNode()}));return e?t.filter(e):t},edges:function(e){var t=this.$((function(e){return e.isEdge()}));return e?t.filter(e):t},$:function(e){var t=this._private.elements;return e?t.filter(e):t.spawnSelf()},mutableElements:function(){return this._private.elements}};lr.elements=lr.filter=lr.$;var dr={};dr.apply=function(e){for(var t=this,C=t._private.cy.collection(),i=0;i0;if(s||M&&l){var d=void 0;s&&l||s?d=o.properties:l&&(d=o.mappedProperties);for(var u=0;u1&&(A=1),r.color){var p=H.valueMin[0],g=H.valueMax[0],v=H.valueMin[1],y=H.valueMax[1],Z=H.valueMin[2],S=H.valueMax[2],b=null==H.valueMin[3]?1:H.valueMin[3],w=null==H.valueMax[3]?1:H.valueMax[3],x=[Math.round(p+(g-p)*A),Math.round(v+(y-v)*A),Math.round(Z+(S-Z)*A),Math.round(b+(w-b)*A)];C={bypass:H.bypass,name:H.name,value:x,strValue:"rgb("+x[0]+", "+x[1]+", "+x[2]+")"}}else{if(!r.number)return!1;var O=H.valueMin+(H.valueMax-H.valueMin)*A;C=this.parse(H.name,O,H.bypass,s)}if(!C)return u(),!1;C.mapping=H,H=C;break;case V.data:for(var k=H.field.split("."),E=M.data,P=0;P0&&n>0){for(var r={},L=!1,o=0;o0?e.delayAnimation(V).play().promise().then(t):t()})).then((function(){return e.animation({style:r,duration:n,easing:e.pstyle("transition-timing-function").value,queue:!1}).play().promise()})).then((function(){C.removeBypasses(e,H),e.emitAndNotify("style"),i.transitioning=!1}))}else i.transitioning&&(this.removeBypasses(e,H),e.emitAndNotify("style"),i.transitioning=!1)},dr.checkTrigger=function(e,t,C,i,H,n){var V=this.properties[t],r=H(V);null!=r&&r(C,i)&&n(V)},dr.checkZOrderTrigger=function(e,t,C,i){var H=this;this.checkTrigger(e,t,C,i,(function(e){return e.triggersZOrder}),(function(){H._private.cy.notify("zorder",e)}))},dr.checkBoundsTrigger=function(e,t,C,i){this.checkTrigger(e,t,C,i,(function(e){return e.triggersBounds}),(function(H){e.dirtyCompoundBoundsCache(),e.dirtyBoundingBoxCache(),"curve-style"!==t||"bezier"!==C&&"bezier"!==i||!H.triggersBoundsOfParallelBeziers||e.parallelEdges().forEach((function(e){e.isBundledBezier()&&e.dirtyBoundingBoxCache()}))}))},dr.checkTriggers=function(e,t,C,i){e.dirtyStyleCache(),this.checkZOrderTrigger(e,t,C,i),this.checkBoundsTrigger(e,t,C,i)};var ur={applyBypass:function(e,t,C,i){var H=[];if("*"===t||"**"===t){if(void 0!==C)for(var n=0;nt.length?n.substr(t.length):""}function r(){C=C.length>i.length?C.substr(i.length):""}for(n=n.replace(/[/][*](\s|.)+?[*][/]/g,"");;){if(n.match(/^\s*$/))break;var L=n.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!L){Xt("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: "+n);break}t=L[0];var o=L[1];if("core"!==o)if(new dn(o).invalid){Xt("Skipping parsing of block: Invalid selector found in string stylesheet: "+o),V();continue}var a=L[2],M=!1;C=a;for(var s=[];;){if(C.match(/^\s*$/))break;var l=C.match(/^\s*(.+?)\s*:\s*(.+?)\s*;/);if(!l){Xt("Skipping parsing of block: Invalid formatting of style property and value definitions found in:"+a),M=!0;break}i=l[0];var d=l[1],u=l[2];if(this.properties[d])H.parse(d,u)?(s.push({name:d,val:u}),r()):(Xt("Skipping property: Invalid property definition in: "+i),r());else Xt("Skipping property: Invalid property name in: "+i),r()}if(M){V();break}H.selector(o);for(var A=0;A=7&&"d"===t[0]&&(o=new RegExp(r.data.regex).exec(t))){if(C)return!1;var s=r.data;return{name:e,value:o,strValue:""+t,mapped:s,field:o[1],bypass:C}}if(t.length>=10&&"m"===t[0]&&(a=new RegExp(r.mapData.regex).exec(t))){if(C)return!1;if(M.multiple)return!1;var l=r.mapData;if(!M.color&&!M.number)return!1;var d=this.parse(e,a[4]);if(!d||d.mapped)return!1;var u=this.parse(e,a[5]);if(!u||u.mapped)return!1;if(d.pfValue===u.pfValue||d.strValue===u.strValue)return Xt("`"+e+": "+t+"` is not a valid mapper because the output range is zero; converting to `"+e+": "+d.strValue+"`"),this.parse(e,d.strValue);if(M.color){var A=d.value,c=u.value;if(!(A[0]!==c[0]||A[1]!==c[1]||A[2]!==c[2]||A[3]!==c[3]&&(null!=A[3]&&1!==A[3]||null!=c[3]&&1!==c[3])))return!1}return{name:e,value:a,strValue:""+t,mapped:l,field:a[1],fieldMin:parseFloat(a[2]),fieldMax:parseFloat(a[3]),valueMin:d.value,valueMax:u.value,bypass:C}}}if(M.multiple&&"multiple"!==i){var h;if(h=L?t.split(/\s+/):Ct(t)?t:[t],M.evenMultiple&&h.length%2!=0)return null;for(var m=[],f=[],p=[],g="",v=!1,y=0;y0?" ":"")+Z.strValue}return M.validate&&!M.validate(m,f)?null:M.singleEnum&&v?1===m.length&&et(m[0])?{name:e,value:m[0],strValue:m[0],bypass:C}:null:{name:e,value:m,pfValue:p,strValue:g,bypass:C,units:f}}var S,b,w=function(){for(var i=0;iM.max||M.strictMax&&t===M.max))return null;var P={name:e,value:t,strValue:""+t+(x||""),units:x,bypass:C};return M.unitless||"px"!==x&&"em"!==x?P.pfValue=t:P.pfValue="px"!==x&&x?this.getEmSizeInPixels()*t:t,"ms"!==x&&"s"!==x||(P.pfValue="ms"===x?t:1e3*t),"deg"!==x&&"rad"!==x||(P.pfValue="rad"===x?t:(S=t,Math.PI*S/180)),"%"===x&&(P.pfValue=t/100),P}if(M.propList){var T=[],_=""+t;if("none"===_);else{for(var B=_.split(/\s*,\s*|\s+/),D=0;D0&&L>0&&!isNaN(C.w)&&!isNaN(C.h)&&C.w>0&&C.h>0)return{zoom:V=(V=(V=Math.min((r-2*t)/C.w,(L-2*t)/C.h))>this._private.maxZoom?this._private.maxZoom:V)=C.minZoom&&(C.maxZoom=t),this},minZoom:function(e){return void 0===e?this._private.minZoom:this.zoomRange({min:e})},maxZoom:function(e){return void 0===e?this._private.maxZoom:this.zoomRange({max:e})},getZoomedViewport:function(e){var t,C,i=this._private,H=i.pan,n=i.zoom,V=!1;if(i.zoomingEnabled||(V=!0),Ht(e)?C=e:it(e)&&(C=e.level,null!=e.position?t=yC(e.position,n,H):null!=e.renderedPosition&&(t=e.renderedPosition),null==t||i.panningEnabled||(V=!0)),C=(C=C>i.maxZoom?i.maxZoom:C)t.maxZoom||!t.zoomingEnabled?n=!0:(t.zoom=r,H.push("zoom"))}if(i&&(!n||!e.cancelOnFailedZoom)&&t.panningEnabled){var L=e.pan;Ht(L.x)&&(t.pan.x=L.x,V=!1),Ht(L.y)&&(t.pan.y=L.y,V=!1),V||H.push("pan")}return H.length>0&&(H.push("viewport"),this.emit(H.join(" ")),this.notify("viewport")),this},center:function(e){var t=this.getCenterPan(e);return t&&(this._private.pan=t,this.emit("pan viewport"),this.notify("viewport")),this},getCenterPan:function(e,t){if(this._private.panningEnabled){if(et(e)){var C=e;e=this.mutableElements().filter(C)}else Vt(e)||(e=this.mutableElements());if(0!==e.length){var i=e.boundingBox(),H=this.width(),n=this.height();return{x:(H-(t=void 0===t?this._private.zoom:t)*(i.x1+i.x2))/2,y:(n-t*(i.y1+i.y2))/2}}}},reset:function(){return this._private.panningEnabled&&this._private.zoomingEnabled?(this.viewport({pan:{x:0,y:0},zoom:1}),this):this},invalidateSize:function(){this._private.sizeCache=null},size:function(){var e,t,C=this._private,i=C.container;return C.sizeCache=C.sizeCache||(i?(e=Ue.getComputedStyle(i),t=function(t){return parseFloat(e.getPropertyValue(t))},{width:i.clientWidth-t("padding-left")-t("padding-right"),height:i.clientHeight-t("padding-top")-t("padding-bottom")}):{width:1,height:1})},width:function(){return this.size().width},height:function(){return this.size().height},extent:function(){var e=this._private.pan,t=this._private.zoom,C=this.renderedExtent(),i={x1:(C.x1-e.x)/t,x2:(C.x2-e.x)/t,y1:(C.y1-e.y)/t,y2:(C.y2-e.y)/t};return i.w=i.x2-i.x1,i.h=i.y2-i.y1,i},renderedExtent:function(){var e=this.width(),t=this.height();return{x1:0,y1:0,x2:e,y2:t,w:e,h:t}},multiClickDebounceTime:function(e){return e?(this._private.multiClickDebounceTime=e,this):this._private.multiClickDebounceTime}};Zr.centre=Zr.center,Zr.autolockNodes=Zr.autolock,Zr.autoungrabifyNodes=Zr.autoungrabify;var Sr={data:xH.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeData:xH.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),scratch:xH.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:xH.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0})};Sr.attr=Sr.data,Sr.removeAttr=Sr.removeData;var br=function(e){var t=this,C=(e=ft({},e)).container;C&&!nt(C)&&nt(C[0])&&(C=C[0]);var i=C?C._cyreg:null;(i=i||{})&&i.cy&&(i.cy.destroy(),i={});var H=i.readies=i.readies||[];C&&(C._cyreg=i),i.cy=t;var n=void 0!==Ue&&void 0!==C&&!e.headless,V=e;V.layout=ft({name:n?"grid":"null"},V.layout),V.renderer=ft({name:n?"canvas":"null"},V.renderer);var r=function(e,t,C){return void 0!==t?t:void 0!==C?C:e},L=this._private={container:C,ready:!1,options:V,elements:new WV(this),listeners:[],aniEles:new WV(this),data:V.data||{},scratch:{},layout:null,renderer:null,destroyed:!1,notificationsEnabled:!0,minZoom:1e-50,maxZoom:1e50,zoomingEnabled:r(!0,V.zoomingEnabled),userZoomingEnabled:r(!0,V.userZoomingEnabled),panningEnabled:r(!0,V.panningEnabled),userPanningEnabled:r(!0,V.userPanningEnabled),boxSelectionEnabled:r(!0,V.boxSelectionEnabled),autolock:r(!1,V.autolock,V.autolockNodes),autoungrabify:r(!1,V.autoungrabify,V.autoungrabifyNodes),autounselectify:r(!1,V.autounselectify),styleEnabled:void 0===V.styleEnabled?n:V.styleEnabled,zoom:Ht(V.zoom)?V.zoom:1,pan:{x:it(V.pan)&&Ht(V.pan.x)?V.pan.x:0,y:it(V.pan)&&Ht(V.pan.y)?V.pan.y:0},animation:{current:[],queue:[]},hasCompoundNodes:!1,multiClickDebounceTime:r(250,V.multiClickDebounceTime)};this.createEmitter(),this.selectionType(V.selectionType),this.zoomRange({min:V.minZoom,max:V.maxZoom});L.styleEnabled&&t.setStyle([]);var o=ft({},V,V.renderer);t.initRenderer(o);!function(e,t){if(e.some(st))return vH.all(e).then(t);t(e)}([V.style,V.elements],(function(e){var C=e[0],n=e[1];L.styleEnabled&&t.style().append(C),function(e,C,i){t.notifications(!1);var H=t.mutableElements();H.length>0&&H.remove(),null!=e&&(it(e)||Ct(e))&&t.add(e),t.one("layoutready",(function(e){t.notifications(!0),t.emit(e),t.one("load",C),t.emitAndNotify("load")})).one("layoutstop",(function(){t.one("done",i),t.emit("done")}));var n=ft({},t._private.options.layout);n.eles=t.elements(),t.layout(n).run()}(n,(function(){t.startAnimationLoop(),L.ready=!0,tt(V.ready)&&t.on("ready",V.ready);for(var e=0;e0,o=BC(C.boundingBox?C.boundingBox:{x1:0,y1:0,w:i.width(),h:i.height()});if(Vt(C.roots))e=C.roots;else if(Ct(C.roots)){for(var a=[],M=0;M0;){var x=S.shift(),O=Z(x,b);if(O)x.outgoers().filter((function(e){return e.isNode()&&H.has(e)})).forEach(w);else if(null===O){Xt("Detected double maximal shift for node `"+x.id()+"`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.");break}}}y();var k=0;if(C.avoidOverlap)for(var E=0;E0&&c[0].length<=3?L/2:0),M=2*Math.PI/c[i].length*H;return 0===i&&1===c[0].length&&(a=1),{x:G+a*Math.cos(M),y:W+a*Math.sin(M)}}return{x:G+(H+1-(n+1)/2)*V,y:(i+1)*r}})),this};var Pr={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,radius:void 0,startAngle:1.5*Math.PI,sweep:void 0,clockwise:!0,sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function Tr(e){this.options=ft({},Pr,e)}Tr.prototype.run=function(){var e=this.options,t=e,C=e.cy,i=t.eles,H=void 0!==t.counterclockwise?!t.counterclockwise:t.clockwise,n=i.nodes().not(":parent");t.sort&&(n=n.sort(t.sort));for(var V,r=BC(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:C.width(),h:C.height()}),L=r.x1+r.w/2,o=r.y1+r.h/2,a=(void 0===t.sweep?2*Math.PI-2*Math.PI/n.length:t.sweep)/Math.max(1,n.length-1),M=0,s=0;s1&&t.avoidOverlap){M*=1.75;var A=Math.cos(a)-Math.cos(0),c=Math.sin(a)-Math.sin(0),h=Math.sqrt(M*M/(A*A+c*c));V=Math.max(h,V)}return i.nodes().layoutPositions(this,t,(function(e,C){var i=t.startAngle+C*a*(H?1:-1),n=V*Math.cos(i),r=V*Math.sin(i);return{x:L+n,y:o+r}})),this};var _r,Br={fit:!0,padding:30,startAngle:1.5*Math.PI,sweep:void 0,clockwise:!0,equidistant:!1,minNodeSpacing:10,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,height:void 0,width:void 0,spacingFactor:void 0,concentric:function(e){return e.degree()},levelWidth:function(e){return e.maxDegree()/4},animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function Dr(e){this.options=ft({},Br,e)}Dr.prototype.run=function(){for(var e=this.options,t=e,C=void 0!==t.counterclockwise?!t.counterclockwise:t.clockwise,i=e.cy,H=t.eles,n=H.nodes().not(":parent"),V=BC(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:i.width(),h:i.height()}),r=V.x1+V.w/2,L=V.y1+V.h/2,o=[],a=0,M=0;M0)Math.abs(h[0].value-f.value)>=A&&(h=[],c.push(h));h.push(f)}var p=a+t.minNodeSpacing;if(!t.avoidOverlap){var g=c.length>0&&c[0].length>1,v=(Math.min(V.w,V.h)/2-p)/(c.length+g?1:0);p=Math.min(p,v)}for(var y=0,Z=0;Z1&&t.avoidOverlap){var x=Math.cos(w)-Math.cos(0),O=Math.sin(w)-Math.sin(0),k=Math.sqrt(p*p/(x*x+O*O));y=Math.max(k,y)}S.r=y,y+=p}if(t.equidistant){for(var E=0,P=0,T=0;T=e.numIter)&&($r(i,e),i.temperature=i.temperature*e.coolingFactor,!(i.temperature=e.animationThreshold&&n(),wt(t)):(HL(i,e),r())}()}else{for(;o;)o=V(L),L++;HL(i,e),r()}return this},Rr.prototype.stop=function(){return this.stopped=!0,this.thread&&this.thread.stop(),this.emit("layoutstop"),this},Rr.prototype.destroy=function(){return this.thread&&this.thread.stop(),this};var Fr=function(e,t,C){for(var i=C.eles.edges(),H=C.eles.nodes(),n={isCompound:e.hasCompoundNodes(),layoutNodes:[],idToIndex:{},nodeSize:H.size(),graphSet:[],indexToGraph:[],layoutEdges:[],edgeSize:i.size(),temperature:C.initialTemp,clientWidth:e.width(),clientHeight:e.width(),boundingBox:BC(C.boundingBox?C.boundingBox:{x1:0,y1:0,w:e.width(),h:e.height()})},V=C.eles.components(),r={},L=0;L0){n.graphSet.push(f);for(L=0;Li.count?0:i.graph},zr=function e(t,C,i,H){var n=H.graphSet[i];if(-10)var r=(o=i.nodeOverlap*V)*H/(u=Math.sqrt(H*H+n*n)),L=o*n/u;else{var o,a=Qr(e,H,n),M=Qr(t,-1*H,-1*n),s=M.x-a.x,l=M.y-a.y,d=s*s+l*l,u=Math.sqrt(d);r=(o=(e.nodeRepulsion+t.nodeRepulsion)/d)*s/u,L=o*l/u}e.isLocked||(e.offsetX-=r,e.offsetY-=L),t.isLocked||(t.offsetX+=r,t.offsetY+=L)}},qr=function(e,t,C,i){if(C>0)var H=e.maxX-t.minX;else H=t.maxX-e.minX;if(i>0)var n=e.maxY-t.minY;else n=t.maxY-e.minY;return H>=0&&n>=0?Math.sqrt(H*H+n*n):0},Qr=function(e,t,C){var i=e.positionX,H=e.positionY,n=e.height||1,V=e.width||1,r=C/t,L=n/V,o={};return 0===t&&0C?(o.x=i,o.y=H+n/2,o):0t&&-1*L<=r&&r<=L?(o.x=i-V/2,o.y=H-V*C/2/t,o):0=L)?(o.x=i+n*t/2/C,o.y=H+n/2,o):0>C&&(r<=-1*L||r>=L)?(o.x=i-n*t/2/C,o.y=H-n/2,o):o},Kr=function(e,t){for(var C=0;C1){var d=t.gravity*M/l,u=t.gravity*s/l;a.offsetX+=d,a.offsetY+=u}}}}},eL=function(e,t){var C=[],i=0,H=-1;for(C.push.apply(C,e.graphSet[0]),H+=e.graphSet[0].length;i<=H;){var n=C[i++],V=e.idToIndex[n],r=e.layoutNodes[V],L=r.children;if(0C)var H={x:C*e/i,y:C*t/i};else H={x:e,y:t};return H},iL=function e(t,C){var i=t.parentId;if(null!=i){var H=C.layoutNodes[C.idToIndex[i]],n=!1;return(null==H.maxX||t.maxX+H.padRight>H.maxX)&&(H.maxX=t.maxX+H.padRight,n=!0),(null==H.minX||t.minX-H.padLeftH.maxY)&&(H.maxY=t.maxY+H.padBottom,n=!0),(null==H.minY||t.minY-H.padTopd&&(M+=l+t.componentSpacing,a=0,s=0,l=0)}}},nL={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,avoidOverlapPadding:10,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,condense:!1,rows:void 0,cols:void 0,position:function(e){},sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function VL(e){this.options=ft({},nL,e)}VL.prototype.run=function(){var e=this.options,t=e,C=e.cy,i=t.eles,H=i.nodes().not(":parent");t.sort&&(H=H.sort(t.sort));var n=BC(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:C.width(),h:C.height()});if(0===n.h||0===n.w)i.nodes().layoutPositions(this,t,(function(e){return{x:n.x1,y:n.y1}}));else{var V=H.size(),r=Math.sqrt(V*n.h/n.w),L=Math.round(r),o=Math.round(n.w/n.h*r),a=function(e){if(null==e)return Math.min(L,o);Math.min(L,o)==L?L=e:o=e},M=function(e){if(null==e)return Math.max(L,o);Math.max(L,o)==L?L=e:o=e},s=t.rows,l=null!=t.cols?t.cols:t.columns;if(null!=s&&null!=l)L=s,o=l;else if(null!=s&&null==l)L=s,o=Math.ceil(V/L);else if(null==s&&null!=l)o=l,L=Math.ceil(V/o);else if(o*L>V){var d=a(),u=M();(d-1)*u>=V?a(d-1):(u-1)*d>=V&&M(u-1)}else for(;o*L=V?M(c+1):a(A+1)}var h=n.w/o,m=n.h/L;if(t.condense&&(h=0,m=0),t.avoidOverlap)for(var f=0;f=o&&(k=0,O++)},P={},T=0;T(i=YC(e,t,f[p],f[p+1],f[p+2],f[p+3])))return A(C,i),!0}else if("bezier"===n.edgeType||"multibezier"===n.edgeType||"self"===n.edgeType||"compound"===n.edgeType)for(f=n.allpts,p=0;p+5(i=UC(e,t,f[p],f[p+1],f[p+2],f[p+3],f[p+4],f[p+5])))return A(C,i),!0;h=h||H.source,m=m||H.target;var g=V.getArrowWidth(L,a),v=[{name:"source",x:n.arrowStartX,y:n.arrowStartY,angle:n.srcArrowAngle},{name:"target",x:n.arrowEndX,y:n.arrowEndY,angle:n.tgtArrowAngle},{name:"mid-source",x:n.midX,y:n.midY,angle:n.midsrcArrowAngle},{name:"mid-target",x:n.midX,y:n.midY,angle:n.midtgtArrowAngle}];for(p=0;p0&&(c(h),c(m))}function m(e,t,C){return iC(e,t,C)}function f(C,i){var H,n=C._private,V=d;H=i?i+"-":"",C.boundingBox();var r=n.labelBounds[i||"main"],L=C.pstyle(H+"label").value;if("yes"===C.pstyle("text-events").strValue&&L){var o=m(n.rscratch,"labelX",i),a=m(n.rscratch,"labelY",i),M=m(n.rscratch,"labelAngle",i),s=C.pstyle(H+"text-margin-x").pfValue,l=C.pstyle(H+"text-margin-y").pfValue,u=r.x1-V-s,c=r.x2+V-s,h=r.y1-V-l,f=r.y2+V-l;if(M){var p=Math.cos(M),g=Math.sin(M),v=function(e,t){return{x:(e-=o)*p-(t-=a)*g+o,y:e*g+t*p+a}},y=v(u,h),Z=v(u,f),S=v(c,h),b=v(c,f),w=[y.x+s,y.y+l,S.x+s,S.y+l,b.x+s,b.y+l,Z.x+s,Z.y+l];if(XC(e,t,w))return A(C),!0}else if(zC(r,e,t))return A(C),!0}}C&&(L=L.interactive);for(var p=L.length-1;p>=0;p--){var g=L[p];g.isNode()?c(g)||f(g):h(g)||f(g)||f(g,"source")||f(g,"target")}return o},getAllInBox:function(e,t,C,i){for(var H,n,V=this.getCachedZSortedEles().interactive,r=[],L=Math.min(e,C),o=Math.max(e,C),a=Math.min(t,i),M=Math.max(t,i),s=BC({x1:e=L,y1:t=a,x2:C=o,y2:i=M}),l=0;l0?Math.max(e-t,0):Math.min(e+t,0)},b=S(y,g),w=S(Z,v),x=!1;"auto"===A?u=Math.abs(b)>Math.abs(w)?H:i:A===L||A===r?(u=i,x=!0):A!==n&&A!==V||(u=H,x=!0);var O,k=u===i,E=k?w:b,P=k?Z:y,T=xC(P),_=!1;(x&&(h||f)||!(A===r&&P<0||A===L&&P>0||A===n&&P>0||A===V&&P<0)||(E=(T*=-1)*Math.abs(E),_=!0),h)?O=(m<0?1+m:m)*E:O=(m<0?E:0)+m*T;var B=function(e){return Math.abs(e)=Math.abs(E)},D=B(O),N=B(Math.abs(E)-Math.abs(O));if((D||N)&&!_)if(k){var R=Math.abs(P)<=M/2,F=Math.abs(y)<=s/2;if(R){var I=(o.x1+o.x2)/2,z=o.y1,j=o.y2;C.segpts=[I,z,I,j]}else if(F){var G=(o.y1+o.y2)/2,W=o.x1,$=o.x2;C.segpts=[W,G,$,G]}else C.segpts=[o.x1,o.y2]}else{var U=Math.abs(P)<=a/2,Y=Math.abs(Z)<=l/2;if(U){var X=(o.y1+o.y2)/2,q=o.x1,Q=o.x2;C.segpts=[q,X,Q,X]}else if(Y){var K=(o.x1+o.x2)/2,J=o.y1,ee=o.y2;C.segpts=[K,J,K,ee]}else C.segpts=[o.x2,o.y1]}else if(k){var te=o.y1+O+(d?M/2*T:0),Ce=o.x1,ie=o.x2;C.segpts=[Ce,te,ie,te]}else{var He=o.x1+O+(d?a/2*T:0),ne=o.y1,Ve=o.y2;C.segpts=[He,ne,He,Ve]}},fL.tryToCorrectInvalidPoints=function(e,t){var C=e._private.rscratch;if("bezier"===C.edgeType){var i=t.srcPos,H=t.tgtPos,n=t.srcW,V=t.srcH,r=t.tgtW,L=t.tgtH,o=t.srcShape,a=t.tgtShape,M=!Ht(C.startX)||!Ht(C.startY),s=!Ht(C.arrowStartX)||!Ht(C.arrowStartY),l=!Ht(C.endX)||!Ht(C.endY),d=!Ht(C.arrowEndX)||!Ht(C.arrowEndY),u=3*(this.getArrowWidth(e.pstyle("width").pfValue,e.pstyle("arrow-scale").value)*this.arrowShapeWidth),A=OC({x:C.ctrlpts[0],y:C.ctrlpts[1]},{x:C.startX,y:C.startY}),c=As.poolIndex()){var l=M;M=s,s=l}var d=r.srcPos=M.position(),u=r.tgtPos=s.position(),A=r.srcW=M.outerWidth(),c=r.srcH=M.outerHeight(),h=r.tgtW=s.outerWidth(),m=r.tgtH=s.outerHeight(),f=r.srcShape=C.nodeShapes[t.getNodeShape(M)],p=r.tgtShape=C.nodeShapes[t.getNodeShape(s)];r.dirCounts={north:0,west:0,south:0,east:0,northwest:0,southwest:0,northeast:0,southeast:0};for(var g=0;g0){var I=o,z=kC(I,SC(t)),j=kC(I,SC(F)),G=z;if(j2)kC(I,{x:F[2],y:F[3]})0){var ie=a,He=kC(ie,SC(t)),ne=kC(ie,SC(Ce)),Ve=He;if(ne2)kC(ie,{x:Ce[2],y:Ce[3]})=o||h){a={cp:u,segment:c};break}}if(a)break}var m=a.cp,f=a.segment,p=(o-s)/f.length,g=f.t1-f.t0,v=r?f.t0+g*p:f.t1-g*p;v=_C(0,v,1),t=TC(m.p0,m.p1,m.p2,v),H=function(e,t,C,i){var H=_C(0,i-.001,1),n=_C(0,i+.001,1),V=TC(e,t,C,H),r=TC(e,t,C,n);return bL(V,r)}(m.p0,m.p1,m.p2,v);break;case"straight":case"segments":case"haystack":for(var y,Z,S,b,w=0,x=i.allpts.length,O=0;O+3=o));O+=2);var k=(o-Z)/y;k=_C(0,k,1),t=function(e,t,C,i){var H=t.x-e.x,n=t.y-e.y,V=OC(e,t),r=H/V,L=n/V;return C=null==C?0:C,i=null!=i?i:C*V,{x:e.x+r*i,y:e.y+L*i}}(S,b,k),H=bL(S,b)}V("labelX",C,t.x),V("labelY",C,t.y),V("labelAutoAngle",C,H)}};o("source"),o("target"),this.applyLabelDimensions(e)}},ZL.applyLabelDimensions=function(e){this.applyPrefixedLabelDimensions(e),e.isEdge()&&(this.applyPrefixedLabelDimensions(e,"source"),this.applyPrefixedLabelDimensions(e,"target"))},ZL.applyPrefixedLabelDimensions=function(e,t){var C=e._private,i=this.getLabelText(e,t),H=this.calculateLabelDimensions(e,i),n=e.pstyle("line-height").pfValue,V=e.pstyle("text-wrap").strValue,r=iC(C.rscratch,"labelWrapCachedLines",t)||[],L="wrap"!==V?1:Math.max(r.length,1),o=H.height/L,a=o*n,M=H.width,s=H.height+(L-1)*(n-1)*o;HC(C.rstyle,"labelWidth",t,M),HC(C.rscratch,"labelWidth",t,M),HC(C.rstyle,"labelHeight",t,s),HC(C.rscratch,"labelHeight",t,s),HC(C.rscratch,"labelLineHeight",t,a)},ZL.getLabelText=function(e,t){var C=e._private,i=t?t+"-":"",H=e.pstyle(i+"label").strValue,n=e.pstyle("text-transform").value,V=function(e,i){return i?(HC(C.rscratch,e,t,i),i):iC(C.rscratch,e,t)};if(!H)return"";"none"==n||("uppercase"==n?H=H.toUpperCase():"lowercase"==n&&(H=H.toLowerCase()));var r=e.pstyle("text-wrap").value;if("wrap"===r){var L=V("labelKey");if(null!=L&&V("labelWrapKey")===L)return V("labelWrapCachedText");for(var o=H.split("\n"),a=e.pstyle("text-max-width").pfValue,M="anywhere"===e.pstyle("text-overflow-wrap").value,s=[],l=/[\s\u200b]+/,d=M?"":" ",u=0;ua){for(var m=A.split(l),f="",p=0;py)break;Z+=H[b],b===H.length-1&&(S=!0)}return S||(Z+="…"),Z}return H},ZL.getLabelJustification=function(e){var t=e.pstyle("text-justification").strValue,C=e.pstyle("text-halign").strValue;if("auto"!==t)return t;if(!e.isNode())return"center";switch(C){case"left":return"right";case"right":return"left";default:return"center"}},ZL.calculateLabelDimensions=function(e,t){var C=Bt(t,e._private.labelDimsKey),i=this.labelDimCache||(this.labelDimCache=[]),H=i[C];if(null!=H)return H;var n=e.pstyle("font-style").strValue,V=e.pstyle("font-size").pfValue,r=e.pstyle("font-family").strValue,L=e.pstyle("font-weight").strValue,o=this.labelCalcCanvas,a=this.labelCalcCanvasContext;if(!o){o=this.labelCalcCanvas=document.createElement("canvas"),a=this.labelCalcCanvasContext=o.getContext("2d");var M=o.style;M.position="absolute",M.left="-9999px",M.top="-9999px",M.zIndex="-1",M.visibility="hidden",M.pointerEvents="none"}a.font="".concat(n," ").concat(L," ").concat(V,"px ").concat(r);for(var s=0,l=0,d=t.split("\n"),u=0;u1&&void 0!==arguments[1])||arguments[1];if(t.merge(e),C)for(var i=0;i=e.desktopTapThreshold2}var S=i(t);A&&(e.hoverData.tapholdCancelled=!0);n=!0,C(u,["mousemove","vmousemove","tapdrag"],t,{x:M[0],y:M[1]});var b=function(){e.data.bgActivePosistion=void 0,e.hoverData.selecting||V.emit({originalEvent:t,type:"boxstart",position:{x:M[0],y:M[1]}}),d[4]=1,e.hoverData.selecting=!0,e.redrawHint("select",!0),e.redraw()};if(3===e.hoverData.which){if(A){var w={originalEvent:t,type:"cxtdrag",position:{x:M[0],y:M[1]}};h?h.emit(w):V.emit(w),e.hoverData.cxtDragged=!0,e.hoverData.cxtOver&&u===e.hoverData.cxtOver||(e.hoverData.cxtOver&&e.hoverData.cxtOver.emit({originalEvent:t,type:"cxtdragout",position:{x:M[0],y:M[1]}}),e.hoverData.cxtOver=u,u&&u.emit({originalEvent:t,type:"cxtdragover",position:{x:M[0],y:M[1]}}))}}else if(e.hoverData.dragging){if(n=!0,V.panningEnabled()&&V.userPanningEnabled()){var x;if(e.hoverData.justStartedPan){var O=e.hoverData.mdownPos;x={x:(M[0]-O[0])*r,y:(M[1]-O[1])*r},e.hoverData.justStartedPan=!1}else x={x:m[0]*r,y:m[1]*r};V.panBy(x),V.emit("dragpan"),e.hoverData.dragged=!0}M=e.projectIntoViewport(t.clientX,t.clientY)}else if(1!=d[4]||null!=h&&!h.pannable()){if(h&&h.pannable()&&h.active()&&h.unactivate(),h&&h.grabbed()||u==c||(c&&C(c,["mouseout","tapdragout"],t,{x:M[0],y:M[1]}),u&&C(u,["mouseover","tapdragover"],t,{x:M[0],y:M[1]}),e.hoverData.last=u),h)if(A){if(V.boxSelectionEnabled()&&S)h&&h.grabbed()&&(a(p),h.emit("freeon"),p.emit("free"),e.dragData.didDrag&&(h.emit("dragfreeon"),p.emit("dragfree"))),b();else if(h&&h.grabbed()&&e.nodeIsDraggable(h)){var k=!e.dragData.didDrag;k&&e.redrawHint("eles",!0),e.dragData.didDrag=!0;var E=V.collection();e.hoverData.draggingEles||L(p,{inDragLayer:!0});var P={x:0,y:0};if(Ht(m[0])&&Ht(m[1])&&(P.x+=m[0],P.y+=m[1],k)){var T=e.hoverData.dragDelta;T&&Ht(T[0])&&Ht(T[1])&&(P.x+=T[0],P.y+=T[1])}for(var _=0;_0&&e.redrawHint("eles",!0),e.dragData.possibleDragElements=o=n.collection()),L!=M||e.dragData.didDrag||e.hoverData.selecting||null!=L&&L._private.selectable&&(e.hoverData.dragging||("additive"===n.selectionType()||s?L.selected()?L.unselect(["tapunselect"]):L.select(["tapselect"]):s||(n.$(t).unmerge(L).unselect(["tapunselect"]),L.select(["tapselect"]))),e.redrawHint("eles",!0)),e.hoverData.selecting){var u=n.collection(e.getAllInBox(r[0],r[1],r[2],r[3]));e.redrawHint("select",!0),u.length>0&&e.redrawHint("eles",!0),n.emit({type:"boxend",originalEvent:H,position:{x:V[0],y:V[1]}});var A=function(e){return e.selectable()&&!e.selected()};"additive"===n.selectionType()||s||n.$(t).unmerge(u).unselect(),u.emit("box").stdFilter(A).select().emit("boxselect"),e.redraw()}if(e.hoverData.dragging&&(e.hoverData.dragging=!1,e.redrawHint("select",!0),e.redrawHint("eles",!0),e.redraw()),!r[4]){e.redrawHint("drag",!0),e.redrawHint("eles",!0);var f=M&&M.grabbed();a(o),f&&(M.emit("freeon"),o.emit("free"),e.dragData.didDrag&&(M.emit("dragfreeon"),o.emit("dragfree")))}}r[4]=0,e.hoverData.down=null,e.hoverData.cxtStarted=!1,e.hoverData.draggingEles=!1,e.hoverData.selecting=!1,e.hoverData.isOverThresholdDrag=!1,e.dragData.didDrag=!1,e.hoverData.dragged=!1,e.hoverData.dragDelta=[],e.hoverData.mdownPos=null,e.hoverData.mdownGPos=null}}),!1);var p,g,v,y,Z,S,b,w,x,O,k,E,P,T=function(t){if(!e.scrollingPage){var C=e.cy,i=C.zoom(),H=C.pan(),n=e.projectIntoViewport(t.clientX,t.clientY),V=[n[0]*i+H.x,n[1]*i+H.y];if(e.hoverData.draggingEles||e.hoverData.dragging||e.hoverData.cxtStarted||0!==e.selection[4])t.preventDefault();else if(C.panningEnabled()&&C.userPanningEnabled()&&C.zoomingEnabled()&&C.userZoomingEnabled()){var r;t.preventDefault(),e.data.wheelZooming=!0,clearTimeout(e.data.wheelTimeout),e.data.wheelTimeout=setTimeout((function(){e.data.wheelZooming=!1,e.redrawHint("eles",!0),e.redraw()}),150),r=null!=t.deltaY?t.deltaY/-250:null!=t.wheelDeltaY?t.wheelDeltaY/1e3:t.wheelDelta/1e3,r*=e.wheelSensitivity,1===t.deltaMode&&(r*=33);var L=C.zoom()*Math.pow(10,r);"gesturechange"===t.type&&(L=e.gestureStartZoom*t.scale),C.zoom({level:L,renderedPosition:{x:V[0],y:V[1]}}),C.emit("gesturechange"===t.type?"pinchzoom":"scrollzoom")}}};e.registerBinding(e.container,"wheel",T,!0),e.registerBinding(window,"scroll",(function(t){e.scrollingPage=!0,clearTimeout(e.scrollingPageTimeout),e.scrollingPageTimeout=setTimeout((function(){e.scrollingPage=!1}),250)}),!0),e.registerBinding(e.container,"gesturestart",(function(t){e.gestureStartZoom=e.cy.zoom(),e.hasTouchStarted||t.preventDefault()}),!0),e.registerBinding(e.container,"gesturechange",(function(t){e.hasTouchStarted||T(t)}),!0),e.registerBinding(e.container,"mouseout",(function(t){var C=e.projectIntoViewport(t.clientX,t.clientY);e.cy.emit({originalEvent:t,type:"mouseout",position:{x:C[0],y:C[1]}})}),!1),e.registerBinding(e.container,"mouseover",(function(t){var C=e.projectIntoViewport(t.clientX,t.clientY);e.cy.emit({originalEvent:t,type:"mouseover",position:{x:C[0],y:C[1]}})}),!1);var _,B,D,N,R,F,I,z=function(e,t,C,i){return Math.sqrt((C-e)*(C-e)+(i-t)*(i-t))},j=function(e,t,C,i){return(C-e)*(C-e)+(i-t)*(i-t)};if(e.registerBinding(e.container,"touchstart",_=function(t){if(e.hasTouchStarted=!0,f(t)){s(),e.touchData.capture=!0,e.data.bgActivePosistion=void 0;var i=e.cy,H=e.touchData.now,n=e.touchData.earlier;if(t.touches[0]){var r=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);H[0]=r[0],H[1]=r[1]}if(t.touches[1]){r=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);H[2]=r[0],H[3]=r[1]}if(t.touches[2]){r=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);H[4]=r[0],H[5]=r[1]}if(t.touches[1]){e.touchData.singleTouchMoved=!0,a(e.dragData.touchDragEles);var M=e.findContainerClientCoords();x=M[0],O=M[1],k=M[2],E=M[3],p=t.touches[0].clientX-x,g=t.touches[0].clientY-O,v=t.touches[1].clientX-x,y=t.touches[1].clientY-O,P=0<=p&&p<=k&&0<=v&&v<=k&&0<=g&&g<=E&&0<=y&&y<=E;var l=i.pan(),d=i.zoom();Z=z(p,g,v,y),S=j(p,g,v,y),w=[((b=[(p+v)/2,(g+y)/2])[0]-l.x)/d,(b[1]-l.y)/d];if(S<4e4&&!t.touches[2]){var u=e.findNearestElement(H[0],H[1],!0,!0),A=e.findNearestElement(H[2],H[3],!0,!0);return u&&u.isNode()?(u.activate().emit({originalEvent:t,type:"cxttapstart",position:{x:H[0],y:H[1]}}),e.touchData.start=u):A&&A.isNode()?(A.activate().emit({originalEvent:t,type:"cxttapstart",position:{x:H[0],y:H[1]}}),e.touchData.start=A):i.emit({originalEvent:t,type:"cxttapstart",position:{x:H[0],y:H[1]}}),e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxt=!0,e.touchData.cxtDragged=!1,e.data.bgActivePosistion=void 0,void e.redraw()}}if(t.touches[2])i.boxSelectionEnabled()&&t.preventDefault();else if(t.touches[1]);else if(t.touches[0]){var c=e.findNearestElements(H[0],H[1],!0,!0),h=c[0];if(null!=h&&(h.activate(),e.touchData.start=h,e.touchData.starts=c,e.nodeIsGrabbable(h))){var m=e.dragData.touchDragEles=i.collection(),T=null;e.redrawHint("eles",!0),e.redrawHint("drag",!0),h.selected()?(T=i.$((function(t){return t.selected()&&e.nodeIsGrabbable(t)})),L(T,{addToList:m})):o(h,{addToList:m}),V(h);var _=function(e){return{originalEvent:t,type:e,position:{x:H[0],y:H[1]}}};h.emit(_("grabon")),T?T.forEach((function(e){e.emit(_("grab"))})):h.emit(_("grab"))}C(h,["touchstart","tapstart","vmousedown"],t,{x:H[0],y:H[1]}),null==h&&(e.data.bgActivePosistion={x:r[0],y:r[1]},e.redrawHint("select",!0),e.redraw()),e.touchData.singleTouchMoved=!1,e.touchData.singleTouchStartTime=+new Date,clearTimeout(e.touchData.tapholdTimeout),e.touchData.tapholdTimeout=setTimeout((function(){!1!==e.touchData.singleTouchMoved||e.pinching||e.touchData.selecting||C(e.touchData.start,["taphold"],t,{x:H[0],y:H[1]})}),e.tapholdDuration)}if(t.touches.length>=1){for(var B=e.touchData.startPosition=[],D=0;D=e.touchTapThreshold2}if(i&&e.touchData.cxt){t.preventDefault();var b=t.touches[0].clientX-x,k=t.touches[0].clientY-O,E=t.touches[1].clientX-x,T=t.touches[1].clientY-O,_=j(b,k,E,T);if(_/S>=2.25||_>=22500){e.touchData.cxt=!1,e.data.bgActivePosistion=void 0,e.redrawHint("select",!0);var B={originalEvent:t,type:"cxttapend",position:{x:r[0],y:r[1]}};e.touchData.start?(e.touchData.start.unactivate().emit(B),e.touchData.start=null):V.emit(B)}}if(i&&e.touchData.cxt){B={originalEvent:t,type:"cxtdrag",position:{x:r[0],y:r[1]}};e.data.bgActivePosistion=void 0,e.redrawHint("select",!0),e.touchData.start?e.touchData.start.emit(B):V.emit(B),e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxtDragged=!0;var D=e.findNearestElement(r[0],r[1],!0,!0);e.touchData.cxtOver&&D===e.touchData.cxtOver||(e.touchData.cxtOver&&e.touchData.cxtOver.emit({originalEvent:t,type:"cxtdragout",position:{x:r[0],y:r[1]}}),e.touchData.cxtOver=D,D&&D.emit({originalEvent:t,type:"cxtdragover",position:{x:r[0],y:r[1]}}))}else if(i&&t.touches[2]&&V.boxSelectionEnabled())t.preventDefault(),e.data.bgActivePosistion=void 0,this.lastThreeTouch=+new Date,e.touchData.selecting||V.emit({originalEvent:t,type:"boxstart",position:{x:r[0],y:r[1]}}),e.touchData.selecting=!0,e.touchData.didSelect=!0,n[4]=1,n&&0!==n.length&&void 0!==n[0]?(n[2]=(r[0]+r[2]+r[4])/3,n[3]=(r[1]+r[3]+r[5])/3):(n[0]=(r[0]+r[2]+r[4])/3,n[1]=(r[1]+r[3]+r[5])/3,n[2]=(r[0]+r[2]+r[4])/3+1,n[3]=(r[1]+r[3]+r[5])/3+1),e.redrawHint("select",!0),e.redraw();else if(i&&t.touches[1]&&!e.touchData.didSelect&&V.zoomingEnabled()&&V.panningEnabled()&&V.userZoomingEnabled()&&V.userPanningEnabled()){if(t.preventDefault(),e.data.bgActivePosistion=void 0,e.redrawHint("select",!0),J=e.dragData.touchDragEles){e.redrawHint("drag",!0);for(var N=0;N0&&!e.hoverData.draggingEles&&!e.swipePanning&&null!=e.data.bgActivePosistion&&(e.data.bgActivePosistion=void 0,e.redrawHint("select",!0),e.redraw())}},!1),e.registerBinding(window,"touchcancel",D=function(t){var C=e.touchData.start;e.touchData.capture=!1,C&&C.unactivate()}),e.registerBinding(window,"touchend",N=function(i){var H=e.touchData.start;if(e.touchData.capture){0===i.touches.length&&(e.touchData.capture=!1),i.preventDefault();var n=e.selection;e.swipePanning=!1,e.hoverData.draggingEles=!1;var V,r=e.cy,L=r.zoom(),o=e.touchData.now,M=e.touchData.earlier;if(i.touches[0]){var s=e.projectIntoViewport(i.touches[0].clientX,i.touches[0].clientY);o[0]=s[0],o[1]=s[1]}if(i.touches[1]){s=e.projectIntoViewport(i.touches[1].clientX,i.touches[1].clientY);o[2]=s[0],o[3]=s[1]}if(i.touches[2]){s=e.projectIntoViewport(i.touches[2].clientX,i.touches[2].clientY);o[4]=s[0],o[5]=s[1]}if(H&&H.unactivate(),e.touchData.cxt){if(V={originalEvent:i,type:"cxttapend",position:{x:o[0],y:o[1]}},H?H.emit(V):r.emit(V),!e.touchData.cxtDragged){var l={originalEvent:i,type:"cxttap",position:{x:o[0],y:o[1]}};H?H.emit(l):r.emit(l)}return e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxt=!1,e.touchData.start=null,void e.redraw()}if(!i.touches[2]&&r.boxSelectionEnabled()&&e.touchData.selecting){e.touchData.selecting=!1;var d=r.collection(e.getAllInBox(n[0],n[1],n[2],n[3]));n[0]=void 0,n[1]=void 0,n[2]=void 0,n[3]=void 0,n[4]=0,e.redrawHint("select",!0),r.emit({type:"boxend",originalEvent:i,position:{x:o[0],y:o[1]}});d.emit("box").stdFilter((function(e){return e.selectable()&&!e.selected()})).select().emit("boxselect"),d.nonempty()&&e.redrawHint("eles",!0),e.redraw()}if(null!=H&&H.unactivate(),i.touches[2])e.data.bgActivePosistion=void 0,e.redrawHint("select",!0);else if(i.touches[1]);else if(i.touches[0]);else if(!i.touches[0]){e.data.bgActivePosistion=void 0,e.redrawHint("select",!0);var u=e.dragData.touchDragEles;if(null!=H){var A=H._private.grabbed;a(u),e.redrawHint("drag",!0),e.redrawHint("eles",!0),A&&(H.emit("freeon"),u.emit("free"),e.dragData.didDrag&&(H.emit("dragfreeon"),u.emit("dragfree"))),C(H,["touchend","tapend","vmouseup","tapdragout"],i,{x:o[0],y:o[1]}),H.unactivate(),e.touchData.start=null}else{var c=e.findNearestElement(o[0],o[1],!0,!0);C(c,["touchend","tapend","vmouseup","tapdragout"],i,{x:o[0],y:o[1]})}var h=e.touchData.startPosition[0]-o[0],m=h*h,f=e.touchData.startPosition[1]-o[1],p=(m+f*f)*L*L;e.touchData.singleTouchMoved||(H||r.$(":selected").unselect(["tapunselect"]),C(H,["tap","vclick"],i,{x:o[0],y:o[1]}),R=!1,i.timeStamp-I<=r.multiClickDebounceTime()?(F&&clearTimeout(F),R=!0,I=null,C(H,["dbltap","vdblclick"],i,{x:o[0],y:o[1]})):(F=setTimeout((function(){R||C(H,["onetap","voneclick"],i,{x:o[0],y:o[1]})}),r.multiClickDebounceTime()),I=i.timeStamp)),null!=H&&!e.dragData.didDrag&&H._private.selectable&&p2){for(var w=[o[0],o[1]],x=Math.pow(w[0]-e,2)+Math.pow(w[1]-t,2),O=1;O0)return u[0]}return null},s=Object.keys(a),l=0;l0?L:GC(H,n,e,t,C,i,V)},checkPoint:function(e,t,C,i,H,n,V){var r=Li(i,H),L=2*r;if(qC(e,t,this.points,n,V,i,H-L,[0,-1],C))return!0;if(qC(e,t,this.points,n,V,i-L,H,[0,-1],C))return!0;var o=i/2+2*C,a=H/2+2*C;return!!XC(e,t,[n-o,V-a,n-o,V,n+o,V,n+o,V-a])||(!!JC(e,t,L,L,n+i/2-r,V+H/2-r,C)||!!JC(e,t,L,L,n-i/2+r,V+H/2-r,C))}}},_L.registerNodeShapes=function(){var e=this.nodeShapes={},t=this;this.generateEllipse(),this.generatePolygon("triangle",ni(3,0)),this.generateRoundPolygon("round-triangle",ni(3,0)),this.generatePolygon("rectangle",ni(4,0)),e.square=e.rectangle,this.generateRoundRectangle(),this.generateCutRectangle(),this.generateBarrel(),this.generateBottomRoundrectangle();var C=[0,1,1,0,0,-1,-1,0];this.generatePolygon("diamond",C),this.generateRoundPolygon("round-diamond",C),this.generatePolygon("pentagon",ni(5,0)),this.generateRoundPolygon("round-pentagon",ni(5,0)),this.generatePolygon("hexagon",ni(6,0)),this.generateRoundPolygon("round-hexagon",ni(6,0)),this.generatePolygon("heptagon",ni(7,0)),this.generateRoundPolygon("round-heptagon",ni(7,0)),this.generatePolygon("octagon",ni(8,0)),this.generateRoundPolygon("round-octagon",ni(8,0));var i=new Array(20),H=ri(5,0),n=ri(5,Math.PI/5),V=.5*(3-Math.sqrt(5));V*=1.57;for(var r=0;r=e.deqFastCost*u)break}else if(H){if(l>=e.deqCost*L||l>=e.deqAvgCost*r)break}else if(d>=16.666666666666668*e.deqNoDrawCost)break;var A=e.deq(t,M,a);if(!(A.length>0))break;for(var c=0;c0&&(e.onDeqd(t,o),!H&&e.shouldRedraw(t,o,M,a)&&i())}),H(t))}}},IL=function(){function e(t){var C=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Gt;ze(this,e),this.idsByKey=new nC,this.keyForId=new nC,this.cachesByLvl=new nC,this.lvls=[],this.getKey=t,this.doesEleInvalidateKey=C}return Ge(e,[{key:"getIdsFor",value:function(e){null==e&&Ut("Can not get id list for null key");var t=this.idsByKey,C=this.idsByKey.get(e);return C||(C=new rC,t.set(e,C)),C}},{key:"addIdForKey",value:function(e,t){null!=e&&this.getIdsFor(e).add(t)}},{key:"deleteIdForKey",value:function(e,t){null!=e&&this.getIdsFor(e).delete(t)}},{key:"getNumberOfIdsForKey",value:function(e){return null==e?0:this.getIdsFor(e).size}},{key:"updateKeyMappingFor",value:function(e){var t=e.id(),C=this.keyForId.get(t),i=this.getKey(e);this.deleteIdForKey(C,t),this.addIdForKey(i,t),this.keyForId.set(t,i)}},{key:"deleteKeyMappingFor",value:function(e){var t=e.id(),C=this.keyForId.get(t);this.deleteIdForKey(C,t),this.keyForId.delete(t)}},{key:"keyHasChangedFor",value:function(e){var t=e.id();return this.keyForId.get(t)!==this.getKey(e)}},{key:"isInvalid",value:function(e){return this.keyHasChangedFor(e)||this.doesEleInvalidateKey(e)}},{key:"getCachesAt",value:function(e){var t=this.cachesByLvl,C=this.lvls,i=t.get(e);return i||(i=new nC,t.set(e,i),C.push(e)),i}},{key:"getCache",value:function(e,t){return this.getCachesAt(t).get(e)}},{key:"get",value:function(e,t){var C=this.getKey(e),i=this.getCache(C,t);return null!=i&&this.updateKeyMappingFor(e),i}},{key:"getForCachedKey",value:function(e,t){var C=this.keyForId.get(e.id());return this.getCache(C,t)}},{key:"hasCache",value:function(e,t){return this.getCachesAt(t).has(e)}},{key:"has",value:function(e,t){var C=this.getKey(e);return this.hasCache(C,t)}},{key:"setCache",value:function(e,t,C){C.key=e,this.getCachesAt(t).set(e,C)}},{key:"set",value:function(e,t,C){var i=this.getKey(e);this.setCache(i,t,C),this.updateKeyMappingFor(e)}},{key:"deleteCache",value:function(e,t){this.getCachesAt(t).delete(e)}},{key:"delete",value:function(e,t){var C=this.getKey(e);this.deleteCache(C,t)}},{key:"invalidateKey",value:function(e){var t=this;this.lvls.forEach((function(C){return t.deleteCache(e,C)}))}},{key:"invalidate",value:function(e){var t=e.id(),C=this.keyForId.get(t);this.deleteKeyMappingFor(e);var i=this.doesEleInvalidateKey(e);return i&&this.invalidateKey(C),i||0===this.getNumberOfIdsForKey(C)}}]),e}(),zL={dequeue:"dequeue",downscale:"downscale",highQuality:"highQuality"},jL=eC({getKey:null,doesEleInvalidateKey:Gt,drawElement:null,getBoundingBox:null,getRotationPoint:null,getRotationOffset:null,isVisible:jt,allowEdgeTxrCaching:!0,allowParentTxrCaching:!0}),GL=function(e,t){var C=this;C.renderer=e,C.onDequeues=[];var i=jL(t);ft(C,i),C.lookup=new IL(i.getKey,i.doesEleInvalidateKey),C.setupDequeueing()},WL=GL.prototype;WL.reasons=zL,WL.getTextureQueue=function(e){var t=this;return t.eleImgCaches=t.eleImgCaches||{},t.eleImgCaches[e]=t.eleImgCaches[e]||[]},WL.getRetiredTextureQueue=function(e){var t=this.eleImgCaches.retired=this.eleImgCaches.retired||{};return t[e]=t[e]||[]},WL.getElementQueue=function(){return this.eleCacheQueue=this.eleCacheQueue||new Fe((function(e,t){return t.reqs-e.reqs}))},WL.getElementKeyToQueue=function(){return this.eleKeyToCacheQueue=this.eleKeyToCacheQueue||{}},WL.getElement=function(e,t,C,i,H){var n=this,V=this.renderer,r=V.cy.zoom(),L=this.lookup;if(!t||0===t.w||0===t.h||isNaN(t.w)||isNaN(t.h)||!e.visible()||e.removed())return null;if(!n.allowEdgeTxrCaching&&e.isEdge()||!n.allowParentTxrCaching&&e.isParent())return null;if(null==i&&(i=Math.ceil(wC(r*C))),i<-4)i=-4;else if(r>=7.99||i>3)return null;var o=Math.pow(2,i),a=t.h*o,M=t.w*o,s=V.eleTextBiggerThanMin(e,o);if(!this.isVisible(e,s))return null;var l,d=L.get(e,i);if(d&&d.invalidated&&(d.invalidated=!1,d.texture.invalidatedWidth-=d.width),d)return d;if(l=a<=25?25:a<=50?50:50*Math.ceil(a/50),a>1024||M>1024)return null;var u=n.getTextureQueue(l),A=u[u.length-2],c=function(){return n.recycleTexture(l,M)||n.addTexture(l,M)};A||(A=u[u.length-1]),A||(A=c()),A.width-A.usedWidthi;b--)Z=n.getElement(e,t,C,b,zL.downscale);S()}else{var w;if(!f&&!p&&!g)for(var x=i-1;x>=-4;x--){var O=L.get(e,x);if(O){w=O;break}}if(m(w))return n.queueElement(e,i),w;A.context.translate(A.usedWidth,0),A.context.scale(o,o),this.drawElement(A.context,e,t,s,!1),A.context.scale(1/o,1/o),A.context.translate(-A.usedWidth,0)}return d={x:A.usedWidth,texture:A,level:i,scale:o,width:M,height:a,scaledLabelShown:s},A.usedWidth+=Math.ceil(M+8),A.eleCaches.push(d),L.set(e,i,d),n.checkTextureFullness(A),d},WL.invalidateElements=function(e){for(var t=0;t=.2*e.width&&this.retireTexture(e)},WL.checkTextureFullness=function(e){var t=this.getTextureQueue(e.height);e.usedWidth/e.width>.8&&e.fullnessChecks>=10?tC(t,e):e.fullnessChecks++},WL.retireTexture=function(e){var t=e.height,C=this.getTextureQueue(t),i=this.lookup;tC(C,e),e.retired=!0;for(var H=e.eleCaches,n=0;n=t)return n.retired=!1,n.usedWidth=0,n.invalidatedWidth=0,n.fullnessChecks=0,CC(n.eleCaches),n.context.setTransform(1,0,0,1,0,0),n.context.clearRect(0,0,n.width,n.height),tC(i,n),C.push(n),n}},WL.queueElement=function(e,t){var C=this.getElementQueue(),i=this.getElementKeyToQueue(),H=this.getKey(e),n=i[H];if(n)n.level=Math.max(n.level,t),n.eles.merge(e),n.reqs++,C.updateItem(n);else{var V={eles:e.spawn().merge(e),level:t,reqs:1,key:H};C.push(V),i[H]=V}},WL.dequeue=function(e){for(var t=this,C=t.getElementQueue(),i=t.getElementKeyToQueue(),H=[],n=t.lookup,V=0;V<1&&C.size()>0;V++){var r=C.pop(),L=r.key,o=r.eles[0],a=n.hasCache(o,r.level);if(i[L]=null,!a){H.push(r);var M=t.getBoundingBox(o);t.getElement(o,M,e,r.level,zL.dequeue)}}return H},WL.removeFromQueue=function(e){var t=this.getElementQueue(),C=this.getElementKeyToQueue(),i=this.getKey(e),H=C[i];null!=H&&(1===H.eles.length?(H.reqs=zt,t.updateItem(H),t.pop(),C[i]=null):H.eles.unmerge(e))},WL.onDequeue=function(e){this.onDequeues.push(e)},WL.offDequeue=function(e){tC(this.onDequeues,e)},WL.setupDequeueing=FL({deqRedrawThreshold:100,deqCost:.15,deqAvgCost:.1,deqNoDrawCost:.9,deqFastCost:.9,deq:function(e,t,C){return e.dequeue(t,C)},onDeqd:function(e,t){for(var C=0;C=3.99||C>2)return null;i.validateLayersElesOrdering(C,e);var V,r,L=i.layersByLevel,o=Math.pow(2,C),a=L[C]=L[C]||[];if(i.levelIsComplete(C,e))return a;!function(){var t=function(t){if(i.validateLayersElesOrdering(t,e),i.levelIsComplete(t,e))return r=L[t],!0},H=function(e){if(!r)for(var i=C+e;-4<=i&&i<=2&&!t(i);i+=e);};H(1),H(-1);for(var n=a.length-1;n>=0;n--){var V=a[n];V.invalid&&tC(a,V)}}();var M=function(t){var H=(t=t||{}).after;if(function(){if(!V){V=BC();for(var t=0;t16e6)return null;var n=i.makeLayer(V,C);if(null!=H){var r=a.indexOf(H)+1;a.splice(r,0,n)}else(void 0===t.insert||t.insert)&&a.unshift(n);return n};if(i.skipping&&!n)return null;for(var s=null,l=e.length/1,d=!n,u=0;u=l||!jC(s.bb,A.boundingBox()))&&!(s=M({insert:!0,after:s})))return null;r||d?i.queueLayer(s,A):i.drawEleInLayer(s,A,C,t),s.eles.push(A),h[C]=s}}return r||(d?null:a)},UL.getEleLevelForLayerLevel=function(e,t){return e},UL.drawEleInLayer=function(e,t,C,i){var H=this.renderer,n=e.context,V=t.boundingBox();0!==V.w&&0!==V.h&&t.visible()&&(C=this.getEleLevelForLayerLevel(C,i),H.setImgSmoothing(n,!1),H.drawCachedElement(n,t,null,null,C,true),H.setImgSmoothing(n,!0))},UL.levelIsComplete=function(e,t){var C=this.layersByLevel[e];if(!C||0===C.length)return!1;for(var i=0,H=0;H0)return!1;if(n.invalid)return!1;i+=n.eles.length}return i===t.length},UL.validateLayersElesOrdering=function(e,t){var C=this.layersByLevel[e];if(C)for(var i=0;i0){e=!0;break}}return e},UL.invalidateElements=function(e){var t=this;0!==e.length&&(t.lastInvalidationTime=xt(),0!==e.length&&t.haveLayers()&&t.updateElementsInLayers(e,(function(e,C,i){t.invalidateLayer(e)})))},UL.invalidateLayer=function(e){if(this.lastInvalidationTime=xt(),!e.invalid){var t=e.level,C=e.eles,i=this.layersByLevel[t];tC(i,e),e.elesQueue=[],e.invalid=!0,e.replacement&&(e.replacement.invalid=!0);for(var H=0;H3&&void 0!==arguments[3])||arguments[3],H=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],n=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],V=this,r=t._private.rscratch;if((!n||t.visible())&&!r.badLine&&null!=r.allpts&&!isNaN(r.allpts[0])){var L;C&&(L=C,e.translate(-L.x1,-L.y1));var o=n?t.pstyle("opacity").value:1,a=n?t.pstyle("line-opacity").value:1,M=t.pstyle("curve-style").value,s=t.pstyle("line-style").value,l=t.pstyle("width").pfValue,d=t.pstyle("line-cap").value,u=o*a,A=o*a,c=function(){var C=arguments.length>0&&void 0!==arguments[0]?arguments[0]:u;"straight-triangle"===M?(V.eleStrokeStyle(e,t,C),V.drawEdgeTrianglePath(t,e,r.allpts)):(e.lineWidth=l,e.lineCap=d,V.eleStrokeStyle(e,t,C),V.drawEdgePath(t,e,r.allpts,s),e.lineCap="butt")},h=function(){H&&V.drawEdgeOverlay(e,t)},m=function(){H&&V.drawEdgeUnderlay(e,t)},f=function(){var C=arguments.length>0&&void 0!==arguments[0]?arguments[0]:A;V.drawArrowheads(e,t,C)},p=function(){V.drawElementText(e,t,null,i)};e.lineJoin="round";var g="yes"===t.pstyle("ghost").value;if(g){var v=t.pstyle("ghost-offset-x").pfValue,y=t.pstyle("ghost-offset-y").pfValue,Z=t.pstyle("ghost-opacity").value,S=u*Z;e.translate(v,y),c(S),f(S),e.translate(-v,-y)}m(),c(),f(),h(),p(),C&&e.translate(L.x1,L.y1)}}},Mo=function(e){if(!["overlay","underlay"].includes(e))throw new Error("Invalid state");return function(t,C){if(C.visible()){var i=C.pstyle("".concat(e,"-opacity")).value;if(0!==i){var H=this,n=H.usePaths(),V=C._private.rscratch,r=2*C.pstyle("".concat(e,"-padding")).pfValue,L=C.pstyle("".concat(e,"-color")).value;t.lineWidth=r,"self"!==V.edgeType||n?t.lineCap="round":t.lineCap="butt",H.colorStrokeStyle(t,L[0],L[1],L[2],i),H.drawEdgePath(C,t,V.allpts,"solid")}}}};ao.drawEdgeOverlay=Mo("overlay"),ao.drawEdgeUnderlay=Mo("underlay"),ao.drawEdgePath=function(e,t,C,i){var H,n=e._private.rscratch,V=t,r=!1,L=this.usePaths(),o=e.pstyle("line-dash-pattern").pfValue,a=e.pstyle("line-dash-offset").pfValue;if(L){var M=C.join("$");n.pathCacheKey&&n.pathCacheKey===M?(H=t=n.pathCache,r=!0):(H=t=new Path2D,n.pathCacheKey=M,n.pathCache=H)}if(V.setLineDash)switch(i){case"dotted":V.setLineDash([1,1]);break;case"dashed":V.setLineDash(o),V.lineDashOffset=a;break;case"solid":V.setLineDash([])}if(!r&&!n.badLine)switch(t.beginPath&&t.beginPath(),t.moveTo(C[0],C[1]),n.edgeType){case"bezier":case"self":case"compound":case"multibezier":for(var s=2;s+35&&void 0!==arguments[5]?arguments[5]:5;e.beginPath(),e.moveTo(t+n,C),e.lineTo(t+i-n,C),e.quadraticCurveTo(t+i,C,t+i,C+n),e.lineTo(t+i,C+H-n),e.quadraticCurveTo(t+i,C+H,t+i-n,C+H),e.lineTo(t+n,C+H),e.quadraticCurveTo(t,C+H,t,C+H-n),e.lineTo(t,C+n),e.quadraticCurveTo(t,C,t+n,C),e.closePath(),e.fill()}lo.eleTextBiggerThanMin=function(e,t){if(!t){var C=e.cy().zoom(),i=this.getPixelRatio(),H=Math.ceil(wC(C*i));t=Math.pow(2,H)}return!(e.pstyle("font-size").pfValue*t5&&void 0!==arguments[5])||arguments[5],V=this;if(null==i){if(n&&!V.eleTextBiggerThanMin(t))return}else if(!1===i)return;if(t.isNode()){var r=t.pstyle("label");if(!r||!r.value)return;var L=V.getLabelJustification(t);e.textAlign=L,e.textBaseline="bottom"}else{var o=t.element()._private.rscratch.badLine,a=t.pstyle("label"),M=t.pstyle("source-label"),s=t.pstyle("target-label");if(o||(!a||!a.value)&&(!M||!M.value)&&(!s||!s.value))return;e.textAlign="center",e.textBaseline="bottom"}var l,d=!C;C&&(l=C,e.translate(-l.x1,-l.y1)),null==H?(V.drawText(e,t,null,d,n),t.isEdge()&&(V.drawText(e,t,"source",d,n),V.drawText(e,t,"target",d,n))):V.drawText(e,t,H,d,n),C&&e.translate(l.x1,l.y1)},lo.getFontCache=function(e){var t;this.fontCaches=this.fontCaches||[];for(var C=0;C2&&void 0!==arguments[2])||arguments[2],i=t.pstyle("font-style").strValue,H=t.pstyle("font-size").pfValue+"px",n=t.pstyle("font-family").strValue,V=t.pstyle("font-weight").strValue,r=C?t.effectiveOpacity()*t.pstyle("text-opacity").value:1,L=t.pstyle("text-outline-opacity").value*r,o=t.pstyle("color").value,a=t.pstyle("text-outline-color").value;e.font=i+" "+V+" "+H+" "+n,e.lineJoin="round",this.colorFillStyle(e,o[0],o[1],o[2],r),this.colorStrokeStyle(e,a[0],a[1],a[2],L)},lo.getTextAngle=function(e,t){var C=e._private.rscratch,i=t?t+"-":"",H=e.pstyle(i+"text-rotation"),n=iC(C,"labelAngle",t);return"autorotate"===H.strValue?e.isEdge()?n:0:"none"===H.strValue?0:H.pfValue},lo.drawText=function(e,t,C){var i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],H=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],n=t._private,V=n.rscratch,r=H?t.effectiveOpacity():1;if(!H||0!==r&&0!==t.pstyle("text-opacity").value){"main"===C&&(C=null);var L,o,a=iC(V,"labelX",C),M=iC(V,"labelY",C),s=this.getLabelText(t,C);if(null!=s&&""!==s&&!isNaN(a)&&!isNaN(M)){this.setupTextStyle(e,t,H);var l,d=C?C+"-":"",u=iC(V,"labelWidth",C),A=iC(V,"labelHeight",C),c=t.pstyle(d+"text-margin-x").pfValue,h=t.pstyle(d+"text-margin-y").pfValue,m=t.isEdge(),f=t.pstyle("text-halign").value,p=t.pstyle("text-valign").value;switch(m&&(f="center",p="center"),a+=c,M+=h,0!==(l=i?this.getTextAngle(t,C):0)&&(L=a,o=M,e.translate(L,o),e.rotate(l),a=0,M=0),p){case"top":break;case"center":M+=A/2;break;case"bottom":M+=A}var g=t.pstyle("text-background-opacity").value,v=t.pstyle("text-border-opacity").value,y=t.pstyle("text-border-width").pfValue,Z=t.pstyle("text-background-padding").pfValue;if(g>0||y>0&&v>0){var S=a-Z;switch(f){case"left":S-=u;break;case"center":S-=u/2}var b=M-A-Z,w=u+2*Z,x=A+2*Z;if(g>0){var O=e.fillStyle,k=t.pstyle("text-background-color").value;e.fillStyle="rgba("+k[0]+","+k[1]+","+k[2]+","+g*r+")";var E=t.pstyle("text-background-shape").strValue;0===E.indexOf("round")?uo(e,S,b,w,x,2):e.fillRect(S,b,w,x),e.fillStyle=O}if(y>0&&v>0){var P=e.strokeStyle,T=e.lineWidth,_=t.pstyle("text-border-color").value,B=t.pstyle("text-border-style").value;if(e.strokeStyle="rgba("+_[0]+","+_[1]+","+_[2]+","+v*r+")",e.lineWidth=y,e.setLineDash)switch(B){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"double":e.lineWidth=y/4,e.setLineDash([]);break;case"solid":e.setLineDash([])}if(e.strokeRect(S,b,w,x),"double"===B){var D=y/2;e.strokeRect(S+D,b+D,w-2*D,x-2*D)}e.setLineDash&&e.setLineDash([]),e.lineWidth=T,e.strokeStyle=P}}var N=2*t.pstyle("text-outline-width").pfValue;if(N>0&&(e.lineWidth=N),"wrap"===t.pstyle("text-wrap").value){var R=iC(V,"labelWrapCachedLines",C),F=iC(V,"labelLineHeight",C),I=u/2,z=this.getLabelJustification(t);switch("auto"===z||("left"===f?"left"===z?a+=-u:"center"===z&&(a+=-I):"center"===f?"left"===z?a+=-I:"right"===z&&(a+=I):"right"===f&&("center"===z?a+=I:"right"===z&&(a+=u))),p){case"top":case"center":case"bottom":M-=(R.length-1)*F}for(var j=0;j0&&e.strokeText(R[j],a,M),e.fillText(R[j],a,M),M+=F}else N>0&&e.strokeText(s,a,M),e.fillText(s,a,M);0!==l&&(e.rotate(-l),e.translate(-L,-o))}}};var Ao={drawNode:function(e,t,C){var i,H,n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],V=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],r=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],L=this,o=t._private,a=o.rscratch,M=t.position();if(Ht(M.x)&&Ht(M.y)&&(!r||t.visible())){var s,l,d=r?t.effectiveOpacity():1,u=L.usePaths(),A=!1,c=t.padding();i=t.width()+2*c,H=t.height()+2*c,C&&(l=C,e.translate(-l.x1,-l.y1));for(var h=t.pstyle("background-image"),m=h.value,f=new Array(m.length),p=new Array(m.length),g=0,v=0;v0&&void 0!==arguments[0]?arguments[0]:x;L.eleFillStyle(e,t,C)},T=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:E;L.colorStrokeStyle(e,O[0],O[1],O[2],t)},_=t.pstyle("shape").strValue,B=t.pstyle("shape-polygon-points").pfValue;if(u){e.translate(M.x,M.y);var D=L.nodePathCache=L.nodePathCache||[],N=Dt("polygon"===_?_+","+B.join(","):_,""+H,""+i),R=D[N];null!=R?(s=R,A=!0,a.pathCache=s):(s=new Path2D,D[N]=a.pathCache=s)}var F=function(){if(!A){var C=M;u&&(C={x:0,y:0}),L.nodeShapes[L.getNodeShape(t)].draw(s||e,C.x,C.y,i,H)}u?e.fill(s):e.fill()},I=function(){for(var C=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d,i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],H=o.backgrounding,n=0,V=0;V0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d;L.hasPie(t)&&(L.drawPie(e,t,n),C&&(u||L.nodeShapes[L.getNodeShape(t)].draw(e,M.x,M.y,i,H)))},j=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d,C=(b>0?b:-b)*t,i=b>0?0:255;0!==b&&(L.colorFillStyle(e,i,i,i,C),u?e.fill(s):e.fill())},G=function(){if(w>0){if(e.lineWidth=w,e.lineCap="butt",e.setLineDash)switch(k){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"solid":case"double":e.setLineDash([])}if(u?e.stroke(s):e.stroke(),"double"===k){e.lineWidth=w/3;var t=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",u?e.stroke(s):e.stroke(),e.globalCompositeOperation=t}e.setLineDash&&e.setLineDash([])}},W=function(){V&&L.drawNodeOverlay(e,t,M,i,H)},$=function(){V&&L.drawNodeUnderlay(e,t,M,i,H)},U=function(){L.drawElementText(e,t,null,n)},Y="yes"===t.pstyle("ghost").value;if(Y){var X=t.pstyle("ghost-offset-x").pfValue,q=t.pstyle("ghost-offset-y").pfValue,Q=t.pstyle("ghost-opacity").value,K=Q*d;e.translate(X,q),P(Q*x),F(),I(K,!0),T(Q*E),G(),z(0!==b||0!==w),I(K,!1),j(K),e.translate(-X,-q)}u&&e.translate(-M.x,-M.y),$(),u&&e.translate(M.x,M.y),P(),F(),I(d,!0),T(),G(),z(0!==b||0!==w),I(d,!1),j(),u&&e.translate(-M.x,-M.y),U(),W(),C&&e.translate(l.x1,l.y1)}}},co=function(e){if(!["overlay","underlay"].includes(e))throw new Error("Invalid state");return function(t,C,i,H,n){if(C.visible()){var V=C.pstyle("".concat(e,"-padding")).pfValue,r=C.pstyle("".concat(e,"-opacity")).value,L=C.pstyle("".concat(e,"-color")).value,o=C.pstyle("".concat(e,"-shape")).value;if(r>0){if(i=i||C.position(),null==H||null==n){var a=C.padding();H=C.width()+2*a,n=C.height()+2*a}this.colorFillStyle(t,L[0],L[1],L[2],r),this.nodeShapes[o].draw(t,i.x,i.y,H+2*V,n+2*V),t.fill()}}}};Ao.drawNodeOverlay=co("overlay"),Ao.drawNodeUnderlay=co("underlay"),Ao.hasPie=function(e){return(e=e[0])._private.hasPie},Ao.drawPie=function(e,t,C,i){t=t[0],i=i||t.position();var H=t.cy().style(),n=t.pstyle("pie-size"),V=i.x,r=i.y,L=t.width(),o=t.height(),a=Math.min(L,o)/2,M=0;this.usePaths()&&(V=0,r=0),"%"===n.units?a*=n.pfValue:void 0!==n.pfValue&&(a=n.pfValue/2);for(var s=1;s<=H.pieBackgroundN;s++){var l=t.pstyle("pie-"+s+"-background-size").value,d=t.pstyle("pie-"+s+"-background-color").value,u=t.pstyle("pie-"+s+"-background-opacity").value*C,A=l/100;A+M>1&&(A=1-M);var c=1.5*Math.PI+2*Math.PI*M,h=c+2*Math.PI*A;0===l||M>=1||M+A>1||(e.beginPath(),e.moveTo(V,r),e.arc(V,r,a,c,h),e.closePath(),this.colorFillStyle(e,d[0],d[1],d[2],u),e.fill(),M+=A)}};var ho={};ho.getPixelRatio=function(){var e=this.data.contexts[0];if(null!=this.forcedPixelRatio)return this.forcedPixelRatio;var t=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return(window.devicePixelRatio||1)/t},ho.paintCache=function(e){for(var t,C=this.paintCaches=this.paintCaches||[],i=!0,H=0;HV.minMbLowQualFrames&&(V.motionBlurPxRatio=V.mbPxRBlurry)),V.clearingMotionBlur&&(V.motionBlurPxRatio=1),V.textureDrawLastFrame&&!M&&(a[V.NODE]=!0,a[V.SELECT_BOX]=!0);var h=L.style(),m=L.zoom(),f=void 0!==H?H:m,p=L.pan(),g={x:p.x,y:p.y},v={zoom:m,pan:{x:p.x,y:p.y}},y=V.prevViewport;void 0===y||v.zoom!==y.zoom||v.pan.x!==y.pan.x||v.pan.y!==y.pan.y||u&&!d||(V.motionBlurPxRatio=1),n&&(g=n),f*=r,g.x*=r,g.y*=r;var Z=V.getCachedZSortedEles();function S(e,t,C,i,H){var n=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",V.colorFillStyle(e,255,255,255,V.motionBlurTransparency),e.fillRect(t,C,i,H),e.globalCompositeOperation=n}function b(e,i){var r,L,a,M;V.clearingMotionBlur||e!==o.bufferContexts[V.MOTIONBLUR_BUFFER_NODE]&&e!==o.bufferContexts[V.MOTIONBLUR_BUFFER_DRAG]?(r=g,L=f,a=V.canvasWidth,M=V.canvasHeight):(r={x:p.x*l,y:p.y*l},L=m*l,a=V.canvasWidth*l,M=V.canvasHeight*l),e.setTransform(1,0,0,1,0,0),"motionBlur"===i?S(e,0,0,a,M):t||void 0!==i&&!i||e.clearRect(0,0,a,M),C||(e.translate(r.x,r.y),e.scale(L,L)),n&&e.translate(n.x,n.y),H&&e.scale(H,H)}if(M||(V.textureDrawLastFrame=!1),M){if(V.textureDrawLastFrame=!0,!V.textureCache){V.textureCache={},V.textureCache.bb=L.mutableElements().boundingBox(),V.textureCache.texture=V.data.bufferCanvases[V.TEXTURE_BUFFER];var w=V.data.bufferContexts[V.TEXTURE_BUFFER];w.setTransform(1,0,0,1,0,0),w.clearRect(0,0,V.canvasWidth*V.textureMult,V.canvasHeight*V.textureMult),V.render({forcedContext:w,drawOnlyNodeLayer:!0,forcedPxRatio:r*V.textureMult}),(v=V.textureCache.viewport={zoom:L.zoom(),pan:L.pan(),width:V.canvasWidth,height:V.canvasHeight}).mpan={x:(0-v.pan.x)/v.zoom,y:(0-v.pan.y)/v.zoom}}a[V.DRAG]=!1,a[V.NODE]=!1;var x=o.contexts[V.NODE],O=V.textureCache.texture;v=V.textureCache.viewport;x.setTransform(1,0,0,1,0,0),s?S(x,0,0,v.width,v.height):x.clearRect(0,0,v.width,v.height);var k=h.core("outside-texture-bg-color").value,E=h.core("outside-texture-bg-opacity").value;V.colorFillStyle(x,k[0],k[1],k[2],E),x.fillRect(0,0,v.width,v.height);m=L.zoom();b(x,!1),x.clearRect(v.mpan.x,v.mpan.y,v.width/v.zoom/r,v.height/v.zoom/r),x.drawImage(O,v.mpan.x,v.mpan.y,v.width/v.zoom/r,v.height/v.zoom/r)}else V.textureOnViewport&&!t&&(V.textureCache=null);var P=L.extent(),T=V.pinching||V.hoverData.dragging||V.swipePanning||V.data.wheelZooming||V.hoverData.draggingEles||V.cy.animated(),_=V.hideEdgesOnViewport&&T,B=[];if(B[V.NODE]=!a[V.NODE]&&s&&!V.clearedForMotionBlur[V.NODE]||V.clearingMotionBlur,B[V.NODE]&&(V.clearedForMotionBlur[V.NODE]=!0),B[V.DRAG]=!a[V.DRAG]&&s&&!V.clearedForMotionBlur[V.DRAG]||V.clearingMotionBlur,B[V.DRAG]&&(V.clearedForMotionBlur[V.DRAG]=!0),a[V.NODE]||C||i||B[V.NODE]){var D=s&&!B[V.NODE]&&1!==l;b(x=t||(D?V.data.bufferContexts[V.MOTIONBLUR_BUFFER_NODE]:o.contexts[V.NODE]),s&&!D?"motionBlur":void 0),_?V.drawCachedNodes(x,Z.nondrag,r,P):V.drawLayeredElements(x,Z.nondrag,r,P),V.debug&&V.drawDebugPoints(x,Z.nondrag),C||s||(a[V.NODE]=!1)}if(!i&&(a[V.DRAG]||C||B[V.DRAG])){D=s&&!B[V.DRAG]&&1!==l;b(x=t||(D?V.data.bufferContexts[V.MOTIONBLUR_BUFFER_DRAG]:o.contexts[V.DRAG]),s&&!D?"motionBlur":void 0),_?V.drawCachedNodes(x,Z.drag,r,P):V.drawCachedElements(x,Z.drag,r,P),V.debug&&V.drawDebugPoints(x,Z.drag),C||s||(a[V.DRAG]=!1)}if(V.showFps||!i&&a[V.SELECT_BOX]&&!C){if(b(x=t||o.contexts[V.SELECT_BOX]),1==V.selection[4]&&(V.hoverData.selecting||V.touchData.selecting)){m=V.cy.zoom();var N=h.core("selection-box-border-width").value/m;x.lineWidth=N,x.fillStyle="rgba("+h.core("selection-box-color").value[0]+","+h.core("selection-box-color").value[1]+","+h.core("selection-box-color").value[2]+","+h.core("selection-box-opacity").value+")",x.fillRect(V.selection[0],V.selection[1],V.selection[2]-V.selection[0],V.selection[3]-V.selection[1]),N>0&&(x.strokeStyle="rgba("+h.core("selection-box-border-color").value[0]+","+h.core("selection-box-border-color").value[1]+","+h.core("selection-box-border-color").value[2]+","+h.core("selection-box-opacity").value+")",x.strokeRect(V.selection[0],V.selection[1],V.selection[2]-V.selection[0],V.selection[3]-V.selection[1]))}if(o.bgActivePosistion&&!V.hoverData.selecting){m=V.cy.zoom();var R=o.bgActivePosistion;x.fillStyle="rgba("+h.core("active-bg-color").value[0]+","+h.core("active-bg-color").value[1]+","+h.core("active-bg-color").value[2]+","+h.core("active-bg-opacity").value+")",x.beginPath(),x.arc(R.x,R.y,h.core("active-bg-size").pfValue/m,0,2*Math.PI),x.fill()}var F=V.lastRedrawTime;if(V.showFps&&F){F=Math.round(F);var I=Math.round(1e3/F);x.setTransform(1,0,0,1,0,0),x.fillStyle="rgba(255, 0, 0, 0.75)",x.strokeStyle="rgba(255, 0, 0, 0.75)",x.lineWidth=1,x.fillText("1 frame = "+F+" ms = "+I+" fps",0,20);x.strokeRect(0,30,250,20),x.fillRect(0,30,250*Math.min(I/60,1),20)}C||(a[V.SELECT_BOX]=!1)}if(s&&1!==l){var z=o.contexts[V.NODE],j=V.data.bufferCanvases[V.MOTIONBLUR_BUFFER_NODE],G=o.contexts[V.DRAG],W=V.data.bufferCanvases[V.MOTIONBLUR_BUFFER_DRAG],$=function(e,t,C){e.setTransform(1,0,0,1,0,0),C||!c?e.clearRect(0,0,V.canvasWidth,V.canvasHeight):S(e,0,0,V.canvasWidth,V.canvasHeight);var i=l;e.drawImage(t,0,0,V.canvasWidth*i,V.canvasHeight*i,0,0,V.canvasWidth,V.canvasHeight)};(a[V.NODE]||B[V.NODE])&&($(z,j,B[V.NODE]),a[V.NODE]=!1),(a[V.DRAG]||B[V.DRAG])&&($(G,W,B[V.DRAG]),a[V.DRAG]=!1)}V.prevViewport=v,V.clearingMotionBlur&&(V.clearingMotionBlur=!1,V.motionBlurCleared=!0,V.motionBlur=!0),s&&(V.motionBlurTimeout=setTimeout((function(){V.motionBlurTimeout=null,V.clearedForMotionBlur[V.NODE]=!1,V.clearedForMotionBlur[V.DRAG]=!1,V.motionBlur=!1,V.clearingMotionBlur=!M,V.mbFrames=0,a[V.NODE]=!0,a[V.DRAG]=!0,V.redraw()}),100)),t||L.emit("render")};for(var mo={drawPolygonPath:function(e,t,C,i,H,n){var V=i/2,r=H/2;e.beginPath&&e.beginPath(),e.moveTo(t+V*n[0],C+r*n[1]);for(var L=1;L0&&n>0){s.clearRect(0,0,H,n),s.globalCompositeOperation="source-over";var l=this.getCachedZSortedEles();if(e.full)s.translate(-C.x1*L,-C.y1*L),s.scale(L,L),this.drawElements(s,l),s.scale(1/L,1/L),s.translate(C.x1*L,C.y1*L);else{var d=t.pan(),u={x:d.x*L,y:d.y*L};L*=t.zoom(),s.translate(u.x,u.y),s.scale(L,L),this.drawElements(s,l),s.scale(1/L,1/L),s.translate(-u.x,-u.y)}e.bg&&(s.globalCompositeOperation="destination-over",s.fillStyle=e.bg,s.rect(0,0,H,n),s.fill())}return M},So.png=function(e){return wo(e,this.bufferCanvasImage(e),"image/png")},So.jpg=function(e){return wo(e,this.bufferCanvasImage(e),"image/jpeg")};var xo={nodeShapeImpl:function(e,t,C,i,H,n,V){switch(e){case"ellipse":return this.drawEllipsePath(t,C,i,H,n);case"polygon":return this.drawPolygonPath(t,C,i,H,n,V);case"round-polygon":return this.drawRoundPolygonPath(t,C,i,H,n,V);case"roundrectangle":case"round-rectangle":return this.drawRoundRectanglePath(t,C,i,H,n);case"cutrectangle":case"cut-rectangle":return this.drawCutRectanglePath(t,C,i,H,n);case"bottomroundrectangle":case"bottom-round-rectangle":return this.drawBottomRoundRectanglePath(t,C,i,H,n);case"barrel":return this.drawBarrelPath(t,C,i,H,n)}}},Oo=Eo,ko=Eo.prototype;function Eo(e){var t=this;t.data={canvases:new Array(ko.CANVAS_LAYERS),contexts:new Array(ko.CANVAS_LAYERS),canvasNeedsRedraw:new Array(ko.CANVAS_LAYERS),bufferCanvases:new Array(ko.BUFFER_COUNT),bufferContexts:new Array(ko.CANVAS_LAYERS)};var C="-webkit-tap-highlight-color",i="rgba(0,0,0,0)";t.data.canvasContainer=document.createElement("div");var H=t.data.canvasContainer.style;t.data.canvasContainer.style[C]=i,H.position="relative",H.zIndex="0",H.overflow="hidden";var n=e.cy.container();n.appendChild(t.data.canvasContainer),n.style[C]=i;var V={"-webkit-user-select":"none","-moz-user-select":"-moz-none","user-select":"none","-webkit-tap-highlight-color":"rgba(0,0,0,0)","outline-style":"none"};Ye&&Ye.userAgent.match(/msie|trident|edge/i)&&(V["-ms-touch-action"]="none",V["touch-action"]="none");for(var r=0;r\n \n `}const ca={ag_expand:Uo,ag_collapse:$o,ag_select_all:Ma,ag_select_inverse:sa,ag_select_neighbors:la,ag_lock:La,ag_unlock:oa,ag_hide:Qo,ag_unhide:qo,ag_fit:ea,ag_image:ra,ag_workspace:da,ag_local:ta,ag_fdgd:ia,ag_concentric:na,ag_grid:Xo,ag_hierarchy:Ha,ag_file:Ko,ag_filter:Jo,ag_save:Yo,ag_node_list:Ca,ag_style:aa,ag_help:Va};function ha(e){let t,C,i,H,n;return{c(){t=v("button"),C=y("svg"),i=y("path"),x(i,"d",e[0]),E(C,"width","17px"),E(C,"height","17px"),x(C,"viewBox","0 0 24 24"),x(C,"xmlns","http://www.w3.org/2000/svg"),x(t,"type","button"),x(t,"class","juggl-button"),x(t,"aria-label",e[3]),t.disabled=e[2]},m(V,r){f(V,t,r),m(t,C),m(C,i),H||(n=w(t,"click",(function(){u(e[1])&&e[1].apply(this,arguments)})),H=!0)},p(C,[H]){e=C,1&H&&x(i,"d",e[0]),8&H&&x(t,"aria-label",e[3]),4&H&&(t.disabled=e[2])},i:M,o:M,d(e){e&&p(t),H=!1,n()}}}function ma(e,t,C){let{icon:i}=t,{onClick:H}=t,{disabled:n=!1}=t,{title:V}=t;return e.$$set=e=>{"icon"in e&&C(0,i=e.icon),"onClick"in e&&C(1,H=e.onClick),"disabled"in e&&C(2,n=e.disabled),"title"in e&&C(3,V=e.title)},[i,H,n,V]}class fa extends te{constructor(e){super(),ee(this,e,ma,ha,A,{icon:0,onClick:1,disabled:2,title:3})}}class pa extends e.ItemView{constructor(){super(...arguments),this.frame=null}async onOpen(){this.frame=document.createElement("iframe"),this.frame.addClass("juggl-site"),this.frame.setAttr("style","height: 100%; width:100%"),this.frame.setAttr("src","https://juggl.io"),this.frame.setAttr("tabindex","0"),this.containerEl.children[1].appendChild(this.frame)}getDisplayText(){return"Juggl help"}getViewType(){return"juggl-help"}}function ga(e){let t,C;return t=new fa({props:{icon:ca.ag_help,title:"Help",onClick:e[0]}}),{c(){q(t.$$.fragment)},m(e,i){Q(t,e,i),C=!0},p:M,i(e){C||(Y(t.$$.fragment,e),C=!0)},o(e){X(t.$$.fragment,e),C=!1},d(e){K(t,e)}}}function va(e,t,C){let{workspace:i}=t;return e.$$set=e=>{"workspace"in e&&C(1,i=e.workspace)},[function(){let e=i.getLeaf(!0),t=new pa(e);e.open(t)},i]}class ya extends te{constructor(e){super(),ee(this,e,va,ga,A,{workspace:1})}}function Za(e){let t,C,i,H,n,V,r,L,o,a,M,s,l,d,A,c,h,g,y,Z,b,O,k,E,P,T,_,B,D,N,R,F,I,z,j,G,W,$,U,J,ee,te,Ce,ie;return C=new fa({props:{icon:ca.ag_fdgd,onClick:e[2],title:"Force directed layout"}}),H=new fa({props:{icon:ca.ag_concentric,onClick:e[3],title:"Circle layout"}}),V=new fa({props:{icon:ca.ag_grid,onClick:e[4],title:"Grid layout"}}),L=new fa({props:{icon:ca.ag_hierarchy,onClick:e[5],title:"Hierarchical layout"}}),M=new fa({props:{icon:ca.ag_fit,onClick:e[14],title:"Fit view"}}),l=new fa({props:{icon:ca.ag_local,onClick:e[15],title:"Local mode"}}),c=new ya({props:{workspace:e[17]}}),g=new fa({props:{icon:ca.ag_save,onClick:e[16],title:"Manage workspace graphs"}}),b=new fa({props:{icon:ca.ag_expand,onClick:e[6],disabled:e[18],title:"Expand selected nodes (E)"}}),k=new fa({props:{icon:ca.ag_collapse,onClick:e[7],disabled:e[18],title:"Collapse expanded nodes (C)"}}),P=new fa({props:{icon:ca.ag_hide,onClick:e[8],disabled:e[18],title:"Hide selected nodes (H)"}}),B=new fa({props:{icon:ca.ag_select_all,onClick:e[9],title:"Select all nodes (A)"}}),N=new fa({props:{icon:ca.ag_select_inverse,onClick:e[10],disabled:e[18],title:"Invert selection (I)"}}),F=new fa({props:{icon:ca.ag_select_neighbors,onClick:e[11],disabled:e[18],title:"Select neighbors (N)"}}),j=new fa({props:{icon:ca.ag_lock,onClick:e[12],disabled:e[19],title:"Lock selected nodes in place (P)"}}),W=new fa({props:{icon:ca.ag_unlock,onClick:e[13],disabled:e[20],title:"Unlock selected nodes in place (U)"}}),{c(){t=v("div"),q(C.$$.fragment),i=S(),q(H.$$.fragment),n=S(),q(V.$$.fragment),r=S(),q(L.$$.fragment),o=S(),a=v("div"),q(M.$$.fragment),s=S(),q(l.$$.fragment),d=S(),A=v("div"),q(c.$$.fragment),h=S(),q(g.$$.fragment),y=S(),Z=v("div"),q(b.$$.fragment),O=S(),q(k.$$.fragment),E=S(),q(P.$$.fragment),T=S(),_=v("div"),q(B.$$.fragment),D=S(),q(N.$$.fragment),R=S(),q(F.$$.fragment),I=S(),z=v("div"),q(j.$$.fragment),G=S(),q(W.$$.fragment),$=S(),U=v("br"),J=v("label"),J.textContent="Filter: ",ee=v("input"),x(t,"class","cy-toolbar-section"),x(a,"class","cy-toolbar-section"),x(A,"class","cy-toolbar-section"),x(Z,"class","cy-toolbar-section"),x(_,"class","cy-toolbar-section"),x(z,"class","cy-toolbar-section"),x(J,"for","ag-filter"),x(ee,"type","text"),x(ee,"id","ag-filter"),x(ee,"name","ag-filter"),ee.value=e[1]},m(p,v){f(p,t,v),Q(C,t,null),m(t,i),Q(H,t,null),m(t,n),Q(V,t,null),m(t,r),Q(L,t,null),f(p,o,v),f(p,a,v),Q(M,a,null),m(a,s),Q(l,a,null),f(p,d,v),f(p,A,v),Q(c,A,null),m(A,h),Q(g,A,null),f(p,y,v),f(p,Z,v),Q(b,Z,null),m(Z,O),Q(k,Z,null),m(Z,E),Q(P,Z,null),f(p,T,v),f(p,_,v),Q(B,_,null),m(_,D),Q(N,_,null),m(_,R),Q(F,_,null),f(p,I,v),f(p,z,v),Q(j,z,null),m(z,G),Q(W,z,null),f(p,$,v),f(p,U,v),f(p,J,v),f(p,ee,v),te=!0,Ce||(ie=w(ee,"input",(function(){u(e[0])&&e[0].apply(this,arguments)})),Ce=!0)},p(t,[i]){e=t;const n={};4&i&&(n.onClick=e[2]),C.$set(n);const r={};8&i&&(r.onClick=e[3]),H.$set(r);const o={};16&i&&(o.onClick=e[4]),V.$set(o);const a={};32&i&&(a.onClick=e[5]),L.$set(a);const s={};16384&i&&(s.onClick=e[14]),M.$set(s);const d={};32768&i&&(d.onClick=e[15]),l.$set(d);const u={};131072&i&&(u.workspace=e[17]),c.$set(u);const A={};65536&i&&(A.onClick=e[16]),g.$set(A);const h={};64&i&&(h.onClick=e[6]),262144&i&&(h.disabled=e[18]),b.$set(h);const m={};128&i&&(m.onClick=e[7]),262144&i&&(m.disabled=e[18]),k.$set(m);const f={};256&i&&(f.onClick=e[8]),262144&i&&(f.disabled=e[18]),P.$set(f);const p={};512&i&&(p.onClick=e[9]),B.$set(p);const v={};1024&i&&(v.onClick=e[10]),262144&i&&(v.disabled=e[18]),N.$set(v);const y={};2048&i&&(y.onClick=e[11]),262144&i&&(y.disabled=e[18]),F.$set(y);const Z={};4096&i&&(Z.onClick=e[12]),524288&i&&(Z.disabled=e[19]),j.$set(Z);const S={};8192&i&&(S.onClick=e[13]),1048576&i&&(S.disabled=e[20]),W.$set(S),(!te||2&i&&ee.value!==e[1])&&(ee.value=e[1])},i(e){te||(Y(C.$$.fragment,e),Y(H.$$.fragment,e),Y(V.$$.fragment,e),Y(L.$$.fragment,e),Y(M.$$.fragment,e),Y(l.$$.fragment,e),Y(c.$$.fragment,e),Y(g.$$.fragment,e),Y(b.$$.fragment,e),Y(k.$$.fragment,e),Y(P.$$.fragment,e),Y(B.$$.fragment,e),Y(N.$$.fragment,e),Y(F.$$.fragment,e),Y(j.$$.fragment,e),Y(W.$$.fragment,e),te=!0)},o(e){X(C.$$.fragment,e),X(H.$$.fragment,e),X(V.$$.fragment,e),X(L.$$.fragment,e),X(M.$$.fragment,e),X(l.$$.fragment,e),X(c.$$.fragment,e),X(g.$$.fragment,e),X(b.$$.fragment,e),X(k.$$.fragment,e),X(P.$$.fragment,e),X(B.$$.fragment,e),X(N.$$.fragment,e),X(F.$$.fragment,e),X(j.$$.fragment,e),X(W.$$.fragment,e),te=!1},d(e){e&&p(t),K(C),K(H),K(V),K(L),e&&p(o),e&&p(a),K(M),K(l),e&&p(d),e&&p(A),K(c),K(g),e&&p(y),e&&p(Z),K(b),K(k),K(P),e&&p(T),e&&p(_),K(B),K(N),K(F),e&&p(I),e&&p(z),K(j),K(W),e&&p($),e&&p(U),e&&p(J),e&&p(ee),Ce=!1,ie()}}}function Sa(t,C,i){let{viz:H}=C,{filterValue:n}=C,{fdgdClick:V}=C,{concentricClick:r}=C,{gridClick:L}=C,{hierarchyClick:o}=C,{expandClick:a}=C,{collapseClick:M}=C,{hideClick:s}=C,{selectAllClick:l}=C,{selectInvertClick:d}=C,{selectNeighborClick:u}=C,{lockClick:A}=C,{unlockClick:c}=C,{fitClick:h}=C,{localModeClick:m}=C,{filterInput:f}=C,{saveClick:p}=C,{workspace:g}=C;f=e.debounce(f,500,!0);let v=!1,y=!1,Z=!0;return t.$$set=e=>{"viz"in e&&i(21,H=e.viz),"filterValue"in e&&i(1,n=e.filterValue),"fdgdClick"in e&&i(2,V=e.fdgdClick),"concentricClick"in e&&i(3,r=e.concentricClick),"gridClick"in e&&i(4,L=e.gridClick),"hierarchyClick"in e&&i(5,o=e.hierarchyClick),"expandClick"in e&&i(6,a=e.expandClick),"collapseClick"in e&&i(7,M=e.collapseClick),"hideClick"in e&&i(8,s=e.hideClick),"selectAllClick"in e&&i(9,l=e.selectAllClick),"selectInvertClick"in e&&i(10,d=e.selectInvertClick),"selectNeighborClick"in e&&i(11,u=e.selectNeighborClick),"lockClick"in e&&i(12,A=e.lockClick),"unlockClick"in e&&i(13,c=e.unlockClick),"fitClick"in e&&i(14,h=e.fitClick),"localModeClick"in e&&i(15,m=e.localModeClick),"filterInput"in e&&i(0,f=e.filterInput),"saveClick"in e&&i(16,p=e.saveClick),"workspace"in e&&i(17,g=e.workspace)},[f,n,V,r,L,o,a,M,s,l,d,u,A,c,h,m,p,g,v,y,Z,H,function(){let e=H.nodes(":selected");i(18,v=0===e.length);let t=H.nodes(".pinned"),C=e.difference(t).length>0,n=e.intersection(t);i(19,y=!C||v),i(20,Z=!n||v)}]}class ba extends te{constructor(e){super(),ee(this,e,Sa,Za,A,{viz:21,filterValue:1,fdgdClick:2,concentricClick:3,gridClick:4,hierarchyClick:5,expandClick:6,collapseClick:7,hideClick:8,selectAllClick:9,selectInvertClick:10,selectNeighborClick:11,lockClick:12,unlockClick:13,fitClick:14,localModeClick:15,filterInput:0,saveClick:16,workspace:17,onSelect:22})}get onSelect(){return this.$$.ctx[22]}}class wa{constructor(e,t){this.options=Object.assign({},wa.DEFAULT,e,{animate:!!t&&"end"})}startLayout(e){return e.viz.layout(this.options).start()}}wa.DEFAULT={name:"cola",animate:!0,refresh:2,maxSimulationTime:1500,ungrabifyWhileSimulating:!1,fit:!1,padding:30,nodeDimensionsIncludeLabels:!0,randomize:!1,avoidOverlap:!0,handleDisconnected:!0,convergenceThreshold:.01,nodeSpacing:10};class xa{constructor(e,t){this.options=Object.assign({},xa.DEFAULT,e,{animate:!!t&&"end"})}startLayout(e){return e.viz.layout(Object.assign(this.options,{linkId:function(e){return e.id}})).start()}}xa.DEFAULT={name:"d3-force",animate:"end",maxIterations:0,maxSimulationTime:1500,ungrabifyWhileSimulating:!1,fixedAfterDragging:!1,fit:!1,padding:30,alpha:1,alphaMin:.001,alphaDecay:1-Math.pow(.001,1/300),alphaTarget:0,velocityDecay:.4,collideRadius:60,collideStrength:.9,collideIterations:1,linkDistance:150,linkStrength:.7,linkIterations:1,manyBodyStrength:-600,manyBodyDistanceMin:5,xStrength:.1,xX:0,yStrength:.1,yY:0,radialStrength:.1,radialX:0,radialY:0,radialRadius:10,randomize:!1,infinite:!1};class Oa{constructor(e){this.options=Object.assign({},Oa.DEFAULT,e)}startLayout(e){return e.viz.layout(this.options).start()}}Oa.DEFAULT={name:"grid",animate:!0,animationDuration:500,spacingFactor:.5,fit:!1,padding:30,nodeDimensionsIncludeLabels:!0,avoidOverlap:!0};class ka{constructor(e){this.options=Object.assign({},ka.DEFAULT,e)}startLayout(e){return e.viz.layout(this.options).start()}}ka.DEFAULT={name:"dagre",animate:!0,animationDuration:500,spacingFactor:.5,fit:!1,padding:30,nodeDimensionsIncludeLabels:!0,avoidOverlap:!0};class Ea{constructor(e){this.options=Object.assign({},Ea.DEFAULT,e)}startLayout(e){return e.viz.layout(Object.assign(this.options,{concentric:e=>e.hasClass("active-node")?1e3:e.hasClass("expanded")?100:1})).start()}}Ea.DEFAULT={name:"concentric",animate:"end",animationDuration:500,fit:!1,padding:30,nodeDimensionsIncludeLabels:!0,avoidOverlap:!0};const Pa=function(e,t,C){switch(e){case"circle":case"concentric":return new Ea(C);case"force-directed":return t&&"d3-force"===t.fdgdLayout?new xa(C,t.animateLayout):new wa(C,t.animateLayout);case"hierarchy":case"dagre":return new ka(C);case"grid":return new Oa(C);case"cola":return new wa(C,t.animateLayout);case"d3-force":return new xa(C,t.animateLayout)}};function Ta(e){let t,C,i,H,n,V,r,L,o;return{c(){t=v("div"),C=v("div"),i=Z(e[0]),H=S(),n=v("button"),n.textContent="Load",V=S(),r=v("div"),r.innerHTML='',x(C,"class","list-item-part mod-extended"),x(n,"class","list-item-part"),x(r,"class","list-item-part clickable-icon"),x(r,"aria-label","Delete graph"),x(t,"class","list-item")},m(a,M){f(a,t,M),m(t,C),m(C,i),m(t,H),m(t,n),m(t,V),m(t,r),L||(o=[w(n,"click",(function(){u(e[1](e[0]))&&e[1](e[0]).apply(this,arguments)})),w(r,"click",(function(){u(e[2](e[0]))&&e[2](e[0]).apply(this,arguments)}))],L=!0)},p(t,[C]){e=t,1&C&&O(i,e[0])},i:M,o:M,d(e){e&&p(t),L=!1,d(o)}}}function _a(e,t,C){let{name:i}=t,{onClick:H}=t,{onDelete:n}=t;return e.$$set=e=>{"name"in e&&C(0,i=e.name),"onClick"in e&&C(1,H=e.onClick),"onDelete"in e&&C(2,n=e.onDelete)},[i,H,n]}class Ba extends te{constructor(e){super(),ee(this,e,_a,Ta,A,{name:0,onClick:1,onDelete:2})}}function Da(e,t,C){const i=e.slice();return i[9]=t[C],i}function Na(e){let t,C;return t=new Ba({props:{name:e[9],onClick:e[1],onDelete:e[4]}}),{c(){q(t.$$.fragment)},m(e,i){Q(t,e,i),C=!0},p(e,C){const i={};1&C&&(i.name=e[9]),2&C&&(i.onClick=e[1]),t.$set(i)},i(e){C||(Y(t.$$.fragment,e),C=!0)},o(e){X(t.$$.fragment,e),C=!1},d(e){K(t,e)}}}function Ra(e){let t,C,i,H,n,V,r,L,o,a,M,s=e[0],l=[];for(let t=0;tX(l[e],1,1,(()=>{l[e]=null}));return{c(){t=v("div"),C=v("input"),i=S(),H=v("button"),H.textContent="Save",n=S(),V=v("hr"),r=S(),L=v("div");for(let e=0;e{"onLoad"in e&&C(1,i=e.onLoad),"onSave"in e&&C(6,H=e.onSave),"onDelete"in e&&C(7,n=e.onDelete),"savedGraphs"in e&&C(0,V=e.savedGraphs)},[V,i,r,async e=>{await H(e),C(0,V)},async e=>{await n(e),C(0,V)},e=>"/"!==e.key||(e.preventDefault(),!1),H,n,function(){r=this.value,C(2,r)}]}class Ia extends te{constructor(e){super(),ee(this,e,Fa,Ra,A,{onLoad:1,onSave:6,onDelete:7,savedGraphs:0})}}class za extends e.Modal{constructor(e,t,C){super(e),this.manager=t,this.view=C}onOpen(){super.onOpen(),this.titleEl.innerHTML="Manage workspace graphs",new Ia({target:this.contentEl,props:{onSave:e=>this.manager.saveGraph(e,this.view),savedGraphs:this.manager.graphs,onLoad:e=>this.manager.loadGraph(e,this.view),onDelete:e=>this.manager.deleteGraph(e,this.view)}})}}class ja extends e.Component{constructor(e){super(),this.events=[],this.recursionPreventer=!1,this.view=e}onload(){this.view.vizReady?this._onLoad():this.registerEvent(this.view.on("vizReady",(e=>{this._onLoad()})))}_onLoad(){this.viz=this.view.viz;const e=this,t=this.view,C=getComputedStyle(document.body),i=C.getPropertyValue("--text-selection"),H=C.getPropertyValue("--background-secondary"),V=C.getPropertyValue("--text-normal");C.getPropertyValue("--text");const r=this.view.plugin,L={menuRadius:70,selector:"node",commands:C=>{const i=[];return"core"===n.fromNode(C).storeId&&i.push({content:Aa(ca.ag_file),select:async function(e,t,C){await r.openFileFromNode(e,C.originalEvent.metaKey)},enabled:!0}),i.push({content:Aa(ca.ag_hide),select:function(t){e.removeNodes(t)},enabled:!0},{content:Aa(ca.ag_fit),select:function(t){e.updateActiveNode(t,!0)},enabled:!0}),C.hasClass("pinned")?i.push({content:Aa(ca.ag_unlock),select:function(t){e.unpin(t)},enabled:!0}):i.push({content:Aa(ca.ag_lock),select:function(t){e.pin(t)},enabled:!0}),C.hasClass("expanded")?i.push({content:Aa(ca.ag_collapse),select:function(t){e.removeNodes(t)},enabled:!0}):i.push({content:Aa(ca.ag_expand),select:function(e){t.expand(e)},enabled:!0}),i},fillColor:`${H}`,activeFillColor:`${i}`,activePadding:20,indicatorSize:24,separatorWidth:3,spotlightPadding:0,adaptativeNodeSpotlightRadius:!0,openMenuEvents:"taphold",itemColor:`${V}`,itemTextShadowColor:"transparent",zIndex:9999,atMouse:!1,outsideMenuCancel:15};this.menu=this.viz.cxtmenu(L),this.registerCyEvent("tap","node",(async e=>{if(!this.view.settings.openWithShift||e.originalEvent.shiftKey){await this.view.plugin.openFileFromNode(e.target,e.originalEvent.metaKey)&&this.updateActiveNode(e.target,this.view.settings.autoZoom)}})),this.registerCyEvent("taphold","node",(e=>{this.view.destroyHover&&this.view.destroyHover()})),this.registerCyEvent("dblclick","node",(async e=>{await this.view.expand(e.target)})),this.registerCyEvent("tapselect tapunselect boxselect",null,(e=>{this.view.trigger("selectChange")})),this.registerEvent(this.view.workspace.on("file-open",(async e=>{if(this.view.settings.autoAddNodes&&e&&this.view.settings.autoAddNodes){const t=e.name,C=new n(t,"core");let i=!0;if(0===this.viz.$id(C.toId()).length){const e=await this.view.datastores.coreStore.get(C,this.view);this.viz.startBatch(),this.viz.add(e).addClass("protected");const t=await this.view.buildEdges(this.viz.$id(C.toId()));this.viz.add(t),this.view.onGraphChanged(!1,!0),this.viz.endBatch(),i=!1}const H=this.viz.$id(C.toId());H.addClass("protected"),this.updateActiveNode(H,i&&this.view.settings.autoZoom)}}))),this.registerEvent(this.view.on("expand",(e=>{this.updateActiveNode(e,!1)}))),this.registerEvent(this.view.on("elementsChange",(()=>{this.recursionPreventer||(this.viz.nodes().difference(this.viz.nodes(".protected")).filter((e=>0===e.closedNeighborhood("node.protected").length)).remove(),this.updateActiveNode(this.viz.nodes(".active-node"),!1),this.recursionPreventer=!0,this.view.onGraphChanged(),this.recursionPreventer=!1)}))),this.windowEvent=async e=>{document.activeElement===this.view.element&&("e"===e.key?await this.expandSelection():"h"===e.key||"Backspace"===e.key?this.removeSelection():"i"===e.key?this.invertSelection():"a"===e.key?this.selectAll():"n"===e.key?this.selectNeighboursOfSelected():"p"===e.key?this.pinSelection():"u"===e.key?this.unpinSelection():"c"===e.key?this.collapseSelection():"v"===e.key?this.view.fitView():"f"===e.key&&this.view.fitView(this.viz.nodes(":selected")))},document.on("keydown",".cy-content",this.windowEvent,!0)}registerCyEvent(e,t,C){this.events.push({eventName:e,selector:t,event:C}),t?this.viz.on(e,t,C):this.viz.on(e,C)}onunload(){for(const e of this.events)e.selector?this.viz.off(e.eventName,e.selector,e.event):this.viz.off(e.eventName,e.event);this.events=[],document.off("keydown",".cy-content",this.windowEvent,!0),this.toolbar&&this.toolbar.$destroy(),this.menu&&this.menu.destroy()}getName(){return"workspace"}fillMenu(e,t){if(t.length>0&&(e.addItem((e=>{e.setTitle("Expand selection (E)").setIcon("ag-expand").onClick((async e=>{await this.view.expand(t)}))})),e.addItem((e=>{e.setTitle("Collapse selection (C)").setIcon("ag-collapse").onClick((e=>{this.collapse(t)}))})),e.addItem((e=>{e.setTitle("Hide selection (H)").setIcon("ag-hide").onClick((e=>{this.removeNodes(t)}))})),e.addItem((e=>{e.setTitle("Select all (A)").setIcon("ag-select-all").onClick((e=>{this.selectAll()}))})),e.addItem((e=>{e.setTitle("Invert selection (I)").setIcon("ag-select-inverse").onClick((e=>{this.invertSelection()}))}))),t.length>0){e.addItem((e=>{e.setTitle("Select neighbors (N)").setIcon("ag-select-neighbors").onClick((e=>{this.selectNeighbourhood(t)}))}));const C=this.view.getPinned();t.difference(C).length>0&&e.addItem((e=>{e.setTitle("Pin selection (P)").setIcon("ag-lock").onClick((e=>{this.pin(t)}))})),t.intersect(C).length>0&&e.addItem((e=>{e.setTitle("Unpin selection (U)").setIcon("ag-unlock").onClick((e=>{this.unpin(t)}))}))}}createToolbar(e){this.toolbar=new ba({target:e,props:{viz:this.viz,filterValue:this.view.settings.filter,expandClick:this.expandSelection.bind(this),fdgdClick:()=>this.view.setLayout(Pa("force-directed",this.view.settings)),concentricClick:()=>this.view.setLayout(Pa("circle")),gridClick:()=>this.view.setLayout(Pa("grid")),hierarchyClick:()=>this.view.setLayout(Pa("hierarchy")),collapseClick:this.collapseSelection.bind(this),hideClick:this.removeSelection.bind(this),selectAllClick:this.selectAll.bind(this),selectInvertClick:this.invertSelection.bind(this),selectNeighborClick:this.selectNeighboursOfSelected.bind(this),lockClick:this.pinSelection.bind(this),unlockClick:this.unpinSelection.bind(this),fitClick:this.view.fitView.bind(this.view),localModeClick:()=>this.view.setMode("local"),filterInput:e=>{this.view.searchFilter(e.target.value),this.view.restartLayout()},saveClick:()=>{"app"in this.view.plugin&&"workspaceManager"in this.view.plugin&&new za(this.view.plugin.app,this.view.plugin.workspaceManager,this.view).open()},workspace:this.view.plugin.app.workspace}}),this.view.on("selectChange",this.toolbar.onSelect.bind(this.toolbar)),this.view.on("vizReady",(e=>{this.toolbar.$set({viz:e}),this.toolbar.onSelect.bind(this.toolbar)()}))}updateActiveNode(e,t){this.viz.elements().removeClass(["connected-active-node","active-node","inactive-node"]).difference(e.closedNeighborhood()).addClass("inactive-node"),e.addClass("active-node");const C=e.connectedEdges().addClass("connected-active-node").connectedNodes().addClass("connected-active-node").union(e);t&&this.viz.animate({fit:{eles:C,padding:0},duration:250,queue:!1}),this.viz.one("tap",(e=>{e.cy.elements().removeClass(["connected-active-node","active-node","inactive-node"])}))}async expandSelection(){await this.view.expand(this.viz.nodes(":selected"))}collapse(e){e.filter(":selected").removeClass(["protected","expanded"]).openNeighborhood().nodes().filter((e=>0===e.closedNeighborhood("node.protected").length)).remove(),this.recursionPreventer=!0,this.view.onGraphChanged(!0,!0),this.recursionPreventer=!1}collapseSelection(){this.collapse(this.viz.nodes(":selected"))}removeNodes(e){e.addClass("hard-filtered"),this.view.onGraphChanged(!0,!0),this.view.trigger("hide",e),this.view.trigger("selectChange")}removeSelection(){this.removeNodes(this.viz.nodes(":selected"))}selectAll(){this.viz.nodes().select(),this.view.trigger("selectChange")}invertSelection(){this.viz.$(":selected").unselect().absoluteComplement().select(),this.view.trigger("selectChange")}selectNeighboursOfSelected(){this.selectNeighbourhood(this.viz.nodes(":selected"))}selectNeighbourhood(e){this.viz.nodes(":selected").unselect(),e.openNeighborhood().select(),this.view.trigger("selectChange")}unpin(e){const t=e.unlock().removeClass("pinned");this.view.restartLayout(),this.view.trigger("unpin",t)}unpinSelection(){this.unpin(this.viz.nodes(":selected"))}pin(e){const t=e.lock().addClass("pinned");this.view.restartLayout(),this.view.trigger("pin",t)}pinSelection(){this.pin(this.viz.nodes(":selected"))}}function Ga(e){let t,C,i,H,n,V,r,L,o,a,M,s,l,d,A,c,h,g,y,Z,b,O,k;return C=new fa({props:{icon:ca.ag_fdgd,onClick:e[1],title:"Force directed layout"}}),H=new fa({props:{icon:ca.ag_concentric,onClick:e[2],title:"Circle layout"}}),V=new fa({props:{icon:ca.ag_grid,onClick:e[3],title:"Grid layout"}}),L=new fa({props:{icon:ca.ag_hierarchy,onClick:e[4],title:"Hierarchical layout"}}),M=new fa({props:{icon:ca.ag_fit,onClick:e[5],title:"Fit view"}}),l=new fa({props:{icon:ca.ag_workspace,onClick:e[6],title:"Workspace mode"}}),c=new ya({props:{workspace:e[8]}}),{c(){t=v("div"),q(C.$$.fragment),i=S(),q(H.$$.fragment),n=S(),q(V.$$.fragment),r=S(),q(L.$$.fragment),o=S(),a=v("div"),q(M.$$.fragment),s=S(),q(l.$$.fragment),d=S(),A=v("div"),q(c.$$.fragment),h=S(),g=v("br"),y=v("label"),y.textContent="Filter: ",Z=v("input"),x(t,"class","cy-toolbar-section"),x(a,"class","cy-toolbar-section"),x(A,"class","cy-toolbar-section"),x(y,"for","ag-filter"),x(Z,"type","text"),x(Z,"id","ag-filter"),x(Z,"name","ag-filter"),Z.value=e[7]},m(p,v){f(p,t,v),Q(C,t,null),m(t,i),Q(H,t,null),m(t,n),Q(V,t,null),m(t,r),Q(L,t,null),f(p,o,v),f(p,a,v),Q(M,a,null),m(a,s),Q(l,a,null),f(p,d,v),f(p,A,v),Q(c,A,null),f(p,h,v),f(p,g,v),f(p,y,v),f(p,Z,v),b=!0,O||(k=w(Z,"input",(function(){u(e[0])&&e[0].apply(this,arguments)})),O=!0)},p(t,[i]){e=t;const n={};2&i&&(n.onClick=e[1]),C.$set(n);const r={};4&i&&(r.onClick=e[2]),H.$set(r);const o={};8&i&&(o.onClick=e[3]),V.$set(o);const a={};16&i&&(a.onClick=e[4]),L.$set(a);const s={};32&i&&(s.onClick=e[5]),M.$set(s);const d={};64&i&&(d.onClick=e[6]),l.$set(d);const u={};256&i&&(u.workspace=e[8]),c.$set(u),(!b||128&i&&Z.value!==e[7])&&(Z.value=e[7])},i(e){b||(Y(C.$$.fragment,e),Y(H.$$.fragment,e),Y(V.$$.fragment,e),Y(L.$$.fragment,e),Y(M.$$.fragment,e),Y(l.$$.fragment,e),Y(c.$$.fragment,e),b=!0)},o(e){X(C.$$.fragment,e),X(H.$$.fragment,e),X(V.$$.fragment,e),X(L.$$.fragment,e),X(M.$$.fragment,e),X(l.$$.fragment,e),X(c.$$.fragment,e),b=!1},d(e){e&&p(t),K(C),K(H),K(V),K(L),e&&p(o),e&&p(a),K(M),K(l),e&&p(d),e&&p(A),K(c),e&&p(h),e&&p(g),e&&p(y),e&&p(Z),O=!1,k()}}}function Wa(t,C,i){let{fdgdClick:H}=C,{concentricClick:n}=C,{gridClick:V}=C,{hierarchyClick:r}=C,{fitClick:L}=C,{workspaceModeClick:o}=C,{filterInput:a}=C,{filterValue:M}=C,{workspace:s}=C;return a=e.debounce(a,500,!0),t.$$set=e=>{"fdgdClick"in e&&i(1,H=e.fdgdClick),"concentricClick"in e&&i(2,n=e.concentricClick),"gridClick"in e&&i(3,V=e.gridClick),"hierarchyClick"in e&&i(4,r=e.hierarchyClick),"fitClick"in e&&i(5,L=e.fitClick),"workspaceModeClick"in e&&i(6,o=e.workspaceModeClick),"filterInput"in e&&i(0,a=e.filterInput),"filterValue"in e&&i(7,M=e.filterValue),"workspace"in e&&i(8,s=e.workspace)},[a,H,n,V,r,L,o,M,s]}class $a extends te{constructor(e){super(),ee(this,e,Wa,Ga,A,{fdgdClick:1,concentricClick:2,gridClick:3,hierarchyClick:4,fitClick:5,workspaceModeClick:6,filterInput:0,filterValue:7,workspace:8})}}class Ua extends e.Component{constructor(e){super(),this.events=[],this.view=e}onload(){this.view.vizReady?this._onLoad():this.registerEvent(this.view.on("vizReady",(e=>{this._onLoad()})))}_onLoad(){this.viz=this.view.viz,this.registerCyEvent("tap","node",(async e=>{const t=await this.view.plugin.openFileFromNode(e.target,e.originalEvent.metaKey);t&&await this.onOpenFile(t)})),this.registerEvent(this.view.workspace.on("file-open",(async e=>{e&&await this.onOpenFile(e)})))}async onOpenFile(e){if(!this.view.settings.autoAddNodes)return;const t=new n(e.name,"core");let C;if(this.viz.startBatch(),0===this.viz.$id(t.toId()).length){const e=await this.view.datastores.coreStore.get(t,this.view);C=this.viz.add(e)}else C=this.viz.$id(t.toId());await this.view.expand(C,!1),C.addClass("active-node"),this.viz.nodes().difference(C.closedNeighborhood()).remove(),this.view.onGraphChanged(!1),this.updateActiveFile(C),this.viz.endBatch()}registerCyEvent(e,t,C){this.events.push({eventName:e,selector:t,event:C}),t?this.viz.on(e,t,C):this.viz.on(e,C)}onunload(){for(const e of this.events)e.selector?this.viz.off(e.eventName,e.selector,e.event):this.viz.off(e.eventName,e.event);this.events=[],this.toolbar.$destroy()}getName(){return"local"}fillMenu(e,t){}createToolbar(e){const t=this.view;this.toolbar=new $a({target:e,props:{viz:this.viz,fitClick:this.view.fitView.bind(t),fdgdClick:()=>this.view.setLayout(Pa("force-directed",this.view.settings)),concentricClick:()=>this.view.setLayout(Pa("circle")),gridClick:()=>this.view.setLayout(Pa("grid")),hierarchyClick:()=>this.view.setLayout(Pa("hierarchy")),workspaceModeClick:()=>t.setMode("workspace"),filterInput:e=>{this.view.searchFilter(e.target.value),this.view.restartLayout()},filterValue:this.view.settings.filter,workspace:this.view.plugin.app.workspace}})}updateActiveFile(e){this.viz.elements().removeClass(["connected-active-node","active-node","inactive-node"]).difference(e.closedNeighborhood()).addClass("inactive-node"),e.addClass("active-node"),e.connectedEdges().addClass("connected-active-node").connectedNodes().addClass("connected-active-node").union(e)}} /*! * search-query-parser.js * Copyright(c) 2014-2019 * MIT Licensed */var Ya=fe((function(e,t){t.parse=function(e,t){if(t?t.offsets=void 0===t.offsets||t.offsets:t={offsets:!0},e||(e=""),-1!==e.indexOf(":")||t.tokenize){if(t.keywords||t.ranges||t.tokenize){var C={text:[]};t.offsets&&(C.offsets=[]);for(var i,H={},n=[],V=/(\S+:'(?:[^'\\]|\\.)*')|(\S+:"(?:[^"\\]|\\.)*")|(-?"(?:[^"\\]|\\.)*")|(-?'(?:[^'\\]|\\.)*')|\S+|\S+:\S+/g;null!==(i=V.exec(e));){var r,L=(r=i[0]).indexOf(":");if(-1!==L){r.split(":");var o=r.slice(0,L),a=r.slice(L+1);a=((a=a.replace(/^\"|\"$|^\'|\'$/g,""))+"").replace(/\\(.?)/g,(function(e,t){switch(t){case"\\":return"\\";case"0":return"\0";case"":return"";default:return t}})),n.push({keyword:o,value:a,offsetStart:i.index,offsetEnd:i.index+r.length})}else{var M=!1;"-"===r[0]&&(M=!0,r=r.slice(1)),r=((r=r.replace(/^\"|\"$|^\'|\'$/g,""))+"").replace(/\\(.?)/g,(function(e,t){switch(t){case"\\":return"\\";case"0":return"\0";case"":return"";default:return t}})),M?H.text?(H.text instanceof Array||(H.text=[H.text]),H.text.push(r)):H.text=r:n.push({text:r,offsetStart:i.index,offsetEnd:i.index+r.length})}}for(n.reverse();r=n.pop();)if(r.text)C.text.push(r.text),t.offsets&&C.offsets.push(r);else{o=r.keyword;t.keywords=t.keywords||[];var s=!1,l=!1;if(/^-/.test(o)){if("-"===o[0]){var d=o.slice(1);(s=!(-1===t.keywords.indexOf(d)))&&(o=d,l=!0)}}else s=!(-1===t.keywords.indexOf(o));t.ranges=t.ranges||[];var u=!(-1===t.ranges.indexOf(o));if(s){if(t.offsets&&C.offsets.push({keyword:o,value:r.value,offsetStart:l?r.offsetStart+1:r.offsetStart,offsetEnd:r.offsetEnd}),(c=r.value).length){var A=c.split(",");l?H[o]?H[o]instanceof Array?A.length>1?H[o]=H[o].concat(A):H[o].push(c):(H[o]=[H[o]],H[o].push(c)):A.length>1?H[o]=A:t.alwaysArray?H[o]=[c]:H[o]=c:C[o]?C[o]instanceof Array?A.length>1?C[o]=C[o].concat(A):C[o].push(c):(C[o]=[C[o]],C[o].push(c)):A.length>1?C[o]=A:t.alwaysArray?C[o]=[c]:C[o]=c}}else if(u){t.offsets&&C.offsets.push(r);var c,h=(c=r.value).split("-");C[o]={},2===h.length?(C[o].from=h[0],C[o].to=h[1]):!h.length%2||(C[o].from=c)}else{var m=r.keyword+":"+r.value;C.text.push(m),t.offsets&&C.offsets.push({text:m,offsetStart:r.offsetStart,offsetEnd:r.offsetEnd})}}return C.text.length?t.tokenize||(C.text=C.text.join(" ").trim()):delete C.text,C.exclude=H,C}return e}return e},t.stringify=function(e,C,i){if(C||(C={offsets:!0}),!e)return"";if("string"==typeof e)return e;if(Array.isArray(e))return e.join(" ");if(!Object.keys(e).length)return"";if(3===Object.keys(e).length&&e.text&&e.offsets&&e.exclude&&"string"==typeof e.text)return e.text;i||(i="");var H=function(e){return e.indexOf(" ")>-1?JSON.stringify(e):e},n=function(e){return i+e},V=[];if(e.text){var r=[];"string"==typeof e.text?r.push(e.text):r.push.apply(r,e.text),r.length>0&&V.push(r.map(H).map(n).join(" "))}return C.keywords&&C.keywords.forEach((function(t){if(e[t]){var C=[];"string"==typeof e[t]?C.push(e[t]):C.push.apply(C,e[t]),C.length>0&&V.push(n(t+":"+C.map(H).join(",")))}})),C.ranges&&C.ranges.forEach((function(t){if(e[t]){var C=e[t].from,i=e[t].to;i&&(C=C+"-"+i),C&&V.push(n(t+":"+C))}})),e.exclude&&Object.keys(e.exclude).length>0&&V.push(t.stringify(e.exclude,C,"-")),V.join(" ")}})),Xa=Ya;const qa=function(e,t,C="*="){return"string"==typeof t||t instanceof String?[`[${e} ${C} '${t}']`]:t.map((t=>`[${e} ${C} '${t}']`))},Qa=function(e,t){switch(t){case"exclude":return[];case"content":case"ignore-case":case"text":return qa("content",e[t],"@*=");case"match-case":return qa("content",e[t],"*=");case"file":return qa("name",e[t]);case"name":return qa("name",e[t],"@*=");case"tag":return"string"==typeof(i=e[t])||i instanceof String?i.length>0&&"#"===i[0]?(i.slice(1),[`.tag-${i.slice(1).replaceAll("/","-")}`]):[]:i.map((e=>e.length>0&&"#"===e[0]?`.tag-${e.slice(1).replaceAll("/","-")}`:""));case"class":return"string"==typeof(C=e[t])||C instanceof String?[`.${C}`]:C.map((e=>`.${e}`));case"raw":return[e[t]];default:return qa(t,e[t])}var C,i},Ka=function(e,t,C){if(C===e)return function(e,t){const C=new Set;t.forEach((e=>{Object.keys(e.data()).forEach((e=>C.add(e)))}));const i=["file","tag","raw","match-case","ignore-case","class"];i.push(...C);const H={keywords:i,tokenize:!0,offsets:!1},n=Xa.parse(e,H);let V="node";for(const e of Object.keys(n))V+=Qa(n,e).join();let r=t.filter(V);if(n.exclude)for(const e of Object.keys(n.exclude))for(const t of Qa(n.exclude,e)){const e="node"+t;r=r.not(e)}return r}(e,t);const i=[];let H=0,n=0;for(let t=0;te.union(function(e,t){const C=[],i=[];let H=0,n=-1,V=-1;for(let t=0;t0&&"-"===e[t-1]?t-1:t);H.trim().length>0&&(i.push(!1),C.push(H))}H+=1}else if(")"===e[t])H-=1,0===H&&(V=t,i.push(n>0&&"-"===e[n-1]),C.push(e.slice(n+1,V)));else if(t===e.length-1){const t=e.slice(V+1);t.trim().length>0&&(i.push(!1),C.push(t))}let r=t;for(let t=0;tnew n(e,this.datastores.coreStore.storeId()))),C=this.settings.expandInitial?await this.neighbourhood(i):await Promise.all(i.map((e=>this.datastores.coreStore.get(e,this)))),C=C.filter((e=>e)),this.viz=Wo({container:t,elements:C,minZoom:.3,maxZoom:10,wheelSensitivity:this.settings.zoomSpeed})):this.viz=Wo({container:t,elements:[{data:{id:"a"}},{data:{id:"b"}}],minZoom:.3,maxZoom:10,wheelSensitivity:this.settings.zoomSpeed}),this.viz.dblclick(),this.settings.navigator){const e=document.createElement("div");e.id="cynav"+eM,t.children[0].appendChild(e),e.addClass("cy-navigator"),this.viz.navigator({container:"#cynav"+eM,viewLiveFramerate:0,thumbnailEventFramerate:10,thumbnailLiveFramerate:!1,dblClickDelay:200,removeCustomContainer:!0,rerenderDelay:100})}if(eM+=1,i){for(const e of i){const t=this.viz.$id(e.toId());this.settings.expandInitial&&t.addClass("expanded"),t.addClass("protected")}const e=this.viz.nodes(),t=await this.buildEdges(e);this.viz.add(t),this.onGraphChanged(!0)}await this.updateStylesheet(),i&&this.restartLayout();this.viz.on("tap boxselect",(async e=>{this.element.focus()})),this.viz.on("tap","node",(async e=>{n.fromNode(e.target).storeId})),this.viz.on("tap","edge",(async e=>{})),this.viz.on("mouseover","node",(async e=>{e.target.unlock();const t=e.target;e.cy.elements().difference(t.closedNeighborhood()).addClass("unhover"),t.addClass("hover").connectedEdges().addClass("connected-hover").connectedNodes().addClass("connected-hover");const C=n.fromNode(e.target);if("core"===C.storeId){const t=this.plugin.metadata.getFirstLinkpathDest(C.id,"");!t||"md"!==t.extension||!e.originalEvent.metaKey&&this.settings.metaKeyHover||(this.hoverTimeout[e.target.id()]=setTimeout((async()=>this.plugin.app.workspace.trigger("link-hover",this.element,null,t.path,"")),300))}})),this.viz.on("mouseover","edge",(async e=>{const t=e.target;this.settings.hoverEdges&&(e.cy.elements().difference(t.connectedNodes().union(t)).addClass("unhover"),t.addClass("hover").connectedNodes().addClass("connected-hover")),!("context"in t.data())||!e.originalEvent.metaKey&&this.settings.metaKeyHover||(this.hoverTimeout[e.target.id()]=setTimeout((async()=>{const e=n.fromNode(t.source()),C=this.plugin.metadata.getFirstLinkpathDest(e.id,"");if(C&&"md"===C.extension&&"obsidian-hover-editor"in this.plugin.app.plugins.plugins){const e=t.data().line,i={scroll:e,line:e,startLoc:{line:e,col:t.data().start,offset:0},endLoc:{line:e,col:t.data().end,offset:0}};this.plugin.app.workspace.trigger("link-hover",this.element,null,C.path,"",i)}else await this.popover(t.data().context,"",t,"juggl-preview-edge")}),800))})),this.viz.on("mouseout",(e=>{if(e.target===e.cy)return;const t=e.target.id();t in this.hoverTimeout&&(clearTimeout(this.hoverTimeout[t]),this.hoverTimeout[t]=void 0),e.cy.elements().removeClass(["hover","unhover","connected-hover"]),e.target.hasClass("pinned")&&e.target.lock()})),this.viz.on("grab",(e=>{this.activeLayout&&this.activeLayout.stop()})),this.viz.on("dragfree",(e=>{this.activeLayout&&this.activeLayout.stop(),this.activeLayout.start();const t=e.target;t.lock(),this.activeLayout.one("layoutstop",(e=>{t.hasClass("pinned")||t.unlock()}))})),this.viz.on("cxttap",(t=>{const C=new e.Menu(this.plugin.app);if(t.target!==this.viz&&"nodes"===t.target.group()){const e=n.fromNode(t.target);if(t.target.select(),"core"===e.storeId){const t=this.plugin.app.metadataCache.getFirstLinkpathDest(e.id,"");void 0!==t&&this.plugin.app.workspace.trigger("file-menu",C,t,"my-context-menu",null)}}this.mode.fillMenu(C,this.viz.nodes(":selected")),C.showAtPosition({x:t.originalEvent.x,y:t.originalEvent.y})})),this.viz.on("layoutstop",e.debounce((e=>{if(!this.settings.autoZoom)return;let t;const C=this.viz.nodes(".active-node");t=C.length>0?C.closedNeighborhood():this.viz.nodes(),e.cy.animate({fit:{eles:t,padding:0},duration:250,queue:!1})}),500,!0)),this.vizReady=!0,this.trigger("vizReady",this.viz),console.log("Visualization ready")}catch(e){throw console.log(e),e}}async popover(t,C,i,H){const n=document.createElement("div");n.addClasses(["popover","hover-popover","is-loaded","juggl-hover"]);const V=document.createElement("div");V.addClasses(["markdown-embed",H]),n.appendChild(V);const r=document.createElement("div");r.addClasses(["markdown-embed-content"]),V.appendChild(r);const L=document.createElement("div");L.addClasses(["markdown-preview-view"]),r.appendChild(L);const o=document.createElement("div");o.addClasses(["markdown-preview-sizer","markdown-preview-section"]),L.appendChild(o),await e.MarkdownRenderer.renderMarkdown(t,o,C,null),document.body.appendChild(n);const a=i.popper({content:()=>n,popper:{placement:"top"}}),M=function(){a.update()};i.on("position",M),this.viz.on("pan zoom resize",M),n.addEventListener("mouseenter",(e=>{n.addClass("popover-hovered")})),this.destroyHover=()=>{a.destroy(),n.remove(),this.destroyHover=null},n.addEventListener("mouseleave",this.destroyHover);const s=this.destroyHover;this.viz.one("mouseout",(e=>{setTimeout((function(){n.hasClass("popover-hovered")||s()}),300)}))}async neighbourhood(e){const t=[];for(const C of this.datastores.dataStores){const i=await C.getNeighbourhood(e,this);t.push(...i)}return t}async buildEdges(e){const t=[];for(const C of this.datastores.dataStores)t.push(...await C.connectNodes(this.viz.nodes(),e,this));return t}async expand(e,t=!0,C=!0){if(0===e.length)return null;t&&this.viz.startBatch(),e.addClass("expanded"),e.addClass("protected");const i=e.map((e=>n.fromNode(e))),H=await this.neighbourhood(i);this.mergeToGraph(H,!1,!1);const V=this.viz.collection();H.forEach((e=>{V.merge(this.viz.$id(e.data.id))}));const r=await this.buildEdges(V),L=this.mergeToGraph(r,!1,C);return t&&this.viz.endBatch(),this.trigger("expand",e),L}async updateStylesheet(){const e=new Ve(this.plugin);this.trigger("stylesheet",e);const t=await e.getStylesheet(this);this.viz.style(t)}onunload(){}removeNodes(e){let t=null;return this.viz.batch((()=>{this.getExpanded().intersection(e.neighborhood()).removeClass("expanded"),t=e.remove(),this.onGraphChanged(!1,!0)})),t}fitView(e){e?this.viz.fit(e):this.viz.fit()}restartLayout(){this.activeLayout&&this.activeLayout.stop();const e="string"==typeof(t=this.settings).layout||t.layout instanceof String?Pa(t.layout,t):Pa(t.layout.name,t,t.layout);var t;try{this.activeLayout=e.startLayout(this)}catch(e){console.log(e)}}setLayout(e){this.settings.layout=e.options,this.restartLayout()}mergeToGraph(e,t=!0,C=!0){t&&this.viz.startBatch();const H=[],n=this.viz.collection();e.forEach((e=>{if(0===this.viz.$id(e.data.id).length)H.push(e);else{const t=this.viz.$id(e.data.id),C=i.filter((e=>t.hasClass(e)));C.push(...t.classes().filter((e=>e.startsWith("global-")||e.startsWith("local-")))),t.classes(e.classes);for(const e of C)t.addClass(e);t.data(e.data),n.merge(t)}}));const V=this.viz.add(H);return n.merge(V),C&&this.onGraphChanged(!1),t&&this.viz.endBatch(),{merged:n,added:V}}assignStyleGroups(){const e=this.viz,t=function(t,C){for(const[i,H]of t.entries()){const t=`${C}-${i}`;e.nodes().removeClass(t);Ja(H.filter,e.nodes()).addClass(t)}};t(this.settings.styleGroups,"local"),"settings"in this.plugin&&t(this.plugin.settings.globalStyleGroups,"global")}onGraphChanged(e=!0,t=!1){e&&this.viz.startBatch(),this.viz.nodes().forEach((e=>{e.data("degree",e.degree(!1)),e.data("nameLength",e.data("name").length),e.addClass([...new Set(e.incomers("edge").map((e=>"has-incoming-"+(e.data("type")?e.data("type"):"inline"))))]),e.addClass([...new Set(e.outgoers("edge").map((e=>"has-outgoing-"+(e.data("type")?e.data("type"):"inline"))))])})),e&&this.viz.endBatch(),this.trigger("elementsChange"),this.searchFilter(this.settings.filter),t?this.debouncedRestartLayout():this.restartLayout(),this.assignStyleGroups()}getViz(){return this.viz}setMode(e){this.removeChild(this.mode),"local"===e?this.mode=new Ua(this):"workspace"===e&&(this.mode=new ja(this)),this.addChild(this.mode),this.settings.toolbar&&this.mode.createToolbar(this.element.children[0])}searchFilter(e){this.viz.nodes().removeClass("filtered");const t=Ja(e,this.viz.nodes());this.viz.nodes().difference(t).addClass("filtered"),this.settings.filter=e}getPinned(){return this.viz.nodes(".pinned")}getExpanded(){return this.viz.nodes(".expanded")}getProtected(){return this.viz.nodes(".protected")}on(e,t,C){return this.events.on(e,t,C)}off(e,t){this.events.off(e,t)}offref(e){this.events.offref(e)}trigger(e,...t){this.events.trigger(e,...t)}tryTrigger(e,t){this.events.tryTrigger(e,t)}}class CM extends e.Component{constructor(e){super(),this.settings=e.settings,this.plugin=e,this.imgServer=null}async onload(){if(super.onload(),e.Platform.isMobile||!this.settings.useImgServer)return;const t=require("path"),C=require("http"),i=require("fs");let H=null;try{H=t.join(this.plugin.path)}catch(e){return console.log("Couldn't start image server. This is likely because we're on mobile!"),console.log("Alternatively, windows might block it using the firewall"),void console.log(e)}const n={gif:"image/gif",jpg:"image/jpeg",png:"image/png",svg:"image/svg+xml"},V=this.settings,r=this.plugin.app.vault;this.imgServer=C.createServer((function(e,C){const L=e.url.toString().split("?")[0];if("GET"!==e.method)return C.statusCode=501,C.setHeader("Content-Type","text/plain"),C.end("Method not implemented");let o=t.join(H,decodeURI(L.replace(/\/$/,"/index.html")));o=r.adapter.getFullPath(o),V.debug&&(console.log("entering server query"),console.log(e),console.log(o));const a=n[t.extname(o).slice(1)],M=i.createReadStream(o);M.on("open",(function(){C.setHeader("Content-Type",a),C.setHeader("Access-Control-Allow-Origin","*"),M.pipe(C)})),M.on("error",(function(){console.log("Here3"),C.setHeader("Content-Type","text/plain"),C.statusCode=404,C.end("Not found")}))}));try{const e=this.settings.imgServerPort;this.imgServer.listen(e,(function(){console.log("Image server listening on http://localhost:"+e+"/")}))}catch(t){console.log(t),new e.Notice("Juggl: Couldn't start image server, see console")}}async onunload(){super.onunload(),this.imgServer&&(this.imgServer.close(),this.imgServer=null)}}var iM=fe((function(e){!function(){var t={container:!1,viewLiveFramerate:0,dblClickDelay:200,removeCustomContainer:!0,rerenderDelay:500},C=function(){var e=Math.max,t=Date.now||function(){return(new Date).getTime()};return function(C,i,H){var n,V,r,L,o,a,M,s,l,d=0,u=!1,A=!0;if("function"!=typeof C)throw new TypeError("Expected a function");if(i=i<0?0:+i||0,!0===H){var c=!0;A=!1}else l=typeof(s=H),!s||"object"!=l&&"function"!=l||(c=!!H.leading,u="maxWait"in H&&e(+H.maxWait||0,i),A="trailing"in H?!!H.trailing:A);function h(e,i){i&&clearTimeout(i),V=a=M=void 0,e&&(d=t(),r=C.apply(o,n),a||V||(n=o=void 0))}function m(){var e=i-(t()-L);e<=0||e>i?h(M,V):a=setTimeout(m,e)}function f(){h(A,a)}function p(){if(n=arguments,L=t(),o=this,M=A&&(a||!c),!1===u)var e=c&&!a;else{V||c||(d=L);var H=u-(L-d),s=H<=0||H>u;s?(V&&(V=clearTimeout(V)),d=L,r=C.apply(o,n)):V||(V=setTimeout(f,H))}return s&&a?a=clearTimeout(a):a||i===u||(a=setTimeout(m,i)),e&&(s=!0,r=C.apply(o,n)),!s||a||V||(n=o=void 0),r}return p.cancel=function(){a&&clearTimeout(a),V&&clearTimeout(V),d=0,V=a=M=void 0},p}}(),i=function(e,t){this._init(e,t)},H=function(){for(var e=1;e0?-1!==e.container.indexOf("#")?this.$panel=document.getElementById(e.container.replace("#","")):this.$panel=document.getElementsByClassName(e.container.replace(".",""))[0]:(this.$panel=document.createElement("div"),this.$panel.className="cytoscape-navigator",document.body.appendChild(this.$panel)),this._setupPanel(),this._addCyListener("resize",this.resize.bind(this))},_setupPanel:function(){this.panelWidth=n(this.$panel),this.panelHeight=V(this.$panel)},_initThumbnail:function(){this.$thumbnail=document.createElement("img"),this.$panel.appendChild(this.$thumbnail),this._setupThumbnailSizes(),this._setupThumbnail()},_setupThumbnail:function(){this._updateThumbnailImage()},_setupThumbnailSizes:function(){this.boundingBox=this.bb(),this.thumbnailZoom=Math.min(this.panelHeight/this.boundingBox.h,this.panelWidth/this.boundingBox.w),this.thumbnailPan={x:(this.panelWidth-this.thumbnailZoom*(this.boundingBox.x1+this.boundingBox.x2))/2,y:(this.panelHeight-this.thumbnailZoom*(this.boundingBox.y1+this.boundingBox.y2))/2}},_checkThumbnailSizesAndUpdate:function(){var e=this.thumbnailZoom,t=this.thumbnailPan.x,C=this.thumbnailPan.y;this._setupThumbnailSizes(),e!=this.thumbnailZoom||t!=this.thumbnailPan.x||C!=this.thumbnailPan.y?(this._setupThumbnail(),this._setupView()):this._updateThumbnailImage()},_initView:function(){this.$view=document.createElement("div"),this.$view.className="cytoscape-navigatorView",this.$panel.appendChild(this.$view),this.viewBorderTop=parseInt(this.$view.style["border-top-width"],10)||0,this.viewBorderRight=parseInt(this.$view.style["border-right-width"],10)||0,this.viewBorderBottom=parseInt(this.$view.style["border-bottom-width"],10)||0,this.viewBorderLeft=parseInt(this.$view.style["border-left-width"],10)||0,this.viewBorderHorizontal=this.viewBorderLeft+this.viewBorderRight,this.viewBorderVertical=this.viewBorderTop+this.viewBorderBottom,this._setupView(),this._addCyListener("zoom pan",this._setupView.bind(this))},_setupView:function(){if(!this.viewLocked){var e=this.cy.zoom(),t=this.cy.pan();this.viewW=this.width/e*this.thumbnailZoom,this.viewX=-t.x*this.viewW/this.width+this.thumbnailPan.x-this.viewBorderLeft,this.viewH=this.height/e*this.thumbnailZoom,this.viewY=-t.y*this.viewH/this.height+this.thumbnailPan.y-this.viewBorderTop,this.$view.style.width=this.viewW+"px",this.$view.style.height=this.viewH+"px",this.$view.style.position="absolute",this.$view.style.left=this.viewX+"px",this.$view.style.top=this.viewY+"px"}},_initOverlay:function(){this.$overlay=document.createElement("div"),this.$overlay.className="cytoscape-navigatorOverlay",this.$panel.appendChild(this.$overlay),this.overlayHookPointX=0,this.overlayHookPointY=0,this._initEventsHandling()},resize:function(){this.width=n(this.$element),this.height=V(this.$element),this._thumbnailSetup=!1,this._setupPanel(),this._checkThumbnailSizesAndUpdate(),this._setupView()},_initEventsHandling:function(){for(var e=this,t=["mousedown","mousewheel","DOMMouseScroll","touchstart"],C=["mouseup","mouseout","mousemove","touchmove","touchend"],i=function(t){if("touchstart"==t.type&&(Object.defineProperty(t,"offsetX",{value:e.viewX+e.viewW/2,writable:!0}),Object.defineProperty(t,"offsetY",{value:e.viewY+e.viewH/2,writable:!0})),void 0===t.offsetX||void 0===t.offsetY){var C=t.target.getBoundingClientRect(),i={top:C.top+window.scrollY,left:C.left+window.scrollX};Object.defineProperty(t,"offsetX",{value:t.pageX-i.left,writable:!0}),Object.defineProperty(t,"offsetY",{value:t.pageY-i.top,writable:!0})}return"mousedown"==t.type||"touchstart"==t.type?e._eventMoveStart(t):"mousewheel"!=t.type&&"DOMMouseScroll"!=t.type||e._eventZoom(t),!1},H=function(t){if(e.overlayInMovement){if("touchend"==t.type?(Object.defineProperty(t,"offsetX",{value:e.viewX+e.viewW/2,writable:!0}),Object.defineProperty(t,"offsetY",{value:e.viewY+e.viewH/2,writable:!0})):"touchmove"==t.type&&(Object.defineProperty(t,"pageX",{value:t.originalEvent.touches[0].pageX,writable:!0}),Object.defineProperty(t,"pageY",{value:t.originalEvent.touches[0].pageY,writable:!0})),void 0===t.offsetX||void 0===t.offsetY){var C={top:(i=t.target.getBoundingClientRect()).top+window.scrollY,left:i.left+window.scrollX};Object.defineProperty(t,"offsetX",{value:t.pageX-C.left,writable:!0}),Object.defineProperty(t,"offsetY",{value:t.pageY-C.top,writable:!0})}if(t.target!==e.$overlay){var i=t.target.getBoundingClientRect(),H=e.$overlay.getBoundingClientRect(),n=(C={top:i.top+window.scrollY,left:i.left+window.scrollX},{top:H.top+window.scrollY,left:H.left+window.scrollX});if(!C||!n)return!1;Object.defineProperty(t,"offsetX",{value:t.offsetX-n.left+C.left,writable:!0}),Object.defineProperty(t,"offsetY",{value:t.offsetY-n.top+C.top,writable:!0})}return"mousemove"==t.type||"touchmove"==t.type?e._eventMove(t):"mouseup"!=t.type&&"touchend"!=t.type||e._eventMoveEnd(t),!1}},n=0;nt?(this.overlayLastMoveStartTime=0,this.overlayInMovement=!0,this.overlayHookPointX=this.viewW/2,this.overlayHookPointY=this.viewH/2,!1!==this.options.viewLiveFramerate?this._eventMove({offsetX:this.panelWidth/2,offsetY:this.panelHeight/2}):this._eventMoveEnd({offsetX:this.panelWidth/2,offsetY:this.panelHeight/2}),this.overlayInMovement=!1):(this.overlayLastMoveStartTime=t,this.overlayInMovement=!0,this.viewLocked=!0,e.offsetX>=this.viewX&&e.offsetX<=this.viewX+this.viewW&&e.offsetY>=this.viewY&&e.offsetY<=this.viewY+this.viewH?(this.overlayHookPointX=e.offsetX-this.viewX,this.overlayHookPointY=e.offsetY-this.viewY):(this.overlayHookPointX=this.viewW/2,this.overlayHookPointY=this.viewH/2,this._eventMove(e)))},_eventMove:function(e){var t=this;this._checkMousePosition(e),this.overlayInMovement&&(this.viewX=e.offsetX-this.overlayHookPointX,this.viewY=e.offsetY-this.overlayHookPointY,this.$view.style.left=this.viewX+"px",this.$view.style.top=this.viewY+"px",!1!==this.options.viewLiveFramerate&&(0==this.options.viewLiveFramerate?this._moveCy():this.overlayTimeout||(this.overlayTimeout=setTimeout((function(){t._moveCy(),t.overlayTimeout=!1}),1e3/this.options.viewLiveFramerate))))},_checkMousePosition:function(e){e.offsetX>this.viewX&&e.offsetXthis.viewY&&e.offsetY0&&(i=gM(C.width)/V||1),n>0&&(H=gM(C.height)/n||1)}return{width:C.width/i,height:C.height/H,top:C.top/H,right:C.right/i,bottom:C.bottom/H,left:C.left/i,x:C.left/i,y:C.top/H}}function yM(e){var t=vM(e),C=e.offsetWidth,i=e.offsetHeight;return Math.abs(t.width-C)<=1&&(C=t.width),Math.abs(t.height-i)<=1&&(i=t.height),{x:e.offsetLeft,y:e.offsetTop,width:C,height:i}}function ZM(e,t){var C=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(C&&cM(C)){var i=t;do{if(i&&e.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function SM(e){return dM(e).getComputedStyle(e)}function bM(e){return["table","td","th"].indexOf(lM(e))>=0}function wM(e){return((uM(e)?e.ownerDocument:e.document)||window.document).documentElement}function xM(e){return"html"===lM(e)?e:e.assignedSlot||e.parentNode||(cM(e)?e.host:null)||wM(e)}function OM(e){return AM(e)&&"fixed"!==SM(e).position?e.offsetParent:null}function kM(e){for(var t=dM(e),C=OM(e);C&&bM(C)&&"static"===SM(C).position;)C=OM(C);return C&&("html"===lM(C)||"body"===lM(C)&&"static"===SM(C).position)?t:C||function(e){var t=-1!==navigator.userAgent.toLowerCase().indexOf("firefox");if(-1!==navigator.userAgent.indexOf("Trident")&&AM(e)&&"fixed"===SM(e).position)return null;for(var C=xM(e);AM(C)&&["html","body"].indexOf(lM(C))<0;){var i=SM(C);if("none"!==i.transform||"none"!==i.perspective||"paint"===i.contain||-1!==["transform","perspective"].indexOf(i.willChange)||t&&"filter"===i.willChange||t&&i.filter&&"none"!==i.filter)return C;C=C.parentNode}return null}(e)||t}function EM(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function PM(e,t,C){return fM(e,pM(t,C))}function TM(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function _M(e,t){return t.reduce((function(t,C){return t[C]=e,t}),{})}var BM={name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,C=e.state,i=e.name,H=e.options,n=C.elements.arrow,V=C.modifiersData.popperOffsets,r=mM(C.placement),L=EM(r),o=[rM,VM].indexOf(r)>=0?"height":"width";if(n&&V){var a=function(e,t){return TM("number"!=typeof(e="function"==typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:_M(e,LM))}(H.padding,C),M=yM(n),s="y"===L?HM:rM,l="y"===L?nM:VM,d=C.rects.reference[o]+C.rects.reference[L]-V[L]-C.rects.popper[o],u=V[L]-C.rects.reference[L],A=kM(n),c=A?"y"===L?A.clientHeight||0:A.clientWidth||0:0,h=d/2-u/2,m=a[s],f=c-M[o]-a[l],p=c/2-M[o]/2+h,g=PM(m,p,f),v=L;C.modifiersData[i]=((t={})[v]=g,t.centerOffset=g-p,t)}},effect:function(e){var t=e.state,C=e.options.element,i=void 0===C?"[data-popper-arrow]":C;null!=i&&("string"!=typeof i||(i=t.elements.popper.querySelector(i)))&&("production"!==process.env.NODE_ENV&&(AM(i)||console.error(['Popper: "arrow" element must be an HTMLElement (not an SVGElement).',"To use an SVG arrow, wrap it in an HTMLElement that will be used as","the arrow."].join(" "))),ZM(t.elements.popper,i)?t.elements.arrow=i:"production"!==process.env.NODE_ENV&&console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper',"element."].join(" ")))},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function DM(e){return e.split("-")[1]}var NM={top:"auto",right:"auto",bottom:"auto",left:"auto"};function RM(e){var t,C=e.popper,i=e.popperRect,H=e.placement,n=e.variation,V=e.offsets,r=e.position,L=e.gpuAcceleration,o=e.adaptive,a=e.roundOffsets,M=e.isFixed,s=V.x,l=void 0===s?0:s,d=V.y,u=void 0===d?0:d,A="function"==typeof a?a({x:l,y:u}):{x:l,y:u};l=A.x,u=A.y;var c=V.hasOwnProperty("x"),h=V.hasOwnProperty("y"),m=rM,f=HM,p=window;if(o){var g=kM(C),v="clientHeight",y="clientWidth";if(g===dM(C)&&"static"!==SM(g=wM(C)).position&&"absolute"===r&&(v="scrollHeight",y="scrollWidth"),g=g,H===HM||(H===rM||H===VM)&&n===oM)f=nM,u-=(M&&p.visualViewport?p.visualViewport.height:g[v])-i.height,u*=L?1:-1;if(H===rM||(H===HM||H===nM)&&n===oM)m=VM,l-=(M&&p.visualViewport?p.visualViewport.width:g[y])-i.width,l*=L?1:-1}var Z,S=Object.assign({position:r},o&&NM),b=!0===a?function(e){var t=e.x,C=e.y,i=window.devicePixelRatio||1;return{x:gM(t*i)/i||0,y:gM(C*i)/i||0}}({x:l,y:u}):{x:l,y:u};return l=b.x,u=b.y,L?Object.assign({},S,((Z={})[f]=h?"0":"",Z[m]=c?"0":"",Z.transform=(p.devicePixelRatio||1)<=1?"translate("+l+"px, "+u+"px)":"translate3d("+l+"px, "+u+"px, 0)",Z)):Object.assign({},S,((t={})[f]=h?u+"px":"",t[m]=c?l+"px":"",t.transform="",t))}var FM={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(e){var t=e.state,C=e.options,i=C.gpuAcceleration,H=void 0===i||i,n=C.adaptive,V=void 0===n||n,r=C.roundOffsets,L=void 0===r||r;if("production"!==process.env.NODE_ENV){var o=SM(t.elements.popper).transitionProperty||"";V&&["transform","top","right","bottom","left"].some((function(e){return o.indexOf(e)>=0}))&&console.warn(["Popper: Detected CSS transitions on at least one of the following",'CSS properties: "transform", "top", "right", "bottom", "left".',"\n\n",'Disable the "computeStyles" modifier\'s `adaptive` option to allow',"for smooth transitions, or remove these properties from the CSS","transition declaration on the popper element if only transitioning","opacity or background-color for example.","\n\n","We recommend using the popper element as a wrapper around an inner","element that can have any CSS property transitioned for animations."].join(" "))}var a={placement:mM(t.placement),variation:DM(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:H,isFixed:"fixed"===t.options.strategy};null!=t.modifiersData.popperOffsets&&(t.styles.popper=Object.assign({},t.styles.popper,RM(Object.assign({},a,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:V,roundOffsets:L})))),null!=t.modifiersData.arrow&&(t.styles.arrow=Object.assign({},t.styles.arrow,RM(Object.assign({},a,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:L})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})},data:{}},IM={passive:!0};var zM={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(e){var t=e.state,C=e.instance,i=e.options,H=i.scroll,n=void 0===H||H,V=i.resize,r=void 0===V||V,L=dM(t.elements.popper),o=[].concat(t.scrollParents.reference,t.scrollParents.popper);return n&&o.forEach((function(e){e.addEventListener("scroll",C.update,IM)})),r&&L.addEventListener("resize",C.update,IM),function(){n&&o.forEach((function(e){e.removeEventListener("scroll",C.update,IM)})),r&&L.removeEventListener("resize",C.update,IM)}},data:{}},jM={left:"right",right:"left",bottom:"top",top:"bottom"};function GM(e){return e.replace(/left|right|bottom|top/g,(function(e){return jM[e]}))}var WM={start:"end",end:"start"};function $M(e){return e.replace(/start|end/g,(function(e){return WM[e]}))}function UM(e){var t=dM(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function YM(e){return vM(wM(e)).left+UM(e).scrollLeft}function XM(e){var t=SM(e),C=t.overflow,i=t.overflowX,H=t.overflowY;return/auto|scroll|overlay|hidden/.test(C+H+i)}function qM(e){return["html","body","#document"].indexOf(lM(e))>=0?e.ownerDocument.body:AM(e)&&XM(e)?e:qM(xM(e))}function QM(e,t){var C;void 0===t&&(t=[]);var i=qM(e),H=i===(null==(C=e.ownerDocument)?void 0:C.body),n=dM(i),V=H?[n].concat(n.visualViewport||[],XM(i)?i:[]):i,r=t.concat(V);return H?r:r.concat(QM(xM(V)))}function KM(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function JM(e,t){return"viewport"===t?KM(function(e){var t=dM(e),C=wM(e),i=t.visualViewport,H=C.clientWidth,n=C.clientHeight,V=0,r=0;return i&&(H=i.width,n=i.height,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||(V=i.offsetLeft,r=i.offsetTop)),{width:H,height:n,x:V+YM(e),y:r}}(e)):uM(t)?function(e){var t=vM(e);return t.top=t.top+e.clientTop,t.left=t.left+e.clientLeft,t.bottom=t.top+e.clientHeight,t.right=t.left+e.clientWidth,t.width=e.clientWidth,t.height=e.clientHeight,t.x=t.left,t.y=t.top,t}(t):KM(function(e){var t,C=wM(e),i=UM(e),H=null==(t=e.ownerDocument)?void 0:t.body,n=fM(C.scrollWidth,C.clientWidth,H?H.scrollWidth:0,H?H.clientWidth:0),V=fM(C.scrollHeight,C.clientHeight,H?H.scrollHeight:0,H?H.clientHeight:0),r=-i.scrollLeft+YM(e),L=-i.scrollTop;return"rtl"===SM(H||C).direction&&(r+=fM(C.clientWidth,H?H.clientWidth:0)-n),{width:n,height:V,x:r,y:L}}(wM(e)))}function es(e,t,C){var i="clippingParents"===t?function(e){var t=QM(xM(e)),C=["absolute","fixed"].indexOf(SM(e).position)>=0&&AM(e)?kM(e):e;return uM(C)?t.filter((function(e){return uM(e)&&ZM(e,C)&&"body"!==lM(e)})):[]}(e):[].concat(t),H=[].concat(i,[C]),n=H[0],V=H.reduce((function(t,C){var i=JM(e,C);return t.top=fM(i.top,t.top),t.right=pM(i.right,t.right),t.bottom=pM(i.bottom,t.bottom),t.left=fM(i.left,t.left),t}),JM(e,n));return V.width=V.right-V.left,V.height=V.bottom-V.top,V.x=V.left,V.y=V.top,V}function ts(e){var t,C=e.reference,i=e.element,H=e.placement,n=H?mM(H):null,V=H?DM(H):null,r=C.x+C.width/2-i.width/2,L=C.y+C.height/2-i.height/2;switch(n){case HM:t={x:r,y:C.y-i.height};break;case nM:t={x:r,y:C.y+C.height};break;case VM:t={x:C.x+C.width,y:L};break;case rM:t={x:C.x-i.width,y:L};break;default:t={x:C.x,y:C.y}}var o=n?EM(n):null;if(null!=o){var a="y"===o?"height":"width";switch(V){case"start":t[o]=t[o]-(C[a]/2-i[a]/2);break;case oM:t[o]=t[o]+(C[a]/2-i[a]/2)}}return t}function Cs(e,t){void 0===t&&(t={});var C=t,i=C.placement,H=void 0===i?e.placement:i,n=C.boundary,V=void 0===n?"clippingParents":n,r=C.rootBoundary,L=void 0===r?"viewport":r,o=C.elementContext,a=void 0===o?"popper":o,M=C.altBoundary,s=void 0!==M&&M,l=C.padding,d=void 0===l?0:l,u=TM("number"!=typeof d?d:_M(d,LM)),A="popper"===a?"reference":"popper",c=e.rects.popper,h=e.elements[s?A:a],m=es(uM(h)?h:h.contextElement||wM(e.elements.popper),V,L),f=vM(e.elements.reference),p=ts({reference:f,element:c,strategy:"absolute",placement:H}),g=KM(Object.assign({},c,p)),v="popper"===a?g:f,y={top:m.top-v.top+u.top,bottom:v.bottom-m.bottom+u.bottom,left:m.left-v.left+u.left,right:v.right-m.right+u.right},Z=e.modifiersData.offset;if("popper"===a&&Z){var S=Z[H];Object.keys(y).forEach((function(e){var t=[VM,nM].indexOf(e)>=0?1:-1,C=[HM,nM].indexOf(e)>=0?"y":"x";y[e]+=S[C]*t}))}return y}function is(e,t){void 0===t&&(t={});var C=t,i=C.placement,H=C.boundary,n=C.rootBoundary,V=C.padding,r=C.flipVariations,L=C.allowedAutoPlacements,o=void 0===L?MM:L,a=DM(i),M=a?r?aM:aM.filter((function(e){return DM(e)===a})):LM,s=M.filter((function(e){return o.indexOf(e)>=0}));0===s.length&&(s=M,"production"!==process.env.NODE_ENV&&console.error(["Popper: The `allowedAutoPlacements` option did not allow any","placements. Ensure the `placement` option matches the variation","of the allowed placements.",'For example, "auto" cannot be used to allow "bottom-start".','Use "auto-start" instead.'].join(" ")));var l=s.reduce((function(t,C){return t[C]=Cs(e,{placement:C,boundary:H,rootBoundary:n,padding:V})[mM(C)],t}),{});return Object.keys(l).sort((function(e,t){return l[e]-l[t]}))}var Hs={name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,C=e.options,i=e.name;if(!t.modifiersData[i]._skip){for(var H=C.mainAxis,n=void 0===H||H,V=C.altAxis,r=void 0===V||V,L=C.fallbackPlacements,o=C.padding,a=C.boundary,M=C.rootBoundary,s=C.altBoundary,l=C.flipVariations,d=void 0===l||l,u=C.allowedAutoPlacements,A=t.options.placement,c=mM(A),h=L||(c===A||!d?[GM(A)]:function(e){if("auto"===mM(e))return[];var t=GM(e);return[$M(e),t,$M(t)]}(A)),m=[A].concat(h).reduce((function(e,C){return e.concat("auto"===mM(C)?is(t,{placement:C,boundary:a,rootBoundary:M,padding:o,flipVariations:d,allowedAutoPlacements:u}):C)}),[]),f=t.rects.reference,p=t.rects.popper,g=new Map,v=!0,y=m[0],Z=0;Z=0,O=x?"width":"height",k=Cs(t,{placement:S,boundary:a,rootBoundary:M,altBoundary:s,padding:o}),E=x?w?VM:rM:w?nM:HM;f[O]>p[O]&&(E=GM(E));var P=GM(E),T=[];if(n&&T.push(k[b]<=0),r&&T.push(k[E]<=0,k[P]<=0),T.every((function(e){return e}))){y=S,v=!1;break}g.set(S,T)}if(v)for(var _=function(e){var t=m.find((function(t){var C=g.get(t);if(C)return C.slice(0,e).every((function(e){return e}))}));if(t)return y=t,"break"},B=d?3:1;B>0;B--){if("break"===_(B))break}t.placement!==y&&(t.modifiersData[i]._skip=!0,t.placement=y,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function ns(e,t,C){return void 0===C&&(C={x:0,y:0}),{top:e.top-t.height-C.y,right:e.right-t.width+C.x,bottom:e.bottom-t.height+C.y,left:e.left-t.width-C.x}}function Vs(e){return[HM,VM,nM,rM].some((function(t){return e[t]>=0}))}var rs={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,C=e.name,i=t.rects.reference,H=t.rects.popper,n=t.modifiersData.preventOverflow,V=Cs(t,{elementContext:"reference"}),r=Cs(t,{altBoundary:!0}),L=ns(V,i),o=ns(r,H,n),a=Vs(L),M=Vs(o);t.modifiersData[C]={referenceClippingOffsets:L,popperEscapeOffsets:o,isReferenceHidden:a,hasPopperEscaped:M},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":a,"data-popper-escaped":M})}};var Ls={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(e){var t=e.state,C=e.options,i=e.name,H=C.offset,n=void 0===H?[0,0]:H,V=MM.reduce((function(e,C){return e[C]=function(e,t,C){var i=mM(e),H=[rM,HM].indexOf(i)>=0?-1:1,n="function"==typeof C?C(Object.assign({},t,{placement:e})):C,V=n[0],r=n[1];return V=V||0,r=(r||0)*H,[rM,VM].indexOf(i)>=0?{x:r,y:V}:{x:V,y:r}}(C,t.rects,n),e}),{}),r=V[t.placement],L=r.x,o=r.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=L,t.modifiersData.popperOffsets.y+=o),t.modifiersData[i]=V}};var os={name:"popperOffsets",enabled:!0,phase:"read",fn:function(e){var t=e.state,C=e.name;t.modifiersData[C]=ts({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})},data:{}};var as={name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,C=e.options,i=e.name,H=C.mainAxis,n=void 0===H||H,V=C.altAxis,r=void 0!==V&&V,L=C.boundary,o=C.rootBoundary,a=C.altBoundary,M=C.padding,s=C.tether,l=void 0===s||s,d=C.tetherOffset,u=void 0===d?0:d,A=Cs(t,{boundary:L,rootBoundary:o,padding:M,altBoundary:a}),c=mM(t.placement),h=DM(t.placement),m=!h,f=EM(c),p="x"===f?"y":"x",g=t.modifiersData.popperOffsets,v=t.rects.reference,y=t.rects.popper,Z="function"==typeof u?u(Object.assign({},t.rects,{placement:t.placement})):u,S="number"==typeof Z?{mainAxis:Z,altAxis:Z}:Object.assign({mainAxis:0,altAxis:0},Z),b=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,w={x:0,y:0};if(g){if(n){var x,O="y"===f?HM:rM,k="y"===f?nM:VM,E="y"===f?"height":"width",P=g[f],T=P+A[O],_=P-A[k],B=l?-y[E]/2:0,D="start"===h?v[E]:y[E],N="start"===h?-y[E]:-v[E],R=t.elements.arrow,F=l&&R?yM(R):{width:0,height:0},I=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},z=I[O],j=I[k],G=PM(0,v[E],F[E]),W=m?v[E]/2-B-G-z-S.mainAxis:D-G-z-S.mainAxis,$=m?-v[E]/2+B+G+j+S.mainAxis:N+G+j+S.mainAxis,U=t.elements.arrow&&kM(t.elements.arrow),Y=U?"y"===f?U.clientTop||0:U.clientLeft||0:0,X=null!=(x=null==b?void 0:b[f])?x:0,q=P+$-X,Q=PM(l?pM(T,P+W-X-Y):T,P,l?fM(_,q):_);g[f]=Q,w[f]=Q-P}if(r){var K,J="x"===f?HM:rM,ee="x"===f?nM:VM,te=g[p],Ce="y"===p?"height":"width",ie=te+A[J],He=te-A[ee],ne=-1!==[HM,rM].indexOf(c),Ve=null!=(K=null==b?void 0:b[p])?K:0,re=ne?ie:te-v[Ce]-y[Ce]-Ve+S.altAxis,Le=ne?te+v[Ce]+y[Ce]-Ve-S.altAxis:He,oe=l&&ne?function(e,t,C){var i=PM(e,t,C);return i>C?C:i}(re,te,Le):PM(l?re:ie,te,l?Le:He);g[p]=oe,w[p]=oe-te}t.modifiersData[i]=w}},requiresIfExists:["offset"]};function Ms(e,t,C){void 0===C&&(C=!1);var i,H=AM(t),n=AM(t)&&function(e){var t=e.getBoundingClientRect(),C=gM(t.width)/e.offsetWidth||1,i=gM(t.height)/e.offsetHeight||1;return 1!==C||1!==i}(t),V=wM(t),r=vM(e,n),L={scrollLeft:0,scrollTop:0},o={x:0,y:0};return(H||!H&&!C)&&(("body"!==lM(t)||XM(V))&&(L=(i=t)!==dM(i)&&AM(i)?function(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}(i):UM(i)),AM(t)?((o=vM(t,!0)).x+=t.clientLeft,o.y+=t.clientTop):V&&(o.x=YM(V))),{x:r.left+L.scrollLeft-o.x,y:r.top+L.scrollTop-o.y,width:r.width,height:r.height}}function ss(e){var t=new Map,C=new Set,i=[];function H(e){C.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach((function(e){if(!C.has(e)){var i=t.get(e);i&&H(i)}})),i.push(e)}return e.forEach((function(e){t.set(e.name,e)})),e.forEach((function(e){C.has(e.name)||H(e)})),i}function ls(e){var t;return function(){return t||(t=new Promise((function(C){Promise.resolve().then((function(){t=void 0,C(e())}))}))),t}}function ds(e){for(var t=arguments.length,C=new Array(t>1?t-1:0),i=1;i100){console.error("Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.");break}if(!0!==H.reset){var V=H.orderedModifiers[n],o=V.fn,a=V.options,M=void 0===a?{}:a,s=V.name;"function"==typeof o&&(H=o({state:H,options:M,name:s,instance:L})||H)}else H.reset=!1,n=-1}}else"production"!==process.env.NODE_ENV&&console.error(cs)}},update:ls((function(){return new Promise((function(e){L.forceUpdate(),e(H)}))})),destroy:function(){o(),r=!0}};if(!ms(e,t))return"production"!==process.env.NODE_ENV&&console.error(cs),L;function o(){V.forEach((function(e){return e()})),V=[]}return L.setOptions(C).then((function(e){!r&&C.onFirstUpdate&&C.onFirstUpdate(e)})),L}}var ps=fs(),gs=fs({defaultModifiers:[zM,os,FM,hM]}),vs=fs({defaultModifiers:[zM,os,FM,hM,Ls,Hs,as,BM,rs]}),ys=me(Object.freeze({__proto__:null,popperGenerator:fs,detectOverflow:Cs,createPopperBase:ps,createPopper:vs,createPopperLite:gs,top:HM,bottom:nM,right:VM,left:rM,auto:"auto",basePlacements:LM,start:"start",end:oM,clippingParents:"clippingParents",viewport:"viewport",popper:"popper",reference:"reference",variationPlacements:aM,placements:MM,beforeRead:"beforeRead",read:"read",afterRead:"afterRead",beforeMain:"beforeMain",main:"main",afterMain:"afterMain",beforeWrite:"beforeWrite",write:"write",afterWrite:"afterWrite",modifierPhases:sM,applyStyles:hM,arrow:BM,computeStyles:FM,eventListeners:zM,flip:Hs,hide:rs,offset:Ls,popperOffsets:os,preventOverflow:as})),Zs=fe((function(e,t){var C;C=function(e){return function(e){var t={};function C(i){if(t[i])return t[i].exports;var H=t[i]={i:i,l:!1,exports:{}};return e[i].call(H.exports,H,H.exports,C),H.l=!0,H.exports}return C.m=e,C.c=t,C.i=function(e){return e},C.d=function(e,t,i){C.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},C.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return C.d(t,"a",t),t},C.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},C.p="",C(C.s=7)}([function(e,t,C){e.exports=null!=Object.assign?Object.assign.bind(Object):function(e){for(var t=arguments.length,C=Array(t>1?t-1:0),i=1;i1&&(console.warn("Popper.js Extension should only be used on one element."),console.warn("Ignoring all subsequent elements"))}e.exports={popper:function(e){return r(this),H(this[0],V(this[0],e))},popperRef:function(e){return r(this),n(this[0],V(this[0],e))}}},function(e,t,C){var i=C(0),H=C(2).getPopper,n=C(1).getRef;function V(e,t){return i({},{boundingBox:{top:0,left:0,right:0,bottom:0,w:3,h:3},renderedDimensions:function(){return{w:3,h:3}},renderedPosition:function(){return{x:0,y:0}},popper:{},cy:e},t)}e.exports={popper:function(e){return H(this,V(this,e))},popperRef:function(e){return n(this,V(this,e))}}},function(e,t,C){e.exports={getBoundingBox:function(e,t){var C=t.renderedPosition,i=t.cy,H=t.renderedDimensions,n=i.container().getBoundingClientRect(),V=H(e),r=C(e);return{top:r.y+n.top,left:r.x+n.left,right:r.x+V.w+n.left,bottom:r.y+V.h+n.top,width:V.w,height:V.h}}}},function(e,t,C){e.exports={getContent:function(e,t){var C=null;if("function"!=typeof t){if(t instanceof HTMLElement)return t;throw new Error("Can not create popper from 'target' with unknown type")}if(null===(C=t(e)))throw new Error("No 'target' specified to create popper");return C}}},function(e,t,C){var i=C(4),H=C(3),n=function(e){e&&(e("core","popper",i.popper),e("collection","popper",H.popper),e("core","popperRef",i.popperRef),e("collection","popperRef",H.popperRef))};"undefined"!=typeof cytoscape&&n(cytoscape),e.exports=n},function(t,C){t.exports=e}])},e.exports=C(ys)})),Ss=he(Zs),bs=function(e,t,C){this.source=e,this.target=t,this.type=C},ws=bs,xs=function(){function e(e,t,C,i){var H=this;if(this.linkAccessor=C,this.modules=new Array(e),this.roots=[],i)this.initModulesFromGroup(i);else{this.roots.push(new Ts);for(var n=0;n=this.R))return this.merge(t.a,t.b,e),!0}},e.prototype.nEdges=function(e,t){var C=e.incoming.intersection(t.incoming),i=e.outgoing.intersection(t.outgoing);return this.R-C.count()-i.count()},e.prototype.getGroupHierarchy=function(e){var t=this,C=[];return ks(this.roots[0],{},C),this.allEdges().forEach((function(i){var H=t.modules[i.source],n=t.modules[i.target];e.push(new bs(void 0===H.gid?i.source:C[H.gid],void 0===n.gid?i.target:C[n.gid],i.type))})),C},e.prototype.allEdges=function(){var t=[];return e.getEdges(this.roots[0],t),t},e.getEdges=function(t,C){t.forAll((function(t){t.getEdges(C),e.getEdges(t.children,C)}))},e}(),Os=xs;function ks(e,t,C){e.forAll((function(e){if(e.isLeaf())t.leaves||(t.leaves=[]),t.leaves.push(e.id);else{var i=t;if(e.gid=C.length,!e.isIsland()||e.isPredefined()){if(i={id:e.gid},e.isPredefined())for(var H in e.definition)i[H]=e.definition[H];t.groups||(t.groups=[]),t.groups.push(e.gid),C.push(i)}ks(e.children,i,C)}}))}var Es=function(){function e(e,t,C,i,H){void 0===t&&(t=new Bs),void 0===C&&(C=new Bs),void 0===i&&(i=new Ts),this.id=e,this.outgoing=t,this.incoming=C,this.children=i,this.definition=H}return e.prototype.getEdges=function(e){var t=this;this.outgoing.forAll((function(C,i){C.forAll((function(C){e.push(new bs(t.id,C.id,i))}))}))},e.prototype.isLeaf=function(){return 0===this.children.count()},e.prototype.isIsland=function(){return 0===this.outgoing.count()&&0===this.incoming.count()},e.prototype.isPredefined=function(){return void 0!==this.definition},e}(),Ps=Es;var Ts=function(){function e(){this.table={}}return e.prototype.count=function(){return Object.keys(this.table).length},e.prototype.intersection=function(t){var C=new e;return C.table=function(e,t){var C={};for(var i in e)i in t&&(C[i]=e[i]);return C}(this.table,t.table),C},e.prototype.intersectionCount=function(e){return this.intersection(e).count()},e.prototype.contains=function(e){return e in this.table},e.prototype.add=function(e){this.table[e.id]=e},e.prototype.remove=function(e){delete this.table[e.id]},e.prototype.forAll=function(e){for(var t in this.table)e(this.table[t])},e.prototype.modules=function(){var e=[];return this.forAll((function(t){t.isPredefined()||e.push(t)})),e},e}(),_s=Ts,Bs=function(){function e(){this.sets={},this.n=0}return e.prototype.count=function(){return this.n},e.prototype.contains=function(e){var t=!1;return this.forAllModules((function(C){t||C.id!=e||(t=!0)})),t},e.prototype.add=function(e,t){(e in this.sets?this.sets[e]:this.sets[e]=new Ts).add(t),++this.n},e.prototype.remove=function(e,t){var C=this.sets[e];C.remove(t),0===C.count()&&delete this.sets[e],--this.n},e.prototype.forAll=function(e){for(var t in this.sets)e(this.sets[t],Number(t))},e.prototype.forAllModules=function(e){this.forAll((function(t,C){return t.forAll(e)}))},e.prototype.intersection=function(t){var C=new e;return this.forAll((function(e,i){if(i in t.sets){var H=e.intersection(t.sets[i]),n=H.count();n>0&&(C.sets[i]=H,C.n+=n)}})),C},e}(),Ds=Bs;var Ns=function(e,t,C,i){for(var H=e.length,n=new xs(H,t,C,i);n.greedyMerge(););var V=[],r=n.getGroupHierarchy(V);return V.forEach((function(t){var C=function(C){var i=t[C];"number"==typeof i&&(t[C]=e[i])};C("source"),C("target")})),{groups:r,powerEdges:V}},Rs=Object.defineProperty({PowerEdge:ws,Configuration:Os,Module:Ps,ModuleSet:_s,LinkSets:Ds,getGroups:Ns},"__esModule",{value:!0});function Fs(e,t){var C={};for(var i in e)C[i]={};for(var i in t)C[i]={};return Object.keys(C).length}function Is(e,t){var C=0;for(var i in e)void 0!==t[i]&&++C;return C}function zs(e,t,C,i){var H=function(e,t){var C={},i=function(e,t){void 0===C[e]&&(C[e]={}),C[e][t]={}};return e.forEach((function(e){var C=t.getSourceIndex(e),H=t.getTargetIndex(e);i(C,H),i(H,C)})),C}(e,i);e.forEach((function(e){var n=H[i.getSourceIndex(e)],V=H[i.getTargetIndex(e)];i.setLength(e,1+t*C(n,V))}))}var js=function(e,t,C){void 0===C&&(C=1),zs(e,C,(function(e,t){return Math.sqrt(Fs(e,t)-Is(e,t))}),t)};var Gs=function(e,t,C){void 0===C&&(C=1),zs(e,C,(function(e,t){return Math.min(Object.keys(e).length,Object.keys(t).length)<1.1?0:Is(e,t)/Fs(e,t)}),t)};var Ws=function(e,t,C,i){var H=$s(e,t,i),n={};H.forEach((function(e,t){return e.forEach((function(e){return n[e]=t}))}));var V=[];return t.forEach((function(e){var t=i.getSourceIndex(e),H=i.getTargetIndex(e);n[t]!==n[H]&&V.push({axis:C,left:t,right:H,gap:i.getMinSeparation(e)})})),V};function $s(e,t,C){var i=[],H=0,n=[],V=[];function r(e){e.index=e.lowlink=H++,n.push(e),e.onStack=!0;for(var t=0,C=e.out;tn;){var V=t[n][H];V>0&&V1e-9)break;var l=this.offsetDir();for(i=0;i1&&d>u||!isFinite(u))for(i=0;i1&&(A=1);var c=u*u,h=2*A*(d-u)/(c*d),m=d*d*d,f=2*-A/(c*m);for(isFinite(h)||console.log(h),i=0;i0?Z-(w+1)*g:Z-(w-1)*g)&&s<=p&&(this.scaleSnapByMaxH?(this.g[i][L]+=r*v*s,this.H[i][L][L]+=r*v):(this.g[i][L]+=v*s,this.H[i][L][L]+=v))}this.locks.isEmpty()||this.locks.apply((function(C,H){for(i=0;i0;)for(var H=t;H-- >0;)C(i,H)},e.prototype.matrixApply=function(t){e.mApply(this.k,this.n,t)},e.prototype.computeNextPosition=function(e,t){var C=this;this.computeDerivatives(e);var i=this.computeStepSize(this.g);if(this.stepAndProject(e,t,this.g,i),this.project){this.matrixApply((function(i,H){return C.e[i][H]=e[i][H]-t[i][H]}));var H=this.computeStepSize(this.e);H=Math.max(.2,Math.min(H,1)),this.stepAndProject(e,t,this.e,H)}},e.prototype.run=function(e){for(var t=Number.MAX_VALUE,C=!1;!C&&e-- >0;){var i=this.rungeKutta();C=Math.abs(t/i-1)>16)/this.range},e.prototype.getNextBetween=function(e,t){return e+this.getNext()*(t-e)},e}(),el=Js,tl=Object.defineProperty({Locks:qs,Descent:Ks,PseudoRandom:el},"__esModule",{value:!0}),Cl=function(){function e(e){this.scale=e,this.AB=0,this.AD=0,this.A2=0}return e.prototype.addVariable=function(e){var t=this.scale/e.scale,C=e.offset/e.scale,i=e.weight;this.AB+=i*t*C,this.AD+=i*t*e.desiredPosition,this.A2+=i*t*t},e.prototype.getPosn=function(){return(this.AD-this.AB)/this.A2},e}(),il=Cl,Hl=function(){function e(e,t,C,i){void 0===i&&(i=!1),this.left=e,this.right=t,this.gap=C,this.equality=i,this.active=!1,this.unsatisfiable=!1,this.left=e,this.right=t,this.gap=C,this.equality=i}return e.prototype.slack=function(){return this.unsatisfiable?Number.MAX_VALUE:this.right.scale*this.right.position()-this.gap-this.left.scale*this.left.position()},e}(),nl=Hl,Vl=function(){function e(e,t,C){void 0===t&&(t=1),void 0===C&&(C=1),this.desiredPosition=e,this.weight=t,this.scale=C,this.offset=0}return e.prototype.dfdv=function(){return 2*this.weight*(this.position()-this.desiredPosition)},e.prototype.position=function(){return(this.block.ps.scale*this.block.posn+this.offset)/this.scale},e.prototype.visitNeighbours=function(e,t){var C=function(C,i){return C.active&&e!==i&&t(C,i)};this.cOut.forEach((function(e){return C(e,e.right)})),this.cIn.forEach((function(e){return C(e,e.left)}))},e}(),rl=Vl,Ll=function(){function e(e){this.vars=[],e.offset=0,this.ps=new Cl(e.scale),this.addVariable(e)}return e.prototype.addVariable=function(e){e.block=this,this.vars.push(e),this.ps.addVariable(e),this.posn=this.ps.getPosn()},e.prototype.updateWeightedPosition=function(){this.ps.AB=this.ps.AD=this.ps.A2=0;for(var e=0,t=this.vars.length;e=0?this.inactive.push(t):this.bs.merge(t)}}},e.prototype.solve=function(){this.satisfy();for(var e=Number.MAX_VALUE,t=this.bs.cost();Math.abs(e-t)>1e-4;)this.satisfy(),e=t,t=this.bs.cost();return t},e.LAGRANGIAN_TOLERANCE=-1e-4,e.ZERO_UPPERBOUND=-1e-10,e}(),ll=sl;var dl,ul=function(e,t,C){for(var i=e.map((function(e){return new Vl(e.desiredCenter)})),H=[],n=e.length,V=0;V0)}return null}}return e.prototype.clear=function(){this._root=null,this.size=0},e.prototype.find=function(e){for(var t=this._root;null!==t;){var C=this._comparator(e,t.data);if(0===C)return t.data;t=t.get_child(C>0)}return null},e.prototype.lowerBound=function(e){return this._bound(e,this._comparator)},e.prototype.upperBound=function(e){var t=this._comparator;return this._bound(e,(function(e,C){return t(C,e)}))},e.prototype.min=function(){var e=this._root;if(null===e)return null;for(;null!==e.left;)e=e.left;return e.data},e.prototype.max=function(){var e=this._root;if(null===e)return null;for(;null!==e.right;)e=e.right;return e.data},e.prototype.iterator=function(){return new fl(this)},e.prototype.each=function(e){for(var t,C=this.iterator();null!==(t=C.next());)e(t)},e.prototype.reach=function(e){for(var t,C=this.iterator();null!==(t=C.prev());)e(t)},e.prototype._bound=function(e,t){for(var C=this._root,i=this.iterator();null!==C;){var H=this._comparator(e,C.data);if(0===H)return i._cursor=C,i;i._ancestors.push(C),C=C.get_child(H>0)}for(var n=i._ancestors.length-1;n>=0;--n)if(t(e,(C=i._ancestors[n]).data)>0)return i._cursor=C,i._ancestors.length=n,i;return i._ancestors.length=0,i},e}(),ml=hl,fl=function(){function e(e){this._tree=e,this._ancestors=[],this._cursor=null}return e.prototype.data=function(){return null!==this._cursor?this._cursor.data:null},e.prototype.next=function(){if(null===this._cursor){var e=this._tree._root;null!==e&&this._minNode(e)}else{var t;if(null===this._cursor.right)do{if(t=this._cursor,!this._ancestors.length){this._cursor=null;break}this._cursor=this._ancestors.pop()}while(this._cursor.right===t);else this._ancestors.push(this._cursor),this._minNode(this._cursor.right)}return null!==this._cursor?this._cursor.data:null},e.prototype.prev=function(){if(null===this._cursor){var e=this._tree._root;null!==e&&this._maxNode(e)}else{var t;if(null===this._cursor.left)do{if(t=this._cursor,!this._ancestors.length){this._cursor=null;break}this._cursor=this._ancestors.pop()}while(this._cursor.left===t);else this._ancestors.push(this._cursor),this._maxNode(this._cursor.left)}return null!==this._cursor?this._cursor.data:null},e.prototype._minNode=function(e){for(;null!==e.left;)this._ancestors.push(e),e=e.left;this._cursor=e},e.prototype._maxNode=function(e){for(;null!==e.right;)this._ancestors.push(e),e=e.right;this._cursor=e},e}(),pl=fl,gl=function(){function e(e){this.data=e,this.left=null,this.right=null,this.red=!0}return e.prototype.get_child=function(e){return e?this.right:this.left},e.prototype.set_child=function(e,t){e?this.right=t:this.left=t},e}(),vl=function(e){function t(t){var C=e.call(this)||this;return C._root=null,C._comparator=t,C.size=0,C}return cl(t,e),t.prototype.insert=function(e){var C=!1;if(null===this._root)this._root=new gl(e),C=!0,this.size++;else{var i=new gl(void 0),H=!1,n=!1,V=null,r=i,L=null,o=this._root;for(r.right=this._root;;){if(null===o?(o=new gl(e),L.set_child(H,o),C=!0,this.size++):t.is_red(o.left)&&t.is_red(o.right)&&(o.red=!0,o.left.red=!1,o.right.red=!1),t.is_red(o)&&t.is_red(L)){var a=r.right===V;o===L.get_child(n)?r.set_child(a,t.single_rotate(V,!n)):r.set_child(a,t.double_rotate(V,!n))}var M=this._comparator(o.data,e);if(0===M)break;n=H,H=M<0,null!==V&&(r=V),V=L,L=o,o=o.get_child(H)}this._root=i.right}return this._root.red=!1,C},t.prototype.remove=function(e){if(null===this._root)return!1;var C=new gl(void 0),i=C;i.right=this._root;for(var H=null,n=null,V=null,r=!0;null!==i.get_child(r);){var L=r;n=H,H=i,i=i.get_child(r);var o=this._comparator(e,i.data);if(r=o>0,0===o&&(V=i),!t.is_red(i)&&!t.is_red(i.get_child(r)))if(t.is_red(i.get_child(!r))){var a=t.single_rotate(i,r);H.set_child(L,a),H=a}else if(!t.is_red(i.get_child(!r))){var M=H.get_child(!L);if(null!==M)if(t.is_red(M.get_child(!L))||t.is_red(M.get_child(L))){var s=n.right===H;t.is_red(M.get_child(L))?n.set_child(s,t.double_rotate(H,L)):t.is_red(M.get_child(!L))&&n.set_child(s,t.single_rotate(H,L));var l=n.get_child(s);l.red=!0,i.red=!0,l.left.red=!1,l.right.red=!1}else H.red=!1,M.red=!0,i.red=!0}}return null!==V&&(V.data=i.data,H.set_child(H.right===i,i.get_child(null===i.left)),this.size--),this._root=C.right,null!==this._root&&(this._root.red=!1),null!==V},t.is_red=function(e){return null!==e&&e.red},t.single_rotate=function(e,t){var C=e.get_child(!t);return e.set_child(!t,C.get_child(t)),C.set_child(t,e),e.red=!0,C.red=!1,C},t.double_rotate=function(e,C){return e.set_child(!C,t.single_rotate(e.get_child(!C),!C)),t.single_rotate(e,C)},t}(hl),yl=vl,Zl=Object.defineProperty({TreeBase:ml,Iterator:pl,RBTree:yl},"__esModule",{value:!0}),Sl=ce&&ce.__extends||function(){var e=function(t,C){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var C in t)t.hasOwnProperty(C)&&(e[C]=t[C])},e(t,C)};return function(t,C){function i(){this.constructor=t}e(t,C),t.prototype=null===C?Object.create(C):(i.prototype=C.prototype,new i)}}();function bl(e){return e.bounds=void 0!==e.leaves?e.leaves.reduce((function(e,t){return t.bounds.union(e)}),xl.empty()):xl.empty(),void 0!==e.groups&&(e.bounds=e.groups.reduce((function(e,t){return bl(t).union(e)}),e.bounds)),e.bounds=e.bounds.inflate(e.padding),e.bounds}var wl=bl,xl=function(){function e(e,t,C,i){this.x=e,this.X=t,this.y=C,this.Y=i}return e.empty=function(){return new e(Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY)},e.prototype.cx=function(){return(this.x+this.X)/2},e.prototype.cy=function(){return(this.y+this.Y)/2},e.prototype.overlapX=function(e){var t=this.cx(),C=e.cx();return t<=C&&e.x0?C[0]:null},e.prototype.vertices=function(){return[{x:this.x,y:this.y},{x:this.X,y:this.y},{x:this.X,y:this.Y},{x:this.x,y:this.Y}]},e.lineIntersection=function(e,t,C,i,H,n,V,r){var L=C-e,o=V-H,a=i-t,M=r-n,s=M*L-o*a;if(0==s)return null;var l=e-H,d=t-n,u=(o*d-M*l)/s,A=(L*d-a*l)/s;return u>=0&&u<=1&&A>=0&&A<=1?{x:e+u*L,y:t+u*a}:null},e.prototype.inflate=function(t){return new e(this.x-t,this.X+t,this.y-t,this.Y+t)},e}(),Ol=xl;var kl=function(e,t,C){var i=e.rayIntersection(t.cx(),t.cy())||{x:e.cx(),y:e.cy()},H=t.rayIntersection(e.cx(),e.cy())||{x:t.cx(),y:t.cy()},n=H.x-i.x,V=H.y-i.y,r=Math.sqrt(n*n+V*V),L=r-C;return{sourceIntersection:i,targetIntersection:H,arrowStart:{x:i.x+L*n/r,y:i.y+L*V/r}}};var El=function(e,t,C){var i=t.rayIntersection(e.x,e.y);i||(i={x:t.cx(),y:t.cy()});var H=i.x-e.x,n=i.y-e.y,V=Math.sqrt(H*H+n*n);return{x:i.x-C*H/V,y:i.y-C*n/V}},Pl=function(e,t,C){this.v=e,this.r=t,this.pos=C,this.prev=Bl(),this.next=Bl()},Tl=function(e,t,C){this.isOpen=e,this.v=t,this.pos=C};function _l(e,t){return e.pos>t.pos?1:e.pos0&&(e[C].insert(H),H[i].insert(e))};C("next","prev"),C("prev","next")}};function Rl(e,t,C,i){void 0===i&&(i=!1);var H=e.padding,n=void 0!==e.groups?e.groups.length:0,V=void 0!==e.leaves?e.leaves.length:0,r=n?e.groups.reduce((function(e,i){return e.concat(Rl(i,t,C,!0))}),[]):[],L=(i?2:0)+V+n,o=new Array(L),a=new Array(L),M=0,s=function(e,t){a[M]=e,o[M++]=t};if(i){var l=e.bounds,d=t.getCentre(l),u=t.getSize(l)/2,A=t.getOpen(l),c=t.getClose(l),h=d-u+H/2,m=d+u-H/2;e.minVar.desiredPosition=h,s(t.makeRect(A,c,h,H),e.minVar),e.maxVar.desiredPosition=m,s(t.makeRect(A,c,m,H),e.maxVar)}V&&e.leaves.forEach((function(e){return s(e.bounds,e.variable)})),n&&e.groups.forEach((function(e){var C=e.bounds;s(t.makeRect(t.getOpen(C),t.getClose(C),t.getCentre(C),t.getSize(C)),e.minVar)}));var f=Fl(a,o,t,C);return n&&(o.forEach((function(e){e.cOut=[],e.cIn=[]})),f.forEach((function(e){e.left.cOut.push(e),e.right.cIn.push(e)})),e.groups.forEach((function(e){var C=(e.padding-t.getSize(e.bounds))/2;e.minVar.cIn.forEach((function(e){return e.gap+=C})),e.minVar.cOut.forEach((function(t){t.left=e.maxVar,t.gap+=C}))}))),r.concat(f)}function Fl(e,t,C,i){var H,n=e.length,V=2*n;console.assert(t.length>=n);var r=new Array(V);for(H=0;He[C]&&(e[C]=t)}n=e}))}},e.prototype.createAlignment=function(e){var t=this,C=this.nodes[e.offsets[0].node].variable;this.makeFeasible(e);var i="x"===e.axis?this.xConstraints:this.yConstraints;e.offsets.slice(1).forEach((function(e){var H=t.nodes[e.node].variable;i.push(new Al.Constraint(C,H,e.offset,!0))}))},e.prototype.createConstraints=function(e){var t=this,C=function(e){return void 0===e.type||"separation"===e.type};this.xConstraints=e.filter((function(e){return"x"===e.axis&&C(e)})).map((function(e){return t.createSeparation(e)})),this.yConstraints=e.filter((function(e){return"y"===e.axis&&C(e)})).map((function(e){return t.createSeparation(e)})),e.filter((function(e){return"alignment"===e.type})).forEach((function(e){return t.createAlignment(e)}))},e.prototype.setupVariablesAndBounds=function(e,t,C,i){this.nodes.forEach((function(H,n){H.fixed?(H.variable.weight=H.fixedWeight?H.fixedWeight:1e3,C[n]=i(H)):H.variable.weight=1;var V=(H.width||0)/2,r=(H.height||0)/2,L=e[n],o=t[n];H.bounds=new xl(L-V,L+V,o-r,o+r)}))},e.prototype.xProject=function(e,t,C){(this.rootGroup||this.avoidOverlaps||this.xConstraints)&&this.project(e,t,e,C,(function(e){return e.px}),this.xConstraints,Wl,(function(e){return e.bounds.setXCentre(C[e.variable.index]=e.variable.position())}),(function(e){var t=C[e.minVar.index]=e.minVar.position(),i=C[e.maxVar.index]=e.maxVar.position(),H=e.padding/2;e.bounds.x=t-H,e.bounds.X=i+H}))},e.prototype.yProject=function(e,t,C){(this.rootGroup||this.yConstraints)&&this.project(e,t,t,C,(function(e){return e.py}),this.yConstraints,Ul,(function(e){return e.bounds.setYCentre(C[e.variable.index]=e.variable.position())}),(function(e){var t=C[e.minVar.index]=e.minVar.position(),i=C[e.maxVar.index]=e.maxVar.position(),H=e.padding/2;e.bounds.y=t-H,e.bounds.Y=i+H}))},e.prototype.projectFunctions=function(){var e=this;return[function(t,C,i){return e.xProject(t,C,i)},function(t,C,i){return e.yProject(t,C,i)}]},e.prototype.project=function(e,t,C,i,H,n,V,r,L){this.setupVariablesAndBounds(e,t,i,H),this.rootGroup&&this.avoidOverlaps&&(bl(this.rootGroup),n=n.concat(V(this.rootGroup))),this.solve(this.variables,n,C,i),this.nodes.forEach(r),this.rootGroup&&this.avoidOverlaps&&(this.groups.forEach(L),bl(this.rootGroup))},e.prototype.solve=function(e,t,C,i){var H=new Al.Solver(e,t);H.setStartingPositions(C),H.setDesiredPositions(i),H.solve()},e}(),Jl=Kl,ed=Object.defineProperty({computeGroupBounds:wl,Rectangle:Ol,makeEdgeBetween:kl,makeEdgeTo:El,generateXConstraints:zl,generateYConstraints:Gl,generateXGroupConstraints:$l,generateYGroupConstraints:Yl,removeOverlaps:Xl,IndexedVariable:Ql,Projection:Jl},"__esModule",{value:!0}),td=function(){function e(e){this.elem=e,this.subheaps=[]}return e.prototype.toString=function(e){for(var t="",C=!1,i=0;ia&&(L.d=a,L.prev=V,C.reduceKey(L.q,L,(function(e,t){return e.q=t})))}}return H},e}(),ad=od,Md=Object.defineProperty({Calculator:ad},"__esModule",{value:!0}),sd=ce&&ce.__extends||function(){var e=function(t,C){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var C in t)t.hasOwnProperty(C)&&(e[C]=t[C])},e(t,C)};return function(t,C){function i(){this.constructor=t}e(t,C),t.prototype=null===C?Object.create(C):(i.prototype=C.prototype,new i)}}(),ld=function(){},dd=ld,ud=function(e,t,C,i){this.x1=e,this.y1=t,this.x2=C,this.y2=i},Ad=ud,cd=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return sd(t,e),t}(ld);function hd(e,t,C){return(t.x-e.x)*(C.y-e.y)-(C.x-e.x)*(t.y-e.y)}var md=hd;function fd(e,t,C){return hd(e,t,C)>0}function pd(e,t,C){return hd(e,t,C)<0}var gd=function(e){var t,C=e.slice(0).sort((function(e,t){return e.x!==t.x?t.x-e.x:t.y-e.y})),i=e.length,H=C[0].x;for(t=1;t=0&&C[t].x===o;t--);for(r=t+1,t=n;++t<=r;)if(!(hd(C[0],C[r],C[t])>=0&&t1&&!(hd(V[V.length-2],V[V.length-1],C[t])>0);)V.length-=1;0!=t&&V.push(C[t])}L!=r&&V.push(C[L]);var a=V.length;for(t=r;--t>=n;)if(!(hd(C[L],C[n],C[t])>=0&&t>n)){for(;V.length>a&&!(hd(V[V.length-2],V[V.length-1],C[t])>0);)V.length-=1;0!=t&&V.push(C[t])}}return V};var vd=function(e,t,C){t.slice(0).sort((function(t,C){return Math.atan2(t.y-e.y,t.x-e.x)-Math.atan2(C.y-e.y,C.x-e.x)})).forEach(C)};function yd(e,t){var C,i,H,n,V=t.length-1;if(pd(e,t[1],t[0])&&!fd(e,t[V-1],t[0]))return 0;for(C=0,i=V;;){if(i-C==1)return fd(e,t[C],t[i])?C:i;if((n=pd(e,t[(H=Math.floor((C+i)/2))+1],t[H]))&&!fd(e,t[H-1],t[H]))return H;fd(e,t[C+1],t[C])?n||fd(e,t[C],t[H])?i=H:C=H:n&&pd(e,t[C],t[H])?i=H:C=H}}function Zd(e,t){var C,i,H,n,V=t.length-1;if(fd(e,t[V-1],t[0])&&!pd(e,t[1],t[0]))return 0;for(C=0,i=V;;){if(i-C==1)return pd(e,t[C],t[i])?C:i;if(n=pd(e,t[(H=Math.floor((C+i)/2))+1],t[H]),fd(e,t[H-1],t[H])&&!n)return H;pd(e,t[C+1],t[C])?n?pd(e,t[C],t[H])?i=H:C=H:i=H:n?C=H:fd(e,t[C],t[H])?i=H:C=H}}function Sd(e,t,C,i,H,n){var V,r;r=i(e[V=C(t[0],e)],t);for(var L=!1;!L;){for(L=!0;V===e.length-1&&(V=0),!H(t[r],e[V],e[V+1]);)++V;for(;0===r&&(r=t.length-1),!n(e[V],t[r],t[r-1]);)--r,L=!1}return{t1:V,t2:r}}var bd=Sd;var wd=function(e,t){var C=xd(t,e);return{t1:C.t2,t2:C.t1}};function xd(e,t){return Sd(e,t,yd,Zd,fd,pd)}var Od=xd;var kd=function(e,t){return Sd(e,t,Zd,Zd,pd,pd)};var Ed=function(e,t){return Sd(e,t,yd,yd,fd,fd)},Pd=function(e,t){this.t1=e,this.t2=t},Td=Pd,_d=function(){},Bd=_d,Dd=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return sd(t,e),t}(ld),Nd=function(e,t,C,i){this.id=e,this.polyid=t,this.polyvertid=C,this.p=i,i.vv=this},Rd=Nd,Fd=function(){function e(e,t){this.source=e,this.target=t}return e.prototype.length=function(){var e=this.source.p.x-this.target.p.x,t=this.source.p.y-this.target.p.y;return Math.sqrt(e*e+t*t)},e}(),Id=Fd,zd=function(){function e(e,t){if(this.P=e,this.V=[],this.E=[],t)this.V=t.V.slice(0),this.E=t.E.slice(0);else{for(var C=e.length,i=0;i0&&this.E.push(new Fd(H[n-1].vv,r))}H.length>1&&this.E.push(new Fd(H[0].vv,H[H.length-1].vv))}for(i=0;i0)return!0;return!1},e}(),jd=zd;function Gd(e,t){for(var C=[],i=1,H=t.length;i=0&&d>=0&&u<0&&A>=0&&c>=0&&h<0?H.ll=new Pd(n,V):l<=0&&d<=0&&u>0&&A<=0&&c<=0&&h>0?H.rr=new Pd(n,V):l<=0&&d>0&&u<=0&&A>=0&&c<0&&h>=0?H.rl=new Pd(n,V):l>=0&&d<0&&u>=0&&A<=0&&c>0&&h<=0&&(H.lr=new Pd(n,V))}return H}var $d=Wd;function Ud(e,t){return!e.every((function(e){return!function(e,t){for(var C=1,i=t.length;C0)return!0}return!1},Xd=Object.defineProperty({Point:dd,LineSegment:Ad,PolyPoint:cd,isLeft:md,ConvexHull:gd,clockwiseRadialSweep:vd,tangent_PolyPolyC:bd,LRtangent_PolyPolyC:wd,RLtangent_PolyPolyC:Od,LLtangent_PolyPolyC:kd,RRtangent_PolyPolyC:Ed,BiTangent:Td,BiTangents:Bd,TVGPoint:Dd,VisibilityVertex:Rd,VisibilityEdge:Id,TangentVisibilityGraph:jd,tangents:$d,polysOverlap:Yd},"__esModule",{value:!0}),qd=10,Qd=(1+Math.sqrt(5))/2,Kd=1e-4;var Jd=function(e,t,C,i,H,n){void 0===H&&(H=1),void 0===n&&(n=!0);var V=t,r=C,L=(H=void 0!==H?H:1,i=void 0!==i?i:0,0),o=0,a=0,M=0,s=[];function l(e,t){s=[],L=0,o=0,M=0;for(var C=0;C=e.height&&s[i].x+s[i].width+e.width+qd-t<=Kd){C=s[i];break}s.push(e),void 0!==C?(e.x=C.x+C.width+qd,e.y=C.bottom,e.space_left=e.height,e.bottom=e.y,C.space_left-=e.height+qd,C.bottom+=e.height+qd):(e.y=M,M+=e.height+qd,e.x=0,e.bottom=e.y,e.space_left=e.height),e.y+e.height-o>-Kd&&(o=e.y+e.height-0),e.x+e.width-L>-Kd&&(L=e.x+e.width-0)}0!=e.length&&(function(e){e.forEach((function(e){!function(e){var t=Number.MAX_VALUE,C=Number.MAX_VALUE,H=0,n=0;e.array.forEach((function(e){var V=void 0!==e.width?e.width:i,r=void 0!==e.height?e.height:i;V/=2,r/=2,H=Math.max(e.x+V,H),t=Math.min(e.x-V,t),n=Math.max(e.y+r,n),C=Math.min(e.y-r,C)})),e.width=H-t,e.height=n-C}(e)}))}(e),function(e,t){var C=Number.POSITIVE_INFINITY,i=0;e.sort((function(e,t){return t.height-e.height})),a=e.reduce((function(e,t){return e.widtha||s>Kd;){if(1!=o){var d=n-(n-H)/Qd;r=l(e,d)}if(0!=o){var u=H+(n-H)/Qd;L=l(e,u)}if(M=Math.abs(d-u),s=Math.abs(r-L),rL?(H=d,d=u,r=L,o=1):(n=u,u=d,L=r,o=0),V++>100)break}l(e,i)}(e),n&&function(e){e.forEach((function(e){var t={x:0,y:0};e.array.forEach((function(e){t.x+=e.x,t.y+=e.y})),t.x/=e.array.length,t.y/=e.array.length;var C={x:t.x-e.width/2,y:t.y-e.height/2},i={x:e.x-C.x+V/2-L/2,y:e.y-C.y+r/2-o/2};e.array.forEach((function(e){e.x+=i.x,e.y+=i.y}))}))}(e))};var eu=function(e,t){for(var C={},i={},H=[],n=0,V=0;V0){var t=0;this._links.forEach((function(e){t=Math.max(t,e.source,e.target)})),this._nodes=new Array(++t);for(var C=0;C0?e:0:e>0&&(this._running||(this._running=!0,this.trigger({type:C.start,alpha:this._alpha=e}),this.kick())),this):this._alpha},e.prototype.getLinkLength=function(e){return"function"==typeof this._linkDistance?+this._linkDistance(e):this._linkDistance},e.setLinkLength=function(e,t){e.length=t},e.prototype.getLinkType=function(e){return"function"==typeof this._linkType?this._linkType(e):0},e.prototype.symmetricDiffLinkLengths=function(e,t){var C=this;return void 0===t&&(t=1),this.linkDistance((function(t){return e*t.length})),this._linkLengthCalculator=function(){return Ys.symmetricDiffLinkLengths(C._links,C.linkAccessor,t)},this},e.prototype.jaccardLinkLengths=function(e,t){var C=this;return void 0===t&&(t=1),this.linkDistance((function(t){return e*t.length})),this._linkLengthCalculator=function(){return Ys.jaccardLinkLengths(C._links,C.linkAccessor,t)},this},e.prototype.start=function(t,C,i,H,n,V){var r=this;void 0===t&&(t=0),void 0===C&&(C=0),void 0===i&&(i=0),void 0===H&&(H=0),void 0===n&&(n=!0),void 0===V&&(V=!0);var L=this.nodes().length,o=L+2*this._groups.length;this._links.length;var a,M=this._canvasSize[0],s=this._canvasSize[1],l=new Array(o),d=new Array(o),u=null,A=this._avoidOverlaps;this._nodes.forEach((function(e,t){e.index=t,void 0===e.x&&(e.x=M/2,e.y=s/2),l[t]=e.x,d[t]=e.y})),this._linkLengthCalculator&&this._linkLengthCalculator(),this._distanceMatrix?a=this._distanceMatrix:(a=new Md.Calculator(o,this._links,e.getSourceIndex,e.getTargetIndex,(function(e){return r.getLinkLength(e)})).DistanceMatrix(),u=tl.Descent.createSquareMatrix(o,(function(){return 2})),this._links.forEach((function(e){"number"==typeof e.source&&(e.source=r._nodes[e.source]),"number"==typeof e.target&&(e.target=r._nodes[e.target])})),this._links.forEach((function(t){var C=e.getSourceIndex(t),i=e.getTargetIndex(t);u[C][i]=u[i][C]=t.weight||1})));var c=tl.Descent.createSquareMatrix(o,(function(e,t){return a[e][t]}));if(this._rootGroup&&void 0!==this._rootGroup.groups){var h=L;this._groups.forEach((function(e){!function(e,t,C,i){u[e][t]=u[t][e]=C,c[e][t]=c[t][e]=i}(h,h+1,r._groupCompactness,.1),l[h]=0,d[h++]=0,l[h]=0,d[h++]=0}))}else this._rootGroup={leaves:this._nodes,groups:[]};var m=this._constraints||[];this._directedLinkConstraints&&(this.linkAccessor.getMinSeparation=this._directedLinkConstraints.getMinSeparation,m=m.concat(Ys.generateDirectedEdgeConstraints(L,this._links,this._directedLinkConstraints.axis,this.linkAccessor))),this.avoidOverlaps(!1),this._descent=new tl.Descent([l,d],c),this._descent.locks.clear();for(h=0;h0&&(this._descent.project=new ed.Projection(this._nodes,this._groups,this._rootGroup,m).projectFunctions()),this._descent.run(C),this.separateOverlappingComponents(M,s,V),this.avoidOverlaps(A),A&&(this._nodes.forEach((function(e,t){e.x=l[t],e.y=d[t]})),this._descent.project=new ed.Projection(this._nodes,this._groups,this._rootGroup,m,!0).projectFunctions(),this._nodes.forEach((function(e,t){l[t]=e.x,d[t]=e.y}))),this._descent.G=u,this._descent.run(i),H){this._descent.snapStrength=1e3,this._descent.snapGridSize=this._nodes[0].width,this._descent.numGridSnapNodes=L,this._descent.scaleSnapByMaxH=L!=o;var g=tl.Descent.createSquareMatrix(o,(function(e,t){return e>=L||t>=L?u[e][t]:0}));this._descent.G=g,this._descent.run(H)}return this.updateNodePositions(),this.separateOverlappingComponents(M,s,V),n?this.resume():this},e.prototype.initialLayout=function(t,C,i){if(this._groups.length>0&&t>0){var H=this._nodes.length,n=this._links.map((function(e){return{source:e.source.index,target:e.target.index}})),V=this._nodes.map((function(e){return{index:e.index}}));this._groups.forEach((function(e,t){V.push({index:e.index=H+t})})),this._groups.forEach((function(e,t){void 0!==e.leaves&&e.leaves.forEach((function(t){return n.push({source:e.index,target:t.index})})),void 0!==e.groups&&e.groups.forEach((function(t){return n.push({source:e.index,target:t.index})}))})),(new e).size(this.size()).nodes(V).links(n).avoidOverlaps(!1).linkDistance(this.linkDistance()).symmetricDiffLinkLengths(5).convergenceThreshold(1e-4).start(t,0,0,0,!1),this._nodes.forEach((function(e){C[e.index]=V[e.index].x,i[e.index]=V[e.index].y}))}else this._descent.run(t)},e.prototype.separateOverlappingComponents=function(e,t,C){var i=this;if(void 0===C&&(C=!0),!this._distanceMatrix&&this._handleDisconnected){var H=this._descent.x[0],n=this._descent.x[1];this._nodes.forEach((function(e,t){e.x=H[t],e.y=n[t]}));var V=tu.separateGraphs(this._nodes,this._links);tu.applyPacking(V,e,t,this._defaultNodeSize,1,C),this._nodes.forEach((function(e,t){i._descent.x[0][t]=e.x,i._descent.x[1][t]=e.y,e.bounds&&(e.bounds.setXCentre(e.x),e.bounds.setYCentre(e.y))}))}},e.prototype.resume=function(){return this.alpha(.1)},e.prototype.stop=function(){return this.alpha(0)},e.prototype.prepareEdgeRouting=function(e){void 0===e&&(e=0),this._visibilityGraph=new Xd.TangentVisibilityGraph(this._nodes.map((function(t){return t.bounds.inflate(-e).vertices()})))},e.prototype.routeEdge=function(e,t,C){void 0===t&&(t=5);var i=[],H=new Xd.TangentVisibilityGraph(this._visibilityGraph.P,{V:this._visibilityGraph.V,E:this._visibilityGraph.E}),n={x:e.source.x,y:e.source.y},V={x:e.target.x,y:e.target.y},r=H.addPoint(n,e.source.index),L=H.addPoint(V,e.target.index);H.addEdgeIfVisible(n,V,e.source.index,e.target.index),void 0!==C&&C(H);var o=new Md.Calculator(H.V.length,H.E,(function(e){return e.source.id}),(function(e){return e.target.id}),(function(e){return e.length()})).PathFromNodeToNode(r.id,L.id);if(1===o.length||o.length===H.V.length){var a=ed.makeEdgeBetween(e.source.innerBounds,e.target.innerBounds,t);i=[a.sourceIntersection,a.arrowStart]}else{for(var M=o.length-2,s=H.V[o[M]].p,l=H.V[o[0]].p,d=(i=[e.source.innerBounds.rayIntersection(s.x,s.y)],M);d>=0;--d)i.push(H.V[o[d]].p);i.push(ed.makeEdgeTo(l,e.target.innerBounds,t))}return i},e.getSourceIndex=function(e){return"number"==typeof e.source?e.source:e.source.index},e.getTargetIndex=function(e){return"number"==typeof e.target?e.target:e.target.index},e.linkId=function(t){return e.getSourceIndex(t)+"-"+e.getTargetIndex(t)},e.dragStart=function(t){i(t)?e.storeOffset(t,e.dragOrigin(t)):(e.stopNode(t),t.fixed|=2)},e.stopNode=function(e){e.px=e.x,e.py=e.y},e.storeOffset=function(t,C){void 0!==t.leaves&&t.leaves.forEach((function(t){t.fixed|=2,e.stopNode(t),t._dragGroupOffsetX=t.x-C.x,t._dragGroupOffsetY=t.y-C.y})),void 0!==t.groups&&t.groups.forEach((function(t){return e.storeOffset(t,C)}))},e.dragOrigin=function(e){return i(e)?{x:e.bounds.cx(),y:e.bounds.cy()}:e},e.drag=function(t,C){i(t)?(void 0!==t.leaves&&t.leaves.forEach((function(e){t.bounds.setXCentre(C.x),t.bounds.setYCentre(C.y),e.px=e._dragGroupOffsetX+C.x,e.py=e._dragGroupOffsetY+C.y})),void 0!==t.groups&&t.groups.forEach((function(t){return e.drag(t,C)}))):(t.px=C.x,t.py=C.y)},e.dragEnd=function(t){i(t)?(void 0!==t.leaves&&t.leaves.forEach((function(t){e.dragEnd(t),delete t._dragGroupOffsetX,delete t._dragGroupOffsetY})),void 0!==t.groups&&t.groups.forEach(e.dragEnd)):t.fixed&=-7},e.mouseOver=function(e){e.fixed|=4,e.px=e.x,e.py=e.y},e.mouseOut=function(e){e.fixed&=-5},e}();t.Layout=H})),iu=ce&&ce.__extends||function(){var e=function(t,C){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var C in t)t.hasOwnProperty(C)&&(e[C]=t[C])},e(t,C)};return function(t,C){function i(){this.constructor=t}e(t,C),t.prototype=null===C?Object.create(C):(i.prototype=C.prototype,new i)}}(),Hu=function(e){function t(t){var C=e.call(this)||this,i=t;return i.trigger&&(C.trigger=i.trigger),i.kick&&(C.kick=i.kick),i.drag&&(C.drag=i.drag),i.on&&(C.on=i.on),C.dragstart=C.dragStart=Cu.Layout.dragStart,C.dragend=C.dragEnd=Cu.Layout.dragEnd,C}return iu(t,e),t.prototype.trigger=function(e){},t.prototype.kick=function(){},t.prototype.drag=function(){},t.prototype.on=function(e,t){return this},t}(Cu.Layout),nu=Hu;var Vu=function(e){return new Hu(e)},ru=Object.defineProperty({LayoutAdaptor:nu,adaptor:Vu},"__esModule",{value:!0}),Lu=ce&&ce.__extends||function(){var e=function(t,C){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var C in t)t.hasOwnProperty(C)&&(e[C]=t[C])},e(t,C)};return function(t,C){function i(){this.constructor=t}e(t,C),t.prototype=null===C?Object.create(C):(i.prototype=C.prototype,new i)}}(),ou=function(e){function t(){var t=e.call(this)||this;t.event=d3.dispatch(Cu.EventType[Cu.EventType.start],Cu.EventType[Cu.EventType.tick],Cu.EventType[Cu.EventType.end]);var C=t;return t.drag=function(){if(!e)var e=d3.behavior.drag().origin(Cu.Layout.dragOrigin).on("dragstart.d3adaptor",Cu.Layout.dragStart).on("drag.d3adaptor",(function(e){Cu.Layout.drag(e,d3.event),C.resume()})).on("dragend.d3adaptor",Cu.Layout.dragEnd);if(!arguments.length)return e;this.call(e)},t}return Lu(t,e),t.prototype.trigger=function(e){var t={type:Cu.EventType[e.type],alpha:e.alpha,stress:e.stress};this.event[t.type](t)},t.prototype.kick=function(){var t=this;d3.timer((function(){return e.prototype.tick.call(t)}))},t.prototype.on=function(e,t){return"string"==typeof e?this.event.on(e,t):this.event.on(Cu.EventType[e],t),this},t}(Cu.Layout),au=ou;var Mu=function(){return new ou},su=Object.defineProperty({D3StyleLayoutAdaptor:au,d3adaptor:Mu},"__esModule",{value:!0}),lu=ce&&ce.__extends||function(){var e=function(t,C){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var C in t)t.hasOwnProperty(C)&&(e[C]=t[C])},e(t,C)};return function(t,C){function i(){this.constructor=t}e(t,C),t.prototype=null===C?Object.create(C):(i.prototype=C.prototype,new i)}}(),du=function(e){function t(t){var C=e.call(this)||this;C.d3Context=t,C.event=t.dispatch(Cu.EventType[Cu.EventType.start],Cu.EventType[Cu.EventType.tick],Cu.EventType[Cu.EventType.end]);var i=C;return C.drag=function(){if(!e)var e=t.drag().subject(Cu.Layout.dragOrigin).on("start.d3adaptor",Cu.Layout.dragStart).on("drag.d3adaptor",(function(e){Cu.Layout.drag(e,t.event),i.resume()})).on("end.d3adaptor",Cu.Layout.dragEnd);if(!arguments.length)return e;arguments[0].call(e)},C}return lu(t,e),t.prototype.trigger=function(e){var t={type:Cu.EventType[e.type],alpha:e.alpha,stress:e.stress};this.event.call(t.type,t)},t.prototype.kick=function(){var t=this,C=this.d3Context.timer((function(){return e.prototype.tick.call(t)&&C.stop()}))},t.prototype.on=function(e,t){return"string"==typeof e?this.event.on(e,t):this.event.on(Cu.EventType[e],t),this},t}(Cu.Layout),uu=Object.defineProperty({D3StyleLayoutAdaptor:du},"__esModule",{value:!0});var Au=function(e){return!e||function(e){var t=/^3\./;return e.version&&null!==e.version.match(t)}(e)?new su.D3StyleLayoutAdaptor:new uu.D3StyleLayoutAdaptor(e)};var cu=Object.defineProperty({d3adaptor:Au},"__esModule",{value:!0}),hu=function(e,t,C){this.id=e,this.rect=t,this.children=C,this.leaf=void 0===C||0===C.length},mu=hu,fu=function(e,t,C,i,H){void 0===i&&(i=null),void 0===H&&(H=null),this.id=e,this.x=t,this.y=C,this.node=i,this.line=H},pu=fu,gu=function(){function e(t,C){this.s=t,this.t=C;var i=e.findMatch(t,C),H=C.slice(0).reverse(),n=e.findMatch(t,H);i.length>=n.length?(this.length=i.length,this.si=i.si,this.ti=i.ti,this.reversed=!1):(this.length=n.length,this.si=n.si,this.ti=C.length-n.ti-n.length,this.reversed=!0)}return e.findMatch=function(e,t){for(var C=e.length,i=t.length,H={length:0,si:-1,ti:-1},n=new Array(C),V=0;VH.length&&(H.length=L,H.si=V-L+1,H.ti=r-L+1)}else n[V][r]=0}return H},e.prototype.getSequence=function(){return this.length>=0?this.s.slice(this.si,this.si+this.length):[]},e}(),vu=gu,yu=function(){function e(e,t,C){var i=this;void 0===C&&(C=12),this.originalnodes=e,this.groupPadding=C,this.leaves=null,this.nodes=e.map((function(e,C){return new hu(C,t.getBounds(e),t.getChildren(e))})),this.leaves=this.nodes.filter((function(e){return e.leaf})),this.groups=this.nodes.filter((function(e){return!e.leaf})),this.cols=this.getGridLines("x"),this.rows=this.getGridLines("y"),this.groups.forEach((function(e){return e.children.forEach((function(t){return i.nodes[t].parent=e}))})),this.root={children:[]},this.nodes.forEach((function(e){void 0===e.parent&&(e.parent=i.root,i.root.children.push(e.id)),e.ports=[]})),this.backToFront=this.nodes.slice(0),this.backToFront.sort((function(e,t){return i.getDepth(e)-i.getDepth(t)})),this.backToFront.slice(0).reverse().filter((function(e){return!e.leaf})).forEach((function(e){var t=ed.Rectangle.empty();e.children.forEach((function(e){return t=t.union(i.nodes[e].rect)})),e.rect=t.inflate(i.groupPadding)}));var H=this.midPoints(this.cols.map((function(e){return e.pos}))),n=this.midPoints(this.rows.map((function(e){return e.pos}))),V=H[0],r=H[H.length-1],L=n[0],o=n[n.length-1],a=this.rows.map((function(e){return{x1:V,x2:r,y1:e.pos,y2:e.pos}})).concat(n.map((function(e){return{x1:V,x2:r,y1:e,y2:e}}))),M=this.cols.map((function(e){return{x1:e.pos,x2:e.pos,y1:L,y2:o}})).concat(H.map((function(e){return{x1:e,x2:e,y1:L,y2:o}}))),s=a.concat(M);s.forEach((function(e){return e.verts=[]})),this.verts=[],this.edges=[],a.forEach((function(e){return M.forEach((function(t){var C=new fu(i.verts.length,t.x1,e.y1);e.verts.push(C),t.verts.push(C),i.verts.push(C);for(var H=i.backToFront.length;H-- >0;){var n=i.backToFront[H],V=n.rect,r=Math.abs(C.x-V.cx()),L=Math.abs(C.y-V.cy());if(r0;){var i=C.filter((function(t){return t.rect["overlap"+e.toUpperCase()](C[0].rect)})),H={nodes:i,pos:this.avg(i.map((function(t){return t.rect["c"+e]()})))};t.push(H),H.nodes.forEach((function(e){return C.splice(C.indexOf(e),1)}))}return t.sort((function(e,t){return e.pos-t.pos})),t},e.prototype.getDepth=function(e){for(var t=0;e.parent!==this.root;)t++,e=e.parent;return t},e.prototype.midPoints=function(e){for(var t=e[1]-e[0],C=[e[0]-t/2],i=1;i.1)&&(o={pos:M[0][t],segments:[]},L.push(o)),o.segments.push(M)}return L},e.nudgeSegs=function(e,t,C,i,H,n){var V=i.length;if(!(V<=1)){for(var r=i.map((function(t){return new Al.Variable(t[0][e])})),L=[],o=0;o=0&&L.push(new Al.Constraint(r[u],r[A],n))}new Al.Solver(r,L).solve(),r.forEach((function(t,H){var n=i[H],V=t.position();n[0][e]=n[1][e]=V;var r=C[n.edgeid];n.i>0&&(r[n.i-1][1][e]=V),n.iMath.PI||H<-Math.PI)&&(H=i-C),H},e.isLeft=function(e,t,C){return(t.x-e.x)*(C.y-e.y)-(t.y-e.y)*(C.x-e.x)<=0},e.getOrder=function(e){for(var t={},C=0;C=L.length||a.ti+a.length>=o.length)?C.push({l:i,r:H}):(a.si+a.length>=L.length||a.ti+a.length>=o.length?(n=L[a.si+1],r=L[a.si-1],V=o[a.ti-1]):(n=L[a.si+a.length-2],V=L[a.si+a.length],r=o[a.ti+a.length]),e.isLeft(n,V,r)?C.push({l:H,r:i}):C.push({l:i,r:H})))}return e.getOrder(C)},e.makeSegments=function(e){function t(e){return{x:e.x,y:e.y}}for(var C=function(e,t,C){return Math.abs((t.x-e.x)*(C.y-e.y)-(t.y-e.y)*(C.x-e.x))<.001},i=[],H=t(e[0]),n=1;n1&&a>1?1e3:0})),a=o.reverse().map((function(e){return C.verts[e]}));return a.push(this.nodes[H.id].ports[0]),a.filter((function(e,t){return!(t0&&e.node===H&&a[t-1].node===H)}))},e.getRoutePath=function(t,C,i,H){var n={routepath:"M "+t[0][0].x+" "+t[0][0].y+" ",arrowpath:""};if(t.length>1)for(var V=0;V0?r-=o/Math.abs(o)*C:L-=a/Math.abs(a)*C,n.routepath+="L "+r+" "+L+" ";var M=t[V+1],s=M[0].x,l=M[0].y;o=M[1].x-s,a=M[1].y-l;var d,u,A=e.angleBetween2Lines(f,M)<0?1:0;Math.abs(o)>0?(d=s+o/Math.abs(o)*C,u=l):(d=s,u=l+a/Math.abs(a)*C);var c=Math.abs(d-r),h=Math.abs(u-L);n.routepath+="A "+c+" "+h+" 0 0 "+A+" "+d+" "+u+" "}else{var m=[r,L];Math.abs(o)>0?(p=[r-=o/Math.abs(o)*H,L+i],g=[r,L-i]):(p=[r+i,L-=a/Math.abs(a)*H],g=[r-i,L]),n.routepath+="L "+r+" "+L+" ",H>0&&(n.arrowpath="M "+m[0]+" "+m[1]+" L "+p[0]+" "+p[1]+" L "+g[0]+" "+g[1])}}else{var f,p,g;r=(f=t[0])[1].x,L=f[1].y,o=r-f[0].x,a=L-f[0].y,m=[r,L];Math.abs(o)>0?(p=[r-=o/Math.abs(o)*H,L+i],g=[r,L-i]):(p=[r+i,L-=a/Math.abs(a)*H],g=[r-i,L]),n.routepath+="L "+r+" "+L+" ",H>0&&(n.arrowpath="M "+m[0]+" "+m[1]+" L "+p[0]+" "+p[1]+" L "+g[0]+" "+g[1])}return n},e}(),Zu=yu,Su=Object.defineProperty({NodeWrapper:mu,Vert:pu,LongestCommonSubsequence:vu,GridRouter:Zu},"__esModule",{value:!0}),bu=function(){function e(e,t){this.source=e,this.target=t}return e.prototype.actualLength=function(e){var t=this;return Math.sqrt(e.reduce((function(e,C){var i=C[t.target]-C[t.source];return e+i*i}),0))},e}(),wu=function(e,t,C){void 0===e&&(e=0),void 0===t&&(t=0),void 0===C&&(C=0),this.x=e,this.y=t,this.z=C},xu=function(){function e(t,C,i){var H=this;void 0===i&&(i=1),this.nodes=t,this.links=C,this.idealLinkLength=i,this.constraints=null,this.useJaccardLinkLengths=!0,this.result=new Array(e.k);for(var n=0;n0&&f.constraints(Z),f.groups(l.map((function(e,C){var i=a(t.nodeSpacing,e),H=function(t){return parseFloat(e.style("padding-"+t))},n=H("left")+i,V=H("right")+i,r=H("top")+i,L=H("bottom")+i;return e.scratch().cola={index:C,padding:Math.max(n,V,r,L),leaves:e.children().intersection(d).map((function(e){return e[0].scratch().cola.index})),fixed:e.locked()},e})).map((function(e){return e.scratch().cola.groups=e.children().intersection(l).map((function(e){return e.scratch().cola.index})),e.scratch().cola})));var S,b=void 0,w=void 0;if(null!=t.edgeLength?(b=t.edgeLength,w="linkDistance"):null!=t.edgeSymDiffLength?(b=t.edgeSymDiffLength,w="symmetricDiffLinkLengths"):null!=t.edgeJaccardLength?(b=t.edgeJaccardLength,w="jaccardLinkLengths"):(b=100,w="linkDistance"),f.links(M.stdFilter((function(e){return d.contains(e.source())&&d.contains(e.target())})).map((function(e){var t=e.scratch().cola={source:e.source()[0].scratch().cola.index,target:e.target()[0].scratch().cola.index};return null!=b&&(t.calcLength=a(b,e)),t}))),f.size([u.w,u.h]),null!=b&&f[w]((function(e){return e.calcLength})),t.flow){var x=void 0;(void 0===(S=t.flow)?"undefined":i(S))===i("")?x={axis:t.flow,minSeparation:50}:L(t.flow)?x={axis:"y",minSeparation:t.flow}:function(e){return null!=e&&(void 0===e?"undefined":i(e))===i({})}(t.flow)?((x=t.flow).axis=x.axis||"y",x.minSeparation=null!=x.minSeparation?x.minSeparation:50):x={axis:"y",minSeparation:50},f.flowLayout(x.axis,x.minSeparation)}return e.trigger({type:"layoutstart",layout:e}),f.avoidOverlaps(t.avoidOverlap).handleDisconnected(t.handleDisconnected).start(t.unconstrIter,t.userConstIter,t.allConstIter,void 0,void 0,t.centerGraph),t.infinite||setTimeout((function(){e.manuallyStopped||f.stop()}),t.maxSimulationTime),this},M.prototype.stop=function(){return this.adaptor&&(this.manuallyStopped=!0,this.adaptor.stop()),this},e.exports=M},function(e,t,C){e.exports=null!=Object.assign?Object.assign.bind(Object):function(e){for(var t=arguments.length,C=Array(t>1?t-1:0),i=1;it&&(this.rect.x-=(this.labelWidth-t)/2,this.setWidth(this.labelWidth)),this.labelHeight>C&&("center"==this.labelPos?this.rect.y-=(this.labelHeight-C)/2:"top"==this.labelPos&&(this.rect.y-=this.labelHeight-C),this.setHeight(this.labelHeight))}}},o.prototype.getInclusionTreeDepth=function(){if(this.inclusionTreeDepth==H.MAX_VALUE)throw"assert failed";return this.inclusionTreeDepth},o.prototype.transform=function(e){var t=this.rect.x;t>V.WORLD_BOUNDARY?t=V.WORLD_BOUNDARY:t<-V.WORLD_BOUNDARY&&(t=-V.WORLD_BOUNDARY);var C=this.rect.y;C>V.WORLD_BOUNDARY?C=V.WORLD_BOUNDARY:C<-V.WORLD_BOUNDARY&&(C=-V.WORLD_BOUNDARY);var i=new L(t,C),H=e.inverseTransformPoint(i);this.setLocation(H.x,H.y)},o.prototype.getLeft=function(){return this.rect.x},o.prototype.getRight=function(){return this.rect.x+this.rect.width},o.prototype.getTop=function(){return this.rect.y},o.prototype.getBottom=function(){return this.rect.y+this.rect.height},o.prototype.getParent=function(){return null==this.owner?null:this.owner.getParent()},e.exports=o},function(e,t,C){function i(e,t){null==e&&null==t?(this.x=0,this.y=0):(this.x=e,this.y=t)}i.prototype.getX=function(){return this.x},i.prototype.getY=function(){return this.y},i.prototype.setX=function(e){this.x=e},i.prototype.setY=function(e){this.y=e},i.prototype.getDifference=function(e){return new DimensionD(this.x-e.x,this.y-e.y)},i.prototype.getCopy=function(){return new i(this.x,this.y)},i.prototype.translate=function(e){return this.x+=e.width,this.y+=e.height,this},e.exports=i},function(e,t,C){var i=C(2),H=C(10),n=C(0),V=C(6),r=C(3),L=C(1),o=C(13),a=C(12),M=C(11);function s(e,t,C){i.call(this,C),this.estimatedSize=H.MIN_VALUE,this.margin=n.DEFAULT_GRAPH_MARGIN,this.edges=[],this.nodes=[],this.isConnected=!1,this.parent=e,null!=t&&t instanceof V?this.graphManager=t:null!=t&&t instanceof Layout&&(this.graphManager=t.graphManager)}for(var l in s.prototype=Object.create(i.prototype),i)s[l]=i[l];s.prototype.getNodes=function(){return this.nodes},s.prototype.getEdges=function(){return this.edges},s.prototype.getGraphManager=function(){return this.graphManager},s.prototype.getParent=function(){return this.parent},s.prototype.getLeft=function(){return this.left},s.prototype.getRight=function(){return this.right},s.prototype.getTop=function(){return this.top},s.prototype.getBottom=function(){return this.bottom},s.prototype.isConnected=function(){return this.isConnected},s.prototype.add=function(e,t,C){if(null==t&&null==C){var i=e;if(null==this.graphManager)throw"Graph has no graph mgr!";if(this.getNodes().indexOf(i)>-1)throw"Node already in graph!";return i.owner=this,this.getNodes().push(i),i}var H=e;if(!(this.getNodes().indexOf(t)>-1&&this.getNodes().indexOf(C)>-1))throw"Source or target not in graph!";if(t.owner!=C.owner||t.owner!=this)throw"Both owners must be this graph!";return t.owner!=C.owner?null:(H.source=t,H.target=C,H.isInterGraph=!1,this.getEdges().push(H),t.edges.push(H),C!=t&&C.edges.push(H),H)},s.prototype.remove=function(e){var t=e;if(e instanceof r){if(null==t)throw"Node is null!";if(null==t.owner||t.owner!=this)throw"Owner graph is invalid!";if(null==this.graphManager)throw"Owner graph manager is invalid!";for(var C=t.edges.slice(),i=C.length,H=0;H-1&&a>-1))throw"Source and/or target doesn't know this edge!";if(n.source.edges.splice(o,1),n.target!=n.source&&n.target.edges.splice(a,1),-1==(V=n.source.owner.getEdges().indexOf(n)))throw"Not in owner's edge list!";n.source.owner.getEdges().splice(V,1)}},s.prototype.updateLeftTop=function(){for(var e,t,C,i=H.MAX_VALUE,n=H.MAX_VALUE,V=this.getNodes(),r=V.length,L=0;L(e=o.getTop())&&(i=e),n>(t=o.getLeft())&&(n=t)}return i==H.MAX_VALUE?null:(C=null!=V[0].getParent().paddingLeft?V[0].getParent().paddingLeft:this.margin,this.left=n-C,this.top=i-C,new a(this.left,this.top))},s.prototype.updateBounds=function(e){for(var t,C,i,n,V,r=H.MAX_VALUE,L=-H.MAX_VALUE,a=H.MAX_VALUE,M=-H.MAX_VALUE,s=this.nodes,l=s.length,d=0;d(t=u.getLeft())&&(r=t),L<(C=u.getRight())&&(L=C),a>(i=u.getTop())&&(a=i),M<(n=u.getBottom())&&(M=n)}var A=new o(r,a,L-r,M-a);r==H.MAX_VALUE&&(this.left=this.parent.getLeft(),this.right=this.parent.getRight(),this.top=this.parent.getTop(),this.bottom=this.parent.getBottom()),V=null!=s[0].getParent().paddingLeft?s[0].getParent().paddingLeft:this.margin,this.left=A.x-V,this.right=A.x+A.width+V,this.top=A.y-V,this.bottom=A.y+A.height+V},s.calculateBounds=function(e){for(var t,C,i,n,V=H.MAX_VALUE,r=-H.MAX_VALUE,L=H.MAX_VALUE,a=-H.MAX_VALUE,M=e.length,s=0;s(t=l.getLeft())&&(V=t),r<(C=l.getRight())&&(r=C),L>(i=l.getTop())&&(L=i),a<(n=l.getBottom())&&(a=n)}return new o(V,L,r-V,a-L)},s.prototype.getInclusionTreeDepth=function(){return this==this.graphManager.getRoot()?1:this.parent.getInclusionTreeDepth()},s.prototype.getEstimatedSize=function(){if(this.estimatedSize==H.MIN_VALUE)throw"assert failed";return this.estimatedSize},s.prototype.calcEstimatedSize=function(){for(var e=0,t=this.nodes,C=t.length,i=0;i=this.nodes.length){var L=0;H.forEach((function(t){t.owner==e&&L++})),L==this.nodes.length&&(this.isConnected=!0)}}else this.isConnected=!0},e.exports=s},function(e,t,C){var i,H=C(1);function n(e){i=C(5),this.layout=e,this.graphs=[],this.edges=[]}n.prototype.addRoot=function(){var e=this.layout.newGraph(),t=this.layout.newNode(null),C=this.add(e,t);return this.setRootGraph(C),this.rootGraph},n.prototype.add=function(e,t,C,i,H){if(null==C&&null==i&&null==H){if(null==e)throw"Graph is null!";if(null==t)throw"Parent node is null!";if(this.graphs.indexOf(e)>-1)throw"Graph already in this graph mgr!";if(this.graphs.push(e),null!=e.parent)throw"Already has a parent!";if(null!=t.child)throw"Already has a child!";return e.parent=t,t.child=e,e}H=C,C=e;var n=(i=t).getOwner(),V=H.getOwner();if(null==n||n.getGraphManager()!=this)throw"Source not in this graph mgr!";if(null==V||V.getGraphManager()!=this)throw"Target not in this graph mgr!";if(n==V)return C.isInterGraph=!1,n.add(C,i,H);if(C.isInterGraph=!0,C.source=i,C.target=H,this.edges.indexOf(C)>-1)throw"Edge already in inter-graph edge list!";if(this.edges.push(C),null==C.source||null==C.target)throw"Edge source and/or target is null!";if(-1!=C.source.edges.indexOf(C)||-1!=C.target.edges.indexOf(C))throw"Edge already in source and/or target incidency list!";return C.source.edges.push(C),C.target.edges.push(C),C},n.prototype.remove=function(e){if(e instanceof i){var t=e;if(t.getGraphManager()!=this)throw"Graph not in this graph mgr";if(t!=this.rootGraph&&(null==t.parent||t.parent.graphManager!=this))throw"Invalid parent node!";for(var C,n=[],V=(n=n.concat(t.getEdges())).length,r=0;r=t.getRight()?C[0]+=Math.min(t.getX()-e.getX(),e.getRight()-t.getRight()):t.getX()<=e.getX()&&t.getRight()>=e.getRight()&&(C[0]+=Math.min(e.getX()-t.getX(),t.getRight()-e.getRight())),e.getY()<=t.getY()&&e.getBottom()>=t.getBottom()?C[1]+=Math.min(t.getY()-e.getY(),e.getBottom()-t.getBottom()):t.getY()<=e.getY()&&t.getBottom()>=e.getBottom()&&(C[1]+=Math.min(e.getY()-t.getY(),t.getBottom()-e.getBottom()));var n=Math.abs((t.getCenterY()-e.getCenterY())/(t.getCenterX()-e.getCenterX()));t.getCenterY()===e.getCenterY()&&t.getCenterX()===e.getCenterX()&&(n=1);var V=n*C[0],r=C[1]/n;C[0]V)return C[0]=i,C[1]=L,C[2]=n,C[3]=m,!1;if(Hn)return C[0]=r,C[1]=H,C[2]=c,C[3]=V,!1;if(in?(C[0]=a,C[1]=M,v=!0):(C[0]=o,C[1]=L,v=!0):Z===b&&(i>n?(C[0]=r,C[1]=L,v=!0):(C[0]=s,C[1]=M,v=!0)),-S===b?n>i?(C[2]=h,C[3]=m,y=!0):(C[2]=c,C[3]=A,y=!0):S===b&&(n>i?(C[2]=u,C[3]=A,y=!0):(C[2]=f,C[3]=m,y=!0)),v&&y)return!1;if(i>n?H>V?(w=this.getCardinalDirection(Z,b,4),x=this.getCardinalDirection(S,b,2)):(w=this.getCardinalDirection(-Z,b,3),x=this.getCardinalDirection(-S,b,1)):H>V?(w=this.getCardinalDirection(-Z,b,1),x=this.getCardinalDirection(-S,b,3)):(w=this.getCardinalDirection(Z,b,2),x=this.getCardinalDirection(S,b,4)),!v)switch(w){case 1:k=L,O=i+-d/b,C[0]=O,C[1]=k;break;case 2:O=s,k=H+l*b,C[0]=O,C[1]=k;break;case 3:k=M,O=i+d/b,C[0]=O,C[1]=k;break;case 4:O=a,k=H+-l*b,C[0]=O,C[1]=k}if(!y)switch(x){case 1:P=A,E=n+-g/b,C[2]=E,C[3]=P;break;case 2:E=f,P=V+p*b,C[2]=E,C[3]=P;break;case 3:P=m,E=n+g/b,C[2]=E,C[3]=P;break;case 4:E=h,P=V+-p*b,C[2]=E,C[3]=P}}return!1},H.getCardinalDirection=function(e,t,C){return e>t?C:1+C%4},H.getIntersection=function(e,t,C,H){if(null==H)return this.getIntersection2(e,t,C);var n,V,r,L,o,a,M,s=e.x,l=e.y,d=t.x,u=t.y,A=C.x,c=C.y,h=H.x,m=H.y;return 0==(M=(n=u-l)*(L=A-h)-(V=m-c)*(r=s-d))?null:new i((r*(a=h*c-A*m)-L*(o=d*l-s*u))/M,(V*o-n*a)/M)},H.angleOfVector=function(e,t,C,i){var H=void 0;return e!==C?(H=Math.atan((i-t)/(C-e)),C0?1:e<0?-1:0},i.floor=function(e){return e<0?Math.ceil(e):Math.floor(e)},i.ceil=function(e){return e<0?Math.floor(e):Math.ceil(e)},e.exports=i},function(e,t,C){function i(){}i.MAX_VALUE=2147483647,i.MIN_VALUE=-2147483648,e.exports=i},function(e,t,C){var i=function(){function e(e,t){for(var C=0;C0&&t;){for(r.push(o[0]);r.length>0&&t;){var a=r[0];r.splice(0,1),V.add(a);var M=a.getEdges();for(n=0;n-1&&o.splice(u,1)}V=new Set,L=new Map}else e=[]}return e},s.prototype.createDummyNodesForBendpoints=function(e){for(var t=[],C=e.source,i=this.graphManager.calcLowestCommonAncestor(e.source,e.target),H=0;H0){for(var H=this.edgeToDummyNodes.get(C),n=0;n=0&&t.splice(M,1),a.getNeighborsList().forEach((function(e){if(C.indexOf(e)<0){var t=i.get(e)-1;1==t&&L.push(e),i.set(e,t)}}))}C=C.concat(L),1!=t.length&&2!=t.length||(H=!0,n=t[0])}return n},s.prototype.setGraphManager=function(e){this.graphManager=e},e.exports=s},function(e,t,C){function i(){}i.seed=1,i.x=0,i.nextDouble=function(){return i.x=1e4*Math.sin(i.seed++),i.x-Math.floor(i.x)},e.exports=i},function(e,t,C){var i=C(4);function H(e,t){this.lworldOrgX=0,this.lworldOrgY=0,this.ldeviceOrgX=0,this.ldeviceOrgY=0,this.lworldExtX=1,this.lworldExtY=1,this.ldeviceExtX=1,this.ldeviceExtY=1}H.prototype.getWorldOrgX=function(){return this.lworldOrgX},H.prototype.setWorldOrgX=function(e){this.lworldOrgX=e},H.prototype.getWorldOrgY=function(){return this.lworldOrgY},H.prototype.setWorldOrgY=function(e){this.lworldOrgY=e},H.prototype.getWorldExtX=function(){return this.lworldExtX},H.prototype.setWorldExtX=function(e){this.lworldExtX=e},H.prototype.getWorldExtY=function(){return this.lworldExtY},H.prototype.setWorldExtY=function(e){this.lworldExtY=e},H.prototype.getDeviceOrgX=function(){return this.ldeviceOrgX},H.prototype.setDeviceOrgX=function(e){this.ldeviceOrgX=e},H.prototype.getDeviceOrgY=function(){return this.ldeviceOrgY},H.prototype.setDeviceOrgY=function(e){this.ldeviceOrgY=e},H.prototype.getDeviceExtX=function(){return this.ldeviceExtX},H.prototype.setDeviceExtX=function(e){this.ldeviceExtX=e},H.prototype.getDeviceExtY=function(){return this.ldeviceExtY},H.prototype.setDeviceExtY=function(e){this.ldeviceExtY=e},H.prototype.transformX=function(e){var t=0,C=this.lworldExtX;return 0!=C&&(t=this.ldeviceOrgX+(e-this.lworldOrgX)*this.ldeviceExtX/C),t},H.prototype.transformY=function(e){var t=0,C=this.lworldExtY;return 0!=C&&(t=this.ldeviceOrgY+(e-this.lworldOrgY)*this.ldeviceExtY/C),t},H.prototype.inverseTransformX=function(e){var t=0,C=this.ldeviceExtX;return 0!=C&&(t=this.lworldOrgX+(e-this.ldeviceOrgX)*this.lworldExtX/C),t},H.prototype.inverseTransformY=function(e){var t=0,C=this.ldeviceExtY;return 0!=C&&(t=this.lworldOrgY+(e-this.ldeviceOrgY)*this.lworldExtY/C),t},H.prototype.inverseTransformPoint=function(e){return new i(this.inverseTransformX(e.x),this.inverseTransformY(e.y))},e.exports=H},function(e,t,C){var i=C(15),H=C(7),n=C(0),V=C(8),r=C(9);function L(){i.call(this),this.useSmartIdealEdgeLengthCalculation=H.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.idealEdgeLength=H.DEFAULT_EDGE_LENGTH,this.springConstant=H.DEFAULT_SPRING_STRENGTH,this.repulsionConstant=H.DEFAULT_REPULSION_STRENGTH,this.gravityConstant=H.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=H.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=H.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=H.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.displacementThresholdPerNode=3*H.DEFAULT_EDGE_LENGTH/100,this.coolingFactor=H.DEFAULT_COOLING_FACTOR_INCREMENTAL,this.initialCoolingFactor=H.DEFAULT_COOLING_FACTOR_INCREMENTAL,this.totalDisplacement=0,this.oldTotalDisplacement=0,this.maxIterations=H.MAX_ITERATIONS}for(var o in L.prototype=Object.create(i.prototype),i)L[o]=i[o];L.prototype.initParameters=function(){i.prototype.initParameters.call(this,arguments),this.totalIterations=0,this.notAnimatedIterations=0,this.useFRGridVariant=H.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION,this.grid=[]},L.prototype.calcIdealEdgeLengths=function(){for(var e,t,C,i,V,r,L=this.getGraphManager().getAllEdges(),o=0;oH.ADAPTATION_LOWER_NODE_LIMIT&&(this.coolingFactor=Math.max(this.coolingFactor*H.COOLING_ADAPTATION_FACTOR,this.coolingFactor-(e-H.ADAPTATION_LOWER_NODE_LIMIT)/(H.ADAPTATION_UPPER_NODE_LIMIT-H.ADAPTATION_LOWER_NODE_LIMIT)*this.coolingFactor*(1-H.COOLING_ADAPTATION_FACTOR))),this.maxNodeDisplacement=H.MAX_NODE_DISPLACEMENT_INCREMENTAL):(e>H.ADAPTATION_LOWER_NODE_LIMIT?this.coolingFactor=Math.max(H.COOLING_ADAPTATION_FACTOR,1-(e-H.ADAPTATION_LOWER_NODE_LIMIT)/(H.ADAPTATION_UPPER_NODE_LIMIT-H.ADAPTATION_LOWER_NODE_LIMIT)*(1-H.COOLING_ADAPTATION_FACTOR)):this.coolingFactor=1,this.initialCoolingFactor=this.coolingFactor,this.maxNodeDisplacement=H.MAX_NODE_DISPLACEMENT),this.maxIterations=Math.max(5*this.getAllNodes().length,this.maxIterations),this.totalDisplacementThreshold=this.displacementThresholdPerNode*this.getAllNodes().length,this.repulsionRange=this.calcRepulsionRange()},L.prototype.calcSpringForces=function(){for(var e,t=this.getAllEdges(),C=0;C0&&void 0!==arguments[0])||arguments[0],r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],L=this.getAllNodes();if(this.useFRGridVariant)for(this.totalIterations%H.GRID_CALCULATION_CHECK_PERIOD==1&&V&&this.updateGrid(),n=new Set,e=0;e(L=t.getEstimatedSize()*this.gravityRangeFactor)||r>L)&&(e.gravitationForceX=-this.gravityConstant*H,e.gravitationForceY=-this.gravityConstant*n):(V>(L=t.getEstimatedSize()*this.compoundGravityRangeFactor)||r>L)&&(e.gravitationForceX=-this.gravityConstant*H*this.compoundGravityConstant,e.gravitationForceY=-this.gravityConstant*n*this.compoundGravityConstant)},L.prototype.isConverged=function(){var e,t=!1;return this.totalIterations>this.maxIterations/3&&(t=Math.abs(this.totalDisplacement-this.oldTotalDisplacement)<2),e=this.totalDisplacement=r.length||o>=r[0].length))for(var a=0;ae}}]),e}();e.exports=n},function(e,t,C){var i=function(){function e(e,t){for(var C=0;C2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,V=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1;H(this,e),this.sequence1=t,this.sequence2=C,this.match_score=i,this.mismatch_penalty=n,this.gap_penalty=V,this.iMax=t.length+1,this.jMax=C.length+1,this.grid=new Array(this.iMax);for(var r=0;r=0;C--){var i=this.listeners[C];i.event===e&&i.callback===t&&this.listeners.splice(C,1)}},H.emit=function(e,t){for(var C=0;C=0;H--){var n=i[H];n.isOrdered()||e.stack.push(n)}return t},H.prototype.calculateRadius=function(){var e=this,t=0;e.getNodes().forEach((function(e){return t+=Math.sqrt(e.getWidth()*e.getWidth()+e.getHeight()*e.getHeight())})),e.perimeter=t+e.getNodes().length*e.nodeSeparation;var C=e.perimeter/(2*Math.PI);e.getParent().setWidth(2*C),e.getParent().setHeight(2*C),e.getParent().setCenter(e.getParent().getWidth(),e.getParent().getHeight()),e.centerX=e.getParent().getCenterX(),e.centerY=e.getParent().getCenterY(),e.radius=e.getParent().getHeight()/2},H.prototype.calculateEdgeCrossingsOfNodes=function(){this.getNodes().forEach((function(e){return e.calculateTotalCrossing()}))},H.prototype.loadOldIndicesOfNodes=function(){for(var e=0;eMath.min(V,r)&&0!==r&&0!==V},H.prototype.crossingWithEdge=function(e){return this.crossesWithEdge(e)?1:0},H.prototype.calculateTotalCrossingWithList=function(e){var t=this,C=0;return e.forEach((function(e){return C+=t.crossingWithEdge(e)})),C},e.exports=H},function(e,t,C){var i=C(0).LNode;function H(e,t,C,H){void 0!==C&&void 0!==H?i.call(this,e,t,C,H):i.call(this,e,t),this.angle=0,this.circleIndex=-1,this.totalCrossingOfEdges=-1,this.isCrossingNumberValid=!1}for(var n in C(0).Quicksort,H.prototype=Object.create(i.prototype),i)H[n]=i[n];H.prototype.getCircle=function(){return this.getOwner()},H.prototype.setIndex=function(e){this.circleIndex=e,this.isCrossingNumberValid=!1},H.prototype.getIndex=function(){return this.circleIndex},H.prototype.getNeighborsSortedByDegree=function(){var e=Array.from(this.getNeighborsList());return(e=e.filter((function(e){return-1===e.getIndex()}))).sort((function(e,t){return e.getDegree()-t.getDegree()})),e},H.prototype.getDegree=function(){return this.getEdges().length},H.prototype.isOrdered=function(){return this.getIndex()>-1},H.prototype.setAngle=function(e){this.angle=e},H.prototype.getAngle=function(){return this.angle},H.prototype.getCircDistWithTheNode=function(e){var t=this,C=e.getIndex();if(-1===C||-1===t.getIndex())return-1;var i=t.getIndex()-C;return i<0&&(i+=t.getCircle().getSize()),i},H.prototype.getCrossingNumberWithNode=function(e){var t=0;return this.getEdges().forEach((function(C){e.getEdges().forEach((function(e){t+=C.crossingWithEdge(e)}))})),t},H.prototype.getTotalCrossingOfEdges=function(){var e=this;return e.isCrossingNumberValid||(e.calculateTotalCrossing(),e.isCrossingNumberValid=!0),e.totalCrossingOfEdges},H.prototype.calculateTotalCrossing=function(){var e=this,t=0,C=[];C.push.apply(C,e.getCircle().getEdges()),C=C.filter((function(t){return e.getEdges().indexOf(t)<0})),e.getEdges().forEach((function(e){return t+=e.calculateTotalCrossingWithList(C)})),e.totalCrossingOfEdges=t},e.exports=H},function(e,t,C){var i=C(0).Layout,H=C(2),n=C(1),V=C(4),r=C(3);function L(){i.call(this),this.nodeSeparation=H.DEFAULT_NODE_SEPARATION}for(var o in L.prototype=Object.create(i.prototype),i)L[o]=i[o];L.prototype.newGraph=function(e){return this.avsdfCircle=new n(null,this.graphManager,e),this.avsdfCircle},L.prototype.newNode=function(e){return new V(this.graphManager,e)},L.prototype.newEdge=function(e){return new r(null,null,e)},L.prototype.getPositionsData=function(){for(var e=this.graphManager.getAllNodes(),t={},C=0;C1)return!1;var e=this.avsdfCircle;for(e.setNodeSeparation(this.nodeSeparation),e.calculateRadius(),e.initOrdering();!e.hasFinishedOrdering();){var t=e.findNodeToPlace();e.putInOrder(t)}return!0},L.prototype.updateNodeAngles=function(){this.graphManager.getRoot().correctAngles()},L.prototype.updateNodeCoordinates=function(){var e=this.graphManager.getRoot();e.getNodes().forEach((function(t){t.setCenter(e.getCenterX()+e.getRadius()*Math.cos(t.getAngle()),e.getCenterY()+e.getRadius()*Math.sin(t.getAngle()))}))},L.prototype.initPostProcess=function(){this.avsdfCircle.calculateEdgeCrossingsOfNodes();var e=this.avsdfCircle.getNodes();return e.sort((function(e,t){return t.getTotalCrossingOfEdges()-e.getTotalCrossingOfEdges()})),e},L.prototype.oneStepPostProcess=function(e){for(var t=this,C=e.getTotalCrossingOfEdges(),i=void 0,H=Array.from(e.getNeighborsList()),n=0;n=C?t.avsdfCircle.loadOldIndicesOfNodes():(t.avsdfCircle.reOrderVertices(),C=i)}}},e.exports=L},function(e,t,C){var i={};i.layoutBase=C(0),i.AVSDFConstants=C(2),i.AVSDFEdge=C(3),i.AVSDFCircle=C(1),i.AVSDFLayout=C(5),i.AVSDFNode=C(4),e.exports=i}])},e.exports=C(Fu)})),zu=fe((function(e,t){var C;C=function(e){return function(e){var t={};function C(i){if(t[i])return t[i].exports;var H=t[i]={i:i,l:!1,exports:{}};return e[i].call(H.exports,H,H.exports,C),H.l=!0,H.exports}return C.m=e,C.c=t,C.i=function(e){return e},C.d=function(e,t,i){C.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},C.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return C.d(t,"a",t),t},C.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},C.p="",C(C.s=3)}([function(t,C){t.exports=e},function(e,t,C){e.exports=null!=Object.assign?Object.assign.bind(Object):function(e){for(var t=arguments.length,C=Array(t>1?t-1:0),i=1;i=t.nodes.size())return!0;this.avsdfLayout.oneStepPostProcess(this.sortedByDegreeList[t.tickIndex]),this.avsdfLayout.updateNodeAngles(),this.avsdfLayout.updateNodeCoordinates()}},{key:"postrun",value:function(){}},{key:"destroy",value:function(){return H(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"destroy",this).call(this),this}},{key:"processChildrenList",value:function(e,t,C){for(var i=t.length,H=0;H1&&void 0!==arguments[1]?arguments[1]:i,C=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i,n=!1,V=e,r=0;r-1};var Qu=function(e,t){var C=this.__data__,i=$u(C,e);return i<0?(++this.size,C.push([e,t])):C[i][1]=t,this};function Ku(e){var t=-1,C=null==e?0:e.length;for(this.clear();++t-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991},vc={};vc["[object Float32Array]"]=vc["[object Float64Array]"]=vc["[object Int8Array]"]=vc["[object Int16Array]"]=vc["[object Int32Array]"]=vc["[object Uint8Array]"]=vc["[object Uint8ClampedArray]"]=vc["[object Uint16Array]"]=vc["[object Uint32Array]"]=!0,vc["[object Arguments]"]=vc["[object Array]"]=vc["[object ArrayBuffer]"]=vc["[object Boolean]"]=vc["[object DataView]"]=vc["[object Date]"]=vc["[object Error]"]=vc["[object Function]"]=vc["[object Map]"]=vc["[object Number]"]=vc["[object Object]"]=vc["[object RegExp]"]=vc["[object Set]"]=vc["[object String]"]=vc["[object WeakMap]"]=!1;var yc=function(e){return Mc(e)&&gc(e.length)&&!!vc[AA(e)]};var Zc=function(e){return function(t){return e(t)}},Sc=fe((function(e,t){var C=t&&!t.nodeType&&t,i=C&&e&&!e.nodeType&&e,H=i&&i.exports===C&&HA.process,n=function(){try{var e=i&&i.require&&i.require("util").types;return e||H&&H.binding&&H.binding("util")}catch(e){}}();e.exports=n})),bc=Sc&&Sc.isTypedArray,wc=bc?Zc(bc):yc,xc=Object.prototype.hasOwnProperty;var Oc=function(e,t){var C=cc(e),i=!C&&Ac(e),H=!C&&!i&&mc(e),n=!C&&!i&&!H&&wc(e),V=C||i||H||n,r=V?ac(e.length,String):[],L=r.length;for(var o in e)!t&&!xc.call(e,o)||V&&("length"==o||H&&("offset"==o||"parent"==o)||n&&("buffer"==o||"byteLength"==o||"byteOffset"==o)||pc(o,L))||r.push(o);return r},kc=Object.prototype;var Ec=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||kc)};var Pc=function(e,t){return function(C){return e(t(C))}},Tc=Pc(Object.keys,Object),_c=Object.prototype.hasOwnProperty;var Bc=function(e){if(!Ec(e))return Tc(e);var t=[];for(var C in Object(e))_c.call(e,C)&&"constructor"!=C&&t.push(C);return t};var Dc=function(e){return null!=e&&gc(e.length)&&!mA(e)};var Nc=function(e){return Dc(e)?Oc(e):Bc(e)};var Rc=function(e,t){return e&&oc(t,Nc(t),e)};var Fc=function(e){var t=[];if(null!=e)for(var C in Object(e))t.push(C);return t},Ic=Object.prototype.hasOwnProperty;var zc=function(e){if(!cA(e))return Fc(e);var t=Ec(e),C=[];for(var i in e)("constructor"!=i||!t&&Ic.call(e,i))&&C.push(i);return C};var jc=function(e){return Dc(e)?Oc(e,!0):zc(e)};var Gc=function(e,t){return e&&oc(t,jc(t),e)},Wc=fe((function(e,t){var C=t&&!t.nodeType&&t,i=C&&e&&!e.nodeType&&e,H=i&&i.exports===C?VA.Buffer:void 0,n=H?H.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var C=e.length,i=n?n(C):new e.constructor(C);return e.copy(i),i}}));var $c=function(e,t){var C=-1,i=e.length;for(t||(t=Array(i));++Cr))return!1;var o=n.get(e),a=n.get(t);if(o&&a)return o==t&&a==e;var M=-1,s=!0,l=2&C?new Hm:void 0;for(n.set(e,t),n.set(t,e);++M0&&i(L)?C>1?e(L,C-1,i,H,n):eh(n,L):H||(n[n.length]=L)}return n};var kf=function(e,t,C){switch(C.length){case 0:return e.call(t);case 1:return e.call(t,C[0]);case 2:return e.call(t,C[0],C[1]);case 3:return e.call(t,C[0],C[1],C[2])}return e.apply(t,C)},Ef=Math.max;var Pf=function(e,t,C){return t=Ef(void 0===t?e.length-1:t,0),function(){for(var i=arguments,H=-1,n=Ef(i.length-t,0),V=Array(n);++H0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}},Nf=Df(_f);var Rf=function(e,t){return Nf(Pf(e,t,qh),e+"")};var Ff=function(e,t,C,i){for(var H=e.length,n=C+(i?1:-1);i?n--:++n-1};var Wf=function(e,t,C){for(var i=-1,H=null==e?0:e.length;++i=200){var o=t?null:Yf(e);if(o)return om(o);V=!1,H=Vm,L=new Hm}else L=t?[]:r;e:for(;++in){var V=H;H=n,n=V}return H+""+n+""+(tp.isUndefined(i)?"\0":i)}function rp(e,t,C,i){var H=""+t,n=""+C;if(!e&&H>n){var V=H;H=n,n=V}var r={v:H,w:n};return i&&(r.name=i),r}function Lp(e,t){return Vp(e,t.v,t.w,t.name)}ip.prototype._nodeCount=0,ip.prototype._edgeCount=0,ip.prototype.isDirected=function(){return this._isDirected},ip.prototype.isMultigraph=function(){return this._isMultigraph},ip.prototype.isCompound=function(){return this._isCompound},ip.prototype.setGraph=function(e){return this._label=e,this},ip.prototype.graph=function(){return this._label},ip.prototype.setDefaultNodeLabel=function(e){return tp.isFunction(e)||(e=tp.constant(e)),this._defaultNodeLabelFn=e,this},ip.prototype.nodeCount=function(){return this._nodeCount},ip.prototype.nodes=function(){return tp.keys(this._nodes)},ip.prototype.sources=function(){var e=this;return tp.filter(this.nodes(),(function(t){return tp.isEmpty(e._in[t])}))},ip.prototype.sinks=function(){var e=this;return tp.filter(this.nodes(),(function(t){return tp.isEmpty(e._out[t])}))},ip.prototype.setNodes=function(e,t){var C=arguments,i=this;return tp.each(e,(function(e){C.length>1?i.setNode(e,t):i.setNode(e)})),this},ip.prototype.setNode=function(e,t){return tp.has(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)},ip.prototype.node=function(e){return this._nodes[e]},ip.prototype.hasNode=function(e){return tp.has(this._nodes,e)},ip.prototype.removeNode=function(e){var t=this;if(tp.has(this._nodes,e)){var C=function(e){t.removeEdge(t._edgeObjs[e])};delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],tp.each(this.children(e),(function(e){t.setParent(e)})),delete this._children[e]),tp.each(tp.keys(this._in[e]),C),delete this._in[e],delete this._preds[e],tp.each(tp.keys(this._out[e]),C),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this},ip.prototype.setParent=function(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(tp.isUndefined(t))t="\0";else{for(var C=t+="";!tp.isUndefined(C);C=this.parent(C))if(C===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this},ip.prototype._removeFromParentsChildList=function(e){delete this._children[this._parent[e]][e]},ip.prototype.parent=function(e){if(this._isCompound){var t=this._parent[e];if("\0"!==t)return t}},ip.prototype.children=function(e){if(tp.isUndefined(e)&&(e="\0"),this._isCompound){var t=this._children[e];if(t)return tp.keys(t)}else{if("\0"===e)return this.nodes();if(this.hasNode(e))return[]}},ip.prototype.predecessors=function(e){var t=this._preds[e];if(t)return tp.keys(t)},ip.prototype.successors=function(e){var t=this._sucs[e];if(t)return tp.keys(t)},ip.prototype.neighbors=function(e){var t=this.predecessors(e);if(t)return tp.union(t,this.successors(e))},ip.prototype.isLeaf=function(e){return 0===(this.isDirected()?this.successors(e):this.neighbors(e)).length},ip.prototype.filterNodes=function(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var C=this;tp.each(this._nodes,(function(C,i){e(i)&&t.setNode(i,C)})),tp.each(this._edgeObjs,(function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,C.edge(e))}));var i={};function H(e){var n=C.parent(e);return void 0===n||t.hasNode(n)?(i[e]=n,n):n in i?i[n]:H(n)}return this._isCompound&&tp.each(t.nodes(),(function(e){t.setParent(e,H(e))})),t},ip.prototype.setDefaultEdgeLabel=function(e){return tp.isFunction(e)||(e=tp.constant(e)),this._defaultEdgeLabelFn=e,this},ip.prototype.edgeCount=function(){return this._edgeCount},ip.prototype.edges=function(){return tp.values(this._edgeObjs)},ip.prototype.setPath=function(e,t){var C=this,i=arguments;return tp.reduce(e,(function(e,H){return i.length>1?C.setEdge(e,H,t):C.setEdge(e,H),H})),this},ip.prototype.setEdge=function(){var e,t,C,i,H=!1,n=arguments[0];"object"==typeof n&&null!==n&&"v"in n?(e=n.v,t=n.w,C=n.name,2===arguments.length&&(i=arguments[1],H=!0)):(e=n,t=arguments[1],C=arguments[3],arguments.length>2&&(i=arguments[2],H=!0)),e=""+e,t=""+t,tp.isUndefined(C)||(C=""+C);var V=Vp(this._isDirected,e,t,C);if(tp.has(this._edgeLabels,V))return H&&(this._edgeLabels[V]=i),this;if(!tp.isUndefined(C)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(t),this._edgeLabels[V]=H?i:this._defaultEdgeLabelFn(e,t,C);var r=rp(this._isDirected,e,t,C);return e=r.v,t=r.w,Object.freeze(r),this._edgeObjs[V]=r,Hp(this._preds[t],e),Hp(this._sucs[e],t),this._in[t][V]=r,this._out[e][V]=r,this._edgeCount++,this},ip.prototype.edge=function(e,t,C){var i=1===arguments.length?Lp(this._isDirected,arguments[0]):Vp(this._isDirected,e,t,C);return this._edgeLabels[i]},ip.prototype.hasEdge=function(e,t,C){var i=1===arguments.length?Lp(this._isDirected,arguments[0]):Vp(this._isDirected,e,t,C);return tp.has(this._edgeLabels,i)},ip.prototype.removeEdge=function(e,t,C){var i=1===arguments.length?Lp(this._isDirected,arguments[0]):Vp(this._isDirected,e,t,C),H=this._edgeObjs[i];return H&&(e=H.v,t=H.w,delete this._edgeLabels[i],delete this._edgeObjs[i],np(this._preds[t],e),np(this._sucs[e],t),delete this._in[t][i],delete this._out[e][i],this._edgeCount--),this},ip.prototype.inEdges=function(e,t){var C=this._in[e];if(C){var i=tp.values(C);return t?tp.filter(i,(function(e){return e.v===t})):i}},ip.prototype.outEdges=function(e,t){var C=this._out[e];if(C){var i=tp.values(C);return t?tp.filter(i,(function(e){return e.w===t})):i}},ip.prototype.nodeEdges=function(e,t){var C=this.inEdges(e,t);if(C)return C.concat(this.outEdges(e,t))};var op={Graph:Cp,version:"2.1.8"},ap={write:function(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Mp(e),edges:sp(e)};tp.isUndefined(e.graph())||(t.value=tp.clone(e.graph()));return t},read:function(e){var t=new Cp(e.options).setGraph(e.value);return tp.each(e.nodes,(function(e){t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)})),tp.each(e.edges,(function(e){t.setEdge({v:e.v,w:e.w,name:e.name},e.value)})),t}};function Mp(e){return tp.map(e.nodes(),(function(t){var C=e.node(t),i=e.parent(t),H={v:t};return tp.isUndefined(C)||(H.value=C),tp.isUndefined(i)||(H.parent=i),H}))}function sp(e){return tp.map(e.edges(),(function(t){var C=e.edge(t),i={v:t.v,w:t.w};return tp.isUndefined(t.name)||(i.name=t.name),tp.isUndefined(C)||(i.value=C),i}))}var lp=function(e){var t,C={},i=[];function H(i){tp.has(C,i)||(C[i]=!0,t.push(i),tp.each(e.successors(i),H),tp.each(e.predecessors(i),H))}return tp.each(e.nodes(),(function(e){t=[],H(e),t.length&&i.push(t)})),i};var dp=up;function up(){this._arr=[],this._keyIndices={}}up.prototype.size=function(){return this._arr.length},up.prototype.keys=function(){return this._arr.map((function(e){return e.key}))},up.prototype.has=function(e){return tp.has(this._keyIndices,e)},up.prototype.priority=function(e){var t=this._keyIndices[e];if(void 0!==t)return this._arr[t].priority},up.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},up.prototype.add=function(e,t){var C=this._keyIndices;if(e=String(e),!tp.has(C,e)){var i=this._arr,H=i.length;return C[e]=H,i.push({key:e,priority:t}),this._decrease(H),!0}return!1},up.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key},up.prototype.decrease=function(e,t){var C=this._keyIndices[e];if(t>this._arr[C].priority)throw new Error("New priority is greater than current priority. Key: "+e+" Old: "+this._arr[C].priority+" New: "+t);this._arr[C].priority=t,this._decrease(C)},up.prototype._heapify=function(e){var t=this._arr,C=2*e,i=C+1,H=e;C>1].priority0&&(H=r.removeMin(),(n=V[H]).distance!==Number.POSITIVE_INFINITY);)i(H).forEach(L);return V}(e,String(t),C||cp,i||function(t){return e.outEdges(t)})},cp=tp.constant(1);var hp=function(e,t,C){return tp.transform(e.nodes(),(function(i,H){i[H]=Ap(e,H,t,C)}),{})};var mp=function(e){var t=0,C=[],i={},H=[];function n(V){var r=i[V]={onStack:!0,lowlink:t,index:t++};if(C.push(V),e.successors(V).forEach((function(e){tp.has(i,e)?i[e].onStack&&(r.lowlink=Math.min(r.lowlink,i[e].index)):(n(e),r.lowlink=Math.min(r.lowlink,i[e].lowlink))})),r.lowlink===r.index){var L,o=[];do{L=C.pop(),i[L].onStack=!1,o.push(L)}while(V!==L);H.push(o)}}return e.nodes().forEach((function(e){tp.has(i,e)||n(e)})),H};var fp=function(e){return tp.filter(mp(e),(function(t){return t.length>1||1===t.length&&e.hasEdge(t[0],t[0])}))};var pp=function(e,t,C){return function(e,t,C){var i={},H=e.nodes();return H.forEach((function(e){i[e]={},i[e][e]={distance:0},H.forEach((function(t){e!==t&&(i[e][t]={distance:Number.POSITIVE_INFINITY})})),C(e).forEach((function(C){var H=C.v===e?C.w:C.v,n=t(C);i[e][H]={distance:n,predecessor:e}}))})),H.forEach((function(e){var t=i[e];H.forEach((function(C){var n=i[C];H.forEach((function(C){var i=n[e],H=t[C],V=n[C],r=i.distance+H.distance;r0;){if(C=n.removeMin(),tp.has(H,C))i.setEdge(C,H[C]);else{if(r)throw new Error("Input graph is not connected: "+e);r=!0}e.nodeEdges(C).forEach(V)}return i};var xp,Op={Graph:op.Graph,json:ap,alg:{components:lp,dijkstra:Ap,dijkstraAll:hp,findCycles:fp,floydWarshall:pp,isAcyclic:function(e){try{vp(e)}catch(e){if(e instanceof vp.CycleException)return!1;throw e}return!0},postorder:function(e,t){return Sp(e,t,"post")},preorder:function(e,t){return Sp(e,t,"pre")},prim:wp,tarjan:mp,topsort:vp},version:op.version};try{xp=Op}catch(e){}xp||(xp=window.graphlib);var kp=xp;var Ep=function(e){return zh(e,5)};var Pp=function(e,t,C){if(!cA(C))return!1;var i=typeof t;return!!("number"==i?Dc(C)&&pc(t,C.length):"string"==i&&t in C)&&Wu(C[t],e)},Tp=Object.prototype,_p=Tp.hasOwnProperty,Bp=Rf((function(e,t){e=Object(e);var C=-1,i=t.length,H=i>2?t[2]:void 0;for(H&&Pp(t[0],t[1],H)&&(i=1);++C-1?H[n?t[V]:V]:void 0}},Rp=/\s/;var Fp=function(e){for(var t=e.length;t--&&Rp.test(e.charAt(t)););return t},Ip=/^\s+/;var zp=function(e){return e?e.slice(0,Fp(e)+1).replace(Ip,""):e},jp=/^[-+]0x[0-9a-f]+$/i,Gp=/^0b[01]+$/i,Wp=/^0o[0-7]+$/i,$p=parseInt;var Up=function(e){if("number"==typeof e)return e;if(vm(e))return NaN;if(cA(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=cA(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=zp(e);var C=Gp.test(e);return C||Wp.test(e)?$p(e.slice(2),C?2:8):jp.test(e)?NaN:+e};var Yp=function(e){return e?Infinity===(e=Up(e))||-Infinity===e?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0};var Xp=function(e){var t=Yp(e),C=t%1;return t==t?C?t-C:t:0},qp=Math.max;var Qp=function(e,t,C){var i=null==e?0:e.length;if(!i)return-1;var H=null==C?0:Xp(C);return H<0&&(H=qp(i+H,0)),Ff(e,qm(t),H)},Kp=Np(Qp);var Jp=function(e){return(null==e?0:e.length)?Of(e,1):[]};var eg=function(e,t){return null==e?e:$h(e,Qh(t),jc)};var tg=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0};var Cg=function(e,t){var C={};return t=qm(t),Uh(e,(function(e,i,H){Vc(C,i,t(e,i,H))})),C};var ig=function(e,t,C){for(var i=-1,H=e.length;++it};var ng=function(e){return e&&e.length?ig(e,qh,Hg):void 0};var Vg=function(e,t,C){(void 0!==C&&!Wu(e[t],C)||void 0===C&&!(t in e))&&Vc(e,t,C)},rg=Function.prototype,Lg=Object.prototype,og=rg.toString,ag=Lg.hasOwnProperty,Mg=og.call(Object);var sg=function(e){if(!Mc(e)||"[object Object]"!=AA(e))return!1;var t=th(e);if(null===t)return!0;var C=ag.call(t,"constructor")&&t.constructor;return"function"==typeof C&&C instanceof C&&og.call(C)==Mg};var lg=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]};var dg=function(e){return oc(e,jc(e))};var ug=function(e,t,C,i,H,n,V){var r=lg(e,C),L=lg(t,C),o=V.get(L);if(o)Vg(e,C,o);else{var a=n?n(r,L,C+"",e,t,V):void 0,M=void 0===a;if(M){var s=cc(L),l=!s&&mc(L),d=!s&&!l&&wc(L);a=L,s||l||d?cc(r)?a=r:qf(r)?a=$c(r):l?(M=!1,a=Wc(L,!0)):d?(M=!1,a=xh(L,!0)):a=[]:sg(L)||Ac(L)?(a=r,Ac(r)?a=dg(r):cA(r)&&!mA(r)||(a=Th(L))):M=!1}M&&(V.set(L,a),H(a,L,i,n,V),V.delete(L)),Vg(e,C,a)}};var Ag=function e(t,C,i,H,n){t!==C&&$h(C,(function(V,r){if(n||(n=new Cc),cA(V))ug(t,C,r,i,e,H,n);else{var L=H?H(lg(t,r),V,r+"",t,C,n):void 0;void 0===L&&(L=V),Vg(t,r,L)}}),jc)};var cg=function(e){return Rf((function(t,C){var i=-1,H=C.length,n=H>1?C[H-1]:void 0,V=H>2?C[2]:void 0;for(n=e.length>3&&"function"==typeof n?(H--,n):void 0,V&&Pp(C[0],C[1],V)&&(n=H<3?void 0:n,H=1),t=Object(t);++it||n&&V&&L&&!r&&!o||i&&V&&L||!C&&L||!H)return 1;if(!i&&!n&&!o&&e=r?L:L*("desc"==C[i]?-1:1)}return e.index-t.index};var Ng=function(e,t,C){t=t.length?Tm(t,(function(e){return cc(e)?function(t){return Im(t,1===e.length?e[0]:e)}:e})):[qh];var i=-1;t=Tm(t,Zc(qm));var H=nf(e,(function(e,C,H){return{criteria:Tm(t,(function(t){return t(e)})),index:++i,value:e}}));return _g(H,(function(e,t){return Dg(e,t,C)}))},Rg=Rf((function(e,t){if(null==e)return[];var C=t.length;return C>1&&Pp(e,t[0],t[1])?t=[]:C>2&&Pp(t[0],t[1],t[2])&&(t=[t[0]]),Ng(e,Of(t,1),[])})),Fg=Rg,Ig=0;var zg=function(e){var t=++Ig;return Nm(e)+t};var jg=function(e,t,C){for(var i=-1,H=e.length,n=t.length,V={};++i0;--r)if(i=t[r].dequeue()){H=H.concat(ev(e,t,C,i,!0));break}}return H}(C.graph,C.buckets,C.zeroIdx);return $g.flatten($g.map(i,(function(t){return e.outEdges(t.v,t.w)})),!0)},Jg=$g.constant(1);function ev(e,t,C,i,H){var n=H?[]:void 0;return $g.forEach(e.inEdges(i.v),(function(i){var V=e.edge(i),r=e.node(i.v);H&&n.push({v:i.v,w:i.w}),r.out-=V,tv(t,C,r)})),$g.forEach(e.outEdges(i.v),(function(i){var H=e.edge(i),n=i.w,V=e.node(n);V.in-=H,tv(t,C,V)})),e.removeNode(i.v),n}function tv(e,t,C){C.out?C.in?e[C.out-C.in+t].enqueue(C):e[e.length-1].enqueue(C):e[0].enqueue(C)}var Cv={run:function(e){var t="greedy"===e.graph().acyclicer?Kg(e,function(e){return function(t){return e.edge(t).weight}}(e)):function(e){var t=[],C={},i={};function H(n){$g.has(i,n)||(i[n]=!0,C[n]=!0,$g.forEach(e.outEdges(n),(function(e){$g.has(C,e.w)?t.push(e):H(e.w)})),delete C[n])}return $g.forEach(e.nodes(),H),t}(e);$g.forEach(t,(function(t){var C=e.edge(t);e.removeEdge(t),C.forwardName=t.name,C.reversed=!0,e.setEdge(t.w,t.v,C,$g.uniqueId("rev"))}))},undo:function(e){$g.forEach(e.edges(),(function(t){var C=e.edge(t);if(C.reversed){e.removeEdge(t);var i=C.forwardName;delete C.reversed,delete C.forwardName,e.setEdge(t.w,t.v,C,i)}}))}};var iv=kp.Graph,Hv={addDummyNode:nv,simplify:function(e){var t=(new iv).setGraph(e.graph());return $g.forEach(e.nodes(),(function(C){t.setNode(C,e.node(C))})),$g.forEach(e.edges(),(function(C){var i=t.edge(C.v,C.w)||{weight:0,minlen:1},H=e.edge(C);t.setEdge(C.v,C.w,{weight:i.weight+H.weight,minlen:Math.max(i.minlen,H.minlen)})})),t},asNonCompoundGraph:function(e){var t=new iv({multigraph:e.isMultigraph()}).setGraph(e.graph());return $g.forEach(e.nodes(),(function(C){e.children(C).length||t.setNode(C,e.node(C))})),$g.forEach(e.edges(),(function(C){t.setEdge(C,e.edge(C))})),t},successorWeights:function(e){var t=$g.map(e.nodes(),(function(t){var C={};return $g.forEach(e.outEdges(t),(function(t){C[t.w]=(C[t.w]||0)+e.edge(t).weight})),C}));return $g.zipObject(e.nodes(),t)},predecessorWeights:function(e){var t=$g.map(e.nodes(),(function(t){var C={};return $g.forEach(e.inEdges(t),(function(t){C[t.v]=(C[t.v]||0)+e.edge(t).weight})),C}));return $g.zipObject(e.nodes(),t)},intersectRect:function(e,t){var C,i,H=e.x,n=e.y,V=t.x-H,r=t.y-n,L=e.width/2,o=e.height/2;if(!V&&!r)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(r)*L>Math.abs(V)*o?(r<0&&(o=-o),C=o*V/r,i=o):(V<0&&(L=-L),C=L,i=L*r/V);return{x:H+C,y:n+i}},buildLayerMatrix:function(e){var t=$g.map($g.range(Vv(e)+1),(function(){return[]}));return $g.forEach(e.nodes(),(function(C){var i=e.node(C),H=i.rank;$g.isUndefined(H)||(t[H][i.order]=C)})),t},normalizeRanks:function(e){var t=$g.min($g.map(e.nodes(),(function(t){return e.node(t).rank})));$g.forEach(e.nodes(),(function(C){var i=e.node(C);$g.has(i,"rank")&&(i.rank-=t)}))},removeEmptyRanks:function(e){var t=$g.min($g.map(e.nodes(),(function(t){return e.node(t).rank}))),C=[];$g.forEach(e.nodes(),(function(i){var H=e.node(i).rank-t;C[H]||(C[H]=[]),C[H].push(i)}));var i=0,H=e.graph().nodeRankFactor;$g.forEach(C,(function(t,C){$g.isUndefined(t)&&C%H!=0?--i:i&&$g.forEach(t,(function(t){e.node(t).rank+=i}))}))},addBorderNode:function(e,t,C,i){var H={width:0,height:0};arguments.length>=4&&(H.rank=C,H.order=i);return nv(e,"border",H,t)},maxRank:Vv,partition:function(e,t){var C={lhs:[],rhs:[]};return $g.forEach(e,(function(e){t(e)?C.lhs.push(e):C.rhs.push(e)})),C},time:function(e,t){var C=$g.now();try{return t()}finally{console.log(e+" time: "+($g.now()-C)+"ms")}},notime:function(e,t){return t()}};function nv(e,t,C,i){var H;do{H=$g.uniqueId(i)}while(e.hasNode(H));return C.dummy=t,e.setNode(H,C),H}function Vv(e){return $g.max($g.map(e.nodes(),(function(t){var C=e.node(t).rank;if(!$g.isUndefined(C))return C})))}var rv={run:function(e){e.graph().dummyChains=[],$g.forEach(e.edges(),(function(t){!function(e,t){var C,i,H,n=t.v,V=e.node(n).rank,r=t.w,L=e.node(r).rank,o=t.name,a=e.edge(t),M=a.labelRank;if(L===V+1)return;for(e.removeEdge(t),H=0,++V;VV.lim&&(r=V,L=!0);var o=$g.filter(t.edges(),(function(t){return L===Ov(e,e.node(t.v),r)&&L!==Ov(e,e.node(t.w),r)}));return $g.minBy(o,(function(e){return Av(t,e)}))}function xv(e,t,C,i){var H=C.v,n=C.w;e.removeEdge(H,n),e.setEdge(i.v,i.w,{}),Zv(e),vv(e,t),function(e,t){var C=$g.find(e.nodes(),(function(e){return!t.node(e).parent})),i=hv(e,C);i=i.slice(1),$g.forEach(i,(function(C){var i=e.node(C).parent,H=t.edge(C,i),n=!1;H||(H=t.edge(i,C),n=!0),t.node(C).rank=t.node(i).rank+(n?H.minlen:-H.minlen)}))}(e,t)}function Ov(e,t,C){return C.low<=t.lim&&t.lim<=C.lim}gv.initLowLimValues=Zv,gv.initCutValues=vv,gv.calcCutValue=yv,gv.leaveEdge=bv,gv.enterEdge=wv,gv.exchangeEdges=xv;var kv=Lv,Ev=function(e){if("function"==typeof e.graph().ranker)e.graph().ranker(e);else switch(e.graph().ranker){case"network-simplex":default:Tv(e);break;case"tight-tree":!function(e){kv(e),sv(e)}(e);break;case"longest-path":Pv(e)}};var Pv=kv;function Tv(e){pv(e)}var _v=function(e){var t=function(e){var t={},C=0;function i(H){var n=C;$g.forEach(e.children(H),i),t[H]={low:n,lim:C++}}return $g.forEach(e.children(),i),t}(e);$g.forEach(e.graph().dummyChains,(function(C){for(var i=e.node(C),H=i.edgeObj,n=function(e,t,C,i){var H,n,V=[],r=[],L=Math.min(t[C].low,t[i].low),o=Math.max(t[C].lim,t[i].lim);H=C;do{H=e.parent(H),V.push(H)}while(H&&(t[H].low>L||o>t[H].lim));n=H,H=i;for(;(H=e.parent(H))!==n;)r.push(H);return{path:V.concat(r.reverse()),lca:n}}(e,t,H.v,H.w),V=n.path,r=n.lca,L=0,o=V[L],a=!0;C!==H.w;){if(i=e.node(C),a){for(;(o=V[L])!==r&&e.node(o).maxRank0;)t%2&&(C+=r[t+1]),r[t=t-1>>1]+=e.weight;L+=e.weight*C}))),L}var Yv=function(e,t){return $g.map(t,(function(t){var C=e.inEdges(t);if(C.length){var i=$g.reduce(C,(function(t,C){var i=e.edge(C),H=e.node(C.v);return{sum:t.sum+i.weight*H.order,weight:t.weight+i.weight}}),{sum:0,weight:0});return{v:t,barycenter:i.sum/i.weight,weight:i.weight}}return{v:t}}))};var Xv=function(e,t){var C={};return $g.forEach(e,(function(e,t){var i=C[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:t};$g.isUndefined(e.barycenter)||(i.barycenter=e.barycenter,i.weight=e.weight)})),$g.forEach(t.edges(),(function(e){var t=C[e.v],i=C[e.w];$g.isUndefined(t)||$g.isUndefined(i)||(i.indegree++,t.out.push(C[e.w]))})),function(e){var t=[];function C(e){return function(t){t.merged||($g.isUndefined(t.barycenter)||$g.isUndefined(e.barycenter)||t.barycenter>=e.barycenter)&&function(e,t){var C=0,i=0;e.weight&&(C+=e.barycenter*e.weight,i+=e.weight);t.weight&&(C+=t.barycenter*t.weight,i+=t.weight);e.vs=t.vs.concat(e.vs),e.barycenter=C/i,e.weight=i,e.i=Math.min(t.i,e.i),t.merged=!0}(e,t)}}function i(t){return function(C){C.in.push(t),0==--C.indegree&&e.push(C)}}for(;e.length;){var H=e.pop();t.push(H),$g.forEach(H.in.reverse(),C(H)),$g.forEach(H.out,i(H))}return $g.map($g.filter(t,(function(e){return!e.merged})),(function(e){return $g.pick(e,["vs","i","barycenter","weight"])}))}($g.filter(C,(function(e){return!e.indegree})))};var qv=function(e,t){var C=Hv.partition(e,(function(e){return $g.has(e,"barycenter")})),i=C.lhs,H=$g.sortBy(C.rhs,(function(e){return-e.i})),n=[],V=0,r=0,L=0;i.sort((o=!!t,function(e,t){return e.barycentert.barycenter?1:o?t.i-e.i:e.i-t.i})),L=Qv(n,H,L),$g.forEach(i,(function(e){L+=e.vs.length,n.push(e.vs),V+=e.barycenter*e.weight,r+=e.weight,L=Qv(n,H,L)}));var o;var a={vs:$g.flatten(n,!0)};r&&(a.barycenter=V/r,a.weight=r);return a};function Qv(e,t,C){for(var i;t.length&&(i=$g.last(t)).i<=C;)t.pop(),e.push(i.vs),C++;return C}var Kv=function e(t,C,i,H){var n=t.children(C),V=t.node(C),r=V?V.borderLeft:void 0,L=V?V.borderRight:void 0,o={};r&&(n=$g.filter(n,(function(e){return e!==r&&e!==L})));var a=Yv(t,n);$g.forEach(a,(function(C){if(t.children(C.v).length){var n=e(t,C.v,i,H);o[C.v]=n,$g.has(n,"barycenter")&&(V=C,r=n,$g.isUndefined(V.barycenter)?(V.barycenter=r.barycenter,V.weight=r.weight):(V.barycenter=(V.barycenter*V.weight+r.barycenter*r.weight)/(V.weight+r.weight),V.weight+=r.weight))}var V,r}));var M=Xv(a,i);!function(e,t){$g.forEach(e,(function(e){e.vs=$g.flatten(e.vs.map((function(e){return t[e]?t[e].vs:e})),!0)}))}(M,o);var s=qv(M,H);if(r&&(s.vs=$g.flatten([r,s.vs,L],!0),t.predecessors(r).length)){var l=t.node(t.predecessors(r)[0]),d=t.node(t.predecessors(L)[0]);$g.has(s,"barycenter")||(s.barycenter=0,s.weight=0),s.barycenter=(s.barycenter*s.weight+l.order+d.order)/(s.weight+2),s.weight+=2}return s};var Jv=kp.Graph,ey=function(e,t,C){var i=function(e){var t;for(;e.hasNode(t=$g.uniqueId("_root")););return t}(e),H=new Jv({compound:!0}).setGraph({root:i}).setDefaultNodeLabel((function(t){return e.node(t)}));return $g.forEach(e.nodes(),(function(n){var V=e.node(n),r=e.parent(n);(V.rank===t||V.minRank<=t&&t<=V.maxRank)&&(H.setNode(n),H.setParent(n,r||i),$g.forEach(e[C](n),(function(t){var C=t.v===n?t.w:t.v,i=H.edge(C,n),V=$g.isUndefined(i)?0:i.weight;H.setEdge(C,n,{weight:e.edge(t).weight+V})})),$g.has(V,"minRank")&&H.setNode(n,{borderLeft:V.borderLeft[t],borderRight:V.borderRight[t]}))})),H};var ty=function(e,t,C){var i,H={};$g.forEach(C,(function(C){for(var n,V,r=e.parent(C);r;){if((n=e.parent(r))?(V=H[n],H[n]=r):(V=i,i=r),V&&V!==r)return void t.setEdge(V,r);r=n}}))};var Cy=kp.Graph,iy=function(e){var t=Hv.maxRank(e),C=Hy(e,$g.range(1,t+1),"inEdges"),i=Hy(e,$g.range(t-1,-1,-1),"outEdges"),H=Wv(e);Vy(e,H);for(var n,V=Number.POSITIVE_INFINITY,r=0,L=0;L<4;++r,++L){ny(r%2?C:i,r%4>=2),H=Hv.buildLayerMatrix(e);var o=$v(e,H);oV)&&My(C,t,r)}))}))}return $g.reduce(t,(function(t,C){var H,n=-1,V=0;return $g.forEach(C,(function(r,L){if("border"===e.node(r).dummy){var o=e.predecessors(r);o.length&&(H=e.node(o[0]).order,i(C,V,L,n,H),V=L,n=H)}i(C,V,C.length,H,t.length)})),C})),C}function My(e,t,C){if(t>C){var i=t;t=C,C=i}var H=e[t];H||(e[t]=H={}),H[C]=!0}function sy(e,t,C){if(t>C){var i=t;t=C,C=i}return $g.has(e[t],C)}function ly(e,t,C,i){var H={},n={},V={};return $g.forEach(t,(function(e){$g.forEach(e,(function(e,t){H[e]=e,n[e]=e,V[e]=t}))})),$g.forEach(t,(function(e){var t=-1;$g.forEach(e,(function(e){var r=i(e);if(r.length){r=$g.sortBy(r,(function(e){return V[e]}));for(var L=(r.length-1)/2,o=Math.floor(L),a=Math.ceil(L);o<=a;++o){var M=r[o];n[e]===e&&t1?t-1:0),i=1;i=(n=(u+c)/2))?u=n:c=n,(a=C>=(V=(A+h)/2))?A=V:h=V,H=l,!(l=l[M=a<<1|o]))return H[M]=d,e;if(r=+e._x.call(null,l.data),L=+e._y.call(null,l.data),t===r&&C===L)return d.next=l,H?H[M]=d:e._root=d,e;do{H=H?H[M]=new Array(4):e._root=new Array(4),(o=t>=(n=(u+c)/2))?u=n:c=n,(a=C>=(V=(A+h)/2))?A=V:h=V}while((M=a<<1|o)==(s=(L>=V)<<1|r>=n));return H[s]=l,H[M]=d,e}function i(e){var t,i,H,n,V=e.length,r=new Array(V),L=new Array(V),o=1/0,a=1/0,M=-1/0,s=-1/0;for(i=0;iM&&(M=H),ns&&(s=n));if(o>M||a>s)return this;for(this.cover(o,a).cover(M,s),i=0;ie||e>=H||i>t||t>=n;)switch(r=(tl||(n=o.y0)>d||(V=o.x1)=h)<<1|e>=c)&&(o=u[u.length-1],u[u.length-1]=u[u.length-1-a],u[u.length-1-a]=o)}else{var m=e-+this._x.call(null,A.data),f=t-+this._y.call(null,A.data),p=m*m+f*f;if(p=(r=(d+A)/2))?d=r:A=r,(a=V>=(L=(u+c)/2))?u=L:c=L,t=l,!(l=l[M=a<<1|o]))return this;if(!l.length)break;(t[M+1&3]||t[M+2&3]||t[M+3&3])&&(C=t,s=M)}for(;l.data!==e;)if(i=l,!(l=l.next))return this;return(H=l.next)&&delete l.next,i?(H?i.next=H:delete i.next,this):t?(H?t[M]=H:delete t[M],(l=t[0]||t[1]||t[2]||t[3])&&l===(t[3]||t[2]||t[1]||t[0])&&!l.length&&(C?C[s]=l:this._root=l),this):(this._root=H,this)}function a(e){for(var t=0,C=e.length;t{}};function C(){for(var e,t=0,C=arguments.length,H={};t=0&&(C=e.slice(i+1),e=e.slice(0,i)),e&&!t.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:C}}))}function n(e,t){for(var C,i=0,H=e.length;i0)for(var C,i,H=new Array(C),n=0;n=0&&C._call.call(null,e),C=C._next;--i}function c(){L=(r=a.now())+o,i=H=0;try{A()}finally{i=0,m(),L=0}}function h(){var e=a.now(),t=e-r;t>V&&(o-=t,r=e)}function m(){for(var e,i,H=t,n=1/0;H;)H._call?(n>H._time&&(n=H._time),e=H,H=H._next):(i=H._next,H._next=null,H=e?e._next=i:t=i);C=e,f(n)}function f(e){i||(H&&(H=clearTimeout(H)),e-L>24?(e<1/0&&(H=setTimeout(c,e-a.now()-o)),n&&(n=clearInterval(n))):(n||(r=a.now(),n=setInterval(h,V)),i=1,M(c)))}function p(e,t,C){var i=new d;return t=null==t?0:+t,i.restart((C=>{i.stop(),e(C+t)}),t,C),i}function g(e,t,C){var i=new d,H=t;return null==t?(i.restart(e,t,C),i):(i._restart=i.restart,i.restart=function(e,t,C){t=+t,C=null==C?s():+C,i._restart((function n(V){V+=H,i._restart(n,H+=t,C),e(V)}),t,C)},i.restart(e,t,C),i)}d.prototype=u.prototype={constructor:d,restart:function(e,i,H){if("function"!=typeof e)throw new TypeError("callback is not a function");H=(null==H?s():+H)+(null==i?0:+i),this._next||C===this||(C?C._next=this:t=this,C=this),this._call=e,this._time=H,f()},stop:function(){this._call&&(this._call=null,this._time=1/0,f())}},e.interval=g,e.now=s,e.timeout=p,e.timer=u,e.timerFlush=A,Object.defineProperty(e,"__esModule",{value:!0})}(t)})),zy=fe((function(e,t){!function(e,t,C,i){function H(e,t){var C,i=1;function H(){var H,n,V=C.length,r=0,L=0;for(H=0;Hl+a||id+a||nM.index){var s=l-r.x-r.vx,c=d-r.y-r.vy,h=s*s+c*c;he.r&&(e.r=e[t].r)}function l(){if(C){var t,H,n=C.length;for(i=new Array(n),t=0;t[o(e,t,i),e])));for(n=0,H=new Array(L);n(e=(l*e+d)%u)/u}function c(e){return e.x}function h(e){return e.y}var m=10,f=Math.PI*(3-Math.sqrt(5));function p(e){var t,H=1,n=.001,V=1-Math.pow(n,1/300),r=0,L=.6,o=new Map,a=i.timer(l),M=C.dispatch("tick","end"),s=A();function l(){d(),M.call("tick",t),H1?(null==C?o.delete(e):o.set(e,c(C)),t):o.get(e)},find:function(t,C,i){var H,n,V,r,L,o=0,a=e.length;for(null==i?i=1/0:i*=i,o=0;o1?(M.on(e,C),t):M.on(e)}}}function g(){var e,C,i,H,r,L=n(-30),o=1,a=1/0,M=.81;function s(i){var n,V=e.length,r=t.quadtree(e,c,h).visitAfter(d);for(H=i,n=0;n=a)){(e.data!==C||e.next)&&(0===s&&(u+=(s=V(i))*s),0===l&&(u+=(l=V(i))*l),u1?1:H)>=1?this.end(!e.infinite):(e.tick&&e.tick(H),e.animate&&this.refreshPositions(e.nodes,e,e.fit))}},{key:"end",value:function(e){var t=this.state;this.refreshPositions(t.nodes,t,t.fit),this.emit("layoutstop",t.cy),this.reset(e)}},{key:"reset",value:function(e){this.simulation&&this.simulation.stop();var t=this.state;return this.destroyedEvent&&this.destroyedEvent(),(e||!t.infinite)&&this.removeCytoscapeEvents&&this.removeCytoscapeEvents(),t.animate&&this.regrabify(t.nodes),this}},{key:"run",value:function(){var e=this;this.reset();var t,C=this,i=this.state,H=!1;if(i.currentBoundingBox=this.makeBoundingBox(i.boundingBox,i.cy),i.ready&&C.one("layoutready",i.ready),i.stop&&C.one("layoutstop",i.stop),i.nodes.forEach((function(t){return e.setInitialPositionState(t,i)})),H||(H=!0,C.emit("layoutready")),!C.simulation){var r=i.nodes.map((function(e){return V(C.getScratch(e),e.data())})),L=i.edges.map((function(e){return V({},e.data())}));C.simulation=n.forceSimulation(r),i.alpha&&C.simulation.alpha(i.alpha),i.alphaMin&&C.simulation.alphaMin(i.alphaMin),i.alphaDecay&&C.simulation.alphaDecay(i.alphaDecay),i.alphaTarget&&C.simulation.alphaTarget(i.alphaTarget),i.velocityDecay&&C.simulation.velocityDecay(i.velocityDecay);var o=n.forceCollide();i.collideRadius&&o.radius(i.collideRadius),i.collideStrength&&o.strength(i.collideStrength),i.collideIterations&&o.iterations(i.collideIterations);var a=n.forceLink(L);i.linkId&&a.id(i.linkId),i.linkDistance&&a.distance(i.linkDistance),i.linkStrength&&a.strength(i.linkStrength),i.linkIterations&&a.iterations(i.linkIterations);var M=n.forceManyBody();i.manyBodyStrength&&M.strength(i.manyBodyStrength),i.manyBodyTheta&&M.theta(i.manyBodyTheta),i.manyBodyDistanceMin&&M.distanceMin(i.manyBodyDistanceMin),i.manyBodyDistanceMax&&M.distanceMax(i.manyBodyDistanceMax);var s=n.forceX();i.xX&&s.x(i.xX),i.xStrength&&s.strength(i.xStrength);var l=n.forceY();i.yY&&l.y(i.yY),i.yStrength&&l.strength(i.yStrength);var d=null;(i.radialRadius||i.radialStrength||i.radialX||i.radialY)&&(d=n.forceRadial(),i.radialRadius&&d.radius(i.radialRadius),i.radialStrength&&d.strength(i.radialStrength),i.radialX&&d.x(i.radialX),i.radialY&&d.y(i.radialY));var u=n.forceCenter(i.currentBoundingBox.w/2,i.currentBoundingBox.h/2);C.simulation.force("collide",o).force("link",a).force("many-body",M).force("x",s).force("y",l).force("center",u),d&&C.simulation.force("radius",d),C.simulation.on("tick",(function(){C.tick()})).on("end",(function(){C.end()}))}C.destroyedEvent||(i.cy.one("destroy",t=function(){C.stop()}),C.destroyedEvent=function(){i.cy.off("destroy",t),C.destroyedEvent=null});if(C.prerun(i),C.emit("layoutstart"),i.progress=0,i.iterations=0,i.startTime=Date.now(),i.animate){var A=Math.abs((i.alpha||1)-(i.alphaTarget||0))/3;if(!C.removeCytoscapeEvents){var c=function(e){var t=this,H=t.position();if(e.cyTarget===t||e.target===t){var n=C.getScratch(t);i.progress=0,i.iterations=0,i.startTime=Date.now(),n.x=H.x,n.y=H.y,"grab"===e.type?C.simulation.alphaTarget(A).restart():"unlock"===e.type||"free"===e.type?(i.fixedAfterDragging?(n.fx=H.x,n.fy=H.y):(delete n.fx,delete n.fy),C.simulation.alphaTarget(A).restart()):(n.fx=H.x,n.fy=H.y)}};C.removeCytoscapeEvents=function(){i.nodes.off("grab free drag lock unlock",c),C.removeCytoscapeEvents=null},i.nodes.on("grab free drag lock unlock",c)}C.ungrabify(i.nodes)}return C.postrun(i),this}},{key:"prerun",value:function(){}},{key:"postrun",value:function(){}},{key:"stop",value:function(){return this.reset(!0)}}]),e}();e.exports=r},function(e,t,C){e.exports=null!=Object.assign?Object.assign.bind(Object):function(e){for(var t=arguments.length,C=Array(t>1?t-1:0),i=1;in+t.spotlightPadding?n+t.spotlightPadding:t.indicatorSize;c.beginPath(),c.fillRect(-s/2,-s/2,s,s),c.closePath(),c.fill(),c.rotate(-M),c.translate(-o,-a),c.beginPath(),c.arc(i+t.activePadding,i+t.activePadding,n+t.spotlightPadding,0,2*Math.PI,!0),c.closePath(),c.fill(),c.globalCompositeOperation="source-over"}function Z(){var e=o(),t=m,C=m;u.width=t*e,u.height=C*e,u.style.width=t+"px",u.style.height=C+"px",c.setTransform(1,0,0,1,0,0),c.scale(e,e)}n.insertBefore(l,n.firstChild),l.appendChild(d),d.appendChild(u),r(l,{position:"absolute",zIndex:t.zIndex,userSelect:"none",pointerEvents:"none"}),["mousedown","mousemove","mouseup","contextmenu"].forEach((function(e){l.addEventListener(e,(function(e){return e.preventDefault(),!1}))})),r(d,{display:"none",width:m+"px",height:m+"px",position:"absolute",zIndex:1,marginLeft:-t.activePadding+"px",marginTop:-t.activePadding+"px",userSelect:"none"}),u.width=m,u.height=m;var S=!0,b={},w=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(e){return setTimeout(e,16)};Z(),function e(){b.drawBg&&v.apply(null,b.drawBg),b.drawCommands&&y.apply(null,b.drawCommands),b={},S&&w(e)}();var x,O,k,E,P,T,_,B,D=void 0,N=void 0,R=void 0,F={on:function(e,t,i){var H=i;return"core"===t&&(H=function(e){if(e.cyTarget===C||e.target===C)return i.apply(this,[e])}),s.handlers.push({events:e,selector:t,fn:H}),"core"===t?C.on(e,H):C.on(e,t,H),this}};function I(){S=!1,function(){for(var e=s.handlers,t=0;t0,H=(i?C.touches[0].pageX:C.pageX)-window.pageXOffset,n=(i?C.touches[0].pageY:C.pageY)-window.pageYOffset;f=void 0;var V=H-p.left-D,r=n-p.top-N;0===V&&(V=.01);var L=Math.sqrt(V*V+r*r),o=(r*r-L*L-V*V)/(-2*L*V),a=Math.acos(o),s=void 0;if(M&&M.isNode instanceof Function&&M.isNode()&&!M.isParent()&&!t.atMouse?(s=M.renderedOuterWidth(),R=s/2,R=!t.adaptativeNodeSpotlightRadius&&t.minSpotlightRadius?Math.max(R,t.minSpotlightRadius):R,R=!t.adaptativeNodeSpotlightRadius&&t.maxSpotlightRadius?Math.min(R,t.maxSpotlightRadius):R):(R=(s=1)/2,R=t.minSpotlightRadius?Math.max(R,t.minSpotlightRadius):R,R=t.maxSpotlightRadius?Math.min(R,t.maxSpotlightRadius):R),h=s/2+(t.menuRadius instanceof Function?t.menuRadius(M):Number(t.menuRadius)),Lh+t.activePadding+t.outsideMenuCancel)g(h,R);else{g(h,R);var l=V*h/L,d=r*h/L;r>0&&(a=Math.PI+Math.abs(a-Math.PI));for(var u=2*Math.PI/A.length,c=Math.PI/2,m=c+u,v=0;v1?t-1:0),i=1;i1&&void 0!==arguments[1]?arguments[1]:document,C=t.querySelectorAll(e),i=0;ie.data("name").localeCompare(t.data("name"));function CZ(e,t,C){let{name:i}=t,{nodes:H}=t,{onClickText:n}=t,{onClickButton:V}=t,{icon:r=null}=t,{icon_tooltip:L=null}=t,{ctxmenu:o}=t,a=!0;return e.$$set=e=>{"name"in e&&C(0,i=e.name),"nodes"in e&&C(1,H=e.nodes),"onClickText"in e&&C(2,n=e.onClickText),"onClickButton"in e&&C(3,V=e.onClickButton),"icon"in e&&C(4,r=e.icon),"icon_tooltip"in e&&C(5,L=e.icon_tooltip),"ctxmenu"in e&&C(6,o=e.ctxmenu)},[i,H,n,V,r,L,o,a,function(){C(7,a=!a)},(e,t)=>n(e,t),(e,t)=>o(e,t)]}class iZ extends te{constructor(e){super(),ee(this,e,CZ,eZ,A,{name:0,nodes:1,onClickText:2,onClickButton:3,icon:4,icon_tooltip:5,ctxmenu:6})}}function HZ(e){let t,C,i,H,n;return C=new iZ({props:{nodes:e[0],name:"Nodes in graph",ctxmenu:e[2],onClickText:e[3]}}),H=new iZ({props:{nodes:e[1],name:"Hidden nodes",ctxmenu:e[2],onClickText:e[3],icon:ca.ag_unhide,icon_tooltip:"Show in graph",onClickButton:e[4]}}),{c(){t=v("div"),q(C.$$.fragment),i=S(),q(H.$$.fragment),x(t,"class","juggl-nodes-pane")},m(e,V){f(e,t,V),Q(C,t,null),m(t,i),Q(H,t,null),n=!0},p(e,[t]){const i={};1&t&&(i.nodes=e[0]),C.$set(i);const n={};2&t&&(n.nodes=e[1]),H.$set(n)},i(e){n||(Y(C.$$.fragment,e),Y(H.$$.fragment,e),n=!0)},o(e){X(C.$$.fragment,e),X(H.$$.fragment,e),n=!1},d(e){e&&p(t),K(C),K(H)}}}function nZ(t,C,i){let H=null,V=Wo().collection(),r=Wo().collection();return[V,r,function(t,C){const i=new e.Menu,V=n.fromNode(t),r=H.plugin.metadata.getFirstLinkpathDest(V.id,"");void 0!==r&&H.plugin.app.workspace.trigger("file-menu",i,r,"my-context-menu",null),H.mode.fillMenu(i,t),i.showAtPosition({x:C.x,y:C.y})},function(e,t){H.plugin.openFileFromNode(e,t.metaKey)},function(e){e.removeClass("hard-filtered"),H.onGraphChanged(!0,!0)},function(e){if(!e)return H=null,i(0,V=Wo().collection()),void i(1,r=Wo().collection());H=e,i(0,V=H.viz.nodes(":visible")),i(1,r=H.viz.nodes(".hard-filtered"))}]}class VZ extends te{constructor(e){super(),ee(this,e,nZ,HZ,A,{setViz:5})}get setViz(){return this.$$.ctx[5]}}class rZ extends e.FuzzySuggestModal{constructor(e,t,C){super(e),this.callback=t,this.resultContainerEl.addClass("juggl-icon-picker"),this.color=C}getItemText(e){return e.name}getItems(){const e=[{name:"No icon",path:"",color:this.color}];return e.push(...Object.keys(ua).map((e=>({name:e.slice(3).replace(/([A-Z])/g," $1").trim(),path:ua[e],color:this.color})))),e}onChooseItem(e,t){this.callback(e)}renderSuggestion(e,t){t.empty();const C=Aa(e.item.path);t.createEl("span",{cls:"react-icon "}).innerHTML=C,super.renderSuggestion(e,t)}}function LZ(e,t,C){const i=e.slice();return i[15]=t[C],i[16]=t,i[17]=C,i}function oZ(e,t,C){const i=e.slice();return i[18]=t[C],i}function aZ(e){let t,C,i,H,n,V,r,L,o=e[15].filter+"";return{c(){t=v("div"),C=v("div"),C.innerHTML='',i=S(),H=Z(o),n=S(),V=v("br"),x(C,"class","clickable-icon"),E(C,"display","inline"),x(C,"aria-label","Show group options"),x(t,"class","juggl-style-group-hidden")},m(o,a){f(o,t,a),m(t,C),m(t,i),m(t,H),f(o,n,a),f(o,V,a),r||(L=w(C,"click",(function(){u(e[7](e[15],!0))&&e[7](e[15],!0).apply(this,arguments)})),r=!0)},p(t,C){e=t,1&C&&o!==(o=e[15].filter+"")&&O(H,o)},d(e){e&&p(t),e&&p(n),e&&p(V),r=!1,L()}}}function MZ(e){let t,C,i,H,n,V,r,L,o,a,M,s,l,A,c,h,b,E,T,_,B,D,N,R,F,z,j,G,W,$,U,Y,X,q,Q,K=Math.round(100*e[15].size)/100+"";function J(){e[10].call(M,e[16],e[17])}function ee(){e[11].call(E,e[16],e[17])}let te=ie,Ce=[];for(let t=0;t',H=S(),n=v("div"),V=y("svg"),r=y("path"),a=S(),M=v("input"),s=S(),l=v("div"),l.innerHTML='',A=S(),c=v("div"),h=S(),b=v("div"),E=v("input"),T=S(),_=v("select");for(let e=0;eNew group',x(t,"class","juggl-list-header"),x(V,"class","graph-color-button-container"),x(H,"class","juggl-style-group-container")},m(o,M){f(o,t,M),m(t,C),f(o,i,M),f(o,H,M);for(let e=0;e{"groups"in e&&C(0,i=e.groups),"title"in e&&C(1,H=e.title),"onChangeFilter"in e&&C(2,n=e.onChangeFilter),"onChangeGroups"in e&&C(3,V=e.onChangeGroups),"plugin"in e&&C(9,r=e.plugin)},[i,H,n,V,function(){i.push({...de}),C(0,i),V()},function(e){i.remove(e),C(0,i),n(),V()},function(e){new rZ(r.app,(function(t){e.icon=t,V(),C(0,i)}),e.icon.color).open()},function(e,t){e.showInPane=t,C(0,i)},function(e){e.show=!e.show,V(),C(0,i)},r,function(e,t){e[t].filter=this.value,C(0,i)},function(e,t){e[t].color=this.value,C(0,i)},function(e,t){e[t].shape=function(e){const t=e.querySelector(":checked")||e.options[0];return t&&t.__value}(this),C(0,i)},function(e,t){e[t].icon.color=this.value,C(0,i)},function(e,t){var H;e[t].size=""===(H=this.value)?null:+H,C(0,i)}]}class mZ extends te{constructor(e){super(),ee(this,e,hZ,cZ,A,{groups:0,title:1,onChangeFilter:2,onChangeGroups:3,plugin:9})}}function fZ(e){let t,C,i,H,n;return C=new mZ({props:{groups:e[1],title:"Local style groups",onChangeGroups:e[3],onChangeFilter:e[5],plugin:e[0]}}),H=new mZ({props:{groups:e[2],title:"Global style groups",onChangeGroups:e[4],onChangeFilter:e[6],plugin:e[0]}}),{c(){t=v("div"),q(C.$$.fragment),i=S(),q(H.$$.fragment),x(t,"class","juggl-style-pane")},m(e,V){f(e,t,V),Q(C,t,null),m(t,i),Q(H,t,null),n=!0},p(e,[t]){const i={};2&t&&(i.groups=e[1]),1&t&&(i.plugin=e[0]),C.$set(i);const n={};1&t&&(n.plugin=e[0]),H.$set(n)},i(e){n||(Y(C.$$.fragment,e),Y(H.$$.fragment,e),n=!0)},o(e){X(C.$$.fragment,e),X(H.$$.fragment,e),n=!1},d(e){e&&p(t),K(C),K(H)}}}function pZ(e,t,C){let{viz:i}=t,{plugin:H}=t,n=H?.settings;let V=[],r=n.globalStyleGroups;return e.$$set=e=>{"viz"in e&&C(7,i=e.viz),"plugin"in e&&C(0,H=e.plugin)},[H,V,r,function(){i&&i.updateStylesheet()},function(){H.saveData(n),H.activeGraphs().forEach((e=>e.updateStylesheet()))},function(){i&&i.assignStyleGroups()},function(){H.saveData(n),H.activeGraphs().forEach((e=>e.assignStyleGroups()))},i,function(e){C(7,i=e),C(1,V=i?i.settings.styleGroups:[])}]}class gZ extends te{constructor(e){super(),ee(this,e,pZ,fZ,A,{viz:7,plugin:0,setViz:8})}get setViz(){return this.$$.ctx[8]}}class vZ extends e.ItemView{constructor(e,t){super(e),this.activeViz=null,this.changeRef=null,this.plugin=t;const C=this;this.registerEvent(this.plugin.app.workspace.on("active-leaf-change",(e=>{if(this.changeRef&&(this.activeViz.offref(this.changeRef),this.changeRef=null),e)if("juggl_view"===e.view.getViewType()){const t=e.view.juggl;if(this.changeRef=t.on("elementsChange",(()=>{C.onActiveVizChange()})),t===this.activeViz)return;this.activeViz=t}else e.view instanceof vZ||(this.activeViz=null);else this.activeViz=null;this.onActiveVizChange()})))}setViz(e){this.activeViz=e,this.onActiveVizChange()}}class yZ extends vZ{constructor(e,t){super(e,t),this.icon="ag-node-list"}onload(){super.onload(),this.pane=new VZ({target:this.contentEl})}getDisplayText(){return"Juggl nodes"}getViewType(){return"juggl_nodes"}onActiveVizChange(){this.pane&&this.pane.setViz.bind(this.pane)(this.activeViz)}}class ZZ extends vZ{constructor(e,t){super(e,t),this.icon="ag-style"}onload(){super.onload(),this.pane=new gZ({target:this.contentEl,props:{plugin:this.plugin}})}getDisplayText(){return"Juggl style"}getViewType(){return"juggl_style"}onActiveVizChange(){this.pane&&this.pane.setViz.bind(this.pane)(this.activeViz)}}class SZ extends e.Component{constructor(e){super(),this.graphs=[],this.plugin=e,this.adapter=this.plugin.app.vault.adapter}async onload(){super.onload();try{await this.adapter.mkdir(H(this.plugin.vault));const e=require("path");this.graphs=(await this.adapter.list(H(this.plugin.vault))).folders.map((t=>e.basename(t)))}catch(e){console.log(e)}}async saveGraph(e,t){try{const C=H(t.vault)+e;await this.adapter.mkdir(C);const i=t.viz.json();await this.adapter.write(C+"/graph.json",JSON.stringify(i));const n=t.settings;await this.adapter.write(C+"/settings.json",JSON.stringify(n)),this.graphs.contains(e)||this.graphs.push(e)}catch(e){console.log(e)}}async loadGraph(e,t){try{const C=H(t.vault)+e,i=JSON.parse(await this.adapter.read(C+"/graph.json")),V=JSON.parse(await this.adapter.read(C+"/settings.json"));t.viz.json(i),t.settings=V;const r=t.viz.nodes();for(let e=1;e{"cancelCallback"in e&&C(0,i=e.cancelCallback),"continueCallback"in e&&C(1,H=e.continueCallback)},[i,H]}class xZ extends te{constructor(e){super(),ee(this,e,wZ,bZ,A,{cancelCallback:0,continueCallback:1})}}class OZ extends e.Modal{constructor(e,t){super(e);new xZ({target:this.modalEl,props:{cancelCallback:this.close.bind(this),continueCallback:t}})}}class kZ extends e.Plugin{constructor(){super(...arguments),this.coreStores={},this.stores=[]}async onload(){super.onload(),console.log("Loading Juggl"),iM(Wo),Wo.use(Ss),Wo.use(Ru),Wo.use(Ny),Wo.use(ju),Wo.use(Gy),Wo.use($y),Wo.use(Yy),Object.keys(ca).forEach((t=>{e.addIcon(t.replace("_","-").replace("_","-"),Aa(ca[t]))})),this.vault=this.app.vault,this.metadata=this.app.metadataCache,this.path=this.vault.getRoot().path;const t=new a(this);this.addChild(t),this.workspaceManager=new SZ(this),this.addChild(this.workspaceManager),this.registerCoreStore(t,"Obsidian"),ue.globalStyleGroups=function(e){const t={},C=[["#0089BA","#2C73D2","#008E9B","#0081CF","#008F7A","#008E9B"],["#D65DB1","#0082C1","#9270D3","#007F93","#007ED9","#007660"],["#FF9671","#A36AAA","#F27D88","#6967A9","#D26F9D","#1b6299"],["#FFC75F","#4C9A52","#C3BB4E","#00855B","#88AC4B","#006F61"],["#FF6F91","#6F7F22","#E07250","#257A3E","#AC7C26","#006F5F"],["#F9F871","#2FAB63","#B8E067","#008E63","#78C664","#007160"]],i=[];for(const e of Array(6).keys())for(const t of Array(6).keys())i.push(C[t][e]);let H=0;for(const C of e.vault.getMarkdownFiles()){const n=e.metadata.getFileCache(C);n?.tags&&n.tags.forEach((e=>{const C=e.tag.slice(1).split("/"),n=[];for(const e in C){const t=C.slice(0,parseInt(e)+1).join("-");n.push(t)}for(const e of n)e in t||(t[e]=i[H],H+=1,H>=i.length&&(H=0))}))}const n=[{filter:"class:dangling",color:ne("color-fill-unresolved"),shape:"ellipse",icon:{name:"No icon",path:"",color:"white"},showInPane:!0,show:!0,size:1},{filter:"class:file -class:image",color:ne("color-fill"),shape:"ellipse",icon:{name:"No icon",path:"",color:"white"},showInPane:!0,show:!0,size:1}];for(const e of Object.keys(t))n.push({filter:`tag:#${e}`,color:t[e],shape:"ellipse",icon:{name:"No icon",path:"",color:"white"},showInPane:!0,show:!0,size:1});return n}(this),this.settings=Object.assign({},ue,await this.loadData()),this.settings.globalStyleGroups=this.settings.globalStyleGroups.map((e=>Object.assign({},de,e))),this.settings.graphSettings=Object.assign({},ue.graphSettings,this.settings.graphSettings),this.settings.embedSettings=Object.assign({},ue.embedSettings,this.settings.embedSettings),this.addCommand({id:"open-vis",name:"Open local graph of note",callback:()=>{const e=this.app.workspace.getActiveFile().name;this.openLocalGraph(e)}}),this.addCommand({id:"open-vis-global",name:"Open global graph",callback:()=>{this.openGlobalGraph()}}),this.addSettingTab(new Ae(this.app,this)),this.registerEvent(this.app.workspace.on("file-menu",((e,t)=>{t&&e.addItem((e=>{e.setTitle("Open Juggl").setIcon("dot-network").onClick((e=>{"md"===t.extension?this.openLocalGraph(t.basename):this.openLocalGraph(t.name)}))}))}))),this.registerMarkdownCodeBlockProcessor("juggl",(async(t,C,i)=>{setTimeout((async()=>{const i=e.parseYaml(t);try{const e=Object.assign({},this.settings.embedSettings,i);if(!le.contains(e.layout))throw new Error(`Invalid layout. Choose one from ${le}`);const t={dataStores:[this.coreStores[e.coreStore]].concat(this.stores),coreStore:this.coreStores[e.coreStore]};if(C.style.width=e.width,C.style.height=e.height,Object.keys(i).contains("local"))this.addChild(new tM(C,this,t,e,[i.local]));else if(Object.keys(i).contains("workspace")){const H=new tM(C,this,t,e,null);if(!this.workspaceManager.graphs.contains(i.workspace))throw new Error("Did not recognize workspace. Did you misspell its name?");this.addChild(H),await this.workspaceManager.loadGraph(i.workspace,H)}else{if(!Object.keys(i).contains("oql"))throw new Error("Invalid query. Specify either the local property or the workspace property.");if(!("obsidian-query-language"in this.app.plugins.plugins))throw new Error("The Obsidian Query Language plugin isn't loaded, so cannot query using oql!");{const H=await this.app.plugins.plugins["obsidian-query-language"].search(i.oql);e.expandInitial=!1,this.addChild(new tM(C,this,t,e,H.map((e=>e.title))))}}}catch(e){const t=document.createElement("div");t.addClass("juggl-error"),t.innerText=e.message,C.appendChild(t)}}),200)}));const C=this;this.registerView("juggl_nodes",(e=>new yZ(e,C))),this.registerView("juggl_style",(e=>new ZZ(e,C)));const i=function(){if(0===C.app.workspace.getLeavesOfType("juggl_nodes").length){C.app.workspace.getRightLeaf(!1).setViewState({type:"juggl_nodes"})}},H=function(){if(0===C.app.workspace.getLeavesOfType("juggl_style").length){C.app.workspace.getRightLeaf(!1).setViewState({type:"juggl_style"})}};this.app.workspace.onLayoutReady(i),this.app.workspace.onLayoutReady(H),this.addCommand({id:"show-nodes-pane",name:"Open Nodes Pane",checkCallback:e=>{if(e)return 0===this.app.workspace.getLeavesOfType("juggl_nodes").length;i()}}),this.addCommand({id:"show-style-pane",name:"Open Style Pane",checkCallback:e=>{if(e)return 0===this.app.workspace.getLeavesOfType("juggl_style").length;H()}});const n=Ce(this.vault);this.registerEvent(this.vault.on("raw",(e=>{if(e===n){console.log(`Updating stylesheet from ${n}`);for(const e of this.activeGraphs())e.updateStylesheet().then()}}))),this.setGlobalIcon(),this.addChild(new CM(this))}setGlobalIcon(){this.ribbonIcon&&this.ribbonIcon.detach(),this.settings.globalGraphRibbon&&(this.ribbonIcon=this.addRibbonIcon("ag-concentric","Juggl global graph",(()=>{this.openGlobalGraph()})))}async openFileFromNode(e,t=!1){const C=n.fromNode(e);if("core"!==C.storeId)return null;let i=this.app.metadataCache.getFirstLinkpathDest(C.id,"");if(i)await this.openFile(i);else{const e=C.id+".md";i=await this.vault.create(e,""),await this.openFile(i)}return i}async openFile(e,t=!1){await this.app.workspace.getLeaf(t).openFile(e)}async openLocalGraph(e){const t=this.app.workspace.splitActiveLeaf(this.settings.splitDirection),C=new Xy(t,this.settings.graphSettings,this,[e]);await t.open(C)}async openGlobalGraph(){const e=this.app.workspace.getLeaf(!1),t=this.app.vault.getFiles().map((e=>"md"===e.extension?e.basename:e.name));if(t.length>250){const C=new OZ(this.app,(async()=>{const i=new Xy(e,this.settings.globalGraphSettings,this,t);await e.open(i),C.close()}));C.open()}else{const C=new Xy(e,this.settings.globalGraphSettings,this,t);await e.open(C)}}activeGraphs(){return this.app.workspace.getLeavesOfType("juggl_view").map((e=>e.view.juggl))}async onunload(){super.onunload(),console.log("Unloading Juggl"),this.app.workspace.detachLeavesOfType("juggl_nodes"),this.app.workspace.detachLeavesOfType("juggl_style"),this.watcher&&this.watcher.close()}registerStore(e){this.stores.push(e)}removeStore(e){this.stores.remove(e)}registerCoreStore(e,t){if("core"!==e.storeId())throw new Error("Can only register IDataStores as core if their storeId is core");this.coreStores[t]=e}createJuggl(e,t,C,i){return t||(t=Object.assign({},ue.embedSettings),i&&(t.expandInitial=!1)),C||(C=this.defaultStores()),new tM(e,this,C,t,i)}defaultStores(){return{dataStores:[this.coreStores.Obsidian].concat(this.stores),coreStore:this.coreStores.Obsidian}}}kZ.CAT_DANGLING="dangling",module.exports=kZ;