import{l as Nr,a3 as yv,a4 as mv,a5 as bv,g as ao,B as wv,_ as Ev,Q as Cn,i as Dn,d as xv,V as Tv}from"./intro-yEGgrrvb.js";import{g as Cv}from"./_commonjsHelpers-D6-XlEtG.js";import{c as Dv}from"./createText-1719965b-BPRaF8Mh.js";import"./dayjs.min-CfWDS3UC.js";import"./index-bIIEL2MP.js";import"./iframe-CzjIX-qr.js";import"./index-CO-0pc0F.js";import"./index-Z-6k0Xrj.js";import"./index-aQYXhgXp.js";import"./index-DrFu-skq.js";import"./docsPage-CT2vyZOj.js";import"./Table-F-lkejrq.js";import"./parseCss-DFN8Q8fx.js";import"./index-D7HDsfES.js";import"./_color-UiaLB_4F.js";function Bs(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,a=Array(e);r=t.length?{done:!0}:{done:!1,value:t[a++]}},e:function(u){throw u},f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i,s=!0,o=!1;return{s:function(){r=r.call(t)},n:function(){var u=r.next();return s=u.done,u},e:function(u){o=!0,i=u},f:function(){try{s||r.return==null||r.return()}finally{if(o)throw i}}}}function hf(t,e,r){return(e=df(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Rv(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Iv(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var a,n,i,s,o=[],u=!0,l=!1;try{if(i=(r=r.call(t)).next,e===0){if(Object(r)!==r)return;u=!1}else for(;!(u=(a=i.call(r)).done)&&(o.push(a.value),o.length!==e);u=!0);}catch(f){l=!0,n=f}finally{try{if(!u&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(l)throw n}}return o}}function Pv(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Mv(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Je(t,e){return Sv(t)||Iv(t,e)||no(t,e)||Pv()}function Sn(t){return Av(t)||Rv(t)||no(t)||Mv()}function Ov(t,e){if(typeof t!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var a=r.call(t,e);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}function df(t){var e=Ov(t,"string");return typeof e=="symbol"?e:e+""}function nt(t){"@babel/helpers - typeof";return nt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},nt(t)}function no(t,e){if(t){if(typeof t=="string")return Bs(t,e);var r={}.toString.call(t).slice(8,-1);return r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set"?Array.from(t):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Bs(t,e):void 0}}var tt=typeof window>"u"?null:window,No=tt?tt.navigator:null;tt&&tt.document;var kv=nt(""),gf=nt({}),Nv=nt(function(){}),Bv=typeof HTMLElement>"u"?"undefined":nt(HTMLElement),Ba=function(e){return e&&e.instanceString&&Xe(e.instanceString)?e.instanceString():null},ge=function(e){return e!=null&&nt(e)==kv},Xe=function(e){return e!=null&&nt(e)===Nv},Ve=function(e){return!Lt(e)&&(Array.isArray?Array.isArray(e):e!=null&&e instanceof Array)},Oe=function(e){return e!=null&&nt(e)===gf&&!Ve(e)&&e.constructor===Object},Fv=function(e){return e!=null&&nt(e)===gf},ne=function(e){return e!=null&&nt(e)===nt(1)&&!isNaN(e)},_v=function(e){return ne(e)&&Math.floor(e)===e},An=function(e){if(Bv!=="undefined")return e!=null&&e instanceof HTMLElement},Lt=function(e){return Fa(e)||pf(e)},Fa=function(e){return Ba(e)==="collection"&&e._private.single},pf=function(e){return Ba(e)==="collection"&&!e._private.single},io=function(e){return Ba(e)==="core"},yf=function(e){return Ba(e)==="stylesheet"},Gv=function(e){return Ba(e)==="event"},fr=function(e){return e==null?!0:!!(e===""||e.match(/^\s+$/))},zv=function(e){return typeof HTMLElement>"u"?!1:e instanceof HTMLElement},Vv=function(e){return Oe(e)&&ne(e.x1)&&ne(e.x2)&&ne(e.y1)&&ne(e.y2)},Uv=function(e){return Fv(e)&&Xe(e.then)},qv=function(){return No&&No.userAgent.match(/msie|trident|edge/i)},ta=function(e,r){r||(r=function(){if(arguments.length===1)return arguments[0];if(arguments.length===0)return"undefined";for(var i=[],s=0;sr?1:0},Zv=function(e,r){return-1*bf(e,r)},be=Object.assign!=null?Object.assign.bind(Object):function(t){for(var e=arguments,r=1;r1&&(g-=1),g<1/6?d+(p-d)*6*g:g<1/2?p:g<2/3?d+(p-d)*(2/3-g)*6:d}var c=new RegExp("^"+Xv+"$").exec(e);if(c){if(a=parseInt(c[1]),a<0?a=(360- -1*a%360)%360:a>360&&(a=a%360),a/=360,n=parseFloat(c[2]),n<0||n>100||(n=n/100,i=parseFloat(c[3]),i<0||i>100)||(i=i/100,s=c[4],s!==void 0&&(s=parseFloat(s),s<0||s>1)))return;if(n===0)o=u=l=Math.round(i*255);else{var v=i<.5?i*(1+n):i+n-i*n,h=2*i-v;o=Math.round(255*f(h,v,a+1/3)),u=Math.round(255*f(h,v,a)),l=Math.round(255*f(h,v,a-1/3))}r=[o,u,l,s]}return r},jv=function(e){var r,a=new RegExp("^"+Yv+"$").exec(e);if(a){r=[];for(var n=[],i=1;i<=3;i++){var s=a[i];if(s[s.length-1]==="%"&&(n[i]=!0),s=parseFloat(s),n[i]&&(s=s/100*255),s<0||s>255)return;r.push(Math.floor(s))}var o=n[1]||n[2]||n[3],u=n[1]&&n[2]&&n[3];if(o&&!u)return;var l=a[4];if(l!==void 0){if(l=parseFloat(l),l<0||l>1)return;r.push(l)}}return r},eh=function(e){return th[e.toLowerCase()]},wf=function(e){return(Ve(e)?e:null)||eh(e)||Qv(e)||jv(e)||Jv(e)},th={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]},Ef=function(e){for(var r=e.map,a=e.keys,n=a.length,i=0;i=u||I<0||b&&M>=v}function x(){var R=e();if(w(R))return C(R);d=setTimeout(x,S(R))}function C(R){return d=void 0,m&&f?E(R):(f=c=void 0,h)}function D(){d!==void 0&&clearTimeout(d),g=0,f=p=c=d=void 0}function A(){return d===void 0?h:C(e())}function L(){var R=e(),I=w(R);if(f=arguments,c=this,p=R,I){if(d===void 0)return T(p);if(b)return clearTimeout(d),d=setTimeout(x,u),E(p)}return d===void 0&&(d=setTimeout(x,u)),h}return L.cancel=D,L.flush=A,L}return bi=s,bi}var ch=fh(),Va=_a(ch),wi=tt?tt.performance:null,Cf=wi&&wi.now?function(){return wi.now()}:function(){return Date.now()},vh=function(){if(tt){if(tt.requestAnimationFrame)return function(t){tt.requestAnimationFrame(t)};if(tt.mozRequestAnimationFrame)return function(t){tt.mozRequestAnimationFrame(t)};if(tt.webkitRequestAnimationFrame)return function(t){tt.webkitRequestAnimationFrame(t)};if(tt.msRequestAnimationFrame)return function(t){tt.msRequestAnimationFrame(t)}}return function(t){t&&setTimeout(function(){t(Cf())},1e3/60)}}(),Ln=function(e){return vh(e)},Qt=Cf,Ar=9261,Df=65599,$r=5381,Sf=function(e){for(var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ar,a=r,n;n=e.next(),!n.done;)a=a*Df+n.value|0;return a},Sa=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ar;return r*Df+e|0},Aa=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:$r;return(r<<5)+r+e|0},hh=function(e,r){return e*2097152+r},rr=function(e){return e[0]*2097152+e[1]},Qa=function(e,r){return[Sa(e[0],r[0]),Aa(e[1],r[1])]},Qo=function(e,r){var a={value:0,done:!1},n=0,i=e.length,s={next:function(){return n=0;n--)e[n]===r&&e.splice(n,1)},fo=function(e){e.splice(0,e.length)},Th=function(e,r){for(var a=0;a"u"?"undefined":nt(Set))!==Dh?Set:Sh,Un=function(e,r){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(e===void 0||r===void 0||!io(e)){He("An element must have a core reference and parameters set");return}var n=r.group;if(n==null&&(r.data&&r.data.source!=null&&r.data.target!=null?n="edges":n="nodes"),n!=="nodes"&&n!=="edges"){He("An element must be of type `nodes` or `edges`; you specified `"+n+"`");return}this.length=1,this[0]=this;var i=this._private={cy:e,single:!0,data:r.data||{},position:r.position||{x:0,y:0},autoWidth:void 0,autoHeight:void 0,autoPadding:void 0,compoundBoundsClean:!1,listeners:[],group:n,style:{},rstyle:{},styleCxts:[],styleKeys:{},removed:!0,selected:!!r.selected,selectable:r.selectable===void 0?!0:!!r.selectable,locked:!!r.locked,grabbed:!1,grabbable:r.grabbable===void 0?!0:!!r.grabbable,pannable:r.pannable===void 0?n==="edges":!!r.pannable,active:!1,classes:new na,animation:{current:[],queue:[]},rscratch:{},scratch:r.scratch||{},edges:[],children:[],parent:r.parent&&r.parent.isNode()?r.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(i.position.x==null&&(i.position.x=0),i.position.y==null&&(i.position.y=0),r.renderedPosition){var s=r.renderedPosition,o=e.pan(),u=e.zoom();i.position={x:(s.x-o.x)/u,y:(s.y-o.y)/u}}var l=[];Ve(r.classes)?l=r.classes:ge(r.classes)&&(l=r.classes.split(/\s+/));for(var f=0,c=l.length;fb?1:0},f=function(y,b,m,E,T){var S;if(m==null&&(m=0),T==null&&(T=a),m<0)throw new Error("lo must be non-negative");for(E==null&&(E=y.length);mD;0<=D?C++:C--)x.push(C);return x}).apply(this).reverse(),w=[],E=0,T=S.length;EA;0<=A?++x:--x)L.push(s(y,m));return L},p=function(y,b,m,E){var T,S,w;for(E==null&&(E=a),T=y[m];m>b;){if(w=m-1>>1,S=y[w],E(T,S)<0){y[m]=S,m=w;continue}break}return y[m]=T},g=function(y,b,m){var E,T,S,w,x;for(m==null&&(m=a),T=y.length,x=b,S=y[b],E=2*b+1;E0;){var S=b.pop(),w=g(S),x=S.id();if(v[x]=w,w!==1/0)for(var C=S.neighborhood().intersect(d),D=0;D0)for(k.unshift(O);c[_];){var F=c[_];k.unshift(F.edge),k.unshift(F.node),B=F.node,_=B.id()}return o.spawn(k)}}}},Oh={kruskal:function(e){e=e||function(m){return 1};for(var r=this.byGroup(),a=r.nodes,n=r.edges,i=a.length,s=new Array(i),o=a,u=function(E){for(var T=0;T0;){if(T(),w++,E===f){for(var x=[],C=i,D=f,A=y[D];x.unshift(C),A!=null&&x.unshift(A),C=g[D],C!=null;)D=C.id(),A=y[D];return{found:!0,distance:c[E],path:this.spawn(x),steps:w}}h[E]=!0;for(var L=m._private.edges,R=0;RA&&(d[D]=A,b[D]=C,m[D]=T),!i){var L=C*f+x;!i&&d[L]>A&&(d[L]=A,b[L]=x,m[L]=T)}}}for(var R=0;R1&&arguments[1]!==void 0?arguments[1]:s,ie=m(we),he=[],de=ie;;){if(de==null)return r.spawn();var xe=b(de),pe=xe.edge,De=xe.pred;if(he.unshift(de[0]),de.same(ye)&&he.length>0)break;pe!=null&&he.unshift(pe),de=De}return u.spawn(he)},S=0;S=0;f--){var c=l[f],v=c[1],h=c[2];(r[v]===o&&r[h]===u||r[v]===u&&r[h]===o)&&l.splice(f,1)}for(var d=0;dn;){var i=Math.floor(Math.random()*r.length);r=Vh(i,e,r),a--}return r},Uh={kargerStein:function(){var e=this,r=this.byGroup(),a=r.nodes,n=r.edges;n.unmergeBy(function(k){return k.isLoop()});var i=a.length,s=n.length,o=Math.ceil(Math.pow(Math.log(i)/Math.LN2,2)),u=Math.floor(i/zh);if(i<2){He("At least 2 nodes are required for Karger-Stein algorithm");return}for(var l=[],f=0;f1&&arguments[1]!==void 0?arguments[1]:0,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,n=1/0,i=r;i1&&arguments[1]!==void 0?arguments[1]:0,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,n=-1/0,i=r;i1&&arguments[1]!==void 0?arguments[1]:0,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,n=0,i=0,s=r;s1&&arguments[1]!==void 0?arguments[1]:0,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0;n?e=e.slice(r,a):(a0&&e.splice(0,r));for(var o=0,u=e.length-1;u>=0;u--){var l=e[u];s?isFinite(l)||(e[u]=-1/0,o++):e.splice(u,1)}i&&e.sort(function(v,h){return v-h});var f=e.length,c=Math.floor(f/2);return f%2!==0?e[c+1+o]:(e[c-1+o]+e[c+o])/2},Wh=function(e){return Math.PI*e/180},Ja=function(e,r){return Math.atan2(r,e)-Math.PI/2},co=Math.log2||function(t){return Math.log(t)/Math.log(2)},vo=function(e){return e>0?1:e<0?-1:0},Pr=function(e,r){return Math.sqrt(Dr(e,r))},Dr=function(e,r){var a=r.x-e.x,n=r.y-e.y;return a*a+n*n},Kh=function(e){for(var r=e.length,a=0,n=0;n=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(e.w!=null&&e.h!=null&&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}}},Qh=function(e){return{x1:e.x1,x2:e.x2,w:e.w,y1:e.y1,y2:e.y2,h:e.h}},Jh=function(e){e.x1=1/0,e.y1=1/0,e.x2=-1/0,e.y2=-1/0,e.w=0,e.h=0},jh=function(e,r){e.x1=Math.min(e.x1,r.x1),e.x2=Math.max(e.x2,r.x2),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,r.y1),e.y2=Math.max(e.y2,r.y2),e.h=e.y2-e.y1},Of=function(e,r,a){e.x1=Math.min(e.x1,r),e.x2=Math.max(e.x2,r),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,a),e.y2=Math.max(e.y2,a),e.h=e.y2-e.y1},cn=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return e.x1-=r,e.x2+=r,e.y1-=r,e.y2+=r,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},vn=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[0],a,n,i,s;if(r.length===1)a=n=i=s=r[0];else if(r.length===2)a=i=r[0],s=n=r[1];else if(r.length===4){var o=Je(r,4);a=o[0],n=o[1],i=o[2],s=o[3]}return e.x1-=s,e.x2+=n,e.y1-=a,e.y2+=i,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},au=function(e,r){e.x1=r.x1,e.y1=r.y1,e.x2=r.x2,e.y2=r.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1},ho=function(e,r){return!(e.x1>r.x2||r.x1>e.x2||e.x2r.y2||r.y1>e.y2)},sr=function(e,r,a){return e.x1<=r&&r<=e.x2&&e.y1<=a&&a<=e.y2},nu=function(e,r){return sr(e,r.x,r.y)},kf=function(e,r){return sr(e,r.x1,r.y1)&&sr(e,r.x2,r.y2)},ed=(Ti=Math.hypot)!==null&&Ti!==void 0?Ti:function(t,e){return Math.sqrt(t*t+e*e)};function td(t,e){if(t.length<3)throw new Error("Need at least 3 vertices");var r=function(x,C){return{x:x.x+C.x,y:x.y+C.y}},a=function(x,C){return{x:x.x-C.x,y:x.y-C.y}},n=function(x,C){return{x:x.x*C,y:x.y*C}},i=function(x,C){return x.x*C.y-x.y*C.x},s=function(x){var C=ed(x.x,x.y);return C===0?{x:0,y:0}:{x:x.x/C,y:x.y/C}},o=function(x){for(var C=0,D=0;D7&&arguments[7]!==void 0?arguments[7]:"auto",l=u==="auto"?vr(i,s):u,f=i/2,c=s/2;l=Math.min(l,f,c);var v=l!==f,h=l!==c,d;if(v){var p=a-f+l-o,g=n-c-o,y=a+f-l+o,b=g;if(d=or(e,r,a,n,p,g,y,b,!1),d.length>0)return d}if(h){var m=a+f+o,E=n-c+l-o,T=m,S=n+c-l+o;if(d=or(e,r,a,n,m,E,T,S,!1),d.length>0)return d}if(v){var w=a-f+l-o,x=n+c+o,C=a+f-l+o,D=x;if(d=or(e,r,a,n,w,x,C,D,!1),d.length>0)return d}if(h){var A=a-f-o,L=n-c+l-o,R=A,I=n+c-l+o;if(d=or(e,r,a,n,A,L,R,I,!1),d.length>0)return d}var M;{var N=a-f+l,O=n-c+l;if(M=wa(e,r,a,n,N,O,l+o),M.length>0&&M[0]<=N&&M[1]<=O)return[M[0],M[1]]}{var k=a+f-l,B=n-c+l;if(M=wa(e,r,a,n,k,B,l+o),M.length>0&&M[0]>=k&&M[1]<=B)return[M[0],M[1]]}{var _=a+f-l,F=n+c-l;if(M=wa(e,r,a,n,_,F,l+o),M.length>0&&M[0]>=_&&M[1]>=F)return[M[0],M[1]]}{var G=a-f+l,H=n+c-l;if(M=wa(e,r,a,n,G,H,l+o),M.length>0&&M[0]<=G&&M[1]>=H)return[M[0],M[1]]}return[]},ad=function(e,r,a,n,i,s,o){var u=o,l=Math.min(a,i),f=Math.max(a,i),c=Math.min(n,s),v=Math.max(n,s);return l-u<=e&&e<=f+u&&c-u<=r&&r<=v+u},nd=function(e,r,a,n,i,s,o,u,l){var f={x1:Math.min(a,o,i)-l,x2:Math.max(a,o,i)+l,y1:Math.min(n,u,s)-l,y2:Math.max(n,u,s)+l};return!(ef.x2||rf.y2)},id=function(e,r,a,n){a-=n;var i=r*r-4*e*a;if(i<0)return[];var s=Math.sqrt(i),o=2*e,u=(-r+s)/o,l=(-r-s)/o;return[u,l]},sd=function(e,r,a,n,i){var s=1e-5;e===0&&(e=s),r/=e,a/=e,n/=e;var o,u,l,f,c,v,h,d;if(u=(3*a-r*r)/9,l=-(27*n)+r*(9*a-2*(r*r)),l/=54,o=u*u*u+l*l,i[1]=0,h=r/3,o>0){c=l+Math.sqrt(o),c=c<0?-Math.pow(-c,1/3):Math.pow(c,1/3),v=l-Math.sqrt(o),v=v<0?-Math.pow(-v,1/3):Math.pow(v,1/3),i[0]=-h+c+v,h+=(c+v)/2,i[4]=i[2]=-h,h=Math.sqrt(3)*(-v+c)/2,i[3]=h,i[5]=-h;return}if(i[5]=i[3]=0,o===0){d=l<0?-Math.pow(-l,1/3):Math.pow(l,1/3),i[0]=-h+2*d,i[4]=i[2]=-(d+h);return}u=-u,f=u*u*u,f=Math.acos(l/Math.sqrt(f)),d=2*Math.sqrt(u),i[0]=-h+d*Math.cos(f/3),i[2]=-h+d*Math.cos((f+2*Math.PI)/3),i[4]=-h+d*Math.cos((f+4*Math.PI)/3)},od=function(e,r,a,n,i,s,o,u){var l=1*a*a-4*a*i+2*a*o+4*i*i-4*i*o+o*o+n*n-4*n*s+2*n*u+4*s*s-4*s*u+u*u,f=1*9*a*i-3*a*a-3*a*o-6*i*i+3*i*o+9*n*s-3*n*n-3*n*u-6*s*s+3*s*u,c=1*3*a*a-6*a*i+a*o-a*e+2*i*i+2*i*e-o*e+3*n*n-6*n*s+n*u-n*r+2*s*s+2*s*r-u*r,v=1*a*i-a*a+a*e-i*e+n*s-n*n+n*r-s*r,h=[];sd(l,f,c,v,h);for(var d=1e-7,p=[],g=0;g<6;g+=2)Math.abs(h[g+1])=0&&h[g]<=1&&p.push(h[g]);p.push(1),p.push(0);for(var y=-1,b,m,E,T=0;T=0?El?(e-i)*(e-i)+(r-s)*(r-s):f-v},St=function(e,r,a){for(var n,i,s,o,u,l=0,f=0;f=e&&e>=s||n<=e&&e<=s)u=(e-n)/(s-n)*(o-i)+i,u>r&&l++;else continue;return l%2!==0},Jt=function(e,r,a,n,i,s,o,u,l){var f=new Array(a.length),c;u[0]!=null?(c=Math.atan(u[1]/u[0]),u[0]<0?c=c+Math.PI/2:c=-c-Math.PI/2):c=u;for(var v=Math.cos(-c),h=Math.sin(-c),d=0;d0){var g=Pn(f,-l);p=In(g)}else p=f;return St(e,r,p)},ld=function(e,r,a,n,i,s,o,u){for(var l=new Array(a.length*2),f=0;f=0&&g<=1&&b.push(g),y>=0&&y<=1&&b.push(y),b.length===0)return[];var m=b[0]*u[0]+e,E=b[0]*u[1]+r;if(b.length>1){if(b[0]==b[1])return[m,E];var T=b[1]*u[0]+e,S=b[1]*u[1]+r;return[m,E,T,S]}else return[m,E]},Ci=function(e,r,a){return r<=e&&e<=a||a<=e&&e<=r?e:e<=r&&r<=a||a<=r&&r<=e?r:a},or=function(e,r,a,n,i,s,o,u,l){var f=e-i,c=a-e,v=o-i,h=r-s,d=n-r,p=u-s,g=v*h-p*f,y=c*h-d*f,b=p*c-v*d;if(b!==0){var m=g/b,E=y/b,T=.001,S=0-T,w=1+T;return S<=m&&m<=w&&S<=E&&E<=w?[e+m*c,r+m*d]:l?[e+m*c,r+m*d]:[]}else return g===0||y===0?Ci(e,a,o)===o?[o,u]:Ci(e,a,i)===i?[i,s]:Ci(i,o,a)===a?[a,n]:[]:[]},cd=function(e,r,a,n,i){var s=[],o=n/2,u=i/2,l=r,f=a;s.push({x:l+o*e[0],y:f+u*e[1]});for(var c=1;c0){var p=Pn(c,-u);h=In(p)}else h=c}else h=a;for(var g,y,b,m,E=0;E2){for(var d=[f[0],f[1]],p=Math.pow(d[0]-e,2)+Math.pow(d[1]-r,2),g=1;gf&&(f=E)},get:function(m){return l[m]}},v=0;v0?M=I.edgesTo(R)[0]:M=R.edgesTo(I)[0];var N=n(M);R=R.id(),w[R]>w[A]+N&&(w[R]=w[A]+N,x.nodes.indexOf(R)<0?x.push(R):x.updateItem(R),S[R]=0,T[R]=[]),w[R]==w[A]+N&&(S[R]=S[R]+S[A],T[R].push(A))}else for(var O=0;O0;){for(var F=E.pop(),G=0;G0&&o.push(a[u]);o.length!==0&&i.push(n.collection(o))}return i},Sd=function(e,r){for(var a=0;a5&&arguments[5]!==void 0?arguments[5]:Rd,o=n,u,l,f=0;f=2?ha(e,r,a,0,lu,Id):ha(e,r,a,0,uu)},squaredEuclidean:function(e,r,a){return ha(e,r,a,0,lu)},manhattan:function(e,r,a){return ha(e,r,a,0,uu)},max:function(e,r,a){return ha(e,r,a,-1/0,Pd)}};ra["squared-euclidean"]=ra.squaredEuclidean;ra.squaredeuclidean=ra.squaredEuclidean;function Yn(t,e,r,a,n,i){var s;return Xe(t)?s=t:s=ra[t]||ra.euclidean,e===0&&Xe(t)?s(n,i):s(e,r,a,n,i)}var Md=ht({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),po=function(e){return Md(e)},Mn=function(e,r,a,n,i){var s=i!=="kMedoids",o=s?function(c){return a[c]}:function(c){return n[c](a)},u=function(v){return n[v](r)},l=a,f=r;return Yn(e,n.length,o,u,l,f)},Si=function(e,r,a){for(var n=a.length,i=new Array(n),s=new Array(n),o=new Array(r),u=null,l=0;la)return!1}return!0},Nd=function(e,r,a){for(var n=0;no&&(o=r[l][f],u=f);i[u].push(e[l])}for(var c=0;c=i.threshold||i.mode==="dendrogram"&&e.length===1)return!1;var d=r[s],p=r[n[s]],g;i.mode==="dendrogram"?g={left:d,right:p,key:d.key}:g={value:d.value.concat(p.value),key:d.key},e[d.index]=g,e.splice(p.index,1),r[d.key]=g;for(var y=0;ya[p.key][b.key]&&(u=a[p.key][b.key])):i.linkage==="max"?(u=a[d.key][b.key],a[d.key][b.key]0&&n.push(i);return n},gu=function(e,r,a){for(var n=[],i=0;io&&(s=l,o=r[i*e+l])}s>0&&n.push(s)}for(var f=0;fl&&(u=f,l=c)}a[i]=s[u]}return n=gu(e,r,a),n},pu=function(e){for(var r=this.cy(),a=this.nodes(),n=$d(e),i={},s=0;s=A?(L=A,A=I,R=M):I>L&&(L=I);for(var N=0;N0?1:0;w[C%n.minIterations*o+G]=H,F+=H}if(F>0&&(C>=n.minIterations-1||C==n.maxIterations-1)){for(var Y=0,X=0;X1||S>1)&&(o=!0),c[m]=[],b.outgoers().forEach(function(x){x.isEdge()&&c[m].push(x.id())})}else v[m]=[void 0,b.target().id()]}):s.forEach(function(b){var m=b.id();if(b.isNode()){var E=b.degree(!0);E%2&&(u?l?o=!0:l=m:u=m),c[m]=[],b.connectedEdges().forEach(function(T){return c[m].push(T.id())})}else v[m]=[b.source().id(),b.target().id()]});var h={found:!1,trail:void 0};if(o)return h;if(l&&u)if(i){if(f&&l!=f)return h;f=l}else{if(f&&l!=f&&u!=f)return h;f||(f=l)}else f||(f=s[0].id());var d=function(m){for(var E=m,T=[m],S,w,x;c[E].length;)S=c[E].shift(),w=v[S][0],x=v[S][1],E!=x?(c[x]=c[x].filter(function(C){return C!=S}),E=x):!i&&E!=w&&(c[w]=c[w].filter(function(C){return C!=S}),E=w),T.unshift(S),T.unshift(E);return T},p=[],g=[];for(g=d(f);g.length!=1;)c[g[0]].length==0?(p.unshift(s.getElementById(g.shift())),p.unshift(s.getElementById(g.shift()))):g=d(g.shift()).concat(g);p.unshift(s.getElementById(g.shift()));for(var y in c)if(c[y].length)return h;return h.found=!0,h.trail=this.spawn(p,!0),h}},en=function(){var e=this,r={},a=0,n=0,i=[],s=[],o={},u=function(v,h){for(var d=s.length-1,p=[],g=e.spawn();s[d].x!=v||s[d].y!=h;)p.push(s.pop().edge),d--;p.push(s.pop().edge),p.forEach(function(y){var b=y.connectedNodes().intersection(e);g.merge(y),b.forEach(function(m){var E=m.id(),T=m.connectedEdges().intersection(e);g.merge(m),r[E].cutVertex?g.merge(T.filter(function(S){return S.isLoop()})):g.merge(T)})}),i.push(g)},l=function(v,h,d){v===d&&(n+=1),r[h]={id:a,low:a++,cutVertex:!1};var p=e.getElementById(h).connectedEdges().intersection(e);if(p.size()===0)i.push(e.spawn(e.getElementById(h)));else{var g,y,b,m;p.forEach(function(E){g=E.source().id(),y=E.target().id(),b=g===h?y:g,b!==d&&(m=E.id(),o[m]||(o[m]=!0,s.push({x:h,y:b,edge:E})),b in r?r[h].low=Math.min(r[h].low,r[b].id):(l(v,b,h),r[h].low=Math.min(r[h].low,r[b].low),r[h].id<=r[b].low&&(r[h].cutVertex=!0,u(h,b))))})}};e.forEach(function(c){if(c.isNode()){var v=c.id();v in r||(n=0,l(v,v),r[v].cutVertex=n>1)}});var f=Object.keys(r).filter(function(c){return r[c].cutVertex}).map(function(c){return e.getElementById(c)});return{cut:e.spawn(f),components:i}},tg={hopcroftTarjanBiconnected:en,htbc:en,htb:en,hopcroftTarjanBiconnectedComponents:en},tn=function(){var e=this,r={},a=0,n=[],i=[],s=e.spawn(e),o=function(l){i.push(l),r[l]={index:a,low:a++,explored:!1};var f=e.getElementById(l).connectedEdges().intersection(e);if(f.forEach(function(p){var g=p.target().id();g!==l&&(g in r||o(g),r[g].explored||(r[l].low=Math.min(r[l].low,r[g].low)))}),r[l].index===r[l].low){for(var c=e.spawn();;){var v=i.pop();if(c.merge(e.getElementById(v)),r[v].low=r[l].index,r[v].explored=!0,v===l)break}var h=c.edgesWith(c),d=c.merge(h);n.push(d),s=s.difference(d)}};return e.forEach(function(u){if(u.isNode()){var l=u.id();l in r||o(l)}}),{cut:s,components:n}},rg={tarjanStronglyConnected:tn,tsc:tn,tscc:tn,tarjanStronglyConnectedComponents:tn},Uf={};[La,Mh,Oh,Nh,Fh,Gh,Uh,gd,Jr,jr,Gs,Ld,Vd,Hd,Jd,eg,tg,rg].forEach(function(t){be(Uf,t)});/*! 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 qf=0,Yf=1,Hf=2,_t=function(e){if(!(this instanceof _t))return new _t(e);this.id="Thenable/1.0.7",this.state=qf,this.fulfillValue=void 0,this.rejectReason=void 0,this.onFulfilled=[],this.onRejected=[],this.proxy={then:this.then.bind(this)},typeof e=="function"&&e.call(this,this.fulfill.bind(this),this.reject.bind(this))};_t.prototype={fulfill:function(e){return yu(this,Yf,"fulfillValue",e)},reject:function(e){return yu(this,Hf,"rejectReason",e)},then:function(e,r){var a=this,n=new _t;return a.onFulfilled.push(bu(e,n,"fulfill")),a.onRejected.push(bu(r,n,"reject")),Xf(a),n.proxy}};var yu=function(e,r,a,n){return e.state===qf&&(e.state=r,e[a]=n,Xf(e)),e},Xf=function(e){e.state===Yf?mu(e,"onFulfilled",e.fulfillValue):e.state===Hf&&mu(e,"onRejected",e.rejectReason)},mu=function(e,r,a){if(e[r].length!==0){var n=e[r];e[r]=[];var i=function(){for(var o=0;o0}},clearQueue:function(){return function(){var r=this,a=r.length!==void 0,n=a?r:[r],i=this._private.cy||this;if(!i.styleEnabled())return this;for(var s=0;s-1}return Wi=e,Wi}var Ki,Uu;function Eg(){if(Uu)return Ki;Uu=1;var t=$n();function e(r,a){var n=this.__data__,i=t(n,r);return i<0?(++this.size,n.push([r,a])):n[i][1]=a,this}return Ki=e,Ki}var Zi,qu;function xg(){if(qu)return Zi;qu=1;var t=yg(),e=mg(),r=bg(),a=wg(),n=Eg();function i(s){var o=-1,u=s==null?0:s.length;for(this.clear();++o-1&&a%1==0&&a0&&this.spawn(n).updateStyle().emit("class"),r},addClass:function(e){return this.toggleClass(e,!0)},hasClass:function(e){var r=this[0];return r!=null&&r._private.classes.has(e)},toggleClass:function(e,r){Ve(e)||(e=e.match(/\S+/g)||[]);for(var a=this,n=r===void 0,i=[],s=0,o=a.length;s0&&this.spawn(i).updateStyle().emit("class"),a},removeClass:function(e){return this.toggleClass(e,!1)},flashClass:function(e,r){var a=this;if(r==null)r=250;else if(r===0)return a;return a.addClass(e),setTimeout(function(){a.removeClass(e)},r),a}};hn.className=hn.classNames=hn.classes;var Me={metaChar:"[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",boolOp:"\\?|\\!|\\^",string:`"(?:\\\\"|[^"])*"|'(?:\\\\'|[^'])*'`,number:at,meta:"degree|indegree|outdegree",separator:"\\s*,\\s*",descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$",group:"node|edge|\\*",directedEdge:"\\s+->\\s+",undirectedEdge:"\\s+<->\\s+"};Me.variable="(?:[\\w-.]|(?:\\\\"+Me.metaChar+"))+";Me.className="(?:[\\w-]|(?:\\\\"+Me.metaChar+"))+";Me.value=Me.string+"|"+Me.number;Me.id=Me.variable;(function(){var t,e,r;for(t=Me.comparatorOp.split("|"),r=0;r=0)&&e!=="="&&(Me.comparatorOp+="|\\!"+e)})();var ze=function(){return{checks:[]}},se={GROUP:0,COLLECTION:1,FILTER:2,DATA_COMPARE:3,DATA_EXIST:4,DATA_BOOL:5,META_COMPARE:6,STATE:7,ID:8,CLASS:9,UNDIRECTED_EDGE:10,DIRECTED_EDGE:11,NODE_SOURCE:12,NODE_TARGET:13,NODE_NEIGHBOR:14,CHILD:15,DESCENDANT:16,PARENT:17,ANCESTOR:18,COMPOUND_SPLIT:19,TRUE:20},qs=[{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(t,e){return Zv(t.selector,e.selector)}),jg=function(){for(var t={},e,r=0;r0&&f.edgeCount>0)return Ge("The selector `"+e+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(f.edgeCount>1)return Ge("The selector `"+e+"` is invalid because it uses multiple edge selectors"),!1;f.edgeCount===1&&Ge("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},ip=function(){if(this.toStringCache!=null)return this.toStringCache;for(var e=function(f){return f??""},r=function(f){return ge(f)?'"'+f+'"':e(f)},a=function(f){return" "+f+" "},n=function(f,c){var v=f.type,h=f.value;switch(v){case se.GROUP:{var d=e(h);return d.substring(0,d.length-1)}case se.DATA_COMPARE:{var p=f.field,g=f.operator;return"["+p+a(e(g))+r(h)+"]"}case se.DATA_BOOL:{var y=f.operator,b=f.field;return"["+e(y)+b+"]"}case se.DATA_EXIST:{var m=f.field;return"["+m+"]"}case se.META_COMPARE:{var E=f.operator,T=f.field;return"[["+T+a(e(E))+r(h)+"]]"}case se.STATE:return h;case se.ID:return"#"+h;case se.CLASS:return"."+h;case se.PARENT:case se.CHILD:return i(f.parent,c)+a(">")+i(f.child,c);case se.ANCESTOR:case se.DESCENDANT:return i(f.ancestor,c)+" "+i(f.descendant,c);case se.COMPOUND_SPLIT:{var S=i(f.left,c),w=i(f.subject,c),x=i(f.right,c);return S+(S.length>0?" ":"")+w+x}case se.TRUE:return""}},i=function(f,c){return f.checks.reduce(function(v,h,d){return v+(c===f&&d===0?"$":"")+n(h,c)},"")},s="",o=0;o1&&o=0&&(r=r.replace("!",""),c=!0),r.indexOf("@")>=0&&(r=r.replace("@",""),f=!0),(i||o||f)&&(u=!i&&!s?"":""+e,l=""+a),f&&(e=u=u.toLowerCase(),a=l=l.toLowerCase()),r){case"*=":n=u.indexOf(l)>=0;break;case"$=":n=u.indexOf(l,u.length-l.length)>=0;break;case"^=":n=u.indexOf(l)===0;break;case"=":n=e===a;break;case">":v=!0,n=e>a;break;case">=":v=!0,n=e>=a;break;case"<":v=!0,n=e0;){var f=n.shift();e(f),i.add(f.id()),o&&a(n,i,f)}return t}function ec(t,e,r){if(r.isParent())for(var a=r._private.children,n=0;n1&&arguments[1]!==void 0?arguments[1]:!0;return wo(this,t,e,ec)};function tc(t,e,r){if(r.isChild()){var a=r._private.parent;e.has(a.id())||t.push(a)}}aa.forEachUp=function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return wo(this,t,e,tc)};function hp(t,e,r){tc(t,e,r),ec(t,e,r)}aa.forEachUpAndDown=function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return wo(this,t,e,hp)};aa.ancestors=aa.parents;var Pa,rc;Pa=rc={data:_e.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:_e.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:_e.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:_e.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),rscratch:_e.data({field:"rscratch",allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:_e.removeData({field:"rscratch",triggerEvent:!1}),id:function(){var e=this[0];if(e)return e._private.data.id}};Pa.attr=Pa.data;Pa.removeAttr=Pa.removeData;var dp=rc,Kn={};function Cs(t){return function(e){var r=this;if(e===void 0&&(e=!0),r.length!==0)if(r.isNode()&&!r.removed()){for(var a=0,n=r[0],i=n._private.edges,s=0;se}),minIndegree:zr("indegree",function(t,e){return te}),minOutdegree:zr("outdegree",function(t,e){return te})});be(Kn,{totalDegree:function(e){for(var r=0,a=this.nodes(),n=0;n0,v=c;c&&(f=f[0]);var h=v?f.position():{x:0,y:0};r!==void 0?l.position(e,r+h[e]):i!==void 0&&l.position({x:i.x+h.x,y:i.y+h.y})}else{var d=a.position(),p=o?a.parent():null,g=p&&p.length>0,y=g;g&&(p=p[0]);var b=y?p.position():{x:0,y:0};return i={x:d.x-b.x,y:d.y-b.y},e===void 0?i:i[e]}else if(!s)return;return this}};Bt.modelPosition=Bt.point=Bt.position;Bt.modelPositions=Bt.points=Bt.positions;Bt.renderedPoint=Bt.renderedPosition;Bt.relativePoint=Bt.relativePosition;var gp=ac,ea,br;ea=br={};br.renderedBoundingBox=function(t){var e=this.boundingBox(t),r=this.cy(),a=r.zoom(),n=r.pan(),i=e.x1*a+n.x,s=e.x2*a+n.x,o=e.y1*a+n.y,u=e.y2*a+n.y;return{x1:i,x2:s,y1:o,y2:u,w:s-i,h:u-o}};br.dirtyCompoundBoundsCache=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,e=this.cy();return!e.styleEnabled()||!e.hasCompoundNodes()?this:(this.forEachUp(function(r){if(r.isParent()){var a=r._private;a.compoundBoundsClean=!1,a.bbCache=null,t||r.emitAndNotify("bounds")}}),this)};br.updateCompoundBounds=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,e=this.cy();if(!e.styleEnabled()||!e.hasCompoundNodes())return this;if(!t&&e.batching())return this;function r(s){if(!s.isParent())return;var o=s._private,u=s.children(),l=s.pstyle("compound-sizing-wrt-labels").value==="include",f={width:{val:s.pstyle("min-width").pfValue,left:s.pstyle("min-width-bias-left"),right:s.pstyle("min-width-bias-right")},height:{val:s.pstyle("min-height").pfValue,top:s.pstyle("min-height-bias-top"),bottom:s.pstyle("min-height-bias-bottom")}},c=u.boundingBox({includeLabels:l,includeOverlays:!1,useCache:!1}),v=o.position;(c.w===0||c.h===0)&&(c={w:s.pstyle("width").pfValue,h:s.pstyle("height").pfValue},c.x1=v.x-c.w/2,c.x2=v.x+c.w/2,c.y1=v.y-c.h/2,c.y2=v.y+c.h/2);function h(C,D,A){var L=0,R=0,I=D+A;return C>0&&I>0&&(L=D/I*C,R=A/I*C),{biasDiff:L,biasComplementDiff:R}}function d(C,D,A,L){if(A.units==="%")switch(L){case"width":return C>0?A.pfValue*C:0;case"height":return D>0?A.pfValue*D:0;case"average":return C>0&&D>0?A.pfValue*(C+D)/2:0;case"min":return C>0&&D>0?C>D?A.pfValue*D:A.pfValue*C:0;case"max":return C>0&&D>0?C>D?A.pfValue*C:A.pfValue*D:0;default:return 0}else return A.units==="px"?A.pfValue:0}var p=f.width.left.value;f.width.left.units==="px"&&f.width.val>0&&(p=p*100/f.width.val);var g=f.width.right.value;f.width.right.units==="px"&&f.width.val>0&&(g=g*100/f.width.val);var y=f.height.top.value;f.height.top.units==="px"&&f.height.val>0&&(y=y*100/f.height.val);var b=f.height.bottom.value;f.height.bottom.units==="px"&&f.height.val>0&&(b=b*100/f.height.val);var m=h(f.width.val-c.w,p,g),E=m.biasDiff,T=m.biasComplementDiff,S=h(f.height.val-c.h,y,b),w=S.biasDiff,x=S.biasComplementDiff;o.autoPadding=d(c.w,c.h,s.pstyle("padding"),s.pstyle("padding-relative-to").value),o.autoWidth=Math.max(c.w,f.width.val),v.x=(-E+c.x1+c.x2+T)/2,o.autoHeight=Math.max(c.h,f.height.val),v.y=(-w+c.y1+c.y2+x)/2}for(var a=0;ae.x2?n:e.x2,e.y1=ae.y2?i:e.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1)},nr=function(e,r){return r==null?e:Nt(e,r.x1,r.y1,r.x2,r.y2)},da=function(e,r,a){return Dt(e,r,a)},rn=function(e,r,a){if(!r.cy().headless()){var n=r._private,i=n.rstyle,s=i.arrowWidth/2,o=r.pstyle(a+"-arrow-shape").value,u,l;if(o!=="none"){a==="source"?(u=i.srcX,l=i.srcY):a==="target"?(u=i.tgtX,l=i.tgtY):(u=i.midX,l=i.midY);var f=n.arrowBounds=n.arrowBounds||{},c=f[a]=f[a]||{};c.x1=u-s,c.y1=l-s,c.x2=u+s,c.y2=l+s,c.w=c.x2-c.x1,c.h=c.y2-c.y1,cn(c,1),Nt(e,c.x1,c.y1,c.x2,c.y2)}}},Ds=function(e,r,a){if(!r.cy().headless()){var n;a?n=a+"-":n="";var i=r._private,s=i.rstyle,o=r.pstyle(n+"label").strValue;if(o){var u=r.pstyle("text-halign"),l=r.pstyle("text-valign"),f=da(s,"labelWidth",a),c=da(s,"labelHeight",a),v=da(s,"labelX",a),h=da(s,"labelY",a),d=r.pstyle(n+"text-margin-x").pfValue,p=r.pstyle(n+"text-margin-y").pfValue,g=r.isEdge(),y=r.pstyle(n+"text-rotation"),b=r.pstyle("text-outline-width").pfValue,m=r.pstyle("text-border-width").pfValue,E=m/2,T=r.pstyle("text-background-padding").pfValue,S=2,w=c,x=f,C=x/2,D=w/2,A,L,R,I;if(g)A=v-C,L=v+C,R=h-D,I=h+D;else{switch(u.value){case"left":A=v-x,L=v;break;case"center":A=v-C,L=v+C;break;case"right":A=v,L=v+x;break}switch(l.value){case"top":R=h-w,I=h;break;case"center":R=h-D,I=h+D;break;case"bottom":R=h,I=h+w;break}}var M=d-Math.max(b,E)-T-S,N=d+Math.max(b,E)+T+S,O=p-Math.max(b,E)-T-S,k=p+Math.max(b,E)+T+S;A+=M,L+=N,R+=O,I+=k;var B=a||"main",_=i.labelBounds,F=_[B]=_[B]||{};F.x1=A,F.y1=R,F.x2=L,F.y2=I,F.w=L-A,F.h=I-R,F.leftPad=M,F.rightPad=N,F.topPad=O,F.botPad=k;var G=g&&y.strValue==="autorotate",H=y.pfValue!=null&&y.pfValue!==0;if(G||H){var Y=G?da(i.rstyle,"labelAngle",a):y.pfValue,X=Math.cos(Y),W=Math.sin(Y),ee=(A+L)/2,ae=(R+I)/2;if(!g){switch(u.value){case"left":ee=L;break;case"right":ee=A;break}switch(l.value){case"top":ae=I;break;case"bottom":ae=R;break}}var J=function(Te,we){return Te=Te-ee,we=we-ae,{x:Te*X-we*W+ee,y:Te*W+we*X+ae}},z=J(A,R),V=J(A,I),q=J(L,R),Z=J(L,I);A=Math.min(z.x,V.x,q.x,Z.x),L=Math.max(z.x,V.x,q.x,Z.x),R=Math.min(z.y,V.y,q.y,Z.y),I=Math.max(z.y,V.y,q.y,Z.y)}var re=B+"Rot",ve=_[re]=_[re]||{};ve.x1=A,ve.y1=R,ve.x2=L,ve.y2=I,ve.w=L-A,ve.h=I-R,Nt(e,A,R,L,I),Nt(i.labelBounds.all,A,R,L,I)}return e}},ml=function(e,r){if(!r.cy().headless()){var a=r.pstyle("outline-opacity").value,n=r.pstyle("outline-width").value,i=r.pstyle("outline-offset").value,s=n+i;ic(e,r,a,s,"outside",s/2)}},ic=function(e,r,a,n,i,s){if(!(a===0||n<=0||i==="inside")){var o=r.cy(),u=r.pstyle("shape").value,l=o.renderer().nodeShapes[u],f=r.position(),c=f.x,v=f.y,h=r.width(),d=r.height();if(l.hasMiterBounds){i==="center"&&(n/=2);var p=l.miterBounds(c,v,h,d,n);nr(e,p)}else s!=null&&s>0&&vn(e,[s,s,s,s])}},pp=function(e,r){if(!r.cy().headless()){var a=r.pstyle("border-opacity").value,n=r.pstyle("border-width").pfValue,i=r.pstyle("border-position").value;ic(e,r,a,n,i)}},yp=function(e,r){var a=e._private.cy,n=a.styleEnabled(),i=a.headless(),s=Et(),o=e._private,u=e.isNode(),l=e.isEdge(),f,c,v,h,d,p,g=o.rstyle,y=u&&n?e.pstyle("bounds-expansion").pfValue:[0],b=function(Ie){return Ie.pstyle("display").value!=="none"},m=!n||b(e)&&(!l||b(e.source())&&b(e.target()));if(m){var E=0,T=0;n&&r.includeOverlays&&(E=e.pstyle("overlay-opacity").value,E!==0&&(T=e.pstyle("overlay-padding").value));var S=0,w=0;n&&r.includeUnderlays&&(S=e.pstyle("underlay-opacity").value,S!==0&&(w=e.pstyle("underlay-padding").value));var x=Math.max(T,w),C=0,D=0;if(n&&(C=e.pstyle("width").pfValue,D=C/2),u&&r.includeNodes){var A=e.position();d=A.x,p=A.y;var L=e.outerWidth(),R=L/2,I=e.outerHeight(),M=I/2;f=d-R,c=d+R,v=p-M,h=p+M,Nt(s,f,v,c,h),n&&ml(s,e),n&&r.includeOutlines&&!i&&ml(s,e),n&&pp(s,e)}else if(l&&r.includeEdges)if(n&&!i){var N=e.pstyle("curve-style").strValue;if(f=Math.min(g.srcX,g.midX,g.tgtX),c=Math.max(g.srcX,g.midX,g.tgtX),v=Math.min(g.srcY,g.midY,g.tgtY),h=Math.max(g.srcY,g.midY,g.tgtY),f-=D,c+=D,v-=D,h+=D,Nt(s,f,v,c,h),N==="haystack"){var O=g.haystackPts;if(O&&O.length===2){if(f=O[0].x,v=O[0].y,c=O[1].x,h=O[1].y,f>c){var k=f;f=c,c=k}if(v>h){var B=v;v=h,h=B}Nt(s,f-D,v-D,c+D,h+D)}}else if(N==="bezier"||N==="unbundled-bezier"||ir(N,"segments")||ir(N,"taxi")){var _;switch(N){case"bezier":case"unbundled-bezier":_=g.bezierPts;break;case"segments":case"taxi":case"round-segments":case"round-taxi":_=g.linePts;break}if(_!=null)for(var F=0;F<_.length;F++){var G=_[F];f=G.x-D,c=G.x+D,v=G.y-D,h=G.y+D,Nt(s,f,v,c,h)}}}else{var H=e.source(),Y=H.position(),X=e.target(),W=X.position();if(f=Y.x,c=W.x,v=Y.y,h=W.y,f>c){var ee=f;f=c,c=ee}if(v>h){var ae=v;v=h,h=ae}f-=D,c+=D,v-=D,h+=D,Nt(s,f,v,c,h)}if(n&&r.includeEdges&&l&&(rn(s,e,"mid-source"),rn(s,e,"mid-target"),rn(s,e,"source"),rn(s,e,"target")),n){var J=e.pstyle("ghost").value==="yes";if(J){var z=e.pstyle("ghost-offset-x").pfValue,V=e.pstyle("ghost-offset-y").pfValue;Nt(s,s.x1+z,s.y1+V,s.x2+z,s.y2+V)}}var q=o.bodyBounds=o.bodyBounds||{};au(q,s),vn(q,y),cn(q,1),n&&(f=s.x1,c=s.x2,v=s.y1,h=s.y2,Nt(s,f-x,v-x,c+x,h+x));var Z=o.overlayBounds=o.overlayBounds||{};au(Z,s),vn(Z,y),cn(Z,1);var re=o.labelBounds=o.labelBounds||{};re.all!=null?Jh(re.all):re.all=Et(),n&&r.includeLabels&&(r.includeMainLabels&&Ds(s,e,null),l&&(r.includeSourceLabels&&Ds(s,e,"source"),r.includeTargetLabels&&Ds(s,e,"target")))}return s.x1=Pt(s.x1),s.y1=Pt(s.y1),s.x2=Pt(s.x2),s.y2=Pt(s.y2),s.w=Pt(s.x2-s.x1),s.h=Pt(s.y2-s.y1),s.w>0&&s.h>0&&m&&(vn(s,y),cn(s,1)),s},sc=function(e){var r=0,a=function(s){return(s?1:0)<0&&arguments[0]!==void 0?arguments[0]:Mp,e=arguments.length>1?arguments[1]:void 0,r=0;r=0;o--)s(o);return this};gr.removeAllListeners=function(){return this.removeListener("*")};gr.emit=gr.trigger=function(t,e,r){var a=this.listeners,n=a.length;return this.emitting++,Ve(e)||(e=[e]),Op(this,function(i,s){r!=null&&(a=[{event:s.event,type:s.type,namespace:s.namespace,callback:r}],n=a.length);for(var o=function(){var f=a[u];if(f.type===s.type&&(!f.namespace||f.namespace===s.namespace||f.namespace===Pp)&&i.eventMatches(i.context,f,s)){var c=[s];e!=null&&Th(c,e),i.beforeEmit(i.context,f,s),f.conf&&f.conf.one&&(i.listeners=i.listeners.filter(function(d){return d!==f}));var v=i.callbackContext(i.context,f,s),h=f.callback.apply(v,c);i.afterEmit(i.context,f,s),h===!1&&(s.stopPropagation(),s.preventDefault())}},u=0;u1&&!s){var o=this.length-1,u=this[o],l=u._private.data.id;this[o]=void 0,this[e]=u,i.set(l,{ele:u,index:e})}return this.length--,this},unmergeOne:function(e){e=e[0];var r=this._private,a=e._private.data.id,n=r.map,i=n.get(a);if(!i)return this;var s=i.index;return this.unmergeAt(s),this},unmerge:function(e){var r=this._private.cy;if(!e)return this;if(e&&ge(e)){var a=e;e=r.mutableElements().filter(a)}for(var n=0;n=0;r--){var a=this[r];e(a)&&this.unmergeAt(r)}return this},map:function(e,r){for(var a=[],n=this,i=0;ia&&(a=u,n=o)}return{value:a,ele:n}},min:function(e,r){for(var a=1/0,n,i=this,s=0;s=0&&i"u"?"undefined":nt(Symbol))!=e&&nt(Symbol.iterator)!=e;r&&(On[Symbol.iterator]=function(){var a=this,n={value:void 0,done:!1},i=0,s=this.length;return hf({next:function(){return i1&&arguments[1]!==void 0?arguments[1]:!0,a=this[0],n=a.cy();if(n.styleEnabled()&&a){a._private.styleDirty&&(a._private.styleDirty=!1,n.style().apply(a));var i=a._private.style[e];return i??(r?n.style().getDefaultProperty(e):null)}},numericStyle:function(e){var r=this[0];if(r.cy().styleEnabled()&&r){var a=r.pstyle(e);return a.pfValue!==void 0?a.pfValue:a.value}},numericStyleUnits:function(e){var r=this[0];if(r.cy().styleEnabled()&&r)return r.pstyle(e).units},renderedStyle:function(e){var r=this.cy();if(!r.styleEnabled())return this;var a=this[0];if(a)return r.style().getRenderedStyle(a,e)},style:function(e,r){var a=this.cy();if(!a.styleEnabled())return this;var n=!1,i=a.style();if(Oe(e)){var s=e;i.applyBypass(this,s,n),this.emitAndNotify("style")}else if(ge(e))if(r===void 0){var o=this[0];return o?i.getStylePropertyValue(o,e):void 0}else i.applyBypass(this,e,r,n),this.emitAndNotify("style");else if(e===void 0){var u=this[0];return u?i.getRawStyle(u):void 0}return this},removeStyle:function(e){var r=this.cy();if(!r.styleEnabled())return this;var a=!1,n=r.style(),i=this;if(e===void 0)for(var s=0;s0&&e.push(f[0]),e.push(o[0])}return this.spawn(e,!0).filter(t)},"neighborhood"),closedNeighborhood:function(e){return this.neighborhood().add(this).filter(e)},openNeighborhood:function(e){return this.neighborhood(e)}});pt.neighbourhood=pt.neighborhood;pt.closedNeighbourhood=pt.closedNeighborhood;pt.openNeighbourhood=pt.openNeighborhood;be(pt,{source:Mt(function(e){var r=this[0],a;return r&&(a=r._private.source||r.cy().collection()),a&&e?a.filter(e):a},"source"),target:Mt(function(e){var r=this[0],a;return r&&(a=r._private.target||r.cy().collection()),a&&e?a.filter(e):a},"target"),sources:Rl({attr:"source"}),targets:Rl({attr:"target"})});function Rl(t){return function(r){for(var a=[],n=0;n0);return s},component:function(){var e=this[0];return e.cy().mutableElements().components(e)[0]}});pt.componentsOf=pt.components;var vt=function(e,r){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(e===void 0){He("A collection must have a reference to the core");return}var i=new Zt,s=!1;if(!r)r=[];else if(r.length>0&&Oe(r[0])&&!Fa(r[0])){s=!0;for(var o=[],u=new na,l=0,f=r.length;l0&&arguments[0]!==void 0?arguments[0]:!0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,r=this,a=r.cy(),n=a._private,i=[],s=[],o,u=0,l=r.length;u0){for(var B=o.length===r.length?r:new vt(a,o),_=0;_0&&arguments[0]!==void 0?arguments[0]:!0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,r=this,a=[],n={},i=r._private.cy;function s(I){for(var M=I._private.edges,N=0;N0&&(t?A.emitAndNotify("remove"):e&&A.emit("remove"));for(var L=0;L0?L=I:A=I;while(Math.abs(R)>s&&++M=i?b(D,M):N===0?M:E(D,A,A+l)}var S=!1;function w(){S=!0,(t!==e||r!==a)&&m()}var x=function(A){return S||w(),t===e&&r===a?A:A===0?0:A===1?1:g(T(A),e,a)};x.getControlPoints=function(){return[{x:t,y:e},{x:r,y:a}]};var C="generateBezier("+[t,e,r,a]+")";return x.toString=function(){return C},x}/*! Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */var Yp=function(){function t(a){return-a.tension*a.x-a.friction*a.v}function e(a,n,i){var s={x:a.x+i.dx*n,v:a.v+i.dv*n,tension:a.tension,friction:a.friction};return{dx:s.v,dv:t(s)}}function r(a,n){var i={dx:a.v,dv:t(a)},s=e(a,n*.5,i),o=e(a,n*.5,s),u=e(a,n,o),l=1/6*(i.dx+2*(s.dx+o.dx)+u.dx),f=1/6*(i.dv+2*(s.dv+o.dv)+u.dv);return a.x=a.x+l*n,a.v=a.v+f*n,a}return function a(n,i,s){var o={x:-1,v:0,tension:null,friction:null},u=[0],l=0,f=1/1e4,c=16/1e3,v,h,d;for(n=parseFloat(n)||500,i=parseFloat(i)||20,s=s||null,o.tension=n,o.friction=i,v=s!==null,v?(l=a(n,i),h=l/s*c):h=c;d=r(d||o,h),u.push(1+d.x),l+=16,Math.abs(d.x)>f&&Math.abs(d.v)>f;);return v?function(p){return u[p*(u.length-1)|0]}:l}}(),Ue=function(e,r,a,n){var i=qp(e,r,a,n);return function(s,o,u){return s+(o-s)*i(u)}},gn={linear:function(e,r,a){return e+(r-e)*a},ease:Ue(.25,.1,.25,1),"ease-in":Ue(.42,0,1,1),"ease-out":Ue(0,0,.58,1),"ease-in-out":Ue(.42,0,.58,1),"ease-in-sine":Ue(.47,0,.745,.715),"ease-out-sine":Ue(.39,.575,.565,1),"ease-in-out-sine":Ue(.445,.05,.55,.95),"ease-in-quad":Ue(.55,.085,.68,.53),"ease-out-quad":Ue(.25,.46,.45,.94),"ease-in-out-quad":Ue(.455,.03,.515,.955),"ease-in-cubic":Ue(.55,.055,.675,.19),"ease-out-cubic":Ue(.215,.61,.355,1),"ease-in-out-cubic":Ue(.645,.045,.355,1),"ease-in-quart":Ue(.895,.03,.685,.22),"ease-out-quart":Ue(.165,.84,.44,1),"ease-in-out-quart":Ue(.77,0,.175,1),"ease-in-quint":Ue(.755,.05,.855,.06),"ease-out-quint":Ue(.23,1,.32,1),"ease-in-out-quint":Ue(.86,0,.07,1),"ease-in-expo":Ue(.95,.05,.795,.035),"ease-out-expo":Ue(.19,1,.22,1),"ease-in-out-expo":Ue(1,0,0,1),"ease-in-circ":Ue(.6,.04,.98,.335),"ease-out-circ":Ue(.075,.82,.165,1),"ease-in-out-circ":Ue(.785,.135,.15,.86),spring:function(e,r,a){if(a===0)return gn.linear;var n=Yp(e,r,a);return function(i,s,o){return i+(s-i)*n(o)}},"cubic-bezier":Ue};function Ml(t,e,r,a,n){if(a===1||e===r)return r;var i=n(e,r,a);return t==null||((t.roundValue||t.color)&&(i=Math.round(i)),t.min!==void 0&&(i=Math.max(i,t.min)),t.max!==void 0&&(i=Math.min(i,t.max))),i}function Ol(t,e){return t.pfValue!=null||t.value!=null?t.pfValue!=null&&(e==null||e.type.units!=="%")?t.pfValue:t.value:t}function Vr(t,e,r,a,n){var i=n!=null?n.type:null;r<0?r=0:r>1&&(r=1);var s=Ol(t,n),o=Ol(e,n);if(ne(s)&&ne(o))return Ml(i,s,o,r,a);if(Ve(s)&&Ve(o)){for(var u=[],l=0;l0?(h==="spring"&&d.push(s.duration),s.easingImpl=gn[h].apply(null,d)):s.easingImpl=gn[h]}var p=s.easingImpl,g;if(s.duration===0?g=1:g=(r-u)/s.duration,s.applying&&(g=s.progress),g<0?g=0:g>1&&(g=1),s.delay==null){var y=s.startPosition,b=s.position;if(b&&n&&!t.locked()){var m={};pa(y.x,b.x)&&(m.x=Vr(y.x,b.x,g,p)),pa(y.y,b.y)&&(m.y=Vr(y.y,b.y,g,p)),t.position(m)}var E=s.startPan,T=s.pan,S=i.pan,w=T!=null&&a;w&&(pa(E.x,T.x)&&(S.x=Vr(E.x,T.x,g,p)),pa(E.y,T.y)&&(S.y=Vr(E.y,T.y,g,p)),t.emit("pan"));var x=s.startZoom,C=s.zoom,D=C!=null&&a;D&&(pa(x,C)&&(i.zoom=Ra(i.minZoom,Vr(x,C,g,p),i.maxZoom)),t.emit("zoom")),(w||D)&&t.emit("viewport");var A=s.style;if(A&&A.length>0&&n){for(var L=0;L=0;w--){var x=S[w];x()}S.splice(0,S.length)},b=h.length-1;b>=0;b--){var m=h[b],E=m._private;if(E.stopped){h.splice(b,1),E.hooked=!1,E.playing=!1,E.started=!1,y(E.frames);continue}!E.playing&&!E.applying||(E.playing&&E.applying&&(E.applying=!1),E.started||Xp(f,m,t),Hp(f,m,t,c),E.applying&&(E.applying=!1),y(E.frames),E.step!=null&&E.step(t),m.completed()&&(h.splice(b,1),E.hooked=!1,E.playing=!1,E.started=!1,y(E.completes)),p=!0)}return!c&&h.length===0&&d.length===0&&a.push(f),p}for(var i=!1,s=0;s0?e.notify("draw",r):e.notify("draw")),r.unmerge(a),e.emit("step")}var $p={animate:_e.animate(),animation:_e.animation(),animated:_e.animated(),clearQueue:_e.clearQueue(),delay:_e.delay(),delayAnimation:_e.delayAnimation(),stop:_e.stop(),addToAnimationPool:function(e){var r=this;r.styleEnabled()&&r._private.aniEles.merge(e)},stopAnimationLoop:function(){this._private.animationsRunning=!1},startAnimationLoop:function(){var e=this;if(e._private.animationsRunning=!0,!e.styleEnabled())return;function r(){e._private.animationsRunning&&Ln(function(i){kl(i,e),r()})}var a=e.renderer();a&&a.beforeRender?a.beforeRender(function(i,s){kl(s,e)},a.beforeRenderPriorities.animations):r()}},Wp={qualifierCompare:function(e,r){return e==null||r==null?e==null&&r==null:e.sameText(r)},eventMatches:function(e,r,a){var n=r.qualifier;return n!=null?e!==a.target&&Fa(a.target)&&n.matches(a.target):!0},addEventFields:function(e,r){r.cy=e,r.target=e},callbackContext:function(e,r,a){return r.qualifier!=null?a.target:e}},sn=function(e){return ge(e)?new hr(e):e},yc={createEmitter:function(){var e=this._private;return e.emitter||(e.emitter=new Zn(Wp,this)),this},emitter:function(){return this._private.emitter},on:function(e,r,a){return this.emitter().on(e,sn(r),a),this},removeListener:function(e,r,a){return this.emitter().removeListener(e,sn(r),a),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},one:function(e,r,a){return this.emitter().one(e,sn(r),a),this},once:function(e,r,a){return this.emitter().one(e,sn(r),a),this},emit:function(e,r){return this.emitter().emit(e,r),this},emitAndNotify:function(e,r){return this.emit(e),this.notify(e,r),this}};_e.eventAliasesOn(yc);var Hs={png:function(e){var r=this._private.renderer;return e=e||{},r.png(e)},jpg:function(e){var r=this._private.renderer;return e=e||{},e.bg=e.bg||"#fff",r.jpg(e)}};Hs.jpeg=Hs.jpg;var pn={layout:function(e){var r=this;if(e==null){He("Layout options must be specified to make a layout");return}if(e.name==null){He("A `name` must be specified to make a layout");return}var a=e.name,n=r.extension("layout",a);if(n==null){He("No such layout `"+a+"` found. Did you forget to import it and `cytoscape.use()` it?");return}var i;ge(e.eles)?i=r.$(e.eles):i=e.eles!=null?e.eles:r.$();var s=new n(be({},e,{cy:r,eles:i}));return s}};pn.createLayout=pn.makeLayout=pn.layout;var Kp={notify:function(e,r){var a=this._private;if(this.batching()){a.batchNotifications=a.batchNotifications||{};var n=a.batchNotifications[e]=a.batchNotifications[e]||this.collection();r!=null&&n.merge(r);return}if(a.notificationsEnabled){var i=this.renderer();this.destroyed()||!i||i.notify(e,r)}},notifications:function(e){var r=this._private;return e===void 0?r.notificationsEnabled:(r.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 e.batchCount==null&&(e.batchCount=0),e.batchCount===0&&(e.batchStyleEles=this.collection(),e.batchNotifications={}),e.batchCount++,this},endBatch:function(){var e=this._private;if(e.batchCount===0)return this;if(e.batchCount--,e.batchCount===0){e.batchStyleEles.updateStyle();var r=this.renderer();Object.keys(e.batchNotifications).forEach(function(a){var n=e.batchNotifications[a];n.empty()?r.notify(a):r.notify(a,n)})}return this},batch:function(e){return this.startBatch(),e(),this.endBatch(),this},batchData:function(e){var r=this;return this.batch(function(){for(var a=Object.keys(e),n=0;n0;)r.removeChild(r.childNodes[0]);e._private.renderer=null,e.mutableElements().forEach(function(a){var n=a._private;n.rscratch={},n.rstyle={},n.animation.current=[],n.animation.queue=[]})},onRender:function(e){return this.on("render",e)},offRender:function(e){return this.off("render",e)}};Xs.invalidateDimensions=Xs.resize;var yn={collection:function(e,r){return ge(e)?this.$(e):Lt(e)?e.collection():Ve(e)?(r||(r={}),new vt(this,e,r.unique,r.removed)):new vt(this)},nodes:function(e){var r=this.$(function(a){return a.isNode()});return e?r.filter(e):r},edges:function(e){var r=this.$(function(a){return a.isEdge()});return e?r.filter(e):r},$:function(e){var r=this._private.elements;return e?r.filter(e):r.spawnSelf()},mutableElements:function(){return this._private.elements}};yn.elements=yn.filter=yn.$;var lt={},Ta="t",Qp="f";lt.apply=function(t){for(var e=this,r=e._private,a=r.cy,n=a.collection(),i=0;i0;if(v||c&&h){var d=void 0;v&&h||v?d=l.properties:h&&(d=l.mappedProperties);for(var p=0;p1&&(E=1),o.color){var S=a.valueMin[0],w=a.valueMax[0],x=a.valueMin[1],C=a.valueMax[1],D=a.valueMin[2],A=a.valueMax[2],L=a.valueMin[3]==null?1:a.valueMin[3],R=a.valueMax[3]==null?1:a.valueMax[3],I=[Math.round(S+(w-S)*E),Math.round(x+(C-x)*E),Math.round(D+(A-D)*E),Math.round(L+(R-L)*E)];i={bypass:a.bypass,name:a.name,value:I,strValue:"rgb("+I[0]+", "+I[1]+", "+I[2]+")"}}else if(o.number){var M=a.valueMin+(a.valueMax-a.valueMin)*E;i=this.parse(a.name,M,a.bypass,v)}else return!1;if(!i)return p(),!1;i.mapping=a,a=i;break}case s.data:{for(var N=a.field.split("."),O=c.data,k=0;k0&&i>0){for(var o={},u=!1,l=0;l0?t.delayAnimation(s).play().promise().then(m):m()}).then(function(){return t.animation({style:o,duration:i,easing:t.pstyle("transition-timing-function").value,queue:!1}).play().promise()}).then(function(){r.removeBypasses(t,n),t.emitAndNotify("style"),a.transitioning=!1})}else a.transitioning&&(this.removeBypasses(t,n),t.emitAndNotify("style"),a.transitioning=!1)};lt.checkTrigger=function(t,e,r,a,n,i){var s=this.properties[e],o=n(s);t.removed()||o!=null&&o(r,a,t)&&i(s)};lt.checkZOrderTrigger=function(t,e,r,a){var n=this;this.checkTrigger(t,e,r,a,function(i){return i.triggersZOrder},function(){n._private.cy.notify("zorder",t)})};lt.checkBoundsTrigger=function(t,e,r,a){this.checkTrigger(t,e,r,a,function(n){return n.triggersBounds},function(n){t.dirtyCompoundBoundsCache(),t.dirtyBoundingBoxCache()})};lt.checkConnectedEdgesBoundsTrigger=function(t,e,r,a){this.checkTrigger(t,e,r,a,function(n){return n.triggersBoundsOfConnectedEdges},function(n){t.connectedEdges().forEach(function(i){i.dirtyBoundingBoxCache()})})};lt.checkParallelEdgesBoundsTrigger=function(t,e,r,a){this.checkTrigger(t,e,r,a,function(n){return n.triggersBoundsOfParallelEdges},function(n){t.parallelEdges().forEach(function(i){i.dirtyBoundingBoxCache()})})};lt.checkTriggers=function(t,e,r,a){t.dirtyStyleCache(),this.checkZOrderTrigger(t,e,r,a),this.checkBoundsTrigger(t,e,r,a),this.checkConnectedEdgesBoundsTrigger(t,e,r,a),this.checkParallelEdgesBoundsTrigger(t,e,r,a)};var Ya={};Ya.applyBypass=function(t,e,r,a){var n=this,i=[],s=!0;if(e==="*"||e==="**"){if(r!==void 0)for(var o=0;on.length?a=a.substr(n.length):a=""}function u(){i.length>s.length?i=i.substr(s.length):i=""}for(;;){var l=a.match(/^\s*$/);if(l)break;var f=a.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!f){Ge("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: "+a);break}n=f[0];var c=f[1];if(c!=="core"){var v=new hr(c);if(v.invalid){Ge("Skipping parsing of block: Invalid selector found in string stylesheet: "+c),o();continue}}var h=f[2],d=!1;i=h;for(var p=[];;){var g=i.match(/^\s*$/);if(g)break;var y=i.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/);if(!y){Ge("Skipping parsing of block: Invalid formatting of style property and value definitions found in:"+h),d=!0;break}s=y[0];var b=y[1],m=y[2],E=e.properties[b];if(!E){Ge("Skipping property: Invalid property name in: "+s),u();continue}var T=r.parse(b,m);if(!T){Ge("Skipping property: Invalid property definition in: "+s),u();continue}p.push({name:b,val:m}),u()}if(d){o();break}r.selector(c);for(var S=0;S=7&&e[0]==="d"&&(f=new RegExp(o.data.regex).exec(e))){if(r)return!1;var v=o.data;return{name:t,value:f,strValue:""+e,mapped:v,field:f[1],bypass:r}}else if(e.length>=10&&e[0]==="m"&&(c=new RegExp(o.mapData.regex).exec(e))){if(r||l.multiple)return!1;var h=o.mapData;if(!(l.color||l.number))return!1;var d=this.parse(t,c[4]);if(!d||d.mapped)return!1;var p=this.parse(t,c[5]);if(!p||p.mapped)return!1;if(d.pfValue===p.pfValue||d.strValue===p.strValue)return Ge("`"+t+": "+e+"` is not a valid mapper because the output range is zero; converting to `"+t+": "+d.strValue+"`"),this.parse(t,d.strValue);if(l.color){var g=d.value,y=p.value,b=g[0]===y[0]&&g[1]===y[1]&&g[2]===y[2]&&(g[3]===y[3]||(g[3]==null||g[3]===1)&&(y[3]==null||y[3]===1));if(b)return!1}return{name:t,value:c,strValue:""+e,mapped:h,field:c[1],fieldMin:parseFloat(c[2]),fieldMax:parseFloat(c[3]),valueMin:d.value,valueMax:p.value,bypass:r}}}if(l.multiple&&a!=="multiple"){var m;if(u?m=e.split(/\s+/):Ve(e)?m=e:m=[e],l.evenMultiple&&m.length%2!==0)return null;for(var E=[],T=[],S=[],w="",x=!1,C=0;C0?" ":"")+D.strValue}return l.validate&&!l.validate(E,T)?null:l.singleEnum&&x?E.length===1&&ge(E[0])?{name:t,value:E[0],strValue:E[0],bypass:r}:null:{name:t,value:E,pfValue:S,strValue:w,bypass:r,units:T}}var A=function(){for(var J=0;Jl.max||l.strictMax&&e===l.max))return null;var N={name:t,value:e,strValue:""+e+(L||""),units:L,bypass:r};return l.unitless||L!=="px"&&L!=="em"?N.pfValue=e:N.pfValue=L==="px"||!L?e:this.getEmSizeInPixels()*e,(L==="ms"||L==="s")&&(N.pfValue=L==="ms"?e:1e3*e),(L==="deg"||L==="rad")&&(N.pfValue=L==="rad"?e:Wh(e)),L==="%"&&(N.pfValue=e/100),N}else if(l.propList){var O=[],k=""+e;if(k!=="none"){for(var B=k.split(/\s*,\s*|\s+/),_=0;_0&&o>0&&!isNaN(a.w)&&!isNaN(a.h)&&a.w>0&&a.h>0){u=Math.min((s-2*r)/a.w,(o-2*r)/a.h),u=u>this._private.maxZoom?this._private.maxZoom:u,u=u=a.minZoom&&(a.maxZoom=r),this},minZoom:function(e){return e===void 0?this._private.minZoom:this.zoomRange({min:e})},maxZoom:function(e){return e===void 0?this._private.maxZoom:this.zoomRange({max:e})},getZoomedViewport:function(e){var r=this._private,a=r.pan,n=r.zoom,i,s,o=!1;if(r.zoomingEnabled||(o=!0),ne(e)?s=e:Oe(e)&&(s=e.level,e.position!=null?i=qn(e.position,n,a):e.renderedPosition!=null&&(i=e.renderedPosition),i!=null&&!r.panningEnabled&&(o=!0)),s=s>r.maxZoom?r.maxZoom:s,s=sr.maxZoom||!r.zoomingEnabled?s=!0:(r.zoom=u,i.push("zoom"))}if(n&&(!s||!e.cancelOnFailedZoom)&&r.panningEnabled){var l=e.pan;ne(l.x)&&(r.pan.x=l.x,o=!1),ne(l.y)&&(r.pan.y=l.y,o=!1),o||i.push("pan")}return i.length>0&&(i.push("viewport"),this.emit(i.join(" ")),this.notify("viewport")),this},center:function(e){var r=this.getCenterPan(e);return r&&(this._private.pan=r,this.emit("pan viewport"),this.notify("viewport")),this},getCenterPan:function(e,r){if(this._private.panningEnabled){if(ge(e)){var a=e;e=this.mutableElements().filter(a)}else Lt(e)||(e=this.mutableElements());if(e.length!==0){var n=e.boundingBox(),i=this.width(),s=this.height();r=r===void 0?this._private.zoom:r;var o={x:(i-r*(n.x1+n.x2))/2,y:(s-r*(n.y1+n.y2))/2};return o}}},reset:function(){return!this._private.panningEnabled||!this._private.zoomingEnabled?this:(this.viewport({pan:{x:0,y:0},zoom:1}),this)},invalidateSize:function(){this._private.sizeCache=null},size:function(){var e=this._private,r=e.container,a=this;return e.sizeCache=e.sizeCache||(r?function(){var n=a.window().getComputedStyle(r),i=function(o){return parseFloat(n.getPropertyValue(o))};return{width:r.clientWidth-i("padding-left")-i("padding-right"),height:r.clientHeight-i("padding-top")-i("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,r=this._private.zoom,a=this.renderedExtent(),n={x1:(a.x1-e.x)/r,x2:(a.x2-e.x)/r,y1:(a.y1-e.y)/r,y2:(a.y2-e.y)/r};return n.w=n.x2-n.x1,n.h=n.y2-n.y1,n},renderedExtent:function(){var e=this.width(),r=this.height();return{x1:0,y1:0,x2:e,y2:r,w:e,h:r}},multiClickDebounceTime:function(e){if(e)this._private.multiClickDebounceTime=e;else return this._private.multiClickDebounceTime;return this}};Or.centre=Or.center;Or.autolockNodes=Or.autolock;Or.autoungrabifyNodes=Or.autoungrabify;var Oa={data:_e.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeData:_e.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),scratch:_e.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:_e.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0})};Oa.attr=Oa.data;Oa.removeAttr=Oa.removeData;var ka=function(e){var r=this;e=be({},e);var a=e.container;a&&!An(a)&&An(a[0])&&(a=a[0]);var n=a?a._cyreg:null;n=n||{},n&&n.cy&&(n.cy.destroy(),n={});var i=n.readies=n.readies||[];a&&(a._cyreg=n),n.cy=r;var s=tt!==void 0&&a!==void 0&&!e.headless,o=e;o.layout=be({name:s?"grid":"null"},o.layout),o.renderer=be({name:s?"canvas":"null"},o.renderer);var u=function(d,p,g){return p!==void 0?p:g!==void 0?g:d},l=this._private={container:a,ready:!1,options:o,elements:new vt(this),listeners:[],aniEles:new vt(this),data:o.data||{},scratch:{},layout:null,renderer:null,destroyed:!1,notificationsEnabled:!0,minZoom:1e-50,maxZoom:1e50,zoomingEnabled:u(!0,o.zoomingEnabled),userZoomingEnabled:u(!0,o.userZoomingEnabled),panningEnabled:u(!0,o.panningEnabled),userPanningEnabled:u(!0,o.userPanningEnabled),boxSelectionEnabled:u(!0,o.boxSelectionEnabled),autolock:u(!1,o.autolock,o.autolockNodes),autoungrabify:u(!1,o.autoungrabify,o.autoungrabifyNodes),autounselectify:u(!1,o.autounselectify),styleEnabled:o.styleEnabled===void 0?s:o.styleEnabled,zoom:ne(o.zoom)?o.zoom:1,pan:{x:Oe(o.pan)&&ne(o.pan.x)?o.pan.x:0,y:Oe(o.pan)&&ne(o.pan.y)?o.pan.y:0},animation:{current:[],queue:[]},hasCompoundNodes:!1,multiClickDebounceTime:u(250,o.multiClickDebounceTime)};this.createEmitter(),this.selectionType(o.selectionType),this.zoomRange({min:o.minZoom,max:o.maxZoom});var f=function(d,p){var g=d.some(Uv);if(g)return ia.all(d).then(p);p(d)};l.styleEnabled&&r.setStyle([]);var c=be({},o,o.renderer);r.initRenderer(c);var v=function(d,p,g){r.notifications(!1);var y=r.mutableElements();y.length>0&&y.remove(),d!=null&&(Oe(d)||Ve(d))&&r.add(d),r.one("layoutready",function(m){r.notifications(!0),r.emit(m),r.one("load",p),r.emitAndNotify("load")}).one("layoutstop",function(){r.one("done",g),r.emit("done")});var b=be({},r._private.options.layout);b.eles=r.elements(),r.layout(b).run()};f([o.style,o.elements],function(h){var d=h[0],p=h[1];l.styleEnabled&&r.style().append(d),v(p,function(){r.startAnimationLoop(),l.ready=!0,Xe(o.ready)&&r.on("ready",o.ready);for(var g=0;g0,o=!!t.boundingBox,u=Et(o?t.boundingBox:structuredClone(e.extent())),l;if(Lt(t.roots))l=t.roots;else if(Ve(t.roots)){for(var f=[],c=0;c0;){var I=R(),M=C(I,A);if(M)I.outgoers().filter(function(ye){return ye.isNode()&&r.has(ye)}).forEach(L);else if(M===null){Ge("Detected double maximal shift for node `"+I.id()+"`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.");break}}}var N=0;if(t.avoidOverlap)for(var O=0;O0&&y[0].length<=3?pe/2:0),Pe=2*Math.PI/y[de].length*xe;return de===0&&y[0].length===1&&(De=1),{x:q.x+De*Math.cos(Pe),y:q.y+De*Math.sin(Pe)}}else{var Ne=y[de].length,Be=Math.max(Ne===1?0:o?(u.w-t.padding*2-Z.w)/((t.grid?ve:Ne)-1):(u.w-t.padding*2-Z.w)/((t.grid?ve:Ne)+1),N),Fe={x:q.x+(xe+1-(Ne+1)/2)*Be,y:q.y+(de+1-(X+1)/2)*re};return Fe}},Te={downward:0,leftward:90,upward:180,rightward:-90};Object.keys(Te).indexOf(t.direction)===-1&&He("Invalid direction '".concat(t.direction,"' specified for breadthfirst layout. Valid values are: ").concat(Object.keys(Te).join(", ")));var we=function(ie){return yh(Ie(ie),u,Te[t.direction])};return r.nodes().layoutPositions(this,t,we),this};var ry={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,radius:void 0,startAngle:3/2*Math.PI,sweep:void 0,clockwise:!0,sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,r){return!0},ready:void 0,stop:void 0,transform:function(e,r){return r}};function bc(t){this.options=be({},ry,t)}bc.prototype.run=function(){var t=this.options,e=t,r=t.cy,a=e.eles,n=e.counterclockwise!==void 0?!e.counterclockwise:e.clockwise,i=a.nodes().not(":parent");e.sort&&(i=i.sort(e.sort));for(var s=Et(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()}),o={x:s.x1+s.w/2,y:s.y1+s.h/2},u=e.sweep===void 0?2*Math.PI-2*Math.PI/i.length:e.sweep,l=u/Math.max(1,i.length-1),f,c=0,v=0;v1&&e.avoidOverlap){c*=1.75;var y=Math.cos(l)-Math.cos(0),b=Math.sin(l)-Math.sin(0),m=Math.sqrt(c*c/(y*y+b*b));f=Math.max(m,f)}var E=function(S,w){var x=e.startAngle+w*l*(n?1:-1),C=f*Math.cos(x),D=f*Math.sin(x),A={x:o.x+C,y:o.y+D};return A};return a.nodes().layoutPositions(this,e,E),this};var ay={fit:!0,padding:30,startAngle:3/2*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,r){return!0},ready:void 0,stop:void 0,transform:function(e,r){return r}};function wc(t){this.options=be({},ay,t)}wc.prototype.run=function(){for(var t=this.options,e=t,r=e.counterclockwise!==void 0?!e.counterclockwise:e.clockwise,a=t.cy,n=e.eles,i=n.nodes().not(":parent"),s=Et(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:a.width(),h:a.height()}),o={x:s.x1+s.w/2,y:s.y1+s.h/2},u=[],l=0,f=0;f0){var T=Math.abs(b[0].value-E.value);T>=g&&(b=[],y.push(b))}b.push(E)}var S=l+e.minNodeSpacing;if(!e.avoidOverlap){var w=y.length>0&&y[0].length>1,x=Math.min(s.w,s.h)/2-S,C=x/(y.length+w?1:0);S=Math.min(S,C)}for(var D=0,A=0;A1&&e.avoidOverlap){var M=Math.cos(I)-Math.cos(0),N=Math.sin(I)-Math.sin(0),O=Math.sqrt(S*S/(M*M+N*N));D=Math.max(O,D)}L.r=D,D+=S}if(e.equidistant){for(var k=0,B=0,_=0;_=t.numIter||(fy(a,t),a.temperature=a.temperature*t.coolingFactor,a.temperature=t.animationThreshold&&i(),Ln(f)}};f()}else{for(;l;)l=s(u),u++;Fl(a,t),o()}return this};ti.prototype.stop=function(){return this.stopped=!0,this.thread&&this.thread.stop(),this.emit("layoutstop"),this};ti.prototype.destroy=function(){return this.thread&&this.thread.stop(),this};var iy=function(e,r,a){for(var n=a.eles.edges(),i=a.eles.nodes(),s=Et(a.boundingBox?a.boundingBox:{x1:0,y1:0,w:e.width(),h:e.height()}),o={isCompound:e.hasCompoundNodes(),layoutNodes:[],idToIndex:{},nodeSize:i.size(),graphSet:[],indexToGraph:[],layoutEdges:[],edgeSize:n.size(),temperature:a.initialTemp,clientWidth:s.w,clientHeight:s.h,boundingBox:s},u=a.eles.components(),l={},f=0;f0){o.graphSet.push(x);for(var f=0;fn.count?0:n.graph},Ec=function(e,r,a,n){var i=n.graphSet[a];if(-10)var c=n.nodeOverlap*f,v=Math.sqrt(o*o+u*u),h=c*o/v,d=c*u/v;else var p=Nn(e,o,u),g=Nn(r,-1*o,-1*u),y=g.x-p.x,b=g.y-p.y,m=y*y+b*b,v=Math.sqrt(m),c=(e.nodeRepulsion+r.nodeRepulsion)/m,h=c*y/v,d=c*b/v;e.isLocked||(e.offsetX-=h,e.offsetY-=d),r.isLocked||(r.offsetX+=h,r.offsetY+=d)}},hy=function(e,r,a,n){if(a>0)var i=e.maxX-r.minX;else var i=r.maxX-e.minX;if(n>0)var s=e.maxY-r.minY;else var s=r.maxY-e.minY;return i>=0&&s>=0?Math.sqrt(i*i+s*s):0},Nn=function(e,r,a){var n=e.positionX,i=e.positionY,s=e.height||1,o=e.width||1,u=a/r,l=s/o,f={};return r===0&&0a?(f.x=n,f.y=i+s/2,f):0r&&-1*l<=u&&u<=l?(f.x=n-o/2,f.y=i-o*a/2/r,f):0=l)?(f.x=n+s*r/2/a,f.y=i+s/2,f):(0>a&&(u<=-1*l||u>=l)&&(f.x=n-s*r/2/a,f.y=i-s/2),f)},dy=function(e,r){for(var a=0;aa){var g=r.gravity*h/p,y=r.gravity*d/p;v.offsetX+=g,v.offsetY+=y}}}}},py=function(e,r){var a=[],n=0,i=-1;for(a.push.apply(a,e.graphSet[0]),i+=e.graphSet[0].length;n<=i;){var s=a[n++],o=e.idToIndex[s],u=e.layoutNodes[o],l=u.children;if(0a)var i={x:a*e/n,y:a*r/n};else var i={x:e,y:r};return i},Tc=function(e,r){var a=e.parentId;if(a!=null){var n=r.layoutNodes[r.idToIndex[a]],i=!1;if((n.maxX==null||e.maxX+n.padRight>n.maxX)&&(n.maxX=e.maxX+n.padRight,i=!0),(n.minX==null||e.minX-n.padLeftn.maxY)&&(n.maxY=e.maxY+n.padBottom,i=!0),(n.minY==null||e.minY-n.padTopy&&(d+=g+r.componentSpacing,h=0,p=0,g=0)}}},by={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,r){return!0},ready:void 0,stop:void 0,transform:function(e,r){return r}};function Cc(t){this.options=be({},by,t)}Cc.prototype.run=function(){var t=this.options,e=t,r=t.cy,a=e.eles,n=a.nodes().not(":parent");e.sort&&(n=n.sort(e.sort));var i=Et(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()});if(i.h===0||i.w===0)a.nodes().layoutPositions(this,e,function(H){return{x:i.x1,y:i.y1}});else{var s=n.size(),o=Math.sqrt(s*i.h/i.w),u=Math.round(o),l=Math.round(i.w/i.h*o),f=function(Y){if(Y==null)return Math.min(u,l);var X=Math.min(u,l);X==u?u=Y:l=Y},c=function(Y){if(Y==null)return Math.max(u,l);var X=Math.max(u,l);X==u?u=Y:l=Y},v=e.rows,h=e.cols!=null?e.cols:e.columns;if(v!=null&&h!=null)u=v,l=h;else if(v!=null&&h==null)u=v,l=Math.ceil(s/u);else if(v==null&&h!=null)l=h,u=Math.ceil(s/l);else if(l*u>s){var d=f(),p=c();(d-1)*p>=s?f(d-1):(p-1)*d>=s&&c(p-1)}else for(;l*u=s?c(y+1):f(g+1)}var b=i.w/l,m=i.h/u;if(e.condense&&(b=0,m=0),e.avoidOverlap)for(var E=0;E=l&&(M=0,I++)},O={},k=0;k(M=ud(t,e,N[O],N[O+1],N[O+2],N[O+3])))return g(w,M),!0}else if(C.edgeType==="bezier"||C.edgeType==="multibezier"||C.edgeType==="self"||C.edgeType==="compound"){for(var N=C.allpts,O=0;O+5(M=od(t,e,N[O],N[O+1],N[O+2],N[O+3],N[O+4],N[O+5])))return g(w,M),!0}for(var k=k||x.source,B=B||x.target,_=n.getArrowWidth(D,A),F=[{name:"source",x:C.arrowStartX,y:C.arrowStartY,angle:C.srcArrowAngle},{name:"target",x:C.arrowEndX,y:C.arrowEndY,angle:C.tgtArrowAngle},{name:"mid-source",x:C.midX,y:C.midY,angle:C.midsrcArrowAngle},{name:"mid-target",x:C.midX,y:C.midY,angle:C.midtgtArrowAngle}],O=0;O0&&(y(k),y(B))}function m(w,x,C){return Dt(w,x,C)}function E(w,x){var C=w._private,D=v,A;x?A=x+"-":A="",w.boundingBox();var L=C.labelBounds[x||"main"],R=w.pstyle(A+"label").value,I=w.pstyle("text-events").strValue==="yes";if(!(!I||!R)){var M=m(C.rscratch,"labelX",x),N=m(C.rscratch,"labelY",x),O=m(C.rscratch,"labelAngle",x),k=w.pstyle(A+"text-margin-x").pfValue,B=w.pstyle(A+"text-margin-y").pfValue,_=L.x1-D-k,F=L.x2+D-k,G=L.y1-D-B,H=L.y2+D-B;if(O){var Y=Math.cos(O),X=Math.sin(O),W=function(Z,re){return Z=Z-M,re=re-N,{x:Z*Y-re*X+M,y:Z*X+re*Y+N}},ee=W(_,G),ae=W(_,H),J=W(F,G),z=W(F,H),V=[ee.x+k,ee.y+B,J.x+k,J.y+B,z.x+k,z.y+B,ae.x+k,ae.y+B];if(St(t,e,V))return g(w),!0}else if(sr(L,t,e))return g(w),!0}}for(var T=s.length-1;T>=0;T--){var S=s[T];S.isNode()?y(S)||E(S):b(S)||E(S)||E(S,"source")||E(S,"target")}return o};Br.getAllInBox=function(t,e,r,a){var n=this.getCachedZSortedEles().interactive,i=this.cy.zoom(),s=2/i,o=[],u=Math.min(t,r),l=Math.max(t,r),f=Math.min(e,a),c=Math.max(e,a);t=u,r=l,e=f,a=c;var v=Et({x1:t,y1:e,x2:r,y2:a}),h=[{x:v.x1,y:v.y1},{x:v.x2,y:v.y1},{x:v.x2,y:v.y2},{x:v.x1,y:v.y2}],d=[[h[0],h[1]],[h[1],h[2]],[h[2],h[3]],[h[3],h[0]]];function p(Z,re,ve){return Dt(Z,re,ve)}function g(Z,re){var ve=Z._private,Ie=s,Te="";Z.boundingBox();var we=ve.labelBounds.main;if(!we)return null;var ye=p(ve.rscratch,"labelX",re),ie=p(ve.rscratch,"labelY",re),he=p(ve.rscratch,"labelAngle",re),de=Z.pstyle(Te+"text-margin-x").pfValue,xe=Z.pstyle(Te+"text-margin-y").pfValue,pe=we.x1-Ie-de,De=we.x2+Ie-de,Pe=we.y1-Ie-xe,Ne=we.y2+Ie-xe;if(he){var Be=Math.cos(he),Fe=Math.sin(he),Ee=function(Q,P){return Q=Q-ye,P=P-ie,{x:Q*Be-P*Fe+ye,y:Q*Fe+P*Be+ie}};return[Ee(pe,Pe),Ee(De,Pe),Ee(De,Ne),Ee(pe,Ne)]}else return[{x:pe,y:Pe},{x:De,y:Pe},{x:De,y:Ne},{x:pe,y:Ne}]}function y(Z,re,ve,Ie){function Te(we,ye,ie){return(ie.y-we.y)*(ye.x-we.x)>(ye.y-we.y)*(ie.x-we.x)}return Te(Z,ve,Ie)!==Te(re,ve,Ie)&&Te(Z,re,ve)!==Te(Z,re,Ie)}for(var b=0;b0?-(Math.PI-e.ang):Math.PI+e.ang},Dy=function(e,r,a,n,i){if(e!==Ul?ql(r,e,Vt):Cy(It,Vt),ql(r,a,It),zl=Vt.nx*It.ny-Vt.ny*It.nx,Vl=Vt.nx*It.nx-Vt.ny*-It.ny,Wt=Math.asin(Math.max(-1,Math.min(1,zl))),Math.abs(Wt)<1e-6){$s=r.x,Ws=r.y,Sr=qr=0;return}Lr=1,mn=!1,Vl<0?Wt<0?Wt=Math.PI+Wt:(Wt=Math.PI-Wt,Lr=-1,mn=!0):Wt>0&&(Lr=-1,mn=!0),r.radius!==void 0?qr=r.radius:qr=n,Tr=Wt/2,on=Math.min(Vt.len/2,It.len/2),i?(Gt=Math.abs(Math.cos(Tr)*qr/Math.sin(Tr)),Gt>on?(Gt=on,Sr=Math.abs(Gt*Math.sin(Tr)/Math.cos(Tr))):Sr=qr):(Gt=Math.min(on,qr),Sr=Math.abs(Gt*Math.sin(Tr)/Math.cos(Tr))),Ks=r.x+It.nx*Gt,Zs=r.y+It.ny*Gt,$s=Ks-It.ny*Sr*Lr,Ws=Zs+It.nx*Sr*Lr,Lc=r.x+Vt.nx*Gt,Rc=r.y+Vt.ny*Gt,Ul=r};function Ic(t,e){e.radius===0?t.lineTo(e.cx,e.cy):t.arc(e.cx,e.cy,e.radius,e.startAngle,e.endAngle,e.counterClockwise)}function So(t,e,r,a){var n=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0;return a===0||e.radius===0?{cx:e.x,cy:e.y,radius:0,startX:e.x,startY:e.y,stopX:e.x,stopY:e.y,startAngle:void 0,endAngle:void 0,counterClockwise:void 0}:(Dy(t,e,r,a,n),{cx:$s,cy:Ws,radius:Sr,startX:Lc,startY:Rc,stopX:Ks,stopY:Zs,startAngle:Vt.ang+Math.PI/2*Lr,endAngle:It.ang-Math.PI/2*Lr,counterClockwise:mn})}var Na=.01,Sy=Math.sqrt(2*Na),mt={};mt.findMidptPtsEtc=function(t,e){var r=e.posPts,a=e.intersectionPts,n=e.vectorNormInverse,i,s=t.pstyle("source-endpoint"),o=t.pstyle("target-endpoint"),u=s.units!=null&&o.units!=null,l=function(T,S,w,x){var C=x-S,D=w-T,A=Math.sqrt(D*D+C*C);return{x:-C/A,y:D/A}},f=t.pstyle("edge-distances").value;switch(f){case"node-position":i=r;break;case"intersection":i=a;break;case"endpoints":{if(u){var c=this.manualEndptToPx(t.source()[0],s),v=Je(c,2),h=v[0],d=v[1],p=this.manualEndptToPx(t.target()[0],o),g=Je(p,2),y=g[0],b=g[1],m={x1:h,y1:d,x2:y,y2:b};n=l(h,d,y,b),i=m}else Ge("Edge ".concat(t.id()," has edge-distances:endpoints specified without manual endpoints specified via source-endpoint and target-endpoint. Falling back on edge-distances:intersection (default).")),i=a;break}}return{midptPts:i,vectorNormInverse:n}};mt.findHaystackPoints=function(t){for(var e=0;e0?Math.max(P-U,0):Math.min(P+U,0)},R=L(D,x),I=L(A,C),M=!1;b===l?y=Math.abs(R)>Math.abs(I)?n:a:b===u||b===o?(y=a,M=!0):(b===i||b===s)&&(y=n,M=!0);var N=y===a,O=N?I:R,k=N?A:D,B=vo(k),_=!1;!(M&&(E||S))&&(b===o&&k<0||b===u&&k>0||b===i&&k>0||b===s&&k<0)&&(B*=-1,O=B*Math.abs(O),_=!0);var F;if(E){var G=T<0?1+T:T;F=G*O}else{var H=T<0?O:0;F=H+T*B}var Y=function(P){return Math.abs(P)=Math.abs(O)},X=Y(F),W=Y(Math.abs(O)-Math.abs(F)),ee=X||W;if(ee&&!_)if(N){var ae=Math.abs(k)<=v/2,J=Math.abs(D)<=h/2;if(ae){var z=(f.x1+f.x2)/2,V=f.y1,q=f.y2;r.segpts=[z,V,z,q]}else if(J){var Z=(f.y1+f.y2)/2,re=f.x1,ve=f.x2;r.segpts=[re,Z,ve,Z]}else r.segpts=[f.x1,f.y2]}else{var Ie=Math.abs(k)<=c/2,Te=Math.abs(A)<=d/2;if(Ie){var we=(f.y1+f.y2)/2,ye=f.x1,ie=f.x2;r.segpts=[ye,we,ie,we]}else if(Te){var he=(f.x1+f.x2)/2,de=f.y1,xe=f.y2;r.segpts=[he,de,he,xe]}else r.segpts=[f.x2,f.y1]}else if(N){var pe=f.y1+F+(g?v/2*B:0),De=f.x1,Pe=f.x2;r.segpts=[De,pe,Pe,pe]}else{var Ne=f.x1+F+(g?c/2*B:0),Be=f.y1,Fe=f.y2;r.segpts=[Ne,Be,Ne,Fe]}if(r.isRound){var Ee=t.pstyle("taxi-radius").value,ue=t.pstyle("radius-type").value[0]==="arc-radius";r.radii=new Array(r.segpts.length/2).fill(Ee),r.isArcRadius=new Array(r.segpts.length/2).fill(ue)}};mt.tryToCorrectInvalidPoints=function(t,e){var r=t._private.rscratch;if(r.edgeType==="bezier"){var a=e.srcPos,n=e.tgtPos,i=e.srcW,s=e.srcH,o=e.tgtW,u=e.tgtH,l=e.srcShape,f=e.tgtShape,c=e.srcCornerRadius,v=e.tgtCornerRadius,h=e.srcRs,d=e.tgtRs,p=!ne(r.startX)||!ne(r.startY),g=!ne(r.arrowStartX)||!ne(r.arrowStartY),y=!ne(r.endX)||!ne(r.endY),b=!ne(r.arrowEndX)||!ne(r.arrowEndY),m=3,E=this.getArrowWidth(t.pstyle("width").pfValue,t.pstyle("arrow-scale").value)*this.arrowShapeWidth,T=m*E,S=Pr({x:r.ctrlpts[0],y:r.ctrlpts[1]},{x:r.startX,y:r.startY}),w=Sk.poolIndex()){var B=O;O=k,k=B}var _=R.srcPos=O.position(),F=R.tgtPos=k.position(),G=R.srcW=O.outerWidth(),H=R.srcH=O.outerHeight(),Y=R.tgtW=k.outerWidth(),X=R.tgtH=k.outerHeight(),W=R.srcShape=r.nodeShapes[e.getNodeShape(O)],ee=R.tgtShape=r.nodeShapes[e.getNodeShape(k)],ae=R.srcCornerRadius=O.pstyle("corner-radius").value==="auto"?"auto":O.pstyle("corner-radius").pfValue,J=R.tgtCornerRadius=k.pstyle("corner-radius").value==="auto"?"auto":k.pstyle("corner-radius").pfValue,z=R.tgtRs=k._private.rscratch,V=R.srcRs=O._private.rscratch;R.dirCounts={north:0,west:0,south:0,east:0,northwest:0,southwest:0,northeast:0,southeast:0};for(var q=0;q=Sy||(Pe=Math.sqrt(Math.max(De*De,Na)+Math.max(pe*pe,Na)));var Ne=R.vector={x:De,y:pe},Be=R.vectorNorm={x:Ne.x/Pe,y:Ne.y/Pe},Fe={x:-Be.y,y:Be.x};R.nodesOverlap=!ne(Pe)||ee.checkPoint(we[0],we[1],0,Y,X,F.x,F.y,J,z)||W.checkPoint(ie[0],ie[1],0,G,H,_.x,_.y,ae,V),R.vectorNormInverse=Fe,I={nodesOverlap:R.nodesOverlap,dirCounts:R.dirCounts,calculatedIntersection:!0,hasBezier:R.hasBezier,hasUnbundled:R.hasUnbundled,eles:R.eles,srcPos:F,srcRs:z,tgtPos:_,tgtRs:V,srcW:Y,srcH:X,tgtW:G,tgtH:H,srcIntn:he,tgtIntn:ye,srcShape:ee,tgtShape:W,posPts:{x1:xe.x2,y1:xe.y2,x2:xe.x1,y2:xe.y1},intersectionPts:{x1:de.x2,y1:de.y2,x2:de.x1,y2:de.y1},vector:{x:-Ne.x,y:-Ne.y},vectorNorm:{x:-Be.x,y:-Be.y},vectorNormInverse:{x:-Fe.x,y:-Fe.y}}}var Ee=Te?I:R;re.nodesOverlap=Ee.nodesOverlap,re.srcIntn=Ee.srcIntn,re.tgtIntn=Ee.tgtIntn,re.isRound=ve.startsWith("round"),n&&(O.isParent()||O.isChild()||k.isParent()||k.isChild())&&(O.parents().anySame(k)||k.parents().anySame(O)||O.same(k)&&O.isParent())?e.findCompoundLoopPoints(Z,Ee,q,Ie):O===k?e.findLoopPoints(Z,Ee,q,Ie):ve.endsWith("segments")?e.findSegmentsPoints(Z,Ee):ve.endsWith("taxi")?e.findTaxiPoints(Z,Ee):ve==="straight"||!Ie&&R.eles.length%2===1&&q===Math.floor(R.eles.length/2)?e.findStraightEdgePoints(Z):e.findBezierPoints(Z,Ee,q,Ie,Te),e.findEndpoints(Z),e.tryToCorrectInvalidPoints(Z,Ee),e.checkForInvalidEdgeWarning(Z),e.storeAllpts(Z),e.storeEdgeProjections(Z),e.calculateArrowAngles(Z),e.recalculateEdgeLabelProjections(Z),e.calculateLabelAngles(Z)}},w=0;w0){var we=l,ye=Dr(we,Wr(s)),ie=Dr(we,Wr(Te)),he=ye;if(ie2){var de=Dr(we,{x:Te[2],y:Te[3]});de0){var $=f,K=Dr($,Wr(s)),j=Dr($,Wr(U)),oe=K;if(j2){var te=Dr($,{x:U[2],y:U[3]});te=d||w){g={cp:E,segment:S};break}}if(g)break}var x=g.cp,C=g.segment,D=(d-y)/C.length,A=C.t1-C.t0,L=h?C.t0+A*D:C.t1-A*D;L=Ra(0,L,1),e=Qr(x.p0,x.p1,x.p2,L),v=Ly(x.p0,x.p1,x.p2,L);break}case"straight":case"segments":case"haystack":{for(var R=0,I,M,N,O,k=a.allpts.length,B=0;B+3=d));B+=2);var _=d-M,F=_/I;F=Ra(0,F,1),e=Zh(N,O,F),v=Oc(N,O);break}}s("labelX",c,e.x),s("labelY",c,e.y),s("labelAutoAngle",c,v)}};l("source"),l("target"),this.applyLabelDimensions(t)}};Yt.applyLabelDimensions=function(t){this.applyPrefixedLabelDimensions(t),t.isEdge()&&(this.applyPrefixedLabelDimensions(t,"source"),this.applyPrefixedLabelDimensions(t,"target"))};Yt.applyPrefixedLabelDimensions=function(t,e){var r=t._private,a=this.getLabelText(t,e),n=Ir(a,t._private.labelDimsKey);if(Dt(r.rscratch,"prefixedLabelDimsKey",e)!==n){Kt(r.rscratch,"prefixedLabelDimsKey",e,n);var i=this.calculateLabelDimensions(t,a),s=t.pstyle("line-height").pfValue,o=t.pstyle("text-wrap").strValue,u=Dt(r.rscratch,"labelWrapCachedLines",e)||[],l=o!=="wrap"?1:Math.max(u.length,1),f=i.height/l,c=f*s,v=i.width,h=i.height+(l-1)*(s-1)*f;Kt(r.rstyle,"labelWidth",e,v),Kt(r.rscratch,"labelWidth",e,v),Kt(r.rstyle,"labelHeight",e,h),Kt(r.rscratch,"labelHeight",e,h),Kt(r.rscratch,"labelLineHeight",e,c)}};Yt.getLabelText=function(t,e){var r=t._private,a=e?e+"-":"",n=t.pstyle(a+"label").strValue,i=t.pstyle("text-transform").value,s=function(H,Y){return Y?(Kt(r.rscratch,H,e,Y),Y):Dt(r.rscratch,H,e)};if(!n)return"";i=="none"||(i=="uppercase"?n=n.toUpperCase():i=="lowercase"&&(n=n.toLowerCase()));var o=t.pstyle("text-wrap").value;if(o==="wrap"){var u=s("labelKey");if(u!=null&&s("labelWrapKey")===u)return s("labelWrapCachedText");for(var l="​",f=n.split(` `),c=t.pstyle("text-max-width").pfValue,v=t.pstyle("text-overflow-wrap").value,h=v==="anywhere",d=[],p=/[\s\u200b]+|$/g,g=0;gc){var T=y.matchAll(p),S="",w=0,x=At(T),C;try{for(x.s();!(C=x.n()).done;){var D=C.value,A=D[0],L=y.substring(w,D.index);w=D.index+A.length;var R=S.length===0?L:S+L+A,I=this.calculateLabelDimensions(t,R),M=I.width;M<=c?S+=L+A:(S&&d.push(S),S=L+A)}}catch(G){x.e(G)}finally{x.f()}S.match(/^[\s\u200b]+$/)||d.push(S)}else d.push(y)}s("labelWrapCachedLines",d),n=s("labelWrapCachedText",d.join(` `)),s("labelWrapKey",u)}else if(o==="ellipsis"){var N=t.pstyle("text-max-width").pfValue,O="",k="…",B=!1;if(this.calculateLabelDimensions(t,n).widthN)break;O+=n[_],_===n.length-1&&(B=!0)}return B||(O+=k),O}return n};Yt.getLabelJustification=function(t){var e=t.pstyle("text-justification").strValue,r=t.pstyle("text-halign").strValue;if(e==="auto")if(t.isNode())switch(r){case"left":return"right";case"right":return"left";default:return"center"}else return"center";else return e};Yt.calculateLabelDimensions=function(t,e){var r=this,a=r.cy.window(),n=a.document,i=0,s=t.pstyle("font-style").strValue,o=t.pstyle("font-size").pfValue,u=t.pstyle("font-family").strValue,l=t.pstyle("font-weight").strValue,f=this.labelCalcCanvas,c=this.labelCalcCanvasContext;if(!f){f=this.labelCalcCanvas=n.createElement("canvas"),c=this.labelCalcCanvasContext=f.getContext("2d");var v=f.style;v.position="absolute",v.left="-9999px",v.top="-9999px",v.zIndex="-1",v.visibility="hidden",v.pointerEvents="none"}c.font="".concat(s," ").concat(l," ").concat(o,"px ").concat(u);for(var h=0,d=0,p=e.split(` `),g=0;g1&&arguments[1]!==void 0?arguments[1]:!0;if(e.merge(s),o)for(var u=0;u=t.desktopTapThreshold2}var ft=i(P);je&&(t.hoverData.tapholdCancelled=!0);var tr=function(){var Rt=t.hoverData.dragDelta=t.hoverData.dragDelta||[];Rt.length===0?(Rt.push(Re[0]),Rt.push(Re[1])):(Rt[0]+=Re[0],Rt[1]+=Re[1])};$=!0,n(Ae,["mousemove","vmousemove","tapdrag"],P,{x:te[0],y:te[1]});var Ze=function(Rt){return{originalEvent:P,type:Rt,position:{x:te[0],y:te[1]}}},Xt=function(){t.data.bgActivePosistion=void 0,t.hoverData.selecting||K.emit(Ze("boxstart")),me[4]=1,t.hoverData.selecting=!0,t.redrawHint("select",!0),t.redraw()};if(t.hoverData.which===3){if(je){var $t=Ze("cxtdrag");ce?ce.emit($t):K.emit($t),t.hoverData.cxtDragged=!0,(!t.hoverData.cxtOver||Ae!==t.hoverData.cxtOver)&&(t.hoverData.cxtOver&&t.hoverData.cxtOver.emit(Ze("cxtdragout")),t.hoverData.cxtOver=Ae,Ae&&Ae.emit(Ze("cxtdragover")))}}else if(t.hoverData.dragging){if($=!0,K.panningEnabled()&&K.userPanningEnabled()){var _r;if(t.hoverData.justStartedPan){var Wa=t.hoverData.mdownPos;_r={x:(te[0]-Wa[0])*j,y:(te[1]-Wa[1])*j},t.hoverData.justStartedPan=!1}else _r={x:Re[0]*j,y:Re[1]*j};K.panBy(_r),K.emit(Ze("dragpan")),t.hoverData.dragged=!0}te=t.projectIntoViewport(P.clientX,P.clientY)}else if(me[4]==1&&(ce==null||ce.pannable())){if(je){if(!t.hoverData.dragging&&K.boxSelectionEnabled()&&(ft||!K.panningEnabled()||!K.userPanningEnabled()))Xt();else if(!t.hoverData.selecting&&K.panningEnabled()&&K.userPanningEnabled()){var xr=s(ce,t.hoverData.downs);xr&&(t.hoverData.dragging=!0,t.hoverData.justStartedPan=!0,me[4]=0,t.data.bgActivePosistion=Wr(fe),t.redrawHint("select",!0),t.redraw())}ce&&ce.pannable()&&ce.active()&&ce.unactivate()}}else{if(ce&&ce.pannable()&&ce.active()&&ce.unactivate(),(!ce||!ce.grabbed())&&Ae!=Ce&&(Ce&&n(Ce,["mouseout","tapdragout"],P,{x:te[0],y:te[1]}),Ae&&n(Ae,["mouseover","tapdragover"],P,{x:te[0],y:te[1]}),t.hoverData.last=Ae),ce)if(je){if(K.boxSelectionEnabled()&&ft)ce&&ce.grabbed()&&(y(Le),ce.emit(Ze("freeon")),Le.emit(Ze("free")),t.dragData.didDrag&&(ce.emit(Ze("dragfreeon")),Le.emit(Ze("dragfree")))),Xt();else if(ce&&ce.grabbed()&&t.nodeIsDraggable(ce)){var Tt=!t.dragData.didDrag;Tt&&t.redrawHint("eles",!0),t.dragData.didDrag=!0,t.hoverData.draggingEles||p(Le,{inDragLayer:!0});var gt={x:0,y:0};if(ne(Re[0])&&ne(Re[1])&&(gt.x+=Re[0],gt.y+=Re[1],Tt)){var Ct=t.hoverData.dragDelta;Ct&&ne(Ct[0])&&ne(Ct[1])&&(gt.x+=Ct[0],gt.y+=Ct[1])}t.hoverData.draggingEles=!0,Le.silentShift(gt).emit(Ze("position")).emit(Ze("drag")),t.redrawHint("drag",!0),t.redraw()}}else tr();$=!0}if(me[2]=te[0],me[3]=te[1],$)return P.stopPropagation&&P.stopPropagation(),P.preventDefault&&P.preventDefault(),!1}},!1);var L,R,I;t.registerBinding(e,"mouseup",function(P){if(!(t.hoverData.which===1&&P.which!==1&&t.hoverData.capture)){var U=t.hoverData.capture;if(U){t.hoverData.capture=!1;var $=t.cy,K=t.projectIntoViewport(P.clientX,P.clientY),j=t.selection,oe=t.findNearestElement(K[0],K[1],!0,!1),te=t.dragData.possibleDragElements,fe=t.hoverData.down,le=i(P);t.data.bgActivePosistion&&(t.redrawHint("select",!0),t.redraw()),t.hoverData.tapholdCancelled=!0,t.data.bgActivePosistion=void 0,fe&&fe.unactivate();var me=function($e){return{originalEvent:P,type:$e,position:{x:K[0],y:K[1]}}};if(t.hoverData.which===3){var Ae=me("cxttapend");if(fe?fe.emit(Ae):$.emit(Ae),!t.hoverData.cxtDragged){var Ce=me("cxttap");fe?fe.emit(Ce):$.emit(Ce)}t.hoverData.cxtDragged=!1,t.hoverData.which=null}else if(t.hoverData.which===1){if(n(oe,["mouseup","tapend","vmouseup"],P,{x:K[0],y:K[1]}),!t.dragData.didDrag&&!t.hoverData.dragged&&!t.hoverData.selecting&&!t.hoverData.isOverThresholdDrag&&(n(fe,["click","tap","vclick"],P,{x:K[0],y:K[1]}),R=!1,P.timeStamp-I<=$.multiClickDebounceTime()?(L&&clearTimeout(L),R=!0,I=null,n(fe,["dblclick","dbltap","vdblclick"],P,{x:K[0],y:K[1]})):(L=setTimeout(function(){R||n(fe,["oneclick","onetap","voneclick"],P,{x:K[0],y:K[1]})},$.multiClickDebounceTime()),I=P.timeStamp)),fe==null&&!t.dragData.didDrag&&!t.hoverData.selecting&&!t.hoverData.dragged&&!i(P)&&($.$(r).unselect(["tapunselect"]),te.length>0&&t.redrawHint("eles",!0),t.dragData.possibleDragElements=te=$.collection()),oe==fe&&!t.dragData.didDrag&&!t.hoverData.selecting&&oe!=null&&oe._private.selectable&&(t.hoverData.dragging||($.selectionType()==="additive"||le?oe.selected()?oe.unselect(["tapunselect"]):oe.select(["tapselect"]):le||($.$(r).unmerge(oe).unselect(["tapunselect"]),oe.select(["tapselect"]))),t.redrawHint("eles",!0)),t.hoverData.selecting){var ce=$.collection(t.getAllInBox(j[0],j[1],j[2],j[3]));t.redrawHint("select",!0),ce.length>0&&t.redrawHint("eles",!0),$.emit(me("boxend"));var Re=function($e){return $e.selectable()&&!$e.selected()};$.selectionType()==="additive"||le||$.$(r).unmerge(ce).unselect(),ce.emit(me("box")).stdFilter(Re).select().emit(me("boxselect")),t.redraw()}if(t.hoverData.dragging&&(t.hoverData.dragging=!1,t.redrawHint("select",!0),t.redrawHint("eles",!0),t.redraw()),!j[4]){t.redrawHint("drag",!0),t.redrawHint("eles",!0);var Le=fe&&fe.grabbed();y(te),Le&&(fe.emit(me("freeon")),te.emit(me("free")),t.dragData.didDrag&&(fe.emit(me("dragfreeon")),te.emit(me("dragfree"))))}}j[4]=0,t.hoverData.down=null,t.hoverData.cxtStarted=!1,t.hoverData.draggingEles=!1,t.hoverData.selecting=!1,t.hoverData.isOverThresholdDrag=!1,t.dragData.didDrag=!1,t.hoverData.dragged=!1,t.hoverData.dragDelta=[],t.hoverData.mdownPos=null,t.hoverData.mdownGPos=null,t.hoverData.which=null}}},!1);var M=[],N=4,O,k=1e5,B=function(P,U){for(var $=0;$=N){var K=M;if(O=B(K,5),!O){var j=Math.abs(K[0]);O=_(K)&&j>5}if(O)for(var oe=0;oe5&&($=vo($)*5),Ce=$/-250,O&&(Ce/=k,Ce*=3),Ce=Ce*t.wheelSensitivity;var ce=P.deltaMode===1;ce&&(Ce*=33);var Re=te.zoom()*Math.pow(10,Ce);P.type==="gesturechange"&&(Re=t.gestureStartZoom*P.scale),te.zoom({level:Re,renderedPosition:{x:Ae[0],y:Ae[1]}}),te.emit({type:P.type==="gesturechange"?"pinchzoom":"scrollzoom",originalEvent:P,position:{x:me[0],y:me[1]}})}}}};t.registerBinding(t.container,"wheel",F,!0),t.registerBinding(e,"scroll",function(P){t.scrollingPage=!0,clearTimeout(t.scrollingPageTimeout),t.scrollingPageTimeout=setTimeout(function(){t.scrollingPage=!1},250)},!0),t.registerBinding(t.container,"gesturestart",function(P){t.gestureStartZoom=t.cy.zoom(),t.hasTouchStarted||P.preventDefault()},!0),t.registerBinding(t.container,"gesturechange",function(Q){t.hasTouchStarted||F(Q)},!0),t.registerBinding(t.container,"mouseout",function(P){var U=t.projectIntoViewport(P.clientX,P.clientY);t.cy.emit({originalEvent:P,type:"mouseout",position:{x:U[0],y:U[1]}})},!1),t.registerBinding(t.container,"mouseover",function(P){var U=t.projectIntoViewport(P.clientX,P.clientY);t.cy.emit({originalEvent:P,type:"mouseover",position:{x:U[0],y:U[1]}})},!1);var G,H,Y,X,W,ee,ae,J,z,V,q,Z,re,ve=function(P,U,$,K){return Math.sqrt(($-P)*($-P)+(K-U)*(K-U))},Ie=function(P,U,$,K){return($-P)*($-P)+(K-U)*(K-U)},Te;t.registerBinding(t.container,"touchstart",Te=function(P){if(t.hasTouchStarted=!0,!!D(P)){m(),t.touchData.capture=!0,t.data.bgActivePosistion=void 0;var U=t.cy,$=t.touchData.now,K=t.touchData.earlier;if(P.touches[0]){var j=t.projectIntoViewport(P.touches[0].clientX,P.touches[0].clientY);$[0]=j[0],$[1]=j[1]}if(P.touches[1]){var j=t.projectIntoViewport(P.touches[1].clientX,P.touches[1].clientY);$[2]=j[0],$[3]=j[1]}if(P.touches[2]){var j=t.projectIntoViewport(P.touches[2].clientX,P.touches[2].clientY);$[4]=j[0],$[5]=j[1]}var oe=function(ft){return{originalEvent:P,type:ft,position:{x:$[0],y:$[1]}}};if(P.touches[1]){t.touchData.singleTouchMoved=!0,y(t.dragData.touchDragEles);var te=t.findContainerClientCoords();z=te[0],V=te[1],q=te[2],Z=te[3],G=P.touches[0].clientX-z,H=P.touches[0].clientY-V,Y=P.touches[1].clientX-z,X=P.touches[1].clientY-V,re=0<=G&&G<=q&&0<=Y&&Y<=q&&0<=H&&H<=Z&&0<=X&&X<=Z;var fe=U.pan(),le=U.zoom();W=ve(G,H,Y,X),ee=Ie(G,H,Y,X),ae=[(G+Y)/2,(H+X)/2],J=[(ae[0]-fe.x)/le,(ae[1]-fe.y)/le];var me=200,Ae=me*me;if(ee=1){for(var bt=t.touchData.startPosition=[null,null,null,null,null,null],Ke=0;Ke<$.length;Ke++)bt[Ke]=K[Ke]=$[Ke];var st=P.touches[0];t.touchData.startGPosition=[st.clientX,st.clientY]}}},!1);var we;t.registerBinding(e,"touchmove",we=function(P){var U=t.touchData.capture;if(!(!U&&!D(P))){var $=t.selection,K=t.cy,j=t.touchData.now,oe=t.touchData.earlier,te=K.zoom();if(P.touches[0]){var fe=t.projectIntoViewport(P.touches[0].clientX,P.touches[0].clientY);j[0]=fe[0],j[1]=fe[1]}if(P.touches[1]){var fe=t.projectIntoViewport(P.touches[1].clientX,P.touches[1].clientY);j[2]=fe[0],j[3]=fe[1]}if(P.touches[2]){var fe=t.projectIntoViewport(P.touches[2].clientX,P.touches[2].clientY);j[4]=fe[0],j[5]=fe[1]}var le=function(pv){return{originalEvent:P,type:pv,position:{x:j[0],y:j[1]}}},me=t.touchData.startGPosition,Ae;if(U&&P.touches[0]&&me){for(var Ce=[],ce=0;ce=t.touchTapThreshold2}if(U&&t.touchData.cxt){P.preventDefault();var Ke=P.touches[0].clientX-z,st=P.touches[0].clientY-V,et=P.touches[1].clientX-z,ft=P.touches[1].clientY-V,tr=Ie(Ke,st,et,ft),Ze=tr/ee,Xt=150,$t=Xt*Xt,_r=1.5,Wa=_r*_r;if(Ze>=Wa||tr>=$t){t.touchData.cxt=!1,t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);var xr=le("cxttapend");t.touchData.start?(t.touchData.start.unactivate().emit(xr),t.touchData.start=null):K.emit(xr)}}if(U&&t.touchData.cxt){var xr=le("cxtdrag");t.data.bgActivePosistion=void 0,t.redrawHint("select",!0),t.touchData.start?t.touchData.start.emit(xr):K.emit(xr),t.touchData.start&&(t.touchData.start._private.grabbed=!1),t.touchData.cxtDragged=!0;var Tt=t.findNearestElement(j[0],j[1],!0,!0);(!t.touchData.cxtOver||Tt!==t.touchData.cxtOver)&&(t.touchData.cxtOver&&t.touchData.cxtOver.emit(le("cxtdragout")),t.touchData.cxtOver=Tt,Tt&&Tt.emit(le("cxtdragover")))}else if(U&&P.touches[2]&&K.boxSelectionEnabled())P.preventDefault(),t.data.bgActivePosistion=void 0,this.lastThreeTouch=+new Date,t.touchData.selecting||K.emit(le("boxstart")),t.touchData.selecting=!0,t.touchData.didSelect=!0,$[4]=1,!$||$.length===0||$[0]===void 0?($[0]=(j[0]+j[2]+j[4])/3,$[1]=(j[1]+j[3]+j[5])/3,$[2]=(j[0]+j[2]+j[4])/3+1,$[3]=(j[1]+j[3]+j[5])/3+1):($[2]=(j[0]+j[2]+j[4])/3,$[3]=(j[1]+j[3]+j[5])/3),t.redrawHint("select",!0),t.redraw();else if(U&&P.touches[1]&&!t.touchData.didSelect&&K.zoomingEnabled()&&K.panningEnabled()&&K.userZoomingEnabled()&&K.userPanningEnabled()){P.preventDefault(),t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);var gt=t.dragData.touchDragEles;if(gt){t.redrawHint("drag",!0);for(var Ct=0;Ct0&&!t.hoverData.draggingEles&&!t.swipePanning&&t.data.bgActivePosistion!=null&&(t.data.bgActivePosistion=void 0,t.redrawHint("select",!0),t.redraw())}},!1);var ye;t.registerBinding(e,"touchcancel",ye=function(P){var U=t.touchData.start;t.touchData.capture=!1,U&&U.unactivate()});var ie,he,de,xe;if(t.registerBinding(e,"touchend",ie=function(P){var U=t.touchData.start,$=t.touchData.capture;if($)P.touches.length===0&&(t.touchData.capture=!1),P.preventDefault();else return;var K=t.selection;t.swipePanning=!1,t.hoverData.draggingEles=!1;var j=t.cy,oe=j.zoom(),te=t.touchData.now,fe=t.touchData.earlier;if(P.touches[0]){var le=t.projectIntoViewport(P.touches[0].clientX,P.touches[0].clientY);te[0]=le[0],te[1]=le[1]}if(P.touches[1]){var le=t.projectIntoViewport(P.touches[1].clientX,P.touches[1].clientY);te[2]=le[0],te[3]=le[1]}if(P.touches[2]){var le=t.projectIntoViewport(P.touches[2].clientX,P.touches[2].clientY);te[4]=le[0],te[5]=le[1]}var me=function($t){return{originalEvent:P,type:$t,position:{x:te[0],y:te[1]}}};U&&U.unactivate();var Ae;if(t.touchData.cxt){if(Ae=me("cxttapend"),U?U.emit(Ae):j.emit(Ae),!t.touchData.cxtDragged){var Ce=me("cxttap");U?U.emit(Ce):j.emit(Ce)}t.touchData.start&&(t.touchData.start._private.grabbed=!1),t.touchData.cxt=!1,t.touchData.start=null,t.redraw();return}if(!P.touches[2]&&j.boxSelectionEnabled()&&t.touchData.selecting){t.touchData.selecting=!1;var ce=j.collection(t.getAllInBox(K[0],K[1],K[2],K[3]));K[0]=void 0,K[1]=void 0,K[2]=void 0,K[3]=void 0,K[4]=0,t.redrawHint("select",!0),j.emit(me("boxend"));var Re=function($t){return $t.selectable()&&!$t.selected()};ce.emit(me("box")).stdFilter(Re).select().emit(me("boxselect")),ce.nonempty()&&t.redrawHint("eles",!0),t.redraw()}if(U!=null&&U.unactivate(),P.touches[2])t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);else if(!P.touches[1]){if(!P.touches[0]){if(!P.touches[0]){t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);var Le=t.dragData.touchDragEles;if(U!=null){var je=U._private.grabbed;y(Le),t.redrawHint("drag",!0),t.redrawHint("eles",!0),je&&(U.emit(me("freeon")),Le.emit(me("free")),t.dragData.didDrag&&(U.emit(me("dragfreeon")),Le.emit(me("dragfree")))),n(U,["touchend","tapend","vmouseup","tapdragout"],P,{x:te[0],y:te[1]}),U.unactivate(),t.touchData.start=null}else{var $e=t.findNearestElement(te[0],te[1],!0,!0);n($e,["touchend","tapend","vmouseup","tapdragout"],P,{x:te[0],y:te[1]})}var bt=t.touchData.startPosition[0]-te[0],Ke=bt*bt,st=t.touchData.startPosition[1]-te[1],et=st*st,ft=Ke+et,tr=ft*oe*oe;t.touchData.singleTouchMoved||(U||j.$(":selected").unselect(["tapunselect"]),n(U,["tap","vclick"],P,{x:te[0],y:te[1]}),he=!1,P.timeStamp-xe<=j.multiClickDebounceTime()?(de&&clearTimeout(de),he=!0,xe=null,n(U,["dbltap","vdblclick"],P,{x:te[0],y:te[1]})):(de=setTimeout(function(){he||n(U,["onetap","voneclick"],P,{x:te[0],y:te[1]})},j.multiClickDebounceTime()),xe=P.timeStamp)),U!=null&&!t.dragData.didDrag&&U._private.selectable&&tr"u"){var pe=[],De=function(P){return{clientX:P.clientX,clientY:P.clientY,force:1,identifier:P.pointerId,pageX:P.pageX,pageY:P.pageY,radiusX:P.width/2,radiusY:P.height/2,screenX:P.screenX,screenY:P.screenY,target:P.target}},Pe=function(P){return{event:P,touch:De(P)}},Ne=function(P){pe.push(Pe(P))},Be=function(P){for(var U=0;U0)return G[0]}return null},d=Object.keys(v),p=0;p0?h:Nf(i,s,e,r,a,n,o,u)},checkPoint:function(e,r,a,n,i,s,o,u){u=u==="auto"?vr(n,i):u;var l=2*u;if(Jt(e,r,this.points,s,o,n,i-l,[0,-1],a)||Jt(e,r,this.points,s,o,n-l,i,[0,-1],a))return!0;var f=n/2+2*a,c=i/2+2*a,v=[s-f,o-c,s-f,o,s+f,o,s+f,o-c];return!!(St(e,r,v)||Rr(e,r,l,l,s+n/2-u,o+i/2-u,a)||Rr(e,r,l,l,s-n/2+u,o+i/2-u,a))}}};jt.registerNodeShapes=function(){var t=this.nodeShapes={},e=this;this.generateEllipse(),this.generatePolygon("triangle",wt(3,0)),this.generateRoundPolygon("round-triangle",wt(3,0)),this.generatePolygon("rectangle",wt(4,0)),t.square=t.rectangle,this.generateRoundRectangle(),this.generateCutRectangle(),this.generateBarrel(),this.generateBottomRoundrectangle();{var r=[0,1,1,0,0,-1,-1,0];this.generatePolygon("diamond",r),this.generateRoundPolygon("round-diamond",r)}this.generatePolygon("pentagon",wt(5,0)),this.generateRoundPolygon("round-pentagon",wt(5,0)),this.generatePolygon("hexagon",wt(6,0)),this.generateRoundPolygon("round-hexagon",wt(6,0)),this.generatePolygon("heptagon",wt(7,0)),this.generateRoundPolygon("round-heptagon",wt(7,0)),this.generatePolygon("octagon",wt(8,0)),this.generateRoundPolygon("round-octagon",wt(8,0));var a=new Array(20);{var n=Fs(5,0),i=Fs(5,Math.PI/5),s=.5*(3-Math.sqrt(5));s*=1.57;for(var o=0;o=e.deqFastCost*E)break}else if(l){if(b>=e.deqCost*h||b>=e.deqAvgCost*v)break}else if(m>=e.deqNoDrawCost*Ls)break;var T=e.deq(a,g,p);if(T.length>0)for(var S=0;S0&&(e.onDeqd(a,d),!l&&e.shouldRedraw(a,d,g,p)&&i())},o=e.priority||lo;n.beforeRender(s,o(a))}}}},Iy=function(){function t(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Rn;yr(this,t),this.idsByKey=new Zt,this.keyForId=new Zt,this.cachesByLvl=new Zt,this.lvls=[],this.getKey=e,this.doesEleInvalidateKey=r}return mr(t,[{key:"getIdsFor",value:function(r){r==null&&He("Can not get id list for null key");var a=this.idsByKey,n=this.idsByKey.get(r);return n||(n=new na,a.set(r,n)),n}},{key:"addIdForKey",value:function(r,a){r!=null&&this.getIdsFor(r).add(a)}},{key:"deleteIdForKey",value:function(r,a){r!=null&&this.getIdsFor(r).delete(a)}},{key:"getNumberOfIdsForKey",value:function(r){return r==null?0:this.getIdsFor(r).size}},{key:"updateKeyMappingFor",value:function(r){var a=r.id(),n=this.keyForId.get(a),i=this.getKey(r);this.deleteIdForKey(n,a),this.addIdForKey(i,a),this.keyForId.set(a,i)}},{key:"deleteKeyMappingFor",value:function(r){var a=r.id(),n=this.keyForId.get(a);this.deleteIdForKey(n,a),this.keyForId.delete(a)}},{key:"keyHasChangedFor",value:function(r){var a=r.id(),n=this.keyForId.get(a),i=this.getKey(r);return n!==i}},{key:"isInvalid",value:function(r){return this.keyHasChangedFor(r)||this.doesEleInvalidateKey(r)}},{key:"getCachesAt",value:function(r){var a=this.cachesByLvl,n=this.lvls,i=a.get(r);return i||(i=new Zt,a.set(r,i),n.push(r)),i}},{key:"getCache",value:function(r,a){return this.getCachesAt(a).get(r)}},{key:"get",value:function(r,a){var n=this.getKey(r),i=this.getCache(n,a);return i!=null&&this.updateKeyMappingFor(r),i}},{key:"getForCachedKey",value:function(r,a){var n=this.keyForId.get(r.id()),i=this.getCache(n,a);return i}},{key:"hasCache",value:function(r,a){return this.getCachesAt(a).has(r)}},{key:"has",value:function(r,a){var n=this.getKey(r);return this.hasCache(n,a)}},{key:"setCache",value:function(r,a,n){n.key=r,this.getCachesAt(a).set(r,n)}},{key:"set",value:function(r,a,n){var i=this.getKey(r);this.setCache(i,a,n),this.updateKeyMappingFor(r)}},{key:"deleteCache",value:function(r,a){this.getCachesAt(a).delete(r)}},{key:"delete",value:function(r,a){var n=this.getKey(r);this.deleteCache(n,a)}},{key:"invalidateKey",value:function(r){var a=this;this.lvls.forEach(function(n){return a.deleteCache(r,n)})}},{key:"invalidate",value:function(r){var a=r.id(),n=this.keyForId.get(a);this.deleteKeyMappingFor(r);var i=this.doesEleInvalidateKey(r);return i&&this.invalidateKey(n),i||this.getNumberOfIdsForKey(n)===0}}])}(),$l=25,un=50,bn=-4,Qs=3,Gc=7.99,Py=8,My=1024,Oy=1024,ky=1024,Ny=.2,By=.8,Fy=10,_y=.15,Gy=.1,zy=.9,Vy=.9,Uy=100,qy=1,Zr={dequeue:"dequeue",downscale:"downscale",highQuality:"highQuality"},Yy=ht({getKey:null,doesEleInvalidateKey:Rn,drawElement:null,getBoundingBox:null,getRotationPoint:null,getRotationOffset:null,isVisible:Lf,allowEdgeTxrCaching:!0,allowParentTxrCaching:!0}),xa=function(e,r){var a=this;a.renderer=e,a.onDequeues=[];var n=Yy(r);be(a,n),a.lookup=new Iy(n.getKey,n.doesEleInvalidateKey),a.setupDequeueing()},it=xa.prototype;it.reasons=Zr;it.getTextureQueue=function(t){var e=this;return e.eleImgCaches=e.eleImgCaches||{},e.eleImgCaches[t]=e.eleImgCaches[t]||[]};it.getRetiredTextureQueue=function(t){var e=this,r=e.eleImgCaches.retired=e.eleImgCaches.retired||{},a=r[t]=r[t]||[];return a};it.getElementQueue=function(){var t=this,e=t.eleCacheQueue=t.eleCacheQueue||new Ua(function(r,a){return a.reqs-r.reqs});return e};it.getElementKeyToQueue=function(){var t=this,e=t.eleKeyToCacheQueue=t.eleKeyToCacheQueue||{};return e};it.getElement=function(t,e,r,a,n){var i=this,s=this.renderer,o=s.cy.zoom(),u=this.lookup;if(!e||e.w===0||e.h===0||isNaN(e.w)||isNaN(e.h)||!t.visible()||t.removed()||!i.allowEdgeTxrCaching&&t.isEdge()||!i.allowParentTxrCaching&&t.isParent())return null;if(a==null&&(a=Math.ceil(co(o*r))),a=Gc||a>Qs)return null;var l=Math.pow(2,a),f=e.h*l,c=e.w*l,v=s.eleTextBiggerThanMin(t,l);if(!this.isVisible(t,v))return null;var h=u.get(t,a);if(h&&h.invalidated&&(h.invalidated=!1,h.texture.invalidatedWidth-=h.width),h)return h;var d;if(f<=$l?d=$l:f<=un?d=un:d=Math.ceil(f/un)*un,f>ky||c>Oy)return null;var p=i.getTextureQueue(d),g=p[p.length-2],y=function(){return i.recycleTexture(d,c)||i.addTexture(d,c)};g||(g=p[p.length-1]),g||(g=y()),g.width-g.usedWidtha;A--)C=i.getElement(t,e,r,A,Zr.downscale);D()}else return i.queueElement(t,S.level-1),S;else{var L;if(!m&&!E&&!T)for(var R=a-1;R>=bn;R--){var I=u.get(t,R);if(I){L=I;break}}if(b(L))return i.queueElement(t,a),L;g.context.translate(g.usedWidth,0),g.context.scale(l,l),this.drawElement(g.context,t,e,v,!1),g.context.scale(1/l,1/l),g.context.translate(-g.usedWidth,0)}return h={x:g.usedWidth,texture:g,level:a,scale:l,width:c,height:f,scaledLabelShown:v},g.usedWidth+=Math.ceil(c+Py),g.eleCaches.push(h),u.set(t,a,h),i.checkTextureFullness(g),h};it.invalidateElements=function(t){for(var e=0;e=Ny*t.width&&this.retireTexture(t)};it.checkTextureFullness=function(t){var e=this,r=e.getTextureQueue(t.height);t.usedWidth/t.width>By&&t.fullnessChecks>=Fy?cr(r,t):t.fullnessChecks++};it.retireTexture=function(t){var e=this,r=t.height,a=e.getTextureQueue(r),n=this.lookup;cr(a,t),t.retired=!0;for(var i=t.eleCaches,s=0;s=e)return s.retired=!1,s.usedWidth=0,s.invalidatedWidth=0,s.fullnessChecks=0,fo(s.eleCaches),s.context.setTransform(1,0,0,1,0,0),s.context.clearRect(0,0,s.width,s.height),cr(n,s),a.push(s),s}};it.queueElement=function(t,e){var r=this,a=r.getElementQueue(),n=r.getElementKeyToQueue(),i=this.getKey(t),s=n[i];if(s)s.level=Math.max(s.level,e),s.eles.merge(t),s.reqs++,a.updateItem(s);else{var o={eles:t.spawn().merge(t),level:e,reqs:1,key:i};a.push(o),n[i]=o}};it.dequeue=function(t){for(var e=this,r=e.getElementQueue(),a=e.getElementKeyToQueue(),n=[],i=e.lookup,s=0;s0;s++){var o=r.pop(),u=o.key,l=o.eles[0],f=i.hasCache(l,o.level);if(a[u]=null,f)continue;n.push(o);var c=e.getBoundingBox(l);e.getElement(l,c,t,o.level,Zr.dequeue)}return n};it.removeFromQueue=function(t){var e=this,r=e.getElementQueue(),a=e.getElementKeyToQueue(),n=this.getKey(t),i=a[n];i!=null&&(i.eles.length===1?(i.reqs=uo,r.updateItem(i),r.pop(),a[n]=null):i.eles.unmerge(t))};it.onDequeue=function(t){this.onDequeues.push(t)};it.offDequeue=function(t){cr(this.onDequeues,t)};it.setupDequeueing=_c.setupDequeueing({deqRedrawThreshold:Uy,deqCost:_y,deqAvgCost:Gy,deqNoDrawCost:zy,deqFastCost:Vy,deq:function(e,r,a){return e.dequeue(r,a)},onDeqd:function(e,r){for(var a=0;a=Xy||r>Fn)return null}a.validateLayersElesOrdering(r,t);var u=a.layersByLevel,l=Math.pow(2,r),f=u[r]=u[r]||[],c,v=a.levelIsComplete(r,t),h,d=function(){var D=function(M){if(a.validateLayersElesOrdering(M,t),a.levelIsComplete(M,t))return h=u[M],!0},A=function(M){if(!h)for(var N=r+M;Ca<=N&&N<=Fn&&!D(N);N+=M);};A(1),A(-1);for(var L=f.length-1;L>=0;L--){var R=f[L];R.invalid&&cr(f,R)}};if(!v)d();else return f;var p=function(){if(!c){c=Et();for(var D=0;DKl||R>Kl)return null;var I=L*R;if(I>em)return null;var M=a.makeLayer(c,r);if(A!=null){var N=f.indexOf(A)+1;f.splice(N,0,M)}else(D.insert===void 0||D.insert)&&f.unshift(M);return M};if(a.skipping&&!o)return null;for(var y=null,b=t.length/Hy,m=!o,E=0;E=b||!kf(y.bb,T.boundingBox()))&&(y=g({insert:!0,after:y}),!y))return null;h||m?a.queueLayer(y,T):a.drawEleInLayer(y,T,r,e),y.eles.push(T),w[r]=y}return h||(m?null:f)};dt.getEleLevelForLayerLevel=function(t,e){return t};dt.drawEleInLayer=function(t,e,r,a){var n=this,i=this.renderer,s=t.context,o=e.boundingBox();o.w===0||o.h===0||!e.visible()||(r=n.getEleLevelForLayerLevel(r,a),i.setImgSmoothing(s,!1),i.drawCachedElement(s,e,null,null,r,tm),i.setImgSmoothing(s,!0))};dt.levelIsComplete=function(t,e){var r=this,a=r.layersByLevel[t];if(!a||a.length===0)return!1;for(var n=0,i=0;i0||s.invalid)return!1;n+=s.eles.length}return n===e.length};dt.validateLayersElesOrdering=function(t,e){var r=this.layersByLevel[t];if(r)for(var a=0;a0){e=!0;break}}return e};dt.invalidateElements=function(t){var e=this;t.length!==0&&(e.lastInvalidationTime=Qt(),!(t.length===0||!e.haveLayers())&&e.updateElementsInLayers(t,function(a,n,i){e.invalidateLayer(a)}))};dt.invalidateLayer=function(t){if(this.lastInvalidationTime=Qt(),!t.invalid){var e=t.level,r=t.eles,a=this.layersByLevel[e];cr(a,t),t.elesQueue=[],t.invalid=!0,t.replacement&&(t.replacement.invalid=!0);for(var n=0;n3&&arguments[3]!==void 0?arguments[3]:!0,n=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0,s=this,o=e._private.rscratch;if(!(i&&!e.visible())&&!(o.badLine||o.allpts==null||isNaN(o.allpts[0]))){var u;r&&(u=r,t.translate(-u.x1,-u.y1));var l=i?e.pstyle("opacity").value:1,f=i?e.pstyle("line-opacity").value:1,c=e.pstyle("curve-style").value,v=e.pstyle("line-style").value,h=e.pstyle("width").pfValue,d=e.pstyle("line-cap").value,p=e.pstyle("line-outline-width").value,g=e.pstyle("line-outline-color").value,y=l*f,b=l*f,m=function(){var M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:y;c==="straight-triangle"?(s.eleStrokeStyle(t,e,M),s.drawEdgeTrianglePath(e,t,o.allpts)):(t.lineWidth=h,t.lineCap=d,s.eleStrokeStyle(t,e,M),s.drawEdgePath(e,t,o.allpts,v),t.lineCap="butt")},E=function(){var M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:y;if(t.lineWidth=h+p,t.lineCap=d,p>0)s.colorStrokeStyle(t,g[0],g[1],g[2],M);else{t.lineCap="butt";return}c==="straight-triangle"?s.drawEdgeTrianglePath(e,t,o.allpts):(s.drawEdgePath(e,t,o.allpts,v),t.lineCap="butt")},T=function(){n&&s.drawEdgeOverlay(t,e)},S=function(){n&&s.drawEdgeUnderlay(t,e)},w=function(){var M=arguments.length>0&&arguments[0]!==void 0?arguments[0]:b;s.drawArrowheads(t,e,M)},x=function(){s.drawElementText(t,e,null,a)};t.lineJoin="round";var C=e.pstyle("ghost").value==="yes";if(C){var D=e.pstyle("ghost-offset-x").pfValue,A=e.pstyle("ghost-offset-y").pfValue,L=e.pstyle("ghost-opacity").value,R=y*L;t.translate(D,A),m(R),w(R),t.translate(-D,-A)}else E();S(),m(),w(),T(),x(),r&&t.translate(u.x1,u.y1)}};var Uc=function(e){if(!["overlay","underlay"].includes(e))throw new Error("Invalid state");return function(r,a){if(a.visible()){var n=a.pstyle("".concat(e,"-opacity")).value;if(n!==0){var i=this,s=i.usePaths(),o=a._private.rscratch,u=a.pstyle("".concat(e,"-padding")).pfValue,l=2*u,f=a.pstyle("".concat(e,"-color")).value;r.lineWidth=l,o.edgeType==="self"&&!s?r.lineCap="butt":r.lineCap="round",i.colorStrokeStyle(r,f[0],f[1],f[2],n),i.drawEdgePath(a,r,o.allpts,"solid")}}}};er.drawEdgeOverlay=Uc("overlay");er.drawEdgeUnderlay=Uc("underlay");er.drawEdgePath=function(t,e,r,a){var n=t._private.rscratch,i=e,s,o=!1,u=this.usePaths(),l=t.pstyle("line-dash-pattern").pfValue,f=t.pstyle("line-dash-offset").pfValue;if(u){var c=r.join("$"),v=n.pathCacheKey&&n.pathCacheKey===c;v?(s=e=n.pathCache,o=!0):(s=e=new Path2D,n.pathCacheKey=c,n.pathCache=s)}if(i.setLineDash)switch(a){case"dotted":i.setLineDash([1,1]);break;case"dashed":i.setLineDash(l),i.lineDashOffset=f;break;case"solid":i.setLineDash([]);break}if(!o&&!n.badLine)switch(e.beginPath&&e.beginPath(),e.moveTo(r[0],r[1]),n.edgeType){case"bezier":case"self":case"compound":case"multibezier":for(var h=2;h+35&&arguments[5]!==void 0?arguments[5]:!0,s=this;if(a==null){if(i&&!s.eleTextBiggerThanMin(e))return}else if(a===!1)return;if(e.isNode()){var o=e.pstyle("label");if(!o||!o.value)return;var u=s.getLabelJustification(e);t.textAlign=u,t.textBaseline="bottom"}else{var l=e.element()._private.rscratch.badLine,f=e.pstyle("label"),c=e.pstyle("source-label"),v=e.pstyle("target-label");if(l||(!f||!f.value)&&(!c||!c.value)&&(!v||!v.value))return;t.textAlign="center",t.textBaseline="bottom"}var h=!r,d;r&&(d=r,t.translate(-d.x1,-d.y1)),n==null?(s.drawText(t,e,null,h,i),e.isEdge()&&(s.drawText(t,e,"source",h,i),s.drawText(t,e,"target",h,i))):s.drawText(t,e,n,h,i),r&&t.translate(d.x1,d.y1)};Fr.getFontCache=function(t){var e;this.fontCaches=this.fontCaches||[];for(var r=0;r2&&arguments[2]!==void 0?arguments[2]:!0,a=e.pstyle("font-style").strValue,n=e.pstyle("font-size").pfValue+"px",i=e.pstyle("font-family").strValue,s=e.pstyle("font-weight").strValue,o=r?e.effectiveOpacity()*e.pstyle("text-opacity").value:1,u=e.pstyle("text-outline-opacity").value*o,l=e.pstyle("color").value,f=e.pstyle("text-outline-color").value;t.font=a+" "+s+" "+n+" "+i,t.lineJoin="round",this.colorFillStyle(t,l[0],l[1],l[2],o),this.colorStrokeStyle(t,f[0],f[1],f[2],u)};function vm(t,e,r,a,n){var i=Math.min(a,n),s=i/2,o=e+a/2,u=r+n/2;t.beginPath(),t.arc(o,u,s,0,Math.PI*2),t.closePath()}function jl(t,e,r,a,n){var i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:5,s=Math.min(i,a/2,n/2);t.beginPath(),t.moveTo(e+s,r),t.lineTo(e+a-s,r),t.quadraticCurveTo(e+a,r,e+a,r+s),t.lineTo(e+a,r+n-s),t.quadraticCurveTo(e+a,r+n,e+a-s,r+n),t.lineTo(e+s,r+n),t.quadraticCurveTo(e,r+n,e,r+n-s),t.lineTo(e,r+s),t.quadraticCurveTo(e,r,e+s,r),t.closePath()}Fr.getTextAngle=function(t,e){var r,a=t._private,n=a.rscratch,i=e?e+"-":"",s=t.pstyle(i+"text-rotation");if(s.strValue==="autorotate"){var o=Dt(n,"labelAngle",e);r=t.isEdge()?o:0}else s.strValue==="none"?r=0:r=s.pfValue;return r};Fr.drawText=function(t,e,r){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,n=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,i=e._private,s=i.rscratch,o=n?e.effectiveOpacity():1;if(!(n&&(o===0||e.pstyle("text-opacity").value===0))){r==="main"&&(r=null);var u=Dt(s,"labelX",r),l=Dt(s,"labelY",r),f,c,v=this.getLabelText(e,r);if(v!=null&&v!==""&&!isNaN(u)&&!isNaN(l)){this.setupTextStyle(t,e,n);var h=r?r+"-":"",d=Dt(s,"labelWidth",r),p=Dt(s,"labelHeight",r),g=e.pstyle(h+"text-margin-x").pfValue,y=e.pstyle(h+"text-margin-y").pfValue,b=e.isEdge(),m=e.pstyle("text-halign").value,E=e.pstyle("text-valign").value;b&&(m="center",E="center"),u+=g,l+=y;var T;switch(a?T=this.getTextAngle(e,r):T=0,T!==0&&(f=u,c=l,t.translate(f,c),t.rotate(T),u=0,l=0),E){case"top":break;case"center":l+=p/2;break;case"bottom":l+=p;break}var S=e.pstyle("text-background-opacity").value,w=e.pstyle("text-border-opacity").value,x=e.pstyle("text-border-width").pfValue,C=e.pstyle("text-background-padding").pfValue,D=e.pstyle("text-background-shape").strValue,A=D==="round-rectangle"||D==="roundrectangle",L=D==="circle",R=2;if(S>0||x>0&&w>0){var I=t.fillStyle,M=t.strokeStyle,N=t.lineWidth,O=e.pstyle("text-background-color").value,k=e.pstyle("text-border-color").value,B=e.pstyle("text-border-style").value,_=S>0,F=x>0&&w>0,G=u-C;switch(m){case"left":G-=d;break;case"center":G-=d/2;break}var H=l-p-C,Y=d+2*C,X=p+2*C;if(_&&(t.fillStyle="rgba(".concat(O[0],",").concat(O[1],",").concat(O[2],",").concat(S*o,")")),F&&(t.strokeStyle="rgba(".concat(k[0],",").concat(k[1],",").concat(k[2],",").concat(w*o,")"),t.lineWidth=x,t.setLineDash))switch(B){case"dotted":t.setLineDash([1,1]);break;case"dashed":t.setLineDash([4,2]);break;case"double":t.lineWidth=x/4,t.setLineDash([]);break;case"solid":default:t.setLineDash([]);break}if(A?(t.beginPath(),jl(t,G,H,Y,X,R)):L?(t.beginPath(),vm(t,G,H,Y,X)):(t.beginPath(),t.rect(G,H,Y,X)),_&&t.fill(),F&&t.stroke(),F&&B==="double"){var W=x/2;t.beginPath(),A?jl(t,G+W,H+W,Y-2*W,X-2*W,R):t.rect(G+W,H+W,Y-2*W,X-2*W),t.stroke()}t.fillStyle=I,t.strokeStyle=M,t.lineWidth=N,t.setLineDash&&t.setLineDash([])}var ee=2*e.pstyle("text-outline-width").pfValue;if(ee>0&&(t.lineWidth=ee),e.pstyle("text-wrap").value==="wrap"){var ae=Dt(s,"labelWrapCachedLines",r),J=Dt(s,"labelLineHeight",r),z=d/2,V=this.getLabelJustification(e);switch(V==="auto"||(m==="left"?V==="left"?u+=-d:V==="center"&&(u+=-z):m==="center"?V==="left"?u+=-z:V==="right"&&(u+=z):m==="right"&&(V==="center"?u+=z:V==="right"&&(u+=d))),E){case"top":l-=(ae.length-1)*J;break;case"center":case"bottom":l-=(ae.length-1)*J;break}for(var q=0;q0&&t.strokeText(ae[q],u,l),t.fillText(ae[q],u,l),l+=J}else ee>0&&t.strokeText(v,u,l),t.fillText(v,u,l);T!==0&&(t.rotate(-T),t.translate(-f,-c))}}};var wr={};wr.drawNode=function(t,e,r){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,n=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0,s=this,o,u,l=e._private,f=l.rscratch,c=e.position();if(!(!ne(c.x)||!ne(c.y))&&!(i&&!e.visible())){var v=i?e.effectiveOpacity():1,h=s.usePaths(),d,p=!1,g=e.padding();o=e.width()+2*g,u=e.height()+2*g;var y;r&&(y=r,t.translate(-y.x1,-y.y1));for(var b=e.pstyle("background-image"),m=b.value,E=new Array(m.length),T=new Array(m.length),S=0,w=0;w0&&arguments[0]!==void 0?arguments[0]:R;s.eleFillStyle(t,e,ue)},J=function(){var ue=arguments.length>0&&arguments[0]!==void 0?arguments[0]:F;s.colorStrokeStyle(t,I[0],I[1],I[2],ue)},z=function(){var ue=arguments.length>0&&arguments[0]!==void 0?arguments[0]:X;s.colorStrokeStyle(t,H[0],H[1],H[2],ue)},V=function(ue,Q,P,U){var $=s.nodePathCache=s.nodePathCache||[],K=Af(P==="polygon"?P+","+U.join(","):P,""+Q,""+ue,""+ee),j=$[K],oe,te=!1;return j!=null?(oe=j,te=!0,f.pathCache=oe):(oe=new Path2D,$[K]=f.pathCache=oe),{path:oe,cacheHit:te}},q=e.pstyle("shape").strValue,Z=e.pstyle("shape-polygon-points").pfValue;if(h){t.translate(c.x,c.y);var re=V(o,u,q,Z);d=re.path,p=re.cacheHit}var ve=function(){if(!p){var ue=c;h&&(ue={x:0,y:0}),s.nodeShapes[s.getNodeShape(e)].draw(d||t,ue.x,ue.y,o,u,ee,f)}h?t.fill(d):t.fill()},Ie=function(){for(var ue=arguments.length>0&&arguments[0]!==void 0?arguments[0]:v,Q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,P=l.backgrounding,U=0,$=0;$0&&arguments[0]!==void 0?arguments[0]:!1,Q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:v;s.hasPie(e)&&(s.drawPie(t,e,Q),ue&&(h||s.nodeShapes[s.getNodeShape(e)].draw(t,c.x,c.y,o,u,ee,f)))},we=function(){var ue=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,Q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:v;s.hasStripe(e)&&(t.save(),h?t.clip(f.pathCache):(s.nodeShapes[s.getNodeShape(e)].draw(t,c.x,c.y,o,u,ee,f),t.clip()),s.drawStripe(t,e,Q),t.restore(),ue&&(h||s.nodeShapes[s.getNodeShape(e)].draw(t,c.x,c.y,o,u,ee,f)))},ye=function(){var ue=arguments.length>0&&arguments[0]!==void 0?arguments[0]:v,Q=(A>0?A:-A)*ue,P=A>0?0:255;A!==0&&(s.colorFillStyle(t,P,P,P,Q),h?t.fill(d):t.fill())},ie=function(){if(L>0){if(t.lineWidth=L,t.lineCap=O,t.lineJoin=N,t.setLineDash)switch(M){case"dotted":t.setLineDash([1,1]);break;case"dashed":t.setLineDash(B),t.lineDashOffset=_;break;case"solid":case"double":t.setLineDash([]);break}if(k!=="center"){if(t.save(),t.lineWidth*=2,k==="inside")h?t.clip(d):t.clip();else{var ue=new Path2D;ue.rect(-o/2-L,-u/2-L,o+2*L,u+2*L),ue.addPath(d),t.clip(ue,"evenodd")}h?t.stroke(d):t.stroke(),t.restore()}else h?t.stroke(d):t.stroke();if(M==="double"){t.lineWidth=L/3;var Q=t.globalCompositeOperation;t.globalCompositeOperation="destination-out",h?t.stroke(d):t.stroke(),t.globalCompositeOperation=Q}t.setLineDash&&t.setLineDash([])}},he=function(){if(G>0){if(t.lineWidth=G,t.lineCap="butt",t.setLineDash)switch(Y){case"dotted":t.setLineDash([1,1]);break;case"dashed":t.setLineDash([4,2]);break;case"solid":case"double":t.setLineDash([]);break}var ue=c;h&&(ue={x:0,y:0});var Q=s.getNodeShape(e),P=L;k==="inside"&&(P=0),k==="outside"&&(P*=2);var U=(o+P+(G+W))/o,$=(u+P+(G+W))/u,K=o*U,j=u*$,oe=s.nodeShapes[Q].points,te;if(h){var fe=V(K,j,Q,oe);te=fe.path}if(Q==="ellipse")s.drawEllipsePath(te||t,ue.x,ue.y,K,j);else if(["round-diamond","round-heptagon","round-hexagon","round-octagon","round-pentagon","round-polygon","round-triangle","round-tag"].includes(Q)){var le=0,me=0,Ae=0;Q==="round-diamond"?le=(P+W+G)*1.4:Q==="round-heptagon"?(le=(P+W+G)*1.075,Ae=-(P/2+W+G)/35):Q==="round-hexagon"?le=(P+W+G)*1.12:Q==="round-pentagon"?(le=(P+W+G)*1.13,Ae=-(P/2+W+G)/15):Q==="round-tag"?(le=(P+W+G)*1.12,me=(P/2+G+W)*.07):Q==="round-triangle"&&(le=(P+W+G)*(Math.PI/2),Ae=-(P+W/2+G)/Math.PI),le!==0&&(U=(o+le)/o,K=o*U,["round-hexagon","round-tag"].includes(Q)||($=(u+le)/u,j=u*$)),ee=ee==="auto"?Ff(K,j):ee;for(var Ce=K/2,ce=j/2,Re=ee+(P+G+W)/2,Le=new Array(oe.length/2),je=new Array(oe.length/2),$e=0;$e0){if(n=n||a.position(),i==null||s==null){var h=a.padding();i=a.width()+2*h,s=a.height()+2*h}o.colorFillStyle(r,f[0],f[1],f[2],l),o.nodeShapes[c].draw(r,n.x,n.y,i+u*2,s+u*2,v),r.fill()}}}};wr.drawNodeOverlay=qc("overlay");wr.drawNodeUnderlay=qc("underlay");wr.hasPie=function(t){return t=t[0],t._private.hasPie};wr.hasStripe=function(t){return t=t[0],t._private.hasStripe};wr.drawPie=function(t,e,r,a){e=e[0],a=a||e.position();var n=e.cy().style(),i=e.pstyle("pie-size"),s=e.pstyle("pie-hole"),o=e.pstyle("pie-start-angle").pfValue,u=a.x,l=a.y,f=e.width(),c=e.height(),v=Math.min(f,c)/2,h,d=0,p=this.usePaths();if(p&&(u=0,l=0),i.units==="%"?v=v*i.pfValue:i.pfValue!==void 0&&(v=i.pfValue/2),s.units==="%"?h=v*s.pfValue:s.pfValue!==void 0&&(h=s.pfValue/2),!(h>=v))for(var g=1;g<=n.pieBackgroundN;g++){var y=e.pstyle("pie-"+g+"-background-size").value,b=e.pstyle("pie-"+g+"-background-color").value,m=e.pstyle("pie-"+g+"-background-opacity").value*r,E=y/100;E+d>1&&(E=1-d);var T=1.5*Math.PI+2*Math.PI*d;T+=o;var S=2*Math.PI*E,w=T+S;y===0||d>=1||d+E>1||(h===0?(t.beginPath(),t.moveTo(u,l),t.arc(u,l,v,T,w),t.closePath()):(t.beginPath(),t.arc(u,l,v,T,w),t.arc(u,l,h,w,T,!0),t.closePath()),this.colorFillStyle(t,b[0],b[1],b[2],m),t.fill(),d+=E)}};wr.drawStripe=function(t,e,r,a){e=e[0],a=a||e.position();var n=e.cy().style(),i=a.x,s=a.y,o=e.width(),u=e.height(),l=0,f=this.usePaths();t.save();var c=e.pstyle("stripe-direction").value,v=e.pstyle("stripe-size");switch(c){case"vertical":break;case"righward":t.rotate(-Math.PI/2);break}var h=o,d=u;v.units==="%"?(h=h*v.pfValue,d=d*v.pfValue):v.pfValue!==void 0&&(h=v.pfValue,d=v.pfValue),f&&(i=0,s=0),s-=h/2,i-=d/2;for(var p=1;p<=n.stripeBackgroundN;p++){var g=e.pstyle("stripe-"+p+"-background-size").value,y=e.pstyle("stripe-"+p+"-background-color").value,b=e.pstyle("stripe-"+p+"-background-opacity").value*r,m=g/100;m+l>1&&(m=1-l),!(g===0||l>=1||l+m>1)&&(t.beginPath(),t.rect(i,s+d*l,h,d*m),t.closePath(),this.colorFillStyle(t,y[0],y[1],y[2],b),t.fill(),l+=m)}t.restore()};var xt={},hm=100;xt.getPixelRatio=function(){var t=this.data.contexts[0];if(this.forcedPixelRatio!=null)return this.forcedPixelRatio;var e=this.cy.window(),r=t.backingStorePixelRatio||t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1;return(e.devicePixelRatio||1)/r};xt.paintCache=function(t){for(var e=this.paintCaches=this.paintCaches||[],r=!0,a,n=0;ne.minMbLowQualFrames&&(e.motionBlurPxRatio=e.mbPxRBlurry)),e.clearingMotionBlur&&(e.motionBlurPxRatio=1),e.textureDrawLastFrame&&!c&&(f[e.NODE]=!0,f[e.SELECT_BOX]=!0);var b=r.style(),m=r.zoom(),E=s!==void 0?s:m,T=r.pan(),S={x:T.x,y:T.y},w={zoom:m,pan:{x:T.x,y:T.y}},x=e.prevViewport,C=x===void 0||w.zoom!==x.zoom||w.pan.x!==x.pan.x||w.pan.y!==x.pan.y;!C&&!(p&&!d)&&(e.motionBlurPxRatio=1),o&&(S=o),E*=u,S.x*=u,S.y*=u;var D=e.getCachedZSortedEles();function A(J,z,V,q,Z){var re=J.globalCompositeOperation;J.globalCompositeOperation="destination-out",e.colorFillStyle(J,255,255,255,e.motionBlurTransparency),J.fillRect(z,V,q,Z),J.globalCompositeOperation=re}function L(J,z){var V,q,Z,re;!e.clearingMotionBlur&&(J===l.bufferContexts[e.MOTIONBLUR_BUFFER_NODE]||J===l.bufferContexts[e.MOTIONBLUR_BUFFER_DRAG])?(V={x:T.x*h,y:T.y*h},q=m*h,Z=e.canvasWidth*h,re=e.canvasHeight*h):(V=S,q=E,Z=e.canvasWidth,re=e.canvasHeight),J.setTransform(1,0,0,1,0,0),z==="motionBlur"?A(J,0,0,Z,re):!a&&(z===void 0||z)&&J.clearRect(0,0,Z,re),n||(J.translate(V.x,V.y),J.scale(q,q)),o&&J.translate(o.x,o.y),s&&J.scale(s,s)}if(c||(e.textureDrawLastFrame=!1),c){if(e.textureDrawLastFrame=!0,!e.textureCache){e.textureCache={},e.textureCache.bb=r.mutableElements().boundingBox(),e.textureCache.texture=e.data.bufferCanvases[e.TEXTURE_BUFFER];var R=e.data.bufferContexts[e.TEXTURE_BUFFER];R.setTransform(1,0,0,1,0,0),R.clearRect(0,0,e.canvasWidth*e.textureMult,e.canvasHeight*e.textureMult),e.render({forcedContext:R,drawOnlyNodeLayer:!0,forcedPxRatio:u*e.textureMult});var w=e.textureCache.viewport={zoom:r.zoom(),pan:r.pan(),width:e.canvasWidth,height:e.canvasHeight};w.mpan={x:(0-w.pan.x)/w.zoom,y:(0-w.pan.y)/w.zoom}}f[e.DRAG]=!1,f[e.NODE]=!1;var I=l.contexts[e.NODE],M=e.textureCache.texture,w=e.textureCache.viewport;I.setTransform(1,0,0,1,0,0),v?A(I,0,0,w.width,w.height):I.clearRect(0,0,w.width,w.height);var N=b.core("outside-texture-bg-color").value,O=b.core("outside-texture-bg-opacity").value;e.colorFillStyle(I,N[0],N[1],N[2],O),I.fillRect(0,0,w.width,w.height);var m=r.zoom();L(I,!1),I.clearRect(w.mpan.x,w.mpan.y,w.width/w.zoom/u,w.height/w.zoom/u),I.drawImage(M,w.mpan.x,w.mpan.y,w.width/w.zoom/u,w.height/w.zoom/u)}else e.textureOnViewport&&!a&&(e.textureCache=null);var k=r.extent(),B=e.pinching||e.hoverData.dragging||e.swipePanning||e.data.wheelZooming||e.hoverData.draggingEles||e.cy.animated(),_=e.hideEdgesOnViewport&&B,F=[];if(F[e.NODE]=!f[e.NODE]&&v&&!e.clearedForMotionBlur[e.NODE]||e.clearingMotionBlur,F[e.NODE]&&(e.clearedForMotionBlur[e.NODE]=!0),F[e.DRAG]=!f[e.DRAG]&&v&&!e.clearedForMotionBlur[e.DRAG]||e.clearingMotionBlur,F[e.DRAG]&&(e.clearedForMotionBlur[e.DRAG]=!0),f[e.NODE]||n||i||F[e.NODE]){var G=v&&!F[e.NODE]&&h!==1,I=a||(G?e.data.bufferContexts[e.MOTIONBLUR_BUFFER_NODE]:l.contexts[e.NODE]),H=v&&!G?"motionBlur":void 0;L(I,H),_?e.drawCachedNodes(I,D.nondrag,u,k):e.drawLayeredElements(I,D.nondrag,u,k),e.debug&&e.drawDebugPoints(I,D.nondrag),!n&&!v&&(f[e.NODE]=!1)}if(!i&&(f[e.DRAG]||n||F[e.DRAG])){var G=v&&!F[e.DRAG]&&h!==1,I=a||(G?e.data.bufferContexts[e.MOTIONBLUR_BUFFER_DRAG]:l.contexts[e.DRAG]);L(I,v&&!G?"motionBlur":void 0),_?e.drawCachedNodes(I,D.drag,u,k):e.drawCachedElements(I,D.drag,u,k),e.debug&&e.drawDebugPoints(I,D.drag),!n&&!v&&(f[e.DRAG]=!1)}if(this.drawSelectionRectangle(t,L),v&&h!==1){var Y=l.contexts[e.NODE],X=e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_NODE],W=l.contexts[e.DRAG],ee=e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_DRAG],ae=function(z,V,q){z.setTransform(1,0,0,1,0,0),q||!y?z.clearRect(0,0,e.canvasWidth,e.canvasHeight):A(z,0,0,e.canvasWidth,e.canvasHeight);var Z=h;z.drawImage(V,0,0,e.canvasWidth*Z,e.canvasHeight*Z,0,0,e.canvasWidth,e.canvasHeight)};(f[e.NODE]||F[e.NODE])&&(ae(Y,X,F[e.NODE]),f[e.NODE]=!1),(f[e.DRAG]||F[e.DRAG])&&(ae(W,ee,F[e.DRAG]),f[e.DRAG]=!1)}e.prevViewport=w,e.clearingMotionBlur&&(e.clearingMotionBlur=!1,e.motionBlurCleared=!0,e.motionBlur=!0),v&&(e.motionBlurTimeout=setTimeout(function(){e.motionBlurTimeout=null,e.clearedForMotionBlur[e.NODE]=!1,e.clearedForMotionBlur[e.DRAG]=!1,e.motionBlur=!1,e.clearingMotionBlur=!c,e.mbFrames=0,f[e.NODE]=!0,f[e.DRAG]=!0,e.redraw()},hm)),a||r.emit("render")};var ya;xt.drawSelectionRectangle=function(t,e){var r=this,a=r.cy,n=r.data,i=a.style(),s=t.drawOnlyNodeLayer,o=t.drawAllLayers,u=n.canvasNeedsRedraw,l=t.forcedContext;if(r.showFps||!s&&u[r.SELECT_BOX]&&!o){var f=l||n.contexts[r.SELECT_BOX];if(e(f),r.selection[4]==1&&(r.hoverData.selecting||r.touchData.selecting)){var c=r.cy.zoom(),v=i.core("selection-box-border-width").value/c;f.lineWidth=v,f.fillStyle="rgba("+i.core("selection-box-color").value[0]+","+i.core("selection-box-color").value[1]+","+i.core("selection-box-color").value[2]+","+i.core("selection-box-opacity").value+")",f.fillRect(r.selection[0],r.selection[1],r.selection[2]-r.selection[0],r.selection[3]-r.selection[1]),v>0&&(f.strokeStyle="rgba("+i.core("selection-box-border-color").value[0]+","+i.core("selection-box-border-color").value[1]+","+i.core("selection-box-border-color").value[2]+","+i.core("selection-box-opacity").value+")",f.strokeRect(r.selection[0],r.selection[1],r.selection[2]-r.selection[0],r.selection[3]-r.selection[1]))}if(n.bgActivePosistion&&!r.hoverData.selecting){var c=r.cy.zoom(),h=n.bgActivePosistion;f.fillStyle="rgba("+i.core("active-bg-color").value[0]+","+i.core("active-bg-color").value[1]+","+i.core("active-bg-color").value[2]+","+i.core("active-bg-opacity").value+")",f.beginPath(),f.arc(h.x,h.y,i.core("active-bg-size").pfValue/c,0,2*Math.PI),f.fill()}var d=r.lastRedrawTime;if(r.showFps&&d){d=Math.round(d);var p=Math.round(1e3/d),g="1 frame = "+d+" ms = "+p+" fps";if(f.setTransform(1,0,0,1,0,0),f.fillStyle="rgba(255, 0, 0, 0.75)",f.strokeStyle="rgba(255, 0, 0, 0.75)",f.font="30px Arial",!ya){var y=f.measureText(g);ya=y.actualBoundingBoxAscent}f.fillText(g,0,ya);var b=60;f.strokeRect(0,ya+10,250,20),f.fillRect(0,ya+10,250*Math.min(p/b,1),20)}o||(u[r.SELECT_BOX]=!1)}};function ef(t,e,r){var a=t.createShader(e);if(t.shaderSource(a,r),t.compileShader(a),!t.getShaderParameter(a,t.COMPILE_STATUS))throw new Error(t.getShaderInfoLog(a));return a}function dm(t,e,r){var a=ef(t,t.VERTEX_SHADER,e),n=ef(t,t.FRAGMENT_SHADER,r),i=t.createProgram();if(t.attachShader(i,a),t.attachShader(i,n),t.linkProgram(i),!t.getProgramParameter(i,t.LINK_STATUS))throw new Error("Could not initialize shaders");return i}function gm(t,e,r){r===void 0&&(r=e);var a=t.makeOffscreenCanvas(e,r),n=a.context=a.getContext("2d");return a.clear=function(){return n.clearRect(0,0,a.width,a.height)},a.clear(),a}function Ro(t){var e=t.pixelRatio,r=t.cy.zoom(),a=t.cy.pan();return{zoom:r*e,pan:{x:a.x*e,y:a.y*e}}}function pm(t){var e=t.pixelRatio,r=t.cy.zoom();return r*e}function ym(t,e,r,a,n){var i=a*r+e.x,s=n*r+e.y;return s=Math.round(t.canvasHeight-s),[i,s]}function mm(t){return t.pstyle("background-fill").value!=="solid"||t.pstyle("background-image").strValue!=="none"?!1:t.pstyle("border-width").value===0||t.pstyle("border-opacity").value===0?!0:t.pstyle("border-style").value==="solid"}function bm(t,e){if(t.length!==e.length)return!1;for(var r=0;r>0&255)/255,r[1]=(t>>8&255)/255,r[2]=(t>>16&255)/255,r[3]=(t>>24&255)/255,r}function wm(t){return t[0]+(t[1]<<8)+(t[2]<<16)+(t[3]<<24)}function Em(t,e){var r=t.createTexture();return r.buffer=function(a){t.bindTexture(t.TEXTURE_2D,r),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_NEAREST),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,a),t.generateMipmap(t.TEXTURE_2D),t.bindTexture(t.TEXTURE_2D,null)},r.deleteTexture=function(){t.deleteTexture(r)},r}function Yc(t,e){switch(e){case"float":return[1,t.FLOAT,4];case"vec2":return[2,t.FLOAT,4];case"vec3":return[3,t.FLOAT,4];case"vec4":return[4,t.FLOAT,4];case"int":return[1,t.INT,4];case"ivec2":return[2,t.INT,4]}}function Hc(t,e,r){switch(e){case t.FLOAT:return new Float32Array(r);case t.INT:return new Int32Array(r)}}function xm(t,e,r,a,n,i){switch(e){case t.FLOAT:return new Float32Array(r.buffer,i*a,n);case t.INT:return new Int32Array(r.buffer,i*a,n)}}function Tm(t,e,r,a){var n=Yc(t,e),i=Je(n,2),s=i[0],o=i[1],u=Hc(t,o,a),l=t.createBuffer();return t.bindBuffer(t.ARRAY_BUFFER,l),t.bufferData(t.ARRAY_BUFFER,u,t.STATIC_DRAW),o===t.FLOAT?t.vertexAttribPointer(r,s,o,!1,0,0):o===t.INT&&t.vertexAttribIPointer(r,s,o,0,0),t.enableVertexAttribArray(r),t.bindBuffer(t.ARRAY_BUFFER,null),l}function zt(t,e,r,a){var n=Yc(t,r),i=Je(n,3),s=i[0],o=i[1],u=i[2],l=Hc(t,o,e*s),f=s*u,c=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,c),t.bufferData(t.ARRAY_BUFFER,e*f,t.DYNAMIC_DRAW),t.enableVertexAttribArray(a),o===t.FLOAT?t.vertexAttribPointer(a,s,o,!1,f,0):o===t.INT&&t.vertexAttribIPointer(a,s,o,f,0),t.vertexAttribDivisor(a,1),t.bindBuffer(t.ARRAY_BUFFER,null);for(var v=new Array(e),h=0;hs&&(o=s/a,u=a*o,l=n*o),{scale:o,texW:u,texH:l}}},{key:"draw",value:function(r,a,n){var i=this;if(this.locked)throw new Error("can't draw, atlas is locked");var s=this.texSize,o=this.texRows,u=this.texHeight,l=this.getScale(a),f=l.scale,c=l.texW,v=l.texH,h=function(m,E){if(n&&E){var T=E.context,S=m.x,w=m.row,x=S,C=u*w;T.save(),T.translate(x,C),T.scale(f,f),n(T,a),T.restore()}},d=[null,null],p=function(){h(i.freePointer,i.canvas),d[0]={x:i.freePointer.x,y:i.freePointer.row*u,w:c,h:v},d[1]={x:i.freePointer.x+c,y:i.freePointer.row*u,w:0,h:v},i.freePointer.x+=c,i.freePointer.x==s&&(i.freePointer.x=0,i.freePointer.row++)},g=function(){var m=i.scratch,E=i.canvas;m.clear(),h({x:0,row:0},m);var T=s-i.freePointer.x,S=c-T,w=u;{var x=i.freePointer.x,C=i.freePointer.row*u,D=T;E.context.drawImage(m,0,0,D,w,x,C,D,w),d[0]={x,y:C,w:D,h:v}}{var A=T,L=(i.freePointer.row+1)*u,R=S;E&&E.context.drawImage(m,A,0,R,w,0,L,R,w),d[1]={x:0,y:L,w:R,h:v}}i.freePointer.x=S,i.freePointer.row++},y=function(){i.freePointer.x=0,i.freePointer.row++};if(this.freePointer.x+c<=s)p();else{if(this.freePointer.row>=o-1)return!1;this.freePointer.x===s?(y(),p()):this.enableWrapping?g():(y(),p())}return this.keyToLocation.set(r,d),this.needsBuffer=!0,d}},{key:"getOffsets",value:function(r){return this.keyToLocation.get(r)}},{key:"isEmpty",value:function(){return this.freePointer.x===0&&this.freePointer.row===0}},{key:"canFit",value:function(r){if(this.locked)return!1;var a=this.texSize,n=this.texRows,i=this.getScale(r),s=i.texW;return this.freePointer.x+s>a?this.freePointer.row1&&arguments[1]!==void 0?arguments[1]:{},i=n.forceRedraw,s=i===void 0?!1:i,o=n.filterEle,u=o===void 0?function(){return!0}:o,l=n.filterType,f=l===void 0?function(){return!0}:l,c=!1,v=!1,h=At(r),d;try{for(h.s();!(d=h.n()).done;){var p=d.value;if(u(p)){var g=At(this.renderTypes.values()),y;try{var b=function(){var E=y.value,T=E.type;if(f(T)){var S=a.collections.get(E.collection),w=E.getKey(p),x=Array.isArray(w)?w:[w];if(s)x.forEach(function(L){return S.markKeyForGC(L)}),v=!0;else{var C=E.getID?E.getID(p):p.id(),D=a._key(T,C),A=a.typeAndIdToKey.get(D);A!==void 0&&!bm(x,A)&&(c=!0,a.typeAndIdToKey.delete(D),A.forEach(function(L){return S.markKeyForGC(L)}))}}};for(g.s();!(y=g.n()).done;)b()}catch(m){g.e(m)}finally{g.f()}}}}catch(m){h.e(m)}finally{h.f()}return v&&(this.gc(),c=!1),c}},{key:"gc",value:function(){var r=At(this.collections.values()),a;try{for(r.s();!(a=r.n()).done;){var n=a.value;n.gc()}}catch(i){r.e(i)}finally{r.f()}}},{key:"getOrCreateAtlas",value:function(r,a,n,i){var s=this.renderTypes.get(a),o=this.collections.get(s.collection),u=!1,l=o.draw(i,n,function(v){s.drawClipped?(v.save(),v.beginPath(),v.rect(0,0,n.w,n.h),v.clip(),s.drawElement(v,r,n,!0,!0),v.restore()):s.drawElement(v,r,n,!0,!0),u=!0});if(u){var f=s.getID?s.getID(r):r.id(),c=this._key(a,f);this.typeAndIdToKey.has(c)?this.typeAndIdToKey.get(c).push(i):this.typeAndIdToKey.set(c,[i])}return l}},{key:"getAtlasInfo",value:function(r,a){var n=this,i=this.renderTypes.get(a),s=i.getKey(r),o=Array.isArray(s)?s:[s];return o.map(function(u){var l=i.getBoundingBox(r,u),f=n.getOrCreateAtlas(r,a,l,u),c=f.getOffsets(u),v=Je(c,2),h=v[0],d=v[1];return{atlas:f,tex:h,tex1:h,tex2:d,bb:l}})}},{key:"getDebugInfo",value:function(){var r=[],a=At(this.collections),n;try{for(a.s();!(n=a.n()).done;){var i=Je(n.value,2),s=i[0],o=i[1],u=o.getCounts(),l=u.keyCount,f=u.atlasCount;r.push({type:s,keyCount:l,atlasCount:f})}}catch(c){a.e(c)}finally{a.f()}return r}}])}(),Mm=function(){function t(e){yr(this,t),this.globalOptions=e,this.atlasSize=e.webglTexSize,this.maxAtlasesPerBatch=e.webglTexPerBatch,this.batchAtlases=[]}return mr(t,[{key:"getMaxAtlasesPerBatch",value:function(){return this.maxAtlasesPerBatch}},{key:"getAtlasSize",value:function(){return this.atlasSize}},{key:"getIndexArray",value:function(){return Array.from({length:this.maxAtlasesPerBatch},function(r,a){return a})}},{key:"startBatch",value:function(){this.batchAtlases=[]}},{key:"getAtlasCount",value:function(){return this.batchAtlases.length}},{key:"getAtlases",value:function(){return this.batchAtlases}},{key:"canAddToCurrentBatch",value:function(r){return this.batchAtlases.length===this.maxAtlasesPerBatch?this.batchAtlases.includes(r):!0}},{key:"getAtlasIndexForBatch",value:function(r){var a=this.batchAtlases.indexOf(r);if(a<0){if(this.batchAtlases.length===this.maxAtlasesPerBatch)throw new Error("cannot add more atlases to batch");this.batchAtlases.push(r),a=this.batchAtlases.length-1}return a}}])}(),Om=` float circleSD(vec2 p, float r) { return distance(vec2(0), p) - r; // signed distance } `,km=` float rectangleSD(vec2 p, vec2 b) { vec2 d = abs(p)-b; return distance(vec2(0),max(d,0.0)) + min(max(d.x,d.y),0.0); } `,Nm=` float roundRectangleSD(vec2 p, vec2 b, vec4 cr) { cr.xy = (p.x > 0.0) ? cr.xy : cr.zw; cr.x = (p.y > 0.0) ? cr.x : cr.y; vec2 q = abs(p) - b + cr.x; return min(max(q.x, q.y), 0.0) + distance(vec2(0), max(q, 0.0)) - cr.x; } `,Bm=` float ellipseSD(vec2 p, vec2 ab) { p = abs( p ); // symmetry // find root with Newton solver vec2 q = ab*(p-ab); float w = (q.x1.0) ? d : -d; } `,Da={SCREEN:{name:"screen",screen:!0},PICKING:{name:"picking",picking:!0}},_n={IGNORE:1,USE_BB:2},Ps=0,nf=1,sf=2,Ms=3,Hr=4,ln=5,ma=6,ba=7,Fm=function(){function t(e,r,a){yr(this,t),this.r=e,this.gl=r,this.maxInstances=a.webglBatchSize,this.atlasSize=a.webglTexSize,this.bgColor=a.bgColor,this.debug=a.webglDebug,this.batchDebugInfo=[],a.enableWrapping=!0,a.createTextureCanvas=gm,this.atlasManager=new Pm(e,a),this.batchManager=new Mm(a),this.simpleShapeOptions=new Map,this.program=this._createShaderProgram(Da.SCREEN),this.pickingProgram=this._createShaderProgram(Da.PICKING),this.vao=this._createVAO()}return mr(t,[{key:"addAtlasCollection",value:function(r,a){this.atlasManager.addAtlasCollection(r,a)}},{key:"addTextureAtlasRenderType",value:function(r,a){this.atlasManager.addRenderType(r,a)}},{key:"addSimpleShapeRenderType",value:function(r,a){this.simpleShapeOptions.set(r,a)}},{key:"invalidate",value:function(r){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=a.type,i=this.atlasManager;return n?i.invalidate(r,{filterType:function(o){return o===n},forceRedraw:!0}):i.invalidate(r)}},{key:"gc",value:function(){this.atlasManager.gc()}},{key:"_createShaderProgram",value:function(r){var a=this.gl,n=`#version 300 es precision highp float; uniform mat3 uPanZoomMatrix; uniform int uAtlasSize; // instanced in vec2 aPosition; // a vertex from the unit square in mat3 aTransform; // used to transform verticies, eg into a bounding box in int aVertType; // the type of thing we are rendering // the z-index that is output when using picking mode in vec4 aIndex; // For textures in int aAtlasId; // which shader unit/atlas to use in vec4 aTex; // x/y/w/h of texture in atlas // for edges in vec4 aPointAPointB; in vec4 aPointCPointD; in vec2 aLineWidth; // also used for node border width // simple shapes in vec4 aCornerRadius; // for round-rectangle [top-right, bottom-right, top-left, bottom-left] in vec4 aColor; // also used for edges in vec4 aBorderColor; // aLineWidth is used for border width // output values passed to the fragment shader out vec2 vTexCoord; out vec4 vColor; out vec2 vPosition; // flat values are not interpolated flat out int vAtlasId; flat out int vVertType; flat out vec2 vTopRight; flat out vec2 vBotLeft; flat out vec4 vCornerRadius; flat out vec4 vBorderColor; flat out vec2 vBorderWidth; flat out vec4 vIndex; void main(void) { int vid = gl_VertexID; vec2 position = aPosition; // TODO make this a vec3, simplifies some code below if(aVertType == `.concat(Ps,`) { float texX = aTex.x; // texture coordinates float texY = aTex.y; float texW = aTex.z; float texH = aTex.w; if(vid == 1 || vid == 2 || vid == 4) { texX += texW; } if(vid == 2 || vid == 4 || vid == 5) { texY += texH; } float d = float(uAtlasSize); vTexCoord = vec2(texX / d, texY / d); // tex coords must be between 0 and 1 gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0); } else if(aVertType == `).concat(Hr," || aVertType == ").concat(ba,` || aVertType == `).concat(ln," || aVertType == ").concat(ma,`) { // simple shapes // the bounding box is needed by the fragment shader vBotLeft = (aTransform * vec3(0, 0, 1)).xy; // flat vTopRight = (aTransform * vec3(1, 1, 1)).xy; // flat vPosition = (aTransform * vec3(position, 1)).xy; // will be interpolated // calculations are done in the fragment shader, just pass these along vColor = aColor; vCornerRadius = aCornerRadius; vBorderColor = aBorderColor; vBorderWidth = aLineWidth; gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0); } else if(aVertType == `).concat(nf,`) { vec2 source = aPointAPointB.xy; vec2 target = aPointAPointB.zw; // adjust the geometry so that the line is centered on the edge position.y = position.y - 0.5; // stretch the unit square into a long skinny rectangle vec2 xBasis = target - source; vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x)); vec2 point = source + xBasis * position.x + yBasis * aLineWidth[0] * position.y; gl_Position = vec4(uPanZoomMatrix * vec3(point, 1.0), 1.0); vColor = aColor; } else if(aVertType == `).concat(sf,`) { vec2 pointA = aPointAPointB.xy; vec2 pointB = aPointAPointB.zw; vec2 pointC = aPointCPointD.xy; vec2 pointD = aPointCPointD.zw; // adjust the geometry so that the line is centered on the edge position.y = position.y - 0.5; vec2 p0, p1, p2, pos; if(position.x == 0.0) { // The left side of the unit square p0 = pointA; p1 = pointB; p2 = pointC; pos = position; } else { // The right side of the unit square, use same approach but flip the geometry upside down p0 = pointD; p1 = pointC; p2 = pointB; pos = vec2(0.0, -position.y); } vec2 p01 = p1 - p0; vec2 p12 = p2 - p1; vec2 p21 = p1 - p2; // Find the normal vector. vec2 tangent = normalize(normalize(p12) + normalize(p01)); vec2 normal = vec2(-tangent.y, tangent.x); // Find the vector perpendicular to p0 -> p1. vec2 p01Norm = normalize(vec2(-p01.y, p01.x)); // Determine the bend direction. float sigma = sign(dot(p01 + p21, normal)); float width = aLineWidth[0]; if(sign(pos.y) == -sigma) { // This is an intersecting vertex. Adjust the position so that there's no overlap. vec2 point = 0.5 * width * normal * -sigma / dot(normal, p01Norm); gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0); } else { // This is a non-intersecting vertex. Treat it like a mitre join. vec2 point = 0.5 * width * normal * sigma * dot(normal, p01Norm); gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0); } vColor = aColor; } else if(aVertType == `).concat(Ms,` && vid < 3) { // massage the first triangle into an edge arrow if(vid == 0) position = vec2(-0.15, -0.3); if(vid == 1) position = vec2( 0.0, 0.0); if(vid == 2) position = vec2( 0.15, -0.3); gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0); vColor = aColor; } else { gl_Position = vec4(2.0, 0.0, 0.0, 1.0); // discard vertex by putting it outside webgl clip space } vAtlasId = aAtlasId; vVertType = aVertType; vIndex = aIndex; } `),i=this.batchManager.getIndexArray(),s=`#version 300 es precision highp float; // declare texture unit for each texture atlas in the batch `.concat(i.map(function(l){return"uniform sampler2D uTexture".concat(l,";")}).join(` `),` uniform vec4 uBGColor; uniform float uZoom; in vec2 vTexCoord; in vec4 vColor; in vec2 vPosition; // model coordinates flat in int vAtlasId; flat in vec4 vIndex; flat in int vVertType; flat in vec2 vTopRight; flat in vec2 vBotLeft; flat in vec4 vCornerRadius; flat in vec4 vBorderColor; flat in vec2 vBorderWidth; out vec4 outColor; `).concat(Om,` `).concat(km,` `).concat(Nm,` `).concat(Bm,` vec4 blend(vec4 top, vec4 bot) { // blend colors with premultiplied alpha return vec4( top.rgb + (bot.rgb * (1.0 - top.a)), top.a + (bot.a * (1.0 - top.a)) ); } vec4 distInterp(vec4 cA, vec4 cB, float d) { // interpolate color using Signed Distance // scale to the zoom level so that borders don't look blurry when zoomed in // note 1.5 is an aribitrary value chosen because it looks good return mix(cA, cB, 1.0 - smoothstep(0.0, 1.5 / uZoom, abs(d))); } void main(void) { if(vVertType == `).concat(Ps,`) { // look up the texel from the texture unit `).concat(i.map(function(l){return"if(vAtlasId == ".concat(l,") outColor = texture(uTexture").concat(l,", vTexCoord);")}).join(` else `),` } else if(vVertType == `).concat(Ms,`) { // mimics how canvas renderer uses context.globalCompositeOperation = 'destination-out'; outColor = blend(vColor, uBGColor); outColor.a = 1.0; // make opaque, masks out line under arrow } else if(vVertType == `).concat(Hr,` && vBorderWidth == vec2(0.0)) { // simple rectangle with no border outColor = vColor; // unit square is already transformed to the rectangle, nothing else needs to be done } else if(vVertType == `).concat(Hr," || vVertType == ").concat(ba,` || vVertType == `).concat(ln," || vVertType == ").concat(ma,`) { // use SDF float outerBorder = vBorderWidth[0]; float innerBorder = vBorderWidth[1]; float borderPadding = outerBorder * 2.0; float w = vTopRight.x - vBotLeft.x - borderPadding; float h = vTopRight.y - vBotLeft.y - borderPadding; vec2 b = vec2(w/2.0, h/2.0); // half width, half height vec2 p = vPosition - vec2(vTopRight.x - b[0] - outerBorder, vTopRight.y - b[1] - outerBorder); // translate to center float d; // signed distance if(vVertType == `).concat(Hr,`) { d = rectangleSD(p, b); } else if(vVertType == `).concat(ba,` && w == h) { d = circleSD(p, b.x); // faster than ellipse } else if(vVertType == `).concat(ba,`) { d = ellipseSD(p, b); } else { d = roundRectangleSD(p, b, vCornerRadius.wzyx); } // use the distance to interpolate a color to smooth the edges of the shape, doesn't need multisampling // we must smooth colors inwards, because we can't change pixels outside the shape's bounding box if(d > 0.0) { if(d > outerBorder) { discard; } else { outColor = distInterp(vBorderColor, vec4(0), d - outerBorder); } } else { if(d > innerBorder) { vec4 outerColor = outerBorder == 0.0 ? vec4(0) : vBorderColor; vec4 innerBorderColor = blend(vBorderColor, vColor); outColor = distInterp(innerBorderColor, outerColor, d); } else { vec4 outerColor; if(innerBorder == 0.0 && outerBorder == 0.0) { outerColor = vec4(0); } else if(innerBorder == 0.0) { outerColor = vBorderColor; } else { outerColor = blend(vBorderColor, vColor); } outColor = distInterp(vColor, outerColor, d - innerBorder); } } } else { outColor = vColor; } `).concat(r.picking?`if(outColor.a == 0.0) discard; else outColor = vIndex;`:"",` } `),o=dm(a,n,s);o.aPosition=a.getAttribLocation(o,"aPosition"),o.aIndex=a.getAttribLocation(o,"aIndex"),o.aVertType=a.getAttribLocation(o,"aVertType"),o.aTransform=a.getAttribLocation(o,"aTransform"),o.aAtlasId=a.getAttribLocation(o,"aAtlasId"),o.aTex=a.getAttribLocation(o,"aTex"),o.aPointAPointB=a.getAttribLocation(o,"aPointAPointB"),o.aPointCPointD=a.getAttribLocation(o,"aPointCPointD"),o.aLineWidth=a.getAttribLocation(o,"aLineWidth"),o.aColor=a.getAttribLocation(o,"aColor"),o.aCornerRadius=a.getAttribLocation(o,"aCornerRadius"),o.aBorderColor=a.getAttribLocation(o,"aBorderColor"),o.uPanZoomMatrix=a.getUniformLocation(o,"uPanZoomMatrix"),o.uAtlasSize=a.getUniformLocation(o,"uAtlasSize"),o.uBGColor=a.getUniformLocation(o,"uBGColor"),o.uZoom=a.getUniformLocation(o,"uZoom"),o.uTextures=[];for(var u=0;u1&&arguments[1]!==void 0?arguments[1]:Da.SCREEN;this.panZoomMatrix=r,this.renderTarget=a,this.batchDebugInfo=[],this.wrappedCount=0,this.simpleCount=0,this.startBatch()}},{key:"startBatch",value:function(){this.instanceCount=0,this.batchManager.startBatch()}},{key:"endFrame",value:function(){this.endBatch()}},{key:"_isVisible",value:function(r,a){return r.visible()?a&&a.isVisible?a.isVisible(r):!0:!1}},{key:"drawTexture",value:function(r,a,n){var i=this.atlasManager,s=this.batchManager,o=i.getRenderTypeOpts(n);if(this._isVisible(r,o)&&!(r.isEdge()&&!this._isValidEdge(r))){if(this.renderTarget.picking&&o.getTexPickingMode){var u=o.getTexPickingMode(r);if(u===_n.IGNORE)return;if(u==_n.USE_BB){this.drawPickingRectangle(r,a,n);return}}var l=i.getAtlasInfo(r,n),f=At(l),c;try{for(f.s();!(c=f.n()).done;){var v=c.value,h=v.atlas,d=v.tex1,p=v.tex2;s.canAddToCurrentBatch(h)||this.endBatch();for(var g=s.getAtlasIndexForBatch(h),y=0,b=[[d,!0],[p,!1]];y=this.maxInstances&&this.endBatch()}}}}catch(A){f.e(A)}finally{f.f()}}}},{key:"setTransformMatrix",value:function(r,a,n,i){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,o=0;if(n.shapeProps&&n.shapeProps.padding&&(o=r.pstyle(n.shapeProps.padding).pfValue),i){var u=i.bb,l=i.tex1,f=i.tex2,c=l.w/(l.w+f.w);s||(c=1-c);var v=this._getAdjustedBB(u,o,s,c);this._applyTransformMatrix(a,v,n,r)}else{var h=n.getBoundingBox(r),d=this._getAdjustedBB(h,o,!0,1);this._applyTransformMatrix(a,d,n,r)}}},{key:"_applyTransformMatrix",value:function(r,a,n,i){var s,o;rf(r);var u=n.getRotation?n.getRotation(i):0;if(u!==0){var l=n.getRotationPoint(i),f=l.x,c=l.y;wn(r,r,[f,c]),af(r,r,u);var v=n.getRotationOffset(i);s=v.x+(a.xOffset||0),o=v.y+(a.yOffset||0)}else s=a.x1,o=a.y1;wn(r,r,[s,o]),Js(r,r,[a.w,a.h])}},{key:"_getAdjustedBB",value:function(r,a,n,i){var s=r.x1,o=r.y1,u=r.w,l=r.h,f=r.yOffset;a&&(s-=a,o-=a,u+=2*a,l+=2*a);var c=0,v=u*i;return n&&i<1?u=v:!n&&i<1&&(c=u-v,s+=c,u=v),{x1:s,y1:o,w:u,h:l,xOffset:c,yOffset:f}}},{key:"drawPickingRectangle",value:function(r,a,n){var i=this.atlasManager.getRenderTypeOpts(n),s=this.instanceCount;this.vertTypeBuffer.getView(s)[0]=Hr;var o=this.indexBuffer.getView(s);Yr(a,o);var u=this.colorBuffer.getView(s);Cr([0,0,0],1,u);var l=this.transformBuffer.getMatrixView(s);this.setTransformMatrix(r,l,i),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}},{key:"drawNode",value:function(r,a,n){var i=this.simpleShapeOptions.get(n);if(this._isVisible(r,i)){var s=i.shapeProps,o=this._getVertTypeForShape(r,s.shape);if(o===void 0||i.isSimple&&!i.isSimple(r)){this.drawTexture(r,a,n);return}var u=this.instanceCount;if(this.vertTypeBuffer.getView(u)[0]=o,o===ln||o===ma){var l=i.getBoundingBox(r),f=this._getCornerRadius(r,s.radius,l),c=this.cornerRadiusBuffer.getView(u);c[0]=f,c[1]=f,c[2]=f,c[3]=f,o===ma&&(c[0]=0,c[2]=0)}var v=this.indexBuffer.getView(u);Yr(a,v);var h=r.pstyle(s.color).value,d=r.pstyle(s.opacity).value,p=this.colorBuffer.getView(u);Cr(h,d,p);var g=this.lineWidthBuffer.getView(u);if(g[0]=0,g[1]=0,s.border){var y=r.pstyle("border-width").value;if(y>0){var b=r.pstyle("border-color").value,m=r.pstyle("border-opacity").value,E=this.borderColorBuffer.getView(u);Cr(b,m,E);var T=r.pstyle("border-position").value;if(T==="inside")g[0]=0,g[1]=-y;else if(T==="outside")g[0]=y,g[1]=0;else{var S=y/2;g[0]=S,g[1]=-S}}}var w=this.transformBuffer.getMatrixView(u);this.setTransformMatrix(r,w,i),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}},{key:"_getVertTypeForShape",value:function(r,a){var n=r.pstyle(a).value;switch(n){case"rectangle":return Hr;case"ellipse":return ba;case"roundrectangle":case"round-rectangle":return ln;case"bottom-round-rectangle":return ma;default:return}}},{key:"_getCornerRadius",value:function(r,a,n){var i=n.w,s=n.h;if(r.pstyle(a).value==="auto")return vr(i,s);var o=r.pstyle(a).pfValue,u=i/2,l=s/2;return Math.min(o,l,u)}},{key:"drawEdgeArrow",value:function(r,a,n){if(r.visible()){var i=r._private.rscratch,s,o,u;if(n==="source"?(s=i.arrowStartX,o=i.arrowStartY,u=i.srcArrowAngle):(s=i.arrowEndX,o=i.arrowEndY,u=i.tgtArrowAngle),!(isNaN(s)||s==null||isNaN(o)||o==null||isNaN(u)||u==null)){var l=r.pstyle(n+"-arrow-shape").value;if(l!=="none"){var f=r.pstyle(n+"-arrow-color").value,c=r.pstyle("opacity").value,v=r.pstyle("line-opacity").value,h=c*v,d=r.pstyle("width").pfValue,p=r.pstyle("arrow-scale").value,g=this.r.getArrowWidth(d,p),y=this.instanceCount,b=this.transformBuffer.getMatrixView(y);rf(b),wn(b,b,[s,o]),Js(b,b,[g,g]),af(b,b,u),this.vertTypeBuffer.getView(y)[0]=Ms;var m=this.indexBuffer.getView(y);Yr(a,m);var E=this.colorBuffer.getView(y);Cr(f,h,E),this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}},{key:"drawEdgeLine",value:function(r,a){if(r.visible()){var n=this._getEdgePoints(r);if(n){var i=r.pstyle("opacity").value,s=r.pstyle("line-opacity").value,o=r.pstyle("width").pfValue,u=r.pstyle("line-color").value,l=i*s;if(n.length/2+this.instanceCount>this.maxInstances&&this.endBatch(),n.length==4){var f=this.instanceCount;this.vertTypeBuffer.getView(f)[0]=nf;var c=this.indexBuffer.getView(f);Yr(a,c);var v=this.colorBuffer.getView(f);Cr(u,l,v);var h=this.lineWidthBuffer.getView(f);h[0]=o;var d=this.pointAPointBBuffer.getView(f);d[0]=n[0],d[1]=n[1],d[2]=n[2],d[3]=n[3],this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}else for(var p=0;p=this.maxInstances&&this.endBatch()}}}}},{key:"_isValidEdge",value:function(r){var a=r._private.rscratch;return!(a.badLine||a.allpts==null||isNaN(a.allpts[0]))}},{key:"_getEdgePoints",value:function(r){var a=r._private.rscratch;if(this._isValidEdge(r)){var n=a.allpts;if(n.length==4)return n;var i=this._getNumSegments(r);return this._getCurveSegmentPoints(n,i)}}},{key:"_getNumSegments",value:function(r){var a=15;return Math.min(Math.max(a,5),this.maxInstances)}},{key:"_getCurveSegmentPoints",value:function(r,a){if(r.length==4)return r;for(var n=Array((a+1)*2),i=0;i<=a;i++)if(i==0)n[0]=r[0],n[1]=r[1];else if(i==a)n[i*2]=r[r.length-2],n[i*2+1]=r[r.length-1];else{var s=i/a;this._setCurvePoint(r,s,n,i*2)}return n}},{key:"_setCurvePoint",value:function(r,a,n,i){if(r.length<=2)n[i]=r[0],n[i+1]=r[1];else{for(var s=Array(r.length-2),o=0;o0}},o=function(c){var v=c.pstyle("text-events").strValue==="yes";return v?_n.USE_BB:_n.IGNORE},u=function(c){var v=c.position(),h=v.x,d=v.y,p=c.outerWidth(),g=c.outerHeight();return{w:p,h:g,x1:h-p/2,y1:d-g/2}};r.drawing.addAtlasCollection("node",{texRows:t.webglTexRowsNodes}),r.drawing.addAtlasCollection("label",{texRows:t.webglTexRows}),r.drawing.addTextureAtlasRenderType("node-body",{collection:"node",getKey:e.getStyleKey,getBoundingBox:e.getElementBox,drawElement:e.drawElement}),r.drawing.addSimpleShapeRenderType("node-body",{getBoundingBox:u,isSimple:mm,shapeProps:{shape:"shape",color:"background-color",opacity:"background-opacity",radius:"corner-radius",border:!0}}),r.drawing.addSimpleShapeRenderType("node-overlay",{getBoundingBox:u,isVisible:s("overlay"),shapeProps:{shape:"overlay-shape",color:"overlay-color",opacity:"overlay-opacity",padding:"overlay-padding",radius:"overlay-corner-radius"}}),r.drawing.addSimpleShapeRenderType("node-underlay",{getBoundingBox:u,isVisible:s("underlay"),shapeProps:{shape:"underlay-shape",color:"underlay-color",opacity:"underlay-opacity",padding:"underlay-padding",radius:"underlay-corner-radius"}}),r.drawing.addTextureAtlasRenderType("label",{collection:"label",getTexPickingMode:o,getKey:Os(e.getLabelKey,null),getBoundingBox:ks(e.getLabelBox,null),drawClipped:!0,drawElement:e.drawLabel,getRotation:n(null),getRotationPoint:e.getLabelRotationPoint,getRotationOffset:e.getLabelRotationOffset,isVisible:i("label")}),r.drawing.addTextureAtlasRenderType("edge-source-label",{collection:"label",getTexPickingMode:o,getKey:Os(e.getSourceLabelKey,"source"),getBoundingBox:ks(e.getSourceLabelBox,"source"),drawClipped:!0,drawElement:e.drawSourceLabel,getRotation:n("source"),getRotationPoint:e.getSourceLabelRotationPoint,getRotationOffset:e.getSourceLabelRotationOffset,isVisible:i("source-label")}),r.drawing.addTextureAtlasRenderType("edge-target-label",{collection:"label",getTexPickingMode:o,getKey:Os(e.getTargetLabelKey,"target"),getBoundingBox:ks(e.getTargetLabelBox,"target"),drawClipped:!0,drawElement:e.drawTargetLabel,getRotation:n("target"),getRotationPoint:e.getTargetLabelRotationPoint,getRotationOffset:e.getTargetLabelRotationOffset,isVisible:i("target-label")});var l=Va(function(){console.log("garbage collect flag set"),r.data.gc=!0},1e4);r.onUpdateEleCalcs(function(f,c){var v=!1;c&&c.length>0&&(v|=r.drawing.invalidate(c)),v&&l()}),Gm(r)};function _m(t){var e=t.cy.container(),r=e&&e.style&&e.style.backgroundColor||"white";return wf(r)}function $c(t,e){var r=t._private.rscratch;return Dt(r,"labelWrapCachedLines",e)||[]}var Os=function(e,r){return function(a){var n=e(a),i=$c(a,r);return i.length>1?i.map(function(s,o){return"".concat(n,"_").concat(o)}):n}},ks=function(e,r){return function(a,n){var i=e(a);if(typeof n=="string"){var s=n.indexOf("_");if(s>0){var o=Number(n.substring(s+1)),u=$c(a,r),l=i.h/u.length,f=l*o,c=i.y1+f;return{x1:i.x1,w:i.w,y1:c,h:l,yOffset:f}}}return i}};function Gm(t){{var e=t.render;t.render=function(i){i=i||{};var s=t.cy;t.webgl&&(s.zoom()>Gc?(zm(t),e.call(t,i)):(Vm(t),Kc(t,i,Da.SCREEN)))}}{var r=t.matchCanvasSize;t.matchCanvasSize=function(i){r.call(t,i),t.pickingFrameBuffer.setFramebufferAttachmentSizes(t.canvasWidth,t.canvasHeight),t.pickingFrameBuffer.needsDraw=!0}}t.findNearestElements=function(i,s,o,u){return $m(t,i,s)};{var a=t.invalidateCachedZSortedEles;t.invalidateCachedZSortedEles=function(){a.call(t),t.pickingFrameBuffer.needsDraw=!0}}{var n=t.notify;t.notify=function(i,s){n.call(t,i,s),i==="viewport"||i==="bounds"?t.pickingFrameBuffer.needsDraw=!0:i==="background"&&t.drawing.invalidate(s,{type:"node-body"})}}}function zm(t){var e=t.data.contexts[t.WEBGL];e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)}function Vm(t){var e=function(a){a.save(),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,t.canvasWidth,t.canvasHeight),a.restore()};e(t.data.contexts[t.NODE]),e(t.data.contexts[t.DRAG])}function Um(t){var e=t.canvasWidth,r=t.canvasHeight,a=Ro(t),n=a.pan,i=a.zoom,s=Is();wn(s,s,[n.x,n.y]),Js(s,s,[i,i]);var o=Is();Am(o,e,r);var u=Is();return Sm(u,o,s),u}function Wc(t,e){var r=t.canvasWidth,a=t.canvasHeight,n=Ro(t),i=n.pan,s=n.zoom;e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,r,a),e.translate(i.x,i.y),e.scale(s,s)}function qm(t,e){t.drawSelectionRectangle(e,function(r){return Wc(t,r)})}function Ym(t){var e=t.data.contexts[t.NODE];e.save(),Wc(t,e),e.strokeStyle="rgba(0, 0, 0, 0.3)",e.beginPath(),e.moveTo(-1e3,0),e.lineTo(1e3,0),e.stroke(),e.beginPath(),e.moveTo(0,-1e3),e.lineTo(0,1e3),e.stroke(),e.restore()}function Hm(t){var e=function(n,i,s){for(var o=n.atlasManager.getAtlasCollection(i),u=t.data.contexts[t.NODE],l=o.atlases,f=0;f=0&&E.add(w)}return E}function $m(t,e,r){var a=Xm(t,e,r),n=t.getCachedZSortedEles(),i,s,o=At(a),u;try{for(o.s();!(u=o.n()).done;){var l=u.value,f=n[l];if(!i&&f.isNode()&&(i=f),!s&&f.isEdge()&&(s=f),i&&s)break}}catch(c){o.e(c)}finally{o.f()}return[i,s].filter(Boolean)}function Ns(t,e,r){var a=t.drawing;e+=1,r.isNode()?(a.drawNode(r,e,"node-underlay"),a.drawNode(r,e,"node-body"),a.drawTexture(r,e,"label"),a.drawNode(r,e,"node-overlay")):(a.drawEdgeLine(r,e),a.drawEdgeArrow(r,e,"source"),a.drawEdgeArrow(r,e,"target"),a.drawTexture(r,e,"label"),a.drawTexture(r,e,"edge-source-label"),a.drawTexture(r,e,"edge-target-label"))}function Kc(t,e,r){var a;t.webglDebug&&(a=performance.now());var n=t.drawing,i=0;if(r.screen&&t.data.canvasNeedsRedraw[t.SELECT_BOX]&&qm(t,e),t.data.canvasNeedsRedraw[t.NODE]||r.picking){var s=t.data.contexts[t.WEBGL];r.screen?(s.clearColor(0,0,0,0),s.enable(s.BLEND),s.blendFunc(s.ONE,s.ONE_MINUS_SRC_ALPHA)):s.disable(s.BLEND),s.clear(s.COLOR_BUFFER_BIT|s.DEPTH_BUFFER_BIT),s.viewport(0,0,s.canvas.width,s.canvas.height);var o=Um(t),u=t.getCachedZSortedEles();if(i=u.length,n.startFrame(o,r),r.screen){for(var l=0;l0&&s>0){h.clearRect(0,0,i,s),h.globalCompositeOperation="source-over";var d=this.getCachedZSortedEles();if(t.full)h.translate(-a.x1*l,-a.y1*l),h.scale(l,l),this.drawElements(h,d),h.scale(1/l,1/l),h.translate(a.x1*l,a.y1*l);else{var p=e.pan(),g={x:p.x*l,y:p.y*l};l*=e.zoom(),h.translate(g.x,g.y),h.scale(l,l),this.drawElements(h,d),h.scale(1/l,1/l),h.translate(-g.x,-g.y)}t.bg&&(h.globalCompositeOperation="destination-over",h.fillStyle=t.bg,h.rect(0,0,i,s),h.fill())}return v};function Wm(t,e){for(var r=atob(t),a=new ArrayBuffer(r.length),n=new Uint8Array(a),i=0;i"u"?"undefined":nt(OffscreenCanvas))!=="undefined")r=new OffscreenCanvas(t,e);else{var a=this.cy.window(),n=a.document;r=n.createElement("canvas"),r.width=t,r.height=e}return r};[Vc,Ht,er,Lo,Fr,wr,xt,Xc,Er,$a,Jc].forEach(function(t){be(Se,t)});var Qm=[{name:"null",impl:Ac},{name:"base",impl:Fc},{name:"canvas",impl:Km}],Jm=[{type:"layout",extensions:Ty},{type:"renderer",extensions:Qm}],ev={},tv={};function rv(t,e,r){var a=r,n=function(x){Ge("Can not register `"+e+"` for `"+t+"` since `"+x+"` already exists in the prototype and can not be overridden")};if(t==="core"){if(ka.prototype[e])return n(e);ka.prototype[e]=r}else if(t==="collection"){if(vt.prototype[e])return n(e);vt.prototype[e]=r}else if(t==="layout"){for(var i=function(x){this.options=x,r.call(this,x),Oe(this._private)||(this._private={}),this._private.cy=x.cy,this._private.listeners=[],this.createEmitter()},s=i.prototype=Object.create(r.prototype),o=[],u=0;ud&&(this.rect.x-=(this.labelWidth-d)/2,this.setWidth(this.labelWidth)),this.labelHeight>p&&(this.labelPos=="center"?this.rect.y-=(this.labelHeight-p)/2:this.labelPos=="top"&&(this.rect.y-=this.labelHeight-p),this.setHeight(this.labelHeight))}}},c.prototype.getInclusionTreeDepth=function(){if(this.inclusionTreeDepth==s.MAX_VALUE)throw"assert failed";return this.inclusionTreeDepth},c.prototype.transform=function(h){var d=this.rect.x;d>u.WORLD_BOUNDARY?d=u.WORLD_BOUNDARY:d<-u.WORLD_BOUNDARY&&(d=-u.WORLD_BOUNDARY);var p=this.rect.y;p>u.WORLD_BOUNDARY?p=u.WORLD_BOUNDARY:p<-u.WORLD_BOUNDARY&&(p=-u.WORLD_BOUNDARY);var g=new f(d,p),y=h.inverseTransformPoint(g);this.setLocation(y.x,y.y)},c.prototype.getLeft=function(){return this.rect.x},c.prototype.getRight=function(){return this.rect.x+this.rect.width},c.prototype.getTop=function(){return this.rect.y},c.prototype.getBottom=function(){return this.rect.y+this.rect.height},c.prototype.getParent=function(){return this.owner==null?null:this.owner.getParent()},r.exports=c},function(r,a,n){function i(s,o){s==null&&o==null?(this.x=0,this.y=0):(this.x=s,this.y=o)}i.prototype.getX=function(){return this.x},i.prototype.getY=function(){return this.y},i.prototype.setX=function(s){this.x=s},i.prototype.setY=function(s){this.y=s},i.prototype.getDifference=function(s){return new DimensionD(this.x-s.x,this.y-s.y)},i.prototype.getCopy=function(){return new i(this.x,this.y)},i.prototype.translate=function(s){return this.x+=s.width,this.y+=s.height,this},r.exports=i},function(r,a,n){var i=n(2),s=n(10),o=n(0),u=n(6),l=n(3),f=n(1),c=n(13),v=n(12),h=n(11);function d(g,y,b){i.call(this,b),this.estimatedSize=s.MIN_VALUE,this.margin=o.DEFAULT_GRAPH_MARGIN,this.edges=[],this.nodes=[],this.isConnected=!1,this.parent=g,y!=null&&y instanceof u?this.graphManager=y:y!=null&&y instanceof Layout&&(this.graphManager=y.graphManager)}d.prototype=Object.create(i.prototype);for(var p in i)d[p]=i[p];d.prototype.getNodes=function(){return this.nodes},d.prototype.getEdges=function(){return this.edges},d.prototype.getGraphManager=function(){return this.graphManager},d.prototype.getParent=function(){return this.parent},d.prototype.getLeft=function(){return this.left},d.prototype.getRight=function(){return this.right},d.prototype.getTop=function(){return this.top},d.prototype.getBottom=function(){return this.bottom},d.prototype.isConnected=function(){return this.isConnected},d.prototype.add=function(g,y,b){if(y==null&&b==null){var m=g;if(this.graphManager==null)throw"Graph has no graph mgr!";if(this.getNodes().indexOf(m)>-1)throw"Node already in graph!";return m.owner=this,this.getNodes().push(m),m}else{var E=g;if(!(this.getNodes().indexOf(y)>-1&&this.getNodes().indexOf(b)>-1))throw"Source or target not in graph!";if(!(y.owner==b.owner&&y.owner==this))throw"Both owners must be this graph!";return y.owner!=b.owner?null:(E.source=y,E.target=b,E.isInterGraph=!1,this.getEdges().push(E),y.edges.push(E),b!=y&&b.edges.push(E),E)}},d.prototype.remove=function(g){var y=g;if(g instanceof l){if(y==null)throw"Node is null!";if(!(y.owner!=null&&y.owner==this))throw"Owner graph is invalid!";if(this.graphManager==null)throw"Owner graph manager is invalid!";for(var b=y.edges.slice(),m,E=b.length,T=0;T-1&&x>-1))throw"Source and/or target doesn't know this edge!";m.source.edges.splice(w,1),m.target!=m.source&&m.target.edges.splice(x,1);var S=m.source.owner.getEdges().indexOf(m);if(S==-1)throw"Not in owner's edge list!";m.source.owner.getEdges().splice(S,1)}},d.prototype.updateLeftTop=function(){for(var g=s.MAX_VALUE,y=s.MAX_VALUE,b,m,E,T=this.getNodes(),S=T.length,w=0;wb&&(g=b),y>m&&(y=m)}return g==s.MAX_VALUE?null:(T[0].getParent().paddingLeft!=null?E=T[0].getParent().paddingLeft:E=this.margin,this.left=y-E,this.top=g-E,new v(this.left,this.top))},d.prototype.updateBounds=function(g){for(var y=s.MAX_VALUE,b=-s.MAX_VALUE,m=s.MAX_VALUE,E=-s.MAX_VALUE,T,S,w,x,C,D=this.nodes,A=D.length,L=0;LT&&(y=T),bw&&(m=w),ET&&(y=T),bw&&(m=w),E=this.nodes.length){var A=0;b.forEach(function(L){L.owner==g&&A++}),A==this.nodes.length&&(this.isConnected=!0)}},r.exports=d},function(r,a,n){var i,s=n(1);function o(u){i=n(5),this.layout=u,this.graphs=[],this.edges=[]}o.prototype.addRoot=function(){var u=this.layout.newGraph(),l=this.layout.newNode(null),f=this.add(u,l);return this.setRootGraph(f),this.rootGraph},o.prototype.add=function(u,l,f,c,v){if(f==null&&c==null&&v==null){if(u==null)throw"Graph is null!";if(l==null)throw"Parent node is null!";if(this.graphs.indexOf(u)>-1)throw"Graph already in this graph mgr!";if(this.graphs.push(u),u.parent!=null)throw"Already has a parent!";if(l.child!=null)throw"Already has a child!";return u.parent=l,l.child=u,u}else{v=f,c=l,f=u;var h=c.getOwner(),d=v.getOwner();if(!(h!=null&&h.getGraphManager()==this))throw"Source not in this graph mgr!";if(!(d!=null&&d.getGraphManager()==this))throw"Target not in this graph mgr!";if(h==d)return f.isInterGraph=!1,h.add(f,c,v);if(f.isInterGraph=!0,f.source=c,f.target=v,this.edges.indexOf(f)>-1)throw"Edge already in inter-graph edge list!";if(this.edges.push(f),!(f.source!=null&&f.target!=null))throw"Edge source and/or target is null!";if(!(f.source.edges.indexOf(f)==-1&&f.target.edges.indexOf(f)==-1))throw"Edge already in source and/or target incidency list!";return f.source.edges.push(f),f.target.edges.push(f),f}},o.prototype.remove=function(u){if(u instanceof i){var l=u;if(l.getGraphManager()!=this)throw"Graph not in this graph mgr";if(!(l==this.rootGraph||l.parent!=null&&l.parent.graphManager==this))throw"Invalid parent node!";var f=[];f=f.concat(l.getEdges());for(var c,v=f.length,h=0;h=u.getRight()?l[0]+=Math.min(u.getX()-o.getX(),o.getRight()-u.getRight()):u.getX()<=o.getX()&&u.getRight()>=o.getRight()&&(l[0]+=Math.min(o.getX()-u.getX(),u.getRight()-o.getRight())),o.getY()<=u.getY()&&o.getBottom()>=u.getBottom()?l[1]+=Math.min(u.getY()-o.getY(),o.getBottom()-u.getBottom()):u.getY()<=o.getY()&&u.getBottom()>=o.getBottom()&&(l[1]+=Math.min(o.getY()-u.getY(),u.getBottom()-o.getBottom()));var v=Math.abs((u.getCenterY()-o.getCenterY())/(u.getCenterX()-o.getCenterX()));u.getCenterY()===o.getCenterY()&&u.getCenterX()===o.getCenterX()&&(v=1);var h=v*l[0],d=l[1]/v;l[0]h)return l[0]=f,l[1]=p,l[2]=v,l[3]=D,!1;if(cv)return l[0]=d,l[1]=c,l[2]=x,l[3]=h,!1;if(fv?(l[0]=y,l[1]=b,I=!0):(l[0]=g,l[1]=p,I=!0):N===k&&(f>v?(l[0]=d,l[1]=p,I=!0):(l[0]=m,l[1]=b,I=!0)),-O===k?v>f?(l[2]=C,l[3]=D,M=!0):(l[2]=x,l[3]=w,M=!0):O===k&&(v>f?(l[2]=S,l[3]=w,M=!0):(l[2]=A,l[3]=D,M=!0)),I&&M)return!1;if(f>v?c>h?(B=this.getCardinalDirection(N,k,4),_=this.getCardinalDirection(O,k,2)):(B=this.getCardinalDirection(-N,k,3),_=this.getCardinalDirection(-O,k,1)):c>h?(B=this.getCardinalDirection(-N,k,1),_=this.getCardinalDirection(-O,k,3)):(B=this.getCardinalDirection(N,k,2),_=this.getCardinalDirection(O,k,4)),!I)switch(B){case 1:G=p,F=f+-T/k,l[0]=F,l[1]=G;break;case 2:F=m,G=c+E*k,l[0]=F,l[1]=G;break;case 3:G=b,F=f+T/k,l[0]=F,l[1]=G;break;case 4:F=y,G=c+-E*k,l[0]=F,l[1]=G;break}if(!M)switch(_){case 1:Y=w,H=v+-R/k,l[2]=H,l[3]=Y;break;case 2:H=A,Y=h+L*k,l[2]=H,l[3]=Y;break;case 3:Y=D,H=v+R/k,l[2]=H,l[3]=Y;break;case 4:H=C,Y=h+-L*k,l[2]=H,l[3]=Y;break}}return!1},s.getCardinalDirection=function(o,u,l){return o>u?l:1+l%4},s.getIntersection=function(o,u,l,f){if(f==null)return this.getIntersection2(o,u,l);var c=o.x,v=o.y,h=u.x,d=u.y,p=l.x,g=l.y,y=f.x,b=f.y,m=void 0,E=void 0,T=void 0,S=void 0,w=void 0,x=void 0,C=void 0,D=void 0,A=void 0;return T=d-v,w=c-h,C=h*v-c*d,S=b-g,x=p-y,D=y*g-p*b,A=T*x-S*w,A===0?null:(m=(w*D-x*C)/A,E=(S*C-T*D)/A,new i(m,E))},s.angleOfVector=function(o,u,l,f){var c=void 0;return o!==l?(c=Math.atan((f-u)/(l-o)),l0?1:s<0?-1:0},i.floor=function(s){return s<0?Math.ceil(s):Math.floor(s)},i.ceil=function(s){return s<0?Math.floor(s):Math.ceil(s)},r.exports=i},function(r,a,n){function i(){}i.MAX_VALUE=2147483647,i.MIN_VALUE=-2147483648,r.exports=i},function(r,a,n){var i=function(){function c(v,h){for(var d=0;d"u"?"undefined":i(o);return o==null||u!="object"&&u!="function"},r.exports=s},function(r,a,n){function i(p){if(Array.isArray(p)){for(var g=0,y=Array(p.length);g0&&g;){for(T.push(w[0]);T.length>0&&g;){var x=T[0];T.splice(0,1),E.add(x);for(var C=x.getEdges(),m=0;m-1&&w.splice(R,1)}E=new Set,S=new Map}}return p},d.prototype.createDummyNodesForBendpoints=function(p){for(var g=[],y=p.source,b=this.graphManager.calcLowestCommonAncestor(p.source,p.target),m=0;m0){for(var b=this.edgeToDummyNodes.get(y),m=0;m=0&&g.splice(D,1);var A=S.getNeighborsList();A.forEach(function(I){if(y.indexOf(I)<0){var M=b.get(I),N=M-1;N==1&&x.push(I),b.set(I,N)}})}y=y.concat(x),(g.length==1||g.length==2)&&(m=!0,E=g[0])}return E},d.prototype.setGraphManager=function(p){this.graphManager=p},r.exports=d},function(r,a,n){function i(){}i.seed=1,i.x=0,i.nextDouble=function(){return i.x=Math.sin(i.seed++)*1e4,i.x-Math.floor(i.x)},r.exports=i},function(r,a,n){var i=n(4);function s(o,u){this.lworldOrgX=0,this.lworldOrgY=0,this.ldeviceOrgX=0,this.ldeviceOrgY=0,this.lworldExtX=1,this.lworldExtY=1,this.ldeviceExtX=1,this.ldeviceExtY=1}s.prototype.getWorldOrgX=function(){return this.lworldOrgX},s.prototype.setWorldOrgX=function(o){this.lworldOrgX=o},s.prototype.getWorldOrgY=function(){return this.lworldOrgY},s.prototype.setWorldOrgY=function(o){this.lworldOrgY=o},s.prototype.getWorldExtX=function(){return this.lworldExtX},s.prototype.setWorldExtX=function(o){this.lworldExtX=o},s.prototype.getWorldExtY=function(){return this.lworldExtY},s.prototype.setWorldExtY=function(o){this.lworldExtY=o},s.prototype.getDeviceOrgX=function(){return this.ldeviceOrgX},s.prototype.setDeviceOrgX=function(o){this.ldeviceOrgX=o},s.prototype.getDeviceOrgY=function(){return this.ldeviceOrgY},s.prototype.setDeviceOrgY=function(o){this.ldeviceOrgY=o},s.prototype.getDeviceExtX=function(){return this.ldeviceExtX},s.prototype.setDeviceExtX=function(o){this.ldeviceExtX=o},s.prototype.getDeviceExtY=function(){return this.ldeviceExtY},s.prototype.setDeviceExtY=function(o){this.ldeviceExtY=o},s.prototype.transformX=function(o){var u=0,l=this.lworldExtX;return l!=0&&(u=this.ldeviceOrgX+(o-this.lworldOrgX)*this.ldeviceExtX/l),u},s.prototype.transformY=function(o){var u=0,l=this.lworldExtY;return l!=0&&(u=this.ldeviceOrgY+(o-this.lworldOrgY)*this.ldeviceExtY/l),u},s.prototype.inverseTransformX=function(o){var u=0,l=this.ldeviceExtX;return l!=0&&(u=this.lworldOrgX+(o-this.ldeviceOrgX)*this.lworldExtX/l),u},s.prototype.inverseTransformY=function(o){var u=0,l=this.ldeviceExtY;return l!=0&&(u=this.lworldOrgY+(o-this.ldeviceOrgY)*this.lworldExtY/l),u},s.prototype.inverseTransformPoint=function(o){var u=new i(this.inverseTransformX(o.x),this.inverseTransformY(o.y));return u},r.exports=s},function(r,a,n){function i(h){if(Array.isArray(h)){for(var d=0,p=Array(h.length);do.ADAPTATION_LOWER_NODE_LIMIT&&(this.coolingFactor=Math.max(this.coolingFactor*o.COOLING_ADAPTATION_FACTOR,this.coolingFactor-(h-o.ADAPTATION_LOWER_NODE_LIMIT)/(o.ADAPTATION_UPPER_NODE_LIMIT-o.ADAPTATION_LOWER_NODE_LIMIT)*this.coolingFactor*(1-o.COOLING_ADAPTATION_FACTOR))),this.maxNodeDisplacement=o.MAX_NODE_DISPLACEMENT_INCREMENTAL):(h>o.ADAPTATION_LOWER_NODE_LIMIT?this.coolingFactor=Math.max(o.COOLING_ADAPTATION_FACTOR,1-(h-o.ADAPTATION_LOWER_NODE_LIMIT)/(o.ADAPTATION_UPPER_NODE_LIMIT-o.ADAPTATION_LOWER_NODE_LIMIT)*(1-o.COOLING_ADAPTATION_FACTOR)):this.coolingFactor=1,this.initialCoolingFactor=this.coolingFactor,this.maxNodeDisplacement=o.MAX_NODE_DISPLACEMENT),this.maxIterations=Math.max(this.getAllNodes().length*5,this.maxIterations),this.totalDisplacementThreshold=this.displacementThresholdPerNode*this.getAllNodes().length,this.repulsionRange=this.calcRepulsionRange()},c.prototype.calcSpringForces=function(){for(var h=this.getAllEdges(),d,p=0;p0&&arguments[0]!==void 0?arguments[0]:!0,d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,p,g,y,b,m=this.getAllNodes(),E;if(this.useFRGridVariant)for(this.totalIterations%o.GRID_CALCULATION_CHECK_PERIOD==1&&h&&this.updateGrid(),E=new Set,p=0;pT||E>T)&&(h.gravitationForceX=-this.gravityConstant*y,h.gravitationForceY=-this.gravityConstant*b)):(T=d.getEstimatedSize()*this.compoundGravityRangeFactor,(m>T||E>T)&&(h.gravitationForceX=-this.gravityConstant*y*this.compoundGravityConstant,h.gravitationForceY=-this.gravityConstant*b*this.compoundGravityConstant))},c.prototype.isConverged=function(){var h,d=!1;return this.totalIterations>this.maxIterations/3&&(d=Math.abs(this.totalDisplacement-this.oldTotalDisplacement)<2),h=this.totalDisplacement=m.length||T>=m[0].length)){for(var S=0;Sc}}]),l}();r.exports=u},function(r,a,n){var i=function(){function u(l,f){for(var c=0;c2&&arguments[2]!==void 0?arguments[2]:1,v=arguments.length>3&&arguments[3]!==void 0?arguments[3]:-1,h=arguments.length>4&&arguments[4]!==void 0?arguments[4]:-1;s(this,u),this.sequence1=l,this.sequence2=f,this.match_score=c,this.mismatch_penalty=v,this.gap_penalty=h,this.iMax=l.length+1,this.jMax=f.length+1,this.grid=new Array(this.iMax);for(var d=0;d=0;l--){var f=this.listeners[l];f.event===o&&f.callback===u&&this.listeners.splice(l,1)}},s.emit=function(o,u){for(var l=0;lf.coolingFactor*f.maxNodeDisplacement&&(this.displacementX=f.coolingFactor*f.maxNodeDisplacement*o.sign(this.displacementX)),Math.abs(this.displacementY)>f.coolingFactor*f.maxNodeDisplacement&&(this.displacementY=f.coolingFactor*f.maxNodeDisplacement*o.sign(this.displacementY)),this.child==null?this.moveBy(this.displacementX,this.displacementY):this.child.getNodes().length==0?this.moveBy(this.displacementX,this.displacementY):this.propogateDisplacementToChildren(this.displacementX,this.displacementY),f.totalDisplacement+=Math.abs(this.displacementX)+Math.abs(this.displacementY),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0},u.prototype.propogateDisplacementToChildren=function(f,c){for(var v=this.getChild().getNodes(),h,d=0;d0)this.positionNodesRadially(w);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var x=new Set(this.getAllNodes()),C=this.nodesWithGravity.filter(function(D){return x.has(D)});this.graphManager.setAllNodesToApplyGravitation(C),this.positionNodesRandomly()}}return this.initSpringEmbedder(),this.runSpringEmbedder(),!0},T.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished)if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0;if(this.totalIterations%v.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged())if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0;this.coolingCycle++,this.layoutQuality==0?this.coolingAdjuster=this.coolingCycle:this.layoutQuality==1&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-Math.pow(this.coolingCycle,Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var w=new Set(this.getAllNodes()),x=this.nodesWithGravity.filter(function(A){return w.has(A)});this.graphManager.setAllNodesToApplyGravitation(x),this.graphManager.updateBounds(),this.updateGrid(),this.coolingFactor=v.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),this.coolingFactor=v.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var C=!this.isTreeGrowing&&!this.isGrowthFinished,D=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(C,D),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},T.prototype.getPositionsData=function(){for(var w=this.graphManager.getAllNodes(),x={},C=0;C1){var I;for(I=0;ID&&(D=Math.floor(R.y)),L=Math.floor(R.x+c.DEFAULT_COMPONENT_SEPERATION)}this.transform(new p(h.WORLD_CENTER_X-R.x/2,h.WORLD_CENTER_Y-R.y/2))},T.radialLayout=function(w,x,C){var D=Math.max(this.maxDiagonalInTree(w),c.DEFAULT_RADIAL_SEPARATION);T.branchRadialLayout(x,null,0,359,0,D);var A=m.calculateBounds(w),L=new E;L.setDeviceOrgX(A.getMinX()),L.setDeviceOrgY(A.getMinY()),L.setWorldOrgX(C.x),L.setWorldOrgY(C.y);for(var R=0;R1;){var Y=H[0];H.splice(0,1);var X=k.indexOf(Y);X>=0&&k.splice(X,1),F--,B--}x!=null?G=(k.indexOf(H[0])+1)%F:G=0;for(var W=Math.abs(D-C)/B,ee=G;_!=B;ee=++ee%F){var ae=k[ee].getOtherEnd(w);if(ae!=x){var J=(C+_*W)%360,z=(J+W)%360;T.branchRadialLayout(ae,w,J,z,A+L,L),_++}}},T.maxDiagonalInTree=function(w){for(var x=y.MIN_VALUE,C=0;Cx&&(x=A)}return x},T.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},T.prototype.groupZeroDegreeMembers=function(){var w=this,x={};this.memberGroups={},this.idToDummyNode={};for(var C=[],D=this.graphManager.getAllNodes(),A=0;A"u"&&(x[I]=[]),x[I]=x[I].concat(L)}Object.keys(x).forEach(function(M){if(x[M].length>1){var N="DummyCompound_"+M;w.memberGroups[N]=x[M];var O=x[M][0].getParent(),k=new l(w.graphManager);k.id=N,k.paddingLeft=O.paddingLeft||0,k.paddingRight=O.paddingRight||0,k.paddingBottom=O.paddingBottom||0,k.paddingTop=O.paddingTop||0,w.idToDummyNode[N]=k;var B=w.getGraphManager().add(w.newGraph(),k),_=O.getChild();_.add(k);for(var F=0;F=0;w--){var x=this.compoundOrder[w],C=x.id,D=x.paddingLeft,A=x.paddingTop;this.adjustLocations(this.tiledMemberPack[C],x.rect.x,x.rect.y,D,A)}},T.prototype.repopulateZeroDegreeMembers=function(){var w=this,x=this.tiledZeroDegreePack;Object.keys(x).forEach(function(C){var D=w.idToDummyNode[C],A=D.paddingLeft,L=D.paddingTop;w.adjustLocations(x[C],D.rect.x,D.rect.y,A,L)})},T.prototype.getToBeTiled=function(w){var x=w.id;if(this.toBeTiled[x]!=null)return this.toBeTiled[x];var C=w.getChild();if(C==null)return this.toBeTiled[x]=!1,!1;for(var D=C.getNodes(),A=0;A0)return this.toBeTiled[x]=!1,!1;if(L.getChild()==null){this.toBeTiled[L.id]=!1;continue}if(!this.getToBeTiled(L))return this.toBeTiled[x]=!1,!1}return this.toBeTiled[x]=!0,!0},T.prototype.getNodeDegree=function(w){w.id;for(var x=w.getEdges(),C=0,D=0;DM&&(M=O.rect.height)}C+=M+w.verticalPadding}},T.prototype.tileCompoundMembers=function(w,x){var C=this;this.tiledMemberPack=[],Object.keys(w).forEach(function(D){var A=x[D];C.tiledMemberPack[D]=C.tileNodes(w[D],A.paddingLeft+A.paddingRight),A.rect.width=C.tiledMemberPack[D].width,A.rect.height=C.tiledMemberPack[D].height})},T.prototype.tileNodes=function(w,x){var C=c.TILING_PADDING_VERTICAL,D=c.TILING_PADDING_HORIZONTAL,A={rows:[],rowWidth:[],rowHeight:[],width:0,height:x,verticalPadding:C,horizontalPadding:D};w.sort(function(I,M){return I.rect.width*I.rect.height>M.rect.width*M.rect.height?-1:I.rect.width*I.rect.height0&&(R+=w.horizontalPadding),w.rowWidth[C]=R,w.width0&&(I+=w.verticalPadding);var M=0;I>w.rowHeight[C]&&(M=w.rowHeight[C],w.rowHeight[C]=I,M=w.rowHeight[C]-M),w.height+=M,w.rows[C].push(x)},T.prototype.getShortestRowIndex=function(w){for(var x=-1,C=Number.MAX_VALUE,D=0;DC&&(x=D,C=w.rowWidth[D]);return x},T.prototype.canAddHorizontal=function(w,x,C){var D=this.getShortestRowIndex(w);if(D<0)return!0;var A=w.rowWidth[D];if(A+w.horizontalPadding+x<=w.width)return!0;var L=0;w.rowHeight[D]0&&(L=C+w.verticalPadding-w.rowHeight[D]);var R;w.width-A>=x+w.horizontalPadding?R=(w.height+L)/(A+x+w.horizontalPadding):R=(w.height+L)/w.width,L=C+w.verticalPadding;var I;return w.widthL&&x!=C){D.splice(-1,1),w.rows[C].push(A),w.rowWidth[x]=w.rowWidth[x]-L,w.rowWidth[C]=w.rowWidth[C]+L,w.width=w.rowWidth[instance.getLongestRowIndex(w)];for(var R=Number.MIN_VALUE,I=0;IR&&(R=D[I].height);x>0&&(R+=w.verticalPadding);var M=w.rowHeight[x]+w.rowHeight[C];w.rowHeight[x]=R,w.rowHeight[C]0)for(var _=A;_<=L;_++)B[0]+=this.grid[_][R-1].length+this.grid[_][R].length-1;if(L0)for(var _=R;_<=I;_++)B[3]+=this.grid[A-1][_].length+this.grid[A][_].length-1;for(var F=y.MAX_VALUE,G,H,Y=0;Y0){var I;I=E.getGraphManager().add(E.newGraph(),C),this.processChildrenList(I,x,E)}}},p.prototype.stop=function(){return this.stopped=!0,this};var y=function(m){m("layout","cose-bilkent",p)};typeof cytoscape<"u"&&y(cytoscape),a.exports=y}])})}(En)),En.exports}var u0=o0();const l0=Cv(u0);var ro=function(){var t=function(E,T,S,w){for(S=S||{},w=E.length;w--;S[E[w]]=T);return S},e=[1,4],r=[1,13],a=[1,12],n=[1,15],i=[1,16],s=[1,20],o=[1,19],u=[6,7,8],l=[1,26],f=[1,24],c=[1,25],v=[6,7,11],h=[1,6,13,15,16,19,22],d=[1,33],p=[1,34],g=[1,6,7,11,13,15,16,19,22],y={trace:function(){},yy:{},symbols_:{error:2,start:3,mindMap:4,spaceLines:5,SPACELINE:6,NL:7,MINDMAP:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,node:14,ICON:15,CLASS:16,nodeWithId:17,nodeWithoutId:18,NODE_DSTART:19,NODE_DESCR:20,NODE_DEND:21,NODE_ID:22,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"MINDMAP",11:"EOF",13:"SPACELIST",15:"ICON",16:"CLASS",19:"NODE_DSTART",20:"NODE_DESCR",21:"NODE_DEND",22:"NODE_ID"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,2],[12,2],[12,2],[12,1],[12,1],[12,1],[12,1],[12,1],[14,1],[14,1],[18,3],[17,1],[17,4]],performAction:function(T,S,w,x,C,D,A){var L=D.length-1;switch(C){case 6:case 7:return x;case 8:x.getLogger().trace("Stop NL ");break;case 9:x.getLogger().trace("Stop EOF ");break;case 11:x.getLogger().trace("Stop NL2 ");break;case 12:x.getLogger().trace("Stop EOF2 ");break;case 15:x.getLogger().info("Node: ",D[L].id),x.addNode(D[L-1].length,D[L].id,D[L].descr,D[L].type);break;case 16:x.getLogger().trace("Icon: ",D[L]),x.decorateNode({icon:D[L]});break;case 17:case 21:x.decorateNode({class:D[L]});break;case 18:x.getLogger().trace("SPACELIST");break;case 19:x.getLogger().trace("Node: ",D[L].id),x.addNode(0,D[L].id,D[L].descr,D[L].type);break;case 20:x.decorateNode({icon:D[L]});break;case 25:x.getLogger().trace("node found ..",D[L-2]),this.$={id:D[L-1],descr:D[L-1],type:x.getType(D[L-2],D[L])};break;case 26:this.$={id:D[L],descr:D[L],type:x.nodeType.DEFAULT};break;case 27:x.getLogger().trace("node found ..",D[L-3]),this.$={id:D[L-3],descr:D[L-1],type:x.getType(D[L-2],D[L])};break}},table:[{3:1,4:2,5:3,6:[1,5],8:e},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:e},{6:r,7:[1,10],9:9,12:11,13:a,14:14,15:n,16:i,17:17,18:18,19:s,22:o},t(u,[2,3]),{1:[2,2]},t(u,[2,4]),t(u,[2,5]),{1:[2,6],6:r,12:21,13:a,14:14,15:n,16:i,17:17,18:18,19:s,22:o},{6:r,9:22,12:11,13:a,14:14,15:n,16:i,17:17,18:18,19:s,22:o},{6:l,7:f,10:23,11:c},t(v,[2,22],{17:17,18:18,14:27,15:[1,28],16:[1,29],19:s,22:o}),t(v,[2,18]),t(v,[2,19]),t(v,[2,20]),t(v,[2,21]),t(v,[2,23]),t(v,[2,24]),t(v,[2,26],{19:[1,30]}),{20:[1,31]},{6:l,7:f,10:32,11:c},{1:[2,7],6:r,12:21,13:a,14:14,15:n,16:i,17:17,18:18,19:s,22:o},t(h,[2,14],{7:d,11:p}),t(g,[2,8]),t(g,[2,9]),t(g,[2,10]),t(v,[2,15]),t(v,[2,16]),t(v,[2,17]),{20:[1,35]},{21:[1,36]},t(h,[2,13],{7:d,11:p}),t(g,[2,11]),t(g,[2,12]),{21:[1,37]},t(v,[2,25]),t(v,[2,27])],defaultActions:{2:[2,1],6:[2,2]},parseError:function(T,S){if(S.recoverable)this.trace(T);else{var w=new Error(T);throw w.hash=S,w}},parse:function(T){var S=this,w=[0],x=[],C=[null],D=[],A=this.table,L="",R=0,I=0,M=2,N=1,O=D.slice.call(arguments,1),k=Object.create(this.lexer),B={yy:{}};for(var _ in this.yy)Object.prototype.hasOwnProperty.call(this.yy,_)&&(B.yy[_]=this.yy[_]);k.setInput(T,B.yy),B.yy.lexer=k,B.yy.parser=this,typeof k.yylloc>"u"&&(k.yylloc={});var F=k.yylloc;D.push(F);var G=k.options&&k.options.ranges;typeof B.yy.parseError=="function"?this.parseError=B.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function H(){var re;return re=x.pop()||k.lex()||N,typeof re!="number"&&(re instanceof Array&&(x=re,re=x.pop()),re=S.symbols_[re]||re),re}for(var Y,X,W,ee,ae={},J,z,V,q;;){if(X=w[w.length-1],this.defaultActions[X]?W=this.defaultActions[X]:((Y===null||typeof Y>"u")&&(Y=H()),W=A[X]&&A[X][Y]),typeof W>"u"||!W.length||!W[0]){var Z="";q=[];for(J in A[X])this.terminals_[J]&&J>M&&q.push("'"+this.terminals_[J]+"'");k.showPosition?Z="Parse error on line "+(R+1)+`: `+k.showPosition()+` Expecting `+q.join(", ")+", got '"+(this.terminals_[Y]||Y)+"'":Z="Parse error on line "+(R+1)+": Unexpected "+(Y==N?"end of input":"'"+(this.terminals_[Y]||Y)+"'"),this.parseError(Z,{text:k.match,token:this.terminals_[Y]||Y,line:k.yylineno,loc:F,expected:q})}if(W[0]instanceof Array&&W.length>1)throw new Error("Parse Error: multiple actions possible at state: "+X+", token: "+Y);switch(W[0]){case 1:w.push(Y),C.push(k.yytext),D.push(k.yylloc),w.push(W[1]),Y=null,I=k.yyleng,L=k.yytext,R=k.yylineno,F=k.yylloc;break;case 2:if(z=this.productions_[W[1]][1],ae.$=C[C.length-z],ae._$={first_line:D[D.length-(z||1)].first_line,last_line:D[D.length-1].last_line,first_column:D[D.length-(z||1)].first_column,last_column:D[D.length-1].last_column},G&&(ae._$.range=[D[D.length-(z||1)].range[0],D[D.length-1].range[1]]),ee=this.performAction.apply(ae,[L,I,R,B.yy,W[1],C,D].concat(O)),typeof ee<"u")return ee;z&&(w=w.slice(0,-1*z*2),C=C.slice(0,-1*z),D=D.slice(0,-1*z)),w.push(this.productions_[W[1]][0]),C.push(ae.$),D.push(ae._$),V=A[w[w.length-2]][w[w.length-1]],w.push(V);break;case 3:return!0}}return!0}},b=function(){var E={EOF:1,parseError:function(S,w){if(this.yy.parser)this.yy.parser.parseError(S,w);else throw new Error(S)},setInput:function(T,S){return this.yy=S||this.yy||{},this._input=T,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var T=this._input[0];this.yytext+=T,this.yyleng++,this.offset++,this.match+=T,this.matched+=T;var S=T.match(/(?:\r\n?|\n).*/g);return S?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),T},unput:function(T){var S=T.length,w=T.split(/(?:\r\n?|\n)/g);this._input=T+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-S),this.offset-=S;var x=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),w.length-1&&(this.yylineno-=w.length-1);var C=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:w?(w.length===x.length?this.yylloc.first_column:0)+x[x.length-w.length].length-w[0].length:this.yylloc.first_column-S},this.options.ranges&&(this.yylloc.range=[C[0],C[0]+this.yyleng-S]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true). `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},less:function(T){this.unput(this.match.slice(T))},pastInput:function(){var T=this.matched.substr(0,this.matched.length-this.match.length);return(T.length>20?"...":"")+T.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var T=this.match;return T.length<20&&(T+=this._input.substr(0,20-T.length)),(T.substr(0,20)+(T.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var T=this.pastInput(),S=new Array(T.length+1).join("-");return T+this.upcomingInput()+` `+S+"^"},test_match:function(T,S){var w,x,C;if(this.options.backtrack_lexer&&(C={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(C.yylloc.range=this.yylloc.range.slice(0))),x=T[0].match(/(?:\r\n?|\n).*/g),x&&(this.yylineno+=x.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:x?x[x.length-1].length-x[x.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+T[0].length},this.yytext+=T[0],this.match+=T[0],this.matches=T,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(T[0].length),this.matched+=T[0],w=this.performAction.call(this,this.yy,this,S,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),w)return w;if(this._backtrack){for(var D in C)this[D]=C[D];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var T,S,w,x;this._more||(this.yytext="",this.match="");for(var C=this._currentRules(),D=0;DS[0].length)){if(S=w,x=D,this.options.backtrack_lexer){if(T=this.test_match(w,C[D]),T!==!1)return T;if(this._backtrack){S=!1;continue}else return!1}else if(!this.options.flex)break}return S?(T=this.test_match(S,C[x]),T!==!1?T:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text. `+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var S=this.next();return S||this.lex()},begin:function(S){this.conditionStack.push(S)},popState:function(){var S=this.conditionStack.length-1;return S>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(S){return S=this.conditionStack.length-1-Math.abs(S||0),S>=0?this.conditionStack[S]:"INITIAL"},pushState:function(S){this.begin(S)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(S,w,x,C){switch(x){case 0:return S.getLogger().trace("Found comment",w.yytext),6;case 1:return 8;case 2:this.begin("CLASS");break;case 3:return this.popState(),16;case 4:this.popState();break;case 5:S.getLogger().trace("Begin icon"),this.begin("ICON");break;case 6:return S.getLogger().trace("SPACELINE"),6;case 7:return 7;case 8:return 15;case 9:S.getLogger().trace("end icon"),this.popState();break;case 10:return S.getLogger().trace("Exploding node"),this.begin("NODE"),19;case 11:return S.getLogger().trace("Cloud"),this.begin("NODE"),19;case 12:return S.getLogger().trace("Explosion Bang"),this.begin("NODE"),19;case 13:return S.getLogger().trace("Cloud Bang"),this.begin("NODE"),19;case 14:return this.begin("NODE"),19;case 15:return this.begin("NODE"),19;case 16:return this.begin("NODE"),19;case 17:return this.begin("NODE"),19;case 18:return 13;case 19:return 22;case 20:return 11;case 21:this.begin("NSTR2");break;case 22:return"NODE_DESCR";case 23:this.popState();break;case 24:S.getLogger().trace("Starting NSTR"),this.begin("NSTR");break;case 25:return S.getLogger().trace("description:",w.yytext),"NODE_DESCR";case 26:this.popState();break;case 27:return this.popState(),S.getLogger().trace("node end ))"),"NODE_DEND";case 28:return this.popState(),S.getLogger().trace("node end )"),"NODE_DEND";case 29:return this.popState(),S.getLogger().trace("node end ...",w.yytext),"NODE_DEND";case 30:return this.popState(),S.getLogger().trace("node end (("),"NODE_DEND";case 31:return this.popState(),S.getLogger().trace("node end (-"),"NODE_DEND";case 32:return this.popState(),S.getLogger().trace("node end (-"),"NODE_DEND";case 33:return this.popState(),S.getLogger().trace("node end (("),"NODE_DEND";case 34:return this.popState(),S.getLogger().trace("node end (("),"NODE_DEND";case 35:return S.getLogger().trace("Long description:",w.yytext),20;case 36:return S.getLogger().trace("Long description:",w.yytext),20}},rules:[/^(?:\s*%%.*)/i,/^(?:mindmap\b)/i,/^(?::::)/i,/^(?:.+)/i,/^(?:\n)/i,/^(?:::icon\()/i,/^(?:[\s]+[\n])/i,/^(?:[\n]+)/i,/^(?:[^\)]+)/i,/^(?:\))/i,/^(?:-\))/i,/^(?:\(-)/i,/^(?:\)\))/i,/^(?:\))/i,/^(?:\(\()/i,/^(?:\{\{)/i,/^(?:\()/i,/^(?:\[)/i,/^(?:[\s]+)/i,/^(?:[^\(\[\n\)\{\}]+)/i,/^(?:$)/i,/^(?:["][`])/i,/^(?:[^`"]+)/i,/^(?:[`]["])/i,/^(?:["])/i,/^(?:[^"]+)/i,/^(?:["])/i,/^(?:[\)]\))/i,/^(?:[\)])/i,/^(?:[\]])/i,/^(?:\}\})/i,/^(?:\(-)/i,/^(?:-\))/i,/^(?:\(\()/i,/^(?:\()/i,/^(?:[^\)\]\(\}]+)/i,/^(?:.+(?!\(\())/i],conditions:{CLASS:{rules:[3,4],inclusive:!1},ICON:{rules:[8,9],inclusive:!1},NSTR2:{rules:[22,23],inclusive:!1},NSTR:{rules:[25,26],inclusive:!1},NODE:{rules:[21,24,27,28,29,30,31,32,33,34,35,36],inclusive:!1},INITIAL:{rules:[0,1,2,5,6,7,10,11,12,13,14,15,16,17,18,19,20],inclusive:!0}}};return E}();y.lexer=b;function m(){this.yy={}}return m.prototype=y,y.Parser=m,new m}();ro.parser=ro;const f0=ro;let Ft=[],nv=0,Io={};const c0=()=>{Ft=[],nv=0,Io={}},v0=function(t){for(let e=Ft.length-1;e>=0;e--)if(Ft[e].levelFt.length>0?Ft[0]:null,d0=(t,e,r,a)=>{var n,i;Nr.info("addNode",t,e,r,a);const s=ao();let o=((n=s.mindmap)==null?void 0:n.padding)??Cn.mindmap.padding;switch(a){case rt.ROUNDED_RECT:case rt.RECT:case rt.HEXAGON:o*=2}const u={id:nv++,nodeId:Dn(e,s),level:t,descr:Dn(r,s),type:a,children:[],width:((i=s.mindmap)==null?void 0:i.maxNodeWidth)??Cn.mindmap.maxNodeWidth,padding:o},l=v0(t);if(l)l.children.push(u),Ft.push(u);else if(Ft.length===0)Ft.push(u);else throw new Error('There can be only one root. No parent could be found for ("'+u.descr+'")')},rt={DEFAULT:0,NO_BORDER:0,ROUNDED_RECT:1,RECT:2,CIRCLE:3,CLOUD:4,BANG:5,HEXAGON:6},g0=(t,e)=>{switch(Nr.debug("In get type",t,e),t){case"[":return rt.RECT;case"(":return e===")"?rt.ROUNDED_RECT:rt.CLOUD;case"((":return rt.CIRCLE;case")":return rt.CLOUD;case"))":return rt.BANG;case"{{":return rt.HEXAGON;default:return rt.DEFAULT}},p0=(t,e)=>{Io[t]=e},y0=t=>{if(!t)return;const e=ao(),r=Ft[Ft.length-1];t.icon&&(r.icon=Dn(t.icon,e)),t.class&&(r.class=Dn(t.class,e))},m0=t=>{switch(t){case rt.DEFAULT:return"no-border";case rt.RECT:return"rect";case rt.ROUNDED_RECT:return"rounded-rect";case rt.CIRCLE:return"circle";case rt.CLOUD:return"cloud";case rt.BANG:return"bang";case rt.HEXAGON:return"hexgon";default:return"no-border"}},b0=()=>Nr,w0=t=>Io[t],E0={clear:c0,addNode:d0,getMindmap:h0,nodeType:rt,getType:g0,setElementForId:p0,decorateNode:y0,type2Str:m0,getLogger:b0,getElementById:w0},x0=E0,T0=12,C0=function(t,e,r,a){e.append("path").attr("id","node-"+r.id).attr("class","node-bkg node-"+t.type2Str(r.type)).attr("d",`M0 ${r.height-5} v${-r.height+2*5} q0,-5 5,-5 h${r.width-2*5} q5,0 5,5 v${r.height-5} H0 Z`),e.append("line").attr("class","node-line-"+a).attr("x1",0).attr("y1",r.height).attr("x2",r.width).attr("y2",r.height)},D0=function(t,e,r){e.append("rect").attr("id","node-"+r.id).attr("class","node-bkg node-"+t.type2Str(r.type)).attr("height",r.height).attr("width",r.width)},S0=function(t,e,r){const a=r.width,n=r.height,i=.15*a,s=.25*a,o=.35*a,u=.2*a;e.append("path").attr("id","node-"+r.id).attr("class","node-bkg node-"+t.type2Str(r.type)).attr("d",`M0 0 a${i},${i} 0 0,1 ${a*.25},${-1*a*.1} a${o},${o} 1 0,1 ${a*.4},${-1*a*.1} a${s},${s} 1 0,1 ${a*.35},${1*a*.2} a${i},${i} 1 0,1 ${a*.15},${1*n*.35} a${u},${u} 1 0,1 ${-1*a*.15},${1*n*.65} a${s},${i} 1 0,1 ${-1*a*.25},${a*.15} a${o},${o} 1 0,1 ${-1*a*.5},0 a${i},${i} 1 0,1 ${-1*a*.25},${-1*a*.15} a${i},${i} 1 0,1 ${-1*a*.1},${-1*n*.35} a${u},${u} 1 0,1 ${a*.1},${-1*n*.65} H0 V0 Z`)},A0=function(t,e,r){const a=r.width,n=r.height,i=.15*a;e.append("path").attr("id","node-"+r.id).attr("class","node-bkg node-"+t.type2Str(r.type)).attr("d",`M0 0 a${i},${i} 1 0,0 ${a*.25},${-1*n*.1} a${i},${i} 1 0,0 ${a*.25},0 a${i},${i} 1 0,0 ${a*.25},0 a${i},${i} 1 0,0 ${a*.25},${1*n*.1} a${i},${i} 1 0,0 ${a*.15},${1*n*.33} a${i*.8},${i*.8} 1 0,0 0,${1*n*.34} a${i},${i} 1 0,0 ${-1*a*.15},${1*n*.33} a${i},${i} 1 0,0 ${-1*a*.25},${n*.15} a${i},${i} 1 0,0 ${-1*a*.25},0 a${i},${i} 1 0,0 ${-1*a*.25},0 a${i},${i} 1 0,0 ${-1*a*.25},${-1*n*.15} a${i},${i} 1 0,0 ${-1*a*.1},${-1*n*.33} a${i*.8},${i*.8} 1 0,0 0,${-1*n*.34} a${i},${i} 1 0,0 ${a*.1},${-1*n*.33} H0 V0 Z`)},L0=function(t,e,r){e.append("circle").attr("id","node-"+r.id).attr("class","node-bkg node-"+t.type2Str(r.type)).attr("r",r.width/2)};function R0(t,e,r,a,n){return t.insert("polygon",":first-child").attr("points",a.map(function(i){return i.x+","+i.y}).join(" ")).attr("transform","translate("+(n.width-e)/2+", "+r+")")}const I0=function(t,e,r){const a=r.height,i=a/4,s=r.width-r.padding+2*i,o=[{x:i,y:0},{x:s-i,y:0},{x:s,y:-a/2},{x:s-i,y:-a},{x:i,y:-a},{x:0,y:-a/2}];R0(e,s,a,o,r)},P0=function(t,e,r){e.append("rect").attr("id","node-"+r.id).attr("class","node-bkg node-"+t.type2Str(r.type)).attr("height",r.height).attr("rx",r.padding).attr("ry",r.padding).attr("width",r.width)},M0=function(t,e,r,a,n){const i=n.htmlLabels,s=a%(T0-1),o=e.append("g");r.section=s;let u="section-"+s;s<0&&(u+=" section-root"),o.attr("class",(r.class?r.class+" ":"")+"mindmap-node "+u);const l=o.append("g"),f=o.append("g"),c=r.descr.replace(/()/g,` `);Dv(f,c,{useHtmlLabels:i,width:r.width,classes:"mindmap-node-label"}),i||f.attr("dy","1em").attr("alignment-baseline","middle").attr("dominant-baseline","middle").attr("text-anchor","middle");const v=f.node().getBBox(),[h]=Tv(n.fontSize);if(r.height=v.height+h*1.1*.5+r.padding,r.width=v.width+2*r.padding,r.icon)if(r.type===t.nodeType.CIRCLE)r.height+=50,r.width+=50,o.append("foreignObject").attr("height","50px").attr("width",r.width).attr("style","text-align: center;").append("div").attr("class","icon-container").append("i").attr("class","node-icon-"+s+" "+r.icon),f.attr("transform","translate("+r.width/2+", "+(r.height/2-1.5*r.padding)+")");else{r.width+=50;const d=r.height;r.height=Math.max(d,60);const p=Math.abs(r.height-d);o.append("foreignObject").attr("width","60px").attr("height",r.height).attr("style","text-align: center;margin-top:"+p/2+"px;").append("div").attr("class","icon-container").append("i").attr("class","node-icon-"+s+" "+r.icon),f.attr("transform","translate("+(25+r.width/2)+", "+(p/2+r.padding/2)+")")}else if(i){const d=(r.width-v.width)/2,p=(r.height-v.height)/2;f.attr("transform","translate("+d+", "+p+")")}else{const d=r.width/2,p=r.padding/2;f.attr("transform","translate("+d+", "+p+")")}switch(r.type){case t.nodeType.DEFAULT:C0(t,l,r,s);break;case t.nodeType.ROUNDED_RECT:P0(t,l,r);break;case t.nodeType.RECT:D0(t,l,r);break;case t.nodeType.CIRCLE:l.attr("transform","translate("+r.width/2+", "+ +r.height/2+")"),L0(t,l,r);break;case t.nodeType.CLOUD:S0(t,l,r);break;case t.nodeType.BANG:A0(t,l,r);break;case t.nodeType.HEXAGON:I0(t,l,r);break}return t.setElementForId(r.id,o),r.height},O0=function(t,e){const r=t.getElementById(e.id),a=e.x||0,n=e.y||0;r.attr("transform","translate("+a+","+n+")")};pr.use(l0);function iv(t,e,r,a,n){M0(t,e,r,a,n),r.children&&r.children.forEach((i,s)=>{iv(t,e,i,a<0?s:a,n)})}function k0(t,e){e.edges().map((r,a)=>{const n=r.data();if(r[0]._private.bodyBounds){const i=r[0]._private.rscratch;Nr.trace("Edge: ",a,n),t.insert("path").attr("d",`M ${i.startX},${i.startY} L ${i.midX},${i.midY} L${i.endX},${i.endY} `).attr("class","edge section-edge-"+n.section+" edge-depth-"+n.depth)}})}function sv(t,e,r,a){e.add({group:"nodes",data:{id:t.id.toString(),labelText:t.descr,height:t.height,width:t.width,level:a,nodeId:t.id,padding:t.padding,type:t.type},position:{x:t.x,y:t.y}}),t.children&&t.children.forEach(n=>{sv(n,e,r,a+1),e.add({group:"edges",data:{id:`${t.id}_${n.id}`,source:t.id,target:n.id,depth:a,section:n.section}})})}function N0(t,e){return new Promise(r=>{const a=xv("body").append("div").attr("id","cy").attr("style","display:none"),n=pr({container:document.getElementById("cy"),style:[{selector:"edge",style:{"curve-style":"bezier"}}]});a.remove(),sv(t,n,e,0),n.nodes().forEach(function(i){i.layoutDimensions=()=>{const s=i.data();return{w:s.width,h:s.height}}}),n.layout({name:"cose-bilkent",quality:"proof",styleEnabled:!1,animate:!1}).run(),n.ready(i=>{Nr.info("Ready",i),r(n)})})}function B0(t,e){e.nodes().map((r,a)=>{const n=r.data();n.x=r.position().x,n.y=r.position().y,O0(t,n);const i=t.getElementById(n.nodeId);Nr.info("Id:",a,"Position: (",r.position().x,", ",r.position().y,")",n),i.attr("transform",`translate(${r.position().x-n.width/2}, ${r.position().y-n.height/2})`),i.attr("attr",`apa-${a})`)})}const F0=async(t,e,r,a)=>{var n,i;Nr.debug(`Rendering mindmap diagram `+t);const s=a.db,o=s.getMindmap();if(!o)return;const u=ao();u.htmlLabels=!1;const l=wv(e),f=l.append("g");f.attr("class","mindmap-edges");const c=l.append("g");c.attr("class","mindmap-nodes"),iv(s,c,o,-1,u);const v=await N0(o,u);k0(f,v),B0(s,v),Ev(void 0,l,((n=u.mindmap)==null?void 0:n.padding)??Cn.mindmap.padding,((i=u.mindmap)==null?void 0:i.useMaxWidth)??Cn.mindmap.useMaxWidth)},_0={draw:F0},G0=t=>{let e="";for(let r=0;r` .edge { stroke-width: 3; } ${G0(t)} .section-root rect, .section-root path, .section-root circle, .section-root polygon { fill: ${t.git0}; } .section-root text { fill: ${t.gitBranchLabel0}; } .icon-container { height:100%; display: flex; justify-content: center; align-items: center; } .edge { fill: none; } .mindmap-node-label { dy: 1em; alignment-baseline: middle; text-anchor: middle; dominant-baseline: middle; text-align: center; } `,V0=z0,n1={db:x0,renderer:_0,parser:f0,styles:V0};export{n1 as diagram};