import{aJ as Kl,aK as Gl,aL as Yl,aM as bi,aN as ks,aO as Sn,aP as Xl,aQ as Ul,aR as Zl,aS as Ql,aT as Jl,aU as Ps,at as Kn,aV as jl,aW as _l,aX as ef,az as no,j as Pe,I as tf,d as ai,m as rf,r as af,f as io,L as nf,Y as of,B as sf,b as uf,q as oo,aD as lf}from"./index-3c1b2661.js";import{f as ff}from"./networks-a82d149f.js";var vf=Kl,cf=function(){return vf.Date.now()},df=cf,hf=/\s/;function gf(t){for(var e=t.length;e--&&hf.test(t.charAt(e)););return e}var pf=gf,mf=pf,yf=/^\s+/;function bf(t){return t&&t.slice(0,mf(t)+1).replace(yf,"")}var wf=bf,xf=Gl,Ef=Yl,Cf="[object Symbol]";function Sf(t){return typeof t=="symbol"||Ef(t)&&xf(t)==Cf}var Pa=Sf,Tf=wf,so=bi,Df=Pa,uo=0/0,kf=/^[-+]0x[0-9a-f]+$/i,Pf=/^0b[01]+$/i,Bf=/^0o[0-7]+$/i,Lf=parseInt;function Mf(t){if(typeof t=="number")return t;if(Df(t))return uo;if(so(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=so(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=Tf(t);var r=Pf.test(t);return r||Bf.test(t)?Lf(t.slice(2),r?2:8):kf.test(t)?uo:+t}var Of=Mf,Af=bi,Gn=df,lo=Of,Rf="Expected a function",If=Math.max,Nf=Math.min;function zf(t,e,r){var a,n,i,o,s,u,l=0,f=!1,v=!1,c=!0;if(typeof t!="function")throw new TypeError(Rf);e=lo(e)||0,Af(r)&&(f=!!r.leading,v="maxWait"in r,i=v?If(lo(r.maxWait)||0,e):i,c="trailing"in r?!!r.trailing:c);function h(C){var x=a,T=n;return a=n=void 0,l=C,o=t.apply(T,x),o}function d(C){return l=C,s=setTimeout(g,e),f?h(C):o}function p(C){var x=C-u,T=C-l,E=e-x;return v?Nf(E,i-T):E}function m(C){var x=C-u,T=C-l;return u===void 0||x>=e||x<0||v&&T>=i}function g(){var C=Gn();if(m(C))return y(C);s=setTimeout(g,p(C))}function y(C){return s=void 0,c&&a?h(C):(a=n=void 0,o)}function b(){s!==void 0&&clearTimeout(s),l=0,a=u=n=s=void 0}function w(){return s===void 0?o:y(Gn())}function S(){var C=Gn(),x=m(C);if(a=arguments,n=this,u=C,x){if(s===void 0)return d(u);if(v)return clearTimeout(s),s=setTimeout(g,e),h(u)}return s===void 0&&(s=setTimeout(g,e)),o}return S.cancel=b,S.flush=w,S}var Ff=zf,Bs={exports:{}};(function(t,e){(function(){var r,a,n,i,o,s,u,l,f,v,c,h,d,p,m;n=Math.floor,v=Math.min,a=function(g,y){return gy?1:0},f=function(g,y,b,w,S){var C;if(b==null&&(b=0),S==null&&(S=a),b<0)throw new Error("lo must be non-negative");for(w==null&&(w=g.length);bP;0<=P?E++:E--)T.push(E);return T}).apply(this).reverse(),x=[],w=0,S=C.length;wB;0<=B?++T:--T)D.push(o(g,b));return D},p=function(g,y,b,w){var S,C,x;for(w==null&&(w=a),S=g[b];b>y;){if(x=b-1>>1,C=g[x],w(S,C)<0){g[b]=C,b=x;continue}break}return g[b]=S},m=function(g,y,b){var w,S,C,x,T;for(b==null&&(b=a),S=g.length,T=y,C=g[y],w=2*y+1;wt.length)&&(e=t.length);for(var r=0,a=new Array(e);r"u"?null:window,yo=qe?qe.navigator:null;qe&&qe.document;var gc=We(""),zs=We({}),pc=We(function(){}),mc=typeof HTMLElement>"u"?"undefined":We(HTMLElement),Ma=function(e){return e&&e.instanceString&&ze(e.instanceString)?e.instanceString():null},fe=function(e){return e!=null&&We(e)==gc},ze=function(e){return e!=null&&We(e)===pc},Ae=function(e){return!ht(e)&&(Array.isArray?Array.isArray(e):e!=null&&e instanceof Array)},Ce=function(e){return e!=null&&We(e)===zs&&!Ae(e)&&e.constructor===Object},yc=function(e){return e!=null&&We(e)===zs},ne=function(e){return e!=null&&We(e)===We(1)&&!isNaN(e)},bc=function(e){return ne(e)&&Math.floor(e)===e},hn=function(e){if(mc!=="undefined")return e!=null&&e instanceof HTMLElement},ht=function(e){return Oa(e)||Fs(e)},Oa=function(e){return Ma(e)==="collection"&&e._private.single},Fs=function(e){return Ma(e)==="collection"&&!e._private.single},Si=function(e){return Ma(e)==="core"},Vs=function(e){return Ma(e)==="stylesheet"},wc=function(e){return Ma(e)==="event"},er=function(e){return e==null?!0:!!(e===""||e.match(/^\s+$/))},xc=function(e){return typeof HTMLElement>"u"?!1:e instanceof HTMLElement},Ec=function(e){return Ce(e)&&ne(e.x1)&&ne(e.x2)&&ne(e.y1)&&ne(e.y2)},Cc=function(e){return yc(e)&&ze(e.then)},Sc=function(){return yo&&yo.userAgent.match(/msie|trident|edge/i)},ya=function(e,r){r||(r=function(){if(arguments.length===1)return arguments[0];if(arguments.length===0)return"undefined";for(var i=[],o=0;or?1:0},Mc=function(e,r){return-1*qs(e,r)},ce=Object.assign!=null?Object.assign.bind(Object):function(t){for(var e=arguments,r=1;r1&&(m-=1),m<1/6?d+(p-d)*6*m:m<1/2?p:m<2/3?d+(p-d)*(2/3-m)*6:d}var v=new RegExp("^"+kc+"$").exec(e);if(v){if(a=parseInt(v[1]),a<0?a=(360- -1*a%360)%360:a>360&&(a=a%360),a/=360,n=parseFloat(v[2]),n<0||n>100||(n=n/100,i=parseFloat(v[3]),i<0||i>100)||(i=i/100,o=v[4],o!==void 0&&(o=parseFloat(o),o<0||o>1)))return;if(n===0)s=u=l=Math.round(i*255);else{var c=i<.5?i*(1+n):i+n-i*n,h=2*i-c;s=Math.round(255*f(h,c,a+1/3)),u=Math.round(255*f(h,c,a)),l=Math.round(255*f(h,c,a-1/3))}r=[s,u,l,o]}return r},Rc=function(e){var r,a=new RegExp("^"+Tc+"$").exec(e);if(a){r=[];for(var n=[],i=1;i<=3;i++){var o=a[i];if(o[o.length-1]==="%"&&(n[i]=!0),o=parseFloat(o),n[i]&&(o=o/100*255),o<0||o>255)return;r.push(Math.floor(o))}var s=n[1]||n[2]||n[3],u=n[1]&&n[2]&&n[3];if(s&&!u)return;var l=a[4];if(l!==void 0){if(l=parseFloat(l),l<0||l>1)return;r.push(l)}}return r},Ic=function(e){return zc[e.toLowerCase()]},Nc=function(e){return(Ae(e)?e:null)||Ic(e)||Oc(e)||Rc(e)||Ac(e)},zc={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]},Hs=function(e){for(var r=e.map,a=e.keys,n=a.length,i=0;i1&&arguments[1]!==void 0?arguments[1]:Ar,a=r,n;n=e.next(),!n.done;)a=a*Gs+n.value|0;return a},ba=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ar;return r*Gs+e|0},wa=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:fa;return(r<<5)+r+e|0},Vc=function(e,r){return e*2097152+r},Ut=function(e){return e[0]*2097152+e[1]},Wa=function(e,r){return[ba(e[0],r[0]),wa(e[1],r[1])]},$c=function(e,r){var a={value:0,done:!1},n=0,i=e.length,o={next:function(){return n=0&&!(e[n]===r&&(e.splice(n,1),a));n--);},Pi=function(e){e.splice(0,e.length)},Xc=function(e,r){for(var a=0;a"u"?"undefined":We(Set))!==Zc?Set:Qc,kn=function(e,r){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(e===void 0||r===void 0||!Si(e)){Ve("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"){Ve("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 Ur,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 o=r.renderedPosition,s=e.pan(),u=e.zoom();i.position={x:(o.x-s.x)/u,y:(o.y-s.y)/u}}var l=[];Ae(r.classes)?l=r.classes:fe(r.classes)&&(l=r.classes.split(/\s+/));for(var f=0,v=l.length;f0;){var C=y.pop(),x=m(C),T=C.id();if(c[T]=x,x!==1/0)for(var E=C.neighborhood().intersect(d),P=0;P0)for(N.unshift(A);v[q];){var z=v[q];N.unshift(z.edge),N.unshift(z.node),F=z.node,q=F.id()}return s.spawn(N)}}}},_c={kruskal:function(e){e=e||function(b){return 1};for(var r=this.byGroup(),a=r.nodes,n=r.edges,i=a.length,o=new Array(i),s=a,u=function(w){for(var S=0;S0;){if(S(),x++,w===f){for(var T=[],E=i,P=f,B=g[P];T.unshift(E),B!=null&&T.unshift(B),E=m[P],E!=null;)P=E.id(),B=g[P];return{found:!0,distance:v[w],path:this.spawn(T),steps:x}}h[w]=!0;for(var D=b._private.edges,M=0;MB&&(d[P]=B,y[P]=E,b[P]=S),!i){var D=E*f+T;!i&&d[D]>B&&(d[D]=B,y[D]=T,b[D]=S)}}}for(var M=0;M1&&arguments[1]!==void 0?arguments[1]:o,ge=b(ae),pe=[],ve=ge;;){if(ve==null)return r.spawn();var xe=y(ve),Q=xe.edge,k=xe.pred;if(pe.unshift(ve[0]),ve.same(ue)&&pe.length>0)break;Q!=null&&pe.unshift(Q),ve=k}return u.spawn(pe)},C=0;C=0;f--){var v=l[f],c=v[1],h=v[2];(r[c]===s&&r[h]===u||r[c]===u&&r[h]===s)&&l.splice(f,1)}for(var d=0;dn;){var i=Math.floor(Math.random()*r.length);r=sd(i,e,r),a--}return r},ud={kargerStein:function(){var e=this,r=this.byGroup(),a=r.nodes,n=r.edges;n.unmergeBy(function(N){return N.isLoop()});var i=a.length,o=n.length,s=Math.ceil(Math.pow(Math.log(i)/Math.LN2,2)),u=Math.floor(i/od);if(i<2){Ve("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,o=r;o1&&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,o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0;n?e=e.slice(r,a):(a0&&e.splice(0,r));for(var s=0,u=e.length-1;u>=0;u--){var l=e[u];o?isFinite(l)||(e[u]=-1/0,s++):e.splice(u,1)}i&&e.sort(function(c,h){return c-h});var f=e.length,v=Math.floor(f/2);return f%2!==0?e[v+1+s]:(e[v-1+s]+e[v+s])/2},hd=function(e){return Math.PI*e/180},Ka=function(e,r){return Math.atan2(r,e)-Math.PI/2},Bi=Math.log2||function(t){return Math.log(t)/Math.log(2)},_s=function(e){return e>0?1:e<0?-1:0},gr=function(e,r){return Math.sqrt(fr(e,r))},fr=function(e,r){var a=r.x-e.x,n=r.y-e.y;return a*a+n*n},gd=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}}},md=function(e){return{x1:e.x1,x2:e.x2,w:e.w,y1:e.y1,y2:e.y2,h:e.h}},yd=function(e){e.x1=1/0,e.y1=1/0,e.x2=-1/0,e.y2=-1/0,e.w=0,e.h=0},bd=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},wd=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},on=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},Un=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[0],a,n,i,o;if(r.length===1)a=n=i=o=r[0];else if(r.length===2)a=i=r[0],o=n=r[1];else if(r.length===4){var s=$t(r,4);a=s[0],n=s[1],i=s[2],o=s[3]}return e.x1-=o,e.x2+=n,e.y1-=a,e.y2+=i,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},Co=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},Li=function(e,r){return!(e.x1>r.x2||r.x1>e.x2||e.x2r.y2||r.y1>e.y2)},$r=function(e,r,a){return e.x1<=r&&r<=e.x2&&e.y1<=a&&a<=e.y2},xd=function(e,r){return $r(e,r.x,r.y)},eu=function(e,r){return $r(e,r.x1,r.y1)&&$r(e,r.x2,r.y2)},tu=function(e,r,a,n,i,o,s){var u=Aa(i,o),l=i/2,f=o/2,v;{var c=a-l+u-s,h=n-f-s,d=a+l-u+s,p=h;if(v=Jt(e,r,a,n,c,h,d,p,!1),v.length>0)return v}{var m=a+l+s,g=n-f+u-s,y=m,b=n+f-u+s;if(v=Jt(e,r,a,n,m,g,y,b,!1),v.length>0)return v}{var w=a-l+u-s,S=n+f+s,C=a+l-u+s,x=S;if(v=Jt(e,r,a,n,w,S,C,x,!1),v.length>0)return v}{var T=a-l-s,E=n-f+u-s,P=T,B=n+f-u+s;if(v=Jt(e,r,a,n,T,E,P,B,!1),v.length>0)return v}var D;{var M=a-l+u,L=n-f+u;if(D=va(e,r,a,n,M,L,u+s),D.length>0&&D[0]<=M&&D[1]<=L)return[D[0],D[1]]}{var R=a+l-u,O=n-f+u;if(D=va(e,r,a,n,R,O,u+s),D.length>0&&D[0]>=R&&D[1]<=O)return[D[0],D[1]]}{var A=a+l-u,N=n+f-u;if(D=va(e,r,a,n,A,N,u+s),D.length>0&&D[0]>=A&&D[1]>=N)return[D[0],D[1]]}{var F=a-l+u,q=n+f-u;if(D=va(e,r,a,n,F,q,u+s),D.length>0&&D[0]<=F&&D[1]>=q)return[D[0],D[1]]}return[]},Ed=function(e,r,a,n,i,o,s){var u=s,l=Math.min(a,i),f=Math.max(a,i),v=Math.min(n,o),c=Math.max(n,o);return l-u<=e&&e<=f+u&&v-u<=r&&r<=c+u},Cd=function(e,r,a,n,i,o,s,u,l){var f={x1:Math.min(a,s,i)-l,x2:Math.max(a,s,i)+l,y1:Math.min(n,u,o)-l,y2:Math.max(n,u,o)+l};return!(ef.x2||rf.y2)},Sd=function(e,r,a,n){a-=n;var i=r*r-4*e*a;if(i<0)return[];var o=Math.sqrt(i),s=2*e,u=(-r+o)/s,l=(-r-o)/s;return[u,l]},Td=function(e,r,a,n,i){var o=1e-5;e===0&&(e=o),r/=e,a/=e,n/=e;var s,u,l,f,v,c,h,d;if(u=(3*a-r*r)/9,l=-(27*n)+r*(9*a-2*(r*r)),l/=54,s=u*u*u+l*l,i[1]=0,h=r/3,s>0){v=l+Math.sqrt(s),v=v<0?-Math.pow(-v,1/3):Math.pow(v,1/3),c=l-Math.sqrt(s),c=c<0?-Math.pow(-c,1/3):Math.pow(c,1/3),i[0]=-h+v+c,h+=(v+c)/2,i[4]=i[2]=-h,h=Math.sqrt(3)*(-c+v)/2,i[3]=h,i[5]=-h;return}if(i[5]=i[3]=0,s===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)},Dd=function(e,r,a,n,i,o,s,u){var l=1*a*a-4*a*i+2*a*s+4*i*i-4*i*s+s*s+n*n-4*n*o+2*n*u+4*o*o-4*o*u+u*u,f=1*9*a*i-3*a*a-3*a*s-6*i*i+3*i*s+9*n*o-3*n*n-3*n*u-6*o*o+3*o*u,v=1*3*a*a-6*a*i+a*s-a*e+2*i*i+2*i*e-s*e+3*n*n-6*n*o+n*u-n*r+2*o*o+2*o*r-u*r,c=1*a*i-a*a+a*e-i*e+n*o-n*n+n*r-o*r,h=[];Td(l,f,v,c,h);for(var d=1e-7,p=[],m=0;m<6;m+=2)Math.abs(h[m+1])=0&&h[m]<=1&&p.push(h[m]);p.push(1),p.push(0);for(var g=-1,y,b,w,S=0;S=0?wl?(e-i)*(e-i)+(r-o)*(r-o):f-c},vt=function(e,r,a){for(var n,i,o,s,u,l=0,f=0;f=e&&e>=o||n<=e&&e<=o)u=(e-n)/(o-n)*(s-i)+i,u>r&&l++;else continue;return l%2!==0},Ht=function(e,r,a,n,i,o,s,u,l){var f=new Array(a.length),v;u[0]!=null?(v=Math.atan(u[1]/u[0]),u[0]<0?v=v+Math.PI/2:v=-v-Math.PI/2):v=u;for(var c=Math.cos(-v),h=Math.sin(-v),d=0;d0){var m=au(f,-l);p=ru(m)}else p=f;return vt(e,r,p)},Pd=function(e,r,a,n,i,o,s){for(var u=new Array(a.length),l=o/2,f=s/2,v=Mi(o,s),c=v*v,h=0;h=0&&m<=1&&y.push(m),g>=0&&g<=1&&y.push(g),y.length===0)return[];var b=y[0]*u[0]+e,w=y[0]*u[1]+r;if(y.length>1){if(y[0]==y[1])return[b,w];var S=y[1]*u[0]+e,C=y[1]*u[1]+r;return[b,w,S,C]}else return[b,w]},Zn=function(e,r,a){return r<=e&&e<=a||a<=e&&e<=r?e:e<=r&&r<=a||a<=r&&r<=e?r:a},Jt=function(e,r,a,n,i,o,s,u,l){var f=e-i,v=a-e,c=s-i,h=r-o,d=n-r,p=u-o,m=c*h-p*f,g=v*h-d*f,y=p*v-c*d;if(y!==0){var b=m/y,w=g/y,S=.001,C=0-S,x=1+S;return C<=b&&b<=x&&C<=w&&w<=x?[e+b*v,r+b*d]:l?[e+b*v,r+b*d]:[]}else return m===0||g===0?Zn(e,a,s)===s?[s,u]:Zn(e,a,i)===i?[i,o]:Zn(i,s,a)===a?[a,n]:[]:[]},Ca=function(e,r,a,n,i,o,s,u){var l=[],f,v=new Array(a.length),c=!0;o==null&&(c=!1);var h;if(c){for(var d=0;d0){var p=au(v,-u);h=ru(p)}else h=v}else h=a;for(var m,g,y,b,w=0;w2){for(var O=[l[0],l[1]],A=Math.pow(O[0]-e,2)+Math.pow(O[1]-r,2),N=1;Nf&&(f=w)},get:function(b){return l[b]}},c=0;c0?O=R.edgesTo(L)[0]:O=L.edgesTo(R)[0];var A=n(O);L=L.id(),T[L]>T[D]+A&&(T[L]=T[D]+A,E.nodes.indexOf(L)<0?E.push(L):E.updateItem(L),x[L]=0,C[L]=[]),T[L]==T[D]+A&&(x[L]=x[L]+x[D],C[L].push(D))}else for(var N=0;N0;){for(var $=S.pop(),K=0;K0&&s.push(a[u]);s.length!==0&&i.push(n.collection(s))}return i},Kd=function(e,r){for(var a=0;a5&&arguments[5]!==void 0?arguments[5]:Xd,s=n,u,l,f=0;f=2?na(e,r,a,0,Po,Ud):na(e,r,a,0,ko)},squaredEuclidean:function(e,r,a){return na(e,r,a,0,Po)},manhattan:function(e,r,a){return na(e,r,a,0,ko)},max:function(e,r,a){return na(e,r,a,-1/0,Zd)}};qr["squared-euclidean"]=qr.squaredEuclidean;qr.squaredeuclidean=qr.squaredEuclidean;function Bn(t,e,r,a,n,i){var o;return ze(t)?o=t:o=qr[t]||qr.euclidean,e===0&&ze(t)?o(n,i):o(e,r,a,n,i)}var Qd=Je({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),Oi=function(e){return Qd(e)},mn=function(e,r,a,n,i){var o=i!=="kMedoids",s=o?function(v){return a[v]}:function(v){return n[v](a)},u=function(c){return n[c](r)},l=a,f=r;return Bn(e,n.length,s,u,l,f)},Qn=function(e,r,a){for(var n=a.length,i=new Array(n),o=new Array(n),s=new Array(r),u=null,l=0;la)return!1}return!0},_d=function(e,r,a){for(var n=0;ns&&(s=r[l][f],u=f);i[u].push(e[l])}for(var v=0;v=i.threshold||i.mode==="dendrogram"&&e.length===1)return!1;var d=r[o],p=r[n[o]],m;i.mode==="dendrogram"?m={left:d,right:p,key:d.key}:m={value:d.value.concat(p.value),key:d.key},e[d.index]=m,e.splice(p.index,1),r[d.key]=m;for(var g=0;ga[p.key][y.key]&&(u=a[p.key][y.key])):i.linkage==="max"?(u=a[d.key][y.key],a[d.key][y.key]0&&n.push(i);return n},Ro=function(e,r,a){for(var n=[],i=0;is&&(o=l,s=r[i*e+l])}o>0&&n.push(o)}for(var f=0;fl&&(u=f,l=v)}a[i]=o[u]}return n=Ro(e,r,a),n},Io=function(e){for(var r=this.cy(),a=this.nodes(),n=dh(e),i={},o=0;o=B?(D=B,B=L,M=R):L>D&&(D=L);for(var O=0;O0?1:0;x[E%n.minIterations*s+$]=K,z+=K}if(z>0&&(E>=n.minIterations-1||E==n.maxIterations-1)){for(var Y=0,H=0;H1||C>1)&&(s=!0),v[b]=[],y.outgoers().forEach(function(T){T.isEdge()&&v[b].push(T.id())})}else c[b]=[void 0,y.target().id()]}):o.forEach(function(y){var b=y.id();if(y.isNode()){var w=y.degree(!0);w%2&&(u?l?s=!0:l=b:u=b),v[b]=[],y.connectedEdges().forEach(function(S){return v[b].push(S.id())})}else c[b]=[y.source().id(),y.target().id()]});var h={found:!1,trail:void 0};if(s)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=o[0].id());var d=function(b){for(var w=b,S=[b],C,x,T;v[w].length;)C=v[w].shift(),x=c[C][0],T=c[C][1],w!=T?(v[T]=v[T].filter(function(E){return E!=C}),w=T):!i&&w!=x&&(v[x]=v[x].filter(function(E){return E!=C}),w=x),S.unshift(C),S.unshift(w);return S},p=[],m=[];for(m=d(f);m.length!=1;)v[m[0]].length==0?(p.unshift(o.getElementById(m.shift())),p.unshift(o.getElementById(m.shift()))):m=d(m.shift()).concat(m);p.unshift(o.getElementById(m.shift()));for(var g in v)if(v[g].length)return h;return h.found=!0,h.trail=this.spawn(p,!0),h}},Xa=function(){var e=this,r={},a=0,n=0,i=[],o=[],s={},u=function(c,h){for(var d=o.length-1,p=[],m=e.spawn();o[d].x!=c||o[d].y!=h;)p.push(o.pop().edge),d--;p.push(o.pop().edge),p.forEach(function(g){var y=g.connectedNodes().intersection(e);m.merge(g),y.forEach(function(b){var w=b.id(),S=b.connectedEdges().intersection(e);m.merge(b),r[w].cutVertex?m.merge(S.filter(function(C){return C.isLoop()})):m.merge(S)})}),i.push(m)},l=function v(c,h,d){c===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 m,g,y,b;p.forEach(function(w){m=w.source().id(),g=w.target().id(),y=m===h?g:m,y!==d&&(b=w.id(),s[b]||(s[b]=!0,o.push({x:h,y,edge:w})),y in r?r[h].low=Math.min(r[h].low,r[y].id):(v(c,y,h),r[h].low=Math.min(r[h].low,r[y].low),r[h].id<=r[y].low&&(r[h].cutVertex=!0,u(h,y))))})}};e.forEach(function(v){if(v.isNode()){var c=v.id();c in r||(n=0,l(c,c),r[c].cutVertex=n>1)}});var f=Object.keys(r).filter(function(v){return r[v].cutVertex}).map(function(v){return e.getElementById(v)});return{cut:e.spawn(f),components:i}},xh={hopcroftTarjanBiconnected:Xa,htbc:Xa,htb:Xa,hopcroftTarjanBiconnectedComponents:Xa},Ua=function(){var e=this,r={},a=0,n=[],i=[],o=e.spawn(e),s=function u(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 m=p.target().id();m!==l&&(m in r||u(m),r[m].explored||(r[l].low=Math.min(r[l].low,r[m].low)))}),r[l].index===r[l].low){for(var v=e.spawn();;){var c=i.pop();if(v.merge(e.getElementById(c)),r[c].low=r[l].index,r[c].explored=!0,c===l)break}var h=v.edgesWith(v),d=v.merge(h);n.push(d),o=o.difference(d)}};return e.forEach(function(u){if(u.isNode()){var l=u.id();l in r||s(l)}}),{cut:o,components:n}},Eh={tarjanStronglyConnected:Ua,tsc:Ua,tscc:Ua,tarjanStronglyConnectedComponents:Ua},fu={};[xa,jc,_c,td,ad,id,ud,Ad,zr,Fr,oi,Yd,ih,vh,yh,wh,xh,Eh].forEach(function(t){ce(fu,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 vu=0,cu=1,du=2,Wt=function t(e){if(!(this instanceof t))return new t(e);this.id="Thenable/1.0.7",this.state=vu,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))};Wt.prototype={fulfill:function(e){return No(this,cu,"fulfillValue",e)},reject:function(e){return No(this,du,"rejectReason",e)},then:function(e,r){var a=this,n=new Wt;return a.onFulfilled.push(Fo(e,n,"fulfill")),a.onRejected.push(Fo(r,n,"reject")),hu(a),n.proxy}};var No=function(e,r,a,n){return e.state===vu&&(e.state=r,e[a]=n,hu(e)),e},hu=function(e){e.state===cu?zo(e,"onFulfilled",e.fulfillValue):e.state===du&&zo(e,"onRejected",e.rejectReason)},zo=function(e,r,a){if(e[r].length!==0){var n=e[r];e[r]=[];var i=function(){for(var s=0;s0}},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 o=0;o0&&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){Ae(e)||(e=e.match(/\S+/g)||[]);for(var a=this,n=r===void 0,i=[],o=0,s=a.length;o0&&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}};sn.className=sn.classNames=sn.classes;var Ee={metaChar:"[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",boolOp:"\\?|\\!|\\^",string:`"(?:\\\\"|[^"])*"|'(?:\\\\'|[^'])*'`,number:He,meta:"degree|indegree|outdegree",separator:"\\s*,\\s*",descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$",group:"node|edge|\\*",directedEdge:"\\s+->\\s+",undirectedEdge:"\\s+<->\\s+"};Ee.variable="(?:[\\w-.]|(?:\\\\"+Ee.metaChar+"))+";Ee.className="(?:[\\w-]|(?:\\\\"+Ee.metaChar+"))+";Ee.value=Ee.string+"|"+Ee.number;Ee.id=Ee.variable;(function(){var t,e,r;for(t=Ee.comparatorOp.split("|"),r=0;r=0)&&e!=="="&&(Ee.comparatorOp+="|\\!"+e)})();var Oe=function(){return{checks:[]}},oe={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},ui=[{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 Mc(t.selector,e.selector)}),Ph=function(){for(var t={},e,r=0;r0&&f.edgeCount>0)return Le("The selector `"+e+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(f.edgeCount>1)return Le("The selector `"+e+"` is invalid because it uses multiple edge selectors"),!1;f.edgeCount===1&&Le("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},Rh=function(){if(this.toStringCache!=null)return this.toStringCache;for(var e=function(f){return f??""},r=function(f){return fe(f)?'"'+f+'"':e(f)},a=function(f){return" "+f+" "},n=function(f,v){var c=f.type,h=f.value;switch(c){case oe.GROUP:{var d=e(h);return d.substring(0,d.length-1)}case oe.DATA_COMPARE:{var p=f.field,m=f.operator;return"["+p+a(e(m))+r(h)+"]"}case oe.DATA_BOOL:{var g=f.operator,y=f.field;return"["+e(g)+y+"]"}case oe.DATA_EXIST:{var b=f.field;return"["+b+"]"}case oe.META_COMPARE:{var w=f.operator,S=f.field;return"[["+S+a(e(w))+r(h)+"]]"}case oe.STATE:return h;case oe.ID:return"#"+h;case oe.CLASS:return"."+h;case oe.PARENT:case oe.CHILD:return i(f.parent,v)+a(">")+i(f.child,v);case oe.ANCESTOR:case oe.DESCENDANT:return i(f.ancestor,v)+" "+i(f.descendant,v);case oe.COMPOUND_SPLIT:{var C=i(f.left,v),x=i(f.subject,v),T=i(f.right,v);return C+(C.length>0?" ":"")+x+T}case oe.TRUE:return""}},i=function(f,v){return f.checks.reduce(function(c,h,d){return c+(v===f&&d===0?"$":"")+n(h,v)},"")},o="",s=0;s1&&s=0&&(r=r.replace("!",""),v=!0),r.indexOf("@")>=0&&(r=r.replace("@",""),f=!0),(i||s||f)&&(u=!i&&!o?"":""+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">":c=!0,n=e>a;break;case">=":c=!0,n=e>=a;break;case"<":c=!0,n=e0;){var f=n.shift();e(f),i.add(f.id()),s&&a(n,i,f)}return t}function pu(t,e,r){if(r.isParent())for(var a=r._private.children,n=0;n1&&arguments[1]!==void 0?arguments[1]:!0;return Ri(this,t,e,pu)};function mu(t,e,r){if(r.isChild()){var a=r._private.parent;e.has(a.id())||t.push(a)}}Hr.forEachUp=function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return Ri(this,t,e,mu)};function Hh(t,e,r){mu(t,e,r),pu(t,e,r)}Hr.forEachUpAndDown=function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return Ri(this,t,e,Hh)};Hr.ancestors=Hr.parents;var Sa,yu;Sa=yu={data:Be.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:Be.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:Be.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:Be.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),rscratch:Be.data({field:"rscratch",allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:Be.removeData({field:"rscratch",triggerEvent:!1}),id:function(){var e=this[0];if(e)return e._private.data.id}};Sa.attr=Sa.data;Sa.removeAttr=Sa.removeData;var Wh=yu,Ln={};function Jn(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,o=0;oe}),minIndegree:kr("indegree",function(t,e){return te}),minOutdegree:kr("outdegree",function(t,e){return te})});ce(Ln,{totalDegree:function(e){for(var r=0,a=this.nodes(),n=0;n0,c=v;v&&(f=f[0]);var h=c?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=s?a.parent():null,m=p&&p.length>0,g=m;m&&(p=p[0]);var y=g?p.position():{x:0,y:0};return i={x:d.x-y.x,y:d.y-y.y},e===void 0?i:i[e]}else if(!o)return;return this}};Lt.modelPosition=Lt.point=Lt.position;Lt.modelPositions=Lt.points=Lt.positions;Lt.renderedPoint=Lt.renderedPosition;Lt.relativePoint=Lt.relativePosition;var Kh=bu,Vr,ir;Vr=ir={};ir.renderedBoundingBox=function(t){var e=this.boundingBox(t),r=this.cy(),a=r.zoom(),n=r.pan(),i=e.x1*a+n.x,o=e.x2*a+n.x,s=e.y1*a+n.y,u=e.y2*a+n.y;return{x1:i,x2:o,y1:s,y2:u,w:o-i,h:u-s}};ir.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)};ir.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(o){if(!o.isParent())return;var s=o._private,u=o.children(),l=o.pstyle("compound-sizing-wrt-labels").value==="include",f={width:{val:o.pstyle("min-width").pfValue,left:o.pstyle("min-width-bias-left"),right:o.pstyle("min-width-bias-right")},height:{val:o.pstyle("min-height").pfValue,top:o.pstyle("min-height-bias-top"),bottom:o.pstyle("min-height-bias-bottom")}},v=u.boundingBox({includeLabels:l,includeOverlays:!1,useCache:!1}),c=s.position;(v.w===0||v.h===0)&&(v={w:o.pstyle("width").pfValue,h:o.pstyle("height").pfValue},v.x1=c.x-v.w/2,v.x2=c.x+v.w/2,v.y1=c.y-v.h/2,v.y2=c.y+v.h/2);function h(E,P,B){var D=0,M=0,L=P+B;return E>0&&L>0&&(D=P/L*E,M=B/L*E),{biasDiff:D,biasComplementDiff:M}}function d(E,P,B,D){if(B.units==="%")switch(D){case"width":return E>0?B.pfValue*E:0;case"height":return P>0?B.pfValue*P:0;case"average":return E>0&&P>0?B.pfValue*(E+P)/2:0;case"min":return E>0&&P>0?E>P?B.pfValue*P:B.pfValue*E:0;case"max":return E>0&&P>0?E>P?B.pfValue*E:B.pfValue*P:0;default:return 0}else return B.units==="px"?B.pfValue:0}var p=f.width.left.value;f.width.left.units==="px"&&f.width.val>0&&(p=p*100/f.width.val);var m=f.width.right.value;f.width.right.units==="px"&&f.width.val>0&&(m=m*100/f.width.val);var g=f.height.top.value;f.height.top.units==="px"&&f.height.val>0&&(g=g*100/f.height.val);var y=f.height.bottom.value;f.height.bottom.units==="px"&&f.height.val>0&&(y=y*100/f.height.val);var b=h(f.width.val-v.w,p,m),w=b.biasDiff,S=b.biasComplementDiff,C=h(f.height.val-v.h,g,y),x=C.biasDiff,T=C.biasComplementDiff;s.autoPadding=d(v.w,v.h,o.pstyle("padding"),o.pstyle("padding-relative-to").value),s.autoWidth=Math.max(v.w,f.width.val),c.x=(-w+v.x1+v.x2+S)/2,s.autoHeight=Math.max(v.h,f.height.val),c.y=(-x+v.y1+v.y2+T)/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)},vr=function(e,r){return r==null?e:Pt(e,r.x1,r.y1,r.x2,r.y2)},ia=function(e,r,a){return Bt(e,r,a)},Za=function(e,r,a){if(!r.cy().headless()){var n=r._private,i=n.rstyle,o=i.arrowWidth/2,s=r.pstyle(a+"-arrow-shape").value,u,l;if(s!=="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||{},v=f[a]=f[a]||{};v.x1=u-o,v.y1=l-o,v.x2=u+o,v.y2=l+o,v.w=v.x2-v.x1,v.h=v.y2-v.y1,on(v,1),Pt(e,v.x1,v.y1,v.x2,v.y2)}}},jn=function(e,r,a){if(!r.cy().headless()){var n;a?n=a+"-":n="";var i=r._private,o=i.rstyle,s=r.pstyle(n+"label").strValue;if(s){var u=r.pstyle("text-halign"),l=r.pstyle("text-valign"),f=ia(o,"labelWidth",a),v=ia(o,"labelHeight",a),c=ia(o,"labelX",a),h=ia(o,"labelY",a),d=r.pstyle(n+"text-margin-x").pfValue,p=r.pstyle(n+"text-margin-y").pfValue,m=r.isEdge(),g=r.pstyle(n+"text-rotation"),y=r.pstyle("text-outline-width").pfValue,b=r.pstyle("text-border-width").pfValue,w=b/2,S=r.pstyle("text-background-padding").pfValue,C=2,x=v,T=f,E=T/2,P=x/2,B,D,M,L;if(m)B=c-E,D=c+E,M=h-P,L=h+P;else{switch(u.value){case"left":B=c-T,D=c;break;case"center":B=c-E,D=c+E;break;case"right":B=c,D=c+T;break}switch(l.value){case"top":M=h-x,L=h;break;case"center":M=h-P,L=h+P;break;case"bottom":M=h,L=h+x;break}}B+=d-Math.max(y,w)-S-C,D+=d+Math.max(y,w)+S+C,M+=p-Math.max(y,w)-S-C,L+=p+Math.max(y,w)+S+C;var R=a||"main",O=i.labelBounds,A=O[R]=O[R]||{};A.x1=B,A.y1=M,A.x2=D,A.y2=L,A.w=D-B,A.h=L-M;var N=m&&g.strValue==="autorotate",F=g.pfValue!=null&&g.pfValue!==0;if(N||F){var q=N?ia(i.rstyle,"labelAngle",a):g.pfValue,z=Math.cos(q),$=Math.sin(q),K=(B+D)/2,Y=(M+L)/2;if(!m){switch(u.value){case"left":K=D;break;case"right":K=B;break}switch(l.value){case"top":Y=L;break;case"bottom":Y=M;break}}var H=function(he,re){return he=he-K,re=re-Y,{x:he*z-re*$+K,y:he*$+re*z+Y}},W=H(B,M),I=H(B,L),G=H(D,M),Z=H(D,L);B=Math.min(W.x,I.x,G.x,Z.x),D=Math.max(W.x,I.x,G.x,Z.x),M=Math.min(W.y,I.y,G.y,Z.y),L=Math.max(W.y,I.y,G.y,Z.y)}var _=R+"Rot",ee=O[_]=O[_]||{};ee.x1=B,ee.y1=M,ee.x2=D,ee.y2=L,ee.w=D-B,ee.h=L-M,Pt(e,B,M,D,L),Pt(i.labelBounds.all,B,M,D,L)}return e}},Gh=function(e,r){var a=e._private.cy,n=a.styleEnabled(),i=a.headless(),o=ct(),s=e._private,u=e.isNode(),l=e.isEdge(),f,v,c,h,d,p,m=s.rstyle,g=u&&n?e.pstyle("bounds-expansion").pfValue:[0],y=function(se){return se.pstyle("display").value!=="none"},b=!n||y(e)&&(!l||y(e.source())&&y(e.target()));if(b){var w=0,S=0;n&&r.includeOverlays&&(w=e.pstyle("overlay-opacity").value,w!==0&&(S=e.pstyle("overlay-padding").value));var C=0,x=0;n&&r.includeUnderlays&&(C=e.pstyle("underlay-opacity").value,C!==0&&(x=e.pstyle("underlay-padding").value));var T=Math.max(S,x),E=0,P=0;if(n&&(E=e.pstyle("width").pfValue,P=E/2),u&&r.includeNodes){var B=e.position();d=B.x,p=B.y;var D=e.outerWidth(),M=D/2,L=e.outerHeight(),R=L/2;f=d-M,v=d+M,c=p-R,h=p+R,Pt(o,f,c,v,h)}else if(l&&r.includeEdges)if(n&&!i){var O=e.pstyle("curve-style").strValue;if(f=Math.min(m.srcX,m.midX,m.tgtX),v=Math.max(m.srcX,m.midX,m.tgtX),c=Math.min(m.srcY,m.midY,m.tgtY),h=Math.max(m.srcY,m.midY,m.tgtY),f-=P,v+=P,c-=P,h+=P,Pt(o,f,c,v,h),O==="haystack"){var A=m.haystackPts;if(A&&A.length===2){if(f=A[0].x,c=A[0].y,v=A[1].x,h=A[1].y,f>v){var N=f;f=v,v=N}if(c>h){var F=c;c=h,h=F}Pt(o,f-P,c-P,v+P,h+P)}}else if(O==="bezier"||O==="unbundled-bezier"||O==="segments"||O==="taxi"){var q;switch(O){case"bezier":case"unbundled-bezier":q=m.bezierPts;break;case"segments":case"taxi":q=m.linePts;break}if(q!=null)for(var z=0;zv){var I=f;f=v,v=I}if(c>h){var G=c;c=h,h=G}f-=P,v+=P,c-=P,h+=P,Pt(o,f,c,v,h)}if(n&&r.includeEdges&&l&&(Za(o,e,"mid-source"),Za(o,e,"mid-target"),Za(o,e,"source"),Za(o,e,"target")),n){var Z=e.pstyle("ghost").value==="yes";if(Z){var _=e.pstyle("ghost-offset-x").pfValue,ee=e.pstyle("ghost-offset-y").pfValue;Pt(o,o.x1+_,o.y1+ee,o.x2+_,o.y2+ee)}}var de=s.bodyBounds=s.bodyBounds||{};Co(de,o),Un(de,g),on(de,1),n&&(f=o.x1,v=o.x2,c=o.y1,h=o.y2,Pt(o,f-T,c-T,v+T,h+T));var he=s.overlayBounds=s.overlayBounds||{};Co(he,o),Un(he,g),on(he,1);var re=s.labelBounds=s.labelBounds||{};re.all!=null?yd(re.all):re.all=ct(),n&&r.includeLabels&&(r.includeMainLabels&&jn(o,e,null),l&&(r.includeSourceLabels&&jn(o,e,"source"),r.includeTargetLabels&&jn(o,e,"target")))}return o.x1=bt(o.x1),o.y1=bt(o.y1),o.x2=bt(o.x2),o.y2=bt(o.y2),o.w=bt(o.x2-o.x1),o.h=bt(o.y2-o.y1),o.w>0&&o.h>0&&b&&(Un(o,g),on(o,1)),o},xu=function(e){var r=0,a=function(o){return(o?1:0)<0&&arguments[0]!==void 0?arguments[0]:og,e=arguments.length>1?arguments[1]:void 0,r=0;r=0;s--)o(s);return this};nr.removeAllListeners=function(){return this.removeListener("*")};nr.emit=nr.trigger=function(t,e,r){var a=this.listeners,n=a.length;return this.emitting++,Ae(e)||(e=[e]),sg(this,function(i,o){r!=null&&(a=[{event:o.event,type:o.type,namespace:o.namespace,callback:r}],n=a.length);for(var s=function(f){var v=a[f];if(v.type===o.type&&(!v.namespace||v.namespace===o.namespace||v.namespace===ig)&&i.eventMatches(i.context,v,o)){var c=[o];e!=null&&Xc(c,e),i.beforeEmit(i.context,v,o),v.conf&&v.conf.one&&(i.listeners=i.listeners.filter(function(p){return p!==v}));var h=i.callbackContext(i.context,v,o),d=v.callback.apply(h,c);i.afterEmit(i.context,v,o),d===!1&&(o.stopPropagation(),o.preventDefault())}},u=0;u1&&!o){var s=this.length-1,u=this[s],l=u._private.data.id;this[s]=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 o=i.index;return this.unmergeAt(o),this},unmerge:function(e){var r=this._private.cy;if(!e)return this;if(e&&fe(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=s)}return{value:a,ele:n}},min:function(e,r){for(var a=1/0,n,i=this,o=0;o=0&&i"u"?"undefined":We(Symbol))!=e&&We(Symbol.iterator)!=e;r&&(yn[Symbol.iterator]=function(){var a=this,n={value:void 0,done:!1},i=0,o=this.length;return Ns({next:function(){return i1&&arguments[1]!==void 0?arguments[1]:!0,a=this[0],n=a.cy();if(n.styleEnabled()&&a){this.cleanStyle();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(Ce(e)){var o=e;i.applyBypass(this,o,n),this.emitAndNotify("style")}else if(fe(e))if(r===void 0){var s=this[0];return s?i.getStylePropertyValue(s,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 o=0;o0&&e.push(f[0]),e.push(s[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)}});tt.neighbourhood=tt.neighborhood;tt.closedNeighbourhood=tt.closedNeighborhood;tt.openNeighbourhood=tt.openNeighborhood;ce(tt,{source:wt(function(e){var r=this[0],a;return r&&(a=r._private.source||r.cy().collection()),a&&e?a.filter(e):a},"source"),target:wt(function(e){var r=this[0],a;return r&&(a=r._private.target||r.cy().collection()),a&&e?a.filter(e):a},"target"),sources:Qo({attr:"source"}),targets:Qo({attr:"target"})});function Qo(t){return function(r){for(var a=[],n=0;n0);return o},component:function(){var e=this[0];return e.cy().mutableElements().components(e)[0]}});tt.componentsOf=tt.components;var Qe=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){Ve("A collection must have a reference to the core");return}var i=new At,o=!1;if(!r)r=[];else if(r.length>0&&Ce(r[0])&&!Oa(r[0])){o=!0;for(var s=[],u=new Ur,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=[],o=[],s,u=0,l=r.length;u0){for(var F=s.length===r.length?r:new Qe(a,s),q=0;q0&&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 o(L){for(var R=L._private.edges,O=0;O0&&(t?B.emitAndNotify("remove"):e&&B.emit("remove"));for(var D=0;D0?D=L:B=L;while(Math.abs(M)>o&&++R=i?y(P,R):O===0?R:w(P,B,B+l)}var C=!1;function x(){C=!0,(t!==e||r!==a)&&b()}var T=function(B){return C||x(),t===e&&r===a?B:B===0?0:B===1?1:m(S(B),e,a)};T.getControlPoints=function(){return[{x:t,y:e},{x:r,y:a}]};var E="generateBezier("+[t,e,r,a]+")";return T.toString=function(){return E},T}/*! Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */var yg=function(){function t(a){return-a.tension*a.x-a.friction*a.v}function e(a,n,i){var o={x:a.x+i.dx*n,v:a.v+i.dv*n,tension:a.tension,friction:a.friction};return{dx:o.v,dv:t(o)}}function r(a,n){var i={dx:a.v,dv:t(a)},o=e(a,n*.5,i),s=e(a,n*.5,o),u=e(a,n,s),l=1/6*(i.dx+2*(o.dx+s.dx)+u.dx),f=1/6*(i.dv+2*(o.dv+s.dv)+u.dv);return a.x=a.x+l*n,a.v=a.v+f*n,a}return function a(n,i,o){var s={x:-1,v:0,tension:null,friction:null},u=[0],l=0,f=1/1e4,v=16/1e3,c,h,d;for(n=parseFloat(n)||500,i=parseFloat(i)||20,o=o||null,s.tension=n,s.friction=i,c=o!==null,c?(l=a(n,i),h=l/o*v):h=v;d=r(d||s,h),u.push(1+d.x),l+=16,Math.abs(d.x)>f&&Math.abs(d.v)>f;);return c?function(p){return u[p*(u.length-1)|0]}:l}}(),Re=function(e,r,a,n){var i=mg(e,r,a,n);return function(o,s,u){return o+(s-o)*i(u)}},ln={linear:function(e,r,a){return e+(r-e)*a},ease:Re(.25,.1,.25,1),"ease-in":Re(.42,0,1,1),"ease-out":Re(0,0,.58,1),"ease-in-out":Re(.42,0,.58,1),"ease-in-sine":Re(.47,0,.745,.715),"ease-out-sine":Re(.39,.575,.565,1),"ease-in-out-sine":Re(.445,.05,.55,.95),"ease-in-quad":Re(.55,.085,.68,.53),"ease-out-quad":Re(.25,.46,.45,.94),"ease-in-out-quad":Re(.455,.03,.515,.955),"ease-in-cubic":Re(.55,.055,.675,.19),"ease-out-cubic":Re(.215,.61,.355,1),"ease-in-out-cubic":Re(.645,.045,.355,1),"ease-in-quart":Re(.895,.03,.685,.22),"ease-out-quart":Re(.165,.84,.44,1),"ease-in-out-quart":Re(.77,0,.175,1),"ease-in-quint":Re(.755,.05,.855,.06),"ease-out-quint":Re(.23,1,.32,1),"ease-in-out-quint":Re(.86,0,.07,1),"ease-in-expo":Re(.95,.05,.795,.035),"ease-out-expo":Re(.19,1,.22,1),"ease-in-out-expo":Re(1,0,0,1),"ease-in-circ":Re(.6,.04,.98,.335),"ease-out-circ":Re(.075,.82,.165,1),"ease-in-out-circ":Re(.785,.135,.15,.86),spring:function(e,r,a){if(a===0)return ln.linear;var n=yg(e,r,a);return function(i,o,s){return i+(o-i)*n(s)}},"cubic-bezier":Re};function _o(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 es(t,e){return t.pfValue!=null||t.value!=null?t.pfValue!=null&&(e==null||e.type.units!=="%")?t.pfValue:t.value:t}function Pr(t,e,r,a,n){var i=n!=null?n.type:null;r<0?r=0:r>1&&(r=1);var o=es(t,n),s=es(e,n);if(ne(o)&&ne(s))return _o(i,o,s,r,a);if(Ae(o)&&Ae(s)){for(var u=[],l=0;l0?(h==="spring"&&d.push(o.duration),o.easingImpl=ln[h].apply(null,d)):o.easingImpl=ln[h]}var p=o.easingImpl,m;if(o.duration===0?m=1:m=(r-u)/o.duration,o.applying&&(m=o.progress),m<0?m=0:m>1&&(m=1),o.delay==null){var g=o.startPosition,y=o.position;if(y&&n&&!t.locked()){var b={};sa(g.x,y.x)&&(b.x=Pr(g.x,y.x,m,p)),sa(g.y,y.y)&&(b.y=Pr(g.y,y.y,m,p)),t.position(b)}var w=o.startPan,S=o.pan,C=i.pan,x=S!=null&&a;x&&(sa(w.x,S.x)&&(C.x=Pr(w.x,S.x,m,p)),sa(w.y,S.y)&&(C.y=Pr(w.y,S.y,m,p)),t.emit("pan"));var T=o.startZoom,E=o.zoom,P=E!=null&&a;P&&(sa(T,E)&&(i.zoom=Ea(i.minZoom,Pr(T,E,m,p),i.maxZoom)),t.emit("zoom")),(x||P)&&t.emit("viewport");var B=o.style;if(B&&B.length>0&&n){for(var D=0;D=0;x--){var T=C[x];T()}C.splice(0,C.length)},y=h.length-1;y>=0;y--){var b=h[y],w=b._private;if(w.stopped){h.splice(y,1),w.hooked=!1,w.playing=!1,w.started=!1,g(w.frames);continue}!w.playing&&!w.applying||(w.playing&&w.applying&&(w.applying=!1),w.started||wg(f,b,t),bg(f,b,t,v),w.applying&&(w.applying=!1),g(w.frames),w.step!=null&&w.step(t),b.completed()&&(h.splice(y,1),w.hooked=!1,w.playing=!1,w.started=!1,g(w.completes)),p=!0)}return!v&&h.length===0&&d.length===0&&a.push(f),p}for(var i=!1,o=0;o0?e.notify("draw",r):e.notify("draw")),r.unmerge(a),e.emit("step")}var xg={animate:Be.animate(),animation:Be.animation(),animated:Be.animated(),clearQueue:Be.clearQueue(),delay:Be.delay(),delayAnimation:Be.delayAnimation(),stop:Be.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&&gn(function(i){ts(i,e),r()})}var a=e.renderer();a&&a.beforeRender?a.beforeRender(function(i,o){ts(o,e)},a.beforeRenderPriorities.animations):r()}},Eg={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&&Oa(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}},ja=function(e){return fe(e)?new rr(e):e},Ou={createEmitter:function(){var e=this._private;return e.emitter||(e.emitter=new Mn(Eg,this)),this},emitter:function(){return this._private.emitter},on:function(e,r,a){return this.emitter().on(e,ja(r),a),this},removeListener:function(e,r,a){return this.emitter().removeListener(e,ja(r),a),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},one:function(e,r,a){return this.emitter().one(e,ja(r),a),this},once:function(e,r,a){return this.emitter().one(e,ja(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}};Be.eventAliasesOn(Ou);var fi={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)}};fi.jpeg=fi.jpg;var fn={layout:function(e){var r=this;if(e==null){Ve("Layout options must be specified to make a layout");return}if(e.name==null){Ve("A `name` must be specified to make a layout");return}var a=e.name,n=r.extension("layout",a);if(n==null){Ve("No such layout `"+a+"` found. Did you forget to import it and `cytoscape.use()` it?");return}var i;fe(e.eles)?i=r.$(e.eles):i=e.eles!=null?e.eles:r.$();var o=new n(ce({},e,{cy:r,eles:i}));return o}};fn.createLayout=fn.makeLayout=fn.layout;var Cg={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)}};vi.invalidateDimensions=vi.resize;var vn={collection:function(e,r){return fe(e)?this.$(e):ht(e)?e.collection():Ae(e)?(r||(r={}),new Qe(this,e,r.unique,r.removed)):new Qe(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}};vn.elements=vn.filter=vn.$;var at={},ha="t",Tg="f";at.apply=function(t){for(var e=this,r=e._private,a=r.cy,n=a.collection(),i=0;i0;if(c||v&&h){var d=void 0;c&&h||c?d=l.properties:h&&(d=l.mappedProperties);for(var p=0;p1&&(w=1),s.color){var C=a.valueMin[0],x=a.valueMax[0],T=a.valueMin[1],E=a.valueMax[1],P=a.valueMin[2],B=a.valueMax[2],D=a.valueMin[3]==null?1:a.valueMin[3],M=a.valueMax[3]==null?1:a.valueMax[3],L=[Math.round(C+(x-C)*w),Math.round(T+(E-T)*w),Math.round(P+(B-P)*w),Math.round(D+(M-D)*w)];i={bypass:a.bypass,name:a.name,value:L,strValue:"rgb("+L[0]+", "+L[1]+", "+L[2]+")"}}else if(s.number){var R=a.valueMin+(a.valueMax-a.valueMin)*w;i=this.parse(a.name,R,a.bypass,c)}else return!1;if(!i)return p(),!1;i.mapping=a,a=i;break}case o.data:{for(var O=a.field.split("."),A=v.data,N=0;N0&&i>0){for(var s={},u=!1,l=0;l0?t.delayAnimation(o).play().promise().then(b):b()}).then(function(){return t.animation({style:s,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)};at.checkTrigger=function(t,e,r,a,n,i){var o=this.properties[e],s=n(o);s!=null&&s(r,a)&&i(o)};at.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)})};at.checkBoundsTrigger=function(t,e,r,a){this.checkTrigger(t,e,r,a,function(n){return n.triggersBounds},function(n){t.dirtyCompoundBoundsCache(),t.dirtyBoundingBoxCache(),n.triggersBoundsOfParallelBeziers&&(e==="curve-style"&&(r==="bezier"||a==="bezier")||e==="display"&&(r==="none"||a==="none"))&&t.parallelEdges().forEach(function(i){i.isBundledBezier()&&i.dirtyBoundingBoxCache()})})};at.checkTriggers=function(t,e,r,a){t.dirtyStyleCache(),this.checkZOrderTrigger(t,e,r,a),this.checkBoundsTrigger(t,e,r,a)};var Ia={};Ia.applyBypass=function(t,e,r,a){var n=this,i=[],o=!0;if(e==="*"||e==="**"){if(r!==void 0)for(var s=0;sn.length?a=a.substr(n.length):a=""}function u(){i.length>o.length?i=i.substr(o.length):i=""}for(;;){var l=a.match(/^\s*$/);if(l)break;var f=a.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!f){Le("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: "+a);break}n=f[0];var v=f[1];if(v!=="core"){var c=new rr(v);if(c.invalid){Le("Skipping parsing of block: Invalid selector found in string stylesheet: "+v),s();continue}}var h=f[2],d=!1;i=h;for(var p=[];;){var m=i.match(/^\s*$/);if(m)break;var g=i.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/);if(!g){Le("Skipping parsing of block: Invalid formatting of style property and value definitions found in:"+h),d=!0;break}o=g[0];var y=g[1],b=g[2],w=e.properties[y];if(!w){Le("Skipping property: Invalid property name in: "+o),u();continue}var S=r.parse(y,b);if(!S){Le("Skipping property: Invalid property definition in: "+o),u();continue}p.push({name:y,val:b}),u()}if(d){s();break}r.selector(v);for(var C=0;C=7&&e[0]==="d"&&(f=new RegExp(s.data.regex).exec(e))){if(r)return!1;var c=s.data;return{name:t,value:f,strValue:""+e,mapped:c,field:f[1],bypass:r}}else if(e.length>=10&&e[0]==="m"&&(v=new RegExp(s.mapData.regex).exec(e))){if(r||l.multiple)return!1;var h=s.mapData;if(!(l.color||l.number))return!1;var d=this.parse(t,v[4]);if(!d||d.mapped)return!1;var p=this.parse(t,v[5]);if(!p||p.mapped)return!1;if(d.pfValue===p.pfValue||d.strValue===p.strValue)return Le("`"+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 m=d.value,g=p.value,y=m[0]===g[0]&&m[1]===g[1]&&m[2]===g[2]&&(m[3]===g[3]||(m[3]==null||m[3]===1)&&(g[3]==null||g[3]===1));if(y)return!1}return{name:t,value:v,strValue:""+e,mapped:h,field:v[1],fieldMin:parseFloat(v[2]),fieldMax:parseFloat(v[3]),valueMin:d.value,valueMax:p.value,bypass:r}}}if(l.multiple&&a!=="multiple"){var b;if(u?b=e.split(/\s+/):Ae(e)?b=e:b=[e],l.evenMultiple&&b.length%2!==0)return null;for(var w=[],S=[],C=[],x="",T=!1,E=0;E0?" ":"")+P.strValue}return l.validate&&!l.validate(w,S)?null:l.singleEnum&&T?w.length===1&&fe(w[0])?{name:t,value:w[0],strValue:w[0],bypass:r}:null:{name:t,value:w,pfValue:C,strValue:x,bypass:r,units:S}}var B=function(){for(var Z=0;Zl.max||l.strictMax&&e===l.max))return null;var O={name:t,value:e,strValue:""+e+(D||""),units:D,bypass:r};return l.unitless||D!=="px"&&D!=="em"?O.pfValue=e:O.pfValue=D==="px"||!D?e:this.getEmSizeInPixels()*e,(D==="ms"||D==="s")&&(O.pfValue=D==="ms"?e:1e3*e),(D==="deg"||D==="rad")&&(O.pfValue=D==="rad"?e:hd(e)),D==="%"&&(O.pfValue=e/100),O}else if(l.propList){var A=[],N=""+e;if(N!=="none"){for(var F=N.split(/\s*,\s*|\s+/),q=0;q0&&s>0&&!isNaN(a.w)&&!isNaN(a.h)&&a.w>0&&a.h>0){u=Math.min((o-2*r)/a.w,(s-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,o,s=!1;if(r.zoomingEnabled||(s=!0),ne(e)?o=e:Ce(e)&&(o=e.level,e.position!=null?i=Pn(e.position,n,a):e.renderedPosition!=null&&(i=e.renderedPosition),i!=null&&!r.panningEnabled&&(s=!0)),o=o>r.maxZoom?r.maxZoom:o,o=or.maxZoom||!r.zoomingEnabled?o=!0:(r.zoom=u,i.push("zoom"))}if(n&&(!o||!e.cancelOnFailedZoom)&&r.panningEnabled){var l=e.pan;ne(l.x)&&(r.pan.x=l.x,s=!1),ne(l.y)&&(r.pan.y=l.y,s=!1),s||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(fe(e)){var a=e;e=this.mutableElements().filter(a)}else ht(e)||(e=this.mutableElements());if(e.length!==0){var n=e.boundingBox(),i=this.width(),o=this.height();r=r===void 0?this._private.zoom:r;var s={x:(i-r*(n.x1+n.x2))/2,y:(o-r*(n.y1+n.y2))/2};return s}}},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(s){return parseFloat(n.getPropertyValue(s))};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}};mr.centre=mr.center;mr.autolockNodes=mr.autolock;mr.autoungrabifyNodes=mr.autoungrabify;var Da={data:Be.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeData:Be.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),scratch:Be.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:Be.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0})};Da.attr=Da.data;Da.removeAttr=Da.removeData;var ka=function(e){var r=this;e=ce({},e);var a=e.container;a&&!hn(a)&&hn(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 o=qe!==void 0&&a!==void 0&&!e.headless,s=e;s.layout=ce({name:o?"grid":"null"},s.layout),s.renderer=ce({name:o?"canvas":"null"},s.renderer);var u=function(d,p,m){return p!==void 0?p:m!==void 0?m:d},l=this._private={container:a,ready:!1,options:s,elements:new Qe(this),listeners:[],aniEles:new Qe(this),data:s.data||{},scratch:{},layout:null,renderer:null,destroyed:!1,notificationsEnabled:!0,minZoom:1e-50,maxZoom:1e50,zoomingEnabled:u(!0,s.zoomingEnabled),userZoomingEnabled:u(!0,s.userZoomingEnabled),panningEnabled:u(!0,s.panningEnabled),userPanningEnabled:u(!0,s.userPanningEnabled),boxSelectionEnabled:u(!0,s.boxSelectionEnabled),autolock:u(!1,s.autolock,s.autolockNodes),autoungrabify:u(!1,s.autoungrabify,s.autoungrabifyNodes),autounselectify:u(!1,s.autounselectify),styleEnabled:s.styleEnabled===void 0?o:s.styleEnabled,zoom:ne(s.zoom)?s.zoom:1,pan:{x:Ce(s.pan)&&ne(s.pan.x)?s.pan.x:0,y:Ce(s.pan)&&ne(s.pan.y)?s.pan.y:0},animation:{current:[],queue:[]},hasCompoundNodes:!1,multiClickDebounceTime:u(250,s.multiClickDebounceTime)};this.createEmitter(),this.selectionType(s.selectionType),this.zoomRange({min:s.minZoom,max:s.maxZoom});var f=function(d,p){var m=d.some(Cc);if(m)return Zr.all(d).then(p);p(d)};l.styleEnabled&&r.setStyle([]);var v=ce({},s,s.renderer);r.initRenderer(v);var c=function(d,p,m){r.notifications(!1);var g=r.mutableElements();g.length>0&&g.remove(),d!=null&&(Ce(d)||Ae(d))&&r.add(d),r.one("layoutready",function(b){r.notifications(!0),r.emit(b),r.one("load",p),r.emitAndNotify("load")}).one("layoutstop",function(){r.one("done",m),r.emit("done")});var y=ce({},r._private.options.layout);y.eles=r.elements(),r.layout(y).run()};f([s.style,s.elements],function(h){var d=h[0],p=h[1];l.styleEnabled&&r.style().append(d),c(p,function(){r.startAnimationLoop(),l.ready=!0,ze(s.ready)&&r.on("ready",s.ready);for(var m=0;m0,u=ct(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()}),l;if(ht(e.roots))l=e.roots;else if(Ae(e.roots)){for(var f=[],v=0;v0;){var R=L(),O=P(R,D);if(O)R.outgoers().filter(function(re){return re.isNode()&&a.has(re)}).forEach(M);else if(O===null){Le("Detected double maximal shift for node `"+R.id()+"`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.");break}}}E();var A=0;if(e.avoidOverlap)for(var N=0;N0&&g[0].length<=3?ve/2:0),k=2*Math.PI/g[ie].length*ae;return ie===0&&g[0].length===1&&(Q=1),{x:ee.x+Q*Math.cos(k),y:ee.y+Q*Math.sin(k)}}else{var xe={x:ee.x+(ae+1-(ue+1)/2)*ge,y:(ie+1)*pe};return xe}};return a.nodes().layoutPositions(this,e,he),this};var Lg={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 Ru(t){this.options=ce({},Lg,t)}Ru.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 o=ct(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()}),s={x:o.x1+o.w/2,y:o.y1+o.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,v=0,c=0;c1&&e.avoidOverlap){v*=1.75;var g=Math.cos(l)-Math.cos(0),y=Math.sin(l)-Math.sin(0),b=Math.sqrt(v*v/(g*g+y*y));f=Math.max(b,f)}var w=function(C,x){var T=e.startAngle+x*l*(n?1:-1),E=f*Math.cos(T),P=f*Math.sin(T),B={x:s.x+E,y:s.y+P};return B};return a.nodes().layoutPositions(this,e,w),this};var Mg={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 Iu(t){this.options=ce({},Mg,t)}Iu.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"),o=ct(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:a.width(),h:a.height()}),s={x:o.x1+o.w/2,y:o.y1+o.h/2},u=[],l=0,f=0;f0){var S=Math.abs(y[0].value-w.value);S>=m&&(y=[],g.push(y))}y.push(w)}var C=l+e.minNodeSpacing;if(!e.avoidOverlap){var x=g.length>0&&g[0].length>1,T=Math.min(o.w,o.h)/2-C,E=T/(g.length+x?1:0);C=Math.min(C,E)}for(var P=0,B=0;B1&&e.avoidOverlap){var R=Math.cos(L)-Math.cos(0),O=Math.sin(L)-Math.sin(0),A=Math.sqrt(C*C/(R*R+O*O));P=Math.max(A,P)}D.r=P,P+=C}if(e.equidistant){for(var N=0,F=0,q=0;q=t.numIter||(Vg(a,t),a.temperature=a.temperature*t.coolingFactor,a.temperature=t.animationThreshold&&i(),gn(v)}};f()}else{for(;l;)l=o(u),u++;ns(a,t),s()}return this};Nn.prototype.stop=function(){return this.stopped=!0,this.thread&&this.thread.stop(),this.emit("layoutstop"),this};Nn.prototype.destroy=function(){return this.thread&&this.thread.stop(),this};var Ag=function(e,r,a){for(var n=a.eles.edges(),i=a.eles.nodes(),o=ct(a.boundingBox?a.boundingBox:{x1:0,y1:0,w:e.width(),h:e.height()}),s={isCompound:e.hasCompoundNodes(),layoutNodes:[],idToIndex:{},nodeSize:i.size(),graphSet:[],indexToGraph:[],layoutEdges:[],edgeSize:n.size(),temperature:a.initialTemp,clientWidth:o.w,clientHeight:o.h,boundingBox:o},u=a.eles.components(),l={},f=0;f0){s.graphSet.push(T);for(var f=0;fn.count?0:n.graph},Ig=function t(e,r,a,n){var i=n.graphSet[a];if(-10)var v=n.nodeOverlap*f,c=Math.sqrt(s*s+u*u),h=v*s/c,d=v*u/c;else var p=wn(e,s,u),m=wn(r,-1*s,-1*u),g=m.x-p.x,y=m.y-p.y,b=g*g+y*y,c=Math.sqrt(b),v=(e.nodeRepulsion+r.nodeRepulsion)/b,h=v*g/c,d=v*y/c;e.isLocked||(e.offsetX-=h,e.offsetY-=d),r.isLocked||(r.offsetX+=h,r.offsetY+=d)}},Hg=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 o=e.maxY-r.minY;else var o=r.maxY-e.minY;return i>=0&&o>=0?Math.sqrt(i*i+o*o):0},wn=function(e,r,a){var n=e.positionX,i=e.positionY,o=e.height||1,s=e.width||1,u=a/r,l=o/s,f={};return r===0&&0a?(f.x=n,f.y=i+o/2,f):0r&&-1*l<=u&&u<=l?(f.x=n-s/2,f.y=i-s*a/2/r,f):0=l)?(f.x=n+o*r/2/a,f.y=i+o/2,f):(0>a&&(u<=-1*l||u>=l)&&(f.x=n-o*r/2/a,f.y=i-o/2),f)},Wg=function(e,r){for(var a=0;aa){var m=r.gravity*h/p,g=r.gravity*d/p;c.offsetX+=m,c.offsetY+=g}}}}},Gg=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 o=a[n++],s=e.idToIndex[o],u=e.layoutNodes[s],l=u.children;if(0a)var i={x:a*e/n,y:a*r/n};else var i={x:e,y:r};return i},Ug=function t(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.padTopg&&(d+=m+r.componentSpacing,h=0,p=0,m=0)}}},Zg={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 zu(t){this.options=ce({},Zg,t)}zu.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=ct(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(K){return{x:i.x1,y:i.y1}});else{var o=n.size(),s=Math.sqrt(o*i.h/i.w),u=Math.round(s),l=Math.round(i.w/i.h*s),f=function(Y){if(Y==null)return Math.min(u,l);var H=Math.min(u,l);H==u?u=Y:l=Y},v=function(Y){if(Y==null)return Math.max(u,l);var H=Math.max(u,l);H==u?u=Y:l=Y},c=e.rows,h=e.cols!=null?e.cols:e.columns;if(c!=null&&h!=null)u=c,l=h;else if(c!=null&&h==null)u=c,l=Math.ceil(o/u);else if(c==null&&h!=null)l=h,u=Math.ceil(o/l);else if(l*u>o){var d=f(),p=v();(d-1)*p>=o?f(d-1):(p-1)*d>=o&&v(p-1)}else for(;l*u=o?v(g+1):f(m+1)}var y=i.w/l,b=i.h/u;if(e.condense&&(y=0,b=0),e.avoidOverlap)for(var w=0;w=l&&(R=0,L++)},A={},N=0;N(R=kd(t,e,O[A],O[A+1],O[A+2],O[A+3])))return m(x,R),!0}else if(E.edgeType==="bezier"||E.edgeType==="multibezier"||E.edgeType==="self"||E.edgeType==="compound"){for(var O=E.allpts,A=0;A+5(R=Dd(t,e,O[A],O[A+1],O[A+2],O[A+3],O[A+4],O[A+5])))return m(x,R),!0}for(var N=N||T.source,F=F||T.target,q=n.getArrowWidth(P,B),z=[{name:"source",x:E.arrowStartX,y:E.arrowStartY,angle:E.srcArrowAngle},{name:"target",x:E.arrowEndX,y:E.arrowEndY,angle:E.tgtArrowAngle},{name:"mid-source",x:E.midX,y:E.midY,angle:E.midsrcArrowAngle},{name:"mid-target",x:E.midX,y:E.midY,angle:E.midtgtArrowAngle}],A=0;A0&&(g(N),g(F))}function b(x,T,E){return Bt(x,T,E)}function w(x,T){var E=x._private,P=c,B;T?B=T+"-":B="",x.boundingBox();var D=E.labelBounds[T||"main"],M=x.pstyle(B+"label").value,L=x.pstyle("text-events").strValue==="yes";if(!(!L||!M)){var R=b(E.rscratch,"labelX",T),O=b(E.rscratch,"labelY",T),A=b(E.rscratch,"labelAngle",T),N=x.pstyle(B+"text-margin-x").pfValue,F=x.pstyle(B+"text-margin-y").pfValue,q=D.x1-P-N,z=D.x2+P-N,$=D.y1-P-F,K=D.y2+P-F;if(A){var Y=Math.cos(A),H=Math.sin(A),W=function(he,re){return he=he-R,re=re-O,{x:he*Y-re*H+R,y:he*H+re*Y+O}},I=W(q,$),G=W(q,K),Z=W(z,$),_=W(z,K),ee=[I.x+N,I.y+F,Z.x+N,Z.y+F,_.x+N,_.y+F,G.x+N,G.y+F];if(vt(t,e,ee))return m(x),!0}else if($r(D,t,e))return m(x),!0}}for(var S=o.length-1;S>=0;S--){var C=o[S];C.isNode()?g(C)||w(C):y(C)||w(C)||w(C,"source")||w(C,"target")}return s};Er.getAllInBox=function(t,e,r,a){var n=this.getCachedZSortedEles().interactive,i=[],o=Math.min(t,r),s=Math.max(t,r),u=Math.min(e,a),l=Math.max(e,a);t=o,r=s,e=u,a=l;for(var f=ct({x1:t,y1:e,x2:r,y2:a}),v=0;v0?Math.max(j-le,0):Math.min(j+le,0)},M=D(P,T),L=D(B,E),R=!1;y===l?g=Math.abs(M)>Math.abs(L)?n:a:y===u||y===s?(g=a,R=!0):(y===i||y===o)&&(g=n,R=!0);var O=g===a,A=O?L:M,N=O?B:P,F=_s(N),q=!1;!(R&&(w||C))&&(y===s&&N<0||y===u&&N>0||y===i&&N>0||y===o&&N<0)&&(F*=-1,A=F*Math.abs(A),q=!0);var z;if(w){var $=S<0?1+S:S;z=$*A}else{var K=S<0?A:0;z=K+S*F}var Y=function(j){return Math.abs(j)=Math.abs(A)},H=Y(z),W=Y(Math.abs(A)-Math.abs(z)),I=H||W;if(I&&!q)if(O){var G=Math.abs(N)<=c/2,Z=Math.abs(P)<=h/2;if(G){var _=(f.x1+f.x2)/2,ee=f.y1,de=f.y2;r.segpts=[_,ee,_,de]}else if(Z){var he=(f.y1+f.y2)/2,re=f.x1,te=f.x2;r.segpts=[re,he,te,he]}else r.segpts=[f.x1,f.y2]}else{var se=Math.abs(N)<=v/2,ie=Math.abs(B)<=d/2;if(se){var ae=(f.y1+f.y2)/2,ue=f.x1,ge=f.x2;r.segpts=[ue,ae,ge,ae]}else if(ie){var pe=(f.x1+f.x2)/2,ve=f.y1,xe=f.y2;r.segpts=[pe,ve,pe,xe]}else r.segpts=[f.x2,f.y1]}else if(O){var Q=f.y1+z+(m?c/2*F:0),k=f.x1,V=f.x2;r.segpts=[k,Q,V,Q]}else{var J=f.x1+z+(m?v/2*F:0),X=f.y1,U=f.y2;r.segpts=[J,X,J,U]}};ut.tryToCorrectInvalidPoints=function(t,e){var r=t._private.rscratch;if(r.edgeType==="bezier"){var a=e.srcPos,n=e.tgtPos,i=e.srcW,o=e.srcH,s=e.tgtW,u=e.tgtH,l=e.srcShape,f=e.tgtShape,v=!ne(r.startX)||!ne(r.startY),c=!ne(r.arrowStartX)||!ne(r.arrowStartY),h=!ne(r.endX)||!ne(r.endY),d=!ne(r.arrowEndX)||!ne(r.arrowEndY),p=3,m=this.getArrowWidth(t.pstyle("width").pfValue,t.pstyle("arrow-scale").value)*this.arrowShapeWidth,g=p*m,y=gr({x:r.ctrlpts[0],y:r.ctrlpts[1]},{x:r.startX,y:r.startY}),b=yL.poolIndex()){var R=M;M=L,L=R}var O=E.srcPos=M.position(),A=E.tgtPos=L.position(),N=E.srcW=M.outerWidth(),F=E.srcH=M.outerHeight(),q=E.tgtW=L.outerWidth(),z=E.tgtH=L.outerHeight(),$=E.srcShape=r.nodeShapes[e.getNodeShape(M)],K=E.tgtShape=r.nodeShapes[e.getNodeShape(L)];E.dirCounts={north:0,west:0,south:0,east:0,northwest:0,southwest:0,northeast:0,southeast:0};for(var Y=0;Y0){var G=i,Z=fr(G,Rr(r)),_=fr(G,Rr(I)),ee=Z;if(_2){var de=fr(G,{x:I[2],y:I[3]});de0){var k=o,V=fr(k,Rr(r)),J=fr(k,Rr(Q)),X=V;if(J2){var U=fr(k,{x:Q[2],y:Q[3]});U=d||x){m={cp:w,segment:C};break}}if(m)break}var T=m.cp,E=m.segment,P=(d-g)/E.length,B=E.t1-E.t0,D=h?E.t0+B*P:E.t1-B*P;D=Ea(0,D,1),e=Nr(T.p0,T.p1,T.p2,D),c=tp(T.p0,T.p1,T.p2,D);break}case"straight":case"segments":case"haystack":{for(var M=0,L,R,O,A,N=a.allpts.length,F=0;F+3=d));F+=2);var q=d-R,z=q/L;z=Ea(0,z,1),e=pd(O,A,z),c=Wu(O,A);break}}o("labelX",v,e.x),o("labelY",v,e.y),o("labelAutoAngle",v,c)}};l("source"),l("target"),this.applyLabelDimensions(t)}};zt.applyLabelDimensions=function(t){this.applyPrefixedLabelDimensions(t),t.isEdge()&&(this.applyPrefixedLabelDimensions(t,"source"),this.applyPrefixedLabelDimensions(t,"target"))};zt.applyPrefixedLabelDimensions=function(t,e){var r=t._private,a=this.getLabelText(t,e),n=this.calculateLabelDimensions(t,a),i=t.pstyle("line-height").pfValue,o=t.pstyle("text-wrap").strValue,s=Bt(r.rscratch,"labelWrapCachedLines",e)||[],u=o!=="wrap"?1:Math.max(s.length,1),l=n.height/u,f=l*i,v=n.width,c=n.height+(u-1)*(i-1)*l;Qt(r.rstyle,"labelWidth",e,v),Qt(r.rscratch,"labelWidth",e,v),Qt(r.rstyle,"labelHeight",e,c),Qt(r.rscratch,"labelHeight",e,c),Qt(r.rscratch,"labelLineHeight",e,f)};zt.getLabelText=function(t,e){var r=t._private,a=e?e+"-":"",n=t.pstyle(a+"label").strValue,i=t.pstyle("text-transform").value,o=function(q,z){return z?(Qt(r.rscratch,q,e,z),z):Bt(r.rscratch,q,e)};if(!n)return"";i=="none"||(i=="uppercase"?n=n.toUpperCase():i=="lowercase"&&(n=n.toLowerCase()));var s=t.pstyle("text-wrap").value;if(s==="wrap"){var u=o("labelKey");if(u!=null&&o("labelWrapKey")===u)return o("labelWrapCachedText");for(var l="​",f=n.split(` `),v=t.pstyle("text-max-width").pfValue,c=t.pstyle("text-overflow-wrap").value,h=c==="anywhere",d=[],p=/[\s\u200b]+/,m=h?"":" ",g=0;gv){for(var C=y.split(p),x="",T=0;TM)break;L+=n[A],A===n.length-1&&(O=!0)}return O||(L+=R),L}return n};zt.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};zt.calculateLabelDimensions=function(t,e){var r=this,a=hr(e,t._private.labelDimsKey),n=r.labelDimCache||(r.labelDimCache=[]),i=n[a];if(i!=null)return i;var o=0,s=t.pstyle("font-style").strValue,u=t.pstyle("font-size").pfValue,l=t.pstyle("font-family").strValue,f=t.pstyle("font-weight").strValue,v=this.labelCalcCanvas,c=this.labelCalcCanvasContext;if(!v){v=this.labelCalcCanvas=document.createElement("canvas"),c=this.labelCalcCanvasContext=v.getContext("2d");var h=v.style;h.position="absolute",h.left="-9999px",h.top="-9999px",h.zIndex="-1",h.visibility="hidden",h.pointerEvents="none"}c.font="".concat(s," ").concat(f," ").concat(u,"px ").concat(l);for(var d=0,p=0,m=e.split(` `),g=0;g1&&arguments[1]!==void 0?arguments[1]:!0;if(e.merge(o),s)for(var u=0;u=t.desktopTapThreshold2}var Vt=n(k);Ye&&(t.hoverData.tapholdCancelled=!0);var Xt=function(){var Mt=t.hoverData.dragDelta=t.hoverData.dragDelta||[];Mt.length===0?(Mt.push(we[0]),Mt.push(we[1])):(Mt[0]+=we[0],Mt[1]+=we[1])};J=!0,a(be,["mousemove","vmousemove","tapdrag"],k,{x:j[0],y:j[1]});var Sr=function(){t.data.bgActivePosistion=void 0,t.hoverData.selecting||X.emit({originalEvent:k,type:"boxstart",position:{x:j[0],y:j[1]}}),Me[4]=1,t.hoverData.selecting=!0,t.redrawHint("select",!0),t.redraw()};if(t.hoverData.which===3){if(Ye){var ur={originalEvent:k,type:"cxtdrag",position:{x:j[0],y:j[1]}};ye?ye.emit(ur):X.emit(ur),t.hoverData.cxtDragged=!0,(!t.hoverData.cxtOver||be!==t.hoverData.cxtOver)&&(t.hoverData.cxtOver&&t.hoverData.cxtOver.emit({originalEvent:k,type:"cxtdragout",position:{x:j[0],y:j[1]}}),t.hoverData.cxtOver=be,be&&be.emit({originalEvent:k,type:"cxtdragover",position:{x:j[0],y:j[1]}}))}}else if(t.hoverData.dragging){if(J=!0,X.panningEnabled()&&X.userPanningEnabled()){var Tr;if(t.hoverData.justStartedPan){var $a=t.hoverData.mdownPos;Tr={x:(j[0]-$a[0])*U,y:(j[1]-$a[1])*U},t.hoverData.justStartedPan=!1}else Tr={x:we[0]*U,y:we[1]*U};X.panBy(Tr),X.emit("dragpan"),t.hoverData.dragged=!0}j=t.projectIntoViewport(k.clientX,k.clientY)}else if(Me[4]==1&&(ye==null||ye.pannable())){if(Ye){if(!t.hoverData.dragging&&X.boxSelectionEnabled()&&(Vt||!X.panningEnabled()||!X.userPanningEnabled()))Sr();else if(!t.hoverData.selecting&&X.panningEnabled()&&X.userPanningEnabled()){var lr=i(ye,t.hoverData.downs);lr&&(t.hoverData.dragging=!0,t.hoverData.justStartedPan=!0,Me[4]=0,t.data.bgActivePosistion=Rr(le),t.redrawHint("select",!0),t.redraw())}ye&&ye.pannable()&&ye.active()&&ye.unactivate()}}else{if(ye&&ye.pannable()&&ye.active()&&ye.unactivate(),(!ye||!ye.grabbed())&&be!=ke&&(ke&&a(ke,["mouseout","tapdragout"],k,{x:j[0],y:j[1]}),be&&a(be,["mouseover","tapdragover"],k,{x:j[0],y:j[1]}),t.hoverData.last=be),ye)if(Ye){if(X.boxSelectionEnabled()&&Vt)ye&&ye.grabbed()&&(m(Fe),ye.emit("freeon"),Fe.emit("free"),t.dragData.didDrag&&(ye.emit("dragfreeon"),Fe.emit("dragfree"))),Sr();else if(ye&&ye.grabbed()&&t.nodeIsDraggable(ye)){var lt=!t.dragData.didDrag;lt&&t.redrawHint("eles",!0),t.dragData.didDrag=!0,t.hoverData.draggingEles||d(Fe,{inDragLayer:!0});var _e={x:0,y:0};if(ne(we[0])&&ne(we[1])&&(_e.x+=we[0],_e.y+=we[1],lt)){var ft=t.hoverData.dragDelta;ft&&ne(ft[0])&&ne(ft[1])&&(_e.x+=ft[0],_e.y+=ft[1])}t.hoverData.draggingEles=!0,Fe.silentShift(_e).emit("position drag"),t.redrawHint("drag",!0),t.redraw()}}else Xt();J=!0}if(Me[2]=j[0],Me[3]=j[1],J)return k.stopPropagation&&k.stopPropagation(),k.preventDefault&&k.preventDefault(),!1}},!1);var P,B,D;t.registerBinding(e,"mouseup",function(k){var V=t.hoverData.capture;if(V){t.hoverData.capture=!1;var J=t.cy,X=t.projectIntoViewport(k.clientX,k.clientY),U=t.selection,me=t.findNearestElement(X[0],X[1],!0,!1),j=t.dragData.possibleDragElements,le=t.hoverData.down,Se=n(k);if(t.data.bgActivePosistion&&(t.redrawHint("select",!0),t.redraw()),t.hoverData.tapholdCancelled=!0,t.data.bgActivePosistion=void 0,le&&le.unactivate(),t.hoverData.which===3){var Me={originalEvent:k,type:"cxttapend",position:{x:X[0],y:X[1]}};if(le?le.emit(Me):J.emit(Me),!t.hoverData.cxtDragged){var be={originalEvent:k,type:"cxttap",position:{x:X[0],y:X[1]}};le?le.emit(be):J.emit(be)}t.hoverData.cxtDragged=!1,t.hoverData.which=null}else if(t.hoverData.which===1){if(a(me,["mouseup","tapend","vmouseup"],k,{x:X[0],y:X[1]}),!t.dragData.didDrag&&!t.hoverData.dragged&&!t.hoverData.selecting&&!t.hoverData.isOverThresholdDrag&&(a(le,["click","tap","vclick"],k,{x:X[0],y:X[1]}),B=!1,k.timeStamp-D<=J.multiClickDebounceTime()?(P&&clearTimeout(P),B=!0,D=null,a(le,["dblclick","dbltap","vdblclick"],k,{x:X[0],y:X[1]})):(P=setTimeout(function(){B||a(le,["oneclick","onetap","voneclick"],k,{x:X[0],y:X[1]})},J.multiClickDebounceTime()),D=k.timeStamp)),le==null&&!t.dragData.didDrag&&!t.hoverData.selecting&&!t.hoverData.dragged&&!n(k)&&(J.$(r).unselect(["tapunselect"]),j.length>0&&t.redrawHint("eles",!0),t.dragData.possibleDragElements=j=J.collection()),me==le&&!t.dragData.didDrag&&!t.hoverData.selecting&&me!=null&&me._private.selectable&&(t.hoverData.dragging||(J.selectionType()==="additive"||Se?me.selected()?me.unselect(["tapunselect"]):me.select(["tapselect"]):Se||(J.$(r).unmerge(me).unselect(["tapunselect"]),me.select(["tapselect"]))),t.redrawHint("eles",!0)),t.hoverData.selecting){var ke=J.collection(t.getAllInBox(U[0],U[1],U[2],U[3]));t.redrawHint("select",!0),ke.length>0&&t.redrawHint("eles",!0),J.emit({type:"boxend",originalEvent:k,position:{x:X[0],y:X[1]}});var ye=function(Ye){return Ye.selectable()&&!Ye.selected()};J.selectionType()==="additive"||Se||J.$(r).unmerge(ke).unselect(),ke.emit("box").stdFilter(ye).select().emit("boxselect"),t.redraw()}if(t.hoverData.dragging&&(t.hoverData.dragging=!1,t.redrawHint("select",!0),t.redrawHint("eles",!0),t.redraw()),!U[4]){t.redrawHint("drag",!0),t.redrawHint("eles",!0);var we=le&&le.grabbed();m(j),we&&(le.emit("freeon"),j.emit("free"),t.dragData.didDrag&&(le.emit("dragfreeon"),j.emit("dragfree")))}}U[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}},!1);var M=function(k){if(!t.scrollingPage){var V=t.cy,J=V.zoom(),X=V.pan(),U=t.projectIntoViewport(k.clientX,k.clientY),me=[U[0]*J+X.x,U[1]*J+X.y];if(t.hoverData.draggingEles||t.hoverData.dragging||t.hoverData.cxtStarted||T()){k.preventDefault();return}if(V.panningEnabled()&&V.userPanningEnabled()&&V.zoomingEnabled()&&V.userZoomingEnabled()){k.preventDefault(),t.data.wheelZooming=!0,clearTimeout(t.data.wheelTimeout),t.data.wheelTimeout=setTimeout(function(){t.data.wheelZooming=!1,t.redrawHint("eles",!0),t.redraw()},150);var j;k.deltaY!=null?j=k.deltaY/-250:k.wheelDeltaY!=null?j=k.wheelDeltaY/1e3:j=k.wheelDelta/1e3,j=j*t.wheelSensitivity;var le=k.deltaMode===1;le&&(j*=33);var Se=V.zoom()*Math.pow(10,j);k.type==="gesturechange"&&(Se=t.gestureStartZoom*k.scale),V.zoom({level:Se,renderedPosition:{x:me[0],y:me[1]}}),V.emit(k.type==="gesturechange"?"pinchzoom":"scrollzoom")}}};t.registerBinding(t.container,"wheel",M,!0),t.registerBinding(e,"scroll",function(k){t.scrollingPage=!0,clearTimeout(t.scrollingPageTimeout),t.scrollingPageTimeout=setTimeout(function(){t.scrollingPage=!1},250)},!0),t.registerBinding(t.container,"gesturestart",function(k){t.gestureStartZoom=t.cy.zoom(),t.hasTouchStarted||k.preventDefault()},!0),t.registerBinding(t.container,"gesturechange",function(Q){t.hasTouchStarted||M(Q)},!0),t.registerBinding(t.container,"mouseout",function(k){var V=t.projectIntoViewport(k.clientX,k.clientY);t.cy.emit({originalEvent:k,type:"mouseout",position:{x:V[0],y:V[1]}})},!1),t.registerBinding(t.container,"mouseover",function(k){var V=t.projectIntoViewport(k.clientX,k.clientY);t.cy.emit({originalEvent:k,type:"mouseover",position:{x:V[0],y:V[1]}})},!1);var L,R,O,A,N,F,q,z,$,K,Y,H,W,I=function(k,V,J,X){return Math.sqrt((J-k)*(J-k)+(X-V)*(X-V))},G=function(k,V,J,X){return(J-k)*(J-k)+(X-V)*(X-V)},Z;t.registerBinding(t.container,"touchstart",Z=function(k){if(t.hasTouchStarted=!0,!!E(k)){y(),t.touchData.capture=!0,t.data.bgActivePosistion=void 0;var V=t.cy,J=t.touchData.now,X=t.touchData.earlier;if(k.touches[0]){var U=t.projectIntoViewport(k.touches[0].clientX,k.touches[0].clientY);J[0]=U[0],J[1]=U[1]}if(k.touches[1]){var U=t.projectIntoViewport(k.touches[1].clientX,k.touches[1].clientY);J[2]=U[0],J[3]=U[1]}if(k.touches[2]){var U=t.projectIntoViewport(k.touches[2].clientX,k.touches[2].clientY);J[4]=U[0],J[5]=U[1]}if(k.touches[1]){t.touchData.singleTouchMoved=!0,m(t.dragData.touchDragEles);var me=t.findContainerClientCoords();$=me[0],K=me[1],Y=me[2],H=me[3],L=k.touches[0].clientX-$,R=k.touches[0].clientY-K,O=k.touches[1].clientX-$,A=k.touches[1].clientY-K,W=0<=L&&L<=Y&&0<=O&&O<=Y&&0<=R&&R<=H&&0<=A&&A<=H;var j=V.pan(),le=V.zoom();N=I(L,R,O,A),F=G(L,R,O,A),q=[(L+O)/2,(R+A)/2],z=[(q[0]-j.x)/le,(q[1]-j.y)/le];var Se=200,Me=Se*Se;if(F=1){for(var St=t.touchData.startPosition=[null,null,null,null,null,null],Xe=0;Xe=t.touchTapThreshold2}if(V&&t.touchData.cxt){k.preventDefault();var St=k.touches[0].clientX-$,Xe=k.touches[0].clientY-K,yt=k.touches[1].clientX-$,nt=k.touches[1].clientY-K,Vt=G(St,Xe,yt,nt),Xt=Vt/F,Sr=150,ur=Sr*Sr,Tr=1.5,$a=Tr*Tr;if(Xt>=$a||Vt>=ur){t.touchData.cxt=!1,t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);var lr={originalEvent:k,type:"cxttapend",position:{x:U[0],y:U[1]}};t.touchData.start?(t.touchData.start.unactivate().emit(lr),t.touchData.start=null):X.emit(lr)}}if(V&&t.touchData.cxt){var lr={originalEvent:k,type:"cxtdrag",position:{x:U[0],y:U[1]}};t.data.bgActivePosistion=void 0,t.redrawHint("select",!0),t.touchData.start?t.touchData.start.emit(lr):X.emit(lr),t.touchData.start&&(t.touchData.start._private.grabbed=!1),t.touchData.cxtDragged=!0;var lt=t.findNearestElement(U[0],U[1],!0,!0);(!t.touchData.cxtOver||lt!==t.touchData.cxtOver)&&(t.touchData.cxtOver&&t.touchData.cxtOver.emit({originalEvent:k,type:"cxtdragout",position:{x:U[0],y:U[1]}}),t.touchData.cxtOver=lt,lt&<.emit({originalEvent:k,type:"cxtdragover",position:{x:U[0],y:U[1]}}))}else if(V&&k.touches[2]&&X.boxSelectionEnabled())k.preventDefault(),t.data.bgActivePosistion=void 0,this.lastThreeTouch=+new Date,t.touchData.selecting||X.emit({originalEvent:k,type:"boxstart",position:{x:U[0],y:U[1]}}),t.touchData.selecting=!0,t.touchData.didSelect=!0,J[4]=1,!J||J.length===0||J[0]===void 0?(J[0]=(U[0]+U[2]+U[4])/3,J[1]=(U[1]+U[3]+U[5])/3,J[2]=(U[0]+U[2]+U[4])/3+1,J[3]=(U[1]+U[3]+U[5])/3+1):(J[2]=(U[0]+U[2]+U[4])/3,J[3]=(U[1]+U[3]+U[5])/3),t.redrawHint("select",!0),t.redraw();else if(V&&k.touches[1]&&!t.touchData.didSelect&&X.zoomingEnabled()&&X.panningEnabled()&&X.userZoomingEnabled()&&X.userPanningEnabled()){k.preventDefault(),t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);var _e=t.dragData.touchDragEles;if(_e){t.redrawHint("drag",!0);for(var ft=0;ft<_e.length;ft++){var qa=_e[ft]._private;qa.grabbed=!1,qa.rscratch.inDragLayer=!1}}var Mt=t.touchData.start,St=k.touches[0].clientX-$,Xe=k.touches[0].clientY-K,yt=k.touches[1].clientX-$,nt=k.touches[1].clientY-K,eo=I(St,Xe,yt,nt),Il=eo/N;if(W){var Nl=St-L,zl=Xe-R,Fl=yt-O,Vl=nt-A,$l=(Nl+Fl)/2,ql=(zl+Vl)/2,ra=X.zoom(),Hn=ra*Il,Ha=X.pan(),to=z[0]*ra+Ha.x,ro=z[1]*ra+Ha.y,Hl={x:-Hn/ra*(to-Ha.x-$l)+to,y:-Hn/ra*(ro-Ha.y-ql)+ro};if(Mt&&Mt.active()){var _e=t.dragData.touchDragEles;m(_e),t.redrawHint("drag",!0),t.redrawHint("eles",!0),Mt.unactivate().emit("freeon"),_e.emit("free"),t.dragData.didDrag&&(Mt.emit("dragfreeon"),_e.emit("dragfree"))}X.viewport({zoom:Hn,pan:Hl,cancelOnFailedZoom:!0}),X.emit("pinchzoom"),N=eo,L=St,R=Xe,O=yt,A=nt,t.pinching=!0}if(k.touches[0]){var le=t.projectIntoViewport(k.touches[0].clientX,k.touches[0].clientY);U[0]=le[0],U[1]=le[1]}if(k.touches[1]){var le=t.projectIntoViewport(k.touches[1].clientX,k.touches[1].clientY);U[2]=le[0],U[3]=le[1]}if(k.touches[2]){var le=t.projectIntoViewport(k.touches[2].clientX,k.touches[2].clientY);U[4]=le[0],U[5]=le[1]}}else if(k.touches[0]&&!t.touchData.didSelect){var Tt=t.touchData.start,Wn=t.touchData.last,lt;if(!t.hoverData.draggingEles&&!t.swipePanning&&(lt=t.findNearestElement(U[0],U[1],!0,!0)),V&&Tt!=null&&k.preventDefault(),V&&Tt!=null&&t.nodeIsDraggable(Tt))if(Me){var _e=t.dragData.touchDragEles,ao=!t.dragData.didDrag;ao&&d(_e,{inDragLayer:!0}),t.dragData.didDrag=!0;var aa={x:0,y:0};if(ne(be[0])&&ne(be[1])&&(aa.x+=be[0],aa.y+=be[1],ao)){t.redrawHint("eles",!0);var Dt=t.touchData.dragDelta;Dt&&ne(Dt[0])&&ne(Dt[1])&&(aa.x+=Dt[0],aa.y+=Dt[1])}t.hoverData.draggingEles=!0,_e.silentShift(aa).emit("position drag"),t.redrawHint("drag",!0),t.touchData.startPosition[0]==me[0]&&t.touchData.startPosition[1]==me[1]&&t.redrawHint("eles",!0),t.redraw()}else{var Dt=t.touchData.dragDelta=t.touchData.dragDelta||[];Dt.length===0?(Dt.push(be[0]),Dt.push(be[1])):(Dt[0]+=be[0],Dt[1]+=be[1])}if(a(Tt||lt,["touchmove","tapdrag","vmousemove"],k,{x:U[0],y:U[1]}),(!Tt||!Tt.grabbed())&<!=Wn&&(Wn&&Wn.emit({originalEvent:k,type:"tapdragout",position:{x:U[0],y:U[1]}}),lt&<.emit({originalEvent:k,type:"tapdragover",position:{x:U[0],y:U[1]}})),t.touchData.last=lt,V)for(var ft=0;ft0&&!t.hoverData.draggingEles&&!t.swipePanning&&t.data.bgActivePosistion!=null&&(t.data.bgActivePosistion=void 0,t.redrawHint("select",!0),t.redraw())}},!1);var ee;t.registerBinding(e,"touchcancel",ee=function(k){var V=t.touchData.start;t.touchData.capture=!1,V&&V.unactivate()});var de,he,re,te;if(t.registerBinding(e,"touchend",de=function(k){var V=t.touchData.start,J=t.touchData.capture;if(J)k.touches.length===0&&(t.touchData.capture=!1),k.preventDefault();else return;var X=t.selection;t.swipePanning=!1,t.hoverData.draggingEles=!1;var U=t.cy,me=U.zoom(),j=t.touchData.now,le=t.touchData.earlier;if(k.touches[0]){var Se=t.projectIntoViewport(k.touches[0].clientX,k.touches[0].clientY);j[0]=Se[0],j[1]=Se[1]}if(k.touches[1]){var Se=t.projectIntoViewport(k.touches[1].clientX,k.touches[1].clientY);j[2]=Se[0],j[3]=Se[1]}if(k.touches[2]){var Se=t.projectIntoViewport(k.touches[2].clientX,k.touches[2].clientY);j[4]=Se[0],j[5]=Se[1]}V&&V.unactivate();var Me;if(t.touchData.cxt){if(Me={originalEvent:k,type:"cxttapend",position:{x:j[0],y:j[1]}},V?V.emit(Me):U.emit(Me),!t.touchData.cxtDragged){var be={originalEvent:k,type:"cxttap",position:{x:j[0],y:j[1]}};V?V.emit(be):U.emit(be)}t.touchData.start&&(t.touchData.start._private.grabbed=!1),t.touchData.cxt=!1,t.touchData.start=null,t.redraw();return}if(!k.touches[2]&&U.boxSelectionEnabled()&&t.touchData.selecting){t.touchData.selecting=!1;var ke=U.collection(t.getAllInBox(X[0],X[1],X[2],X[3]));X[0]=void 0,X[1]=void 0,X[2]=void 0,X[3]=void 0,X[4]=0,t.redrawHint("select",!0),U.emit({type:"boxend",originalEvent:k,position:{x:j[0],y:j[1]}});var ye=function(ur){return ur.selectable()&&!ur.selected()};ke.emit("box").stdFilter(ye).select().emit("boxselect"),ke.nonempty()&&t.redrawHint("eles",!0),t.redraw()}if(V!=null&&V.unactivate(),k.touches[2])t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);else if(!k.touches[1]){if(!k.touches[0]){if(!k.touches[0]){t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);var we=t.dragData.touchDragEles;if(V!=null){var Fe=V._private.grabbed;m(we),t.redrawHint("drag",!0),t.redrawHint("eles",!0),Fe&&(V.emit("freeon"),we.emit("free"),t.dragData.didDrag&&(V.emit("dragfreeon"),we.emit("dragfree"))),a(V,["touchend","tapend","vmouseup","tapdragout"],k,{x:j[0],y:j[1]}),V.unactivate(),t.touchData.start=null}else{var Ye=t.findNearestElement(j[0],j[1],!0,!0);a(Ye,["touchend","tapend","vmouseup","tapdragout"],k,{x:j[0],y:j[1]})}var Ct=t.touchData.startPosition[0]-j[0],St=Ct*Ct,Xe=t.touchData.startPosition[1]-j[1],yt=Xe*Xe,nt=St+yt,Vt=nt*me*me;t.touchData.singleTouchMoved||(V||U.$(":selected").unselect(["tapunselect"]),a(V,["tap","vclick"],k,{x:j[0],y:j[1]}),he=!1,k.timeStamp-te<=U.multiClickDebounceTime()?(re&&clearTimeout(re),he=!0,te=null,a(V,["dbltap","vdblclick"],k,{x:j[0],y:j[1]})):(re=setTimeout(function(){he||a(V,["onetap","voneclick"],k,{x:j[0],y:j[1]})},U.multiClickDebounceTime()),te=k.timeStamp)),V!=null&&!t.dragData.didDrag&&V._private.selectable&&Vt"u"){var se=[],ie=function(k){return{clientX:k.clientX,clientY:k.clientY,force:1,identifier:k.pointerId,pageX:k.pageX,pageY:k.pageY,radiusX:k.width/2,radiusY:k.height/2,screenX:k.screenX,screenY:k.screenY,target:k.target}},ae=function(k){return{event:k,touch:ie(k)}},ue=function(k){se.push(ae(k))},ge=function(k){for(var V=0;V0)return z[0]}return null},h=Object.keys(v),d=0;d0?c:tu(i,o,e,r,a,n,s)},checkPoint:function(e,r,a,n,i,o,s){var u=Aa(n,i),l=2*u;if(Ht(e,r,this.points,o,s,n,i-l,[0,-1],a)||Ht(e,r,this.points,o,s,n-l,i,[0,-1],a))return!0;var f=n/2+2*a,v=i/2+2*a,c=[o-f,s-v,o-f,s,o+f,s,o+f,s-v];return!!(vt(e,r,c)||cr(e,r,l,l,o+n/2-u,s+i/2-u,a)||cr(e,r,l,l,o-n/2+u,s+i/2-u,a))}}};Gt.registerNodeShapes=function(){var t=this.nodeShapes={},e=this;this.generateEllipse(),this.generatePolygon("triangle",it(3,0)),this.generateRoundPolygon("round-triangle",it(3,0)),this.generatePolygon("rectangle",it(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",it(5,0)),this.generateRoundPolygon("round-pentagon",it(5,0)),this.generatePolygon("hexagon",it(6,0)),this.generateRoundPolygon("round-hexagon",it(6,0)),this.generatePolygon("heptagon",it(7,0)),this.generateRoundPolygon("round-heptagon",it(7,0)),this.generatePolygon("octagon",it(8,0)),this.generateRoundPolygon("round-octagon",it(8,0));var a=new Array(20);{var n=ni(5,0),i=ni(5,Math.PI/5),o=.5*(3-Math.sqrt(5));o*=1.57;for(var s=0;s=e.deqFastCost*w)break}else if(l){if(y>=e.deqCost*h||y>=e.deqAvgCost*c)break}else if(b>=e.deqNoDrawCost*ti)break;var S=e.deq(a,m,p);if(S.length>0)for(var C=0;C0&&(e.onDeqd(a,d),!l&&e.shouldRedraw(a,d,m,p)&&i())},s=e.priority||ki;n.beforeRender(o,s(a))}}}},ap=function(){function t(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:pn;Ei(this,t),this.idsByKey=new At,this.keyForId=new At,this.cachesByLvl=new At,this.lvls=[],this.getKey=e,this.doesEleInvalidateKey=r}return Ci(t,[{key:"getIdsFor",value:function(r){r==null&&Ve("Can not get id list for null key");var a=this.idsByKey,n=this.idsByKey.get(r);return n||(n=new Ur,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 At,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}}]),t}(),fs=25,_a=50,cn=-4,ci=3,np=7.99,ip=8,op=1024,sp=1024,up=1024,lp=.2,fp=.8,vp=10,cp=.15,dp=.1,hp=.9,gp=.9,pp=100,mp=1,Ir={dequeue:"dequeue",downscale:"downscale",highQuality:"highQuality"},yp=Je({getKey:null,doesEleInvalidateKey:pn,drawElement:null,getBoundingBox:null,getRotationPoint:null,getRotationOffset:null,isVisible:Us,allowEdgeTxrCaching:!0,allowParentTxrCaching:!0}),da=function(e,r){var a=this;a.renderer=e,a.onDequeues=[];var n=yp(r);ce(a,n),a.lookup=new ap(n.getKey,n.doesEleInvalidateKey),a.setupDequeueing()},Ke=da.prototype;Ke.reasons=Ir;Ke.getTextureQueue=function(t){var e=this;return e.eleImgCaches=e.eleImgCaches||{},e.eleImgCaches[t]=e.eleImgCaches[t]||[]};Ke.getRetiredTextureQueue=function(t){var e=this,r=e.eleImgCaches.retired=e.eleImgCaches.retired||{},a=r[t]=r[t]||[];return a};Ke.getElementQueue=function(){var t=this,e=t.eleCacheQueue=t.eleCacheQueue||new La.default(function(r,a){return a.reqs-r.reqs});return e};Ke.getElementKeyToQueue=function(){var t=this,e=t.eleKeyToCacheQueue=t.eleKeyToCacheQueue||{};return e};Ke.getElement=function(t,e,r,a,n){var i=this,o=this.renderer,s=o.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(Bi(s*r))),a=np||a>ci)return null;var l=Math.pow(2,a),f=e.h*l,v=e.w*l,c=o.eleTextBiggerThanMin(t,l);if(!this.isVisible(t,c))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<=fs?d=fs:f<=_a?d=_a:d=Math.ceil(f/_a)*_a,f>up||v>sp)return null;var p=i.getTextureQueue(d),m=p[p.length-2],g=function(){return i.recycleTexture(d,v)||i.addTexture(d,v)};m||(m=p[p.length-1]),m||(m=g()),m.width-m.usedWidtha;B--)E=i.getElement(t,e,r,B,Ir.downscale);P()}else return i.queueElement(t,C.level-1),C;else{var D;if(!b&&!w&&!S)for(var M=a-1;M>=cn;M--){var L=u.get(t,M);if(L){D=L;break}}if(y(D))return i.queueElement(t,a),D;m.context.translate(m.usedWidth,0),m.context.scale(l,l),this.drawElement(m.context,t,e,c,!1),m.context.scale(1/l,1/l),m.context.translate(-m.usedWidth,0)}return h={x:m.usedWidth,texture:m,level:a,scale:l,width:v,height:f,scaledLabelShown:c},m.usedWidth+=Math.ceil(v+ip),m.eleCaches.push(h),u.set(t,a,h),i.checkTextureFullness(m),h};Ke.invalidateElements=function(t){for(var e=0;e=lp*t.width&&this.retireTexture(t)};Ke.checkTextureFullness=function(t){var e=this,r=e.getTextureQueue(t.height);t.usedWidth/t.width>fp&&t.fullnessChecks>=vp?tr(r,t):t.fullnessChecks++};Ke.retireTexture=function(t){var e=this,r=t.height,a=e.getTextureQueue(r),n=this.lookup;tr(a,t),t.retired=!0;for(var i=t.eleCaches,o=0;o=e)return o.retired=!1,o.usedWidth=0,o.invalidatedWidth=0,o.fullnessChecks=0,Pi(o.eleCaches),o.context.setTransform(1,0,0,1,0,0),o.context.clearRect(0,0,o.width,o.height),tr(n,o),a.push(o),o}};Ke.queueElement=function(t,e){var r=this,a=r.getElementQueue(),n=r.getElementKeyToQueue(),i=this.getKey(t),o=n[i];if(o)o.level=Math.max(o.level,e),o.eles.merge(t),o.reqs++,a.updateItem(o);else{var s={eles:t.spawn().merge(t),level:e,reqs:1,key:i};a.push(s),n[i]=s}};Ke.dequeue=function(t){for(var e=this,r=e.getElementQueue(),a=e.getElementKeyToQueue(),n=[],i=e.lookup,o=0;o0;o++){var s=r.pop(),u=s.key,l=s.eles[0],f=i.hasCache(l,s.level);if(a[u]=null,f)continue;n.push(s);var v=e.getBoundingBox(l);e.getElement(l,v,t,s.level,Ir.dequeue)}return n};Ke.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=Di,r.updateItem(i),r.pop(),a[n]=null):i.eles.unmerge(t))};Ke.onDequeue=function(t){this.onDequeues.push(t)};Ke.offDequeue=function(t){tr(this.onDequeues,t)};Ke.setupDequeueing=Uu.setupDequeueing({deqRedrawThreshold:pp,deqCost:cp,deqAvgCost:dp,deqNoDrawCost:hp,deqFastCost:gp,deq:function(e,r,a){return e.dequeue(r,a)},onDeqd:function(e,r){for(var a=0;a=wp||r>En)return null}a.validateLayersElesOrdering(r,t);var u=a.layersByLevel,l=Math.pow(2,r),f=u[r]=u[r]||[],v,c=a.levelIsComplete(r,t),h,d=function(){var P=function(R){if(a.validateLayersElesOrdering(R,t),a.levelIsComplete(R,t))return h=u[R],!0},B=function(R){if(!h)for(var O=r+R;ga<=O&&O<=En&&!P(O);O+=R);};B(1),B(-1);for(var D=f.length-1;D>=0;D--){var M=f[D];M.invalid&&tr(f,M)}};if(!c)d();else return f;var p=function(){if(!v){v=ct();for(var P=0;PPp)return null;var M=a.makeLayer(v,r);if(B!=null){var L=f.indexOf(B)+1;f.splice(L,0,M)}else(P.insert===void 0||P.insert)&&f.unshift(M);return M};if(a.skipping&&!s)return null;for(var g=null,y=t.length/bp,b=!s,w=0;w=y||!eu(g.bb,S.boundingBox()))&&(g=m({insert:!0,after:g}),!g))return null;h||b?a.queueLayer(g,S):a.drawEleInLayer(g,S,r,e),g.eles.push(S),x[r]=g}return h||(b?null:f)};je.getEleLevelForLayerLevel=function(t,e){return t};je.drawEleInLayer=function(t,e,r,a){var n=this,i=this.renderer,o=t.context,s=e.boundingBox();s.w===0||s.h===0||!e.visible()||(r=n.getEleLevelForLayerLevel(r,a),i.setImgSmoothing(o,!1),i.drawCachedElement(o,e,null,null,r,Bp),i.setImgSmoothing(o,!0))};je.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||o.invalid)return!1;n+=o.eles.length}return n===e.length};je.validateLayersElesOrdering=function(t,e){var r=this.layersByLevel[t];if(r)for(var a=0;a0){e=!0;break}}return e};je.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)}))};je.invalidateLayer=function(t){if(this.lastInvalidationTime=qt(),!t.invalid){var e=t.level,r=t.eles,a=this.layersByLevel[e];tr(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,o=this,s=e._private.rscratch;if(!(i&&!e.visible())&&!(s.badLine||s.allpts==null||isNaN(s.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,v=e.pstyle("curve-style").value,c=e.pstyle("line-style").value,h=e.pstyle("width").pfValue,d=e.pstyle("line-cap").value,p=l*f,m=l*f,g=function(){var D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:p;v==="straight-triangle"?(o.eleStrokeStyle(t,e,D),o.drawEdgeTrianglePath(e,t,s.allpts)):(t.lineWidth=h,t.lineCap=d,o.eleStrokeStyle(t,e,D),o.drawEdgePath(e,t,s.allpts,c),t.lineCap="butt")},y=function(){n&&o.drawEdgeOverlay(t,e)},b=function(){n&&o.drawEdgeUnderlay(t,e)},w=function(){var D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:m;o.drawArrowheads(t,e,D)},S=function(){o.drawElementText(t,e,null,a)};t.lineJoin="round";var C=e.pstyle("ghost").value==="yes";if(C){var x=e.pstyle("ghost-offset-x").pfValue,T=e.pstyle("ghost-offset-y").pfValue,E=e.pstyle("ghost-opacity").value,P=p*E;t.translate(x,T),g(P),w(P),t.translate(-x,-T)}b(),g(),w(),y(),S(),r&&t.translate(u.x1,u.y1)}};var Ju=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,o=i.usePaths(),s=a._private.rscratch,u=a.pstyle("".concat(e,"-padding")).pfValue,l=2*u,f=a.pstyle("".concat(e,"-color")).value;r.lineWidth=l,s.edgeType==="self"&&!o?r.lineCap="butt":r.lineCap="round",i.colorStrokeStyle(r,f[0],f[1],f[2],n),i.drawEdgePath(a,r,s.allpts,"solid")}}}};Yt.drawEdgeOverlay=Ju("overlay");Yt.drawEdgeUnderlay=Ju("underlay");Yt.drawEdgePath=function(t,e,r,a){var n=t._private.rscratch,i=e,o,s=!1,u=this.usePaths(),l=t.pstyle("line-dash-pattern").pfValue,f=t.pstyle("line-dash-offset").pfValue;if(u){var v=r.join("$"),c=n.pathCacheKey&&n.pathCacheKey===v;c?(o=e=n.pathCache,s=!0):(o=e=new Path2D,n.pathCacheKey=v,n.pathCache=o)}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(!s&&!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,o=this;if(a==null){if(i&&!o.eleTextBiggerThanMin(e))return}else if(a===!1)return;if(e.isNode()){var s=e.pstyle("label");if(!s||!s.value)return;var u=o.getLabelJustification(e);t.textAlign=u,t.textBaseline="bottom"}else{var l=e.element()._private.rscratch.badLine,f=e.pstyle("label"),v=e.pstyle("source-label"),c=e.pstyle("target-label");if(l||(!f||!f.value)&&(!v||!v.value)&&(!c||!c.value))return;t.textAlign="center",t.textBaseline="bottom"}var h=!r,d;r&&(d=r,t.translate(-d.x1,-d.y1)),n==null?(o.drawText(t,e,null,h,i),e.isEdge()&&(o.drawText(t,e,"source",h,i),o.drawText(t,e,"target",h,i))):o.drawText(t,e,n,h,i),r&&t.translate(d.x1,d.y1)};Cr.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,o=e.pstyle("font-weight").strValue,s=r?e.effectiveOpacity()*e.pstyle("text-opacity").value:1,u=e.pstyle("text-outline-opacity").value*s,l=e.pstyle("color").value,f=e.pstyle("text-outline-color").value;t.font=a+" "+o+" "+n+" "+i,t.lineJoin="round",this.colorFillStyle(t,l[0],l[1],l[2],s),this.colorStrokeStyle(t,f[0],f[1],f[2],u)};function $p(t,e,r,a,n){var i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:5;t.beginPath(),t.moveTo(e+i,r),t.lineTo(e+a-i,r),t.quadraticCurveTo(e+a,r,e+a,r+i),t.lineTo(e+a,r+n-i),t.quadraticCurveTo(e+a,r+n,e+a-i,r+n),t.lineTo(e+i,r+n),t.quadraticCurveTo(e,r+n,e,r+n-i),t.lineTo(e,r+i),t.quadraticCurveTo(e,r,e+i,r),t.closePath(),t.fill()}Cr.getTextAngle=function(t,e){var r,a=t._private,n=a.rscratch,i=e?e+"-":"",o=t.pstyle(i+"text-rotation"),s=Bt(n,"labelAngle",e);return o.strValue==="autorotate"?r=t.isEdge()?s:0:o.strValue==="none"?r=0:r=o.pfValue,r};Cr.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,o=i.rscratch,s=n?e.effectiveOpacity():1;if(!(n&&(s===0||e.pstyle("text-opacity").value===0))){r==="main"&&(r=null);var u=Bt(o,"labelX",r),l=Bt(o,"labelY",r),f,v,c=this.getLabelText(e,r);if(c!=null&&c!==""&&!isNaN(u)&&!isNaN(l)){this.setupTextStyle(t,e,n);var h=r?r+"-":"",d=Bt(o,"labelWidth",r),p=Bt(o,"labelHeight",r),m=e.pstyle(h+"text-margin-x").pfValue,g=e.pstyle(h+"text-margin-y").pfValue,y=e.isEdge(),b=e.pstyle("text-halign").value,w=e.pstyle("text-valign").value;y&&(b="center",w="center"),u+=m,l+=g;var S;switch(a?S=this.getTextAngle(e,r):S=0,S!==0&&(f=u,v=l,t.translate(f,v),t.rotate(S),u=0,l=0),w){case"top":break;case"center":l+=p/2;break;case"bottom":l+=p;break}var C=e.pstyle("text-background-opacity").value,x=e.pstyle("text-border-opacity").value,T=e.pstyle("text-border-width").pfValue,E=e.pstyle("text-background-padding").pfValue;if(C>0||T>0&&x>0){var P=u-E;switch(b){case"left":P-=d;break;case"center":P-=d/2;break}var B=l-p-E,D=d+2*E,M=p+2*E;if(C>0){var L=t.fillStyle,R=e.pstyle("text-background-color").value;t.fillStyle="rgba("+R[0]+","+R[1]+","+R[2]+","+C*s+")";var O=e.pstyle("text-background-shape").strValue;O.indexOf("round")===0?$p(t,P,B,D,M,2):t.fillRect(P,B,D,M),t.fillStyle=L}if(T>0&&x>0){var A=t.strokeStyle,N=t.lineWidth,F=e.pstyle("text-border-color").value,q=e.pstyle("text-border-style").value;if(t.strokeStyle="rgba("+F[0]+","+F[1]+","+F[2]+","+x*s+")",t.lineWidth=T,t.setLineDash)switch(q){case"dotted":t.setLineDash([1,1]);break;case"dashed":t.setLineDash([4,2]);break;case"double":t.lineWidth=T/4,t.setLineDash([]);break;case"solid":t.setLineDash([]);break}if(t.strokeRect(P,B,D,M),q==="double"){var z=T/2;t.strokeRect(P+z,B+z,D-z*2,M-z*2)}t.setLineDash&&t.setLineDash([]),t.lineWidth=N,t.strokeStyle=A}}var $=2*e.pstyle("text-outline-width").pfValue;if($>0&&(t.lineWidth=$),e.pstyle("text-wrap").value==="wrap"){var K=Bt(o,"labelWrapCachedLines",r),Y=Bt(o,"labelLineHeight",r),H=d/2,W=this.getLabelJustification(e);switch(W==="auto"||(b==="left"?W==="left"?u+=-d:W==="center"&&(u+=-H):b==="center"?W==="left"?u+=-H:W==="right"&&(u+=H):b==="right"&&(W==="center"?u+=H:W==="right"&&(u+=d))),w){case"top":l-=(K.length-1)*Y;break;case"center":case"bottom":l-=(K.length-1)*Y;break}for(var I=0;I0&&t.strokeText(K[I],u,l),t.fillText(K[I],u,l),l+=Y}else $>0&&t.strokeText(c,u,l),t.fillText(c,u,l);S!==0&&(t.rotate(-S),t.translate(-f,-v))}}};var ea={};ea.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,o=this,s,u,l=e._private,f=l.rscratch,v=e.position();if(!(!ne(v.x)||!ne(v.y))&&!(i&&!e.visible())){var c=i?e.effectiveOpacity():1,h=o.usePaths(),d,p=!1,m=e.padding();s=e.width()+2*m,u=e.height()+2*m;var g;r&&(g=r,t.translate(-g.x1,-g.y1));for(var y=e.pstyle("background-image"),b=y.value,w=new Array(b.length),S=new Array(b.length),C=0,x=0;x0&&arguments[0]!==void 0?arguments[0]:M;o.eleFillStyle(t,e,ae)},N=function(){var ae=arguments.length>0&&arguments[0]!==void 0?arguments[0]:O;o.colorStrokeStyle(t,L[0],L[1],L[2],ae)},F=e.pstyle("shape").strValue,q=e.pstyle("shape-polygon-points").pfValue;if(h){t.translate(v.x,v.y);var z=o.nodePathCache=o.nodePathCache||[],$=Xs(F==="polygon"?F+","+q.join(","):F,""+u,""+s),K=z[$];K!=null?(d=K,p=!0,f.pathCache=d):(d=new Path2D,z[$]=f.pathCache=d)}var Y=function(){if(!p){var ae=v;h&&(ae={x:0,y:0}),o.nodeShapes[o.getNodeShape(e)].draw(d||t,ae.x,ae.y,s,u)}h?t.fill(d):t.fill()},H=function(){for(var ae=arguments.length>0&&arguments[0]!==void 0?arguments[0]:c,ue=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,ge=l.backgrounding,pe=0,ve=0;ve0&&arguments[0]!==void 0?arguments[0]:!1,ue=arguments.length>1&&arguments[1]!==void 0?arguments[1]:c;o.hasPie(e)&&(o.drawPie(t,e,ue),ae&&(h||o.nodeShapes[o.getNodeShape(e)].draw(t,v.x,v.y,s,u)))},I=function(){var ae=arguments.length>0&&arguments[0]!==void 0?arguments[0]:c,ue=(B>0?B:-B)*ae,ge=B>0?0:255;B!==0&&(o.colorFillStyle(t,ge,ge,ge,ue),h?t.fill(d):t.fill())},G=function(){if(D>0){if(t.lineWidth=D,t.lineCap="butt",t.setLineDash)switch(R){case"dotted":t.setLineDash([1,1]);break;case"dashed":t.setLineDash([4,2]);break;case"solid":case"double":t.setLineDash([]);break}if(h?t.stroke(d):t.stroke(),R==="double"){t.lineWidth=D/3;var ae=t.globalCompositeOperation;t.globalCompositeOperation="destination-out",h?t.stroke(d):t.stroke(),t.globalCompositeOperation=ae}t.setLineDash&&t.setLineDash([])}},Z=function(){n&&o.drawNodeOverlay(t,e,v,s,u)},_=function(){n&&o.drawNodeUnderlay(t,e,v,s,u)},ee=function(){o.drawElementText(t,e,null,a)},de=e.pstyle("ghost").value==="yes";if(de){var he=e.pstyle("ghost-offset-x").pfValue,re=e.pstyle("ghost-offset-y").pfValue,te=e.pstyle("ghost-opacity").value,se=te*c;t.translate(he,re),A(te*M),Y(),H(se,!0),N(te*O),G(),W(B!==0||D!==0),H(se,!1),I(se),t.translate(-he,-re)}h&&t.translate(-v.x,-v.y),_(),h&&t.translate(v.x,v.y),A(),Y(),H(c,!0),N(),G(),W(B!==0||D!==0),H(c,!1),I(),h&&t.translate(-v.x,-v.y),ee(),Z(),r&&t.translate(g.x1,g.y1)}};var ju=function(e){if(!["overlay","underlay"].includes(e))throw new Error("Invalid state");return function(r,a,n,i,o){var s=this;if(a.visible()){var u=a.pstyle("".concat(e,"-padding")).pfValue,l=a.pstyle("".concat(e,"-opacity")).value,f=a.pstyle("".concat(e,"-color")).value,v=a.pstyle("".concat(e,"-shape")).value;if(l>0){if(n=n||a.position(),i==null||o==null){var c=a.padding();i=a.width()+2*c,o=a.height()+2*c}s.colorFillStyle(r,f[0],f[1],f[2],l),s.nodeShapes[v].draw(r,n.x,n.y,i+u*2,o+u*2),r.fill()}}}};ea.drawNodeOverlay=ju("overlay");ea.drawNodeUnderlay=ju("underlay");ea.hasPie=function(t){return t=t[0],t._private.hasPie};ea.drawPie=function(t,e,r,a){e=e[0],a=a||e.position();var n=e.cy().style(),i=e.pstyle("pie-size"),o=a.x,s=a.y,u=e.width(),l=e.height(),f=Math.min(u,l)/2,v=0,c=this.usePaths();c&&(o=0,s=0),i.units==="%"?f=f*i.pfValue:i.pfValue!==void 0&&(f=i.pfValue/2);for(var h=1;h<=n.pieBackgroundN;h++){var d=e.pstyle("pie-"+h+"-background-size").value,p=e.pstyle("pie-"+h+"-background-color").value,m=e.pstyle("pie-"+h+"-background-opacity").value*r,g=d/100;g+v>1&&(g=1-v);var y=1.5*Math.PI+2*Math.PI*v,b=2*Math.PI*g,w=y+b;d===0||v>=1||v+g>1||(t.beginPath(),t.moveTo(o,s),t.arc(o,s,f,y,w),t.closePath(),this.colorFillStyle(t,p[0],p[1],p[2],m),t.fill(),v+=g)}};var mt={},qp=100;mt.getPixelRatio=function(){var t=this.data.contexts[0];if(this.forcedPixelRatio!=null)return this.forcedPixelRatio;var e=t.backingStorePixelRatio||t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1;return(window.devicePixelRatio||1)/e};mt.paintCache=function(t){for(var e=this.paintCaches=this.paintCaches||[],r=!0,a,n=0;no.minMbLowQualFrames&&(o.motionBlurPxRatio=o.mbPxRBlurry)),o.clearingMotionBlur&&(o.motionBlurPxRatio=1),o.textureDrawLastFrame&&!v&&(f[o.NODE]=!0,f[o.SELECT_BOX]=!0);var y=u.style(),b=u.zoom(),w=n!==void 0?n:b,S=u.pan(),C={x:S.x,y:S.y},x={zoom:b,pan:{x:S.x,y:S.y}},T=o.prevViewport,E=T===void 0||x.zoom!==T.zoom||x.pan.x!==T.pan.x||x.pan.y!==T.pan.y;!E&&!(p&&!d)&&(o.motionBlurPxRatio=1),i&&(C=i),w*=s,C.x*=s,C.y*=s;var P=o.getCachedZSortedEles();function B(re,te,se,ie,ae){var ue=re.globalCompositeOperation;re.globalCompositeOperation="destination-out",o.colorFillStyle(re,255,255,255,o.motionBlurTransparency),re.fillRect(te,se,ie,ae),re.globalCompositeOperation=ue}function D(re,te){var se,ie,ae,ue;!o.clearingMotionBlur&&(re===l.bufferContexts[o.MOTIONBLUR_BUFFER_NODE]||re===l.bufferContexts[o.MOTIONBLUR_BUFFER_DRAG])?(se={x:S.x*h,y:S.y*h},ie=b*h,ae=o.canvasWidth*h,ue=o.canvasHeight*h):(se=C,ie=w,ae=o.canvasWidth,ue=o.canvasHeight),re.setTransform(1,0,0,1,0,0),te==="motionBlur"?B(re,0,0,ae,ue):!e&&(te===void 0||te)&&re.clearRect(0,0,ae,ue),r||(re.translate(se.x,se.y),re.scale(ie,ie)),i&&re.translate(i.x,i.y),n&&re.scale(n,n)}if(v||(o.textureDrawLastFrame=!1),v){if(o.textureDrawLastFrame=!0,!o.textureCache){o.textureCache={},o.textureCache.bb=u.mutableElements().boundingBox(),o.textureCache.texture=o.data.bufferCanvases[o.TEXTURE_BUFFER];var M=o.data.bufferContexts[o.TEXTURE_BUFFER];M.setTransform(1,0,0,1,0,0),M.clearRect(0,0,o.canvasWidth*o.textureMult,o.canvasHeight*o.textureMult),o.render({forcedContext:M,drawOnlyNodeLayer:!0,forcedPxRatio:s*o.textureMult});var x=o.textureCache.viewport={zoom:u.zoom(),pan:u.pan(),width:o.canvasWidth,height:o.canvasHeight};x.mpan={x:(0-x.pan.x)/x.zoom,y:(0-x.pan.y)/x.zoom}}f[o.DRAG]=!1,f[o.NODE]=!1;var L=l.contexts[o.NODE],R=o.textureCache.texture,x=o.textureCache.viewport;L.setTransform(1,0,0,1,0,0),c?B(L,0,0,x.width,x.height):L.clearRect(0,0,x.width,x.height);var O=y.core("outside-texture-bg-color").value,A=y.core("outside-texture-bg-opacity").value;o.colorFillStyle(L,O[0],O[1],O[2],A),L.fillRect(0,0,x.width,x.height);var b=u.zoom();D(L,!1),L.clearRect(x.mpan.x,x.mpan.y,x.width/x.zoom/s,x.height/x.zoom/s),L.drawImage(R,x.mpan.x,x.mpan.y,x.width/x.zoom/s,x.height/x.zoom/s)}else o.textureOnViewport&&!e&&(o.textureCache=null);var N=u.extent(),F=o.pinching||o.hoverData.dragging||o.swipePanning||o.data.wheelZooming||o.hoverData.draggingEles||o.cy.animated(),q=o.hideEdgesOnViewport&&F,z=[];if(z[o.NODE]=!f[o.NODE]&&c&&!o.clearedForMotionBlur[o.NODE]||o.clearingMotionBlur,z[o.NODE]&&(o.clearedForMotionBlur[o.NODE]=!0),z[o.DRAG]=!f[o.DRAG]&&c&&!o.clearedForMotionBlur[o.DRAG]||o.clearingMotionBlur,z[o.DRAG]&&(o.clearedForMotionBlur[o.DRAG]=!0),f[o.NODE]||r||a||z[o.NODE]){var $=c&&!z[o.NODE]&&h!==1,L=e||($?o.data.bufferContexts[o.MOTIONBLUR_BUFFER_NODE]:l.contexts[o.NODE]),K=c&&!$?"motionBlur":void 0;D(L,K),q?o.drawCachedNodes(L,P.nondrag,s,N):o.drawLayeredElements(L,P.nondrag,s,N),o.debug&&o.drawDebugPoints(L,P.nondrag),!r&&!c&&(f[o.NODE]=!1)}if(!a&&(f[o.DRAG]||r||z[o.DRAG])){var $=c&&!z[o.DRAG]&&h!==1,L=e||($?o.data.bufferContexts[o.MOTIONBLUR_BUFFER_DRAG]:l.contexts[o.DRAG]);D(L,c&&!$?"motionBlur":void 0),q?o.drawCachedNodes(L,P.drag,s,N):o.drawCachedElements(L,P.drag,s,N),o.debug&&o.drawDebugPoints(L,P.drag),!r&&!c&&(f[o.DRAG]=!1)}if(o.showFps||!a&&f[o.SELECT_BOX]&&!r){var L=e||l.contexts[o.SELECT_BOX];if(D(L),o.selection[4]==1&&(o.hoverData.selecting||o.touchData.selecting)){var b=o.cy.zoom(),Y=y.core("selection-box-border-width").value/b;L.lineWidth=Y,L.fillStyle="rgba("+y.core("selection-box-color").value[0]+","+y.core("selection-box-color").value[1]+","+y.core("selection-box-color").value[2]+","+y.core("selection-box-opacity").value+")",L.fillRect(o.selection[0],o.selection[1],o.selection[2]-o.selection[0],o.selection[3]-o.selection[1]),Y>0&&(L.strokeStyle="rgba("+y.core("selection-box-border-color").value[0]+","+y.core("selection-box-border-color").value[1]+","+y.core("selection-box-border-color").value[2]+","+y.core("selection-box-opacity").value+")",L.strokeRect(o.selection[0],o.selection[1],o.selection[2]-o.selection[0],o.selection[3]-o.selection[1]))}if(l.bgActivePosistion&&!o.hoverData.selecting){var b=o.cy.zoom(),H=l.bgActivePosistion;L.fillStyle="rgba("+y.core("active-bg-color").value[0]+","+y.core("active-bg-color").value[1]+","+y.core("active-bg-color").value[2]+","+y.core("active-bg-opacity").value+")",L.beginPath(),L.arc(H.x,H.y,y.core("active-bg-size").pfValue/b,0,2*Math.PI),L.fill()}var W=o.lastRedrawTime;if(o.showFps&&W){W=Math.round(W);var I=Math.round(1e3/W);L.setTransform(1,0,0,1,0,0),L.fillStyle="rgba(255, 0, 0, 0.75)",L.strokeStyle="rgba(255, 0, 0, 0.75)",L.lineWidth=1,L.fillText("1 frame = "+W+" ms = "+I+" fps",0,20);var G=60;L.strokeRect(0,30,250,20),L.fillRect(0,30,250*Math.min(I/G,1),20)}r||(f[o.SELECT_BOX]=!1)}if(c&&h!==1){var Z=l.contexts[o.NODE],_=o.data.bufferCanvases[o.MOTIONBLUR_BUFFER_NODE],ee=l.contexts[o.DRAG],de=o.data.bufferCanvases[o.MOTIONBLUR_BUFFER_DRAG],he=function(te,se,ie){te.setTransform(1,0,0,1,0,0),ie||!g?te.clearRect(0,0,o.canvasWidth,o.canvasHeight):B(te,0,0,o.canvasWidth,o.canvasHeight);var ae=h;te.drawImage(se,0,0,o.canvasWidth*ae,o.canvasHeight*ae,0,0,o.canvasWidth,o.canvasHeight)};(f[o.NODE]||z[o.NODE])&&(he(Z,_,z[o.NODE]),f[o.NODE]=!1),(f[o.DRAG]||z[o.DRAG])&&(he(ee,de,z[o.DRAG]),f[o.DRAG]=!1)}o.prevViewport=x,o.clearingMotionBlur&&(o.clearingMotionBlur=!1,o.motionBlurCleared=!0,o.motionBlur=!0),c&&(o.motionBlurTimeout=setTimeout(function(){o.motionBlurTimeout=null,o.clearedForMotionBlur[o.NODE]=!1,o.clearedForMotionBlur[o.DRAG]=!1,o.motionBlur=!1,o.clearingMotionBlur=!v,o.mbFrames=0,f[o.NODE]=!0,f[o.DRAG]=!0,o.redraw()},qp)),e||u.emit("render")};var or={};or.drawPolygonPath=function(t,e,r,a,n,i){var o=a/2,s=n/2;t.beginPath&&t.beginPath(),t.moveTo(e+o*i[0],r+s*i[1]);for(var u=1;u0&&o>0){h.clearRect(0,0,i,o),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(),m={x:p.x*l,y:p.y*l};l*=e.zoom(),h.translate(m.x,m.y),h.scale(l,l),this.drawElements(h,d),h.scale(1/l,1/l),h.translate(-m.x,-m.y)}t.bg&&(h.globalCompositeOperation="destination-over",h.fillStyle=t.bg,h.rect(0,0,i,o),h.fill())}return c};function Hp(t,e){for(var r=atob(t),a=new ArrayBuffer(r.length),n=new Uint8Array(a),i=0;i"u"?"undefined":We(OffscreenCanvas))!=="undefined"?r=new OffscreenCanvas(t,e):(r=document.createElement("canvas"),r.width=t,r.height=e),r};[Qu,Ft,Yt,qi,Cr,ea,mt,or,Fa,tl].forEach(function(t){ce(Te,t)});var Gp=[{name:"null",impl:$u},{name:"base",impl:Xu},{name:"canvas",impl:Wp}],Yp=[{type:"layout",extensions:_g},{type:"renderer",extensions:Gp}],al={},nl={};function il(t,e,r){var a=r,n=function(T){Le("Can not register `"+e+"` for `"+t+"` since `"+T+"` 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(Qe.prototype[e])return n(e);Qe.prototype[e]=r}else if(t==="layout"){for(var i=function(T){this.options=T,r.call(this,T),Ce(this._private)||(this._private={}),this._private.cy=T.cy,this._private.listeners=[],this.createEmitter()},o=i.prototype=Object.create(r.prototype),s=[],u=0;u{if(((i,o)=>i==null||o==null)(t,e)&&(t!=null||e!=null))return!0;if(t===e)return!1;if(typeof t!="object"||typeof e!="object")return t!==e;const r=Object.keys(t),a=Object.keys(e),n=i=>t[i]!==e[i];return r.length!==a.length||!(!r.some(n)&&!a.some(n))},kt=(t,e)=>t!=null?t[e]:null,jp={diff:ll,get:kt,toJson:t=>t,forEach:(t,e)=>t.forEach(e),elements:[{data:{id:"a",label:"Example node A"}},{data:{id:"b",label:"Example node B"}},{data:{id:"e",source:"a",target:"b"}}],stylesheet:[{selector:"node",style:{label:"data(label)"}}],zoom:1,pan:{x:0,y:0}},an=(t,e,r,a)=>r(kt(t,a),kt(e,a)),_p=(t,e,r,a,n,i,o)=>{t.batch(()=>{(a===ll||an(e,r,a,"elements"))&&am(t,kt(e,"elements"),kt(r,"elements"),n,i,o,a),an(e,r,a,"stylesheet")&&rm(t,kt(e,"stylesheet"),kt(r,"stylesheet"),n),["zoom","minZoom","maxZoom","zoomingEnabled","userZoomingEnabled","pan","panningEnabled","userPanningEnabled","boxSelectionEnabled","autoungrabify","autolock","autounselectify"].forEach(s=>{an(e,r,a,s)&&em(t,s,kt(e,s),kt(r,s),n)})}),an(e,r,a,"layout")&&tm(t,kt(e,"layout"),kt(r,"layout"),n)},em=(t,e,r,a,n)=>{t[e](n(a))},tm=(t,e,r,a)=>{const n=a(r);n!=null&&t.layout(n).run()},rm=(t,e,r,a)=>{const n=t.style();n!=null&&n.fromJson(a(r)).update()},am=(t,e,r,a,n,i,o)=>{const s=[],u=t.collection(),l=[],f={},v={},c=h=>n(n(h,"data"),"id");i(r,h=>{const d=c(h);v[d]=h}),e!=null&&i(e,h=>{const d=c(h);f[d]=h,(p=>v[p]!=null)(d)||u.merge(t.getElementById(d))}),i(r,h=>{const d=c(h),p=(m=>f[m])(d);(m=>f[m]!=null)(d)?l.push({ele1:p,ele2:h}):s.push(a(h))}),u.length>0&&t.remove(u),s.length>0&&t.add(s),l.forEach(({ele1:h,ele2:d})=>nm(t,h,d,a,n,o))},nm=(t,e,r,a,n,i)=>{const o=n(n(r,"data"),"id"),s=t.getElementById(o),u={};["data","position","selected","selectable","locked","grabbable","classes"].forEach(f=>{const v=n(r,f);i(v,n(e,f))&&(u[f]=a(v))});const l=n(r,"scratch");i(l,n(e,"scratch"))&&s.scratch(a(l)),Object.keys(u).length>0&&s.json(u)};class im extends Kn.Component{static get propTypes(){return Jp}static get defaultProps(){return jp}static normalizeElements(e){if(e.length!=null)return e;{let{nodes:r,edges:a}=e;return r==null&&(r=[]),a==null&&(a=[]),r.concat(a)}}constructor(e){super(e),this.displayName="CytoscapeComponent",this.containerRef=Kn.createRef()}componentDidMount(){const e=this.containerRef.current,{global:r,headless:a,styleEnabled:n,hideEdgesOnViewport:i,textureOnViewport:o,motionBlur:s,motionBlurOpacity:u,wheelSensitivity:l,pixelRatio:f}=this.props,v=this._cy=new ul({container:e,headless:a,styleEnabled:n,hideEdgesOnViewport:i,textureOnViewport:o,motionBlur:s,motionBlurOpacity:u,wheelSensitivity:l,pixelRatio:f});r&&(window[r]=v),this.updateCytoscape(null,this.props)}updateCytoscape(e,r){const a=this._cy,{diff:n,toJson:i,get:o,forEach:s}=r;_p(a,e,r,n,i,o,s),r.cy!=null&&r.cy(a)}componentDidUpdate(e){this.updateCytoscape(e,this.props)}componentWillUnmount(){this._cy.destroy()}render(){const{id:e,className:r,style:a}=this.props;return Kn.createElement("div",{ref:this.containerRef,id:e,className:r,style:a})}}var fl={exports:{}},ot="top",gt="bottom",pt="right",st="left",Vn="auto",ta=[ot,gt,pt,st],wr="start",Wr="end",vl="clippingParents",Hi="viewport",Or="popper",cl="reference",pi=ta.reduce(function(t,e){return t.concat([e+"-"+wr,e+"-"+Wr])},[]),Wi=[].concat(ta,[Vn]).reduce(function(t,e){return t.concat([e,e+"-"+wr,e+"-"+Wr])},[]),dl="beforeRead",hl="read",gl="afterRead",pl="beforeMain",ml="main",yl="afterMain",bl="beforeWrite",wl="write",xl="afterWrite",El=[dl,hl,gl,pl,ml,yl,bl,wl,xl];function Nt(t){return t?(t.nodeName||"").toLowerCase():null}function Et(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function xr(t){var e=Et(t).Element;return t instanceof e||t instanceof Element}function xt(t){var e=Et(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function Ki(t){if(typeof ShadowRoot>"u")return!1;var e=Et(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function om(t){var e=t.state;Object.keys(e.elements).forEach(function(r){var a=e.styles[r]||{},n=e.attributes[r]||{},i=e.elements[r];!xt(i)||!Nt(i)||(Object.assign(i.style,a),Object.keys(n).forEach(function(o){var s=n[o];s===!1?i.removeAttribute(o):i.setAttribute(o,s===!0?"":s)}))})}function sm(t){var e=t.state,r={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,r.popper),e.styles=r,e.elements.arrow&&Object.assign(e.elements.arrow.style,r.arrow),function(){Object.keys(e.elements).forEach(function(a){var n=e.elements[a],i=e.attributes[a]||{},o=Object.keys(e.styles.hasOwnProperty(a)?e.styles[a]:r[a]),s=o.reduce(function(u,l){return u[l]="",u},{});!xt(n)||!Nt(n)||(Object.assign(n.style,s),Object.keys(i).forEach(function(u){n.removeAttribute(u)}))})}}const Gi={name:"applyStyles",enabled:!0,phase:"write",fn:om,effect:sm,requires:["computeStyles"]};function Rt(t){return t.split("-")[0]}var dr=Math.max,Cn=Math.min,Kr=Math.round;function mi(){var t=navigator.userAgentData;return t!=null&&t.brands?t.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function Cl(){return!/^((?!chrome|android).)*safari/i.test(mi())}function Gr(t,e,r){e===void 0&&(e=!1),r===void 0&&(r=!1);var a=t.getBoundingClientRect(),n=1,i=1;e&&xt(t)&&(n=t.offsetWidth>0&&Kr(a.width)/t.offsetWidth||1,i=t.offsetHeight>0&&Kr(a.height)/t.offsetHeight||1);var o=xr(t)?Et(t):window,s=o.visualViewport,u=!Cl()&&r,l=(a.left+(u&&s?s.offsetLeft:0))/n,f=(a.top+(u&&s?s.offsetTop:0))/i,v=a.width/n,c=a.height/i;return{width:v,height:c,top:f,right:l+v,bottom:f+c,left:l,x:l,y:f}}function Yi(t){var e=Gr(t),r=t.offsetWidth,a=t.offsetHeight;return Math.abs(e.width-r)<=1&&(r=e.width),Math.abs(e.height-a)<=1&&(a=e.height),{x:t.offsetLeft,y:t.offsetTop,width:r,height:a}}function Sl(t,e){var r=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(r&&Ki(r)){var a=e;do{if(a&&t.isSameNode(a))return!0;a=a.parentNode||a.host}while(a)}return!1}function Kt(t){return Et(t).getComputedStyle(t)}function um(t){return["table","td","th"].indexOf(Nt(t))>=0}function sr(t){return((xr(t)?t.ownerDocument:t.document)||window.document).documentElement}function $n(t){return Nt(t)==="html"?t:t.assignedSlot||t.parentNode||(Ki(t)?t.host:null)||sr(t)}function bs(t){return!xt(t)||Kt(t).position==="fixed"?null:t.offsetParent}function lm(t){var e=/firefox/i.test(mi()),r=/Trident/i.test(mi());if(r&&xt(t)){var a=Kt(t);if(a.position==="fixed")return null}var n=$n(t);for(Ki(n)&&(n=n.host);xt(n)&&["html","body"].indexOf(Nt(n))<0;){var i=Kt(n);if(i.transform!=="none"||i.perspective!=="none"||i.contain==="paint"||["transform","perspective"].indexOf(i.willChange)!==-1||e&&i.willChange==="filter"||e&&i.filter&&i.filter!=="none")return n;n=n.parentNode}return null}function Va(t){for(var e=Et(t),r=bs(t);r&&um(r)&&Kt(r).position==="static";)r=bs(r);return r&&(Nt(r)==="html"||Nt(r)==="body"&&Kt(r).position==="static")?e:r||lm(t)||e}function Xi(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function pa(t,e,r){return dr(t,Cn(e,r))}function fm(t,e,r){var a=pa(t,e,r);return a>r?r:a}function Tl(){return{top:0,right:0,bottom:0,left:0}}function Dl(t){return Object.assign({},Tl(),t)}function kl(t,e){return e.reduce(function(r,a){return r[a]=t,r},{})}var vm=function(e,r){return e=typeof e=="function"?e(Object.assign({},r.rects,{placement:r.placement})):e,Dl(typeof e!="number"?e:kl(e,ta))};function cm(t){var e,r=t.state,a=t.name,n=t.options,i=r.elements.arrow,o=r.modifiersData.popperOffsets,s=Rt(r.placement),u=Xi(s),l=[st,pt].indexOf(s)>=0,f=l?"height":"width";if(!(!i||!o)){var v=vm(n.padding,r),c=Yi(i),h=u==="y"?ot:st,d=u==="y"?gt:pt,p=r.rects.reference[f]+r.rects.reference[u]-o[u]-r.rects.popper[f],m=o[u]-r.rects.reference[u],g=Va(i),y=g?u==="y"?g.clientHeight||0:g.clientWidth||0:0,b=p/2-m/2,w=v[h],S=y-c[f]-v[d],C=y/2-c[f]/2+b,x=pa(w,C,S),T=u;r.modifiersData[a]=(e={},e[T]=x,e.centerOffset=x-C,e)}}function dm(t){var e=t.state,r=t.options,a=r.element,n=a===void 0?"[data-popper-arrow]":a;n!=null&&(typeof n=="string"&&(n=e.elements.popper.querySelector(n),!n)||Sl(e.elements.popper,n)&&(e.elements.arrow=n))}const Pl={name:"arrow",enabled:!0,phase:"main",fn:cm,effect:dm,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Yr(t){return t.split("-")[1]}var hm={top:"auto",right:"auto",bottom:"auto",left:"auto"};function gm(t){var e=t.x,r=t.y,a=window,n=a.devicePixelRatio||1;return{x:Kr(e*n)/n||0,y:Kr(r*n)/n||0}}function ws(t){var e,r=t.popper,a=t.popperRect,n=t.placement,i=t.variation,o=t.offsets,s=t.position,u=t.gpuAcceleration,l=t.adaptive,f=t.roundOffsets,v=t.isFixed,c=o.x,h=c===void 0?0:c,d=o.y,p=d===void 0?0:d,m=typeof f=="function"?f({x:h,y:p}):{x:h,y:p};h=m.x,p=m.y;var g=o.hasOwnProperty("x"),y=o.hasOwnProperty("y"),b=st,w=ot,S=window;if(l){var C=Va(r),x="clientHeight",T="clientWidth";if(C===Et(r)&&(C=sr(r),Kt(C).position!=="static"&&s==="absolute"&&(x="scrollHeight",T="scrollWidth")),C=C,n===ot||(n===st||n===pt)&&i===Wr){w=gt;var E=v&&C===S&&S.visualViewport?S.visualViewport.height:C[x];p-=E-a.height,p*=u?1:-1}if(n===st||(n===ot||n===gt)&&i===Wr){b=pt;var P=v&&C===S&&S.visualViewport?S.visualViewport.width:C[T];h-=P-a.width,h*=u?1:-1}}var B=Object.assign({position:s},l&&hm),D=f===!0?gm({x:h,y:p}):{x:h,y:p};if(h=D.x,p=D.y,u){var M;return Object.assign({},B,(M={},M[w]=y?"0":"",M[b]=g?"0":"",M.transform=(S.devicePixelRatio||1)<=1?"translate("+h+"px, "+p+"px)":"translate3d("+h+"px, "+p+"px, 0)",M))}return Object.assign({},B,(e={},e[w]=y?p+"px":"",e[b]=g?h+"px":"",e.transform="",e))}function pm(t){var e=t.state,r=t.options,a=r.gpuAcceleration,n=a===void 0?!0:a,i=r.adaptive,o=i===void 0?!0:i,s=r.roundOffsets,u=s===void 0?!0:s,l={placement:Rt(e.placement),variation:Yr(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:n,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,ws(Object.assign({},l,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:o,roundOffsets:u})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,ws(Object.assign({},l,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:u})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const Ui={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:pm,data:{}};var nn={passive:!0};function mm(t){var e=t.state,r=t.instance,a=t.options,n=a.scroll,i=n===void 0?!0:n,o=a.resize,s=o===void 0?!0:o,u=Et(e.elements.popper),l=[].concat(e.scrollParents.reference,e.scrollParents.popper);return i&&l.forEach(function(f){f.addEventListener("scroll",r.update,nn)}),s&&u.addEventListener("resize",r.update,nn),function(){i&&l.forEach(function(f){f.removeEventListener("scroll",r.update,nn)}),s&&u.removeEventListener("resize",r.update,nn)}}const Zi={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:mm,data:{}};var ym={left:"right",right:"left",bottom:"top",top:"bottom"};function dn(t){return t.replace(/left|right|bottom|top/g,function(e){return ym[e]})}var bm={start:"end",end:"start"};function xs(t){return t.replace(/start|end/g,function(e){return bm[e]})}function Qi(t){var e=Et(t),r=e.pageXOffset,a=e.pageYOffset;return{scrollLeft:r,scrollTop:a}}function Ji(t){return Gr(sr(t)).left+Qi(t).scrollLeft}function wm(t,e){var r=Et(t),a=sr(t),n=r.visualViewport,i=a.clientWidth,o=a.clientHeight,s=0,u=0;if(n){i=n.width,o=n.height;var l=Cl();(l||!l&&e==="fixed")&&(s=n.offsetLeft,u=n.offsetTop)}return{width:i,height:o,x:s+Ji(t),y:u}}function xm(t){var e,r=sr(t),a=Qi(t),n=(e=t.ownerDocument)==null?void 0:e.body,i=dr(r.scrollWidth,r.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),o=dr(r.scrollHeight,r.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0),s=-a.scrollLeft+Ji(t),u=-a.scrollTop;return Kt(n||r).direction==="rtl"&&(s+=dr(r.clientWidth,n?n.clientWidth:0)-i),{width:i,height:o,x:s,y:u}}function ji(t){var e=Kt(t),r=e.overflow,a=e.overflowX,n=e.overflowY;return/auto|scroll|overlay|hidden/.test(r+n+a)}function Bl(t){return["html","body","#document"].indexOf(Nt(t))>=0?t.ownerDocument.body:xt(t)&&ji(t)?t:Bl($n(t))}function ma(t,e){var r;e===void 0&&(e=[]);var a=Bl(t),n=a===((r=t.ownerDocument)==null?void 0:r.body),i=Et(a),o=n?[i].concat(i.visualViewport||[],ji(a)?a:[]):a,s=e.concat(o);return n?s:s.concat(ma($n(o)))}function yi(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function Em(t,e){var r=Gr(t,!1,e==="fixed");return r.top=r.top+t.clientTop,r.left=r.left+t.clientLeft,r.bottom=r.top+t.clientHeight,r.right=r.left+t.clientWidth,r.width=t.clientWidth,r.height=t.clientHeight,r.x=r.left,r.y=r.top,r}function Es(t,e,r){return e===Hi?yi(wm(t,r)):xr(e)?Em(e,r):yi(xm(sr(t)))}function Cm(t){var e=ma($n(t)),r=["absolute","fixed"].indexOf(Kt(t).position)>=0,a=r&&xt(t)?Va(t):t;return xr(a)?e.filter(function(n){return xr(n)&&Sl(n,a)&&Nt(n)!=="body"}):[]}function Sm(t,e,r,a){var n=e==="clippingParents"?Cm(t):[].concat(e),i=[].concat(n,[r]),o=i[0],s=i.reduce(function(u,l){var f=Es(t,l,a);return u.top=dr(f.top,u.top),u.right=Cn(f.right,u.right),u.bottom=Cn(f.bottom,u.bottom),u.left=dr(f.left,u.left),u},Es(t,o,a));return s.width=s.right-s.left,s.height=s.bottom-s.top,s.x=s.left,s.y=s.top,s}function Ll(t){var e=t.reference,r=t.element,a=t.placement,n=a?Rt(a):null,i=a?Yr(a):null,o=e.x+e.width/2-r.width/2,s=e.y+e.height/2-r.height/2,u;switch(n){case ot:u={x:o,y:e.y-r.height};break;case gt:u={x:o,y:e.y+e.height};break;case pt:u={x:e.x+e.width,y:s};break;case st:u={x:e.x-r.width,y:s};break;default:u={x:e.x,y:e.y}}var l=n?Xi(n):null;if(l!=null){var f=l==="y"?"height":"width";switch(i){case wr:u[l]=u[l]-(e[f]/2-r[f]/2);break;case Wr:u[l]=u[l]+(e[f]/2-r[f]/2);break}}return u}function Xr(t,e){e===void 0&&(e={});var r=e,a=r.placement,n=a===void 0?t.placement:a,i=r.strategy,o=i===void 0?t.strategy:i,s=r.boundary,u=s===void 0?vl:s,l=r.rootBoundary,f=l===void 0?Hi:l,v=r.elementContext,c=v===void 0?Or:v,h=r.altBoundary,d=h===void 0?!1:h,p=r.padding,m=p===void 0?0:p,g=Dl(typeof m!="number"?m:kl(m,ta)),y=c===Or?cl:Or,b=t.rects.popper,w=t.elements[d?y:c],S=Sm(xr(w)?w:w.contextElement||sr(t.elements.popper),u,f,o),C=Gr(t.elements.reference),x=Ll({reference:C,element:b,strategy:"absolute",placement:n}),T=yi(Object.assign({},b,x)),E=c===Or?T:C,P={top:S.top-E.top+g.top,bottom:E.bottom-S.bottom+g.bottom,left:S.left-E.left+g.left,right:E.right-S.right+g.right},B=t.modifiersData.offset;if(c===Or&&B){var D=B[n];Object.keys(P).forEach(function(M){var L=[pt,gt].indexOf(M)>=0?1:-1,R=[ot,gt].indexOf(M)>=0?"y":"x";P[M]+=D[R]*L})}return P}function Tm(t,e){e===void 0&&(e={});var r=e,a=r.placement,n=r.boundary,i=r.rootBoundary,o=r.padding,s=r.flipVariations,u=r.allowedAutoPlacements,l=u===void 0?Wi:u,f=Yr(a),v=f?s?pi:pi.filter(function(d){return Yr(d)===f}):ta,c=v.filter(function(d){return l.indexOf(d)>=0});c.length===0&&(c=v);var h=c.reduce(function(d,p){return d[p]=Xr(t,{placement:p,boundary:n,rootBoundary:i,padding:o})[Rt(p)],d},{});return Object.keys(h).sort(function(d,p){return h[d]-h[p]})}function Dm(t){if(Rt(t)===Vn)return[];var e=dn(t);return[xs(t),e,xs(e)]}function km(t){var e=t.state,r=t.options,a=t.name;if(!e.modifiersData[a]._skip){for(var n=r.mainAxis,i=n===void 0?!0:n,o=r.altAxis,s=o===void 0?!0:o,u=r.fallbackPlacements,l=r.padding,f=r.boundary,v=r.rootBoundary,c=r.altBoundary,h=r.flipVariations,d=h===void 0?!0:h,p=r.allowedAutoPlacements,m=e.options.placement,g=Rt(m),y=g===m,b=u||(y||!d?[dn(m)]:Dm(m)),w=[m].concat(b).reduce(function(Y,H){return Y.concat(Rt(H)===Vn?Tm(e,{placement:H,boundary:f,rootBoundary:v,padding:l,flipVariations:d,allowedAutoPlacements:p}):H)},[]),S=e.rects.reference,C=e.rects.popper,x=new Map,T=!0,E=w[0],P=0;P=0,R=L?"width":"height",O=Xr(e,{placement:B,boundary:f,rootBoundary:v,altBoundary:c,padding:l}),A=L?M?pt:st:M?gt:ot;S[R]>C[R]&&(A=dn(A));var N=dn(A),F=[];if(i&&F.push(O[D]<=0),s&&F.push(O[A]<=0,O[N]<=0),F.every(function(Y){return Y})){E=B,T=!1;break}x.set(B,F)}if(T)for(var q=d?3:1,z=function(H){var W=w.find(function(I){var G=x.get(I);if(G)return G.slice(0,H).every(function(Z){return Z})});if(W)return E=W,"break"},$=q;$>0;$--){var K=z($);if(K==="break")break}e.placement!==E&&(e.modifiersData[a]._skip=!0,e.placement=E,e.reset=!0)}}const Ml={name:"flip",enabled:!0,phase:"main",fn:km,requiresIfExists:["offset"],data:{_skip:!1}};function Cs(t,e,r){return r===void 0&&(r={x:0,y:0}),{top:t.top-e.height-r.y,right:t.right-e.width+r.x,bottom:t.bottom-e.height+r.y,left:t.left-e.width-r.x}}function Ss(t){return[ot,pt,gt,st].some(function(e){return t[e]>=0})}function Pm(t){var e=t.state,r=t.name,a=e.rects.reference,n=e.rects.popper,i=e.modifiersData.preventOverflow,o=Xr(e,{elementContext:"reference"}),s=Xr(e,{altBoundary:!0}),u=Cs(o,a),l=Cs(s,n,i),f=Ss(u),v=Ss(l);e.modifiersData[r]={referenceClippingOffsets:u,popperEscapeOffsets:l,isReferenceHidden:f,hasPopperEscaped:v},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":f,"data-popper-escaped":v})}const Ol={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:Pm};function Bm(t,e,r){var a=Rt(t),n=[st,ot].indexOf(a)>=0?-1:1,i=typeof r=="function"?r(Object.assign({},e,{placement:t})):r,o=i[0],s=i[1];return o=o||0,s=(s||0)*n,[st,pt].indexOf(a)>=0?{x:s,y:o}:{x:o,y:s}}function Lm(t){var e=t.state,r=t.options,a=t.name,n=r.offset,i=n===void 0?[0,0]:n,o=Wi.reduce(function(f,v){return f[v]=Bm(v,e.rects,i),f},{}),s=o[e.placement],u=s.x,l=s.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=u,e.modifiersData.popperOffsets.y+=l),e.modifiersData[a]=o}const Al={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:Lm};function Mm(t){var e=t.state,r=t.name;e.modifiersData[r]=Ll({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const _i={name:"popperOffsets",enabled:!0,phase:"read",fn:Mm,data:{}};function Om(t){return t==="x"?"y":"x"}function Am(t){var e=t.state,r=t.options,a=t.name,n=r.mainAxis,i=n===void 0?!0:n,o=r.altAxis,s=o===void 0?!1:o,u=r.boundary,l=r.rootBoundary,f=r.altBoundary,v=r.padding,c=r.tether,h=c===void 0?!0:c,d=r.tetherOffset,p=d===void 0?0:d,m=Xr(e,{boundary:u,rootBoundary:l,padding:v,altBoundary:f}),g=Rt(e.placement),y=Yr(e.placement),b=!y,w=Xi(g),S=Om(w),C=e.modifiersData.popperOffsets,x=e.rects.reference,T=e.rects.popper,E=typeof p=="function"?p(Object.assign({},e.rects,{placement:e.placement})):p,P=typeof E=="number"?{mainAxis:E,altAxis:E}:Object.assign({mainAxis:0,altAxis:0},E),B=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,D={x:0,y:0};if(C){if(i){var M,L=w==="y"?ot:st,R=w==="y"?gt:pt,O=w==="y"?"height":"width",A=C[w],N=A+m[L],F=A-m[R],q=h?-T[O]/2:0,z=y===wr?x[O]:T[O],$=y===wr?-T[O]:-x[O],K=e.elements.arrow,Y=h&&K?Yi(K):{width:0,height:0},H=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:Tl(),W=H[L],I=H[R],G=pa(0,x[O],Y[O]),Z=b?x[O]/2-q-G-W-P.mainAxis:z-G-W-P.mainAxis,_=b?-x[O]/2+q+G+I+P.mainAxis:$+G+I+P.mainAxis,ee=e.elements.arrow&&Va(e.elements.arrow),de=ee?w==="y"?ee.clientTop||0:ee.clientLeft||0:0,he=(M=B==null?void 0:B[w])!=null?M:0,re=A+Z-he-de,te=A+_-he,se=pa(h?Cn(N,re):N,A,h?dr(F,te):F);C[w]=se,D[w]=se-A}if(s){var ie,ae=w==="x"?ot:st,ue=w==="x"?gt:pt,ge=C[S],pe=S==="y"?"height":"width",ve=ge+m[ae],xe=ge-m[ue],Q=[ot,st].indexOf(g)!==-1,k=(ie=B==null?void 0:B[S])!=null?ie:0,V=Q?ve:ge-x[pe]-T[pe]-k+P.altAxis,J=Q?ge+x[pe]+T[pe]-k-P.altAxis:xe,X=h&&Q?fm(V,ge,J):pa(h?V:ve,ge,h?J:xe);C[S]=X,D[S]=X-ge}e.modifiersData[a]=D}}const Rl={name:"preventOverflow",enabled:!0,phase:"main",fn:Am,requiresIfExists:["offset"]};function Rm(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function Im(t){return t===Et(t)||!xt(t)?Qi(t):Rm(t)}function Nm(t){var e=t.getBoundingClientRect(),r=Kr(e.width)/t.offsetWidth||1,a=Kr(e.height)/t.offsetHeight||1;return r!==1||a!==1}function zm(t,e,r){r===void 0&&(r=!1);var a=xt(e),n=xt(e)&&Nm(e),i=sr(e),o=Gr(t,n,r),s={scrollLeft:0,scrollTop:0},u={x:0,y:0};return(a||!a&&!r)&&((Nt(e)!=="body"||ji(i))&&(s=Im(e)),xt(e)?(u=Gr(e,!0),u.x+=e.clientLeft,u.y+=e.clientTop):i&&(u.x=Ji(i))),{x:o.left+s.scrollLeft-u.x,y:o.top+s.scrollTop-u.y,width:o.width,height:o.height}}function Fm(t){var e=new Map,r=new Set,a=[];t.forEach(function(i){e.set(i.name,i)});function n(i){r.add(i.name);var o=[].concat(i.requires||[],i.requiresIfExists||[]);o.forEach(function(s){if(!r.has(s)){var u=e.get(s);u&&n(u)}}),a.push(i)}return t.forEach(function(i){r.has(i.name)||n(i)}),a}function Vm(t){var e=Fm(t);return El.reduce(function(r,a){return r.concat(e.filter(function(n){return n.phase===a}))},[])}function $m(t){var e;return function(){return e||(e=new Promise(function(r){Promise.resolve().then(function(){e=void 0,r(t())})})),e}}function qm(t){var e=t.reduce(function(r,a){var n=r[a.name];return r[a.name]=n?Object.assign({},n,a,{options:Object.assign({},n.options,a.options),data:Object.assign({},n.data,a.data)}):a,r},{});return Object.keys(e).map(function(r){return e[r]})}var Ts={placement:"bottom",modifiers:[],strategy:"absolute"};function Ds(){for(var t=arguments.length,e=new Array(t),r=0;r1?s-1:0),l=1;l1&&(console.warn("Popper.js Extension should only be used on one element."),console.warn("Ignoring all subsequent elements"))}a.exports={popper:v,popperRef:c}},function(a,n,i){var o=i(0),s=i(2),u=s.getPopper,l=i(1),f=l.getRef;function v(d){return u(this,h(this,d))}function c(d){return f(this,h(this,d))}function h(d,p){var m={boundingBox:{top:0,left:0,right:0,bottom:0,w:3,h:3},renderedDimensions:function(){return{w:3,h:3}},renderedPosition:function(){return{x:0,y:0}},popper:{},cy:d};return o({},m,p)}a.exports={popper:v,popperRef:c}},function(a,n,i){function o(s,u){var l=u.renderedPosition,f=u.cy,v=u.renderedDimensions,c=f.container().getBoundingClientRect(),h=v(s),d=l(s);return{top:d.y+c.top,left:d.x+c.left,right:d.x+h.w+c.left,bottom:d.y+h.h+c.top,width:h.w,height:h.h}}a.exports={getBoundingBox:o}},function(a,n,i){function o(s,u){var l=null;if(typeof u=="function")l=u(s);else{if(u instanceof HTMLElement)return u;throw new Error("Can not create popper from 'target' with unknown type")}if(l===null)throw new Error("No 'target' specified to create popper");return l}a.exports={getContent:o}},function(a,n,i){var o=i(4),s=i(3),u=function(f){f&&(f("core","popper",o.popper),f("collection","popper",s.popper),f("core","popperRef",o.popperRef),f("collection","popperRef",s.popperRef))};typeof cytoscape<"u"&&u(cytoscape),a.exports=u},function(a,n){a.exports=r}])})})(fl);var Zm=fl.exports;const Qm=Ps(Zm),Jm=t=>{var a;const e=document.createElement("div");return e.className="map-tooltip",ef(e).render(t),(a=document.getElementById("network-map"))==null||a.appendChild(e),e},jm=({item:t,type:e})=>{if(e==="instance"){const r=t,a=no(r,"inet").concat(no(r,"inet6")).map(n=>Pe.jsxs("li",{className:"p-list__item",children:[n.address," (",n.iface,")"]},n.address));return Pe.jsxs("div",{className:"p-text--small tooltip",children:[Pe.jsx("a",{href:`/ui/project/${r.project}/instances/detail/${r.name}`,children:Pe.jsx(tf,{item:r})}),Pe.jsx("br",{}),"Status: ",Pe.jsx("i",{children:r.status}),Pe.jsx("br",{}),"IPs:"," ",Pe.jsx("ul",{className:"p-list u-no-margin--bottom",children:a.length>0?a:Pe.jsx("li",{children:"None"})})]})}if(e==="network"){const r=t;return Pe.jsxs("div",{className:"p-text--small tooltip",children:[r.name,Pe.jsx("br",{}),"Status: ",Pe.jsx("i",{children:r.status!==""?r.status:"None"}),Pe.jsx("br",{}),"Type: ",r.type]})}return null},_m=()=>Pe.jsx(ai.List,{className:"legend",items:[Pe.jsxs("div",{style:{display:"inline-flex"},children:[Pe.jsx("span",{className:"legend-item instance other"}),"Instance (running)"]},"instance"),Pe.jsxs("div",{style:{display:"inline-flex"},children:[Pe.jsx("span",{className:"legend-item instance running"}),"Instance (other status)"]},"instance"),Pe.jsxs("div",{style:{display:"inline-flex"},children:[Pe.jsx("span",{className:"legend-item network"}),"Network"]},"network")]});ul.use(Qm);const ry=()=>{const{project:t}=rf(),e=af.useRef(null),{data:r=[],isLoading:a}=io({queryKey:[oo.instances,t],queryFn:()=>lf(t??""),enabled:!!t}),{data:n=[],isLoading:i}=io({queryKey:[oo.networks],queryFn:()=>ff(t??""),enabled:!!t});if(!t)return Pe.jsx(Pe.Fragment,{children:"Missing project"});if(a||i)return Pe.jsx(nf,{});const o=v=>{switch(v.status){case"Running":return"#0E8420";default:return"#D9D9D9"}},s=r.map(v=>({data:{id:v.name,label:v.name,details:{type:"instance",item:v}},style:{backgroundColor:o(v),"text-background-opacity":1,"text-background-color":"#FFF"}})),u=n.map(v=>({data:{id:v.name,label:v.name,details:{type:"network",item:v}},style:{shape:"square",backgroundColor:"#06C","text-background-opacity":1,"text-background-color":"#FFF"}})),l=[];r.map(v=>Object.values(v.expanded_devices??{}).filter(of).map(c=>{l.push({data:{source:v.name,target:c.network,label:""},style:{lineColor:"#D9D9D9"}})}));const f=[...u,...s,...l];return Pe.jsxs(sf,{title:"Network map (beta)",children:[Pe.jsx(uf,{}),Pe.jsx(ai.Row,{children:Pe.jsxs(ai.Col,{size:12,id:"network-map",className:"network-map",children:[Pe.jsx(_m,{}),Pe.jsx(im,{className:"canvas",elements:f,layout:{name:"cose",nodeDimensionsIncludeLabels:!0,animate:!1},cy:v=>{v.nodes().on("mouseover",c=>{e.current=c.target.popper({content:Jm(Pe.jsx(jm,{...c.target.data().details})),popper:{placement:"right",removeOnDestroy:!0}})}),v.nodes().on("mouseout",()=>{var c;if(e.current){e.current.destroy();const h=document.getElementsByClassName("map-tooltip");(c=h[0].parentNode)==null||c.removeChild(h[0])}})}})]})})]})};export{ry as default};