import{m as e}from"./index-BDq3hoFe.js";function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n=t.length?{done:!0}:{done:!1,value:t[a++]}},"n"),e:e(function(e){throw e},"e"),f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,l=!1;return{s:e(function(){r=r.call(t)},"s"),n:e(function(){var e=r.next();return s=e.done,e},"n"),e:e(function(e){l=!0,o=e},"e"),f:e(function(){try{s||null==r.return||r.return()}finally{if(l)throw o}},"f")}}function l(e,t,n){return(t=v(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e){if(typeof Symbol<"u"&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function c(e,t){var n=null==e?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,i,o,s=[],l=!0,u=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=i.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(e){u=!0,a=e}finally{try{if(!l&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw a}}return s}}function d(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function h(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(e,t){return n(e)||c(e,t)||m(e,t)||d()}function p(e){return r(e)||u(e)||m(e)||h()}function g(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function v(e){var t=g(e,"string");return"symbol"==typeof t?t:t+""}function y(e){return(y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function m(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}e(t,"_arrayLikeToArray"),e(n,"_arrayWithHoles"),e(r,"_arrayWithoutHoles"),e(a,"_classCallCheck"),e(i,"_defineProperties"),e(o,"_createClass"),e(s,"_createForOfIteratorHelper"),e(l,"_defineProperty$1"),e(u,"_iterableToArray"),e(c,"_iterableToArrayLimit"),e(d,"_nonIterableRest"),e(h,"_nonIterableSpread"),e(f,"_slicedToArray"),e(p,"_toConsumableArray"),e(g,"_toPrimitive"),e(v,"_toPropertyKey"),e(y,"_typeof"),e(m,"_unsupportedIterableToArray");var b=typeof window>"u"?null:window,x=b?b.navigator:null;b&&b.document;var w,E,C,T,k,S,P,B,_,D,A,M,R,I,L,N,z,O,F,V,q,j,X,Y,W,H,K,G,U=y(""),Z=y({}),$=y(function(){}),Q=typeof HTMLElement>"u"?"undefined":y(HTMLElement),J=e(function(e){return e&&e.instanceString&&te(e.instanceString)?e.instanceString():null},"instanceStr"),ee=e(function(e){return null!=e&&y(e)==U},"string"),te=e(function(e){return null!=e&&y(e)===$},"fn"),ne=e(function(e){return!le(e)&&(Array.isArray?Array.isArray(e):null!=e&&e instanceof Array)},"array"),re=e(function(e){return null!=e&&y(e)===Z&&!ne(e)&&e.constructor===Object},"plainObject"),ae=e(function(e){return null!=e&&y(e)===Z},"object"),ie=e(function(e){return null!=e&&y(e)===y(1)&&!isNaN(e)},"number"),oe=e(function(e){return ie(e)&&Math.floor(e)===e},"integer"),se=e(function(e){if("undefined"!==Q)return null!=e&&e instanceof HTMLElement},"htmlElement"),le=e(function(e){return ue(e)||ce(e)},"elementOrCollection"),ue=e(function(e){return"collection"===J(e)&&e._private.single},"element"),ce=e(function(e){return"collection"===J(e)&&!e._private.single},"collection"),de=e(function(e){return"core"===J(e)},"core"),he=e(function(e){return"stylesheet"===J(e)},"stylesheet"),fe=e(function(e){return"event"===J(e)},"event"),pe=e(function(e){return null==e||!(""!==e&&!e.match(/^\s+$/))},"emptyString"),ge=e(function(e){return!(typeof HTMLElement>"u")&&e instanceof HTMLElement},"domElement"),ve=e(function(e){return re(e)&&ie(e.x1)&&ie(e.x2)&&ie(e.y1)&&ie(e.y2)},"boundingBox"),ye=e(function(e){return ae(e)&&te(e.then)},"promise"),me=e(function(){return x&&x.userAgent.match(/msie|trident|edge/i)},"ms"),be=e(function(t,n){n||(n=e(function(){if(1===arguments.length)return arguments[0];if(0===arguments.length)return"undefined";for(var e=[],t=0;tt?1:0},"ascending"),Ae=e(function(e,t){return-1*De(e,t)},"descending"),Me=null!=Object.assign?Object.assign.bind(Object):function(e){for(var t=arguments,n=1;n1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}e(c,"hue2rgb");var d=new RegExp("^"+Be+"$").exec(t);if(d){if((r=parseInt(d[1]))<0?r=(360- -1*r%360)%360:r>360&&(r%=360),r/=360,(a=parseFloat(d[2]))<0||a>100||(a/=100,(i=parseFloat(d[3]))<0||i>100)||(i/=100,void 0!==(o=d[4])&&((o=parseFloat(o))<0||o>1)))return;if(0===a)s=l=u=Math.round(255*i);else{var h=i<.5?i*(1+a):i+a-i*a,f=2*i-h;s=Math.round(255*c(f,h,r+1/3)),l=Math.round(255*c(f,h,r)),u=Math.round(255*c(f,h,r-1/3))}n=[s,l,u,o]}return n},"hsl2tuple"),Le=e(function(e){var t,n=new RegExp("^"+Se+"$").exec(e);if(n){t=[];for(var r=[],a=1;a<=3;a++){var i=n[a];if("%"===i[i.length-1]&&(r[a]=!0),i=parseFloat(i),r[a]&&(i=i/100*255),i<0||i>255)return;t.push(Math.floor(i))}var o=r[1]||r[2]||r[3],s=r[1]&&r[2]&&r[3];if(o&&!s)return;var l=n[4];if(void 0!==l){if((l=parseFloat(l))<0||l>1)return;t.push(l)}}return t},"rgb2tuple"),Ne=e(function(e){return Oe[e.toLowerCase()]},"colorname2tuple"),ze=e(function(e){return(ne(e)?e:null)||Ne(e)||Re(e)||Le(e)||Ie(e)},"color2tuple"),Oe={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]},Fe=e(function(e){for(var t=e.map,n=e.keys,r=n.length,a=0;a=s||t<0||y&&e-g>=d}function C(){var e=n();if(E(e))return T(e);f=setTimeout(C,w(e))}function T(e){return f=void 0,m&&u?b(e):(u=c=void 0,h)}function k(){void 0!==f&&clearTimeout(f),g=0,u=p=c=f=void 0}function S(){return void 0===f?h:T(n())}function P(){var e=n(),t=E(e);if(u=arguments,c=this,p=e,t){if(void 0===f)return x(p);if(y)return clearTimeout(f),f=setTimeout(C,s),b(p)}return void 0===f&&(f=setTimeout(C,s)),h}return s=r(s)||0,t(l)&&(v=!!l.leading,d=(y="maxWait"in l)?a(r(l.maxWait)||0,s):d,m="trailing"in l?!!l.trailing:m),e(b,"invokeFunc"),e(x,"leadingEdge"),e(w,"remainingWait"),e(E,"shouldInvoke"),e(C,"timerExpired"),e(T,"trailingEdge"),e(k,"cancel"),e(S,"flush"),e(P,"debounced"),P.cancel=k,P.flush=S,P}return e(o,"debounce"),K=o}e(je,"getDefaultExportFromCjs"),e(Xe,"requireIsObject"),e(Ye,"require_freeGlobal"),e(We,"require_root"),e(He,"requireNow"),e(Ke,"require_trimmedEndIndex"),e(Ge,"require_baseTrim"),e(Ue,"require_Symbol"),e(Ze,"require_getRawTag"),e($e,"require_objectToString"),e(Qe,"require_baseGetTag"),e(Je,"requireIsObjectLike"),e(et,"requireIsSymbol"),e(tt,"requireToNumber"),e(nt,"requireDebounce");var rt=je(nt()),at=b?b.performance:null,it=at&&at.now?function(){return at.now()}:function(){return Date.now()},ot=function(){if(b){if(b.requestAnimationFrame)return function(e){b.requestAnimationFrame(e)};if(b.mozRequestAnimationFrame)return function(e){b.mozRequestAnimationFrame(e)};if(b.webkitRequestAnimationFrame)return function(e){b.webkitRequestAnimationFrame(e)};if(b.msRequestAnimationFrame)return function(e){b.msRequestAnimationFrame(e)}}return function(e){e&&setTimeout(function(){e(it())},1e3/60)}}(),st=e(function(e){return ot(e)},"requestAnimationFrame"),lt=it,ut=9261,ct=5381,dt=e(function(e){for(var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ut;!(t=e.next()).done;)n=65599*n+t.value|0;return n},"hashIterableInts"),ht=e(function(e){return 65599*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:ut)+e|0},"hashInt"),ft=e(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ct;return(t<<5)+t+e|0},"hashIntAlt"),pt=e(function(e,t){return 2097152*e+t},"combineHashes"),gt=e(function(e){return 2097152*e[0]+e[1]},"combineHashesArray"),vt=e(function(e,t){return[ht(e[0],t[0]),ft(e[1],t[1])]},"hashArrays"),yt=e(function(t,n){var r={value:0,done:!1},a=0,i=t.length,o={next:e(function(){return a=0;r--)e[r]===t&&e.splice(r,1)},"removeFromArray"),Xt=e(function(e){e.splice(0,e.length)},"clearArray"),Yt=e(function(e,t){for(var n=0;n"u"?"undefined":y(Set))?Set:Ut,$t=e(function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(void 0!==e&&void 0!==t&&de(e)){var r=t.group;if(null==r&&(r=t.data&&null!=t.data.source&&null!=t.data.target?"edges":"nodes"),"nodes"===r||"edges"===r){this.length=1,this[0]=this;var a=this._private={cy:e,single:!0,data:t.data||{},position:t.position||{x:0,y:0},autoWidth:void 0,autoHeight:void 0,autoPadding:void 0,compoundBoundsClean:!1,listeners:[],group:r,style:{},rstyle:{},styleCxts:[],styleKeys:{},removed:!0,selected:!!t.selected,selectable:void 0===t.selectable||!!t.selectable,locked:!!t.locked,grabbed:!1,grabbable:void 0===t.grabbable||!!t.grabbable,pannable:void 0===t.pannable?"edges"===r:!!t.pannable,active:!1,classes:new Zt,animation:{current:[],queue:[]},rscratch:{},scratch:t.scratch||{},edges:[],children:[],parent:t.parent&&t.parent.isNode()?t.parent:null,traversalCache:{},backgrounding:!1,bbCache:null,bbCacheShift:{x:0,y:0},bodyBounds:null,overlayBounds:null,labelBounds:{all:null,source:null,target:null,main:null},arrowBounds:{source:null,target:null,"mid-source":null,"mid-target":null}};if(null==a.position.x&&(a.position.x=0),null==a.position.y&&(a.position.y=0),t.renderedPosition){var i=t.renderedPosition,o=e.pan(),s=e.zoom();a.position={x:(i.x-o.x)/s,y:(i.y-o.y)/s}}var l=[];ne(t.classes)?l=t.classes:ee(t.classes)&&(l=t.classes.split(/\s+/));for(var u=0,c=l.length;ut?1:0},"defaultCmp"),c=e(function(e,t,n,i,o){var s;if(null==n&&(n=0),null==o&&(o=r),n<0)throw new Error("lo must be non-negative");for(null==i&&(i=e.length);nn;0<=n?t++:t--)u.push(t);return u}.apply(this).reverse()).length;ig;0<=g?++h:--h)v.push(o(e,n));return v},"nsmallest"),g=e(function(e,t,n,a){var i,o,s;for(null==a&&(a=r),i=e[n];n>t&&a(i,o=e[s=n-1>>1])<0;)e[n]=o,n=s;return e[n]=i},"_siftdown"),v=e(function(e,t,n){var a,i,o,s,l;for(null==n&&(n=r),i=e.length,l=t,o=e[t],a=2*t+1;a0;){var E=m.pop(),C=v(E),T=E.id();if(h[T]=C,C!==1/0)for(var k=E.neighborhood().intersect(p),S=0;S0)for(n.unshift(t);d[a];){var i=d[a];n.unshift(i.edge),n.unshift(i.node),a=(r=i.node).id()}return s.spawn(n)},"pathTo")}},"dijkstra")},hn={kruskal:e(function(t){t=t||function(e){return 1};for(var n=this.byGroup(),r=n.nodes,a=n.edges,i=r.length,o=new Array(i),s=r,l=e(function(e){for(var t=0;t0;){if(w(),C++,c===h){for(var T=[],k=i,S=h,P=b[S];T.unshift(k),null!=P&&T.unshift(P),null!=(k=m[S]);)P=b[S=k.id()];return{found:!0,distance:f[c],path:this.spawn(T),steps:C}}g[c]=!0;for(var B=u._private.edges,_=0;_P&&(p[S]=P,m[S]=k,b[S]=w),!i){var B=k*c+T;!i&&p[B]>P&&(p[B]=P,m[B]=T,b[B]=w)}}}for(var _=0;_1&&void 0!==arguments[1]?arguments[1]:o,r=[],a=b(e);;){if(null==a)return n.spawn();var i=m(a),s=i.edge,u=i.pred;if(r.unshift(a[0]),a.same(t)&&r.length>0)break;null!=s&&r.unshift(s),a=u}return l.spawn(r)},"pathTo"),E=0;E=0;u--){var c=l[u],d=c[1],h=c[2];(t[d]===o&&t[h]===s||t[d]===s&&t[h]===o)&&l.splice(u,1)}for(var f=0;fr;){var a=Math.floor(Math.random()*t.length);t=xn(a,e,t),n--}return t},"contractUntil"),En={kargerStein:e(function(){var t=this,n=this.byGroup(),r=n.nodes,a=n.edges;a.unmergeBy(function(e){return e.isLoop()});var i=r.length,o=a.length,s=Math.ceil(Math.pow(Math.log(i)/Math.LN2,2)),l=Math.floor(i/bn);if(!(i<2)){for(var u=[],c=0;c1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=1/0,a=t;a1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=-1/0,a=t;a1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=0,a=0,i=t;i1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],a=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];!(arguments.length>3&&void 0!==arguments[3])||arguments[3]?e=e.slice(t,n):(n0&&e.splice(0,t));for(var i=0,o=e.length-1;o>=0;o--){var s=e[o];a?isFinite(s)||(e[o]=-1/0,i++):e.splice(o,1)}r&&e.sort(function(e,t){return e-t});var l=e.length,u=Math.floor(l/2);return l%2!=0?e[u+1+i]:(e[u-1+i]+e[u+i])/2},"median"),An=e(function(e){return Math.PI*e/180},"deg2rad"),Mn=e(function(e,t){return Math.atan2(t,e)-Math.PI/2},"getAngleFromDisp"),Rn=Math.log2||function(e){return Math.log(e)/Math.log(2)},In=e(function(e){return e>0?1:e<0?-1:0},"signum"),Ln=e(function(e,t){return Math.sqrt(Nn(e,t))},"dist"),Nn=e(function(e,t){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r},"sqdist"),zn=e(function(e){for(var t=e.length,n=0,r=0;r=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}}},"makeBoundingBox"),Xn=e(function(e){return{x1:e.x1,x2:e.x2,w:e.w,y1:e.y1,y2:e.y2,h:e.h}},"copyBoundingBox"),Yn=e(function(e){e.x1=1/0,e.y1=1/0,e.x2=-1/0,e.y2=-1/0,e.w=0,e.h=0},"clearBoundingBox"),Wn=e(function(e,t){e.x1=Math.min(e.x1,t.x1),e.x2=Math.max(e.x2,t.x2),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,t.y1),e.y2=Math.max(e.y2,t.y2),e.h=e.y2-e.y1},"updateBoundingBox"),Hn=e(function(e,t,n){e.x1=Math.min(e.x1,t),e.x2=Math.max(e.x2,t),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,n),e.y2=Math.max(e.y2,n),e.h=e.y2-e.y1},"expandBoundingBoxByPoint"),Kn=e(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e.x1-=t,e.x2+=t,e.y1-=t,e.y2+=t,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},"expandBoundingBox"),Gn=e(function(e){var t,n,r,a,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0];if(1===i.length)t=n=r=a=i[0];else if(2===i.length)t=r=i[0],a=n=i[1];else if(4===i.length){var o=f(i,4);t=o[0],n=o[1],r=o[2],a=o[3]}return e.x1-=a,e.x2+=n,e.y1-=t,e.y2+=r,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},"expandBoundingBoxSides"),Un=e(function(e,t){e.x1=t.x1,e.y1=t.y1,e.x2=t.x2,e.y2=t.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1},"assignBoundingBox"),Zn=e(function(e,t){return!(e.x1>t.x2||t.x1>e.x2||e.x2t.y2||t.y1>e.y2)},"boundingBoxesIntersect"),$n=e(function(e,t,n){return e.x1<=t&&t<=e.x2&&e.y1<=n&&n<=e.y2},"inBoundingBox"),Qn=e(function(e,t){return $n(e,t.x,t.y)},"pointInBoundingBox"),Jn=e(function(e,t){return $n(e,t.x1,t.y1)&&$n(e,t.x2,t.y2)},"boundingBoxInBoundingBox"),er=null!==(ln=Math.hypot)&&void 0!==ln?ln:function(e,t){return Math.sqrt(e*e+t*t)};function tr(t,n){if(t.length<3)throw new Error("Need at least 3 vertices");var r=e(function(e,t){return{x:e.x+t.x,y:e.y+t.y}},"add"),a=e(function(e,t){return{x:e.x-t.x,y:e.y-t.y}},"sub"),i=e(function(e,t){return{x:e.x*t,y:e.y*t}},"scale"),o=e(function(e,t){return e.x*t.y-e.y*t.x},"cross"),s=e(function(e){var t=er(e.x,e.y);return 0===t?{x:0,y:0}:{x:e.x/t,y:e.y/t}},"normalize"),l=e(function(e){for(var t=0,n=0;n7&&void 0!==arguments[7]?arguments[7]:"auto",c="auto"===u?Pr(a,i):u,d=a/2,h=i/2,f=(c=Math.min(c,d,h))!==d,p=c!==h;if(f){var g=r-h-o;if((s=br(e,t,n,r,n-d+c-o,g,n+d-c+o,g,!1)).length>0)return s}if(p){var v=n+d+o;if((s=br(e,t,n,r,v,r-h+c-o,v,r+h-c+o,!1)).length>0)return s}if(f){var y=r+h+o;if((s=br(e,t,n,r,n-d+c-o,y,n+d-c+o,y,!1)).length>0)return s}if(p){var m=n-d-o;if((s=br(e,t,n,r,m,r-h+c-o,m,r+h-c+o,!1)).length>0)return s}var b=n-d+c,x=r-h+c;if((l=yr(e,t,n,r,b,x,c+o)).length>0&&l[0]<=b&&l[1]<=x)return[l[0],l[1]];var w=n+d-c,E=r-h+c;if((l=yr(e,t,n,r,w,E,c+o)).length>0&&l[0]>=w&&l[1]<=E)return[l[0],l[1]];var C=n+d-c,T=r+h-c;if((l=yr(e,t,n,r,C,T,c+o)).length>0&&l[0]>=C&&l[1]>=T)return[l[0],l[1]];var k=n-d+c,S=r+h-c;return(l=yr(e,t,n,r,k,S,c+o)).length>0&&l[0]<=k&&l[1]>=S?[l[0],l[1]]:[]},"roundRectangleIntersectLine"),ar=e(function(e,t,n,r,a,i,o){var s=o,l=Math.min(n,a),u=Math.max(n,a),c=Math.min(r,i),d=Math.max(r,i);return l-s<=e&&e<=u+s&&c-s<=t&&t<=d+s},"inLineVicinity"),ir=e(function(e,t,n,r,a,i,o,s,l){var u=Math.min(n,o,a)-l,c=Math.max(n,o,a)+l,d=Math.min(r,s,i)-l,h=Math.max(r,s,i)+l;return!(ec||th)},"inBezierVicinity"),or=e(function(e,t,n,r){var a=t*t-4*e*(n-=r);if(a<0)return[];var i=Math.sqrt(a),o=2*e;return[(-t+i)/o,(-t-i)/o]},"solveQuadratic"),sr=e(function(e,t,n,r,a){var i,o,s,l,u,c,d,h;return 0===e&&(e=1e-5),s=-27*(r/=e)+(t/=e)*(9*(n/=e)-t*t*2),i=(o=(3*n-t*t)/9)*o*o+(s/=54)*s,a[1]=0,d=t/3,i>0?(u=(u=s+Math.sqrt(i))<0?-Math.pow(-u,1/3):Math.pow(u,1/3),c=(c=s-Math.sqrt(i))<0?-Math.pow(-c,1/3):Math.pow(c,1/3),a[0]=-d+u+c,d+=(u+c)/2,a[4]=a[2]=-d,d=Math.sqrt(3)*(-c+u)/2,a[3]=d,void(a[5]=-d)):(a[5]=a[3]=0,0===i?(h=s<0?-Math.pow(-s,1/3):Math.pow(s,1/3),a[0]=2*h-d,void(a[4]=a[2]=-(h+d))):(l=(o=-o)*o*o,l=Math.acos(s/Math.sqrt(l)),h=2*Math.sqrt(o),a[0]=-d+h*Math.cos(l/3),a[2]=-d+h*Math.cos((l+2*Math.PI)/3),void(a[4]=-d+h*Math.cos((l+4*Math.PI)/3))))},"solveCubic"),lr=e(function(e,t,n,r,a,i,o,s){var l=[];sr(1*n*n-4*n*a+2*n*o+4*a*a-4*a*o+o*o+r*r-4*r*i+2*r*s+4*i*i-4*i*s+s*s,9*n*a-3*n*n-3*n*o-6*a*a+3*a*o+9*r*i-3*r*r-3*r*s-6*i*i+3*i*s,3*n*n-6*n*a+n*o-n*e+2*a*a+2*a*e-o*e+3*r*r-6*r*i+r*s-r*t+2*i*i+2*i*t-s*t,1*n*a-n*n+n*e-a*e+r*i-r*r+r*t-i*t,l);for(var u=[],c=0;c<6;c+=2)Math.abs(l[c+1])<1e-7&&l[c]>=0&&l[c]<=1&&u.push(l[c]);u.push(1),u.push(0);for(var d,h,f,p=-1,g=0;g=0?fl?(e-a)*(e-a)+(t-i)*(t-i):u-d},"sqdistToFiniteLine"),cr=e(function(e,t,n){for(var r,a,i,o,s=0,l=0;l=e&&e>=i||r<=e&&e<=i))continue;(e-r)/(i-r)*(o-a)+a>t&&s++}return s%2!=0},"pointInsidePolygonPoints"),dr=e(function(e,t,n,r,a,i,o,s,l){var u,c,d=new Array(n.length);null!=s[0]?(u=Math.atan(s[1]/s[0]),s[0]<0?u+=Math.PI/2:u=-u-Math.PI/2):u=s;for(var h=Math.cos(-u),f=Math.sin(-u),p=0;p0){var g=pr(d,-l);c=fr(g)}else c=d;return cr(e,t,c)},"pointInsidePolygon"),hr=e(function(e,t,n,r,a,i,o,s){for(var l=new Array(2*n.length),u=0;u=0&&p<=1&&v.push(p),g>=0&&g<=1&&v.push(g),0===v.length)return[];var y=v[0]*s[0]+e,m=v[0]*s[1]+t;return v.length>1?v[0]==v[1]?[y,m]:[y,m,v[1]*s[0]+e,v[1]*s[1]+t]:[y,m]},"intersectLineCircle"),mr=e(function(e,t,n){return t<=e&&e<=n||n<=e&&e<=t?e:e<=t&&t<=n||n<=t&&t<=e?t:n},"midOfThree"),br=e(function(e,t,n,r,a,i,o,s,l){var u=e-a,c=n-e,d=o-a,h=t-i,f=r-t,p=s-i,g=d*h-p*u,v=c*h-f*u,y=p*c-d*f;if(0!==y){var m=g/y,b=v/y,x=-.001;return x<=m&&m<=1.001&&x<=b&&b<=1.001||l?[e+m*c,t+m*f]:[]}return 0===g||0===v?mr(e,n,o)===o?[o,s]:mr(e,n,a)===a?[a,i]:mr(a,o,n)===n?[n,r]:[]:[]},"finiteLinesIntersect"),xr=e(function(e,t,n,r,a){var i=[],o=r/2,s=a/2,l=t,u=n;i.push({x:l+o*e[0],y:u+s*e[1]});for(var c=1;c0){var p=pr(d,-s);u=fr(p)}else u=d}else u=n;for(var g,v,y,m,b=0;b2){for(var f=[c[0],c[1]],p=Math.pow(f[0]-e,2)+Math.pow(f[1]-t,2),g=1;gc&&(c=t)},"set"),get:e(function(e){return u[e]},"get")},h=0;h0?m.edgesTo(y)[0]:y.edgesTo(m)[0];var x=a(b);y=y.id(),u[y]>u[p]+x&&(u[y]=u[p]+x,c.nodes.indexOf(y)<0?c.push(y):c.updateItem(y),r[y]=0,n[y]=[]),u[y]==u[p]+x&&(r[y]=r[y]+r[p],n[y].push(p))}else for(var w=0;w0;){for(var k=t.pop(),S=0;S0&&o.push(n[s]);0!==o.length&&a.push(r.collection(o))}return a},"assign"),$r=e(function(e,t){for(var n=0;n5&&void 0!==arguments[5]?arguments[5]:ta,o=r,s=0;s=2?sa(e,t,n,0,aa,ia):sa(e,t,n,0,ra)},"euclidean"),squaredEuclidean:e(function(e,t,n){return sa(e,t,n,0,aa)},"squaredEuclidean"),manhattan:e(function(e,t,n){return sa(e,t,n,0,ra)},"manhattan"),max:e(function(e,t,n){return sa(e,t,n,-1/0,oa)},"max")};function ua(e,t,n,r,a,i){var o;return o=te(e)?e:la[e]||la.euclidean,0===t&&te(e)?o(a,i):o(t,n,r,a,i)}la["squared-euclidean"]=la.squaredEuclidean,la.squaredeuclidean=la.squaredEuclidean,e(ua,"clusteringDistance");var ca=qt({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),da=e(function(e){return ca(e)},"setOptions"),ha=e(function(t,n,r,a,i){var o="kMedoids"!==i?function(e){return r[e]}:function(e){return a[e](r)},s=e(function(e){return a[e](n)},"getQ"),l=r,u=n;return ua(t,a.length,o,s,l,u)},"getDist"),fa=e(function(e,t,n){for(var r=n.length,a=new Array(r),i=new Array(r),o=new Array(t),s=null,l=0;ln)return!1}return!0},"haveMatricesConverged"),ma=e(function(e,t,n){for(var r=0;ro&&(o=t[l][u],s=u);a[s].push(e[l])}for(var c=0;c=i.threshold||"dendrogram"===i.mode&&1===t.length)return!1;var p,g=n[s],v=n[a[s]];p="dendrogram"===i.mode?{left:g,right:v,key:g.key}:{value:g.value.concat(v.value),key:g.key},t[g.index]=p,t.splice(v.index,1),n[g.key]=p;for(var y=0;yr[v.key][m.key]&&(o=r[v.key][m.key])):"max"===i.linkage?(o=r[g.key][m.key],r[g.key][m.key]0&&r.push(a);return r},"findExemplars"),ja=e(function(e,t,n){for(var r=[],a=0;ao&&(i=l,o=t[a*e+l])}i>0&&r.push(i)}for(var u=0;ul&&(s=u,l=c)}n[a]=i[s]}return r=ja(e,t,n)},"assign"),Ya=e(function(e){for(var t=this.cy(),n=this.nodes(),r=Oa(e),a={},i=0;i=S?(P=S,S=_,B=D):_>P&&(P=_);for(var A=0;A0?1:0;C[h%r.minIterations*o+z]=O,N+=O}if(N>0&&(h>=r.minIterations-1||h==r.maxIterations-1)){for(var F=0,V=0;V1||o>1)&&(c=!0),d[t]=[],e.outgoers().forEach(function(e){e.isEdge()&&d[t].push(e.id())})}else h[t]=[void 0,e.target().id()]}):u.forEach(function(e){var t=e.id();e.isNode()?(e.degree(!0)%2&&(r?a?c=!0:a=t:r=t),d[t]=[],e.connectedEdges().forEach(function(e){return d[t].push(e.id())})):h[t]=[e.source().id(),e.target().id()]});var f={found:!1,trail:void 0};if(c)return f;if(a&&r)if(l){if(i&&a!=i)return f;i=a}else{if(i&&a!=i&&r!=i)return f;i||(i=a)}else i||(i=u[0].id());var p=e(function(e){for(var t,n,r,a=e,i=[e];d[a].length;)t=d[a].shift(),n=h[t][0],a!=(r=h[t][1])?(d[r]=d[r].filter(function(e){return e!=t}),a=r):!l&&a!=n&&(d[n]=d[n].filter(function(e){return e!=t}),a=n),i.unshift(t),i.unshift(a);return i},"walk"),g=[],v=[];for(v=p(i);1!=v.length;)0==d[v[0]].length?(g.unshift(u.getElementById(v.shift())),g.unshift(u.getElementById(v.shift()))):v=p(v.shift()).concat(v);for(var y in g.unshift(u.getElementById(v.shift())),d)if(d[y].length)return f;return f.found=!0,f.trail=this.spawn(g,!0),f},"hierholzer")},Ga=e(function(){var t=this,n={},r=0,a=0,i=[],o=[],s={},l=e(function(e,r){for(var a=o.length-1,s=[],l=t.spawn();o[a].x!=e||o[a].y!=r;)s.push(o.pop().edge),a--;s.push(o.pop().edge),s.forEach(function(e){var r=e.connectedNodes().intersection(t);l.merge(e),r.forEach(function(e){var r=e.id(),a=e.connectedEdges().intersection(t);l.merge(e),n[r].cutVertex?l.merge(a.filter(function(e){return e.isLoop()})):l.merge(a)})}),i.push(l)},"buildComponent"),u=e(function(e,c,d){e===d&&(a+=1),n[c]={id:r,low:r++,cutVertex:!1};var h,f,p,g,v=t.getElementById(c).connectedEdges().intersection(t);0===v.size()?i.push(t.spawn(t.getElementById(c))):v.forEach(function(t){h=t.source().id(),f=t.target().id(),(p=h===c?f:h)!==d&&(g=t.id(),s[g]||(s[g]=!0,o.push({x:c,y:p,edge:t})),p in n?n[c].low=Math.min(n[c].low,n[p].id):(u(e,p,c),n[c].low=Math.min(n[c].low,n[p].low),n[c].id<=n[p].low&&(n[c].cutVertex=!0,l(c,p))))})},"biconnectedSearch");t.forEach(function(e){if(e.isNode()){var t=e.id();t in n||(a=0,u(t,t),n[t].cutVertex=a>1)}});var c=Object.keys(n).filter(function(e){return n[e].cutVertex}).map(function(e){return t.getElementById(e)});return{cut:t.spawn(c),components:i}},"hopcroftTarjanBiconnected"),Ua={hopcroftTarjanBiconnected:Ga,htbc:Ga,htb:Ga,hopcroftTarjanBiconnectedComponents:Ga},Za=e(function(){var t=this,n={},r=0,a=[],i=[],o=t.spawn(t),s=e(function(e){if(i.push(e),n[e]={index:r,low:r++,explored:!1},t.getElementById(e).connectedEdges().intersection(t).forEach(function(t){var r=t.target().id();r!==e&&(r in n||s(r),n[r].explored||(n[e].low=Math.min(n[e].low,n[r].low)))}),n[e].index===n[e].low){for(var l=t.spawn();;){var u=i.pop();if(l.merge(t.getElementById(u)),n[u].low=n[e].index,n[u].explored=!0,u===e)break}var c=l.edgesWith(l),d=l.merge(c);a.push(d),o=o.difference(d)}},"stronglyConnectedSearch");return t.forEach(function(e){if(e.isNode()){var t=e.id();t in n||s(t)}}),{cut:o,components:a}},"tarjanStronglyConnected"),$a={};[Jt,dn,hn,pn,vn,mn,En,Ir,Nr,Or,Vr,ea,Pa,Na,Wa,Ka,Ua,{tarjanStronglyConnected:Za,tsc:Za,tscc:Za,tarjanStronglyConnectedComponents:Za}].forEach(function(e){Me($a,e)});var Qa=e(function(e){if(!(this instanceof Qa))return new Qa(e);this.id="Thenable/1.0.7",this.state=0,this.fulfillValue=void 0,this.rejectReason=void 0,this.onFulfilled=[],this.onRejected=[],this.proxy={then:this.then.bind(this)},"function"==typeof e&&e.call(this,this.fulfill.bind(this),this.reject.bind(this))},"api");Qa.prototype={fulfill:e(function(e){return Ja(this,1,"fulfillValue",e)},"fulfill"),reject:e(function(e){return Ja(this,2,"rejectReason",e)},"reject"),then:e(function(e,t){var n=this,r=new Qa;return n.onFulfilled.push(ni(e,r,"fulfill")),n.onRejected.push(ni(t,r,"reject")),ei(n),r.proxy},"then")};var Ja=e(function(e,t,n,r){return 0===e.state&&(e.state=t,e[n]=r,ei(e)),e},"deliver"),ei=e(function(e){1===e.state?ti(e,"onFulfilled",e.fulfillValue):2===e.state&&ti(e,"onRejected",e.rejectReason)},"execute"),ti=e(function(t,n,r){if(0!==t[n].length){var a=t[n];t[n]=[];var i=e(function(){for(var e=0;e0:void 0},"animatedImpl")},"animated"),clearQueue:e(function(){return e(function(){var e=this,t=void 0!==e.length?e:[e];if(!(this._private.cy||this).styleEnabled())return this;for(var n=0;n-1}return e(n,"listCacheHas"),Ui=n}function us(){if(Qi)return $i;Qi=1;var t=is();function n(e,n){var r=this.__data__,a=t(r,e);return a<0?(++this.size,r.push([e,n])):r[a][1]=n,this}return e(n,"listCacheSet"),$i=n}function cs(){if(eo)return Ji;eo=1;var t=rs(),n=os(),r=ss(),a=ls(),i=us();function o(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t-1&&e%1==0&&e0&&this.spawn(r).updateStyle().emit("class"),t},"classes"),addClass:e(function(e){return this.toggleClass(e,!0)},"addClass"),hasClass:e(function(e){var t=this[0];return null!=t&&t._private.classes.has(e)},"hasClass"),toggleClass:e(function(e,t){ne(e)||(e=e.match(/\S+/g)||[]);for(var n=this,r=void 0===t,a=[],i=0,o=n.length;i0&&this.spawn(a).updateStyle().emit("class"),n},"toggleClass"),removeClass:e(function(e){return this.toggleClass(e,!1)},"removeClass"),flashClass:e(function(e,t){var n=this;if(null==t)t=250;else if(0===t)return n;return n.addClass(e),setTimeout(function(){n.removeClass(e)},t),n},"flashClass")};sl.className=sl.classNames=sl.classes;var ll={metaChar:"[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",boolOp:"\\?|\\!|\\^",string:"\"(?:\\\\\"|[^\"])*\"|'(?:\\\\'|[^'])*'",number:ke,meta:"degree|indegree|outdegree",separator:"\\s*,\\s*",descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$",group:"node|edge|\\*",directedEdge:"\\s+->\\s+",undirectedEdge:"\\s+<->\\s+"};ll.variable="(?:[\\w-.]|(?:\\\\"+ll.metaChar+"))+",ll.className="(?:[\\w-]|(?:\\\\"+ll.metaChar+"))+",ll.value=ll.string+"|"+ll.number,ll.id=ll.variable,function(){var e,t,n;for(e=ll.comparatorOp.split("|"),n=0;n=0)&&"="!==t&&(ll.comparatorOp+="|\\!"+t)}();var ul=e(function(){return{checks:[]}},"newQuery"),cl=0,dl=1,hl=2,fl=3,pl=4,gl=5,vl=6,yl=7,ml=8,bl=9,xl=10,wl=11,El=12,Cl=13,Tl=14,kl=15,Sl=16,Pl=17,Bl=18,_l=19,Dl=20,Al=[{selector:":selected",matches:e(function(e){return e.selected()},"matches")},{selector:":unselected",matches:e(function(e){return!e.selected()},"matches")},{selector:":selectable",matches:e(function(e){return e.selectable()},"matches")},{selector:":unselectable",matches:e(function(e){return!e.selectable()},"matches")},{selector:":locked",matches:e(function(e){return e.locked()},"matches")},{selector:":unlocked",matches:e(function(e){return!e.locked()},"matches")},{selector:":visible",matches:e(function(e){return e.visible()},"matches")},{selector:":hidden",matches:e(function(e){return!e.visible()},"matches")},{selector:":transparent",matches:e(function(e){return e.transparent()},"matches")},{selector:":grabbed",matches:e(function(e){return e.grabbed()},"matches")},{selector:":free",matches:e(function(e){return!e.grabbed()},"matches")},{selector:":removed",matches:e(function(e){return e.removed()},"matches")},{selector:":inside",matches:e(function(e){return!e.removed()},"matches")},{selector:":grabbable",matches:e(function(e){return e.grabbable()},"matches")},{selector:":ungrabbable",matches:e(function(e){return!e.grabbable()},"matches")},{selector:":animated",matches:e(function(e){return e.animated()},"matches")},{selector:":unanimated",matches:e(function(e){return!e.animated()},"matches")},{selector:":parent",matches:e(function(e){return e.isParent()},"matches")},{selector:":childless",matches:e(function(e){return e.isChildless()},"matches")},{selector:":child",matches:e(function(e){return e.isChild()},"matches")},{selector:":orphan",matches:e(function(e){return e.isOrphan()},"matches")},{selector:":nonorphan",matches:e(function(e){return e.isChild()},"matches")},{selector:":compound",matches:e(function(e){return e.isNode()?e.isParent():e.source().isParent()||e.target().isParent()},"matches")},{selector:":loop",matches:e(function(e){return e.isLoop()},"matches")},{selector:":simple",matches:e(function(e){return e.isSimple()},"matches")},{selector:":active",matches:e(function(e){return e.active()},"matches")},{selector:":inactive",matches:e(function(e){return!e.active()},"matches")},{selector:":backgrounding",matches:e(function(e){return e.backgrounding()},"matches")},{selector:":nonbackgrounding",matches:e(function(e){return!e.backgrounding()},"matches")}].sort(function(e,t){return Ae(e.selector,t.selector)}),Ml=function(){for(var e,t={},n=0;n0&&u.edgeCount>0)return It("The selector `"+e+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(u.edgeCount>1)return It("The selector `"+e+"` is invalid because it uses multiple edge selectors"),!1;1===u.edgeCount&&It("The selector `"+e+"` is deprecated. Edge selectors do not take effect on changes to source and target nodes after an edge is added, for performance reasons. Use a class or data selector on edges instead, updating the class or data of an edge when your app detects a change in source or target nodes.")}return!0},"parse"),toString:e(function(){if(null!=this.toStringCache)return this.toStringCache;for(var t=e(function(e){return e??""},"clean"),n=e(function(e){return ee(e)?'"'+e+'"':t(e)},"cleanVal"),r=e(function(e){return" "+e+" "},"space"),a=e(function(e,a){var o=e.type,s=e.value;switch(o){case cl:var l=t(s);return l.substring(0,l.length-1);case fl:var u=e.field,c=e.operator;return"["+u+r(t(c))+n(s)+"]";case gl:var d=e.operator,h=e.field;return"["+t(d)+h+"]";case pl:return"["+e.field+"]";case vl:var f=e.operator;return"[["+e.field+r(t(f))+n(s)+"]]";case yl:return s;case ml:return"#"+s;case bl:return"."+s;case Pl:case kl:return i(e.parent,a)+r(">")+i(e.child,a);case Bl:case Sl:return i(e.ancestor,a)+" "+i(e.descendant,a);case _l:var p=i(e.left,a),g=i(e.subject,a),v=i(e.right,a);return p+(p.length>0?" ":"")+g+v;case Dl:return""}},"checkToString"),i=e(function(e,t){return e.checks.reduce(function(n,r,i){return n+(t===e&&0===i?"$":"")+a(r,t)},"")},"queryToString"),o="",s=0;s1&&s=0&&(t=t.replace("!",""),c=!0),t.indexOf("@")>=0&&(t=t.replace("@",""),u=!0),(o||l||u)&&(a=o||s?""+e:"",i=""+n),u&&(e=a=a.toLowerCase(),n=i=i.toLowerCase()),t){case"*=":r=a.indexOf(i)>=0;break;case"$=":r=a.indexOf(i,a.length-i.length)>=0;break;case"^=":r=0===a.indexOf(i);break;case"=":r=e===n;break;case">":d=!0,r=e>n;break;case">=":d=!0,r=e>=n;break;case"<":d=!0,r=e0;){var u=a.shift();t(u),i.add(u.id()),o&&r(a,i,u)}return e}function au(e,t,n){if(n.isParent())for(var r=n._private.children,a=0;a1&&void 0!==arguments[1])||arguments[1],au)},e(iu,"addParent"),nu.forEachUp=function(e){return ru(this,e,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],iu)},e(ou,"addParentAndChildren"),nu.forEachUpAndDown=function(e){return ru(this,e,!(arguments.length>1&&void 0!==arguments[1])||arguments[1],ou)},nu.ancestors=nu.parents,(Jl=eu={data:il.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),removeData:il.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:il.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:il.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),rscratch:il.data({field:"rscratch",allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:il.removeData({field:"rscratch",triggerEvent:!1}),id:e(function(){var e=this[0];if(e)return e._private.data.id},"id")}).attr=Jl.data,Jl.removeAttr=Jl.removeData;var su=eu,lu={};function uu(e){return function(t){var n=this;if(void 0===t&&(t=!0),0===n.length);else if(n.isNode()&&!n.removed()){for(var r=0,a=n[0],i=a._private.edges,o=0;ot}),minIndegree:cu("indegree",function(e,t){return et}),minOutdegree:cu("outdegree",function(e,t){return et})}),Me(lu,{totalDegree:e(function(e){for(var t=0,n=this.nodes(),r=0;r0,c=u;u&&(l=l[0]);var d=c?l.position():{x:0,y:0};return a={x:s.x-d.x,y:s.y-d.y},void 0===e?a:a[e]}for(var h=0;h0,v=g;g&&(p=p[0]);var y=v?p.position():{x:0,y:0};void 0!==t?f.position(e,t+y[e]):void 0!==a&&f.position({x:a.x+y.x,y:a.y+y.y})}}else if(!i)return;return this},"relativePosition")}).modelPosition=du.point=du.position,du.modelPositions=du.points=du.positions,du.renderedPoint=du.renderedPosition,du.relativePoint=du.relativePosition;var gu,vu,yu=hu;gu=vu={},vu.renderedBoundingBox=function(e){var t=this.boundingBox(e),n=this.cy(),r=n.zoom(),a=n.pan(),i=t.x1*r+a.x,o=t.x2*r+a.x,s=t.y1*r+a.y,l=t.y2*r+a.y;return{x1:i,x2:o,y1:s,y2:l,w:o-i,h:l-s}},vu.dirtyCompoundBoundsCache=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.cy();return t.styleEnabled()&&t.hasCompoundNodes()?(this.forEachUp(function(t){if(t.isParent()){var n=t._private;n.compoundBoundsClean=!1,n.bbCache=null,e||t.emitAndNotify("bounds")}}),this):this},vu.updateCompoundBounds=function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=this.cy();if(!n.styleEnabled()||!n.hasCompoundNodes())return this;if(!t&&n.batching())return this;function r(t){if(t.isParent()){var n=t._private,r=t.children(),a="include"===t.pstyle("compound-sizing-wrt-labels").value,i={width:{val:t.pstyle("min-width").pfValue,left:t.pstyle("min-width-bias-left"),right:t.pstyle("min-width-bias-right")},height:{val:t.pstyle("min-height").pfValue,top:t.pstyle("min-height-bias-top"),bottom:t.pstyle("min-height-bias-bottom")}},o=r.boundingBox({includeLabels:a,includeOverlays:!1,useCache:!1}),s=n.position;(0===o.w||0===o.h)&&((o={w:t.pstyle("width").pfValue,h:t.pstyle("height").pfValue}).x1=s.x-o.w/2,o.x2=s.x+o.w/2,o.y1=s.y-o.h/2,o.y2=s.y+o.h/2),e(m,"computeBiasValues"),e(b,"computePaddingValues");var l=i.width.left.value;"px"===i.width.left.units&&i.width.val>0&&(l=100*l/i.width.val);var u=i.width.right.value;"px"===i.width.right.units&&i.width.val>0&&(u=100*u/i.width.val);var c=i.height.top.value;"px"===i.height.top.units&&i.height.val>0&&(c=100*c/i.height.val);var d=i.height.bottom.value;"px"===i.height.bottom.units&&i.height.val>0&&(d=100*d/i.height.val);var h=m(i.width.val-o.w,l,u),f=h.biasDiff,p=h.biasComplementDiff,g=m(i.height.val-o.h,c,d),v=g.biasDiff,y=g.biasComplementDiff;n.autoPadding=b(o.w,o.h,t.pstyle("padding"),t.pstyle("padding-relative-to").value),n.autoWidth=Math.max(o.w,i.width.val),s.x=(-f+o.x1+o.x2+p)/2,n.autoHeight=Math.max(o.h,i.height.val),s.y=(-v+o.y1+o.y2+y)/2}function m(e,t,n){var r=0,a=0,i=t+n;return e>0&&i>0&&(r=t/i*e,a=n/i*e),{biasDiff:r,biasComplementDiff:a}}function b(e,t,n,r){if("%"!==n.units)return"px"===n.units?n.pfValue:0;switch(r){case"width":return e>0?n.pfValue*e:0;case"height":return t>0?n.pfValue*t:0;case"average":return e>0&&t>0?n.pfValue*(e+t)/2:0;case"min":return e>0&&t>0?e>t?n.pfValue*t:n.pfValue*e:0;case"max":return e>0&&t>0?e>t?n.pfValue*e:n.pfValue*t:0;default:return 0}}}e(r,"update");for(var a=0;ae.x2?r:e.x2,e.y1=ne.y2?a:e.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1)},"updateBounds"),xu=e(function(e,t){return null==t?e:bu(e,t.x1,t.y1,t.x2,t.y2)},"updateBoundsFromBox"),wu=e(function(e,t,n){return Wt(e,t,n)},"prefixedProperty"),Eu=e(function(e,t,n){if(!t.cy().headless()){var r,a,i=t._private,o=i.rstyle,s=o.arrowWidth/2;if("none"!==t.pstyle(n+"-arrow-shape").value){"source"===n?(r=o.srcX,a=o.srcY):"target"===n?(r=o.tgtX,a=o.tgtY):(r=o.midX,a=o.midY);var l=i.arrowBounds=i.arrowBounds||{},u=l[n]=l[n]||{};u.x1=r-s,u.y1=a-s,u.x2=r+s,u.y2=a+s,u.w=u.x2-u.x1,u.h=u.y2-u.y1,Kn(u,1),bu(e,u.x1,u.y1,u.x2,u.y2)}}},"updateBoundsFromArrow"),Cu=e(function(t,n,r){if(!n.cy().headless()){var a;a=r?r+"-":"";var i=n._private,o=i.rstyle;if(n.pstyle(a+"label").strValue){var s,l,u,c,d=n.pstyle("text-halign"),h=n.pstyle("text-valign"),f=wu(o,"labelWidth",r),p=wu(o,"labelHeight",r),g=wu(o,"labelX",r),v=wu(o,"labelY",r),y=n.pstyle(a+"text-margin-x").pfValue,m=n.pstyle(a+"text-margin-y").pfValue,b=n.isEdge(),x=n.pstyle(a+"text-rotation"),w=n.pstyle("text-outline-width").pfValue,E=n.pstyle("text-border-width").pfValue/2,C=n.pstyle("text-background-padding").pfValue,T=p,k=f,S=k/2,P=T/2;if(b)s=g-S,l=g+S,u=v-P,c=v+P;else{switch(d.value){case"left":s=g-k,l=g;break;case"center":s=g-S,l=g+S;break;case"right":s=g,l=g+k}switch(h.value){case"top":u=v-T,c=v;break;case"center":u=v-P,c=v+P;break;case"bottom":u=v,c=v+T}}var B=y-Math.max(w,E)-C-2,_=y+Math.max(w,E)+C+2,D=m-Math.max(w,E)-C-2,A=m+Math.max(w,E)+C+2;s+=B,l+=_,u+=D,c+=A;var M=r||"main",R=i.labelBounds,I=R[M]=R[M]||{};I.x1=s,I.y1=u,I.x2=l,I.y2=c,I.w=l-s,I.h=c-u,I.leftPad=B,I.rightPad=_,I.topPad=D,I.botPad=A;var L=b&&"autorotate"===x.strValue,N=null!=x.pfValue&&0!==x.pfValue;if(L||N){var z=L?wu(i.rstyle,"labelAngle",r):x.pfValue,O=Math.cos(z),F=Math.sin(z),V=(s+l)/2,q=(u+c)/2;if(!b){switch(d.value){case"left":V=l;break;case"right":V=s}switch(h.value){case"top":q=c;break;case"bottom":q=u}}var j=e(function(e,t){return{x:(e-=V)*O-(t-=q)*F+V,y:e*F+t*O+q}},"rotate"),X=j(s,u),Y=j(s,c),W=j(l,u),H=j(l,c);s=Math.min(X.x,Y.x,W.x,H.x),l=Math.max(X.x,Y.x,W.x,H.x),u=Math.min(X.y,Y.y,W.y,H.y),c=Math.max(X.y,Y.y,W.y,H.y)}var K=M+"Rot",G=R[K]=R[K]||{};G.x1=s,G.y1=u,G.x2=l,G.y2=c,G.w=l-s,G.h=c-u,bu(t,s,u,l,c),bu(i.labelBounds.all,s,u,l,c)}return t}},"updateBoundsFromLabel"),Tu=e(function(e,t){if(!t.cy().headless()){var n=t.pstyle("outline-opacity").value,r=t.pstyle("outline-width").value+t.pstyle("outline-offset").value;ku(e,t,n,r,"outside",r/2)}},"updateBoundsFromOutline"),ku=e(function(e,t,n,r,a,i){if(!(0===n||r<=0||"inside"===a)){var o=t.cy(),s=t.pstyle("shape").value,l=o.renderer().nodeShapes[s],u=t.position(),c=u.x,d=u.y,h=t.width(),f=t.height();if(l.hasMiterBounds){"center"===a&&(r/=2);var p=l.miterBounds(c,d,h,f,r);xu(e,p)}else null!=i&&i>0&&Gn(e,[i,i,i,i])}},"updateBoundsFromMiter"),Su=e(function(e,t){if(!t.cy().headless()){var n=t.pstyle("border-opacity").value,r=t.pstyle("border-width").pfValue,a=t.pstyle("border-position").value;ku(e,t,n,r,a)}},"updateBoundsFromMiterBorder"),Pu=e(function(t,n){var r,a,i,o,s,l,u=t._private.cy,c=u.styleEnabled(),d=u.headless(),h=jn(),f=t._private,p=t.isNode(),g=t.isEdge(),v=f.rstyle,y=p&&c?t.pstyle("bounds-expansion").pfValue:[0],m=e(function(e){return"none"!==e.pstyle("display").value},"isDisplayed"),b=!c||m(t)&&(!g||m(t.source())&&m(t.target()));if(b){var x=0;c&&n.includeOverlays&&(0!==t.pstyle("overlay-opacity").value&&(x=t.pstyle("overlay-padding").value));var w=0;c&&n.includeUnderlays&&(0!==t.pstyle("underlay-opacity").value&&(w=t.pstyle("underlay-padding").value));var E=Math.max(x,w),C=0;if(c&&(C=t.pstyle("width").pfValue/2),p&&n.includeNodes){var T=t.position();s=T.x,l=T.y;var k=t.outerWidth()/2,S=t.outerHeight()/2;bu(h,r=s-k,i=l-S,a=s+k,o=l+S),c&&Tu(h,t),c&&n.includeOutlines&&!d&&Tu(h,t),c&&Su(h,t)}else if(g&&n.includeEdges)if(c&&!d){var P=t.pstyle("curve-style").strValue;if(r=Math.min(v.srcX,v.midX,v.tgtX),a=Math.max(v.srcX,v.midX,v.tgtX),i=Math.min(v.srcY,v.midY,v.tgtY),o=Math.max(v.srcY,v.midY,v.tgtY),bu(h,r-=C,i-=C,a+=C,o+=C),"haystack"===P){var B=v.haystackPts;if(B&&2===B.length){if(r=B[0].x,i=B[0].y,r>(a=B[1].x)){var _=r;r=a,a=_}if(i>(o=B[1].y)){var D=i;i=o,o=D}bu(h,r-C,i-C,a+C,o+C)}}else if("bezier"===P||"unbundled-bezier"===P||Te(P,"segments")||Te(P,"taxi")){var A;switch(P){case"bezier":case"unbundled-bezier":A=v.bezierPts;break;case"segments":case"taxi":case"round-segments":case"round-taxi":A=v.linePts}if(null!=A)for(var M=0;M(a=L.x)){var N=r;r=a,a=N}if((i=I.y)>(o=L.y)){var z=i;i=o,o=z}bu(h,r-=C,i-=C,a+=C,o+=C)}if(c&&n.includeEdges&&g&&(Eu(h,t,"mid-source"),Eu(h,t,"mid-target"),Eu(h,t,"source"),Eu(h,t,"target")),c)if("yes"===t.pstyle("ghost").value){var O=t.pstyle("ghost-offset-x").pfValue,F=t.pstyle("ghost-offset-y").pfValue;bu(h,h.x1+O,h.y1+F,h.x2+O,h.y2+F)}var V=f.bodyBounds=f.bodyBounds||{};Un(V,h),Gn(V,y),Kn(V,1),c&&(r=h.x1,a=h.x2,i=h.y1,o=h.y2,bu(h,r-E,i-E,a+E,o+E));var q=f.overlayBounds=f.overlayBounds||{};Un(q,h),Gn(q,y),Kn(q,1);var j=f.labelBounds=f.labelBounds||{};null!=j.all?Yn(j.all):j.all=jn(),c&&n.includeLabels&&(n.includeMainLabels&&Cu(h,t,null),g&&(n.includeSourceLabels&&Cu(h,t,"source"),n.includeTargetLabels&&Cu(h,t,"target")))}return h.x1=mu(h.x1),h.y1=mu(h.y1),h.x2=mu(h.x2),h.y2=mu(h.y2),h.w=mu(h.x2-h.x1),h.h=mu(h.y2-h.y1),h.w>0&&h.h>0&&b&&(Gn(h,y),Kn(h,1)),h},"boundingBoxImpl"),Bu=e(function(t){var n=0,r=e(function(e){return(e?1:0)<0&&void 0!==arguments[0]?arguments[0]:Qu,t=arguments.length>1?arguments[1]:void 0,n=0;n<$u.length;n++){var r=$u[n];this[r]=e[r]||Zu[r]}this.context=t||this.context,this.listeners=[],this.emitting=0}e(Ju,"Emitter");var ec=Ju.prototype,tc=e(function(e,t,n,r,a,i,o){te(r)&&(a=r,r=null),o&&(i=null==i?o:Me({},i,o));for(var s=ne(n)?n:n.split(/\s+/),l=0;l=0;l--)s(l);return this},ec.removeAllListeners=function(){return this.removeListener("*")},ec.emit=ec.trigger=function(t,n,r){var a=this.listeners,i=a.length;return this.emitting++,ne(n)||(n=[n]),rc(this,function(t,o){null!=r&&(a=[{event:o.event,type:o.type,namespace:o.namespace,callback:r}],i=a.length);for(var s=e(function(){var e=a[l];if(e.type===o.type&&(!e.namespace||e.namespace===o.namespace||".*"===e.namespace)&&t.eventMatches(t.context,e,o)){var r=[o];null!=n&&Yt(r,n),t.beforeEmit(t.context,e,o),e.conf&&e.conf.one&&(t.listeners=t.listeners.filter(function(t){return t!==e}));var i=t.callbackContext(t.context,e,o),s=e.callback.apply(i,r);t.afterEmit(t.context,e,o),!1===s&&(o.stopPropagation(),o.preventDefault())}},"_loop2"),l=0;l1&&!r){var a=this.length-1,i=this[a],o=i._private.data.id;this[a]=void 0,this[e]=i,n.set(o,{ele:i,index:e})}return this.length--,this},"unmergeAt"),unmergeOne:e(function(e){e=e[0];var t=this._private,n=e._private.data.id,r=t.map.get(n);if(!r)return this;var a=r.index;return this.unmergeAt(a),this},"unmergeOne"),unmerge:e(function(e){var t=this._private.cy;if(!e)return this;if(e&&ee(e)){var n=e;e=t.mutableElements().filter(n)}for(var r=0;r=0;t--){e(this[t])&&this.unmergeAt(t)}return this},"unmergeBy"),map:e(function(e,t){for(var n=[],r=this,a=0;ar&&(r=s,n=o)}return{value:r,ele:n}},"max"),min:e(function(e,t){for(var n,r=1/0,a=this,i=0;i=0&&a"u"?"undefined":y(Symbol))!=t&&y(Symbol.iterator)!=t&&(dc[Symbol.iterator]=function(){var t=this,n={value:void 0,done:!1},r=0,a=this.length;return l({next:e(function(){return r1&&void 0!==arguments[1])||arguments[1],n=this[0],r=n.cy();if(r.styleEnabled()&&n)return n._private.styleDirty&&(n._private.styleDirty=!1,r.style().apply(n)),n._private.style[e]??(t?r.style().getDefaultProperty(e):null)},"parsedStyle"),numericStyle:e(function(e){var t=this[0];if(t.cy().styleEnabled()&&t){var n=t.pstyle(e);return void 0!==n.pfValue?n.pfValue:n.value}},"numericStyle"),numericStyleUnits:e(function(e){var t=this[0];if(t.cy().styleEnabled()&&t)return t.pstyle(e).units},"numericStyleUnits"),renderedStyle:e(function(e){var t=this.cy();if(!t.styleEnabled())return this;var n=this[0];return n?t.style().getRenderedStyle(n,e):void 0},"renderedStyle"),style:e(function(e,t){var n=this.cy();if(!n.styleEnabled())return this;var r=!1,a=n.style();if(re(e)){var i=e;a.applyBypass(this,i,r),this.emitAndNotify("style")}else if(ee(e)){if(void 0===t){var o=this[0];return o?a.getStylePropertyValue(o,e):void 0}a.applyBypass(this,e,t,r),this.emitAndNotify("style")}else if(void 0===e){var s=this[0];return s?a.getRawStyle(s):void 0}return this},"style"),removeStyle:e(function(e){var t=this.cy();if(!t.styleEnabled())return this;var n=!1,r=t.style(),a=this;if(void 0===e)for(var i=0;i0&&t.push(c[0]),t.push(s[0])}return this.spawn(t,!0).filter(e)},"neighborhood"),closedNeighborhood:e(function(e){return this.neighborhood().add(this).filter(e)},"closedNeighborhood"),openNeighborhood:e(function(e){return this.neighborhood(e)},"openNeighborhood")}),Bc.neighbourhood=Bc.neighborhood,Bc.closedNeighbourhood=Bc.closedNeighborhood,Bc.openNeighbourhood=Bc.openNeighborhood,Me(Bc,{source:tu(e(function(e){var t,n=this[0];return n&&(t=n._private.source||n.cy().collection()),t&&e?t.filter(e):t},"sourceImpl"),"source"),target:tu(e(function(e){var t,n=this[0];return n&&(t=n._private.target||n.cy().collection()),t&&e?t.filter(e):t},"targetImpl"),"target"),sources:Mc({attr:"source"}),targets:Mc({attr:"target"})}),e(Mc,"defineSourceFunction"),Me(Bc,{edgesWith:tu(Rc(),"edgesWith"),edgesTo:tu(Rc({thisIsSrc:!0}),"edgesTo")}),e(Rc,"defineEdgesWithFunction"),Me(Bc,{connectedEdges:tu(function(e){for(var t=[],n=0;n0);return o},"components"),component:e(function(){var e=this[0];return e.cy().mutableElements().components(e)[0]},"component")}),Bc.componentsOf=Bc.components;var Lc=e(function(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(void 0!==t){var i=new Gt,o=!1;if(n){if(n.length>0&&re(n[0])&&!ue(n[0])){o=!0;for(var s=[],l=new Zt,u=0,c=n.length;u0&&void 0!==arguments[0])||arguments[0],r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=this,i=a.cy(),o=i._private,s=[],l=[],u=0,c=a.length;u0){for(var L=t.length===a.length?a:new Lc(i,t),N=0;N0&&void 0!==arguments[0])||arguments[0],n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=this,a=[],i={},o=r._private.cy;function s(e){for(var t=e._private.edges,n=0;n0&&(t?S.emitAndNotify("remove"):n&&S.emit("remove"));for(var P=0;P0?a=o:n=o}while(Math.abs(i)>1e-7&&++s<10);return o}function y(e){for(var n=0,a=1;10!==a&&l[a]<=e;++a)n+=i;--a;var o=n+(e-l[a])/(l[a+1]-l[a])*i,s=f(o,t,r);return s>=.001?p(e,o):0===s?o:v(e,n,n+i)}e(u,"A"),e(c,"B"),e(d,"C"),e(h,"calcBezier"),e(f,"getSlope"),e(p,"newtonRaphsonIterate"),e(g,"calcSampleValues"),e(v,"binarySubdivide"),e(y,"getTForX");var m=!1;function b(){m=!0,(t!==n||r!==a)&&g()}e(b,"precompute");var x=e(function(e){return m||b(),t===n&&r===a?e:0===e?0:1===e?1:h(y(e),n,a)},"f");x.getControlPoints=function(){return[{x:t,y:n},{x:r,y:a}]};var w="generateBezier("+[t,n,r,a]+")";return x.toString=function(){return w},x}e(Oc,"generateCubicBezier");var Fc=function(){function t(e){return-e.tension*e.x-e.friction*e.v}function n(e,n,r){var a={x:e.x+r.dx*n,v:e.v+r.dv*n,tension:e.tension,friction:e.friction};return{dx:a.v,dv:t(a)}}function r(e,r){var a={dx:e.v,dv:t(e)},i=n(e,.5*r,a),o=n(e,.5*r,i),s=n(e,r,o),l=1/6*(a.dx+2*(i.dx+o.dx)+s.dx),u=1/6*(a.dv+2*(i.dv+o.dv)+s.dv);return e.x=e.x+l*r,e.v=e.v+u*r,e}return e(t,"springAccelerationForState"),e(n,"springEvaluateStateWithDerivative"),e(r,"springIntegrateState"),e(function e(t,n,a){var i,o,s,l={x:-1,v:0,tension:null,friction:null},u=[0],c=0,d=1e-4;for(t=parseFloat(t)||500,n=parseFloat(n)||20,a=a||null,l.tension=t,l.friction=n,(i=null!==a)?o=(c=e(t,n))/a*.016:o=.016;s=r(s||l,o),u.push(1+s.x),c+=16,Math.abs(s.x)>d&&Math.abs(s.v)>d;);return i?function(e){return u[e*(u.length-1)|0]}:c},"springRK4Factory")}(),Vc=e(function(e,t,n,r){var a=Oc(e,t,n,r);return function(e,t,n){return e+(t-e)*a(n)}},"cubicBezier"),qc={linear:e(function(e,t,n){return e+(t-e)*n},"linear"),ease:Vc(.25,.1,.25,1),"ease-in":Vc(.42,0,1,1),"ease-out":Vc(0,0,.58,1),"ease-in-out":Vc(.42,0,.58,1),"ease-in-sine":Vc(.47,0,.745,.715),"ease-out-sine":Vc(.39,.575,.565,1),"ease-in-out-sine":Vc(.445,.05,.55,.95),"ease-in-quad":Vc(.55,.085,.68,.53),"ease-out-quad":Vc(.25,.46,.45,.94),"ease-in-out-quad":Vc(.455,.03,.515,.955),"ease-in-cubic":Vc(.55,.055,.675,.19),"ease-out-cubic":Vc(.215,.61,.355,1),"ease-in-out-cubic":Vc(.645,.045,.355,1),"ease-in-quart":Vc(.895,.03,.685,.22),"ease-out-quart":Vc(.165,.84,.44,1),"ease-in-out-quart":Vc(.77,0,.175,1),"ease-in-quint":Vc(.755,.05,.855,.06),"ease-out-quint":Vc(.23,1,.32,1),"ease-in-out-quint":Vc(.86,0,.07,1),"ease-in-expo":Vc(.95,.05,.795,.035),"ease-out-expo":Vc(.19,1,.22,1),"ease-in-out-expo":Vc(1,0,0,1),"ease-in-circ":Vc(.6,.04,.98,.335),"ease-out-circ":Vc(.075,.82,.165,1),"ease-in-out-circ":Vc(.785,.135,.15,.86),spring:e(function(e,t,n){if(0===n)return qc.linear;var r=Fc(e,t,n);return function(e,t,n){return e+(t-e)*r(n)}},"spring"),"cubic-bezier":Vc};function jc(e,t,n,r,a){if(1===r||t===n)return n;var i=a(t,n,r);return null==e||((e.roundValue||e.color)&&(i=Math.round(i)),void 0!==e.min&&(i=Math.max(i,e.min)),void 0!==e.max&&(i=Math.min(i,e.max))),i}function Xc(e,t){return null!=e.pfValue||null!=e.value?null==e.pfValue||null!=t&&"%"===t.type.units?e.value:e.pfValue:e}function Yc(e,t,n,r,a){var i=null!=a?a.type:null;n<0?n=0:n>1&&(n=1);var o=Xc(e,a),s=Xc(t,a);if(ie(o)&&ie(s))return jc(i,o,s,n,r);if(ne(o)&&ne(s)){for(var l=[],u=0;u0?("spring"===d&&h.push(o.duration),o.easingImpl=qc[d].apply(null,h)):o.easingImpl=qc[d]}var f,p=o.easingImpl;if(f=0===o.duration?1:(n-l)/o.duration,o.applying&&(f=o.progress),f<0?f=0:f>1&&(f=1),null==o.delay){var g=o.startPosition,v=o.position;if(v&&a&&!e.locked()){var y={};Hc(g.x,v.x)&&(y.x=Yc(g.x,v.x,f,p)),Hc(g.y,v.y)&&(y.y=Yc(g.y,v.y,f,p)),e.position(y)}var m=o.startPan,b=o.pan,x=i.pan,w=null!=b&&r;w&&(Hc(m.x,b.x)&&(x.x=Yc(m.x,b.x,f,p)),Hc(m.y,b.y)&&(x.y=Yc(m.y,b.y,f,p)),e.emit("pan"));var E=o.startZoom,C=o.zoom,T=null!=C&&r;T&&(Hc(E,C)&&(i.zoom=qn(i.minZoom,Yc(E,C,f,p),i.maxZoom)),e.emit("zoom")),(w||T)&&e.emit("viewport");var k=o.style;if(k&&k.length>0&&a){for(var S=0;S=0;t--){(0,e[t])()}e.splice(0,e.length)},"callbacks"),d=o.length-1;d>=0;d--){var h=o[d],f=h._private;f.stopped?(o.splice(d,1),f.hooked=!1,f.playing=!1,f.started=!1,c(f.frames)):!f.playing&&!f.applying||(f.playing&&f.applying&&(f.applying=!1),f.started||Kc(0,h,t),Wc(n,h,t,r),f.applying&&(f.applying=!1),c(f.frames),null!=f.step&&f.step(t),h.completed()&&(o.splice(d,1),f.hooked=!1,f.playing=!1,f.started=!1,c(f.completes)),l=!0)}return!r&&0===o.length&&0===s.length&&a.push(n),l}e(i,"stepOne");for(var o=!1,s=0;s0?n.notify("draw",r):n.notify("draw")),r.unmerge(a),n.emit("step")}e(jc,"getEasedValue"),e(Xc,"getValue"),e(Yc,"ease"),e(Wc,"step$1"),e(Hc,"valid"),e(Kc,"startAnimation"),e(Gc,"stepAll");var Uc={animate:il.animate(),animation:il.animation(),animated:il.animated(),clearQueue:il.clearQueue(),delay:il.delay(),delayAnimation:il.delayAnimation(),stop:il.stop(),addToAnimationPool:e(function(e){this.styleEnabled()&&this._private.aniEles.merge(e)},"addToAnimationPool"),stopAnimationLoop:e(function(){this._private.animationsRunning=!1},"stopAnimationLoop"),startAnimationLoop:e(function(){var t=this;if(t._private.animationsRunning=!0,t.styleEnabled()){e(r,"headlessStep");var n=t.renderer();n&&n.beforeRender?n.beforeRender(e(function(e,n){Gc(n,t)},"rendererAnimationStep"),n.beforeRenderPriorities.animations):r()}function r(){t._private.animationsRunning&&st(e(function(e){Gc(e,t),r()},"animationStep"))}},"startAnimationLoop")},Zc={qualifierCompare:e(function(e,t){return null==e||null==t?null==e&&null==t:e.sameText(t)},"qualifierCompare"),eventMatches:e(function(e,t,n){var r=t.qualifier;return null==r||e!==n.target&&ue(n.target)&&r.matches(n.target)},"eventMatches"),addEventFields:e(function(e,t){t.cy=e,t.target=e},"addEventFields"),callbackContext:e(function(e,t,n){return null!=t.qualifier?n.target:e},"callbackContext")},$c=e(function(e){return ee(e)?new Zl(e):e},"argSelector"),Qc={createEmitter:e(function(){var e=this._private;return e.emitter||(e.emitter=new Ju(Zc,this)),this},"createEmitter"),emitter:e(function(){return this._private.emitter},"emitter"),on:e(function(e,t,n){return this.emitter().on(e,$c(t),n),this},"on"),removeListener:e(function(e,t,n){return this.emitter().removeListener(e,$c(t),n),this},"removeListener"),removeAllListeners:e(function(){return this.emitter().removeAllListeners(),this},"removeAllListeners"),one:e(function(e,t,n){return this.emitter().one(e,$c(t),n),this},"one"),once:e(function(e,t,n){return this.emitter().one(e,$c(t),n),this},"once"),emit:e(function(e,t){return this.emitter().emit(e,t),this},"emit"),emitAndNotify:e(function(e,t){return this.emit(e),this.notify(e,t),this},"emitAndNotify")};il.eventAliasesOn(Qc);var Jc={png:e(function(e){return e=e||{},this._private.renderer.png(e)},"png"),jpg:e(function(e){var t=this._private.renderer;return(e=e||{}).bg=e.bg||"#fff",t.jpg(e)},"jpg")};Jc.jpeg=Jc.jpg;var ed={layout:e(function(e){var t=this;if(null!=e)if(null!=e.name){var n,r=e.name,a=t.extension("layout",r);if(null!=a)return n=ee(e.eles)?t.$(e.eles):null!=e.eles?e.eles:t.$(),new a(Me({},e,{cy:t,eles:n}));Mt("No such layout `"+r+"` found. Did you forget to import it and `cytoscape.use()` it?")}else Mt("A `name` must be specified to make a layout");else Mt("Layout options must be specified to make a layout")},"layout")};ed.createLayout=ed.makeLayout=ed.layout;var td={notify:e(function(e,t){var n=this._private;if(this.batching()){n.batchNotifications=n.batchNotifications||{};var r=n.batchNotifications[e]=n.batchNotifications[e]||this.collection();null!=t&&r.merge(t)}else if(n.notificationsEnabled){var a=this.renderer();this.destroyed()||!a||a.notify(e,t)}},"notify"),notifications:e(function(e){var t=this._private;return void 0===e?t.notificationsEnabled:(t.notificationsEnabled=!!e,this)},"notifications"),noNotifications:e(function(e){this.notifications(!1),e(),this.notifications(!0)},"noNotifications"),batching:e(function(){return this._private.batchCount>0},"batching"),startBatch:e(function(){var e=this._private;return null==e.batchCount&&(e.batchCount=0),0===e.batchCount&&(e.batchStyleEles=this.collection(),e.batchNotifications={}),e.batchCount++,this},"startBatch"),endBatch:e(function(){var e=this._private;if(0===e.batchCount)return this;if(e.batchCount--,0===e.batchCount){e.batchStyleEles.updateStyle();var t=this.renderer();Object.keys(e.batchNotifications).forEach(function(n){var r=e.batchNotifications[n];r.empty()?t.notify(n):t.notify(n,r)})}return this},"endBatch"),batch:e(function(e){return this.startBatch(),e(),this.endBatch(),this},"batch"),batchData:e(function(e){var t=this;return this.batch(function(){for(var n=Object.keys(e),r=0;r0;)t.removeChild(t.childNodes[0]);e._private.renderer=null,e.mutableElements().forEach(function(e){var t=e._private;t.rscratch={},t.rstyle={},t.animation.current=[],t.animation.queue=[]})},"destroyRenderer"),onRender:e(function(e){return this.on("render",e)},"onRender"),offRender:e(function(e){return this.off("render",e)},"offRender")};rd.invalidateDimensions=rd.resize;var ad={collection:e(function(e,t){return ee(e)?this.$(e):le(e)?e.collection():ne(e)?(t||(t={}),new Lc(this,e,t.unique,t.removed)):new Lc(this)},"collection"),nodes:e(function(e){var t=this.$(function(e){return e.isNode()});return e?t.filter(e):t},"nodes"),edges:e(function(e){var t=this.$(function(e){return e.isEdge()});return e?t.filter(e):t},"edges"),$:e(function(e){var t=this._private.elements;return e?t.filter(e):t.spawnSelf()},"$"),mutableElements:e(function(){return this._private.elements},"mutableElements")};ad.elements=ad.filter=ad.$;var id={},od="t";id.apply=function(e){for(var t=this,n=t._private.cy.collection(),r=0;r0;if(h||d&&f){var p=void 0;h&&f||h?p=u.properties:f&&(p=u.mappedProperties);for(var g=0;g1&&(x=1),l.color){var E=i.valueMin[0],C=i.valueMax[0],T=i.valueMin[1],k=i.valueMax[1],S=i.valueMin[2],P=i.valueMax[2],B=null==i.valueMin[3]?1:i.valueMin[3],_=null==i.valueMax[3]?1:i.valueMax[3],D=[Math.round(E+(C-E)*x),Math.round(T+(k-T)*x),Math.round(S+(P-S)*x),Math.round(B+(_-B)*x)];r={bypass:i.bypass,name:i.name,value:D,strValue:"rgb("+D[0]+", "+D[1]+", "+D[2]+")"}}else{if(!l.number)return!1;var A=i.valueMin+(i.valueMax-i.valueMin)*x;r=this.parse(i.name,A,i.bypass,f)}if(!r)return v(),!1;r.mapping=i,i=r;break;case s.data:for(var M=i.field.split("."),R=h.data,I=0;I0&&i>0){for(var s={},l=!1,u=0;u0?e.delayAnimation(o).play().promise().then(t):t()}).then(function(){return e.animation({style:s,duration:i,easing:e.pstyle("transition-timing-function").value,queue:!1}).play().promise()}).then(function(){n.removeBypasses(e,a),e.emitAndNotify("style"),r.transitioning=!1})}else r.transitioning&&(this.removeBypasses(e,a),e.emitAndNotify("style"),r.transitioning=!1)},id.checkTrigger=function(e,t,n,r,a,i){var o=this.properties[t],s=a(o);e.removed()||null!=s&&s(n,r,e)&&i(o)},id.checkZOrderTrigger=function(e,t,n,r){var a=this;this.checkTrigger(e,t,n,r,function(e){return e.triggersZOrder},function(){a._private.cy.notify("zorder",e)})},id.checkBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,function(e){return e.triggersBounds},function(t){e.dirtyCompoundBoundsCache(),e.dirtyBoundingBoxCache()})},id.checkConnectedEdgesBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,function(e){return e.triggersBoundsOfConnectedEdges},function(t){e.connectedEdges().forEach(function(e){e.dirtyBoundingBoxCache()})})},id.checkParallelEdgesBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,function(e){return e.triggersBoundsOfParallelEdges},function(t){e.parallelEdges().forEach(function(e){e.dirtyBoundingBoxCache()})})},id.checkTriggers=function(e,t,n,r){e.dirtyStyleCache(),this.checkZOrderTrigger(e,t,n,r),this.checkBoundsTrigger(e,t,n,r),this.checkConnectedEdgesBoundsTrigger(e,t,n,r),this.checkParallelEdgesBoundsTrigger(e,t,n,r)};var sd={applyBypass:function(e,t,n,r){var a=[];if("*"===t||"**"===t){if(void 0!==n)for(var i=0;in.length?o.substr(n.length):""}function l(){r=r.length>a.length?r.substr(a.length):""}for(o=o.replace(/[/][*](\s|.)+?[*][/]/g,""),e(s,"removeSelAndBlockFromRemaining"),e(l,"removePropAndValFromRem");;){if(o.match(/^\s*$/))break;var u=o.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!u){It("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: "+o);break}n=u[0];var c=u[1];if("core"!==c)if(new Zl(c).invalid){It("Skipping parsing of block: Invalid selector found in string stylesheet: "+c),s();continue}var d=u[2],h=!1;r=d;for(var f=[];;){if(r.match(/^\s*$/))break;var p=r.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/);if(!p){It("Skipping parsing of block: Invalid formatting of style property and value definitions found in:"+d),h=!0;break}a=p[0];var g=p[1],v=p[2];if(this.properties[g])i.parse(g,v)?(f.push({name:g,val:v}),l()):(It("Skipping property: Invalid property definition in: "+a),l());else It("Skipping property: Invalid property name in: "+a),l()}if(h){s();break}i.selector(c);for(var y=0;y=7&&"d"===n[0]&&(c=new RegExp(l.data.regex).exec(n))){if(r)return!1;var f=l.data;return{name:t,value:c,strValue:""+n,mapped:f,field:c[1],bypass:r}}if(n.length>=10&&"m"===n[0]&&(d=new RegExp(l.mapData.regex).exec(n))){if(r||h.multiple)return!1;var p=l.mapData;if(!h.color&&!h.number)return!1;var g=this.parse(t,d[4]);if(!g||g.mapped)return!1;var v=this.parse(t,d[5]);if(!v||v.mapped)return!1;if(g.pfValue===v.pfValue||g.strValue===v.strValue)return It("`"+t+": "+n+"` is not a valid mapper because the output range is zero; converting to `"+t+": "+g.strValue+"`"),this.parse(t,g.strValue);if(h.color){var y=g.value,m=v.value;if(!(y[0]!==m[0]||y[1]!==m[1]||y[2]!==m[2]||y[3]!==m[3]&&(null!=y[3]&&1!==y[3]||null!=m[3]&&1!==m[3])))return!1}return{name:t,value:d,strValue:""+n,mapped:p,field:d[1],fieldMin:parseFloat(d[2]),fieldMax:parseFloat(d[3]),valueMin:g.value,valueMax:v.value,bypass:r}}}if(h.multiple&&"multiple"!==a){var b;if(b=u?n.split(/\s+/):ne(n)?n:[n],h.evenMultiple&&b.length%2!=0)return null;for(var x=[],w=[],E=[],C="",T=!1,k=0;k0?" ":"")+S.strValue}return h.validate&&!h.validate(x,w)?null:h.singleEnum&&T?1===x.length&&ee(x[0])?{name:t,value:x[0],strValue:x[0],bypass:r}:null:{name:t,value:x,pfValue:E,strValue:C,bypass:r,units:w}}var P=e(function(){for(var e=0;eh.max||h.strictMax&&n===h.max))return null;var M={name:t,value:n,strValue:""+n+(B||""),units:B,bypass:r};return h.unitless||"px"!==B&&"em"!==B?M.pfValue=n:M.pfValue="px"!==B&&B?this.getEmSizeInPixels()*n:n,("ms"===B||"s"===B)&&(M.pfValue="ms"===B?n:1e3*n),("deg"===B||"rad"===B)&&(M.pfValue="rad"===B?n:An(n)),"%"===B&&(M.pfValue=n/100),M}if(h.propList){var R=[],I=""+n;if("none"!==I){for(var L=I.split(/\s*,\s*|\s+/),N=0;N0&&s>0&&!isNaN(n.w)&&!isNaN(n.h)&&n.w>0&&n.h>0)return{zoom:i=(i=(i=Math.min((o-2*t)/n.w,(s-2*t)/n.h))>this._private.maxZoom?this._private.maxZoom:i)=n.minZoom&&(n.maxZoom=t),this},"zoomRange"),minZoom:e(function(e){return void 0===e?this._private.minZoom:this.zoomRange({min:e})},"minZoom"),maxZoom:e(function(e){return void 0===e?this._private.maxZoom:this.zoomRange({max:e})},"maxZoom"),getZoomedViewport:e(function(e){var t,n,r=this._private,a=r.pan,i=r.zoom,o=!1;if(r.zoomingEnabled||(o=!0),ie(e)?n=e:re(e)&&(n=e.level,null!=e.position?t=Tn(e.position,i,a):null!=e.renderedPosition&&(t=e.renderedPosition),null!=t&&!r.panningEnabled&&(o=!0)),n=(n=n>r.maxZoom?r.maxZoom:n)t.maxZoom||!t.zoomingEnabled?i=!0:(t.zoom=s,a.push("zoom"))}if(r&&(!i||!e.cancelOnFailedZoom)&&t.panningEnabled){var l=e.pan;ie(l.x)&&(t.pan.x=l.x,o=!1),ie(l.y)&&(t.pan.y=l.y,o=!1),o||a.push("pan")}return a.length>0&&(a.push("viewport"),this.emit(a.join(" ")),this.notify("viewport")),this},"viewport"),center:e(function(e){var t=this.getCenterPan(e);return t&&(this._private.pan=t,this.emit("pan viewport"),this.notify("viewport")),this},"center"),getCenterPan:e(function(e,t){if(this._private.panningEnabled){if(ee(e)){var n=e;e=this.mutableElements().filter(n)}else le(e)||(e=this.mutableElements());if(0!==e.length){var r=e.boundingBox(),a=this.width(),i=this.height();return{x:(a-(t=void 0===t?this._private.zoom:t)*(r.x1+r.x2))/2,y:(i-t*(r.y1+r.y2))/2}}}},"getCenterPan"),reset:e(function(){return this._private.panningEnabled&&this._private.zoomingEnabled?(this.viewport({pan:{x:0,y:0},zoom:1}),this):this},"reset"),invalidateSize:e(function(){this._private.sizeCache=null},"invalidateSize"),size:e(function(){var t,n,r=this._private,a=r.container,i=this;return r.sizeCache=r.sizeCache||(a?(t=i.window().getComputedStyle(a),n=e(function(e){return parseFloat(t.getPropertyValue(e))},"val"),{width:a.clientWidth-n("padding-left")-n("padding-right"),height:a.clientHeight-n("padding-top")-n("padding-bottom")}):{width:1,height:1})},"size"),width:e(function(){return this.size().width},"width"),height:e(function(){return this.size().height},"height"),extent:e(function(){var e=this._private.pan,t=this._private.zoom,n=this.renderedExtent(),r={x1:(n.x1-e.x)/t,x2:(n.x2-e.x)/t,y1:(n.y1-e.y)/t,y2:(n.y2-e.y)/t};return r.w=r.x2-r.x1,r.h=r.y2-r.y1,r},"extent"),renderedExtent:e(function(){var e=this.width(),t=this.height();return{x1:0,y1:0,x2:e,y2:t,w:e,h:t}},"renderedExtent"),multiClickDebounceTime:e(function(e){return e?(this._private.multiClickDebounceTime=e,this):this._private.multiClickDebounceTime},"multiClickDebounceTime")};yd.centre=yd.center,yd.autolockNodes=yd.autolock,yd.autoungrabifyNodes=yd.autoungrabify;var md={data:il.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeData:il.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),scratch:il.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:il.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0})};md.attr=md.data,md.removeAttr=md.removeData;var bd=e(function(t){var n=this,r=(t=Me({},t)).container;r&&!se(r)&&se(r[0])&&(r=r[0]);var a=r?r._cyreg:null;(a=a||{})&&a.cy&&(a.cy.destroy(),a={});var i=a.readies=a.readies||[];r&&(r._cyreg=a),a.cy=n;var o=void 0!==b&&void 0!==r&&!t.headless,s=t;s.layout=Me({name:o?"grid":"null"},s.layout),s.renderer=Me({name:o?"canvas":"null"},s.renderer);var l=e(function(e,t,n){return void 0!==t?t:void 0!==n?n:e},"defVal"),u=this._private={container:r,ready:!1,options:s,elements:new Lc(this),listeners:[],aniEles:new Lc(this),data:s.data||{},scratch:{},layout:null,renderer:null,destroyed:!1,notificationsEnabled:!0,minZoom:1e-50,maxZoom:1e50,zoomingEnabled:l(!0,s.zoomingEnabled),userZoomingEnabled:l(!0,s.userZoomingEnabled),panningEnabled:l(!0,s.panningEnabled),userPanningEnabled:l(!0,s.userPanningEnabled),boxSelectionEnabled:l(!0,s.boxSelectionEnabled),autolock:l(!1,s.autolock,s.autolockNodes),autoungrabify:l(!1,s.autoungrabify,s.autoungrabifyNodes),autounselectify:l(!1,s.autounselectify),styleEnabled:void 0===s.styleEnabled?o:s.styleEnabled,zoom:ie(s.zoom)?s.zoom:1,pan:{x:re(s.pan)&&ie(s.pan.x)?s.pan.x:0,y:re(s.pan)&&ie(s.pan.y)?s.pan.y:0},animation:{current:[],queue:[]},hasCompoundNodes:!1,multiClickDebounceTime:l(250,s.multiClickDebounceTime)};this.createEmitter(),this.selectionType(s.selectionType),this.zoomRange({min:s.minZoom,max:s.maxZoom});var c=e(function(e,t){if(e.some(ye))return ai.all(e).then(t);t(e)},"loadExtData");u.styleEnabled&&n.setStyle([]);var d=Me({},s,s.renderer);n.initRenderer(d);var h=e(function(e,t,r){n.notifications(!1);var a=n.mutableElements();a.length>0&&a.remove(),null!=e&&(re(e)||ne(e))&&n.add(e),n.one("layoutready",function(e){n.notifications(!0),n.emit(e),n.one("load",t),n.emitAndNotify("load")}).one("layoutstop",function(){n.one("done",r),n.emit("done")});var i=Me({},n._private.options.layout);i.eles=n.elements(),n.layout(i).run()},"setElesAndLayout");c([s.style,s.elements],function(e){var t=e[0],r=e[1];u.styleEnabled&&n.style().append(t),h(r,function(){n.startAnimationLoop(),u.ready=!0,te(s.ready)&&n.on("ready",s.ready);for(var e=0;e0,u=!!n.boundingBox,c=jn(u?n.boundingBox:structuredClone(r.extent()));if(le(n.roots))t=n.roots;else if(ne(n.roots)){for(var d=[],h=0;h0;){var A=D(),M=S(A,B);if(M)A.outgoers().filter(function(e){return e.isNode()&&a.has(e)}).forEach(_);else if(null===M){It("Detected double maximal shift for node `"+A.id()+"`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.");break}}}var R=0;if(n.avoidOverlap)for(var I=0;I0&&m[0].length<=3?i/2:0),s=2*Math.PI/m[r].length*a;return 0===r&&1===m[0].length&&(o=1),{x:G+o*Math.cos(s),y:U+o*Math.sin(s)}}var l=m[r].length,d=Math.max(1===l?0:u?(c.w-2*n.padding-Z.w)/((n.grid?Q:l)-1):(c.w-2*n.padding-Z.w)/((n.grid?Q:l)+1),R);return{x:G+(a+1-(l+1)/2)*d,y:U+(r+1-(q+1)/2)*$}},"getPositionTopBottom"),te={downward:0,leftward:90,upward:180,rightward:-90};-1===Object.keys(te).indexOf(n.direction)&&Mt("Invalid direction '".concat(n.direction,"' specified for breadthfirst layout. Valid values are: ").concat(Object.keys(te).join(", ")));var re=e(function(e){return Ct(J(e),c,te[n.direction])},"getPosition");return a.nodes().layoutPositions(this,n,re),this};var Sd={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,radius:void 0,startAngle:1.5*Math.PI,sweep:void 0,clockwise:!0,sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:e(function(e,t){return!0},"animateFilter"),ready:void 0,stop:void 0,transform:e(function(e,t){return t},"transform")};function Pd(e){this.options=Me({},Sd,e)}e(Pd,"CircleLayout"),Pd.prototype.run=function(){var t=this.options,n=t,r=t.cy,a=n.eles,i=void 0!==n.counterclockwise?!n.counterclockwise:n.clockwise,o=a.nodes().not(":parent");n.sort&&(o=o.sort(n.sort));for(var s,l=jn(n.boundingBox?n.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()}),u={x:l.x1+l.w/2,y:l.y1+l.h/2},c=(void 0===n.sweep?2*Math.PI-2*Math.PI/o.length:n.sweep)/Math.max(1,o.length-1),d=0,h=0;h1&&n.avoidOverlap){d*=1.75;var v=Math.cos(c)-Math.cos(0),y=Math.sin(c)-Math.sin(0),m=Math.sqrt(d*d/(v*v+y*y));s=Math.max(m,s)}var b=e(function(e,t){var r=n.startAngle+t*c*(i?1:-1),a=s*Math.cos(r),o=s*Math.sin(r);return{x:u.x+a,y:u.y+o}},"getPos");return a.nodes().layoutPositions(this,n,b),this};var Bd={fit:!0,padding:30,startAngle:1.5*Math.PI,sweep:void 0,clockwise:!0,equidistant:!1,minNodeSpacing:10,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,height:void 0,width:void 0,spacingFactor:void 0,concentric:e(function(e){return e.degree()},"concentric"),levelWidth:e(function(e){return e.maxDegree()/4},"levelWidth"),animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:e(function(e,t){return!0},"animateFilter"),ready:void 0,stop:void 0,transform:e(function(e,t){return t},"transform")};function _d(e){this.options=Me({},Bd,e)}e(_d,"ConcentricLayout"),_d.prototype.run=function(){for(var e=this.options,t=e,n=void 0!==t.counterclockwise?!t.counterclockwise:t.clockwise,r=e.cy,a=t.eles,i=a.nodes().not(":parent"),o=jn(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()}),s={x:o.x1+o.w/2,y:o.y1+o.h/2},l=[],u=0,c=0;c0)Math.abs(y[0].value-b.value)>=g&&(y=[],v.push(y));y.push(b)}var x=u+t.minNodeSpacing;if(!t.avoidOverlap){var w=v.length>0&&v[0].length>1,E=(Math.min(o.w,o.h)/2-x)/(v.length+w?1:0);x=Math.min(x,E)}for(var C=0,T=0;T1&&t.avoidOverlap){var B=Math.cos(P)-Math.cos(0),_=Math.sin(P)-Math.sin(0),D=Math.sqrt(x*x/(B*B+_*_));C=Math.max(D,C)}k.r=C,C+=x}if(t.equidistant){for(var A=0,M=0,R=0;R=t.numIter||(Fd(a,t),a.temperature=a.temperature*t.coolingFactor,a.temperature=t.animationThreshold&&o(),st(d)):($d(a,t),l())},"frame");d()}else{for(;c;)c=s(u),u++;$d(a,t),l()}return this},Md.prototype.stop=function(){return this.stopped=!0,this.thread&&this.thread.stop(),this.emit("layoutstop"),this},Md.prototype.destroy=function(){return this.thread&&this.thread.stop(),this};var Rd=e(function(e,t,n){for(var r=n.eles.edges(),a=n.eles.nodes(),i=jn(n.boundingBox?n.boundingBox:{x1:0,y1:0,w:e.width(),h:e.height()}),o={isCompound:e.hasCompoundNodes(),layoutNodes:[],idToIndex:{},nodeSize:a.size(),graphSet:[],indexToGraph:[],layoutEdges:[],edgeSize:r.size(),temperature:n.initialTemp,clientWidth:i.w,clientHeight:i.h,boundingBox:i},s=n.eles.components(),l={},u=0;u0){o.graphSet.push(w);for(u=0;ur.count?0:r.graph},"findLCA"),Ld=e(function(e,t,n,r){var a=r.graphSet[n];if(-10)var s=(u=r.nodeOverlap*o)*a/(g=Math.sqrt(a*a+i*i)),l=u*i/g;else{var u,c=Yd(e,a,i),d=Yd(t,-1*a,-1*i),h=d.x-c.x,f=d.y-c.y,p=h*h+f*f,g=Math.sqrt(p);s=(u=(e.nodeRepulsion+t.nodeRepulsion)/p)*h/g,l=u*f/g}e.isLocked||(e.offsetX-=s,e.offsetY-=l),t.isLocked||(t.offsetX+=s,t.offsetY+=l)}},"nodeRepulsion"),Xd=e(function(e,t,n,r){if(n>0)var a=e.maxX-t.minX;else a=t.maxX-e.minX;if(r>0)var i=e.maxY-t.minY;else i=t.maxY-e.minY;return a>=0&&i>=0?Math.sqrt(a*a+i*i):0},"nodesOverlap"),Yd=e(function(e,t,n){var r=e.positionX,a=e.positionY,i=e.height||1,o=e.width||1,s=n/t,l=i/o,u={};return 0===t&&0n?(u.x=r,u.y=a+i/2,u):0t&&-1*l<=s&&s<=l?(u.x=r-o/2,u.y=a-o*n/2/t,u):0=l)?(u.x=r+i*t/2/n,u.y=a+i/2,u):(0>n&&(s<=-1*l||s>=l)&&(u.x=r-i*t/2/n,u.y=a-i/2),u)},"findClippingPoint"),Wd=e(function(e,t){for(var n=0;n1){var p=t.gravity*d/f,g=t.gravity*h/f;c.offsetX+=p,c.offsetY+=g}}}}},"calculateGravityForces"),Kd=e(function(e,t){var n=[],r=0,a=-1;for(n.push.apply(n,e.graphSet[0]),a+=e.graphSet[0].length;r<=a;){var i=n[r++],o=e.idToIndex[i],s=e.layoutNodes[o],l=s.children;if(0n)var a={x:n*e/r,y:n*t/r};else a={x:e,y:t};return a},"limitForce"),Zd=e(function(e,t){var n=e.parentId;if(null!=n){var r=t.layoutNodes[t.idToIndex[n]],a=!1;if((null==r.maxX||e.maxX+r.padRight>r.maxX)&&(r.maxX=e.maxX+r.padRight,a=!0),(null==r.minX||e.minX-r.padLeftr.maxY)&&(r.maxY=e.maxY+r.padBottom,a=!0),(null==r.minY||e.minY-r.padTopp&&(d+=f+t.componentSpacing,c=0,h=0,f=0)}}},"separateComponents"),Qd={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,avoidOverlapPadding:10,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,condense:!1,rows:void 0,cols:void 0,position:e(function(e){},"position"),sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:e(function(e,t){return!0},"animateFilter"),ready:void 0,stop:void 0,transform:e(function(e,t){return t},"transform")};function Jd(e){this.options=Me({},Qd,e)}e(Jd,"GridLayout"),Jd.prototype.run=function(){var t=this.options,n=t,r=t.cy,a=n.eles,i=a.nodes().not(":parent");n.sort&&(i=i.sort(n.sort));var o=jn(n.boundingBox?n.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()});if(0===o.h||0===o.w)a.nodes().layoutPositions(this,n,function(e){return{x:o.x1,y:o.y1}});else{var s=i.size(),l=Math.sqrt(s*o.h/o.w),u=Math.round(l),c=Math.round(o.w/o.h*l),d=e(function(e){if(null==e)return Math.min(u,c);Math.min(u,c)==u?u=e:c=e},"small"),h=e(function(e){if(null==e)return Math.max(u,c);Math.max(u,c)==u?u=e:c=e},"large"),f=n.rows,p=null!=n.cols?n.cols:n.columns;if(null!=f&&null!=p)u=f,c=p;else if(null!=f&&null==p)u=f,c=Math.ceil(s/u);else if(null==f&&null!=p)c=p,u=Math.ceil(s/c);else if(c*u>s){var g=d(),v=h();(g-1)*v>=s?d(g-1):(v-1)*g>=s&&h(v-1)}else for(;c*u=s?h(m+1):d(y+1)}var b=o.w/c,x=o.h/u;if(n.condense&&(b=0,x=0),n.avoidOverlap)for(var w=0;w=c&&(M=0,A++)},"moveToNextCell"),I={},L=0;L(r=ur(t,n,x[w],x[w+1],x[w+2],x[w+3])))return y(e,r),!0}else if("bezier"===i.edgeType||"multibezier"===i.edgeType||"self"===i.edgeType||"compound"===i.edgeType)for(x=i.allpts,w=0;w+5(r=lr(t,n,x[w],x[w+1],x[w+2],x[w+3],x[w+4],x[w+5])))return y(e,r),!0;v=v||a.source,b=b||a.target;var E=s.getArrowWidth(o,u),C=[{name:"source",x:i.arrowStartX,y:i.arrowStartY,angle:i.srcArrowAngle},{name:"target",x:i.arrowEndX,y:i.arrowEndY,angle:i.tgtArrowAngle},{name:"mid-source",x:i.midX,y:i.midY,angle:i.midsrcArrowAngle},{name:"mid-target",x:i.midX,y:i.midY,angle:i.midtgtArrowAngle}];for(w=0;w0&&(m(v),m(b))}function x(e,t,n){return Wt(e,t,n)}function w(r,a){var i,o=r._private,s=g;i=a?a+"-":"",r.boundingBox();var l=o.labelBounds[a||"main"],u=r.pstyle(i+"label").value;if("yes"===r.pstyle("text-events").strValue&&u){var c=x(o.rscratch,"labelX",a),d=x(o.rscratch,"labelY",a),h=x(o.rscratch,"labelAngle",a),f=r.pstyle(i+"text-margin-x").pfValue,p=r.pstyle(i+"text-margin-y").pfValue,v=l.x1-s-f,m=l.x2+s-f,b=l.y1-s-p,w=l.y2+s-p;if(h){var E=Math.cos(h),C=Math.sin(h),T=e(function(e,t){return{x:(e-=c)*E-(t-=d)*C+c,y:e*C+t*E+d}},"rotate"),k=T(v,b),S=T(v,w),P=T(m,b),B=T(m,w),_=[k.x+f,k.y+p,P.x+f,P.y+p,B.x+f,B.y+p,S.x+f,S.y+p];if(cr(t,n,_))return y(r),!0}else if($n(l,t,n))return y(r),!0}}r&&(u=u.interactive),e(y,"addEle"),e(m,"checkNode"),e(b,"checkEdge"),e(x,"preprop"),e(w,"checkLabel");for(var E=u.length-1;E>=0;E--){var C=u[E];C.isNode()?m(C)||w(C):b(C)||w(C)||w(C,"source")||w(C,"target")}return c},getAllInBox:function(t,n,r,a){var i=this.getCachedZSortedEles().interactive,o=2/this.cy.zoom(),s=[],l=Math.min(t,r),u=Math.max(t,r),c=Math.min(n,a),d=Math.max(n,a),h=jn({x1:t=l,y1:n=c,x2:r=u,y2:a=d}),p=[{x:h.x1,y:h.y1},{x:h.x2,y:h.y1},{x:h.x2,y:h.y2},{x:h.x1,y:h.y2}],g=[[p[0],p[1]],[p[1],p[2]],[p[2],p[3]],[p[3],p[0]]];function v(e,t,n){return Wt(e,t,n)}function y(t,n){var r=t._private,a=o;t.boundingBox();var i=r.labelBounds.main;if(!i)return null;var s=v(r.rscratch,"labelX",n),l=v(r.rscratch,"labelY",n),u=v(r.rscratch,"labelAngle",n),c=t.pstyle("text-margin-x").pfValue,d=t.pstyle("text-margin-y").pfValue,h=i.x1-a-c,f=i.x2+a-c,p=i.y1-a-d,g=i.y2+a-d;if(u){var y=Math.cos(u),m=Math.sin(u),b=e(function(e,t){return{x:(e-=s)*y-(t-=l)*m+s,y:e*m+t*y+l}},"rotate");return[b(h,p),b(f,p),b(f,g),b(h,g)]}return[{x:h,y:p},{x:f,y:p},{x:f,y:g},{x:h,y:g}]}function m(t,n,r,a){function i(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}return e(i,"ccw"),i(t,r,a)!==i(n,r,a)&&i(t,n,r)!==i(t,n,a)}e(v,"preprop"),e(y,"getRotatedLabelBox"),e(m,"doLinesIntersect");for(var b=0;b0?-(Math.PI-e.ang):Math.PI+e.ang},"invertVec"),Ih=e(function(e,t,n,r,a){if(e!==_h?Mh(t,e,Dh):Rh(Ah,Dh),Mh(t,n,Ah),gh=Dh.nx*Ah.ny-Dh.ny*Ah.nx,vh=Dh.nx*Ah.nx-Dh.ny*-Ah.ny,bh=Math.asin(Math.max(-1,Math.min(1,gh))),Math.abs(bh)<1e-6)return fh=t.x,ph=t.y,void(wh=Ch=0);yh=1,mh=!1,vh<0?bh<0?bh=Math.PI+bh:(bh=Math.PI-bh,yh=-1,mh=!0):bh>0&&(yh=-1,mh=!0),Ch=void 0!==t.radius?t.radius:r,xh=bh/2,Th=Math.min(Dh.len/2,Ah.len/2),a?(Eh=Math.abs(Math.cos(xh)*Ch/Math.sin(xh)))>Th?(Eh=Th,wh=Math.abs(Eh*Math.sin(xh)/Math.cos(xh))):wh=Ch:(Eh=Math.min(Th,Ch),wh=Math.abs(Eh*Math.sin(xh)/Math.cos(xh))),Ph=t.x+Ah.nx*Eh,Bh=t.y+Ah.ny*Eh,fh=Ph-Ah.ny*wh*yh,ph=Bh+Ah.nx*wh*yh,kh=t.x+Dh.nx*Eh,Sh=t.y+Dh.ny*Eh,_h=t},"calcCornerArc");function Lh(e,t){0===t.radius?e.lineTo(t.cx,t.cy):e.arc(t.cx,t.cy,t.radius,t.startAngle,t.endAngle,t.counterClockwise)}function Nh(e,t,n,r){var a=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];return 0===r||0===t.radius?{cx:t.x,cy:t.y,radius:0,startX:t.x,startY:t.y,stopX:t.x,stopY:t.y,startAngle:void 0,endAngle:void 0,counterClockwise:void 0}:(Ih(e,t,n,r,a),{cx:fh,cy:ph,radius:wh,startX:kh,startY:Sh,stopX:Ph,stopY:Bh,startAngle:Dh.ang+Math.PI/2*yh,endAngle:Ah.ang-Math.PI/2*yh,counterClockwise:mh})}e(Lh,"drawPreparedRoundCorner"),e(Nh,"getRoundCorner");var zh=.01,Oh=Math.sqrt(.02),Fh={};function Vh(e){var t=[];if(null!=e){for(var n=0;n0?Math.max(e-t,0):Math.min(e+t,0)},"subDWH"),B=P(k,C),_=P(S,T),D=!1;"auto"===y?v=Math.abs(B)>Math.abs(_)?i:a:y===u||y===l?(v=a,D=!0):(y===o||y===s)&&(v=i,D=!0);var A,M=v===a,R=M?_:B,I=M?S:k,L=In(I),N=!1;((!D||!b&&!w)&&(y===l&&I<0||y===u&&I>0||y===o&&I>0||y===s&&I<0)&&(R=(L*=-1)*Math.abs(R),N=!0),b)?A=(x<0?1+x:x)*R:A=(x<0?R:0)+x*L;var z=e(function(e){return Math.abs(e)=Math.abs(R)},"getIsTooClose"),O=z(A),F=z(Math.abs(R)-Math.abs(A));if((O||F)&&!N)if(M){var V=Math.abs(I)<=h/2,q=Math.abs(k)<=f/2;if(V){var j=(c.x1+c.x2)/2,X=c.y1,Y=c.y2;r.segpts=[j,X,j,Y]}else if(q){var W=(c.y1+c.y2)/2,H=c.x1,K=c.x2;r.segpts=[H,W,K,W]}else r.segpts=[c.x1,c.y2]}else{var G=Math.abs(I)<=d/2,U=Math.abs(S)<=p/2;if(G){var Z=(c.y1+c.y2)/2,$=c.x1,Q=c.x2;r.segpts=[$,Z,Q,Z]}else if(U){var J=(c.x1+c.x2)/2,ee=c.y1,te=c.y2;r.segpts=[J,ee,J,te]}else r.segpts=[c.x2,c.y1]}else if(M){var ne=c.y1+A+(g?h/2*L:0),re=c.x1,ae=c.x2;r.segpts=[re,ne,ae,ne]}else{var ie=c.x1+A+(g?d/2*L:0),oe=c.y1,se=c.y2;r.segpts=[ie,oe,ie,se]}if(r.isRound){var le=t.pstyle("taxi-radius").value,ue="arc-radius"===t.pstyle("radius-type").value[0];r.radii=new Array(r.segpts.length/2).fill(le),r.isArcRadius=new Array(r.segpts.length/2).fill(ue)}},Fh.tryToCorrectInvalidPoints=function(e,t){var n=e._private.rscratch;if("bezier"===n.edgeType){var r=t.srcPos,a=t.tgtPos,i=t.srcW,o=t.srcH,s=t.tgtW,l=t.tgtH,u=t.srcShape,c=t.tgtShape,d=t.srcCornerRadius,h=t.tgtCornerRadius,f=t.srcRs,p=t.tgtRs,g=!ie(n.startX)||!ie(n.startY),v=!ie(n.arrowStartX)||!ie(n.arrowStartY),y=!ie(n.endX)||!ie(n.endY),m=!ie(n.arrowEndX)||!ie(n.arrowEndY),b=3*(this.getArrowWidth(e.pstyle("width").pfValue,e.pstyle("arrow-scale").value)*this.arrowShapeWidth),x=Ln({x:n.ctrlpts[0],y:n.ctrlpts[1]},{x:n.startX,y:n.startY}),w=xg.poolIndex()){var v=p;p=g,g=v}var y=d.srcPos=p.position(),m=d.tgtPos=g.position(),b=d.srcW=p.outerWidth(),x=d.srcH=p.outerHeight(),w=d.tgtW=g.outerWidth(),C=d.tgtH=g.outerHeight(),T=d.srcShape=r.nodeShapes[n.getNodeShape(p)],k=d.tgtShape=r.nodeShapes[n.getNodeShape(g)],S=d.srcCornerRadius="auto"===p.pstyle("corner-radius").value?"auto":p.pstyle("corner-radius").pfValue,P=d.tgtCornerRadius="auto"===g.pstyle("corner-radius").value?"auto":g.pstyle("corner-radius").pfValue,B=d.tgtRs=g._private.rscratch,_=d.srcRs=p._private.rscratch;d.dirCounts={north:0,west:0,south:0,east:0,northwest:0,southwest:0,northeast:0,southeast:0};for(var D=0;D=Oh||(Y=Math.sqrt(Math.max(X*X,zh)+Math.max(j*j,zh)));var W=d.vector={x:X,y:j},H=d.vectorNorm={x:W.x/Y,y:W.y/Y},K={x:-H.y,y:H.x};d.nodesOverlap=!ie(Y)||k.checkPoint(N[0],N[1],0,w,C,m.x,m.y,P,B)||T.checkPoint(O[0],O[1],0,b,x,y.x,y.y,S,_),d.vectorNormInverse=K,e={nodesOverlap:d.nodesOverlap,dirCounts:d.dirCounts,calculatedIntersection:!0,hasBezier:d.hasBezier,hasUnbundled:d.hasUnbundled,eles:d.eles,srcPos:m,srcRs:B,tgtPos:y,tgtRs:_,srcW:w,srcH:C,tgtW:b,tgtH:x,srcIntn:F,tgtIntn:z,srcShape:k,tgtShape:T,posPts:{x1:q.x2,y1:q.y2,x2:q.x1,y2:q.y1},intersectionPts:{x1:V.x2,y1:V.y2,x2:V.x1,y2:V.y1},vector:{x:-W.x,y:-W.y},vectorNorm:{x:-H.x,y:-H.y},vectorNormInverse:{x:-K.x,y:-K.y}}}var G=L?e:d;M.nodesOverlap=G.nodesOverlap,M.srcIntn=G.srcIntn,M.tgtIntn=G.tgtIntn,M.isRound=R.startsWith("round"),a&&(p.isParent()||p.isChild()||g.isParent()||g.isChild())&&(p.parents().anySame(g)||g.parents().anySame(p)||p.same(g)&&p.isParent())?n.findCompoundLoopPoints(A,G,D,I):p===g?n.findLoopPoints(A,G,D,I):R.endsWith("segments")?n.findSegmentsPoints(A,G):R.endsWith("taxi")?n.findTaxiPoints(A,G):"straight"===R||!I&&d.eles.length%2==1&&D===Math.floor(d.eles.length/2)?n.findStraightEdgePoints(A):n.findBezierPoints(A,G,D,I,L),n.findEndpoints(A),n.tryToCorrectInvalidPoints(A,G),n.checkForInvalidEdgeWarning(A),n.storeAllpts(A),n.storeEdgeProjections(A),n.calculateArrowAngles(A),n.recalculateEdgeLabelProjections(A),n.calculateLabelAngles(A)}},"_loop"),E=0;E0){var Q=u,J=Nn(Q,Sn(i)),ee=Nn(Q,Sn($)),te=J;if(ee2)Nn(Q,{x:$[2],y:$[3]})0){var ge=c,ve=Nn(ge,Sn(i)),ye=Nn(ge,Sn(pe)),me=ve;if(ye2)Nn(ge,{x:pe[2],y:pe[3]})=l||m){c={cp:g,segment:y};break}}if(c)break}var b=c.cp,x=c.segment,w=(l-h)/x.length,E=x.t1-x.t0,C=i?x.t0+E*w:x.t1-E*w;C=qn(0,C,1),n=Fn(b.p0,b.p1,b.p2,C),r=Kh(b.p0,b.p1,b.p2,C);break;case"straight":case"segments":case"haystack":for(var T,k,S,P,B=0,_=a.allpts.length,D=0;D+3<_&&(i?(S={x:a.allpts[D],y:a.allpts[D+1]},P={x:a.allpts[D+2],y:a.allpts[D+3]}):(S={x:a.allpts[_-2-D],y:a.allpts[_-1-D]},P={x:a.allpts[_-4-D],y:a.allpts[_-3-D]}),k=B,!((B+=T=Ln(S,P))>=l));D+=2);var A=(l-k)/T;A=qn(0,A,1),n=Vn(S,P,A),r=Hh(S,P)}s("labelX",e,n.x),s("labelY",e,n.y),s("labelAutoAngle",e,r)}},"calculateEndProjection");c("source"),c("target"),this.applyLabelDimensions(t)}},Yh.applyLabelDimensions=function(e){this.applyPrefixedLabelDimensions(e),e.isEdge()&&(this.applyPrefixedLabelDimensions(e,"source"),this.applyPrefixedLabelDimensions(e,"target"))},Yh.applyPrefixedLabelDimensions=function(e,t){var n=e._private,r=this.getLabelText(e,t),a=mt(r,e._private.labelDimsKey);if(Wt(n.rscratch,"prefixedLabelDimsKey",t)!==a){Ht(n.rscratch,"prefixedLabelDimsKey",t,a);var i=this.calculateLabelDimensions(e,r),o=e.pstyle("line-height").pfValue,s=e.pstyle("text-wrap").strValue,l=Wt(n.rscratch,"labelWrapCachedLines",t)||[],u="wrap"!==s?1:Math.max(l.length,1),c=i.height/u,d=c*o,h=i.width,f=i.height+(u-1)*(o-1)*c;Ht(n.rstyle,"labelWidth",t,h),Ht(n.rscratch,"labelWidth",t,h),Ht(n.rstyle,"labelHeight",t,f),Ht(n.rscratch,"labelHeight",t,f),Ht(n.rscratch,"labelLineHeight",t,d)}},Yh.getLabelText=function(t,n){var r=t._private,a=n?n+"-":"",i=t.pstyle(a+"label").strValue,o=t.pstyle("text-transform").value,l=e(function(e,t){return t?(Ht(r.rscratch,e,n,t),t):Wt(r.rscratch,e,n)},"rscratch");if(!i)return"";"none"==o||("uppercase"==o?i=i.toUpperCase():"lowercase"==o&&(i=i.toLowerCase()));var u=t.pstyle("text-wrap").value;if("wrap"===u){var c=l("labelKey");if(null!=c&&l("labelWrapKey")===c)return l("labelWrapCachedText");for(var d=i.split("\n"),h=t.pstyle("text-max-width").pfValue,f="anywhere"===t.pstyle("text-overflow-wrap").value,p=[],g=/[\s\u200b]+|$/g,v=0;vh){var x,w="",E=0,C=s(y.matchAll(g));try{for(C.s();!(x=C.n()).done;){var T=x.value,k=T[0],S=y.substring(E,T.index);E=T.index+k.length;var P=0===w.length?S:w+S+k;this.calculateLabelDimensions(t,P).width<=h?w+=S+k:(w&&p.push(w),w=S+k)}}catch(e){C.e(e)}finally{C.f()}w.match(/^[\s\u200b]+$/)||p.push(w)}else p.push(y)}l("labelWrapCachedLines",p),i=l("labelWrapCachedText",p.join("\n")),l("labelWrapKey",c)}else if("ellipsis"===u){var B=t.pstyle("text-max-width").pfValue,_="",D=!1;if(this.calculateLabelDimensions(t,i).widthB)break;_+=i[A],A===i.length-1&&(D=!0)}return D||(_+="…"),_}return i},Yh.getLabelJustification=function(e){var t=e.pstyle("text-justification").strValue,n=e.pstyle("text-halign").strValue;if("auto"!==t)return t;if(!e.isNode())return"center";switch(n){case"left":return"right";case"right":return"left";default:return"center"}},Yh.calculateLabelDimensions=function(e,t){var n=this.cy.window().document,r=e.pstyle("font-style").strValue,a=e.pstyle("font-size").pfValue,i=e.pstyle("font-family").strValue,o=e.pstyle("font-weight").strValue,s=this.labelCalcCanvas,l=this.labelCalcCanvasContext;if(!s){s=this.labelCalcCanvas=n.createElement("canvas"),l=this.labelCalcCanvasContext=s.getContext("2d");var u=s.style;u.position="absolute",u.left="-9999px",u.top="-9999px",u.zIndex="-1",u.visibility="hidden",u.pointerEvents="none"}l.font="".concat(r," ").concat(o," ").concat(a,"px ").concat(i);for(var c=0,d=0,h=t.split("\n"),f=0;f1&&void 0!==arguments[1])||arguments[1];if(n.merge(e),t)for(var r=0;r=t.desktopTapThreshold2}var S=o(n);g&&(t.hoverData.tapholdCancelled=!0);var B=e(function(){var e=t.hoverData.dragDelta=t.hoverData.dragDelta||[];0===e.length?(e.push(x[0]),e.push(x[1])):(e[0]+=x[0],e[1]+=x[1])},"updateDragDelta");r=!0,i(p,["mousemove","vmousemove","tapdrag"],n,{x:c[0],y:c[1]});var _=e(function(e){return{originalEvent:n,type:e,position:{x:c[0],y:c[1]}}},"makeEvent"),D=e(function(){t.data.bgActivePosistion=void 0,t.hoverData.selecting||a.emit(_("boxstart")),f[4]=1,t.hoverData.selecting=!0,t.redrawHint("select",!0),t.redraw()},"goIntoBoxMode");if(3===t.hoverData.which){if(g){var A=_("cxtdrag");b?b.emit(A):a.emit(A),t.hoverData.cxtDragged=!0,(!t.hoverData.cxtOver||p!==t.hoverData.cxtOver)&&(t.hoverData.cxtOver&&t.hoverData.cxtOver.emit(_("cxtdragout")),t.hoverData.cxtOver=p,p&&p.emit(_("cxtdragover")))}}else if(t.hoverData.dragging){if(r=!0,a.panningEnabled()&&a.userPanningEnabled()){var M;if(t.hoverData.justStartedPan){var R=t.hoverData.mdownPos;M={x:(c[0]-R[0])*l,y:(c[1]-R[1])*l},t.hoverData.justStartedPan=!1}else M={x:x[0]*l,y:x[1]*l};a.panBy(M),a.emit(_("dragpan")),t.hoverData.dragged=!0}c=t.projectIntoViewport(n.clientX,n.clientY)}else if(1!=f[4]||null!=b&&!b.pannable()){if(b&&b.pannable()&&b.active()&&b.unactivate(),(!b||!b.grabbed())&&p!=y&&(y&&i(y,["mouseout","tapdragout"],n,{x:c[0],y:c[1]}),p&&i(p,["mouseover","tapdragover"],n,{x:c[0],y:c[1]}),t.hoverData.last=p),b)if(g){if(a.boxSelectionEnabled()&&S)b&&b.grabbed()&&(m(w),b.emit(_("freeon")),w.emit(_("free")),t.dragData.didDrag&&(b.emit(_("dragfreeon")),w.emit(_("dragfree")))),D();else if(b&&b.grabbed()&&t.nodeIsDraggable(b)){var I=!t.dragData.didDrag;I&&t.redrawHint("eles",!0),t.dragData.didDrag=!0,t.hoverData.draggingEles||v(w,{inDragLayer:!0});var L={x:0,y:0};if(ie(x[0])&&ie(x[1])&&(L.x+=x[0],L.y+=x[1],I)){var N=t.hoverData.dragDelta;N&&ie(N[0])&&ie(N[1])&&(L.x+=N[0],L.y+=N[1])}t.hoverData.draggingEles=!0,w.silentShift(L).emit(_("position")).emit(_("drag")),t.redrawHint("drag",!0),t.redraw()}}else B();r=!0}else if(g){if(t.hoverData.dragging||!a.boxSelectionEnabled()||!S&&a.panningEnabled()&&a.userPanningEnabled()){if(!t.hoverData.selecting&&a.panningEnabled()&&a.userPanningEnabled()){s(b,t.hoverData.downs)&&(t.hoverData.dragging=!0,t.hoverData.justStartedPan=!0,f[4]=0,t.data.bgActivePosistion=Sn(d),t.redrawHint("select",!0),t.redraw())}}else D();b&&b.pannable()&&b.active()&&b.unactivate()}if(f[2]=c[0],f[3]=c[1],r)return n.stopPropagation&&n.stopPropagation(),n.preventDefault&&n.preventDefault(),!1}},"mousemoveHandler"),!1),t.registerBinding(n,"mouseup",e(function(n){if((1!==t.hoverData.which||1===n.which||!t.hoverData.capture)&&t.hoverData.capture){t.hoverData.capture=!1;var a=t.cy,s=t.projectIntoViewport(n.clientX,n.clientY),l=t.selection,u=t.findNearestElement(s[0],s[1],!0,!1),c=t.dragData.possibleDragElements,d=t.hoverData.down,h=o(n);t.data.bgActivePosistion&&(t.redrawHint("select",!0),t.redraw()),t.hoverData.tapholdCancelled=!0,t.data.bgActivePosistion=void 0,d&&d.unactivate();var f=e(function(e){return{originalEvent:n,type:e,position:{x:s[0],y:s[1]}}},"makeEvent");if(3===t.hoverData.which){var p=f("cxttapend");if(d?d.emit(p):a.emit(p),!t.hoverData.cxtDragged){var g=f("cxttap");d?d.emit(g):a.emit(g)}t.hoverData.cxtDragged=!1,t.hoverData.which=null}else if(1===t.hoverData.which){if(i(u,["mouseup","tapend","vmouseup"],n,{x:s[0],y:s[1]}),!t.dragData.didDrag&&!t.hoverData.dragged&&!t.hoverData.selecting&&!t.hoverData.isOverThresholdDrag&&(i(d,["click","tap","vclick"],n,{x:s[0],y:s[1]}),_=!1,n.timeStamp-D<=a.multiClickDebounceTime()?(B&&clearTimeout(B),_=!0,D=null,i(d,["dblclick","dbltap","vdblclick"],n,{x:s[0],y:s[1]})):(B=setTimeout(function(){_||i(d,["oneclick","onetap","voneclick"],n,{x:s[0],y:s[1]})},a.multiClickDebounceTime()),D=n.timeStamp)),null==d&&!t.dragData.didDrag&&!t.hoverData.selecting&&!t.hoverData.dragged&&!o(n)&&(a.$(r).unselect(["tapunselect"]),c.length>0&&t.redrawHint("eles",!0),t.dragData.possibleDragElements=c=a.collection()),u==d&&!t.dragData.didDrag&&!t.hoverData.selecting&&null!=u&&u._private.selectable&&(t.hoverData.dragging||("additive"===a.selectionType()||h?u.selected()?u.unselect(["tapunselect"]):u.select(["tapselect"]):h||(a.$(r).unmerge(u).unselect(["tapunselect"]),u.select(["tapselect"]))),t.redrawHint("eles",!0)),t.hoverData.selecting){var v=a.collection(t.getAllInBox(l[0],l[1],l[2],l[3]));t.redrawHint("select",!0),v.length>0&&t.redrawHint("eles",!0),a.emit(f("boxend"));var y=e(function(e){return e.selectable()&&!e.selected()},"eleWouldBeSelected");"additive"===a.selectionType()||h||a.$(r).unmerge(v).unselect(),v.emit(f("box")).stdFilter(y).select().emit(f("boxselect")),t.redraw()}if(t.hoverData.dragging&&(t.hoverData.dragging=!1,t.redrawHint("select",!0),t.redrawHint("eles",!0),t.redraw()),!l[4]){t.redrawHint("drag",!0),t.redrawHint("eles",!0);var b=d&&d.grabbed();m(c),b&&(d.emit(f("freeon")),c.emit(f("free")),t.dragData.didDrag&&(d.emit(f("dragfreeon")),c.emit(f("dragfree"))))}}l[4]=0,t.hoverData.down=null,t.hoverData.cxtStarted=!1,t.hoverData.draggingEles=!1,t.hoverData.selecting=!1,t.hoverData.isOverThresholdDrag=!1,t.dragData.didDrag=!1,t.hoverData.dragged=!1,t.hoverData.dragDelta=[],t.hoverData.mdownPos=null,t.hoverData.mdownGPos=null,t.hoverData.which=null}},"mouseupHandler"),!1);var M,R=[],I=1e5,L=e(function(e,t){for(var n=0;n=4){var a=R;if(!(M=L(a,5))){var i=Math.abs(a[0]);M=N(a)&&i>5}if(M)for(var o=0;o5&&(r=5*In(r)),h=r/-250,M&&(h/=I,h*=3),h*=t.wheelSensitivity,1===e.deltaMode&&(h*=33);var f=s.zoom()*Math.pow(10,h);"gesturechange"===e.type&&(f=t.gestureStartZoom*e.scale),s.zoom({level:f,renderedPosition:{x:d[0],y:d[1]}}),s.emit({type:"gesturechange"===e.type?"pinchzoom":"scrollzoom",originalEvent:e,position:{x:c[0],y:c[1]}})}}}},"wheelHandler");t.registerBinding(t.container,"wheel",z,!0),t.registerBinding(n,"scroll",e(function(e){t.scrollingPage=!0,clearTimeout(t.scrollingPageTimeout),t.scrollingPageTimeout=setTimeout(function(){t.scrollingPage=!1},250)},"scrollHandler"),!0),t.registerBinding(t.container,"gesturestart",e(function(e){t.gestureStartZoom=t.cy.zoom(),t.hasTouchStarted||e.preventDefault()},"gestureStartHandler"),!0),t.registerBinding(t.container,"gesturechange",function(e){t.hasTouchStarted||z(e)},!0),t.registerBinding(t.container,"mouseout",e(function(e){var n=t.projectIntoViewport(e.clientX,e.clientY);t.cy.emit({originalEvent:e,type:"mouseout",position:{x:n[0],y:n[1]}})},"mouseOutHandler"),!1),t.registerBinding(t.container,"mouseover",e(function(e){var n=t.projectIntoViewport(e.clientX,e.clientY);t.cy.emit({originalEvent:e,type:"mouseover",position:{x:n[0],y:n[1]}})},"mouseOverHandler"),!1);var O,F,V,q,j,X,Y,W,H,K,G,U,Z,$,Q,J,ee,te,ne,re,ae=e(function(e,t,n,r){return Math.sqrt((n-e)*(n-e)+(r-t)*(r-t))},"distance"),oe=e(function(e,t,n,r){return(n-e)*(n-e)+(r-t)*(r-t)},"distanceSq");if(t.registerBinding(t.container,"touchstart",$=e(function(n){if(t.hasTouchStarted=!0,P(n)){x(),t.touchData.capture=!0,t.data.bgActivePosistion=void 0;var r=t.cy,a=t.touchData.now,o=t.touchData.earlier;if(n.touches[0]){var s=t.projectIntoViewport(n.touches[0].clientX,n.touches[0].clientY);a[0]=s[0],a[1]=s[1]}if(n.touches[1]){s=t.projectIntoViewport(n.touches[1].clientX,n.touches[1].clientY);a[2]=s[0],a[3]=s[1]}if(n.touches[2]){s=t.projectIntoViewport(n.touches[2].clientX,n.touches[2].clientY);a[4]=s[0],a[5]=s[1]}var l=e(function(e){return{originalEvent:n,type:e,position:{x:a[0],y:a[1]}}},"makeEvent");if(n.touches[1]){t.touchData.singleTouchMoved=!0,m(t.dragData.touchDragEles);var u=t.findContainerClientCoords();H=u[0],K=u[1],G=u[2],U=u[3],O=n.touches[0].clientX-H,F=n.touches[0].clientY-K,V=n.touches[1].clientX-H,q=n.touches[1].clientY-K,Z=0<=O&&O<=G&&0<=V&&V<=G&&0<=F&&F<=U&&0<=q&&q<=U;var c=r.pan(),d=r.zoom();j=ae(O,F,V,q),X=oe(O,F,V,q),W=[((Y=[(O+V)/2,(F+q)/2])[0]-c.x)/d,(Y[1]-c.y)/d];if(X<4e4&&!n.touches[2]){var f=t.findNearestElement(a[0],a[1],!0,!0),p=t.findNearestElement(a[2],a[3],!0,!0);return f&&f.isNode()?(f.activate().emit(l("cxttapstart")),t.touchData.start=f):p&&p.isNode()?(p.activate().emit(l("cxttapstart")),t.touchData.start=p):r.emit(l("cxttapstart")),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(n.touches[2])r.boxSelectionEnabled()&&n.preventDefault();else if(!n.touches[1]&&n.touches[0]){var g=t.findNearestElements(a[0],a[1],!0,!0),b=g[0];if(null!=b&&(b.activate(),t.touchData.start=b,t.touchData.starts=g,t.nodeIsGrabbable(b))){var w=t.dragData.touchDragEles=r.collection(),E=null;t.redrawHint("eles",!0),t.redrawHint("drag",!0),b.selected()?(E=r.$(function(e){return e.selected()&&t.nodeIsGrabbable(e)}),v(E,{addToList:w})):y(b,{addToList:w}),h(b),b.emit(l("grabon")),E?E.forEach(function(e){e.emit(l("grab"))}):b.emit(l("grab"))}i(b,["touchstart","tapstart","vmousedown"],n,{x:a[0],y:a[1]}),null==b&&(t.data.bgActivePosistion={x:s[0],y:s[1]},t.redrawHint("select",!0),t.redraw()),t.touchData.singleTouchMoved=!1,t.touchData.singleTouchStartTime=+new Date,clearTimeout(t.touchData.tapholdTimeout),t.touchData.tapholdTimeout=setTimeout(function(){!1===t.touchData.singleTouchMoved&&!t.pinching&&!t.touchData.selecting&&i(t.touchData.start,["taphold"],n,{x:a[0],y:a[1]})},t.tapholdDuration)}if(n.touches.length>=1){for(var C=t.touchData.startPosition=[null,null,null,null,null,null],T=0;T=t.touchTapThreshold2}if(r&&t.touchData.cxt){n.preventDefault();var E=n.touches[0].clientX-H,C=n.touches[0].clientY-K,T=n.touches[1].clientX-H,k=n.touches[1].clientY-K,S=oe(E,C,T,k);if(S/X>=2.25||S>=22500){t.touchData.cxt=!1,t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);var B=f("cxttapend");t.touchData.start?(t.touchData.start.unactivate().emit(B),t.touchData.start=null):o.emit(B)}}if(r&&t.touchData.cxt){B=f("cxtdrag");t.data.bgActivePosistion=void 0,t.redrawHint("select",!0),t.touchData.start?t.touchData.start.emit(B):o.emit(B),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.emit(f("cxtdragout")),t.touchData.cxtOver=_,_&&_.emit(f("cxtdragover")))}else if(r&&n.touches[2]&&o.boxSelectionEnabled())n.preventDefault(),t.data.bgActivePosistion=void 0,this.lastThreeTouch=+new Date,t.touchData.selecting||o.emit(f("boxstart")),t.touchData.selecting=!0,t.touchData.didSelect=!0,a[4]=1,a&&0!==a.length&&void 0!==a[0]?(a[2]=(l[0]+l[2]+l[4])/3,a[3]=(l[1]+l[3]+l[5])/3):(a[0]=(l[0]+l[2]+l[4])/3,a[1]=(l[1]+l[3]+l[5])/3,a[2]=(l[0]+l[2]+l[4])/3+1,a[3]=(l[1]+l[3]+l[5])/3+1),t.redrawHint("select",!0),t.redraw();else if(r&&n.touches[1]&&!t.touchData.didSelect&&o.zoomingEnabled()&&o.panningEnabled()&&o.userZoomingEnabled()&&o.userPanningEnabled()){if(n.preventDefault(),t.data.bgActivePosistion=void 0,t.redrawHint("select",!0),J=t.dragData.touchDragEles){t.redrawHint("drag",!0);for(var D=0;D0&&!t.hoverData.draggingEles&&!t.swipePanning&&null!=t.data.bgActivePosistion&&(t.data.bgActivePosistion=void 0,t.redrawHint("select",!0),t.redraw())}},"touchmoveHandler"),!1),t.registerBinding(n,"touchcancel",J=e(function(e){var n=t.touchData.start;t.touchData.capture=!1,n&&n.unactivate()},"touchcancelHandler")),t.registerBinding(n,"touchend",ee=e(function(n){var a=t.touchData.start;if(t.touchData.capture){0===n.touches.length&&(t.touchData.capture=!1),n.preventDefault();var o=t.selection;t.swipePanning=!1,t.hoverData.draggingEles=!1;var s=t.cy,l=s.zoom(),u=t.touchData.now,c=t.touchData.earlier;if(n.touches[0]){var d=t.projectIntoViewport(n.touches[0].clientX,n.touches[0].clientY);u[0]=d[0],u[1]=d[1]}if(n.touches[1]){d=t.projectIntoViewport(n.touches[1].clientX,n.touches[1].clientY);u[2]=d[0],u[3]=d[1]}if(n.touches[2]){d=t.projectIntoViewport(n.touches[2].clientX,n.touches[2].clientY);u[4]=d[0],u[5]=d[1]}var h,f=e(function(e){return{originalEvent:n,type:e,position:{x:u[0],y:u[1]}}},"makeEvent");if(a&&a.unactivate(),t.touchData.cxt){if(h=f("cxttapend"),a?a.emit(h):s.emit(h),!t.touchData.cxtDragged){var p=f("cxttap");a?a.emit(p):s.emit(p)}return t.touchData.start&&(t.touchData.start._private.grabbed=!1),t.touchData.cxt=!1,t.touchData.start=null,void t.redraw()}if(!n.touches[2]&&s.boxSelectionEnabled()&&t.touchData.selecting){t.touchData.selecting=!1;var g=s.collection(t.getAllInBox(o[0],o[1],o[2],o[3]));o[0]=void 0,o[1]=void 0,o[2]=void 0,o[3]=void 0,o[4]=0,t.redrawHint("select",!0),s.emit(f("boxend"));var v=e(function(e){return e.selectable()&&!e.selected()},"eleWouldBeSelected");g.emit(f("box")).stdFilter(v).select().emit(f("boxselect")),g.nonempty()&&t.redrawHint("eles",!0),t.redraw()}if(a?.unactivate(),n.touches[2])t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);else if(!n.touches[1]&&!n.touches[0]&&!n.touches[0]){t.data.bgActivePosistion=void 0,t.redrawHint("select",!0);var y=t.dragData.touchDragEles;if(null!=a){var b=a._private.grabbed;m(y),t.redrawHint("drag",!0),t.redrawHint("eles",!0),b&&(a.emit(f("freeon")),y.emit(f("free")),t.dragData.didDrag&&(a.emit(f("dragfreeon")),y.emit(f("dragfree")))),i(a,["touchend","tapend","vmouseup","tapdragout"],n,{x:u[0],y:u[1]}),a.unactivate(),t.touchData.start=null}else{var x=t.findNearestElement(u[0],u[1],!0,!0);i(x,["touchend","tapend","vmouseup","tapdragout"],n,{x:u[0],y:u[1]})}var w=t.touchData.startPosition[0]-u[0],E=w*w,C=t.touchData.startPosition[1]-u[1],T=(E+C*C)*l*l;t.touchData.singleTouchMoved||(a||s.$(":selected").unselect(["tapunselect"]),i(a,["tap","vclick"],n,{x:u[0],y:u[1]}),te=!1,n.timeStamp-re<=s.multiClickDebounceTime()?(ne&&clearTimeout(ne),te=!0,re=null,i(a,["dbltap","vdblclick"],n,{x:u[0],y:u[1]})):(ne=setTimeout(function(){te||i(a,["onetap","voneclick"],n,{x:u[0],y:u[1]})},s.multiClickDebounceTime()),re=n.timeStamp)),null!=a&&!t.dragData.didDrag&&a._private.selectable&&T"u"){var se=[],le=e(function(e){return{clientX:e.clientX,clientY:e.clientY,force:1,identifier:e.pointerId,pageX:e.pageX,pageY:e.pageY,radiusX:e.width/2,radiusY:e.height/2,screenX:e.screenX,screenY:e.screenY,target:e.target}},"makeTouch"),ue=e(function(e){return{event:e,touch:le(e)}},"makePointer"),ce=e(function(e){se.push(ue(e))},"addPointer"),de=e(function(e){for(var t=0;t0)return f[0]}return null},"getCurveT"),p=Object.keys(h),g=0;g0?u:rr(a,i,e,t,n,r,o,s)},"intersectLine"),checkPoint:e(function(e,t,n,r,a,i,o,s){var l=2*(s="auto"===s?Pr(r,a):s);if(dr(e,t,this.points,i,o,r,a-l,[0,-1],n)||dr(e,t,this.points,i,o,r-l,a,[0,-1],n))return!0;var u=r/2+2*n,c=a/2+2*n;return!!(cr(e,t,[i-u,o-c,i-u,o,i+u,o,i+u,o-c])||vr(e,t,l,l,i+r/2-s,o+a/2-s,n)||vr(e,t,l,l,i-r/2+s,o+a/2-s,n))},"checkPoint")}},registerNodeShapes:function(){var e=this.nodeShapes={},t=this;this.generateEllipse(),this.generatePolygon("triangle",Tr(3,0)),this.generateRoundPolygon("round-triangle",Tr(3,0)),this.generatePolygon("rectangle",Tr(4,0)),e.square=e.rectangle,this.generateRoundRectangle(),this.generateCutRectangle(),this.generateBarrel(),this.generateBottomRoundrectangle();var n=[0,1,1,0,0,-1,-1,0];this.generatePolygon("diamond",n),this.generateRoundPolygon("round-diamond",n),this.generatePolygon("pentagon",Tr(5,0)),this.generateRoundPolygon("round-pentagon",Tr(5,0)),this.generatePolygon("hexagon",Tr(6,0)),this.generateRoundPolygon("round-hexagon",Tr(6,0)),this.generatePolygon("heptagon",Tr(7,0)),this.generateRoundPolygon("round-heptagon",Tr(7,0)),this.generatePolygon("octagon",Tr(8,0)),this.generateRoundPolygon("round-octagon",Tr(8,0));var r=new Array(20),a=Sr(5,0),i=Sr(5,Math.PI/5),o=.5*(3-Math.sqrt(5));o*=1.57;for(var s=0;s=t.deqFastCost*g)break}else if(e){if(f>=t.deqCost*l||f>=t.deqAvgCost*s)break}else if(p>=t.deqNoDrawCost*sf)break;var v=t.deq(n,d,c);if(!(v.length>0))break;for(var y=0;y0&&(t.onDeqd(n,u),!e&&t.shouldRedraw(n,u,d,c)&&a())},"dequeue"),o=t.priority||At;r.beforeRender(i,o(n))}},"setupDequeueingImpl")},"setupDequeueing")},uf=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_t;a(this,t),this.idsByKey=new Gt,this.keyForId=new Gt,this.cachesByLvl=new Gt,this.lvls=[],this.getKey=e,this.doesEleInvalidateKey=n}return e(t,"ElementTextureCacheLookup"),o(t,[{key:"getIdsFor",value:e(function(e){null==e&&Mt("Can not get id list for null key");var t=this.idsByKey,n=this.idsByKey.get(e);return n||(n=new Zt,t.set(e,n)),n},"getIdsFor")},{key:"addIdForKey",value:e(function(e,t){null!=e&&this.getIdsFor(e).add(t)},"addIdForKey")},{key:"deleteIdForKey",value:e(function(e,t){null!=e&&this.getIdsFor(e).delete(t)},"deleteIdForKey")},{key:"getNumberOfIdsForKey",value:e(function(e){return null==e?0:this.getIdsFor(e).size},"getNumberOfIdsForKey")},{key:"updateKeyMappingFor",value:e(function(e){var t=e.id(),n=this.keyForId.get(t),r=this.getKey(e);this.deleteIdForKey(n,t),this.addIdForKey(r,t),this.keyForId.set(t,r)},"updateKeyMappingFor")},{key:"deleteKeyMappingFor",value:e(function(e){var t=e.id(),n=this.keyForId.get(t);this.deleteIdForKey(n,t),this.keyForId.delete(t)},"deleteKeyMappingFor")},{key:"keyHasChangedFor",value:e(function(e){var t=e.id();return this.keyForId.get(t)!==this.getKey(e)},"keyHasChangedFor")},{key:"isInvalid",value:e(function(e){return this.keyHasChangedFor(e)||this.doesEleInvalidateKey(e)},"isInvalid")},{key:"getCachesAt",value:e(function(e){var t=this.cachesByLvl,n=this.lvls,r=t.get(e);return r||(r=new Gt,t.set(e,r),n.push(e)),r},"getCachesAt")},{key:"getCache",value:e(function(e,t){return this.getCachesAt(t).get(e)},"getCache")},{key:"get",value:e(function(e,t){var n=this.getKey(e),r=this.getCache(n,t);return null!=r&&this.updateKeyMappingFor(e),r},"get")},{key:"getForCachedKey",value:e(function(e,t){var n=this.keyForId.get(e.id());return this.getCache(n,t)},"getForCachedKey")},{key:"hasCache",value:e(function(e,t){return this.getCachesAt(t).has(e)},"hasCache")},{key:"has",value:e(function(e,t){var n=this.getKey(e);return this.hasCache(n,t)},"has")},{key:"setCache",value:e(function(e,t,n){n.key=e,this.getCachesAt(t).set(e,n)},"setCache")},{key:"set",value:e(function(e,t,n){var r=this.getKey(e);this.setCache(r,t,n),this.updateKeyMappingFor(e)},"set")},{key:"deleteCache",value:e(function(e,t){this.getCachesAt(t).delete(e)},"deleteCache")},{key:"delete",value:e(function(e,t){var n=this.getKey(e);this.deleteCache(n,t)},"_delete")},{key:"invalidateKey",value:e(function(e){var t=this;this.lvls.forEach(function(n){return t.deleteCache(e,n)})},"invalidateKey")},{key:"invalidate",value:e(function(e){var t=e.id(),n=this.keyForId.get(t);this.deleteKeyMappingFor(e);var r=this.doesEleInvalidateKey(e);return r&&this.invalidateKey(n),r||0===this.getNumberOfIdsForKey(n)},"invalidate")}])}(),cf={dequeue:"dequeue",downscale:"downscale",highQuality:"highQuality"},df=qt({getKey:null,doesEleInvalidateKey:_t,drawElement:null,getBoundingBox:null,getRotationPoint:null,getRotationOffset:null,isVisible:Bt,allowEdgeTxrCaching:!0,allowParentTxrCaching:!0}),hf=e(function(e,t){var n=this;n.renderer=e,n.onDequeues=[];var r=df(t);Me(n,r),n.lookup=new uf(r.getKey,r.doesEleInvalidateKey),n.setupDequeueing()},"ElementTextureCache"),ff=hf.prototype;ff.reasons=cf,ff.getTextureQueue=function(e){var t=this;return t.eleImgCaches=t.eleImgCaches||{},t.eleImgCaches[e]=t.eleImgCaches[e]||[]},ff.getRetiredTextureQueue=function(e){var t=this.eleImgCaches.retired=this.eleImgCaches.retired||{};return t[e]=t[e]||[]},ff.getElementQueue=function(){return this.eleCacheQueue=this.eleCacheQueue||new un(function(e,t){return t.reqs-e.reqs})},ff.getElementKeyToQueue=function(){return this.eleKeyToCacheQueue=this.eleKeyToCacheQueue||{}},ff.getElement=function(t,n,r,a,i){var o=this,s=this.renderer,l=s.cy.zoom(),u=this.lookup;if(!n||0===n.w||0===n.h||isNaN(n.w)||isNaN(n.h)||!t.visible()||t.removed()||!o.allowEdgeTxrCaching&&t.isEdge()||!o.allowParentTxrCaching&&t.isParent())return null;if(null==a&&(a=Math.ceil(Rn(l*r))),a<-4)a=-4;else if(l>=7.99||a>3)return null;var c=Math.pow(2,a),d=n.h*c,h=n.w*c,f=s.eleTextBiggerThanMin(t,c);if(!this.isVisible(t,f))return null;var p,g=u.get(t,a);if(g&&g.invalidated&&(g.invalidated=!1,g.texture.invalidatedWidth-=g.width),g)return g;if(p=d<=25?25:d<=50?50:50*Math.ceil(d/50),d>1024||h>1024)return null;var v=o.getTextureQueue(p),y=v[v.length-2],m=e(function(){return o.recycleTexture(p,h)||o.addTexture(p,h)},"addNewTxr");y||(y=v[v.length-1]),y||(y=m()),y.width-y.usedWidtha;B--)S=o.getElement(t,n,r,B,cf.downscale);P()}else{var _;if(!w&&!E&&!C)for(var D=a-1;D>=-4;D--){var A=u.get(t,D);if(A){_=A;break}}if(x(_))return o.queueElement(t,a),_;y.context.translate(y.usedWidth,0),y.context.scale(c,c),this.drawElement(y.context,t,n,f,!1),y.context.scale(1/c,1/c),y.context.translate(-y.usedWidth,0)}return g={x:y.usedWidth,texture:y,level:a,scale:c,width:h,height:d,scaledLabelShown:f},y.usedWidth+=Math.ceil(h+8),y.eleCaches.push(g),u.set(t,a,g),o.checkTextureFullness(y),g},ff.invalidateElements=function(e){for(var t=0;t=.2*e.width&&this.retireTexture(e)},ff.checkTextureFullness=function(e){var t=this.getTextureQueue(e.height);e.usedWidth/e.width>.8&&e.fullnessChecks>=10?jt(t,e):e.fullnessChecks++},ff.retireTexture=function(e){var t=e.height,n=this.getTextureQueue(t),r=this.lookup;jt(n,e),e.retired=!0;for(var a=e.eleCaches,i=0;i=t)return i.retired=!1,i.usedWidth=0,i.invalidatedWidth=0,i.fullnessChecks=0,Xt(i.eleCaches),i.context.setTransform(1,0,0,1,0,0),i.context.clearRect(0,0,i.width,i.height),jt(r,i),n.push(i),i}},ff.queueElement=function(e,t){var n=this.getElementQueue(),r=this.getElementKeyToQueue(),a=this.getKey(e),i=r[a];if(i)i.level=Math.max(i.level,t),i.eles.merge(e),i.reqs++,n.updateItem(i);else{var o={eles:e.spawn().merge(e),level:t,reqs:1,key:a};n.push(o),r[a]=o}},ff.dequeue=function(e){for(var t=this,n=t.getElementQueue(),r=t.getElementKeyToQueue(),a=[],i=t.lookup,o=0;o<1&&n.size()>0;o++){var s=n.pop(),l=s.key,u=s.eles[0],c=i.hasCache(u,s.level);if(r[l]=null,!c){a.push(s);var d=t.getBoundingBox(u);t.getElement(u,d,e,s.level,cf.dequeue)}}return a},ff.removeFromQueue=function(e){var t=this.getElementQueue(),n=this.getElementKeyToQueue(),r=this.getKey(e),a=n[r];null!=a&&(1===a.eles.length?(a.reqs=Pt,t.updateItem(a),t.pop(),n[r]=null):a.eles.unmerge(e))},ff.onDequeue=function(e){this.onDequeues.push(e)},ff.offDequeue=function(e){jt(this.onDequeues,e)},ff.setupDequeueing=lf.setupDequeueing({deqRedrawThreshold:100,deqCost:.15,deqAvgCost:.1,deqNoDrawCost:.9,deqFastCost:.9,deq:e(function(e,t,n){return e.dequeue(t,n)},"deq"),onDeqd:e(function(e,t){for(var n=0;n=3.99||r>2)return null;a.validateLayersElesOrdering(r,t);var s,l,u=a.layersByLevel,c=Math.pow(2,r),d=u[r]=u[r]||[],h=a.levelIsComplete(r,t),f=e(function(){var n=e(function(e){if(a.validateLayersElesOrdering(e,t),a.levelIsComplete(e,t))return l=u[e],!0},"canUseAsTmpLvl"),i=e(function(e){if(!l)for(var t=r+e;-4<=t&&t<=2&&!n(t);t+=e);},"checkLvls");i(1),i(-1);for(var o=d.length-1;o>=0;o--){var s=d[o];s.invalid&&jt(d,s)}},"checkTempLevels");if(h)return d;f();var p=e(function(){if(!s){s=jn();for(var e=0;e32767||i>32767)return null;if(n*i>16e6)return null;var o=a.makeLayer(s,r);if(null!=t){var l=d.indexOf(t)+1;d.splice(l,0,o)}else(void 0===e.insert||e.insert)&&d.unshift(o);return o},"makeLayer");if(a.skipping&&!o)return null;for(var v=null,y=t.length/1,m=!o,b=0;b=y||!Jn(v.bb,x.boundingBox()))&&!(v=g({insert:!0,after:v})))return null;l||m?a.queueLayer(v,x):a.drawEleInLayer(v,x,r,n),v.eles.push(x),E[r]=v}}return l||(m?null:d)},gf.getEleLevelForLayerLevel=function(e,t){return e},gf.drawEleInLayer=function(e,t,n,r){var a=this.renderer,i=e.context,o=t.boundingBox();0===o.w||0===o.h||!t.visible()||(n=this.getEleLevelForLayerLevel(n,r),a.setImgSmoothing(i,!1),a.drawCachedElement(i,t,null,null,n,true),a.setImgSmoothing(i,!0))},gf.levelIsComplete=function(e,t){var n=this.layersByLevel[e];if(!n||0===n.length)return!1;for(var r=0,a=0;a0||i.invalid)return!1;r+=i.eles.length}return r===t.length},gf.validateLayersElesOrdering=function(e,t){var n=this.layersByLevel[e];if(n)for(var r=0;r0){e=!0;break}}return e},gf.invalidateElements=function(t){var n=this;0!==t.length&&(n.lastInvalidationTime=lt(),0!==t.length&&n.haveLayers()&&n.updateElementsInLayers(t,e(function(e,t,r){n.invalidateLayer(e)},"invalAssocLayers")))},gf.invalidateLayer=function(e){if(this.lastInvalidationTime=lt(),!e.invalid){var t=e.level,n=e.eles,r=this.layersByLevel[t];jt(r,e),e.elesQueue=[],e.invalid=!0,e.replacement&&(e.replacement.invalid=!0);for(var a=0;a3&&void 0!==arguments[3])||arguments[3],i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],s=this,l=n._private.rscratch;if((!o||n.visible())&&!l.badLine&&null!=l.allpts&&!isNaN(l.allpts[0])){var u;r&&(u=r,t.translate(-u.x1,-u.y1));var c=o?n.pstyle("opacity").value:1,d=o?n.pstyle("line-opacity").value:1,h=n.pstyle("curve-style").value,f=n.pstyle("line-style").value,p=n.pstyle("width").pfValue,g=n.pstyle("line-cap").value,v=n.pstyle("line-outline-width").value,y=n.pstyle("line-outline-color").value,m=c*d,b=c*d,x=e(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:m;"straight-triangle"===h?(s.eleStrokeStyle(t,n,e),s.drawEdgeTrianglePath(n,t,l.allpts)):(t.lineWidth=p,t.lineCap=g,s.eleStrokeStyle(t,n,e),s.drawEdgePath(n,t,l.allpts,f),t.lineCap="butt")},"drawLine"),w=e(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:m;t.lineWidth=p+v,t.lineCap=g,v>0?(s.colorStrokeStyle(t,y[0],y[1],y[2],e),"straight-triangle"===h?s.drawEdgeTrianglePath(n,t,l.allpts):(s.drawEdgePath(n,t,l.allpts,f),t.lineCap="butt")):t.lineCap="butt"},"drawLineOutline"),E=e(function(){i&&s.drawEdgeOverlay(t,n)},"drawOverlay"),C=e(function(){i&&s.drawEdgeUnderlay(t,n)},"drawUnderlay"),T=e(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:b;s.drawArrowheads(t,n,e)},"drawArrows"),k=e(function(){s.drawElementText(t,n,null,a)},"drawText");if(t.lineJoin="round","yes"===n.pstyle("ghost").value){var S=n.pstyle("ghost-offset-x").pfValue,P=n.pstyle("ghost-offset-y").pfValue,B=n.pstyle("ghost-opacity").value,_=m*B;t.translate(S,P),x(_),T(_),t.translate(-S,-P)}else w();C(),x(),T(),E(),k(),r&&t.translate(u.x1,u.y1)}}},Rf=e(function(e){if(!["overlay","underlay"].includes(e))throw new Error("Invalid state");return function(t,n){if(n.visible()){var r=n.pstyle("".concat(e,"-opacity")).value;if(0!==r){var a=this,i=a.usePaths(),o=n._private.rscratch,s=2*n.pstyle("".concat(e,"-padding")).pfValue,l=n.pstyle("".concat(e,"-color")).value;t.lineWidth=s,"self"!==o.edgeType||i?t.lineCap="round":t.lineCap="butt",a.colorStrokeStyle(t,l[0],l[1],l[2],r),a.drawEdgePath(n,t,o.allpts,"solid")}}}},"drawEdgeOverlayUnderlay");Mf.drawEdgeOverlay=Rf("overlay"),Mf.drawEdgeUnderlay=Rf("underlay"),Mf.drawEdgePath=function(e,t,n,r){var a,i=e._private.rscratch,o=t,l=!1,u=this.usePaths(),c=e.pstyle("line-dash-pattern").pfValue,d=e.pstyle("line-dash-offset").pfValue;if(u){var h=n.join("$");i.pathCacheKey&&i.pathCacheKey===h?(a=t=i.pathCache,l=!0):(a=t=new Path2D,i.pathCacheKey=h,i.pathCache=a)}if(o.setLineDash)switch(r){case"dotted":o.setLineDash([1,1]);break;case"dashed":o.setLineDash(c),o.lineDashOffset=d;break;case"solid":o.setLineDash([])}if(!l&&!i.badLine)switch(t.beginPath&&t.beginPath(),t.moveTo(n[0],n[1]),i.edgeType){case"bezier":case"self":case"compound":case"multibezier":for(var f=2;f+35&&void 0!==arguments[5]?arguments[5]:5,o=Math.min(i,r/2,a/2);e.beginPath(),e.moveTo(t+o,n),e.lineTo(t+r-o,n),e.quadraticCurveTo(t+r,n,t+r,n+o),e.lineTo(t+r,n+a-o),e.quadraticCurveTo(t+r,n+a,t+r-o,n+a),e.lineTo(t+o,n+a),e.quadraticCurveTo(t,n+a,t,n+a-o),e.lineTo(t,n+o),e.quadraticCurveTo(t,n,t+o,n),e.closePath()}Lf.eleTextBiggerThanMin=function(e,t){if(!t){var n=e.cy().zoom(),r=this.getPixelRatio(),a=Math.ceil(Rn(n*r));t=Math.pow(2,a)}return!(e.pstyle("font-size").pfValue*t5&&void 0!==arguments[5])||arguments[5],o=this;if(null==r){if(i&&!o.eleTextBiggerThanMin(t))return}else if(!1===r)return;if(t.isNode()){var s=t.pstyle("label");if(!s||!s.value)return;var l=o.getLabelJustification(t);e.textAlign=l,e.textBaseline="bottom"}else{var u=t.element()._private.rscratch.badLine,c=t.pstyle("label"),d=t.pstyle("source-label"),h=t.pstyle("target-label");if(u||(!c||!c.value)&&(!d||!d.value)&&(!h||!h.value))return;e.textAlign="center",e.textBaseline="bottom"}var f,p=!n;n&&(f=n,e.translate(-f.x1,-f.y1)),null==a?(o.drawText(e,t,null,p,i),t.isEdge()&&(o.drawText(e,t,"source",p,i),o.drawText(e,t,"target",p,i))):o.drawText(e,t,a,p,i),n&&e.translate(f.x1,f.y1)},Lf.getFontCache=function(e){var t;this.fontCaches=this.fontCaches||[];for(var n=0;n2&&void 0!==arguments[2])||arguments[2],r=t.pstyle("font-style").strValue,a=t.pstyle("font-size").pfValue+"px",i=t.pstyle("font-family").strValue,o=t.pstyle("font-weight").strValue,s=n?t.effectiveOpacity()*t.pstyle("text-opacity").value:1,l=t.pstyle("text-outline-opacity").value*s,u=t.pstyle("color").value,c=t.pstyle("text-outline-color").value;e.font=r+" "+o+" "+a+" "+i,e.lineJoin="round",this.colorFillStyle(e,u[0],u[1],u[2],s),this.colorStrokeStyle(e,c[0],c[1],c[2],l)},e(Nf,"circle"),e(zf,"roundRect"),Lf.getTextAngle=function(e,t){var n,r=e._private.rscratch,a=t?t+"-":"",i=e.pstyle(a+"text-rotation");if("autorotate"===i.strValue){var o=Wt(r,"labelAngle",t);n=e.isEdge()?o:0}else n="none"===i.strValue?0:i.pfValue;return n},Lf.drawText=function(e,t,n){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],i=t._private.rscratch,o=a?t.effectiveOpacity():1;if(!a||0!==o&&0!==t.pstyle("text-opacity").value){"main"===n&&(n=null);var s,l,u=Wt(i,"labelX",n),c=Wt(i,"labelY",n),d=this.getLabelText(t,n);if(null!=d&&""!==d&&!isNaN(u)&&!isNaN(c)){this.setupTextStyle(e,t,a);var h,f=n?n+"-":"",p=Wt(i,"labelWidth",n),g=Wt(i,"labelHeight",n),v=t.pstyle(f+"text-margin-x").pfValue,y=t.pstyle(f+"text-margin-y").pfValue,m=t.isEdge(),b=t.pstyle("text-halign").value,x=t.pstyle("text-valign").value;switch(m&&(b="center",x="center"),u+=v,c+=y,0!==(h=r?this.getTextAngle(t,n):0)&&(s=u,l=c,e.translate(s,l),e.rotate(h),u=0,c=0),x){case"top":break;case"center":c+=g/2;break;case"bottom":c+=g}var w=t.pstyle("text-background-opacity").value,E=t.pstyle("text-border-opacity").value,C=t.pstyle("text-border-width").pfValue,T=t.pstyle("text-background-padding").pfValue,k=t.pstyle("text-background-shape").strValue,S="round-rectangle"===k||"roundrectangle"===k,P="circle"===k;if(w>0||C>0&&E>0){var B=e.fillStyle,_=e.strokeStyle,D=e.lineWidth,A=t.pstyle("text-background-color").value,M=t.pstyle("text-border-color").value,R=t.pstyle("text-border-style").value,I=w>0,L=C>0&&E>0,N=u-T;switch(b){case"left":N-=p;break;case"center":N-=p/2}var z=c-g-T,O=p+2*T,F=g+2*T;if(I&&(e.fillStyle="rgba(".concat(A[0],",").concat(A[1],",").concat(A[2],",").concat(w*o,")")),L&&(e.strokeStyle="rgba(".concat(M[0],",").concat(M[1],",").concat(M[2],",").concat(E*o,")"),e.lineWidth=C,e.setLineDash))switch(R){case"dotted":e.setLineDash([1,1]);break;case"dashed":e.setLineDash([4,2]);break;case"double":e.lineWidth=C/4,e.setLineDash([]);break;default:e.setLineDash([])}if(S?(e.beginPath(),zf(e,N,z,O,F,2)):P?(e.beginPath(),Nf(e,N,z,O,F)):(e.beginPath(),e.rect(N,z,O,F)),I&&e.fill(),L&&e.stroke(),L&&"double"===R){var V=C/2;e.beginPath(),S?zf(e,N+V,z+V,O-2*V,F-2*V,2):e.rect(N+V,z+V,O-2*V,F-2*V),e.stroke()}e.fillStyle=B,e.strokeStyle=_,e.lineWidth=D,e.setLineDash&&e.setLineDash([])}var q=2*t.pstyle("text-outline-width").pfValue;if(q>0&&(e.lineWidth=q),"wrap"===t.pstyle("text-wrap").value){var j=Wt(i,"labelWrapCachedLines",n),X=Wt(i,"labelLineHeight",n),Y=p/2,W=this.getLabelJustification(t);switch("auto"===W||("left"===b?"left"===W?u+=-p:"center"===W&&(u+=-Y):"center"===b?"left"===W?u+=-Y:"right"===W&&(u+=Y):"right"===b&&("center"===W?u+=Y:"right"===W&&(u+=p))),x){case"top":case"center":case"bottom":c-=(j.length-1)*X}for(var H=0;H0&&e.strokeText(j[H],u,c),e.fillText(j[H],u,c),c+=X}else q>0&&e.strokeText(d,u,c),e.fillText(d,u,c);0!==h&&(e.rotate(-h),e.translate(-s,-l))}}};var Of={drawNode:function(t,n,r){var a,i,o=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],s=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],l=!(arguments.length>5&&void 0!==arguments[5])||arguments[5],u=this,c=n._private,d=c.rscratch,h=n.position();if(ie(h.x)&&ie(h.y)&&(!l||n.visible())){var f,p,g=l?n.effectiveOpacity():1,v=u.usePaths(),y=!1,m=n.padding();a=n.width()+2*m,i=n.height()+2*m,r&&(p=r,t.translate(-p.x1,-p.y1));for(var b=n.pstyle("background-image").value,x=new Array(b.length),w=new Array(b.length),E=0,C=0;C0&&void 0!==arguments[0]?arguments[0]:B;u.eleFillStyle(t,n,e)},"setupShapeColor"),Y=e(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:N;u.colorStrokeStyle(t,_[0],_[1],_[2],e)},"setupBorderColor"),W=e(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:V;u.colorStrokeStyle(t,O[0],O[1],O[2],e)},"setupOutlineColor"),H=e(function(e,t,n,r){var a,i=u.nodePathCache=u.nodePathCache||[],o=bt("polygon"===n?n+","+r.join(","):n,""+t,""+e,""+j),s=i[o],l=!1;return null!=s?(a=s,l=!0,d.pathCache=a):(a=new Path2D,i[o]=d.pathCache=a),{path:a,cacheHit:l}},"getPath"),K=n.pstyle("shape").strValue,G=n.pstyle("shape-polygon-points").pfValue;if(v){t.translate(h.x,h.y);var U=H(a,i,K,G);f=U.path,y=U.cacheHit}var Z=e(function(){if(!y){var e=h;v&&(e={x:0,y:0}),u.nodeShapes[u.getNodeShape(n)].draw(f||t,e.x,e.y,a,i,j,d)}v?t.fill(f):t.fill()},"drawShape"),$=e(function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:g,r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=c.backgrounding,i=0,o=0;o0&&void 0!==arguments[0]&&arguments[0],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:g;u.hasPie(n)&&(u.drawPie(t,n,r),e&&(v||u.nodeShapes[u.getNodeShape(n)].draw(t,h.x,h.y,a,i,j,d)))},"drawPie"),J=e(function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:g;u.hasStripe(n)&&(t.save(),v?t.clip(d.pathCache):(u.nodeShapes[u.getNodeShape(n)].draw(t,h.x,h.y,a,i,j,d),t.clip()),u.drawStripe(t,n,r),t.restore(),e&&(v||u.nodeShapes[u.getNodeShape(n)].draw(t,h.x,h.y,a,i,j,d)))},"drawStripe"),ee=e(function(){var e=(S>0?S:-S)*(arguments.length>0&&void 0!==arguments[0]?arguments[0]:g),n=S>0?0:255;0!==S&&(u.colorFillStyle(t,n,n,n,e),v?t.fill(f):t.fill())},"darken"),te=e(function(){if(P>0){if(t.lineWidth=P,t.lineCap=M,t.lineJoin=A,t.setLineDash)switch(D){case"dotted":t.setLineDash([1,1]);break;case"dashed":t.setLineDash(I),t.lineDashOffset=L;break;case"solid":case"double":t.setLineDash([])}if("center"!==R){if(t.save(),t.lineWidth*=2,"inside"===R)v?t.clip(f):t.clip();else{var e=new Path2D;e.rect(-a/2-P,-i/2-P,a+2*P,i+2*P),e.addPath(f),t.clip(e,"evenodd")}v?t.stroke(f):t.stroke(),t.restore()}else v?t.stroke(f):t.stroke();if("double"===D){t.lineWidth=P/3;var n=t.globalCompositeOperation;t.globalCompositeOperation="destination-out",v?t.stroke(f):t.stroke(),t.globalCompositeOperation=n}t.setLineDash&&t.setLineDash([])}},"drawBorder"),ne=e(function(){if(z>0){if(t.lineWidth=z,t.lineCap="butt",t.setLineDash)switch(F){case"dotted":t.setLineDash([1,1]);break;case"dashed":t.setLineDash([4,2]);break;case"solid":case"double":t.setLineDash([])}var e=h;v&&(e={x:0,y:0});var r=u.getNodeShape(n),o=P;"inside"===R&&(o=0),"outside"===R&&(o*=2);var s,l=(a+o+(z+q))/a,c=(i+o+(z+q))/i,d=a*l,f=i*c,p=u.nodeShapes[r].points;if(v)s=H(d,f,r,p).path;if("ellipse"===r)u.drawEllipsePath(s||t,e.x,e.y,d,f);else if(["round-diamond","round-heptagon","round-hexagon","round-octagon","round-pentagon","round-polygon","round-triangle","round-tag"].includes(r)){var g=0,y=0,m=0;"round-diamond"===r?g=1.4*(o+q+z):"round-heptagon"===r?(g=1.075*(o+q+z),m=-(o/2+q+z)/35):"round-hexagon"===r?g=1.12*(o+q+z):"round-pentagon"===r?(g=1.13*(o+q+z),m=-(o/2+q+z)/15):"round-tag"===r?(g=1.12*(o+q+z),y=.07*(o/2+z+q)):"round-triangle"===r&&(g=(o+q+z)*(Math.PI/2),m=-(o+q/2+z)/Math.PI),0!==g&&(d=a*(l=(a+g)/a),["round-hexagon","round-tag"].includes(r)||(f=i*(c=(i+g)/i)));for(var b=d/2,x=f/2,w=(j="auto"===j?Br(d,f):j)+(o+z+q)/2,E=new Array(p.length/2),C=new Array(p.length/2),T=0;T0){if(r=r||n.position(),null==a||null==i){var d=n.padding();a=n.width()+2*d,i=n.height()+2*d}this.colorFillStyle(t,l[0],l[1],l[2],s),this.nodeShapes[u].draw(t,r.x,r.y,a+2*o,i+2*o,c),t.fill()}}}},"drawNodeOverlayUnderlay");Of.drawNodeOverlay=Ff("overlay"),Of.drawNodeUnderlay=Ff("underlay"),Of.hasPie=function(e){return(e=e[0])._private.hasPie},Of.hasStripe=function(e){return(e=e[0])._private.hasStripe},Of.drawPie=function(e,t,n,r){t=t[0],r=r||t.position();var a,i=t.cy().style(),o=t.pstyle("pie-size"),s=t.pstyle("pie-hole"),l=t.pstyle("pie-start-angle").pfValue,u=r.x,c=r.y,d=t.width(),h=t.height(),f=Math.min(d,h)/2,p=0;if(this.usePaths()&&(u=0,c=0),"%"===o.units?f*=o.pfValue:void 0!==o.pfValue&&(f=o.pfValue/2),"%"===s.units?a=f*s.pfValue:void 0!==s.pfValue&&(a=s.pfValue/2),!(a>=f))for(var g=1;g<=i.pieBackgroundN;g++){var v=t.pstyle("pie-"+g+"-background-size").value,y=t.pstyle("pie-"+g+"-background-color").value,m=t.pstyle("pie-"+g+"-background-opacity").value*n,b=v/100;b+p>1&&(b=1-p);var x=1.5*Math.PI+2*Math.PI*p,w=(x+=l)+2*Math.PI*b;0===v||p>=1||p+b>1||(0===a?(e.beginPath(),e.moveTo(u,c),e.arc(u,c,f,x,w),e.closePath()):(e.beginPath(),e.arc(u,c,f,x,w),e.arc(u,c,a,w,x,!0),e.closePath()),this.colorFillStyle(e,y[0],y[1],y[2],m),e.fill(),p+=b)}},Of.drawStripe=function(e,t,n,r){t=t[0],r=r||t.position();var a=t.cy().style(),i=r.x,o=r.y,s=t.width(),l=t.height(),u=0,c=this.usePaths();e.save();var d=t.pstyle("stripe-direction").value,h=t.pstyle("stripe-size");switch(d){case"vertical":break;case"righward":e.rotate(-Math.PI/2)}var f=s,p=l;"%"===h.units?(f*=h.pfValue,p*=h.pfValue):void 0!==h.pfValue&&(f=h.pfValue,p=h.pfValue),c&&(i=0,o=0),o-=f/2,i-=p/2;for(var g=1;g<=a.stripeBackgroundN;g++){var v=t.pstyle("stripe-"+g+"-background-size").value,y=t.pstyle("stripe-"+g+"-background-color").value,m=t.pstyle("stripe-"+g+"-background-opacity").value*n,b=v/100;b+u>1&&(b=1-u),!(0===v||u>=1||u+b>1)&&(e.beginPath(),e.rect(i,o+p*u,f,p*b),e.closePath(),this.colorFillStyle(e,y[0],y[1],y[2],m),e.fill(),u+=b)}e.restore()};var Vf,qf={};function jf(e,t,n){var r=e.createShader(t);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS))throw new Error(e.getShaderInfoLog(r));return r}function Xf(e,t,n){var r=jf(e,e.VERTEX_SHADER,t),a=jf(e,e.FRAGMENT_SHADER,n),i=e.createProgram();if(e.attachShader(i,r),e.attachShader(i,a),e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS))throw new Error("Could not initialize shaders");return i}function Yf(e,t,n){void 0===n&&(n=t);var r=e.makeOffscreenCanvas(t,n),a=r.context=r.getContext("2d");return r.clear=function(){return a.clearRect(0,0,r.width,r.height)},r.clear(),r}function Wf(e){var t=e.pixelRatio,n=e.cy.zoom(),r=e.cy.pan();return{zoom:n*t,pan:{x:r.x*t,y:r.y*t}}}function Hf(e){var t=e.pixelRatio;return e.cy.zoom()*t}function Kf(e,t,n,r,a){var i=r*n+t.x,o=a*n+t.y;return[i,o=Math.round(e.canvasHeight-o)]}function Gf(e){return"solid"===e.pstyle("background-fill").value&&"none"===e.pstyle("background-image").strValue&&(0===e.pstyle("border-width").value||0===e.pstyle("border-opacity").value||"solid"===e.pstyle("border-style").value)}function Uf(e,t){if(e.length!==t.length)return!1;for(var n=0;n>8&255)/255,n[2]=(e>>16&255)/255,n[3]=(e>>24&255)/255,n}function Qf(e){return e[0]+(e[1]<<8)+(e[2]<<16)+(e[3]<<24)}function Jf(e,t){var n=e.createTexture();return n.buffer=function(t){e.bindTexture(e.TEXTURE_2D,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_NEAREST),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null)},n.deleteTexture=function(){e.deleteTexture(n)},n}function ep(e,t){switch(t){case"float":return[1,e.FLOAT,4];case"vec2":return[2,e.FLOAT,4];case"vec3":return[3,e.FLOAT,4];case"vec4":return[4,e.FLOAT,4];case"int":return[1,e.INT,4];case"ivec2":return[2,e.INT,4]}}function tp(e,t,n){switch(t){case e.FLOAT:return new Float32Array(n);case e.INT:return new Int32Array(n)}}function np(e,t,n,r,a,i){switch(t){case e.FLOAT:return new Float32Array(n.buffer,i*r,a);case e.INT:return new Int32Array(n.buffer,i*r,a)}}function rp(e,t,n,r){var a=f(ep(e,t),2),i=a[0],o=a[1],s=tp(e,o,r),l=e.createBuffer();return e.bindBuffer(e.ARRAY_BUFFER,l),e.bufferData(e.ARRAY_BUFFER,s,e.STATIC_DRAW),o===e.FLOAT?e.vertexAttribPointer(n,i,o,!1,0,0):o===e.INT&&e.vertexAttribIPointer(n,i,o,0,0),e.enableVertexAttribArray(n),e.bindBuffer(e.ARRAY_BUFFER,null),l}function ap(e,t,n,r){var a=f(ep(e,n),3),i=a[0],o=a[1],s=a[2],l=tp(e,o,t*i),u=i*s,c=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,c),e.bufferData(e.ARRAY_BUFFER,t*u,e.DYNAMIC_DRAW),e.enableVertexAttribArray(r),o===e.FLOAT?e.vertexAttribPointer(r,i,o,!1,u,0):o===e.INT&&e.vertexAttribIPointer(r,i,o,u,0),e.vertexAttribDivisor(r,1),e.bindBuffer(e.ARRAY_BUFFER,null);for(var d=new Array(t),h=0;hn.minMbLowQualFrames&&(n.motionBlurPxRatio=n.mbPxRBlurry)),n.clearingMotionBlur&&(n.motionBlurPxRatio=1),n.textureDrawLastFrame&&!h&&(d[n.NODE]=!0,d[n.SELECT_BOX]=!0);var b=r.style(),x=r.zoom(),w=void 0!==s?s:x,E=r.pan(),C={x:E.x,y:E.y},T={zoom:x,pan:{x:E.x,y:E.y}},k=n.prevViewport;!(void 0===k||T.zoom!==k.zoom||T.pan.x!==k.pan.x||T.pan.y!==k.pan.y)&&!(v&&!g)&&(n.motionBlurPxRatio=1),l&&(C=l),w*=u,C.x*=u,C.y*=u;var S=n.getCachedZSortedEles();function P(e,t,r,a,i){var o=e.globalCompositeOperation;e.globalCompositeOperation="destination-out",n.colorFillStyle(e,255,255,255,n.motionBlurTransparency),e.fillRect(t,r,a,i),e.globalCompositeOperation=o}function B(e,t){var r,o,u,d;n.clearingMotionBlur||e!==c.bufferContexts[n.MOTIONBLUR_BUFFER_NODE]&&e!==c.bufferContexts[n.MOTIONBLUR_BUFFER_DRAG]?(r=C,o=w,u=n.canvasWidth,d=n.canvasHeight):(r={x:E.x*p,y:E.y*p},o=x*p,u=n.canvasWidth*p,d=n.canvasHeight*p),e.setTransform(1,0,0,1,0,0),"motionBlur"===t?P(e,0,0,u,d):!a&&(void 0===t||t)&&e.clearRect(0,0,u,d),i||(e.translate(r.x,r.y),e.scale(o,o)),l&&e.translate(l.x,l.y),s&&e.scale(s,s)}if(e(P,"mbclear"),e(B,"setContextTransform"),h||(n.textureDrawLastFrame=!1),h){if(n.textureDrawLastFrame=!0,!n.textureCache){n.textureCache={},n.textureCache.bb=r.mutableElements().boundingBox(),n.textureCache.texture=n.data.bufferCanvases[n.TEXTURE_BUFFER];var _=n.data.bufferContexts[n.TEXTURE_BUFFER];_.setTransform(1,0,0,1,0,0),_.clearRect(0,0,n.canvasWidth*n.textureMult,n.canvasHeight*n.textureMult),n.render({forcedContext:_,drawOnlyNodeLayer:!0,forcedPxRatio:u*n.textureMult}),(T=n.textureCache.viewport={zoom:r.zoom(),pan:r.pan(),width:n.canvasWidth,height:n.canvasHeight}).mpan={x:(0-T.pan.x)/T.zoom,y:(0-T.pan.y)/T.zoom}}d[n.DRAG]=!1,d[n.NODE]=!1;var D=c.contexts[n.NODE],A=n.textureCache.texture;T=n.textureCache.viewport;D.setTransform(1,0,0,1,0,0),f?P(D,0,0,T.width,T.height):D.clearRect(0,0,T.width,T.height);var M=b.core("outside-texture-bg-color").value,R=b.core("outside-texture-bg-opacity").value;n.colorFillStyle(D,M[0],M[1],M[2],R),D.fillRect(0,0,T.width,T.height);x=r.zoom();B(D,!1),D.clearRect(T.mpan.x,T.mpan.y,T.width/T.zoom/u,T.height/T.zoom/u),D.drawImage(A,T.mpan.x,T.mpan.y,T.width/T.zoom/u,T.height/T.zoom/u)}else n.textureOnViewport&&!a&&(n.textureCache=null);var I=r.extent(),L=n.pinching||n.hoverData.dragging||n.swipePanning||n.data.wheelZooming||n.hoverData.draggingEles||n.cy.animated(),N=n.hideEdgesOnViewport&&L,z=[];if(z[n.NODE]=!d[n.NODE]&&f&&!n.clearedForMotionBlur[n.NODE]||n.clearingMotionBlur,z[n.NODE]&&(n.clearedForMotionBlur[n.NODE]=!0),z[n.DRAG]=!d[n.DRAG]&&f&&!n.clearedForMotionBlur[n.DRAG]||n.clearingMotionBlur,z[n.DRAG]&&(n.clearedForMotionBlur[n.DRAG]=!0),d[n.NODE]||i||o||z[n.NODE]){var O=f&&!z[n.NODE]&&1!==p;B(D=a||(O?n.data.bufferContexts[n.MOTIONBLUR_BUFFER_NODE]:c.contexts[n.NODE]),f&&!O?"motionBlur":void 0),N?n.drawCachedNodes(D,S.nondrag,u,I):n.drawLayeredElements(D,S.nondrag,u,I),n.debug&&n.drawDebugPoints(D,S.nondrag),!i&&!f&&(d[n.NODE]=!1)}if(!o&&(d[n.DRAG]||i||z[n.DRAG])){O=f&&!z[n.DRAG]&&1!==p;B(D=a||(O?n.data.bufferContexts[n.MOTIONBLUR_BUFFER_DRAG]:c.contexts[n.DRAG]),f&&!O?"motionBlur":void 0),N?n.drawCachedNodes(D,S.drag,u,I):n.drawCachedElements(D,S.drag,u,I),n.debug&&n.drawDebugPoints(D,S.drag),!i&&!f&&(d[n.DRAG]=!1)}if(this.drawSelectionRectangle(t,B),f&&1!==p){var F=c.contexts[n.NODE],V=n.data.bufferCanvases[n.MOTIONBLUR_BUFFER_NODE],q=c.contexts[n.DRAG],j=n.data.bufferCanvases[n.MOTIONBLUR_BUFFER_DRAG],X=e(function(e,t,r){e.setTransform(1,0,0,1,0,0),r||!m?e.clearRect(0,0,n.canvasWidth,n.canvasHeight):P(e,0,0,n.canvasWidth,n.canvasHeight);var a=p;e.drawImage(t,0,0,n.canvasWidth*a,n.canvasHeight*a,0,0,n.canvasWidth,n.canvasHeight)},"drawMotionBlur");(d[n.NODE]||z[n.NODE])&&(X(F,V,z[n.NODE]),d[n.NODE]=!1),(d[n.DRAG]||z[n.DRAG])&&(X(q,j,z[n.DRAG]),d[n.DRAG]=!1)}n.prevViewport=T,n.clearingMotionBlur&&(n.clearingMotionBlur=!1,n.motionBlurCleared=!0,n.motionBlur=!0),f&&(n.motionBlurTimeout=setTimeout(function(){n.motionBlurTimeout=null,n.clearedForMotionBlur[n.NODE]=!1,n.clearedForMotionBlur[n.DRAG]=!1,n.motionBlur=!1,n.clearingMotionBlur=!h,n.mbFrames=0,d[n.NODE]=!0,d[n.DRAG]=!0,n.redraw()},100)),a||r.emit("render")},qf.drawSelectionRectangle=function(e,t){var n=this,r=n.cy,a=n.data,i=r.style(),o=e.drawOnlyNodeLayer,s=e.drawAllLayers,l=a.canvasNeedsRedraw,u=e.forcedContext;if(n.showFps||!o&&l[n.SELECT_BOX]&&!s){var c=u||a.contexts[n.SELECT_BOX];if(t(c),1==n.selection[4]&&(n.hoverData.selecting||n.touchData.selecting)){var d=n.cy.zoom(),h=i.core("selection-box-border-width").value/d;c.lineWidth=h,c.fillStyle="rgba("+i.core("selection-box-color").value[0]+","+i.core("selection-box-color").value[1]+","+i.core("selection-box-color").value[2]+","+i.core("selection-box-opacity").value+")",c.fillRect(n.selection[0],n.selection[1],n.selection[2]-n.selection[0],n.selection[3]-n.selection[1]),h>0&&(c.strokeStyle="rgba("+i.core("selection-box-border-color").value[0]+","+i.core("selection-box-border-color").value[1]+","+i.core("selection-box-border-color").value[2]+","+i.core("selection-box-opacity").value+")",c.strokeRect(n.selection[0],n.selection[1],n.selection[2]-n.selection[0],n.selection[3]-n.selection[1]))}if(a.bgActivePosistion&&!n.hoverData.selecting){d=n.cy.zoom();var f=a.bgActivePosistion;c.fillStyle="rgba("+i.core("active-bg-color").value[0]+","+i.core("active-bg-color").value[1]+","+i.core("active-bg-color").value[2]+","+i.core("active-bg-opacity").value+")",c.beginPath(),c.arc(f.x,f.y,i.core("active-bg-size").pfValue/d,0,2*Math.PI),c.fill()}var p=n.lastRedrawTime;if(n.showFps&&p){p=Math.round(p);var g=Math.round(1e3/p),v="1 frame = "+p+" ms = "+g+" fps";if(c.setTransform(1,0,0,1,0,0),c.fillStyle="rgba(255, 0, 0, 0.75)",c.strokeStyle="rgba(255, 0, 0, 0.75)",c.font="30px Arial",!Vf){var y=c.measureText(v);Vf=y.actualBoundingBoxAscent}c.fillText(v,0,Vf);c.strokeRect(0,Vf+10,250,20),c.fillRect(0,Vf+10,250*Math.min(g/60,1),20)}s||(l[n.SELECT_BOX]=!1)}},e(jf,"compileShader"),e(Xf,"createProgram"),e(Yf,"createTextureCanvas"),e(Wf,"getEffectivePanZoom"),e(Hf,"getEffectiveZoom"),e(Kf,"modelToRenderedPosition"),e(Gf,"isSimpleShape"),e(Uf,"arrayEqual"),e(Zf,"toWebGLColor"),e($f,"indexToVec4"),e(Qf,"vec4ToIndex"),e(Jf,"createTexture"),e(ep,"getTypeInfo"),e(tp,"createTypedArray"),e(np,"createTypedArrayView"),e(rp,"createBufferStaticDraw"),e(ap,"createBufferDynamicDraw"),e(ip,"create3x3MatrixBufferDynamicDraw"),e(op,"createPickingFrameBuffer");var sp=typeof Float32Array<"u"?Float32Array:Array;function lp(){var e=new sp(9);return sp!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function up(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function cp(e,t,n){var r=t[0],a=t[1],i=t[2],o=t[3],s=t[4],l=t[5],u=t[6],c=t[7],d=t[8],h=n[0],f=n[1],p=n[2],g=n[3],v=n[4],y=n[5],m=n[6],b=n[7],x=n[8];return e[0]=h*r+f*o+p*u,e[1]=h*a+f*s+p*c,e[2]=h*i+f*l+p*d,e[3]=g*r+v*o+y*u,e[4]=g*a+v*s+y*c,e[5]=g*i+v*l+y*d,e[6]=m*r+b*o+x*u,e[7]=m*a+b*s+x*c,e[8]=m*i+b*l+x*d,e}function dp(e,t,n){var r=t[0],a=t[1],i=t[2],o=t[3],s=t[4],l=t[5],u=t[6],c=t[7],d=t[8],h=n[0],f=n[1];return e[0]=r,e[1]=a,e[2]=i,e[3]=o,e[4]=s,e[5]=l,e[6]=h*r+f*o+u,e[7]=h*a+f*s+c,e[8]=h*i+f*l+d,e}function hp(e,t,n){var r=t[0],a=t[1],i=t[2],o=t[3],s=t[4],l=t[5],u=t[6],c=t[7],d=t[8],h=Math.sin(n),f=Math.cos(n);return e[0]=f*r+h*o,e[1]=f*a+h*s,e[2]=f*i+h*l,e[3]=f*o-h*r,e[4]=f*s-h*a,e[5]=f*l-h*i,e[6]=u,e[7]=c,e[8]=d,e}function fp(e,t,n){var r=n[0],a=n[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=a*t[3],e[4]=a*t[4],e[5]=a*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function pp(e,t,n){return e[0]=2/t,e[1]=0,e[2]=0,e[3]=0,e[4]=-2/n,e[5]=0,e[6]=-1,e[7]=1,e[8]=1,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)}),e(lp,"create"),e(up,"identity"),e(cp,"multiply"),e(dp,"translate"),e(hp,"rotate"),e(fp,"scale"),e(pp,"projection");var gp=function(){function t(e,n,r,i){a(this,t),this.debugID=Math.floor(1e4*Math.random()),this.r=e,this.texSize=n,this.texRows=r,this.texHeight=Math.floor(n/r),this.enableWrapping=!0,this.locked=!1,this.texture=null,this.needsBuffer=!0,this.freePointer={x:0,row:0},this.keyToLocation=new Map,this.canvas=i(e,n,n),this.scratch=i(e,n,this.texHeight,"scratch")}return e(t,"Atlas"),o(t,[{key:"lock",value:e(function(){this.locked=!0},"lock")},{key:"getKeys",value:e(function(){return new Set(this.keyToLocation.keys())},"getKeys")},{key:"getScale",value:e(function(e){var t=e.w,n=e.h,r=this.texHeight,a=this.texSize,i=r/n,o=t*i,s=n*i;return o>a&&(o=t*(i=a/t),s=n*i),{scale:i,texW:o,texH:s}},"getScale")},{key:"draw",value:e(function(t,n,r){var a=this;if(this.locked)throw new Error("can't draw, atlas is locked");var i=this.texSize,o=this.texRows,s=this.texHeight,l=this.getScale(n),u=l.scale,c=l.texW,d=l.texH,h=e(function(e,t){if(r&&t){var a=t.context,i=e.x,o=e.row,l=i,c=s*o;a.save(),a.translate(l,c),a.scale(u,u),r(a,n),a.restore()}},"drawAt"),f=[null,null],p=e(function(){h(a.freePointer,a.canvas),f[0]={x:a.freePointer.x,y:a.freePointer.row*s,w:c,h:d},f[1]={x:a.freePointer.x+c,y:a.freePointer.row*s,w:0,h:d},a.freePointer.x+=c,a.freePointer.x==i&&(a.freePointer.x=0,a.freePointer.row++)},"drawNormal"),g=e(function(){var e=a.scratch,t=a.canvas;e.clear(),h({x:0,row:0},e);var n=i-a.freePointer.x,r=c-n,o=s,l=a.freePointer.x,u=a.freePointer.row*s,p=n;t.context.drawImage(e,0,0,p,o,l,u,p,o),f[0]={x:l,y:u,w:p,h:d};var g=n,v=(a.freePointer.row+1)*s,y=r;t&&t.context.drawImage(e,g,0,y,o,0,v,y,o),f[1]={x:0,y:v,w:y,h:d},a.freePointer.x=r,a.freePointer.row++},"drawWrapped"),v=e(function(){a.freePointer.x=0,a.freePointer.row++},"moveToStartOfNextRow");if(this.freePointer.x+c<=i)p();else{if(this.freePointer.row>=o-1)return!1;this.freePointer.x===i?(v(),p()):this.enableWrapping?g():(v(),p())}return this.keyToLocation.set(t,f),this.needsBuffer=!0,f},"draw")},{key:"getOffsets",value:e(function(e){return this.keyToLocation.get(e)},"getOffsets")},{key:"isEmpty",value:e(function(){return 0===this.freePointer.x&&0===this.freePointer.row},"isEmpty")},{key:"canFit",value:e(function(e){if(this.locked)return!1;var t=this.texSize,n=this.texRows,r=this.getScale(e).texW;return!(this.freePointer.x+r>t)||this.freePointer.row1&&void 0!==arguments[1]?arguments[1]:{},i=a.forceRedraw,o=void 0!==i&&i,l=a.filterEle,u=void 0===l?function(){return!0}:l,c=a.filterType,d=void 0===c?function(){return!0}:c,h=!1,f=!1,p=s(t);try{for(p.s();!(n=p.n()).done;){var g=n.value;if(u(g)){var v,y=s(this.renderTypes.values());try{var m=e(function(){var e=v.value,t=e.type;if(d(t)){var n=r.collections.get(e.collection),a=e.getKey(g),i=Array.isArray(a)?a:[a];if(o)i.forEach(function(e){return n.markKeyForGC(e)}),f=!0;else{var s=e.getID?e.getID(g):g.id(),l=r._key(t,s),u=r.typeAndIdToKey.get(l);void 0!==u&&!Uf(i,u)&&(h=!0,r.typeAndIdToKey.delete(l),u.forEach(function(e){return n.markKeyForGC(e)}))}}},"_loop2");for(y.s();!(v=y.n()).done;)m()}catch(e){y.e(e)}finally{y.f()}}}}catch(e){p.e(e)}finally{p.f()}return f&&(this.gc(),h=!1),h},"invalidate")},{key:"gc",value:e(function(){var e,t=s(this.collections.values());try{for(t.s();!(e=t.n()).done;){e.value.gc()}}catch(e){t.e(e)}finally{t.f()}},"gc")},{key:"getOrCreateAtlas",value:e(function(e,t,n,r){var a=this.renderTypes.get(t),i=this.collections.get(a.collection),o=!1,s=i.draw(r,n,function(t){a.drawClipped?(t.save(),t.beginPath(),t.rect(0,0,n.w,n.h),t.clip(),a.drawElement(t,e,n,!0,!0),t.restore()):a.drawElement(t,e,n,!0,!0),o=!0});if(o){var l=a.getID?a.getID(e):e.id(),u=this._key(t,l);this.typeAndIdToKey.has(u)?this.typeAndIdToKey.get(u).push(r):this.typeAndIdToKey.set(u,[r])}return s},"getOrCreateAtlas")},{key:"getAtlasInfo",value:e(function(e,t){var n=this,r=this.renderTypes.get(t),a=r.getKey(e);return(Array.isArray(a)?a:[a]).map(function(a){var i=r.getBoundingBox(e,a),o=n.getOrCreateAtlas(e,t,i,a),s=f(o.getOffsets(a),2),l=s[0];return{atlas:o,tex:l,tex1:l,tex2:s[1],bb:i}})},"getAtlasInfo")},{key:"getDebugInfo",value:e(function(){var e,t=[],n=s(this.collections);try{for(n.s();!(e=n.n()).done;){var r=f(e.value,2),a=r[0],i=r[1].getCounts(),o=i.keyCount,l=i.atlasCount;t.push({type:a,keyCount:o,atlasCount:l})}}catch(e){n.e(e)}finally{n.f()}return t},"getDebugInfo")}])}(),bp=function(){function t(e){a(this,t),this.globalOptions=e,this.atlasSize=e.webglTexSize,this.maxAtlasesPerBatch=e.webglTexPerBatch,this.batchAtlases=[]}return e(t,"AtlasBatchManager"),o(t,[{key:"getMaxAtlasesPerBatch",value:e(function(){return this.maxAtlasesPerBatch},"getMaxAtlasesPerBatch")},{key:"getAtlasSize",value:e(function(){return this.atlasSize},"getAtlasSize")},{key:"getIndexArray",value:e(function(){return Array.from({length:this.maxAtlasesPerBatch},function(e,t){return t})},"getIndexArray")},{key:"startBatch",value:e(function(){this.batchAtlases=[]},"startBatch")},{key:"getAtlasCount",value:e(function(){return this.batchAtlases.length},"getAtlasCount")},{key:"getAtlases",value:e(function(){return this.batchAtlases},"getAtlases")},{key:"canAddToCurrentBatch",value:e(function(e){return this.batchAtlases.length!==this.maxAtlasesPerBatch||this.batchAtlases.includes(e)},"canAddToCurrentBatch")},{key:"getAtlasIndexForBatch",value:e(function(e){var t=this.batchAtlases.indexOf(e);if(t<0){if(this.batchAtlases.length===this.maxAtlasesPerBatch)throw new Error("cannot add more atlases to batch");this.batchAtlases.push(e),t=this.batchAtlases.length-1}return t},"getAtlasIndexForBatch")}])}(),xp={SCREEN:{name:"screen",screen:!0},PICKING:{name:"picking",picking:!0}},wp=1,Ep=2,Cp=function(){function t(e,n,r){a(this,t),this.r=e,this.gl=n,this.maxInstances=r.webglBatchSize,this.atlasSize=r.webglTexSize,this.bgColor=r.bgColor,this.debug=r.webglDebug,this.batchDebugInfo=[],r.enableWrapping=!0,r.createTextureCanvas=Yf,this.atlasManager=new mp(e,r),this.batchManager=new bp(r),this.simpleShapeOptions=new Map,this.program=this._createShaderProgram(xp.SCREEN),this.pickingProgram=this._createShaderProgram(xp.PICKING),this.vao=this._createVAO()}return e(t,"ElementDrawingWebGL"),o(t,[{key:"addAtlasCollection",value:e(function(e,t){this.atlasManager.addAtlasCollection(e,t)},"addAtlasCollection")},{key:"addTextureAtlasRenderType",value:e(function(e,t){this.atlasManager.addRenderType(e,t)},"addTextureAtlasRenderType")},{key:"addSimpleShapeRenderType",value:e(function(e,t){this.simpleShapeOptions.set(e,t)},"addSimpleShapeRenderType")},{key:"invalidate",value:e(function(t){var n=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).type,r=this.atlasManager;return n?r.invalidate(t,{filterType:e(function(e){return e===n},"filterType"),forceRedraw:!0}):r.invalidate(t)},"invalidate")},{key:"gc",value:e(function(){this.atlasManager.gc()},"gc")},{key:"_createShaderProgram",value:e(function(e){var t=this.gl,n="#version 300 es\n precision highp float;\n\n uniform mat3 uPanZoomMatrix;\n uniform int uAtlasSize;\n\n // instanced\n in vec2 aPosition; // a vertex from the unit square\n\n in mat3 aTransform; // used to transform verticies, eg into a bounding box\n in int aVertType; // the type of thing we are rendering\n\n // the z-index that is output when using picking mode\n in vec4 aIndex;\n\n // For textures\n in int aAtlasId; // which shader unit/atlas to use\n in vec4 aTex; // x/y/w/h of texture in atlas\n\n // for edges\n in vec4 aPointAPointB;\n in vec4 aPointCPointD;\n in vec2 aLineWidth; // also used for node border width\n\n // simple shapes\n in vec4 aCornerRadius; // for round-rectangle [top-right, bottom-right, top-left, bottom-left]\n in vec4 aColor; // also used for edges\n in vec4 aBorderColor; // aLineWidth is used for border width\n\n // output values passed to the fragment shader\n out vec2 vTexCoord;\n out vec4 vColor;\n out vec2 vPosition;\n // flat values are not interpolated\n flat out int vAtlasId;\n flat out int vVertType;\n flat out vec2 vTopRight;\n flat out vec2 vBotLeft;\n flat out vec4 vCornerRadius;\n flat out vec4 vBorderColor;\n flat out vec2 vBorderWidth;\n flat out vec4 vIndex;\n\n void main(void) {\n int vid = gl_VertexID;\n vec2 position = aPosition; // TODO make this a vec3, simplifies some code below\n\n if(aVertType == ".concat(0,") {\n float texX = aTex.x; // texture coordinates\n float texY = aTex.y;\n float texW = aTex.z;\n float texH = aTex.w;\n\n if(vid == 1 || vid == 2 || vid == 4) {\n texX += texW;\n }\n if(vid == 2 || vid == 4 || vid == 5) {\n texY += texH;\n }\n\n float d = float(uAtlasSize);\n vTexCoord = vec2(texX / d, texY / d); // tex coords must be between 0 and 1\n\n gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);\n }\n else if(aVertType == ").concat(4," || aVertType == ").concat(7,"\n || aVertType == ").concat(5," || aVertType == ").concat(6,") { // simple shapes\n\n // the bounding box is needed by the fragment shader\n vBotLeft = (aTransform * vec3(0, 0, 1)).xy; // flat\n vTopRight = (aTransform * vec3(1, 1, 1)).xy; // flat\n vPosition = (aTransform * vec3(position, 1)).xy; // will be interpolated\n\n // calculations are done in the fragment shader, just pass these along\n vColor = aColor;\n vCornerRadius = aCornerRadius;\n vBorderColor = aBorderColor;\n vBorderWidth = aLineWidth;\n\n gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);\n }\n else if(aVertType == ").concat(1,") {\n vec2 source = aPointAPointB.xy;\n vec2 target = aPointAPointB.zw;\n\n // adjust the geometry so that the line is centered on the edge\n position.y = position.y - 0.5;\n\n // stretch the unit square into a long skinny rectangle\n vec2 xBasis = target - source;\n vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));\n vec2 point = source + xBasis * position.x + yBasis * aLineWidth[0] * position.y;\n\n gl_Position = vec4(uPanZoomMatrix * vec3(point, 1.0), 1.0);\n vColor = aColor;\n }\n else if(aVertType == ").concat(2,") {\n vec2 pointA = aPointAPointB.xy;\n vec2 pointB = aPointAPointB.zw;\n vec2 pointC = aPointCPointD.xy;\n vec2 pointD = aPointCPointD.zw;\n\n // adjust the geometry so that the line is centered on the edge\n position.y = position.y - 0.5;\n\n vec2 p0, p1, p2, pos;\n if(position.x == 0.0) { // The left side of the unit square\n p0 = pointA;\n p1 = pointB;\n p2 = pointC;\n pos = position;\n } else { // The right side of the unit square, use same approach but flip the geometry upside down\n p0 = pointD;\n p1 = pointC;\n p2 = pointB;\n pos = vec2(0.0, -position.y);\n }\n\n vec2 p01 = p1 - p0;\n vec2 p12 = p2 - p1;\n vec2 p21 = p1 - p2;\n\n // Find the normal vector.\n vec2 tangent = normalize(normalize(p12) + normalize(p01));\n vec2 normal = vec2(-tangent.y, tangent.x);\n\n // Find the vector perpendicular to p0 -> p1.\n vec2 p01Norm = normalize(vec2(-p01.y, p01.x));\n\n // Determine the bend direction.\n float sigma = sign(dot(p01 + p21, normal));\n float width = aLineWidth[0];\n\n if(sign(pos.y) == -sigma) {\n // This is an intersecting vertex. Adjust the position so that there's no overlap.\n vec2 point = 0.5 * width * normal * -sigma / dot(normal, p01Norm);\n gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);\n } else {\n // This is a non-intersecting vertex. Treat it like a mitre join.\n vec2 point = 0.5 * width * normal * sigma * dot(normal, p01Norm);\n gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);\n }\n\n vColor = aColor;\n }\n else if(aVertType == ").concat(3," && vid < 3) {\n // massage the first triangle into an edge arrow\n if(vid == 0)\n position = vec2(-0.15, -0.3);\n if(vid == 1)\n position = vec2( 0.0, 0.0);\n if(vid == 2)\n position = vec2( 0.15, -0.3);\n\n gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);\n vColor = aColor;\n }\n else {\n gl_Position = vec4(2.0, 0.0, 0.0, 1.0); // discard vertex by putting it outside webgl clip space\n }\n\n vAtlasId = aAtlasId;\n vVertType = aVertType;\n vIndex = aIndex;\n }\n "),r=this.batchManager.getIndexArray(),a=Xf(t,n,"#version 300 es\n precision highp float;\n\n // declare texture unit for each texture atlas in the batch\n ".concat(r.map(function(e){return"uniform sampler2D uTexture".concat(e,";")}).join("\n\t"),"\n\n uniform vec4 uBGColor;\n uniform float uZoom;\n\n in vec2 vTexCoord;\n in vec4 vColor;\n in vec2 vPosition; // model coordinates\n\n flat in int vAtlasId;\n flat in vec4 vIndex;\n flat in int vVertType;\n flat in vec2 vTopRight;\n flat in vec2 vBotLeft;\n flat in vec4 vCornerRadius;\n flat in vec4 vBorderColor;\n flat in vec2 vBorderWidth;\n\n out vec4 outColor;\n\n ").concat("\n float circleSD(vec2 p, float r) {\n return distance(vec2(0), p) - r; // signed distance\n }\n","\n ").concat("\n float rectangleSD(vec2 p, vec2 b) {\n vec2 d = abs(p)-b;\n return distance(vec2(0),max(d,0.0)) + min(max(d.x,d.y),0.0);\n }\n","\n ").concat("\n float roundRectangleSD(vec2 p, vec2 b, vec4 cr) {\n cr.xy = (p.x > 0.0) ? cr.xy : cr.zw;\n cr.x = (p.y > 0.0) ? cr.x : cr.y;\n vec2 q = abs(p) - b + cr.x;\n return min(max(q.x, q.y), 0.0) + distance(vec2(0), max(q, 0.0)) - cr.x;\n }\n","\n ").concat("\n float ellipseSD(vec2 p, vec2 ab) {\n p = abs( p ); // symmetry\n\n // find root with Newton solver\n vec2 q = ab*(p-ab);\n float w = (q.x1.0) ? d : -d;\n }\n","\n\n vec4 blend(vec4 top, vec4 bot) { // blend colors with premultiplied alpha\n return vec4(\n top.rgb + (bot.rgb * (1.0 - top.a)),\n top.a + (bot.a * (1.0 - top.a))\n );\n }\n\n vec4 distInterp(vec4 cA, vec4 cB, float d) { // interpolate color using Signed Distance\n // scale to the zoom level so that borders don't look blurry when zoomed in\n // note 1.5 is an aribitrary value chosen because it looks good\n return mix(cA, cB, 1.0 - smoothstep(0.0, 1.5 / uZoom, abs(d)));\n }\n\n void main(void) {\n if(vVertType == ").concat(0,") {\n // look up the texel from the texture unit\n ").concat(r.map(function(e){return"if(vAtlasId == ".concat(e,") outColor = texture(uTexture").concat(e,", vTexCoord);")}).join("\n\telse "),"\n }\n else if(vVertType == ").concat(3,") {\n // mimics how canvas renderer uses context.globalCompositeOperation = 'destination-out';\n outColor = blend(vColor, uBGColor);\n outColor.a = 1.0; // make opaque, masks out line under arrow\n }\n else if(vVertType == ").concat(4," && vBorderWidth == vec2(0.0)) { // simple rectangle with no border\n outColor = vColor; // unit square is already transformed to the rectangle, nothing else needs to be done\n }\n else if(vVertType == ").concat(4," || vVertType == ").concat(7,"\n || vVertType == ").concat(5," || vVertType == ").concat(6,") { // use SDF\n\n float outerBorder = vBorderWidth[0];\n float innerBorder = vBorderWidth[1];\n float borderPadding = outerBorder * 2.0;\n float w = vTopRight.x - vBotLeft.x - borderPadding;\n float h = vTopRight.y - vBotLeft.y - borderPadding;\n vec2 b = vec2(w/2.0, h/2.0); // half width, half height\n vec2 p = vPosition - vec2(vTopRight.x - b[0] - outerBorder, vTopRight.y - b[1] - outerBorder); // translate to center\n\n float d; // signed distance\n if(vVertType == ").concat(4,") {\n d = rectangleSD(p, b);\n } else if(vVertType == ").concat(7," && w == h) {\n d = circleSD(p, b.x); // faster than ellipse\n } else if(vVertType == ").concat(7,") {\n d = ellipseSD(p, b);\n } else {\n d = roundRectangleSD(p, b, vCornerRadius.wzyx);\n }\n\n // use the distance to interpolate a color to smooth the edges of the shape, doesn't need multisampling\n // we must smooth colors inwards, because we can't change pixels outside the shape's bounding box\n if(d > 0.0) {\n if(d > outerBorder) {\n discard;\n } else {\n outColor = distInterp(vBorderColor, vec4(0), d - outerBorder);\n }\n } else {\n if(d > innerBorder) {\n vec4 outerColor = outerBorder == 0.0 ? vec4(0) : vBorderColor;\n vec4 innerBorderColor = blend(vBorderColor, vColor);\n outColor = distInterp(innerBorderColor, outerColor, d);\n }\n else {\n vec4 outerColor;\n if(innerBorder == 0.0 && outerBorder == 0.0) {\n outerColor = vec4(0);\n } else if(innerBorder == 0.0) {\n outerColor = vBorderColor;\n } else {\n outerColor = blend(vBorderColor, vColor);\n }\n outColor = distInterp(vColor, outerColor, d - innerBorder);\n }\n }\n }\n else {\n outColor = vColor;\n }\n\n ").concat(e.picking?"if(outColor.a == 0.0) discard;\n else outColor = vIndex;":"","\n }\n "));a.aPosition=t.getAttribLocation(a,"aPosition"),a.aIndex=t.getAttribLocation(a,"aIndex"),a.aVertType=t.getAttribLocation(a,"aVertType"),a.aTransform=t.getAttribLocation(a,"aTransform"),a.aAtlasId=t.getAttribLocation(a,"aAtlasId"),a.aTex=t.getAttribLocation(a,"aTex"),a.aPointAPointB=t.getAttribLocation(a,"aPointAPointB"),a.aPointCPointD=t.getAttribLocation(a,"aPointCPointD"),a.aLineWidth=t.getAttribLocation(a,"aLineWidth"),a.aColor=t.getAttribLocation(a,"aColor"),a.aCornerRadius=t.getAttribLocation(a,"aCornerRadius"),a.aBorderColor=t.getAttribLocation(a,"aBorderColor"),a.uPanZoomMatrix=t.getUniformLocation(a,"uPanZoomMatrix"),a.uAtlasSize=t.getUniformLocation(a,"uAtlasSize"),a.uBGColor=t.getUniformLocation(a,"uBGColor"),a.uZoom=t.getUniformLocation(a,"uZoom"),a.uTextures=[];for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:xp.SCREEN;this.panZoomMatrix=e,this.renderTarget=t,this.batchDebugInfo=[],this.wrappedCount=0,this.simpleCount=0,this.startBatch()},"startFrame")},{key:"startBatch",value:e(function(){this.instanceCount=0,this.batchManager.startBatch()},"startBatch")},{key:"endFrame",value:e(function(){this.endBatch()},"endFrame")},{key:"_isVisible",value:e(function(e,t){return!!e.visible()&&(!t||!t.isVisible||t.isVisible(e))},"_isVisible")},{key:"drawTexture",value:e(function(e,t,n){var r=this.atlasManager,a=this.batchManager,i=r.getRenderTypeOpts(n);if(this._isVisible(e,i)&&(!e.isEdge()||this._isValidEdge(e))){if(this.renderTarget.picking&&i.getTexPickingMode){var o=i.getTexPickingMode(e);if(o===wp)return;if(o==Ep)return void this.drawPickingRectangle(e,t,n)}var l,u=s(r.getAtlasInfo(e,n));try{for(u.s();!(l=u.n()).done;){var c=l.value,d=c.atlas,h=c.tex1,p=c.tex2;a.canAddToCurrentBatch(d)||this.endBatch();for(var g=a.getAtlasIndexForBatch(d),v=0,y=[[h,!0],[p,!1]];v=this.maxInstances&&this.endBatch()}}}}catch(e){u.e(e)}finally{u.f()}}},"drawTexture")},{key:"setTransformMatrix",value:e(function(e,t,n,r){var a=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],i=0;if(n.shapeProps&&n.shapeProps.padding&&(i=e.pstyle(n.shapeProps.padding).pfValue),r){var o=r.bb,s=r.tex1,l=r.tex2,u=s.w/(s.w+l.w);a||(u=1-u);var c=this._getAdjustedBB(o,i,a,u);this._applyTransformMatrix(t,c,n,e)}else{var d=n.getBoundingBox(e),h=this._getAdjustedBB(d,i,!0,1);this._applyTransformMatrix(t,h,n,e)}},"setTransformMatrix")},{key:"_applyTransformMatrix",value:e(function(e,t,n,r){var a,i;up(e);var o=n.getRotation?n.getRotation(r):0;if(0!==o){var s=n.getRotationPoint(r);dp(e,e,[s.x,s.y]),hp(e,e,o);var l=n.getRotationOffset(r);a=l.x+(t.xOffset||0),i=l.y+(t.yOffset||0)}else a=t.x1,i=t.y1;dp(e,e,[a,i]),fp(e,e,[t.w,t.h])},"_applyTransformMatrix")},{key:"_getAdjustedBB",value:e(function(e,t,n,r){var a=e.x1,i=e.y1,o=e.w,s=e.h;t&&(a-=t,i-=t,o+=2*t,s+=2*t);var l=0,u=o*r;return n&&r<1?o=u:!n&&r<1&&(a+=l=o-u,o=u),{x1:a,y1:i,w:o,h:s,xOffset:l,yOffset:e.yOffset}},"_getAdjustedBB")},{key:"drawPickingRectangle",value:e(function(e,t,n){var r=this.atlasManager.getRenderTypeOpts(n),a=this.instanceCount;this.vertTypeBuffer.getView(a)[0]=4,$f(t,this.indexBuffer.getView(a)),Zf([0,0,0],1,this.colorBuffer.getView(a));var i=this.transformBuffer.getMatrixView(a);this.setTransformMatrix(e,i,r),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()},"drawPickingRectangle")},{key:"drawNode",value:e(function(e,t,n){var r=this.simpleShapeOptions.get(n);if(this._isVisible(e,r)){var a=r.shapeProps,i=this._getVertTypeForShape(e,a.shape);if(void 0===i||r.isSimple&&!r.isSimple(e))return void this.drawTexture(e,t,n);var o=this.instanceCount;if(this.vertTypeBuffer.getView(o)[0]=i,5===i||6===i){var s=r.getBoundingBox(e),l=this._getCornerRadius(e,a.radius,s),u=this.cornerRadiusBuffer.getView(o);u[0]=l,u[1]=l,u[2]=l,u[3]=l,6===i&&(u[0]=0,u[2]=0)}$f(t,this.indexBuffer.getView(o)),Zf(e.pstyle(a.color).value,e.pstyle(a.opacity).value,this.colorBuffer.getView(o));var c=this.lineWidthBuffer.getView(o);if(c[0]=0,c[1]=0,a.border){var d=e.pstyle("border-width").value;if(d>0){Zf(e.pstyle("border-color").value,e.pstyle("border-opacity").value,this.borderColorBuffer.getView(o));var h=e.pstyle("border-position").value;if("inside"===h)c[0]=0,c[1]=-d;else if("outside"===h)c[0]=d,c[1]=0;else{var f=d/2;c[0]=f,c[1]=-f}}}var p=this.transformBuffer.getMatrixView(o);this.setTransformMatrix(e,p,r),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}},"drawNode")},{key:"_getVertTypeForShape",value:e(function(e,t){switch(e.pstyle(t).value){case"rectangle":return 4;case"ellipse":return 7;case"roundrectangle":case"round-rectangle":return 5;case"bottom-round-rectangle":return 6;default:return}},"_getVertTypeForShape")},{key:"_getCornerRadius",value:e(function(e,t,n){var r=n.w,a=n.h;if("auto"===e.pstyle(t).value)return Pr(r,a);var i=e.pstyle(t).pfValue,o=r/2,s=a/2;return Math.min(i,s,o)},"_getCornerRadius")},{key:"drawEdgeArrow",value:e(function(e,t,n){if(e.visible()){var r,a,i,o=e._private.rscratch;if("source"===n?(r=o.arrowStartX,a=o.arrowStartY,i=o.srcArrowAngle):(r=o.arrowEndX,a=o.arrowEndY,i=o.tgtArrowAngle),!(isNaN(r)||null==r||isNaN(a)||null==a||isNaN(i)||null==i))if("none"!==e.pstyle(n+"-arrow-shape").value){var s=e.pstyle(n+"-arrow-color").value,l=e.pstyle("opacity").value*e.pstyle("line-opacity").value,u=e.pstyle("width").pfValue,c=e.pstyle("arrow-scale").value,d=this.r.getArrowWidth(u,c),h=this.instanceCount,f=this.transformBuffer.getMatrixView(h);up(f),dp(f,f,[r,a]),fp(f,f,[d,d]),hp(f,f,i),this.vertTypeBuffer.getView(h)[0]=3,$f(t,this.indexBuffer.getView(h)),Zf(s,l,this.colorBuffer.getView(h)),this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}},"drawEdgeArrow")},{key:"drawEdgeLine",value:e(function(e,t){if(e.visible()){var n=this._getEdgePoints(e);if(n){var r=e.pstyle("opacity").value,a=e.pstyle("line-opacity").value,i=e.pstyle("width").pfValue,o=e.pstyle("line-color").value,s=r*a;if(n.length/2+this.instanceCount>this.maxInstances&&this.endBatch(),4==n.length){var l=this.instanceCount;this.vertTypeBuffer.getView(l)[0]=1,$f(t,this.indexBuffer.getView(l)),Zf(o,s,this.colorBuffer.getView(l)),this.lineWidthBuffer.getView(l)[0]=i;var u=this.pointAPointBBuffer.getView(l);u[0]=n[0],u[1]=n[1],u[2]=n[2],u[3]=n[3],this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}else for(var c=0;c=this.maxInstances&&this.endBatch()}}}},"drawEdgeLine")},{key:"_isValidEdge",value:e(function(e){var t=e._private.rscratch;return!(t.badLine||null==t.allpts||isNaN(t.allpts[0]))},"_isValidEdge")},{key:"_getEdgePoints",value:e(function(e){var t=e._private.rscratch;if(this._isValidEdge(e)){var n=t.allpts;if(4==n.length)return n;var r=this._getNumSegments(e);return this._getCurveSegmentPoints(n,r)}},"_getEdgePoints")},{key:"_getNumSegments",value:e(function(e){return Math.min(Math.max(15,5),this.maxInstances)},"_getNumSegments")},{key:"_getCurveSegmentPoints",value:e(function(e,t){if(4==e.length)return e;for(var n=Array(2*(t+1)),r=0;r<=t;r++)if(0==r)n[0]=e[0],n[1]=e[1];else if(r==t)n[2*r]=e[e.length-2],n[2*r+1]=e[e.length-1];else{var a=r/t;this._setCurvePoint(e,a,n,2*r)}return n},"_getCurveSegmentPoints")},{key:"_setCurvePoint",value:e(function(e,t,n,r){if(!(e.length<=2)){for(var a=Array(e.length-2),i=0;i0}},"isLayerVisible"),l=e(function(e){return"yes"===e.pstyle("text-events").strValue?Ep:wp},"getTexPickingMode"),u=e(function(e){var t=e.position(),n=t.x,r=t.y,a=e.outerWidth(),i=e.outerHeight();return{w:a,h:i,x1:n-a/2,y1:r-i/2}},"getBBForSimpleShape");r.drawing.addAtlasCollection("node",{texRows:t.webglTexRowsNodes}),r.drawing.addAtlasCollection("label",{texRows:t.webglTexRows}),r.drawing.addTextureAtlasRenderType("node-body",{collection:"node",getKey:n.getStyleKey,getBoundingBox:n.getElementBox,drawElement:n.drawElement}),r.drawing.addSimpleShapeRenderType("node-body",{getBoundingBox:u,isSimple:Gf,shapeProps:{shape:"shape",color:"background-color",opacity:"background-opacity",radius:"corner-radius",border:!0}}),r.drawing.addSimpleShapeRenderType("node-overlay",{getBoundingBox:u,isVisible:s("overlay"),shapeProps:{shape:"overlay-shape",color:"overlay-color",opacity:"overlay-opacity",padding:"overlay-padding",radius:"overlay-corner-radius"}}),r.drawing.addSimpleShapeRenderType("node-underlay",{getBoundingBox:u,isVisible:s("underlay"),shapeProps:{shape:"underlay-shape",color:"underlay-color",opacity:"underlay-opacity",padding:"underlay-padding",radius:"underlay-corner-radius"}}),r.drawing.addTextureAtlasRenderType("label",{collection:"label",getTexPickingMode:l,getKey:Pp(n.getLabelKey,null),getBoundingBox:Bp(n.getLabelBox,null),drawClipped:!0,drawElement:n.drawLabel,getRotation:i(null),getRotationPoint:n.getLabelRotationPoint,getRotationOffset:n.getLabelRotationOffset,isVisible:o("label")}),r.drawing.addTextureAtlasRenderType("edge-source-label",{collection:"label",getTexPickingMode:l,getKey:Pp(n.getSourceLabelKey,"source"),getBoundingBox:Bp(n.getSourceLabelBox,"source"),drawClipped:!0,drawElement:n.drawSourceLabel,getRotation:i("source"),getRotationPoint:n.getSourceLabelRotationPoint,getRotationOffset:n.getSourceLabelRotationOffset,isVisible:o("source-label")}),r.drawing.addTextureAtlasRenderType("edge-target-label",{collection:"label",getTexPickingMode:l,getKey:Pp(n.getTargetLabelKey,"target"),getBoundingBox:Bp(n.getTargetLabelBox,"target"),drawClipped:!0,drawElement:n.drawTargetLabel,getRotation:i("target"),getRotationPoint:n.getTargetLabelRotationPoint,getRotationOffset:n.getTargetLabelRotationOffset,isVisible:o("target-label")});var c=rt(function(){console.log("garbage collect flag set"),r.data.gc=!0},1e4);r.onUpdateEleCalcs(function(e,t){var n=!1;t&&t.length>0&&(n|=r.drawing.invalidate(t)),n&&c()}),_p(r)},e(kp,"getBGColor"),e(Sp,"getLabelLines");var Pp=e(function(e,t){return function(n){var r=e(n),a=Sp(n,t);return a.length>1?a.map(function(e,t){return"".concat(r,"_").concat(t)}):r}},"getStyleKeysForLabel"),Bp=e(function(e,t){return function(n,r){var a=e(n);if("string"==typeof r){var i=r.indexOf("_");if(i>0){var o=Number(r.substring(i+1)),s=Sp(n,t),l=a.h/s.length,u=l*o,c=a.y1+u;return{x1:a.x1,w:a.w,y1:c,h:l,yOffset:u}}}return a}},"getBoundingBoxForLabel");function _p(e){var t=e.render;e.render=function(n){n=n||{};var r=e.cy;e.webgl&&(r.zoom()>7.99?(Dp(e),t.call(e,n)):(Ap(e),Vp(e,n,xp.SCREEN)))};var n=e.matchCanvasSize;e.matchCanvasSize=function(t){n.call(e,t),e.pickingFrameBuffer.setFramebufferAttachmentSizes(e.canvasWidth,e.canvasHeight),e.pickingFrameBuffer.needsDraw=!0},e.findNearestElements=function(t,n,r,a){return Op(e,t,n)};var r=e.invalidateCachedZSortedEles;e.invalidateCachedZSortedEles=function(){r.call(e),e.pickingFrameBuffer.needsDraw=!0};var a=e.notify;e.notify=function(t,n){a.call(e,t,n),"viewport"===t||"bounds"===t?e.pickingFrameBuffer.needsDraw=!0:"background"===t&&e.drawing.invalidate(n,{type:"node-body"})}}function Dp(e){var t=e.data.contexts[e.WEBGL];t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)}function Ap(t){var n=e(function(e){e.save(),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.canvasWidth,t.canvasHeight),e.restore()},"clear");n(t.data.contexts[t.NODE]),n(t.data.contexts[t.DRAG])}function Mp(e){var t=e.canvasWidth,n=e.canvasHeight,r=Wf(e),a=r.pan,i=r.zoom,o=lp();dp(o,o,[a.x,a.y]),fp(o,o,[i,i]);var s=lp();pp(s,t,n);var l=lp();return cp(l,s,o),l}function Rp(e,t){var n=e.canvasWidth,r=e.canvasHeight,a=Wf(e),i=a.pan,o=a.zoom;t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,n,r),t.translate(i.x,i.y),t.scale(o,o)}function Ip(e,t){e.drawSelectionRectangle(t,function(t){return Rp(e,t)})}function Lp(e){var t=e.data.contexts[e.NODE];t.save(),Rp(e,t),t.strokeStyle="rgba(0, 0, 0, 0.3)",t.beginPath(),t.moveTo(-1e3,0),t.lineTo(1e3,0),t.stroke(),t.beginPath(),t.moveTo(0,-1e3),t.lineTo(0,1e3),t.stroke(),t.restore()}function Np(t){var n=e(function(e,n,r){for(var a=e.atlasManager.getAtlasCollection(n),i=t.data.contexts[t.NODE],o=a.atlases,s=0;s=0&&d.add(p)}return d}function Op(e,t,n){var r,a,i,o=zp(e,t,n),l=e.getCachedZSortedEles(),u=s(o);try{for(u.s();!(i=u.n()).done;){var c=l[i.value];if(!r&&c.isNode()&&(r=c),!a&&c.isEdge()&&(a=c),r&&a)break}}catch(e){u.e(e)}finally{u.f()}return[r,a].filter(Boolean)}function Fp(e,t,n){var r=e.drawing;t+=1,n.isNode()?(r.drawNode(n,t,"node-underlay"),r.drawNode(n,t,"node-body"),r.drawTexture(n,t,"label"),r.drawNode(n,t,"node-overlay")):(r.drawEdgeLine(n,t),r.drawEdgeArrow(n,t,"source"),r.drawEdgeArrow(n,t,"target"),r.drawTexture(n,t,"label"),r.drawTexture(n,t,"edge-source-label"),r.drawTexture(n,t,"edge-target-label"))}function Vp(e,t,n){var r;e.webglDebug&&(r=performance.now());var a=e.drawing,i=0;if(n.screen&&e.data.canvasNeedsRedraw[e.SELECT_BOX]&&Ip(e,t),e.data.canvasNeedsRedraw[e.NODE]||n.picking){var o=e.data.contexts[e.WEBGL];n.screen?(o.clearColor(0,0,0,0),o.enable(o.BLEND),o.blendFunc(o.ONE,o.ONE_MINUS_SRC_ALPHA)):o.disable(o.BLEND),o.clear(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT),o.viewport(0,0,o.canvas.width,o.canvas.height);var l=Mp(e),u=e.getCachedZSortedEles();if(i=u.length,a.startFrame(l,n),n.screen){for(var c=0;c0&&i>0){h.clearRect(0,0,a,i),h.globalCompositeOperation="source-over";var f=this.getCachedZSortedEles();if(e.full)h.translate(-n.x1*l,-n.y1*l),h.scale(l,l),this.drawElements(h,f),h.scale(1/l,1/l),h.translate(n.x1*l,n.y1*l);else{var p=t.pan(),g={x:p.x*l,y:p.y*l};l*=t.zoom(),h.translate(g.x,g.y),h.scale(l,l),this.drawElements(h,f),h.scale(1/l,1/l),h.translate(-g.x,-g.y)}e.bg&&(h.globalCompositeOperation="destination-over",h.fillStyle=e.bg,h.rect(0,0,a,i),h.fill())}return d},e(Up,"b64ToBlob"),e(Zp,"b64UriToB64"),e($p,"output"),Gp.png=function(e){return $p(e,this.bufferCanvasImage(e),"image/png")},Gp.jpg=function(e){return $p(e,this.bufferCanvasImage(e),"image/jpeg")};var Qp={nodeShapeImpl:function(e,t,n,r,a,i,o,s){switch(e){case"ellipse":return this.drawEllipsePath(t,n,r,a,i);case"polygon":return this.drawPolygonPath(t,n,r,a,i,o);case"round-polygon":return this.drawRoundPolygonPath(t,n,r,a,i,o,s);case"roundrectangle":case"round-rectangle":return this.drawRoundRectanglePath(t,n,r,a,i,s);case"cutrectangle":case"cut-rectangle":return this.drawCutRectanglePath(t,n,r,a,i,o,s);case"bottomroundrectangle":case"bottom-round-rectangle":return this.drawBottomRoundRectanglePath(t,n,r,a,i,s);case"barrel":return this.drawBarrelPath(t,n,r,a,i)}}},Jp=tg,eg=tg.prototype;function tg(t){var n=this,r=n.cy.window().document;t.webgl&&(eg.CANVAS_LAYERS=n.CANVAS_LAYERS=4,console.log("webgl rendering enabled")),n.data={canvases:new Array(eg.CANVAS_LAYERS),contexts:new Array(eg.CANVAS_LAYERS),canvasNeedsRedraw:new Array(eg.CANVAS_LAYERS),bufferCanvases:new Array(eg.BUFFER_COUNT),bufferContexts:new Array(eg.CANVAS_LAYERS)};var a="-webkit-tap-highlight-color",i="rgba(0,0,0,0)";n.data.canvasContainer=r.createElement("div");var o=n.data.canvasContainer.style;n.data.canvasContainer.style[a]=i,o.position="relative",o.zIndex="0",o.overflow="hidden";var s=t.cy.container();s.appendChild(n.data.canvasContainer),s.style[a]=i;var l={"-webkit-user-select":"none","-moz-user-select":"-moz-none","user-select":"none","-webkit-tap-highlight-color":"rgba(0,0,0,0)","outline-style":"none"};me()&&(l["-ms-touch-action"]="none",l["touch-action"]="none");for(var u=0;u"u"?"undefined":y(OffscreenCanvas))?n=new OffscreenCanvas(e,t):((n=this.cy.window().document.createElement("canvas")).width=e,n.height=t);return n},[bf,kf,Mf,If,Lf,Of,qf,Tp,jp,Gp,Qp].forEach(function(e){Me(eg,e)});var rg=[{type:"layout",extensions:oh},{type:"renderer",extensions:[{name:"null",impl:sh},{name:"base",impl:af},{name:"canvas",impl:Jp}]}],ag={},ig={};function og(t,n,r){var a=r,i=e(function(e){It("Can not register `"+n+"` for `"+t+"` since `"+e+"` already exists in the prototype and can not be overridden")},"overrideErr");if("core"===t){if(bd.prototype[n])return i(n);bd.prototype[n]=r}else if("collection"===t){if(Lc.prototype[n])return i(n);Lc.prototype[n]=r}else if("layout"===t){for(var o=e(function(e){this.options=e,r.call(this,e),re(this._private)||(this._private={}),this._private.cy=e.cy,this._private.listeners=[],this.createEmitter()},"Layout"),s=o.prototype=Object.create(r.prototype),l=[],u=0;u