/*! * This file is part of Cytoscape.js 2.4.8. * * Cytoscape.js is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any * later version. * * Cytoscape.js is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License along with * Cytoscape.js. If not, see . */ var cytoscape;!function(e){"use strict";var t=cytoscape=function(){return cytoscape.init.apply(cytoscape,arguments)};t.version="2.4.8",t.init=function(e){return void 0===e&&(e={}),t.is.plainObject(e)?new t.Core(e):t.is.string(e)?t.extension.apply(t.extension,arguments):void 0},t.fn={},"undefined"!=typeof module&&module.exports&&(module.exports=cytoscape),"undefined"!=typeof define&&define.amd&&define("cytoscape",function(){return cytoscape}),e&&(e.cytoscape=cytoscape)}("undefined"==typeof window?null:window),this.cytoscape=cytoscape,function(e){"use strict";var t=0,r=1,i=2,n=function(e){return this instanceof n?(this.id="Thenable/1.0.7",this.state=t,this.fulfillValue=void 0,this.rejectReason=void 0,this.onFulfilled=[],this.onRejected=[],this.proxy={then:this.then.bind(this)},void("function"==typeof e&&e.call(this,this.fulfill.bind(this),this.reject.bind(this)))):new n(e)};n.prototype={fulfill:function(e){return a(this,r,"fulfillValue",e)},reject:function(e){return a(this,i,"rejectReason",e)},then:function(e,t){var r=this,i=new n;return r.onFulfilled.push(l(e,i,"fulfill")),r.onRejected.push(l(t,i,"reject")),o(r),i.proxy}};var a=function(e,r,i,n){return e.state===t&&(e.state=r,e[i]=n,o(e)),e},o=function(e){e.state===r?s(e,"onFulfilled",e.fulfillValue):e.state===i&&s(e,"onRejected",e.rejectReason)},s=function(e,t,r){if(0!==e[t].length){var i=e[t];e[t]=[];var n=function(){for(var e=0;el;l++)if(null!=(t=arguments[l]))for(r in t)i=s[r],n=t[r],s!==n&&(c&&n&&(e.is.plainObject(n)||(a=e.is.array(n)))?(a?(a=!1,o=i&&e.is.array(i)?i:[]):o=i&&e.is.plainObject(i)?i:{},s[r]=e.util.extend(c,o,n)):void 0!==n&&(s[r]=n));return s},require:function(r,i,n){var a;n=e.util.extend({msgIfNotFound:!0},n);var o=!1,s=function(e){o=!0,i(e)},l=function(e){t&&(a=t[r]),void 0!==a&&s(a),e&&e()},u=function(){o||c(d)},c=function(e){if("undefined"!=typeof module&&module.exports&&require)try{a=require(r)}catch(t){}void 0!==a&&s(a),e&&e()},d=function(){o||h(p)},h=function(e){"undefined"!=typeof define&&define.amd&&require&&require([r],function(t){a=t,void 0!==a&&s(a),e&&e()},function(t){e&&e()})},p=function(){!o&&n.msgIfNotFound&&e.util.error("Cytoscape.js tried to pull in dependency `"+r+"` but no module (i.e. CommonJS, AMD, or window) was found")};l(u)},requires:function(t,r){for(var i=[],n=[],a=function(){for(var e=0;e=i){a&&clearTimeout(a);var h=c;a=u=c=void 0,h&&(d=e.util.now(),o=t.apply(l,n),u||a||(n=l=null))}else u=setTimeout(f,i)},g=function(){u&&clearTimeout(u),a=u=c=void 0,(p||h!==r)&&(d=e.util.now(),o=t.apply(l,n),u||a||(n=l=null))};return function(){if(n=arguments,s=e.util.now(),l=this,c=p&&(u||!v),h===!1)var i=v&&!u;else{a||v||(d=s);var y=h-(s-d),m=0>=y;m?(a&&(a=clearTimeout(a)),d=s,o=t.apply(l,n)):a||(a=setTimeout(g,y))}return m&&u?u=clearTimeout(u):u||r===h||(u=setTimeout(f,r)),i&&(m=!0,o=t.apply(l,n)),!m||u||a||(n=l=null),o}}},error:function(e){if(!console)throw e;if(console.error)console.error.apply(console,arguments);else{if(!console.log)throw e;console.log.apply(console,arguments)}},clone:function(e){var t={};for(var r in e)t[r]=e[r];return t},copy:function(t){return null==t?t:e.is.array(t)?t.slice():e.is.plainObject(t)?e.util.clone(t):t},makeBoundingBox:function(e){if(null!=e.x1&&null!=e.y1){if(null!=e.x2&&null!=e.y2&&e.x2>=e.x1&&e.y2>=e.y1)return{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,w:e.x2-e.x1,h:e.y2-e.y1};if(null!=e.w&&null!=e.h&&e.w>=0&&e.h>=0)return{x1:e.x1,y1:e.y1,x2:e.x1+e.w,y2:e.y1+e.h,w:e.w,h:e.h}}},mapEmpty:function(e){var t=!0;if(null!=e)for(var r in e){t=!1;break}return t},pushMap:function(t){var r=e.util.getMap(t);null==r?e.util.setMap($.extend({},t,{value:[t.value]})):r.push(t.value)},setMap:function(t){for(var r,i=t.map,n=t.keys,a=n.length,o=0;a>o;o++){var r=n[o];e.is.plainObject(r)&&e.util.error("Tried to set map with object key"),oa;a++){var o=i[a];if(e.is.plainObject(o)&&e.util.error("Tried to get map with object key"),r=r[o],null==r)return r}return r},deleteMap:function(t){for(var r=t.map,i=t.keys,n=i.length,a=t.keepChildren,o=0;n>o;o++){var s=i[o];e.is.plainObject(s)&&e.util.error("Tried to delete map with object key");var l=o===t.keys.length-1;if(l)if(a)for(var u in r)a[u]||(r[u]=void 0);else r[s]=void 0;else r=r[s]}},capitalize:function(t){return e.is.emptyString(t)?t:t.charAt(0).toUpperCase()+t.substring(1)},trim:function(e){var t,r;for(t=0;tt&&" "===e[r];r--);return e.substring(t,r+1)},hex2tuple:function(e){if((4===e.length||7===e.length)&&"#"===e[0]){var t,r,i,n=4===e.length,a=16;return n?(t=parseInt(e[1]+e[1],a),r=parseInt(e[2]+e[2],a),i=parseInt(e[3]+e[3],a)):(t=parseInt(e[1]+e[2],a),r=parseInt(e[3]+e[4],a),i=parseInt(e[5]+e[6],a)),[t,r,i]}},hsl2tuple:function(t){function r(e,t,r){return 0>r&&(r+=1),r>1&&(r-=1),1/6>r?e+6*(t-e)*r:.5>r?t:2/3>r?e+(t-e)*(2/3-r)*6:e}var i,n,a,o,s,l,u,c,d=new RegExp("^"+e.util.regex.hsla+"$").exec(t);if(d){if(n=parseInt(d[1]),0>n?n=(360- -1*n%360)%360:n>360&&(n%=360),n/=360,a=parseFloat(d[2]),0>a||a>100)return;if(a/=100,o=parseFloat(d[3]),0>o||o>100)return;if(o/=100,s=d[4],void 0!==s&&(s=parseFloat(s),0>s||s>1))return;if(0===a)l=u=c=Math.round(255*o);else{var h=.5>o?o*(1+a):o+a-o*a,p=2*o-h;l=Math.round(255*r(p,h,n+1/3)),u=Math.round(255*r(p,h,n)),c=Math.round(255*r(p,h,n-1/3))}i=[l,u,c,s]}return i},rgb2tuple:function(t){var r,i=new RegExp("^"+e.util.regex.rgba+"$").exec(t);if(i){r=[];for(var n=[],a=1;3>=a;a++){var o=i[a];if("%"===o[o.length-1]&&(n[a]=!0),o=parseFloat(o),n[a]&&(o=o/100*255),0>o||o>255)return;r.push(Math.floor(o))}var s=n[1]||n[2]||n[3],l=n[1]&&n[2]&&n[3];if(s&&!l)return;var u=i[4];if(void 0!==u){if(u=parseFloat(u),0>u||u>1)return;r.push(u)}}return r},colorname2tuple:function(t){return e.util.colors[t.toLowerCase()]},color2tuple:function(t){return(e.is.array(t)?t:null)||e.util.colorname2tuple(t)||e.util.hex2tuple(t)||e.util.rgb2tuple(t)||e.util.hsl2tuple(t)},tuple2hex:function(e){function t(e){var t=e.toString(16);return 1===t.length&&(t="0"+t),t}var r=e[0],i=e[1],n=e[2];return"#"+t(r)+t(i)+t(n)},colors:{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]},memoize:function(e,t){var r=this,i={};return t||(t=function(){if(1===arguments.length)return arguments[0];for(var e=[],t=0;t0?1:0>e?-1:0},e.math.distance=function(e,t){var r=t.x-e.x,i=t.y-e.y;return Math.sqrt(r*r+i*i)},e.math.qbezierAt=function(e,t,r,i){return(1-i)*(1-i)*e+2*(1-i)*i*t+i*i*r},e.math.qbezierPtAt=function(t,r,i,n){return{x:e.math.qbezierAt(t.x,r.x,i.x,n),y:e.math.qbezierAt(t.y,r.y,i.y,n)}},e.math.boundingBoxesIntersect=function(e,t){return e.x1>t.x2?!1:t.x1>e.x2?!1:e.x2t.y2?!1:t.y1>e.y2?!1:!0},e.math.inBoundingBox=function(e,t,r){return e.x1<=t&&t<=e.x2&&e.y1<=r&&r<=e.y2},e.math.pointInBoundingBox=function(e,t){return this.inBoundingBox(e,t.x,t.y)},e.math.roundRectangleIntersectLine=function(e,t,r,i,n,a,o){var s,l=this.getRoundRectangleRadius(n,a),u=n/2,c=a/2,d=r-u+l-o,h=i-c-o,p=r+u-l+o,v=h;if(s=this.finiteLinesIntersect(e,t,r,i,d,h,p,v,!1),s.length>0)return s;var f=r+u+o,g=i-c+l-o,y=f,m=i+c-l+o;if(s=this.finiteLinesIntersect(e,t,r,i,f,g,y,m,!1),s.length>0)return s;var x=r-u+l-o,b=i+c+o,w=r+u-l+o,_=b;if(s=this.finiteLinesIntersect(e,t,r,i,x,b,w,_,!1),s.length>0)return s;var E=r-u-o,S=i-c+l-o,D=E,k=i+c-l+o;if(s=this.finiteLinesIntersect(e,t,r,i,E,S,D,k,!1),s.length>0)return s;var T,P=r-u+l,C=i-c+l;if(T=this.intersectLineCircle(e,t,r,i,P,C,l+o),T.length>0&&T[0]<=P&&T[1]<=C)return[T[0],T[1]];var B=r+u-l,M=i-c+l;if(T=this.intersectLineCircle(e,t,r,i,B,M,l+o),T.length>0&&T[0]>=B&&T[1]<=M)return[T[0],T[1]];var N=r+u-l,I=i+c-l;if(T=this.intersectLineCircle(e,t,r,i,N,I,l+o),T.length>0&&T[0]>=N&&T[1]>=I)return[T[0],T[1]];var O=r-u+l,z=i+c-l;return T=this.intersectLineCircle(e,t,r,i,O,z,l+o),T.length>0&&T[0]<=O&&T[1]>=z?[T[0],T[1]]:[]},e.math.roundRectangleIntersectBox=function(e,t,r,i,n,a,o,s,l){var u=this.getRoundRectangleRadius(n,a),c=o-n/2-l,d=s-a/2+u-l,h=o+n/2+l,p=s+a/2-u+l,v=o-n/2+u-l,f=s-a/2-l,g=o+n/2-u+l,y=s+a/2+l,m=Math.min(e,r),x=Math.max(e,r),b=Math.min(t,i),w=Math.max(t,i);return c>x?!1:m>h?!1:f>w?!1:b>y?!1:c>=m&&x>=c&&d>=b&&w>=d?!0:h>=m&&x>=h&&d>=b&&w>=d?!0:h>=m&&x>=h&&p>=b&&w>=p?!0:c>=m&&x>=c&&p>=b&&w>=p?!0:m>=c&&h>=m&&b>=d&&p>=b?!0:x>=c&&h>=x&&b>=d&&p>=b?!0:x>=c&&h>=x&&w>=d&&p>=w?!0:m>=c&&h>=m&&w>=d&&p>=w?!0:v>=m&&x>=v&&f>=b&&w>=f?!0:g>=m&&x>=g&&f>=b&&w>=f?!0:g>=m&&x>=g&&y>=b&&w>=y?!0:v>=m&&x>=v&&y>=b&&w>=y?!0:m>=v&&g>=m&&b>=f&&y>=b?!0:x>=v&&g>=x&&b>=f&&y>=b?!0:x>=v&&g>=x&&w>=f&&y>=w?!0:m>=v&&g>=m&&w>=f&&y>=w?!0:this.boxIntersectEllipse(m,b,x,w,l,2*u,2*u,v+l,d+l)?!0:this.boxIntersectEllipse(m,b,x,w,l,2*u,2*u,g-l,d+l)?!0:this.boxIntersectEllipse(m,b,x,w,l,2*u,2*u,g-l,p-l)?!0:this.boxIntersectEllipse(m,b,x,w,l,2*u,2*u,v+l,p-l)?!0:!1},e.math.checkInBoundingCircle=function(e,t,r,i,n,a,o,s){return e=(e-o)/(n+i),t=(t-s)/(a+i),r>=e*e+t*t},e.math.boxInBezierVicinity=function(e,t,r,i,n,a,o,s,l,u,c){var d=.25*n+.5*o+.25*l,h=.25*a+.5*s+.25*u,p=Math.min(e,r)-c,v=Math.min(t,i)-c,f=Math.max(e,r)+c,g=Math.max(t,i)+c;if(n>=p&&f>=n&&a>=v&&g>=a)return 1;if(l>=p&&f>=l&&u>=v&&g>=u)return 1;if(d>=p&&f>=d&&h>=v&&g>=h)return 1;if(o>=p&&f>=o&&s>=v&&g>=s)return 1;var y=Math.min(n,d,l),m=Math.min(a,h,u),x=Math.max(n,d,l),b=Math.max(a,h,u);return y>f||p>x||m>g||v>b?0:1},e.math.checkBezierInBox=function(t,r,i,n,a,o,s,l,u,c,d){function h(d){var h=e.math.qbezierAt(a,s,u,d),p=e.math.qbezierAt(o,l,c,d);return h>=t&&i>=h&&p>=r&&n>=p}for(var p=0;1>=p;p+=.25)if(!h(p))return!1;return!0},e.math.checkStraightEdgeInBox=function(e,t,r,i,n,a,o,s,l){return n>=e&&r>=n&&o>=e&&r>=o&&a>=t&&i>=a&&s>=t&&i>=s},e.math.checkStraightEdgeCrossesBox=function(e,t,r,i,n,a,o,s,l){var u,c,d=Math.min(e,r)-l,h=Math.min(t,i)-l,p=Math.max(e,r)+l,v=Math.max(t,i)+l,f=o-n,g=n,y=s-a,m=a;if(Math.abs(f)<1e-4)return n>=d&&p>=n&&Math.min(a,s)<=h&&Math.max(a,s)>=v;var x=(d-g)/f;if(x>0&&1>=x&&(u=y*x+m,u>=h&&v>=u))return!0;var b=(p-g)/f;if(b>0&&1>=b&&(u=y*b+m,u>=h&&v>=u))return!0;var w=(h-m)/y;if(w>0&&1>=w&&(c=f*w+g,c>=d&&p>=c))return!0;var _=(v-m)/y;return _>0&&1>=_&&(c=f*_+g,c>=d&&p>=c)?!0:!1},e.math.checkBezierCrossesBox=function(e,t,r,i,n,a,o,s,l,u,c){var d=Math.min(e,r)-c,h=Math.min(t,i)-c,p=Math.max(e,r)+c,v=Math.max(t,i)+c;if(n>=d&&p>=n&&a>=h&&v>=a)return!0;if(l>=d&&p>=l&&u>=h&&v>=u)return!0;var f=n-2*o+l,g=-2*n+2*o,y=n,m=[];if(Math.abs(f)<1e-4){var x=(d-n)/g,b=(p-n)/g;m.push(x,b)}else{var w,_,E=g*g-4*f*(y-d);if(E>0){var S=Math.sqrt(E);w=(-g+S)/(2*f),_=(-g-S)/(2*f),m.push(w,_)}var D,k,T=g*g-4*f*(y-p);if(T>0){var S=Math.sqrt(T);D=(-g+S)/(2*f),k=(-g-S)/(2*f),m.push(D,k)}}m.sort(function(e,t){return e-t});var P=a-2*s+u,C=-2*a+2*s,B=a,M=[];if(Math.abs(P)<1e-4){var N=(h-a)/C,I=(v-a)/C;M.push(N,I)}else{var O,z,L=C*C-4*P*(B-h);if(L>0){var S=Math.sqrt(L);O=(-C+S)/(2*P),z=(-C-S)/(2*P),M.push(O,z)}var R,V,A=C*C-4*P*(B-v);if(A>0){var S=Math.sqrt(A);R=(-C+S)/(2*P),V=(-C-S)/(2*P),M.push(R,V)}}M.sort(function(e,t){return e-t});for(var X=0;X=0&&m[X]<=1&&m[X+1]>M[F-1]&&M[F-1]<=1&&m[X+1]>=0)return!0;return!1},e.math.inLineVicinity=function(e,t,r,i,n,a,o){var s=o,l=Math.min(r,n),u=Math.max(r,n),c=Math.min(i,a),d=Math.max(i,a);return e>=l-s&&u+s>=e&&t>=c-s&&d+s>=t},e.math.inBezierVicinity=function(e,t,r,i,n,a,o,s,l){var u={x1:Math.min(r,o,n),x2:Math.max(r,o,n),y1:Math.min(i,s,a),y2:Math.max(i,s,a)};return eu.x2||tu.y2?!1:!0},e.math.solveCubic=function(e,t,r,i,n){t/=e,r/=e,i/=e;var a,o,s,l,u,c,d,h;return o=(3*r-t*t)/9,s=-(27*i)+t*(9*r-2*(t*t)),s/=54,a=o*o*o+s*s,n[1]=0,d=t/3,a>0?(u=s+Math.sqrt(a),u=0>u?-Math.pow(-u,1/3):Math.pow(u,1/3),c=s-Math.sqrt(a),c=0>c?-Math.pow(-c,1/3):Math.pow(c,1/3),n[0]=-d+u+c,d+=(u+c)/2,n[4]=n[2]=-d,d=Math.sqrt(3)*(-c+u)/2,n[3]=d,void(n[5]=-d)):(n[5]=n[3]=0,0===a?(h=0>s?-Math.pow(-s,1/3):Math.pow(s,1/3),n[0]=-d+2*h,void(n[4]=n[2]=-(h+d))):(o=-o,l=o*o*o,l=Math.acos(s/Math.sqrt(l)),h=2*Math.sqrt(o),n[0]=-d+h*Math.cos(l/3),n[2]=-d+h*Math.cos((l+2*Math.PI)/3),void(n[4]=-d+h*Math.cos((l+4*Math.PI)/3))))},e.math.sqDistanceToQuadraticBezier=function(e,t,r,i,n,a,o,s){var l=1*r*r-4*r*n+2*r*o+4*n*n-4*n*o+o*o+i*i-4*i*a+2*i*s+4*a*a-4*a*s+s*s,u=9*r*n-3*r*r-3*r*o-6*n*n+3*n*o+9*i*a-3*i*i-3*i*s-6*a*a+3*a*s,c=3*r*r-6*r*n+r*o-r*e+2*n*n+2*n*e-o*e+3*i*i-6*i*a+i*s-i*t+2*a*a+2*a*t-s*t,d=1*r*n-r*r+r*e-n*e+i*a-i*i+i*t-a*t,h=[];this.solveCubic(l,u,c,d,h);for(var p=1e-7,v=[],f=0;6>f;f+=2)Math.abs(h[f+1])=0&&h[f]<=1&&v.push(h[f]);v.push(1),v.push(0);for(var g,y,m,x,b=-1,w=0;w=0?b>x&&(b=x,g=v[w]):(b=x,g=v[w]);return b},e.math.sqDistanceToFiniteLine=function(e,t,r,i,n,a){var o=[e-r,t-i],s=[n-r,a-i],l=s[0]*s[0]+s[1]*s[1],u=o[0]*o[0]+o[1]*o[1],c=o[0]*s[0]+o[1]*s[1],d=c*c/l;return 0>c?u:d>l?(e-n)*(e-n)+(t-a)*(t-a):u-d},e.math.pointInsidePolygon=function(e,t,r,i,n,a,o,s,l){var u=new Array(r.length),c=Math.asin(s[1]/Math.sqrt(s[0]*s[0]+s[1]*s[1]));s[0]<0?c+=Math.PI/2:c=-c-Math.PI/2;for(var d=Math.cos(-c),h=Math.sin(-c),p=0;p0){var f=this.expandPolygon(u,-l);v=this.joinLines(f)}else v=u;for(var g,y,m,x,b,w=0,_=0,p=0;p=e&&e>=m||e>=g&&m>=e))continue;b=(e-g)/(m-g)*(x-y)+y,b>t&&w++,t>b&&_++}return w%2===0?!1:!0},e.math.joinLines=function(e){for(var t,r,i,n,a,o,s,l,u=new Array(e.length/2),c=0;cu)return[];var c=u/l;return[(r-e)*c+e,(i-t)*c+t]},e.math.dotProduct=function(e,t){if(2!=e.length||2!=t.length)throw"dot product: arguments are not vectors";return e[0]*t[0]+e[1]*t[1]},e.math.intersectLineCircle=function(e,t,r,i,n,a,o){var s=[r-e,i-t],l=[n,a],u=[e-n,t-a],c=s[0]*s[0]+s[1]*s[1],d=2*(u[0]*s[0]+u[1]*s[1]),l=u[0]*u[0]+u[1]*u[1]-o*o,h=d*d-4*c*l;if(0>h)return[];var p=(-d+Math.sqrt(h))/(2*c),v=(-d-Math.sqrt(h))/(2*c),f=Math.min(p,v),g=Math.max(p,v),y=[];if(f>=0&&1>=f&&y.push(f),g>=0&&1>=g&&y.push(g),0===y.length)return[];var m=y[0]*s[0]+e,x=y[0]*s[1]+t;if(y.length>1){if(y[0]==y[1])return[m,x];var b=y[1]*s[0]+e,w=y[1]*s[1]+t;return[m,x,b,w]}return[m,x]},e.math.findCircleNearPoint=function(e,t,r,i,n){var a=i-e,o=n-t,s=Math.sqrt(a*a+o*o),l=a/s,u=o/s;return[e+l*r,t+u*r]},e.math.findMaxSqDistanceToOrigin=function(e){for(var t,r=1e-6,i=0;ir&&(r=t);return r},e.math.finiteLinesIntersect=function(e,t,r,i,n,a,o,s,l){var u=(o-n)*(t-a)-(s-a)*(e-n),c=(r-e)*(t-a)-(i-t)*(e-n),d=(s-a)*(r-e)-(o-n)*(i-t);if(0!==d){var h=u/d,p=c/d;return h>=0&&1>=h&&p>=0&&1>=p?[e+h*(r-e),t+h*(i-t)]:l?[e+h*(r-e),t+h*(i-t)]:[]}return 0===u||0===c?[e,r,o].sort()[1]===o?[o,s]:[e,r,n].sort()[1]===n?[n,a]:[n,o,r].sort()[1]===r?[r,i]:[]:[]},e.math.boxIntersectEllipse=function(e,t,r,i,n,a,o,s,l){if(e>r){var u=e;e=r,r=u}if(t>i){var c=t;t=i,i=c}var d=[s-a/2-n,l],h=[s+a/2+n,l],p=[s,l-o/2-n],v=[s,l+o/2+n];return rh[0]?!1:t>v[1]?!1:i=e*e+t*t?!0:1>=r*r+t*t?!0:1>=r*r+i*i?!0:1>=e*e+i*i?!0:!1)},e.math.boxIntersectPolygon=function(t,r,i,n,a,o,s,l,u,c,d){if(t>i){var h=t;t=i,i=h}if(r>n){var p=r;r=n,n=p}var v=new Array(a.length),f=Math.asin(c[1]/Math.sqrt(c[0]*c[0]+c[1]*c[1]));c[0]<0?f+=Math.PI/2:f=-f-Math.PI/2;for(var g=Math.cos(-f),y=Math.sin(-f),m=0;mb&&(b=v[2*m]),v[2*m]_&&(_=v[2*m+1]),v[2*m+1]i)return!1;if(t>b+d)return!1;if(w-d>n)return!1;if(r>_+d)return!1;var E;if(d>0){var S=e.math.expandPolygon(v,-d);E=e.math.joinLines(S)}else E=v;for(var m=0;m0)return!0;if(e.math.finiteLinesIntersect(T,P,D,k,t,n,i,n,!1).length>0)return!0;if(e.math.finiteLinesIntersect(T,P,D,k,t,r,t,n,!1).length>0)return!0;if(e.math.finiteLinesIntersect(T,P,D,k,i,r,i,n,!1).length>0)return!0}return!1},e.math.polygonIntersectLine=function(t,r,i,n,a,o,s,l){for(var u,c=[],d=new Array(i.length),h=0;h0){var v=e.math.expandPolygon(d,-l);p=e.math.joinLines(v)}else p=d;for(var f,g,y,m,h=0;ha&&(a=1e-5),[t[0]+a*i[0],t[1]+a*i[1]]},e.math.generateUnitNgonPointsFitToSquare=function(t,r){var i=e.math.generateUnitNgonPoints(t,r);return i=e.math.fitPolygonToSquare(i)},e.math.fitPolygonToSquare=function(e){for(var t,r,i=e.length/2,n=1/0,a=1/0,o=-(1/0),s=-(1/0),l=0;i>l;l++)t=e[2*l],r=e[2*l+1],n=Math.min(n,t),o=Math.max(o,t),a=Math.min(a,r),s=Math.max(s,r);for(var u=2/(o-n),c=2/(s-a),l=0;i>l;l++)t=e[2*l]=e[2*l]*u,r=e[2*l+1]=e[2*l+1]*c,n=Math.min(n,t),o=Math.max(o,t),a=Math.min(a,r),s=Math.max(s,r);if(-1>a)for(var l=0;i>l;l++)r=e[2*l+1]=e[2*l+1]+(-1-a);return e},e.math.generateUnitNgonPoints=function(e,t){var r=1/e*2*Math.PI,i=e%2===0?Math.PI/2+r/2:Math.PI/2;i+=t;for(var n,a,o,s=new Array(2*e),l=0;e>l;l++)n=l*r+i,a=s[2*l]=Math.cos(n),o=s[2*l+1]=Math.sin(-n);return s},e.math.getRoundRectangleRadius=function(e,t){return Math.min(e/4,t/4,8)}}(cytoscape),function(e){"use strict";function t(t,r,i){var n={};switch(n[r]=i,t){case"core":case"collection":e.fn[t](n)}if("layout"===t){for(var o=i.prototype,s=[],l=0;ld;d++)n.canSet(s[d])&&(s[d]._private[n.field][r]=i);n.updateStyle&&a.updateStyle(),n.onSet(a),n.settingTriggersEvent&&a[n.triggerFnName](n.settingEvent)}}}else if(n.allowSetting&&e.is.plainObject(r)){var p,v,f=r;for(p in f){v=f[p];var c=!n.immutableKeys[p];if(c)for(var d=0,h=s.length;h>d;d++)n.canSet(s[d])&&(s[d]._private[n.field][p]=v)}n.updateStyle&&a.updateStyle(),n.onSet(a),n.settingTriggersEvent&&a[n.triggerFnName](n.settingEvent)}else if(n.allowBinding&&e.is.fn(r)){var g=r;a.bind(n.bindingEvent,g)}else if(n.allowGetting&&void 0===r){var u;return l&&(u=l._private[n.field]),u}return a}},removeData:function(t){var r={field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!1,immutableKeys:{}};return t=e.util.extend({},r,t),function(r){var i=t,n=this,a=void 0!==n.length,o=a?n:[n];if(e.is.string(r)){for(var s=r.split(/\s+/),l=s.length,u=0;l>u;u++){var c=s[u];if(!e.is.emptyString(c)){var d=!i.immutableKeys[c];if(d)for(var h=0,p=o.length;p>h;h++)o[h]._private[i.field][c]=void 0}}i.triggerEvent&&n[i.triggerFnName](i.event)}else if(void 0===r){for(var h=0,p=o.length;p>h;h++){var v=o[h]._private[i.field];for(var c in v){var f=!i.immutableKeys[c];f&&(v[c]=void 0)}}i.triggerEvent&&n[i.triggerFnName](i.event)}return n}},event:{regex:/(\w+)(\.\w+)?/,optionalTypeRegex:/(\w+)?(\.\w+)?/,falseCallback:function(){return!1}},on:function(t){var r={unbindSelfOnTrigger:!1,unbindAllBindersOnTrigger:!1};return t=e.util.extend({},r,t),function(r,i,n,a){var o=this,s=void 0!==o.length,l=s?o:[o],u=e.is.string(r),c=t;if(e.is.plainObject(i)?(a=n,n=i,i=void 0):(e.is.fn(i)||i===!1)&&(a=i,n=void 0,i=void 0),(e.is.fn(n)||n===!1)&&(a=n,n=void 0),!e.is.fn(a)&&a!==!1&&u)return o;if(u){var d={};d[r]=a,r=d}for(var h in r)if(a=r[h],a===!1&&(a=e.define.event.falseCallback),e.is.fn(a)){h=h.split(/\s+/);for(var p=0;p0:void 0}},clearQueue:function(t){var r={};return t=e.util.extend({},r,t),function(){var e=this,t=void 0!==e.length,r=t?e:[e],i=this._private.cy||this;if(!i.styleEnabled())return this;for(var n=0;n\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",boolOp:"\\?|\\!|\\^",string:'"(?:\\\\"|[^"])+"|'+"'(?:\\\\'|[^'])+'",number:e.util.regex.number,meta:"degree|indegree|outdegree",separator:"\\s*,\\s*",descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$"};s.variable="(?:[\\w-]|(?:\\\\"+s.metaChar+"))+",s.value=s.string+"|"+s.number,s.className=s.variable,s.id=s.variable;for(var l=function(e){return e.replace(new RegExp("\\\\("+s.metaChar+")","g"),function(e,t,r,i){return t})},u=s.comparatorOp.split("|"),c=0;c=0||"="!==d&&(s.comparatorOp+="|\\!"+d)}var h={group:{query:!0,regex:"(node|edge|\\*)",populate:function(e){this.group="*"==e?e:e+"s"}},state:{query:!0,regex:"(:selected|:unselected|:locked|:unlocked|:visible|:hidden|:transparent|:grabbed|:free|:removed|:inside|:grabbable|:ungrabbable|:animated|:unanimated|:selectable|:unselectable|:orphan|:nonorphan|:parent|:child|:loop|:simple|:active|:inactive|:touch|:backgrounding|:nonbackgrounding)",populate:function(e){this.colonSelectors.push(e)}},id:{query:!0,regex:"\\#("+s.id+")",populate:function(e){this.ids.push(l(e))}},className:{query:!0,regex:"\\.("+s.className+")",populate:function(e){this.classes.push(l(e))}},dataExists:{query:!0,regex:"\\[\\s*("+s.variable+")\\s*\\]",populate:function(e){this.data.push({field:l(e)})}},dataCompare:{query:!0,regex:"\\[\\s*("+s.variable+")\\s*("+s.comparatorOp+")\\s*("+s.value+")\\s*\\]",populate:function(e,t,r){var i=null!=new RegExp("^"+s.string+"$").exec(r);r=i?r.substring(1,r.length-1):parseFloat(r),this.data.push({field:l(e),operator:t,value:r})}},dataBool:{query:!0,regex:"\\[\\s*("+s.boolOp+")\\s*("+s.variable+")\\s*\\]",populate:function(e,t){this.data.push({field:l(t),operator:e})}},metaCompare:{query:!0,regex:"\\[\\[\\s*("+s.meta+")\\s*("+s.comparatorOp+")\\s*("+s.number+")\\s*\\]\\]",populate:function(e,t,r){this.meta.push({field:l(e),operator:t,value:parseFloat(r)})}},nextQuery:{separator:!0,regex:s.separator,populate:function(){i[++c]=o(),a=null}},child:{separator:!0,regex:s.child,populate:function(){var e=o();e.parent=this,e.subject=a,i[c]=e}},descendant:{separator:!0,regex:s.descendant,populate:function(){var e=o();e.ancestor=this,e.subject=a,i[c]=e}},subject:{modifier:!0,regex:s.subject,populate:function(){return null!=a&&this.subject!=this?(e.util.error("Redefinition of subject in selector `"+r+"`"),!1):(a=this,void(this.subject=this))}}},p=0;for(var v in h)h[p]=h[v],h[p].name=v,p++;h.length=p,i._private.selectorText=r;var f=r,c=0,g=function(t){for(var r,i,n,a=0;a=0&&(d=d.toLowerCase(),h=h.toLowerCase(),s=s.replace("@",""),p=!0);var v=!1,f=!1;switch(s.indexOf("!")>=0&&(s=s.replace("!",""),v=!0),p&&(l=h.toLowerCase(),c=d.toLowerCase()),s){case"*=":a=d.search(h)>=0;break;case"$=":a=null!=new RegExp(h+"$").exec(d);break;case"^=":a=null!=new RegExp("^"+h).exec(d);break;case"=":a=c===l;break;case"!=":a=c!==l;break;case">":a=v?l>=c:c>l,f=!0;break;case">=":a=v?l>c:c>=l,f=!0;break;case"<":a=v?c>=l:l>c,f=!0;break;case"<=":a=v?c>l:l>=c,f=!0;break;default:a=!1}}else if(null!=s)switch(s){case"?":a=t.fieldTruthy(u);break;case"!":a=!t.fieldTruthy(u);break;case"^":a=t.fieldUndefined(u)}else a=!t.fieldUndefined(u);if(v&&!f&&(a=!a,f=!0),!a){i=!1;break}}return i},v=p({name:"data",fieldValue:function(e){return i._private.data[e]},fieldRef:function(e){return"element._private.data."+e},fieldUndefined:function(e){return void 0===i._private.data[e]},fieldTruthy:function(e){return i._private.data[e]?!0:!1}});if(!v)return!1;var f=p({name:"meta",fieldValue:function(e){return i[e]()},fieldRef:function(e){return"element."+e+"()"},fieldUndefined:function(e){return null==i[e]()},fieldTruthy:function(e){return i[e]()?!0:!1}});if(!f)return!1;if(null!=r.collection){var g=null!=r.collection._private.ids[i.id()];if(!g)return!1}if(null!=r.filter&&0===i.collection().filter(r.filter).size())return!1;var y=function(e,r){if(null!=e){var i=!1;if(!n.hasCompoundNodes())return!1;r=r();for(var a=0;a "+t),null!=e.ancestor&&(t=i(e.ancestor)+" "+t),null!=e.child&&(t+=" > "+i(e.child)),null!=e.descendant&&(t+=" "+i(e.descendant)),t},n=0;n1&&n node").css({width:"auto",height:"auto",shape:"rectangle","background-opacity":.5,"padding-top":10,"padding-right":10,"padding-left":10,"padding-bottom":10}).selector("edge").css({width:1}).selector(":active").css({"overlay-color":"black","overlay-padding":10,"overlay-opacity":.25}).selector("core").css({"selection-box-color":"#ddd","selection-box-opacity":.65,"selection-box-border-color":"#aaa","selection-box-border-width":1,"active-bg-color":"black","active-bg-opacity":.15,"active-bg-size":30,"outside-texture-bg-color":"#000","outside-texture-bg-opacity":.125}),this.defaultLength=this.length},e.styfn.clear=function(){for(var e=0;eu.max)return null;var C={name:t,value:r,strValue:""+r+(E?E:""),units:E,bypass:i,hasPie:c&&null!=r&&0!==r&&""!==r};return u.unitless||"px"!==E&&"em"!==E||(C.pxValue="px"!==E&&E?this.getEmSizeInPixels()*r:r),("ms"===E||"s"===E)&&(C.msValue="ms"===E?r:1e3*r),C}if(u.propList){var B=[],M=""+r;if("none"===M);else{for(var N=M.split(","),T=0;T0;if(h||p){var v;h&&p?v=u.properties:h?v=u.properties:p&&(v=u.mappedProperties);for(var f=0;f0){a=!0;break}}r.hasPie=a;var l=n["text-transform"].strValue,u=n.content.strValue,c=n["font-style"].strValue,s=n["font-size"].pxValue+"px",d=n["font-family"].strValue,h=n["font-weight"].strValue,p=n["text-valign"].strValue,v=n["text-valign"].strValue,f=n["text-outline-width"].pxValue,g=n["text-wrap"].strValue,y=n["text-max-width"].pxValue;r.labelKey=c+"$"+s+"$"+d+"$"+h+"$"+u+"$"+l+"$"+p+"$"+v+"$"+f+"$"+g+"$"+y,r.fontKey=c+"$"+h+"$"+s+"$"+d;var m=n.width.pxValue,x=n.height.pxValue,b=n["border-width"].pxValue;if(r.boundingBoxKey=m+"$"+x+"$"+b,"edges"===t._private.group){var w=n["control-point-step-size"].pxValue,_=n["control-point-distance"]?n["control-point-distance"].pxValue:void 0,E=n["control-point-weight"].value,S=n["curve-style"].strValue;r.boundingBoxKey+="$"+w+"$"+_+"$"+E+"$"+S}r.styleKey=Date.now()},e.styfn.applyParsedProperty=function(t,r){var i,n,a=r,o=t._private.style,s=e.style.types,l=e.style.properties[a.name].type,u=a.bypass,c=o[a.name],d=c&&c.bypass,h=t._private;if(("height"===r.name||"width"===r.name)&&t.isNode()){if("auto"===r.value&&!t.isParent())return!1;"auto"!==r.value&&t.isParent()&&(a=r=this.parse(r.name,"auto",u))}if(u&&a.deleteBypass){var p=o[a.name];return p?p.bypass&&p.bypassed?(o[a.name]=p.bypassed,!0):!1:!0}var v=function(){e.util.error("Do not assign mappings to elements without corresponding data (e.g. ele `"+t.id()+"` for property `"+a.name+"` with data field `"+a.field+"`); try a `["+a.field+"]` selector to limit scope to elements with `"+a.field+"` defined")};switch(a.mapped){case s.mapData:case s.mapLayoutData:case s.mapScratch:var i,f=a.mapped===s.mapLayoutData,g=a.mapped===s.mapScratch,y=a.field.split(".");i=g||f?h.scratch:h.data;for(var m=0;mb?b=0:b>1&&(b=1),l.color){var w=a.valueMin[0],_=a.valueMax[0],E=a.valueMin[1],S=a.valueMax[1],D=a.valueMin[2],k=a.valueMax[2],T=null==a.valueMin[3]?1:a.valueMin[3],P=null==a.valueMax[3]?1:a.valueMax[3],C=[Math.round(w+(_-w)*b),Math.round(E+(S-E)*b),Math.round(D+(k-D)*b),Math.round(T+(P-T)*b)]; n={bypass:a.bypass,name:a.name,value:C,strValue:"rgb("+C[0]+", "+C[1]+", "+C[2]+")"}}else{if(!l.number)return!1;var B=a.valueMin+(a.valueMax-a.valueMin)*b;n=this.parse(a.name,B,a.bypass,!0)}n||(n=this.parse(a.name,c.strValue,a.bypass,!0)),n||v(),n.mapping=a,a=n;break;case s.data:case s.layoutData:case s.scratch:var i,f=a.mapped===s.layoutData,g=a.mapped===s.scratch,y=a.field.split(".");if(i=g||f?h.scratch:h.data)for(var m=0;m0&&s>0){for(var c=!1,d=0;d0&&t.delay(l),t.animate({css:u},{duration:s,queue:!1,complete:function(){i||n.removeBypasses(t,o),t._private.transitioning=!1}})}else t._private.transitioning&&(t.stop(),this.removeBypasses(t,o),t._private.transitioning=!1)}}(cytoscape),function(e){"use strict";e.styfn.applyBypass=function(t,r,i,n){var a=[],o=!0;if("*"===r||"**"===r){if(void 0!==i)for(var s=0;sa.length?l.substr(a.length):""}function n(){o=o.length>s.length?o.substr(s.length):""}var a,o,s,l=""+r;for(l=l.replace(/[\/][*](\s|.)+?[*][\/]/g,"");;){var u=l.match(/^\s*$/);if(u)break;var c=l.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!c){e.util.error("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: "+l);break}a=c[0];var d=c[1];if("core"!==d){var h=new e.Selector(d);if(h._private.invalid){e.util.error("Skipping parsing of block: Invalid selector found in string stylesheet: "+d),i();continue}}var p=c[2],v=!1;o=p;for(var f=[];;){var u=o.match(/^\s*$/);if(u)break;var g=o.match(/^\s*(.+?)\s*:\s*(.+?)\s*;/);if(!g){e.util.error("Skipping parsing of block: Invalid formatting of style property and value definitions found in:"+p),v=!0;break}s=g[0];var y=g[1],m=g[2],x=e.style.properties[y];if(x){var b=t.parse(y,m);b?(f.push({name:y,val:m}),n()):(e.util.error("Skipping property: Invalid property definition in: "+s),n())}else e.util.error("Skipping property: Invalid property name in: "+s),n()}if(v){i();break}t.selector(d);for(var w=0;w1?", "+JSON.stringify(r):"")+" );"," "," resolve = origResolve;"," resolve( res.length > 0 ? res : ret );","}"].join("\n"))}};e.fn.thread({reduce:o({name:"reduce"}),reduceRight:o({name:"reduceRight"}),map:o({name:"map"})});var s=e.thdfn;s.promise=s.run,s.terminate=s.halt=s.stop,s.include=s.require,e.worker=e.Worker=e.Thread,e.fn.thread({on:e.define.on(),one:e.define.on({unbindSelfOnTrigger:!0}),off:e.define.off(),trigger:e.define.trigger()}),e.define.eventAliasesOn(e.thdfn)}(cytoscape,"undefined"==typeof window?null:window),function(e,t){"use strict";e.Fabric=function(t){if(!(this instanceof e.Fabric))return new e.Fabric(t);this._private={pass:[]};var r=4;e.is.number(t),t="undefined"!=typeof navigator&&null!=navigator.hardwareConcurrency?navigator.hardwareConcurrency:"undefined"!=typeof module?require("os").cpus().length:r;for(var i=0;t>i;i++)this[i]=e.Thread();this.length=t},e.fabric=e.Fabric,e.fabfn=e.Fabric.prototype,e.fn.fabric=function(t,r){for(var i in t){var n=t[i];e.Fabric.prototype[i]=n}},e.fn.fabric({require:function(e,t){for(var r=0;re?-1:e>t?1:0},t.require(e,"_$_$_cmp"),t.spread(function(e){var t=e.sort(_$_$_cmp);resolve(t)}).then(function(t){for(var n=function(i,n,a){n=Math.min(n,r),a=Math.min(a,r);for(var o=i,s=n,l=[],u=o;a>u;u++){var c=t[i],d=t[n];s>i&&(n>=a||e(c,d)<=0)?(l.push(c),i++):(l.push(d),n++)}for(var u=0;ua;a*=2)for(var o=0;r>o;o+=2*a)n(o,o+a,o+2*a);return t})}});var r=function(e){return e=e||{},function(t,r){var i=this._private.pass.shift();return this.random().pass(i)[e.threadFn](t,r)}};e.fn.fabric({randomMap:r({threadFn:"map"}),reduce:r({threadFn:"reduce"}),reduceRight:r({threadFn:"reduceRight"})});var i=e.fabfn;i.promise=i.run,i.terminate=i.halt=i.stop,i.include=i.require,e.fn.fabric({on:e.define.on(),one:e.define.on({unbindSelfOnTrigger:!0}),off:e.define.off(),trigger:e.define.trigger()}),e.define.eventAliasesOn(e.fabfn)}(cytoscape,"undefined"==typeof window?null:window),function(e,t){"use strict";var r={},i=e.util.copy(r);e.defaults=function(t){r=e.util.extend({},i,t)},e.fn.core=function(t,r){for(var i in t){var n=t[i];e.Core.prototype[i]=n}},e.Core=function(i){if(!(this instanceof e.Core))return new e.Core(i);var n=this;i=e.util.extend({},r,i);var a=i.container,o=a?a._cyreg:null;if(o=o||{},o&&o.cy){if(a)for(;a.firstChild;)a.removeChild(a.firstChild);o.cy.notify({type:"destroy"}),o={}}var s=o.readies=o.readies||[];a&&(a._cyreg=o),o.cy=n;var l=void 0!==t&&void 0!==a&&!i.headless,u=i;u.layout=e.util.extend({name:l?"grid":"null"},u.layout),u.renderer=e.util.extend({name:l?"canvas":"null"},u.renderer);var c=function(e,t,r){return void 0!==t?t:void 0!==r?r:e},d=this._private={container:u.container,ready:!1,initrender:!1,options:u,elements:[],id2index:{},listeners:[],onRenders:[],aniEles:e.Collection(this),scratch:{},layout:null,renderer:null,notificationsEnabled:!0,minZoom:1e-50,maxZoom:1e50,zoomingEnabled:c(!0,u.zoomingEnabled),userZoomingEnabled:c(!0,u.userZoomingEnabled),panningEnabled:c(!0,u.panningEnabled),userPanningEnabled:c(!0,u.userPanningEnabled),boxSelectionEnabled:c(!1,u.boxSelectionEnabled),autolock:c(!1,u.autolock,u.autolockNodes),autoungrabify:c(!1,u.autoungrabify,u.autoungrabifyNodes),autounselectify:c(!1,u.autounselectify),styleEnabled:void 0===u.styleEnabled?l:u.styleEnabled,zoom:e.is.number(u.zoom)?u.zoom:1,pan:{x:e.is.plainObject(u.pan)&&e.is.number(u.pan.x)?u.pan.x:0,y:e.is.plainObject(u.pan)&&e.is.number(u.pan.y)?u.pan.y:0},animation:{current:[],queue:[]},hasCompoundNodes:!1,deferredExecQueue:[]},h=u.selectionType;void 0===h||"additive"!==h&&"single"!==h?d.selectionType="single":d.selectionType=h,e.is.number(u.minZoom)&&e.is.number(u.maxZoom)&&u.minZoom0?u.wheelSensitivity:1,motionBlur:void 0===u.motionBlur?!0:u.motionBlur,motionBlurOpacity:void 0===u.motionBlurOpacity?.05:u.motionBlurOpacity,pixelRatio:e.is.number(u.pixelRatio)&&u.pixelRatio>0?u.pixelRatio:"auto"===u.pixelRatio?void 0:1,desktopTapThreshold:void 0===u.desktopTapThreshold?4:u.desktopTapThreshold,touchTapThreshold:void 0===u.touchTapThreshold?8:u.touchTapThreshold},u.renderer)),u.initrender&&(n.on("initrender",u.initrender),n.on("initrender",function(){n._private.initrender=!0})),n.load(i,function(){n.startAnimationLoop(),n._private.ready=!0,e.is.fn(u.ready)&&n.on("ready",u.ready);for(var t=0;t0;)i.shift()();r.deferredTimeout=null},0))}})}(cytoscape,"undefined"==typeof window?null:window),function(e,t){"use strict";function r(e){var t=!document||"interactive"!==document.readyState&&"complete"!==document.readyState?r:e;setTimeout(t,9,e)}e.fn.core({add:function(t){var r,i=this;if(e.is.elementOrCollection(t)){var n=t;if(n._private.cy===i)r=n.restore();else{for(var a=[],o=0;oo;o++){var d=u[o],h=l[d];if(e.is.array(h))for(var p=0,v=h.length;v>p;p++){var f=h[p];f.group=d,a.push(f)}}r=new e.Collection(i,a)}else{var f=t;r=new e.Element(i,f).collection()}return r},remove:function(t){if(e.is.elementOrCollection(t))t=t;else if(e.is.string(t)){var r=t;t=this.$(r)}return t.remove()},load:function(i,n,a){function o(){s.one("layoutready",function(e){s.notifications(!0),s.trigger(e),s.notify({type:"load",collection:s.elements()}),s.one("load",n),s.trigger("load")}).one("layoutstop",function(){s.one("done",a),s.trigger("done")});var t=e.util.extend({},s._private.options.layout);t.eles=s.$(),s.layout(t)}var s=this;s.notifications(!1);var l=s.elements();return l.length>0&&l.remove(),null!=i&&(e.is.plainObject(i)||e.is.array(i))&&s.add(i),t?r(o):o(),this}})}(cytoscape,"undefined"==typeof window?null:window),function(e,t){"use strict";e.fn.core({animated:e.define.animated(),clearQueue:e.define.clearQueue(),delay:e.define.delay(),animate:e.define.animate(),stop:e.define.stop(),addToAnimationPool:function(e){var t=this;t.styleEnabled()&&t._private.aniEles.merge(e)},startAnimationLoop:function(){function r(){e.util.requestAnimationFrame(function(e){i(e),r()})}function i(t){function r(r,i){var l=r._private.animation.current,u=r._private.animation.queue,c=!1;if(0===l.length){var d=u.length>0?u.shift():null;d&&(d.callTime=t,l.push(d))}for(var h=[],p=l.length-1;p>=0;p--){var v=l[p];v.started||(n(r,v),s=!0),a(r,v,t,i),v.done&&(h.push(v),l.splice(p,1)),c=!0}for(var p=0;p0||d){var h;if(i.length>0){var p=i.updateCompoundBounds();h=p.length>0?i.add(p):i}l.notify({type:s?"style":"draw",collection:h})}i.unmerge(o)}function n(t,r){var i=e.is.core(t),n=!i,a=t,o=l._private.style;if(n)var s=a._private.position,u={x:s.x,y:s.y},c=o.getValueStyle(a);if(i)var d=l._private.pan,h={x:d.x,y:d.y},p=l._private.zoom;r.started=!0,r.startTime=Date.now(),r.startPosition=u,r.startStyle=c,r.startPan=h,r.startZoom=p}function a(t,r,i,n){var a,u=l._private.style,c=r.properties,d=r.params,h=r.startTime,p=!n;if(a=0===r.duration?1:Math.min(1,(i-h)/r.duration),0>a?a=0:a>1&&(a=1),null==c.delay){var v=r.startPosition,f=c.position,g=t._private.position;f&&p&&(o(v.x,f.x)&&(g.x=s(v.x,f.x,a)),o(v.y,f.y)&&(g.y=s(v.y,f.y,a)));var y=r.startPan,m=c.pan,x=t._private.pan,b=null!=m&&n;b&&(o(y.x,m.x)&&(x.x=s(y.x,m.x,a)),o(y.y,m.y)&&(x.y=s(y.y,m.y,a)),t.trigger("pan"));var w=r.startZoom,_=c.zoom,E=null!=_&&n;E&&(o(w,_)&&(t._private.zoom=s(w,_,a)),t.trigger("zoom")),(b||E)&&t.trigger("viewport");var S=c.style||c.css;if(S&&p)for(var D=0;D=1&&(r.done=!0),a}function o(t,r){return null==t||null==r?!1:e.is.number(t)&&e.is.number(r)?!0:t&&r?!0:!1}function s(t,r,i){0>i?i=0:i>1&&(i=1);var n,a;if(n=null!=t.pxValue||null!=t.value?null!=t.pxValue?t.pxValue:t.value:t,a=null!=r.pxValue||null!=r.value?null!=r.pxValue?r.pxValue:r.value:r,e.is.number(n)&&e.is.number(a))return n+(a-n)*i;if(e.is.number(n[0])&&e.is.number(a[0])){var o=n,s=a,l=function(e,t){var r=t-e,n=e;return Math.round(i*r+n)},u=l(o[0],s[0]),c=l(o[1],s[1]),d=l(o[2],s[2]);return[u,c,d]}return void 0}var l=this;l.styleEnabled()&&t&&r()}})}(cytoscape,"undefined"==typeof window?null:window),function(e){"use strict";e.fn.core({data:e.define.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0}),removeData:e.define.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0}),scratch:e.define.data({field:"scratch",allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeScratch:e.define.removeData({field:"scratch",triggerEvent:!1})})}(cytoscape),function(e){"use strict";e.fn.core({on:e.define.on(),one:e.define.on({unbindSelfOnTrigger:!0}),once:e.define.on({unbindAllBindersOnTrigger:!0}),off:e.define.off(),trigger:e.define.trigger()}),e.define.eventAliasesOn(e.corefn)}(cytoscape),function(e){"use strict";e.fn.core({png:function(e){var t=this._private.renderer;return e=e||{},t.png(e)},jpg:function(e){var t=this._private.renderer;return e=e||{},e.bg=e.bg||"#fff",t.jpg(e)}}),e.corefn.jpeg=e.corefn.jpg}(cytoscape),function(e){"use strict";e.fn.core({layout:function(t){var r;return null==t&&(t=e.util.extend({},this._private.options.layout),t.eles=this.$()),r=this.initLayout(t),r.run(),this},makeLayout:function(e){return this.initLayout(e)},initLayout:function(t){if(null==t)return void e.util.error("Layout options must be specified to make a layout");if(null==t.name)return void e.util.error("A `name` must be specified to make a layout");var r=t.name,i=e.extension("layout",r);if(null==i)return void e.util.error("Can not apply layout: No such layout `"+r+"` found; did you include its JS file?");t.eles=null!=t.eles?t.eles:this.$(),e.is.string(t.eles)&&(t.eles=this.$(t.eles));var n=new i(e.util.extend({},t,{cy:this}));return e.is.plainObject(n._private)||(n._private={}),n._private.cy=this,n._private.listeners=[],n}}),e.corefn.createLayout=e.corefn.makeLayout}(cytoscape),function(e){"use strict";e.fn.core({notify:function(e){if(this._private.batchingNotify){var t=this._private.batchNotifyEles,r=this._private.batchNotifyTypes;if(e.collection)for(var i=0;i0&&l>0&&!isNaN(i.w)&&!isNaN(i.h)&&i.w>0&&i.h>0){o=Math.min((s-2*r)/i.w,(l-2*r)/i.h),o=o>this._private.maxZoom?this._private.maxZoom:o,o=othis._private.maxZoom?this._private.maxZoom:i,i=ir.maxZoom||!r.zoomingEnabled?o=!0:(r.zoom=l,a.push("zoom"))}if(n&&(!o||!t.cancelOnFailedZoom)&&r.panningEnabled){var u=t.pan;e.is.number(u.x)&&(r.pan.x=u.x,s=!1),e.is.number(u.y)&&(r.pan.y=u.y,s=!1),s||a.push("pan")}return a.length>0&&(a.push("viewport"),this.trigger(a.join(" ")),this.notify({type:"viewport"})),this},center:function(e){var t=this.getCenterPan(e);return t&&(this._private.pan=t,this.trigger("pan viewport"),this.notify({type:"viewport"})),this},getCenterPan:function(t,r){if(this._private.panningEnabled){if(e.is.string(t)){var i=t;t=this.elements(i)}else e.is.elementOrCollection(t)||(t=this.elements());var n=t.boundingBox(),a=this.width(),o=this.height();r=void 0===r?this._private.zoom:r;var s={x:(a-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.viewport({pan:{x:0,y:0},zoom:1}),this):this},width:function(){var e=this._private.container;return e?e.clientWidth:1},height:function(){var e=this._private.container;return e?e.clientHeight:1},extent:function(){var e=this._private.pan,t=this._private.zoom,r=this.renderedExtent(),i={x1:(r.x1-e.x)/t,x2:(r.x2-e.x)/t,y1:(r.y1-e.y)/t,y2:(r.y2-e.y)/t};return i.w=i.x2-i.x1,i.h=i.y2-i.y1,i},renderedExtent:function(){var e=this.width(),t=this.height();return{x1:0,y1:0,x2:e,y2:t,w:e,h:t}}}),e.corefn.centre=e.corefn.center,e.corefn.autolockNodes=e.corefn.autolock,e.corefn.autoungrabifyNodes=e.corefn.autoungrabify}(cytoscape),function(e){"use strict";e.fn.collection=e.fn.eles=function(t,r){for(var i in t){var n=t[i];e.Collection.prototype[i]=n}};var t={prefix:{nodes:"n",edges:"e"},id:{nodes:0,edges:0},generate:function(t,r,i){var n=e.is.element(r)?r._private:r,a=n.group,o=null!=i?i:this.prefix[a]+this.id[a];if(t.getElementById(o).empty())this.id[a]++;else for(;!t.getElementById(o).empty();)o=this.prefix[a]+ ++this.id[a];return o}};e.Element=function(t,r,i){if(!(this instanceof e.Element))return new e.Element(t,r,i);var n=this;if(i=void 0===i||i?!0:!1,void 0===t||void 0===r||!e.is.core(t))return void e.util.error("An element must have a core reference and parameters set");if("nodes"!==r.group&&"edges"!==r.group)return void e.util.error("An element must be of type `nodes` or `edges`; you specified `"+r.group+"`");if(this.length=1,this[0]=this,this._private={cy:t,single:!0,data:r.data||{},position:r.position||{},autoWidth:void 0,autoHeight:void 0,listeners:[],group:r.group,style:{},rstyle:{},styleCxts:[],removed:!0,selected:r.selected?!0:!1,selectable:void 0===r.selectable?!0:r.selectable?!0:!1,locked:r.locked?!0:!1,grabbed:!1,grabbable:void 0===r.grabbable?!0:r.grabbable?!0:!1,active:!1,classes:{},animation:{current:[],queue:[]},rscratch:{},scratch:r.scratch||{},edges:[],children:[]},r.renderedPosition){var a=r.renderedPosition,o=t.pan(),s=t.zoom();this._private.position={x:(a.x-o.x)/s,y:(a.y-o.y)/s}}if(e.is.string(r.classes))for(var l=r.classes.split(/\s+/),u=0,c=l.length;c>u;u++){var d=l[u];d&&""!==d&&(n._private.classes[d]=!0)}r.css&&t.style().applyBypass(this,r.css),(void 0===i||i)&&this.restore()},e.Collection=function(r,i,n){if(!(this instanceof e.Collection))return new e.Collection(r,i);if(void 0===r||!e.is.core(r))return void e.util.error("A collection must have a reference to the core");var a={},o={},s=!1;if(i){if(i.length>0&&e.is.plainObject(i[0])&&!e.is.element(i[0])){s=!0;for(var l=[],u={},c=0,d=i.length;d>c;c++){var h=i[c];null==h.data&&(h.data={});var p=h.data;if(null==p.id)p.id=t.generate(r,h);else if(0!==r.getElementById(p.id).length||u[p.id])continue;var v=new e.Element(r,h,!1);l.push(v),u[p.id]=!0}i=l}}else i=[];this.length=0;for(var c=0,d=i.length;d>c;c++){var f=i[c];if(f){var g=f._private.data.id;(!n||n.unique&&!a[g])&&(a[g]=f,o[g]=this.length,this[this.length]=f,this.length++)}}this._private={cy:r,ids:a,indexes:o},s&&this.restore()},e.elefn=e.elesfn=e.Element.prototype=e.Collection.prototype,e.elesfn.cy=function(){return this._private.cy},e.elesfn.element=function(){return this[0]},e.elesfn.collection=function(){return e.is.collection(this)?this:new e.Collection(this._private.cy,[this])},e.elesfn.unique=function(){return new e.Collection(this._private.cy,this,{unique:!0})},e.elesfn.getElementById=function(t){var r=this._private.cy,i=this._private.ids[t];return i?i:e.Collection(r)},e.elesfn.json=function(){var t=this.element();if(null==t)return void 0;var r=t._private,i=e.util.copy({data:r.data,position:r.position,group:r.group,bypass:r.bypass,removed:r.removed,selected:r.selected,selectable:r.selectable,locked:r.locked,grabbed:r.grabbed,grabbable:r.grabbable,classes:""}),n=[];for(var a in r.classes)r.classes[a]&&n.push(a);for(var o=0;od;d++){var p=i[d];p.isNode()?(s.push(p),u++):(l.push(p),c++)}o=s.concat(l);for(var d=0,h=o.length;h>d;d++){var p=o[d];if(p.removed()){var v=p._private,f=v.data;if(void 0===f.id)f.id=t.generate(a,p);else if(e.is.number(f.id))f.id=""+f.id;else{if(e.is.emptyString(f.id)||!e.is.string(f.id)){e.util.error("Can not create element with invalid string ID `"+f.id+"`");continue}if(0!==a.getElementById(f.id).length){e.util.error("Can not create second element with ID `"+f.id+"`");continue}}var g=f.id;if(p.isNode()){var y=p,m=v.position;null==m.x&&(m.x=0),null==m.y&&(m.y=0)}if(p.isEdge()){for(var x=p,b=["source","target"],w=b.length,_=!1,E=0;w>E;E++){var S=b[E],D=f[S];e.is.number(D)&&(D=f[S]=""+f[S]),null==D||""===D?(e.util.error("Can not create edge `"+g+"` with unspecified "+S),_=!0):a.getElementById(D).empty()&&(e.util.error("Can not create edge `"+g+"` with nonexistant "+S+" `"+D+"`"),_=!0)}if(_)continue;var k=a.getElementById(f.source),T=a.getElementById(f.target);k._private.edges.push(x),T._private.edges.push(x),x._private.source=k,x._private.target=T}v.ids={},v.ids[g]=p,v.removed=!1,a.addToPool(p),n.push(p)}}for(var d=0;u>d;d++){var y=o[d],f=y._private.data;e.is.number(f.parent)&&(f.parent=""+f.parent);var P=f.parent,C=null!=P;if(C){var B=a.getElementById(P);if(B.empty())f.parent=void 0;else{for(var M=!1,N=B;!N.empty();){if(y.same(N)){M=!0,f.parent=void 0;break}N=N.parent()}M||(B[0]._private.children.push(y),y._private.parent=B[0],a._private.hasCompoundNodes=!0)}}}if(n=new e.Collection(a,n),n.length>0){var I=n.add(n.connectedNodes()).add(n.parent());I.updateStyle(r),r?n.rtrigger("add"):n.trigger("add")}return i},e.elesfn.removed=function(){var e=this[0];return e&&e._private.removed},e.elesfn.inside=function(){var e=this[0];return e&&!e._private.removed},e.elesfn.remove=function(t){function r(e){for(var t=e._private.edges,r=0;rh;h++){var v=s[h];n(v)}for(var h=0;h0&&(t&&this.cy().notify({type:"remove",collection:x}),x.trigger("remove"));for(var b={},h=0;h0,a=t.getElementById(i).length>0;if(n||a){var o=this.jsons();this.remove();for(var s=0;s0;if(c){var o=this.jsons(),d=this.descendants(),h=d.merge(d.add(this).connectedEdges());this.remove();for(var s=0;su||!n)&&(o=u,n=l)}return{edge:n,dist:o}};f.size()>0;){var y=f.pop(),m=y.value,x=y.id,b=a.getElementById(x);if(u[x]=m,m===Math.Infinite)break;for(var w=b.neighborhood().intersect(d),p=0;p0)for(i.unshift(r);l[n.id()];){var o=l[n.id()];i.unshift(o.edge),i.unshift(o.node),n=o.node}return new e.Collection(a,i)}}}}),e.elesfn.bfs=e.elesfn.breadthFirstSearch,e.elesfn.dfs=e.elesfn.depthFirstSearch,e.elesfn.stdBfs=e.elesfn.stdBreadthFirstSearch,e.elesfn.stdDfs=e.elesfn.stdDepthFirstSearch}(cytoscape),function(e){"use strict";e.fn.eles({aStar:function(t){t=t||{};var r=function(e,t,i,a){if(e==t)return a.push(n.getElementById(t)),a;if(t in i){var o=i[t],s=p[t];return a.push(n.getElementById(t)),a.push(n.getElementById(s)),r(e,o,i,a)}return void 0},i=function(e,t){if(0===e.length)return void 0;for(var r=0,i=t[e[0]],n=1;na&&(i=a,r=n)}return r},n=this._private.cy;if(null==t||null==t.root)return void 0;var a=e.is.string(t.root)?this.filter(t.root)[0]:t.root[0];if(null==t.goal)return void 0;var o=e.is.string(t.goal)?this.filter(t.goal)[0]:t.goal[0];if(null!=t.heuristic&&e.is.fn(t.heuristic))var s=t.heuristic;else var s=function(){return 0};if(null!=t.weight&&e.is.fn(t.weight))var l=t.weight;else var l=function(e){return 1};if(null!=t.directed)var u=t.directed;else var u=!1;var c=[],d=[a.id()],h={},p={},v={},f={};v[a.id()]=0,f[a.id()]=s(a);for(var g=this.edges().stdFilter(function(e){return!e.isLoop()}),y=this.nodes(),m=0;d.length>0;){var x=i(d,f),b=n.getElementById(d[x]);if(m++,b.id()==o.id()){var w=r(a.id(),o.id(),h,[]);return w.reverse(),{found:!0,distance:v[b.id()],path:new e.Collection(n,w),steps:m}}c.push(b.id()),d.splice(x,1);var _=b.connectedEdges();u&&(_=_.stdFilter(function(e){return e.data("source")===b.id()})),_=_.intersect(g);for(var E=0;E<_.length;E++){var S=_[E],D=S.connectedNodes().stdFilter(function(e){return e.id()!==b.id()}).intersect(y);if(-1==c.indexOf(D.id())){var k=v[b.id()]+l.apply(S,[S]);-1!=d.indexOf(D.id())?ku;u++)l[o[u].id()]=u;for(var c=[],u=0;s>u;u++){for(var d=new Array(s),h=0;s>h;h++)u==h?d[h]=0:d[h]=1/0;c.push(d)}var p=[],v=[],f=function(e){for(var t=0;s>t;t++){for(var r=new Array(s),i=0;s>i;i++)r[i]=void 0;e.push(r)}};f(p),f(v);for(var u=0;um&&(c[g][y]=m,p[g][y]=y,v[g][y]=a[u])}if(!n)for(var u=0;um&&(c[g][y]=m,p[g][y]=y,v[g][y]=a[u])}for(var x=0;s>x;x++)for(var u=0;s>u;u++)for(var h=0;s>h;h++)c[u][x]+c[x][h]u;u++)b.push(o[u].id());var w={distance:function(t,i){if(e.is.string(t))var n=r.filter(t)[0].id();else var n=t.id();if(e.is.string(i))var a=r.filter(i)[0].id();else var a=i.id();return c[l[n]][l[a]]},path:function(t,i){var n=function(e,t,i,n,a){if(e===t)return r.getElementById(n[e]);if(void 0===i[e][t])return void 0;for(var o=[r.getElementById(n[e])],s=e;e!==t;){s=e,e=i[e][t];var l=a[s][e];o.push(l),o.push(r.getElementById(n[e]))}return o};if(e.is.string(t))var a=r.filter(t)[0].id();else var a=t.id();if(e.is.string(i))var o=r.filter(i)[0].id();else var o=i.id();var s=n(l[a],l[o],p,b,v);return new e.Collection(r,s)}};return w},bellmanFord:function(t){if(t=t||{},null!=t.weight&&e.is.fn(t.weight))var r=t.weight;else var r=function(e){return 1};if(null!=t.directed)var i=t.directed;else var i=!1;if(null==t.root)return void e.util.error("options.root required");if(e.is.string(t.root))var n=this.filter(t.root)[0];else var n=t.root[0];for(var a=this._private.cy,o=this.edges().stdFilter(function(e){return!e.isLoop()}),s=this.nodes(),l=s.length,u={},c=0;l>c;c++)u[s[c].id()]=c;for(var d=[],h=[],p=[],c=0;l>c;c++)s[c].id()===n.id()?d[c]=0:d[c]=1/0,h[c]=void 0;for(var v=!1,c=1;l>c;c++){v=!1;for(var f=0;fc;c++)b.push(s[c].id());var w={distanceTo:function(t){if(e.is.string(t))var r=a.filter(t)[0].id();else var r=t.id();return d[u[r]]},pathTo:function(t){var r=function(e,t,r,i,n,o){for(;;){if(n.push(a.getElementById(i[r])),n.push(o[r]),t===r)return n;var s=e[r];if("undefined"==typeof s)return void 0;r=s}};if(e.is.string(t))var i=a.filter(t)[0].id();else var i=t.id();var o=[],s=r(h,u[n.id()],u[i],b,o,p);return null!=s&&s.reverse(),new e.Collection(a,s)},hasNegativeWeightCycle:!1};return w},kargerStein:function(t){t=t||{};var r=function(e,t,r){for(var i=r[e],n=i[1],a=i[2],o=t[n],s=t[a],l=r.filter(function(e){return t[e[1]]===o&&t[e[2]]===s?!1:t[e[1]]===s&&t[e[2]]===o?!1:!0}),u=0;u=n)return t;var o=Math.floor(Math.random()*t.length),s=r(o,e,t);return i(e,s,n-1,a)},n=this._private.cy,a=this.edges().stdFilter(function(e){return!e.isLoop()}),o=this.nodes(),s=o.length,l=a.length,u=Math.ceil(Math.pow(Math.log(s)/Math.LN2,2)),c=Math.floor(s/Math.sqrt(2));if(2>s)return void e.util.error("At least 2 nodes are required for KargerSteing algorithm!");for(var d={},h=0;s>h;h++)d[o[h].id()]=h;for(var p=[],h=0;l>h;h++){var v=a[h];p.push([h,d[v.source().id()],d[v.target().id()]])}for(var f,g=1/0,y=[],h=0;s>h;h++)y.push(h);for(var m=0;u>=m;m++){var x=y.slice(0),b=i(x,p,s,c),w=x.slice(0),_=i(x,b,c,2),E=i(w,b,c,2);_.length<=E.length&&_.lengthi;i++)r+=e[i];for(var i=0;t>i;i++)e[i]=e[i]/r};if(null!=t&&null!=t.dampingfactor)var i=t.dampingFactor;else var i=.8;if(null!=t&&null!=t.precision)var n=t.precision;else var n=1e-6;if(null!=t&&null!=t.iterations)var a=t.iterations;else var a=200;if(null!=t&&null!=t.weight&&e.is.fn(t.weight))var o=t.weight;else var o=function(e){return 1};for(var s=this._private.cy,l=this.edges().stdFilter(function(e){return!e.isLoop()}),u=this.nodes(),c=u.length,d=l.length,h={},p=0;c>p;p++)h[u[p].id()]=p;for(var v=[],f=[],g=(1-i)/c,p=0;c>p;p++){for(var y=[],m=0;c>m;m++)y.push(0);v.push(y),f.push(0)}for(var p=0;d>p;p++){var x=l[p],b=h[x.source().id()],w=h[x.target().id()],_=o.apply(x,[x]);v[w][b]+=_,f[b]+=_}for(var E=1/c+g,m=0;c>m;m++)if(0===f[m])for(var p=0;c>p;p++)v[p][m]=E;else for(var p=0;c>p;p++)v[p][m]=v[p][m]/f[m]+g;for(var S,D=[],k=[],p=0;c>p;p++)D.push(1),k.push(0);for(var T=0;a>T;T++){for(var P=k.slice(0),p=0;c>p;p++)for(var m=0;c>m;m++)P[p]+=v[p][m]*D[m];r(P),S=D,D=P;for(var C=0,p=0;c>p;p++)C+=Math.pow(S[p]-D[p],2);if(n>C)break}var B={rank:function(t){if(e.is.string(t))var r=s.filter(t)[0].id();else var r=t.id();return D[h[r]]}};return B},degreeCentralityNormalized:function(t){if(t=t||{},null!=t.directed)var r=t.directed;else var r=!1;var i=this.nodes(),n=i.length;if(r){for(var a={},o={},s=0,l=0,u=0;n>u;u++){var c=i[u],d=this.degreeCentrality(e.util.extend({},t,{root:c}));su;u++){var c=i[u],d=this.degreeCentrality(e.util.extend({},t,{root:c}));pn&&(n=l),i[a[s].id()]=l}return{closeness:function(t){if(e.is.string(t))var t=cy.filter(t)[0].id();else var t=t.id();return i[t]/n}}},closenessCentrality:function(t){if(t=t||{},null==t.root)return void e.util.error("options.root required");if(e.is.string(t.root))var r=this.filter(t.root)[0];else var r=t.root[0];if(null!=t.weight&&e.is.fn(t.weight))var i=t.weight;else var i=function(){return 1};if(null!=t.directed&&e.is.bool(t.directed))var n=t.directed;else var n=!1;var a=t.harmonic;void 0===a&&(a=!0);for(var o=this.dijkstra({root:r,weight:i,directed:n}),s=0,l=this.nodes(),u=0;u0;){var y=g.pop();h.push(y),i?l[y].forEach(function(e){if(o.$("#"+y).edgesTo(e).length>0)var t=o.$("#"+y).edgesTo(e)[0];else var t=e.edgesTo("#"+y)[0];var i=r.apply(t,[t]);f[e.id()]>f[y]+i&&(f[e.id()]=f[y]+i,g.indexOf(e.id())<0?a(g,e.id()):(g.splice(g.indexOf(e.id()),1),a(g,e.id())),v[e.id()]=0,p[e.id()]=[]),f[e.id()]==f[y]+i&&(v[e.id()]=v[e.id()]+v[y],p[e.id()].push(y))}):l[y].forEach(function(e){f[e.id()]==Number.POSITIVE_INFINITY&&(g.unshift(e.id()),f[e.id()]=f[y]+1),f[e.id()]==f[y]+1&&(v[e.id()]=v[e.id()]+v[y],p[e.id()].push(y))})}for(var m={},c=0;c0;){var x=h.pop();p[x].forEach(function(e){m[e]=m[e]+v[e]/v[x]*(1+m[x]),x!=s[d].id()&&(u[x]=u[x]+m[x])})}}var b=0;for(var w in u)b0&&new e.Collection(this._private.cy,i).updateStyle().trigger("class"),r},hasClass:function(e){var t=this[0];return null!=t&&t._private.classes[e]?!0:!1},toggleClass:function(t,r){for(var i=t.split(/\s+/),n=this,a=[],o=0,s=n.length;s>o;o++)for(var l=n[o],u=0;u0&&new e.Collection(this._private.cy,a).updateStyle().trigger("class"),n},removeClass:function(t){t=t.split(/\s+/);for(var r=this,i=[],n=0;n0&&new e.Collection(r._private.cy,i).updateStyle(),r.trigger("class"),r},flashClass:function(e,t){var r=this;if(null==t)t=250;else if(0===t)return r;return r.addClass(e),setTimeout(function(){r.removeClass(e)},t),r}})}(cytoscape),function(e){"use strict";e.fn.eles({allAre:function(e){return this.filter(e).length===this.length},is:function(e){return this.filter(e).length>0},some:function(e,t){for(var r=0;r0},allAreNeighbors:function(e){return e=this.cy().collection(e),this.neighborhood().intersect(e).length===e.length}}),e.elesfn.allAreNeighbours=e.elesfn.allAreNeighbors}(cytoscape),function(e){"use strict";e.fn.eles({parent:function(t){for(var r=[],i=this._private.cy,n=0;n0&&r.push(o)}return new e.Collection(i,r,{unique:!0}).filter(t)},parents:function(t){for(var r=[],i=this.parent();i.nonempty();){for(var n=0;n0?this.add(s):this;r?l.trigger("position"):l.rtrigger("position")}return this},silentPositions:function(e){return this.positions(e,!0)},updateCompoundBounds:function(){function t(e){var t=e.children(),r=e._private.style,n="include"===r["compound-sizing-wrt-labels"].value,a=t.boundingBox({includeLabels:n,includeEdges:!0}),o={top:r["padding-top"].pxValue,bottom:r["padding-bottom"].pxValue,left:r["padding-left"].pxValue,right:r["padding-right"].pxValue},s=e._private.position,l=!1;"auto"===r.width.value&&(e._private.autoWidth=a.w+o.left+o.right,s.x=(a.x1+a.x2-o.left+o.right)/2,l=!0),"auto"===r.height.value&&(e._private.autoHeight=a.h+o.top+o.bottom,s.y=(a.y1+a.y2-o.top+o.bottom)/2,l=!0),l&&i.push(e)}var r=this.cy();if(!r.styleEnabled()||!r.hasCompoundNodes())return r.collection();for(var i=[],n=this.parent();n.nonempty();){for(var a=0;a0,d=c;c&&(u=u[0]);var h=d?u._private.position:{x:0,y:0};return a={x:l.x-h.x,y:l.y-h.y},void 0===t?a:a[t]}for(var p=0;p0,d=c;c&&(u=u[0]);var h=d?u._private.position:{x:0,y:0};void 0!==r?i._private.position[t]=r+h[t]:void 0!==a&&(i._private.position={x:a.x+h.x,y:a.y+h.y})}this.rtrigger("position")}else if(!o)return void 0;return this},width:function(){var e=this[0],t=e._private.cy,r=t._private.styleEnabled;if(e){if(r){var i=e._private.style.width;return"auto"===i.strValue?e._private.autoWidth:i.pxValue}return 1}},outerWidth:function(){var e=this[0],i=e._private.cy,n=i._private.styleEnabled;if(e){if(n){var a=e._private.style,o="auto"===a.width.strValue?e._private.autoWidth:a.width.pxValue,s=a["border-width"]?a["border-width"].pxValue*t+r:0;return o+s}return 1}},renderedWidth:function(){var e=this[0];if(e){var t=e.width();return t*this.cy().zoom()}},renderedOuterWidth:function(){var e=this[0];if(e){var t=e.outerWidth();return t*this.cy().zoom()}},height:function(){var e=this[0],t=e._private.cy,r=t._private.styleEnabled;if(e&&"nodes"===e._private.group){if(r){var i=e._private.style.height;return"auto"===i.strValue?e._private.autoHeight:i.pxValue}return 1}},outerHeight:function(){var e=this[0],i=e._private.cy,n=i._private.styleEnabled;if(e&&"nodes"===e._private.group){if(!n)return 1;var a=e._private.style,o="auto"===a.height.strValue?e._private.autoHeight:a.height.pxValue,s=a["border-width"]?a["border-width"].pxValue*t+r:0;return o+s}},renderedHeight:function(){var e=this[0];if(e&&"nodes"===e._private.group){var t=e.height();return t*this.cy().zoom()}},renderedOuterHeight:function(){var e=this[0];if(e&&"nodes"===e._private.group){var t=e.outerHeight();return t*this.cy().zoom()}},renderedBoundingBox:function(e){var t=this.boundingBox(e),r=this.cy(),i=r.zoom(),n=r.pan(),a=t.x1*i+n.x,o=t.x2*i+n.x,s=t.y1*i+n.y,l=t.y2*i+n.y;return{x1:a,x2:o,y1:s,y2:l,w:o-a,h:l-s}},boundingBox:function(e){var t=this,r=t._private.cy,i=r._private,n=i.styleEnabled;e=e||{};var a=void 0===e.includeNodes?!0:e.includeNodes,o=void 0===e.includeEdges?!0:e.includeEdges,s=void 0===e.includeLabels?!0:e.includeLabels;n&&i.renderer.recalculateRenderedStyle(this);for(var l=1/0,u=-(1/0),c=1/0,d=-(1/0),h=0;hp?p:l,u=v>u?v:u,c=c>f?f:c,d=g>d?g:d}else if(x.isEdge()&&o){S=!0;var B=b.source,M=B._private,N=M.position,I=b.target,O=I._private,z=O.position,L=b.rstyle||{},k=0,R=0;if(n&&(k=w.width.pxValue,R=k/2),p=N.x,v=z.x,f=N.y,g=z.y,p>v){var V=p;p=v,v=V}if(f>g){var V=f;f=g,g=V}if(p-=R,v+=R,f-=R,g+=R,l=l>p?p:l,u=v>u?v:u,c=c>f?f:c,d=g>d?g:d,n)for(var A=L.bezierPts||[],X=0;Xp?p:l,u=v>u?v:u,c=c>f?f:c,d=g>d?g:d}if(n&&"haystack"===w["curve-style"].strValue){var Y=b.rscratch.haystackPts;if(p=Y[0],f=Y[1],v=Y[2],g=Y[3],p>v){var V=p;p=v,v=V}if(f>g){var V=f;f=g,g=V}l=l>p?p:l,u=v>u?v:u,c=c>f?f:c,d=g>d?g:d}}if(n){var w=x._private.style,L=x._private.rstyle,q=w.content.strValue,j=w["font-size"],$=w["text-halign"],W=w["text-valign"],H=L.labelWidth,Z=L.labelHeight,U=L.labelX,G=L.labelY;if(S&&s&&q&&j&&null!=Z&&null!=H&&null!=U&&null!=G&&$&&W){var K,J,Q,ee,te=Z,re=H;if(x.isEdge())K=U-re/2,J=U+re/2,Q=G-te/2,ee=G+te/2;else{switch($.value){case"left":K=U-re,J=U;break;case"center":K=U-re/2,J=U+re/2;break;case"right":K=U,J=U+re}switch(W.value){case"top":Q=G-te,ee=G;break;case"center":Q=G-te/2,ee=G+te/2;break;case"bottom":Q=G,ee=G+te}}l=l>K?K:l,u=J>u?J:u,c=c>Q?Q:c,d=ee>d?ee:d}}}}var ie=function(e){return e===1/0||e===-(1/0)?0:e};return l=ie(l),u=ie(u),c=ie(c),d=ie(d),{x1:l,x2:u,y1:c,y2:d,w:u-l,h:d-c}}});var i=e.elesfn;i.attr=i.data,i.removeAttr=i.removeData,i.modelPosition=i.point=i.position,i.modelPositions=i.points=i.positions,i.renderedPoint=i.renderedPosition,i.relativePoint=i.relativePosition,i.boundingbox=i.boundingBox,i.renderedBoundingbox=i.renderedBoundingBox}(cytoscape),function(e){"use strict";function t(e){return function(t){var r=this;if(void 0===t&&(t=!0),0!==r.length&&r.isNode()&&!r.removed()){for(var i=0,n=r[0],a=n._private.edges,o=0;oe}),maxDegree:r("degree",function(e,t){return e>t}),minIndegree:r("indegree",function(e,t){return t>e}),maxIndegree:r("indegree",function(e,t){return e>t}),minOutdegree:r("outdegree",function(e,t){return t>e}),maxOutdegree:r("outdegree",function(e,t){return e>t})}),e.fn.eles({totalDegree:function(e){for(var t=0,r=this.nodes(),i=0;i1&&!n){var a=this.length-1,o=this[a];this[a]=void 0,this[i]=o,t.indexes[o.id()]=i}return this.length--,this},unmerge:function(t){var r=this._private.cy;if(!t)return this;if(e.is.string(t)){var i=t;t=r.elements(i)}for(var n=0;ni&&(i=s,r=o)}return{value:i,ele:r}},min:function(e,t){for(var r,i=1/0,n=this,a=0;as&&(i=s,r=o)}return{value:i,ele:r}}});var t=e.elesfn;t.u=t["|"]=t["+"]=t.union=t.or=t.add,t["\\"]=t["!"]=t["-"]=t.difference=t.relativeComplement=t.not,t.n=t["&"]=t["."]=t.and=t.intersection=t.intersect,t["^"]=t["(+)"]=t["(-)"]=t.symmetricDifference=t.symdiff=t.xor,t.fnFilter=t.filterFn=t.stdFilter,t.complement=t.abscomp=t.absoluteComplement}(cytoscape),function(e){"use strict";e.fn.eles({isNode:function(){return"nodes"===this.group()},isEdge:function(){return"edges"===this.group()},isLoop:function(){return this.isEdge()&&this.source().id()===this.target().id()},isSimple:function(){return this.isEdge()&&this.source().id()!==this.target().id()},group:function(){var e=this[0];return e?e._private.group:void 0}})}(cytoscape),function(e){"use strict";e.fn.eles({each:function(t){if(e.is.fn(t))for(var r=0;rt&&(t=n+t),0>r&&(r=n+r);for(var a=t;a>=0&&r>a&&n>a;a++)i.push(this[a]);return new e.Collection(this.cy(),i)},size:function(){return this.length},eq:function(t){return this[t]||new e.Collection(this.cy())},first:function(){return this[0]||new e.Collection(this.cy())},last:function(){return this[this.length-1]||new e.Collection(this.cy())},empty:function(){return 0===this.length},nonempty:function(){return!this.empty()},sort:function(t){if(!e.is.fn(t))return this;var r=this.cy(),i=this.toArray().sort(t);return new e.Collection(r,i)},sortByZIndex:function(){return this.sort(e.Collection.zIndexSort)},zDepth:function(){var e=this[0];if(!e)return void 0;var t=e._private,r=t.group;if("nodes"===r){var i=t.data.parent?e.parents().size():0;return e.isParent()?i:Number.MAX_VALUE}var n=t.source,a=t.target,o=n.zDepth(),s=a.zDepth();return Math.max(o,s,0)}}),e.Collection.zIndexSort=function(e,t){var r=e.cy(),i=e._private,n=t._private,a=i.style["z-index"].value-n.style["z-index"].value,o=0,s=0,l=r.hasCompoundNodes(),u="nodes"===i.group,c="edges"===i.group,d="nodes"===n.group,h="edges"===n.group;l&&(o=e.zDepth(),s=t.zDepth());var p=o-s,v=0===p;return v?u&&h?1:c&&d?-1:0===a?i.index-n.index:a:p}}(cytoscape),function(e){"use strict";e.fn.eles({layoutPositions:function(t,r,i){var n=this.nodes(),a=this.cy();if(t.trigger({type:"layoutstart",layout:t}),r.animate){for(var o=0;o0?this.add(o):this;return e?s.rtrigger("style"):s.trigger("style"),this},updateMappers:function(e){var t=this._private.cy,r=t.style();if(e=e||void 0===e?!0:!1,!t.styleEnabled())return this;r.updateMappers(this);var i=this.updateCompoundBounds(),n=i.length>0?this.add(i):this;return e?n.rtrigger("style"):n.trigger("style"),this},renderedCss:function(e){var t=this.cy();if(!t.styleEnabled())return this;var r=this[0];if(r){var i=r.cy().style().getRenderedStyle(r);return void 0===e?i:i[e]}},css:function(t,r){var i=this.cy();if(!i.styleEnabled())return this;var n=!1,a=i.style();if(e.is.plainObject(t)){var o=t;a.applyBypass(this,o,n);var s=this.updateCompoundBounds(),l=s.length>0?this.add(s):this;l.rtrigger("style")}else if(e.is.string(t)){if(void 0===r){var u=this[0];return u?u._private.style[t].strValue:void 0}a.applyBypass(this,t,r,n);var s=this.updateCompoundBounds(),l=s.length>0?this.add(s):this;l.rtrigger("style")}else if(void 0===t){var u=this[0];return u?a.getRawStyle(u):void 0}return this},removeCss:function(e){var t=this.cy();if(!t.styleEnabled())return this;var r=!1,i=t.style(),n=this;if(void 0===e)for(var a=0;a0?this.add(s):this;return l.rtrigger("style"),this},show:function(){return this.css("display","element"),this},hide:function(){return this.css("display","none"),this},visible:function(){var e=this.cy();if(!e.styleEnabled())return!0;var t=this[0],r=e.hasCompoundNodes();if(t){var i=t._private.style;if("visible"!==i.visibility.value||"element"!==i.display.value)return!1;if("nodes"===t._private.group){if(!r)return!0;var n=t._private.data.parent?t.parents():null;if(n)for(var a=0;a0;o||i.push(a)}}return new e.Collection(this._private.cy,i,{unique:!0}).filter(t)},leaves:function(t){for(var r=this,i=[],n=0;n0;o||i.push(a)}}return new e.Collection(this._private.cy,i,{unique:!0}).filter(t)},outgoers:function(t){for(var r=this,i=[],n=0;n0&&r.push(c[0]),r.push(u[0])}return new e.Collection(i,r,{unique:!0}).filter(t)},closedNeighborhood:function(e){return this.neighborhood().add(this).filter(e)},openNeighborhood:function(e){return this.neighborhood(e)}}),e.elesfn.neighbourhood=e.elesfn.neighborhood,e.elesfn.closedNeighbourhood=e.elesfn.closedNeighborhood,e.elesfn.openNeighbourhood=e.elesfn.openNeighborhood,e.fn.eles({source:function(e){var t,r=this[0];return r&&(t=r._private.source),t&&e?t.filter(e):t},target:function(e){var t,r=this[0];return r&&(t=r._private.target),t&&e?t.filter(e):t},sources:t({attr:"source"}),targets:t({attr:"target"})}),e.fn.eles({edgesWith:r(),edgesTo:r({thisIs:"source"})}),e.fn.eles({connectedEdges:function(t){for(var r=[],i=this._private.cy,n=this,a=0;ad;d+=1){if(l.push(n.call(t,r[d],d,r)),a=r[d].id(),u.hasOwnProperty(a))throw"ERROR: Multiple items with the same id found: "+a;u[a]=d,c.push(a)}for(this._private={cy:t,heap:l,pointers:u,elements:c,comparator:i,extractor:n,length:s},d=Math.floor(s/2);d>=0;d-=1)o=this.heapify(d);return o}},e.Heap.idFn=function(e){return e.id()},e.Heap.minHeapComparator=function(e,t){return e>=t},e.Heap.maxHeapComparator=function(e,t){return t>=e},e.fn.heap=function(t,r){for(var i in t){var n=t[i];e.Heap.prototype[i]=n}},e.heapfn=e.Heap.prototype,e.heapfn.size=function(){return this._private.length},e.heapfn.getArgumentAsCollection=function(t,r){var i;if("undefined"==typeof r&&(r=this._private.cy),e.is.elementOrCollection(t))i=t;else{for(var n=[],a=[].concat.apply([],[t]),o=0;o0&&n.push(l)}i=new e.Collection(r,n)}return i},e.heapfn.isHeap=function(){var e,t,r,i,n,a=this._private.heap,o=a.length,s=this._private.comparator;for(e=0;o>e;e+=1)if(t=2*e+1,r=t+1,i=o>t?s(a[t],a[e]):!0,n=o>r?s(a[r],a[e]):!0,!i||!n)return!1;return!0},e.heapfn.heapSwap=function(e,t){var r=this._private.heap,i=this._private.pointers,n=this._private.elements,a=r[e],o=n[e],s=n[e],l=n[t];r[e]=r[t],n[e]=n[t],i[s]=t,i[l]=e,r[t]=a,n[t]=o},e.heapfn.heapify=function(e,t){var r,i,n,a,o,s,l,u=0,c=!1;for("undefined"==typeof t&&(t=!0),r=this._private.heap,u=r.length,s=this._private.comparator,i=e;!c;)t?(n=2*i+1,a=n+1,o=i,u>n&&!s(r[n],r[o])&&(o=n),u>a&&!s(r[a],r[o])&&(o=a),c=o===i,c||(this.heapSwap(o,i),i=o)):(l=Math.floor((i-1)/2),o=i,c=0>l||s(r[o],r[l]),c||(this.heapSwap(o,l),i=l))},e.heapfn.insert=function(e){var t,r,i,n,a,o=this.getArgumentAsCollection(e),s=o.length;for(a=0;s>a;a+=1){if(t=o[a],r=this._private.heap.length,i=this._private.extractor(t),n=t.id(),this._private.pointers.hasOwnProperty(n))throw"ERROR: Multiple items with the same id found: "+n;this._private.heap.push(i),this._private.elements.push(n),this._private.pointers[n]=r,this.heapify(r,!1)}this._private.length=this._private.heap.length},e.heapfn.getValueById=function(e){if(this._private.pointers.hasOwnProperty(e)){var t=this._private.pointers[e];return this._private.heap[t]}},e.heapfn.contains=function(e){for(var t=this.getArgumentAsCollection(e),r=0;r0?{value:this._private.heap[0],id:this._private.elements[0]}:void 0},e.heapfn.pop=function(){if(this._private.length>0){var e,t,r,i=this.top(),n=this._private.length-1;return this.heapSwap(0,n),e=this._private.elements[n],t=this._private.heap[n],r=e,this._private.heap.pop(),this._private.elements.pop(),this._private.length=this._private.heap.length,this._private.pointers[r]=void 0,this.heapify(0),i}},e.heapfn.findDirectionHeapify=function(e){var t=Math.floor((e-1)/2),r=this._private.heap,i=0>t||this._private.comparator(r[e],r[t]);this.heapify(e,i)},e.heapfn.edit=function(t,r){for(var i=this.getArgumentAsCollection(t),n=0;n=l&&u>=e&&t>=c&&d>=t},a=function(e,t,r,i,n){i=-i;var a=e*Math.cos(i)-t*Math.sin(i),o=e*Math.sin(i)+t*Math.cos(i),s=a*r,l=o*r,u=s+n.x,c=l+n.y;return{x:u,y:c}};i.arrow={_points:[-.15,-.3,0,0,.15,-.3],collide:function(t,r,n,a,o,s,l,u){var c=i.arrow._points;return e.math.pointInsidePolygon(t,r,c,n,a,o,s,l,u)},roughCollide:n,draw:function(e,t,r,n){for(var o=i.arrow._points,s=0;s(s=e.math.sqDistanceToQuadraticBezier(r,i,d.startX,d.startY,d.cp2ax,d.cp2ay,d.selfEdgeMidX,d.selfEdgeMidY))||(b=e.math.inBezierVicinity(r,i,d.selfEdgeMidX,d.selfEdgeMidY,d.cp2cx,d.cp2cy,d.endX,d.endY,g))&&w()&&g>(s=e.math.sqDistanceToQuadraticBezier(r,i,d.selfEdgeMidX,d.selfEdgeMidY,d.cp2cx,d.cp2cy,d.endX,d.endY)))&&c.push(a);else if("haystack"===d.edgeType){var _=v["haystack-radius"].value,E=_/2,S=x._private.position,D=x.width(),k=x.height(),T=m._private.position,P=m.width(),C=m.height(),B=T.x+d.source.x*P*E,M=T.y+d.source.y*C*E,N=S.x+d.target.x*D*E,I=S.y+d.target.y*k*E;(b=e.math.inLineVicinity(r,i,B,M,N,I,y))&&w()&&g>(s=e.math.sqDistanceToFiniteLine(r,i,B,M,N,I))&&c.push(a)}else"straight"===d.edgeType?(b=e.math.inLineVicinity(r,i,d.startX,d.startY,d.endX,d.endY,y))&&w()&&g>(s=e.math.sqDistanceToFiniteLine(r,i,d.startX,d.startY,d.endX,d.endY))&&c.push(a):"bezier"===d.edgeType&&(b=e.math.inBezierVicinity(r,i,d.startX,d.startY,d.cp2x,d.cp2y,d.endX,d.endY,g))&&w()&&g>(s=e.math.sqDistanceToQuadraticBezier(r,i,d.startX,d.startY,d.cp2x,d.cp2y,d.endX,d.endY))&&c.push(a);if(b&&w()&&0===c.length||c[c.length-1]!==a){var O=t.arrowShapes[v["source-arrow-shape"].value],z=t.arrowShapes[v["target-arrow-shape"].value],m=m||a._private.source,x=x||a._private.target,S=x._private.position,T=m._private.position,L=l.getArrowWidth(v.width.pxValue),R=l.getArrowHeight(v.width.pxValue),V=L,A=R;(O.roughCollide(r,i,d.arrowStartX,d.arrowStartY,L,R,[d.arrowStartX-T.x,d.arrowStartY-T.y],p)&&O.collide(r,i,d.arrowStartX,d.arrowStartY,L,R,[d.arrowStartX-T.x,d.arrowStartY-T.y],p)||z.roughCollide(r,i,d.arrowEndX,d.arrowEndY,V,A,[d.arrowEndX-S.x,d.arrowEndY-S.y],p)&&z.collide(r,i,d.arrowEndX,d.arrowEndY,V,A,[d.arrowEndX-S.x,d.arrowEndY-S.y],p))&&c.push(a)}h&&c.length>0&&c[c.length-1]===a&&(o(m),o(x))}for(var l=this,u=this.getCachedZSortedEles(),c=[],d=this.data.cy.zoom(),h=this.data.cy.hasCompoundNodes(),p=(a?24:8)/d,v=(a?8:2)/d,f=u.length-1;f>=0;f--){var g=u[f];if(c.length>0)break;"nodes"===g._private.group?o(u[f]):s(u[f])}return c.length>0?c[c.length-1]:null},r.getAllInBox=function(r,i,n,a){var o=this.getCachedNodes(),s=this.getCachedEdges(),l=[],u=Math.min(r,n),c=Math.max(r,n),d=Math.min(i,a),h=Math.max(i,a);r=u,n=c,i=d,a=h;for(var p,v=0;v=r&&n>=k&&T>=i&&a>=T,M=P>=r&&n>=P&&C>=i&&a>=C;B&&M&&l.push(s[v])}}return l},r.getNodeWidth=function(e){return e.width()},r.getNodeHeight=function(e){return e.height()},r.getNodeShape=function(e){var t=e._private.style.shape.value;return e.isParent()?"rectangle"===t||"roundrectangle"===t?t:"rectangle":t},r.getNodePadding=function(e){var t=e._private.style["padding-left"].pxValue,r=e._private.style["padding-right"].pxValue,i=e._private.style["padding-top"].pxValue,n=e._private.style["padding-bottom"].pxValue;return isNaN(t)&&(t=0),isNaN(r)&&(r=0),isNaN(i)&&(i=0),isNaN(n)&&(n=0),{left:t,right:r,top:i,bottom:n}},r.zOrderSort=e.Collection.zIndexSort,r.updateCachedZSortedEles=function(){this.getCachedZSortedEles(!0)},r.getCachedZSortedEles=function(e){var t=this.lastZOrderCachedNodes,r=this.lastZOrderCachedEdges,i=this.getCachedNodes(),n=this.getCachedEdges(),a=[];if(!e&&t&&r&&t===i&&r===n)a=this.cachedZSortedEles;else{for(var o=0;oo){for(var h=u.split(/\s+/),p="",v=0;v=m?p+=f+" ":(s.push(p),p=f+" ")}p.match(/^\s+$/)||s.push(p)}else s.push(u)}n.labelWrapCachedLines=s,n.labelWrapCachedText=r=s.join("\n"),n.labelWrapKey=n.labelKey}return r},r.calculateLabelDimensions=function(e,t,r){var i=this,n=e._private.style,a=n["font-style"].strValue,o=n["font-size"].pxValue+"px",s=n["font-family"].strValue,l=n["font-weight"].strValue,u=e._private.labelKey;r&&(u+="$@$"+r);var c=i.labelDimCache||(i.labelDimCache={});if(c[u])return c[u];var d=this.labelCalcDiv;d||(d=this.labelCalcDiv=document.createElement("div"),document.body.appendChild(d));var h=d.style;return h.fontFamily=s,h.fontStyle=a,h.fontSize=o,h.fontWeight=l,h.position="absolute",h.left="-9999px",h.top="-9999px",h.zIndex="-1",h.visibility="hidden",h.pointerEvents="none",h.padding="0",h.lineHeight="1","wrap"===n["text-wrap"].value?h.whiteSpace="pre":h.whiteSpace="normal",d.textContent=t,c[u]={width:d.clientWidth,height:d.clientHeight},c[u]},r.recalculateRenderedStyle=function(e){for(var t=[],r=[],i={},n=0;nv?v+"-"+p:p+"-"+v,h&&(i="unbundled"+c._private.data.id),null==o[i]&&(o[i]=[],s.push(i)),o[i].push(c),h&&(o[i].hasUnbundled=!0)}else l.push(c)}for(var f,g,y,m,x,b,w,_,E,S,D,k,T,P,C=0;Cg._private.data.id){var M=f;f=g,g=M}if(y=f._private.position,m=g._private.position,x=this.getNodeWidth(f),b=this.getNodeHeight(f),w=this.getNodeWidth(g),_=this.getNodeHeight(g),E=t.nodeShapes[this.getNodeShape(f)],S=t.nodeShapes[this.getNodeShape(g)],D=f._private.style["border-width"].pxValue,k=g._private.style["border-width"].pxValue,P=!1,B.length>1&&f!==g||B.hasUnbundled){var N=E.intersectLine(y.x,y.y,x,b,m.x,m.y,D/2),I=S.intersectLine(m.x,m.y,w,_,y.x,y.y,k/2),O={x1:N[0],x2:I[0],y1:N[1],y2:I[1]},z=I[1]-N[1],L=I[0]-N[0],R=Math.sqrt(L*L+z*z),V={x:L,y:z},A={x:V.x/R,y:V.y/R};T={x:-A.y,y:A.x},(S.checkPoint(N[0],N[1],k/2,w,_,m.x,m.y)||E.checkPoint(I[0],I[1],D/2,x,b,y.x,y.y))&&(T={},P=!0)}for(var c,X,u=0;uOe,Le=e.math.distance({x:X.cp2x,y:X.cp2y},{x:X.endX,y:X.endY}),Re=Ie>Le;if("bezier"===X.edgeType){var Ve=!1;if(Te||Pe||ze){Ve=!0;var Ae={x:X.cp2x-y.x,y:X.cp2y-y.y},Xe=Math.sqrt(Ae.x*Ae.x+Ae.y*Ae.y),Fe={x:Ae.x/Xe,y:Ae.y/Xe},Ye=Math.max(x,b),qe={x:X.cp2x+2*Fe.x*Ye,y:X.cp2y+2*Fe.y*Ye},je=E.intersectLine(y.x,y.y,x,b,qe.x,qe.y,D/2);ze?(X.cp2x=X.cp2x+Fe.x*(Ie-Oe),X.cp2y=X.cp2y+Fe.y*(Ie-Oe)):(X.cp2x=je[0]+Fe.x*Ie,X.cp2y=je[1]+Fe.y*Ie)}if(Ce||Be||Re){Ve=!0;var Ae={x:X.cp2x-m.x,y:X.cp2y-m.y},Xe=Math.sqrt(Ae.x*Ae.x+Ae.y*Ae.y),Fe={x:Ae.x/Xe,y:Ae.y/Xe},Ye=Math.max(x,b),qe={x:X.cp2x+2*Fe.x*Ye,y:X.cp2y+2*Fe.y*Ye},$e=S.intersectLine(m.x,m.y,w,_,qe.x,qe.y,k/2);Re?(X.cp2x=X.cp2x+Fe.x*(Ie-Le),X.cp2y=X.cp2y+Fe.y*(Ie-Le)):(X.cp2x=$e[0]+Fe.x*Ie,X.cp2y=$e[1]+Fe.y*Ie)}Ve&&this.findEndpoints(c)}else"straight"===X.edgeType&&(X.midX=(K+ae)/2,X.midY=(Q+se)/2);this.projectBezier(c),this.recalculateEdgeLabelProjection(c)}}}for(var u=0;uS*k+D*T)n.straightEdgeTooShort=!0;else{var _=n;this.drawStyledEdge(r,e,[_.startX,_.startY,_.endX,_.endY],g,f),n.straightEdgeTooShort=!1}}else{var _=n;this.drawStyledEdge(r,e,[_.startX,_.startY,_.cp2x,_.cp2y,_.endX,_.endY],g,f)}"haystack"===n.edgeType?this.drawArrowheads(e,r,i):n.noArrowPlacement!==!0&&void 0!==n.startX&&this.drawArrowheads(e,r,i),this.shadowStyle(e,"transparent",0)}}},r.drawStyledEdge=function(e,r,i,n,a){var o,s=e._private.rscratch,l=r,u=!1,c=t.usePaths();if(c){for(var d=i,h=s.pathCacheKey&&d.length===s.pathCacheKey.length,p=h,v=0;p&&vu?y+=Math.PI/2:y=-(Math.PI/2+y);var m=this.getArrowWidth(a),x=t.arrowShapes[o];if(h){var b=m+"$"+o+"$"+y+"$"+s+"$"+l;p.arrowPathCacheKey=p.arrowPathCacheKey||{},p.arrowPathCache=p.arrowPathCache||{};var w=p.arrowPathCacheKey[r]===b;w?(d=i=p.arrowPathCache[r],v=!0):(d=i=new Path2D,p.arrowPathCacheKey[r]=b,p.arrowPathCache[r]=d)}i.beginPath&&i.beginPath(),v||x.draw(i,m,y,g),!x.leavePathOpen&&i.closePath&&i.closePath(),i=f,("filled"===n||"both"===n)&&(h?i.fill(d):i.fill()),("hollow"===n||"both"===n)&&(i.lineWidth=x.matchEdgeWidth?a:1,i.lineJoin="miter",h?i.stroke(d):i.stroke())}}(cytoscape),function(e){"use strict";var t=e("renderer","canvas"),r=t.prototype;r.getCachedImage=function(e,t){var r=this,i=r.imageCache=r.imageCache||{};if(i[e]&&i[e].image)return i[e].image;var n=i[e]=i[e]||{},a=n.image=new Image;return a.addEventListener("load",t),a.src=e,a},r.safeDrawImage=function(e,r,i,n,a,o,s,l,u,c){var d=this;try{e.drawImage(r,i,n,a,o,s,l,u,c)}catch(h){d.data.canvasNeedsRedraw[t.NODE]=!0,d.data.canvasNeedsRedraw[t.DRAG]=!0,d.drawingImage=!0,d.redraw()}},r.drawInscribedImage=function(e,r,i){var n=this,a=i._private.position.x,o=i._private.position.y,s=i._private.style,l=s["background-fit"].value,u=s["background-position-x"],c=s["background-position-y"],d=s["background-repeat"].value,h=i.width(),p=i.height(),v=i._private.rscratch,f=s["background-clip"].value,g="node"===f,y=s["background-image-opacity"].value,m=r.width,x=r.height; if(0!==m&&0!==x){var b=s["background-width"];"auto"!==b.value&&(m="%"===b.units?b.value/100*h:b.pxValue);var w=s["background-height"];if("auto"!==w.value&&(x="%"===w.units?w.value/100*p:w.pxValue),0!==m&&0!==x){if("contain"===l){var _=Math.min(h/m,p/x);m*=_,x*=_}else if("cover"===l){var _=Math.max(h/m,p/x);m*=_,x*=_}var E=a-h/2;E+="%"===u.units?(h-m)*u.value/100:u.pxValue;var S=o-p/2;S+="%"===c.units?(p-x)*c.value/100:c.pxValue,v.pathCache&&(E-=a,S-=o,a=0,o=0);var D=e.globalAlpha;if(e.globalAlpha=y,"no-repeat"===d)g&&(e.save(),v.pathCache?e.clip(v.pathCache):(t.nodeShapes[n.getNodeShape(i)].drawPath(e,a,o,h,p),e.clip())),n.safeDrawImage(e,r,0,0,r.width,r.height,E,S,m,x),g&&e.restore();else{var k=e.createPattern(r,d);e.fillStyle=k,t.nodeShapes[n.getNodeShape(i)].drawPath(e,a,o,h,p),e.translate(E,S),e.fill(),e.translate(-E,-S)}e.globalAlpha=D}}}}(cytoscape),function(e){"use strict";function t(e,t,r,i,n,a){var a=a||5;e.beginPath(),e.moveTo(t+a,r),e.lineTo(t+i-a,r),e.quadraticCurveTo(t+i,r,t+i,r+a),e.lineTo(t+i,r+n-a),e.quadraticCurveTo(t+i,r+n,t+i-a,r+n),e.lineTo(t+a,r+n),e.quadraticCurveTo(t,r+n,t,r+n-a),e.lineTo(t,r+a),e.quadraticCurveTo(t,r,t+a,r),e.closePath(),e.fill()}var r=e("renderer","canvas"),i=r.prototype;i.drawEdgeText=function(t,r){var i=r._private.style.content.strValue;if(i&&!i.match(/^\s+$/)&&(!this.hideEdgesOnViewport||!(this.dragData.didDrag||this.pinching||this.hoverData.dragging||this.data.wheel||this.swipePanning))){var n=r._private.style["font-size"].pxValue*r.cy().zoom(),a=r._private.style["min-zoomed-font-size"].pxValue;if(!(a>n)){t.textAlign="center",t.textBaseline="middle";var o=r._private.rscratch;if(e.is.number(o.labelX)&&e.is.number(o.labelY)){var s,l,u,c=r._private.style,d="autorotate"===c["edge-text-rotation"].strValue;if(d){switch(o.edgeType){case"haystack":l=o.haystackPts[2]-o.haystackPts[0],u=o.haystackPts[3]-o.haystackPts[1];break;default:l=o.endX-o.startX,u=o.endY-o.startY}s=Math.atan(u/l),t.translate(o.labelX,o.labelY),t.rotate(s),this.drawText(t,r,0,0),t.rotate(-s),t.translate(-o.labelX,-o.labelY)}else this.drawText(t,r,o.labelX,o.labelY)}}}},i.drawNodeText=function(t,r){var i=r._private.style.content.strValue;if(i&&!i.match(/^\s+$/)){var n=r._private.style["font-size"].pxValue*r.cy().zoom(),a=r._private.style["min-zoomed-font-size"].pxValue;if(!(a>n)){var o=r._private.style["text-halign"].strValue,s=r._private.style["text-valign"].strValue,l=r._private.rscratch;if(e.is.number(l.labelX)&&e.is.number(l.labelY)){switch(o){case"left":t.textAlign="right";break;case"right":t.textAlign="left";break;default:t.textAlign="center"}switch(s){case"top":t.textBaseline="bottom";break;case"bottom":t.textBaseline="top";break;default:t.textBaseline="middle"}this.drawText(t,r,l.labelX,l.labelY)}}}},i.getFontCache=function(e){var t;this.fontCaches=this.fontCaches||[];for(var r=0;r0||f>0&&v>0){var g=4+f/2;r.isNode()&&("top"===h?n-=g:"bottom"===h&&(n+=g),"left"===d?i-=g:"right"===d&&(i+=g));var y=s.labelWidth,m=s.labelHeight,x=i;d&&("center"==d?x-=y/2:"left"==d&&(x-=y));var b=n;if(r.isNode()?"top"==h?b-=m:"center"==h&&(b-=m/2):b-=m/2,"autorotate"===o["edge-text-rotation"].strValue?(n=0,y+=4,x=i-y/2,b=n-m/2):(x-=g,b-=g,m+=2*g,y+=2*g),p>0){var w=e.fillStyle,_=o["text-background-color"].value;e.fillStyle="rgba("+_[0]+","+_[1]+","+_[2]+","+p*u+")";var E=o["text-background-shape"].strValue;"roundrectangle"==E?t(e,x,b,y,m,2):e.fillRect(x,b,y,m),e.fillStyle=w}if(f>0&&v>0){var S=e.strokeStyle,D=e.lineWidth,k=o["text-border-color"].value,T=o["text-border-style"].value;if(e.strokeStyle="rgba("+k[0]+","+k[1]+","+k[2]+","+v*u+")",e.lineWidth=f,e.setLineDash)switch(T){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"double":e.lineWidth=f/4,e.setLineDash([]);break;case"solid":e.setLineDash([])}if(e.strokeRect(x,b,y,m),"double"===T){var P=f/2;e.strokeRect(x+P,b+P,y-2*P,m-2*P)}e.setLineDash&&e.setLineDash([]),e.lineWidth=D,e.strokeStyle=S}}var C=2*o["text-outline-width"].pxValue;if(C>0&&(e.lineWidth=C),"wrap"===o["text-wrap"].value){var B=l.labelWrapCachedLines,M=s.labelHeight/B.length;switch(h){case"top":n-=(B.length-1)*M;break;case"bottom":break;default:case"center":n-=(B.length-1)*M/2}for(var N=0;N0&&e.strokeText(B[N],i,n),e.fillText(B[N],i,n),n+=M}else C>0&&e.strokeText(c,i,n),e.fillText(c,i,n);this.shadowStyle(e,"transparent",0)}}}}(cytoscape),function(e){"use strict";var t=e("renderer","canvas"),r=t.prototype;r.drawNode=function(e,r,i){var n,a,o=this,s=r._private.style,l=r._private.rscratch,u=r._private,c=u.position;if(void 0!==c.x&&void 0!==c.y){var d,h=t.usePaths(),p=e,v=!1,f=s["overlay-padding"].pxValue,g=s["overlay-opacity"].value,y=s["overlay-color"].value;if(!i||0!==g){var m=r.effectiveOpacity();if(0!==m)if(n=this.getNodeWidth(r),a=this.getNodeHeight(r),e.lineWidth=s["border-width"].pxValue,void 0!==i&&i)g>0&&(this.fillStyle(e,y[0],y[1],y[2],g),t.nodeShapes.roundrectangle.drawPath(e,r._private.position.x,r._private.position.y,n+2*f,a+2*f),e.fill());else{var x,b=s["background-image"].value[2]||s["background-image"].value[1];if(void 0!==b){x=this.getCachedImage(b,function(){o.data.canvasNeedsRedraw[t.NODE]=!0,o.data.canvasNeedsRedraw[t.DRAG]=!0,o.drawingImage=!0,o.redraw()});var w=u.backgrounding;u.backgrounding=!x.complete,w!==u.backgrounding&&r.updateStyle(!1)}var _=s["background-color"].value,E=s["border-color"].value,S=s["border-style"].value;this.fillStyle(e,_[0],_[1],_[2],s["background-opacity"].value*m),this.strokeStyle(e,E[0],E[1],E[2],s["border-opacity"].value*m);var D=s["shadow-blur"].pxValue,k=s["shadow-opacity"].value,T=s["shadow-color"].value,P=s["shadow-offset-x"].pxValue,C=s["shadow-offset-y"].pxValue;if(this.shadowStyle(e,T,k,D,P,C),e.lineJoin="miter",e.setLineDash)switch(S){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"solid":case"double":e.setLineDash([])}var B=s.shape.strValue;if(h){var M=B+"$"+n+"$"+a;e.translate(c.x,c.y),l.pathCacheKey===M?(d=e=l.pathCache,v=!0):(d=e=new Path2D,l.pathCacheKey=M,l.pathCache=d)}if(!v){var N=c;h&&(N={x:0,y:0}),t.nodeShapes[this.getNodeShape(r)].drawPath(e,N.x,N.y,n,a)}e=p,h?e.fill(d):e.fill(),this.shadowStyle(e,"transparent",0),void 0!==b&&x.complete&&this.drawInscribedImage(e,x,r);var I=s["background-blacken"].value,O=s["border-width"].pxValue;if(this.hasPie(r)&&(this.drawPie(e,r,m),(0!==I||0!==O)&&(h||t.nodeShapes[this.getNodeShape(r)].drawPath(e,c.x,c.y,n,a))),I>0?(this.fillStyle(e,0,0,0,I),h?e.fill(d):e.fill()):0>I&&(this.fillStyle(e,255,255,255,-I),h?e.fill(d):e.fill()),O>0&&(h?e.stroke(d):e.stroke(),"double"===S)){e.lineWidth=s["border-width"].pxValue/3;var z=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",h?e.stroke(d):e.stroke(),e.globalCompositeOperation=z}h&&e.translate(-c.x,-c.y),e.setLineDash&&e.setLineDash([])}}}},r.hasPie=function(e){return e=e[0],e._private.hasPie},r.drawPie=function(r,i,n){i=i[0];var a=i._private,o=a.style,s=o["pie-size"],l=this.getNodeWidth(i),u=this.getNodeHeight(i),c=a.position.x,d=a.position.y,h=Math.min(l,u)/2,p=0,v=t.usePaths();v&&(c=0,d=0),"%"===s.units?h=h*s.value/100:void 0!==s.pxValue&&(h=s.pxValue/2);for(var f=1;f<=e.style.pieBackgroundN;f++){var g=o["pie-"+f+"-background-size"].value,y=o["pie-"+f+"-background-color"].value,m=o["pie-"+f+"-background-opacity"].value*n,x=g/100;x+p>1&&(x=1-p);var b=1.5*Math.PI+2*Math.PI*p,w=2*Math.PI*x,_=b+w;0===g||p>=1||p+x>1||(r.beginPath(),r.moveTo(c,d),r.arc(c,d,h,b,_),r.closePath(),this.fillStyle(r,y[0],y[1],y[2],m),r.fill(),p+=x)}}}(cytoscape),function(e){"use strict";var t=e("renderer","canvas"),r=t,i=t.prototype;i.getPixelRatio=function(){var e=this.data.contexts[0];if(null!=this.forcedPixelRatio)return this.forcedPixelRatio;var t=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return(window.devicePixelRatio||1)/t},i.paintCache=function(e){for(var t,r=this.paintCaches=this.paintCaches||[],i=!0,n=0;n0?(e.shadowBlur=i*o,e.shadowColor="rgba("+t[0]+","+t[1]+","+t[2]+","+r+")",e.shadowOffsetX=n*o,e.shadowOffsetY=a*o):(e.shadowBlur=0,e.shadowColor="transparent"))},i.matchCanvasSize=function(e){var i=this.data,n=e.clientWidth,a=e.clientHeight,o=this.getPixelRatio(),s=this.motionBlurPxRatio;(e===this.data.bufferCanvases[r.MOTIONBLUR_BUFFER_NODE]||e===this.data.bufferCanvases[r.MOTIONBLUR_BUFFER_DRAG])&&(o=s);var l,u=n*o,c=a*o;if(u!==this.canvasWidth||c!==this.canvasHeight){this.fontCaches=null;var d=i.canvasContainer;d.style.width=n+"px",d.style.height=a+"px";for(var h=0;h=o&&(l=i.bufferCanvases[t.TEXTURE_BUFFER],this.textureMult=2,l.width=u*this.textureMult,l.height=c*this.textureMult),this.canvasWidth=u,this.canvasHeight=c}},i.renderTo=function(e,t,r,i){this.redraw({forcedContext:e,forcedZoom:t,forcedPan:r,drawAllLayers:!0,forcedPxRatio:i})},i.timeToRender=function(){return this.redrawTotalTime/this.redrawCount},t.minRedrawLimit=1e3/60,t.maxRedrawLimit=1e3,t.motionBlurDelay=100,i.redraw=function(i){function n(){function i(e,t,r,i,n){var a=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",c.fillStyle(e,255,255,255,c.motionBlurTransparency),e.fillRect(t,r,i,n),e.globalCompositeOperation=a}function n(e,t){var n,s,d,h;/*!r.fullQualityMb &&*/c.clearingMotionBlur||e!==p.bufferContexts[r.MOTIONBLUR_BUFFER_NODE]&&e!==p.bufferContexts[r.MOTIONBLUR_BUFFER_DRAG]?(n=T,s=D,d=c.canvasWidth,h=c.canvasHeight):(n={x:k.x*y,y:k.y*y},s=S*y,d=c.canvasWidth*y,h=c.canvasHeight*y),e.setTransform(1,0,0,1,0,0),"motionBlur"===t?i(e,0,0,d,h):a||void 0!==t&&!t||e.clearRect(0,0,d,h),o||(e.translate(n.x,n.y),e.scale(s,s)),u&&e.translate(u.x,u.y),l&&e.scale(l,l)}function b(e,t){for(var r=e.eles,i=0;i0&&(z.strokeStyle="rgba("+E["selection-box-border-color"].value[0]+","+E["selection-box-border-color"].value[1]+","+E["selection-box-border-color"].value[2]+","+E["selection-box-opacity"].value+")",z.strokeRect(p.select[0],p.select[1],p.select[2]-p.select[0],p.select[3]-p.select[1]))}if(p.bgActivePosistion&&!c.hoverData.selecting){var S=p.cy.zoom(),J=p.bgActivePosistion;z.fillStyle="rgba("+E["active-bg-color"].value[0]+","+E["active-bg-color"].value[1]+","+E["active-bg-color"].value[2]+","+E["active-bg-opacity"].value+")",z.beginPath(),z.arc(J.x,J.y,E["active-bg-size"].pxValue/S,0,2*Math.PI),z.fill()}var Q=c.averageRedrawTime;if(c.showFps&&Q){Q=Math.round(Q);var ee=Math.round(1e3/Q);z.setTransform(1,0,0,1,0,0),z.fillStyle="rgba(255, 0, 0, 0.75)",z.strokeStyle="rgba(255, 0, 0, 0.75)",z.lineWidth=1,z.fillText("1 frame = "+Q+" ms = "+ee+" fps",0,20);var te=60;z.strokeRect(0,30,250,20),z.fillRect(0,30,250*Math.min(ee/te,1),20)}o||(v[r.SELECT_BOX]=!1)}if(g&&1!==y){var re=p.contexts[r.NODE],ie=c.data.bufferCanvases[r.MOTIONBLUR_BUFFER_NODE],ne=p.contexts[r.DRAG],ae=c.data.bufferCanvases[r.MOTIONBLUR_BUFFER_DRAG],oe=function(e,t,r){e.setTransform(1,0,0,1,0,0),r||!w?e.clearRect(0,0,c.canvasWidth,c.canvasHeight):i(e,0,0,c.canvasWidth,c.canvasHeight);var n=y;e.drawImage(t,0,0,c.canvasWidth*n,c.canvasHeight*n,0,0,c.canvasWidth,c.canvasHeight)};(v[r.NODE]||Z[r.NODE])&&(oe(re,ie,Z[r.NODE]),v[r.NODE]=!1),(v[r.DRAG]||Z[r.DRAG])&&(oe(ne,ae,Z[r.DRAG]),v[r.DRAG]=!1)}var se=Date.now();void 0===c.averageRedrawTime&&(c.averageRedrawTime=se-P),void 0===c.redrawCount&&(c.redrawCount=0),c.redrawCount++,void 0===c.redrawTotalTime&&(c.redrawTotalTime=0),c.redrawTotalTime+=se-P,c.lastRedrawTime=se-P,c.averageRedrawTime=c.averageRedrawTime/2+(se-P)/2,c.currentlyDrawing=!1,c.prevViewport=C,c.clearingMotionBlur&&(c.clearingMotionBlur=!1,c.motionBlurCleared=!0,c.motionBlur=!0),g&&(c.motionBlurTimeout=setTimeout(function(){c.motionBlurTimeout=null,c.clearedForMotionBlur[r.NODE]=!1,c.clearedForMotionBlur[r.DRAG]=!1,c.motionBlur=!1,c.clearingMotionBlur=!f,c.mbFrames=0,v[r.NODE]=!0,v[r.DRAG]=!0,c.redraw()},t.motionBlurDelay)),c.drawingImage=!1}i=i||{};var a=i.forcedContext,o=i.drawAllLayers,s=i.drawOnlyNodeLayer,l=i.forcedZoom,u=i.forcedPan,c=this,d=void 0===i.forcedPxRatio?this.getPixelRatio():i.forcedPxRatio,h=c.data.cy,p=c.data,v=p.canvasNeedsRedraw,f=c.textureOnViewport&&!a&&(c.pinching||c.hoverData.dragging||c.swipePanning||c.data.wheelZooming),g=void 0!==i.motionBlur?i.motionBlur:c.motionBlur,y=c.motionBlurPxRatio,m=h.hasCompoundNodes(),x=c.hoverData.draggingEles,b=c.hoverData.selecting||c.touchData.selecting?!0:!1;g=g&&!a&&c.motionBlurEnabled&&!b;var w=g;!a&&c.motionBlurTimeout&&clearTimeout(c.motionBlurTimeout),!a&&this.redrawTimeout&&clearTimeout(this.redrawTimeout),this.redrawTimeout=null,void 0===this.averageRedrawTime&&(this.averageRedrawTime=0);var _=t.minRedrawLimit,E=t.maxRedrawLimit,S=this.averageRedrawTime;S=_>S?_:S,S=E>S?S:E,void 0===this.lastDrawTime&&(this.lastDrawTime=0);var D=Date.now(),k=D-this.lastDrawTime,T=k>=S;if(!a&&!c.clearingMotionBlur){if(!T||this.currentlyDrawing)return void(this.redrawTimeout=setTimeout(function(){c.redraw()},S));this.lastDrawTime=D,this.currentlyDrawing=!0}g&&(null==c.mbFrames&&(c.mbFrames=0),c.drawingImage||c.mbFrames++,c.mbFrames<3&&(w=!1),c.mbFrames>c.minMbLowQualFrames&&(c.motionBlurPxRatio=c.mbPxRBlurry)),c.clearingMotionBlur&&(c.motionBlurPxRatio=1);var P=Date.now();a?n():e.util.requestAnimationFrame(n),a||c.initrender||(c.initrender=!0,h.trigger("initrender")),a||h.triggerOnRender()}}(cytoscape),function(e){"use strict";var t=e("renderer","canvas"),r=t.prototype;r.drawPolygonPath=function(e,t,r,i,n,a){var o=i/2,s=n/2;e.beginPath&&e.beginPath(),e.moveTo(t+o*a[0],r+s*a[1]);for(var l=1;l0&&o>0)if(d.clearRect(0,0,a,o),t.bg&&(d.fillStyle=t.bg,d.rect(0,0,a,o),d.fill()),d.globalCompositeOperation="source-over",t.full)this.redraw({forcedContext:d,drawAllLayers:!0,forcedZoom:s,forcedPan:{x:-n.x1*s,y:-n.y1*s},forcedPxRatio:1});else{var h=i.pan(),p={x:h.x*s,y:h.y*s},v=i.zoom()*s;this.redraw({forcedContext:d,drawAllLayers:!0,forcedZoom:v,forcedPan:p,forcedPxRatio:1})}return c},r.png=function(e){return this.bufferCanvasImage(e).toDataURL("image/png")},r.jpg=function(e){return this.bufferCanvasImage(e).toDataURL("image/jpeg")}}(cytoscape),function(e){"use strict";var t=e("renderer","canvas"),r=t,i=r.prototype;i.registerBinding=function(e,t,r,i){this.bindings.push({target:e,event:t,handler:r,useCapture:i}),e.addEventListener(t,r,i)},i.nodeIsDraggable=function(e){return 0!==e._private.style.opacity.value&&"visible"==e._private.style.visibility.value&&"element"==e._private.style.display.value&&!e.locked()&&e.grabbable()?!0:!1},i.load=function(){var t=this,i=function(e){var r;if(e.addToList&&t.data.cy.hasCompoundNodes()){if(!e.addToList.hasId){e.addToList.hasId={};for(var i=0;is[0]&&i.clientXs[1]&&i.clientY=r.panOrBoxSelectDelay)&&!t.hoverData.selecting&&T>=t.desktopTapThreshold2&&h.panningEnabled()&&h.userPanningEnabled())t.hoverData.dragging=!0,t.hoverData.selecting=!1,t.hoverData.justStartedPan=!0,f[4]=0;else{if(h.boxSelectionEnabled()&&!t.hoverData.dragging&&Math.pow(f[2]-f[0],2)+Math.pow(f[3]-f[1],2)>7&&f[4]&&(clearTimeout(t.bgActiveTimeout),t.data.bgActivePosistion=void 0,t.hoverData.selecting=!0,g[r.SELECT_BOX]=!0,t.redraw()),x&&x.isEdge()&&x.active()&&x.unactivate(),y!=m&&(m&&(m.trigger(new e.Event(i,{type:"mouseout",cyPosition:{x:v[0],y:v[1]}})),m.trigger(new e.Event(i,{type:"tapdragout",cyPosition:{x:v[0],y:v[1]}}))),y&&(y.trigger(new e.Event(i,{type:"mouseover",cyPosition:{x:v[0],y:v[1]}})),y.trigger(new e.Event(i,{type:"tapdragover",cyPosition:{x:v[0],y:v[1]}}))),t.hoverData.last=y),x&&x.isNode()&&t.nodeIsDraggable(x))if(T>=t.desktopTapThreshold2){var N=!t.dragData.didDrag;N&&(g[r.NODE]=!0),t.dragData.didDrag=!0;for(var I=[],O=0;O0&&(p[r.NODE]=!0),t.dragData.possibleDragElements=c=[]),null!=u?u.trigger(new e.Event(i,{type:"mouseup",cyPosition:{x:s[0],y:s[1]}})).trigger(new e.Event(i,{type:"tapend",cyPosition:{x:s[0],y:s[1]}})).trigger(new e.Event(i,{type:"vmouseup",cyPosition:{x:s[0],y:s[1]}})):null==u&&a.trigger(new e.Event(i,{type:"mouseup",cyPosition:{x:s[0],y:s[1]}})).trigger(new e.Event(i,{type:"tapend",cyPosition:{x:s[0],y:s[1]}})).trigger(new e.Event(i,{type:"vmouseup",cyPosition:{x:s[0],y:s[1]}})),t.dragData.didDrag||t.hoverData.dragged||(null!=u?u.trigger(new e.Event(i,{type:"click",cyPosition:{x:s[0],y:s[1]}})).trigger(new e.Event(i,{type:"tap",cyPosition:{x:s[0],y:s[1]}})).trigger(new e.Event(i,{type:"vclick",cyPosition:{x:s[0],y:s[1]}})):null==u&&a.trigger(new e.Event(i,{type:"click",cyPosition:{x:s[0],y:s[1]}})).trigger(new e.Event(i,{type:"tap",cyPosition:{x:s[0],y:s[1]}})).trigger(new e.Event(i,{type:"vclick",cyPosition:{x:s[0],y:s[1]}}))),u!=d||t.dragData.didDrag||null!=u&&u._private.selectable&&(t.hoverData.dragging||("additive"===a.selectionType()||h?u.selected()?u.unselect():u.select():h||(a.$(":selected").unmerge(u).unselect(),u.select())),p[r.NODE]=!0),t.hoverData.selecting&&a.boxSelectionEnabled()&&Math.pow(l[2]-l[0],2)+Math.pow(l[3]-l[1],2)>7&&l[4]){var g=[],y=t.getAllInBox(l[0],l[1],l[2],l[3]);p[r.SELECT_BOX]=!0,y.length>0&&(p[r.NODE]=!0);for(var m=0;m=0&&_>=h&&v>=0&&_>=v&&p>=0&&E>=p&&f>=0&&E>=f;var C=n.pan(),B=n.zoom();g=D(h,p,v,f),y=k(h,p,v,f),m=[(h+v)/2,(p+f)/2],x=[(m[0]-C.x)/B,(m[1]-C.y)/B];var M=200,N=M*M;if(N>y&&!i.touches[2]){var I=t.findNearestElement(l[0],l[1],!0,!0),O=t.findNearestElement(l[2],l[3],!0,!0);return I&&I.isNode()?(I.activate().trigger(new e.Event(i,{type:"cxttapstart",cyPosition:{x:l[0],y:l[1]}})),t.touchData.start=I):O&&O.isNode()?(O.activate().trigger(new e.Event(i,{type:"cxttapstart",cyPosition:{x:l[0],y:l[1]}})),t.touchData.start=O):(n.trigger(new e.Event(i,{type:"cxttapstart",cyPosition:{x:l[0],y:l[1]}})),t.touchData.start=null),t.touchData.start&&(t.touchData.start._private.grabbed=!1),t.touchData.cxt=!0,t.touchData.cxtDragged=!1,t.data.bgActivePosistion=void 0,void t.redraw()}}if(i.touches[2]);else if(i.touches[1]);else if(i.touches[0]){var z=t.findNearestElement(l[0],l[1],!0,!0);if(null!=z){if(z.activate(),t.touchData.start=z,z.isNode()&&t.nodeIsDraggable(z)){var L=t.dragData.touchDragEles=[];if(c[r.NODE]=!0,c[r.DRAG]=!0,z.selected())for(var R=n.$(function(){return this.isNode()&&this.selected()}),V=0;V=q||V>=F){t.touchData.cxt=!1,t.touchData.start&&(t.touchData.start.unactivate(),t.touchData.start=null),t.data.bgActivePosistion=void 0,d[r.SELECT_BOX]=!0;var j=new e.Event(i,{type:"cxttapend",cyPosition:{x:l[0],y:l[1]}});t.touchData.start?t.touchData.start.trigger(j):s.trigger(j)}}if(o&&t.touchData.cxt){var j=new e.Event(i,{type:"cxtdrag",cyPosition:{x:l[0],y:l[1]}});t.data.bgActivePosistion=void 0,d[r.SELECT_BOX]=!0,t.touchData.start?t.touchData.start.trigger(j):s.trigger(j),t.touchData.start&&(t.touchData.start._private.grabbed=!1),t.touchData.cxtDragged=!0;var $=t.findNearestElement(l[0],l[1],!0,!0);t.touchData.cxtOver&&$===t.touchData.cxtOver||(t.touchData.cxtOver&&t.touchData.cxtOver.trigger(new e.Event(i,{type:"cxtdragout",cyPosition:{x:l[0],y:l[1]}})),t.touchData.cxtOver=$,$&&$.trigger(new e.Event(i,{type:"cxtdragover",cyPosition:{x:l[0],y:l[1]}})))}else if(o&&i.touches[2]&&s.boxSelectionEnabled())t.data.bgActivePosistion=void 0,clearTimeout(this.threeFingerSelectTimeout),this.lastThreeTouch=+new Date,t.touchData.selecting=!0,d[r.SELECT_BOX]=!0,n&&0!==n.length&&void 0!==n[0]?(n[2]=(l[0]+l[2]+l[4])/3,n[3]=(l[1]+l[3]+l[5])/3):(n[0]=(l[0]+l[2]+l[4])/3,n[1]=(l[1]+l[3]+l[5])/3,n[2]=(l[0]+l[2]+l[4])/3+1,n[3]=(l[1]+l[3]+l[5])/3+1),n[4]=1,t.touchData.selecting=!0,t.redraw();else if(o&&i.touches[1]&&s.zoomingEnabled()&&s.panningEnabled()&&s.userZoomingEnabled()&&s.userPanningEnabled()){t.data.bgActivePosistion=void 0,d[r.SELECT_BOX]=!0;var W=t.dragData.touchDragEles;if(W){d[r.DRAG]=!0;for(var H=0;H=t.touchTapThreshold2){for(var W=t.dragData.touchDragEles,he=0;he4&&(t.touchData.singleTouchMoved=!0);if(o&&(null==ce||ce.isEdge())&&s.panningEnabled()&&s.userPanningEnabled()){t.swipePanning?s.panBy({x:_[0]*c,y:_[1]*c}):I>=t.touchTapThreshold2&&(t.swipePanning=!0,s.panBy({x:P*c,y:B*c})),ce&&(ce.unactivate(),t.data.bgActivePosistion||(t.data.bgActivePosistion={x:l[0],y:l[1]}),d[r.SELECT_BOX]=!0,t.touchData.start=null);var m=t.projectIntoViewport(i.touches[0].clientX,i.touches[0].clientY);l[0]=m[0],l[1]=m[1]}}for(var E=0;E0?h[r.NODE]=!0:t.redraw()}var b=!1;if(null!=n&&(n._private.active=!1,b=!0,n.unactivate()),i.touches[2])t.data.bgActivePosistion=void 0,h[r.SELECT_BOX]=!0;else if(i.touches[1]);else if(i.touches[0]);else if(!i.touches[0]){t.data.bgActivePosistion=void 0,h[r.SELECT_BOX]=!0;var w=t.dragData.touchDragEles;if(null!=n){var _=n._private.grabbed;o(w),h[r.DRAG]=!0,h[r.NODE]=!0,_&&n.trigger("free"),n.trigger(new e.Event(i,{type:"touchend",cyPosition:{x:c[0],y:c[1]}})).trigger(new e.Event(i,{type:"tapend",cyPosition:{x:c[0],y:c[1]}})).trigger(new e.Event(i,{type:"vmouseup",cyPosition:{x:c[0],y:c[1]}})),n.unactivate(),t.touchData.start=null}else{var E=t.findNearestElement(c[0],c[1],!0,!0);null!=E&&E.trigger(new e.Event(i,{type:"touchend",cyPosition:{x:c[0],y:c[1]}})).trigger(new e.Event(i,{type:"tapend",cyPosition:{x:c[0],y:c[1]}})).trigger(new e.Event(i,{type:"vmouseup",cyPosition:{x:c[0],y:c[1]}})),null==E&&l.trigger(new e.Event(i,{type:"touchend",cyPosition:{x:c[0],y:c[1]}})).trigger(new e.Event(i,{type:"tapend",cyPosition:{x:c[0],y:c[1]}})).trigger(new e.Event(i,{type:"vmouseup",cyPosition:{x:c[0],y:c[1]}}))}var S=t.touchData.startPosition[0]-c[0],D=S*S,k=t.touchData.startPosition[1]-c[1],T=k*k,P=D+T,C=P*u*u;null!=n&&!t.dragData.didDrag&&n._private.selectable&&Cd;d++)h[4*d]=p[2*d],h[4*d+1]=p[2*d+1],h[4*d+2]=v[2*d],h[4*d+3]=v[2*d+1];h=e.math.fitPolygonToSquare(h),t("star",h),t("vee",[-1,-1,0,-.333,1,-1,0,1]),t("rhomboid",[-1,-1,.333,-1,1,1,-.333,1])}(cytoscape),function(e){"use strict";function t(t){this._private={},this._private.options=e.util.extend({},r,t)}var r={animate:!0,maxSimulationTime:4e3,fit:!0,padding:30,boundingBox:void 0,ungrabifyWhileSimulating:!1,ready:void 0,stop:void 0,repulsion:void 0,stiffness:void 0,friction:void 0,gravity:!0,fps:void 0,precision:void 0,nodeMass:void 0,edgeLength:void 0,stepSize:.1,stableEnergy:function(e){var t=e;return t.max<=.5||t.mean<=.3},infinite:!1};t.prototype.run=function(){var t=this,r=this._private.options;return e.util.require("arbor",function(i){function n(e,t){return null==t?void 0:"function"==typeof t?t.apply(e,[e._private.data,{nodes:u.length,edges:c.length,element:e}]):t}function a(e){if(!e.isFullAutoParent()){var t=e._private.data.id,i=n(e,r.nodeMass),a=e._private.locked,o=e.position(),s=p.fromScreen({x:o.x,y:o.y});e.scratch().arbor=p.addNode(t,{element:e,mass:i,fixed:a,x:a&&s?s.x:void 0,y:a&&s?s.y:void 0})}}function o(e){var t=e.source().id(),i=e.target().id(),a=n(e,r.edgeLength);e.scratch().arbor=p.addEdge(t,i,{length:a})}var s=r.cy,l=r.eles,u=l.nodes().not(":parent"),c=l.edges(),d=e.util.makeBoundingBox(r.boundingBox?r.boundingBox:{x1:0,y1:0,w:s.width(),h:s.height()}),h=!1;if(t.trigger({type:"layoutstart",layout:t}),void 0!==r.liveUpdate&&(r.animate=r.liveUpdate),l.nodes().size()<=1)return r.fit&&s.reset(),l.nodes().position({x:Math.round((d.x1+d.x2)/2),y:Math.round((d.y1+d.y2)/2)}),t.one("layoutready",r.ready),t.trigger({type:"layoutready",layout:t}),t.one("layoutstop",r.stop),void t.trigger({type:"layoutstop",layout:t});var p=t._private.system=i.ParticleSystem();p.parameters({repulsion:r.repulsion,stiffness:r.stiffness,friction:r.friction,gravity:r.gravity,fps:r.fps,dt:r.dt,precision:r.precision}),r.animate&&r.fit&&s.fit(d,r.padding);var v,f=250,g=!1,y=+new Date,m={init:function(e){},redraw:function(){var e=p.energy();if(!r.infinite&&null!=r.stableEnergy&&null!=e&&e.n>0&&r.stableEnergy(e))return void t.stop();r.infinite||f==1/0||(clearTimeout(v),v=setTimeout(D,f));var i=s.collection();p.eachNode(function(e,t){var r=e.data,n=r.element;null!=n&&(n.locked()||n.grabbed()||(n.silentPosition({x:d.x1+t.x,y:d.y1+t.y}),i.merge(n)))}),r.animate&&i.length>0&&(h=!0,i.rtrigger("position"),r.fit&&s.fit(r.padding),y=+new Date,h=!1),g||(g=!0,t.one("layoutready",r.ready),t.trigger({type:"layoutready",layout:t}))}};p.renderer=m,p.screenSize(d.w,d.h),p.screenPadding(r.padding,r.padding,r.padding,r.padding),p.screenStep(r.stepSize);var x;u.on("grab free position",x=function(e){if(!h){var t=this.position(),n=p.fromScreen(t);if(n){var a=i.Point(n.x,n.y),o=r.padding;switch(d.x1+o<=t.x&&t.x<=d.x2-o&&d.y1+o<=t.y&&t.y<=d.y2-o&&(this.scratch().arbor.p=a),e.type){case"grab":this.scratch().arbor.fixed=!0;break;case"free":this.scratch().arbor.fixed=!1}}}});var b;u.on("lock unlock",b=function(e){node.scratch().arbor.fixed=node.locked()});var w;l.on("remove",w=function(e){});var _;s.on("add","*",_=function(){});var E;s.on("resize",E=function(){if(null==r.boundingBox&&null!=t._private.system){var e=s.width(),i=s.height();p.screenSize(e,i)}}),u.each(function(e,t){a(t)}),c.each(function(e,t){o(t)});var S=u.filter(":grabbable");r.ungrabifyWhileSimulating&&S.ungrabify();var D=t._private.doneHandler=function(){t._private.doneHandler=null,r.animate||(r.fit&&s.reset(),u.rtrigger("position")),u.off("grab free position",x),u.off("lock unlock",b),l.off("remove",w),s.off("add","*",_),s.off("resize",E),r.ungrabifyWhileSimulating&&S.grabify(),t.one("layoutstop",r.stop),t.trigger({type:"layoutstop",layout:t})};p.start(),!r.infinite&&null!=r.maxSimulationTime&&r.maxSimulationTime>0&&r.maxSimulationTime!==1/0&&setTimeout(function(){t.stop()},r.maxSimulationTime)}),this},t.prototype.stop=function(){return null!=this._private.system&&this._private.system.stop(),this._private.doneHandler&&this._private.doneHandler(),this},e("layout","arbor",t)}(cytoscape),function(e){"use strict";function t(t){this.options=e.util.extend({},r,t)}var r={fit:!0,directed:!1,padding:30,circle:!1,spacingFactor:1.75,boundingBox:void 0,avoidOverlap:!0,roots:void 0,maximalAdjustments:0,animate:!1,animationDuration:500,ready:void 0,stop:void 0};t.prototype.run=function(){var t,r=this.options,i=r,n=r.cy,a=i.eles,o=a.nodes().not(":parent"),s=a,l=e.util.makeBoundingBox(i.boundingBox?i.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()});if(e.is.elementOrCollection(i.roots))t=i.roots;else if(e.is.array(i.roots)){for(var u=[],c=0;c0;){var f=n.collection();a.bfs({roots:v[0],visit:function(e,t,r,i,n){f=f.add(r)},directed:!1}),v=v.not(f),p.push(f)}t=n.collection();for(var c=0;cT;){for(var P=D.shift(),C=P.neighborhood().nodes(),B=!1,c=0;cc;c++)for(var M=x[c],R=M.length,V=0;R>V;V++){var h=M[V],A=h._private.scratch.breadthfirst,X=I(h);X&&(A.intEle=X,L.push(h))}for(var c=0;cx.length-1;)x.push([]);x[Y].push(h),A.depth=Y,A.index=x[Y].length-1}N()}var q=0;if(i.avoidOverlap){for(var c=0;cu||0===t)&&(i+=l/c,n++)}return n=Math.max(1,n),i/=n,0===n&&(i=void 0),W[e.id()]=i,i},Z=function(e,t){var r=H(e),i=H(t);return r-i},U=0;3>U;U++){for(var c=0;c0&&x[0].length<=3?c/2:0),h=2*Math.PI/x[n].length*a;return 0===n&&1===x[0].length&&(d=1),{x:K.x+d*Math.cos(h),y:K.y+d*Math.sin(h)}}return{x:K.x+(a+1-(o+1)/2)*s,y:(n+1)*u}}var p={x:K.x+(a+1-(o+1)/2)*s,y:(n+1)*u};return t?p:p},Q={},c=x.length-1;c>=0;c--)for(var M=x[c],V=0;V1&&r.avoidOverlap){d*=1.75;var c=2*Math.PI/a.length,f=Math.cos(c)-Math.cos(0),g=Math.sin(c)-Math.sin(0),y=Math.sqrt(d*d/(f*f+g*g));o=Math.max(y,o)}var m=function(e,t){var i=o*Math.cos(u),n=o*Math.sin(u),a={x:l.x+i,y:l.y+n};return u=r.counterclockwise?u-c:u+c,a};return a.layoutPositions(this,r,m),this},e("layout","circle",t)}(cytoscape),function(e){"use strict";function t(t){this.options=e.util.extend(!0,{},r,t)}var r={animate:!0,refresh:1,maxSimulationTime:4e3,ungrabifyWhileSimulating:!1,fit:!0,padding:30,boundingBox:void 0,ready:function(){},stop:function(){},randomize:!1,avoidOverlap:!0,handleDisconnected:!0,nodeSpacing:function(e){return 10},flow:void 0,alignment:void 0,edgeLength:void 0,edgeSymDiffLength:void 0,edgeJaccardLength:void 0,unconstrIter:void 0,userConstIter:void 0,allConstIter:void 0,infinite:!1};t.prototype.run=function(){var t=this,r=this.options;return t.manuallyStopped=!1,e.util.require("cola",function(i){var n=r.cy,a=r.eles,o=a.nodes(),s=a.edges(),l=!1,u=e.util.makeBoundingBox(r.boundingBox?r.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()}),c=function(t,r){if(e.is.fn(t)){var i=t;return i.apply(r,[r])}return t},d=function(){for(var t={min:1/0,max:-(1/0)},i={min:1/0,max:-(1/0)},a=0;at&&!e;t++)e=e||i();return e};if(r.animate){var a=function(){n()||e.util.requestAnimationFrame(a)};e.util.requestAnimationFrame(a)}else for(;!i(););},on:function(e,t){},drag:function(){}});t.adaptor=g;var y=o.filter(":grabbable");r.ungrabifyWhileSimulating&&y.ungrabify();var m;o.on("grab free position",m=function(e){var t=this,r=t._private.scratch.cola,i=t._private.position;switch(r.x=i.x-u.x1,r.y=i.y-u.y1,e.type){case"grab":g.dragstart(r),g.resume();break;case"free":g.dragend(r)}});var x;o.on("lock unlock",x=function(e){var t=this,r=t._private.scratch.cola;t.locked()?g.dragstart(r):g.dragend(r)});var b=o.stdFilter(function(e){return!e.isParent()});if(g.nodes(b.map(function(e,t){var i=c(r.nodeSpacing,e),n=e.position(),a=e.boundingBox(),o=e._private.scratch.cola={x:r.randomize||void 0===n.x?Math.round(Math.random()*u.w):n.x,y:r.randomize||void 0===n.y?Math.round(Math.random()*u.h):n.y,width:a.w+2*i,height:a.h+2*i,index:t};return o})),r.alignment){var w=[],_=[];b.forEach(function(e){var t=c(r.alignment,e),i=e._private.scratch.cola,n=i.index;t&&(null!=t.x&&w.push({node:n,offset:t.x}),null!=t.y&&_.push({node:n,offset:t.y}))});var E=[];w.length>0&&E.push({type:"alignment",axis:"x",offsets:w}),_.length>0&&E.push({type:"alignment",axis:"y",offsets:_}),g.constraints(E)}g.groups(o.stdFilter(function(e){return e.isParent()}).map(function(e,t){var i=e._private.style,n=c(r.nodeSpacing,e),a=i["padding-left"].pxValue+n,o=i["padding-right"].pxValue+n,s=i["padding-top"].pxValue+n,l=i["padding-bottom"].pxValue+n;return e._private.scratch.cola={index:t,padding:Math.max(a,o,s,l),leaves:e.descendants().stdFilter(function(e){return!e.isParent()}).map(function(e){return e[0]._private.scratch.cola.index})},e}).map(function(e){return e._private.scratch.cola.groups=e.descendants().stdFilter(function(e){return e.isParent()}).map(function(e){return e._private.scratch.cola.index}),e._private.scratch.cola}));var S,D;null!=r.edgeLength?(S=r.edgeLength,D="linkDistance"):null!=r.edgeSymDiffLength?(S=r.edgeSymDiffLength,D="symmetricDiffLinkLengths"):null!=r.edgeJaccardLength?(S=r.edgeJaccardLength,D="jaccardLinkLengths"):(S=100,D="linkDistance");var k=function(e){return e.calcLength};if(g.links(s.stdFilter(function(e){return!e.source().isParent()&&!e.target().isParent()}).map(function(e,t){var r=e._private.scratch.cola={source:e.source()[0]._private.scratch.cola.index,target:e.target()[0]._private.scratch.cola.index};return null!=S&&(r.calcLength=c(S,e)),r})),g.size([u.w,u.h]),null!=S&&g[D](k),r.flow){var T,P="y",C=50;e.is.string(r.flow)?T={axis:r.flow,minSeparation:C}:e.is.number(r.flow)?T={axis:P,minSeparation:r.flow}:e.is.plainObject(r.flow)?(T=r.flow,T.axis=T.axis||P,T.minSeparation=null!=T.minSeparation?T.minSeparation:C):T={axis:P,minSeparation:C},g.flowLayout(T.axis,T.minSeparation)}t.trigger({type:"layoutstart",layout:t}),g.avoidOverlaps(r.avoidOverlap).handleDisconnected(r.handleDisconnected).start(r.unconstrIter,r.userConstIter,r.allConstIter),r.infinite||setTimeout(function(){t.manuallyStopped||g.stop()},r.maxSimulationTime)}),this},t.prototype.stop=function(){return this.adaptor&&(this.manuallyStopped=!0,this.adaptor.stop()),this},e("layout","cola",t)}(cytoscape),function(e){"use strict";function t(t){this.options=e.util.extend({},r,t)}var r={fit:!0,padding:30,startAngle:1.5*Math.PI, counterclockwise:!1,minNodeSpacing:10,boundingBox:void 0,avoidOverlap:!0,height:void 0,width:void 0,concentric:function(e){return e.degree()},levelWidth:function(e){return e.maxDegree()/4},animate:!1,animationDuration:500,ready:void 0,stop:void 0};t.prototype.run=function(){for(var t=this.options,r=t,i=t.cy,n=r.eles,a=n.nodes().not(":parent"),o=e.util.makeBoundingBox(r.boundingBox?r.boundingBox:{x1:0,y1:0,w:i.width(),h:i.height()}),s={x:o.x1+o.w/2,y:o.y1+o.h/2},l=[],u=r.startAngle,c=0,d=0;d0){var m=Math.abs(g[0].value-y.value);m>=v&&(g=[],f.push(g))}g.push(y)}var x={},b=0,w=c+r.minNodeSpacing;if(!r.avoidOverlap){var _=f.length>0&&f[0].length>1,E=Math.min(o.w,o.h)/2-w,S=E/(f.length+_?1:0);w=Math.min(w,S)}for(var d=0;d1&&r.avoidOverlap){var T=Math.cos(k)-Math.cos(0),P=Math.sin(k)-Math.sin(0),C=Math.sqrt(w*w/(T*T+P*P));b=Math.max(C,b)}for(var B=0;B=d;){var g=c[d++],y=s.idToIndex[g],m=s.layoutNodes[y],x=m.children;if(x.length>0){s.graphSet.push(x);for(var l=0;li.count?0:i.graph},o=function(e,t,r,i){var n=i.graphSet[r];if(-1<$.inArray(e,n)&&-1<$.inArray(t,n))return{count:2,graph:r};for(var a=0,s=0;so;o++)for(var s=e.layoutNodes[e.idToIndex[n[o]]],l=o+1;a>l;l++){var u=e.layoutNodes[e.idToIndex[n[l]]];h(s,u,e,t,r)}},h=function(e,t,r,i,n){var a=t.positionX-e.positionX,o=t.positionY-e.positionY;if(0!==a||0!==o){var s=v(e,t,a,o);if(s>0)var l=n.nodeOverlap*s,u=Math.sqrt(a*a+o*o),c=l*a/u,d=l*o/u;else var h=p(e,a,o),f=p(t,-1*a,-1*o),g=f.x-h.x,y=f.y-h.y,m=g*g+y*y,u=Math.sqrt(m),l=n.nodeRepulsion/m,c=l*g/u,d=l*y/u;e.offsetX-=c,e.offsetY-=d,t.offsetX+=c,t.offsetY+=d}},p=function(e,t,r){var i=e.positionX,n=e.positionY,a=e.height,o=e.width,s=r/t,l=a/o,u={};do{if(0===t&&r>0){u.x=i,u.y=n+a/2;break}if(0===t&&0>r){u.x=i,u.y=n+a/2;break}if(t>0&&s>=-1*l&&l>=s){u.x=i+o/2,u.y=n+o*r/2/t;break}if(0>t&&s>=-1*l&&l>=s){u.x=i-o/2,u.y=n-o*r/2/t;break}if(r>0&&(-1*l>=s||s>=l)){u.x=i+a*t/2/r,u.y=n+a/2;break}if(0>r&&(-1*l>=s||s>=l)){u.x=i-a*t/2/r,u.y=n-a/2;break}}while(!1);return u},v=function(e,t,r,i){if(r>0)var n=e.maxX-t.minX;else var n=t.maxX-e.minX;if(i>0)var a=e.maxY-t.minY;else var a=t.maxY-e.minY;return n>=0&&a>=0?Math.sqrt(n*n+a*a):0},f=function(e,t,r){for(var i=0;ic;c++){var d=e.layoutNodes[e.idToIndex[n[c]]],h=o-d.positionX,p=s-d.positionY,v=Math.sqrt(h*h+p*p);if(v>1){var f=r.gravity*h/v,g=r.gravity*p/v;d.offsetX+=f,d.offsetY+=g}}}},y=function(e,t,r){var i=[],n=0,a=-1;for(i.push.apply(i,e.graphSet[0]),a+=e.graphSet[0].length;a>=n;){var o=i[n++],s=e.idToIndex[o],l=e.layoutNodes[s],u=l.children;if(0r)var n={x:r*e/i,y:r*t/i};else var n={x:e,y:t};return n},b=function(e,t){var r=e.parentId;if(null!=r){var i=t.layoutNodes[t.idToIndex[r]],n=!1;return(null==i.maxX||e.maxX+i.padRight>i.maxX)&&(i.maxX=e.maxX+i.padRight,n=!0),(null==i.minX||e.minX-i.padLefti.maxY)&&(i.maxY=e.maxY+i.padBottom,n=!0),(null==i.minY||e.minY-i.padTops){var p=d(),v=h();(p-1)*v>=s?d(p-1):(v-1)*p>=s&&h(v-1)}else for(;s>c*u;){var p=d(),v=h();(v+1)*p>=s?h(v+1):d(p+1)}var f=o.w/c,g=o.h/u;if(r.avoidOverlap)for(var y=0;y=c&&(D=0,S++)},T={},y=0;ylExpFact&&(lExpFact=Math.max(.05,Math.min(.1,lMinDist/Math.sqrt(lWidth*lHeight/fv.length)*.5)));for(var prevInfractions=checkMinDist(diagram.edges),bStop=0>=prevInfractions,voronoiIteration=0,expandIteration=0;!bStop;){++voronoiIteration;for(var it=0;4>=it;++it){voronoi.recycle(diagram),diagram=voronoi.compute(fv,bbox),cells=diagram.cells;for(var i=0;i=currInfractions?bStop=!0:(currInfractions>=prevInfractions||voronoiIteration>=4)&&(expandIteration>=lMaxExpIt?bStop=!0:(lWidth+=lWidth*lExpFact,lHeight+=lHeight*lExpFact,bbox={xl:0,xr:lWidth,yt:0,yb:lHeight},++expandIteration,voronoiIteration=0)),prevInfractions=currInfractions,savePositions(),messagePositions()}return savePositions(),pData}).then(function(e){var t=e.vertices;setPositions(e);var r=e.startTime,i=new Date;console.info("Layout on "+t.length+" nodes took "+(i-r)+" ms"),layout.one("layoutstop",options.stop),options.animate||layout.trigger("layoutready"),layout.trigger("layoutstop"),t1.stop()})}),this},SpreadLayout.prototype.stop=function(){},$$("layout","spread",SpreadLayout)}(cytoscape),function(e){"use strict";function t(t){this.options=e.util.extend(!0,{},r,t)}var r={animate:!0,maxSimulationTime:4e3,ungrabifyWhileSimulating:!1,fit:!0,padding:30,boundingBox:void 0,random:!1,infinite:!1,ready:void 0,stop:void 0,stiffness:400,repulsion:400,damping:.5};t.prototype.run=function(){var t=this,r=this,i=this.options;return e.util.require("Springy",function(n){function a(e){var t=e.scratch("springy").model.id,r=w.layout.nodePoints[t].p,i=e.position(),n=null!=i.x&&null!=i.y?y(e.position()):{x:4*Math.random()-2,y:4*Math.random()-2};r.x=n.x,r.y=n.y}function o(){r.stopped=!1,i.ungrabifyWhileSimulating&&E.ungrabify(),w.start()}var s=!1,l=i.cy;t.trigger({type:"layoutstart",layout:t});var u=i.eles,c=u.nodes().not(":parent"),d=u.edges(),h=e.util.makeBoundingBox(i.boundingBox?i.boundingBox:{x1:0,y1:0,w:l.width(),h:l.height()}),p=new n.Graph;c.each(function(e,t){t.scratch("springy",{model:p.newNode({element:t})})}),d.each(function(e,t){var r=t.source().scratch("springy").model,i=t.target().scratch("springy").model;t.scratch("springy",{model:p.newEdge(r,i,{element:t})})});var v=window.sim=new n.Layout.ForceDirected(p,i.stiffness,i.repulsion,i.damping);i.infinite&&(v.minEnergyThreshold=-(1/0));var f=v.getBoundingBox(),g=function(e){f=v.getBoundingBox();var t=f.topright.subtract(f.bottomleft),r=e.subtract(f.bottomleft).divide(t.x).x*h.w+h.x1,i=e.subtract(f.bottomleft).divide(t.y).y*h.h+h.x1;return new n.Vector(r,i)},y=function(e){f=v.getBoundingBox();var t=f.topright.subtract(f.bottomleft),r=(e.x-h.x1)/h.w*t.x+f.bottomleft.x,i=(e.y-h.y1)/h.h*t.y+f.bottomleft.y;return new n.Vector(r,i)},m=l.collection(),x=l.nodes().size(),b=1,w=new n.Renderer(v,function(){r.stopped||m.length>0&&i.animate&&(s=!0,m.rtrigger("position"),i.fit&&l.fit(i.padding),m=l.collection(),s=!1)},function(e,t,r){},function(e,n){if(!r.stopped){var a=g(n),o=e.data.element;o.locked()||o.grabbed()||(o._private.position={x:a.x,y:a.y},m.merge(o)),b==x&&(t.one("layoutready",i.ready),t.trigger({type:"layoutready",layout:t})),b++}});c.each(function(e,t){i.random||a(t)});var _;c.on("position",_=function(){s||a(this)});var E=c.filter(":grabbable");r.stopSystem=function(){r.stopped=!0,p.filterNodes(function(){return!1}),i.ungrabifyWhileSimulating&&E.grabify(),i.fit&&l.fit(i.padding),c.off("drag position",_),t.one("layoutstop",i.stop),t.trigger({type:"layoutstop",layout:t}),r.stopSystem=null},o(),i.infinite||setTimeout(function(){r.stop()},i.maxSimulationTime)}),this},t.prototype.stop=function(){return null!=this.stopSystem&&this.stopSystem(),this},e("layout","springy",t)}(cytoscape),function(e){"use strict";function t(e){this.options=e}t.prototype.recalculateRenderedStyle=function(){},t.prototype.notify=function(){},e("renderer","null",t)}(cytoscape);