From c00b8c2cfe2d4d6ef97a49b0aabf80876db33c0b Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 30 Mar 2024 17:29:26 +0100 Subject: [PATCH] Fixes #236: Saved filter doesn't reload show cables (#475) * fix restore saved filter options * fix restore saved filter group options * fix htmx export to xml --- netbox_topology_views/api/views.py | 26 +++++++++++++- .../static/netbox_topology_views/js/app.js | 22 ++++++------ netbox_topology_views/static_dev/js/home.js | 10 +++--- netbox_topology_views/utils.py | 6 +++- netbox_topology_views/views.py | 35 +++++++++++++++++-- 5 files changed, 79 insertions(+), 20 deletions(-) diff --git a/netbox_topology_views/api/views.py b/netbox_topology_views/api/views.py index df7c71d..6741dd8 100644 --- a/netbox_topology_views/api/views.py +++ b/netbox_topology_views/api/views.py @@ -3,6 +3,7 @@ from circuits.models import Circuit from dcim.models import Device, DeviceRole, PowerFeed, PowerPanel +from extras.models import SavedFilter from django.conf import settings from django.contrib.auth.mixins import PermissionRequiredMixin from django.contrib.contenttypes.models import ContentType @@ -108,7 +109,30 @@ def list(self, request): if request.GET: - save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks,show_neighbors = get_query_settings(request) + filter_id, save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks,show_neighbors = get_query_settings(request) + + # Read options from saved filters as NetBox does not handle custom plugin filters + if "filter_id" in request.GET and request.GET["filter_id"] != '': + try: + saved_filter = SavedFilter.objects.get(pk=filter_id) + saved_filter_params = getattr(saved_filter, 'parameters') + + if save_coords == False and 'save_coords' in saved_filter_params: save_coords = saved_filter_params['save_coords'] + if show_power == False and 'show_power' in saved_filter_params: show_power = saved_filter_params['show_power'] + if show_circuit == False and 'show_circuit' in saved_filter_params: show_circuit = saved_filter_params['show_circuit'] + if show_logical_connections == False and 'show_logical_connections' in saved_filter_params: show_logical_connections = saved_filter_params['show_logical_connections'] + if show_single_cable_logical_conns == False and 'show_single_cable_logical_conns' in saved_filter_params: show_single_cable_logical_conns = saved_filter_params['show_single_cable_logical_conns'] + if show_cables == False and 'show_cables' in saved_filter_params: show_cables = saved_filter_params['show_cables'] + if show_wireless == False and 'show_wireless' in saved_filter_params: show_wireless = saved_filter_params['show_wireless'] + if group_sites == False and 'group_sites' in saved_filter_params: group_sites = saved_filter_params['group_sites'] + if group_locations == False and 'group_locations' in saved_filter_params: group_locations = saved_filter_params['group_locations'] + if group_racks == False and 'group_racks' in saved_filter_params: group_racks = saved_filter_params['group_racks'] + if show_neighbors == False and 'show_neighbors' in saved_filter_params: show_neighbors = saved_filter_params['show_neighbors'] + except SavedFilter.DoesNotExist: # filter_id not found + pass + except Exception as inst: + print(type(inst)) + if 'group' not in request.query_params: group_id = "default" else: diff --git a/netbox_topology_views/static/netbox_topology_views/js/app.js b/netbox_topology_views/static/netbox_topology_views/js/app.js index 8e7aebe..a29f432 100644 --- a/netbox_topology_views/static/netbox_topology_views/js/app.js +++ b/netbox_topology_views/static/netbox_topology_views/js/app.js @@ -1,8 +1,8 @@ -(()=>{var En=Object.create;var Tt=Object.defineProperty,xn=Object.defineProperties,Cn=Object.getOwnPropertyDescriptor,Tn=Object.getOwnPropertyDescriptors,kn=Object.getOwnPropertyNames,Wi=Object.getOwnPropertySymbols,On=Object.getPrototypeOf,Vi=Object.prototype.hasOwnProperty,Sn=Object.prototype.propertyIsEnumerable;var Zt=(n,e,t)=>e in n?Tt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,he=(n,e)=>{for(var t in e||(e={}))Vi.call(e,t)&&Zt(n,t,e[t]);if(Wi)for(var t of Wi(e))Sn.call(e,t)&&Zt(n,t,e[t]);return n},Fe=(n,e)=>xn(n,Tn(e)),In=n=>Tt(n,"__esModule",{value:!0});var Pn=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var Mn=(n,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of kn(e))!Vi.call(n,i)&&i!=="default"&&Tt(n,i,{get:()=>e[i],enumerable:!(t=Cn(e,i))||t.enumerable});return n},qi=n=>Mn(In(Tt(n!=null?En(On(n)):{},"default",n&&n.__esModule&&"default"in n?{get:()=>n.default,enumerable:!0}:{value:n,enumerable:!0})),n);var X=(n,e,t)=>(Zt(n,typeof e!="symbol"?e+"":e,t),t);var Ui=(n,e,t)=>new Promise((i,s)=>{var o=d=>{try{a(t.next(d))}catch(h){s(h)}},r=d=>{try{a(t.throw(d))}catch(h){s(h)}},a=d=>d.done?i(d.value):Promise.resolve(d.value).then(o,r);a((t=t.apply(n,e)).next())});var Jt=Pn((ja,Qt)=>{typeof Qt!="undefined"&&(Qt.exports=te);function te(n){if(n)return Dn(n)}function Dn(n){for(var e in te.prototype)n[e]=te.prototype[e];return n}te.prototype.on=te.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this};te.prototype.once=function(n,e){function t(){this.off(n,t),e.apply(this,arguments)}return t.fn=e,this.on(n,t),this};te.prototype.off=te.prototype.removeListener=te.prototype.removeAllListeners=te.prototype.removeEventListener=function(n,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+n];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var i,s=0;s-1}function Wn(n){if(Le(n,Ae))return Ae;var e=Le(n,ot),t=Le(n,nt);return e&&t?Ae:e||t?e?ot:nt:Le(n,ii)?ii:$i}var es=function(){function n(t,i){this.manager=t,this.set(i)}var e=n.prototype;return e.set=function(i){i===Ki&&(i=this.compute()),Gi&&this.manager.element.style&&St[i]&&(this.manager.element.style[Xi]=i),this.actions=i.toLowerCase().trim()},e.update=function(){this.set(this.manager.options.touchAction)},e.compute=function(){var i=[];return me(this.manager.recognizers,function(s){Mt(s.options.enable,[s])&&(i=i.concat(s.getTouchAction()))}),Wn(i.join(" "))},e.preventDefaults=function(i){var s=i.srcEvent,o=i.offsetDirection;if(this.manager.session.prevented){s.preventDefault();return}var r=this.actions,a=Le(r,Ae)&&!St[Ae],d=Le(r,nt)&&!St[nt],h=Le(r,ot)&&!St[ot];if(a){var l=i.pointers.length===1,c=i.distance<2,u=i.deltaTime<250;if(l&&c&&u)return}if(!(h&&d)&&(a||d&&o&ue||h&&o&Re))return this.preventSrc(s)},e.preventSrc=function(i){this.manager.session.prevented=!0,i.preventDefault()},n}();function oi(n,e){for(;n;){if(n===e)return!0;n=n.parentNode}return!1}function ts(n){var e=n.length;if(e===1)return{x:Ke(n[0].clientX),y:Ke(n[0].clientY)};for(var t=0,i=0,s=0;s=Be(e)?n<0?at:dt:e<0?ht:$e}function Vn(n,e){var t=e.center,i=n.offsetDelta||{},s=n.prevDelta||{},o=n.prevInput||{};(e.eventType===$||o.eventType===W)&&(s=n.prevDelta={x:o.deltaX||0,y:o.deltaY||0},i=n.offsetDelta={x:t.x,y:t.y}),e.deltaX=s.x+(t.x-i.x),e.deltaY=s.y+(t.y-i.y)}function os(n,e,t){return{x:e/n||0,y:t/n||0}}function qn(n,e){return Dt(e[0],e[1],Pt)/Dt(n[0],n[1],Pt)}function Un(n,e){return ni(e[1],e[0],Pt)+ni(n[1],n[0],Pt)}function Yn(n,e){var t=n.lastInterval||e,i=e.timeStamp-t.timeStamp,s,o,r,a;if(e.eventType!==J&&(i>jn||t.velocity===void 0)){var d=e.deltaX-t.deltaX,h=e.deltaY-t.deltaY,l=os(i,d,h);o=l.x,r=l.y,s=Be(l.x)>Be(l.y)?l.x:l.y,a=ss(d,h),n.lastInterval=e}else s=t.velocity,o=t.velocityX,r=t.velocityY,a=t.direction;e.velocity=s,e.velocityX=o,e.velocityY=r,e.direction=a}function Xn(n,e){var t=n.session,i=e.pointers,s=i.length;t.firstInput||(t.firstInput=is(e)),s>1&&!t.firstMultiple?t.firstMultiple=is(e):s===1&&(t.firstMultiple=!1);var o=t.firstInput,r=t.firstMultiple,a=r?r.center:o.center,d=e.center=ts(i);e.timeStamp=ti(),e.deltaTime=e.timeStamp-o.timeStamp,e.angle=ni(a,d),e.distance=Dt(a,d),Vn(t,e),e.offsetDirection=ss(e.deltaX,e.deltaY);var h=os(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=h.x,e.overallVelocityY=h.y,e.overallVelocity=Be(h.x)>Be(h.y)?h.x:h.y,e.scale=r?qn(r.pointers,i):1,e.rotation=r?Un(r.pointers,i):0,e.maxPointers=t.prevInput?e.pointers.length>t.prevInput.maxPointers?e.pointers.length:t.prevInput.maxPointers:e.pointers.length,Yn(t,e);var l=n.element,c=e.srcEvent,u;c.composedPath?u=c.composedPath()[0]:c.path?u=c.path[0]:u=c.target,oi(u,l)&&(l=u),e.target=l}function Gn(n,e,t){var i=t.pointers.length,s=t.changedPointers.length,o=e&$&&i-s==0,r=e&(W|J)&&i-s==0;t.isFirst=!!o,t.isFinal=!!r,o&&(n.session={}),t.eventType=e,Xn(n,t),n.emit("hammer.input",t),n.recognize(t),n.session.prevInput=t}function lt(n){return n.trim().split(/\s+/g)}function ct(n,e,t){me(lt(e),function(i){n.addEventListener(i,t,!1)})}function ut(n,e,t){me(lt(e),function(i){n.removeEventListener(i,t,!1)})}function ns(n){var e=n.ownerDocument||n;return e.defaultView||e.parentWindow||window}var Ze=function(){function n(t,i){var s=this;this.manager=t,this.callback=i,this.element=t.element,this.target=t.options.inputTarget,this.domHandler=function(o){Mt(t.options.enable,[t])&&s.handler(o)},this.init()}var e=n.prototype;return e.handler=function(){},e.init=function(){this.evEl&&ct(this.element,this.evEl,this.domHandler),this.evTarget&&ct(this.target,this.evTarget,this.domHandler),this.evWin&&ct(ns(this.element),this.evWin,this.domHandler)},e.destroy=function(){this.evEl&&ut(this.element,this.evEl,this.domHandler),this.evTarget&&ut(this.target,this.evTarget,this.domHandler),this.evWin&&ut(ns(this.element),this.evWin,this.domHandler)},n}();function He(n,e,t){if(n.indexOf&&!t)return n.indexOf(e);for(var i=0;id[e]}):i=i.sort()),i}var Zn={touchstart:$,touchmove:ze,touchend:W,touchcancel:J},Qn="touchstart touchmove touchend touchcancel",ai=function(n){oe(e,n);function e(){var i;return e.prototype.evTarget=Qn,i=n.apply(this,arguments)||this,i.targetIds={},i}var t=e.prototype;return t.handler=function(s){var o=Zn[s.type],r=Jn.call(this,s,o);!r||this.callback(this.manager,o,{pointers:r[0],changedPointers:r[1],pointerType:rt,srcEvent:s})},e}(Ze);function Jn(n,e){var t=ft(n.touches),i=this.targetIds;if(e&($|ze)&&t.length===1)return i[t[0].identifier]=!0,[t,t];var s,o,r=ft(n.changedTouches),a=[],d=this.target;if(o=t.filter(function(h){return oi(h.target,d)}),e===$)for(s=0;s-1&&s.splice(a,1)};setTimeout(o,sr)}}function or(n,e){n&$?(this.primaryTouch=e.changedPointers[0].identifier,ls.call(this,e)):n&(W|J)&&ls.call(this,e)}function nr(n){for(var e=n.srcEvent.clientX,t=n.srcEvent.clientY,i=0;i-1&&this.requireFail.splice(s,1),this},e.hasRequireFailures=function(){return this.requireFail.length>0},e.canRecognizeWith=function(i){return!!this.simultaneous[i.id]},e.emit=function(i){var s=this,o=this.state;function r(a){s.manager.emit(a,i)}o=ke&&r(s.options.event+us(o))},e.tryEmit=function(i){if(this.canEmit())return this.emit(i);this.state=fe},e.canEmit=function(){for(var i=0;io.threshold&&d&o.direction},t.attrTest=function(s){return et.prototype.attrTest.call(this,s)&&(this.state&ne||!(this.state&ne)&&this.directionTest(s))},t.emit=function(s){this.pX=s.deltaX,this.pY=s.deltaY;var o=fs(s.direction);o&&(s.additionalEvent=this.options.event+o),n.prototype.emit.call(this,s)},e}(et),ps=function(n){oe(e,n);function e(i){return i===void 0&&(i={}),n.call(this,le({event:"swipe",threshold:10,velocity:.3,direction:ue|Re,pointers:1},i))||this}var t=e.prototype;return t.getTouchAction=function(){return li.prototype.getTouchAction.call(this)},t.attrTest=function(s){var o=this.options.direction,r;return o&(ue|Re)?r=s.overallVelocity:o&ue?r=s.overallVelocityX:o&Re&&(r=s.overallVelocityY),n.prototype.attrTest.call(this,s)&&o&s.offsetDirection&&s.distance>this.options.threshold&&s.maxPointers===this.options.pointers&&Be(r)>this.options.velocity&&s.eventType&W},t.emit=function(s){var o=fs(s.offsetDirection);o&&this.manager.emit(this.options.event+o,s),this.manager.emit(this.options.event,s)},e}(et),gs=function(n){oe(e,n);function e(i){return i===void 0&&(i={}),n.call(this,le({event:"pinch",threshold:0,pointers:2},i))||this}var t=e.prototype;return t.getTouchAction=function(){return[Ae]},t.attrTest=function(s){return n.prototype.attrTest.call(this,s)&&(Math.abs(s.scale-1)>this.options.threshold||this.state&ne)},t.emit=function(s){if(s.scale!==1){var o=s.scale<1?"in":"out";s.additionalEvent=this.options.event+o}n.prototype.emit.call(this,s)},e}(et),ms=function(n){oe(e,n);function e(i){return i===void 0&&(i={}),n.call(this,le({event:"rotate",threshold:0,pointers:2},i))||this}var t=e.prototype;return t.getTouchAction=function(){return[Ae]},t.attrTest=function(s){return n.prototype.attrTest.call(this,s)&&(Math.abs(s.rotation)>this.options.threshold||this.state&ne)},e}(et),ys=function(n){oe(e,n);function e(i){var s;return i===void 0&&(i={}),s=n.call(this,le({event:"press",pointers:1,time:251,threshold:9},i))||this,s._timer=null,s._input=null,s}var t=e.prototype;return t.getTouchAction=function(){return[$i]},t.process=function(s){var o=this,r=this.options,a=s.pointers.length===r.pointers,d=s.distancer.time;if(this._input=s,!d||!a||s.eventType&(W|J)&&!h)this.reset();else if(s.eventType&$)this.reset(),this._timer=setTimeout(function(){o.state=ye,o.tryEmit()},r.time);else if(s.eventType&W)return ye;return fe},t.reset=function(){clearTimeout(this._timer)},t.emit=function(s){this.state===ye&&(s&&s.eventType&W?this.manager.emit(this.options.event+"up",s):(this._input.timeStamp=ti(),this.manager.emit(this.options.event,this._input)))},e}(gt),bs={domEvents:!1,touchAction:Ki,enable:!0,inputTarget:null,inputClass:null,cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}},vs=[[ms,{enable:!1}],[gs,{enable:!1},["rotate"]],[ps,{direction:ue}],[li,{direction:ue},["swipe"]],[hi],[hi,{event:"doubletap",taps:2},["tap"]],[ys]],hr=1,ws=2;function _s(n,e){var t=n.element;if(!!t.style){var i;me(n.options.cssProps,function(s,o){i=Ot(t.style,o),e?(n.oldCssProps[i]=t.style[i],t.style[i]=s):t.style[i]=n.oldCssProps[i]||""}),e||(n.oldCssProps={})}}function lr(n,e){var t=document.createEvent("Event");t.initEvent(n,!0,!0),t.gesture=e,e.target.dispatchEvent(t)}var Es=function(){function n(t,i){var s=this;this.options=Ne({},bs,i||{}),this.options.inputTarget=this.options.inputTarget||t,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=t,this.input=rr(this),this.touchAction=new es(this,this.options.touchAction),_s(this,!0),me(this.options.recognizers,function(o){var r=s.add(new o[0](o[1]));o[2]&&r.recognizeWith(o[2]),o[3]&&r.requireFailure(o[3])},this)}var e=n.prototype;return e.set=function(i){return Ne(this.options,i),i.touchAction&&this.touchAction.update(),i.inputTarget&&(this.input.destroy(),this.input.target=i.inputTarget,this.input.init()),this},e.stop=function(i){this.session.stopped=i?ws:hr},e.recognize=function(i){var s=this.session;if(!s.stopped){this.touchAction.preventDefaults(i);var o,r=this.recognizers,a=s.curRecognizer;(!a||a&&a.state&ye)&&(s.curRecognizer=null,a=null);for(var d=0;d{var bn=Object.create;var Tt=Object.defineProperty,vn=Object.defineProperties,wn=Object.getOwnPropertyDescriptor,_n=Object.getOwnPropertyDescriptors,En=Object.getOwnPropertyNames,ji=Object.getOwnPropertySymbols,xn=Object.getPrototypeOf,Wi=Object.prototype.hasOwnProperty,Cn=Object.prototype.propertyIsEnumerable;var Zt=(n,e,t)=>e in n?Tt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,le=(n,e)=>{for(var t in e||(e={}))Wi.call(e,t)&&Zt(n,t,e[t]);if(ji)for(var t of ji(e))Cn.call(e,t)&&Zt(n,t,e[t]);return n},Be=(n,e)=>vn(n,_n(e)),Tn=n=>Tt(n,"__esModule",{value:!0});var kn=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var On=(n,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of En(e))!Wi.call(n,i)&&i!=="default"&&Tt(n,i,{get:()=>e[i],enumerable:!(t=wn(e,i))||t.enumerable});return n},Vi=n=>On(Tn(Tt(n!=null?bn(xn(n)):{},"default",n&&n.__esModule&&"default"in n?{get:()=>n.default,enumerable:!0}:{value:n,enumerable:!0})),n);var X=(n,e,t)=>(Zt(n,typeof e!="symbol"?e+"":e,t),t);var qi=(n,e,t)=>new Promise((i,s)=>{var o=d=>{try{a(t.next(d))}catch(h){s(h)}},r=d=>{try{a(t.throw(d))}catch(h){s(h)}},a=d=>d.done?i(d.value):Promise.resolve(d.value).then(o,r);a((t=t.apply(n,e)).next())});var Jt=kn((za,Qt)=>{typeof Qt!="undefined"&&(Qt.exports=te);function te(n){if(n)return Sn(n)}function Sn(n){for(var e in te.prototype)n[e]=te.prototype[e];return n}te.prototype.on=te.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this};te.prototype.once=function(n,e){function t(){this.off(n,t),e.apply(this,arguments)}return t.fn=e,this.on(n,t),this};te.prototype.off=te.prototype.removeListener=te.prototype.removeAllListeners=te.prototype.removeEventListener=function(n,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+n];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var i,s=0;s-1}function Rn(n){if(je(n,Re))return Re;var e=je(n,nt),t=je(n,rt);return e&&t?Re:e||t?e?nt:rt:je(n,ii)?ii:Ki}var Ji=function(){function n(t,i){this.manager=t,this.set(i)}var e=n.prototype;return e.set=function(i){i===Gi&&(i=this.compute()),Xi&&this.manager.element.style&&St[i]&&(this.manager.element.style[Yi]=i),this.actions=i.toLowerCase().trim()},e.update=function(){this.set(this.manager.options.touchAction)},e.compute=function(){var i=[];return ye(this.manager.recognizers,function(s){Mt(s.options.enable,[s])&&(i=i.concat(s.getTouchAction()))}),Rn(i.join(" "))},e.preventDefaults=function(i){var s=i.srcEvent,o=i.offsetDirection;if(this.manager.session.prevented){s.preventDefault();return}var r=this.actions,a=je(r,Re)&&!St[Re],d=je(r,rt)&&!St[rt],h=je(r,nt)&&!St[nt];if(a){var l=i.pointers.length===1,c=i.distance<2,u=i.deltaTime<250;if(l&&c&&u)return}if(!(h&&d)&&(a||d&&o&ue||h&&o&He))return this.preventSrc(s)},e.preventSrc=function(i){this.manager.session.prevented=!0,i.preventDefault()},n}();function oi(n,e){for(;n;){if(n===e)return!0;n=n.parentNode}return!1}function es(n){var e=n.length;if(e===1)return{x:$e(n[0].clientX),y:$e(n[0].clientY)};for(var t=0,i=0,s=0;s=ze(e)?n<0?dt:ht:e<0?lt:Ze}function Ln(n,e){var t=e.center,i=n.offsetDelta||{},s=n.prevDelta||{},o=n.prevInput||{};(e.eventType===$||o.eventType===j)&&(s=n.prevDelta={x:o.deltaX||0,y:o.deltaY||0},i=n.offsetDelta={x:t.x,y:t.y}),e.deltaX=s.x+(t.x-i.x),e.deltaY=s.y+(t.y-i.y)}function ss(n,e,t){return{x:e/n||0,y:t/n||0}}function Hn(n,e){return Dt(e[0],e[1],Pt)/Dt(n[0],n[1],Pt)}function jn(n,e){return ni(e[1],e[0],Pt)+ni(n[1],n[0],Pt)}function Wn(n,e){var t=n.lastInterval||e,i=e.timeStamp-t.timeStamp,s,o,r,a;if(e.eventType!==J&&(i>zn||t.velocity===void 0)){var d=e.deltaX-t.deltaX,h=e.deltaY-t.deltaY,l=ss(i,d,h);o=l.x,r=l.y,s=ze(l.x)>ze(l.y)?l.x:l.y,a=is(d,h),n.lastInterval=e}else s=t.velocity,o=t.velocityX,r=t.velocityY,a=t.direction;e.velocity=s,e.velocityX=o,e.velocityY=r,e.direction=a}function Vn(n,e){var t=n.session,i=e.pointers,s=i.length;t.firstInput||(t.firstInput=ts(e)),s>1&&!t.firstMultiple?t.firstMultiple=ts(e):s===1&&(t.firstMultiple=!1);var o=t.firstInput,r=t.firstMultiple,a=r?r.center:o.center,d=e.center=es(i);e.timeStamp=ti(),e.deltaTime=e.timeStamp-o.timeStamp,e.angle=ni(a,d),e.distance=Dt(a,d),Ln(t,e),e.offsetDirection=is(e.deltaX,e.deltaY);var h=ss(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=h.x,e.overallVelocityY=h.y,e.overallVelocity=ze(h.x)>ze(h.y)?h.x:h.y,e.scale=r?Hn(r.pointers,i):1,e.rotation=r?jn(r.pointers,i):0,e.maxPointers=t.prevInput?e.pointers.length>t.prevInput.maxPointers?e.pointers.length:t.prevInput.maxPointers:e.pointers.length,Wn(t,e);var l=n.element,c=e.srcEvent,u;c.composedPath?u=c.composedPath()[0]:c.path?u=c.path[0]:u=c.target,oi(u,l)&&(l=u),e.target=l}function qn(n,e,t){var i=t.pointers.length,s=t.changedPointers.length,o=e&$&&i-s==0,r=e&(j|J)&&i-s==0;t.isFirst=!!o,t.isFinal=!!r,o&&(n.session={}),t.eventType=e,Vn(n,t),n.emit("hammer.input",t),n.recognize(t),n.session.prevInput=t}function ct(n){return n.trim().split(/\s+/g)}function ut(n,e,t){ye(ct(e),function(i){n.addEventListener(i,t,!1)})}function ft(n,e,t){ye(ct(e),function(i){n.removeEventListener(i,t,!1)})}function os(n){var e=n.ownerDocument||n;return e.defaultView||e.parentWindow||window}var Qe=function(){function n(t,i){var s=this;this.manager=t,this.callback=i,this.element=t.element,this.target=t.options.inputTarget,this.domHandler=function(o){Mt(t.options.enable,[t])&&s.handler(o)},this.init()}var e=n.prototype;return e.handler=function(){},e.init=function(){this.evEl&&ut(this.element,this.evEl,this.domHandler),this.evTarget&&ut(this.target,this.evTarget,this.domHandler),this.evWin&&ut(os(this.element),this.evWin,this.domHandler)},e.destroy=function(){this.evEl&&ft(this.element,this.evEl,this.domHandler),this.evTarget&&ft(this.target,this.evTarget,this.domHandler),this.evWin&&ft(os(this.element),this.evWin,this.domHandler)},n}();function We(n,e,t){if(n.indexOf&&!t)return n.indexOf(e);for(var i=0;id[e]}):i=i.sort()),i}var Xn={touchstart:$,touchmove:Le,touchend:j,touchcancel:J},Gn="touchstart touchmove touchend touchcancel",ai=function(n){ne(e,n);function e(){var i;return e.prototype.evTarget=Gn,i=n.apply(this,arguments)||this,i.targetIds={},i}var t=e.prototype;return t.handler=function(s){var o=Xn[s.type],r=Kn.call(this,s,o);!r||this.callback(this.manager,o,{pointers:r[0],changedPointers:r[1],pointerType:at,srcEvent:s})},e}(Qe);function Kn(n,e){var t=pt(n.touches),i=this.targetIds;if(e&($|Le)&&t.length===1)return i[t[0].identifier]=!0,[t,t];var s,o,r=pt(n.changedTouches),a=[],d=this.target;if(o=t.filter(function(h){return oi(h.target,d)}),e===$)for(s=0;s-1&&s.splice(a,1)};setTimeout(o,Jn)}}function er(n,e){n&$?(this.primaryTouch=e.changedPointers[0].identifier,hs.call(this,e)):n&(j|J)&&hs.call(this,e)}function tr(n){for(var e=n.srcEvent.clientX,t=n.srcEvent.clientY,i=0;i-1&&this.requireFail.splice(s,1),this},e.hasRequireFailures=function(){return this.requireFail.length>0},e.canRecognizeWith=function(i){return!!this.simultaneous[i.id]},e.emit=function(i){var s=this,o=this.state;function r(a){s.manager.emit(a,i)}o=Se&&r(s.options.event+cs(o))},e.tryEmit=function(i){if(this.canEmit())return this.emit(i);this.state=fe},e.canEmit=function(){for(var i=0;io.threshold&&d&o.direction},t.attrTest=function(s){return tt.prototype.attrTest.call(this,s)&&(this.state&re||!(this.state&re)&&this.directionTest(s))},t.emit=function(s){this.pX=s.deltaX,this.pY=s.deltaY;var o=us(s.direction);o&&(s.additionalEvent=this.options.event+o),n.prototype.emit.call(this,s)},e}(tt),fs=function(n){ne(e,n);function e(i){return i===void 0&&(i={}),n.call(this,ce({event:"swipe",threshold:10,velocity:.3,direction:ue|He,pointers:1},i))||this}var t=e.prototype;return t.getTouchAction=function(){return li.prototype.getTouchAction.call(this)},t.attrTest=function(s){var o=this.options.direction,r;return o&(ue|He)?r=s.overallVelocity:o&ue?r=s.overallVelocityX:o&He&&(r=s.overallVelocityY),n.prototype.attrTest.call(this,s)&&o&s.offsetDirection&&s.distance>this.options.threshold&&s.maxPointers===this.options.pointers&&ze(r)>this.options.velocity&&s.eventType&j},t.emit=function(s){var o=us(s.offsetDirection);o&&this.manager.emit(this.options.event+o,s),this.manager.emit(this.options.event,s)},e}(tt),ps=function(n){ne(e,n);function e(i){return i===void 0&&(i={}),n.call(this,ce({event:"pinch",threshold:0,pointers:2},i))||this}var t=e.prototype;return t.getTouchAction=function(){return[Re]},t.attrTest=function(s){return n.prototype.attrTest.call(this,s)&&(Math.abs(s.scale-1)>this.options.threshold||this.state&re)},t.emit=function(s){if(s.scale!==1){var o=s.scale<1?"in":"out";s.additionalEvent=this.options.event+o}n.prototype.emit.call(this,s)},e}(tt),gs=function(n){ne(e,n);function e(i){return i===void 0&&(i={}),n.call(this,ce({event:"rotate",threshold:0,pointers:2},i))||this}var t=e.prototype;return t.getTouchAction=function(){return[Re]},t.attrTest=function(s){return n.prototype.attrTest.call(this,s)&&(Math.abs(s.rotation)>this.options.threshold||this.state&re)},e}(tt),ms=function(n){ne(e,n);function e(i){var s;return i===void 0&&(i={}),s=n.call(this,ce({event:"press",pointers:1,time:251,threshold:9},i))||this,s._timer=null,s._input=null,s}var t=e.prototype;return t.getTouchAction=function(){return[Ki]},t.process=function(s){var o=this,r=this.options,a=s.pointers.length===r.pointers,d=s.distancer.time;if(this._input=s,!d||!a||s.eventType&(j|J)&&!h)this.reset();else if(s.eventType&$)this.reset(),this._timer=setTimeout(function(){o.state=be,o.tryEmit()},r.time);else if(s.eventType&j)return be;return fe},t.reset=function(){clearTimeout(this._timer)},t.emit=function(s){this.state===be&&(s&&s.eventType&j?this.manager.emit(this.options.event+"up",s):(this._input.timeStamp=ti(),this.manager.emit(this.options.event,this._input)))},e}(mt),ys={domEvents:!1,touchAction:Gi,enable:!0,inputTarget:null,inputClass:null,cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}},bs=[[gs,{enable:!1}],[ps,{enable:!1},["rotate"]],[fs,{direction:ue}],[li,{direction:ue},["swipe"]],[hi],[hi,{event:"doubletap",taps:2},["tap"]],[ms]],nr=1,vs=2;function ws(n,e){var t=n.element;if(!!t.style){var i;ye(n.options.cssProps,function(s,o){i=Ot(t.style,o),e?(n.oldCssProps[i]=t.style[i],t.style[i]=s):t.style[i]=n.oldCssProps[i]||""}),e||(n.oldCssProps={})}}function rr(n,e){var t=document.createEvent("Event");t.initEvent(n,!0,!0),t.gesture=e,e.target.dispatchEvent(t)}var _s=function(){function n(t,i){var s=this;this.options=Ae({},ys,i||{}),this.options.inputTarget=this.options.inputTarget||t,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=t,this.input=ir(this),this.touchAction=new Ji(this,this.options.touchAction),ws(this,!0),ye(this.options.recognizers,function(o){var r=s.add(new o[0](o[1]));o[2]&&r.recognizeWith(o[2]),o[3]&&r.requireFailure(o[3])},this)}var e=n.prototype;return e.set=function(i){return Ae(this.options,i),i.touchAction&&this.touchAction.update(),i.inputTarget&&(this.input.destroy(),this.input.target=i.inputTarget,this.input.init()),this},e.stop=function(i){this.session.stopped=i?vs:nr},e.recognize=function(i){var s=this.session;if(!s.stopped){this.touchAction.preventDefaults(i);var o,r=this.recognizers,a=s.curRecognizer;(!a||a&&a.state&be)&&(s.curRecognizer=null,a=null);for(var d=0;d\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",r=window.console&&(window.console.warn||window.console.log);return r&&r.call(window.console,i,o),n.apply(this,arguments)}}var Cs=xs(function(n,e,t){for(var i=Object.keys(e),s=0;s2)return Bt(Ps(n[0],n[1]),...n.slice(2));let e=n[0],t=n[1];if(e instanceof Date&&t instanceof Date)return e.setTime(t.getTime()),e;for(let i of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,i)&&(t[i]===ci?delete e[i]:e[i]!==null&&t[i]!==null&&typeof e[i]=="object"&&typeof t[i]=="object"&&!Array.isArray(e[i])&&!Array.isArray(t[i])?e[i]=Bt(e[i],t[i]):e[i]=Ms(t[i]));return e}function Ms(n){return Array.isArray(n)?n.map(e=>Ms(e)):typeof n=="object"&&n!==null?n instanceof Date?new Date(n.getTime()):Bt({},n):n}function Ds(n){for(let e of Object.keys(n))n[e]===ci?delete n[e]:typeof n[e]=="object"&&n[e]!==null&&Ds(n[e])}function mt(...n){return br(n.length?n:[Date.now()])}function br(n){let[e,t,i]=vr(n),s=1,o=()=>{let r=2091639*e+s*23283064365386963e-26;return e=t,t=i,i=r-(s=r|0)};return o.uint32=()=>o()*4294967296,o.fract53=()=>o()+(o()*2097152|0)*11102230246251565e-32,o.algorithm="Alea",o.seed=n,o.version="0.9",o}function vr(...n){let e=wr(),t=e(" "),i=e(" "),s=e(" ");for(let o=0;o>>0,s-=n,s*=n,n=s>>>0,s-=n,n+=s*4294967296}return(n>>>0)*23283064365386963e-26}}function _r(){let n=()=>{};return{on:n,off:n,destroy:n,emit:n,get(){return{set:n}}}}var ui=typeof window!="undefined"?window.Hammer||Os:function(){return _r()};function pe(n){this._cleanupQueue=[],this.active=!1,this._dom={container:n,overlay:document.createElement("div")},this._dom.overlay.classList.add("vis-overlay"),this._dom.container.appendChild(this._dom.overlay),this._cleanupQueue.push(()=>{this._dom.overlay.parentNode.removeChild(this._dom.overlay)});let e=ui(this._dom.overlay);e.on("tap",this._onTapOverlay.bind(this)),this._cleanupQueue.push(()=>{e.destroy()}),["tap","doubletap","press","pinch","pan","panstart","panmove","panend"].forEach(i=>{e.on(i,s=>{s.srcEvent.stopPropagation()})}),document&&document.body&&(this._onClick=i=>{Er(i.target,n)||this.deactivate()},document.body.addEventListener("click",this._onClick),this._cleanupQueue.push(()=>{document.body.removeEventListener("click",this._onClick)})),this._escListener=i=>{("key"in i?i.key==="Escape":i.keyCode===27)&&this.deactivate()}}(0,Ss.default)(pe.prototype);pe.current=null;pe.prototype.destroy=function(){this.deactivate();for(let n of this._cleanupQueue.splice(0).reverse())n()};pe.prototype.activate=function(){pe.current&&pe.current.deactivate(),pe.current=this,this.active=!0,this._dom.overlay.style.display="none",this._dom.container.classList.add("vis-active"),this.emit("change"),this.emit("activate"),document.body.addEventListener("keydown",this._escListener)};pe.prototype.deactivate=function(){this.active=!1,this._dom.overlay.style.display="block",this._dom.container.classList.remove("vis-active"),document.body.removeEventListener("keydown",this._escListener),this.emit("change"),this.emit("deactivate")};pe.prototype._onTapOverlay=function(n){this.activate(),n.srcEvent.stopPropagation()};function Er(n,e){for(;n;){if(n===e)return!0;n=n.parentNode}return!1}var xr=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,Cr=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,Tr=/^rgb\( *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *(1?\d{1,2}|2[0-4]\d|25[0-5]) *\)$/i,kr=/^rgba\( *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *([01]|0?\.\d+) *\)$/i;function be(n){if(n)for(;n.hasChildNodes()===!0;){let e=n.firstChild;e&&(be(e),n.removeChild(e))}}function ve(n){return n instanceof String||typeof n=="string"}function Fs(n){return typeof n=="object"&&n!==null}function je(n,e,t,i){let s=!1;i===!0&&(s=e[t]===null&&n[t]!==void 0),s?delete n[t]:n[t]=e[t]}function fi(n,e,t=!1){for(let i in n)if(e[i]!==void 0)if(e[i]===null||typeof e[i]!="object")je(n,e,i,t);else{let s=n[i],o=e[i];Fs(s)&&Fs(o)&&fi(s,o,t)}}function We(n,e,t,i=!1){if(Array.isArray(t))throw new TypeError("Arrays are not supported by deepExtend");for(let s=0;s{},this.closeCallback=()=>{},this._create()}insertTo(e){this.hammer!==void 0&&(this.hammer.destroy(),this.hammer=void 0),this.container=e,this.container.appendChild(this.frame),this._bindHammer(),this._setSize()}setUpdateCallback(e){if(typeof e=="function")this.updateCallback=e;else throw new Error("Function attempted to set as colorPicker update callback is not a function.")}setCloseCallback(e){if(typeof e=="function")this.closeCallback=e;else throw new Error("Function attempted to set as colorPicker closing callback is not a function.")}_isColorString(e){if(typeof e=="string")return Pr[e]}setColor(e,t=!0){if(e==="none")return;let i,s=this._isColorString(e);if(s!==void 0&&(e=s),ve(e)===!0){if(Rs(e)===!0){let o=e.substr(4).substr(0,e.length-5).split(",");i={r:o[0],g:o[1],b:o[2],a:1}}else if(Ir(e)===!0){let o=e.substr(5).substr(0,e.length-6).split(",");i={r:o[0],g:o[1],b:o[2],a:o[3]}}else if(zs(e)===!0){let o=pi(e);i={r:o.r,g:o.g,b:o.b,a:1}}}else if(e instanceof Object&&e.r!==void 0&&e.g!==void 0&&e.b!==void 0){let o=e.a!==void 0?e.a:"1.0";i={r:e.r,g:e.g,b:e.b,a:o}}if(i===void 0)throw new Error("Unknown color passed to the colorPicker. Supported are strings: rgb, hex, rgba. Object: rgb ({r:r,g:g,b:b,[a:a]}). Supplied: "+JSON.stringify(e));this._setColor(i,t)}show(){this.closeCallback!==void 0&&(this.closeCallback(),this.closeCallback=void 0),this.applied=!1,this.frame.style.display="block",this._generateHueCircle()}_hide(e=!0){e===!0&&(this.previousColor=Object.assign({},this.color)),this.applied===!0&&this.updateCallback(this.initialColor),this.frame.style.display="none",setTimeout(()=>{this.closeCallback!==void 0&&(this.closeCallback(),this.closeCallback=void 0)},0)}_save(){this.updateCallback(this.color),this.applied=!1,this._hide()}_apply(){this.applied=!0,this.updateCallback(this.color),this._updatePicker(this.color)}_loadLast(){this.previousColor!==void 0?this.setColor(this.previousColor,!1):alert("There is no last color to load...")}_setColor(e,t=!0){t===!0&&(this.initialColor=Object.assign({},e)),this.color=e;let i=bt(e.r,e.g,e.b),s=2*Math.PI,o=this.r*i.s,r=this.centerCoordinates.x+o*Math.sin(s*i.h),a=this.centerCoordinates.y+o*Math.cos(s*i.h);this.colorPickerSelector.style.left=r-.5*this.colorPickerSelector.clientWidth+"px",this.colorPickerSelector.style.top=a-.5*this.colorPickerSelector.clientHeight+"px",this._updatePicker(e)}_setOpacity(e){this.color.a=e/100,this._updatePicker(this.color)}_setBrightness(e){let t=bt(this.color.r,this.color.g,this.color.b);t.v=e/100;let i=Rt(t.h,t.s,t.v);i.a=this.color.a,this.color=i,this._updatePicker()}_updatePicker(e=this.color){let t=bt(e.r,e.g,e.b),i=this.colorPickerCanvas.getContext("2d");this.pixelRation===void 0&&(this.pixelRatio=(window.devicePixelRatio||1)/(i.webkitBackingStorePixelRatio||i.mozBackingStorePixelRatio||i.msBackingStorePixelRatio||i.oBackingStorePixelRatio||i.backingStorePixelRatio||1)),i.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0);let s=this.colorPickerCanvas.clientWidth,o=this.colorPickerCanvas.clientHeight;i.clearRect(0,0,s,o),i.putImageData(this.hueCircle,0,0),i.fillStyle="rgba(0,0,0,"+(1-t.v)+")",i.circle(this.centerCoordinates.x,this.centerCoordinates.y,this.r),i.fill(),this.brightnessRange.value=100*t.v,this.opacityRange.value=100*e.a,this.initialColorDiv.style.backgroundColor="rgba("+this.initialColor.r+","+this.initialColor.g+","+this.initialColor.b+","+this.initialColor.a+")",this.newColorDiv.style.backgroundColor="rgba("+this.color.r+","+this.color.g+","+this.color.b+","+this.color.a+")"}_setSize(){this.colorPickerCanvas.style.width="100%",this.colorPickerCanvas.style.height="100%",this.colorPickerCanvas.width=289*this.pixelRatio,this.colorPickerCanvas.height=289*this.pixelRatio}_create(){if(this.frame=document.createElement("div"),this.frame.className="vis-color-picker",this.colorPickerDiv=document.createElement("div"),this.colorPickerSelector=document.createElement("div"),this.colorPickerSelector.className="vis-selector",this.colorPickerDiv.appendChild(this.colorPickerSelector),this.colorPickerCanvas=document.createElement("canvas"),this.colorPickerDiv.appendChild(this.colorPickerCanvas),this.colorPickerCanvas.getContext){let t=this.colorPickerCanvas.getContext("2d");this.pixelRatio=(window.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1),this.colorPickerCanvas.getContext("2d").setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0)}else{let t=document.createElement("DIV");t.style.color="red",t.style.fontWeight="bold",t.style.padding="10px",t.innerText="Error: your browser does not support HTML canvas",this.colorPickerCanvas.appendChild(t)}this.colorPickerDiv.className="vis-color",this.opacityDiv=document.createElement("div"),this.opacityDiv.className="vis-opacity",this.brightnessDiv=document.createElement("div"),this.brightnessDiv.className="vis-brightness",this.arrowDiv=document.createElement("div"),this.arrowDiv.className="vis-arrow",this.opacityRange=document.createElement("input");try{this.opacityRange.type="range",this.opacityRange.min="0",this.opacityRange.max="100"}catch(t){}this.opacityRange.value="100",this.opacityRange.className="vis-range",this.brightnessRange=document.createElement("input");try{this.brightnessRange.type="range",this.brightnessRange.min="0",this.brightnessRange.max="100"}catch(t){}this.brightnessRange.value="100",this.brightnessRange.className="vis-range",this.opacityDiv.appendChild(this.opacityRange),this.brightnessDiv.appendChild(this.brightnessRange);let e=this;this.opacityRange.onchange=function(){e._setOpacity(this.value)},this.opacityRange.oninput=function(){e._setOpacity(this.value)},this.brightnessRange.onchange=function(){e._setBrightness(this.value)},this.brightnessRange.oninput=function(){e._setBrightness(this.value)},this.brightnessLabel=document.createElement("div"),this.brightnessLabel.className="vis-label vis-brightness",this.brightnessLabel.innerText="brightness:",this.opacityLabel=document.createElement("div"),this.opacityLabel.className="vis-label vis-opacity",this.opacityLabel.innerText="opacity:",this.newColorDiv=document.createElement("div"),this.newColorDiv.className="vis-new-color",this.newColorDiv.innerText="new",this.initialColorDiv=document.createElement("div"),this.initialColorDiv.className="vis-initial-color",this.initialColorDiv.innerText="initial",this.cancelButton=document.createElement("div"),this.cancelButton.className="vis-button vis-cancel",this.cancelButton.innerText="cancel",this.cancelButton.onclick=this._hide.bind(this,!1),this.applyButton=document.createElement("div"),this.applyButton.className="vis-button vis-apply",this.applyButton.innerText="apply",this.applyButton.onclick=this._apply.bind(this),this.saveButton=document.createElement("div"),this.saveButton.className="vis-button vis-save",this.saveButton.innerText="save",this.saveButton.onclick=this._save.bind(this),this.loadButton=document.createElement("div"),this.loadButton.className="vis-button vis-load",this.loadButton.innerText="load last",this.loadButton.onclick=this._loadLast.bind(this),this.frame.appendChild(this.colorPickerDiv),this.frame.appendChild(this.arrowDiv),this.frame.appendChild(this.brightnessLabel),this.frame.appendChild(this.brightnessDiv),this.frame.appendChild(this.opacityLabel),this.frame.appendChild(this.opacityDiv),this.frame.appendChild(this.newColorDiv),this.frame.appendChild(this.initialColorDiv),this.frame.appendChild(this.cancelButton),this.frame.appendChild(this.applyButton),this.frame.appendChild(this.saveButton),this.frame.appendChild(this.loadButton)}_bindHammer(){this.drag={},this.pinch={},this.hammer=new ui(this.colorPickerCanvas),this.hammer.get("pinch").set({enable:!0}),this.hammer.on("hammer.input",e=>{e.isFirst&&this._moveSelector(e)}),this.hammer.on("tap",e=>{this._moveSelector(e)}),this.hammer.on("panstart",e=>{this._moveSelector(e)}),this.hammer.on("panmove",e=>{this._moveSelector(e)}),this.hammer.on("panend",e=>{this._moveSelector(e)})}_generateHueCircle(){if(this.generated===!1){let e=this.colorPickerCanvas.getContext("2d");this.pixelRation===void 0&&(this.pixelRatio=(window.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1)),e.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0);let t=this.colorPickerCanvas.clientWidth,i=this.colorPickerCanvas.clientHeight;e.clearRect(0,0,t,i);let s,o,r,a;this.centerCoordinates={x:t*.5,y:i*.5},this.r=.49*t;let d=2*Math.PI/360,h=1/360,l=1/this.r,c;for(r=0;r<360;r++)for(a=0;a!1){this.parent=e,this.changedOptions=[],this.container=t,this.allowCreation=!1,this.hideOption=o,this.options={},this.initialized=!1,this.popupCounter=0,this.defaultOptions={enabled:!1,filter:!0,container:void 0,showButton:!0},Object.assign(this.options,this.defaultOptions),this.configureOptions=i,this.moduleOptions={},this.domElements=[],this.popupDiv={},this.popupLimit=5,this.popupHistory={},this.colorPicker=new Mr(s),this.wrapper=void 0}setOptions(e){if(e!==void 0){this.popupHistory={},this._removePopup();let t=!0;if(typeof e=="string")this.options.filter=e;else if(Array.isArray(e))this.options.filter=e.join();else if(typeof e=="object"){if(e==null)throw new TypeError("options cannot be null");e.container!==void 0&&(this.options.container=e.container),e.filter!==void 0&&(this.options.filter=e.filter),e.showButton!==void 0&&(this.options.showButton=e.showButton),e.enabled!==void 0&&(t=e.enabled)}else typeof e=="boolean"?(this.options.filter=!0,t=e):typeof e=="function"&&(this.options.filter=e,t=!0);this.options.filter===!1&&(t=!1),this.options.enabled=t}this._clean()}setModuleOptions(e){this.moduleOptions=e,this.options.enabled===!0&&(this._clean(),this.options.container!==void 0&&(this.container=this.options.container),this._create())}_create(){this._clean(),this.changedOptions=[];let e=this.options.filter,t=0,i=!1;for(let s in this.configureOptions)Object.prototype.hasOwnProperty.call(this.configureOptions,s)&&(this.allowCreation=!1,i=!1,typeof e=="function"?(i=e(s,[]),i=i||this._handleObject(this.configureOptions[s],[s],!0)):(e===!0||e.indexOf(s)!==-1)&&(i=!0),i!==!1&&(this.allowCreation=!0,t>0&&this._makeItem([]),this._makeHeader(s),this._handleObject(this.configureOptions[s],[s])),t++);this._makeButton(),this._push()}_push(){this.wrapper=document.createElement("div"),this.wrapper.className="vis-configuration-wrapper",this.container.appendChild(this.wrapper);for(let e=0;e{i.appendChild(s)}),this.domElements.push(i),this.domElements.length}return 0}_makeHeader(e){let t=document.createElement("div");t.className="vis-configuration vis-config-header",t.innerText=e,this._makeItem([],t)}_makeLabel(e,t,i=!1){let s=document.createElement("div");if(s.className="vis-configuration vis-config-label vis-config-s"+t.length,i===!0){for(;s.firstChild;)s.removeChild(s.firstChild);s.appendChild(gi("i","b",e))}else s.innerText=e+":";return s}_makeDropdown(e,t,i){let s=document.createElement("select");s.className="vis-configuration vis-config-select";let o=0;t!==void 0&&e.indexOf(t)!==-1&&(o=e.indexOf(t));for(let d=0;dr&&r!==1&&(d.max=Math.ceil(t*m),l=d.max,h="range increased"),d.value=t}else d.value=s;let c=document.createElement("input");c.className="vis-configuration vis-config-rangeinput",c.value=d.value;let u=this;d.onchange=function(){c.value=this.value,u._update(Number(this.value),i)},d.oninput=function(){c.value=this.value};let f=this._makeLabel(i[i.length-1],i),p=this._makeItem(i,f,d,c);h!==""&&this.popupHistory[p]!==l&&(this.popupHistory[p]=l,this._setupPopup(h,p))}_makeButton(){if(this.options.showButton===!0){let e=document.createElement("div");e.className="vis-configuration vis-config-button",e.innerText="generate options",e.onclick=()=>{this._printOptions()},e.onmouseover=()=>{e.className="vis-configuration vis-config-button hover"},e.onmouseout=()=>{e.className="vis-configuration vis-config-button"},this.optionsContainer=document.createElement("div"),this.optionsContainer.className="vis-configuration vis-config-option-container",this.domElements.push(this.optionsContainer),this.domElements.push(e)}}_setupPopup(e,t){if(this.initialized===!0&&this.allowCreation===!0&&this.popupCounter{this._removePopup()},this.popupCounter+=1,this.popupDiv={html:i,index:t}}}_removePopup(){this.popupDiv.html!==void 0&&(this.popupDiv.html.parentNode.removeChild(this.popupDiv.html),clearTimeout(this.popupDiv.hideTimeout),clearTimeout(this.popupDiv.deleteTimeout),this.popupDiv={})}_showPopupIfNeeded(){if(this.popupDiv.html!==void 0){let t=this.domElements[this.popupDiv.index].getBoundingClientRect();this.popupDiv.html.style.left=t.left+"px",this.popupDiv.html.style.top=t.top-30+"px",document.body.appendChild(this.popupDiv.html),this.popupDiv.hideTimeout=setTimeout(()=>{this.popupDiv.html.style.opacity=0},1500),this.popupDiv.deleteTimeout=setTimeout(()=>{this._removePopup()},1800)}}_makeCheckbox(e,t,i){let s=document.createElement("input");s.type="checkbox",s.className="vis-configuration vis-config-checkbox",s.checked=e,t!==void 0&&(s.checked=t,t!==e&&(typeof e=="object"?t!==e.enabled&&this.changedOptions.push({path:i,value:t}):this.changedOptions.push({path:i,value:t})));let o=this;s.onchange=function(){o._update(this.checked,i)};let r=this._makeLabel(i[i.length-1],i);this._makeItem(i,r,s)}_makeTextInput(e,t,i){let s=document.createElement("input");s.type="text",s.className="vis-configuration vis-config-text",s.value=t,t!==e&&this.changedOptions.push({path:i,value:t});let o=this;s.onchange=function(){o._update(this.value,i)};let r=this._makeLabel(i[i.length-1],i);this._makeItem(i,r,s)}_makeColorField(e,t,i){let s=e[1],o=document.createElement("div");t=t===void 0?s:t,t!=="none"?(o.className="vis-configuration vis-config-colorBlock",o.style.backgroundColor=t):o.className="vis-configuration vis-config-colorBlock none",t=t===void 0?s:t,o.onclick=()=>{this._showColorPicker(t,o,i)};let r=this._makeLabel(i[i.length-1],i);this._makeItem(i,r,o)}_showColorPicker(e,t,i){t.onclick=function(){},this.colorPicker.insertTo(t),this.colorPicker.show(),this.colorPicker.setColor(e),this.colorPicker.setUpdateCallback(s=>{let o="rgba("+s.r+","+s.g+","+s.b+","+s.a+")";t.style.backgroundColor=o,this._update(o,i)}),this.colorPicker.setCloseCallback(()=>{t.onclick=()=>{this._showColorPicker(e,t,i)}})}_handleObject(e,t=[],i=!1){let s=!1,o=this.options.filter,r=!1;for(let a in e)if(Object.prototype.hasOwnProperty.call(e,a)){s=!0;let d=e[a],h=At(t,a);if(typeof o=="function"&&(s=o(a,t),s===!1&&!Array.isArray(d)&&typeof d!="string"&&typeof d!="boolean"&&d instanceof Object&&(this.allowCreation=!1,s=this._handleObject(d,h,!0),this.allowCreation=i===!1)),s!==!1){r=!0;let l=this._getValue(h);if(Array.isArray(d))this._handleArray(d,l,h);else if(typeof d=="string")this._makeTextInput(d,l,h);else if(typeof d=="boolean")this._makeCheckbox(d,l,h);else if(d instanceof Object){if(!this.hideOption(t,a,this.moduleOptions))if(d.enabled!==void 0){let c=At(h,"enabled"),u=this._getValue(c);if(u===!0){let f=this._makeLabel(a,h,!0);this._makeItem(h,f),r=this._handleObject(d,h)||r}else this._makeCheckbox(d,u,h)}else{let c=this._makeLabel(a,h,!0);this._makeItem(h,c),r=this._handleObject(d,h)||r}}else console.error("dont know how to handle",d,a,h)}}return r}_handleArray(e,t,i){typeof e[0]=="string"&&e[0]==="color"?(this._makeColorField(e,t,i),e[1]!==t&&this.changedOptions.push({path:i,value:t})):typeof e[0]=="string"?(this._makeDropdown(e,t,i),e[0]!==t&&this.changedOptions.push({path:i,value:t})):typeof e[0]=="number"&&(this._makeRange(e,t,i),e[0]!==t&&this.changedOptions.push({path:i,value:Number(t)}))}_update(e,t){let i=this._constructOptions(e,t);this.parent.body&&this.parent.body.emitter&&this.parent.body.emitter.emit&&this.parent.body.emitter.emit("configChange",i),this.initialized=!0,this.parent.setOptions(i)}_constructOptions(e,t,i={}){let s=i;e=e==="true"?!0:e,e=e==="false"?!1:e;for(let o=0;oo-this.padding&&(d=!0),d?r=this.x-i:r=this.x,h?a=this.y-t:a=this.y}else a=this.y-t,a+t+this.padding>s&&(a=s-t-this.padding),ao&&(r=o-i-this.padding),r\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",r=window.console&&(window.console.warn||window.console.log);return r&&r.call(window.console,i,o),n.apply(this,arguments)}}var xs=Es(function(n,e,t){for(var i=Object.keys(e),s=0;s2)return Bt(Is(n[0],n[1]),...n.slice(2));let e=n[0],t=n[1];if(e instanceof Date&&t instanceof Date)return e.setTime(t.getTime()),e;for(let i of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,i)&&(t[i]===ci?delete e[i]:e[i]!==null&&t[i]!==null&&typeof e[i]=="object"&&typeof t[i]=="object"&&!Array.isArray(e[i])&&!Array.isArray(t[i])?e[i]=Bt(e[i],t[i]):e[i]=Ps(t[i]));return e}function Ps(n){return Array.isArray(n)?n.map(e=>Ps(e)):typeof n=="object"&&n!==null?n instanceof Date?new Date(n.getTime()):Bt({},n):n}function Ms(n){for(let e of Object.keys(n))n[e]===ci?delete n[e]:typeof n[e]=="object"&&n[e]!==null&&Ms(n[e])}function yt(...n){return pr(n.length?n:[Date.now()])}function pr(n){let[e,t,i]=gr(n),s=1,o=()=>{let r=2091639*e+s*23283064365386963e-26;return e=t,t=i,i=r-(s=r|0)};return o.uint32=()=>o()*4294967296,o.fract53=()=>o()+(o()*2097152|0)*11102230246251565e-32,o.algorithm="Alea",o.seed=n,o.version="0.9",o}function gr(...n){let e=mr(),t=e(" "),i=e(" "),s=e(" ");for(let o=0;o>>0,s-=n,s*=n,n=s>>>0,s-=n,n+=s*4294967296}return(n>>>0)*23283064365386963e-26}}function yr(){let n=()=>{};return{on:n,off:n,destroy:n,emit:n,get(){return{set:n}}}}var ui=typeof window!="undefined"?window.Hammer||ks:function(){return yr()};function pe(n){this._cleanupQueue=[],this.active=!1,this._dom={container:n,overlay:document.createElement("div")},this._dom.overlay.classList.add("vis-overlay"),this._dom.container.appendChild(this._dom.overlay),this._cleanupQueue.push(()=>{this._dom.overlay.parentNode.removeChild(this._dom.overlay)});let e=ui(this._dom.overlay);e.on("tap",this._onTapOverlay.bind(this)),this._cleanupQueue.push(()=>{e.destroy()}),["tap","doubletap","press","pinch","pan","panstart","panmove","panend"].forEach(i=>{e.on(i,s=>{s.srcEvent.stopPropagation()})}),document&&document.body&&(this._onClick=i=>{br(i.target,n)||this.deactivate()},document.body.addEventListener("click",this._onClick),this._cleanupQueue.push(()=>{document.body.removeEventListener("click",this._onClick)})),this._escListener=i=>{("key"in i?i.key==="Escape":i.keyCode===27)&&this.deactivate()}}(0,Os.default)(pe.prototype);pe.current=null;pe.prototype.destroy=function(){this.deactivate();for(let n of this._cleanupQueue.splice(0).reverse())n()};pe.prototype.activate=function(){pe.current&&pe.current.deactivate(),pe.current=this,this.active=!0,this._dom.overlay.style.display="none",this._dom.container.classList.add("vis-active"),this.emit("change"),this.emit("activate"),document.body.addEventListener("keydown",this._escListener)};pe.prototype.deactivate=function(){this.active=!1,this._dom.overlay.style.display="block",this._dom.container.classList.remove("vis-active"),document.body.removeEventListener("keydown",this._escListener),this.emit("change"),this.emit("deactivate")};pe.prototype._onTapOverlay=function(n){this.activate(),n.srcEvent.stopPropagation()};function br(n,e){for(;n;){if(n===e)return!0;n=n.parentNode}return!1}var vr=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,wr=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,_r=/^rgb\( *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *(1?\d{1,2}|2[0-4]\d|25[0-5]) *\)$/i,Er=/^rgba\( *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *(1?\d{1,2}|2[0-4]\d|25[0-5]) *, *([01]|0?\.\d+) *\)$/i;function ve(n){if(n)for(;n.hasChildNodes()===!0;){let e=n.firstChild;e&&(ve(e),n.removeChild(e))}}function we(n){return n instanceof String||typeof n=="string"}function Ds(n){return typeof n=="object"&&n!==null}function Ve(n,e,t,i){let s=!1;i===!0&&(s=e[t]===null&&n[t]!==void 0),s?delete n[t]:n[t]=e[t]}function fi(n,e,t=!1){for(let i in n)if(e[i]!==void 0)if(e[i]===null||typeof e[i]!="object")Ve(n,e,i,t);else{let s=n[i],o=e[i];Ds(s)&&Ds(o)&&fi(s,o,t)}}function qe(n,e,t,i=!1){if(Array.isArray(t))throw new TypeError("Arrays are not supported by deepExtend");for(let s=0;s{},this.closeCallback=()=>{},this._create()}insertTo(e){this.hammer!==void 0&&(this.hammer.destroy(),this.hammer=void 0),this.container=e,this.container.appendChild(this.frame),this._bindHammer(),this._setSize()}setUpdateCallback(e){if(typeof e=="function")this.updateCallback=e;else throw new Error("Function attempted to set as colorPicker update callback is not a function.")}setCloseCallback(e){if(typeof e=="function")this.closeCallback=e;else throw new Error("Function attempted to set as colorPicker closing callback is not a function.")}_isColorString(e){if(typeof e=="string")return kr[e]}setColor(e,t=!0){if(e==="none")return;let i,s=this._isColorString(e);if(s!==void 0&&(e=s),we(e)===!0){if(zs(e)===!0){let o=e.substr(4).substr(0,e.length-5).split(",");i={r:o[0],g:o[1],b:o[2],a:1}}else if(Tr(e)===!0){let o=e.substr(5).substr(0,e.length-6).split(",");i={r:o[0],g:o[1],b:o[2],a:o[3]}}else if(As(e)===!0){let o=pi(e);i={r:o.r,g:o.g,b:o.b,a:1}}}else if(e instanceof Object&&e.r!==void 0&&e.g!==void 0&&e.b!==void 0){let o=e.a!==void 0?e.a:"1.0";i={r:e.r,g:e.g,b:e.b,a:o}}if(i===void 0)throw new Error("Unknown color passed to the colorPicker. Supported are strings: rgb, hex, rgba. Object: rgb ({r:r,g:g,b:b,[a:a]}). Supplied: "+JSON.stringify(e));this._setColor(i,t)}show(){this.closeCallback!==void 0&&(this.closeCallback(),this.closeCallback=void 0),this.applied=!1,this.frame.style.display="block",this._generateHueCircle()}_hide(e=!0){e===!0&&(this.previousColor=Object.assign({},this.color)),this.applied===!0&&this.updateCallback(this.initialColor),this.frame.style.display="none",setTimeout(()=>{this.closeCallback!==void 0&&(this.closeCallback(),this.closeCallback=void 0)},0)}_save(){this.updateCallback(this.color),this.applied=!1,this._hide()}_apply(){this.applied=!0,this.updateCallback(this.color),this._updatePicker(this.color)}_loadLast(){this.previousColor!==void 0?this.setColor(this.previousColor,!1):alert("There is no last color to load...")}_setColor(e,t=!0){t===!0&&(this.initialColor=Object.assign({},e)),this.color=e;let i=vt(e.r,e.g,e.b),s=2*Math.PI,o=this.r*i.s,r=this.centerCoordinates.x+o*Math.sin(s*i.h),a=this.centerCoordinates.y+o*Math.cos(s*i.h);this.colorPickerSelector.style.left=r-.5*this.colorPickerSelector.clientWidth+"px",this.colorPickerSelector.style.top=a-.5*this.colorPickerSelector.clientHeight+"px",this._updatePicker(e)}_setOpacity(e){this.color.a=e/100,this._updatePicker(this.color)}_setBrightness(e){let t=vt(this.color.r,this.color.g,this.color.b);t.v=e/100;let i=Rt(t.h,t.s,t.v);i.a=this.color.a,this.color=i,this._updatePicker()}_updatePicker(e=this.color){let t=vt(e.r,e.g,e.b),i=this.colorPickerCanvas.getContext("2d");this.pixelRation===void 0&&(this.pixelRatio=(window.devicePixelRatio||1)/(i.webkitBackingStorePixelRatio||i.mozBackingStorePixelRatio||i.msBackingStorePixelRatio||i.oBackingStorePixelRatio||i.backingStorePixelRatio||1)),i.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0);let s=this.colorPickerCanvas.clientWidth,o=this.colorPickerCanvas.clientHeight;i.clearRect(0,0,s,o),i.putImageData(this.hueCircle,0,0),i.fillStyle="rgba(0,0,0,"+(1-t.v)+")",i.circle(this.centerCoordinates.x,this.centerCoordinates.y,this.r),i.fill(),this.brightnessRange.value=100*t.v,this.opacityRange.value=100*e.a,this.initialColorDiv.style.backgroundColor="rgba("+this.initialColor.r+","+this.initialColor.g+","+this.initialColor.b+","+this.initialColor.a+")",this.newColorDiv.style.backgroundColor="rgba("+this.color.r+","+this.color.g+","+this.color.b+","+this.color.a+")"}_setSize(){this.colorPickerCanvas.style.width="100%",this.colorPickerCanvas.style.height="100%",this.colorPickerCanvas.width=289*this.pixelRatio,this.colorPickerCanvas.height=289*this.pixelRatio}_create(){if(this.frame=document.createElement("div"),this.frame.className="vis-color-picker",this.colorPickerDiv=document.createElement("div"),this.colorPickerSelector=document.createElement("div"),this.colorPickerSelector.className="vis-selector",this.colorPickerDiv.appendChild(this.colorPickerSelector),this.colorPickerCanvas=document.createElement("canvas"),this.colorPickerDiv.appendChild(this.colorPickerCanvas),this.colorPickerCanvas.getContext){let t=this.colorPickerCanvas.getContext("2d");this.pixelRatio=(window.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1),this.colorPickerCanvas.getContext("2d").setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0)}else{let t=document.createElement("DIV");t.style.color="red",t.style.fontWeight="bold",t.style.padding="10px",t.innerText="Error: your browser does not support HTML canvas",this.colorPickerCanvas.appendChild(t)}this.colorPickerDiv.className="vis-color",this.opacityDiv=document.createElement("div"),this.opacityDiv.className="vis-opacity",this.brightnessDiv=document.createElement("div"),this.brightnessDiv.className="vis-brightness",this.arrowDiv=document.createElement("div"),this.arrowDiv.className="vis-arrow",this.opacityRange=document.createElement("input");try{this.opacityRange.type="range",this.opacityRange.min="0",this.opacityRange.max="100"}catch(t){}this.opacityRange.value="100",this.opacityRange.className="vis-range",this.brightnessRange=document.createElement("input");try{this.brightnessRange.type="range",this.brightnessRange.min="0",this.brightnessRange.max="100"}catch(t){}this.brightnessRange.value="100",this.brightnessRange.className="vis-range",this.opacityDiv.appendChild(this.opacityRange),this.brightnessDiv.appendChild(this.brightnessRange);let e=this;this.opacityRange.onchange=function(){e._setOpacity(this.value)},this.opacityRange.oninput=function(){e._setOpacity(this.value)},this.brightnessRange.onchange=function(){e._setBrightness(this.value)},this.brightnessRange.oninput=function(){e._setBrightness(this.value)},this.brightnessLabel=document.createElement("div"),this.brightnessLabel.className="vis-label vis-brightness",this.brightnessLabel.innerText="brightness:",this.opacityLabel=document.createElement("div"),this.opacityLabel.className="vis-label vis-opacity",this.opacityLabel.innerText="opacity:",this.newColorDiv=document.createElement("div"),this.newColorDiv.className="vis-new-color",this.newColorDiv.innerText="new",this.initialColorDiv=document.createElement("div"),this.initialColorDiv.className="vis-initial-color",this.initialColorDiv.innerText="initial",this.cancelButton=document.createElement("div"),this.cancelButton.className="vis-button vis-cancel",this.cancelButton.innerText="cancel",this.cancelButton.onclick=this._hide.bind(this,!1),this.applyButton=document.createElement("div"),this.applyButton.className="vis-button vis-apply",this.applyButton.innerText="apply",this.applyButton.onclick=this._apply.bind(this),this.saveButton=document.createElement("div"),this.saveButton.className="vis-button vis-save",this.saveButton.innerText="save",this.saveButton.onclick=this._save.bind(this),this.loadButton=document.createElement("div"),this.loadButton.className="vis-button vis-load",this.loadButton.innerText="load last",this.loadButton.onclick=this._loadLast.bind(this),this.frame.appendChild(this.colorPickerDiv),this.frame.appendChild(this.arrowDiv),this.frame.appendChild(this.brightnessLabel),this.frame.appendChild(this.brightnessDiv),this.frame.appendChild(this.opacityLabel),this.frame.appendChild(this.opacityDiv),this.frame.appendChild(this.newColorDiv),this.frame.appendChild(this.initialColorDiv),this.frame.appendChild(this.cancelButton),this.frame.appendChild(this.applyButton),this.frame.appendChild(this.saveButton),this.frame.appendChild(this.loadButton)}_bindHammer(){this.drag={},this.pinch={},this.hammer=new ui(this.colorPickerCanvas),this.hammer.get("pinch").set({enable:!0}),this.hammer.on("hammer.input",e=>{e.isFirst&&this._moveSelector(e)}),this.hammer.on("tap",e=>{this._moveSelector(e)}),this.hammer.on("panstart",e=>{this._moveSelector(e)}),this.hammer.on("panmove",e=>{this._moveSelector(e)}),this.hammer.on("panend",e=>{this._moveSelector(e)})}_generateHueCircle(){if(this.generated===!1){let e=this.colorPickerCanvas.getContext("2d");this.pixelRation===void 0&&(this.pixelRatio=(window.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1)),e.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0);let t=this.colorPickerCanvas.clientWidth,i=this.colorPickerCanvas.clientHeight;e.clearRect(0,0,t,i);let s,o,r,a;this.centerCoordinates={x:t*.5,y:i*.5},this.r=.49*t;let d=2*Math.PI/360,h=1/360,l=1/this.r,c;for(r=0;r<360;r++)for(a=0;a!1){this.parent=e,this.changedOptions=[],this.container=t,this.allowCreation=!1,this.hideOption=o,this.options={},this.initialized=!1,this.popupCounter=0,this.defaultOptions={enabled:!1,filter:!0,container:void 0,showButton:!0},Object.assign(this.options,this.defaultOptions),this.configureOptions=i,this.moduleOptions={},this.domElements=[],this.popupDiv={},this.popupLimit=5,this.popupHistory={},this.colorPicker=new Or(s),this.wrapper=void 0}setOptions(e){if(e!==void 0){this.popupHistory={},this._removePopup();let t=!0;if(typeof e=="string")this.options.filter=e;else if(Array.isArray(e))this.options.filter=e.join();else if(typeof e=="object"){if(e==null)throw new TypeError("options cannot be null");e.container!==void 0&&(this.options.container=e.container),e.filter!==void 0&&(this.options.filter=e.filter),e.showButton!==void 0&&(this.options.showButton=e.showButton),e.enabled!==void 0&&(t=e.enabled)}else typeof e=="boolean"?(this.options.filter=!0,t=e):typeof e=="function"&&(this.options.filter=e,t=!0);this.options.filter===!1&&(t=!1),this.options.enabled=t}this._clean()}setModuleOptions(e){this.moduleOptions=e,this.options.enabled===!0&&(this._clean(),this.options.container!==void 0&&(this.container=this.options.container),this._create())}_create(){this._clean(),this.changedOptions=[];let e=this.options.filter,t=0,i=!1;for(let s in this.configureOptions)Object.prototype.hasOwnProperty.call(this.configureOptions,s)&&(this.allowCreation=!1,i=!1,typeof e=="function"?(i=e(s,[]),i=i||this._handleObject(this.configureOptions[s],[s],!0)):(e===!0||e.indexOf(s)!==-1)&&(i=!0),i!==!1&&(this.allowCreation=!0,t>0&&this._makeItem([]),this._makeHeader(s),this._handleObject(this.configureOptions[s],[s])),t++);this._makeButton(),this._push()}_push(){this.wrapper=document.createElement("div"),this.wrapper.className="vis-configuration-wrapper",this.container.appendChild(this.wrapper);for(let e=0;e{i.appendChild(s)}),this.domElements.push(i),this.domElements.length}return 0}_makeHeader(e){let t=document.createElement("div");t.className="vis-configuration vis-config-header",t.innerText=e,this._makeItem([],t)}_makeLabel(e,t,i=!1){let s=document.createElement("div");if(s.className="vis-configuration vis-config-label vis-config-s"+t.length,i===!0){for(;s.firstChild;)s.removeChild(s.firstChild);s.appendChild(gi("i","b",e))}else s.innerText=e+":";return s}_makeDropdown(e,t,i){let s=document.createElement("select");s.className="vis-configuration vis-config-select";let o=0;t!==void 0&&e.indexOf(t)!==-1&&(o=e.indexOf(t));for(let d=0;dr&&r!==1&&(d.max=Math.ceil(t*v),l=d.max,h="range increased"),d.value=t}else d.value=s;let c=document.createElement("input");c.className="vis-configuration vis-config-rangeinput",c.value=d.value;let u=this;d.onchange=function(){c.value=this.value,u._update(Number(this.value),i)},d.oninput=function(){c.value=this.value};let f=this._makeLabel(i[i.length-1],i),y=this._makeItem(i,f,d,c);h!==""&&this.popupHistory[y]!==l&&(this.popupHistory[y]=l,this._setupPopup(h,y))}_makeButton(){if(this.options.showButton===!0){let e=document.createElement("div");e.className="vis-configuration vis-config-button",e.innerText="generate options",e.onclick=()=>{this._printOptions()},e.onmouseover=()=>{e.className="vis-configuration vis-config-button hover"},e.onmouseout=()=>{e.className="vis-configuration vis-config-button"},this.optionsContainer=document.createElement("div"),this.optionsContainer.className="vis-configuration vis-config-option-container",this.domElements.push(this.optionsContainer),this.domElements.push(e)}}_setupPopup(e,t){if(this.initialized===!0&&this.allowCreation===!0&&this.popupCounter{this._removePopup()},this.popupCounter+=1,this.popupDiv={html:i,index:t}}}_removePopup(){this.popupDiv.html!==void 0&&(this.popupDiv.html.parentNode.removeChild(this.popupDiv.html),clearTimeout(this.popupDiv.hideTimeout),clearTimeout(this.popupDiv.deleteTimeout),this.popupDiv={})}_showPopupIfNeeded(){if(this.popupDiv.html!==void 0){let t=this.domElements[this.popupDiv.index].getBoundingClientRect();this.popupDiv.html.style.left=t.left+"px",this.popupDiv.html.style.top=t.top-30+"px",document.body.appendChild(this.popupDiv.html),this.popupDiv.hideTimeout=setTimeout(()=>{this.popupDiv.html.style.opacity=0},1500),this.popupDiv.deleteTimeout=setTimeout(()=>{this._removePopup()},1800)}}_makeCheckbox(e,t,i){let s=document.createElement("input");s.type="checkbox",s.className="vis-configuration vis-config-checkbox",s.checked=e,t!==void 0&&(s.checked=t,t!==e&&(typeof e=="object"?t!==e.enabled&&this.changedOptions.push({path:i,value:t}):this.changedOptions.push({path:i,value:t})));let o=this;s.onchange=function(){o._update(this.checked,i)};let r=this._makeLabel(i[i.length-1],i);this._makeItem(i,r,s)}_makeTextInput(e,t,i){let s=document.createElement("input");s.type="text",s.className="vis-configuration vis-config-text",s.value=t,t!==e&&this.changedOptions.push({path:i,value:t});let o=this;s.onchange=function(){o._update(this.value,i)};let r=this._makeLabel(i[i.length-1],i);this._makeItem(i,r,s)}_makeColorField(e,t,i){let s=e[1],o=document.createElement("div");t=t===void 0?s:t,t!=="none"?(o.className="vis-configuration vis-config-colorBlock",o.style.backgroundColor=t):o.className="vis-configuration vis-config-colorBlock none",t=t===void 0?s:t,o.onclick=()=>{this._showColorPicker(t,o,i)};let r=this._makeLabel(i[i.length-1],i);this._makeItem(i,r,o)}_showColorPicker(e,t,i){t.onclick=function(){},this.colorPicker.insertTo(t),this.colorPicker.show(),this.colorPicker.setColor(e),this.colorPicker.setUpdateCallback(s=>{let o="rgba("+s.r+","+s.g+","+s.b+","+s.a+")";t.style.backgroundColor=o,this._update(o,i)}),this.colorPicker.setCloseCallback(()=>{t.onclick=()=>{this._showColorPicker(e,t,i)}})}_handleObject(e,t=[],i=!1){let s=!1,o=this.options.filter,r=!1;for(let a in e)if(Object.prototype.hasOwnProperty.call(e,a)){s=!0;let d=e[a],h=At(t,a);if(typeof o=="function"&&(s=o(a,t),s===!1&&!Array.isArray(d)&&typeof d!="string"&&typeof d!="boolean"&&d instanceof Object&&(this.allowCreation=!1,s=this._handleObject(d,h,!0),this.allowCreation=i===!1)),s!==!1){r=!0;let l=this._getValue(h);if(Array.isArray(d))this._handleArray(d,l,h);else if(typeof d=="string")this._makeTextInput(d,l,h);else if(typeof d=="boolean")this._makeCheckbox(d,l,h);else if(d instanceof Object){if(!this.hideOption(t,a,this.moduleOptions))if(d.enabled!==void 0){let c=At(h,"enabled"),u=this._getValue(c);if(u===!0){let f=this._makeLabel(a,h,!0);this._makeItem(h,f),r=this._handleObject(d,h)||r}else this._makeCheckbox(d,u,h)}else{let c=this._makeLabel(a,h,!0);this._makeItem(h,c),r=this._handleObject(d,h)||r}}else console.error("dont know how to handle",d,a,h)}}return r}_handleArray(e,t,i){typeof e[0]=="string"&&e[0]==="color"?(this._makeColorField(e,t,i),e[1]!==t&&this.changedOptions.push({path:i,value:t})):typeof e[0]=="string"?(this._makeDropdown(e,t,i),e[0]!==t&&this.changedOptions.push({path:i,value:t})):typeof e[0]=="number"&&(this._makeRange(e,t,i),e[0]!==t&&this.changedOptions.push({path:i,value:Number(t)}))}_update(e,t){let i=this._constructOptions(e,t);this.parent.body&&this.parent.body.emitter&&this.parent.body.emitter.emit&&this.parent.body.emitter.emit("configChange",i),this.initialized=!0,this.parent.setOptions(i)}_constructOptions(e,t,i={}){let s=i;e=e==="true"?!0:e,e=e==="false"?!1:e;for(let o=0;oo-this.padding&&(d=!0),d?r=this.x-i:r=this.x,h?a=this.y-t:a=this.y}else a=this.y-t,a+t+this.padding>s&&(a=s-t-this.padding),ao&&(r=o-i-this.padding),ro.distance?d=" in "+L.printLocation(s.path,e,"")+"Perhaps it was misplaced? Matching option found at: "+L.printLocation(o.path,o.closestMatch,""):s.distance<=r?d='. Did you mean "'+s.closestMatch+'"?'+L.printLocation(s.path,e):d=". Did you mean one of these: "+L.print(Object.keys(t))+L.printLocation(i,e),console.error('%cUnknown option detected: "'+e+'"'+d,mi),vt=!0}static findInOptions(e,t,i,s=!1){let o=1e9,r="",a=[],d=e.toLowerCase(),h;for(let l in t){let c;if(t[l].__type__!==void 0&&s===!0){let u=L.findInOptions(e,t[l],At(i,l));o>u.distance&&(r=u.closestMatch,a=u.path,o=u.distance,h=u.indexMatch)}else l.toLowerCase().indexOf(d)!==-1&&(h=l),c=L.levenshteinDistance(e,l),o>c&&(r=l,a=Or(i),o=c)}return{closestMatch:r,path:a,distance:o,indexMatch:h}}static printLocation(e,t,i=`Problem value found at: +`:o.distance<=a&&s.distance>o.distance?d=" in "+L.printLocation(s.path,e,"")+"Perhaps it was misplaced? Matching option found at: "+L.printLocation(o.path,o.closestMatch,""):s.distance<=r?d='. Did you mean "'+s.closestMatch+'"?'+L.printLocation(s.path,e):d=". Did you mean one of these: "+L.print(Object.keys(t))+L.printLocation(i,e),console.error('%cUnknown option detected: "'+e+'"'+d,mi),wt=!0}static findInOptions(e,t,i,s=!1){let o=1e9,r="",a=[],d=e.toLowerCase(),h;for(let l in t){let c;if(t[l].__type__!==void 0&&s===!0){let u=L.findInOptions(e,t[l],At(i,l));o>u.distance&&(r=u.closestMatch,a=u.path,o=u.distance,h=u.indexMatch)}else l.toLowerCase().indexOf(d)!==-1&&(h=l),c=L.levenshteinDistance(e,l),o>c&&(r=l,a=xr(i),o=c)}return{closestMatch:r,path:a,distance:o,indexMatch:h}}static printLocation(e,t,i=`Problem value found at: `){let s=` `+i+`options = { @@ -11,16 +11,16 @@ `;for(let o=0;o1&&arguments[1]!==void 0?arguments[1]:0,t=(U[n[e+0]]+U[n[e+1]]+U[n[e+2]]+U[n[e+3]]+"-"+U[n[e+4]]+U[n[e+5]]+"-"+U[n[e+6]]+U[n[e+7]]+"-"+U[n[e+8]]+U[n[e+9]]+"-"+U[n[e+10]]+U[n[e+11]]+U[n[e+12]]+U[n[e+13]]+U[n[e+14]]+U[n[e+15]]).toLowerCase();if(!Ys(t))throw TypeError("Stringified UUID is invalid");return t}var Xs=zr;function Rr(n,e,t){n=n||{};var i=n.random||(n.rng||bi)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){t=t||0;for(var s=0;s<16;++s)e[t+s]=i[s];return e}return Xs(i)}var Ee=Rr;function Gs(n){return typeof n=="string"||typeof n=="number"}var Wt=class{constructor(e){X(this,"delay");X(this,"max");X(this,"_queue",[]);X(this,"_timeout",null);X(this,"_extended",null);this.delay=null,this.max=1/0,this.setOptions(e)}setOptions(e){e&&typeof e.delay!="undefined"&&(this.delay=e.delay),e&&typeof e.max!="undefined"&&(this.max=e.max),this._flushIfNeeded()}static extend(e,t){let i=new Wt(t);if(e.flush!==void 0)throw new Error("Target object already has a property flush");e.flush=()=>{i.flush()};let s=[{name:"flush",original:void 0}];if(t&&t.replace)for(let o=0;othis.max&&this.flush(),this._timeout!=null&&(clearTimeout(this._timeout),this._timeout=null),this.queue.length>0&&typeof this.delay=="number"&&(this._timeout=setTimeout(()=>{this.flush()},this.delay))}flush(){this._queue.splice(0).forEach(e=>{e.fn.apply(e.context||e.fn,e.args||[])})}},wt=class{constructor(){X(this,"_subscribers",{"*":[],add:[],remove:[],update:[]});X(this,"subscribe",wt.prototype.on);X(this,"unsubscribe",wt.prototype.off)}_trigger(e,t,i){if(e==="*")throw new Error("Cannot trigger event *");[...this._subscribers[e],...this._subscribers["*"]].forEach(s=>{s(e,t,i!=null?i:null)})}on(e,t){typeof t=="function"&&this._subscribers[e].push(t)}off(e,t){this._subscribers[e]=this._subscribers[e].filter(i=>i!==t)}},Oe=class{constructor(e){X(this,"_pairs");this._pairs=e}*[Symbol.iterator](){for(let[e,t]of this._pairs)yield[e,t]}*entries(){for(let[e,t]of this._pairs)yield[e,t]}*keys(){for(let[e]of this._pairs)yield e}*values(){for(let[,e]of this._pairs)yield e}toIdArray(){return[...this._pairs].map(e=>e[0])}toItemArray(){return[...this._pairs].map(e=>e[1])}toEntryArray(){return[...this._pairs]}toObjectMap(){let e=Object.create(null);for(let[t,i]of this._pairs)e[t]=i;return e}toMap(){return new Map(this._pairs)}toIdSet(){return new Set(this.toIdArray())}toItemSet(){return new Set(this.toItemArray())}cache(){return new Oe([...this._pairs])}distinct(e){let t=new Set;for(let[i,s]of this._pairs)t.add(e(s,i));return t}filter(e){let t=this._pairs;return new Oe({*[Symbol.iterator](){for(let[i,s]of t)e(s,i)&&(yield[i,s])}})}forEach(e){for(let[t,i]of this._pairs)e(i,t)}map(e){let t=this._pairs;return new Oe({*[Symbol.iterator](){for(let[i,s]of t)yield[i,e(s,i)]}})}max(e){let t=this._pairs[Symbol.iterator](),i=t.next();if(i.done)return null;let s=i.value[1],o=e(i.value[1],i.value[0]);for(;!(i=t.next()).done;){let[r,a]=i.value,d=e(a,r);d>o&&(o=d,s=a)}return s}min(e){let t=this._pairs[Symbol.iterator](),i=t.next();if(i.done)return null;let s=i.value[1],o=e(i.value[1],i.value[0]);for(;!(i=t.next()).done;){let[r,a]=i.value,d=e(a,r);d[...this._pairs].sort(([t,i],[s,o])=>e(i,o,t,s))[Symbol.iterator]()})}};function Lr(n,e){return n[e]==null&&(n[e]=Ee()),n}var xe=class extends wt{constructor(e,t){super();X(this,"flush");X(this,"length");X(this,"_options");X(this,"_data");X(this,"_idProp");X(this,"_queue",null);e&&!Array.isArray(e)&&(t=e,e=[]),this._options=t||{},this._data=new Map,this.length=0,this._idProp=this._options.fieldId||"id",e&&e.length&&this.add(e),this.setOptions(t)}get idProp(){return this._idProp}setOptions(e){e&&e.queue!==void 0&&(e.queue===!1?this._queue&&(this._queue.destroy(),this._queue=null):(this._queue||(this._queue=Wt.extend(this,{replace:["add","update","remove"]})),e.queue&&typeof e.queue=="object"&&this._queue.setOptions(e.queue)))}add(e,t){let i=[],s;if(Array.isArray(e)){if(e.map(r=>r[this._idProp]).some(r=>this._data.has(r)))throw new Error("A duplicate id was found in the parameter array.");for(let r=0,a=e.length;r{let l=h[a];if(l!=null&&this._data.has(l)){let c=h,u=Object.assign({},this._data.get(l)),f=this._updateItem(c);s.push(f),r.push(c),o.push(u)}else{let c=this._addItem(h);i.push(c)}};if(Array.isArray(e))for(let h=0,l=e.length;h{let o=this._data.get(s[this._idProp]);if(o==null)throw new Error("Updating non-existent items is not allowed.");return{oldData:o,update:s}}).map(({oldData:s,update:o})=>{let r=s[this._idProp],a=Is(s,o);return this._data.set(r,a),{id:r,oldData:s,updatedData:a}});if(i.length){let s={items:i.map(o=>o.id),oldData:i.map(o=>o.oldData),data:i.map(o=>o.updatedData)};return this._trigger("update",s,t),s.items}else return[]}get(e,t){let i,s,o;Gs(e)?(i=e,o=t):Array.isArray(e)?(s=e,o=t):o=e;let r=o&&o.returnType==="Object"?"Object":"Array",a=o&&o.filter,d=[],h,l,c;if(i!=null)h=this._data.get(i),h&&a&&!a(h)&&(h=void 0);else if(s!=null)for(let u=0,f=s.length;u(i[s]=e[s],i),{})}_sort(e,t){if(typeof t=="string"){let i=t;e.sort((s,o)=>{let r=s[i],a=o[i];return r>a?1:ri)&&(t=s,i=o)}return t||null}min(e){let t=null,i=null;for(let s of this._data.values()){let o=s[e];typeof o=="number"&&(i==null||o=.1;)p=+o[c++%r],p>l&&(p=l),f=Math.sqrt(p*p/(1+h*h)),f=a<0?-f:f,e+=f,t+=h*f,u===!0?n.lineTo(e,t):n.moveTo(e,t),l-=p,u=!u}function Yr(n,e,t,i){n.beginPath();let s=6,o=Math.PI*2/s;n.moveTo(e+i,t);for(let r=1;r":!0,"--":!0},Se="",tt=0,P="",k="",ee=Z.NULL;function Kr(){tt=0,P=Se.charAt(0)}function q(){tt++,P=Se.charAt(tt)}function it(){return Se.charAt(tt+1)}function io(n){var e=n.charCodeAt(0);return e<47?e===35||e===46:e<59?e>47:e<91?e>64:e<96?e===95:e<123?e>96:!1}function Ie(n,e){if(n||(n={}),e)for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n}function $r(n,e,t){for(var i=e.split("."),s=n;i.length;){var o=i.shift();i.length?(s[o]||(s[o]={}),s=s[o]):s[o]=t}}function so(n,e){for(var t,i,s=null,o=[n],r=n;r.parent;)o.push(r.parent),r=r.parent;if(r.nodes){for(t=0,i=r.nodes.length;t=0;t--){var a=o[t];a.nodes||(a.nodes=[]),a.nodes.indexOf(s)===-1&&a.nodes.push(s)}e.attr&&(s.attr=Ie(s.attr,e.attr))}function Zr(n,e){if(n.edges||(n.edges=[]),n.edges.push(e),n.edge){var t=Ie({},n.edge);e.attr=Ie(t,e.attr)}}function oo(n,e,t,i,s){var o={from:e,to:t,type:i};return n.edge&&(o.attr=Ie({},n.edge)),o.attr=Ie(o.attr||{},s),s!=null&&s.hasOwnProperty("arrows")&&s.arrows!=null&&(o.arrows={to:{enabled:!0,type:s.arrows.type}},s.arrows=null),o}function B(){for(ee=Z.NULL,k="";P===" "||P===" "||P===` -`||P==="\r";)q();do{var n=!1;if(P==="#"){for(var e=tt-1;Se.charAt(e)===" "||Se.charAt(e)===" ";)e--;if(Se.charAt(e)===` -`||Se.charAt(e)===""){for(;P!=""&&P!=` -`;)q();n=!0}}if(P==="/"&&it()==="/"){for(;P!=""&&P!=` -`;)q();n=!0}if(P==="/"&&it()==="*"){for(;P!="";)if(P==="*"&&it()==="/"){q(),q();break}else q();n=!0}for(;P===" "||P===" "||P===` -`||P==="\r";)q()}while(n);if(P===""){ee=Z.DELIMITER;return}var t=P+it();if(to[t]){ee=Z.DELIMITER,k=t,q(),q();return}if(to[P]){ee=Z.DELIMITER,k=P,q();return}if(io(P)||P==="-"){for(k+=P,q();io(P);)k+=P,q();k==="false"?k=!1:k==="true"?k=!0:isNaN(Number(k))||(k=Number(k)),ee=Z.IDENTIFIER;return}if(P==='"'){for(q();P!=""&&(P!='"'||P==='"'&&it()==='"');)P==='"'?(k+=P,q()):P==="\\"&&it()==="n"?(k+=` -`,q()):k+=P,q();if(P!='"')throw Q('End of string " expected');q(),ee=Z.IDENTIFIER;return}for(ee=Z.UNKNOWN;P!="";)k+=P,q();throw new SyntaxError('Syntax error in part "'+ho(k,30)+'"')}function Qr(){var n={};if(Kr(),B(),k==="strict"&&(n.strict=!0,B()),(k==="graph"||k==="digraph")&&(n.type=k,B()),ee===Z.IDENTIFIER&&(n.id=k,B()),k!="{")throw Q("Angle bracket { expected");if(B(),no(n),k!="}")throw Q("Angle bracket } expected");if(B(),k!=="")throw Q("End of file expected");return B(),delete n.node,delete n.edge,delete n.graph,n}function no(n){for(;k!==""&&k!="}";)Jr(n),k===";"&&B()}function Jr(n){var e=ro(n);if(e){ao(n,e);return}var t=ea(n);if(!t){if(ee!=Z.IDENTIFIER)throw Q("Identifier expected");var i=k;if(B(),k==="="){if(B(),ee!=Z.IDENTIFIER)throw Q("Identifier expected");n[i]=k,B()}else ta(n,i)}}function ro(n){var e=null;if(k==="subgraph"&&(e={},e.type="subgraph",B(),ee===Z.IDENTIFIER&&(e.id=k,B())),k==="{"){if(B(),e||(e={}),e.parent=n,e.node=n.node,e.edge=n.edge,e.graph=n.graph,no(e),k!="}")throw Q("Angle bracket } expected");B(),delete e.node,delete e.edge,delete e.graph,delete e.parent,n.subgraphs||(n.subgraphs=[]),n.subgraphs.push(e)}return e}function ea(n){return k==="node"?(B(),n.node=_t(),"node"):k==="edge"?(B(),n.edge=_t(),"edge"):k==="graph"?(B(),n.graph=_t(),"graph"):null}function ta(n,e){var t={id:e},i=_t();i&&(t.attr=i),so(n,t),ao(n,e)}function ao(n,e){for(;k==="->"||k==="--";){var t,i=k;B();var s=ro(n);if(s)t=s;else{if(ee!=Z.IDENTIFIER)throw Q("Identifier or subgraph expected");t=k,so(n,{id:t}),B()}var o=_t(),r=oo(n,e,t,i,o);Zr(n,r),e=t}}function _t(){for(var n,e=null,t={dashed:!0,solid:!1,dotted:[1,5]},i={dot:"circle",box:"box",crow:"crow",curve:"curve",icurve:"inv_curve",normal:"triangle",inv:"inv_triangle",diamond:"diamond",tee:"bar",vee:"vee"},s=new Array,o=new Array;k==="[";){for(B(),e={};k!==""&&k!="]";){if(ee!=Z.IDENTIFIER)throw Q("Attribute name expected");var r=k;if(B(),k!="=")throw Q("Equal sign = expected");if(B(),ee!=Z.IDENTIFIER)throw Q("Attribute value expected");var a=k;r==="style"&&(a=t[a]);var d;r==="arrowhead"&&(d=i[a],r="arrows",a={to:{enabled:!0,type:d}}),r==="arrowtail"&&(d=i[a],r="arrows",a={from:{enabled:!0,type:d}}),s.push({attr:e,name:r,value:a}),o.push(r),B(),k==","&&B()}if(k!="]")throw Q("Bracket ] expected");B()}if(o.includes("dir")){var h={};for(h.arrows={},n=0;n"&&(o.arrows="to"),o};e.edges.forEach(function(s){var o,r;s.from instanceof Object?o=s.from.nodes:o={id:s.from},s.to instanceof Object?r=s.to.nodes:r={id:s.to},s.from instanceof Object&&s.from.edges&&s.from.edges.forEach(function(a){var d=i(a);t.edges.push(d)}),ia(o,r,function(a,d){var h=oo(t,a.id,d.id,s.type,s.attr),l=i(h);t.edges.push(l)}),s.to instanceof Object&&s.to.edges&&s.to.edges.forEach(function(a){var d=i(a);t.edges.push(d)})})}return e.attr&&(t.options=e.attr),t}function oa(n,e){let t={edges:{inheritColor:!1},nodes:{fixed:!1,parseColor:!1}};e!=null&&(e.fixed!=null&&(t.nodes.fixed=e.fixed),e.parseColor!=null&&(t.nodes.parseColor=e.parseColor),e.inheritColor!=null&&(t.edges.inheritColor=e.inheritColor));let s=n.edges.map(r=>{let a={from:r.source,id:r.id,to:r.target};return r.attributes!=null&&(a.attributes=r.attributes),r.label!=null&&(a.label=r.label),r.attributes!=null&&r.attributes.title!=null&&(a.title=r.attributes.title),r.type==="Directed"&&(a.arrows="to"),r.color&&t.edges.inheritColor===!1&&(a.color=r.color),a});return{nodes:n.nodes.map(r=>{let a={id:r.id,fixed:t.nodes.fixed&&r.x!=null&&r.y!=null};return r.attributes!=null&&(a.attributes=r.attributes),r.label!=null&&(a.label=r.label),r.size!=null&&(a.size=r.size),r.attributes!=null&&r.attributes.title!=null&&(a.title=r.attributes.title),r.title!=null&&(a.title=r.title),r.x!=null&&(a.x=r.x),r.y!=null&&(a.y=r.y),r.color!=null&&(t.nodes.parseColor===!0?a.color=r.color:a.color={background:r.color,border:r.color,highlight:{background:r.color,border:r.color},hover:{background:r.color,border:r.color}}),a}),edges:s}}var na={addDescription:"Click in an empty space to place a new node.",addEdge:"Add Edge",addNode:"Add Node",back:"Back",close:"Close",createEdgeError:"Cannot link edges to a cluster.",del:"Delete selected",deleteClusterError:"Clusters cannot be deleted.",edgeDescription:"Click on a node and drag the edge to another node to connect them.",edit:"Edit",editClusterError:"Clusters cannot be edited.",editEdge:"Edit Edge",editEdgeDescription:"Click on the control points and drag them to a node to connect to it.",editNode:"Edit Node"},ra={addDescription:"Klicke auf eine freie Stelle, um einen neuen Knoten zu plazieren.",addEdge:"Kante hinzuf\xFCgen",addNode:"Knoten hinzuf\xFCgen",back:"Zur\xFCck",close:"Schlie\xDFen",createEdgeError:"Es ist nicht m\xF6glich, Kanten mit Clustern zu verbinden.",del:"L\xF6sche Auswahl",deleteClusterError:"Cluster k\xF6nnen nicht gel\xF6scht werden.",edgeDescription:"Klicke auf einen Knoten und ziehe die Kante zu einem anderen Knoten, um diese zu verbinden.",edit:"Editieren",editClusterError:"Cluster k\xF6nnen nicht editiert werden.",editEdge:"Kante editieren",editEdgeDescription:"Klicke auf die Verbindungspunkte und ziehe diese auf einen Knoten, um sie zu verbinden.",editNode:"Knoten editieren"},aa={addDescription:"Haga clic en un lugar vac\xEDo para colocar un nuevo nodo.",addEdge:"A\xF1adir arista",addNode:"A\xF1adir nodo",back:"Atr\xE1s",close:"Cerrar",createEdgeError:"No se puede conectar una arista a un grupo.",del:"Eliminar selecci\xF3n",deleteClusterError:"No es posible eliminar grupos.",edgeDescription:"Haga clic en un nodo y arrastre la arista hacia otro nodo para conectarlos.",edit:"Editar",editClusterError:"No es posible editar grupos.",editEdge:"Editar arista",editEdgeDescription:"Haga clic en un punto de control y arrastrelo a un nodo para conectarlo.",editNode:"Editar nodo"},da={addDescription:"Clicca per aggiungere un nuovo nodo",addEdge:"Aggiungi un vertice",addNode:"Aggiungi un nodo",back:"Indietro",close:"Chiudere",createEdgeError:"Non si possono collegare vertici ad un cluster",del:"Cancella la selezione",deleteClusterError:"I cluster non possono essere cancellati",edgeDescription:"Clicca su un nodo e trascinalo ad un altro nodo per connetterli.",edit:"Modifica",editClusterError:"I clusters non possono essere modificati.",editEdge:"Modifica il vertice",editEdgeDescription:"Clicca sui Punti di controllo e trascinali ad un nodo per connetterli.",editNode:"Modifica il nodo"},ha={addDescription:"Klik op een leeg gebied om een nieuwe node te maken.",addEdge:"Link toevoegen",addNode:"Node toevoegen",back:"Terug",close:"Sluiten",createEdgeError:"Kan geen link maken naar een cluster.",del:"Selectie verwijderen",deleteClusterError:"Clusters kunnen niet worden verwijderd.",edgeDescription:"Klik op een node en sleep de link naar een andere node om ze te verbinden.",edit:"Wijzigen",editClusterError:"Clusters kunnen niet worden aangepast.",editEdge:"Link wijzigen",editEdgeDescription:"Klik op de verbindingspunten en sleep ze naar een node om daarmee te verbinden.",editNode:"Node wijzigen"},la={addDescription:"Clique em um espa\xE7o em branco para adicionar um novo n\xF3",addEdge:"Adicionar aresta",addNode:"Adicionar n\xF3",back:"Voltar",close:"Fechar",createEdgeError:"N\xE3o foi poss\xEDvel linkar arestas a um cluster.",del:"Remover selecionado",deleteClusterError:"Clusters n\xE3o puderam ser removidos.",edgeDescription:"Clique em um n\xF3 e arraste a aresta at\xE9 outro n\xF3 para conect\xE1-los",edit:"Editar",editClusterError:"Clusters n\xE3o puderam ser editados.",editEdge:"Editar aresta",editEdgeDescription:"Clique nos pontos de controle e os arraste para um n\xF3 para conect\xE1-los",editNode:"Editar n\xF3"},ca={addDescription:"\u041A\u043B\u0438\u043A\u043D\u0438\u0442\u0435 \u0432 \u0441\u0432\u043E\u0431\u043E\u0434\u043D\u043E\u0435 \u043C\u0435\u0441\u0442\u043E, \u0447\u0442\u043E\u0431\u044B \u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u043D\u043E\u0432\u044B\u0439 \u0443\u0437\u0435\u043B.",addEdge:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0440\u0435\u0431\u0440\u043E",addNode:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0443\u0437\u0435\u043B",back:"\u041D\u0430\u0437\u0430\u0434",close:"\u0417\u0430\u043A\u0440\u044B\u0432\u0430\u0442\u044C",createEdgeError:"\u041D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E \u0441\u043E\u0435\u0434\u0438\u043D\u0438\u0442\u044C \u0440\u0435\u0431\u0440\u0430 \u0432 \u043A\u043B\u0430\u0441\u0442\u0435\u0440.",del:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0432\u044B\u0431\u0440\u0430\u043D\u043D\u043E\u0435",deleteClusterError:"\u041A\u043B\u0430\u0441\u0442\u0435\u0440\u044B \u043D\u0435 \u043C\u043E\u0433\u0443\u0442 \u0431\u044B\u0442\u044C \u0443\u0434\u0430\u043B\u0435\u043D\u044B",edgeDescription:"\u041A\u043B\u0438\u043A\u043D\u0438\u0442\u0435 \u043D\u0430 \u0443\u0437\u0435\u043B \u0438 \u043F\u0440\u043E\u0442\u044F\u043D\u0438\u0442\u0435 \u0440\u0435\u0431\u0440\u043E \u043A \u0434\u0440\u0443\u0433\u043E\u043C\u0443 \u0443\u0437\u043B\u0443, \u0447\u0442\u043E\u0431\u044B \u0441\u043E\u0435\u0434\u0438\u043D\u0438\u0442\u044C \u0438\u0445.",edit:"\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C",editClusterError:"\u041A\u043B\u0430\u0441\u0442\u0435\u0440\u044B \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B \u0434\u043B\u044F \u0440\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F.",editEdge:"\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0440\u0435\u0431\u0440\u043E",editEdgeDescription:"\u041A\u043B\u0438\u043A\u043D\u0438\u0442\u0435 \u043D\u0430 \u043A\u043E\u043D\u0442\u0440\u043E\u043B\u044C\u043D\u044B\u0435 \u0442\u043E\u0447\u043A\u0438 \u0438 \u043F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0438\u0445 \u0432 \u0443\u0437\u0435\u043B, \u0447\u0442\u043E\u0431\u044B \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u044C\u0441\u044F \u043A \u043D\u0435\u043C\u0443.",editNode:"\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0443\u0437\u0435\u043B"},ua={addDescription:"\u5355\u51FB\u7A7A\u767D\u5904\u653E\u7F6E\u65B0\u8282\u70B9\u3002",addEdge:"\u6DFB\u52A0\u8FDE\u63A5\u7EBF",addNode:"\u6DFB\u52A0\u8282\u70B9",back:"\u8FD4\u56DE",close:"\u95DC\u9589",createEdgeError:"\u65E0\u6CD5\u5C06\u8FDE\u63A5\u7EBF\u8FDE\u63A5\u5230\u7FA4\u96C6\u3002",del:"\u5220\u9664\u9009\u5B9A",deleteClusterError:"\u65E0\u6CD5\u5220\u9664\u7FA4\u96C6\u3002",edgeDescription:"\u5355\u51FB\u67D0\u4E2A\u8282\u70B9\u5E76\u5C06\u8BE5\u8FDE\u63A5\u7EBF\u62D6\u52A8\u5230\u53E6\u4E00\u4E2A\u8282\u70B9\u4EE5\u8FDE\u63A5\u5B83\u4EEC\u3002",edit:"\u7F16\u8F91",editClusterError:"\u65E0\u6CD5\u7F16\u8F91\u7FA4\u96C6\u3002",editEdge:"\u7F16\u8F91\u8FDE\u63A5\u7EBF",editEdgeDescription:"\u5355\u51FB\u63A7\u5236\u8282\u70B9\u5E76\u5C06\u5B83\u4EEC\u62D6\u5230\u8282\u70B9\u4E0A\u8FDE\u63A5\u3002",editNode:"\u7F16\u8F91\u8282\u70B9"},fa={addDescription:"K\u043B\u0456\u043A\u043D\u0456\u0442\u044C \u043D\u0430 \u0432\u0456\u043B\u044C\u043D\u0435 \u043C\u0456\u0441\u0446\u0435, \u0449\u043E\u0431 \u0434\u043E\u0434\u0430\u0442\u0438 \u043D\u043E\u0432\u0438\u0439 \u0432\u0443\u0437\u043E\u043B.",addEdge:"\u0414\u043E\u0434\u0430\u0442\u0438 \u043A\u0440\u0430\u0439",addNode:"\u0414\u043E\u0434\u0430\u0442\u0438 \u0432\u0443\u0437\u043E\u043B",back:"\u041D\u0430\u0437\u0430\u0434",close:"\u0417\u0430\u043A\u0440\u0438\u0442\u0438",createEdgeError:"\u041D\u0435 \u043C\u043E\u0436\u043B\u0438\u0432\u043E \u043E\u0431'\u0454\u0434\u043D\u0430\u0442\u0438 \u043A\u0440\u0430\u0457 \u0432 \u0433\u0440\u0443\u043F\u0443.",del:"\u0412\u0438\u0434\u0430\u043B\u0438\u0442\u0438 \u043E\u0431\u0440\u0430\u043D\u0435",deleteClusterError:"\u0413\u0440\u0443\u043F\u0438 \u043D\u0435 \u043C\u043E\u0436\u0443\u0442\u044C \u0431\u0443\u0442\u0438 \u0432\u0438\u0434\u0430\u043B\u0435\u043D\u0456.",edgeDescription:"\u041A\u043B\u0456\u043A\u043D\u0456\u0442\u044C \u043D\u0430 \u0432\u0443\u0437\u043E\u043B \u0456 \u043F\u0435\u0440\u0435\u0442\u044F\u0433\u043D\u0456\u0442\u044C \u043A\u0440\u0430\u0439 \u0434\u043E \u0456\u043D\u0448\u043E\u0433\u043E \u0432\u0443\u0437\u043B\u0430, \u0449\u043E\u0431 \u0457\u0445 \u0437'\u0454\u0434\u043D\u0430\u0442\u0438.",edit:"\u0420\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u0442\u0438",editClusterError:"\u0413\u0440\u0443\u043F\u0438 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u0456 \u0434\u043B\u044F \u0440\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u043D\u043D\u044F.",editEdge:"\u0420\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u0442\u0438 \u043A\u0440\u0430\u0439",editEdgeDescription:"\u041A\u043B\u0456\u043A\u043D\u0456\u0442\u044C \u043D\u0430 \u043A\u043E\u043D\u0442\u0440\u043E\u043B\u044C\u043D\u0456 \u0442\u043E\u0447\u043A\u0438 \u0456 \u043F\u0435\u0440\u0435\u0442\u044F\u0433\u043D\u0456\u0442\u044C \u0457\u0445 \u0443 \u0432\u0443\u0437\u043E\u043B, \u0449\u043E\u0431 \u043F\u0456\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u0438\u0441\u044F \u0434\u043E \u043D\u044C\u043E\u0433\u043E.",editNode:"\u0420\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u0442\u0438 \u0432\u0443\u0437\u043E\u043B"},pa={addDescription:"Cliquez dans un endroit vide pour placer un n\u0153ud.",addEdge:"Ajouter un lien",addNode:"Ajouter un n\u0153ud",back:"Retour",close:"Fermer",createEdgeError:"Impossible de cr\xE9er un lien vers un cluster.",del:"Effacer la s\xE9lection",deleteClusterError:"Les clusters ne peuvent pas \xEAtre effac\xE9s.",edgeDescription:"Cliquez sur un n\u0153ud et glissez le lien vers un autre n\u0153ud pour les connecter.",edit:"\xC9diter",editClusterError:"Les clusters ne peuvent pas \xEAtre \xE9dit\xE9s.",editEdge:"\xC9diter le lien",editEdgeDescription:"Cliquez sur les points de contr\xF4le et glissez-les pour connecter un n\u0153ud.",editNode:"\xC9diter le n\u0153ud"},ga={addDescription:"Kluknut\xEDm do pr\xE1zdn\xE9ho prostoru m\u016F\u017Eete p\u0159idat nov\xFD vrchol.",addEdge:"P\u0159idat hranu",addNode:"P\u0159idat vrchol",back:"Zp\u011Bt",close:"Zav\u0159\xEDt",createEdgeError:"Nelze p\u0159ipojit hranu ke shluku.",del:"Smazat v\xFDb\u011Br",deleteClusterError:"Nelze mazat shluky.",edgeDescription:"P\u0159eta\u017Een\xEDm z jednoho vrcholu do druh\xE9ho m\u016F\u017Eete spojit tyto vrcholy novou hranou.",edit:"Upravit",editClusterError:"Nelze upravovat shluky.",editEdge:"Upravit hranu",editEdgeDescription:"P\u0159eta\u017Een\xEDm kontroln\xEDho vrcholu hrany ji m\u016F\u017Eete p\u0159ipojit k jin\xE9mu vrcholu.",editNode:"Upravit vrchol"},ma=Object.freeze({__proto__:null,cn:ua,cs:ga,de:ra,en:na,es:aa,fr:pa,it:da,nl:ha,pt:la,ru:ca,uk:fa});function ya(n,e){try{let[t,i]=e.split(/[-_ /]/,2),s=t!=null?t.toLowerCase():null,o=i!=null?i.toUpperCase():null;if(s&&o){let r=s+"-"+o;if(Object.prototype.hasOwnProperty.call(n,r))return r;console.warn(`Unknown variant ${o} of language ${s}.`)}if(s){let r=s;if(Object.prototype.hasOwnProperty.call(n,r))return r;console.warn(`Unknown language ${s}`)}return console.warn(`Unknown locale ${e}, falling back to English.`),"en"}catch(t){return console.error(t),console.warn(`Unexpected error while normalizing locale ${e}, falling back to English.`),"en"}}var co=class{constructor(){this.NUM_ITERATIONS=4,this.image=new Image,this.canvas=document.createElement("canvas")}init(){if(this.initialized())return;this.src=this.image.src;let e=this.image.width,t=this.image.height;this.width=e,this.height=t;let i=Math.floor(t/2),s=Math.floor(t/4),o=Math.floor(t/8),r=Math.floor(t/16),a=Math.floor(e/2),d=Math.floor(e/4),h=Math.floor(e/8),l=Math.floor(e/16);this.canvas.width=3*d,this.canvas.height=i,this.coordinates=[[0,0,a,i],[a,0,d,s],[a,s,h,o],[5*h,s,l,r]],this._fillMipMap()}initialized(){return this.coordinates!==void 0}_fillMipMap(){let e=this.canvas.getContext("2d"),t=this.coordinates[0];e.drawImage(this.image,t[0],t[1],t[2],t[3]);for(let i=1;i2){t*=.5;let a=0;for(;t>2&&a=this.NUM_ITERATIONS&&(a=this.NUM_ITERATIONS-1);let d=this.coordinates[a];e.drawImage(this.canvas,d[0],d[1],d[2],d[3],i,s,o,r)}else e.drawImage(this.image,i,s,o,r)}},uo=class{constructor(e){this.images={},this.imageBroken={},this.callback=e}_tryloadBrokenUrl(e,t,i){if(!(e===void 0||i===void 0)){if(t===void 0){console.warn("No broken url image defined");return}i.image.onerror=()=>{console.error("Could not load brokenImage:",t)},i.image.src=t}}_redrawWithImage(e){this.callback&&this.callback(e)}load(e,t){let i=this.images[e];if(i)return i;let s=new co;return this.images[e]=s,s.image.onload=()=>{this._fixImageCoordinates(s.image),s.init(),this._redrawWithImage(s)},s.image.onerror=()=>{console.error("Could not load image:",e),this._tryloadBrokenUrl(e,t,s)},s.image.src=e,s}_fixImageCoordinates(e){e.width===0&&(document.body.appendChild(e),e.width=e.offsetWidth,e.height=e.offsetHeight,document.body.removeChild(e))}},fo=class{constructor(){this.clear(),this._defaultIndex=0,this._groupIndex=0,this._defaultGroups=[{border:"#2B7CE9",background:"#97C2FC",highlight:{border:"#2B7CE9",background:"#D2E5FF"},hover:{border:"#2B7CE9",background:"#D2E5FF"}},{border:"#FFA500",background:"#FFFF00",highlight:{border:"#FFA500",background:"#FFFFA3"},hover:{border:"#FFA500",background:"#FFFFA3"}},{border:"#FA0A10",background:"#FB7E81",highlight:{border:"#FA0A10",background:"#FFAFB1"},hover:{border:"#FA0A10",background:"#FFAFB1"}},{border:"#41A906",background:"#7BE141",highlight:{border:"#41A906",background:"#A1EC76"},hover:{border:"#41A906",background:"#A1EC76"}},{border:"#E129F0",background:"#EB7DF4",highlight:{border:"#E129F0",background:"#F0B3F5"},hover:{border:"#E129F0",background:"#F0B3F5"}},{border:"#7C29F0",background:"#AD85E4",highlight:{border:"#7C29F0",background:"#D3BDF0"},hover:{border:"#7C29F0",background:"#D3BDF0"}},{border:"#C37F00",background:"#FFA807",highlight:{border:"#C37F00",background:"#FFCA66"},hover:{border:"#C37F00",background:"#FFCA66"}},{border:"#4220FB",background:"#6E6EFD",highlight:{border:"#4220FB",background:"#9B9BFD"},hover:{border:"#4220FB",background:"#9B9BFD"}},{border:"#FD5A77",background:"#FFC0CB",highlight:{border:"#FD5A77",background:"#FFD1D9"},hover:{border:"#FD5A77",background:"#FFD1D9"}},{border:"#4AD63A",background:"#C2FABC",highlight:{border:"#4AD63A",background:"#E6FFE3"},hover:{border:"#4AD63A",background:"#E6FFE3"}},{border:"#990000",background:"#EE0000",highlight:{border:"#BB0000",background:"#FF3333"},hover:{border:"#BB0000",background:"#FF3333"}},{border:"#FF6000",background:"#FF6000",highlight:{border:"#FF6000",background:"#FF6000"},hover:{border:"#FF6000",background:"#FF6000"}},{border:"#97C2FC",background:"#2B7CE9",highlight:{border:"#D2E5FF",background:"#2B7CE9"},hover:{border:"#D2E5FF",background:"#2B7CE9"}},{border:"#399605",background:"#255C03",highlight:{border:"#399605",background:"#255C03"},hover:{border:"#399605",background:"#255C03"}},{border:"#B70054",background:"#FF007E",highlight:{border:"#B70054",background:"#FF007E"},hover:{border:"#B70054",background:"#FF007E"}},{border:"#AD85E4",background:"#7C29F0",highlight:{border:"#D3BDF0",background:"#7C29F0"},hover:{border:"#D3BDF0",background:"#7C29F0"}},{border:"#4557FA",background:"#000EA1",highlight:{border:"#6E6EFD",background:"#000EA1"},hover:{border:"#6E6EFD",background:"#000EA1"}},{border:"#FFC0CB",background:"#FD5A77",highlight:{border:"#FFD1D9",background:"#FD5A77"},hover:{border:"#FFD1D9",background:"#FD5A77"}},{border:"#C2FABC",background:"#74D66A",highlight:{border:"#E6FFE3",background:"#74D66A"},hover:{border:"#E6FFE3",background:"#74D66A"}},{border:"#EE0000",background:"#990000",highlight:{border:"#FF3333",background:"#BB0000"},hover:{border:"#FF3333",background:"#BB0000"}}],this.options={},this.defaultOptions={useDefaultGroups:!0},Object.assign(this.options,this.defaultOptions)}setOptions(e){let t=["useDefaultGroups"];if(e!==void 0){for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)===-1){let s=e[i];this.add(i,s)}}}clear(){this._groups=new Map,this._groupNames=[]}get(e,t=!0){let i=this._groups.get(e);if(i===void 0&&t)if(this.options.useDefaultGroups===!1&&this._groupNames.length>0){let s=this._groupIndex%this._groupNames.length;++this._groupIndex,i={},i.color=this._groups.get(this._groupNames[s]),this._groups.set(e,i)}else{let s=this._defaultIndex%this._defaultGroups.length;this._defaultIndex++,i={},i.color=this._defaultGroups[s],this._groups.set(e,i)}return i}add(e,t){return this._groups.has(e)||this._groupNames.push(e),this._groups.set(e,t),t}};function Ci(n,e){let t=["node","edge","label"],i=!0,s=_e(e,"chosen");if(typeof s=="boolean")i=s;else if(typeof s=="object"){if(t.indexOf(n)===-1)throw new Error("choosify: subOption '"+n+"' should be one of '"+t.join("', '")+"'");let o=_e(e,["chosen",n]);(typeof o=="boolean"||typeof o=="function")&&(i=o)}return i}function Ti(n,e,t){if(n.width<=0||n.height<=0)return!1;if(t!==void 0){let o={x:e.x-t.x,y:e.y-t.y};if(t.angle!==0){let r=-t.angle;e={x:Math.cos(r)*o.x-Math.sin(r)*o.y,y:Math.sin(r)*o.x+Math.cos(r)*o.y}}else e=o}let i=n.x+n.width,s=n.y+n.width;return n.lefte.x&&n.tope.y}function qt(n){return typeof n=="string"&&n!==""}function po(n,e,t,i){let s=i.x,o=i.y;if(typeof i.distanceToBorder=="function"){let r=i.distanceToBorder(n,e),a=Math.sin(e)*r,d=Math.cos(e)*r;d===r?(s+=r,o=i.y):a===r?(s=i.x,o-=r):(s+=d,o-=a)}else i.shape.width>i.shape.height?(s=i.x+i.shape.width*.5,o=i.y-t):(s=i.x+t,o=i.y-i.shape.height*.5);return{x:s,y:o}}var go=class{constructor(e){this.measureText=e,this.current=0,this.width=0,this.height=0,this.lines=[]}_add(e,t,i="normal"){this.lines[e]===void 0&&(this.lines[e]={width:0,height:0,blocks:[]});let s=t;(t===void 0||t==="")&&(s=" ");let o=this.measureText(s,i),r=Object.assign({},o.values);r.text=t,r.width=o.width,r.mod=i,(t===void 0||t==="")&&(r.width=0),this.lines[e].blocks.push(r),this.lines[e].width+=r.width}curWidth(){let e=this.lines[this.current];return e===void 0?0:e.width}append(e,t="normal"){this._add(this.current,e,t)}newLine(e,t="normal"){this._add(this.current,e,t),this.current++}determineLineHeights(){for(let e=0;ee&&(e=s.width),t+=s.height}this.width=e,this.height=t}removeEmptyBlocks(){let e=[];for(let t=0;t"://,""://,""://,"":/<\/b>/,"":/<\/i>/,"":/<\/code>/,"*":/\*/,_:/_/,"`":/`/,afterBold:/[^*]/,afterItal:/[^_]/,afterMono:/[^`]/},ki=class{constructor(e){this.text=e,this.bold=!1,this.ital=!1,this.mono=!1,this.spacing=!1,this.position=0,this.buffer="",this.modStack=[],this.blocks=[]}mod(){return this.modStack.length===0?"normal":this.modStack[0]}modName(){if(this.modStack.length===0)return"normal";if(this.modStack[0]==="mono")return"mono";if(this.bold&&this.ital)return"boldital";if(this.bold)return"bold";if(this.ital)return"ital"}emitBlock(){this.spacing&&(this.add(" "),this.spacing=!1),this.buffer.length>0&&(this.blocks.push({text:this.buffer,mod:this.modName()}),this.buffer="")}add(e){e===" "&&(this.spacing=!0),this.spacing&&(this.buffer+=" ",this.spacing=!1),e!=" "&&(this.buffer+=e)}parseWS(e){return/[ \t]/.test(e)?(this.mono?this.add(e):this.spacing=!0,!0):!1}setTag(e){this.emitBlock(),this[e]=!0,this.modStack.unshift(e)}unsetTag(e){this.emitBlock(),this[e]=!1,this.modStack.shift()}parseStartTag(e,t){return!this.mono&&!this[e]&&this.match(t)?(this.setTag(e),!0):!1}match(e,t=!0){let[i,s]=this.prepareRegExp(e),o=i.test(this.text.substr(this.position,s));return o&&t&&(this.position+=s-1),o}parseEndTag(e,t,i){let s=this.mod()===e;return e==="mono"?s=s&&this.mono:s=s&&!this.mono,s&&this.match(t)?(i!==void 0?(this.position===this.text.length-1||this.match(i,!1))&&this.unsetTag(e):this.unsetTag(e),!0):!1}replace(e,t){return this.match(e)?(this.add(t),this.position+=length-1,!0):!1}prepareRegExp(e){let t,i;if(e instanceof RegExp)i=e,t=1;else{let s=ba[e];s!==void 0?i=s:i=new RegExp(e),t=e.length}return[i,t]}},mo=class{constructor(e,t,i,s){this.ctx=e,this.parent=t,this.selected=i,this.hover=s;let o=(r,a)=>{if(r===void 0)return 0;let d=this.parent.getFormattingValues(e,i,s,a),h=0;return r!==""&&(h=this.ctx.measureText(r).width),{width:h,values:d}};this.lines=new go(o)}process(e){if(!qt(e))return this.lines.finalize();let t=this.parent.fontOptions;e=e.replace(/\r\n/g,` +`}static print(e){return JSON.stringify(e).replace(/(")|(\[)|(\])|(,"__type__")/g,"").replace(/(,)/g,", ")}static levenshteinDistance(e,t){if(e.length===0)return t.length;if(t.length===0)return e.length;let i=[],s;for(s=0;s<=t.length;s++)i[s]=[s];let o;for(o=0;o<=e.length;o++)i[0][o]=o;for(s=1;s<=t.length;s++)for(o=1;o<=e.length;o++)t.charAt(s-1)==e.charAt(o-1)?i[s][o]=i[s-1][o-1]:i[s][o]=Math.min(i[s-1][o-1]+1,Math.min(i[s][o-1]+1,i[s-1][o]+1));return i[t.length][e.length]}},Hs=pe;var js=Sr,Ue=ui,Ws=Ir,yi=mi,Vs=Pr;var Ht,Mr=new Uint8Array(16);function bi(){if(!Ht&&(Ht=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!="undefined"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Ht))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ht(Mr)}var qs=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Dr(n){return typeof n=="string"&&qs.test(n)}var Us=Dr;var U=[];for(jt=0;jt<256;++jt)U.push((jt+256).toString(16).substr(1));var jt;function Fr(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(U[n[e+0]]+U[n[e+1]]+U[n[e+2]]+U[n[e+3]]+"-"+U[n[e+4]]+U[n[e+5]]+"-"+U[n[e+6]]+U[n[e+7]]+"-"+U[n[e+8]]+U[n[e+9]]+"-"+U[n[e+10]]+U[n[e+11]]+U[n[e+12]]+U[n[e+13]]+U[n[e+14]]+U[n[e+15]]).toLowerCase();if(!Us(t))throw TypeError("Stringified UUID is invalid");return t}var Ys=Fr;function Nr(n,e,t){n=n||{};var i=n.random||(n.rng||bi)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){t=t||0;for(var s=0;s<16;++s)e[t+s]=i[s];return e}return Ys(i)}var xe=Nr;function Xs(n){return typeof n=="string"||typeof n=="number"}var Wt=class{constructor(e){X(this,"delay");X(this,"max");X(this,"_queue",[]);X(this,"_timeout",null);X(this,"_extended",null);this.delay=null,this.max=1/0,this.setOptions(e)}setOptions(e){e&&typeof e.delay!="undefined"&&(this.delay=e.delay),e&&typeof e.max!="undefined"&&(this.max=e.max),this._flushIfNeeded()}static extend(e,t){let i=new Wt(t);if(e.flush!==void 0)throw new Error("Target object already has a property flush");e.flush=()=>{i.flush()};let s=[{name:"flush",original:void 0}];if(t&&t.replace)for(let o=0;othis.max&&this.flush(),this._timeout!=null&&(clearTimeout(this._timeout),this._timeout=null),this.queue.length>0&&typeof this.delay=="number"&&(this._timeout=setTimeout(()=>{this.flush()},this.delay))}flush(){this._queue.splice(0).forEach(e=>{e.fn.apply(e.context||e.fn,e.args||[])})}},_t=class{constructor(){X(this,"_subscribers",{"*":[],add:[],remove:[],update:[]});X(this,"subscribe",_t.prototype.on);X(this,"unsubscribe",_t.prototype.off)}_trigger(e,t,i){if(e==="*")throw new Error("Cannot trigger event *");[...this._subscribers[e],...this._subscribers["*"]].forEach(s=>{s(e,t,i!=null?i:null)})}on(e,t){typeof t=="function"&&this._subscribers[e].push(t)}off(e,t){this._subscribers[e]=this._subscribers[e].filter(i=>i!==t)}},Ie=class{constructor(e){X(this,"_pairs");this._pairs=e}*[Symbol.iterator](){for(let[e,t]of this._pairs)yield[e,t]}*entries(){for(let[e,t]of this._pairs)yield[e,t]}*keys(){for(let[e]of this._pairs)yield e}*values(){for(let[,e]of this._pairs)yield e}toIdArray(){return[...this._pairs].map(e=>e[0])}toItemArray(){return[...this._pairs].map(e=>e[1])}toEntryArray(){return[...this._pairs]}toObjectMap(){let e=Object.create(null);for(let[t,i]of this._pairs)e[t]=i;return e}toMap(){return new Map(this._pairs)}toIdSet(){return new Set(this.toIdArray())}toItemSet(){return new Set(this.toItemArray())}cache(){return new Ie([...this._pairs])}distinct(e){let t=new Set;for(let[i,s]of this._pairs)t.add(e(s,i));return t}filter(e){let t=this._pairs;return new Ie({*[Symbol.iterator](){for(let[i,s]of t)e(s,i)&&(yield[i,s])}})}forEach(e){for(let[t,i]of this._pairs)e(i,t)}map(e){let t=this._pairs;return new Ie({*[Symbol.iterator](){for(let[i,s]of t)yield[i,e(s,i)]}})}max(e){let t=this._pairs[Symbol.iterator](),i=t.next();if(i.done)return null;let s=i.value[1],o=e(i.value[1],i.value[0]);for(;!(i=t.next()).done;){let[r,a]=i.value,d=e(a,r);d>o&&(o=d,s=a)}return s}min(e){let t=this._pairs[Symbol.iterator](),i=t.next();if(i.done)return null;let s=i.value[1],o=e(i.value[1],i.value[0]);for(;!(i=t.next()).done;){let[r,a]=i.value,d=e(a,r);d[...this._pairs].sort(([t,i],[s,o])=>e(i,o,t,s))[Symbol.iterator]()})}};function Br(n,e){return n[e]==null&&(n[e]=xe()),n}var Ce=class extends _t{constructor(e,t){super();X(this,"flush");X(this,"length");X(this,"_options");X(this,"_data");X(this,"_idProp");X(this,"_queue",null);e&&!Array.isArray(e)&&(t=e,e=[]),this._options=t||{},this._data=new Map,this.length=0,this._idProp=this._options.fieldId||"id",e&&e.length&&this.add(e),this.setOptions(t)}get idProp(){return this._idProp}setOptions(e){e&&e.queue!==void 0&&(e.queue===!1?this._queue&&(this._queue.destroy(),this._queue=null):(this._queue||(this._queue=Wt.extend(this,{replace:["add","update","remove"]})),e.queue&&typeof e.queue=="object"&&this._queue.setOptions(e.queue)))}add(e,t){let i=[],s;if(Array.isArray(e)){if(e.map(r=>r[this._idProp]).some(r=>this._data.has(r)))throw new Error("A duplicate id was found in the parameter array.");for(let r=0,a=e.length;r{let l=h[a];if(l!=null&&this._data.has(l)){let c=h,u=Object.assign({},this._data.get(l)),f=this._updateItem(c);s.push(f),r.push(c),o.push(u)}else{let c=this._addItem(h);i.push(c)}};if(Array.isArray(e))for(let h=0,l=e.length;h{let o=this._data.get(s[this._idProp]);if(o==null)throw new Error("Updating non-existent items is not allowed.");return{oldData:o,update:s}}).map(({oldData:s,update:o})=>{let r=s[this._idProp],a=Ss(s,o);return this._data.set(r,a),{id:r,oldData:s,updatedData:a}});if(i.length){let s={items:i.map(o=>o.id),oldData:i.map(o=>o.oldData),data:i.map(o=>o.updatedData)};return this._trigger("update",s,t),s.items}else return[]}get(e,t){let i,s,o;Xs(e)?(i=e,o=t):Array.isArray(e)?(s=e,o=t):o=e;let r=o&&o.returnType==="Object"?"Object":"Array",a=o&&o.filter,d=[],h,l,c;if(i!=null)h=this._data.get(i),h&&a&&!a(h)&&(h=void 0);else if(s!=null)for(let u=0,f=s.length;u(i[s]=e[s],i),{})}_sort(e,t){if(typeof t=="string"){let i=t;e.sort((s,o)=>{let r=s[i],a=o[i];return r>a?1:ri)&&(t=s,i=o)}return t||null}min(e){let t=null,i=null;for(let s of this._data.values()){let o=s[e];typeof o=="number"&&(i==null||o=.1;)y=+o[c++%r],y>l&&(y=l),f=Math.sqrt(y*y/(1+h*h)),f=a<0?-f:f,e+=f,t+=h*f,u===!0?n.lineTo(e,t):n.moveTo(e,t),l-=y,u=!u}function Wr(n,e,t,i){n.beginPath();let s=6,o=Math.PI*2/s;n.moveTo(e+i,t);for(let r=1;r":!0,"--":!0},Pe="",it=0,P="",S="",ee=Z.NULL;function Ur(){it=0,P=Pe.charAt(0)}function V(){it++,P=Pe.charAt(it)}function st(){return Pe.charAt(it+1)}function to(n){var e=n.charCodeAt(0);return e<47?e===35||e===46:e<59?e>47:e<91?e>64:e<96?e===95:e<123?e>96:!1}function Me(n,e){if(n||(n={}),e)for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n}function Yr(n,e,t){for(var i=e.split("."),s=n;i.length;){var o=i.shift();i.length?(s[o]||(s[o]={}),s=s[o]):s[o]=t}}function io(n,e){for(var t,i,s=null,o=[n],r=n;r.parent;)o.push(r.parent),r=r.parent;if(r.nodes){for(t=0,i=r.nodes.length;t=0;t--){var a=o[t];a.nodes||(a.nodes=[]),a.nodes.indexOf(s)===-1&&a.nodes.push(s)}e.attr&&(s.attr=Me(s.attr,e.attr))}function Xr(n,e){if(n.edges||(n.edges=[]),n.edges.push(e),n.edge){var t=Me({},n.edge);e.attr=Me(t,e.attr)}}function so(n,e,t,i,s){var o={from:e,to:t,type:i};return n.edge&&(o.attr=Me({},n.edge)),o.attr=Me(o.attr||{},s),s!=null&&s.hasOwnProperty("arrows")&&s.arrows!=null&&(o.arrows={to:{enabled:!0,type:s.arrows.type}},s.arrows=null),o}function B(){for(ee=Z.NULL,S="";P===" "||P===" "||P===` +`||P==="\r";)V();do{var n=!1;if(P==="#"){for(var e=it-1;Pe.charAt(e)===" "||Pe.charAt(e)===" ";)e--;if(Pe.charAt(e)===` +`||Pe.charAt(e)===""){for(;P!=""&&P!=` +`;)V();n=!0}}if(P==="/"&&st()==="/"){for(;P!=""&&P!=` +`;)V();n=!0}if(P==="/"&&st()==="*"){for(;P!="";)if(P==="*"&&st()==="/"){V(),V();break}else V();n=!0}for(;P===" "||P===" "||P===` +`||P==="\r";)V()}while(n);if(P===""){ee=Z.DELIMITER;return}var t=P+st();if(eo[t]){ee=Z.DELIMITER,S=t,V(),V();return}if(eo[P]){ee=Z.DELIMITER,S=P,V();return}if(to(P)||P==="-"){for(S+=P,V();to(P);)S+=P,V();S==="false"?S=!1:S==="true"?S=!0:isNaN(Number(S))||(S=Number(S)),ee=Z.IDENTIFIER;return}if(P==='"'){for(V();P!=""&&(P!='"'||P==='"'&&st()==='"');)P==='"'?(S+=P,V()):P==="\\"&&st()==="n"?(S+=` +`,V()):S+=P,V();if(P!='"')throw Q('End of string " expected');V(),ee=Z.IDENTIFIER;return}for(ee=Z.UNKNOWN;P!="";)S+=P,V();throw new SyntaxError('Syntax error in part "'+ao(S,30)+'"')}function Gr(){var n={};if(Ur(),B(),S==="strict"&&(n.strict=!0,B()),(S==="graph"||S==="digraph")&&(n.type=S,B()),ee===Z.IDENTIFIER&&(n.id=S,B()),S!="{")throw Q("Angle bracket { expected");if(B(),oo(n),S!="}")throw Q("Angle bracket } expected");if(B(),S!=="")throw Q("End of file expected");return B(),delete n.node,delete n.edge,delete n.graph,n}function oo(n){for(;S!==""&&S!="}";)Kr(n),S===";"&&B()}function Kr(n){var e=no(n);if(e){ro(n,e);return}var t=$r(n);if(!t){if(ee!=Z.IDENTIFIER)throw Q("Identifier expected");var i=S;if(B(),S==="="){if(B(),ee!=Z.IDENTIFIER)throw Q("Identifier expected");n[i]=S,B()}else Zr(n,i)}}function no(n){var e=null;if(S==="subgraph"&&(e={},e.type="subgraph",B(),ee===Z.IDENTIFIER&&(e.id=S,B())),S==="{"){if(B(),e||(e={}),e.parent=n,e.node=n.node,e.edge=n.edge,e.graph=n.graph,oo(e),S!="}")throw Q("Angle bracket } expected");B(),delete e.node,delete e.edge,delete e.graph,delete e.parent,n.subgraphs||(n.subgraphs=[]),n.subgraphs.push(e)}return e}function $r(n){return S==="node"?(B(),n.node=Et(),"node"):S==="edge"?(B(),n.edge=Et(),"edge"):S==="graph"?(B(),n.graph=Et(),"graph"):null}function Zr(n,e){var t={id:e},i=Et();i&&(t.attr=i),io(n,t),ro(n,e)}function ro(n,e){for(;S==="->"||S==="--";){var t,i=S;B();var s=no(n);if(s)t=s;else{if(ee!=Z.IDENTIFIER)throw Q("Identifier or subgraph expected");t=S,io(n,{id:t}),B()}var o=Et(),r=so(n,e,t,i,o);Xr(n,r),e=t}}function Et(){for(var n,e=null,t={dashed:!0,solid:!1,dotted:[1,5]},i={dot:"circle",box:"box",crow:"crow",curve:"curve",icurve:"inv_curve",normal:"triangle",inv:"inv_triangle",diamond:"diamond",tee:"bar",vee:"vee"},s=new Array,o=new Array;S==="[";){for(B(),e={};S!==""&&S!="]";){if(ee!=Z.IDENTIFIER)throw Q("Attribute name expected");var r=S;if(B(),S!="=")throw Q("Equal sign = expected");if(B(),ee!=Z.IDENTIFIER)throw Q("Attribute value expected");var a=S;r==="style"&&(a=t[a]);var d;r==="arrowhead"&&(d=i[a],r="arrows",a={to:{enabled:!0,type:d}}),r==="arrowtail"&&(d=i[a],r="arrows",a={from:{enabled:!0,type:d}}),s.push({attr:e,name:r,value:a}),o.push(r),B(),S==","&&B()}if(S!="]")throw Q("Bracket ] expected");B()}if(o.includes("dir")){var h={};for(h.arrows={},n=0;n"&&(o.arrows="to"),o};e.edges.forEach(function(s){var o,r;s.from instanceof Object?o=s.from.nodes:o={id:s.from},s.to instanceof Object?r=s.to.nodes:r={id:s.to},s.from instanceof Object&&s.from.edges&&s.from.edges.forEach(function(a){var d=i(a);t.edges.push(d)}),Qr(o,r,function(a,d){var h=so(t,a.id,d.id,s.type,s.attr),l=i(h);t.edges.push(l)}),s.to instanceof Object&&s.to.edges&&s.to.edges.forEach(function(a){var d=i(a);t.edges.push(d)})})}return e.attr&&(t.options=e.attr),t}function ea(n,e){let t={edges:{inheritColor:!1},nodes:{fixed:!1,parseColor:!1}};e!=null&&(e.fixed!=null&&(t.nodes.fixed=e.fixed),e.parseColor!=null&&(t.nodes.parseColor=e.parseColor),e.inheritColor!=null&&(t.edges.inheritColor=e.inheritColor));let s=n.edges.map(r=>{let a={from:r.source,id:r.id,to:r.target};return r.attributes!=null&&(a.attributes=r.attributes),r.label!=null&&(a.label=r.label),r.attributes!=null&&r.attributes.title!=null&&(a.title=r.attributes.title),r.type==="Directed"&&(a.arrows="to"),r.color&&t.edges.inheritColor===!1&&(a.color=r.color),a});return{nodes:n.nodes.map(r=>{let a={id:r.id,fixed:t.nodes.fixed&&r.x!=null&&r.y!=null};return r.attributes!=null&&(a.attributes=r.attributes),r.label!=null&&(a.label=r.label),r.size!=null&&(a.size=r.size),r.attributes!=null&&r.attributes.title!=null&&(a.title=r.attributes.title),r.title!=null&&(a.title=r.title),r.x!=null&&(a.x=r.x),r.y!=null&&(a.y=r.y),r.color!=null&&(t.nodes.parseColor===!0?a.color=r.color:a.color={background:r.color,border:r.color,highlight:{background:r.color,border:r.color},hover:{background:r.color,border:r.color}}),a}),edges:s}}var ta={addDescription:"Click in an empty space to place a new node.",addEdge:"Add Edge",addNode:"Add Node",back:"Back",close:"Close",createEdgeError:"Cannot link edges to a cluster.",del:"Delete selected",deleteClusterError:"Clusters cannot be deleted.",edgeDescription:"Click on a node and drag the edge to another node to connect them.",edit:"Edit",editClusterError:"Clusters cannot be edited.",editEdge:"Edit Edge",editEdgeDescription:"Click on the control points and drag them to a node to connect to it.",editNode:"Edit Node"},ia={addDescription:"Klicke auf eine freie Stelle, um einen neuen Knoten zu plazieren.",addEdge:"Kante hinzuf\xFCgen",addNode:"Knoten hinzuf\xFCgen",back:"Zur\xFCck",close:"Schlie\xDFen",createEdgeError:"Es ist nicht m\xF6glich, Kanten mit Clustern zu verbinden.",del:"L\xF6sche Auswahl",deleteClusterError:"Cluster k\xF6nnen nicht gel\xF6scht werden.",edgeDescription:"Klicke auf einen Knoten und ziehe die Kante zu einem anderen Knoten, um diese zu verbinden.",edit:"Editieren",editClusterError:"Cluster k\xF6nnen nicht editiert werden.",editEdge:"Kante editieren",editEdgeDescription:"Klicke auf die Verbindungspunkte und ziehe diese auf einen Knoten, um sie zu verbinden.",editNode:"Knoten editieren"},sa={addDescription:"Haga clic en un lugar vac\xEDo para colocar un nuevo nodo.",addEdge:"A\xF1adir arista",addNode:"A\xF1adir nodo",back:"Atr\xE1s",close:"Cerrar",createEdgeError:"No se puede conectar una arista a un grupo.",del:"Eliminar selecci\xF3n",deleteClusterError:"No es posible eliminar grupos.",edgeDescription:"Haga clic en un nodo y arrastre la arista hacia otro nodo para conectarlos.",edit:"Editar",editClusterError:"No es posible editar grupos.",editEdge:"Editar arista",editEdgeDescription:"Haga clic en un punto de control y arrastrelo a un nodo para conectarlo.",editNode:"Editar nodo"},oa={addDescription:"Clicca per aggiungere un nuovo nodo",addEdge:"Aggiungi un vertice",addNode:"Aggiungi un nodo",back:"Indietro",close:"Chiudere",createEdgeError:"Non si possono collegare vertici ad un cluster",del:"Cancella la selezione",deleteClusterError:"I cluster non possono essere cancellati",edgeDescription:"Clicca su un nodo e trascinalo ad un altro nodo per connetterli.",edit:"Modifica",editClusterError:"I clusters non possono essere modificati.",editEdge:"Modifica il vertice",editEdgeDescription:"Clicca sui Punti di controllo e trascinali ad un nodo per connetterli.",editNode:"Modifica il nodo"},na={addDescription:"Klik op een leeg gebied om een nieuwe node te maken.",addEdge:"Link toevoegen",addNode:"Node toevoegen",back:"Terug",close:"Sluiten",createEdgeError:"Kan geen link maken naar een cluster.",del:"Selectie verwijderen",deleteClusterError:"Clusters kunnen niet worden verwijderd.",edgeDescription:"Klik op een node en sleep de link naar een andere node om ze te verbinden.",edit:"Wijzigen",editClusterError:"Clusters kunnen niet worden aangepast.",editEdge:"Link wijzigen",editEdgeDescription:"Klik op de verbindingspunten en sleep ze naar een node om daarmee te verbinden.",editNode:"Node wijzigen"},ra={addDescription:"Clique em um espa\xE7o em branco para adicionar um novo n\xF3",addEdge:"Adicionar aresta",addNode:"Adicionar n\xF3",back:"Voltar",close:"Fechar",createEdgeError:"N\xE3o foi poss\xEDvel linkar arestas a um cluster.",del:"Remover selecionado",deleteClusterError:"Clusters n\xE3o puderam ser removidos.",edgeDescription:"Clique em um n\xF3 e arraste a aresta at\xE9 outro n\xF3 para conect\xE1-los",edit:"Editar",editClusterError:"Clusters n\xE3o puderam ser editados.",editEdge:"Editar aresta",editEdgeDescription:"Clique nos pontos de controle e os arraste para um n\xF3 para conect\xE1-los",editNode:"Editar n\xF3"},aa={addDescription:"\u041A\u043B\u0438\u043A\u043D\u0438\u0442\u0435 \u0432 \u0441\u0432\u043E\u0431\u043E\u0434\u043D\u043E\u0435 \u043C\u0435\u0441\u0442\u043E, \u0447\u0442\u043E\u0431\u044B \u0434\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u043D\u043E\u0432\u044B\u0439 \u0443\u0437\u0435\u043B.",addEdge:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0440\u0435\u0431\u0440\u043E",addNode:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u0443\u0437\u0435\u043B",back:"\u041D\u0430\u0437\u0430\u0434",close:"\u0417\u0430\u043A\u0440\u044B\u0432\u0430\u0442\u044C",createEdgeError:"\u041D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E \u0441\u043E\u0435\u0434\u0438\u043D\u0438\u0442\u044C \u0440\u0435\u0431\u0440\u0430 \u0432 \u043A\u043B\u0430\u0441\u0442\u0435\u0440.",del:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0432\u044B\u0431\u0440\u0430\u043D\u043D\u043E\u0435",deleteClusterError:"\u041A\u043B\u0430\u0441\u0442\u0435\u0440\u044B \u043D\u0435 \u043C\u043E\u0433\u0443\u0442 \u0431\u044B\u0442\u044C \u0443\u0434\u0430\u043B\u0435\u043D\u044B",edgeDescription:"\u041A\u043B\u0438\u043A\u043D\u0438\u0442\u0435 \u043D\u0430 \u0443\u0437\u0435\u043B \u0438 \u043F\u0440\u043E\u0442\u044F\u043D\u0438\u0442\u0435 \u0440\u0435\u0431\u0440\u043E \u043A \u0434\u0440\u0443\u0433\u043E\u043C\u0443 \u0443\u0437\u043B\u0443, \u0447\u0442\u043E\u0431\u044B \u0441\u043E\u0435\u0434\u0438\u043D\u0438\u0442\u044C \u0438\u0445.",edit:"\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C",editClusterError:"\u041A\u043B\u0430\u0441\u0442\u0435\u0440\u044B \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B \u0434\u043B\u044F \u0440\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u044F.",editEdge:"\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0440\u0435\u0431\u0440\u043E",editEdgeDescription:"\u041A\u043B\u0438\u043A\u043D\u0438\u0442\u0435 \u043D\u0430 \u043A\u043E\u043D\u0442\u0440\u043E\u043B\u044C\u043D\u044B\u0435 \u0442\u043E\u0447\u043A\u0438 \u0438 \u043F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0438\u0445 \u0432 \u0443\u0437\u0435\u043B, \u0447\u0442\u043E\u0431\u044B \u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u044C\u0441\u044F \u043A \u043D\u0435\u043C\u0443.",editNode:"\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0443\u0437\u0435\u043B"},da={addDescription:"\u5355\u51FB\u7A7A\u767D\u5904\u653E\u7F6E\u65B0\u8282\u70B9\u3002",addEdge:"\u6DFB\u52A0\u8FDE\u63A5\u7EBF",addNode:"\u6DFB\u52A0\u8282\u70B9",back:"\u8FD4\u56DE",close:"\u95DC\u9589",createEdgeError:"\u65E0\u6CD5\u5C06\u8FDE\u63A5\u7EBF\u8FDE\u63A5\u5230\u7FA4\u96C6\u3002",del:"\u5220\u9664\u9009\u5B9A",deleteClusterError:"\u65E0\u6CD5\u5220\u9664\u7FA4\u96C6\u3002",edgeDescription:"\u5355\u51FB\u67D0\u4E2A\u8282\u70B9\u5E76\u5C06\u8BE5\u8FDE\u63A5\u7EBF\u62D6\u52A8\u5230\u53E6\u4E00\u4E2A\u8282\u70B9\u4EE5\u8FDE\u63A5\u5B83\u4EEC\u3002",edit:"\u7F16\u8F91",editClusterError:"\u65E0\u6CD5\u7F16\u8F91\u7FA4\u96C6\u3002",editEdge:"\u7F16\u8F91\u8FDE\u63A5\u7EBF",editEdgeDescription:"\u5355\u51FB\u63A7\u5236\u8282\u70B9\u5E76\u5C06\u5B83\u4EEC\u62D6\u5230\u8282\u70B9\u4E0A\u8FDE\u63A5\u3002",editNode:"\u7F16\u8F91\u8282\u70B9"},ha={addDescription:"K\u043B\u0456\u043A\u043D\u0456\u0442\u044C \u043D\u0430 \u0432\u0456\u043B\u044C\u043D\u0435 \u043C\u0456\u0441\u0446\u0435, \u0449\u043E\u0431 \u0434\u043E\u0434\u0430\u0442\u0438 \u043D\u043E\u0432\u0438\u0439 \u0432\u0443\u0437\u043E\u043B.",addEdge:"\u0414\u043E\u0434\u0430\u0442\u0438 \u043A\u0440\u0430\u0439",addNode:"\u0414\u043E\u0434\u0430\u0442\u0438 \u0432\u0443\u0437\u043E\u043B",back:"\u041D\u0430\u0437\u0430\u0434",close:"\u0417\u0430\u043A\u0440\u0438\u0442\u0438",createEdgeError:"\u041D\u0435 \u043C\u043E\u0436\u043B\u0438\u0432\u043E \u043E\u0431'\u0454\u0434\u043D\u0430\u0442\u0438 \u043A\u0440\u0430\u0457 \u0432 \u0433\u0440\u0443\u043F\u0443.",del:"\u0412\u0438\u0434\u0430\u043B\u0438\u0442\u0438 \u043E\u0431\u0440\u0430\u043D\u0435",deleteClusterError:"\u0413\u0440\u0443\u043F\u0438 \u043D\u0435 \u043C\u043E\u0436\u0443\u0442\u044C \u0431\u0443\u0442\u0438 \u0432\u0438\u0434\u0430\u043B\u0435\u043D\u0456.",edgeDescription:"\u041A\u043B\u0456\u043A\u043D\u0456\u0442\u044C \u043D\u0430 \u0432\u0443\u0437\u043E\u043B \u0456 \u043F\u0435\u0440\u0435\u0442\u044F\u0433\u043D\u0456\u0442\u044C \u043A\u0440\u0430\u0439 \u0434\u043E \u0456\u043D\u0448\u043E\u0433\u043E \u0432\u0443\u0437\u043B\u0430, \u0449\u043E\u0431 \u0457\u0445 \u0437'\u0454\u0434\u043D\u0430\u0442\u0438.",edit:"\u0420\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u0442\u0438",editClusterError:"\u0413\u0440\u0443\u043F\u0438 \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u0456 \u0434\u043B\u044F \u0440\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u043D\u043D\u044F.",editEdge:"\u0420\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u0442\u0438 \u043A\u0440\u0430\u0439",editEdgeDescription:"\u041A\u043B\u0456\u043A\u043D\u0456\u0442\u044C \u043D\u0430 \u043A\u043E\u043D\u0442\u0440\u043E\u043B\u044C\u043D\u0456 \u0442\u043E\u0447\u043A\u0438 \u0456 \u043F\u0435\u0440\u0435\u0442\u044F\u0433\u043D\u0456\u0442\u044C \u0457\u0445 \u0443 \u0432\u0443\u0437\u043E\u043B, \u0449\u043E\u0431 \u043F\u0456\u0434\u043A\u043B\u044E\u0447\u0438\u0442\u0438\u0441\u044F \u0434\u043E \u043D\u044C\u043E\u0433\u043E.",editNode:"\u0420\u0435\u0434\u0430\u0433\u0443\u0432\u0430\u0442\u0438 \u0432\u0443\u0437\u043E\u043B"},la={addDescription:"Cliquez dans un endroit vide pour placer un n\u0153ud.",addEdge:"Ajouter un lien",addNode:"Ajouter un n\u0153ud",back:"Retour",close:"Fermer",createEdgeError:"Impossible de cr\xE9er un lien vers un cluster.",del:"Effacer la s\xE9lection",deleteClusterError:"Les clusters ne peuvent pas \xEAtre effac\xE9s.",edgeDescription:"Cliquez sur un n\u0153ud et glissez le lien vers un autre n\u0153ud pour les connecter.",edit:"\xC9diter",editClusterError:"Les clusters ne peuvent pas \xEAtre \xE9dit\xE9s.",editEdge:"\xC9diter le lien",editEdgeDescription:"Cliquez sur les points de contr\xF4le et glissez-les pour connecter un n\u0153ud.",editNode:"\xC9diter le n\u0153ud"},ca={addDescription:"Kluknut\xEDm do pr\xE1zdn\xE9ho prostoru m\u016F\u017Eete p\u0159idat nov\xFD vrchol.",addEdge:"P\u0159idat hranu",addNode:"P\u0159idat vrchol",back:"Zp\u011Bt",close:"Zav\u0159\xEDt",createEdgeError:"Nelze p\u0159ipojit hranu ke shluku.",del:"Smazat v\xFDb\u011Br",deleteClusterError:"Nelze mazat shluky.",edgeDescription:"P\u0159eta\u017Een\xEDm z jednoho vrcholu do druh\xE9ho m\u016F\u017Eete spojit tyto vrcholy novou hranou.",edit:"Upravit",editClusterError:"Nelze upravovat shluky.",editEdge:"Upravit hranu",editEdgeDescription:"P\u0159eta\u017Een\xEDm kontroln\xEDho vrcholu hrany ji m\u016F\u017Eete p\u0159ipojit k jin\xE9mu vrcholu.",editNode:"Upravit vrchol"},ua=Object.freeze({__proto__:null,cn:da,cs:ca,de:ia,en:ta,es:sa,fr:la,it:oa,nl:na,pt:ra,ru:aa,uk:ha});function fa(n,e){try{let[t,i]=e.split(/[-_ /]/,2),s=t!=null?t.toLowerCase():null,o=i!=null?i.toUpperCase():null;if(s&&o){let r=s+"-"+o;if(Object.prototype.hasOwnProperty.call(n,r))return r;console.warn(`Unknown variant ${o} of language ${s}.`)}if(s){let r=s;if(Object.prototype.hasOwnProperty.call(n,r))return r;console.warn(`Unknown language ${s}`)}return console.warn(`Unknown locale ${e}, falling back to English.`),"en"}catch(t){return console.error(t),console.warn(`Unexpected error while normalizing locale ${e}, falling back to English.`),"en"}}var lo=class{constructor(){this.NUM_ITERATIONS=4,this.image=new Image,this.canvas=document.createElement("canvas")}init(){if(this.initialized())return;this.src=this.image.src;let e=this.image.width,t=this.image.height;this.width=e,this.height=t;let i=Math.floor(t/2),s=Math.floor(t/4),o=Math.floor(t/8),r=Math.floor(t/16),a=Math.floor(e/2),d=Math.floor(e/4),h=Math.floor(e/8),l=Math.floor(e/16);this.canvas.width=3*d,this.canvas.height=i,this.coordinates=[[0,0,a,i],[a,0,d,s],[a,s,h,o],[5*h,s,l,r]],this._fillMipMap()}initialized(){return this.coordinates!==void 0}_fillMipMap(){let e=this.canvas.getContext("2d"),t=this.coordinates[0];e.drawImage(this.image,t[0],t[1],t[2],t[3]);for(let i=1;i2){t*=.5;let a=0;for(;t>2&&a=this.NUM_ITERATIONS&&(a=this.NUM_ITERATIONS-1);let d=this.coordinates[a];e.drawImage(this.canvas,d[0],d[1],d[2],d[3],i,s,o,r)}else e.drawImage(this.image,i,s,o,r)}},co=class{constructor(e){this.images={},this.imageBroken={},this.callback=e}_tryloadBrokenUrl(e,t,i){if(!(e===void 0||i===void 0)){if(t===void 0){console.warn("No broken url image defined");return}i.image.onerror=()=>{console.error("Could not load brokenImage:",t)},i.image.src=t}}_redrawWithImage(e){this.callback&&this.callback(e)}load(e,t){let i=this.images[e];if(i)return i;let s=new lo;return this.images[e]=s,s.image.onload=()=>{this._fixImageCoordinates(s.image),s.init(),this._redrawWithImage(s)},s.image.onerror=()=>{console.error("Could not load image:",e),this._tryloadBrokenUrl(e,t,s)},s.image.src=e,s}_fixImageCoordinates(e){e.width===0&&(document.body.appendChild(e),e.width=e.offsetWidth,e.height=e.offsetHeight,document.body.removeChild(e))}},uo=class{constructor(){this.clear(),this._defaultIndex=0,this._groupIndex=0,this._defaultGroups=[{border:"#2B7CE9",background:"#97C2FC",highlight:{border:"#2B7CE9",background:"#D2E5FF"},hover:{border:"#2B7CE9",background:"#D2E5FF"}},{border:"#FFA500",background:"#FFFF00",highlight:{border:"#FFA500",background:"#FFFFA3"},hover:{border:"#FFA500",background:"#FFFFA3"}},{border:"#FA0A10",background:"#FB7E81",highlight:{border:"#FA0A10",background:"#FFAFB1"},hover:{border:"#FA0A10",background:"#FFAFB1"}},{border:"#41A906",background:"#7BE141",highlight:{border:"#41A906",background:"#A1EC76"},hover:{border:"#41A906",background:"#A1EC76"}},{border:"#E129F0",background:"#EB7DF4",highlight:{border:"#E129F0",background:"#F0B3F5"},hover:{border:"#E129F0",background:"#F0B3F5"}},{border:"#7C29F0",background:"#AD85E4",highlight:{border:"#7C29F0",background:"#D3BDF0"},hover:{border:"#7C29F0",background:"#D3BDF0"}},{border:"#C37F00",background:"#FFA807",highlight:{border:"#C37F00",background:"#FFCA66"},hover:{border:"#C37F00",background:"#FFCA66"}},{border:"#4220FB",background:"#6E6EFD",highlight:{border:"#4220FB",background:"#9B9BFD"},hover:{border:"#4220FB",background:"#9B9BFD"}},{border:"#FD5A77",background:"#FFC0CB",highlight:{border:"#FD5A77",background:"#FFD1D9"},hover:{border:"#FD5A77",background:"#FFD1D9"}},{border:"#4AD63A",background:"#C2FABC",highlight:{border:"#4AD63A",background:"#E6FFE3"},hover:{border:"#4AD63A",background:"#E6FFE3"}},{border:"#990000",background:"#EE0000",highlight:{border:"#BB0000",background:"#FF3333"},hover:{border:"#BB0000",background:"#FF3333"}},{border:"#FF6000",background:"#FF6000",highlight:{border:"#FF6000",background:"#FF6000"},hover:{border:"#FF6000",background:"#FF6000"}},{border:"#97C2FC",background:"#2B7CE9",highlight:{border:"#D2E5FF",background:"#2B7CE9"},hover:{border:"#D2E5FF",background:"#2B7CE9"}},{border:"#399605",background:"#255C03",highlight:{border:"#399605",background:"#255C03"},hover:{border:"#399605",background:"#255C03"}},{border:"#B70054",background:"#FF007E",highlight:{border:"#B70054",background:"#FF007E"},hover:{border:"#B70054",background:"#FF007E"}},{border:"#AD85E4",background:"#7C29F0",highlight:{border:"#D3BDF0",background:"#7C29F0"},hover:{border:"#D3BDF0",background:"#7C29F0"}},{border:"#4557FA",background:"#000EA1",highlight:{border:"#6E6EFD",background:"#000EA1"},hover:{border:"#6E6EFD",background:"#000EA1"}},{border:"#FFC0CB",background:"#FD5A77",highlight:{border:"#FFD1D9",background:"#FD5A77"},hover:{border:"#FFD1D9",background:"#FD5A77"}},{border:"#C2FABC",background:"#74D66A",highlight:{border:"#E6FFE3",background:"#74D66A"},hover:{border:"#E6FFE3",background:"#74D66A"}},{border:"#EE0000",background:"#990000",highlight:{border:"#FF3333",background:"#BB0000"},hover:{border:"#FF3333",background:"#BB0000"}}],this.options={},this.defaultOptions={useDefaultGroups:!0},Object.assign(this.options,this.defaultOptions)}setOptions(e){let t=["useDefaultGroups"];if(e!==void 0){for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)===-1){let s=e[i];this.add(i,s)}}}clear(){this._groups=new Map,this._groupNames=[]}get(e,t=!0){let i=this._groups.get(e);if(i===void 0&&t)if(this.options.useDefaultGroups===!1&&this._groupNames.length>0){let s=this._groupIndex%this._groupNames.length;++this._groupIndex,i={},i.color=this._groups.get(this._groupNames[s]),this._groups.set(e,i)}else{let s=this._defaultIndex%this._defaultGroups.length;this._defaultIndex++,i={},i.color=this._defaultGroups[s],this._groups.set(e,i)}return i}add(e,t){return this._groups.has(e)||this._groupNames.push(e),this._groups.set(e,t),t}};function Ci(n,e){let t=["node","edge","label"],i=!0,s=Ee(e,"chosen");if(typeof s=="boolean")i=s;else if(typeof s=="object"){if(t.indexOf(n)===-1)throw new Error("choosify: subOption '"+n+"' should be one of '"+t.join("', '")+"'");let o=Ee(e,["chosen",n]);(typeof o=="boolean"||typeof o=="function")&&(i=o)}return i}function Ti(n,e,t){if(n.width<=0||n.height<=0)return!1;if(t!==void 0){let o={x:e.x-t.x,y:e.y-t.y};if(t.angle!==0){let r=-t.angle;e={x:Math.cos(r)*o.x-Math.sin(r)*o.y,y:Math.sin(r)*o.x+Math.cos(r)*o.y}}else e=o}let i=n.x+n.width,s=n.y+n.width;return n.lefte.x&&n.tope.y}function qt(n){return typeof n=="string"&&n!==""}function fo(n,e,t,i){let s=i.x,o=i.y;if(typeof i.distanceToBorder=="function"){let r=i.distanceToBorder(n,e),a=Math.sin(e)*r,d=Math.cos(e)*r;d===r?(s+=r,o=i.y):a===r?(s=i.x,o-=r):(s+=d,o-=a)}else i.shape.width>i.shape.height?(s=i.x+i.shape.width*.5,o=i.y-t):(s=i.x+t,o=i.y-i.shape.height*.5);return{x:s,y:o}}var po=class{constructor(e){this.measureText=e,this.current=0,this.width=0,this.height=0,this.lines=[]}_add(e,t,i="normal"){this.lines[e]===void 0&&(this.lines[e]={width:0,height:0,blocks:[]});let s=t;(t===void 0||t==="")&&(s=" ");let o=this.measureText(s,i),r=Object.assign({},o.values);r.text=t,r.width=o.width,r.mod=i,(t===void 0||t==="")&&(r.width=0),this.lines[e].blocks.push(r),this.lines[e].width+=r.width}curWidth(){let e=this.lines[this.current];return e===void 0?0:e.width}append(e,t="normal"){this._add(this.current,e,t)}newLine(e,t="normal"){this._add(this.current,e,t),this.current++}determineLineHeights(){for(let e=0;ee&&(e=s.width),t+=s.height}this.width=e,this.height=t}removeEmptyBlocks(){let e=[];for(let t=0;t"://,""://,""://,"":/<\/b>/,"":/<\/i>/,"":/<\/code>/,"*":/\*/,_:/_/,"`":/`/,afterBold:/[^*]/,afterItal:/[^_]/,afterMono:/[^`]/},ki=class{constructor(e){this.text=e,this.bold=!1,this.ital=!1,this.mono=!1,this.spacing=!1,this.position=0,this.buffer="",this.modStack=[],this.blocks=[]}mod(){return this.modStack.length===0?"normal":this.modStack[0]}modName(){if(this.modStack.length===0)return"normal";if(this.modStack[0]==="mono")return"mono";if(this.bold&&this.ital)return"boldital";if(this.bold)return"bold";if(this.ital)return"ital"}emitBlock(){this.spacing&&(this.add(" "),this.spacing=!1),this.buffer.length>0&&(this.blocks.push({text:this.buffer,mod:this.modName()}),this.buffer="")}add(e){e===" "&&(this.spacing=!0),this.spacing&&(this.buffer+=" ",this.spacing=!1),e!=" "&&(this.buffer+=e)}parseWS(e){return/[ \t]/.test(e)?(this.mono?this.add(e):this.spacing=!0,!0):!1}setTag(e){this.emitBlock(),this[e]=!0,this.modStack.unshift(e)}unsetTag(e){this.emitBlock(),this[e]=!1,this.modStack.shift()}parseStartTag(e,t){return!this.mono&&!this[e]&&this.match(t)?(this.setTag(e),!0):!1}match(e,t=!0){let[i,s]=this.prepareRegExp(e),o=i.test(this.text.substr(this.position,s));return o&&t&&(this.position+=s-1),o}parseEndTag(e,t,i){let s=this.mod()===e;return e==="mono"?s=s&&this.mono:s=s&&!this.mono,s&&this.match(t)?(i!==void 0?(this.position===this.text.length-1||this.match(i,!1))&&this.unsetTag(e):this.unsetTag(e),!0):!1}replace(e,t){return this.match(e)?(this.add(t),this.position+=length-1,!0):!1}prepareRegExp(e){let t,i;if(e instanceof RegExp)i=e,t=1;else{let s=pa[e];s!==void 0?i=s:i=new RegExp(e),t=e.length}return[i,t]}},go=class{constructor(e,t,i,s){this.ctx=e,this.parent=t,this.selected=i,this.hover=s;let o=(r,a)=>{if(r===void 0)return 0;let d=this.parent.getFormattingValues(e,i,s,a),h=0;return r!==""&&(h=this.ctx.measureText(r).width),{width:h,values:d}};this.lines=new po(o)}process(e){if(!qt(e))return this.lines.finalize();let t=this.parent.fontOptions;e=e.replace(/\r\n/g,` `),e=e.replace(/\r/g,` `);let i=String(e).split(` -`),s=i.length;if(t.multi)for(let o=0;o0)for(let a=0;a0)for(let o=0;o/&/.test(s)?(t.replace(t.text,"<","<")||t.replace(t.text,"&","&")||t.add("&"),!0):!1;for(;t.position")||t.parseStartTag("ital","")||t.parseStartTag("mono","")||t.parseEndTag("bold","")||t.parseEndTag("ital","")||t.parseEndTag("mono",""))||i(s)||t.add(s),t.position++}return t.emitBlock(),t.blocks}splitMarkdownBlocks(e){let t=new ki(e),i=!0,s=o=>/\\/.test(o)?(t.positionthis.parent.fontOptions.maxWdt}getLongestFit(e){let t="",i=0;for(;i0;){let o=this.getLongestFit(s);if(o===0){let r=s[0],a=this.getLongestFitWord(r);this.lines.newLine(r.slice(0,a),t),s[0]=r.slice(a)}else{let r=o;s[o-1]===" "?o--:s[r]===" "&&r++;let a=s.slice(0,o).join("");o==s.length&&i?this.lines.append(a,t):this.lines.newLine(a,t),s=s.slice(r)}}}},Ut=["bold","ital","boldital","mono"],qe=class{constructor(e,t,i=!1){this.body=e,this.pointToSelf=!1,this.baseSize=void 0,this.fontOptions={},this.setOptions(t),this.size={top:0,left:0,width:0,height:0,yLine:0},this.isEdgeLabel=i}setOptions(e){if(this.elementOptions=e,this.initFontOptions(e.font),qt(e.label)?this.labelDirty=!0:e.label=void 0,e.font!==void 0&&e.font!==null){if(typeof e.font=="string")this.baseSize=this.fontOptions.size;else if(typeof e.font=="object"){let t=e.font.size;t!==void 0&&(this.baseSize=t)}}}initFontOptions(e){if(I(Ut,t=>{this.fontOptions[t]={}}),qe.parseFontString(this.fontOptions,e)){this.fontOptions.vadjust=0;return}I(e,(t,i)=>{t!=null&&typeof t!="object"&&(this.fontOptions[i]=t)})}static parseFontString(e,t){if(!t||typeof t!="string")return!1;let i=t.split(" ");return e.size=+i[0].replace("px",""),e.face=i[1],e.color=i[2],!0}constrain(e){let t={constrainWidth:!1,maxWdt:-1,minWdt:-1,constrainHeight:!1,minHgt:-1,valign:"middle"},i=_e(e,"widthConstraint");if(typeof i=="number")t.maxWdt=Number(i),t.minWdt=Number(i);else if(typeof i=="object"){let o=_e(e,["widthConstraint","maximum"]);typeof o=="number"&&(t.maxWdt=Number(o));let r=_e(e,["widthConstraint","minimum"]);typeof r=="number"&&(t.minWdt=Number(r))}let s=_e(e,"heightConstraint");if(typeof s=="number")t.minHgt=Number(s);else if(typeof s=="object"){let o=_e(e,["heightConstraint","minimum"]);typeof o=="number"&&(t.minHgt=Number(o));let r=_e(e,["heightConstraint","valign"]);typeof r=="string"&&(r==="top"||r==="bottom")&&(t.valign=r)}return t}update(e,t){this.setOptions(e,!0),this.propagateFonts(t),D(this.fontOptions,this.constrain(t)),this.fontOptions.chooser=Ci("label",t)}adjustSizes(e){let t=e?e.right+e.left:0;this.fontOptions.constrainWidth&&(this.fontOptions.maxWdt-=t,this.fontOptions.minWdt-=t);let i=e?e.top+e.bottom:0;this.fontOptions.constrainHeight&&(this.fontOptions.minHgt-=i)}addFontOptionsToPile(e,t){for(let i=0;i{r!==void 0&&(Object.prototype.hasOwnProperty.call(t,a)||(Ut.indexOf(a)!==-1?t[a]={}:t[a]=r))})}return t}getFontOption(e,t,i){let s;for(let o=0;o{o[d]=a}),o.size=Number(o.size),o.vadjust=Number(o.vadjust)}}draw(e,t,i,s,o,r="middle"){if(this.elementOptions.label===void 0)return;let a=this.fontOptions.size*this.body.view.scale;this.elementOptions.label&&a=this.elementOptions.scaling.label.maxVisible&&(a=Number(this.elementOptions.scaling.label.maxVisible)/this.body.view.scale),this.calculateLabelSize(e,s,o,t,i,r),this._drawBackground(e),this._drawText(e,t,this.size.yLine,r,a))}_drawBackground(e){if(this.fontOptions.background!==void 0&&this.fontOptions.background!=="none"){e.fillStyle=this.fontOptions.background;let t=this.getSize();e.fillRect(t.left,t.top,t.width,t.height)}}_drawText(e,t,i,s="middle",o){[t,i]=this._setAlignment(e,t,i,s),e.textAlign="left",t=t-this.size.width/2,this.fontOptions.valign&&this.size.height>this.size.labelHeight&&(this.fontOptions.valign==="top"&&(i-=(this.size.height-this.size.labelHeight)/2),this.fontOptions.valign==="bottom"&&(i+=(this.size.height-this.size.labelHeight)/2));for(let r=0;r0&&(e.lineWidth=l.strokeWidth,e.strokeStyle=u,e.lineJoin="round"),e.fillStyle=c,l.strokeWidth>0&&e.strokeText(l.text,t+d,i+l.vadjust),e.fillText(l.text,t+d,i+l.vadjust),d+=l.width}i+=a.height}}}_setAlignment(e,t,i,s){if(this.isEdgeLabel&&this.fontOptions.align!=="horizontal"&&this.pointToSelf===!1){t=0,i=0;let o=2;this.fontOptions.align==="top"?(e.textBaseline="alphabetic",i-=2*o):this.fontOptions.align==="bottom"?(e.textBaseline="hanging",i+=2*o):e.textBaseline="middle"}else e.textBaseline=s;return[t,i]}_getColor(e,t,i){let s=e||"#000000",o=i||"#ffffff";if(t<=this.elementOptions.scaling.label.drawThreshold){let r=Math.max(0,Math.min(1,1-(this.elementOptions.scaling.label.drawThreshold-t)));s=ie(s,r),o=ie(o,r)}return[s,o]}getTextSize(e,t=!1,i=!1){return this._processLabel(e,t,i),{width:this.size.width,height:this.size.height,lineCount:this.lineCount}}getSize(){let e=2,t=this.size.left,i=this.size.top-.5*e;if(this.isEdgeLabel){let o=-this.size.width*.5;switch(this.fontOptions.align){case"middle":t=o,i=-this.size.height*.5;break;case"top":t=o,i=-(this.size.height+e);break;case"bottom":t=o,i=e;break}}return{left:t,top:i,width:this.size.width,height:this.size.height}}calculateLabelSize(e,t,i,s=0,o=0,r="middle"){this._processLabel(e,t,i),this.size.left=s-this.size.width*.5,this.size.top=o-this.size.height*.5,this.size.yLine=o+(1-this.lineCount)*.5*this.fontOptions.size,r==="hanging"&&(this.size.top+=.5*this.fontOptions.size,this.size.top+=4,this.size.yLine+=4)}getFormattingValues(e,t,i,s){let o=function(d,h,l){return h==="normal"?l==="mod"?"":d[l]:d[h][l]!==void 0?d[h][l]:d[l]},r={color:o(this.fontOptions,s,"color"),size:o(this.fontOptions,s,"size"),face:o(this.fontOptions,s,"face"),mod:o(this.fontOptions,s,"mod"),vadjust:o(this.fontOptions,s,"vadjust"),strokeWidth:this.fontOptions.strokeWidth,strokeColor:this.fontOptions.strokeColor};(t||i)&&(s==="normal"&&this.fontOptions.chooser===!0&&this.elementOptions.labelHighlightBold?r.mod="bold":typeof this.fontOptions.chooser=="function"&&this.fontOptions.chooser(r,this.elementOptions.id,t,i));let a="";return r.mod!==void 0&&r.mod!==""&&(a+=r.mod+" "),a+=r.size+"px "+r.face,e.font=a.replace(/"/g,""),r.font=e.font,r.height=r.size,r}differentState(e,t){return e!==this.selectedState||t!==this.hoverState}_processLabelText(e,t,i,s){return new mo(e,this,t,i).process(s)}_processLabel(e,t,i){if(this.labelDirty===!1&&!this.differentState(t,i))return;let s=this._processLabelText(e,t,i,this.elementOptions.label);this.fontOptions.minWdt>0&&s.width0&&s.height0&&(this.enableBorderDashes(e,t),e.stroke(),this.disableBorderDashes(e,t)),e.restore()}performFill(e,t){e.save(),e.fillStyle=t.color,this.enableShadow(e,t),e.fill(),this.disableShadow(e,t),e.restore(),this.performStroke(e,t)}_addBoundingBoxMargin(e){this.boundingBox.left-=e,this.boundingBox.top-=e,this.boundingBox.bottom+=e,this.boundingBox.right+=e}_updateBoundingBox(e,t,i,s,o){i!==void 0&&this.resize(i,s,o),this.left=e-this.width/2,this.top=t-this.height/2,this.boundingBox.left=this.left,this.boundingBox.top=this.top,this.boundingBox.bottom=this.top+this.height,this.boundingBox.right=this.left+this.width}updateBoundingBox(e,t,i,s,o){this._updateBoundingBox(e,t,i,s,o)}getDimensionsFromLabel(e,t,i){this.textSize=this.labelModule.getTextSize(e,t,i);let s=this.textSize.width,o=this.textSize.height,r=14;return s===0&&(s=r,o=r),{width:s,height:o}}},va=class extends Pe{constructor(e,t,i){super(e,t,i);this._setMargins(i)}resize(e,t=this.selected,i=this.hover){if(this.needsRefresh(t,i)){let s=this.getDimensionsFromLabel(e,t,i);this.width=s.width+this.margin.right+this.margin.left,this.height=s.height+this.margin.top+this.margin.bottom,this.radius=this.width/2}}draw(e,t,i,s,o,r){this.resize(e,s,o),this.left=t-this.width/2,this.top=i-this.height/2,this.initContextForDraw(e,r),$s(e,this.left,this.top,this.width,this.height,r.borderRadius),this.performFill(e,r),this.updateBoundingBox(t,i,e,s,o),this.labelModule.draw(e,this.left+this.textSize.width/2+this.margin.left,this.top+this.textSize.height/2+this.margin.top,s,o)}updateBoundingBox(e,t,i,s,o){this._updateBoundingBox(e,t,i,s,o);let r=this.options.shapeProperties.borderRadius;this._addBoundingBoxMargin(r)}distanceToBorder(e,t){e&&this.resize(e);let i=this.options.borderWidth;return Math.min(Math.abs(this.width/2/Math.cos(t)),Math.abs(this.height/2/Math.sin(t)))+i}},Yt=class extends Pe{constructor(e,t,i){super(e,t,i);this.labelOffset=0,this.selected=!1}setOptions(e,t,i){this.options=e,t===void 0&&i===void 0||this.setImages(t,i)}setImages(e,t){t&&this.selected?(this.imageObj=t,this.imageObjAlt=e):(this.imageObj=e,this.imageObjAlt=t)}switchImages(e){let t=e&&!this.selected||!e&&this.selected;if(this.selected=e,this.imageObjAlt!==void 0&&t){let i=this.imageObj;this.imageObj=this.imageObjAlt,this.imageObjAlt=i}}_getImagePadding(){let e={top:0,right:0,bottom:0,left:0};if(this.options.imagePadding){let t=this.options.imagePadding;typeof t=="object"?(e.top=t.top,e.right=t.right,e.bottom=t.bottom,e.left=t.left):(e.top=t,e.right=t,e.bottom=t,e.left=t)}return e}_resizeImage(){let e,t;if(this.options.shapeProperties.useImageSize===!1){let i=1,s=1;this.imageObj.width&&this.imageObj.height&&(this.imageObj.width>this.imageObj.height?i=this.imageObj.width/this.imageObj.height:s=this.imageObj.height/this.imageObj.width),e=this.options.size*2*i,t=this.options.size*2*s}else{let i=this._getImagePadding();e=this.imageObj.width+i.left+i.right,t=this.imageObj.height+i.top+i.bottom}this.width=e,this.height=t,this.radius=.5*this.width}_drawRawCircle(e,t,i,s){this.initContextForDraw(e,s),wi(e,t,i,s.size),this.performFill(e,s)}_drawImageAtPosition(e,t){if(this.imageObj.width!=0){e.globalAlpha=t.opacity!==void 0?t.opacity:1,this.enableShadow(e,t);let i=1;this.options.shapeProperties.interpolation===!0&&(i=this.imageObj.width/this.width/this.body.view.scale);let s=this._getImagePadding(),o=this.left+s.left,r=this.top+s.top,a=this.width-s.left-s.right,d=this.height-s.top-s.bottom;this.imageObj.drawImageAtPosition(e,i,o,r,a,d),this.disableShadow(e,t)}}_drawImageLabel(e,t,i,s,o){let r=0;if(this.height!==void 0){r=this.height*.5;let d=this.labelModule.getTextSize(e,s,o);d.lineCount>=1&&(r+=d.height/2)}let a=i+r;this.options.label&&(this.labelOffset=r),this.labelModule.draw(e,t,a,s,o,"hanging")}},wa=class extends Yt{constructor(e,t,i){super(e,t,i);this._setMargins(i)}resize(e,t=this.selected,i=this.hover){if(this.needsRefresh(t,i)){let s=this.getDimensionsFromLabel(e,t,i),o=Math.max(s.width+this.margin.right+this.margin.left,s.height+this.margin.top+this.margin.bottom);this.options.size=o/2,this.width=o,this.height=o,this.radius=this.width/2}}draw(e,t,i,s,o,r){this.resize(e,s,o),this.left=t-this.width/2,this.top=i-this.height/2,this._drawRawCircle(e,t,i,r),this.updateBoundingBox(t,i),this.labelModule.draw(e,this.left+this.textSize.width/2+this.margin.left,i,s,o)}updateBoundingBox(e,t){this.boundingBox.top=t-this.options.size,this.boundingBox.left=e-this.options.size,this.boundingBox.right=e+this.options.size,this.boundingBox.bottom=t+this.options.size}distanceToBorder(e){return e&&this.resize(e),this.width*.5}},yo=class extends Yt{constructor(e,t,i,s,o){super(e,t,i);this.setImages(s,o)}resize(e,t=this.selected,i=this.hover){if(this.imageObj.src===void 0||this.imageObj.width===void 0||this.imageObj.height===void 0){let o=this.options.size*2;this.width=o,this.height=o,this.radius=.5*this.width;return}this.needsRefresh(t,i)&&this._resizeImage()}draw(e,t,i,s,o,r){this.switchImages(s),this.resize();let a=t,d=i;this.options.shapeProperties.coordinateOrigin==="top-left"?(this.left=t,this.top=i,a+=this.width/2,d+=this.height/2):(this.left=t-this.width/2,this.top=i-this.height/2),this._drawRawCircle(e,a,d,r),e.save(),e.clip(),this._drawImageAtPosition(e,r),e.restore(),this._drawImageLabel(e,a,d,s,o),this.updateBoundingBox(t,i)}updateBoundingBox(e,t){this.options.shapeProperties.coordinateOrigin==="top-left"?(this.boundingBox.top=t,this.boundingBox.left=e,this.boundingBox.right=e+this.options.size*2,this.boundingBox.bottom=t+this.options.size*2):(this.boundingBox.top=t-this.options.size,this.boundingBox.left=e-this.options.size,this.boundingBox.right=e+this.options.size,this.boundingBox.bottom=t+this.options.size),this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelOffset)}distanceToBorder(e){return e&&this.resize(e),this.width*.5}},Ce=class extends Pe{constructor(e,t,i){super(e,t,i)}resize(e,t=this.selected,i=this.hover,s={size:this.options.size}){var o,r;if(this.needsRefresh(t,i)){this.labelModule.getTextSize(e,t,i);let a=2*s.size;this.width=(o=this.customSizeWidth)!=null?o:a,this.height=(r=this.customSizeHeight)!=null?r:a,this.radius=.5*this.width}}_drawShape(e,t,i,s,o,r,a,d){return this.resize(e,r,a,d),this.left=s-this.width/2,this.top=o-this.height/2,this.initContextForDraw(e,d),Xr(t)(e,s,o,d.size),this.performFill(e,d),this.options.icon!==void 0&&this.options.icon.code!==void 0&&(e.font=(r?"bold ":"")+this.height/2+"px "+(this.options.icon.face||"FontAwesome"),e.fillStyle=this.options.icon.color||"black",e.textAlign="center",e.textBaseline="middle",e.fillText(this.options.icon.code,s,o)),{drawExternalLabel:()=>{if(this.options.label!==void 0){this.labelModule.calculateLabelSize(e,r,a,s,o,"hanging");let h=o+.5*this.height+.5*this.labelModule.size.height;this.labelModule.draw(e,s,h,r,a,"hanging")}this.updateBoundingBox(s,o)}}}updateBoundingBox(e,t){this.boundingBox.top=t-this.options.size,this.boundingBox.left=e-this.options.size,this.boundingBox.right=e+this.options.size,this.boundingBox.bottom=t+this.options.size,this.options.label!==void 0&&this.labelModule.size.width>0&&(this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelModule.size.height))}},bo=class extends Ce{constructor(e,t,i,s){super(e,t,i,s);this.ctxRenderer=s}draw(e,t,i,s,o,r){this.resize(e,s,o,r),this.left=t-this.width/2,this.top=i-this.height/2,e.save();let a=this.ctxRenderer({ctx:e,id:this.options.id,x:t,y:i,state:{selected:s,hover:o},style:he({},r),label:this.options.label});if(a.drawNode!=null&&a.drawNode(),e.restore(),a.drawExternalLabel){let d=a.drawExternalLabel;a.drawExternalLabel=()=>{e.save(),d(),e.restore()}}return a.nodeDimensions&&(this.customSizeWidth=a.nodeDimensions.width,this.customSizeHeight=a.nodeDimensions.height),a}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},vo=class extends Pe{constructor(e,t,i){super(e,t,i);this._setMargins(i)}resize(e,t,i){if(this.needsRefresh(t,i)){let o=this.getDimensionsFromLabel(e,t,i).width+this.margin.right+this.margin.left;this.width=o,this.height=o,this.radius=this.width/2}}draw(e,t,i,s,o,r){this.resize(e,s,o),this.left=t-this.width/2,this.top=i-this.height/2,this.initContextForDraw(e,r),Zs(e,t-this.width/2,i-this.height/2,this.width,this.height),this.performFill(e,r),this.updateBoundingBox(t,i,e,s,o),this.labelModule.draw(e,this.left+this.textSize.width/2+this.margin.left,this.top+this.textSize.height/2+this.margin.top,s,o)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},_a=class extends Ce{constructor(e,t,i){super(e,t,i)}draw(e,t,i,s,o,r){return this._drawShape(e,"diamond",4,t,i,s,o,r)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},wo=class extends Ce{constructor(e,t,i){super(e,t,i)}draw(e,t,i,s,o,r){return this._drawShape(e,"circle",2,t,i,s,o,r)}distanceToBorder(e){return e&&this.resize(e),this.options.size}},Oi=class extends Pe{constructor(e,t,i){super(e,t,i)}resize(e,t=this.selected,i=this.hover){if(this.needsRefresh(t,i)){let s=this.getDimensionsFromLabel(e,t,i);this.height=s.height*2,this.width=s.width+s.height,this.radius=.5*this.width}}draw(e,t,i,s,o,r){this.resize(e,s,o),this.left=t-this.width*.5,this.top=i-this.height*.5,this.initContextForDraw(e,r),_i(e,this.left,this.top,this.width,this.height),this.performFill(e,r),this.updateBoundingBox(t,i,e,s,o),this.labelModule.draw(e,t,i,s,o)}distanceToBorder(e,t){e&&this.resize(e);let i=this.width*.5,s=this.height*.5,o=Math.sin(t)*i,r=Math.cos(t)*s;return i*s/Math.sqrt(o*o+r*r)}},_o=class extends Pe{constructor(e,t,i){super(e,t,i);this._setMargins(i)}resize(e,t,i){this.needsRefresh(t,i)&&(this.iconSize={width:Number(this.options.icon.size),height:Number(this.options.icon.size)},this.width=this.iconSize.width+this.margin.right+this.margin.left,this.height=this.iconSize.height+this.margin.top+this.margin.bottom,this.radius=.5*this.width)}draw(e,t,i,s,o,r){return this.resize(e,s,o),this.options.icon.size=this.options.icon.size||50,this.left=t-this.width/2,this.top=i-this.height/2,this._icon(e,t,i,s,o,r),{drawExternalLabel:()=>{if(this.options.label!==void 0){let a=5;this.labelModule.draw(e,this.left+this.iconSize.width/2+this.margin.left,i+this.height/2+a,s)}this.updateBoundingBox(t,i)}}}updateBoundingBox(e,t){if(this.boundingBox.top=t-this.options.icon.size*.5,this.boundingBox.left=e-this.options.icon.size*.5,this.boundingBox.right=e+this.options.icon.size*.5,this.boundingBox.bottom=t+this.options.icon.size*.5,this.options.label!==void 0&&this.labelModule.size.width>0){let i=5;this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelModule.size.height+i)}}_icon(e,t,i,s,o,r){let a=Number(this.options.icon.size);this.options.icon.code!==void 0?(e.font=[this.options.icon.weight!=null?this.options.icon.weight:s?"bold":"",(this.options.icon.weight!=null&&s?5:0)+a+"px",this.options.icon.face].join(" "),e.fillStyle=this.options.icon.color||"black",e.textAlign="center",e.textBaseline="middle",this.enableShadow(e,r),e.fillText(this.options.icon.code,t,i),this.disableShadow(e,r)):console.error("When using the icon shape, you need to define the code in the icon options object. This can be done per node or globally.")}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Ea=class extends Yt{constructor(e,t,i,s,o){super(e,t,i);this.setImages(s,o)}resize(e,t=this.selected,i=this.hover){if(this.imageObj.src===void 0||this.imageObj.width===void 0||this.imageObj.height===void 0){let o=this.options.size*2;this.width=o,this.height=o;return}this.needsRefresh(t,i)&&this._resizeImage()}draw(e,t,i,s,o,r){e.save(),this.switchImages(s),this.resize();let a=t,d=i;if(this.options.shapeProperties.coordinateOrigin==="top-left"?(this.left=t,this.top=i,a+=this.width/2,d+=this.height/2):(this.left=t-this.width/2,this.top=i-this.height/2),this.options.shapeProperties.useBorderWithImage===!0){let h=this.options.borderWidth,l=this.options.borderWidthSelected||2*this.options.borderWidth,c=(s?l:h)/this.body.view.scale;e.lineWidth=Math.min(this.width,c),e.beginPath();let u=s?this.options.color.highlight.border:o?this.options.color.hover.border:this.options.color.border,f=s?this.options.color.highlight.background:o?this.options.color.hover.background:this.options.color.background;r.opacity!==void 0&&(u=ie(u,r.opacity),f=ie(f,r.opacity)),e.strokeStyle=u,e.fillStyle=f,e.rect(this.left-.5*e.lineWidth,this.top-.5*e.lineWidth,this.width+e.lineWidth,this.height+e.lineWidth),e.fill(),this.performStroke(e,r),e.closePath()}this._drawImageAtPosition(e,r),this._drawImageLabel(e,a,d,s,o),this.updateBoundingBox(t,i),e.restore()}updateBoundingBox(e,t){this.resize(),this.options.shapeProperties.coordinateOrigin==="top-left"?(this.left=e,this.top=t):(this.left=e-this.width/2,this.top=t-this.height/2),this.boundingBox.left=this.left,this.boundingBox.top=this.top,this.boundingBox.bottom=this.top+this.height,this.boundingBox.right=this.left+this.width,this.options.label!==void 0&&this.labelModule.size.width>0&&(this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelOffset))}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Eo=class extends Ce{constructor(e,t,i){super(e,t,i)}draw(e,t,i,s,o,r){return this._drawShape(e,"square",2,t,i,s,o,r)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},xo=class extends Ce{constructor(e,t,i){super(e,t,i)}draw(e,t,i,s,o,r){return this._drawShape(e,"hexagon",4,t,i,s,o,r)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Co=class extends Ce{constructor(e,t,i){super(e,t,i)}draw(e,t,i,s,o,r){return this._drawShape(e,"star",4,t,i,s,o,r)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},To=class extends Pe{constructor(e,t,i){super(e,t,i);this._setMargins(i)}resize(e,t,i){this.needsRefresh(t,i)&&(this.textSize=this.labelModule.getTextSize(e,t,i),this.width=this.textSize.width+this.margin.right+this.margin.left,this.height=this.textSize.height+this.margin.top+this.margin.bottom,this.radius=.5*this.width)}draw(e,t,i,s,o,r){this.resize(e,s,o),this.left=t-this.width/2,this.top=i-this.height/2,this.enableShadow(e,r),this.labelModule.draw(e,this.left+this.textSize.width/2+this.margin.left,this.top+this.textSize.height/2+this.margin.top,s,o),this.disableShadow(e,r),this.updateBoundingBox(t,i,e,s,o)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},xa=class extends Ce{constructor(e,t,i){super(e,t,i)}draw(e,t,i,s,o,r){return this._drawShape(e,"triangle",3,t,i,s,o,r)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},ko=class extends Ce{constructor(e,t,i){super(e,t,i)}draw(e,t,i,s,o,r){return this._drawShape(e,"triangleDown",3,t,i,s,o,r)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},z=class{constructor(e,t,i,s,o,r){this.options=we(o),this.globalOptions=o,this.defaultOptions=r,this.body=t,this.edges=[],this.id=void 0,this.imagelist=i,this.grouplist=s,this.x=void 0,this.y=void 0,this.baseSize=this.options.size,this.baseFontSize=this.options.font.size,this.predefinedPosition=!1,this.selected=!1,this.hover=!1,this.labelModule=new qe(this.body,this.options,!1),this.setOptions(e)}attachEdge(e){this.edges.indexOf(e)===-1&&this.edges.push(e)}detachEdge(e){let t=this.edges.indexOf(e);t!=-1&&this.edges.splice(t,1)}setOptions(e){let t=this.options.shape;if(!e)return;if(typeof e.color!="undefined"&&(this._localColor=e.color),e.id!==void 0&&(this.id=e.id),this.id===void 0)throw new Error("Node must have an id");z.checkMass(e,this.id),e.x!==void 0&&(e.x===null?(this.x=void 0,this.predefinedPosition=!1):(this.x=parseInt(e.x),this.predefinedPosition=!0)),e.y!==void 0&&(e.y===null?(this.y=void 0,this.predefinedPosition=!1):(this.y=parseInt(e.y),this.predefinedPosition=!0)),e.size!==void 0&&(this.baseSize=e.size),e.value!==void 0&&(e.value=parseFloat(e.value)),z.parseOptions(this.options,e,!0,this.globalOptions,this.grouplist);let i=[e,this.options,this.defaultOptions];return this.chooser=Ci("node",i),this._load_images(),this.updateLabelModule(e),e.opacity!==void 0&&z.checkOpacity(e.opacity)&&(this.options.opacity=e.opacity),this.updateShape(t),e.hidden!==void 0||e.physics!==void 0}_load_images(){if((this.options.shape==="circularImage"||this.options.shape==="image")&&this.options.image===void 0)throw new Error("Option image must be defined for node type '"+this.options.shape+"'");if(this.options.image!==void 0){if(this.imagelist===void 0)throw new Error("Internal Error: No images provided");if(typeof this.options.image=="string")this.imageObj=this.imagelist.load(this.options.image,this.options.brokenImage,this.id);else{if(this.options.image.unselected===void 0)throw new Error("No unselected image provided");this.imageObj=this.imagelist.load(this.options.image.unselected,this.options.brokenImage,this.id),this.options.image.selected!==void 0?this.imageObjAlt=this.imagelist.load(this.options.image.selected,this.options.brokenImage,this.id):this.imageObjAlt=void 0}}}static checkOpacity(e){return 0<=e&&e<=1}static checkCoordinateOrigin(e){return e===void 0||e==="center"||e==="top-left"}static updateGroupOptions(e,t,i){if(i===void 0)return;let s=e.group;if(t!==void 0&&t.group!==void 0&&s!==t.group)throw new Error("updateGroupOptions: group values in options don't match.");if(!(typeof s=="number"||typeof s=="string"&&s!=""))return;let r=i.get(s);r.opacity!==void 0&&t.opacity===void 0&&(z.checkOpacity(r.opacity)||(console.error("Invalid option for node opacity. Value must be between 0 and 1, found: "+r.opacity),r.opacity=void 0));let a=Object.getOwnPropertyNames(t).filter(d=>t[d]!=null);a.push("font"),yt(a,e,r),e.color=zt(e.color)}static parseOptions(e,t,i=!1,s={},o){if(yt(["color","fixed","shadow"],e,t,i),z.checkMass(t),e.opacity!==void 0&&(z.checkOpacity(e.opacity)||(console.error("Invalid option for node opacity. Value must be between 0 and 1, found: "+e.opacity),e.opacity=void 0)),t.opacity!==void 0&&(z.checkOpacity(t.opacity)||(console.error("Invalid option for node opacity. Value must be between 0 and 1, found: "+t.opacity),t.opacity=void 0)),t.shapeProperties&&!z.checkCoordinateOrigin(t.shapeProperties.coordinateOrigin)&&console.error("Invalid option for node coordinateOrigin, found: "+t.shapeProperties.coordinateOrigin),se(e,t,"shadow",s),t.color!==void 0&&t.color!==null){let a=zt(t.color);fi(e.color,a)}else i===!0&&t.color===null&&(e.color=we(s.color));t.fixed!==void 0&&t.fixed!==null&&(typeof t.fixed=="boolean"?(e.fixed.x=t.fixed,e.fixed.y=t.fixed):(t.fixed.x!==void 0&&typeof t.fixed.x=="boolean"&&(e.fixed.x=t.fixed.x),t.fixed.y!==void 0&&typeof t.fixed.y=="boolean"&&(e.fixed.y=t.fixed.y))),i===!0&&t.font===null&&(e.font=we(s.font)),z.updateGroupOptions(e,t,o),t.scaling!==void 0&&se(e.scaling,t.scaling,"label",s.scaling)}getFormattingValues(){let e={color:this.options.color.background,opacity:this.options.opacity,borderWidth:this.options.borderWidth,borderColor:this.options.color.border,size:this.options.size,borderDashes:this.options.shapeProperties.borderDashes,borderRadius:this.options.shapeProperties.borderRadius,shadow:this.options.shadow.enabled,shadowColor:this.options.shadow.color,shadowSize:this.options.shadow.size,shadowX:this.options.shadow.x,shadowY:this.options.shadow.y};if(this.selected||this.hover?this.chooser===!0?this.selected?(this.options.borderWidthSelected!=null?e.borderWidth=this.options.borderWidthSelected:e.borderWidth*=2,e.color=this.options.color.highlight.background,e.borderColor=this.options.color.highlight.border,e.shadow=this.options.shadow.enabled):this.hover&&(e.color=this.options.color.hover.background,e.borderColor=this.options.color.hover.border,e.shadow=this.options.shadow.enabled):typeof this.chooser=="function"&&(this.chooser(e,this.options.id,this.selected,this.hover),e.shadow===!1&&(e.shadowColor!==this.options.shadow.color||e.shadowSize!==this.options.shadow.size||e.shadowX!==this.options.shadow.x||e.shadowY!==this.options.shadow.y)&&(e.shadow=!0)):e.shadow=this.options.shadow.enabled,this.options.opacity!==void 0){let t=this.options.opacity;e.borderColor=ie(e.borderColor,t),e.color=ie(e.color,t),e.shadowColor=ie(e.shadowColor,t)}return e}updateLabelModule(e){(this.options.label===void 0||this.options.label===null)&&(this.options.label=""),z.updateGroupOptions(this.options,Fe(he({},e),{color:e&&e.color||this._localColor||void 0}),this.grouplist);let t=this.grouplist.get(this.options.group,!1),i=[e,this.options,t,this.globalOptions,this.defaultOptions];this.labelModule.update(this.options,i),this.labelModule.baseSize!==void 0&&(this.baseFontSize=this.labelModule.baseSize)}updateShape(e){if(e===this.options.shape&&this.shape)this.shape.setOptions(this.options,this.imageObj,this.imageObjAlt);else switch(this.options.shape){case"box":this.shape=new va(this.options,this.body,this.labelModule);break;case"circle":this.shape=new wa(this.options,this.body,this.labelModule);break;case"circularImage":this.shape=new yo(this.options,this.body,this.labelModule,this.imageObj,this.imageObjAlt);break;case"custom":this.shape=new bo(this.options,this.body,this.labelModule,this.options.ctxRenderer);break;case"database":this.shape=new vo(this.options,this.body,this.labelModule);break;case"diamond":this.shape=new _a(this.options,this.body,this.labelModule);break;case"dot":this.shape=new wo(this.options,this.body,this.labelModule);break;case"ellipse":this.shape=new Oi(this.options,this.body,this.labelModule);break;case"icon":this.shape=new _o(this.options,this.body,this.labelModule);break;case"image":this.shape=new Ea(this.options,this.body,this.labelModule,this.imageObj,this.imageObjAlt);break;case"square":this.shape=new Eo(this.options,this.body,this.labelModule);break;case"hexagon":this.shape=new xo(this.options,this.body,this.labelModule);break;case"star":this.shape=new Co(this.options,this.body,this.labelModule);break;case"text":this.shape=new To(this.options,this.body,this.labelModule);break;case"triangle":this.shape=new xa(this.options,this.body,this.labelModule);break;case"triangleDown":this.shape=new ko(this.options,this.body,this.labelModule);break;default:this.shape=new Oi(this.options,this.body,this.labelModule);break}this.needsRefresh()}select(){this.selected=!0,this.needsRefresh()}unselect(){this.selected=!1,this.needsRefresh()}needsRefresh(){this.shape.refreshNeeded=!0}getTitle(){return this.options.title}distanceToBorder(e,t){return this.shape.distanceToBorder(e,t)}isFixed(){return this.options.fixed.x&&this.options.fixed.y}isSelected(){return this.selected}getValue(){return this.options.value}getLabelSize(){return this.labelModule.size()}setValueRange(e,t,i){if(this.options.value!==void 0){let s=this.options.scaling.customScalingFunction(e,t,i,this.options.value),o=this.options.scaling.max-this.options.scaling.min;if(this.options.scaling.label.enabled===!0){let r=this.options.scaling.label.max-this.options.scaling.label.min;this.options.font.size=this.options.scaling.label.min+s*r}this.options.size=this.options.scaling.min+s*o}else this.options.size=this.baseSize,this.options.font.size=this.baseFontSize;this.updateLabelModule()}draw(e){let t=this.getFormattingValues();return this.shape.draw(e,this.x,this.y,this.selected,this.hover,t)||{}}updateBoundingBox(e){this.shape.updateBoundingBox(this.x,this.y,e)}resize(e){let t=this.getFormattingValues();this.shape.resize(e,this.selected,this.hover,t)}getItemsOnPoint(e){let t=[];return this.labelModule.visible()&&Ti(this.labelModule.getSize(),e)&&t.push({nodeId:this.id,labelId:0}),Ti(this.shape.boundingBox,e)&&t.push({nodeId:this.id}),t}isOverlappingWith(e){return this.shape.lefte.left&&this.shape.tope.top}isBoundingBoxOverlappingWith(e){return this.shape.boundingBox.lefte.left&&this.shape.boundingBox.tope.top}static checkMass(e,t){if(e.mass!==void 0&&e.mass<=0){let i="";t!==void 0&&(i=" in node id: "+t),console.error("%cNegative or zero mass disallowed"+i+", setting mass to 1.",yi),e.mass=1}}},Oo=class{constructor(e,t,i,s){if(this.body=e,this.images=t,this.groups=i,this.layoutEngine=s,this.body.functions.createNode=this.create.bind(this),this.nodesListeners={add:(o,r)=>{this.add(r.items)},update:(o,r)=>{this.update(r.items,r.data,r.oldData)},remove:(o,r)=>{this.remove(r.items)}},this.defaultOptions={borderWidth:1,borderWidthSelected:void 0,brokenImage:void 0,color:{border:"#2B7CE9",background:"#97C2FC",highlight:{border:"#2B7CE9",background:"#D2E5FF"},hover:{border:"#2B7CE9",background:"#D2E5FF"}},opacity:void 0,fixed:{x:!1,y:!1},font:{color:"#343434",size:14,face:"arial",background:"none",strokeWidth:0,strokeColor:"#ffffff",align:"center",vadjust:0,multi:!1,bold:{mod:"bold"},boldital:{mod:"bold italic"},ital:{mod:"italic"},mono:{mod:"",size:15,face:"monospace",vadjust:2}},group:void 0,hidden:!1,icon:{face:"FontAwesome",code:void 0,size:50,color:"#2B7CE9"},image:void 0,imagePadding:{top:0,right:0,bottom:0,left:0},label:void 0,labelHighlightBold:!0,level:void 0,margin:{top:5,right:5,bottom:5,left:5},mass:1,physics:!0,scaling:{min:10,max:30,label:{enabled:!1,min:14,max:30,maxVisible:30,drawThreshold:5},customScalingFunction:function(o,r,a,d){if(r===o)return .5;{let h=1/(r-o);return Math.max(0,(d-o)*h)}}},shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:10,x:5,y:5},shape:"ellipse",shapeProperties:{borderDashes:!1,borderRadius:6,interpolation:!0,useImageSize:!1,useBorderWithImage:!1,coordinateOrigin:"center"},size:25,title:void 0,value:void 0,x:void 0,y:void 0},this.defaultOptions.mass<=0)throw"Internal error: mass in defaultOptions of NodesHandler may not be zero or negative";this.options=we(this.defaultOptions),this.bindEventListeners()}bindEventListeners(){this.body.emitter.on("refreshNodes",this.refresh.bind(this)),this.body.emitter.on("refresh",this.refresh.bind(this)),this.body.emitter.on("destroy",()=>{I(this.nodesListeners,(e,t)=>{this.body.data.nodes&&this.body.data.nodes.off(t,e)}),delete this.body.functions.createNode,delete this.nodesListeners.add,delete this.nodesListeners.update,delete this.nodesListeners.remove,delete this.nodesListeners})}setOptions(e){if(e!==void 0){if(z.parseOptions(this.options,e),e.opacity!==void 0&&(Number.isNaN(e.opacity)||!Number.isFinite(e.opacity)||e.opacity<0||e.opacity>1?console.error("Invalid option for node opacity. Value must be between 0 and 1, found: "+e.opacity):this.options.opacity=e.opacity),e.shape!==void 0)for(let t in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,t)&&this.body.nodes[t].updateShape();if(typeof e.font!="undefined"||typeof e.widthConstraint!="undefined"||typeof e.heightConstraint!="undefined")for(let t of Object.keys(this.body.nodes))this.body.nodes[t].updateLabelModule(),this.body.nodes[t].needsRefresh();if(e.size!==void 0)for(let t in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,t)&&this.body.nodes[t].needsRefresh();(e.hidden!==void 0||e.physics!==void 0)&&this.body.emitter.emit("_dataChanged")}}setData(e,t=!1){let i=this.body.data.nodes;if(vi("id",e))this.body.data.nodes=e;else if(Array.isArray(e))this.body.data.nodes=new xe,this.body.data.nodes.add(e);else if(!e)this.body.data.nodes=new xe;else throw new TypeError("Array or DataSet expected");if(i&&I(this.nodesListeners,function(s,o){i.off(o,s)}),this.body.nodes={},this.body.data.nodes){let s=this;I(this.nodesListeners,function(r,a){s.body.data.nodes.on(a,r)});let o=this.body.data.nodes.getIds();this.add(o,!0)}t===!1&&this.body.emitter.emit("_dataChanged")}add(e,t=!1){let i,s=[];for(let o=0;o{let s=this.body.data.nodes.get(i);s!==void 0&&(e===!0&&t.setOptions({x:null,y:null}),t.setOptions({fixed:!1}),t.setOptions(s))})}getPositions(e){let t={};if(e!==void 0){if(Array.isArray(e)===!0){for(let i=0;i{this.body.emitter.emit("startSimulation")},0)):console.error("Node id supplied to moveNode does not exist. Provided: ",e)}},H=class{static transform(e,t){Array.isArray(e)||(e=[e]);let i=t.point.x,s=t.point.y,o=t.angle,r=t.length;for(let a=0;a0?d>0?r=f:a=f:d>0?a=f:r=f,++m}while(r<=a&&m1?l=1:l<0&&(l=0);let c=e+l*a,u=t+l*d,f=c-o,p=u-r;return Math.sqrt(f*f+p*p)}getArrowData(e,t,i,s,o,r){let a,d,h,l,c,u,f,p=r.width;t==="from"?(h=this.from,l=this.to,c=r.fromArrowScale<0,u=Math.abs(r.fromArrowScale),f=r.fromArrowType):t==="to"?(h=this.to,l=this.from,c=r.toArrowScale<0,u=Math.abs(r.toArrowScale),f=r.toArrowType):(h=this.to,l=this.from,c=r.middleArrowScale<0,u=Math.abs(r.middleArrowScale),f=r.middleArrowType);let m=15*u+3*p;if(h!=l){let E=Math.hypot(h.x-l.x,h.y-l.y),C=m/E;if(t!=="middle")if(this.options.smooth.enabled===!0){let O=this._findBorderPosition(h,e,{via:i}),S=this.getPoint(O.t+C*(t==="from"?1:-1),i);a=Math.atan2(O.y-S.y,O.x-S.x),d=O}else a=Math.atan2(h.y-l.y,h.x-l.x),d=this._findBorderPosition(h,e);else{let O=(c?-C:C)/2,S=this.getPoint(.5+O,i),M=this.getPoint(.5-O,i);a=Math.atan2(S.y-M.y,S.x-M.x),d=this.getPoint(.5,i)}}else{let[E,C,O]=this._getCircleData(e);if(t==="from"){let S=this.options.selfReference.angle,M=this.options.selfReference.angle+Math.PI,R=this._findBorderPositionCircle(this.from,e,{x:E,y:C,low:S,high:M,direction:-1});a=R.t*-2*Math.PI+1.5*Math.PI+.1*Math.PI,d=R}else if(t==="to"){let S=this.options.selfReference.angle,M=this.options.selfReference.angle+Math.PI,R=this._findBorderPositionCircle(this.from,e,{x:E,y:C,low:S,high:M,direction:1});a=R.t*-2*Math.PI+1.5*Math.PI-1.1*Math.PI,d=R}else{let S=this.options.selfReference.angle/(2*Math.PI);d=this._pointOnCircle(E,C,O,S),a=S*-2*Math.PI+1.5*Math.PI+.1*Math.PI}}let g=d.x-m*.9*Math.cos(a),b=d.y-m*.9*Math.sin(a);return{point:d,core:{x:g,y:b},angle:a,length:m,type:f}}drawArrowHead(e,t,i,s,o){e.strokeStyle=this.getColor(e,t),e.fillStyle=e.strokeStyle,e.lineWidth=t.width,Si.draw(e,o)&&(this.enableShadow(e,t),e.fill(),this.disableShadow(e,t))}enableShadow(e,t){t.shadow===!0&&(e.shadowColor=t.shadowColor,e.shadowBlur=t.shadowSize,e.shadowOffsetX=t.shadowX,e.shadowOffsetY=t.shadowY)}disableShadow(e,t){t.shadow===!0&&(e.shadowColor="rgba(0,0,0,0)",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0)}drawBackground(e,t){if(t.background!==!1){let i={strokeStyle:e.strokeStyle,lineWidth:e.lineWidth,dashes:e.dashes};e.strokeStyle=t.backgroundColor,e.lineWidth=t.backgroundSize,this.setStrokeDashed(e,t.backgroundDashes),e.stroke(),e.strokeStyle=i.strokeStyle,e.lineWidth=i.lineWidth,e.dashes=i.dashes,this.setStrokeDashed(e,t.dashes)}}setStrokeDashed(e,t){if(t!==!1)if(e.setLineDash!==void 0){let i=Array.isArray(t)?t:[5,5];e.setLineDash(i)}else console.warn("setLineDash is not supported in this browser. The dashed stroke cannot be used.");else e.setLineDash!==void 0?e.setLineDash([]):console.warn("setLineDash is not supported in this browser. The dashed stroke cannot be used.")}},Xt=class extends Ii{constructor(e,t,i){super(e,t,i)}_findBorderPositionBezier(e,t,i=this._getViaCoordinates()){let s=10,o=.2,r=!1,a=1,d=0,h=this.to,l,c,u=this.options.endPointOffset?this.options.endPointOffset.to:0;e.id===this.from.id&&(h=this.from,r=!0,u=this.options.endPointOffset?this.options.endPointOffset.from:0),this.options.arrowStrikethrough===!1&&(u=0);let f=0;do{c=(d+a)*.5,l=this.getPoint(c,i);let p=Math.atan2(h.y-l.y,h.x-l.x),m=h.distanceToBorder(t,p)+u,g=Math.sqrt(Math.pow(l.x-h.x,2)+Math.pow(l.y-h.y,2)),b=m-g;if(Math.abs(b)0&&(h=this._getDistanceToLine(p,m,u,f,o,r),d=h{this.positionBezierNode()},this._body.emitter.on("_repositionBezierNodes",this._boundFunction)}setOptions(e){super.setOptions(e);let t=!1;this.options.physics!==e.physics&&(t=!0),this.options=e,this.id=this.options.id,this.from=this._body.nodes[this.options.from],this.to=this._body.nodes[this.options.to],this.setupSupportNode(),this.connect(),t===!0&&(this.via.setOptions({physics:this.options.physics}),this.positionBezierNode())}connect(){this.from=this._body.nodes[this.options.from],this.to=this._body.nodes[this.options.to],this.from===void 0||this.to===void 0||this.options.physics===!1?this.via.setOptions({physics:!1}):this.from.id===this.to.id?this.via.setOptions({physics:!1}):this.via.setOptions({physics:!0})}cleanup(){return this._body.emitter.off("_repositionBezierNodes",this._boundFunction),this.via!==void 0?(delete this._body.nodes[this.via.id],this.via=void 0,!0):!1}setupSupportNode(){if(this.via===void 0){let e="edgeId:"+this.id,t=this._body.functions.createNode({id:e,shape:"circle",physics:!0,hidden:!0});this._body.nodes[e]=t,this.via=t,this.via.parentEdgeId=this.id,this.positionBezierNode()}}positionBezierNode(){this.via!==void 0&&this.from!==void 0&&this.to!==void 0?(this.via.x=.5*(this.from.x+this.to.x),this.via.y=.5*(this.from.y+this.to.y)):this.via!==void 0&&(this.via.x=0,this.via.y=0)}_line(e,t,i){this._bezierCurve(e,t,i)}_getViaCoordinates(){return this.via}getViaNode(){return this.via}getPoint(e,t=this.via){if(this.from===this.to){let[i,s,o]=this._getCircleData(),r=2*Math.PI*(1-e);return{x:i+o*Math.sin(r),y:s+o-o*(1-Math.cos(r))}}else return{x:Math.pow(1-e,2)*this.fromPoint.x+2*e*(1-e)*t.x+Math.pow(e,2)*this.toPoint.x,y:Math.pow(1-e,2)*this.fromPoint.y+2*e*(1-e)*t.y+Math.pow(e,2)*this.toPoint.y}}_findBorderPosition(e,t){return this._findBorderPositionBezier(e,t,this.via)}_getDistanceToEdge(e,t,i,s,o,r){return this._getDistanceToBezierEdge(e,t,i,s,o,r,this.via)}},Mi=class extends Xt{constructor(e,t,i){super(e,t,i)}_line(e,t,i){this._bezierCurve(e,t,i)}getViaNode(){return this._getViaCoordinates()}_getViaCoordinates(){let e=this.options.smooth.roundness,t=this.options.smooth.type,i=Math.abs(this.from.x-this.to.x),s=Math.abs(this.from.y-this.to.y);if(t==="discrete"||t==="diagonalCross"){let o,r;i<=s?o=r=e*s:o=r=e*i,this.from.x>this.to.x&&(o=-o),this.from.y>=this.to.y&&(r=-r);let a=this.from.x+o,d=this.from.y+r;return t==="discrete"&&(i<=s?a=ithis.to.x&&(o=-o),this.from.y>=this.to.y&&(r=-r);let a=this.from.x+o,d=this.from.y+r;return i<=s?this.from.x<=this.to.x?a=this.to.xa?this.to.x:a:this.from.y>=this.to.y?d=this.to.y>d?this.to.y:d:d=this.to.y0){let b=this._getDistanceToLine(l,c,m,g,o,r);h=bMath.abs(t)||this.options.smooth.forceDirection===!0||this.options.smooth.forceDirection==="horizontal")&&this.options.smooth.forceDirection!=="vertical"?(s=this.from.y,r=this.to.y,i=this.from.x-a*e,o=this.to.x+a*e):(s=this.from.y-a*t,r=this.to.y+a*t,i=this.from.x,o=this.to.x),[{x:i,y:s},{x:o,y:r}]}getViaNode(){return this._getViaCoordinates()}_findBorderPosition(e,t){return this._findBorderPositionBezier(e,t)}_getDistanceToEdge(e,t,i,s,o,r,[a,d]=this._getViaCoordinates()){return this._getDistanceToBezierEdge2(e,t,i,s,o,r,a,d)}getPoint(e,[t,i]=this._getViaCoordinates()){let s=e,o=[Math.pow(1-s,3),3*s*Math.pow(1-s,2),3*Math.pow(s,2)*(1-s),Math.pow(s,3)],r=o[0]*this.fromPoint.x+o[1]*t.x+o[2]*i.x+o[3]*this.toPoint.x,a=o[0]*this.fromPoint.y+o[1]*t.y+o[2]*i.y+o[3]*this.toPoint.y;return{x:r,y:a}}},Fi=class extends Ii{constructor(e,t,i){super(e,t,i)}_line(e,t){e.beginPath(),e.moveTo(this.fromPoint.x,this.fromPoint.y),e.lineTo(this.toPoint.x,this.toPoint.y),this.enableShadow(e,t),e.stroke(),this.disableShadow(e,t)}getViaNode(){}getPoint(e){return{x:(1-e)*this.fromPoint.x+e*this.toPoint.x,y:(1-e)*this.fromPoint.y+e*this.toPoint.y}}_findBorderPosition(e,t){let i=this.to,s=this.from;e.id===this.from.id&&(i=this.from,s=this.to);let o=Math.atan2(i.y-s.y,i.x-s.x),r=i.x-s.x,a=i.y-s.y,d=Math.sqrt(r*r+a*a),h=e.distanceToBorder(t,o),l=(d-h)/d;return{x:(1-l)*s.x+l*i.x,y:(1-l)*s.y+l*i.y,t:0}}_getDistanceToEdge(e,t,i,s,o,r){return this._getDistanceToLine(e,t,i,s,o,r)}},Te=class{constructor(e,t,i,s,o){if(t===void 0)throw new Error("No body provided");this.options=we(s),this.globalOptions=s,this.defaultOptions=o,this.body=t,this.imagelist=i,this.id=void 0,this.fromId=void 0,this.toId=void 0,this.selected=!1,this.hover=!1,this.labelDirty=!0,this.baseWidth=this.options.width,this.baseFontSize=this.options.font.size,this.from=void 0,this.to=void 0,this.edgeType=void 0,this.connected=!1,this.labelModule=new qe(this.body,this.options,!0),this.setOptions(e)}setOptions(e){if(!e)return;let t=typeof e.physics!="undefined"&&this.options.physics!==e.physics||typeof e.hidden!="undefined"&&(this.options.hidden||!1)!==(e.hidden||!1)||typeof e.from!="undefined"&&this.options.from!==e.from||typeof e.to!="undefined"&&this.options.to!==e.to;Te.parseOptions(this.options,e,!0,this.globalOptions),e.id!==void 0&&(this.id=e.id),e.from!==void 0&&(this.fromId=e.from),e.to!==void 0&&(this.toId=e.to),e.title!==void 0&&(this.title=e.title),e.value!==void 0&&(e.value=parseFloat(e.value));let i=[e,this.options,this.defaultOptions];return this.chooser=Ci("edge",i),this.updateLabelModule(e),t=this.updateEdgeType()||t,this._setInteractionWidths(),this.connect(),t}static parseOptions(e,t,i=!1,s={},o=!1){if(We(["endPointOffset","arrowStrikethrough","id","from","hidden","hoverWidth","labelHighlightBold","length","line","opacity","physics","scaling","selectionWidth","selfReferenceSize","selfReference","to","title","value","width","font","chosen","widthConstraint"],e,t,i),t.endPointOffset!==void 0&&t.endPointOffset.from!==void 0&&(Number.isFinite(t.endPointOffset.from)?e.endPointOffset.from=t.endPointOffset.from:(e.endPointOffset.from=s.endPointOffset.from!==void 0?s.endPointOffset.from:0,console.error("endPointOffset.from is not a valid number"))),t.endPointOffset!==void 0&&t.endPointOffset.to!==void 0&&(Number.isFinite(t.endPointOffset.to)?e.endPointOffset.to=t.endPointOffset.to:(e.endPointOffset.to=s.endPointOffset.to!==void 0?s.endPointOffset.to:0,console.error("endPointOffset.to is not a valid number"))),qt(t.label)?e.label=t.label:qt(e.label)||(e.label=void 0),se(e,t,"smooth",s),se(e,t,"shadow",s),se(e,t,"background",s),t.dashes!==void 0&&t.dashes!==null?e.dashes=t.dashes:i===!0&&t.dashes===null&&(e.dashes=Object.create(s.dashes)),t.scaling!==void 0&&t.scaling!==null?(t.scaling.min!==void 0&&(e.scaling.min=t.scaling.min),t.scaling.max!==void 0&&(e.scaling.max=t.scaling.max),se(e.scaling,t.scaling,"label",s.scaling)):i===!0&&t.scaling===null&&(e.scaling=Object.create(s.scaling)),t.arrows!==void 0&&t.arrows!==null)if(typeof t.arrows=="string"){let a=t.arrows.toLowerCase();e.arrows.to.enabled=a.indexOf("to")!=-1,e.arrows.middle.enabled=a.indexOf("middle")!=-1,e.arrows.from.enabled=a.indexOf("from")!=-1}else if(typeof t.arrows=="object")se(e.arrows,t.arrows,"to",s.arrows),se(e.arrows,t.arrows,"middle",s.arrows),se(e.arrows,t.arrows,"from",s.arrows);else throw new Error("The arrow newOptions can only be an object or a string. Refer to the documentation. You used:"+JSON.stringify(t.arrows));else i===!0&&t.arrows===null&&(e.arrows=Object.create(s.arrows));if(t.color!==void 0&&t.color!==null){let a=ve(t.color)?{color:t.color,highlight:t.color,hover:t.color,inherit:!1,opacity:1}:t.color,d=e.color;if(o)D(d,s.color,!1,i);else for(let h in d)Object.prototype.hasOwnProperty.call(d,h)&&delete d[h];if(ve(d))d.color=d,d.highlight=d,d.hover=d,d.inherit=!1,a.opacity===void 0&&(d.opacity=1);else{let h=!1;a.color!==void 0&&(d.color=a.color,h=!0),a.highlight!==void 0&&(d.highlight=a.highlight,h=!0),a.hover!==void 0&&(d.hover=a.hover,h=!0),a.inherit!==void 0&&(d.inherit=a.inherit),a.opacity!==void 0&&(d.opacity=Math.min(1,Math.max(0,a.opacity))),h===!0?d.inherit=!1:d.inherit===void 0&&(d.inherit="from")}}else i===!0&&t.color===null&&(e.color=we(s.color));i===!0&&t.font===null&&(e.font=we(s.font)),Object.prototype.hasOwnProperty.call(t,"selfReferenceSize")&&(console.warn("The selfReferenceSize property has been deprecated. Please use selfReference property instead. The selfReference can be set like thise selfReference:{size:30, angle:Math.PI / 4}"),e.selfReference.size=t.selfReferenceSize)}getFormattingValues(){let e=this.options.arrows.to===!0||this.options.arrows.to.enabled===!0,t=this.options.arrows.from===!0||this.options.arrows.from.enabled===!0,i=this.options.arrows.middle===!0||this.options.arrows.middle.enabled===!0,s=this.options.color.inherit,o={toArrow:e,toArrowScale:this.options.arrows.to.scaleFactor,toArrowType:this.options.arrows.to.type,toArrowSrc:this.options.arrows.to.src,toArrowImageWidth:this.options.arrows.to.imageWidth,toArrowImageHeight:this.options.arrows.to.imageHeight,middleArrow:i,middleArrowScale:this.options.arrows.middle.scaleFactor,middleArrowType:this.options.arrows.middle.type,middleArrowSrc:this.options.arrows.middle.src,middleArrowImageWidth:this.options.arrows.middle.imageWidth,middleArrowImageHeight:this.options.arrows.middle.imageHeight,fromArrow:t,fromArrowScale:this.options.arrows.from.scaleFactor,fromArrowType:this.options.arrows.from.type,fromArrowSrc:this.options.arrows.from.src,fromArrowImageWidth:this.options.arrows.from.imageWidth,fromArrowImageHeight:this.options.arrows.from.imageHeight,arrowStrikethrough:this.options.arrowStrikethrough,color:s?void 0:this.options.color.color,inheritsColor:s,opacity:this.options.color.opacity,hidden:this.options.hidden,length:this.options.length,shadow:this.options.shadow.enabled,shadowColor:this.options.shadow.color,shadowSize:this.options.shadow.size,shadowX:this.options.shadow.x,shadowY:this.options.shadow.y,dashes:this.options.dashes,width:this.options.width,background:this.options.background.enabled,backgroundColor:this.options.background.color,backgroundSize:this.options.background.size,backgroundDashes:this.options.background.dashes};if(this.selected||this.hover)if(this.chooser===!0){if(this.selected){let r=this.options.selectionWidth;typeof r=="function"?o.width=r(o.width):typeof r=="number"&&(o.width+=r),o.width=Math.max(o.width,.3/this.body.view.scale),o.color=this.options.color.highlight,o.shadow=this.options.shadow.enabled}else if(this.hover){let r=this.options.hoverWidth;typeof r=="function"?o.width=r(o.width):typeof r=="number"&&(o.width+=r),o.width=Math.max(o.width,.3/this.body.view.scale),o.color=this.options.color.hover,o.shadow=this.options.shadow.enabled}}else typeof this.chooser=="function"&&(this.chooser(o,this.options.id,this.selected,this.hover),o.color!==void 0&&(o.inheritsColor=!1),o.shadow===!1&&(o.shadowColor!==this.options.shadow.color||o.shadowSize!==this.options.shadow.size||o.shadowX!==this.options.shadow.x||o.shadowY!==this.options.shadow.y)&&(o.shadow=!0));else o.shadow=this.options.shadow.enabled,o.width=Math.max(o.width,.3/this.body.view.scale);return o}updateLabelModule(e){let t=[e,this.options,this.globalOptions,this.defaultOptions];this.labelModule.update(this.options,t),this.labelModule.baseSize!==void 0&&(this.baseFontSize=this.labelModule.baseSize)}updateEdgeType(){let e=this.options.smooth,t=!1,i=!0;return this.edgeType!==void 0&&((this.edgeType instanceof Pi&&e.enabled===!0&&e.type==="dynamic"||this.edgeType instanceof Di&&e.enabled===!0&&e.type==="cubicBezier"||this.edgeType instanceof Mi&&e.enabled===!0&&e.type!=="dynamic"&&e.type!=="cubicBezier"||this.edgeType instanceof Fi&&e.type.enabled===!1)&&(i=!1),i===!0&&(t=this.cleanup())),i===!0?e.enabled===!0?e.type==="dynamic"?(t=!0,this.edgeType=new Pi(this.options,this.body,this.labelModule)):e.type==="cubicBezier"?this.edgeType=new Di(this.options,this.body,this.labelModule):this.edgeType=new Mi(this.options,this.body,this.labelModule):this.edgeType=new Fi(this.options,this.body,this.labelModule):this.edgeType.setOptions(this.options),t}connect(){this.disconnect(),this.from=this.body.nodes[this.fromId]||void 0,this.to=this.body.nodes[this.toId]||void 0,this.connected=this.from!==void 0&&this.to!==void 0,this.connected===!0?(this.from.attachEdge(this),this.to.attachEdge(this)):(this.from&&this.from.detachEdge(this),this.to&&this.to.detachEdge(this)),this.edgeType.connect()}disconnect(){this.from&&(this.from.detachEdge(this),this.from=void 0),this.to&&(this.to.detachEdge(this),this.to=void 0),this.connected=!1}getTitle(){return this.title}isSelected(){return this.selected}getValue(){return this.options.value}setValueRange(e,t,i){if(this.options.value!==void 0){let s=this.options.scaling.customScalingFunction(e,t,i,this.options.value),o=this.options.scaling.max-this.options.scaling.min;if(this.options.scaling.label.enabled===!0){let r=this.options.scaling.label.max-this.options.scaling.label.min;this.options.font.size=this.options.scaling.label.min+s*r}this.options.width=this.options.scaling.min+s*o}else this.options.width=this.baseWidth,this.options.font.size=this.baseFontSize;this._setInteractionWidths(),this.updateLabelModule()}_setInteractionWidths(){typeof this.options.hoverWidth=="function"?this.edgeType.hoverWidth=this.options.hoverWidth(this.options.width):this.edgeType.hoverWidth=this.options.hoverWidth+this.options.width,typeof this.options.selectionWidth=="function"?this.edgeType.selectionWidth=this.options.selectionWidth(this.options.width):this.edgeType.selectionWidth=this.options.selectionWidth+this.options.width}draw(e){let t=this.getFormattingValues();if(t.hidden)return;let i=this.edgeType.getViaNode();this.edgeType.drawLine(e,t,this.selected,this.hover,i),this.drawLabel(e,i)}drawArrows(e){let t=this.getFormattingValues();if(t.hidden)return;let i=this.edgeType.getViaNode(),s={};this.edgeType.fromPoint=this.edgeType.from,this.edgeType.toPoint=this.edgeType.to,t.fromArrow&&(s.from=this.edgeType.getArrowData(e,"from",i,this.selected,this.hover,t),t.arrowStrikethrough===!1&&(this.edgeType.fromPoint=s.from.core),t.fromArrowSrc&&(s.from.image=this.imagelist.load(t.fromArrowSrc)),t.fromArrowImageWidth&&(s.from.imageWidth=t.fromArrowImageWidth),t.fromArrowImageHeight&&(s.from.imageHeight=t.fromArrowImageHeight)),t.toArrow&&(s.to=this.edgeType.getArrowData(e,"to",i,this.selected,this.hover,t),t.arrowStrikethrough===!1&&(this.edgeType.toPoint=s.to.core),t.toArrowSrc&&(s.to.image=this.imagelist.load(t.toArrowSrc)),t.toArrowImageWidth&&(s.to.imageWidth=t.toArrowImageWidth),t.toArrowImageHeight&&(s.to.imageHeight=t.toArrowImageHeight)),t.middleArrow&&(s.middle=this.edgeType.getArrowData(e,"middle",i,this.selected,this.hover,t),t.middleArrowSrc&&(s.middle.image=this.imagelist.load(t.middleArrowSrc)),t.middleArrowImageWidth&&(s.middle.imageWidth=t.middleArrowImageWidth),t.middleArrowImageHeight&&(s.middle.imageHeight=t.middleArrowImageHeight)),t.fromArrow&&this.edgeType.drawArrowHead(e,t,this.selected,this.hover,s.from),t.middleArrow&&this.edgeType.drawArrowHead(e,t,this.selected,this.hover,s.middle),t.toArrow&&this.edgeType.drawArrowHead(e,t,this.selected,this.hover,s.to)}drawLabel(e,t){if(this.options.label!==void 0){let i=this.from,s=this.to;this.labelModule.differentState(this.selected,this.hover)&&this.labelModule.getTextSize(e,this.selected,this.hover);let o;if(i.id!=s.id){this.labelModule.pointToSelf=!1,o=this.edgeType.getPoint(.5,t),e.save();let r=this._getRotation(e);r.angle!=0&&(e.translate(r.x,r.y),e.rotate(r.angle)),this.labelModule.draw(e,o.x,o.y,this.selected,this.hover),e.restore()}else{this.labelModule.pointToSelf=!0;let r=po(e,this.options.selfReference.angle,this.options.selfReference.size,i);o=this._pointOnCircle(r.x,r.y,this.options.selfReference.size,this.options.selfReference.angle),this.labelModule.draw(e,o.x,o.y,this.selected,this.hover)}}}getItemsOnPoint(e){let t=[];if(this.labelModule.visible()){let s=this._getRotation();Ti(this.labelModule.getSize(),e,s)&&t.push({edgeId:this.id,labelId:0})}let i={left:e.x,top:e.y};return this.isOverlappingWith(i)&&t.push({edgeId:this.id}),t}isOverlappingWith(e){if(this.connected){let t=10,i=this.from.x,s=this.from.y,o=this.to.x,r=this.to.y,a=e.left,d=e.top;return this.edgeType.getDistanceToEdge(i,s,o,r,a,d)0&&r<0)&&(a+=Math.PI),s.angle=a,s}_pointOnCircle(e,t,i,s){return{x:e+i*Math.cos(s),y:t-i*Math.sin(s)}}select(){this.selected=!0}unselect(){this.selected=!1}cleanup(){return this.edgeType.cleanup()}remove(){this.cleanup(),this.disconnect(),delete this.body.edges[this.id]}endPointsValid(){return this.body.nodes[this.fromId]!==void 0&&this.body.nodes[this.toId]!==void 0}},Ho=class{constructor(e,t,i){this.body=e,this.images=t,this.groups=i,this.body.functions.createEdge=this.create.bind(this),this.edgesListeners={add:(s,o)=>{this.add(o.items)},update:(s,o)=>{this.update(o.items)},remove:(s,o)=>{this.remove(o.items)}},this.options={},this.defaultOptions={arrows:{to:{enabled:!1,scaleFactor:1,type:"arrow"},middle:{enabled:!1,scaleFactor:1,type:"arrow"},from:{enabled:!1,scaleFactor:1,type:"arrow"}},endPointOffset:{from:0,to:0},arrowStrikethrough:!0,color:{color:"#848484",highlight:"#848484",hover:"#848484",inherit:"from",opacity:1},dashes:!1,font:{color:"#343434",size:14,face:"arial",background:"none",strokeWidth:2,strokeColor:"#ffffff",align:"horizontal",multi:!1,vadjust:0,bold:{mod:"bold"},boldital:{mod:"bold italic"},ital:{mod:"italic"},mono:{mod:"",size:15,face:"courier new",vadjust:2}},hidden:!1,hoverWidth:1.5,label:void 0,labelHighlightBold:!0,length:void 0,physics:!0,scaling:{min:1,max:15,label:{enabled:!0,min:14,max:30,maxVisible:30,drawThreshold:5},customScalingFunction:function(s,o,r,a){if(o===s)return .5;{let d=1/(o-s);return Math.max(0,(a-s)*d)}}},selectionWidth:1.5,selfReference:{size:20,angle:Math.PI/4,renderBehindTheNode:!0},shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:10,x:5,y:5},background:{enabled:!1,color:"rgba(111,111,111,1)",size:10,dashes:!1},smooth:{enabled:!0,type:"dynamic",forceDirection:"none",roundness:.5},title:void 0,width:1,value:void 0},D(this.options,this.defaultOptions),this.bindEventListeners()}bindEventListeners(){this.body.emitter.on("_forceDisableDynamicCurves",(e,t=!0)=>{e==="dynamic"&&(e="continuous");let i=!1;for(let s in this.body.edges)if(Object.prototype.hasOwnProperty.call(this.body.edges,s)){let o=this.body.edges[s],r=this.body.data.edges.get(s);if(r!=null){let a=r.smooth;a!==void 0&&a.enabled===!0&&a.type==="dynamic"&&(e===void 0?o.setOptions({smooth:!1}):o.setOptions({smooth:{type:e}}),i=!0)}}t===!0&&i===!0&&this.body.emitter.emit("_dataChanged")}),this.body.emitter.on("_dataUpdated",()=>{this.reconnectEdges()}),this.body.emitter.on("refreshEdges",this.refresh.bind(this)),this.body.emitter.on("refresh",this.refresh.bind(this)),this.body.emitter.on("destroy",()=>{I(this.edgesListeners,(e,t)=>{this.body.data.edges&&this.body.data.edges.off(t,e)}),delete this.body.functions.createEdge,delete this.edgesListeners.add,delete this.edgesListeners.update,delete this.edgesListeners.remove,delete this.edgesListeners})}setOptions(e){if(e!==void 0){Te.parseOptions(this.options,e,!0,this.defaultOptions,!0);let t=!1;if(e.smooth!==void 0)for(let i in this.body.edges)Object.prototype.hasOwnProperty.call(this.body.edges,i)&&(t=this.body.edges[i].updateEdgeType()||t);if(e.font!==void 0)for(let i in this.body.edges)Object.prototype.hasOwnProperty.call(this.body.edges,i)&&this.body.edges[i].updateLabelModule();(e.hidden!==void 0||e.physics!==void 0||t===!0)&&this.body.emitter.emit("_dataChanged")}}setData(e,t=!1){let i=this.body.data.edges;if(vi("id",e))this.body.data.edges=e;else if(Array.isArray(e))this.body.data.edges=new xe,this.body.data.edges.add(e);else if(!e)this.body.data.edges=new xe;else throw new TypeError("Array or DataSet expected");if(i&&I(this.edgesListeners,(s,o)=>{i.off(o,s)}),this.body.edges={},this.body.data.edges){I(this.edgesListeners,(o,r)=>{this.body.data.edges.on(r,o)});let s=this.body.data.edges.getIds();this.add(s,!0)}this.body.emitter.emit("_adjustEdgesForHierarchicalLayout"),t===!1&&this.body.emitter.emit("_dataChanged")}add(e,t=!1){let i=this.body.edges,s=this.body.data.edges;for(let o=0;o{let o=i[s];o!==void 0&&o.remove()}),t&&this.body.emitter.emit("_dataChanged")}refresh(){I(this.body.edges,(e,t)=>{let i=this.body.data.edges.get(t);i!==void 0&&e.setOptions(i)})}create(e){return new Te(e,this.body,this.images,this.options,this.defaultOptions)}reconnectEdges(){let e,t=this.body.nodes,i=this.body.edges;for(e in t)Object.prototype.hasOwnProperty.call(t,e)&&(t[e].edges=[]);for(e in i)if(Object.prototype.hasOwnProperty.call(i,e)){let s=i[e];s.from=null,s.to=null,s.connect()}}getConnectedNodes(e){let t=[];if(this.body.edges[e]!==void 0){let i=this.body.edges[e];i.fromId!==void 0&&t.push(i.fromId),i.toId!==void 0&&t.push(i.toId)}return t}_updateState(){this._addMissingEdges(),this._removeInvalidEdges()}_removeInvalidEdges(){let e=[];I(this.body.edges,(t,i)=>{let s=this.body.nodes[t.toId],o=this.body.nodes[t.fromId];s!==void 0&&s.isCluster===!0||o!==void 0&&o.isCluster===!0||(s===void 0||o===void 0)&&e.push(i)}),this.remove(e,!1)}_addMissingEdges(){let e=this.body.data.edges;if(e==null)return;let t=this.body.edges,i=[];e.forEach((s,o)=>{t[o]===void 0&&i.push(o)}),this.add(i,!0)}},Ni=class{constructor(e,t,i){this.body=e,this.physicsBody=t,this.barnesHutTree,this.setOptions(i),this._rng=mt("BARNES HUT SOLVER")}setOptions(e){this.options=e,this.thetaInversed=1/this.options.theta,this.overlapAvoidanceFactor=1-Math.max(0,Math.min(1,this.options.avoidOverlap))}solve(){if(this.options.gravitationalConstant!==0&&this.physicsBody.physicsNodeIndices.length>0){let e,t=this.body.nodes,i=this.physicsBody.physicsNodeIndices,s=i.length,o=this._formBarnesHutTree(t,i);this.barnesHutTree=o;for(let r=0;r0&&this._getForceContributions(o.root,e)}}_getForceContributions(e,t){this._getForceContribution(e.children.NW,t),this._getForceContribution(e.children.NE,t),this._getForceContribution(e.children.SW,t),this._getForceContribution(e.children.SE,t)}_getForceContribution(e,t){if(e.childrenCount>0){let i=e.centerOfMass.x-t.x,s=e.centerOfMass.y-t.y,o=Math.sqrt(i*i+s*s);o*e.calcSize>this.thetaInversed?this._calculateForces(o,i,s,t,e):e.childrenCount===4?this._getForceContributions(e,t):e.children.data.id!=t.id&&this._calculateForces(o,i,s,t,e)}}_calculateForces(e,t,i,s,o){e===0&&(e=.1,t=e),this.overlapAvoidanceFactor<1&&s.shape.radius&&(e=Math.max(.1+this.overlapAvoidanceFactor*s.shape.radius,e-s.shape.radius));let r=this.options.gravitationalConstant*o.mass*s.options.mass/Math.pow(e,3),a=t*r,d=i*r;this.physicsBody.forces[s.id].x+=a,this.physicsBody.forces[s.id].y+=d}_formBarnesHutTree(e,t){let i,s=t.length,o=e[t[0]].x,r=e[t[0]].y,a=e[t[0]].x,d=e[t[0]].y;for(let g=1;g0&&(va&&(a=v),Ed&&(d=E))}let h=Math.abs(a-o)-Math.abs(d-r);h>0?(r-=.5*h,d+=.5*h):(o+=.5*h,a-=.5*h);let c=Math.max(1e-5,Math.abs(a-o)),u=.5*c,f=.5*(o+a),p=.5*(r+d),m={root:{centerOfMass:{x:0,y:0},mass:0,range:{minX:f-u,maxX:f+u,minY:p-u,maxY:p+u},size:c,calcSize:1/c,children:{data:null},maxWidth:0,level:0,childrenCount:4}};this._splitBranch(m.root);for(let g=0;g0&&this._placeInTree(m.root,i);return m}_updateBranchMass(e,t){let i=e.centerOfMass,s=e.mass+t.options.mass,o=1/s;i.x=i.x*e.mass+t.x*t.options.mass,i.x*=o,i.y=i.y*e.mass+t.y*t.options.mass,i.y*=o,e.mass=s;let r=Math.max(Math.max(t.height,t.radius),t.width);e.maxWidth=e.maxWidtht.x?s.maxY>t.y?o="NW":o="SW":s.maxY>t.y?o="NE":o="SE",this._placeInRegion(e,t,o)}_placeInRegion(e,t,i){let s=e.children[i];switch(s.childrenCount){case 0:s.children.data=t,s.childrenCount=1,this._updateBranchMass(s,t);break;case 1:s.children.data.x===t.x&&s.children.data.y===t.y?(t.x+=this._rng(),t.y+=this._rng()):(this._splitBranch(s),this._placeInTree(s,t));break;case 4:this._placeInTree(s,t);break}}_splitBranch(e){let t=null;e.childrenCount===1&&(t=e.children.data,e.mass=0,e.centerOfMass.x=0,e.centerOfMass.y=0),e.childrenCount=4,e.children.data=null,this._insertRegion(e,"NW"),this._insertRegion(e,"NE"),this._insertRegion(e,"SW"),this._insertRegion(e,"SE"),t!=null&&this._placeInTree(e,t)}_insertRegion(e,t){let i,s,o,r,a=.5*e.size;switch(t){case"NW":i=e.range.minX,s=e.range.minX+a,o=e.range.minY,r=e.range.minY+a;break;case"NE":i=e.range.minX+a,s=e.range.maxX,o=e.range.minY,r=e.range.minY+a;break;case"SW":i=e.range.minX,s=e.range.minX+a,o=e.range.minY+a,r=e.range.maxY;break;case"SE":i=e.range.minX+a,s=e.range.maxX,o=e.range.minY+a,r=e.range.maxY;break}e.children[t]={centerOfMass:{x:0,y:0},mass:0,range:{minX:i,maxX:s,minY:o,maxY:r},size:.5*e.size,calcSize:2*e.calcSize,children:{data:null},maxWidth:0,level:e.level+1,childrenCount:0}}_debug(e,t){this.barnesHutTree!==void 0&&(e.lineWidth=1,this._drawBranch(this.barnesHutTree.root,e,t))}_drawBranch(e,t,i){i===void 0&&(i="#FF0000"),e.childrenCount===4&&(this._drawBranch(e.children.NW,t),this._drawBranch(e.children.NE,t),this._drawBranch(e.children.SE,t),this._drawBranch(e.children.SW,t)),t.strokeStyle=i,t.beginPath(),t.moveTo(e.range.minX,e.range.minY),t.lineTo(e.range.maxX,e.range.minY),t.stroke(),t.beginPath(),t.moveTo(e.range.maxX,e.range.minY),t.lineTo(e.range.maxX,e.range.maxY),t.stroke(),t.beginPath(),t.moveTo(e.range.maxX,e.range.maxY),t.lineTo(e.range.minX,e.range.maxY),t.stroke(),t.beginPath(),t.moveTo(e.range.minX,e.range.maxY),t.lineTo(e.range.minX,e.range.minY),t.stroke()}},jo=class{constructor(e,t,i){this._rng=mt("REPULSION SOLVER"),this.body=e,this.physicsBody=t,this.setOptions(i)}setOptions(e){this.options=e}solve(){let e,t,i,s,o,r,a,d,h=this.body.nodes,l=this.physicsBody.physicsNodeIndices,c=this.physicsBody.forces,u=this.options.nodeDistance,f=-2/3/u,p=4/3;for(let m=0;m0){let r=o.edges.length+1,a=this.options.centralGravity*r*o.options.mass;s[o.id].x=t*a,s[o.id].y=i*a}}},Yo=class{constructor(e){this.body=e,this.physicsBody={physicsNodeIndices:[],physicsEdgeIndices:[],forces:{},velocities:{}},this.physicsEnabled=!0,this.simulationInterval=1e3/60,this.requiresTimeout=!0,this.previousStates={},this.referenceState={},this.freezeCache={},this.renderTimer=void 0,this.adaptiveTimestep=!1,this.adaptiveTimestepEnabled=!1,this.adaptiveCounter=0,this.adaptiveInterval=3,this.stabilized=!1,this.startedStabilization=!1,this.stabilizationIterations=0,this.ready=!1,this.options={},this.defaultOptions={enabled:!0,barnesHut:{theta:.5,gravitationalConstant:-2e3,centralGravity:.3,springLength:95,springConstant:.04,damping:.09,avoidOverlap:0},forceAtlas2Based:{theta:.5,gravitationalConstant:-50,centralGravity:.01,springConstant:.08,springLength:100,damping:.4,avoidOverlap:0},repulsion:{centralGravity:.2,springLength:200,springConstant:.05,nodeDistance:100,damping:.09,avoidOverlap:0},hierarchicalRepulsion:{centralGravity:0,springLength:100,springConstant:.01,nodeDistance:120,damping:.09},maxVelocity:50,minVelocity:.75,solver:"barnesHut",stabilization:{enabled:!0,iterations:1e3,updateInterval:50,onlyDynamicEdges:!1,fit:!0},timestep:.5,adaptiveTimestep:!0,wind:{x:0,y:0}},Object.assign(this.options,this.defaultOptions),this.timestep=.5,this.layoutFailed=!1,this.bindEventListeners()}bindEventListeners(){this.body.emitter.on("initPhysics",()=>{this.initPhysics()}),this.body.emitter.on("_layoutFailed",()=>{this.layoutFailed=!0}),this.body.emitter.on("resetPhysics",()=>{this.stopSimulation(),this.ready=!1}),this.body.emitter.on("disablePhysics",()=>{this.physicsEnabled=!1,this.stopSimulation()}),this.body.emitter.on("restorePhysics",()=>{this.setOptions(this.options),this.ready===!0&&this.startSimulation()}),this.body.emitter.on("startSimulation",()=>{this.ready===!0&&this.startSimulation()}),this.body.emitter.on("stopSimulation",()=>{this.stopSimulation()}),this.body.emitter.on("destroy",()=>{this.stopSimulation(!1),this.body.emitter.off()}),this.body.emitter.on("_dataChanged",()=>{this.updatePhysicsData()})}setOptions(e){if(e!==void 0)if(e===!1)this.options.enabled=!1,this.physicsEnabled=!1,this.stopSimulation();else if(e===!0)this.options.enabled=!0,this.physicsEnabled=!0,this.startSimulation();else{this.physicsEnabled=!0,yt(["stabilization"],this.options,e),se(this.options,e,"stabilization"),e.enabled===void 0&&(this.options.enabled=!0),this.options.enabled===!1&&(this.physicsEnabled=!1,this.stopSimulation());let t=this.options.wind;t&&((typeof t.x!="number"||Number.isNaN(t.x))&&(t.x=0),(typeof t.y!="number"||Number.isNaN(t.y))&&(t.y=0)),this.timestep=this.options.timestep}this.init()}init(){let e;this.options.solver==="forceAtlas2Based"?(e=this.options.forceAtlas2Based,this.nodesSolver=new qo(this.body,this.physicsBody,e),this.edgesSolver=new Gt(this.body,this.physicsBody,e),this.gravitySolver=new Uo(this.body,this.physicsBody,e)):this.options.solver==="repulsion"?(e=this.options.repulsion,this.nodesSolver=new jo(this.body,this.physicsBody,e),this.edgesSolver=new Gt(this.body,this.physicsBody,e),this.gravitySolver=new Et(this.body,this.physicsBody,e)):this.options.solver==="hierarchicalRepulsion"?(e=this.options.hierarchicalRepulsion,this.nodesSolver=new Wo(this.body,this.physicsBody,e),this.edgesSolver=new Vo(this.body,this.physicsBody,e),this.gravitySolver=new Et(this.body,this.physicsBody,e)):(e=this.options.barnesHut,this.nodesSolver=new Ni(this.body,this.physicsBody,e),this.edgesSolver=new Gt(this.body,this.physicsBody,e),this.gravitySolver=new Et(this.body,this.physicsBody,e)),this.modelOptions=e}initPhysics(){this.physicsEnabled===!0&&this.options.enabled===!0?this.options.stabilization.enabled===!0?this.stabilize():(this.stabilized=!1,this.ready=!0,this.body.emitter.emit("fit",{},this.layoutFailed),this.startSimulation()):(this.ready=!0,this.body.emitter.emit("fit"))}startSimulation(){this.physicsEnabled===!0&&this.options.enabled===!0?(this.stabilized=!1,this.adaptiveTimestep=!1,this.body.emitter.emit("_resizeNodes"),this.viewFunction===void 0&&(this.viewFunction=this.simulationStep.bind(this),this.body.emitter.on("initRedraw",this.viewFunction),this.body.emitter.emit("_startRendering"))):this.body.emitter.emit("_redraw")}stopSimulation(e=!0){this.stabilized=!0,e===!0&&this._emitStabilized(),this.viewFunction!==void 0&&(this.body.emitter.off("initRedraw",this.viewFunction),this.viewFunction=void 0,e===!0&&this.body.emitter.emit("_stopRendering"))}simulationStep(){let e=Date.now();this.physicsTick(),(Date.now()-e<.4*this.simulationInterval||this.runDoubleSpeed===!0)&&this.stabilized===!1&&(this.physicsTick(),this.runDoubleSpeed=!0),this.stabilized===!0&&this.stopSimulation()}_emitStabilized(e=this.stabilizationIterations){(this.stabilizationIterations>1||this.startedStabilization===!0)&&setTimeout(()=>{this.body.emitter.emit("stabilized",{iterations:e}),this.startedStabilization=!1,this.stabilizationIterations=0},0)}physicsStep(){this.gravitySolver.solve(),this.nodesSolver.solve(),this.edgesSolver.solve(),this.moveNodes()}adjustTimeStep(){let e=1.2;this._evaluateStepQuality()===!0?this.timestep=e*this.timestep:this.timestep/er))return!1;return!0}moveNodes(){let e=this.physicsBody.physicsNodeIndices,t=0,i=0,s=5;for(let o=0;or&&(e=e>0?r:-r),e}_performStep(e){let t=this.body.nodes[e],i=this.physicsBody.forces[e];this.options.wind&&(i.x+=this.options.wind.x,i.y+=this.options.wind.y);let s=this.physicsBody.velocities[e];return this.previousStates[e]={x:t.x,y:t.y,vx:s.x,vy:s.y},t.options.fixed.x===!1?(s.x=this.calculateComponentVelocity(s.x,i.x,t.options.mass),t.x+=s.x*this.timestep):(i.x=0,s.x=0),t.options.fixed.y===!1?(s.y=this.calculateComponentVelocity(s.y,i.y,t.options.mass),t.y+=s.y*this.timestep):(i.y=0,s.y=0),Math.sqrt(Math.pow(s.x,2)+Math.pow(s.y,2))}_freezeNodes(){let e=this.body.nodes;for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&e[t].x&&e[t].y){let i=e[t].options.fixed;this.freezeCache[t]={x:i.x,y:i.y},i.x=!0,i.y=!0}}_restoreFrozenNodes(){let e=this.body.nodes;for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.freezeCache[t]!==void 0&&(e[t].options.fixed.x=this.freezeCache[t].x,e[t].options.fixed.y=this.freezeCache[t].y);this.freezeCache={}}stabilize(e=this.options.stabilization.iterations){if(typeof e!="number"&&(e=this.options.stabilization.iterations,console.error("The stabilize method needs a numeric amount of iterations. Switching to default: ",e)),this.physicsBody.physicsNodeIndices.length===0){this.ready=!0;return}this.adaptiveTimestep=this.options.adaptiveTimestep,this.body.emitter.emit("_resizeNodes"),this.stopSimulation(),this.stabilized=!1,this.body.emitter.emit("_blockRedraw"),this.targetIterations=e,this.options.stabilization.onlyDynamicEdges===!0&&this._freezeNodes(),this.stabilizationIterations=0,setTimeout(()=>this._stabilizationBatch(),0)}_startStabilizing(){return this.startedStabilization===!0?!1:(this.body.emitter.emit("startStabilizing"),this.startedStabilization=!0,!0)}_stabilizationBatch(){let e=()=>this.stabilized===!1&&this.stabilizationIterations{this.body.emitter.emit("stabilizationProgress",{iterations:this.stabilizationIterations,total:this.targetIterations})};this._startStabilizing()&&t();let i=0;for(;e()&&i0)for(let d=0;da.shape.boundingBox.left&&(o=a.shape.boundingBox.left),ra.shape.boundingBox.top&&(i=a.shape.boundingBox.top),s0)for(let d=0;da.x&&(o=a.x),ra.y&&(i=a.y),s{delete this.containedEdges[i.id]}),I(t.containedNodes,(i,s)=>{this.containedNodes[s]=i}),t.containedNodes={},I(t.containedEdges,(i,s)=>{this.containedEdges[s]=i}),t.containedEdges={},I(t.edges,i=>{I(this.edges,s=>{let o=s.clusteringEdgeReplacingIds.indexOf(i.id);o!==-1&&(I(i.clusteringEdgeReplacingIds,r=>{s.clusteringEdgeReplacingIds.push(r),this.body.edges[r].edgeReplacedById=s.id}),s.clusteringEdgeReplacingIds.splice(o,1))})}),t.edges=[]}},Go=class{constructor(e){this.body=e,this.clusteredNodes={},this.clusteredEdges={},this.options={},this.defaultOptions={},Object.assign(this.options,this.defaultOptions),this.body.emitter.on("_resetData",()=>{this.clusteredNodes={},this.clusteredEdges={}})}clusterByHubsize(e,t){e===void 0?e=this._getHubSize():typeof e=="object"&&(t=this._checkOptions(e),e=this._getHubSize());let i=[];for(let s=0;s=e&&i.push(o.id)}for(let s=0;s{o.options&&e.joinCondition(o.options)===!0&&(i[r]=o,I(o.edges,a=>{this.clusteredEdges[a.id]===void 0&&(s[a.id]=a)}))}),this._cluster(i,s,e,t)}clusterByEdgeCount(e,t,i=!0){t=this._checkOptions(t);let s=[],o={},r,a,d;for(let h=0;h0&&Object.keys(c).length>0&&m===!0){let b=function(){for(let v=0;v-1&&(r[f.id]=f)}}this._cluster(o,r,t,i)}_createClusterEdges(e,t,i,s){let o,r,a,d,h,l,c=Object.keys(e),u=[];for(let m=0;ms?a.x:s,o=a.yr?a.y:r;return{x:.5*(i+s),y:.5*(o+r)}}openCluster(e,t,i=!0){if(e===void 0)throw new Error("No clusterNodeId supplied to openCluster.");let s=this.body.nodes[e];if(s===void 0)throw new Error("The clusterNodeId supplied to openCluster does not exist.");if(s.isCluster!==!0||s.containedNodes===void 0||s.containedEdges===void 0)throw new Error("The node:"+e+" is not a valid cluster.");let o=this.findNode(e),r=o.indexOf(e)-1;if(r>=0){let l=o[r];this.body.nodes[l]._openChildCluster(e),delete this.body.nodes[e],i===!0&&this.body.emitter.emit("_dataChanged");return}let a=s.containedNodes,d=s.containedEdges;if(t!==void 0&&t.releaseFunction!==void 0&&typeof t.releaseFunction=="function"){let l={},c={x:s.x,y:s.y};for(let f in a)if(Object.prototype.hasOwnProperty.call(a,f)){let p=this.body.nodes[f];l[f]={x:p.x,y:p.y}}let u=t.releaseFunction(c,l);for(let f in a)if(Object.prototype.hasOwnProperty.call(a,f)){let p=this.body.nodes[f];u[f]!==void 0&&(p.x=u[f].x===void 0?s.x:u[f].x,p.y=u[f].y===void 0?s.y:u[f].y)}}else I(a,function(l){l.options.fixed.x===!1&&(l.x=s.x),l.options.fixed.y===!1&&(l.y=s.y)});for(let l in a)if(Object.prototype.hasOwnProperty.call(a,l)){let c=this.body.nodes[l];c.vx=s.vx,c.vy=s.vy,c.setOptions({physics:!0}),delete this.clusteredNodes[l]}let h=[];for(let l=0;l0&&rs&&(s=h.edges.length),e+=h.edges.length,t+=Math.pow(h.edges.length,2),i+=1}e=e/i,t=t/i;let o=t-Math.pow(e,2),r=Math.sqrt(o),a=Math.floor(e+2*r);return a>s&&(a=s),a}_createClusteredEdge(e,t,i,s,o){let r=G.cloneOptions(i,"edge");D(r,s),r.from=e,r.to=t,r.id="clusterEdge:"+Ee(),o!==void 0&&D(r,o);let a=this.body.functions.createEdge(r);return a.clusteringEdgeReplacingIds=[i.id],a.connect(),this.body.edges[a.id]=a,a}_clusterEdges(e,t,i,s){if(t instanceof Te){let o=t,r={};r[o.id]=o,t=r}if(e instanceof z){let o=e,r={};r[o.id]=o,e=r}if(i==null)throw new Error("_clusterEdges: parameter clusterNode required");s===void 0&&(s=i.clusterEdgeProperties),this._createClusterEdges(e,t,i,s);for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&this.body.edges[o]!==void 0){let r=this.body.edges[o];this._backupEdgeOptions(r),r.setOptions({physics:!1})}for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&(this.clusteredNodes[o]={clusterId:i.id,node:this.body.nodes[o]},this.body.nodes[o].setOptions({physics:!1}))}_getClusterNodeForNode(e){if(e===void 0)return;let t=this.clusteredNodes[e];if(t===void 0)return;let i=t.clusterId;if(i!==void 0)return this.body.nodes[i]}_filter(e,t){let i=[];return I(e,s=>{t(s)&&i.push(s)}),i}_updateState(){let e,t=[],i={},s=d=>{I(this.body.nodes,h=>{h.isCluster===!0&&d(h)})};for(e in this.clusteredNodes){if(!Object.prototype.hasOwnProperty.call(this.clusteredNodes,e))continue;this.body.nodes[e]===void 0&&t.push(e)}s(function(d){for(let h=0;h{let h=this.body.edges[d];(h===void 0||!h.endPointsValid())&&(i[d]=d)}),s(function(d){I(d.containedEdges,(h,l)=>{!h.endPointsValid()&&!i[l]&&(i[l]=l)})}),I(this.body.edges,(d,h)=>{let l=!0,c=d.clusteringEdgeReplacingIds;if(c!==void 0){let u=0;I(c,f=>{let p=this.body.edges[f];p!==void 0&&p.endPointsValid()&&(u+=1)}),l=u>0}(!d.endPointsValid()||!l)&&(i[h]=h)}),s(d=>{I(i,h=>{delete d.containedEdges[h],I(d.edges,(l,c)=>{if(l.id===h){d.edges[c]=null;return}l.clusteringEdgeReplacingIds=this._filter(l.clusteringEdgeReplacingIds,function(u){return!i[u]})}),d.edges=this._filter(d.edges,function(l){return l!==null})})}),I(i,d=>{delete this.clusteredEdges[d]}),I(i,d=>{delete this.body.edges[d]});let o=Object.keys(this.body.edges);I(o,d=>{let h=this.body.edges[d],l=this._isClusteredNode(h.fromId)||this._isClusteredNode(h.toId);if(l!==this._isClusteredEdge(h.id))if(l){let c=this._getClusterNodeForNode(h.fromId);c!==void 0&&this._clusterEdges(this.body.nodes[h.fromId],h,c);let u=this._getClusterNodeForNode(h.toId);u!==void 0&&this._clusterEdges(this.body.nodes[h.toId],h,u)}else delete this._clusterEdges[d],this._restoreEdge(h)});let r=!1,a=!0;for(;a;){let d=[];s(function(h){let l=Object.keys(h.containedNodes).length,c=h.options.allowSingleNodeCluster===!0;(c&&l<1||!c&&l<2)&&d.push(h.id)});for(let h=0;h0,r=r||a}r&&this._updateState()}_isClusteredNode(e){return this.clusteredNodes[e]!==void 0}_isClusteredEdge(e){return this.clusteredEdges[e]!==void 0}};function Ta(){let n;window!==void 0&&(n=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame),n===void 0?window.requestAnimationFrame=function(e){e()}:window.requestAnimationFrame=n}var Ko=class{constructor(e,t){Ta(),this.body=e,this.canvas=t,this.redrawRequested=!1,this.renderTimer=void 0,this.requiresTimeout=!0,this.renderingActive=!1,this.renderRequests=0,this.allowRedraw=!0,this.dragging=!1,this.zooming=!1,this.options={},this.defaultOptions={hideEdgesOnDrag:!1,hideEdgesOnZoom:!1,hideNodesOnDrag:!1},Object.assign(this.options,this.defaultOptions),this._determineBrowserMethod(),this.bindEventListeners()}bindEventListeners(){this.body.emitter.on("dragStart",()=>{this.dragging=!0}),this.body.emitter.on("dragEnd",()=>{this.dragging=!1}),this.body.emitter.on("zoom",()=>{this.zooming=!0,window.clearTimeout(this.zoomTimeoutId),this.zoomTimeoutId=window.setTimeout(()=>{this.zooming=!1,this._requestRedraw.bind(this)()},250)}),this.body.emitter.on("_resizeNodes",()=>{this._resizeNodes()}),this.body.emitter.on("_redraw",()=>{this.renderingActive===!1&&this._redraw()}),this.body.emitter.on("_blockRedraw",()=>{this.allowRedraw=!1}),this.body.emitter.on("_allowRedraw",()=>{this.allowRedraw=!0,this.redrawRequested=!1}),this.body.emitter.on("_requestRedraw",this._requestRedraw.bind(this)),this.body.emitter.on("_startRendering",()=>{this.renderRequests+=1,this.renderingActive=!0,this._startRendering()}),this.body.emitter.on("_stopRendering",()=>{this.renderRequests-=1,this.renderingActive=this.renderRequests>0,this.renderTimer=void 0}),this.body.emitter.on("destroy",()=>{this.renderRequests=0,this.allowRedraw=!1,this.renderingActive=!1,this.requiresTimeout===!0?clearTimeout(this.renderTimer):window.cancelAnimationFrame(this.renderTimer),this.body.emitter.off()})}setOptions(e){e!==void 0&&We(["hideEdgesOnDrag","hideEdgesOnZoom","hideNodesOnDrag"],this.options,e)}_requestNextFrame(e,t){if(typeof window=="undefined")return;let i,s=window;return this.requiresTimeout===!0?i=s.setTimeout(e,t):s.requestAnimationFrame&&(i=s.requestAnimationFrame(e)),i}_startRendering(){this.renderingActive===!0&&this.renderTimer===void 0&&(this.renderTimer=this._requestNextFrame(this._renderStep.bind(this),this.simulationInterval))}_renderStep(){this.renderingActive===!0&&(this.renderTimer=void 0,this.requiresTimeout===!0&&this._startRendering(),this._redraw(),this.requiresTimeout===!1&&this._startRendering())}redraw(){this.body.emitter.emit("setSize"),this._redraw()}_requestRedraw(){this.redrawRequested!==!0&&this.renderingActive===!1&&this.allowRedraw===!0&&(this.redrawRequested=!0,this._requestNextFrame(()=>{this._redraw(!1)},0))}_redraw(e=!1){if(this.allowRedraw===!0){this.body.emitter.emit("initRedraw"),this.redrawRequested=!1;let t={drawExternalLabels:null};(this.canvas.frame.canvas.width===0||this.canvas.frame.canvas.height===0)&&this.canvas.setSize(),this.canvas.setTransform();let i=this.canvas.getContext(),s=this.canvas.frame.canvas.clientWidth,o=this.canvas.frame.canvas.clientHeight;if(i.clearRect(0,0,s,o),this.canvas.frame.clientWidth===0)return;if(i.save(),i.translate(this.body.view.translation.x,this.body.view.translation.y),i.scale(this.body.view.scale,this.body.view.scale),i.beginPath(),this.body.emitter.emit("beforeDrawing",i),i.closePath(),e===!1&&(this.dragging===!1||this.dragging===!0&&this.options.hideEdgesOnDrag===!1)&&(this.zooming===!1||this.zooming===!0&&this.options.hideEdgesOnZoom===!1)&&this._drawEdges(i),this.dragging===!1||this.dragging===!0&&this.options.hideNodesOnDrag===!1){let{drawExternalLabels:r}=this._drawNodes(i,e);t.drawExternalLabels=r}e===!1&&(this.dragging===!1||this.dragging===!0&&this.options.hideEdgesOnDrag===!1)&&(this.zooming===!1||this.zooming===!0&&this.options.hideEdgesOnZoom===!1)&&this._drawArrows(i),t.drawExternalLabels!=null&&t.drawExternalLabels(),e===!1&&this._drawSelectionBox(i),i.beginPath(),this.body.emitter.emit("afterDrawing",i),i.closePath(),i.restore(),e===!0&&i.clearRect(0,0,s,o)}}_resizeNodes(){this.canvas.setTransform();let e=this.canvas.getContext();e.save(),e.translate(this.body.view.translation.x,this.body.view.translation.y),e.scale(this.body.view.scale,this.body.view.scale);let t=this.body.nodes,i;for(let s in t)Object.prototype.hasOwnProperty.call(t,s)&&(i=t[s],i.resize(e),i.updateBoundingBox(e,i.selected));e.restore()}_drawNodes(e,t=!1){let i=this.body.nodes,s=this.body.nodeIndices,o,r=[],a=[],d=20,h=this.canvas.DOMtoCanvas({x:-d,y:-d}),l=this.canvas.DOMtoCanvas({x:this.canvas.frame.canvas.clientWidth+d,y:this.canvas.frame.canvas.clientHeight+d}),c={top:h.y,left:h.x,bottom:l.y,right:l.x},u=[];for(let g=0;g{for(let g of u)g()}}}_drawEdges(e){let t=this.body.edges,i=this.body.edgeIndices;for(let s=0;s{e.width!==0&&(this.body.view.translation.x=e.width*.5),e.height!==0&&(this.body.view.translation.y=e.height*.5)}),this.body.emitter.on("setSize",this.setSize.bind(this)),this.body.emitter.on("destroy",()=>{this.hammerFrame.destroy(),this.hammer.destroy(),this._cleanUp()})}setOptions(e){if(e!==void 0&&We(["width","height","autoResize"],this.options,e),this._cleanUp(),this.options.autoResize===!0){if(window.ResizeObserver){let i=new ResizeObserver(()=>{this.setSize()===!0&&this.body.emitter.emit("_requestRedraw")}),{frame:s}=this;i.observe(s),this._cleanupCallbacks.push(()=>{i.unobserve(s)})}else{let i=setInterval(()=>{this.setSize()===!0&&this.body.emitter.emit("_requestRedraw")},1e3);this._cleanupCallbacks.push(()=>{clearInterval(i)})}let t=this._onResize.bind(this);window.addEventListener("resize",t),this._cleanupCallbacks.push(()=>{window.removeEventListener("resize",t)})}}_cleanUp(){this._cleanupCallbacks.splice(0).reverse().forEach(e=>{try{e()}catch(t){console.error(t)}})}_onResize(){this.setSize(),this.body.emitter.emit("_redraw")}_getCameraState(e=this.pixelRatio){this.initialized===!0&&(this.cameraState.previousWidth=this.frame.canvas.width/e,this.cameraState.previousHeight=this.frame.canvas.height/e,this.cameraState.scale=this.body.view.scale,this.cameraState.position=this.DOMtoCanvas({x:.5*this.frame.canvas.width/e,y:.5*this.frame.canvas.height/e}))}_setCameraState(){if(this.cameraState.scale!==void 0&&this.frame.canvas.clientWidth!==0&&this.frame.canvas.clientHeight!==0&&this.pixelRatio!==0&&this.cameraState.previousWidth>0&&this.cameraState.previousHeight>0){let e=this.frame.canvas.width/this.pixelRatio/this.cameraState.previousWidth,t=this.frame.canvas.height/this.pixelRatio/this.cameraState.previousHeight,i=this.cameraState.scale;e!=1&&t!=1?i=this.cameraState.scale*.5*(e+t):e!=1?i=this.cameraState.scale*e:t!=1&&(i=this.cameraState.scale*t),this.body.view.scale=i;let s=this.DOMtoCanvas({x:.5*this.frame.canvas.clientWidth,y:.5*this.frame.canvas.clientHeight}),o={x:s.x-this.cameraState.position.x,y:s.y-this.cameraState.position.y};this.body.view.translation.x+=o.x*this.body.view.scale,this.body.view.translation.y+=o.y*this.body.view.scale}}_prepareValue(e){if(typeof e=="number")return e+"px";if(typeof e=="string"){if(e.indexOf("%")!==-1||e.indexOf("px")!==-1)return e;if(e.indexOf("%")===-1)return e+"px"}throw new Error("Could not use the value supplied for width or height:"+e)}_create(){for(;this.body.container.hasChildNodes();)this.body.container.removeChild(this.body.container.firstChild);if(this.frame=document.createElement("div"),this.frame.className="vis-network",this.frame.style.position="relative",this.frame.style.overflow="hidden",this.frame.tabIndex=0,this.frame.canvas=document.createElement("canvas"),this.frame.canvas.style.position="relative",this.frame.appendChild(this.frame.canvas),this.frame.canvas.getContext)this._setPixelRatio(),this.setTransform();else{let e=document.createElement("DIV");e.style.color="red",e.style.fontWeight="bold",e.style.padding="10px",e.innerText="Error: your browser does not support HTML canvas",this.frame.canvas.appendChild(e)}this.body.container.appendChild(this.frame),this.body.view.scale=1,this.body.view.translation={x:.5*this.frame.canvas.clientWidth,y:.5*this.frame.canvas.clientHeight},this._bindHammer()}_bindHammer(){this.hammer!==void 0&&this.hammer.destroy(),this.drag={},this.pinch={},this.hammer=new Ve(this.frame.canvas),this.hammer.get("pinch").set({enable:!0}),this.hammer.get("pan").set({threshold:5,direction:Ve.DIRECTION_ALL}),Kt(this.hammer,e=>{this.body.eventListeners.onTouch(e)}),this.hammer.on("tap",e=>{this.body.eventListeners.onTap(e)}),this.hammer.on("doubletap",e=>{this.body.eventListeners.onDoubleTap(e)}),this.hammer.on("press",e=>{this.body.eventListeners.onHold(e)}),this.hammer.on("panstart",e=>{this.body.eventListeners.onDragStart(e)}),this.hammer.on("panmove",e=>{this.body.eventListeners.onDrag(e)}),this.hammer.on("panend",e=>{this.body.eventListeners.onDragEnd(e)}),this.hammer.on("pinch",e=>{this.body.eventListeners.onPinch(e)}),this.frame.canvas.addEventListener("wheel",e=>{this.body.eventListeners.onMouseWheel(e)}),this.frame.canvas.addEventListener("mousemove",e=>{this.body.eventListeners.onMouseMove(e)}),this.frame.canvas.addEventListener("contextmenu",e=>{this.body.eventListeners.onContext(e)}),this.hammerFrame=new Ve(this.frame),$o(this.hammerFrame,e=>{this.body.eventListeners.onRelease(e)})}setSize(e=this.options.width,t=this.options.height){e=this._prepareValue(e),t=this._prepareValue(t);let i=!1,s=this.frame.canvas.width,o=this.frame.canvas.height,r=this.pixelRatio;if(this._setPixelRatio(),e!=this.options.width||t!=this.options.height||this.frame.style.width!=e||this.frame.style.height!=t)this._getCameraState(r),this.frame.style.width=e,this.frame.style.height=t,this.frame.canvas.style.width="100%",this.frame.canvas.style.height="100%",this.frame.canvas.width=Math.round(this.frame.canvas.clientWidth*this.pixelRatio),this.frame.canvas.height=Math.round(this.frame.canvas.clientHeight*this.pixelRatio),this.options.width=e,this.options.height=t,this.canvasViewCenter={x:.5*this.frame.clientWidth,y:.5*this.frame.clientHeight},i=!0;else{let a=Math.round(this.frame.canvas.clientWidth*this.pixelRatio),d=Math.round(this.frame.canvas.clientHeight*this.pixelRatio);(this.frame.canvas.width!==a||this.frame.canvas.height!==d)&&this._getCameraState(r),this.frame.canvas.width!==a&&(this.frame.canvas.width=a,i=!0),this.frame.canvas.height!==d&&(this.frame.canvas.height=d,i=!0)}return i===!0&&(this.body.emitter.emit("resize",{width:Math.round(this.frame.canvas.width/this.pixelRatio),height:Math.round(this.frame.canvas.height/this.pixelRatio),oldWidth:Math.round(s/this.pixelRatio),oldHeight:Math.round(o/this.pixelRatio)}),this._setCameraState()),this.initialized=!0,i}getContext(){return this.frame.canvas.getContext("2d")}_determinePixelRatio(){let e=this.getContext();if(e===void 0)throw new Error("Could not get canvax context");let t=1;typeof window!="undefined"&&(t=window.devicePixelRatio||1);let i=e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return t/i}_setPixelRatio(){this.pixelRatio=this._determinePixelRatio()}setTransform(){let e=this.getContext();if(e===void 0)throw new Error("Could not get canvax context");e.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0)}_XconvertDOMtoCanvas(e){return(e-this.body.view.translation.x)/this.body.view.scale}_XconvertCanvasToDOM(e){return e*this.body.view.scale+this.body.view.translation.x}_YconvertDOMtoCanvas(e){return(e-this.body.view.translation.y)/this.body.view.scale}_YconvertCanvasToDOM(e){return e*this.body.view.scale+this.body.view.translation.y}canvasToDOM(e){return{x:this._XconvertCanvasToDOM(e.x),y:this._YconvertCanvasToDOM(e.y)}}DOMtoCanvas(e){return{x:this._XconvertDOMtoCanvas(e.x),y:this._YconvertDOMtoCanvas(e.y)}}};function ka(n,e){let t=Object.assign({nodes:e,minZoomLevel:Number.MIN_VALUE,maxZoomLevel:1},n!=null?n:{});if(!Array.isArray(t.nodes))throw new TypeError("Nodes has to be an array of ids.");if(t.nodes.length===0&&(t.nodes=e),!(typeof t.minZoomLevel=="number"&&t.minZoomLevel>0))throw new TypeError("Min zoom level has to be a number higher than zero.");if(!(typeof t.maxZoomLevel=="number"&&t.minZoomLevel<=t.maxZoomLevel))throw new TypeError("Max zoom level has to be a number higher than min zoom level.");return t}var Qo=class{constructor(e,t){this.body=e,this.canvas=t,this.animationSpeed=1/this.renderRefreshRate,this.animationEasingFunction="easeInOutQuint",this.easingTime=0,this.sourceScale=0,this.targetScale=0,this.sourceTranslation=0,this.targetTranslation=0,this.lockedOnNodeId=void 0,this.lockedOnNodeOffset=void 0,this.touchTime=0,this.viewFunction=void 0,this.body.emitter.on("fit",this.fit.bind(this)),this.body.emitter.on("animationFinished",()=>{this.body.emitter.emit("_stopRendering")}),this.body.emitter.on("unlockNode",this.releaseNode.bind(this))}setOptions(e={}){this.options=e}fit(e,t=!1){e=ka(e,this.body.nodeIndices);let i=this.canvas.frame.canvas.clientWidth,s=this.canvas.frame.canvas.clientHeight,o,r;if(i===0||s===0)r=1,o=G.getRange(this.body.nodes,e.nodes);else if(t===!0){let h=0;for(let u in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,u)&&this.body.nodes[u].predefinedPosition===!0&&(h+=1);if(h>.5*this.body.nodeIndices.length){this.fit(e,!1);return}o=G.getRange(this.body.nodes,e.nodes);let l=this.body.nodeIndices.length;r=12.662/(l+7.4147)+.0964822,r*=Math.min(i/600,s/600)}else{this.body.emitter.emit("_resizeNodes"),o=G.getRange(this.body.nodes,e.nodes);let h=Math.abs(o.maxX-o.minX)*1.1,l=Math.abs(o.maxY-o.minY)*1.1,c=i/h,u=s/l;r=c<=u?c:u}r>e.maxZoomLevel?r=e.maxZoomLevel:r0))throw new TypeError('The option "scale" has to be a number greater than zero.')}else e.scale=this.body.view.scale;e.animation===void 0&&(e.animation={duration:0}),e.animation===!1&&(e.animation={duration:0}),e.animation===!0&&(e.animation={}),e.animation.duration===void 0&&(e.animation.duration=1e3),e.animation.easingFunction===void 0&&(e.animation.easingFunction="easeInOutQuad"),this.animateView(e)}animateView(e){if(e===void 0)return;this.animationEasingFunction=e.animation.easingFunction,this.releaseNode(),e.locked===!0&&(this.lockedOnNodeId=e.lockedOnNode,this.lockedOnNodeOffset=e.offset),this.easingTime!=0&&this._transitionRedraw(!0),this.sourceScale=this.body.view.scale,this.sourceTranslation=this.body.view.translation,this.targetScale=e.scale,this.body.view.scale=this.targetScale;let t=this.canvas.DOMtoCanvas({x:.5*this.canvas.frame.canvas.clientWidth,y:.5*this.canvas.frame.canvas.clientHeight}),i={x:t.x-e.position.x,y:t.y-e.position.y};this.targetTranslation={x:this.sourceTranslation.x+i.x*this.targetScale+e.offset.x,y:this.sourceTranslation.y+i.y*this.targetScale+e.offset.y},e.animation.duration===0?this.lockedOnNodeId!=null?(this.viewFunction=this._lockedRedraw.bind(this),this.body.emitter.on("initRedraw",this.viewFunction)):(this.body.view.scale=this.targetScale,this.body.view.translation=this.targetTranslation,this.body.emitter.emit("_requestRedraw")):(this.animationSpeed=1/(60*e.animation.duration*.001)||1/60,this.animationEasingFunction=e.animation.easingFunction,this.viewFunction=this._transitionRedraw.bind(this),this.body.emitter.on("initRedraw",this.viewFunction),this.body.emitter.emit("_startRendering"))}_lockedRedraw(){let e={x:this.body.nodes[this.lockedOnNodeId].x,y:this.body.nodes[this.lockedOnNodeId].y},t=this.canvas.DOMtoCanvas({x:.5*this.canvas.frame.canvas.clientWidth,y:.5*this.canvas.frame.canvas.clientHeight}),i={x:t.x-e.x,y:t.y-e.y},s=this.body.view.translation,o={x:s.x+i.x*this.body.view.scale+this.lockedOnNodeOffset.x,y:s.y+i.y*this.body.view.scale+this.lockedOnNodeOffset.y};this.body.view.translation=o}releaseNode(){this.lockedOnNodeId!==void 0&&this.viewFunction!==void 0&&(this.body.emitter.off("initRedraw",this.viewFunction),this.lockedOnNodeId=void 0,this.lockedOnNodeOffset=void 0)}_transitionRedraw(e=!1){this.easingTime+=this.animationSpeed,this.easingTime=e===!0?1:this.easingTime;let t=Ls[this.animationEasingFunction](this.easingTime);this.body.view.scale=this.sourceScale+(this.targetScale-this.sourceScale)*t,this.body.view.translation={x:this.sourceTranslation.x+(this.targetTranslation.x-this.sourceTranslation.x)*t,y:this.sourceTranslation.y+(this.targetTranslation.y-this.sourceTranslation.y)*t},this.easingTime>=1&&(this.body.emitter.off("initRedraw",this.viewFunction),this.easingTime=0,this.lockedOnNodeId!=null&&(this.viewFunction=this._lockedRedraw.bind(this),this.body.emitter.on("initRedraw",this.viewFunction)),this.body.emitter.emit("animationFinished"))}getScale(){return this.body.view.scale}getViewPosition(){return this.canvas.DOMtoCanvas({x:.5*this.canvas.frame.canvas.clientWidth,y:.5*this.canvas.frame.canvas.clientHeight})}},Jo=class{constructor(e,t){this.body=e,this.canvas=t,this.iconsCreated=!1,this.navigationHammers=[],this.boundFunctions={},this.touchTime=0,this.activated=!1,this.body.emitter.on("activate",()=>{this.activated=!0,this.configureKeyboardBindings()}),this.body.emitter.on("deactivate",()=>{this.activated=!1,this.configureKeyboardBindings()}),this.body.emitter.on("destroy",()=>{this.keycharm!==void 0&&this.keycharm.destroy()}),this.options={}}setOptions(e){e!==void 0&&(this.options=e,this.create())}create(){this.options.navigationButtons===!0?this.iconsCreated===!1&&this.loadNavigationElements():this.iconsCreated===!0&&this.cleanNavigation(),this.configureKeyboardBindings()}cleanNavigation(){if(this.navigationHammers.length!=0){for(let e=0;e{this._stopMovement()}),this.navigationHammers.push(i),this.iconsCreated=!0}bindToRedraw(e){this.boundFunctions[e]===void 0&&(this.boundFunctions[e]=this[e].bind(this),this.body.emitter.on("initRedraw",this.boundFunctions[e]),this.body.emitter.emit("_startRendering"))}unbindFromRedraw(e){this.boundFunctions[e]!==void 0&&(this.body.emitter.off("initRedraw",this.boundFunctions[e]),this.body.emitter.emit("_stopRendering"),delete this.boundFunctions[e])}_fit(){new Date().valueOf()-this.touchTime>700&&(this.body.emitter.emit("fit",{duration:700}),this.touchTime=new Date().valueOf())}_stopMovement(){for(let e in this.boundFunctions)Object.prototype.hasOwnProperty.call(this.boundFunctions,e)&&(this.body.emitter.off("initRedraw",this.boundFunctions[e]),this.body.emitter.emit("_stopRendering"));this.boundFunctions={}}_moveUp(){this.body.view.translation.y+=this.options.keyboard.speed.y}_moveDown(){this.body.view.translation.y-=this.options.keyboard.speed.y}_moveLeft(){this.body.view.translation.x+=this.options.keyboard.speed.x}_moveRight(){this.body.view.translation.x-=this.options.keyboard.speed.x}_zoomIn(){let e=this.body.view.scale,t=this.body.view.scale*(1+this.options.keyboard.speed.zoom),i=this.body.view.translation,s=t/e,o=(1-s)*this.canvas.canvasViewCenter.x+i.x*s,r=(1-s)*this.canvas.canvasViewCenter.y+i.y*s;this.body.view.scale=t,this.body.view.translation={x:o,y:r},this.body.emitter.emit("zoom",{direction:"+",scale:this.body.view.scale,pointer:null})}_zoomOut(){let e=this.body.view.scale,t=this.body.view.scale/(1+this.options.keyboard.speed.zoom),i=this.body.view.translation,s=t/e,o=(1-s)*this.canvas.canvasViewCenter.x+i.x*s,r=(1-s)*this.canvas.canvasViewCenter.y+i.y*s;this.body.view.scale=t,this.body.view.translation={x:o,y:r},this.body.emitter.emit("zoom",{direction:"-",scale:this.body.view.scale,pointer:null})}configureKeyboardBindings(){this.keycharm!==void 0&&this.keycharm.destroy(),this.options.keyboard.enabled===!0&&(this.options.keyboard.bindToWindow===!0?this.keycharm=Vt({container:window,preventDefault:!0}):this.keycharm=Vt({container:this.canvas.frame,preventDefault:!0}),this.keycharm.reset(),this.activated===!0&&(this.keycharm.bind("up",()=>{this.bindToRedraw("_moveUp")},"keydown"),this.keycharm.bind("down",()=>{this.bindToRedraw("_moveDown")},"keydown"),this.keycharm.bind("left",()=>{this.bindToRedraw("_moveLeft")},"keydown"),this.keycharm.bind("right",()=>{this.bindToRedraw("_moveRight")},"keydown"),this.keycharm.bind("=",()=>{this.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("num+",()=>{this.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("num-",()=>{this.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("-",()=>{this.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("[",()=>{this.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("]",()=>{this.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("pageup",()=>{this.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("pagedown",()=>{this.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("up",()=>{this.unbindFromRedraw("_moveUp")},"keyup"),this.keycharm.bind("down",()=>{this.unbindFromRedraw("_moveDown")},"keyup"),this.keycharm.bind("left",()=>{this.unbindFromRedraw("_moveLeft")},"keyup"),this.keycharm.bind("right",()=>{this.unbindFromRedraw("_moveRight")},"keyup"),this.keycharm.bind("=",()=>{this.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("num+",()=>{this.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("num-",()=>{this.unbindFromRedraw("_zoomOut")},"keyup"),this.keycharm.bind("-",()=>{this.unbindFromRedraw("_zoomOut")},"keyup"),this.keycharm.bind("[",()=>{this.unbindFromRedraw("_zoomOut")},"keyup"),this.keycharm.bind("]",()=>{this.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("pageup",()=>{this.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("pagedown",()=>{this.unbindFromRedraw("_zoomOut")},"keyup")))}},en=class{constructor(e,t,i){this.body=e,this.canvas=t,this.selectionHandler=i,this.navigationHandler=new Jo(e,t),this.body.eventListeners.onTap=this.onTap.bind(this),this.body.eventListeners.onTouch=this.onTouch.bind(this),this.body.eventListeners.onDoubleTap=this.onDoubleTap.bind(this),this.body.eventListeners.onHold=this.onHold.bind(this),this.body.eventListeners.onDragStart=this.onDragStart.bind(this),this.body.eventListeners.onDrag=this.onDrag.bind(this),this.body.eventListeners.onDragEnd=this.onDragEnd.bind(this),this.body.eventListeners.onMouseWheel=this.onMouseWheel.bind(this),this.body.eventListeners.onPinch=this.onPinch.bind(this),this.body.eventListeners.onMouseMove=this.onMouseMove.bind(this),this.body.eventListeners.onRelease=this.onRelease.bind(this),this.body.eventListeners.onContext=this.onContext.bind(this),this.touchTime=0,this.drag={},this.pinch={},this.popup=void 0,this.popupObj=void 0,this.popupTimer=void 0,this.body.functions.getPointer=this.getPointer.bind(this),this.options={},this.defaultOptions={dragNodes:!0,dragView:!0,hover:!1,keyboard:{enabled:!1,speed:{x:10,y:10,zoom:.02},bindToWindow:!0,autoFocus:!0},navigationButtons:!1,tooltipDelay:300,zoomView:!0,zoomSpeed:1},Object.assign(this.options,this.defaultOptions),this.bindEventListeners()}bindEventListeners(){this.body.emitter.on("destroy",()=>{clearTimeout(this.popupTimer),delete this.body.functions.getPointer})}setOptions(e){e!==void 0&&(yt(["hideEdgesOnDrag","hideEdgesOnZoom","hideNodesOnDrag","keyboard","multiselect","selectable","selectConnectedEdges"],this.options,e),se(this.options,e,"keyboard"),e.tooltip&&(Object.assign(this.options.tooltip,e.tooltip),e.tooltip.color&&(this.options.tooltip.color=zt(e.tooltip.color)))),this.navigationHandler.setOptions(this.options)}getPointer(e){return{x:e.x-Ns(this.canvas.frame.canvas),y:e.y-Bs(this.canvas.frame.canvas)}}onTouch(e){new Date().valueOf()-this.touchTime>50&&(this.drag.pointer=this.getPointer(e.center),this.drag.pinched=!1,this.pinch.scale=this.body.view.scale,this.touchTime=new Date().valueOf())}onTap(e){let t=this.getPointer(e.center),i=this.selectionHandler.options.multiselect&&(e.changedPointers[0].ctrlKey||e.changedPointers[0].metaKey);this.checkSelectionChanges(t,i),this.selectionHandler.commitAndEmit(t,e),this.selectionHandler.generateClickEvent("click",e,t)}onDoubleTap(e){let t=this.getPointer(e.center);this.selectionHandler.generateClickEvent("doubleClick",e,t)}onHold(e){let t=this.getPointer(e.center),i=this.selectionHandler.options.multiselect;this.checkSelectionChanges(t,i),this.selectionHandler.commitAndEmit(t,e),this.selectionHandler.generateClickEvent("click",e,t),this.selectionHandler.generateClickEvent("hold",e,t)}onRelease(e){if(new Date().valueOf()-this.touchTime>10){let t=this.getPointer(e.center);this.selectionHandler.generateClickEvent("release",e,t),this.touchTime=new Date().valueOf()}}onContext(e){let t=this.getPointer({x:e.clientX,y:e.clientY});this.selectionHandler.generateClickEvent("oncontext",e,t)}checkSelectionChanges(e,t=!1){t===!0?this.selectionHandler.selectAdditionalOnPoint(e):this.selectionHandler.selectOnPoint(e)}_determineDifference(e,t){let i=function(s,o){let r=[];for(let a=0;a{let a=r.node;r.xFixed===!1&&(a.x=this.canvas._XconvertDOMtoCanvas(this.canvas._XconvertCanvasToDOM(r.x)+s)),r.yFixed===!1&&(a.y=this.canvas._YconvertDOMtoCanvas(this.canvas._YconvertCanvasToDOM(r.y)+o))}),this.body.emitter.emit("startSimulation")}else{if(e.srcEvent.shiftKey){if(this.selectionHandler.generateClickEvent("dragging",e,t,void 0,!0),this.drag.pointer===void 0){this.onDragStart(e);return}this.body.selectionBox.position.end={x:this.canvas._XconvertDOMtoCanvas(t.x),y:this.canvas._YconvertDOMtoCanvas(t.y)},this.body.emitter.emit("_requestRedraw")}if(this.options.dragView===!0&&!e.srcEvent.shiftKey){if(this.selectionHandler.generateClickEvent("dragging",e,t,void 0,!0),this.drag.pointer===void 0){this.onDragStart(e);return}let s=t.x-this.drag.pointer.x,o=t.y-this.drag.pointer.y;this.body.view.translation={x:this.drag.translation.x+s,y:this.drag.translation.y+o},this.body.emitter.emit("_requestRedraw")}}}onDragEnd(e){if(this.drag.dragging=!1,this.body.selectionBox.show){this.body.selectionBox.show=!1;let t=this.body.selectionBox.position,i={minX:Math.min(t.start.x,t.end.x),minY:Math.min(t.start.y,t.end.y),maxX:Math.max(t.start.x,t.end.x),maxY:Math.max(t.start.y,t.end.y)};this.body.nodeIndices.filter(r=>{let a=this.body.nodes[r];return a.x>=i.minX&&a.x<=i.maxX&&a.y>=i.minY&&a.y<=i.maxY}).forEach(r=>this.selectionHandler.selectObject(this.body.nodes[r]));let o=this.getPointer(e.center);this.selectionHandler.commitAndEmit(o,e),this.selectionHandler.generateClickEvent("dragEnd",e,this.getPointer(e.center),void 0,!0),this.body.emitter.emit("_requestRedraw")}else{let t=this.drag.selection;t&&t.length?(t.forEach(function(i){i.node.options.fixed.x=i.xFixed,i.node.options.fixed.y=i.yFixed}),this.selectionHandler.generateClickEvent("dragEnd",e,this.getPointer(e.center)),this.body.emitter.emit("startSimulation")):(this.selectionHandler.generateClickEvent("dragEnd",e,this.getPointer(e.center),void 0,!0),this.body.emitter.emit("_requestRedraw"))}}onPinch(e){let t=this.getPointer(e.center);this.drag.pinched=!0,this.pinch.scale===void 0&&(this.pinch.scale=1);let i=this.pinch.scale*e.scale;this.zoom(i,t)}zoom(e,t){if(this.options.zoomView===!0){let i=this.body.view.scale;e<1e-5&&(e=1e-5),e>10&&(e=10);let s;this.drag!==void 0&&this.drag.dragging===!0&&(s=this.canvas.DOMtoCanvas(this.drag.pointer));let o=this.body.view.translation,r=e/i,a=(1-r)*t.x+o.x*r,d=(1-r)*t.y+o.y*r;if(this.body.view.scale=e,this.body.view.translation={x:a,y:d},s!=null){let h=this.canvas.canvasToDOM(s);this.drag.pointer.x=h.x,this.drag.pointer.y=h.y}this.body.emitter.emit("_requestRedraw"),ithis._checkShowPopup(t),this.options.tooltipDelay))),this.options.hover===!0&&this.selectionHandler.hoverObject(e,t)}_checkShowPopup(e){let t=this.canvas._XconvertDOMtoCanvas(e.x),i=this.canvas._YconvertDOMtoCanvas(e.y),s={left:t,top:i,right:t,bottom:i},o=this.popupObj===void 0?void 0:this.popupObj.id,r=!1,a="node";if(this.popupObj===void 0){let d=this.body.nodeIndices,h=this.body.nodes,l,c=[];for(let u=0;u0&&(this.popupObj=h[c[c.length-1]],r=!0)}if(this.popupObj===void 0&&r===!1){let d=this.body.edgeIndices,h=this.body.edges,l,c=[];for(let u=0;u0&&(this.popupObj=h[c[c.length-1]],a="edge")}this.popupObj!==void 0?this.popupObj.id!==o&&(this.popup===void 0&&(this.popup=new Vs(this.canvas.frame)),this.popup.popupTargetType=a,this.popup.popupTargetId=this.popupObj.id,this.popup.setPosition(e.x+3,e.y-5),this.popup.setText(this.popupObj.getTitle()),this.popup.show(),this.body.emitter.emit("showPopup",this.popupObj.id)):this.popup!==void 0&&(this.popup.hide(),this.body.emitter.emit("hidePopup"))}_checkHidePopup(e){let t=this.selectionHandler._pointerToPositionObject(e),i=!1;if(this.popup.popupTargetType==="node"){if(this.body.nodes[this.popup.popupTargetId]!==void 0&&(i=this.body.nodes[this.popup.popupTargetId].isOverlappingWith(t),i===!0)){let s=this.selectionHandler.getNodeAt(e);i=s===void 0?!1:s.id===this.popup.popupTargetId}}else this.selectionHandler.getNodeAt(e)===void 0&&this.body.edges[this.popup.popupTargetId]!==void 0&&(i=this.body.edges[this.popup.popupTargetId].isOverlappingWith(t));i===!1&&(this.popupObj=void 0,this.popup.hide(),this.body.emitter.emit("hidePopup"))}};function A(n,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?n!==e||!i:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(n):i?i.value:e.get(n)}function Bi(n,e,t,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(n,t):s?s.value=t:e.set(n,t),t}typeof SuppressedError=="function"&&SuppressedError;var Ue,re,Me,De,$t;function tn(n,e){let t=new Set;for(let i of e)n.has(i)||t.add(i);return t}var Ai=class{constructor(){Ue.set(this,new Set),re.set(this,new Set)}get size(){return A(this,re,"f").size}add(...e){for(let t of e)A(this,re,"f").add(t)}delete(...e){for(let t of e)A(this,re,"f").delete(t)}clear(){A(this,re,"f").clear()}getSelection(){return[...A(this,re,"f")]}getChanges(){return{added:[...tn(A(this,Ue,"f"),A(this,re,"f"))],deleted:[...tn(A(this,re,"f"),A(this,Ue,"f"))],previous:[...new Set(A(this,Ue,"f"))],current:[...new Set(A(this,re,"f"))]}}commit(){let e=this.getChanges();Bi(this,Ue,A(this,re,"f"),"f"),Bi(this,re,new Set(A(this,Ue,"f")),"f");for(let t of e.added)t.select();for(let t of e.deleted)t.unselect();return e}};Ue=new WeakMap,re=new WeakMap;var sn=class{constructor(e=()=>{}){Me.set(this,new Ai),De.set(this,new Ai),$t.set(this,void 0),Bi(this,$t,e,"f")}get sizeNodes(){return A(this,Me,"f").size}get sizeEdges(){return A(this,De,"f").size}getNodes(){return A(this,Me,"f").getSelection()}getEdges(){return A(this,De,"f").getSelection()}addNodes(...e){A(this,Me,"f").add(...e)}addEdges(...e){A(this,De,"f").add(...e)}deleteNodes(e){A(this,Me,"f").delete(e)}deleteEdges(e){A(this,De,"f").delete(e)}clear(){A(this,Me,"f").clear(),A(this,De,"f").clear()}commit(...e){let t={nodes:A(this,Me,"f").commit(),edges:A(this,De,"f").commit()};return A(this,$t,"f").call(this,t,...e),t}};Me=new WeakMap,De=new WeakMap,$t=new WeakMap;var on=class{constructor(e,t){this.body=e,this.canvas=t,this._selectionAccumulator=new sn,this.hoverObj={nodes:{},edges:{}},this.options={},this.defaultOptions={multiselect:!1,selectable:!0,selectConnectedEdges:!0,hoverConnectedEdges:!0},Object.assign(this.options,this.defaultOptions),this.body.emitter.on("_dataChanged",()=>{this.updateSelection()})}setOptions(e){e!==void 0&&We(["multiselect","hoverConnectedEdges","selectable","selectConnectedEdges"],this.options,e)}selectOnPoint(e){let t=!1;if(this.options.selectable===!0){let i=this.getNodeAt(e)||this.getEdgeAt(e);this.unselectAll(),i!==void 0&&(t=this.selectObject(i)),this.body.emitter.emit("_requestRedraw")}return t}selectAdditionalOnPoint(e){let t=!1;if(this.options.selectable===!0){let i=this.getNodeAt(e)||this.getEdgeAt(e);i!==void 0&&(t=!0,i.isSelected()===!0?this.deselectObject(i):this.selectObject(i),this.body.emitter.emit("_requestRedraw"))}return t}_initBaseEvent(e,t){let i={};return i.pointer={DOM:{x:t.x,y:t.y},canvas:this.canvas.DOMtoCanvas(t)},i.event=e,i}generateClickEvent(e,t,i,s,o=!1){let r=this._initBaseEvent(t,i);if(o===!0)r.nodes=[],r.edges=[];else{let a=this.getSelection();r.nodes=a.nodes,r.edges=a.edges}s!==void 0&&(r.previousSelection=s),e=="click"&&(r.items=this.getClickedItems(i)),t.controlEdge!==void 0&&(r.controlEdge=t.controlEdge),this.body.emitter.emit(e,r)}selectObject(e,t=this.options.selectConnectedEdges){return e!==void 0?(e instanceof z?(t===!0&&this._selectionAccumulator.addEdges(...e.edges),this._selectionAccumulator.addNodes(e)):this._selectionAccumulator.addEdges(e),!0):!1}deselectObject(e){e.isSelected()===!0&&(e.selected=!1,this._removeFromSelection(e))}_getAllNodesOverlappingWith(e){let t=[],i=this.body.nodes;for(let s=0;s0)return t===!0?this.body.nodes[s[s.length-1]]:s[s.length-1]}_getEdgesOverlappingWith(e,t){let i=this.body.edges;for(let s=0;s0&&(this.generateClickEvent("deselectEdge",t,e,o),i=!0),s.nodes.deleted.length>0&&(this.generateClickEvent("deselectNode",t,e,o),i=!0),s.nodes.added.length>0&&(this.generateClickEvent("selectNode",t,e),i=!0),s.edges.added.length>0&&(this.generateClickEvent("selectEdge",t,e),i=!0),i===!0&&this.generateClickEvent("select",t,e)}getSelection(){return{nodes:this.getSelectedNodeIds(),edges:this.getSelectedEdgeIds()}}getSelectedNodes(){return this._selectionAccumulator.getNodes()}getSelectedEdges(){return this._selectionAccumulator.getEdges()}getSelectedNodeIds(){return this._selectionAccumulator.getNodes().map(e=>e.id)}getSelectedEdgeIds(){return this._selectionAccumulator.getEdges().map(e=>e.id)}setSelection(e,t={}){if(!e||!e.nodes&&!e.edges)throw new TypeError("Selection must be an object with nodes and/or edges properties");if((t.unselectAll||t.unselectAll===void 0)&&this.unselectAll(),e.nodes)for(let i of e.nodes){let s=this.body.nodes[i];if(!s)throw new RangeError('Node with id "'+i+'" not found');this.selectObject(s,t.highlightEdges)}if(e.edges)for(let i of e.edges){let s=this.body.edges[i];if(!s)throw new RangeError('Edge with id "'+i+'" not found');this.selectObject(s)}this.body.emitter.emit("_requestRedraw"),this._selectionAccumulator.commit()}selectNodes(e,t=!0){if(!e||e.length===void 0)throw"Selection must be an array with ids";this.setSelection({nodes:e},{highlightEdges:t})}selectEdges(e){if(!e||e.length===void 0)throw"Selection must be an array with ids";this.setSelection({edges:e})}updateSelection(){for(let e in this._selectionAccumulator.getNodes())Object.prototype.hasOwnProperty.call(this.body.nodes,e.id)||this._selectionAccumulator.deleteNodes(e);for(let e in this._selectionAccumulator.getEdges())Object.prototype.hasOwnProperty.call(this.body.edges,e.id)||this._selectionAccumulator.deleteEdges(e)}getClickedItems(e){let t=this.canvas.DOMtoCanvas(e),i=[],s=this.body.nodeIndices,o=this.body.nodes;for(let d=s.length-1;d>=0;d--){let l=o[s[d]].getItemsOnPoint(t);i.push.apply(i,l)}let r=this.body.edgeIndices,a=this.body.edges;for(let d=r.length-1;d>=0;d--){let l=a[r[d]].getItemsOnPoint(t);i.push.apply(i,l)}return i}},zi=class{abstract(){throw new Error("Can't instantiate abstract class!")}fake_use(){}curveType(){return this.abstract()}getPosition(e){return this.fake_use(e),this.abstract()}setPosition(e,t,i=void 0){this.fake_use(e,t,i),this.abstract()}getTreeSize(e){return this.fake_use(e),this.abstract()}sort(e){this.fake_use(e),this.abstract()}fix(e,t){this.fake_use(e,t),this.abstract()}shift(e,t){this.fake_use(e,t),this.abstract()}},nn=class extends zi{constructor(e){super();this.layout=e}curveType(){return"horizontal"}getPosition(e){return e.x}setPosition(e,t,i=void 0){i!==void 0&&this.layout.hierarchical.addToOrdering(e,i),e.x=t}getTreeSize(e){let t=this.layout.hierarchical.getTreeSize(this.layout.body.nodes,e);return{min:t.min_x,max:t.max_x}}sort(e){e.sort(function(t,i){return t.x-i.x})}fix(e,t){e.y=this.layout.options.hierarchical.levelSeparation*t,e.options.fixed.y=!0}shift(e,t){this.layout.body.nodes[e].x+=t}},rn=class extends zi{constructor(e){super();this.layout=e}curveType(){return"vertical"}getPosition(e){return e.y}setPosition(e,t,i=void 0){i!==void 0&&this.layout.hierarchical.addToOrdering(e,i),e.y=t}getTreeSize(e){let t=this.layout.hierarchical.getTreeSize(this.layout.body.nodes,e);return{min:t.min_y,max:t.max_y}}sort(e){e.sort(function(t,i){return t.y-i.y})}fix(e,t){e.x=this.layout.options.hierarchical.levelSeparation*t,e.options.fixed.x=!0}shift(e,t){this.layout.body.nodes[e].y+=t}};function Oa(n,e){let t=new Set;return n.forEach(i=>{i.edges.forEach(s=>{s.connected&&t.add(s)})}),t.forEach(i=>{let s=i.from.id,o=i.to.id;e[s]==null&&(e[s]=0),(e[o]==null||e[s]>=e[o])&&(e[o]=e[s]+1)}),e}function Sa(n){return an(e=>e.edges.filter(t=>n.has(t.toId)).every(t=>t.to===e),(e,t)=>t>e,"from",n)}function Ia(n){return an(e=>e.edges.filter(t=>n.has(t.toId)).every(t=>t.from===e),(e,t)=>td+1+h.edges.length,0),r=t+"Id",a=t==="to"?1:-1;for(let[d,h]of i){if(!i.has(d)||!n(h))continue;s[d]=0;let l=[h],c=0,u;for(;u=l.pop();){if(!i.has(d))continue;let f=s[u.id]+a;if(u.edges.filter(p=>p.connected&&p.to!==p.from&&p[t]!==u&&i.has(p.toId)&&i.has(p.fromId)).forEach(p=>{let m=p[r],g=s[m];(g==null||e(f,g))&&(s[m]=f,l.push(p[t]))}),c>o)return Oa(i,s);++c}}return s}var dn=class{constructor(){this.childrenReference={},this.parentReference={},this.trees={},this.distributionOrdering={},this.levels={},this.distributionIndex={},this.isTree=!1,this.treeIndex=-1}addRelation(e,t){this.childrenReference[e]===void 0&&(this.childrenReference[e]=[]),this.childrenReference[e].push(t),this.parentReference[t]===void 0&&(this.parentReference[t]=[]),this.parentReference[t].push(e)}checkIfTree(){for(let e in this.parentReference)if(this.parentReference[e].length>1){this.isTree=!1;return}this.isTree=!0}numTrees(){return this.treeIndex+1}setTreeIndex(e,t){t!==void 0&&this.trees[e.id]===void 0&&(this.trees[e.id]=t,this.treeIndex=Math.max(t,this.treeIndex))}ensureLevel(e){this.levels[e]===void 0&&(this.levels[e]=0)}getMaxLevel(e){let t={},i=s=>{if(t[s]!==void 0)return t[s];let o=this.levels[s];if(this.childrenReference[s]){let r=this.childrenReference[s];if(r.length>0)for(let a=0;a{this.setupHierarchicalLayout()}),this.body.emitter.on("_dataLoaded",()=>{this.layoutNetwork()}),this.body.emitter.on("_resetHierarchicalLayout",()=>{this.setupHierarchicalLayout()}),this.body.emitter.on("_adjustEdgesForHierarchicalLayout",()=>{if(this.options.hierarchical.enabled!==!0)return;let e=this.direction.curveType();this.body.emitter.emit("_forceDisableDynamicCurves",e,!1)})}setOptions(e,t){if(e!==void 0){let i=this.options.hierarchical,s=i.enabled;if(We(["randomSeed","improvedLayout","clusterThreshold"],this.options,e),se(this.options,e,"hierarchical"),e.randomSeed!==void 0&&this._resetRNG(e.randomSeed),i.enabled===!0)return s===!0&&this.body.emitter.emit("refresh",!0),i.direction==="RL"||i.direction==="DU"?i.levelSeparation>0&&(i.levelSeparation*=-1):i.levelSeparation<0&&(i.levelSeparation*=-1),this.setDirectionStrategy(),this.body.emitter.emit("_resetHierarchicalLayout"),this.adaptAllOptionsForHierarchicalLayout(t);if(s===!0)return this.body.emitter.emit("refresh"),D(t,this.optionsBackup)}return t}_resetRNG(e){this.initialRandomSeed=e,this._rng=mt(this.initialRandomSeed)}adaptAllOptionsForHierarchicalLayout(e){if(this.options.hierarchical.enabled===!0){let t=this.optionsBackup.physics;e.physics===void 0||e.physics===!0?(e.physics={enabled:t.enabled===void 0?!0:t.enabled,solver:"hierarchicalRepulsion"},t.enabled=t.enabled===void 0?!0:t.enabled,t.solver=t.solver||"barnesHut"):typeof e.physics=="object"?(t.enabled=e.physics.enabled===void 0?!0:e.physics.enabled,t.solver=e.physics.solver||"barnesHut",e.physics.solver="hierarchicalRepulsion"):e.physics!==!1&&(t.solver="barnesHut",e.physics={solver:"hierarchicalRepulsion"});let i=this.direction.curveType();if(e.edges===void 0)this.optionsBackup.edges={smooth:{enabled:!0,type:"dynamic"}},e.edges={smooth:!1};else if(e.edges.smooth===void 0)this.optionsBackup.edges={smooth:{enabled:!0,type:"dynamic"}},e.edges.smooth=!1;else if(typeof e.edges.smooth=="boolean")this.optionsBackup.edges={smooth:e.edges.smooth},e.edges.smooth={enabled:e.edges.smooth,type:i};else{let s=e.edges.smooth;s.type!==void 0&&s.type!=="dynamic"&&(i=s.type),this.optionsBackup.edges={smooth:{enabled:s.enabled===void 0?!0:s.enabled,type:s.type===void 0?"dynamic":s.type,roundness:s.roundness===void 0?.5:s.roundness,forceDirection:s.forceDirection===void 0?!1:s.forceDirection}},e.edges.smooth={enabled:s.enabled===void 0?!0:s.enabled,type:i,roundness:s.roundness===void 0?.5:s.roundness,forceDirection:s.forceDirection===void 0?!1:s.forceDirection}}this.body.emitter.emit("_forceDisableDynamicCurves",i)}return e}positionInitially(e){if(this.options.hierarchical.enabled!==!0){this._resetRNG(this.initialRandomSeed);let t=e.length+50;for(let i=0;io){let d=e.length;for(;e.length>o&&s<=i;){s+=1;let h=e.length;s%3==0?this.body.modules.clustering.clusterBridges(r):this.body.modules.clustering.clusterOutliers(r);let l=e.length;if(h==l&&s%3!=0){this._declusterAll(),this.body.emitter.emit("_layoutFailed"),console.info("This network could not be positioned by this version of the improved layout algorithm. Please disable improvedLayout for better performance.");return}}this.body.modules.kamadaKawai.setOptions({springLength:Math.max(150,2*d)})}s>i&&console.info("The clustering didn't succeed within the amount of interations allowed, progressing with partial result."),this.body.modules.kamadaKawai.solve(e,this.body.edgeIndices,!0),this._shiftToCenter();let a=70;for(let d=0;d0){let e,t,i=!1,s=!1;this.lastNodeOnLevel={},this.hierarchical=new dn;for(t in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,t)&&(e=this.body.nodes[t],e.options.level!==void 0?(i=!0,this.hierarchical.levels[t]=e.options.level):s=!0);if(s===!0&&i===!0)throw new Error("To use the hierarchical layout, nodes require either no predefined levels or levels have to be defined for all nodes.");{if(s===!0){let r=this.options.hierarchical.sortMethod;r==="hubsize"?this._determineLevelsByHubsize():r==="directed"?this._determineLevelsDirected():r==="custom"&&this._determineLevelsCustomCallback()}for(let r in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,r)&&this.hierarchical.ensureLevel(r);let o=this._getDistribution();this._generateMap(),this._placeNodesByHierarchy(o),this._condenseHierarchy(),this._shiftToCenter()}}}_condenseHierarchy(){let e=!1,t={},i=()=>{let g=o(),b=0;for(let v=0;v{let v=this.hierarchical.trees;for(let E in v)Object.prototype.hasOwnProperty.call(v,E)&&v[E]===g&&this.direction.shift(E,b)},o=()=>{let g=[];for(let b=0;b{if(!b[g.id]&&(b[g.id]=!0,this.hierarchical.childrenReference[g.id])){let v=this.hierarchical.childrenReference[g.id];if(v.length>0)for(let E=0;E{let v=1e9,E=1e9,C=1e9,O=-1e9;for(let S in g)if(Object.prototype.hasOwnProperty.call(g,S)){let M=this.body.nodes[S],R=this.hierarchical.levels[M.id],j=this.direction.getPosition(M),[ce,Ye]=this._getSpaceAroundNode(M,g);v=Math.min(ce,v),E=Math.min(Ye,E),R<=b&&(C=Math.min(j,C),O=Math.max(j,O))}return[C,O,v,E]},d=(g,b)=>{let v=this.hierarchical.getMaxLevel(g.id),E=this.hierarchical.getMaxLevel(b.id);return Math.min(v,E)},h=(g,b,v)=>{let E=this.hierarchical;for(let C=0;C1)for(let M=0;M{let E=this.direction.getPosition(g),C=this.direction.getPosition(b),O=Math.abs(C-E),S=this.options.hierarchical.nodeSpacing;if(O>S){let M={},R={};r(g,M),r(b,R);let j=d(g,b),ce=a(M,j),Ye=a(R,j),Ct=ce[1],Xe=Ye[0],V=Ye[2];if(Math.abs(Ct-Xe)>S){let N=Ct-Xe+S;N<-V+S&&(N=-V+S),N<0&&(this._shiftBlock(b.id,N),e=!0,v===!0&&this._centerParent(b))}}},c=(g,b)=>{let v=b.id,E=b.edges,C=this.hierarchical.levels[b.id],O=this.options.hierarchical.levelSeparation*this.options.hierarchical.levelSeparation,S={},M=[];for(let V=0;V{let N=0;for(let Y=0;Y{let N=0;for(let Y=0;Y{let N=this.direction.getPosition(b),Y={};for(let K=0;K{let F=this.direction.getPosition(b);if(t[b.id]===void 0){let st={};r(b,st),t[b.id]=st}let N=a(t[b.id]),Y=N[2],K=N[3],de=V-F,Ge=0;de>0?Ge=Math.min(de,K-this.options.hierarchical.nodeSpacing):de<0&&(Ge=-Math.min(-de,Y-this.options.hierarchical.nodeSpacing)),Ge!=0&&(this._shiftBlock(b.id,Ge),e=!0)},Ct=V=>{let F=this.direction.getPosition(b),[N,Y]=this._getSpaceAroundNode(b),K=V-F,de=F;K>0?de=Math.min(F+(Y-this.options.hierarchical.nodeSpacing),V):K<0&&(de=Math.max(F-(N-this.options.hierarchical.nodeSpacing),V)),de!==F&&(this.direction.setPosition(b,de),e=!0)},Xe=ce(g,M);Ye(Xe),Xe=ce(g,E),Ct(Xe)},u=g=>{let b=this.hierarchical.getLevels();b=b.reverse();for(let v=0;v{let b=this.hierarchical.getLevels();b=b.reverse();for(let v=0;v{for(let g in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,g)&&this._centerParent(this.body.nodes[g])},m=()=>{let g=this.hierarchical.getLevels();g=g.reverse();for(let b=0;b0&&Math.abs(c)0&&(d=this.direction.getPosition(i[o-1])+a),this.direction.setPosition(r,d,t),this._validatePositionAndContinue(r,t,d),s++}}}}_placeBranchNodes(e,t){let i=this.hierarchical.childrenReference[e];if(i===void 0)return;let s=[];for(let r=0;rt&&this.positionedNodes[a.id]===void 0){let h=this.options.hierarchical.nodeSpacing,l;r===0?l=this.direction.getPosition(this.body.nodes[e]):l=this.direction.getPosition(s[r-1])+h,this.direction.setPosition(a,l,d),this._validatePositionAndContinue(a,d,l)}else return}let o=this._getCenterPosition(s);this.direction.setPosition(this.body.nodes[e],o,t)}_validatePositionAndContinue(e,t,i){if(!!this.hierarchical.isTree){if(this.lastNodeOnLevel[t]!==void 0){let s=this.direction.getPosition(this.body.nodes[this.lastNodeOnLevel[t]]);if(i-s{this.body.edgeIndices.indexOf(i.id)!==-1&&t.push(i)}),t}_getHubSizes(){let e={},t=this.body.nodeIndices;I(t,s=>{let o=this.body.nodes[s],r=this._getActiveEdges(o).length;e[r]=!0});let i=[];return I(e,s=>{i.push(Number(s))}),i.sort(function(s,o){return o-s}),i}_determineLevelsByHubsize(){let e=(i,s)=>{this.hierarchical.levelDownstream(i,s)},t=this._getHubSizes();for(let i=0;i{let r=this.body.nodes[o];s===this._getActiveEdges(r).length&&this._crawlNetwork(e,o)})}}_determineLevelsCustomCallback(){let e=1e5,t=function(s,o,r){},i=(s,o,r)=>{let a=this.hierarchical.levels[s.id];a===void 0&&(a=this.hierarchical.levels[s.id]=e);let d=t(G.cloneOptions(s,"node"),G.cloneOptions(o,"node"),G.cloneOptions(r,"edge"));this.hierarchical.levels[o.id]=a+d};this._crawlNetwork(i),this.hierarchical.setMinLevelToZero(this.body.nodes)}_determineLevelsDirected(){let e=this.body.nodeIndices.reduce((t,i)=>(t.set(i,this.body.nodes[i]),t),new Map);this.options.hierarchical.shakeTowards==="roots"?this.hierarchical.levels=Ia(e):this.hierarchical.levels=Sa(e),this.hierarchical.setMinLevelToZero(this.body.nodes)}_generateMap(){let e=(t,i)=>{this.hierarchical.levels[i.id]>this.hierarchical.levels[t.id]&&this.hierarchical.addRelation(t.id,i.id)};this._crawlNetwork(e),this.hierarchical.checkIfTree()}_crawlNetwork(e=function(){},t){let i={},s=(o,r)=>{if(i[o.id]===void 0){this.hierarchical.setTreeIndex(o,r),i[o.id]=!0;let a,d=this._getActiveEdges(o);for(let h=0;h{if(i[o])return;i[o]=!0,this.direction.shift(o,t);let r=this.hierarchical.childrenReference[o];if(r!==void 0)for(let a=0;a{let d=this.hierarchical.parentReference[a];if(d!==void 0)for(let h=0;h{let d=this.hierarchical.parentReference[a];if(d!==void 0)for(let h=0;h{this._clean()}),this.body.emitter.on("_dataChanged",this._restore.bind(this)),this.body.emitter.on("_resetData",this._restore.bind(this))}_restore(){this.inMode!==!1&&(this.options.initiallyActive===!0?this.enableEditMode():this.disableEditMode())}setOptions(e,t,i){t!==void 0&&(t.locale!==void 0?this.options.locale=t.locale:this.options.locale=i.locale,t.locales!==void 0?this.options.locales=t.locales:this.options.locales=i.locales),e!==void 0&&(typeof e=="boolean"?this.options.enabled=e:(this.options.enabled=!0,D(this.options,e)),this.options.initiallyActive===!0&&(this.editMode=!0),this._setup())}toggleEditMode(){this.editMode===!0?this.disableEditMode():this.enableEditMode()}enableEditMode(){this.editMode=!0,this._clean(),this.guiEnabled===!0&&(this.manipulationDiv.style.display="block",this.closeDiv.style.display="block",this.editModeDiv.style.display="none",this.showManipulatorToolbar())}disableEditMode(){this.editMode=!1,this._clean(),this.guiEnabled===!0&&(this.manipulationDiv.style.display="none",this.closeDiv.style.display="none",this.editModeDiv.style.display="block",this._createEditButton())}showManipulatorToolbar(){if(this._clean(),this.manipulationDOM={},this.guiEnabled===!0){this.editMode=!0,this.manipulationDiv.style.display="block",this.closeDiv.style.display="block";let e=this.selectionHandler.getSelectedNodeCount(),t=this.selectionHandler.getSelectedEdgeCount(),i=e+t,s=this.options.locales[this.options.locale],o=!1;this.options.addNode!==!1&&(this._createAddNodeButton(s),o=!0),this.options.addEdge!==!1&&(o===!0?this._createSeperator(1):o=!0,this._createAddEdgeButton(s)),e===1&&typeof this.options.editNode=="function"?(o===!0?this._createSeperator(2):o=!0,this._createEditNodeButton(s)):t===1&&e===0&&this.options.editEdge!==!1&&(o===!0?this._createSeperator(3):o=!0,this._createEditEdgeButton(s)),i!==0&&(e>0&&this.options.deleteNode!==!1?(o===!0&&this._createSeperator(4),this._createDeleteButton(s)):e===0&&this.options.deleteEdge!==!1&&(o===!0&&this._createSeperator(4),this._createDeleteButton(s))),this._bindElementEvents(this.closeDiv,this.toggleEditMode.bind(this)),this._temporaryBindEvent("select",this.showManipulatorToolbar.bind(this))}this.body.emitter.emit("_redraw")}addNodeMode(){if(this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="addNode",this.guiEnabled===!0){let e=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(e),this._createSeperator(),this._createDescription(e.addDescription||this.options.locales.en.addDescription),this._bindElementEvents(this.closeDiv,this.toggleEditMode.bind(this))}this._temporaryBindEvent("click",this._performAddNode.bind(this))}editNode(){this.editMode!==!0&&this.enableEditMode(),this._clean();let e=this.selectionHandler.getSelectedNodes()[0];if(e!==void 0)if(this.inMode="editNode",typeof this.options.editNode=="function")if(e.isCluster!==!0){let t=D({},e.options,!1);if(t.x=e.x,t.y=e.y,this.options.editNode.length===2)this.options.editNode(t,i=>{i!=null&&this.inMode==="editNode"&&this.body.data.nodes.getDataSet().update(i),this.showManipulatorToolbar()});else throw new Error("The function for edit does not support two arguments (data, callback)")}else alert(this.options.locales[this.options.locale].editClusterError||this.options.locales.en.editClusterError);else throw new Error("No function has been configured to handle the editing of nodes.");else this.showManipulatorToolbar()}addEdgeMode(){if(this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="addEdge",this.guiEnabled===!0){let e=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(e),this._createSeperator(),this._createDescription(e.edgeDescription||this.options.locales.en.edgeDescription),this._bindElementEvents(this.closeDiv,this.toggleEditMode.bind(this))}this._temporaryBindUI("onTouch",this._handleConnect.bind(this)),this._temporaryBindUI("onDragEnd",this._finishConnect.bind(this)),this._temporaryBindUI("onDrag",this._dragControlNode.bind(this)),this._temporaryBindUI("onRelease",this._finishConnect.bind(this)),this._temporaryBindUI("onDragStart",this._dragStartEdge.bind(this)),this._temporaryBindUI("onHold",()=>{})}editEdgeMode(){if(this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="editEdge",typeof this.options.editEdge=="object"&&typeof this.options.editEdge.editWithoutDrag=="function"&&(this.edgeBeingEditedId=this.selectionHandler.getSelectedEdgeIds()[0],this.edgeBeingEditedId!==void 0)){let e=this.body.edges[this.edgeBeingEditedId];this._performEditEdge(e.from.id,e.to.id);return}if(this.guiEnabled===!0){let e=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(e),this._createSeperator(),this._createDescription(e.editEdgeDescription||this.options.locales.en.editEdgeDescription),this._bindElementEvents(this.closeDiv,this.toggleEditMode.bind(this))}if(this.edgeBeingEditedId=this.selectionHandler.getSelectedEdgeIds()[0],this.edgeBeingEditedId!==void 0){let e=this.body.edges[this.edgeBeingEditedId],t=this._getNewTargetNode(e.from.x,e.from.y),i=this._getNewTargetNode(e.to.x,e.to.y);this.temporaryIds.nodes.push(t.id),this.temporaryIds.nodes.push(i.id),this.body.nodes[t.id]=t,this.body.nodeIndices.push(t.id),this.body.nodes[i.id]=i,this.body.nodeIndices.push(i.id),this._temporaryBindUI("onTouch",this._controlNodeTouch.bind(this)),this._temporaryBindUI("onTap",()=>{}),this._temporaryBindUI("onHold",()=>{}),this._temporaryBindUI("onDragStart",this._controlNodeDragStart.bind(this)),this._temporaryBindUI("onDrag",this._controlNodeDrag.bind(this)),this._temporaryBindUI("onDragEnd",this._controlNodeDragEnd.bind(this)),this._temporaryBindUI("onMouseMove",()=>{}),this._temporaryBindEvent("beforeDrawing",s=>{let o=e.edgeType.findBorderPositions(s);t.selected===!1&&(t.x=o.from.x,t.y=o.from.y),i.selected===!1&&(i.x=o.to.x,i.y=o.to.y)}),this.body.emitter.emit("_redraw")}else this.showManipulatorToolbar()}deleteSelected(){this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="delete";let e=this.selectionHandler.getSelectedNodeIds(),t=this.selectionHandler.getSelectedEdgeIds(),i;if(e.length>0){for(let s=0;s0&&typeof this.options.deleteEdge=="function"&&(i=this.options.deleteEdge);if(typeof i=="function"){let s={nodes:e,edges:t};if(i.length===2)i(s,o=>{o!=null&&this.inMode==="delete"?(this.body.data.edges.getDataSet().remove(o.edges),this.body.data.nodes.getDataSet().remove(o.nodes),this.body.emitter.emit("startSimulation"),this.showManipulatorToolbar()):(this.body.emitter.emit("startSimulation"),this.showManipulatorToolbar())});else throw new Error("The function for delete does not support two arguments (data, callback)")}else this.body.data.edges.getDataSet().remove(t),this.body.data.nodes.getDataSet().remove(e),this.body.emitter.emit("startSimulation"),this.showManipulatorToolbar()}_setup(){this.options.enabled===!0?(this.guiEnabled=!0,this._createWrappers(),this.editMode===!1?this._createEditButton():this.showManipulatorToolbar()):(this._removeManipulationDOM(),this.guiEnabled=!1)}_createWrappers(){var e,t;this.manipulationDiv===void 0&&(this.manipulationDiv=document.createElement("div"),this.manipulationDiv.className="vis-manipulation",this.editMode===!0?this.manipulationDiv.style.display="block":this.manipulationDiv.style.display="none",this.canvas.frame.appendChild(this.manipulationDiv)),this.editModeDiv===void 0&&(this.editModeDiv=document.createElement("div"),this.editModeDiv.className="vis-edit-mode",this.editMode===!0?this.editModeDiv.style.display="none":this.editModeDiv.style.display="block",this.canvas.frame.appendChild(this.editModeDiv)),this.closeDiv===void 0&&(this.closeDiv=document.createElement("button"),this.closeDiv.className="vis-close",this.closeDiv.setAttribute("aria-label",(t=(e=this.options.locales[this.options.locale])==null?void 0:e.close)!=null?t:this.options.locales.en.close),this.closeDiv.style.display=this.manipulationDiv.style.display,this.canvas.frame.appendChild(this.closeDiv))}_getNewTargetNode(e,t){let i=D({},this.options.controlNodeStyle);i.id="targetNode"+Ee(),i.hidden=!1,i.physics=!1,i.x=e,i.y=t;let s=this.body.functions.createNode(i);return s.shape.boundingBox={left:e,right:e,top:t,bottom:t},s}_createEditButton(){this._clean(),this.manipulationDOM={},be(this.editModeDiv);let e=this.options.locales[this.options.locale],t=this._createButton("editMode","vis-edit vis-edit-mode",e.edit||this.options.locales.en.edit);this.editModeDiv.appendChild(t),this._bindElementEvents(t,this.toggleEditMode.bind(this))}_clean(){this.inMode=!1,this.guiEnabled===!0&&(be(this.editModeDiv),be(this.manipulationDiv),this._cleanupDOMEventListeners()),this._cleanupTemporaryNodesAndEdges(),this._unbindTemporaryUIs(),this._unbindTemporaryEvents(),this.body.emitter.emit("restorePhysics")}_cleanupDOMEventListeners(){for(let e of this._domEventListenerCleanupQueue.splice(0))e()}_removeManipulationDOM(){this._clean(),be(this.manipulationDiv),be(this.editModeDiv),be(this.closeDiv),this.manipulationDiv&&this.canvas.frame.removeChild(this.manipulationDiv),this.editModeDiv&&this.canvas.frame.removeChild(this.editModeDiv),this.closeDiv&&this.canvas.frame.removeChild(this.closeDiv),this.manipulationDiv=void 0,this.editModeDiv=void 0,this.closeDiv=void 0}_createSeperator(e=1){this.manipulationDOM["seperatorLineDiv"+e]=document.createElement("div"),this.manipulationDOM["seperatorLineDiv"+e].className="vis-separator-line",this.manipulationDiv.appendChild(this.manipulationDOM["seperatorLineDiv"+e])}_createAddNodeButton(e){let t=this._createButton("addNode","vis-add",e.addNode||this.options.locales.en.addNode);this.manipulationDiv.appendChild(t),this._bindElementEvents(t,this.addNodeMode.bind(this))}_createAddEdgeButton(e){let t=this._createButton("addEdge","vis-connect",e.addEdge||this.options.locales.en.addEdge);this.manipulationDiv.appendChild(t),this._bindElementEvents(t,this.addEdgeMode.bind(this))}_createEditNodeButton(e){let t=this._createButton("editNode","vis-edit",e.editNode||this.options.locales.en.editNode);this.manipulationDiv.appendChild(t),this._bindElementEvents(t,this.editNode.bind(this))}_createEditEdgeButton(e){let t=this._createButton("editEdge","vis-edit",e.editEdge||this.options.locales.en.editEdge);this.manipulationDiv.appendChild(t),this._bindElementEvents(t,this.editEdgeMode.bind(this))}_createDeleteButton(e){let t;this.options.rtl?t="vis-delete-rtl":t="vis-delete";let i=this._createButton("delete",t,e.del||this.options.locales.en.del);this.manipulationDiv.appendChild(i),this._bindElementEvents(i,this.deleteSelected.bind(this))}_createBackButton(e){let t=this._createButton("back","vis-back",e.back||this.options.locales.en.back);this.manipulationDiv.appendChild(t),this._bindElementEvents(t,this.showManipulatorToolbar.bind(this))}_createButton(e,t,i,s="vis-label"){return this.manipulationDOM[e+"Div"]=document.createElement("button"),this.manipulationDOM[e+"Div"].className="vis-button "+t,this.manipulationDOM[e+"Label"]=document.createElement("div"),this.manipulationDOM[e+"Label"].className=s,this.manipulationDOM[e+"Label"].innerText=i,this.manipulationDOM[e+"Div"].appendChild(this.manipulationDOM[e+"Label"]),this.manipulationDOM[e+"Div"]}_createDescription(e){this.manipulationDOM.descriptionLabel=document.createElement("div"),this.manipulationDOM.descriptionLabel.className="vis-none",this.manipulationDOM.descriptionLabel.innerText=e,this.manipulationDiv.appendChild(this.manipulationDOM.descriptionLabel)}_temporaryBindEvent(e,t){this.temporaryEventFunctions.push({event:e,boundFunction:t}),this.body.emitter.on(e,t)}_temporaryBindUI(e,t){if(this.body.eventListeners[e]!==void 0)this.temporaryUIFunctions[e]=this.body.eventListeners[e],this.body.eventListeners[e]=t;else throw new Error("This UI function does not exist. Typo? You tried: "+e+" possible are: "+JSON.stringify(Object.keys(this.body.eventListeners)))}_unbindTemporaryUIs(){for(let e in this.temporaryUIFunctions)Object.prototype.hasOwnProperty.call(this.temporaryUIFunctions,e)&&(this.body.eventListeners[e]=this.temporaryUIFunctions[e],delete this.temporaryUIFunctions[e]);this.temporaryUIFunctions={}}_unbindTemporaryEvents(){for(let e=0;e{i.destroy()});let s=({keyCode:o,key:r})=>{(r==="Enter"||r===" "||o===13||o===32)&&t()};e.addEventListener("keyup",s,!1),this._domEventListenerCleanupQueue.push(()=>{e.removeEventListener("keyup",s,!1)})}_cleanupTemporaryNodesAndEdges(){for(let e=0;e=0;a--)if(o[a]!==this.selectedControlNode.id){r=this.body.nodes[o[a]];break}if(r!==void 0&&this.selectedControlNode!==void 0)if(r.isCluster===!0)alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError);else{let a=this.body.nodes[this.temporaryIds.nodes[0]];this.selectedControlNode.id===a.id?this._performEditEdge(r.id,s.to.id):this._performEditEdge(s.from.id,r.id)}else s.updateEdgeType(),this.body.emitter.emit("restorePhysics");this.body.emitter.emit("_redraw")}_handleConnect(e){if(new Date().valueOf()-this.touchTime>100){this.lastTouch=this.body.functions.getPointer(e.center),this.lastTouch.translation=Object.assign({},this.body.view.translation),this.interactionHandler.drag.pointer=this.lastTouch,this.interactionHandler.drag.translation=this.lastTouch.translation;let t=this.lastTouch,i=this.selectionHandler.getNodeAt(t);if(i!==void 0)if(i.isCluster===!0)alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError);else{let s=this._getNewTargetNode(i.x,i.y);this.body.nodes[s.id]=s,this.body.nodeIndices.push(s.id);let o=this.body.functions.createEdge({id:"connectionEdge"+Ee(),from:i.id,to:s.id,physics:!1,smooth:{enabled:!0,type:"continuous",roundness:.5}});this.body.edges[o.id]=o,this.body.edgeIndices.push(o.id),this.temporaryIds.nodes.push(s.id),this.temporaryIds.edges.push(o.id)}this.touchTime=new Date().valueOf()}}_dragControlNode(e){let t=this.body.functions.getPointer(e.center),i=this.selectionHandler._pointerToPositionObject(t),s;this.temporaryIds.edges[0]!==void 0&&(s=this.body.edges[this.temporaryIds.edges[0]].fromId);let o=this.selectionHandler._getAllNodesOverlappingWith(i),r;for(let a=o.length-1;a>=0;a--)if(this.temporaryIds.nodes.indexOf(o[a])===-1){r=this.body.nodes[o[a]];break}if(e.controlEdge={from:s,to:r?r.id:void 0},this.selectionHandler.generateClickEvent("controlNodeDragging",e,t),this.temporaryIds.nodes[0]!==void 0){let a=this.body.nodes[this.temporaryIds.nodes[0]];a.x=this.canvas._XconvertDOMtoCanvas(t.x),a.y=this.canvas._YconvertDOMtoCanvas(t.y),this.body.emitter.emit("_redraw")}else this.interactionHandler.onDrag(e)}_finishConnect(e){let t=this.body.functions.getPointer(e.center),i=this.selectionHandler._pointerToPositionObject(t),s;this.temporaryIds.edges[0]!==void 0&&(s=this.body.edges[this.temporaryIds.edges[0]].fromId);let o=this.selectionHandler._getAllNodesOverlappingWith(i),r;for(let a=o.length-1;a>=0;a--)if(this.temporaryIds.nodes.indexOf(o[a])===-1){r=this.body.nodes[o[a]];break}this._cleanupTemporaryNodesAndEdges(),r!==void 0&&(r.isCluster===!0?alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError):this.body.nodes[s]!==void 0&&this.body.nodes[r.id]!==void 0&&this._performAddEdge(s,r.id)),e.controlEdge={from:s,to:r?r.id:void 0},this.selectionHandler.generateClickEvent("controlNodeDragEnd",e,t),this.body.emitter.emit("_redraw")}_dragStartEdge(e){let t=this.lastTouch;this.selectionHandler.generateClickEvent("dragStart",e,t,void 0,!0)}_performAddNode(e){let t={id:Ee(),x:e.pointer.canvas.x,y:e.pointer.canvas.y,label:"new"};if(typeof this.options.addNode=="function")if(this.options.addNode.length===2)this.options.addNode(t,i=>{i!=null&&this.inMode==="addNode"&&this.body.data.nodes.getDataSet().add(i),this.showManipulatorToolbar()});else throw this.showManipulatorToolbar(),new Error("The function for add does not support two arguments (data,callback)");else this.body.data.nodes.getDataSet().add(t),this.showManipulatorToolbar()}_performAddEdge(e,t){let i={from:e,to:t};if(typeof this.options.addEdge=="function")if(this.options.addEdge.length===2)this.options.addEdge(i,s=>{s!=null&&this.inMode==="addEdge"&&(this.body.data.edges.getDataSet().add(s),this.selectionHandler.unselectAll(),this.showManipulatorToolbar())});else throw new Error("The function for connect does not support two arguments (data,callback)");else this.body.data.edges.getDataSet().add(i),this.selectionHandler.unselectAll(),this.showManipulatorToolbar()}_performEditEdge(e,t){let i={id:this.edgeBeingEditedId,from:e,to:t,label:this.body.data.edges.get(this.edgeBeingEditedId).label},s=this.options.editEdge;if(typeof s=="object"&&(s=s.editWithoutDrag),typeof s=="function")if(s.length===2)s(i,o=>{o==null||this.inMode!=="editEdge"?(this.body.edges[i.id].updateEdgeType(),this.body.emitter.emit("_redraw"),this.showManipulatorToolbar()):(this.body.data.edges.getDataSet().update(o),this.selectionHandler.unselectAll(),this.showManipulatorToolbar())});else throw new Error("The function for edit does not support two arguments (data, callback)");else this.body.data.edges.getDataSet().update(i),this.selectionHandler.unselectAll(),this.showManipulatorToolbar()}},_="string",w="boolean",y="number",xt="array",T="object",cn="dom",Pa="any",Ri=["arrow","bar","box","circle","crow","curve","diamond","image","inv_curve","inv_triangle","triangle","vee"],Li={borderWidth:{number:y},borderWidthSelected:{number:y,undefined:"undefined"},brokenImage:{string:_,undefined:"undefined"},chosen:{label:{boolean:w,function:"function"},node:{boolean:w,function:"function"},__type__:{object:T,boolean:w}},color:{border:{string:_},background:{string:_},highlight:{border:{string:_},background:{string:_},__type__:{object:T,string:_}},hover:{border:{string:_},background:{string:_},__type__:{object:T,string:_}},__type__:{object:T,string:_}},opacity:{number:y,undefined:"undefined"},fixed:{x:{boolean:w},y:{boolean:w},__type__:{object:T,boolean:w}},font:{align:{string:_},color:{string:_},size:{number:y},face:{string:_},background:{string:_},strokeWidth:{number:y},strokeColor:{string:_},vadjust:{number:y},multi:{boolean:w,string:_},bold:{color:{string:_},size:{number:y},face:{string:_},mod:{string:_},vadjust:{number:y},__type__:{object:T,string:_}},boldital:{color:{string:_},size:{number:y},face:{string:_},mod:{string:_},vadjust:{number:y},__type__:{object:T,string:_}},ital:{color:{string:_},size:{number:y},face:{string:_},mod:{string:_},vadjust:{number:y},__type__:{object:T,string:_}},mono:{color:{string:_},size:{number:y},face:{string:_},mod:{string:_},vadjust:{number:y},__type__:{object:T,string:_}},__type__:{object:T,string:_}},group:{string:_,number:y,undefined:"undefined"},heightConstraint:{minimum:{number:y},valign:{string:_},__type__:{object:T,boolean:w,number:y}},hidden:{boolean:w},icon:{face:{string:_},code:{string:_},size:{number:y},color:{string:_},weight:{string:_,number:y},__type__:{object:T}},id:{string:_,number:y},image:{selected:{string:_,undefined:"undefined"},unselected:{string:_,undefined:"undefined"},__type__:{object:T,string:_}},imagePadding:{top:{number:y},right:{number:y},bottom:{number:y},left:{number:y},__type__:{object:T,number:y}},label:{string:_,undefined:"undefined"},labelHighlightBold:{boolean:w},level:{number:y,undefined:"undefined"},margin:{top:{number:y},right:{number:y},bottom:{number:y},left:{number:y},__type__:{object:T,number:y}},mass:{number:y},physics:{boolean:w},scaling:{min:{number:y},max:{number:y},label:{enabled:{boolean:w},min:{number:y},max:{number:y},maxVisible:{number:y},drawThreshold:{number:y},__type__:{object:T,boolean:w}},customScalingFunction:{function:"function"},__type__:{object:T}},shadow:{enabled:{boolean:w},color:{string:_},size:{number:y},x:{number:y},y:{number:y},__type__:{object:T,boolean:w}},shape:{string:["custom","ellipse","circle","database","box","text","image","circularImage","diamond","dot","star","triangle","triangleDown","square","icon","hexagon"]},ctxRenderer:{function:"function"},shapeProperties:{borderDashes:{boolean:w,array:xt},borderRadius:{number:y},interpolation:{boolean:w},useImageSize:{boolean:w},useBorderWithImage:{boolean:w},coordinateOrigin:{string:["center","top-left"]},__type__:{object:T}},size:{number:y},title:{string:_,dom:cn,undefined:"undefined"},value:{number:y,undefined:"undefined"},widthConstraint:{minimum:{number:y},maximum:{number:y},__type__:{object:T,boolean:w,number:y}},x:{number:y},y:{number:y},__type__:{object:T}},Ma={configure:{enabled:{boolean:w},filter:{boolean:w,string:_,array:xt,function:"function"},container:{dom:cn},showButton:{boolean:w},__type__:{object:T,boolean:w,string:_,array:xt,function:"function"}},edges:{arrows:{to:{enabled:{boolean:w},scaleFactor:{number:y},type:{string:Ri},imageHeight:{number:y},imageWidth:{number:y},src:{string:_},__type__:{object:T,boolean:w}},middle:{enabled:{boolean:w},scaleFactor:{number:y},type:{string:Ri},imageWidth:{number:y},imageHeight:{number:y},src:{string:_},__type__:{object:T,boolean:w}},from:{enabled:{boolean:w},scaleFactor:{number:y},type:{string:Ri},imageWidth:{number:y},imageHeight:{number:y},src:{string:_},__type__:{object:T,boolean:w}},__type__:{string:["from","to","middle"],object:T}},endPointOffset:{from:{number:y},to:{number:y},__type__:{object:T,number:y}},arrowStrikethrough:{boolean:w},background:{enabled:{boolean:w},color:{string:_},size:{number:y},dashes:{boolean:w,array:xt},__type__:{object:T,boolean:w}},chosen:{label:{boolean:w,function:"function"},edge:{boolean:w,function:"function"},__type__:{object:T,boolean:w}},color:{color:{string:_},highlight:{string:_},hover:{string:_},inherit:{string:["from","to","both"],boolean:w},opacity:{number:y},__type__:{object:T,string:_}},dashes:{boolean:w,array:xt},font:{color:{string:_},size:{number:y},face:{string:_},background:{string:_},strokeWidth:{number:y},strokeColor:{string:_},align:{string:["horizontal","top","middle","bottom"]},vadjust:{number:y},multi:{boolean:w,string:_},bold:{color:{string:_},size:{number:y},face:{string:_},mod:{string:_},vadjust:{number:y},__type__:{object:T,string:_}},boldital:{color:{string:_},size:{number:y},face:{string:_},mod:{string:_},vadjust:{number:y},__type__:{object:T,string:_}},ital:{color:{string:_},size:{number:y},face:{string:_},mod:{string:_},vadjust:{number:y},__type__:{object:T,string:_}},mono:{color:{string:_},size:{number:y},face:{string:_},mod:{string:_},vadjust:{number:y},__type__:{object:T,string:_}},__type__:{object:T,string:_}},hidden:{boolean:w},hoverWidth:{function:"function",number:y},label:{string:_,undefined:"undefined"},labelHighlightBold:{boolean:w},length:{number:y,undefined:"undefined"},physics:{boolean:w},scaling:{min:{number:y},max:{number:y},label:{enabled:{boolean:w},min:{number:y},max:{number:y},maxVisible:{number:y},drawThreshold:{number:y},__type__:{object:T,boolean:w}},customScalingFunction:{function:"function"},__type__:{object:T}},selectionWidth:{function:"function",number:y},selfReferenceSize:{number:y},selfReference:{size:{number:y},angle:{number:y},renderBehindTheNode:{boolean:w},__type__:{object:T}},shadow:{enabled:{boolean:w},color:{string:_},size:{number:y},x:{number:y},y:{number:y},__type__:{object:T,boolean:w}},smooth:{enabled:{boolean:w},type:{string:["dynamic","continuous","discrete","diagonalCross","straightCross","horizontal","vertical","curvedCW","curvedCCW","cubicBezier"]},roundness:{number:y},forceDirection:{string:["horizontal","vertical","none"],boolean:w},__type__:{object:T,boolean:w}},title:{string:_,undefined:"undefined"},width:{number:y},widthConstraint:{maximum:{number:y},__type__:{object:T,boolean:w,number:y}},value:{number:y,undefined:"undefined"},__type__:{object:T}},groups:{useDefaultGroups:{boolean:w},__any__:Li,__type__:{object:T}},interaction:{dragNodes:{boolean:w},dragView:{boolean:w},hideEdgesOnDrag:{boolean:w},hideEdgesOnZoom:{boolean:w},hideNodesOnDrag:{boolean:w},hover:{boolean:w},keyboard:{enabled:{boolean:w},speed:{x:{number:y},y:{number:y},zoom:{number:y},__type__:{object:T}},bindToWindow:{boolean:w},autoFocus:{boolean:w},__type__:{object:T,boolean:w}},multiselect:{boolean:w},navigationButtons:{boolean:w},selectable:{boolean:w},selectConnectedEdges:{boolean:w},hoverConnectedEdges:{boolean:w},tooltipDelay:{number:y},zoomView:{boolean:w},zoomSpeed:{number:y},__type__:{object:T}},layout:{randomSeed:{undefined:"undefined",number:y,string:_},improvedLayout:{boolean:w},clusterThreshold:{number:y},hierarchical:{enabled:{boolean:w},levelSeparation:{number:y},nodeSpacing:{number:y},treeSpacing:{number:y},blockShifting:{boolean:w},edgeMinimization:{boolean:w},parentCentralization:{boolean:w},direction:{string:["UD","DU","LR","RL"]},sortMethod:{string:["hubsize","directed"]},shakeTowards:{string:["leaves","roots"]},__type__:{object:T,boolean:w}},__type__:{object:T}},manipulation:{enabled:{boolean:w},initiallyActive:{boolean:w},addNode:{boolean:w,function:"function"},addEdge:{boolean:w,function:"function"},editNode:{function:"function"},editEdge:{editWithoutDrag:{function:"function"},__type__:{object:T,boolean:w,function:"function"}},deleteNode:{boolean:w,function:"function"},deleteEdge:{boolean:w,function:"function"},controlNodeStyle:Li,__type__:{object:T,boolean:w}},nodes:Li,physics:{enabled:{boolean:w},barnesHut:{theta:{number:y},gravitationalConstant:{number:y},centralGravity:{number:y},springLength:{number:y},springConstant:{number:y},damping:{number:y},avoidOverlap:{number:y},__type__:{object:T}},forceAtlas2Based:{theta:{number:y},gravitationalConstant:{number:y},centralGravity:{number:y},springLength:{number:y},springConstant:{number:y},damping:{number:y},avoidOverlap:{number:y},__type__:{object:T}},repulsion:{centralGravity:{number:y},springLength:{number:y},springConstant:{number:y},nodeDistance:{number:y},damping:{number:y},__type__:{object:T}},hierarchicalRepulsion:{centralGravity:{number:y},springLength:{number:y},springConstant:{number:y},nodeDistance:{number:y},damping:{number:y},avoidOverlap:{number:y},__type__:{object:T}},maxVelocity:{number:y},minVelocity:{number:y},solver:{string:["barnesHut","repulsion","hierarchicalRepulsion","forceAtlas2Based"]},stabilization:{enabled:{boolean:w},iterations:{number:y},updateInterval:{number:y},onlyDynamicEdges:{boolean:w},fit:{boolean:w},__type__:{object:T,boolean:w}},timestep:{number:y},adaptiveTimestep:{boolean:w},wind:{x:{number:y},y:{number:y},__type__:{object:T}},__type__:{object:T,boolean:w}},autoResize:{boolean:w},clickToUse:{boolean:w},locale:{string:_},locales:{__any__:{any:Pa},__type__:{object:T}},height:{string:_},width:{string:_},__type__:{object:T}},un={nodes:{borderWidth:[1,0,10,1],borderWidthSelected:[2,0,10,1],color:{border:["color","#2B7CE9"],background:["color","#97C2FC"],highlight:{border:["color","#2B7CE9"],background:["color","#D2E5FF"]},hover:{border:["color","#2B7CE9"],background:["color","#D2E5FF"]}},opacity:[0,0,1,.1],fixed:{x:!1,y:!1},font:{color:["color","#343434"],size:[14,0,100,1],face:["arial","verdana","tahoma"],background:["color","none"],strokeWidth:[0,0,50,1],strokeColor:["color","#ffffff"]},hidden:!1,labelHighlightBold:!0,physics:!0,scaling:{min:[10,0,200,1],max:[30,0,200,1],label:{enabled:!1,min:[14,0,200,1],max:[30,0,200,1],maxVisible:[30,0,200,1],drawThreshold:[5,0,20,1]}},shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:[10,0,20,1],x:[5,-30,30,1],y:[5,-30,30,1]},shape:["ellipse","box","circle","database","diamond","dot","square","star","text","triangle","triangleDown","hexagon"],shapeProperties:{borderDashes:!1,borderRadius:[6,0,20,1],interpolation:!0,useImageSize:!1},size:[25,0,200,1]},edges:{arrows:{to:{enabled:!1,scaleFactor:[1,0,3,.05],type:"arrow"},middle:{enabled:!1,scaleFactor:[1,0,3,.05],type:"arrow"},from:{enabled:!1,scaleFactor:[1,0,3,.05],type:"arrow"}},endPointOffset:{from:[0,-10,10,1],to:[0,-10,10,1]},arrowStrikethrough:!0,color:{color:["color","#848484"],highlight:["color","#848484"],hover:["color","#848484"],inherit:["from","to","both",!0,!1],opacity:[1,0,1,.05]},dashes:!1,font:{color:["color","#343434"],size:[14,0,100,1],face:["arial","verdana","tahoma"],background:["color","none"],strokeWidth:[2,0,50,1],strokeColor:["color","#ffffff"],align:["horizontal","top","middle","bottom"]},hidden:!1,hoverWidth:[1.5,0,5,.1],labelHighlightBold:!0,physics:!0,scaling:{min:[1,0,100,1],max:[15,0,100,1],label:{enabled:!0,min:[14,0,200,1],max:[30,0,200,1],maxVisible:[30,0,200,1],drawThreshold:[5,0,20,1]}},selectionWidth:[1.5,0,5,.1],selfReferenceSize:[20,0,200,1],selfReference:{size:[20,0,200,1],angle:[Math.PI/2,-6*Math.PI,6*Math.PI,Math.PI/8],renderBehindTheNode:!0},shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:[10,0,20,1],x:[5,-30,30,1],y:[5,-30,30,1]},smooth:{enabled:!0,type:["dynamic","continuous","discrete","diagonalCross","straightCross","horizontal","vertical","curvedCW","curvedCCW","cubicBezier"],forceDirection:["horizontal","vertical","none"],roundness:[.5,0,1,.05]},width:[1,0,30,1]},layout:{hierarchical:{enabled:!1,levelSeparation:[150,20,500,5],nodeSpacing:[100,20,500,5],treeSpacing:[200,20,500,5],blockShifting:!0,edgeMinimization:!0,parentCentralization:!0,direction:["UD","DU","LR","RL"],sortMethod:["hubsize","directed"],shakeTowards:["leaves","roots"]}},interaction:{dragNodes:!0,dragView:!0,hideEdgesOnDrag:!1,hideEdgesOnZoom:!1,hideNodesOnDrag:!1,hover:!1,keyboard:{enabled:!1,speed:{x:[10,0,40,1],y:[10,0,40,1],zoom:[.02,0,.1,.005]},bindToWindow:!0,autoFocus:!0},multiselect:!1,navigationButtons:!1,selectable:!0,selectConnectedEdges:!0,hoverConnectedEdges:!0,tooltipDelay:[300,0,1e3,25],zoomView:!0,zoomSpeed:[1,.1,2,.1]},manipulation:{enabled:!1,initiallyActive:!1},physics:{enabled:!0,barnesHut:{theta:[.5,.1,1,.05],gravitationalConstant:[-2e3,-3e4,0,50],centralGravity:[.3,0,10,.05],springLength:[95,0,500,5],springConstant:[.04,0,1.2,.005],damping:[.09,0,1,.01],avoidOverlap:[0,0,1,.01]},forceAtlas2Based:{theta:[.5,.1,1,.05],gravitationalConstant:[-50,-500,0,1],centralGravity:[.01,0,1,.005],springLength:[95,0,500,5],springConstant:[.08,0,1.2,.005],damping:[.4,0,1,.01],avoidOverlap:[0,0,1,.01]},repulsion:{centralGravity:[.2,0,10,.05],springLength:[200,0,500,5],springConstant:[.05,0,1.2,.005],nodeDistance:[100,0,500,5],damping:[.09,0,1,.01]},hierarchicalRepulsion:{centralGravity:[.2,0,10,.05],springLength:[100,0,500,5],springConstant:[.01,0,1.2,.005],nodeDistance:[120,0,500,5],damping:[.09,0,1,.01],avoidOverlap:[0,0,1,.01]},maxVelocity:[50,0,150,1],minVelocity:[.1,.01,.5,.01],solver:["barnesHut","forceAtlas2Based","repulsion","hierarchicalRepulsion"],timestep:[.5,.01,1,.01],wind:{x:[0,-10,10,.1],y:[0,-10,10,.1]}}},Da=(n,e,t)=>!!(n.includes("physics")&&un.physics.solver.includes(e)&&t.physics.solver!==e&&e!=="wind");var fn=class{constructor(){}getDistances(e,t,i){let s={},o=e.edges;for(let a=0;ao&&ar&&mthis.body.emitter.emit("_requestRedraw")),this.groups=new fo,this.canvas=new Zo(this.body),this.selectionHandler=new on(this.body,this.canvas),this.interactionHandler=new en(this.body,this.canvas,this.selectionHandler),this.view=new Qo(this.body,this.canvas),this.renderer=new Ko(this.body,this.canvas),this.physics=new Yo(this.body),this.layoutEngine=new hn(this.body),this.clustering=new Go(this.body),this.manipulation=new ln(this.body,this.canvas,this.selectionHandler,this.interactionHandler),this.nodesHandler=new Oo(this.body,this.images,this.groups,this.layoutEngine),this.edgesHandler=new Ho(this.body,this.images,this.groups),this.body.modules.kamadaKawai=new pn(this.body,150,.05),this.body.modules.clustering=this.clustering,this.canvas._create(),this.setOptions(t),this.setData(e)}(0,Ks.default)(x.prototype);x.prototype.setOptions=function(n){if(n===null&&(n=void 0),n!==void 0){if(qs.validate(n,Ma)===!0&&console.error("%cErrors have been found in the supplied options object.",yi),We(["locale","locales","clickToUse"],this.options,n),n.locale!==void 0&&(n.locale=ya(n.locales||this.options.locales,n.locale)),n=this.layoutEngine.setOptions(n.layout,n),this.canvas.setOptions(n),this.groups.setOptions(n.groups),this.nodesHandler.setOptions(n.nodes),this.edgesHandler.setOptions(n.edges),this.physics.setOptions(n.physics),this.manipulation.setOptions(n.manipulation,n,this.options),this.interactionHandler.setOptions(n.interaction),this.renderer.setOptions(n.interaction),this.selectionHandler.setOptions(n.interaction),n.groups!==void 0&&this.body.emitter.emit("refreshNodes"),"configure"in n&&(this.configurator||(this.configurator=new Ws(this,this.body.container,un,this.canvas.pixelRatio,Da)),this.configurator.setOptions(n.configure)),this.configurator&&this.configurator.options.enabled===!0){let i={nodes:{},edges:{},layout:{},interaction:{},manipulation:{},physics:{},global:{}};D(i.nodes,this.nodesHandler.options),D(i.edges,this.edgesHandler.options),D(i.layout,this.layoutEngine.options),D(i.interaction,this.selectionHandler.options),D(i.interaction,this.renderer.options),D(i.interaction,this.interactionHandler.options),D(i.manipulation,this.manipulation.options),D(i.physics,this.physics.options),D(i.global,this.canvas.options),D(i.global,this.options),this.configurator.setModuleOptions(i)}n.clickToUse!==void 0?n.clickToUse===!0?this.activator===void 0&&(this.activator=new js(this.canvas.frame),this.activator.on("change",()=>{this.body.emitter.emit("activate")})):(this.activator!==void 0&&(this.activator.destroy(),delete this.activator),this.body.emitter.emit("activate")):this.body.emitter.emit("activate"),this.canvas.setSize(),this.body.emitter.emit("startSimulation")}};x.prototype._updateVisibleIndices=function(){let n=this.body.nodes,e=this.body.edges;this.body.nodeIndices=[],this.body.edgeIndices=[];for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&!this.clustering._isClusteredNode(t)&&n[t].options.hidden===!1&&this.body.nodeIndices.push(n[t].id);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let i=e[t],s=n[i.fromId],o=n[i.toId],r=s!==void 0&&o!==void 0;!this.clustering._isClusteredEdge(t)&&i.options.hidden===!1&&r&&s.options.hidden===!1&&o.options.hidden===!1&&this.body.edgeIndices.push(i.id)}};x.prototype.bindEventListeners=function(){this.body.emitter.on("_dataChanged",()=>{this.edgesHandler._updateState(),this.body.emitter.emit("_dataUpdated")}),this.body.emitter.on("_dataUpdated",()=>{this.clustering._updateState(),this._updateVisibleIndices(),this._updateValueRange(this.body.nodes),this._updateValueRange(this.body.edges),this.body.emitter.emit("startSimulation"),this.body.emitter.emit("_requestRedraw")})};x.prototype.setData=function(n){if(this.body.emitter.emit("resetPhysics"),this.body.emitter.emit("_resetData"),this.selectionHandler.unselectAll(),n&&n.dot&&(n.nodes||n.edges))throw new SyntaxError('Data must contain either parameter "dot" or parameter pair "nodes" and "edges", but not both.');if(this.setOptions(n&&n.options),n&&n.dot){console.warn("The dot property has been deprecated. Please use the static convertDot method to convert DOT into vis.network format and use the normal data format with nodes and edges. This converter is used like this: var data = vis.network.convertDot(dotString);");let e=sa(n.dot);this.setData(e);return}else if(n&&n.gephi){console.warn("The gephi property has been deprecated. Please use the static convertGephi method to convert gephi into vis.network format and use the normal data format with nodes and edges. This converter is used like this: var data = vis.network.convertGephi(gephiJson);");let e=oa(n.gephi);this.setData(e);return}else this.nodesHandler.setData(n&&n.nodes,!0),this.edgesHandler.setData(n&&n.edges,!0);this.body.emitter.emit("_dataChanged"),this.body.emitter.emit("_dataLoaded"),this.body.emitter.emit("initPhysics")};x.prototype.destroy=function(){this.body.emitter.emit("destroy"),this.body.emitter.off(),this.off(),delete this.groups,delete this.canvas,delete this.selectionHandler,delete this.interactionHandler,delete this.view,delete this.renderer,delete this.physics,delete this.layoutEngine,delete this.clustering,delete this.manipulation,delete this.nodesHandler,delete this.edgesHandler,delete this.configurator,delete this.images;for(let n in this.body.nodes)!Object.prototype.hasOwnProperty.call(this.body.nodes,n)||delete this.body.nodes[n];for(let n in this.body.edges)!Object.prototype.hasOwnProperty.call(this.body.edges,n)||delete this.body.edges[n];be(this.body.container)};x.prototype._updateValueRange=function(n){let e,t,i,s=0;for(e in n)if(Object.prototype.hasOwnProperty.call(n,e)){let o=n[e].getValue();o!==void 0&&(t=t===void 0?o:Math.min(o,t),i=i===void 0?o:Math.max(o,i),s+=o)}if(t!==void 0&&i!==void 0)for(e in n)Object.prototype.hasOwnProperty.call(n,e)&&n[e].setValueRange(t,i,s)};x.prototype.isActive=function(){return!this.activator||this.activator.active};x.prototype.setSize=function(){return this.canvas.setSize.apply(this.canvas,arguments)};x.prototype.canvasToDOM=function(){return this.canvas.canvasToDOM.apply(this.canvas,arguments)};x.prototype.DOMtoCanvas=function(){return this.canvas.DOMtoCanvas.apply(this.canvas,arguments)};x.prototype.findNode=function(){return this.clustering.findNode.apply(this.clustering,arguments)};x.prototype.isCluster=function(){return this.clustering.isCluster.apply(this.clustering,arguments)};x.prototype.openCluster=function(){return this.clustering.openCluster.apply(this.clustering,arguments)};x.prototype.cluster=function(){return this.clustering.cluster.apply(this.clustering,arguments)};x.prototype.getNodesInCluster=function(){return this.clustering.getNodesInCluster.apply(this.clustering,arguments)};x.prototype.clusterByConnection=function(){return this.clustering.clusterByConnection.apply(this.clustering,arguments)};x.prototype.clusterByHubsize=function(){return this.clustering.clusterByHubsize.apply(this.clustering,arguments)};x.prototype.updateClusteredNode=function(){return this.clustering.updateClusteredNode.apply(this.clustering,arguments)};x.prototype.getClusteredEdges=function(){return this.clustering.getClusteredEdges.apply(this.clustering,arguments)};x.prototype.getBaseEdge=function(){return this.clustering.getBaseEdge.apply(this.clustering,arguments)};x.prototype.getBaseEdges=function(){return this.clustering.getBaseEdges.apply(this.clustering,arguments)};x.prototype.updateEdge=function(){return this.clustering.updateEdge.apply(this.clustering,arguments)};x.prototype.clusterOutliers=function(){return this.clustering.clusterOutliers.apply(this.clustering,arguments)};x.prototype.getSeed=function(){return this.layoutEngine.getSeed.apply(this.layoutEngine,arguments)};x.prototype.enableEditMode=function(){return this.manipulation.enableEditMode.apply(this.manipulation,arguments)};x.prototype.disableEditMode=function(){return this.manipulation.disableEditMode.apply(this.manipulation,arguments)};x.prototype.addNodeMode=function(){return this.manipulation.addNodeMode.apply(this.manipulation,arguments)};x.prototype.editNode=function(){return this.manipulation.editNode.apply(this.manipulation,arguments)};x.prototype.editNodeMode=function(){return console.warn("Deprecated: Please use editNode instead of editNodeMode."),this.manipulation.editNode.apply(this.manipulation,arguments)};x.prototype.addEdgeMode=function(){return this.manipulation.addEdgeMode.apply(this.manipulation,arguments)};x.prototype.editEdgeMode=function(){return this.manipulation.editEdgeMode.apply(this.manipulation,arguments)};x.prototype.deleteSelected=function(){return this.manipulation.deleteSelected.apply(this.manipulation,arguments)};x.prototype.getPositions=function(){return this.nodesHandler.getPositions.apply(this.nodesHandler,arguments)};x.prototype.getPosition=function(){return this.nodesHandler.getPosition.apply(this.nodesHandler,arguments)};x.prototype.storePositions=function(){return this.nodesHandler.storePositions.apply(this.nodesHandler,arguments)};x.prototype.moveNode=function(){return this.nodesHandler.moveNode.apply(this.nodesHandler,arguments)};x.prototype.getBoundingBox=function(){return this.nodesHandler.getBoundingBox.apply(this.nodesHandler,arguments)};x.prototype.getConnectedNodes=function(n){return this.body.nodes[n]!==void 0?this.nodesHandler.getConnectedNodes.apply(this.nodesHandler,arguments):this.edgesHandler.getConnectedNodes.apply(this.edgesHandler,arguments)};x.prototype.getConnectedEdges=function(){return this.nodesHandler.getConnectedEdges.apply(this.nodesHandler,arguments)};x.prototype.startSimulation=function(){return this.physics.startSimulation.apply(this.physics,arguments)};x.prototype.stopSimulation=function(){return this.physics.stopSimulation.apply(this.physics,arguments)};x.prototype.stabilize=function(){return this.physics.stabilize.apply(this.physics,arguments)};x.prototype.getSelection=function(){return this.selectionHandler.getSelection.apply(this.selectionHandler,arguments)};x.prototype.setSelection=function(){return this.selectionHandler.setSelection.apply(this.selectionHandler,arguments)};x.prototype.getSelectedNodes=function(){return this.selectionHandler.getSelectedNodeIds.apply(this.selectionHandler,arguments)};x.prototype.getSelectedEdges=function(){return this.selectionHandler.getSelectedEdgeIds.apply(this.selectionHandler,arguments)};x.prototype.getNodeAt=function(){let n=this.selectionHandler.getNodeAt.apply(this.selectionHandler,arguments);return n!==void 0&&n.id!==void 0?n.id:n};x.prototype.getEdgeAt=function(){let n=this.selectionHandler.getEdgeAt.apply(this.selectionHandler,arguments);return n!==void 0&&n.id!==void 0?n.id:n};x.prototype.selectNodes=function(){return this.selectionHandler.selectNodes.apply(this.selectionHandler,arguments)};x.prototype.selectEdges=function(){return this.selectionHandler.selectEdges.apply(this.selectionHandler,arguments)};x.prototype.unselectAll=function(){this.selectionHandler.unselectAll.apply(this.selectionHandler,arguments),this.selectionHandler.commitWithoutEmitting.apply(this.selectionHandler),this.redraw()};x.prototype.redraw=function(){return this.renderer.redraw.apply(this.renderer,arguments)};x.prototype.getScale=function(){return this.view.getScale.apply(this.view,arguments)};x.prototype.getViewPosition=function(){return this.view.getViewPosition.apply(this.view,arguments)};x.prototype.fit=function(){return this.view.fit.apply(this.view,arguments)};x.prototype.moveTo=function(){return this.view.moveTo.apply(this.view,arguments)};x.prototype.focus=function(){return this.view.focus.apply(this.view,arguments)};x.prototype.releaseNode=function(){return this.view.releaseNode.apply(this.view,arguments)};x.prototype.getOptionsFromConfigurator=function(){let n={};return this.configurator&&(n=this.configurator.getOptions.apply(this.configurator)),n};var gn=n=>{if(!document.cookie)return;let e=null,t=document.cookie.split(";");for(let i=0;iFe(he({},p),{title:e(p.title)})));window.nodes=t;let i=new xe(topologyData.edges.map(p=>Fe(he({},p),{title:e(p.title)})));ae=new x(vn,{nodes:t,edges:i},Hi),ae.fit(),ae.on("dragEnd",p=>{wn!=null&&(!wn.checked||Promise.allSettled(Object.entries(ae.getPositions(p.nodes)).map(b=>Ui(this,[b],function*([m,g]){isNaN(parseInt(m))?nodeKey=m:nodeKey=parseInt(m);try{window.nodes.update({id:nodeKey,physics:!1,x:g.x,y:g.y})}catch(E){console.log(["Error while executing window.nodes.update()","nodeId: "+m,"nodeKey: "+nodeKey,"x: "+g.x,"y: "+g.y]),console.log(E)}let v=yield fetch("/"+basePath+"api/plugins/netbox_topology_views/save-coords/save_coords/",{method:"PATCH",headers:{"X-CSRFToken":Fa,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({node_id:m,x:g.x,y:g.y,group:topologyData.group})})}))))}),ae.on("doubleClick",p=>{p.nodes.length>0?p.nodes.forEach(m=>{window.open(t.get(m).href,"_blank")}):p.edges.forEach(m=>{window.open(i.get(m).href,"_blank")})}),ae.on("afterDrawing",p=>{o=[],mn!=null&&mn=="on"&&a(p,d,h),yn!=null&&yn=="on"&&a(p,l,c),bn!=null&&bn=="on"&&a(p,u,f)}),ae.on("click",p=>{o.forEach(m=>{if(p.pointer.canvas.x>m.x1-m.border/2-1&&p.pointer.canvas.xm.y1-m.border/2-1&&p.pointer.canvas.ym.x2-m.border/2-1||p.pointer.canvas.ym.y2-m.border/2-1)){let g=[];m.category=="Site"&&d.forEach(b=>{b.forEach(v=>{v[1]==m.id&&g.push(v[0])})}),m.category=="Location"&&l.forEach(b=>{b.forEach(v=>{v[1]===m.id&&g.push(v[0])})}),m.category=="Rack"&&u.forEach(b=>{b.forEach(v=>{v[1]===m.id&&g.push(v[0])})}),ae.selectNodes(g)}})});function s(p,m){let g=[];for(let[v,E]of t._data)E[p]!=null&&g.push([E.id,E[p],E[m]]);let b=g.reduce((v,E)=>{let C=E[1];return v[C]=v[C]||[],v[C].push(E),v},{});return Object.values(b)}var o=[];function r(p){p.ctx.beginPath(),p.ctx.lineWidth=p.lineWidth,p.ctx.strokeStyle=p.color,p.ctx.rect(p.x,p.y,p.width,p.height),p.ctx.stroke(),p.ctx.font=p.font,p.ctx.fillStyle=p.color,p.ctx.fillText(p.text,p.x+p.textPaddingX,p.y+p.textPaddingY),o.push({category:p.category,id:p.id,x1:p.x,y1:p.y,x2:p.x+p.width,y2:p.y+p.height,border:p.lineWidth})}function a(p,m,g){for(let b of Object.entries(m)){let v=[],E=[],C=[];for(let j of b[1])E.push(ae.getPosition(j[0]).x),C.push(ae.getPosition(j[0]).y);let O=Math.min(...E)-g.paddingX,S=Math.min(...C)-g.paddingY,M=Math.max(...E)-Math.min(...E)+2*g.paddingX,R=Math.max(...C)-Math.min(...C)+2*g.paddingY;v.push({ctx:p,x:O,y:S,width:M,height:R,lineWidth:g.lineWidth,color:g.color,text:b[1][0][2],textPaddingX:g.textPaddingX,textPaddingY:g.textPaddingY,font:g.font,id:b[1][0][1],category:g.category}),v.forEach(function(j){r(j)})}}let d=s("site_id","site"),h={lineWidth:"5",color:"red",paddingX:84,paddingY:84,textPaddingX:8,textPaddingY:-8,font:"14px helvetica",category:"Site"},l=s("location_id","location"),c={lineWidth:"5",color:"#337ab7",paddingX:77,paddingY:77,textPaddingX:12,textPaddingY:22,font:"14px helvetica",category:"Location"},u=s("rack_id","rack"),f={lineWidth:"5",color:"green",paddingX:70,paddingY:70,textPaddingX:8,textPaddingY:30,font:"14px helvetica",category:"Rack"}})();var Na="image/png",Ba=document.querySelector("#btnDownloadImage");Ba.addEventListener("click",n=>{Aa()});function Aa(){let n=vn.querySelector("canvas"),e=document.createElement("a"),t=n.toDataURL(Na);e.href=t,e.download="topology",document.body.appendChild(e),e.click(),document.body.removeChild(e)}var za=document.querySelector("#btnDownloadXml");za.addEventListener("click",n=>{Ra()});function Ra(){let n=document.createElement("a"),e="";if(typeof is_htmx!="undefined"){var t=window.location.href;let o="/sites/",r="/locations/";if(t.includes(o)){var i=t.split(o)[1];i=i.split("/")[0],e="site_id="+i+"&show_cables=on&show_unconnected=on"}else if(t.includes(r)){var s=t.split(r)[1];s=s.split("/")[0],e="location_id="+s+"&show_cables=on&show_unconnected=on"}}else e=new URLSearchParams(window.location.search);fetch("/"+basePath+"api/plugins/netbox_topology_views/xml-export/?"+e).then(o=>o.text()).then(o=>{var r=new Blob([o],{type:"text/plain"});n.setAttribute("href",window.URL.createObjectURL(r)),n.setAttribute("download","topology.xml"),n.dataset.downloadurl=["text/plain",n.download,n.href].join(":"),n.click()})}var La=new MutationObserver(n=>n.forEach(e=>{if(!ae||e.type!=="attributes"||e.attributeName!=="data-netbox-color-mode"||!(e.target instanceof HTMLElement))return;let{netboxColorMode:t}=e.target.dataset;Hi.nodes.font.color=t==="dark"?"#fff":"#000",ae.setOptions(Hi)}));La.observe(document.documentElement,{attributes:!0,attributeFilter:["data-netbox-color-mode"]});})(); +`),s=i.length;if(t.multi)for(let o=0;o0)for(let a=0;a0)for(let o=0;o/&/.test(s)?(t.replace(t.text,"<","<")||t.replace(t.text,"&","&")||t.add("&"),!0):!1;for(;t.position")||t.parseStartTag("ital","")||t.parseStartTag("mono","")||t.parseEndTag("bold","")||t.parseEndTag("ital","")||t.parseEndTag("mono",""))||i(s)||t.add(s),t.position++}return t.emitBlock(),t.blocks}splitMarkdownBlocks(e){let t=new ki(e),i=!0,s=o=>/\\/.test(o)?(t.positionthis.parent.fontOptions.maxWdt}getLongestFit(e){let t="",i=0;for(;i0;){let o=this.getLongestFit(s);if(o===0){let r=s[0],a=this.getLongestFitWord(r);this.lines.newLine(r.slice(0,a),t),s[0]=r.slice(a)}else{let r=o;s[o-1]===" "?o--:s[r]===" "&&r++;let a=s.slice(0,o).join("");o==s.length&&i?this.lines.append(a,t):this.lines.newLine(a,t),s=s.slice(r)}}}},Ut=["bold","ital","boldital","mono"],Ye=class{constructor(e,t,i=!1){this.body=e,this.pointToSelf=!1,this.baseSize=void 0,this.fontOptions={},this.setOptions(t),this.size={top:0,left:0,width:0,height:0,yLine:0},this.isEdgeLabel=i}setOptions(e){if(this.elementOptions=e,this.initFontOptions(e.font),qt(e.label)?this.labelDirty=!0:e.label=void 0,e.font!==void 0&&e.font!==null){if(typeof e.font=="string")this.baseSize=this.fontOptions.size;else if(typeof e.font=="object"){let t=e.font.size;t!==void 0&&(this.baseSize=t)}}}initFontOptions(e){if(I(Ut,t=>{this.fontOptions[t]={}}),Ye.parseFontString(this.fontOptions,e)){this.fontOptions.vadjust=0;return}I(e,(t,i)=>{t!=null&&typeof t!="object"&&(this.fontOptions[i]=t)})}static parseFontString(e,t){if(!t||typeof t!="string")return!1;let i=t.split(" ");return e.size=+i[0].replace("px",""),e.face=i[1],e.color=i[2],!0}constrain(e){let t={constrainWidth:!1,maxWdt:-1,minWdt:-1,constrainHeight:!1,minHgt:-1,valign:"middle"},i=Ee(e,"widthConstraint");if(typeof i=="number")t.maxWdt=Number(i),t.minWdt=Number(i);else if(typeof i=="object"){let o=Ee(e,["widthConstraint","maximum"]);typeof o=="number"&&(t.maxWdt=Number(o));let r=Ee(e,["widthConstraint","minimum"]);typeof r=="number"&&(t.minWdt=Number(r))}let s=Ee(e,"heightConstraint");if(typeof s=="number")t.minHgt=Number(s);else if(typeof s=="object"){let o=Ee(e,["heightConstraint","minimum"]);typeof o=="number"&&(t.minHgt=Number(o));let r=Ee(e,["heightConstraint","valign"]);typeof r=="string"&&(r==="top"||r==="bottom")&&(t.valign=r)}return t}update(e,t){this.setOptions(e,!0),this.propagateFonts(t),D(this.fontOptions,this.constrain(t)),this.fontOptions.chooser=Ci("label",t)}adjustSizes(e){let t=e?e.right+e.left:0;this.fontOptions.constrainWidth&&(this.fontOptions.maxWdt-=t,this.fontOptions.minWdt-=t);let i=e?e.top+e.bottom:0;this.fontOptions.constrainHeight&&(this.fontOptions.minHgt-=i)}addFontOptionsToPile(e,t){for(let i=0;i{r!==void 0&&(Object.prototype.hasOwnProperty.call(t,a)||(Ut.indexOf(a)!==-1?t[a]={}:t[a]=r))})}return t}getFontOption(e,t,i){let s;for(let o=0;o{o[d]=a}),o.size=Number(o.size),o.vadjust=Number(o.vadjust)}}draw(e,t,i,s,o,r="middle"){if(this.elementOptions.label===void 0)return;let a=this.fontOptions.size*this.body.view.scale;this.elementOptions.label&&a=this.elementOptions.scaling.label.maxVisible&&(a=Number(this.elementOptions.scaling.label.maxVisible)/this.body.view.scale),this.calculateLabelSize(e,s,o,t,i,r),this._drawBackground(e),this._drawText(e,t,this.size.yLine,r,a))}_drawBackground(e){if(this.fontOptions.background!==void 0&&this.fontOptions.background!=="none"){e.fillStyle=this.fontOptions.background;let t=this.getSize();e.fillRect(t.left,t.top,t.width,t.height)}}_drawText(e,t,i,s="middle",o){[t,i]=this._setAlignment(e,t,i,s),e.textAlign="left",t=t-this.size.width/2,this.fontOptions.valign&&this.size.height>this.size.labelHeight&&(this.fontOptions.valign==="top"&&(i-=(this.size.height-this.size.labelHeight)/2),this.fontOptions.valign==="bottom"&&(i+=(this.size.height-this.size.labelHeight)/2));for(let r=0;r0&&(e.lineWidth=l.strokeWidth,e.strokeStyle=u,e.lineJoin="round"),e.fillStyle=c,l.strokeWidth>0&&e.strokeText(l.text,t+d,i+l.vadjust),e.fillText(l.text,t+d,i+l.vadjust),d+=l.width}i+=a.height}}}_setAlignment(e,t,i,s){if(this.isEdgeLabel&&this.fontOptions.align!=="horizontal"&&this.pointToSelf===!1){t=0,i=0;let o=2;this.fontOptions.align==="top"?(e.textBaseline="alphabetic",i-=2*o):this.fontOptions.align==="bottom"?(e.textBaseline="hanging",i+=2*o):e.textBaseline="middle"}else e.textBaseline=s;return[t,i]}_getColor(e,t,i){let s=e||"#000000",o=i||"#ffffff";if(t<=this.elementOptions.scaling.label.drawThreshold){let r=Math.max(0,Math.min(1,1-(this.elementOptions.scaling.label.drawThreshold-t)));s=ie(s,r),o=ie(o,r)}return[s,o]}getTextSize(e,t=!1,i=!1){return this._processLabel(e,t,i),{width:this.size.width,height:this.size.height,lineCount:this.lineCount}}getSize(){let e=2,t=this.size.left,i=this.size.top-.5*e;if(this.isEdgeLabel){let o=-this.size.width*.5;switch(this.fontOptions.align){case"middle":t=o,i=-this.size.height*.5;break;case"top":t=o,i=-(this.size.height+e);break;case"bottom":t=o,i=e;break}}return{left:t,top:i,width:this.size.width,height:this.size.height}}calculateLabelSize(e,t,i,s=0,o=0,r="middle"){this._processLabel(e,t,i),this.size.left=s-this.size.width*.5,this.size.top=o-this.size.height*.5,this.size.yLine=o+(1-this.lineCount)*.5*this.fontOptions.size,r==="hanging"&&(this.size.top+=.5*this.fontOptions.size,this.size.top+=4,this.size.yLine+=4)}getFormattingValues(e,t,i,s){let o=function(d,h,l){return h==="normal"?l==="mod"?"":d[l]:d[h][l]!==void 0?d[h][l]:d[l]},r={color:o(this.fontOptions,s,"color"),size:o(this.fontOptions,s,"size"),face:o(this.fontOptions,s,"face"),mod:o(this.fontOptions,s,"mod"),vadjust:o(this.fontOptions,s,"vadjust"),strokeWidth:this.fontOptions.strokeWidth,strokeColor:this.fontOptions.strokeColor};(t||i)&&(s==="normal"&&this.fontOptions.chooser===!0&&this.elementOptions.labelHighlightBold?r.mod="bold":typeof this.fontOptions.chooser=="function"&&this.fontOptions.chooser(r,this.elementOptions.id,t,i));let a="";return r.mod!==void 0&&r.mod!==""&&(a+=r.mod+" "),a+=r.size+"px "+r.face,e.font=a.replace(/"/g,""),r.font=e.font,r.height=r.size,r}differentState(e,t){return e!==this.selectedState||t!==this.hoverState}_processLabelText(e,t,i,s){return new go(e,this,t,i).process(s)}_processLabel(e,t,i){if(this.labelDirty===!1&&!this.differentState(t,i))return;let s=this._processLabelText(e,t,i,this.elementOptions.label);this.fontOptions.minWdt>0&&s.width0&&s.height0&&(this.enableBorderDashes(e,t),e.stroke(),this.disableBorderDashes(e,t)),e.restore()}performFill(e,t){e.save(),e.fillStyle=t.color,this.enableShadow(e,t),e.fill(),this.disableShadow(e,t),e.restore(),this.performStroke(e,t)}_addBoundingBoxMargin(e){this.boundingBox.left-=e,this.boundingBox.top-=e,this.boundingBox.bottom+=e,this.boundingBox.right+=e}_updateBoundingBox(e,t,i,s,o){i!==void 0&&this.resize(i,s,o),this.left=e-this.width/2,this.top=t-this.height/2,this.boundingBox.left=this.left,this.boundingBox.top=this.top,this.boundingBox.bottom=this.top+this.height,this.boundingBox.right=this.left+this.width}updateBoundingBox(e,t,i,s,o){this._updateBoundingBox(e,t,i,s,o)}getDimensionsFromLabel(e,t,i){this.textSize=this.labelModule.getTextSize(e,t,i);let s=this.textSize.width,o=this.textSize.height,r=14;return s===0&&(s=r,o=r),{width:s,height:o}}},ga=class extends De{constructor(e,t,i){super(e,t,i);this._setMargins(i)}resize(e,t=this.selected,i=this.hover){if(this.needsRefresh(t,i)){let s=this.getDimensionsFromLabel(e,t,i);this.width=s.width+this.margin.right+this.margin.left,this.height=s.height+this.margin.top+this.margin.bottom,this.radius=this.width/2}}draw(e,t,i,s,o,r){this.resize(e,s,o),this.left=t-this.width/2,this.top=i-this.height/2,this.initContextForDraw(e,r),Ks(e,this.left,this.top,this.width,this.height,r.borderRadius),this.performFill(e,r),this.updateBoundingBox(t,i,e,s,o),this.labelModule.draw(e,this.left+this.textSize.width/2+this.margin.left,this.top+this.textSize.height/2+this.margin.top,s,o)}updateBoundingBox(e,t,i,s,o){this._updateBoundingBox(e,t,i,s,o);let r=this.options.shapeProperties.borderRadius;this._addBoundingBoxMargin(r)}distanceToBorder(e,t){e&&this.resize(e);let i=this.options.borderWidth;return Math.min(Math.abs(this.width/2/Math.cos(t)),Math.abs(this.height/2/Math.sin(t)))+i}},Yt=class extends De{constructor(e,t,i){super(e,t,i);this.labelOffset=0,this.selected=!1}setOptions(e,t,i){this.options=e,t===void 0&&i===void 0||this.setImages(t,i)}setImages(e,t){t&&this.selected?(this.imageObj=t,this.imageObjAlt=e):(this.imageObj=e,this.imageObjAlt=t)}switchImages(e){let t=e&&!this.selected||!e&&this.selected;if(this.selected=e,this.imageObjAlt!==void 0&&t){let i=this.imageObj;this.imageObj=this.imageObjAlt,this.imageObjAlt=i}}_getImagePadding(){let e={top:0,right:0,bottom:0,left:0};if(this.options.imagePadding){let t=this.options.imagePadding;typeof t=="object"?(e.top=t.top,e.right=t.right,e.bottom=t.bottom,e.left=t.left):(e.top=t,e.right=t,e.bottom=t,e.left=t)}return e}_resizeImage(){let e,t;if(this.options.shapeProperties.useImageSize===!1){let i=1,s=1;this.imageObj.width&&this.imageObj.height&&(this.imageObj.width>this.imageObj.height?i=this.imageObj.width/this.imageObj.height:s=this.imageObj.height/this.imageObj.width),e=this.options.size*2*i,t=this.options.size*2*s}else{let i=this._getImagePadding();e=this.imageObj.width+i.left+i.right,t=this.imageObj.height+i.top+i.bottom}this.width=e,this.height=t,this.radius=.5*this.width}_drawRawCircle(e,t,i,s){this.initContextForDraw(e,s),wi(e,t,i,s.size),this.performFill(e,s)}_drawImageAtPosition(e,t){if(this.imageObj.width!=0){e.globalAlpha=t.opacity!==void 0?t.opacity:1,this.enableShadow(e,t);let i=1;this.options.shapeProperties.interpolation===!0&&(i=this.imageObj.width/this.width/this.body.view.scale);let s=this._getImagePadding(),o=this.left+s.left,r=this.top+s.top,a=this.width-s.left-s.right,d=this.height-s.top-s.bottom;this.imageObj.drawImageAtPosition(e,i,o,r,a,d),this.disableShadow(e,t)}}_drawImageLabel(e,t,i,s,o){let r=0;if(this.height!==void 0){r=this.height*.5;let d=this.labelModule.getTextSize(e,s,o);d.lineCount>=1&&(r+=d.height/2)}let a=i+r;this.options.label&&(this.labelOffset=r),this.labelModule.draw(e,t,a,s,o,"hanging")}},ma=class extends Yt{constructor(e,t,i){super(e,t,i);this._setMargins(i)}resize(e,t=this.selected,i=this.hover){if(this.needsRefresh(t,i)){let s=this.getDimensionsFromLabel(e,t,i),o=Math.max(s.width+this.margin.right+this.margin.left,s.height+this.margin.top+this.margin.bottom);this.options.size=o/2,this.width=o,this.height=o,this.radius=this.width/2}}draw(e,t,i,s,o,r){this.resize(e,s,o),this.left=t-this.width/2,this.top=i-this.height/2,this._drawRawCircle(e,t,i,r),this.updateBoundingBox(t,i),this.labelModule.draw(e,this.left+this.textSize.width/2+this.margin.left,i,s,o)}updateBoundingBox(e,t){this.boundingBox.top=t-this.options.size,this.boundingBox.left=e-this.options.size,this.boundingBox.right=e+this.options.size,this.boundingBox.bottom=t+this.options.size}distanceToBorder(e){return e&&this.resize(e),this.width*.5}},mo=class extends Yt{constructor(e,t,i,s,o){super(e,t,i);this.setImages(s,o)}resize(e,t=this.selected,i=this.hover){if(this.imageObj.src===void 0||this.imageObj.width===void 0||this.imageObj.height===void 0){let o=this.options.size*2;this.width=o,this.height=o,this.radius=.5*this.width;return}this.needsRefresh(t,i)&&this._resizeImage()}draw(e,t,i,s,o,r){this.switchImages(s),this.resize();let a=t,d=i;this.options.shapeProperties.coordinateOrigin==="top-left"?(this.left=t,this.top=i,a+=this.width/2,d+=this.height/2):(this.left=t-this.width/2,this.top=i-this.height/2),this._drawRawCircle(e,a,d,r),e.save(),e.clip(),this._drawImageAtPosition(e,r),e.restore(),this._drawImageLabel(e,a,d,s,o),this.updateBoundingBox(t,i)}updateBoundingBox(e,t){this.options.shapeProperties.coordinateOrigin==="top-left"?(this.boundingBox.top=t,this.boundingBox.left=e,this.boundingBox.right=e+this.options.size*2,this.boundingBox.bottom=t+this.options.size*2):(this.boundingBox.top=t-this.options.size,this.boundingBox.left=e-this.options.size,this.boundingBox.right=e+this.options.size,this.boundingBox.bottom=t+this.options.size),this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelOffset)}distanceToBorder(e){return e&&this.resize(e),this.width*.5}},Te=class extends De{constructor(e,t,i){super(e,t,i)}resize(e,t=this.selected,i=this.hover,s={size:this.options.size}){var o,r;if(this.needsRefresh(t,i)){this.labelModule.getTextSize(e,t,i);let a=2*s.size;this.width=(o=this.customSizeWidth)!=null?o:a,this.height=(r=this.customSizeHeight)!=null?r:a,this.radius=.5*this.width}}_drawShape(e,t,i,s,o,r,a,d){return this.resize(e,r,a,d),this.left=s-this.width/2,this.top=o-this.height/2,this.initContextForDraw(e,d),Vr(t)(e,s,o,d.size),this.performFill(e,d),this.options.icon!==void 0&&this.options.icon.code!==void 0&&(e.font=(r?"bold ":"")+this.height/2+"px "+(this.options.icon.face||"FontAwesome"),e.fillStyle=this.options.icon.color||"black",e.textAlign="center",e.textBaseline="middle",e.fillText(this.options.icon.code,s,o)),{drawExternalLabel:()=>{if(this.options.label!==void 0){this.labelModule.calculateLabelSize(e,r,a,s,o,"hanging");let h=o+.5*this.height+.5*this.labelModule.size.height;this.labelModule.draw(e,s,h,r,a,"hanging")}this.updateBoundingBox(s,o)}}}updateBoundingBox(e,t){this.boundingBox.top=t-this.options.size,this.boundingBox.left=e-this.options.size,this.boundingBox.right=e+this.options.size,this.boundingBox.bottom=t+this.options.size,this.options.label!==void 0&&this.labelModule.size.width>0&&(this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelModule.size.height))}},yo=class extends Te{constructor(e,t,i,s){super(e,t,i,s);this.ctxRenderer=s}draw(e,t,i,s,o,r){this.resize(e,s,o,r),this.left=t-this.width/2,this.top=i-this.height/2,e.save();let a=this.ctxRenderer({ctx:e,id:this.options.id,x:t,y:i,state:{selected:s,hover:o},style:le({},r),label:this.options.label});if(a.drawNode!=null&&a.drawNode(),e.restore(),a.drawExternalLabel){let d=a.drawExternalLabel;a.drawExternalLabel=()=>{e.save(),d(),e.restore()}}return a.nodeDimensions&&(this.customSizeWidth=a.nodeDimensions.width,this.customSizeHeight=a.nodeDimensions.height),a}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},bo=class extends De{constructor(e,t,i){super(e,t,i);this._setMargins(i)}resize(e,t,i){if(this.needsRefresh(t,i)){let o=this.getDimensionsFromLabel(e,t,i).width+this.margin.right+this.margin.left;this.width=o,this.height=o,this.radius=this.width/2}}draw(e,t,i,s,o,r){this.resize(e,s,o),this.left=t-this.width/2,this.top=i-this.height/2,this.initContextForDraw(e,r),$s(e,t-this.width/2,i-this.height/2,this.width,this.height),this.performFill(e,r),this.updateBoundingBox(t,i,e,s,o),this.labelModule.draw(e,this.left+this.textSize.width/2+this.margin.left,this.top+this.textSize.height/2+this.margin.top,s,o)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},ya=class extends Te{constructor(e,t,i){super(e,t,i)}draw(e,t,i,s,o,r){return this._drawShape(e,"diamond",4,t,i,s,o,r)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},vo=class extends Te{constructor(e,t,i){super(e,t,i)}draw(e,t,i,s,o,r){return this._drawShape(e,"circle",2,t,i,s,o,r)}distanceToBorder(e){return e&&this.resize(e),this.options.size}},Oi=class extends De{constructor(e,t,i){super(e,t,i)}resize(e,t=this.selected,i=this.hover){if(this.needsRefresh(t,i)){let s=this.getDimensionsFromLabel(e,t,i);this.height=s.height*2,this.width=s.width+s.height,this.radius=.5*this.width}}draw(e,t,i,s,o,r){this.resize(e,s,o),this.left=t-this.width*.5,this.top=i-this.height*.5,this.initContextForDraw(e,r),_i(e,this.left,this.top,this.width,this.height),this.performFill(e,r),this.updateBoundingBox(t,i,e,s,o),this.labelModule.draw(e,t,i,s,o)}distanceToBorder(e,t){e&&this.resize(e);let i=this.width*.5,s=this.height*.5,o=Math.sin(t)*i,r=Math.cos(t)*s;return i*s/Math.sqrt(o*o+r*r)}},wo=class extends De{constructor(e,t,i){super(e,t,i);this._setMargins(i)}resize(e,t,i){this.needsRefresh(t,i)&&(this.iconSize={width:Number(this.options.icon.size),height:Number(this.options.icon.size)},this.width=this.iconSize.width+this.margin.right+this.margin.left,this.height=this.iconSize.height+this.margin.top+this.margin.bottom,this.radius=.5*this.width)}draw(e,t,i,s,o,r){return this.resize(e,s,o),this.options.icon.size=this.options.icon.size||50,this.left=t-this.width/2,this.top=i-this.height/2,this._icon(e,t,i,s,o,r),{drawExternalLabel:()=>{if(this.options.label!==void 0){let a=5;this.labelModule.draw(e,this.left+this.iconSize.width/2+this.margin.left,i+this.height/2+a,s)}this.updateBoundingBox(t,i)}}}updateBoundingBox(e,t){if(this.boundingBox.top=t-this.options.icon.size*.5,this.boundingBox.left=e-this.options.icon.size*.5,this.boundingBox.right=e+this.options.icon.size*.5,this.boundingBox.bottom=t+this.options.icon.size*.5,this.options.label!==void 0&&this.labelModule.size.width>0){let i=5;this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelModule.size.height+i)}}_icon(e,t,i,s,o,r){let a=Number(this.options.icon.size);this.options.icon.code!==void 0?(e.font=[this.options.icon.weight!=null?this.options.icon.weight:s?"bold":"",(this.options.icon.weight!=null&&s?5:0)+a+"px",this.options.icon.face].join(" "),e.fillStyle=this.options.icon.color||"black",e.textAlign="center",e.textBaseline="middle",this.enableShadow(e,r),e.fillText(this.options.icon.code,t,i),this.disableShadow(e,r)):console.error("When using the icon shape, you need to define the code in the icon options object. This can be done per node or globally.")}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},ba=class extends Yt{constructor(e,t,i,s,o){super(e,t,i);this.setImages(s,o)}resize(e,t=this.selected,i=this.hover){if(this.imageObj.src===void 0||this.imageObj.width===void 0||this.imageObj.height===void 0){let o=this.options.size*2;this.width=o,this.height=o;return}this.needsRefresh(t,i)&&this._resizeImage()}draw(e,t,i,s,o,r){e.save(),this.switchImages(s),this.resize();let a=t,d=i;if(this.options.shapeProperties.coordinateOrigin==="top-left"?(this.left=t,this.top=i,a+=this.width/2,d+=this.height/2):(this.left=t-this.width/2,this.top=i-this.height/2),this.options.shapeProperties.useBorderWithImage===!0){let h=this.options.borderWidth,l=this.options.borderWidthSelected||2*this.options.borderWidth,c=(s?l:h)/this.body.view.scale;e.lineWidth=Math.min(this.width,c),e.beginPath();let u=s?this.options.color.highlight.border:o?this.options.color.hover.border:this.options.color.border,f=s?this.options.color.highlight.background:o?this.options.color.hover.background:this.options.color.background;r.opacity!==void 0&&(u=ie(u,r.opacity),f=ie(f,r.opacity)),e.strokeStyle=u,e.fillStyle=f,e.rect(this.left-.5*e.lineWidth,this.top-.5*e.lineWidth,this.width+e.lineWidth,this.height+e.lineWidth),e.fill(),this.performStroke(e,r),e.closePath()}this._drawImageAtPosition(e,r),this._drawImageLabel(e,a,d,s,o),this.updateBoundingBox(t,i),e.restore()}updateBoundingBox(e,t){this.resize(),this.options.shapeProperties.coordinateOrigin==="top-left"?(this.left=e,this.top=t):(this.left=e-this.width/2,this.top=t-this.height/2),this.boundingBox.left=this.left,this.boundingBox.top=this.top,this.boundingBox.bottom=this.top+this.height,this.boundingBox.right=this.left+this.width,this.options.label!==void 0&&this.labelModule.size.width>0&&(this.boundingBox.left=Math.min(this.boundingBox.left,this.labelModule.size.left),this.boundingBox.right=Math.max(this.boundingBox.right,this.labelModule.size.left+this.labelModule.size.width),this.boundingBox.bottom=Math.max(this.boundingBox.bottom,this.boundingBox.bottom+this.labelOffset))}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},_o=class extends Te{constructor(e,t,i){super(e,t,i)}draw(e,t,i,s,o,r){return this._drawShape(e,"square",2,t,i,s,o,r)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Eo=class extends Te{constructor(e,t,i){super(e,t,i)}draw(e,t,i,s,o,r){return this._drawShape(e,"hexagon",4,t,i,s,o,r)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},xo=class extends Te{constructor(e,t,i){super(e,t,i)}draw(e,t,i,s,o,r){return this._drawShape(e,"star",4,t,i,s,o,r)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},Co=class extends De{constructor(e,t,i){super(e,t,i);this._setMargins(i)}resize(e,t,i){this.needsRefresh(t,i)&&(this.textSize=this.labelModule.getTextSize(e,t,i),this.width=this.textSize.width+this.margin.right+this.margin.left,this.height=this.textSize.height+this.margin.top+this.margin.bottom,this.radius=.5*this.width)}draw(e,t,i,s,o,r){this.resize(e,s,o),this.left=t-this.width/2,this.top=i-this.height/2,this.enableShadow(e,r),this.labelModule.draw(e,this.left+this.textSize.width/2+this.margin.left,this.top+this.textSize.height/2+this.margin.top,s,o),this.disableShadow(e,r),this.updateBoundingBox(t,i,e,s,o)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},va=class extends Te{constructor(e,t,i){super(e,t,i)}draw(e,t,i,s,o,r){return this._drawShape(e,"triangle",3,t,i,s,o,r)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},To=class extends Te{constructor(e,t,i){super(e,t,i)}draw(e,t,i,s,o,r){return this._drawShape(e,"triangleDown",3,t,i,s,o,r)}distanceToBorder(e,t){return this._distanceToBorder(e,t)}},z=class{constructor(e,t,i,s,o,r){this.options=_e(o),this.globalOptions=o,this.defaultOptions=r,this.body=t,this.edges=[],this.id=void 0,this.imagelist=i,this.grouplist=s,this.x=void 0,this.y=void 0,this.baseSize=this.options.size,this.baseFontSize=this.options.font.size,this.predefinedPosition=!1,this.selected=!1,this.hover=!1,this.labelModule=new Ye(this.body,this.options,!1),this.setOptions(e)}attachEdge(e){this.edges.indexOf(e)===-1&&this.edges.push(e)}detachEdge(e){let t=this.edges.indexOf(e);t!=-1&&this.edges.splice(t,1)}setOptions(e){let t=this.options.shape;if(!e)return;if(typeof e.color!="undefined"&&(this._localColor=e.color),e.id!==void 0&&(this.id=e.id),this.id===void 0)throw new Error("Node must have an id");z.checkMass(e,this.id),e.x!==void 0&&(e.x===null?(this.x=void 0,this.predefinedPosition=!1):(this.x=parseInt(e.x),this.predefinedPosition=!0)),e.y!==void 0&&(e.y===null?(this.y=void 0,this.predefinedPosition=!1):(this.y=parseInt(e.y),this.predefinedPosition=!0)),e.size!==void 0&&(this.baseSize=e.size),e.value!==void 0&&(e.value=parseFloat(e.value)),z.parseOptions(this.options,e,!0,this.globalOptions,this.grouplist);let i=[e,this.options,this.defaultOptions];return this.chooser=Ci("node",i),this._load_images(),this.updateLabelModule(e),e.opacity!==void 0&&z.checkOpacity(e.opacity)&&(this.options.opacity=e.opacity),this.updateShape(t),e.hidden!==void 0||e.physics!==void 0}_load_images(){if((this.options.shape==="circularImage"||this.options.shape==="image")&&this.options.image===void 0)throw new Error("Option image must be defined for node type '"+this.options.shape+"'");if(this.options.image!==void 0){if(this.imagelist===void 0)throw new Error("Internal Error: No images provided");if(typeof this.options.image=="string")this.imageObj=this.imagelist.load(this.options.image,this.options.brokenImage,this.id);else{if(this.options.image.unselected===void 0)throw new Error("No unselected image provided");this.imageObj=this.imagelist.load(this.options.image.unselected,this.options.brokenImage,this.id),this.options.image.selected!==void 0?this.imageObjAlt=this.imagelist.load(this.options.image.selected,this.options.brokenImage,this.id):this.imageObjAlt=void 0}}}static checkOpacity(e){return 0<=e&&e<=1}static checkCoordinateOrigin(e){return e===void 0||e==="center"||e==="top-left"}static updateGroupOptions(e,t,i){if(i===void 0)return;let s=e.group;if(t!==void 0&&t.group!==void 0&&s!==t.group)throw new Error("updateGroupOptions: group values in options don't match.");if(!(typeof s=="number"||typeof s=="string"&&s!=""))return;let r=i.get(s);r.opacity!==void 0&&t.opacity===void 0&&(z.checkOpacity(r.opacity)||(console.error("Invalid option for node opacity. Value must be between 0 and 1, found: "+r.opacity),r.opacity=void 0));let a=Object.getOwnPropertyNames(t).filter(d=>t[d]!=null);a.push("font"),bt(a,e,r),e.color=zt(e.color)}static parseOptions(e,t,i=!1,s={},o){if(bt(["color","fixed","shadow"],e,t,i),z.checkMass(t),e.opacity!==void 0&&(z.checkOpacity(e.opacity)||(console.error("Invalid option for node opacity. Value must be between 0 and 1, found: "+e.opacity),e.opacity=void 0)),t.opacity!==void 0&&(z.checkOpacity(t.opacity)||(console.error("Invalid option for node opacity. Value must be between 0 and 1, found: "+t.opacity),t.opacity=void 0)),t.shapeProperties&&!z.checkCoordinateOrigin(t.shapeProperties.coordinateOrigin)&&console.error("Invalid option for node coordinateOrigin, found: "+t.shapeProperties.coordinateOrigin),se(e,t,"shadow",s),t.color!==void 0&&t.color!==null){let a=zt(t.color);fi(e.color,a)}else i===!0&&t.color===null&&(e.color=_e(s.color));t.fixed!==void 0&&t.fixed!==null&&(typeof t.fixed=="boolean"?(e.fixed.x=t.fixed,e.fixed.y=t.fixed):(t.fixed.x!==void 0&&typeof t.fixed.x=="boolean"&&(e.fixed.x=t.fixed.x),t.fixed.y!==void 0&&typeof t.fixed.y=="boolean"&&(e.fixed.y=t.fixed.y))),i===!0&&t.font===null&&(e.font=_e(s.font)),z.updateGroupOptions(e,t,o),t.scaling!==void 0&&se(e.scaling,t.scaling,"label",s.scaling)}getFormattingValues(){let e={color:this.options.color.background,opacity:this.options.opacity,borderWidth:this.options.borderWidth,borderColor:this.options.color.border,size:this.options.size,borderDashes:this.options.shapeProperties.borderDashes,borderRadius:this.options.shapeProperties.borderRadius,shadow:this.options.shadow.enabled,shadowColor:this.options.shadow.color,shadowSize:this.options.shadow.size,shadowX:this.options.shadow.x,shadowY:this.options.shadow.y};if(this.selected||this.hover?this.chooser===!0?this.selected?(this.options.borderWidthSelected!=null?e.borderWidth=this.options.borderWidthSelected:e.borderWidth*=2,e.color=this.options.color.highlight.background,e.borderColor=this.options.color.highlight.border,e.shadow=this.options.shadow.enabled):this.hover&&(e.color=this.options.color.hover.background,e.borderColor=this.options.color.hover.border,e.shadow=this.options.shadow.enabled):typeof this.chooser=="function"&&(this.chooser(e,this.options.id,this.selected,this.hover),e.shadow===!1&&(e.shadowColor!==this.options.shadow.color||e.shadowSize!==this.options.shadow.size||e.shadowX!==this.options.shadow.x||e.shadowY!==this.options.shadow.y)&&(e.shadow=!0)):e.shadow=this.options.shadow.enabled,this.options.opacity!==void 0){let t=this.options.opacity;e.borderColor=ie(e.borderColor,t),e.color=ie(e.color,t),e.shadowColor=ie(e.shadowColor,t)}return e}updateLabelModule(e){(this.options.label===void 0||this.options.label===null)&&(this.options.label=""),z.updateGroupOptions(this.options,Be(le({},e),{color:e&&e.color||this._localColor||void 0}),this.grouplist);let t=this.grouplist.get(this.options.group,!1),i=[e,this.options,t,this.globalOptions,this.defaultOptions];this.labelModule.update(this.options,i),this.labelModule.baseSize!==void 0&&(this.baseFontSize=this.labelModule.baseSize)}updateShape(e){if(e===this.options.shape&&this.shape)this.shape.setOptions(this.options,this.imageObj,this.imageObjAlt);else switch(this.options.shape){case"box":this.shape=new ga(this.options,this.body,this.labelModule);break;case"circle":this.shape=new ma(this.options,this.body,this.labelModule);break;case"circularImage":this.shape=new mo(this.options,this.body,this.labelModule,this.imageObj,this.imageObjAlt);break;case"custom":this.shape=new yo(this.options,this.body,this.labelModule,this.options.ctxRenderer);break;case"database":this.shape=new bo(this.options,this.body,this.labelModule);break;case"diamond":this.shape=new ya(this.options,this.body,this.labelModule);break;case"dot":this.shape=new vo(this.options,this.body,this.labelModule);break;case"ellipse":this.shape=new Oi(this.options,this.body,this.labelModule);break;case"icon":this.shape=new wo(this.options,this.body,this.labelModule);break;case"image":this.shape=new ba(this.options,this.body,this.labelModule,this.imageObj,this.imageObjAlt);break;case"square":this.shape=new _o(this.options,this.body,this.labelModule);break;case"hexagon":this.shape=new Eo(this.options,this.body,this.labelModule);break;case"star":this.shape=new xo(this.options,this.body,this.labelModule);break;case"text":this.shape=new Co(this.options,this.body,this.labelModule);break;case"triangle":this.shape=new va(this.options,this.body,this.labelModule);break;case"triangleDown":this.shape=new To(this.options,this.body,this.labelModule);break;default:this.shape=new Oi(this.options,this.body,this.labelModule);break}this.needsRefresh()}select(){this.selected=!0,this.needsRefresh()}unselect(){this.selected=!1,this.needsRefresh()}needsRefresh(){this.shape.refreshNeeded=!0}getTitle(){return this.options.title}distanceToBorder(e,t){return this.shape.distanceToBorder(e,t)}isFixed(){return this.options.fixed.x&&this.options.fixed.y}isSelected(){return this.selected}getValue(){return this.options.value}getLabelSize(){return this.labelModule.size()}setValueRange(e,t,i){if(this.options.value!==void 0){let s=this.options.scaling.customScalingFunction(e,t,i,this.options.value),o=this.options.scaling.max-this.options.scaling.min;if(this.options.scaling.label.enabled===!0){let r=this.options.scaling.label.max-this.options.scaling.label.min;this.options.font.size=this.options.scaling.label.min+s*r}this.options.size=this.options.scaling.min+s*o}else this.options.size=this.baseSize,this.options.font.size=this.baseFontSize;this.updateLabelModule()}draw(e){let t=this.getFormattingValues();return this.shape.draw(e,this.x,this.y,this.selected,this.hover,t)||{}}updateBoundingBox(e){this.shape.updateBoundingBox(this.x,this.y,e)}resize(e){let t=this.getFormattingValues();this.shape.resize(e,this.selected,this.hover,t)}getItemsOnPoint(e){let t=[];return this.labelModule.visible()&&Ti(this.labelModule.getSize(),e)&&t.push({nodeId:this.id,labelId:0}),Ti(this.shape.boundingBox,e)&&t.push({nodeId:this.id}),t}isOverlappingWith(e){return this.shape.lefte.left&&this.shape.tope.top}isBoundingBoxOverlappingWith(e){return this.shape.boundingBox.lefte.left&&this.shape.boundingBox.tope.top}static checkMass(e,t){if(e.mass!==void 0&&e.mass<=0){let i="";t!==void 0&&(i=" in node id: "+t),console.error("%cNegative or zero mass disallowed"+i+", setting mass to 1.",yi),e.mass=1}}},ko=class{constructor(e,t,i,s){if(this.body=e,this.images=t,this.groups=i,this.layoutEngine=s,this.body.functions.createNode=this.create.bind(this),this.nodesListeners={add:(o,r)=>{this.add(r.items)},update:(o,r)=>{this.update(r.items,r.data,r.oldData)},remove:(o,r)=>{this.remove(r.items)}},this.defaultOptions={borderWidth:1,borderWidthSelected:void 0,brokenImage:void 0,color:{border:"#2B7CE9",background:"#97C2FC",highlight:{border:"#2B7CE9",background:"#D2E5FF"},hover:{border:"#2B7CE9",background:"#D2E5FF"}},opacity:void 0,fixed:{x:!1,y:!1},font:{color:"#343434",size:14,face:"arial",background:"none",strokeWidth:0,strokeColor:"#ffffff",align:"center",vadjust:0,multi:!1,bold:{mod:"bold"},boldital:{mod:"bold italic"},ital:{mod:"italic"},mono:{mod:"",size:15,face:"monospace",vadjust:2}},group:void 0,hidden:!1,icon:{face:"FontAwesome",code:void 0,size:50,color:"#2B7CE9"},image:void 0,imagePadding:{top:0,right:0,bottom:0,left:0},label:void 0,labelHighlightBold:!0,level:void 0,margin:{top:5,right:5,bottom:5,left:5},mass:1,physics:!0,scaling:{min:10,max:30,label:{enabled:!1,min:14,max:30,maxVisible:30,drawThreshold:5},customScalingFunction:function(o,r,a,d){if(r===o)return .5;{let h=1/(r-o);return Math.max(0,(d-o)*h)}}},shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:10,x:5,y:5},shape:"ellipse",shapeProperties:{borderDashes:!1,borderRadius:6,interpolation:!0,useImageSize:!1,useBorderWithImage:!1,coordinateOrigin:"center"},size:25,title:void 0,value:void 0,x:void 0,y:void 0},this.defaultOptions.mass<=0)throw"Internal error: mass in defaultOptions of NodesHandler may not be zero or negative";this.options=_e(this.defaultOptions),this.bindEventListeners()}bindEventListeners(){this.body.emitter.on("refreshNodes",this.refresh.bind(this)),this.body.emitter.on("refresh",this.refresh.bind(this)),this.body.emitter.on("destroy",()=>{I(this.nodesListeners,(e,t)=>{this.body.data.nodes&&this.body.data.nodes.off(t,e)}),delete this.body.functions.createNode,delete this.nodesListeners.add,delete this.nodesListeners.update,delete this.nodesListeners.remove,delete this.nodesListeners})}setOptions(e){if(e!==void 0){if(z.parseOptions(this.options,e),e.opacity!==void 0&&(Number.isNaN(e.opacity)||!Number.isFinite(e.opacity)||e.opacity<0||e.opacity>1?console.error("Invalid option for node opacity. Value must be between 0 and 1, found: "+e.opacity):this.options.opacity=e.opacity),e.shape!==void 0)for(let t in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,t)&&this.body.nodes[t].updateShape();if(typeof e.font!="undefined"||typeof e.widthConstraint!="undefined"||typeof e.heightConstraint!="undefined")for(let t of Object.keys(this.body.nodes))this.body.nodes[t].updateLabelModule(),this.body.nodes[t].needsRefresh();if(e.size!==void 0)for(let t in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,t)&&this.body.nodes[t].needsRefresh();(e.hidden!==void 0||e.physics!==void 0)&&this.body.emitter.emit("_dataChanged")}}setData(e,t=!1){let i=this.body.data.nodes;if(vi("id",e))this.body.data.nodes=e;else if(Array.isArray(e))this.body.data.nodes=new Ce,this.body.data.nodes.add(e);else if(!e)this.body.data.nodes=new Ce;else throw new TypeError("Array or DataSet expected");if(i&&I(this.nodesListeners,function(s,o){i.off(o,s)}),this.body.nodes={},this.body.data.nodes){let s=this;I(this.nodesListeners,function(r,a){s.body.data.nodes.on(a,r)});let o=this.body.data.nodes.getIds();this.add(o,!0)}t===!1&&this.body.emitter.emit("_dataChanged")}add(e,t=!1){let i,s=[];for(let o=0;o{let s=this.body.data.nodes.get(i);s!==void 0&&(e===!0&&t.setOptions({x:null,y:null}),t.setOptions({fixed:!1}),t.setOptions(s))})}getPositions(e){let t={};if(e!==void 0){if(Array.isArray(e)===!0){for(let i=0;i{this.body.emitter.emit("startSimulation")},0)):console.error("Node id supplied to moveNode does not exist. Provided: ",e)}},H=class{static transform(e,t){Array.isArray(e)||(e=[e]);let i=t.point.x,s=t.point.y,o=t.angle,r=t.length;for(let a=0;a0?d>0?r=f:a=f:d>0?a=f:r=f,++v}while(r<=a&&v1?l=1:l<0&&(l=0);let c=e+l*a,u=t+l*d,f=c-o,y=u-r;return Math.sqrt(f*f+y*y)}getArrowData(e,t,i,s,o,r){let a,d,h,l,c,u,f,y=r.width;t==="from"?(h=this.from,l=this.to,c=r.fromArrowScale<0,u=Math.abs(r.fromArrowScale),f=r.fromArrowType):t==="to"?(h=this.to,l=this.from,c=r.toArrowScale<0,u=Math.abs(r.toArrowScale),f=r.toArrowType):(h=this.to,l=this.from,c=r.middleArrowScale<0,u=Math.abs(r.middleArrowScale),f=r.middleArrowType);let v=15*u+3*y;if(h!=l){let _=Math.hypot(h.x-l.x,h.y-l.y),C=v/_;if(t!=="middle")if(this.options.smooth.enabled===!0){let x=this._findBorderPosition(h,e,{via:i}),O=this.getPoint(x.t+C*(t==="from"?1:-1),i);a=Math.atan2(x.y-O.y,x.x-O.x),d=x}else a=Math.atan2(h.y-l.y,h.x-l.x),d=this._findBorderPosition(h,e);else{let x=(c?-C:C)/2,O=this.getPoint(.5+x,i),M=this.getPoint(.5-x,i);a=Math.atan2(O.y-M.y,O.x-M.x),d=this.getPoint(.5,i)}}else{let[_,C,x]=this._getCircleData(e);if(t==="from"){let O=this.options.selfReference.angle,M=this.options.selfReference.angle+Math.PI,R=this._findBorderPositionCircle(this.from,e,{x:_,y:C,low:O,high:M,direction:-1});a=R.t*-2*Math.PI+1.5*Math.PI+.1*Math.PI,d=R}else if(t==="to"){let O=this.options.selfReference.angle,M=this.options.selfReference.angle+Math.PI,R=this._findBorderPositionCircle(this.from,e,{x:_,y:C,low:O,high:M,direction:1});a=R.t*-2*Math.PI+1.5*Math.PI-1.1*Math.PI,d=R}else{let O=this.options.selfReference.angle/(2*Math.PI);d=this._pointOnCircle(_,C,x,O),a=O*-2*Math.PI+1.5*Math.PI+.1*Math.PI}}let g=d.x-v*.9*Math.cos(a),p=d.y-v*.9*Math.sin(a);return{point:d,core:{x:g,y:p},angle:a,length:v,type:f}}drawArrowHead(e,t,i,s,o){e.strokeStyle=this.getColor(e,t),e.fillStyle=e.strokeStyle,e.lineWidth=t.width,Si.draw(e,o)&&(this.enableShadow(e,t),e.fill(),this.disableShadow(e,t))}enableShadow(e,t){t.shadow===!0&&(e.shadowColor=t.shadowColor,e.shadowBlur=t.shadowSize,e.shadowOffsetX=t.shadowX,e.shadowOffsetY=t.shadowY)}disableShadow(e,t){t.shadow===!0&&(e.shadowColor="rgba(0,0,0,0)",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0)}drawBackground(e,t){if(t.background!==!1){let i={strokeStyle:e.strokeStyle,lineWidth:e.lineWidth,dashes:e.dashes};e.strokeStyle=t.backgroundColor,e.lineWidth=t.backgroundSize,this.setStrokeDashed(e,t.backgroundDashes),e.stroke(),e.strokeStyle=i.strokeStyle,e.lineWidth=i.lineWidth,e.dashes=i.dashes,this.setStrokeDashed(e,t.dashes)}}setStrokeDashed(e,t){if(t!==!1)if(e.setLineDash!==void 0){let i=Array.isArray(t)?t:[5,5];e.setLineDash(i)}else console.warn("setLineDash is not supported in this browser. The dashed stroke cannot be used.");else e.setLineDash!==void 0?e.setLineDash([]):console.warn("setLineDash is not supported in this browser. The dashed stroke cannot be used.")}},Xt=class extends Ii{constructor(e,t,i){super(e,t,i)}_findBorderPositionBezier(e,t,i=this._getViaCoordinates()){let s=10,o=.2,r=!1,a=1,d=0,h=this.to,l,c,u=this.options.endPointOffset?this.options.endPointOffset.to:0;e.id===this.from.id&&(h=this.from,r=!0,u=this.options.endPointOffset?this.options.endPointOffset.from:0),this.options.arrowStrikethrough===!1&&(u=0);let f=0;do{c=(d+a)*.5,l=this.getPoint(c,i);let y=Math.atan2(h.y-l.y,h.x-l.x),v=h.distanceToBorder(t,y)+u,g=Math.sqrt(Math.pow(l.x-h.x,2)+Math.pow(l.y-h.y,2)),p=v-g;if(Math.abs(p)0&&(h=this._getDistanceToLine(y,v,u,f,o,r),d=h{this.positionBezierNode()},this._body.emitter.on("_repositionBezierNodes",this._boundFunction)}setOptions(e){super.setOptions(e);let t=!1;this.options.physics!==e.physics&&(t=!0),this.options=e,this.id=this.options.id,this.from=this._body.nodes[this.options.from],this.to=this._body.nodes[this.options.to],this.setupSupportNode(),this.connect(),t===!0&&(this.via.setOptions({physics:this.options.physics}),this.positionBezierNode())}connect(){this.from=this._body.nodes[this.options.from],this.to=this._body.nodes[this.options.to],this.from===void 0||this.to===void 0||this.options.physics===!1?this.via.setOptions({physics:!1}):this.from.id===this.to.id?this.via.setOptions({physics:!1}):this.via.setOptions({physics:!0})}cleanup(){return this._body.emitter.off("_repositionBezierNodes",this._boundFunction),this.via!==void 0?(delete this._body.nodes[this.via.id],this.via=void 0,!0):!1}setupSupportNode(){if(this.via===void 0){let e="edgeId:"+this.id,t=this._body.functions.createNode({id:e,shape:"circle",physics:!0,hidden:!0});this._body.nodes[e]=t,this.via=t,this.via.parentEdgeId=this.id,this.positionBezierNode()}}positionBezierNode(){this.via!==void 0&&this.from!==void 0&&this.to!==void 0?(this.via.x=.5*(this.from.x+this.to.x),this.via.y=.5*(this.from.y+this.to.y)):this.via!==void 0&&(this.via.x=0,this.via.y=0)}_line(e,t,i){this._bezierCurve(e,t,i)}_getViaCoordinates(){return this.via}getViaNode(){return this.via}getPoint(e,t=this.via){if(this.from===this.to){let[i,s,o]=this._getCircleData(),r=2*Math.PI*(1-e);return{x:i+o*Math.sin(r),y:s+o-o*(1-Math.cos(r))}}else return{x:Math.pow(1-e,2)*this.fromPoint.x+2*e*(1-e)*t.x+Math.pow(e,2)*this.toPoint.x,y:Math.pow(1-e,2)*this.fromPoint.y+2*e*(1-e)*t.y+Math.pow(e,2)*this.toPoint.y}}_findBorderPosition(e,t){return this._findBorderPositionBezier(e,t,this.via)}_getDistanceToEdge(e,t,i,s,o,r){return this._getDistanceToBezierEdge(e,t,i,s,o,r,this.via)}},Mi=class extends Xt{constructor(e,t,i){super(e,t,i)}_line(e,t,i){this._bezierCurve(e,t,i)}getViaNode(){return this._getViaCoordinates()}_getViaCoordinates(){let e=this.options.smooth.roundness,t=this.options.smooth.type,i=Math.abs(this.from.x-this.to.x),s=Math.abs(this.from.y-this.to.y);if(t==="discrete"||t==="diagonalCross"){let o,r;i<=s?o=r=e*s:o=r=e*i,this.from.x>this.to.x&&(o=-o),this.from.y>=this.to.y&&(r=-r);let a=this.from.x+o,d=this.from.y+r;return t==="discrete"&&(i<=s?a=ithis.to.x&&(o=-o),this.from.y>=this.to.y&&(r=-r);let a=this.from.x+o,d=this.from.y+r;return i<=s?this.from.x<=this.to.x?a=this.to.xa?this.to.x:a:this.from.y>=this.to.y?d=this.to.y>d?this.to.y:d:d=this.to.y0){let p=this._getDistanceToLine(l,c,v,g,o,r);h=pMath.abs(t)||this.options.smooth.forceDirection===!0||this.options.smooth.forceDirection==="horizontal")&&this.options.smooth.forceDirection!=="vertical"?(s=this.from.y,r=this.to.y,i=this.from.x-a*e,o=this.to.x+a*e):(s=this.from.y-a*t,r=this.to.y+a*t,i=this.from.x,o=this.to.x),[{x:i,y:s},{x:o,y:r}]}getViaNode(){return this._getViaCoordinates()}_findBorderPosition(e,t){return this._findBorderPositionBezier(e,t)}_getDistanceToEdge(e,t,i,s,o,r,[a,d]=this._getViaCoordinates()){return this._getDistanceToBezierEdge2(e,t,i,s,o,r,a,d)}getPoint(e,[t,i]=this._getViaCoordinates()){let s=e,o=[Math.pow(1-s,3),3*s*Math.pow(1-s,2),3*Math.pow(s,2)*(1-s),Math.pow(s,3)],r=o[0]*this.fromPoint.x+o[1]*t.x+o[2]*i.x+o[3]*this.toPoint.x,a=o[0]*this.fromPoint.y+o[1]*t.y+o[2]*i.y+o[3]*this.toPoint.y;return{x:r,y:a}}},Fi=class extends Ii{constructor(e,t,i){super(e,t,i)}_line(e,t){e.beginPath(),e.moveTo(this.fromPoint.x,this.fromPoint.y),e.lineTo(this.toPoint.x,this.toPoint.y),this.enableShadow(e,t),e.stroke(),this.disableShadow(e,t)}getViaNode(){}getPoint(e){return{x:(1-e)*this.fromPoint.x+e*this.toPoint.x,y:(1-e)*this.fromPoint.y+e*this.toPoint.y}}_findBorderPosition(e,t){let i=this.to,s=this.from;e.id===this.from.id&&(i=this.from,s=this.to);let o=Math.atan2(i.y-s.y,i.x-s.x),r=i.x-s.x,a=i.y-s.y,d=Math.sqrt(r*r+a*a),h=e.distanceToBorder(t,o),l=(d-h)/d;return{x:(1-l)*s.x+l*i.x,y:(1-l)*s.y+l*i.y,t:0}}_getDistanceToEdge(e,t,i,s,o,r){return this._getDistanceToLine(e,t,i,s,o,r)}},ke=class{constructor(e,t,i,s,o){if(t===void 0)throw new Error("No body provided");this.options=_e(s),this.globalOptions=s,this.defaultOptions=o,this.body=t,this.imagelist=i,this.id=void 0,this.fromId=void 0,this.toId=void 0,this.selected=!1,this.hover=!1,this.labelDirty=!0,this.baseWidth=this.options.width,this.baseFontSize=this.options.font.size,this.from=void 0,this.to=void 0,this.edgeType=void 0,this.connected=!1,this.labelModule=new Ye(this.body,this.options,!0),this.setOptions(e)}setOptions(e){if(!e)return;let t=typeof e.physics!="undefined"&&this.options.physics!==e.physics||typeof e.hidden!="undefined"&&(this.options.hidden||!1)!==(e.hidden||!1)||typeof e.from!="undefined"&&this.options.from!==e.from||typeof e.to!="undefined"&&this.options.to!==e.to;ke.parseOptions(this.options,e,!0,this.globalOptions),e.id!==void 0&&(this.id=e.id),e.from!==void 0&&(this.fromId=e.from),e.to!==void 0&&(this.toId=e.to),e.title!==void 0&&(this.title=e.title),e.value!==void 0&&(e.value=parseFloat(e.value));let i=[e,this.options,this.defaultOptions];return this.chooser=Ci("edge",i),this.updateLabelModule(e),t=this.updateEdgeType()||t,this._setInteractionWidths(),this.connect(),t}static parseOptions(e,t,i=!1,s={},o=!1){if(qe(["endPointOffset","arrowStrikethrough","id","from","hidden","hoverWidth","labelHighlightBold","length","line","opacity","physics","scaling","selectionWidth","selfReferenceSize","selfReference","to","title","value","width","font","chosen","widthConstraint"],e,t,i),t.endPointOffset!==void 0&&t.endPointOffset.from!==void 0&&(Number.isFinite(t.endPointOffset.from)?e.endPointOffset.from=t.endPointOffset.from:(e.endPointOffset.from=s.endPointOffset.from!==void 0?s.endPointOffset.from:0,console.error("endPointOffset.from is not a valid number"))),t.endPointOffset!==void 0&&t.endPointOffset.to!==void 0&&(Number.isFinite(t.endPointOffset.to)?e.endPointOffset.to=t.endPointOffset.to:(e.endPointOffset.to=s.endPointOffset.to!==void 0?s.endPointOffset.to:0,console.error("endPointOffset.to is not a valid number"))),qt(t.label)?e.label=t.label:qt(e.label)||(e.label=void 0),se(e,t,"smooth",s),se(e,t,"shadow",s),se(e,t,"background",s),t.dashes!==void 0&&t.dashes!==null?e.dashes=t.dashes:i===!0&&t.dashes===null&&(e.dashes=Object.create(s.dashes)),t.scaling!==void 0&&t.scaling!==null?(t.scaling.min!==void 0&&(e.scaling.min=t.scaling.min),t.scaling.max!==void 0&&(e.scaling.max=t.scaling.max),se(e.scaling,t.scaling,"label",s.scaling)):i===!0&&t.scaling===null&&(e.scaling=Object.create(s.scaling)),t.arrows!==void 0&&t.arrows!==null)if(typeof t.arrows=="string"){let a=t.arrows.toLowerCase();e.arrows.to.enabled=a.indexOf("to")!=-1,e.arrows.middle.enabled=a.indexOf("middle")!=-1,e.arrows.from.enabled=a.indexOf("from")!=-1}else if(typeof t.arrows=="object")se(e.arrows,t.arrows,"to",s.arrows),se(e.arrows,t.arrows,"middle",s.arrows),se(e.arrows,t.arrows,"from",s.arrows);else throw new Error("The arrow newOptions can only be an object or a string. Refer to the documentation. You used:"+JSON.stringify(t.arrows));else i===!0&&t.arrows===null&&(e.arrows=Object.create(s.arrows));if(t.color!==void 0&&t.color!==null){let a=we(t.color)?{color:t.color,highlight:t.color,hover:t.color,inherit:!1,opacity:1}:t.color,d=e.color;if(o)D(d,s.color,!1,i);else for(let h in d)Object.prototype.hasOwnProperty.call(d,h)&&delete d[h];if(we(d))d.color=d,d.highlight=d,d.hover=d,d.inherit=!1,a.opacity===void 0&&(d.opacity=1);else{let h=!1;a.color!==void 0&&(d.color=a.color,h=!0),a.highlight!==void 0&&(d.highlight=a.highlight,h=!0),a.hover!==void 0&&(d.hover=a.hover,h=!0),a.inherit!==void 0&&(d.inherit=a.inherit),a.opacity!==void 0&&(d.opacity=Math.min(1,Math.max(0,a.opacity))),h===!0?d.inherit=!1:d.inherit===void 0&&(d.inherit="from")}}else i===!0&&t.color===null&&(e.color=_e(s.color));i===!0&&t.font===null&&(e.font=_e(s.font)),Object.prototype.hasOwnProperty.call(t,"selfReferenceSize")&&(console.warn("The selfReferenceSize property has been deprecated. Please use selfReference property instead. The selfReference can be set like thise selfReference:{size:30, angle:Math.PI / 4}"),e.selfReference.size=t.selfReferenceSize)}getFormattingValues(){let e=this.options.arrows.to===!0||this.options.arrows.to.enabled===!0,t=this.options.arrows.from===!0||this.options.arrows.from.enabled===!0,i=this.options.arrows.middle===!0||this.options.arrows.middle.enabled===!0,s=this.options.color.inherit,o={toArrow:e,toArrowScale:this.options.arrows.to.scaleFactor,toArrowType:this.options.arrows.to.type,toArrowSrc:this.options.arrows.to.src,toArrowImageWidth:this.options.arrows.to.imageWidth,toArrowImageHeight:this.options.arrows.to.imageHeight,middleArrow:i,middleArrowScale:this.options.arrows.middle.scaleFactor,middleArrowType:this.options.arrows.middle.type,middleArrowSrc:this.options.arrows.middle.src,middleArrowImageWidth:this.options.arrows.middle.imageWidth,middleArrowImageHeight:this.options.arrows.middle.imageHeight,fromArrow:t,fromArrowScale:this.options.arrows.from.scaleFactor,fromArrowType:this.options.arrows.from.type,fromArrowSrc:this.options.arrows.from.src,fromArrowImageWidth:this.options.arrows.from.imageWidth,fromArrowImageHeight:this.options.arrows.from.imageHeight,arrowStrikethrough:this.options.arrowStrikethrough,color:s?void 0:this.options.color.color,inheritsColor:s,opacity:this.options.color.opacity,hidden:this.options.hidden,length:this.options.length,shadow:this.options.shadow.enabled,shadowColor:this.options.shadow.color,shadowSize:this.options.shadow.size,shadowX:this.options.shadow.x,shadowY:this.options.shadow.y,dashes:this.options.dashes,width:this.options.width,background:this.options.background.enabled,backgroundColor:this.options.background.color,backgroundSize:this.options.background.size,backgroundDashes:this.options.background.dashes};if(this.selected||this.hover)if(this.chooser===!0){if(this.selected){let r=this.options.selectionWidth;typeof r=="function"?o.width=r(o.width):typeof r=="number"&&(o.width+=r),o.width=Math.max(o.width,.3/this.body.view.scale),o.color=this.options.color.highlight,o.shadow=this.options.shadow.enabled}else if(this.hover){let r=this.options.hoverWidth;typeof r=="function"?o.width=r(o.width):typeof r=="number"&&(o.width+=r),o.width=Math.max(o.width,.3/this.body.view.scale),o.color=this.options.color.hover,o.shadow=this.options.shadow.enabled}}else typeof this.chooser=="function"&&(this.chooser(o,this.options.id,this.selected,this.hover),o.color!==void 0&&(o.inheritsColor=!1),o.shadow===!1&&(o.shadowColor!==this.options.shadow.color||o.shadowSize!==this.options.shadow.size||o.shadowX!==this.options.shadow.x||o.shadowY!==this.options.shadow.y)&&(o.shadow=!0));else o.shadow=this.options.shadow.enabled,o.width=Math.max(o.width,.3/this.body.view.scale);return o}updateLabelModule(e){let t=[e,this.options,this.globalOptions,this.defaultOptions];this.labelModule.update(this.options,t),this.labelModule.baseSize!==void 0&&(this.baseFontSize=this.labelModule.baseSize)}updateEdgeType(){let e=this.options.smooth,t=!1,i=!0;return this.edgeType!==void 0&&((this.edgeType instanceof Pi&&e.enabled===!0&&e.type==="dynamic"||this.edgeType instanceof Di&&e.enabled===!0&&e.type==="cubicBezier"||this.edgeType instanceof Mi&&e.enabled===!0&&e.type!=="dynamic"&&e.type!=="cubicBezier"||this.edgeType instanceof Fi&&e.type.enabled===!1)&&(i=!1),i===!0&&(t=this.cleanup())),i===!0?e.enabled===!0?e.type==="dynamic"?(t=!0,this.edgeType=new Pi(this.options,this.body,this.labelModule)):e.type==="cubicBezier"?this.edgeType=new Di(this.options,this.body,this.labelModule):this.edgeType=new Mi(this.options,this.body,this.labelModule):this.edgeType=new Fi(this.options,this.body,this.labelModule):this.edgeType.setOptions(this.options),t}connect(){this.disconnect(),this.from=this.body.nodes[this.fromId]||void 0,this.to=this.body.nodes[this.toId]||void 0,this.connected=this.from!==void 0&&this.to!==void 0,this.connected===!0?(this.from.attachEdge(this),this.to.attachEdge(this)):(this.from&&this.from.detachEdge(this),this.to&&this.to.detachEdge(this)),this.edgeType.connect()}disconnect(){this.from&&(this.from.detachEdge(this),this.from=void 0),this.to&&(this.to.detachEdge(this),this.to=void 0),this.connected=!1}getTitle(){return this.title}isSelected(){return this.selected}getValue(){return this.options.value}setValueRange(e,t,i){if(this.options.value!==void 0){let s=this.options.scaling.customScalingFunction(e,t,i,this.options.value),o=this.options.scaling.max-this.options.scaling.min;if(this.options.scaling.label.enabled===!0){let r=this.options.scaling.label.max-this.options.scaling.label.min;this.options.font.size=this.options.scaling.label.min+s*r}this.options.width=this.options.scaling.min+s*o}else this.options.width=this.baseWidth,this.options.font.size=this.baseFontSize;this._setInteractionWidths(),this.updateLabelModule()}_setInteractionWidths(){typeof this.options.hoverWidth=="function"?this.edgeType.hoverWidth=this.options.hoverWidth(this.options.width):this.edgeType.hoverWidth=this.options.hoverWidth+this.options.width,typeof this.options.selectionWidth=="function"?this.edgeType.selectionWidth=this.options.selectionWidth(this.options.width):this.edgeType.selectionWidth=this.options.selectionWidth+this.options.width}draw(e){let t=this.getFormattingValues();if(t.hidden)return;let i=this.edgeType.getViaNode();this.edgeType.drawLine(e,t,this.selected,this.hover,i),this.drawLabel(e,i)}drawArrows(e){let t=this.getFormattingValues();if(t.hidden)return;let i=this.edgeType.getViaNode(),s={};this.edgeType.fromPoint=this.edgeType.from,this.edgeType.toPoint=this.edgeType.to,t.fromArrow&&(s.from=this.edgeType.getArrowData(e,"from",i,this.selected,this.hover,t),t.arrowStrikethrough===!1&&(this.edgeType.fromPoint=s.from.core),t.fromArrowSrc&&(s.from.image=this.imagelist.load(t.fromArrowSrc)),t.fromArrowImageWidth&&(s.from.imageWidth=t.fromArrowImageWidth),t.fromArrowImageHeight&&(s.from.imageHeight=t.fromArrowImageHeight)),t.toArrow&&(s.to=this.edgeType.getArrowData(e,"to",i,this.selected,this.hover,t),t.arrowStrikethrough===!1&&(this.edgeType.toPoint=s.to.core),t.toArrowSrc&&(s.to.image=this.imagelist.load(t.toArrowSrc)),t.toArrowImageWidth&&(s.to.imageWidth=t.toArrowImageWidth),t.toArrowImageHeight&&(s.to.imageHeight=t.toArrowImageHeight)),t.middleArrow&&(s.middle=this.edgeType.getArrowData(e,"middle",i,this.selected,this.hover,t),t.middleArrowSrc&&(s.middle.image=this.imagelist.load(t.middleArrowSrc)),t.middleArrowImageWidth&&(s.middle.imageWidth=t.middleArrowImageWidth),t.middleArrowImageHeight&&(s.middle.imageHeight=t.middleArrowImageHeight)),t.fromArrow&&this.edgeType.drawArrowHead(e,t,this.selected,this.hover,s.from),t.middleArrow&&this.edgeType.drawArrowHead(e,t,this.selected,this.hover,s.middle),t.toArrow&&this.edgeType.drawArrowHead(e,t,this.selected,this.hover,s.to)}drawLabel(e,t){if(this.options.label!==void 0){let i=this.from,s=this.to;this.labelModule.differentState(this.selected,this.hover)&&this.labelModule.getTextSize(e,this.selected,this.hover);let o;if(i.id!=s.id){this.labelModule.pointToSelf=!1,o=this.edgeType.getPoint(.5,t),e.save();let r=this._getRotation(e);r.angle!=0&&(e.translate(r.x,r.y),e.rotate(r.angle)),this.labelModule.draw(e,o.x,o.y,this.selected,this.hover),e.restore()}else{this.labelModule.pointToSelf=!0;let r=fo(e,this.options.selfReference.angle,this.options.selfReference.size,i);o=this._pointOnCircle(r.x,r.y,this.options.selfReference.size,this.options.selfReference.angle),this.labelModule.draw(e,o.x,o.y,this.selected,this.hover)}}}getItemsOnPoint(e){let t=[];if(this.labelModule.visible()){let s=this._getRotation();Ti(this.labelModule.getSize(),e,s)&&t.push({edgeId:this.id,labelId:0})}let i={left:e.x,top:e.y};return this.isOverlappingWith(i)&&t.push({edgeId:this.id}),t}isOverlappingWith(e){if(this.connected){let t=10,i=this.from.x,s=this.from.y,o=this.to.x,r=this.to.y,a=e.left,d=e.top;return this.edgeType.getDistanceToEdge(i,s,o,r,a,d)0&&r<0)&&(a+=Math.PI),s.angle=a,s}_pointOnCircle(e,t,i,s){return{x:e+i*Math.cos(s),y:t-i*Math.sin(s)}}select(){this.selected=!0}unselect(){this.selected=!1}cleanup(){return this.edgeType.cleanup()}remove(){this.cleanup(),this.disconnect(),delete this.body.edges[this.id]}endPointsValid(){return this.body.nodes[this.fromId]!==void 0&&this.body.nodes[this.toId]!==void 0}},Lo=class{constructor(e,t,i){this.body=e,this.images=t,this.groups=i,this.body.functions.createEdge=this.create.bind(this),this.edgesListeners={add:(s,o)=>{this.add(o.items)},update:(s,o)=>{this.update(o.items)},remove:(s,o)=>{this.remove(o.items)}},this.options={},this.defaultOptions={arrows:{to:{enabled:!1,scaleFactor:1,type:"arrow"},middle:{enabled:!1,scaleFactor:1,type:"arrow"},from:{enabled:!1,scaleFactor:1,type:"arrow"}},endPointOffset:{from:0,to:0},arrowStrikethrough:!0,color:{color:"#848484",highlight:"#848484",hover:"#848484",inherit:"from",opacity:1},dashes:!1,font:{color:"#343434",size:14,face:"arial",background:"none",strokeWidth:2,strokeColor:"#ffffff",align:"horizontal",multi:!1,vadjust:0,bold:{mod:"bold"},boldital:{mod:"bold italic"},ital:{mod:"italic"},mono:{mod:"",size:15,face:"courier new",vadjust:2}},hidden:!1,hoverWidth:1.5,label:void 0,labelHighlightBold:!0,length:void 0,physics:!0,scaling:{min:1,max:15,label:{enabled:!0,min:14,max:30,maxVisible:30,drawThreshold:5},customScalingFunction:function(s,o,r,a){if(o===s)return .5;{let d=1/(o-s);return Math.max(0,(a-s)*d)}}},selectionWidth:1.5,selfReference:{size:20,angle:Math.PI/4,renderBehindTheNode:!0},shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:10,x:5,y:5},background:{enabled:!1,color:"rgba(111,111,111,1)",size:10,dashes:!1},smooth:{enabled:!0,type:"dynamic",forceDirection:"none",roundness:.5},title:void 0,width:1,value:void 0},D(this.options,this.defaultOptions),this.bindEventListeners()}bindEventListeners(){this.body.emitter.on("_forceDisableDynamicCurves",(e,t=!0)=>{e==="dynamic"&&(e="continuous");let i=!1;for(let s in this.body.edges)if(Object.prototype.hasOwnProperty.call(this.body.edges,s)){let o=this.body.edges[s],r=this.body.data.edges.get(s);if(r!=null){let a=r.smooth;a!==void 0&&a.enabled===!0&&a.type==="dynamic"&&(e===void 0?o.setOptions({smooth:!1}):o.setOptions({smooth:{type:e}}),i=!0)}}t===!0&&i===!0&&this.body.emitter.emit("_dataChanged")}),this.body.emitter.on("_dataUpdated",()=>{this.reconnectEdges()}),this.body.emitter.on("refreshEdges",this.refresh.bind(this)),this.body.emitter.on("refresh",this.refresh.bind(this)),this.body.emitter.on("destroy",()=>{I(this.edgesListeners,(e,t)=>{this.body.data.edges&&this.body.data.edges.off(t,e)}),delete this.body.functions.createEdge,delete this.edgesListeners.add,delete this.edgesListeners.update,delete this.edgesListeners.remove,delete this.edgesListeners})}setOptions(e){if(e!==void 0){ke.parseOptions(this.options,e,!0,this.defaultOptions,!0);let t=!1;if(e.smooth!==void 0)for(let i in this.body.edges)Object.prototype.hasOwnProperty.call(this.body.edges,i)&&(t=this.body.edges[i].updateEdgeType()||t);if(e.font!==void 0)for(let i in this.body.edges)Object.prototype.hasOwnProperty.call(this.body.edges,i)&&this.body.edges[i].updateLabelModule();(e.hidden!==void 0||e.physics!==void 0||t===!0)&&this.body.emitter.emit("_dataChanged")}}setData(e,t=!1){let i=this.body.data.edges;if(vi("id",e))this.body.data.edges=e;else if(Array.isArray(e))this.body.data.edges=new Ce,this.body.data.edges.add(e);else if(!e)this.body.data.edges=new Ce;else throw new TypeError("Array or DataSet expected");if(i&&I(this.edgesListeners,(s,o)=>{i.off(o,s)}),this.body.edges={},this.body.data.edges){I(this.edgesListeners,(o,r)=>{this.body.data.edges.on(r,o)});let s=this.body.data.edges.getIds();this.add(s,!0)}this.body.emitter.emit("_adjustEdgesForHierarchicalLayout"),t===!1&&this.body.emitter.emit("_dataChanged")}add(e,t=!1){let i=this.body.edges,s=this.body.data.edges;for(let o=0;o{let o=i[s];o!==void 0&&o.remove()}),t&&this.body.emitter.emit("_dataChanged")}refresh(){I(this.body.edges,(e,t)=>{let i=this.body.data.edges.get(t);i!==void 0&&e.setOptions(i)})}create(e){return new ke(e,this.body,this.images,this.options,this.defaultOptions)}reconnectEdges(){let e,t=this.body.nodes,i=this.body.edges;for(e in t)Object.prototype.hasOwnProperty.call(t,e)&&(t[e].edges=[]);for(e in i)if(Object.prototype.hasOwnProperty.call(i,e)){let s=i[e];s.from=null,s.to=null,s.connect()}}getConnectedNodes(e){let t=[];if(this.body.edges[e]!==void 0){let i=this.body.edges[e];i.fromId!==void 0&&t.push(i.fromId),i.toId!==void 0&&t.push(i.toId)}return t}_updateState(){this._addMissingEdges(),this._removeInvalidEdges()}_removeInvalidEdges(){let e=[];I(this.body.edges,(t,i)=>{let s=this.body.nodes[t.toId],o=this.body.nodes[t.fromId];s!==void 0&&s.isCluster===!0||o!==void 0&&o.isCluster===!0||(s===void 0||o===void 0)&&e.push(i)}),this.remove(e,!1)}_addMissingEdges(){let e=this.body.data.edges;if(e==null)return;let t=this.body.edges,i=[];e.forEach((s,o)=>{t[o]===void 0&&i.push(o)}),this.add(i,!0)}},Ni=class{constructor(e,t,i){this.body=e,this.physicsBody=t,this.barnesHutTree,this.setOptions(i),this._rng=yt("BARNES HUT SOLVER")}setOptions(e){this.options=e,this.thetaInversed=1/this.options.theta,this.overlapAvoidanceFactor=1-Math.max(0,Math.min(1,this.options.avoidOverlap))}solve(){if(this.options.gravitationalConstant!==0&&this.physicsBody.physicsNodeIndices.length>0){let e,t=this.body.nodes,i=this.physicsBody.physicsNodeIndices,s=i.length,o=this._formBarnesHutTree(t,i);this.barnesHutTree=o;for(let r=0;r0&&this._getForceContributions(o.root,e)}}_getForceContributions(e,t){this._getForceContribution(e.children.NW,t),this._getForceContribution(e.children.NE,t),this._getForceContribution(e.children.SW,t),this._getForceContribution(e.children.SE,t)}_getForceContribution(e,t){if(e.childrenCount>0){let i=e.centerOfMass.x-t.x,s=e.centerOfMass.y-t.y,o=Math.sqrt(i*i+s*s);o*e.calcSize>this.thetaInversed?this._calculateForces(o,i,s,t,e):e.childrenCount===4?this._getForceContributions(e,t):e.children.data.id!=t.id&&this._calculateForces(o,i,s,t,e)}}_calculateForces(e,t,i,s,o){e===0&&(e=.1,t=e),this.overlapAvoidanceFactor<1&&s.shape.radius&&(e=Math.max(.1+this.overlapAvoidanceFactor*s.shape.radius,e-s.shape.radius));let r=this.options.gravitationalConstant*o.mass*s.options.mass/Math.pow(e,3),a=t*r,d=i*r;this.physicsBody.forces[s.id].x+=a,this.physicsBody.forces[s.id].y+=d}_formBarnesHutTree(e,t){let i,s=t.length,o=e[t[0]].x,r=e[t[0]].y,a=e[t[0]].x,d=e[t[0]].y;for(let g=1;g0&&(ba&&(a=b),_d&&(d=_))}let h=Math.abs(a-o)-Math.abs(d-r);h>0?(r-=.5*h,d+=.5*h):(o+=.5*h,a-=.5*h);let c=Math.max(1e-5,Math.abs(a-o)),u=.5*c,f=.5*(o+a),y=.5*(r+d),v={root:{centerOfMass:{x:0,y:0},mass:0,range:{minX:f-u,maxX:f+u,minY:y-u,maxY:y+u},size:c,calcSize:1/c,children:{data:null},maxWidth:0,level:0,childrenCount:4}};this._splitBranch(v.root);for(let g=0;g0&&this._placeInTree(v.root,i);return v}_updateBranchMass(e,t){let i=e.centerOfMass,s=e.mass+t.options.mass,o=1/s;i.x=i.x*e.mass+t.x*t.options.mass,i.x*=o,i.y=i.y*e.mass+t.y*t.options.mass,i.y*=o,e.mass=s;let r=Math.max(Math.max(t.height,t.radius),t.width);e.maxWidth=e.maxWidtht.x?s.maxY>t.y?o="NW":o="SW":s.maxY>t.y?o="NE":o="SE",this._placeInRegion(e,t,o)}_placeInRegion(e,t,i){let s=e.children[i];switch(s.childrenCount){case 0:s.children.data=t,s.childrenCount=1,this._updateBranchMass(s,t);break;case 1:s.children.data.x===t.x&&s.children.data.y===t.y?(t.x+=this._rng(),t.y+=this._rng()):(this._splitBranch(s),this._placeInTree(s,t));break;case 4:this._placeInTree(s,t);break}}_splitBranch(e){let t=null;e.childrenCount===1&&(t=e.children.data,e.mass=0,e.centerOfMass.x=0,e.centerOfMass.y=0),e.childrenCount=4,e.children.data=null,this._insertRegion(e,"NW"),this._insertRegion(e,"NE"),this._insertRegion(e,"SW"),this._insertRegion(e,"SE"),t!=null&&this._placeInTree(e,t)}_insertRegion(e,t){let i,s,o,r,a=.5*e.size;switch(t){case"NW":i=e.range.minX,s=e.range.minX+a,o=e.range.minY,r=e.range.minY+a;break;case"NE":i=e.range.minX+a,s=e.range.maxX,o=e.range.minY,r=e.range.minY+a;break;case"SW":i=e.range.minX,s=e.range.minX+a,o=e.range.minY+a,r=e.range.maxY;break;case"SE":i=e.range.minX+a,s=e.range.maxX,o=e.range.minY+a,r=e.range.maxY;break}e.children[t]={centerOfMass:{x:0,y:0},mass:0,range:{minX:i,maxX:s,minY:o,maxY:r},size:.5*e.size,calcSize:2*e.calcSize,children:{data:null},maxWidth:0,level:e.level+1,childrenCount:0}}_debug(e,t){this.barnesHutTree!==void 0&&(e.lineWidth=1,this._drawBranch(this.barnesHutTree.root,e,t))}_drawBranch(e,t,i){i===void 0&&(i="#FF0000"),e.childrenCount===4&&(this._drawBranch(e.children.NW,t),this._drawBranch(e.children.NE,t),this._drawBranch(e.children.SE,t),this._drawBranch(e.children.SW,t)),t.strokeStyle=i,t.beginPath(),t.moveTo(e.range.minX,e.range.minY),t.lineTo(e.range.maxX,e.range.minY),t.stroke(),t.beginPath(),t.moveTo(e.range.maxX,e.range.minY),t.lineTo(e.range.maxX,e.range.maxY),t.stroke(),t.beginPath(),t.moveTo(e.range.maxX,e.range.maxY),t.lineTo(e.range.minX,e.range.maxY),t.stroke(),t.beginPath(),t.moveTo(e.range.minX,e.range.maxY),t.lineTo(e.range.minX,e.range.minY),t.stroke()}},Ho=class{constructor(e,t,i){this._rng=yt("REPULSION SOLVER"),this.body=e,this.physicsBody=t,this.setOptions(i)}setOptions(e){this.options=e}solve(){let e,t,i,s,o,r,a,d,h=this.body.nodes,l=this.physicsBody.physicsNodeIndices,c=this.physicsBody.forces,u=this.options.nodeDistance,f=-2/3/u,y=4/3;for(let v=0;v0){let r=o.edges.length+1,a=this.options.centralGravity*r*o.options.mass;s[o.id].x=t*a,s[o.id].y=i*a}}},Uo=class{constructor(e){this.body=e,this.physicsBody={physicsNodeIndices:[],physicsEdgeIndices:[],forces:{},velocities:{}},this.physicsEnabled=!0,this.simulationInterval=1e3/60,this.requiresTimeout=!0,this.previousStates={},this.referenceState={},this.freezeCache={},this.renderTimer=void 0,this.adaptiveTimestep=!1,this.adaptiveTimestepEnabled=!1,this.adaptiveCounter=0,this.adaptiveInterval=3,this.stabilized=!1,this.startedStabilization=!1,this.stabilizationIterations=0,this.ready=!1,this.options={},this.defaultOptions={enabled:!0,barnesHut:{theta:.5,gravitationalConstant:-2e3,centralGravity:.3,springLength:95,springConstant:.04,damping:.09,avoidOverlap:0},forceAtlas2Based:{theta:.5,gravitationalConstant:-50,centralGravity:.01,springConstant:.08,springLength:100,damping:.4,avoidOverlap:0},repulsion:{centralGravity:.2,springLength:200,springConstant:.05,nodeDistance:100,damping:.09,avoidOverlap:0},hierarchicalRepulsion:{centralGravity:0,springLength:100,springConstant:.01,nodeDistance:120,damping:.09},maxVelocity:50,minVelocity:.75,solver:"barnesHut",stabilization:{enabled:!0,iterations:1e3,updateInterval:50,onlyDynamicEdges:!1,fit:!0},timestep:.5,adaptiveTimestep:!0,wind:{x:0,y:0}},Object.assign(this.options,this.defaultOptions),this.timestep=.5,this.layoutFailed=!1,this.bindEventListeners()}bindEventListeners(){this.body.emitter.on("initPhysics",()=>{this.initPhysics()}),this.body.emitter.on("_layoutFailed",()=>{this.layoutFailed=!0}),this.body.emitter.on("resetPhysics",()=>{this.stopSimulation(),this.ready=!1}),this.body.emitter.on("disablePhysics",()=>{this.physicsEnabled=!1,this.stopSimulation()}),this.body.emitter.on("restorePhysics",()=>{this.setOptions(this.options),this.ready===!0&&this.startSimulation()}),this.body.emitter.on("startSimulation",()=>{this.ready===!0&&this.startSimulation()}),this.body.emitter.on("stopSimulation",()=>{this.stopSimulation()}),this.body.emitter.on("destroy",()=>{this.stopSimulation(!1),this.body.emitter.off()}),this.body.emitter.on("_dataChanged",()=>{this.updatePhysicsData()})}setOptions(e){if(e!==void 0)if(e===!1)this.options.enabled=!1,this.physicsEnabled=!1,this.stopSimulation();else if(e===!0)this.options.enabled=!0,this.physicsEnabled=!0,this.startSimulation();else{this.physicsEnabled=!0,bt(["stabilization"],this.options,e),se(this.options,e,"stabilization"),e.enabled===void 0&&(this.options.enabled=!0),this.options.enabled===!1&&(this.physicsEnabled=!1,this.stopSimulation());let t=this.options.wind;t&&((typeof t.x!="number"||Number.isNaN(t.x))&&(t.x=0),(typeof t.y!="number"||Number.isNaN(t.y))&&(t.y=0)),this.timestep=this.options.timestep}this.init()}init(){let e;this.options.solver==="forceAtlas2Based"?(e=this.options.forceAtlas2Based,this.nodesSolver=new Vo(this.body,this.physicsBody,e),this.edgesSolver=new Gt(this.body,this.physicsBody,e),this.gravitySolver=new qo(this.body,this.physicsBody,e)):this.options.solver==="repulsion"?(e=this.options.repulsion,this.nodesSolver=new Ho(this.body,this.physicsBody,e),this.edgesSolver=new Gt(this.body,this.physicsBody,e),this.gravitySolver=new xt(this.body,this.physicsBody,e)):this.options.solver==="hierarchicalRepulsion"?(e=this.options.hierarchicalRepulsion,this.nodesSolver=new jo(this.body,this.physicsBody,e),this.edgesSolver=new Wo(this.body,this.physicsBody,e),this.gravitySolver=new xt(this.body,this.physicsBody,e)):(e=this.options.barnesHut,this.nodesSolver=new Ni(this.body,this.physicsBody,e),this.edgesSolver=new Gt(this.body,this.physicsBody,e),this.gravitySolver=new xt(this.body,this.physicsBody,e)),this.modelOptions=e}initPhysics(){this.physicsEnabled===!0&&this.options.enabled===!0?this.options.stabilization.enabled===!0?this.stabilize():(this.stabilized=!1,this.ready=!0,this.body.emitter.emit("fit",{},this.layoutFailed),this.startSimulation()):(this.ready=!0,this.body.emitter.emit("fit"))}startSimulation(){this.physicsEnabled===!0&&this.options.enabled===!0?(this.stabilized=!1,this.adaptiveTimestep=!1,this.body.emitter.emit("_resizeNodes"),this.viewFunction===void 0&&(this.viewFunction=this.simulationStep.bind(this),this.body.emitter.on("initRedraw",this.viewFunction),this.body.emitter.emit("_startRendering"))):this.body.emitter.emit("_redraw")}stopSimulation(e=!0){this.stabilized=!0,e===!0&&this._emitStabilized(),this.viewFunction!==void 0&&(this.body.emitter.off("initRedraw",this.viewFunction),this.viewFunction=void 0,e===!0&&this.body.emitter.emit("_stopRendering"))}simulationStep(){let e=Date.now();this.physicsTick(),(Date.now()-e<.4*this.simulationInterval||this.runDoubleSpeed===!0)&&this.stabilized===!1&&(this.physicsTick(),this.runDoubleSpeed=!0),this.stabilized===!0&&this.stopSimulation()}_emitStabilized(e=this.stabilizationIterations){(this.stabilizationIterations>1||this.startedStabilization===!0)&&setTimeout(()=>{this.body.emitter.emit("stabilized",{iterations:e}),this.startedStabilization=!1,this.stabilizationIterations=0},0)}physicsStep(){this.gravitySolver.solve(),this.nodesSolver.solve(),this.edgesSolver.solve(),this.moveNodes()}adjustTimeStep(){let e=1.2;this._evaluateStepQuality()===!0?this.timestep=e*this.timestep:this.timestep/er))return!1;return!0}moveNodes(){let e=this.physicsBody.physicsNodeIndices,t=0,i=0,s=5;for(let o=0;or&&(e=e>0?r:-r),e}_performStep(e){let t=this.body.nodes[e],i=this.physicsBody.forces[e];this.options.wind&&(i.x+=this.options.wind.x,i.y+=this.options.wind.y);let s=this.physicsBody.velocities[e];return this.previousStates[e]={x:t.x,y:t.y,vx:s.x,vy:s.y},t.options.fixed.x===!1?(s.x=this.calculateComponentVelocity(s.x,i.x,t.options.mass),t.x+=s.x*this.timestep):(i.x=0,s.x=0),t.options.fixed.y===!1?(s.y=this.calculateComponentVelocity(s.y,i.y,t.options.mass),t.y+=s.y*this.timestep):(i.y=0,s.y=0),Math.sqrt(Math.pow(s.x,2)+Math.pow(s.y,2))}_freezeNodes(){let e=this.body.nodes;for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&e[t].x&&e[t].y){let i=e[t].options.fixed;this.freezeCache[t]={x:i.x,y:i.y},i.x=!0,i.y=!0}}_restoreFrozenNodes(){let e=this.body.nodes;for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.freezeCache[t]!==void 0&&(e[t].options.fixed.x=this.freezeCache[t].x,e[t].options.fixed.y=this.freezeCache[t].y);this.freezeCache={}}stabilize(e=this.options.stabilization.iterations){if(typeof e!="number"&&(e=this.options.stabilization.iterations,console.error("The stabilize method needs a numeric amount of iterations. Switching to default: ",e)),this.physicsBody.physicsNodeIndices.length===0){this.ready=!0;return}this.adaptiveTimestep=this.options.adaptiveTimestep,this.body.emitter.emit("_resizeNodes"),this.stopSimulation(),this.stabilized=!1,this.body.emitter.emit("_blockRedraw"),this.targetIterations=e,this.options.stabilization.onlyDynamicEdges===!0&&this._freezeNodes(),this.stabilizationIterations=0,setTimeout(()=>this._stabilizationBatch(),0)}_startStabilizing(){return this.startedStabilization===!0?!1:(this.body.emitter.emit("startStabilizing"),this.startedStabilization=!0,!0)}_stabilizationBatch(){let e=()=>this.stabilized===!1&&this.stabilizationIterations{this.body.emitter.emit("stabilizationProgress",{iterations:this.stabilizationIterations,total:this.targetIterations})};this._startStabilizing()&&t();let i=0;for(;e()&&i0)for(let d=0;da.shape.boundingBox.left&&(o=a.shape.boundingBox.left),ra.shape.boundingBox.top&&(i=a.shape.boundingBox.top),s0)for(let d=0;da.x&&(o=a.x),ra.y&&(i=a.y),s{delete this.containedEdges[i.id]}),I(t.containedNodes,(i,s)=>{this.containedNodes[s]=i}),t.containedNodes={},I(t.containedEdges,(i,s)=>{this.containedEdges[s]=i}),t.containedEdges={},I(t.edges,i=>{I(this.edges,s=>{let o=s.clusteringEdgeReplacingIds.indexOf(i.id);o!==-1&&(I(i.clusteringEdgeReplacingIds,r=>{s.clusteringEdgeReplacingIds.push(r),this.body.edges[r].edgeReplacedById=s.id}),s.clusteringEdgeReplacingIds.splice(o,1))})}),t.edges=[]}},Xo=class{constructor(e){this.body=e,this.clusteredNodes={},this.clusteredEdges={},this.options={},this.defaultOptions={},Object.assign(this.options,this.defaultOptions),this.body.emitter.on("_resetData",()=>{this.clusteredNodes={},this.clusteredEdges={}})}clusterByHubsize(e,t){e===void 0?e=this._getHubSize():typeof e=="object"&&(t=this._checkOptions(e),e=this._getHubSize());let i=[];for(let s=0;s=e&&i.push(o.id)}for(let s=0;s{o.options&&e.joinCondition(o.options)===!0&&(i[r]=o,I(o.edges,a=>{this.clusteredEdges[a.id]===void 0&&(s[a.id]=a)}))}),this._cluster(i,s,e,t)}clusterByEdgeCount(e,t,i=!0){t=this._checkOptions(t);let s=[],o={},r,a,d;for(let h=0;h0&&Object.keys(c).length>0&&v===!0){let p=function(){for(let b=0;b-1&&(r[f.id]=f)}}this._cluster(o,r,t,i)}_createClusterEdges(e,t,i,s){let o,r,a,d,h,l,c=Object.keys(e),u=[];for(let v=0;vs?a.x:s,o=a.yr?a.y:r;return{x:.5*(i+s),y:.5*(o+r)}}openCluster(e,t,i=!0){if(e===void 0)throw new Error("No clusterNodeId supplied to openCluster.");let s=this.body.nodes[e];if(s===void 0)throw new Error("The clusterNodeId supplied to openCluster does not exist.");if(s.isCluster!==!0||s.containedNodes===void 0||s.containedEdges===void 0)throw new Error("The node:"+e+" is not a valid cluster.");let o=this.findNode(e),r=o.indexOf(e)-1;if(r>=0){let l=o[r];this.body.nodes[l]._openChildCluster(e),delete this.body.nodes[e],i===!0&&this.body.emitter.emit("_dataChanged");return}let a=s.containedNodes,d=s.containedEdges;if(t!==void 0&&t.releaseFunction!==void 0&&typeof t.releaseFunction=="function"){let l={},c={x:s.x,y:s.y};for(let f in a)if(Object.prototype.hasOwnProperty.call(a,f)){let y=this.body.nodes[f];l[f]={x:y.x,y:y.y}}let u=t.releaseFunction(c,l);for(let f in a)if(Object.prototype.hasOwnProperty.call(a,f)){let y=this.body.nodes[f];u[f]!==void 0&&(y.x=u[f].x===void 0?s.x:u[f].x,y.y=u[f].y===void 0?s.y:u[f].y)}}else I(a,function(l){l.options.fixed.x===!1&&(l.x=s.x),l.options.fixed.y===!1&&(l.y=s.y)});for(let l in a)if(Object.prototype.hasOwnProperty.call(a,l)){let c=this.body.nodes[l];c.vx=s.vx,c.vy=s.vy,c.setOptions({physics:!0}),delete this.clusteredNodes[l]}let h=[];for(let l=0;l0&&rs&&(s=h.edges.length),e+=h.edges.length,t+=Math.pow(h.edges.length,2),i+=1}e=e/i,t=t/i;let o=t-Math.pow(e,2),r=Math.sqrt(o),a=Math.floor(e+2*r);return a>s&&(a=s),a}_createClusteredEdge(e,t,i,s,o){let r=G.cloneOptions(i,"edge");D(r,s),r.from=e,r.to=t,r.id="clusterEdge:"+xe(),o!==void 0&&D(r,o);let a=this.body.functions.createEdge(r);return a.clusteringEdgeReplacingIds=[i.id],a.connect(),this.body.edges[a.id]=a,a}_clusterEdges(e,t,i,s){if(t instanceof ke){let o=t,r={};r[o.id]=o,t=r}if(e instanceof z){let o=e,r={};r[o.id]=o,e=r}if(i==null)throw new Error("_clusterEdges: parameter clusterNode required");s===void 0&&(s=i.clusterEdgeProperties),this._createClusterEdges(e,t,i,s);for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o)&&this.body.edges[o]!==void 0){let r=this.body.edges[o];this._backupEdgeOptions(r),r.setOptions({physics:!1})}for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&(this.clusteredNodes[o]={clusterId:i.id,node:this.body.nodes[o]},this.body.nodes[o].setOptions({physics:!1}))}_getClusterNodeForNode(e){if(e===void 0)return;let t=this.clusteredNodes[e];if(t===void 0)return;let i=t.clusterId;if(i!==void 0)return this.body.nodes[i]}_filter(e,t){let i=[];return I(e,s=>{t(s)&&i.push(s)}),i}_updateState(){let e,t=[],i={},s=d=>{I(this.body.nodes,h=>{h.isCluster===!0&&d(h)})};for(e in this.clusteredNodes){if(!Object.prototype.hasOwnProperty.call(this.clusteredNodes,e))continue;this.body.nodes[e]===void 0&&t.push(e)}s(function(d){for(let h=0;h{let h=this.body.edges[d];(h===void 0||!h.endPointsValid())&&(i[d]=d)}),s(function(d){I(d.containedEdges,(h,l)=>{!h.endPointsValid()&&!i[l]&&(i[l]=l)})}),I(this.body.edges,(d,h)=>{let l=!0,c=d.clusteringEdgeReplacingIds;if(c!==void 0){let u=0;I(c,f=>{let y=this.body.edges[f];y!==void 0&&y.endPointsValid()&&(u+=1)}),l=u>0}(!d.endPointsValid()||!l)&&(i[h]=h)}),s(d=>{I(i,h=>{delete d.containedEdges[h],I(d.edges,(l,c)=>{if(l.id===h){d.edges[c]=null;return}l.clusteringEdgeReplacingIds=this._filter(l.clusteringEdgeReplacingIds,function(u){return!i[u]})}),d.edges=this._filter(d.edges,function(l){return l!==null})})}),I(i,d=>{delete this.clusteredEdges[d]}),I(i,d=>{delete this.body.edges[d]});let o=Object.keys(this.body.edges);I(o,d=>{let h=this.body.edges[d],l=this._isClusteredNode(h.fromId)||this._isClusteredNode(h.toId);if(l!==this._isClusteredEdge(h.id))if(l){let c=this._getClusterNodeForNode(h.fromId);c!==void 0&&this._clusterEdges(this.body.nodes[h.fromId],h,c);let u=this._getClusterNodeForNode(h.toId);u!==void 0&&this._clusterEdges(this.body.nodes[h.toId],h,u)}else delete this._clusterEdges[d],this._restoreEdge(h)});let r=!1,a=!0;for(;a;){let d=[];s(function(h){let l=Object.keys(h.containedNodes).length,c=h.options.allowSingleNodeCluster===!0;(c&&l<1||!c&&l<2)&&d.push(h.id)});for(let h=0;h0,r=r||a}r&&this._updateState()}_isClusteredNode(e){return this.clusteredNodes[e]!==void 0}_isClusteredEdge(e){return this.clusteredEdges[e]!==void 0}};function _a(){let n;window!==void 0&&(n=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame),n===void 0?window.requestAnimationFrame=function(e){e()}:window.requestAnimationFrame=n}var Go=class{constructor(e,t){_a(),this.body=e,this.canvas=t,this.redrawRequested=!1,this.renderTimer=void 0,this.requiresTimeout=!0,this.renderingActive=!1,this.renderRequests=0,this.allowRedraw=!0,this.dragging=!1,this.zooming=!1,this.options={},this.defaultOptions={hideEdgesOnDrag:!1,hideEdgesOnZoom:!1,hideNodesOnDrag:!1},Object.assign(this.options,this.defaultOptions),this._determineBrowserMethod(),this.bindEventListeners()}bindEventListeners(){this.body.emitter.on("dragStart",()=>{this.dragging=!0}),this.body.emitter.on("dragEnd",()=>{this.dragging=!1}),this.body.emitter.on("zoom",()=>{this.zooming=!0,window.clearTimeout(this.zoomTimeoutId),this.zoomTimeoutId=window.setTimeout(()=>{this.zooming=!1,this._requestRedraw.bind(this)()},250)}),this.body.emitter.on("_resizeNodes",()=>{this._resizeNodes()}),this.body.emitter.on("_redraw",()=>{this.renderingActive===!1&&this._redraw()}),this.body.emitter.on("_blockRedraw",()=>{this.allowRedraw=!1}),this.body.emitter.on("_allowRedraw",()=>{this.allowRedraw=!0,this.redrawRequested=!1}),this.body.emitter.on("_requestRedraw",this._requestRedraw.bind(this)),this.body.emitter.on("_startRendering",()=>{this.renderRequests+=1,this.renderingActive=!0,this._startRendering()}),this.body.emitter.on("_stopRendering",()=>{this.renderRequests-=1,this.renderingActive=this.renderRequests>0,this.renderTimer=void 0}),this.body.emitter.on("destroy",()=>{this.renderRequests=0,this.allowRedraw=!1,this.renderingActive=!1,this.requiresTimeout===!0?clearTimeout(this.renderTimer):window.cancelAnimationFrame(this.renderTimer),this.body.emitter.off()})}setOptions(e){e!==void 0&&qe(["hideEdgesOnDrag","hideEdgesOnZoom","hideNodesOnDrag"],this.options,e)}_requestNextFrame(e,t){if(typeof window=="undefined")return;let i,s=window;return this.requiresTimeout===!0?i=s.setTimeout(e,t):s.requestAnimationFrame&&(i=s.requestAnimationFrame(e)),i}_startRendering(){this.renderingActive===!0&&this.renderTimer===void 0&&(this.renderTimer=this._requestNextFrame(this._renderStep.bind(this),this.simulationInterval))}_renderStep(){this.renderingActive===!0&&(this.renderTimer=void 0,this.requiresTimeout===!0&&this._startRendering(),this._redraw(),this.requiresTimeout===!1&&this._startRendering())}redraw(){this.body.emitter.emit("setSize"),this._redraw()}_requestRedraw(){this.redrawRequested!==!0&&this.renderingActive===!1&&this.allowRedraw===!0&&(this.redrawRequested=!0,this._requestNextFrame(()=>{this._redraw(!1)},0))}_redraw(e=!1){if(this.allowRedraw===!0){this.body.emitter.emit("initRedraw"),this.redrawRequested=!1;let t={drawExternalLabels:null};(this.canvas.frame.canvas.width===0||this.canvas.frame.canvas.height===0)&&this.canvas.setSize(),this.canvas.setTransform();let i=this.canvas.getContext(),s=this.canvas.frame.canvas.clientWidth,o=this.canvas.frame.canvas.clientHeight;if(i.clearRect(0,0,s,o),this.canvas.frame.clientWidth===0)return;if(i.save(),i.translate(this.body.view.translation.x,this.body.view.translation.y),i.scale(this.body.view.scale,this.body.view.scale),i.beginPath(),this.body.emitter.emit("beforeDrawing",i),i.closePath(),e===!1&&(this.dragging===!1||this.dragging===!0&&this.options.hideEdgesOnDrag===!1)&&(this.zooming===!1||this.zooming===!0&&this.options.hideEdgesOnZoom===!1)&&this._drawEdges(i),this.dragging===!1||this.dragging===!0&&this.options.hideNodesOnDrag===!1){let{drawExternalLabels:r}=this._drawNodes(i,e);t.drawExternalLabels=r}e===!1&&(this.dragging===!1||this.dragging===!0&&this.options.hideEdgesOnDrag===!1)&&(this.zooming===!1||this.zooming===!0&&this.options.hideEdgesOnZoom===!1)&&this._drawArrows(i),t.drawExternalLabels!=null&&t.drawExternalLabels(),e===!1&&this._drawSelectionBox(i),i.beginPath(),this.body.emitter.emit("afterDrawing",i),i.closePath(),i.restore(),e===!0&&i.clearRect(0,0,s,o)}}_resizeNodes(){this.canvas.setTransform();let e=this.canvas.getContext();e.save(),e.translate(this.body.view.translation.x,this.body.view.translation.y),e.scale(this.body.view.scale,this.body.view.scale);let t=this.body.nodes,i;for(let s in t)Object.prototype.hasOwnProperty.call(t,s)&&(i=t[s],i.resize(e),i.updateBoundingBox(e,i.selected));e.restore()}_drawNodes(e,t=!1){let i=this.body.nodes,s=this.body.nodeIndices,o,r=[],a=[],d=20,h=this.canvas.DOMtoCanvas({x:-d,y:-d}),l=this.canvas.DOMtoCanvas({x:this.canvas.frame.canvas.clientWidth+d,y:this.canvas.frame.canvas.clientHeight+d}),c={top:h.y,left:h.x,bottom:l.y,right:l.x},u=[];for(let g=0;g{for(let g of u)g()}}}_drawEdges(e){let t=this.body.edges,i=this.body.edgeIndices;for(let s=0;s{e.width!==0&&(this.body.view.translation.x=e.width*.5),e.height!==0&&(this.body.view.translation.y=e.height*.5)}),this.body.emitter.on("setSize",this.setSize.bind(this)),this.body.emitter.on("destroy",()=>{this.hammerFrame.destroy(),this.hammer.destroy(),this._cleanUp()})}setOptions(e){if(e!==void 0&&qe(["width","height","autoResize"],this.options,e),this._cleanUp(),this.options.autoResize===!0){if(window.ResizeObserver){let i=new ResizeObserver(()=>{this.setSize()===!0&&this.body.emitter.emit("_requestRedraw")}),{frame:s}=this;i.observe(s),this._cleanupCallbacks.push(()=>{i.unobserve(s)})}else{let i=setInterval(()=>{this.setSize()===!0&&this.body.emitter.emit("_requestRedraw")},1e3);this._cleanupCallbacks.push(()=>{clearInterval(i)})}let t=this._onResize.bind(this);window.addEventListener("resize",t),this._cleanupCallbacks.push(()=>{window.removeEventListener("resize",t)})}}_cleanUp(){this._cleanupCallbacks.splice(0).reverse().forEach(e=>{try{e()}catch(t){console.error(t)}})}_onResize(){this.setSize(),this.body.emitter.emit("_redraw")}_getCameraState(e=this.pixelRatio){this.initialized===!0&&(this.cameraState.previousWidth=this.frame.canvas.width/e,this.cameraState.previousHeight=this.frame.canvas.height/e,this.cameraState.scale=this.body.view.scale,this.cameraState.position=this.DOMtoCanvas({x:.5*this.frame.canvas.width/e,y:.5*this.frame.canvas.height/e}))}_setCameraState(){if(this.cameraState.scale!==void 0&&this.frame.canvas.clientWidth!==0&&this.frame.canvas.clientHeight!==0&&this.pixelRatio!==0&&this.cameraState.previousWidth>0&&this.cameraState.previousHeight>0){let e=this.frame.canvas.width/this.pixelRatio/this.cameraState.previousWidth,t=this.frame.canvas.height/this.pixelRatio/this.cameraState.previousHeight,i=this.cameraState.scale;e!=1&&t!=1?i=this.cameraState.scale*.5*(e+t):e!=1?i=this.cameraState.scale*e:t!=1&&(i=this.cameraState.scale*t),this.body.view.scale=i;let s=this.DOMtoCanvas({x:.5*this.frame.canvas.clientWidth,y:.5*this.frame.canvas.clientHeight}),o={x:s.x-this.cameraState.position.x,y:s.y-this.cameraState.position.y};this.body.view.translation.x+=o.x*this.body.view.scale,this.body.view.translation.y+=o.y*this.body.view.scale}}_prepareValue(e){if(typeof e=="number")return e+"px";if(typeof e=="string"){if(e.indexOf("%")!==-1||e.indexOf("px")!==-1)return e;if(e.indexOf("%")===-1)return e+"px"}throw new Error("Could not use the value supplied for width or height:"+e)}_create(){for(;this.body.container.hasChildNodes();)this.body.container.removeChild(this.body.container.firstChild);if(this.frame=document.createElement("div"),this.frame.className="vis-network",this.frame.style.position="relative",this.frame.style.overflow="hidden",this.frame.tabIndex=0,this.frame.canvas=document.createElement("canvas"),this.frame.canvas.style.position="relative",this.frame.appendChild(this.frame.canvas),this.frame.canvas.getContext)this._setPixelRatio(),this.setTransform();else{let e=document.createElement("DIV");e.style.color="red",e.style.fontWeight="bold",e.style.padding="10px",e.innerText="Error: your browser does not support HTML canvas",this.frame.canvas.appendChild(e)}this.body.container.appendChild(this.frame),this.body.view.scale=1,this.body.view.translation={x:.5*this.frame.canvas.clientWidth,y:.5*this.frame.canvas.clientHeight},this._bindHammer()}_bindHammer(){this.hammer!==void 0&&this.hammer.destroy(),this.drag={},this.pinch={},this.hammer=new Ue(this.frame.canvas),this.hammer.get("pinch").set({enable:!0}),this.hammer.get("pan").set({threshold:5,direction:Ue.DIRECTION_ALL}),Kt(this.hammer,e=>{this.body.eventListeners.onTouch(e)}),this.hammer.on("tap",e=>{this.body.eventListeners.onTap(e)}),this.hammer.on("doubletap",e=>{this.body.eventListeners.onDoubleTap(e)}),this.hammer.on("press",e=>{this.body.eventListeners.onHold(e)}),this.hammer.on("panstart",e=>{this.body.eventListeners.onDragStart(e)}),this.hammer.on("panmove",e=>{this.body.eventListeners.onDrag(e)}),this.hammer.on("panend",e=>{this.body.eventListeners.onDragEnd(e)}),this.hammer.on("pinch",e=>{this.body.eventListeners.onPinch(e)}),this.frame.canvas.addEventListener("wheel",e=>{this.body.eventListeners.onMouseWheel(e)}),this.frame.canvas.addEventListener("mousemove",e=>{this.body.eventListeners.onMouseMove(e)}),this.frame.canvas.addEventListener("contextmenu",e=>{this.body.eventListeners.onContext(e)}),this.hammerFrame=new Ue(this.frame),Ko(this.hammerFrame,e=>{this.body.eventListeners.onRelease(e)})}setSize(e=this.options.width,t=this.options.height){e=this._prepareValue(e),t=this._prepareValue(t);let i=!1,s=this.frame.canvas.width,o=this.frame.canvas.height,r=this.pixelRatio;if(this._setPixelRatio(),e!=this.options.width||t!=this.options.height||this.frame.style.width!=e||this.frame.style.height!=t)this._getCameraState(r),this.frame.style.width=e,this.frame.style.height=t,this.frame.canvas.style.width="100%",this.frame.canvas.style.height="100%",this.frame.canvas.width=Math.round(this.frame.canvas.clientWidth*this.pixelRatio),this.frame.canvas.height=Math.round(this.frame.canvas.clientHeight*this.pixelRatio),this.options.width=e,this.options.height=t,this.canvasViewCenter={x:.5*this.frame.clientWidth,y:.5*this.frame.clientHeight},i=!0;else{let a=Math.round(this.frame.canvas.clientWidth*this.pixelRatio),d=Math.round(this.frame.canvas.clientHeight*this.pixelRatio);(this.frame.canvas.width!==a||this.frame.canvas.height!==d)&&this._getCameraState(r),this.frame.canvas.width!==a&&(this.frame.canvas.width=a,i=!0),this.frame.canvas.height!==d&&(this.frame.canvas.height=d,i=!0)}return i===!0&&(this.body.emitter.emit("resize",{width:Math.round(this.frame.canvas.width/this.pixelRatio),height:Math.round(this.frame.canvas.height/this.pixelRatio),oldWidth:Math.round(s/this.pixelRatio),oldHeight:Math.round(o/this.pixelRatio)}),this._setCameraState()),this.initialized=!0,i}getContext(){return this.frame.canvas.getContext("2d")}_determinePixelRatio(){let e=this.getContext();if(e===void 0)throw new Error("Could not get canvax context");let t=1;typeof window!="undefined"&&(t=window.devicePixelRatio||1);let i=e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return t/i}_setPixelRatio(){this.pixelRatio=this._determinePixelRatio()}setTransform(){let e=this.getContext();if(e===void 0)throw new Error("Could not get canvax context");e.setTransform(this.pixelRatio,0,0,this.pixelRatio,0,0)}_XconvertDOMtoCanvas(e){return(e-this.body.view.translation.x)/this.body.view.scale}_XconvertCanvasToDOM(e){return e*this.body.view.scale+this.body.view.translation.x}_YconvertDOMtoCanvas(e){return(e-this.body.view.translation.y)/this.body.view.scale}_YconvertCanvasToDOM(e){return e*this.body.view.scale+this.body.view.translation.y}canvasToDOM(e){return{x:this._XconvertCanvasToDOM(e.x),y:this._YconvertCanvasToDOM(e.y)}}DOMtoCanvas(e){return{x:this._XconvertDOMtoCanvas(e.x),y:this._YconvertDOMtoCanvas(e.y)}}};function Ea(n,e){let t=Object.assign({nodes:e,minZoomLevel:Number.MIN_VALUE,maxZoomLevel:1},n!=null?n:{});if(!Array.isArray(t.nodes))throw new TypeError("Nodes has to be an array of ids.");if(t.nodes.length===0&&(t.nodes=e),!(typeof t.minZoomLevel=="number"&&t.minZoomLevel>0))throw new TypeError("Min zoom level has to be a number higher than zero.");if(!(typeof t.maxZoomLevel=="number"&&t.minZoomLevel<=t.maxZoomLevel))throw new TypeError("Max zoom level has to be a number higher than min zoom level.");return t}var Zo=class{constructor(e,t){this.body=e,this.canvas=t,this.animationSpeed=1/this.renderRefreshRate,this.animationEasingFunction="easeInOutQuint",this.easingTime=0,this.sourceScale=0,this.targetScale=0,this.sourceTranslation=0,this.targetTranslation=0,this.lockedOnNodeId=void 0,this.lockedOnNodeOffset=void 0,this.touchTime=0,this.viewFunction=void 0,this.body.emitter.on("fit",this.fit.bind(this)),this.body.emitter.on("animationFinished",()=>{this.body.emitter.emit("_stopRendering")}),this.body.emitter.on("unlockNode",this.releaseNode.bind(this))}setOptions(e={}){this.options=e}fit(e,t=!1){e=Ea(e,this.body.nodeIndices);let i=this.canvas.frame.canvas.clientWidth,s=this.canvas.frame.canvas.clientHeight,o,r;if(i===0||s===0)r=1,o=G.getRange(this.body.nodes,e.nodes);else if(t===!0){let h=0;for(let u in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,u)&&this.body.nodes[u].predefinedPosition===!0&&(h+=1);if(h>.5*this.body.nodeIndices.length){this.fit(e,!1);return}o=G.getRange(this.body.nodes,e.nodes);let l=this.body.nodeIndices.length;r=12.662/(l+7.4147)+.0964822,r*=Math.min(i/600,s/600)}else{this.body.emitter.emit("_resizeNodes"),o=G.getRange(this.body.nodes,e.nodes);let h=Math.abs(o.maxX-o.minX)*1.1,l=Math.abs(o.maxY-o.minY)*1.1,c=i/h,u=s/l;r=c<=u?c:u}r>e.maxZoomLevel?r=e.maxZoomLevel:r0))throw new TypeError('The option "scale" has to be a number greater than zero.')}else e.scale=this.body.view.scale;e.animation===void 0&&(e.animation={duration:0}),e.animation===!1&&(e.animation={duration:0}),e.animation===!0&&(e.animation={}),e.animation.duration===void 0&&(e.animation.duration=1e3),e.animation.easingFunction===void 0&&(e.animation.easingFunction="easeInOutQuad"),this.animateView(e)}animateView(e){if(e===void 0)return;this.animationEasingFunction=e.animation.easingFunction,this.releaseNode(),e.locked===!0&&(this.lockedOnNodeId=e.lockedOnNode,this.lockedOnNodeOffset=e.offset),this.easingTime!=0&&this._transitionRedraw(!0),this.sourceScale=this.body.view.scale,this.sourceTranslation=this.body.view.translation,this.targetScale=e.scale,this.body.view.scale=this.targetScale;let t=this.canvas.DOMtoCanvas({x:.5*this.canvas.frame.canvas.clientWidth,y:.5*this.canvas.frame.canvas.clientHeight}),i={x:t.x-e.position.x,y:t.y-e.position.y};this.targetTranslation={x:this.sourceTranslation.x+i.x*this.targetScale+e.offset.x,y:this.sourceTranslation.y+i.y*this.targetScale+e.offset.y},e.animation.duration===0?this.lockedOnNodeId!=null?(this.viewFunction=this._lockedRedraw.bind(this),this.body.emitter.on("initRedraw",this.viewFunction)):(this.body.view.scale=this.targetScale,this.body.view.translation=this.targetTranslation,this.body.emitter.emit("_requestRedraw")):(this.animationSpeed=1/(60*e.animation.duration*.001)||1/60,this.animationEasingFunction=e.animation.easingFunction,this.viewFunction=this._transitionRedraw.bind(this),this.body.emitter.on("initRedraw",this.viewFunction),this.body.emitter.emit("_startRendering"))}_lockedRedraw(){let e={x:this.body.nodes[this.lockedOnNodeId].x,y:this.body.nodes[this.lockedOnNodeId].y},t=this.canvas.DOMtoCanvas({x:.5*this.canvas.frame.canvas.clientWidth,y:.5*this.canvas.frame.canvas.clientHeight}),i={x:t.x-e.x,y:t.y-e.y},s=this.body.view.translation,o={x:s.x+i.x*this.body.view.scale+this.lockedOnNodeOffset.x,y:s.y+i.y*this.body.view.scale+this.lockedOnNodeOffset.y};this.body.view.translation=o}releaseNode(){this.lockedOnNodeId!==void 0&&this.viewFunction!==void 0&&(this.body.emitter.off("initRedraw",this.viewFunction),this.lockedOnNodeId=void 0,this.lockedOnNodeOffset=void 0)}_transitionRedraw(e=!1){this.easingTime+=this.animationSpeed,this.easingTime=e===!0?1:this.easingTime;let t=Rs[this.animationEasingFunction](this.easingTime);this.body.view.scale=this.sourceScale+(this.targetScale-this.sourceScale)*t,this.body.view.translation={x:this.sourceTranslation.x+(this.targetTranslation.x-this.sourceTranslation.x)*t,y:this.sourceTranslation.y+(this.targetTranslation.y-this.sourceTranslation.y)*t},this.easingTime>=1&&(this.body.emitter.off("initRedraw",this.viewFunction),this.easingTime=0,this.lockedOnNodeId!=null&&(this.viewFunction=this._lockedRedraw.bind(this),this.body.emitter.on("initRedraw",this.viewFunction)),this.body.emitter.emit("animationFinished"))}getScale(){return this.body.view.scale}getViewPosition(){return this.canvas.DOMtoCanvas({x:.5*this.canvas.frame.canvas.clientWidth,y:.5*this.canvas.frame.canvas.clientHeight})}},Qo=class{constructor(e,t){this.body=e,this.canvas=t,this.iconsCreated=!1,this.navigationHammers=[],this.boundFunctions={},this.touchTime=0,this.activated=!1,this.body.emitter.on("activate",()=>{this.activated=!0,this.configureKeyboardBindings()}),this.body.emitter.on("deactivate",()=>{this.activated=!1,this.configureKeyboardBindings()}),this.body.emitter.on("destroy",()=>{this.keycharm!==void 0&&this.keycharm.destroy()}),this.options={}}setOptions(e){e!==void 0&&(this.options=e,this.create())}create(){this.options.navigationButtons===!0?this.iconsCreated===!1&&this.loadNavigationElements():this.iconsCreated===!0&&this.cleanNavigation(),this.configureKeyboardBindings()}cleanNavigation(){if(this.navigationHammers.length!=0){for(let e=0;e{this._stopMovement()}),this.navigationHammers.push(i),this.iconsCreated=!0}bindToRedraw(e){this.boundFunctions[e]===void 0&&(this.boundFunctions[e]=this[e].bind(this),this.body.emitter.on("initRedraw",this.boundFunctions[e]),this.body.emitter.emit("_startRendering"))}unbindFromRedraw(e){this.boundFunctions[e]!==void 0&&(this.body.emitter.off("initRedraw",this.boundFunctions[e]),this.body.emitter.emit("_stopRendering"),delete this.boundFunctions[e])}_fit(){new Date().valueOf()-this.touchTime>700&&(this.body.emitter.emit("fit",{duration:700}),this.touchTime=new Date().valueOf())}_stopMovement(){for(let e in this.boundFunctions)Object.prototype.hasOwnProperty.call(this.boundFunctions,e)&&(this.body.emitter.off("initRedraw",this.boundFunctions[e]),this.body.emitter.emit("_stopRendering"));this.boundFunctions={}}_moveUp(){this.body.view.translation.y+=this.options.keyboard.speed.y}_moveDown(){this.body.view.translation.y-=this.options.keyboard.speed.y}_moveLeft(){this.body.view.translation.x+=this.options.keyboard.speed.x}_moveRight(){this.body.view.translation.x-=this.options.keyboard.speed.x}_zoomIn(){let e=this.body.view.scale,t=this.body.view.scale*(1+this.options.keyboard.speed.zoom),i=this.body.view.translation,s=t/e,o=(1-s)*this.canvas.canvasViewCenter.x+i.x*s,r=(1-s)*this.canvas.canvasViewCenter.y+i.y*s;this.body.view.scale=t,this.body.view.translation={x:o,y:r},this.body.emitter.emit("zoom",{direction:"+",scale:this.body.view.scale,pointer:null})}_zoomOut(){let e=this.body.view.scale,t=this.body.view.scale/(1+this.options.keyboard.speed.zoom),i=this.body.view.translation,s=t/e,o=(1-s)*this.canvas.canvasViewCenter.x+i.x*s,r=(1-s)*this.canvas.canvasViewCenter.y+i.y*s;this.body.view.scale=t,this.body.view.translation={x:o,y:r},this.body.emitter.emit("zoom",{direction:"-",scale:this.body.view.scale,pointer:null})}configureKeyboardBindings(){this.keycharm!==void 0&&this.keycharm.destroy(),this.options.keyboard.enabled===!0&&(this.options.keyboard.bindToWindow===!0?this.keycharm=Vt({container:window,preventDefault:!0}):this.keycharm=Vt({container:this.canvas.frame,preventDefault:!0}),this.keycharm.reset(),this.activated===!0&&(this.keycharm.bind("up",()=>{this.bindToRedraw("_moveUp")},"keydown"),this.keycharm.bind("down",()=>{this.bindToRedraw("_moveDown")},"keydown"),this.keycharm.bind("left",()=>{this.bindToRedraw("_moveLeft")},"keydown"),this.keycharm.bind("right",()=>{this.bindToRedraw("_moveRight")},"keydown"),this.keycharm.bind("=",()=>{this.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("num+",()=>{this.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("num-",()=>{this.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("-",()=>{this.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("[",()=>{this.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("]",()=>{this.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("pageup",()=>{this.bindToRedraw("_zoomIn")},"keydown"),this.keycharm.bind("pagedown",()=>{this.bindToRedraw("_zoomOut")},"keydown"),this.keycharm.bind("up",()=>{this.unbindFromRedraw("_moveUp")},"keyup"),this.keycharm.bind("down",()=>{this.unbindFromRedraw("_moveDown")},"keyup"),this.keycharm.bind("left",()=>{this.unbindFromRedraw("_moveLeft")},"keyup"),this.keycharm.bind("right",()=>{this.unbindFromRedraw("_moveRight")},"keyup"),this.keycharm.bind("=",()=>{this.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("num+",()=>{this.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("num-",()=>{this.unbindFromRedraw("_zoomOut")},"keyup"),this.keycharm.bind("-",()=>{this.unbindFromRedraw("_zoomOut")},"keyup"),this.keycharm.bind("[",()=>{this.unbindFromRedraw("_zoomOut")},"keyup"),this.keycharm.bind("]",()=>{this.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("pageup",()=>{this.unbindFromRedraw("_zoomIn")},"keyup"),this.keycharm.bind("pagedown",()=>{this.unbindFromRedraw("_zoomOut")},"keyup")))}},Jo=class{constructor(e,t,i){this.body=e,this.canvas=t,this.selectionHandler=i,this.navigationHandler=new Qo(e,t),this.body.eventListeners.onTap=this.onTap.bind(this),this.body.eventListeners.onTouch=this.onTouch.bind(this),this.body.eventListeners.onDoubleTap=this.onDoubleTap.bind(this),this.body.eventListeners.onHold=this.onHold.bind(this),this.body.eventListeners.onDragStart=this.onDragStart.bind(this),this.body.eventListeners.onDrag=this.onDrag.bind(this),this.body.eventListeners.onDragEnd=this.onDragEnd.bind(this),this.body.eventListeners.onMouseWheel=this.onMouseWheel.bind(this),this.body.eventListeners.onPinch=this.onPinch.bind(this),this.body.eventListeners.onMouseMove=this.onMouseMove.bind(this),this.body.eventListeners.onRelease=this.onRelease.bind(this),this.body.eventListeners.onContext=this.onContext.bind(this),this.touchTime=0,this.drag={},this.pinch={},this.popup=void 0,this.popupObj=void 0,this.popupTimer=void 0,this.body.functions.getPointer=this.getPointer.bind(this),this.options={},this.defaultOptions={dragNodes:!0,dragView:!0,hover:!1,keyboard:{enabled:!1,speed:{x:10,y:10,zoom:.02},bindToWindow:!0,autoFocus:!0},navigationButtons:!1,tooltipDelay:300,zoomView:!0,zoomSpeed:1},Object.assign(this.options,this.defaultOptions),this.bindEventListeners()}bindEventListeners(){this.body.emitter.on("destroy",()=>{clearTimeout(this.popupTimer),delete this.body.functions.getPointer})}setOptions(e){e!==void 0&&(bt(["hideEdgesOnDrag","hideEdgesOnZoom","hideNodesOnDrag","keyboard","multiselect","selectable","selectConnectedEdges"],this.options,e),se(this.options,e,"keyboard"),e.tooltip&&(Object.assign(this.options.tooltip,e.tooltip),e.tooltip.color&&(this.options.tooltip.color=zt(e.tooltip.color)))),this.navigationHandler.setOptions(this.options)}getPointer(e){return{x:e.x-Fs(this.canvas.frame.canvas),y:e.y-Ns(this.canvas.frame.canvas)}}onTouch(e){new Date().valueOf()-this.touchTime>50&&(this.drag.pointer=this.getPointer(e.center),this.drag.pinched=!1,this.pinch.scale=this.body.view.scale,this.touchTime=new Date().valueOf())}onTap(e){let t=this.getPointer(e.center),i=this.selectionHandler.options.multiselect&&(e.changedPointers[0].ctrlKey||e.changedPointers[0].metaKey);this.checkSelectionChanges(t,i),this.selectionHandler.commitAndEmit(t,e),this.selectionHandler.generateClickEvent("click",e,t)}onDoubleTap(e){let t=this.getPointer(e.center);this.selectionHandler.generateClickEvent("doubleClick",e,t)}onHold(e){let t=this.getPointer(e.center),i=this.selectionHandler.options.multiselect;this.checkSelectionChanges(t,i),this.selectionHandler.commitAndEmit(t,e),this.selectionHandler.generateClickEvent("click",e,t),this.selectionHandler.generateClickEvent("hold",e,t)}onRelease(e){if(new Date().valueOf()-this.touchTime>10){let t=this.getPointer(e.center);this.selectionHandler.generateClickEvent("release",e,t),this.touchTime=new Date().valueOf()}}onContext(e){let t=this.getPointer({x:e.clientX,y:e.clientY});this.selectionHandler.generateClickEvent("oncontext",e,t)}checkSelectionChanges(e,t=!1){t===!0?this.selectionHandler.selectAdditionalOnPoint(e):this.selectionHandler.selectOnPoint(e)}_determineDifference(e,t){let i=function(s,o){let r=[];for(let a=0;a{let a=r.node;r.xFixed===!1&&(a.x=this.canvas._XconvertDOMtoCanvas(this.canvas._XconvertCanvasToDOM(r.x)+s)),r.yFixed===!1&&(a.y=this.canvas._YconvertDOMtoCanvas(this.canvas._YconvertCanvasToDOM(r.y)+o))}),this.body.emitter.emit("startSimulation")}else{if(e.srcEvent.shiftKey){if(this.selectionHandler.generateClickEvent("dragging",e,t,void 0,!0),this.drag.pointer===void 0){this.onDragStart(e);return}this.body.selectionBox.position.end={x:this.canvas._XconvertDOMtoCanvas(t.x),y:this.canvas._YconvertDOMtoCanvas(t.y)},this.body.emitter.emit("_requestRedraw")}if(this.options.dragView===!0&&!e.srcEvent.shiftKey){if(this.selectionHandler.generateClickEvent("dragging",e,t,void 0,!0),this.drag.pointer===void 0){this.onDragStart(e);return}let s=t.x-this.drag.pointer.x,o=t.y-this.drag.pointer.y;this.body.view.translation={x:this.drag.translation.x+s,y:this.drag.translation.y+o},this.body.emitter.emit("_requestRedraw")}}}onDragEnd(e){if(this.drag.dragging=!1,this.body.selectionBox.show){this.body.selectionBox.show=!1;let t=this.body.selectionBox.position,i={minX:Math.min(t.start.x,t.end.x),minY:Math.min(t.start.y,t.end.y),maxX:Math.max(t.start.x,t.end.x),maxY:Math.max(t.start.y,t.end.y)};this.body.nodeIndices.filter(r=>{let a=this.body.nodes[r];return a.x>=i.minX&&a.x<=i.maxX&&a.y>=i.minY&&a.y<=i.maxY}).forEach(r=>this.selectionHandler.selectObject(this.body.nodes[r]));let o=this.getPointer(e.center);this.selectionHandler.commitAndEmit(o,e),this.selectionHandler.generateClickEvent("dragEnd",e,this.getPointer(e.center),void 0,!0),this.body.emitter.emit("_requestRedraw")}else{let t=this.drag.selection;t&&t.length?(t.forEach(function(i){i.node.options.fixed.x=i.xFixed,i.node.options.fixed.y=i.yFixed}),this.selectionHandler.generateClickEvent("dragEnd",e,this.getPointer(e.center)),this.body.emitter.emit("startSimulation")):(this.selectionHandler.generateClickEvent("dragEnd",e,this.getPointer(e.center),void 0,!0),this.body.emitter.emit("_requestRedraw"))}}onPinch(e){let t=this.getPointer(e.center);this.drag.pinched=!0,this.pinch.scale===void 0&&(this.pinch.scale=1);let i=this.pinch.scale*e.scale;this.zoom(i,t)}zoom(e,t){if(this.options.zoomView===!0){let i=this.body.view.scale;e<1e-5&&(e=1e-5),e>10&&(e=10);let s;this.drag!==void 0&&this.drag.dragging===!0&&(s=this.canvas.DOMtoCanvas(this.drag.pointer));let o=this.body.view.translation,r=e/i,a=(1-r)*t.x+o.x*r,d=(1-r)*t.y+o.y*r;if(this.body.view.scale=e,this.body.view.translation={x:a,y:d},s!=null){let h=this.canvas.canvasToDOM(s);this.drag.pointer.x=h.x,this.drag.pointer.y=h.y}this.body.emitter.emit("_requestRedraw"),ithis._checkShowPopup(t),this.options.tooltipDelay))),this.options.hover===!0&&this.selectionHandler.hoverObject(e,t)}_checkShowPopup(e){let t=this.canvas._XconvertDOMtoCanvas(e.x),i=this.canvas._YconvertDOMtoCanvas(e.y),s={left:t,top:i,right:t,bottom:i},o=this.popupObj===void 0?void 0:this.popupObj.id,r=!1,a="node";if(this.popupObj===void 0){let d=this.body.nodeIndices,h=this.body.nodes,l,c=[];for(let u=0;u0&&(this.popupObj=h[c[c.length-1]],r=!0)}if(this.popupObj===void 0&&r===!1){let d=this.body.edgeIndices,h=this.body.edges,l,c=[];for(let u=0;u0&&(this.popupObj=h[c[c.length-1]],a="edge")}this.popupObj!==void 0?this.popupObj.id!==o&&(this.popup===void 0&&(this.popup=new Ws(this.canvas.frame)),this.popup.popupTargetType=a,this.popup.popupTargetId=this.popupObj.id,this.popup.setPosition(e.x+3,e.y-5),this.popup.setText(this.popupObj.getTitle()),this.popup.show(),this.body.emitter.emit("showPopup",this.popupObj.id)):this.popup!==void 0&&(this.popup.hide(),this.body.emitter.emit("hidePopup"))}_checkHidePopup(e){let t=this.selectionHandler._pointerToPositionObject(e),i=!1;if(this.popup.popupTargetType==="node"){if(this.body.nodes[this.popup.popupTargetId]!==void 0&&(i=this.body.nodes[this.popup.popupTargetId].isOverlappingWith(t),i===!0)){let s=this.selectionHandler.getNodeAt(e);i=s===void 0?!1:s.id===this.popup.popupTargetId}}else this.selectionHandler.getNodeAt(e)===void 0&&this.body.edges[this.popup.popupTargetId]!==void 0&&(i=this.body.edges[this.popup.popupTargetId].isOverlappingWith(t));i===!1&&(this.popupObj=void 0,this.popup.hide(),this.body.emitter.emit("hidePopup"))}};function A(n,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?n!==e||!i:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(n):i?i.value:e.get(n)}function Bi(n,e,t,i,s){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?s.call(n,t):s?s.value=t:e.set(n,t),t}typeof SuppressedError=="function"&&SuppressedError;var Xe,ae,Fe,Ne,$t;function en(n,e){let t=new Set;for(let i of e)n.has(i)||t.add(i);return t}var Ai=class{constructor(){Xe.set(this,new Set),ae.set(this,new Set)}get size(){return A(this,ae,"f").size}add(...e){for(let t of e)A(this,ae,"f").add(t)}delete(...e){for(let t of e)A(this,ae,"f").delete(t)}clear(){A(this,ae,"f").clear()}getSelection(){return[...A(this,ae,"f")]}getChanges(){return{added:[...en(A(this,Xe,"f"),A(this,ae,"f"))],deleted:[...en(A(this,ae,"f"),A(this,Xe,"f"))],previous:[...new Set(A(this,Xe,"f"))],current:[...new Set(A(this,ae,"f"))]}}commit(){let e=this.getChanges();Bi(this,Xe,A(this,ae,"f"),"f"),Bi(this,ae,new Set(A(this,Xe,"f")),"f");for(let t of e.added)t.select();for(let t of e.deleted)t.unselect();return e}};Xe=new WeakMap,ae=new WeakMap;var tn=class{constructor(e=()=>{}){Fe.set(this,new Ai),Ne.set(this,new Ai),$t.set(this,void 0),Bi(this,$t,e,"f")}get sizeNodes(){return A(this,Fe,"f").size}get sizeEdges(){return A(this,Ne,"f").size}getNodes(){return A(this,Fe,"f").getSelection()}getEdges(){return A(this,Ne,"f").getSelection()}addNodes(...e){A(this,Fe,"f").add(...e)}addEdges(...e){A(this,Ne,"f").add(...e)}deleteNodes(e){A(this,Fe,"f").delete(e)}deleteEdges(e){A(this,Ne,"f").delete(e)}clear(){A(this,Fe,"f").clear(),A(this,Ne,"f").clear()}commit(...e){let t={nodes:A(this,Fe,"f").commit(),edges:A(this,Ne,"f").commit()};return A(this,$t,"f").call(this,t,...e),t}};Fe=new WeakMap,Ne=new WeakMap,$t=new WeakMap;var sn=class{constructor(e,t){this.body=e,this.canvas=t,this._selectionAccumulator=new tn,this.hoverObj={nodes:{},edges:{}},this.options={},this.defaultOptions={multiselect:!1,selectable:!0,selectConnectedEdges:!0,hoverConnectedEdges:!0},Object.assign(this.options,this.defaultOptions),this.body.emitter.on("_dataChanged",()=>{this.updateSelection()})}setOptions(e){e!==void 0&&qe(["multiselect","hoverConnectedEdges","selectable","selectConnectedEdges"],this.options,e)}selectOnPoint(e){let t=!1;if(this.options.selectable===!0){let i=this.getNodeAt(e)||this.getEdgeAt(e);this.unselectAll(),i!==void 0&&(t=this.selectObject(i)),this.body.emitter.emit("_requestRedraw")}return t}selectAdditionalOnPoint(e){let t=!1;if(this.options.selectable===!0){let i=this.getNodeAt(e)||this.getEdgeAt(e);i!==void 0&&(t=!0,i.isSelected()===!0?this.deselectObject(i):this.selectObject(i),this.body.emitter.emit("_requestRedraw"))}return t}_initBaseEvent(e,t){let i={};return i.pointer={DOM:{x:t.x,y:t.y},canvas:this.canvas.DOMtoCanvas(t)},i.event=e,i}generateClickEvent(e,t,i,s,o=!1){let r=this._initBaseEvent(t,i);if(o===!0)r.nodes=[],r.edges=[];else{let a=this.getSelection();r.nodes=a.nodes,r.edges=a.edges}s!==void 0&&(r.previousSelection=s),e=="click"&&(r.items=this.getClickedItems(i)),t.controlEdge!==void 0&&(r.controlEdge=t.controlEdge),this.body.emitter.emit(e,r)}selectObject(e,t=this.options.selectConnectedEdges){return e!==void 0?(e instanceof z?(t===!0&&this._selectionAccumulator.addEdges(...e.edges),this._selectionAccumulator.addNodes(e)):this._selectionAccumulator.addEdges(e),!0):!1}deselectObject(e){e.isSelected()===!0&&(e.selected=!1,this._removeFromSelection(e))}_getAllNodesOverlappingWith(e){let t=[],i=this.body.nodes;for(let s=0;s0)return t===!0?this.body.nodes[s[s.length-1]]:s[s.length-1]}_getEdgesOverlappingWith(e,t){let i=this.body.edges;for(let s=0;s0&&(this.generateClickEvent("deselectEdge",t,e,o),i=!0),s.nodes.deleted.length>0&&(this.generateClickEvent("deselectNode",t,e,o),i=!0),s.nodes.added.length>0&&(this.generateClickEvent("selectNode",t,e),i=!0),s.edges.added.length>0&&(this.generateClickEvent("selectEdge",t,e),i=!0),i===!0&&this.generateClickEvent("select",t,e)}getSelection(){return{nodes:this.getSelectedNodeIds(),edges:this.getSelectedEdgeIds()}}getSelectedNodes(){return this._selectionAccumulator.getNodes()}getSelectedEdges(){return this._selectionAccumulator.getEdges()}getSelectedNodeIds(){return this._selectionAccumulator.getNodes().map(e=>e.id)}getSelectedEdgeIds(){return this._selectionAccumulator.getEdges().map(e=>e.id)}setSelection(e,t={}){if(!e||!e.nodes&&!e.edges)throw new TypeError("Selection must be an object with nodes and/or edges properties");if((t.unselectAll||t.unselectAll===void 0)&&this.unselectAll(),e.nodes)for(let i of e.nodes){let s=this.body.nodes[i];if(!s)throw new RangeError('Node with id "'+i+'" not found');this.selectObject(s,t.highlightEdges)}if(e.edges)for(let i of e.edges){let s=this.body.edges[i];if(!s)throw new RangeError('Edge with id "'+i+'" not found');this.selectObject(s)}this.body.emitter.emit("_requestRedraw"),this._selectionAccumulator.commit()}selectNodes(e,t=!0){if(!e||e.length===void 0)throw"Selection must be an array with ids";this.setSelection({nodes:e},{highlightEdges:t})}selectEdges(e){if(!e||e.length===void 0)throw"Selection must be an array with ids";this.setSelection({edges:e})}updateSelection(){for(let e in this._selectionAccumulator.getNodes())Object.prototype.hasOwnProperty.call(this.body.nodes,e.id)||this._selectionAccumulator.deleteNodes(e);for(let e in this._selectionAccumulator.getEdges())Object.prototype.hasOwnProperty.call(this.body.edges,e.id)||this._selectionAccumulator.deleteEdges(e)}getClickedItems(e){let t=this.canvas.DOMtoCanvas(e),i=[],s=this.body.nodeIndices,o=this.body.nodes;for(let d=s.length-1;d>=0;d--){let l=o[s[d]].getItemsOnPoint(t);i.push.apply(i,l)}let r=this.body.edgeIndices,a=this.body.edges;for(let d=r.length-1;d>=0;d--){let l=a[r[d]].getItemsOnPoint(t);i.push.apply(i,l)}return i}},zi=class{abstract(){throw new Error("Can't instantiate abstract class!")}fake_use(){}curveType(){return this.abstract()}getPosition(e){return this.fake_use(e),this.abstract()}setPosition(e,t,i=void 0){this.fake_use(e,t,i),this.abstract()}getTreeSize(e){return this.fake_use(e),this.abstract()}sort(e){this.fake_use(e),this.abstract()}fix(e,t){this.fake_use(e,t),this.abstract()}shift(e,t){this.fake_use(e,t),this.abstract()}},on=class extends zi{constructor(e){super();this.layout=e}curveType(){return"horizontal"}getPosition(e){return e.x}setPosition(e,t,i=void 0){i!==void 0&&this.layout.hierarchical.addToOrdering(e,i),e.x=t}getTreeSize(e){let t=this.layout.hierarchical.getTreeSize(this.layout.body.nodes,e);return{min:t.min_x,max:t.max_x}}sort(e){e.sort(function(t,i){return t.x-i.x})}fix(e,t){e.y=this.layout.options.hierarchical.levelSeparation*t,e.options.fixed.y=!0}shift(e,t){this.layout.body.nodes[e].x+=t}},nn=class extends zi{constructor(e){super();this.layout=e}curveType(){return"vertical"}getPosition(e){return e.y}setPosition(e,t,i=void 0){i!==void 0&&this.layout.hierarchical.addToOrdering(e,i),e.y=t}getTreeSize(e){let t=this.layout.hierarchical.getTreeSize(this.layout.body.nodes,e);return{min:t.min_y,max:t.max_y}}sort(e){e.sort(function(t,i){return t.y-i.y})}fix(e,t){e.x=this.layout.options.hierarchical.levelSeparation*t,e.options.fixed.x=!0}shift(e,t){this.layout.body.nodes[e].y+=t}};function xa(n,e){let t=new Set;return n.forEach(i=>{i.edges.forEach(s=>{s.connected&&t.add(s)})}),t.forEach(i=>{let s=i.from.id,o=i.to.id;e[s]==null&&(e[s]=0),(e[o]==null||e[s]>=e[o])&&(e[o]=e[s]+1)}),e}function Ca(n){return rn(e=>e.edges.filter(t=>n.has(t.toId)).every(t=>t.to===e),(e,t)=>t>e,"from",n)}function Ta(n){return rn(e=>e.edges.filter(t=>n.has(t.toId)).every(t=>t.from===e),(e,t)=>td+1+h.edges.length,0),r=t+"Id",a=t==="to"?1:-1;for(let[d,h]of i){if(!i.has(d)||!n(h))continue;s[d]=0;let l=[h],c=0,u;for(;u=l.pop();){if(!i.has(d))continue;let f=s[u.id]+a;if(u.edges.filter(y=>y.connected&&y.to!==y.from&&y[t]!==u&&i.has(y.toId)&&i.has(y.fromId)).forEach(y=>{let v=y[r],g=s[v];(g==null||e(f,g))&&(s[v]=f,l.push(y[t]))}),c>o)return xa(i,s);++c}}return s}var an=class{constructor(){this.childrenReference={},this.parentReference={},this.trees={},this.distributionOrdering={},this.levels={},this.distributionIndex={},this.isTree=!1,this.treeIndex=-1}addRelation(e,t){this.childrenReference[e]===void 0&&(this.childrenReference[e]=[]),this.childrenReference[e].push(t),this.parentReference[t]===void 0&&(this.parentReference[t]=[]),this.parentReference[t].push(e)}checkIfTree(){for(let e in this.parentReference)if(this.parentReference[e].length>1){this.isTree=!1;return}this.isTree=!0}numTrees(){return this.treeIndex+1}setTreeIndex(e,t){t!==void 0&&this.trees[e.id]===void 0&&(this.trees[e.id]=t,this.treeIndex=Math.max(t,this.treeIndex))}ensureLevel(e){this.levels[e]===void 0&&(this.levels[e]=0)}getMaxLevel(e){let t={},i=s=>{if(t[s]!==void 0)return t[s];let o=this.levels[s];if(this.childrenReference[s]){let r=this.childrenReference[s];if(r.length>0)for(let a=0;a{this.setupHierarchicalLayout()}),this.body.emitter.on("_dataLoaded",()=>{this.layoutNetwork()}),this.body.emitter.on("_resetHierarchicalLayout",()=>{this.setupHierarchicalLayout()}),this.body.emitter.on("_adjustEdgesForHierarchicalLayout",()=>{if(this.options.hierarchical.enabled!==!0)return;let e=this.direction.curveType();this.body.emitter.emit("_forceDisableDynamicCurves",e,!1)})}setOptions(e,t){if(e!==void 0){let i=this.options.hierarchical,s=i.enabled;if(qe(["randomSeed","improvedLayout","clusterThreshold"],this.options,e),se(this.options,e,"hierarchical"),e.randomSeed!==void 0&&this._resetRNG(e.randomSeed),i.enabled===!0)return s===!0&&this.body.emitter.emit("refresh",!0),i.direction==="RL"||i.direction==="DU"?i.levelSeparation>0&&(i.levelSeparation*=-1):i.levelSeparation<0&&(i.levelSeparation*=-1),this.setDirectionStrategy(),this.body.emitter.emit("_resetHierarchicalLayout"),this.adaptAllOptionsForHierarchicalLayout(t);if(s===!0)return this.body.emitter.emit("refresh"),D(t,this.optionsBackup)}return t}_resetRNG(e){this.initialRandomSeed=e,this._rng=yt(this.initialRandomSeed)}adaptAllOptionsForHierarchicalLayout(e){if(this.options.hierarchical.enabled===!0){let t=this.optionsBackup.physics;e.physics===void 0||e.physics===!0?(e.physics={enabled:t.enabled===void 0?!0:t.enabled,solver:"hierarchicalRepulsion"},t.enabled=t.enabled===void 0?!0:t.enabled,t.solver=t.solver||"barnesHut"):typeof e.physics=="object"?(t.enabled=e.physics.enabled===void 0?!0:e.physics.enabled,t.solver=e.physics.solver||"barnesHut",e.physics.solver="hierarchicalRepulsion"):e.physics!==!1&&(t.solver="barnesHut",e.physics={solver:"hierarchicalRepulsion"});let i=this.direction.curveType();if(e.edges===void 0)this.optionsBackup.edges={smooth:{enabled:!0,type:"dynamic"}},e.edges={smooth:!1};else if(e.edges.smooth===void 0)this.optionsBackup.edges={smooth:{enabled:!0,type:"dynamic"}},e.edges.smooth=!1;else if(typeof e.edges.smooth=="boolean")this.optionsBackup.edges={smooth:e.edges.smooth},e.edges.smooth={enabled:e.edges.smooth,type:i};else{let s=e.edges.smooth;s.type!==void 0&&s.type!=="dynamic"&&(i=s.type),this.optionsBackup.edges={smooth:{enabled:s.enabled===void 0?!0:s.enabled,type:s.type===void 0?"dynamic":s.type,roundness:s.roundness===void 0?.5:s.roundness,forceDirection:s.forceDirection===void 0?!1:s.forceDirection}},e.edges.smooth={enabled:s.enabled===void 0?!0:s.enabled,type:i,roundness:s.roundness===void 0?.5:s.roundness,forceDirection:s.forceDirection===void 0?!1:s.forceDirection}}this.body.emitter.emit("_forceDisableDynamicCurves",i)}return e}positionInitially(e){if(this.options.hierarchical.enabled!==!0){this._resetRNG(this.initialRandomSeed);let t=e.length+50;for(let i=0;io){let d=e.length;for(;e.length>o&&s<=i;){s+=1;let h=e.length;s%3==0?this.body.modules.clustering.clusterBridges(r):this.body.modules.clustering.clusterOutliers(r);let l=e.length;if(h==l&&s%3!=0){this._declusterAll(),this.body.emitter.emit("_layoutFailed"),console.info("This network could not be positioned by this version of the improved layout algorithm. Please disable improvedLayout for better performance.");return}}this.body.modules.kamadaKawai.setOptions({springLength:Math.max(150,2*d)})}s>i&&console.info("The clustering didn't succeed within the amount of interations allowed, progressing with partial result."),this.body.modules.kamadaKawai.solve(e,this.body.edgeIndices,!0),this._shiftToCenter();let a=70;for(let d=0;d0){let e,t,i=!1,s=!1;this.lastNodeOnLevel={},this.hierarchical=new an;for(t in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,t)&&(e=this.body.nodes[t],e.options.level!==void 0?(i=!0,this.hierarchical.levels[t]=e.options.level):s=!0);if(s===!0&&i===!0)throw new Error("To use the hierarchical layout, nodes require either no predefined levels or levels have to be defined for all nodes.");{if(s===!0){let r=this.options.hierarchical.sortMethod;r==="hubsize"?this._determineLevelsByHubsize():r==="directed"?this._determineLevelsDirected():r==="custom"&&this._determineLevelsCustomCallback()}for(let r in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,r)&&this.hierarchical.ensureLevel(r);let o=this._getDistribution();this._generateMap(),this._placeNodesByHierarchy(o),this._condenseHierarchy(),this._shiftToCenter()}}}_condenseHierarchy(){let e=!1,t={},i=()=>{let g=o(),p=0;for(let b=0;b{let b=this.hierarchical.trees;for(let _ in b)Object.prototype.hasOwnProperty.call(b,_)&&b[_]===g&&this.direction.shift(_,p)},o=()=>{let g=[];for(let p=0;p{if(!p[g.id]&&(p[g.id]=!0,this.hierarchical.childrenReference[g.id])){let b=this.hierarchical.childrenReference[g.id];if(b.length>0)for(let _=0;_{let b=1e9,_=1e9,C=1e9,x=-1e9;for(let O in g)if(Object.prototype.hasOwnProperty.call(g,O)){let M=this.body.nodes[O],R=this.hierarchical.levels[M.id],q=this.direction.getPosition(M),[oe,Oe]=this._getSpaceAroundNode(M,g);b=Math.min(oe,b),_=Math.min(Oe,_),R<=p&&(C=Math.min(q,C),x=Math.max(q,x))}return[C,x,b,_]},d=(g,p)=>{let b=this.hierarchical.getMaxLevel(g.id),_=this.hierarchical.getMaxLevel(p.id);return Math.min(b,_)},h=(g,p,b)=>{let _=this.hierarchical;for(let C=0;C1)for(let M=0;M{let _=this.direction.getPosition(g),C=this.direction.getPosition(p),x=Math.abs(C-_),O=this.options.hierarchical.nodeSpacing;if(x>O){let M={},R={};r(g,M),r(p,R);let q=d(g,p),oe=a(M,q),Oe=a(R,q),ge=oe[1],Ge=Oe[0],W=Oe[2];if(Math.abs(ge-Ge)>O){let N=ge-Ge+O;N<-W+O&&(N=-W+O),N<0&&(this._shiftBlock(p.id,N),e=!0,b===!0&&this._centerParent(p))}}},c=(g,p)=>{let b=p.id,_=p.edges,C=this.hierarchical.levels[p.id],x=this.options.hierarchical.levelSeparation*this.options.hierarchical.levelSeparation,O={},M=[];for(let W=0;W<_.length;W++){let F=_[W];if(F.toId!=F.fromId){let N=F.toId==b?F.from:F.to;O[_[W].id]=N,this.hierarchical.levels[N.id]{let N=0;for(let Y=0;Y{let N=0;for(let Y=0;Y{let N=this.direction.getPosition(p),Y={};for(let K=0;K{let F=this.direction.getPosition(p);if(t[p.id]===void 0){let ot={};r(p,ot),t[p.id]=ot}let N=a(t[p.id]),Y=N[2],K=N[3],he=W-F,Ke=0;he>0?Ke=Math.min(he,K-this.options.hierarchical.nodeSpacing):he<0&&(Ke=-Math.min(-he,Y-this.options.hierarchical.nodeSpacing)),Ke!=0&&(this._shiftBlock(p.id,Ke),e=!0)},ge=W=>{let F=this.direction.getPosition(p),[N,Y]=this._getSpaceAroundNode(p),K=W-F,he=F;K>0?he=Math.min(F+(Y-this.options.hierarchical.nodeSpacing),W):K<0&&(he=Math.max(F-(N-this.options.hierarchical.nodeSpacing),W)),he!==F&&(this.direction.setPosition(p,he),e=!0)},Ge=oe(g,M);Oe(Ge),Ge=oe(g,_),ge(Ge)},u=g=>{let p=this.hierarchical.getLevels();p=p.reverse();for(let b=0;b{let p=this.hierarchical.getLevels();p=p.reverse();for(let b=0;b{for(let g in this.body.nodes)Object.prototype.hasOwnProperty.call(this.body.nodes,g)&&this._centerParent(this.body.nodes[g])},v=()=>{let g=this.hierarchical.getLevels();g=g.reverse();for(let p=0;p0&&Math.abs(c)0&&(d=this.direction.getPosition(i[o-1])+a),this.direction.setPosition(r,d,t),this._validatePositionAndContinue(r,t,d),s++}}}}_placeBranchNodes(e,t){let i=this.hierarchical.childrenReference[e];if(i===void 0)return;let s=[];for(let r=0;rt&&this.positionedNodes[a.id]===void 0){let h=this.options.hierarchical.nodeSpacing,l;r===0?l=this.direction.getPosition(this.body.nodes[e]):l=this.direction.getPosition(s[r-1])+h,this.direction.setPosition(a,l,d),this._validatePositionAndContinue(a,d,l)}else return}let o=this._getCenterPosition(s);this.direction.setPosition(this.body.nodes[e],o,t)}_validatePositionAndContinue(e,t,i){if(!!this.hierarchical.isTree){if(this.lastNodeOnLevel[t]!==void 0){let s=this.direction.getPosition(this.body.nodes[this.lastNodeOnLevel[t]]);if(i-s{this.body.edgeIndices.indexOf(i.id)!==-1&&t.push(i)}),t}_getHubSizes(){let e={},t=this.body.nodeIndices;I(t,s=>{let o=this.body.nodes[s],r=this._getActiveEdges(o).length;e[r]=!0});let i=[];return I(e,s=>{i.push(Number(s))}),i.sort(function(s,o){return o-s}),i}_determineLevelsByHubsize(){let e=(i,s)=>{this.hierarchical.levelDownstream(i,s)},t=this._getHubSizes();for(let i=0;i{let r=this.body.nodes[o];s===this._getActiveEdges(r).length&&this._crawlNetwork(e,o)})}}_determineLevelsCustomCallback(){let e=1e5,t=function(s,o,r){},i=(s,o,r)=>{let a=this.hierarchical.levels[s.id];a===void 0&&(a=this.hierarchical.levels[s.id]=e);let d=t(G.cloneOptions(s,"node"),G.cloneOptions(o,"node"),G.cloneOptions(r,"edge"));this.hierarchical.levels[o.id]=a+d};this._crawlNetwork(i),this.hierarchical.setMinLevelToZero(this.body.nodes)}_determineLevelsDirected(){let e=this.body.nodeIndices.reduce((t,i)=>(t.set(i,this.body.nodes[i]),t),new Map);this.options.hierarchical.shakeTowards==="roots"?this.hierarchical.levels=Ta(e):this.hierarchical.levels=Ca(e),this.hierarchical.setMinLevelToZero(this.body.nodes)}_generateMap(){let e=(t,i)=>{this.hierarchical.levels[i.id]>this.hierarchical.levels[t.id]&&this.hierarchical.addRelation(t.id,i.id)};this._crawlNetwork(e),this.hierarchical.checkIfTree()}_crawlNetwork(e=function(){},t){let i={},s=(o,r)=>{if(i[o.id]===void 0){this.hierarchical.setTreeIndex(o,r),i[o.id]=!0;let a,d=this._getActiveEdges(o);for(let h=0;h{if(i[o])return;i[o]=!0,this.direction.shift(o,t);let r=this.hierarchical.childrenReference[o];if(r!==void 0)for(let a=0;a{let d=this.hierarchical.parentReference[a];if(d!==void 0)for(let h=0;h{let d=this.hierarchical.parentReference[a];if(d!==void 0)for(let h=0;h{this._clean()}),this.body.emitter.on("_dataChanged",this._restore.bind(this)),this.body.emitter.on("_resetData",this._restore.bind(this))}_restore(){this.inMode!==!1&&(this.options.initiallyActive===!0?this.enableEditMode():this.disableEditMode())}setOptions(e,t,i){t!==void 0&&(t.locale!==void 0?this.options.locale=t.locale:this.options.locale=i.locale,t.locales!==void 0?this.options.locales=t.locales:this.options.locales=i.locales),e!==void 0&&(typeof e=="boolean"?this.options.enabled=e:(this.options.enabled=!0,D(this.options,e)),this.options.initiallyActive===!0&&(this.editMode=!0),this._setup())}toggleEditMode(){this.editMode===!0?this.disableEditMode():this.enableEditMode()}enableEditMode(){this.editMode=!0,this._clean(),this.guiEnabled===!0&&(this.manipulationDiv.style.display="block",this.closeDiv.style.display="block",this.editModeDiv.style.display="none",this.showManipulatorToolbar())}disableEditMode(){this.editMode=!1,this._clean(),this.guiEnabled===!0&&(this.manipulationDiv.style.display="none",this.closeDiv.style.display="none",this.editModeDiv.style.display="block",this._createEditButton())}showManipulatorToolbar(){if(this._clean(),this.manipulationDOM={},this.guiEnabled===!0){this.editMode=!0,this.manipulationDiv.style.display="block",this.closeDiv.style.display="block";let e=this.selectionHandler.getSelectedNodeCount(),t=this.selectionHandler.getSelectedEdgeCount(),i=e+t,s=this.options.locales[this.options.locale],o=!1;this.options.addNode!==!1&&(this._createAddNodeButton(s),o=!0),this.options.addEdge!==!1&&(o===!0?this._createSeperator(1):o=!0,this._createAddEdgeButton(s)),e===1&&typeof this.options.editNode=="function"?(o===!0?this._createSeperator(2):o=!0,this._createEditNodeButton(s)):t===1&&e===0&&this.options.editEdge!==!1&&(o===!0?this._createSeperator(3):o=!0,this._createEditEdgeButton(s)),i!==0&&(e>0&&this.options.deleteNode!==!1?(o===!0&&this._createSeperator(4),this._createDeleteButton(s)):e===0&&this.options.deleteEdge!==!1&&(o===!0&&this._createSeperator(4),this._createDeleteButton(s))),this._bindElementEvents(this.closeDiv,this.toggleEditMode.bind(this)),this._temporaryBindEvent("select",this.showManipulatorToolbar.bind(this))}this.body.emitter.emit("_redraw")}addNodeMode(){if(this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="addNode",this.guiEnabled===!0){let e=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(e),this._createSeperator(),this._createDescription(e.addDescription||this.options.locales.en.addDescription),this._bindElementEvents(this.closeDiv,this.toggleEditMode.bind(this))}this._temporaryBindEvent("click",this._performAddNode.bind(this))}editNode(){this.editMode!==!0&&this.enableEditMode(),this._clean();let e=this.selectionHandler.getSelectedNodes()[0];if(e!==void 0)if(this.inMode="editNode",typeof this.options.editNode=="function")if(e.isCluster!==!0){let t=D({},e.options,!1);if(t.x=e.x,t.y=e.y,this.options.editNode.length===2)this.options.editNode(t,i=>{i!=null&&this.inMode==="editNode"&&this.body.data.nodes.getDataSet().update(i),this.showManipulatorToolbar()});else throw new Error("The function for edit does not support two arguments (data, callback)")}else alert(this.options.locales[this.options.locale].editClusterError||this.options.locales.en.editClusterError);else throw new Error("No function has been configured to handle the editing of nodes.");else this.showManipulatorToolbar()}addEdgeMode(){if(this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="addEdge",this.guiEnabled===!0){let e=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(e),this._createSeperator(),this._createDescription(e.edgeDescription||this.options.locales.en.edgeDescription),this._bindElementEvents(this.closeDiv,this.toggleEditMode.bind(this))}this._temporaryBindUI("onTouch",this._handleConnect.bind(this)),this._temporaryBindUI("onDragEnd",this._finishConnect.bind(this)),this._temporaryBindUI("onDrag",this._dragControlNode.bind(this)),this._temporaryBindUI("onRelease",this._finishConnect.bind(this)),this._temporaryBindUI("onDragStart",this._dragStartEdge.bind(this)),this._temporaryBindUI("onHold",()=>{})}editEdgeMode(){if(this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="editEdge",typeof this.options.editEdge=="object"&&typeof this.options.editEdge.editWithoutDrag=="function"&&(this.edgeBeingEditedId=this.selectionHandler.getSelectedEdgeIds()[0],this.edgeBeingEditedId!==void 0)){let e=this.body.edges[this.edgeBeingEditedId];this._performEditEdge(e.from.id,e.to.id);return}if(this.guiEnabled===!0){let e=this.options.locales[this.options.locale];this.manipulationDOM={},this._createBackButton(e),this._createSeperator(),this._createDescription(e.editEdgeDescription||this.options.locales.en.editEdgeDescription),this._bindElementEvents(this.closeDiv,this.toggleEditMode.bind(this))}if(this.edgeBeingEditedId=this.selectionHandler.getSelectedEdgeIds()[0],this.edgeBeingEditedId!==void 0){let e=this.body.edges[this.edgeBeingEditedId],t=this._getNewTargetNode(e.from.x,e.from.y),i=this._getNewTargetNode(e.to.x,e.to.y);this.temporaryIds.nodes.push(t.id),this.temporaryIds.nodes.push(i.id),this.body.nodes[t.id]=t,this.body.nodeIndices.push(t.id),this.body.nodes[i.id]=i,this.body.nodeIndices.push(i.id),this._temporaryBindUI("onTouch",this._controlNodeTouch.bind(this)),this._temporaryBindUI("onTap",()=>{}),this._temporaryBindUI("onHold",()=>{}),this._temporaryBindUI("onDragStart",this._controlNodeDragStart.bind(this)),this._temporaryBindUI("onDrag",this._controlNodeDrag.bind(this)),this._temporaryBindUI("onDragEnd",this._controlNodeDragEnd.bind(this)),this._temporaryBindUI("onMouseMove",()=>{}),this._temporaryBindEvent("beforeDrawing",s=>{let o=e.edgeType.findBorderPositions(s);t.selected===!1&&(t.x=o.from.x,t.y=o.from.y),i.selected===!1&&(i.x=o.to.x,i.y=o.to.y)}),this.body.emitter.emit("_redraw")}else this.showManipulatorToolbar()}deleteSelected(){this.editMode!==!0&&this.enableEditMode(),this._clean(),this.inMode="delete";let e=this.selectionHandler.getSelectedNodeIds(),t=this.selectionHandler.getSelectedEdgeIds(),i;if(e.length>0){for(let s=0;s0&&typeof this.options.deleteEdge=="function"&&(i=this.options.deleteEdge);if(typeof i=="function"){let s={nodes:e,edges:t};if(i.length===2)i(s,o=>{o!=null&&this.inMode==="delete"?(this.body.data.edges.getDataSet().remove(o.edges),this.body.data.nodes.getDataSet().remove(o.nodes),this.body.emitter.emit("startSimulation"),this.showManipulatorToolbar()):(this.body.emitter.emit("startSimulation"),this.showManipulatorToolbar())});else throw new Error("The function for delete does not support two arguments (data, callback)")}else this.body.data.edges.getDataSet().remove(t),this.body.data.nodes.getDataSet().remove(e),this.body.emitter.emit("startSimulation"),this.showManipulatorToolbar()}_setup(){this.options.enabled===!0?(this.guiEnabled=!0,this._createWrappers(),this.editMode===!1?this._createEditButton():this.showManipulatorToolbar()):(this._removeManipulationDOM(),this.guiEnabled=!1)}_createWrappers(){var e,t;this.manipulationDiv===void 0&&(this.manipulationDiv=document.createElement("div"),this.manipulationDiv.className="vis-manipulation",this.editMode===!0?this.manipulationDiv.style.display="block":this.manipulationDiv.style.display="none",this.canvas.frame.appendChild(this.manipulationDiv)),this.editModeDiv===void 0&&(this.editModeDiv=document.createElement("div"),this.editModeDiv.className="vis-edit-mode",this.editMode===!0?this.editModeDiv.style.display="none":this.editModeDiv.style.display="block",this.canvas.frame.appendChild(this.editModeDiv)),this.closeDiv===void 0&&(this.closeDiv=document.createElement("button"),this.closeDiv.className="vis-close",this.closeDiv.setAttribute("aria-label",(t=(e=this.options.locales[this.options.locale])==null?void 0:e.close)!=null?t:this.options.locales.en.close),this.closeDiv.style.display=this.manipulationDiv.style.display,this.canvas.frame.appendChild(this.closeDiv))}_getNewTargetNode(e,t){let i=D({},this.options.controlNodeStyle);i.id="targetNode"+xe(),i.hidden=!1,i.physics=!1,i.x=e,i.y=t;let s=this.body.functions.createNode(i);return s.shape.boundingBox={left:e,right:e,top:t,bottom:t},s}_createEditButton(){this._clean(),this.manipulationDOM={},ve(this.editModeDiv);let e=this.options.locales[this.options.locale],t=this._createButton("editMode","vis-edit vis-edit-mode",e.edit||this.options.locales.en.edit);this.editModeDiv.appendChild(t),this._bindElementEvents(t,this.toggleEditMode.bind(this))}_clean(){this.inMode=!1,this.guiEnabled===!0&&(ve(this.editModeDiv),ve(this.manipulationDiv),this._cleanupDOMEventListeners()),this._cleanupTemporaryNodesAndEdges(),this._unbindTemporaryUIs(),this._unbindTemporaryEvents(),this.body.emitter.emit("restorePhysics")}_cleanupDOMEventListeners(){for(let e of this._domEventListenerCleanupQueue.splice(0))e()}_removeManipulationDOM(){this._clean(),ve(this.manipulationDiv),ve(this.editModeDiv),ve(this.closeDiv),this.manipulationDiv&&this.canvas.frame.removeChild(this.manipulationDiv),this.editModeDiv&&this.canvas.frame.removeChild(this.editModeDiv),this.closeDiv&&this.canvas.frame.removeChild(this.closeDiv),this.manipulationDiv=void 0,this.editModeDiv=void 0,this.closeDiv=void 0}_createSeperator(e=1){this.manipulationDOM["seperatorLineDiv"+e]=document.createElement("div"),this.manipulationDOM["seperatorLineDiv"+e].className="vis-separator-line",this.manipulationDiv.appendChild(this.manipulationDOM["seperatorLineDiv"+e])}_createAddNodeButton(e){let t=this._createButton("addNode","vis-add",e.addNode||this.options.locales.en.addNode);this.manipulationDiv.appendChild(t),this._bindElementEvents(t,this.addNodeMode.bind(this))}_createAddEdgeButton(e){let t=this._createButton("addEdge","vis-connect",e.addEdge||this.options.locales.en.addEdge);this.manipulationDiv.appendChild(t),this._bindElementEvents(t,this.addEdgeMode.bind(this))}_createEditNodeButton(e){let t=this._createButton("editNode","vis-edit",e.editNode||this.options.locales.en.editNode);this.manipulationDiv.appendChild(t),this._bindElementEvents(t,this.editNode.bind(this))}_createEditEdgeButton(e){let t=this._createButton("editEdge","vis-edit",e.editEdge||this.options.locales.en.editEdge);this.manipulationDiv.appendChild(t),this._bindElementEvents(t,this.editEdgeMode.bind(this))}_createDeleteButton(e){let t;this.options.rtl?t="vis-delete-rtl":t="vis-delete";let i=this._createButton("delete",t,e.del||this.options.locales.en.del);this.manipulationDiv.appendChild(i),this._bindElementEvents(i,this.deleteSelected.bind(this))}_createBackButton(e){let t=this._createButton("back","vis-back",e.back||this.options.locales.en.back);this.manipulationDiv.appendChild(t),this._bindElementEvents(t,this.showManipulatorToolbar.bind(this))}_createButton(e,t,i,s="vis-label"){return this.manipulationDOM[e+"Div"]=document.createElement("button"),this.manipulationDOM[e+"Div"].className="vis-button "+t,this.manipulationDOM[e+"Label"]=document.createElement("div"),this.manipulationDOM[e+"Label"].className=s,this.manipulationDOM[e+"Label"].innerText=i,this.manipulationDOM[e+"Div"].appendChild(this.manipulationDOM[e+"Label"]),this.manipulationDOM[e+"Div"]}_createDescription(e){this.manipulationDOM.descriptionLabel=document.createElement("div"),this.manipulationDOM.descriptionLabel.className="vis-none",this.manipulationDOM.descriptionLabel.innerText=e,this.manipulationDiv.appendChild(this.manipulationDOM.descriptionLabel)}_temporaryBindEvent(e,t){this.temporaryEventFunctions.push({event:e,boundFunction:t}),this.body.emitter.on(e,t)}_temporaryBindUI(e,t){if(this.body.eventListeners[e]!==void 0)this.temporaryUIFunctions[e]=this.body.eventListeners[e],this.body.eventListeners[e]=t;else throw new Error("This UI function does not exist. Typo? You tried: "+e+" possible are: "+JSON.stringify(Object.keys(this.body.eventListeners)))}_unbindTemporaryUIs(){for(let e in this.temporaryUIFunctions)Object.prototype.hasOwnProperty.call(this.temporaryUIFunctions,e)&&(this.body.eventListeners[e]=this.temporaryUIFunctions[e],delete this.temporaryUIFunctions[e]);this.temporaryUIFunctions={}}_unbindTemporaryEvents(){for(let e=0;e{i.destroy()});let s=({keyCode:o,key:r})=>{(r==="Enter"||r===" "||o===13||o===32)&&t()};e.addEventListener("keyup",s,!1),this._domEventListenerCleanupQueue.push(()=>{e.removeEventListener("keyup",s,!1)})}_cleanupTemporaryNodesAndEdges(){for(let e=0;e=0;a--)if(o[a]!==this.selectedControlNode.id){r=this.body.nodes[o[a]];break}if(r!==void 0&&this.selectedControlNode!==void 0)if(r.isCluster===!0)alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError);else{let a=this.body.nodes[this.temporaryIds.nodes[0]];this.selectedControlNode.id===a.id?this._performEditEdge(r.id,s.to.id):this._performEditEdge(s.from.id,r.id)}else s.updateEdgeType(),this.body.emitter.emit("restorePhysics");this.body.emitter.emit("_redraw")}_handleConnect(e){if(new Date().valueOf()-this.touchTime>100){this.lastTouch=this.body.functions.getPointer(e.center),this.lastTouch.translation=Object.assign({},this.body.view.translation),this.interactionHandler.drag.pointer=this.lastTouch,this.interactionHandler.drag.translation=this.lastTouch.translation;let t=this.lastTouch,i=this.selectionHandler.getNodeAt(t);if(i!==void 0)if(i.isCluster===!0)alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError);else{let s=this._getNewTargetNode(i.x,i.y);this.body.nodes[s.id]=s,this.body.nodeIndices.push(s.id);let o=this.body.functions.createEdge({id:"connectionEdge"+xe(),from:i.id,to:s.id,physics:!1,smooth:{enabled:!0,type:"continuous",roundness:.5}});this.body.edges[o.id]=o,this.body.edgeIndices.push(o.id),this.temporaryIds.nodes.push(s.id),this.temporaryIds.edges.push(o.id)}this.touchTime=new Date().valueOf()}}_dragControlNode(e){let t=this.body.functions.getPointer(e.center),i=this.selectionHandler._pointerToPositionObject(t),s;this.temporaryIds.edges[0]!==void 0&&(s=this.body.edges[this.temporaryIds.edges[0]].fromId);let o=this.selectionHandler._getAllNodesOverlappingWith(i),r;for(let a=o.length-1;a>=0;a--)if(this.temporaryIds.nodes.indexOf(o[a])===-1){r=this.body.nodes[o[a]];break}if(e.controlEdge={from:s,to:r?r.id:void 0},this.selectionHandler.generateClickEvent("controlNodeDragging",e,t),this.temporaryIds.nodes[0]!==void 0){let a=this.body.nodes[this.temporaryIds.nodes[0]];a.x=this.canvas._XconvertDOMtoCanvas(t.x),a.y=this.canvas._YconvertDOMtoCanvas(t.y),this.body.emitter.emit("_redraw")}else this.interactionHandler.onDrag(e)}_finishConnect(e){let t=this.body.functions.getPointer(e.center),i=this.selectionHandler._pointerToPositionObject(t),s;this.temporaryIds.edges[0]!==void 0&&(s=this.body.edges[this.temporaryIds.edges[0]].fromId);let o=this.selectionHandler._getAllNodesOverlappingWith(i),r;for(let a=o.length-1;a>=0;a--)if(this.temporaryIds.nodes.indexOf(o[a])===-1){r=this.body.nodes[o[a]];break}this._cleanupTemporaryNodesAndEdges(),r!==void 0&&(r.isCluster===!0?alert(this.options.locales[this.options.locale].createEdgeError||this.options.locales.en.createEdgeError):this.body.nodes[s]!==void 0&&this.body.nodes[r.id]!==void 0&&this._performAddEdge(s,r.id)),e.controlEdge={from:s,to:r?r.id:void 0},this.selectionHandler.generateClickEvent("controlNodeDragEnd",e,t),this.body.emitter.emit("_redraw")}_dragStartEdge(e){let t=this.lastTouch;this.selectionHandler.generateClickEvent("dragStart",e,t,void 0,!0)}_performAddNode(e){let t={id:xe(),x:e.pointer.canvas.x,y:e.pointer.canvas.y,label:"new"};if(typeof this.options.addNode=="function")if(this.options.addNode.length===2)this.options.addNode(t,i=>{i!=null&&this.inMode==="addNode"&&this.body.data.nodes.getDataSet().add(i),this.showManipulatorToolbar()});else throw this.showManipulatorToolbar(),new Error("The function for add does not support two arguments (data,callback)");else this.body.data.nodes.getDataSet().add(t),this.showManipulatorToolbar()}_performAddEdge(e,t){let i={from:e,to:t};if(typeof this.options.addEdge=="function")if(this.options.addEdge.length===2)this.options.addEdge(i,s=>{s!=null&&this.inMode==="addEdge"&&(this.body.data.edges.getDataSet().add(s),this.selectionHandler.unselectAll(),this.showManipulatorToolbar())});else throw new Error("The function for connect does not support two arguments (data,callback)");else this.body.data.edges.getDataSet().add(i),this.selectionHandler.unselectAll(),this.showManipulatorToolbar()}_performEditEdge(e,t){let i={id:this.edgeBeingEditedId,from:e,to:t,label:this.body.data.edges.get(this.edgeBeingEditedId).label},s=this.options.editEdge;if(typeof s=="object"&&(s=s.editWithoutDrag),typeof s=="function")if(s.length===2)s(i,o=>{o==null||this.inMode!=="editEdge"?(this.body.edges[i.id].updateEdgeType(),this.body.emitter.emit("_redraw"),this.showManipulatorToolbar()):(this.body.data.edges.getDataSet().update(o),this.selectionHandler.unselectAll(),this.showManipulatorToolbar())});else throw new Error("The function for edit does not support two arguments (data, callback)");else this.body.data.edges.getDataSet().update(i),this.selectionHandler.unselectAll(),this.showManipulatorToolbar()}},E="string",w="boolean",m="number",Ct="array",k="object",ln="dom",ka="any",Ri=["arrow","bar","box","circle","crow","curve","diamond","image","inv_curve","inv_triangle","triangle","vee"],Li={borderWidth:{number:m},borderWidthSelected:{number:m,undefined:"undefined"},brokenImage:{string:E,undefined:"undefined"},chosen:{label:{boolean:w,function:"function"},node:{boolean:w,function:"function"},__type__:{object:k,boolean:w}},color:{border:{string:E},background:{string:E},highlight:{border:{string:E},background:{string:E},__type__:{object:k,string:E}},hover:{border:{string:E},background:{string:E},__type__:{object:k,string:E}},__type__:{object:k,string:E}},opacity:{number:m,undefined:"undefined"},fixed:{x:{boolean:w},y:{boolean:w},__type__:{object:k,boolean:w}},font:{align:{string:E},color:{string:E},size:{number:m},face:{string:E},background:{string:E},strokeWidth:{number:m},strokeColor:{string:E},vadjust:{number:m},multi:{boolean:w,string:E},bold:{color:{string:E},size:{number:m},face:{string:E},mod:{string:E},vadjust:{number:m},__type__:{object:k,string:E}},boldital:{color:{string:E},size:{number:m},face:{string:E},mod:{string:E},vadjust:{number:m},__type__:{object:k,string:E}},ital:{color:{string:E},size:{number:m},face:{string:E},mod:{string:E},vadjust:{number:m},__type__:{object:k,string:E}},mono:{color:{string:E},size:{number:m},face:{string:E},mod:{string:E},vadjust:{number:m},__type__:{object:k,string:E}},__type__:{object:k,string:E}},group:{string:E,number:m,undefined:"undefined"},heightConstraint:{minimum:{number:m},valign:{string:E},__type__:{object:k,boolean:w,number:m}},hidden:{boolean:w},icon:{face:{string:E},code:{string:E},size:{number:m},color:{string:E},weight:{string:E,number:m},__type__:{object:k}},id:{string:E,number:m},image:{selected:{string:E,undefined:"undefined"},unselected:{string:E,undefined:"undefined"},__type__:{object:k,string:E}},imagePadding:{top:{number:m},right:{number:m},bottom:{number:m},left:{number:m},__type__:{object:k,number:m}},label:{string:E,undefined:"undefined"},labelHighlightBold:{boolean:w},level:{number:m,undefined:"undefined"},margin:{top:{number:m},right:{number:m},bottom:{number:m},left:{number:m},__type__:{object:k,number:m}},mass:{number:m},physics:{boolean:w},scaling:{min:{number:m},max:{number:m},label:{enabled:{boolean:w},min:{number:m},max:{number:m},maxVisible:{number:m},drawThreshold:{number:m},__type__:{object:k,boolean:w}},customScalingFunction:{function:"function"},__type__:{object:k}},shadow:{enabled:{boolean:w},color:{string:E},size:{number:m},x:{number:m},y:{number:m},__type__:{object:k,boolean:w}},shape:{string:["custom","ellipse","circle","database","box","text","image","circularImage","diamond","dot","star","triangle","triangleDown","square","icon","hexagon"]},ctxRenderer:{function:"function"},shapeProperties:{borderDashes:{boolean:w,array:Ct},borderRadius:{number:m},interpolation:{boolean:w},useImageSize:{boolean:w},useBorderWithImage:{boolean:w},coordinateOrigin:{string:["center","top-left"]},__type__:{object:k}},size:{number:m},title:{string:E,dom:ln,undefined:"undefined"},value:{number:m,undefined:"undefined"},widthConstraint:{minimum:{number:m},maximum:{number:m},__type__:{object:k,boolean:w,number:m}},x:{number:m},y:{number:m},__type__:{object:k}},Oa={configure:{enabled:{boolean:w},filter:{boolean:w,string:E,array:Ct,function:"function"},container:{dom:ln},showButton:{boolean:w},__type__:{object:k,boolean:w,string:E,array:Ct,function:"function"}},edges:{arrows:{to:{enabled:{boolean:w},scaleFactor:{number:m},type:{string:Ri},imageHeight:{number:m},imageWidth:{number:m},src:{string:E},__type__:{object:k,boolean:w}},middle:{enabled:{boolean:w},scaleFactor:{number:m},type:{string:Ri},imageWidth:{number:m},imageHeight:{number:m},src:{string:E},__type__:{object:k,boolean:w}},from:{enabled:{boolean:w},scaleFactor:{number:m},type:{string:Ri},imageWidth:{number:m},imageHeight:{number:m},src:{string:E},__type__:{object:k,boolean:w}},__type__:{string:["from","to","middle"],object:k}},endPointOffset:{from:{number:m},to:{number:m},__type__:{object:k,number:m}},arrowStrikethrough:{boolean:w},background:{enabled:{boolean:w},color:{string:E},size:{number:m},dashes:{boolean:w,array:Ct},__type__:{object:k,boolean:w}},chosen:{label:{boolean:w,function:"function"},edge:{boolean:w,function:"function"},__type__:{object:k,boolean:w}},color:{color:{string:E},highlight:{string:E},hover:{string:E},inherit:{string:["from","to","both"],boolean:w},opacity:{number:m},__type__:{object:k,string:E}},dashes:{boolean:w,array:Ct},font:{color:{string:E},size:{number:m},face:{string:E},background:{string:E},strokeWidth:{number:m},strokeColor:{string:E},align:{string:["horizontal","top","middle","bottom"]},vadjust:{number:m},multi:{boolean:w,string:E},bold:{color:{string:E},size:{number:m},face:{string:E},mod:{string:E},vadjust:{number:m},__type__:{object:k,string:E}},boldital:{color:{string:E},size:{number:m},face:{string:E},mod:{string:E},vadjust:{number:m},__type__:{object:k,string:E}},ital:{color:{string:E},size:{number:m},face:{string:E},mod:{string:E},vadjust:{number:m},__type__:{object:k,string:E}},mono:{color:{string:E},size:{number:m},face:{string:E},mod:{string:E},vadjust:{number:m},__type__:{object:k,string:E}},__type__:{object:k,string:E}},hidden:{boolean:w},hoverWidth:{function:"function",number:m},label:{string:E,undefined:"undefined"},labelHighlightBold:{boolean:w},length:{number:m,undefined:"undefined"},physics:{boolean:w},scaling:{min:{number:m},max:{number:m},label:{enabled:{boolean:w},min:{number:m},max:{number:m},maxVisible:{number:m},drawThreshold:{number:m},__type__:{object:k,boolean:w}},customScalingFunction:{function:"function"},__type__:{object:k}},selectionWidth:{function:"function",number:m},selfReferenceSize:{number:m},selfReference:{size:{number:m},angle:{number:m},renderBehindTheNode:{boolean:w},__type__:{object:k}},shadow:{enabled:{boolean:w},color:{string:E},size:{number:m},x:{number:m},y:{number:m},__type__:{object:k,boolean:w}},smooth:{enabled:{boolean:w},type:{string:["dynamic","continuous","discrete","diagonalCross","straightCross","horizontal","vertical","curvedCW","curvedCCW","cubicBezier"]},roundness:{number:m},forceDirection:{string:["horizontal","vertical","none"],boolean:w},__type__:{object:k,boolean:w}},title:{string:E,undefined:"undefined"},width:{number:m},widthConstraint:{maximum:{number:m},__type__:{object:k,boolean:w,number:m}},value:{number:m,undefined:"undefined"},__type__:{object:k}},groups:{useDefaultGroups:{boolean:w},__any__:Li,__type__:{object:k}},interaction:{dragNodes:{boolean:w},dragView:{boolean:w},hideEdgesOnDrag:{boolean:w},hideEdgesOnZoom:{boolean:w},hideNodesOnDrag:{boolean:w},hover:{boolean:w},keyboard:{enabled:{boolean:w},speed:{x:{number:m},y:{number:m},zoom:{number:m},__type__:{object:k}},bindToWindow:{boolean:w},autoFocus:{boolean:w},__type__:{object:k,boolean:w}},multiselect:{boolean:w},navigationButtons:{boolean:w},selectable:{boolean:w},selectConnectedEdges:{boolean:w},hoverConnectedEdges:{boolean:w},tooltipDelay:{number:m},zoomView:{boolean:w},zoomSpeed:{number:m},__type__:{object:k}},layout:{randomSeed:{undefined:"undefined",number:m,string:E},improvedLayout:{boolean:w},clusterThreshold:{number:m},hierarchical:{enabled:{boolean:w},levelSeparation:{number:m},nodeSpacing:{number:m},treeSpacing:{number:m},blockShifting:{boolean:w},edgeMinimization:{boolean:w},parentCentralization:{boolean:w},direction:{string:["UD","DU","LR","RL"]},sortMethod:{string:["hubsize","directed"]},shakeTowards:{string:["leaves","roots"]},__type__:{object:k,boolean:w}},__type__:{object:k}},manipulation:{enabled:{boolean:w},initiallyActive:{boolean:w},addNode:{boolean:w,function:"function"},addEdge:{boolean:w,function:"function"},editNode:{function:"function"},editEdge:{editWithoutDrag:{function:"function"},__type__:{object:k,boolean:w,function:"function"}},deleteNode:{boolean:w,function:"function"},deleteEdge:{boolean:w,function:"function"},controlNodeStyle:Li,__type__:{object:k,boolean:w}},nodes:Li,physics:{enabled:{boolean:w},barnesHut:{theta:{number:m},gravitationalConstant:{number:m},centralGravity:{number:m},springLength:{number:m},springConstant:{number:m},damping:{number:m},avoidOverlap:{number:m},__type__:{object:k}},forceAtlas2Based:{theta:{number:m},gravitationalConstant:{number:m},centralGravity:{number:m},springLength:{number:m},springConstant:{number:m},damping:{number:m},avoidOverlap:{number:m},__type__:{object:k}},repulsion:{centralGravity:{number:m},springLength:{number:m},springConstant:{number:m},nodeDistance:{number:m},damping:{number:m},__type__:{object:k}},hierarchicalRepulsion:{centralGravity:{number:m},springLength:{number:m},springConstant:{number:m},nodeDistance:{number:m},damping:{number:m},avoidOverlap:{number:m},__type__:{object:k}},maxVelocity:{number:m},minVelocity:{number:m},solver:{string:["barnesHut","repulsion","hierarchicalRepulsion","forceAtlas2Based"]},stabilization:{enabled:{boolean:w},iterations:{number:m},updateInterval:{number:m},onlyDynamicEdges:{boolean:w},fit:{boolean:w},__type__:{object:k,boolean:w}},timestep:{number:m},adaptiveTimestep:{boolean:w},wind:{x:{number:m},y:{number:m},__type__:{object:k}},__type__:{object:k,boolean:w}},autoResize:{boolean:w},clickToUse:{boolean:w},locale:{string:E},locales:{__any__:{any:ka},__type__:{object:k}},height:{string:E},width:{string:E},__type__:{object:k}},cn={nodes:{borderWidth:[1,0,10,1],borderWidthSelected:[2,0,10,1],color:{border:["color","#2B7CE9"],background:["color","#97C2FC"],highlight:{border:["color","#2B7CE9"],background:["color","#D2E5FF"]},hover:{border:["color","#2B7CE9"],background:["color","#D2E5FF"]}},opacity:[0,0,1,.1],fixed:{x:!1,y:!1},font:{color:["color","#343434"],size:[14,0,100,1],face:["arial","verdana","tahoma"],background:["color","none"],strokeWidth:[0,0,50,1],strokeColor:["color","#ffffff"]},hidden:!1,labelHighlightBold:!0,physics:!0,scaling:{min:[10,0,200,1],max:[30,0,200,1],label:{enabled:!1,min:[14,0,200,1],max:[30,0,200,1],maxVisible:[30,0,200,1],drawThreshold:[5,0,20,1]}},shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:[10,0,20,1],x:[5,-30,30,1],y:[5,-30,30,1]},shape:["ellipse","box","circle","database","diamond","dot","square","star","text","triangle","triangleDown","hexagon"],shapeProperties:{borderDashes:!1,borderRadius:[6,0,20,1],interpolation:!0,useImageSize:!1},size:[25,0,200,1]},edges:{arrows:{to:{enabled:!1,scaleFactor:[1,0,3,.05],type:"arrow"},middle:{enabled:!1,scaleFactor:[1,0,3,.05],type:"arrow"},from:{enabled:!1,scaleFactor:[1,0,3,.05],type:"arrow"}},endPointOffset:{from:[0,-10,10,1],to:[0,-10,10,1]},arrowStrikethrough:!0,color:{color:["color","#848484"],highlight:["color","#848484"],hover:["color","#848484"],inherit:["from","to","both",!0,!1],opacity:[1,0,1,.05]},dashes:!1,font:{color:["color","#343434"],size:[14,0,100,1],face:["arial","verdana","tahoma"],background:["color","none"],strokeWidth:[2,0,50,1],strokeColor:["color","#ffffff"],align:["horizontal","top","middle","bottom"]},hidden:!1,hoverWidth:[1.5,0,5,.1],labelHighlightBold:!0,physics:!0,scaling:{min:[1,0,100,1],max:[15,0,100,1],label:{enabled:!0,min:[14,0,200,1],max:[30,0,200,1],maxVisible:[30,0,200,1],drawThreshold:[5,0,20,1]}},selectionWidth:[1.5,0,5,.1],selfReferenceSize:[20,0,200,1],selfReference:{size:[20,0,200,1],angle:[Math.PI/2,-6*Math.PI,6*Math.PI,Math.PI/8],renderBehindTheNode:!0},shadow:{enabled:!1,color:"rgba(0,0,0,0.5)",size:[10,0,20,1],x:[5,-30,30,1],y:[5,-30,30,1]},smooth:{enabled:!0,type:["dynamic","continuous","discrete","diagonalCross","straightCross","horizontal","vertical","curvedCW","curvedCCW","cubicBezier"],forceDirection:["horizontal","vertical","none"],roundness:[.5,0,1,.05]},width:[1,0,30,1]},layout:{hierarchical:{enabled:!1,levelSeparation:[150,20,500,5],nodeSpacing:[100,20,500,5],treeSpacing:[200,20,500,5],blockShifting:!0,edgeMinimization:!0,parentCentralization:!0,direction:["UD","DU","LR","RL"],sortMethod:["hubsize","directed"],shakeTowards:["leaves","roots"]}},interaction:{dragNodes:!0,dragView:!0,hideEdgesOnDrag:!1,hideEdgesOnZoom:!1,hideNodesOnDrag:!1,hover:!1,keyboard:{enabled:!1,speed:{x:[10,0,40,1],y:[10,0,40,1],zoom:[.02,0,.1,.005]},bindToWindow:!0,autoFocus:!0},multiselect:!1,navigationButtons:!1,selectable:!0,selectConnectedEdges:!0,hoverConnectedEdges:!0,tooltipDelay:[300,0,1e3,25],zoomView:!0,zoomSpeed:[1,.1,2,.1]},manipulation:{enabled:!1,initiallyActive:!1},physics:{enabled:!0,barnesHut:{theta:[.5,.1,1,.05],gravitationalConstant:[-2e3,-3e4,0,50],centralGravity:[.3,0,10,.05],springLength:[95,0,500,5],springConstant:[.04,0,1.2,.005],damping:[.09,0,1,.01],avoidOverlap:[0,0,1,.01]},forceAtlas2Based:{theta:[.5,.1,1,.05],gravitationalConstant:[-50,-500,0,1],centralGravity:[.01,0,1,.005],springLength:[95,0,500,5],springConstant:[.08,0,1.2,.005],damping:[.4,0,1,.01],avoidOverlap:[0,0,1,.01]},repulsion:{centralGravity:[.2,0,10,.05],springLength:[200,0,500,5],springConstant:[.05,0,1.2,.005],nodeDistance:[100,0,500,5],damping:[.09,0,1,.01]},hierarchicalRepulsion:{centralGravity:[.2,0,10,.05],springLength:[100,0,500,5],springConstant:[.01,0,1.2,.005],nodeDistance:[120,0,500,5],damping:[.09,0,1,.01],avoidOverlap:[0,0,1,.01]},maxVelocity:[50,0,150,1],minVelocity:[.1,.01,.5,.01],solver:["barnesHut","forceAtlas2Based","repulsion","hierarchicalRepulsion"],timestep:[.5,.01,1,.01],wind:{x:[0,-10,10,.1],y:[0,-10,10,.1]}}},Sa=(n,e,t)=>!!(n.includes("physics")&&cn.physics.solver.includes(e)&&t.physics.solver!==e&&e!=="wind");var un=class{constructor(){}getDistances(e,t,i){let s={},o=e.edges;for(let a=0;ao&&ar&&vthis.body.emitter.emit("_requestRedraw")),this.groups=new uo,this.canvas=new $o(this.body),this.selectionHandler=new sn(this.body,this.canvas),this.interactionHandler=new Jo(this.body,this.canvas,this.selectionHandler),this.view=new Zo(this.body,this.canvas),this.renderer=new Go(this.body,this.canvas),this.physics=new Uo(this.body),this.layoutEngine=new dn(this.body),this.clustering=new Xo(this.body),this.manipulation=new hn(this.body,this.canvas,this.selectionHandler,this.interactionHandler),this.nodesHandler=new ko(this.body,this.images,this.groups,this.layoutEngine),this.edgesHandler=new Lo(this.body,this.images,this.groups),this.body.modules.kamadaKawai=new fn(this.body,150,.05),this.body.modules.clustering=this.clustering,this.canvas._create(),this.setOptions(t),this.setData(e)}(0,Gs.default)(T.prototype);T.prototype.setOptions=function(n){if(n===null&&(n=void 0),n!==void 0){if(Vs.validate(n,Oa)===!0&&console.error("%cErrors have been found in the supplied options object.",yi),qe(["locale","locales","clickToUse"],this.options,n),n.locale!==void 0&&(n.locale=fa(n.locales||this.options.locales,n.locale)),n=this.layoutEngine.setOptions(n.layout,n),this.canvas.setOptions(n),this.groups.setOptions(n.groups),this.nodesHandler.setOptions(n.nodes),this.edgesHandler.setOptions(n.edges),this.physics.setOptions(n.physics),this.manipulation.setOptions(n.manipulation,n,this.options),this.interactionHandler.setOptions(n.interaction),this.renderer.setOptions(n.interaction),this.selectionHandler.setOptions(n.interaction),n.groups!==void 0&&this.body.emitter.emit("refreshNodes"),"configure"in n&&(this.configurator||(this.configurator=new js(this,this.body.container,cn,this.canvas.pixelRatio,Sa)),this.configurator.setOptions(n.configure)),this.configurator&&this.configurator.options.enabled===!0){let i={nodes:{},edges:{},layout:{},interaction:{},manipulation:{},physics:{},global:{}};D(i.nodes,this.nodesHandler.options),D(i.edges,this.edgesHandler.options),D(i.layout,this.layoutEngine.options),D(i.interaction,this.selectionHandler.options),D(i.interaction,this.renderer.options),D(i.interaction,this.interactionHandler.options),D(i.manipulation,this.manipulation.options),D(i.physics,this.physics.options),D(i.global,this.canvas.options),D(i.global,this.options),this.configurator.setModuleOptions(i)}n.clickToUse!==void 0?n.clickToUse===!0?this.activator===void 0&&(this.activator=new Hs(this.canvas.frame),this.activator.on("change",()=>{this.body.emitter.emit("activate")})):(this.activator!==void 0&&(this.activator.destroy(),delete this.activator),this.body.emitter.emit("activate")):this.body.emitter.emit("activate"),this.canvas.setSize(),this.body.emitter.emit("startSimulation")}};T.prototype._updateVisibleIndices=function(){let n=this.body.nodes,e=this.body.edges;this.body.nodeIndices=[],this.body.edgeIndices=[];for(let t in n)Object.prototype.hasOwnProperty.call(n,t)&&!this.clustering._isClusteredNode(t)&&n[t].options.hidden===!1&&this.body.nodeIndices.push(n[t].id);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let i=e[t],s=n[i.fromId],o=n[i.toId],r=s!==void 0&&o!==void 0;!this.clustering._isClusteredEdge(t)&&i.options.hidden===!1&&r&&s.options.hidden===!1&&o.options.hidden===!1&&this.body.edgeIndices.push(i.id)}};T.prototype.bindEventListeners=function(){this.body.emitter.on("_dataChanged",()=>{this.edgesHandler._updateState(),this.body.emitter.emit("_dataUpdated")}),this.body.emitter.on("_dataUpdated",()=>{this.clustering._updateState(),this._updateVisibleIndices(),this._updateValueRange(this.body.nodes),this._updateValueRange(this.body.edges),this.body.emitter.emit("startSimulation"),this.body.emitter.emit("_requestRedraw")})};T.prototype.setData=function(n){if(this.body.emitter.emit("resetPhysics"),this.body.emitter.emit("_resetData"),this.selectionHandler.unselectAll(),n&&n.dot&&(n.nodes||n.edges))throw new SyntaxError('Data must contain either parameter "dot" or parameter pair "nodes" and "edges", but not both.');if(this.setOptions(n&&n.options),n&&n.dot){console.warn("The dot property has been deprecated. Please use the static convertDot method to convert DOT into vis.network format and use the normal data format with nodes and edges. This converter is used like this: var data = vis.network.convertDot(dotString);");let e=Jr(n.dot);this.setData(e);return}else if(n&&n.gephi){console.warn("The gephi property has been deprecated. Please use the static convertGephi method to convert gephi into vis.network format and use the normal data format with nodes and edges. This converter is used like this: var data = vis.network.convertGephi(gephiJson);");let e=ea(n.gephi);this.setData(e);return}else this.nodesHandler.setData(n&&n.nodes,!0),this.edgesHandler.setData(n&&n.edges,!0);this.body.emitter.emit("_dataChanged"),this.body.emitter.emit("_dataLoaded"),this.body.emitter.emit("initPhysics")};T.prototype.destroy=function(){this.body.emitter.emit("destroy"),this.body.emitter.off(),this.off(),delete this.groups,delete this.canvas,delete this.selectionHandler,delete this.interactionHandler,delete this.view,delete this.renderer,delete this.physics,delete this.layoutEngine,delete this.clustering,delete this.manipulation,delete this.nodesHandler,delete this.edgesHandler,delete this.configurator,delete this.images;for(let n in this.body.nodes)!Object.prototype.hasOwnProperty.call(this.body.nodes,n)||delete this.body.nodes[n];for(let n in this.body.edges)!Object.prototype.hasOwnProperty.call(this.body.edges,n)||delete this.body.edges[n];ve(this.body.container)};T.prototype._updateValueRange=function(n){let e,t,i,s=0;for(e in n)if(Object.prototype.hasOwnProperty.call(n,e)){let o=n[e].getValue();o!==void 0&&(t=t===void 0?o:Math.min(o,t),i=i===void 0?o:Math.max(o,i),s+=o)}if(t!==void 0&&i!==void 0)for(e in n)Object.prototype.hasOwnProperty.call(n,e)&&n[e].setValueRange(t,i,s)};T.prototype.isActive=function(){return!this.activator||this.activator.active};T.prototype.setSize=function(){return this.canvas.setSize.apply(this.canvas,arguments)};T.prototype.canvasToDOM=function(){return this.canvas.canvasToDOM.apply(this.canvas,arguments)};T.prototype.DOMtoCanvas=function(){return this.canvas.DOMtoCanvas.apply(this.canvas,arguments)};T.prototype.findNode=function(){return this.clustering.findNode.apply(this.clustering,arguments)};T.prototype.isCluster=function(){return this.clustering.isCluster.apply(this.clustering,arguments)};T.prototype.openCluster=function(){return this.clustering.openCluster.apply(this.clustering,arguments)};T.prototype.cluster=function(){return this.clustering.cluster.apply(this.clustering,arguments)};T.prototype.getNodesInCluster=function(){return this.clustering.getNodesInCluster.apply(this.clustering,arguments)};T.prototype.clusterByConnection=function(){return this.clustering.clusterByConnection.apply(this.clustering,arguments)};T.prototype.clusterByHubsize=function(){return this.clustering.clusterByHubsize.apply(this.clustering,arguments)};T.prototype.updateClusteredNode=function(){return this.clustering.updateClusteredNode.apply(this.clustering,arguments)};T.prototype.getClusteredEdges=function(){return this.clustering.getClusteredEdges.apply(this.clustering,arguments)};T.prototype.getBaseEdge=function(){return this.clustering.getBaseEdge.apply(this.clustering,arguments)};T.prototype.getBaseEdges=function(){return this.clustering.getBaseEdges.apply(this.clustering,arguments)};T.prototype.updateEdge=function(){return this.clustering.updateEdge.apply(this.clustering,arguments)};T.prototype.clusterOutliers=function(){return this.clustering.clusterOutliers.apply(this.clustering,arguments)};T.prototype.getSeed=function(){return this.layoutEngine.getSeed.apply(this.layoutEngine,arguments)};T.prototype.enableEditMode=function(){return this.manipulation.enableEditMode.apply(this.manipulation,arguments)};T.prototype.disableEditMode=function(){return this.manipulation.disableEditMode.apply(this.manipulation,arguments)};T.prototype.addNodeMode=function(){return this.manipulation.addNodeMode.apply(this.manipulation,arguments)};T.prototype.editNode=function(){return this.manipulation.editNode.apply(this.manipulation,arguments)};T.prototype.editNodeMode=function(){return console.warn("Deprecated: Please use editNode instead of editNodeMode."),this.manipulation.editNode.apply(this.manipulation,arguments)};T.prototype.addEdgeMode=function(){return this.manipulation.addEdgeMode.apply(this.manipulation,arguments)};T.prototype.editEdgeMode=function(){return this.manipulation.editEdgeMode.apply(this.manipulation,arguments)};T.prototype.deleteSelected=function(){return this.manipulation.deleteSelected.apply(this.manipulation,arguments)};T.prototype.getPositions=function(){return this.nodesHandler.getPositions.apply(this.nodesHandler,arguments)};T.prototype.getPosition=function(){return this.nodesHandler.getPosition.apply(this.nodesHandler,arguments)};T.prototype.storePositions=function(){return this.nodesHandler.storePositions.apply(this.nodesHandler,arguments)};T.prototype.moveNode=function(){return this.nodesHandler.moveNode.apply(this.nodesHandler,arguments)};T.prototype.getBoundingBox=function(){return this.nodesHandler.getBoundingBox.apply(this.nodesHandler,arguments)};T.prototype.getConnectedNodes=function(n){return this.body.nodes[n]!==void 0?this.nodesHandler.getConnectedNodes.apply(this.nodesHandler,arguments):this.edgesHandler.getConnectedNodes.apply(this.edgesHandler,arguments)};T.prototype.getConnectedEdges=function(){return this.nodesHandler.getConnectedEdges.apply(this.nodesHandler,arguments)};T.prototype.startSimulation=function(){return this.physics.startSimulation.apply(this.physics,arguments)};T.prototype.stopSimulation=function(){return this.physics.stopSimulation.apply(this.physics,arguments)};T.prototype.stabilize=function(){return this.physics.stabilize.apply(this.physics,arguments)};T.prototype.getSelection=function(){return this.selectionHandler.getSelection.apply(this.selectionHandler,arguments)};T.prototype.setSelection=function(){return this.selectionHandler.setSelection.apply(this.selectionHandler,arguments)};T.prototype.getSelectedNodes=function(){return this.selectionHandler.getSelectedNodeIds.apply(this.selectionHandler,arguments)};T.prototype.getSelectedEdges=function(){return this.selectionHandler.getSelectedEdgeIds.apply(this.selectionHandler,arguments)};T.prototype.getNodeAt=function(){let n=this.selectionHandler.getNodeAt.apply(this.selectionHandler,arguments);return n!==void 0&&n.id!==void 0?n.id:n};T.prototype.getEdgeAt=function(){let n=this.selectionHandler.getEdgeAt.apply(this.selectionHandler,arguments);return n!==void 0&&n.id!==void 0?n.id:n};T.prototype.selectNodes=function(){return this.selectionHandler.selectNodes.apply(this.selectionHandler,arguments)};T.prototype.selectEdges=function(){return this.selectionHandler.selectEdges.apply(this.selectionHandler,arguments)};T.prototype.unselectAll=function(){this.selectionHandler.unselectAll.apply(this.selectionHandler,arguments),this.selectionHandler.commitWithoutEmitting.apply(this.selectionHandler),this.redraw()};T.prototype.redraw=function(){return this.renderer.redraw.apply(this.renderer,arguments)};T.prototype.getScale=function(){return this.view.getScale.apply(this.view,arguments)};T.prototype.getViewPosition=function(){return this.view.getViewPosition.apply(this.view,arguments)};T.prototype.fit=function(){return this.view.fit.apply(this.view,arguments)};T.prototype.moveTo=function(){return this.view.moveTo.apply(this.view,arguments)};T.prototype.focus=function(){return this.view.focus.apply(this.view,arguments)};T.prototype.releaseNode=function(){return this.view.releaseNode.apply(this.view,arguments)};T.prototype.getOptionsFromConfigurator=function(){let n={};return this.configurator&&(n=this.configurator.getOptions.apply(this.configurator)),n};var pn=n=>{if(!document.cookie)return;let e=null,t=document.cookie.split(";");for(let i=0;iBe(le({},p),{title:e(p.title)})));window.nodes=t;let i=new Ce(topologyData.edges.map(p=>Be(le({},p),{title:e(p.title)}))),s=topologyData.options.group_sites,o=topologyData.options.group_locations,r=topologyData.options.group_racks;de=new T(gn,{nodes:t,edges:i},Hi),de.fit(),de.on("dragEnd",p=>{mn!=null&&(!mn.checked||Promise.allSettled(Object.entries(de.getPositions(p.nodes)).map(C=>qi(this,[C],function*([b,_]){isNaN(parseInt(b))?nodeKey=b:nodeKey=parseInt(b);try{window.nodes.update({id:nodeKey,physics:!1,x:_.x,y:_.y})}catch(O){console.log(["Error while executing window.nodes.update()","nodeId: "+b,"nodeKey: "+nodeKey,"x: "+_.x,"y: "+_.y]),console.log(O)}let x=yield fetch("/"+basePath+"api/plugins/netbox_topology_views/save-coords/save_coords/",{method:"PATCH",headers:{"X-CSRFToken":Ia,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({node_id:b,x:_.x,y:_.y,group:topologyData.group})})}))))}),de.on("doubleClick",p=>{p.nodes.length>0?p.nodes.forEach(b=>{window.open(t.get(b).href,"_blank")}):p.edges.forEach(b=>{window.open(i.get(b).href,"_blank")})}),de.on("afterDrawing",p=>{d=[],s!=null&&s=="on"&&l(p,c,u),o!=null&&o=="on"&&l(p,f,y),r!=null&&r=="on"&&l(p,v,g)}),de.on("click",p=>{d.forEach(b=>{if(p.pointer.canvas.x>b.x1-b.border/2-1&&p.pointer.canvas.xb.y1-b.border/2-1&&p.pointer.canvas.yb.x2-b.border/2-1||p.pointer.canvas.yb.y2-b.border/2-1)){let _=[];b.category=="Site"&&c.forEach(C=>{C.forEach(x=>{x[1]==b.id&&_.push(x[0])})}),b.category=="Location"&&f.forEach(C=>{C.forEach(x=>{x[1]===b.id&&_.push(x[0])})}),b.category=="Rack"&&v.forEach(C=>{C.forEach(x=>{x[1]===b.id&&_.push(x[0])})}),de.selectNodes(_)}})});function a(p,b){let _=[];for(let[x,O]of t._data)O[p]!=null&&_.push([O.id,O[p],O[b]]);let C=_.reduce((x,O)=>{let M=O[1];return x[M]=x[M]||[],x[M].push(O),x},{});return Object.values(C)}var d=[];function h(p){p.ctx.beginPath(),p.ctx.lineWidth=p.lineWidth,p.ctx.strokeStyle=p.color,p.ctx.rect(p.x,p.y,p.width,p.height),p.ctx.stroke(),p.ctx.font=p.font,p.ctx.fillStyle=p.color,p.ctx.fillText(p.text,p.x+p.textPaddingX,p.y+p.textPaddingY),d.push({category:p.category,id:p.id,x1:p.x,y1:p.y,x2:p.x+p.width,y2:p.y+p.height,border:p.lineWidth})}function l(p,b,_){for(let C of Object.entries(b)){let x=[],O=[],M=[];for(let ge of C[1])O.push(de.getPosition(ge[0]).x),M.push(de.getPosition(ge[0]).y);let R=Math.min(...O)-_.paddingX,q=Math.min(...M)-_.paddingY,oe=Math.max(...O)-Math.min(...O)+2*_.paddingX,Oe=Math.max(...M)-Math.min(...M)+2*_.paddingY;x.push({ctx:p,x:R,y:q,width:oe,height:Oe,lineWidth:_.lineWidth,color:_.color,text:C[1][0][2],textPaddingX:_.textPaddingX,textPaddingY:_.textPaddingY,font:_.font,id:C[1][0][1],category:_.category}),x.forEach(function(ge){h(ge)})}}let c=a("site_id","site"),u={lineWidth:"5",color:"red",paddingX:84,paddingY:84,textPaddingX:8,textPaddingY:-8,font:"14px helvetica",category:"Site"},f=a("location_id","location"),y={lineWidth:"5",color:"#337ab7",paddingX:77,paddingY:77,textPaddingX:12,textPaddingY:22,font:"14px helvetica",category:"Location"},v=a("rack_id","rack"),g={lineWidth:"5",color:"green",paddingX:70,paddingY:70,textPaddingX:8,textPaddingY:30,font:"14px helvetica",category:"Rack"}})();var Pa="image/png",Ma=document.querySelector("#btnDownloadImage");Ma.addEventListener("click",n=>{Da()});function Da(){let n=gn.querySelector("canvas"),e=document.createElement("a"),t=n.toDataURL(Pa);e.href=t,e.download="topology",document.body.appendChild(e),e.click(),document.body.removeChild(e)}var Fa=document.querySelector("#btnDownloadXml");Fa.addEventListener("click",n=>{Na()});function Na(){let n=document.createElement("a"),e="";if(typeof is_htmx!="undefined"){var t=window.location.href;let o="/sites/",r="/locations/";if(t.includes(o)){var i=t.split(o)[1];i=i.split("/")[0],e="site_id="+i+"&show_cables=on&show_unconnected=on"}else if(t.includes(r)){var s=t.split(r)[1];s=s.split("/")[0],e="location_id="+s+"&show_cables=on&show_unconnected=on"}}else e=new URLSearchParams(window.location.search);fetch("/"+basePath+"api/plugins/netbox_topology_views/xml-export/?"+e).then(o=>o.text()).then(o=>{var r=new Blob([o],{type:"text/plain"});n.setAttribute("href",window.URL.createObjectURL(r)),n.setAttribute("download","topology.xml"),n.dataset.downloadurl=["text/plain",n.download,n.href].join(":"),n.click()})}var Ba=new MutationObserver(n=>n.forEach(e=>{if(!de||e.type!=="attributes"||e.attributeName!=="data-netbox-color-mode"||!(e.target instanceof HTMLElement))return;let{netboxColorMode:t}=e.target.dataset;Hi.nodes.font.color=t==="dark"?"#fff":"#000",de.setOptions(Hi)}));Ba.observe(document.documentElement,{attributes:!0,attributeFilter:["data-netbox-color-mode"]});})(); /*! Hammer.JS - v2.0.17-rc - 2019-12-16 * http://naver.github.io/egjs * diff --git a/netbox_topology_views/static_dev/js/home.js b/netbox_topology_views/static_dev/js/home.js index a75d0c0..59165d7 100644 --- a/netbox_topology_views/static_dev/js/home.js +++ b/netbox_topology_views/static_dev/js/home.js @@ -42,11 +42,6 @@ const csrftoken = getCookie('csrftoken') // Render vis graph let graph = null // vis graph instance -let searchParams = new URLSearchParams(window.location.search) -let group_sites = searchParams.get('group_sites') -let group_locations = searchParams.get('group_locations') -let group_racks = searchParams.get('group_racks') - const container = document.querySelector('#visgraph') const coordSaveCheckbox = document.querySelector('#id_save_coords') ;(function handleLoadData() { @@ -74,6 +69,11 @@ const coordSaveCheckbox = document.querySelector('#id_save_coords') title: htmlTitle(node.title) })) ) + + const group_sites = topologyData.options.group_sites + const group_locations = topologyData.options.group_locations + const group_racks = topologyData.options.group_racks + graph = new Network(container, { nodes, edges }, options) graph.fit() diff --git a/netbox_topology_views/utils.py b/netbox_topology_views/utils.py index 931cd1d..a23fbba 100644 --- a/netbox_topology_views/utils.py +++ b/netbox_topology_views/utils.py @@ -107,6 +107,10 @@ def get_model_role(model: Type[Model]) -> Role: ) def get_query_settings(request): + filter_id = '' + if "filter_id" in request.GET: + filter_id = request.GET["filter_id"] + save_coords = False if "save_coords" in request.GET: if request.GET["save_coords"] == "on": @@ -174,7 +178,7 @@ def get_query_settings(request): if request.GET["show_neighbors"] == "on" : show_neighbors = True - return save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks, show_neighbors + return filter_id, save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks, show_neighbors class LinePattern(): wireless = [2, 10, 2, 10] diff --git a/netbox_topology_views/views.py b/netbox_topology_views/views.py index 5281b18..ed1be4b 100644 --- a/netbox_topology_views/views.py +++ b/netbox_topology_views/views.py @@ -27,7 +27,7 @@ from django.http import HttpRequest, HttpResponseRedirect, QueryDict from django.shortcuts import render, get_object_or_404 from django.views.generic import View -from extras.models import Tag +from extras.models import Tag, SavedFilter from wireless.models import WirelessLink from netbox.views.generic import ( ObjectView, @@ -351,6 +351,7 @@ def get_topology_data( nodes_devices = {} edges = [] nodes = [] + options = {} edge_ids = 0 nodes_circuits: Dict[int, Circuit] = {} nodes_powerpanel: Dict[int, PowerPanel] = {} @@ -664,6 +665,13 @@ def get_topology_data( ) ) + if group_locations: + options['group_locations'] = 'on' + if group_racks: + options['group_racks'] = 'on' + if group_sites: + options['group_sites'] = 'on' + for qs_device in queryset: if qs_device.pk not in nodes_devices and show_unconnected: nodes_devices[qs_device.pk] = qs_device @@ -676,6 +684,7 @@ def get_topology_data( results["nodes"] = nodes results["edges"] = edges results["group"] = group_id + results["options"] = options return results @@ -701,8 +710,30 @@ def get(self, request): if request.GET: - save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks, show_neighbors = get_query_settings(request) + filter_id, save_coords, show_unconnected, show_power, show_circuit, show_logical_connections, show_single_cable_logical_conns, show_cables, show_wireless, group_sites, group_locations, group_racks, show_neighbors = get_query_settings(request) + # Read options from saved filters as NetBox does not handle custom plugin filters + if "filter_id" in request.GET and request.GET["filter_id"] != '': + try: + saved_filter = SavedFilter.objects.get(pk=filter_id) + saved_filter_params = getattr(saved_filter, 'parameters') + + if save_coords == False and 'save_coords' in saved_filter_params: save_coords = saved_filter_params['save_coords'] + if show_power == False and 'show_power' in saved_filter_params: show_power = saved_filter_params['show_power'] + if show_circuit == False and 'show_circuit' in saved_filter_params: show_circuit = saved_filter_params['show_circuit'] + if show_logical_connections == False and 'show_logical_connections' in saved_filter_params: show_logical_connections = saved_filter_params['show_logical_connections'] + if show_single_cable_logical_conns == False and 'show_single_cable_logical_conns' in saved_filter_params: show_single_cable_logical_conns = saved_filter_params['show_single_cable_logical_conns'] + if show_cables == False and 'show_cables' in saved_filter_params: show_cables = saved_filter_params['show_cables'] + if show_wireless == False and 'show_wireless' in saved_filter_params: show_wireless = saved_filter_params['show_wireless'] + if group_sites == False and 'group_sites' in saved_filter_params: group_sites = saved_filter_params['group_sites'] + if group_locations == False and 'group_locations' in saved_filter_params: group_locations = saved_filter_params['group_locations'] + if group_racks == False and 'group_racks' in saved_filter_params: group_racks = saved_filter_params['group_racks'] + if show_neighbors == False and 'show_neighbors' in saved_filter_params: show_neighbors = saved_filter_params['show_neighbors'] + except SavedFilter.DoesNotExist: # filter_id not found + pass + except Exception as inst: + print(type(inst)) + if "group" not in request.GET: group_id = "default" else: