diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 9c67c07..1207f7b 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -44,14 +44,11 @@ jobs: npm ci npm run build:release - # 2. Refresh the copies the docs site embeds. + # 2. Refresh the copy the docs site embeds. The worker is inlined into + # orb.min.js, so there are no separate worker chunks to copy. - name: Sync bundle into docs site run: | cp dist/browser/orb.min.js docs/site/public/orb.min.js - cp dist/browser/orb.worker.min.js docs/site/public/orb.worker.min.js - # The module worker loads this shared vendor chunk as a sibling; without - # it the worker fails silently and layout simulation never runs. - cp dist/browser/orb.worker.vendor.min.js docs/site/public/orb.worker.vendor.min.js # 3. Build the VitePress site. - name: Build docs diff --git a/docs/site/public/orb.min.js b/docs/site/public/orb.min.js index a5d3127..9e03f70 100644 --- a/docs/site/public/orb.min.js +++ b/docs/site/public/orb.min.js @@ -1,2 +1,2 @@ /*! For license information please see orb.min.js.LICENSE.txt */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Orb=e():t.Orb=e()}(self,()=>(()=>{var t={481(t,e){!function(t){"use strict";function e(t){var e,i,n,o;for(i=1,n=arguments.length;i0?Math.floor(t):Math.ceil(t)};function D(t,e,i){return t instanceof N?t:p(t)?new N(t[0],t[1]):null==t?t:"object"==typeof t&&"x"in t&&"y"in t?new N(t.x,t.y):new N(t,e,i)}function O(t,e){if(t)for(var i=e?[t,e]:t,n=0,o=i.length;n=this.min.x&&i.x<=this.max.x&&e.y>=this.min.y&&i.y<=this.max.y},intersects:function(t){t=R(t);var e=this.min,i=this.max,n=t.min,o=t.max,s=o.x>=e.x&&n.x<=i.x,r=o.y>=e.y&&n.y<=i.y;return s&&r},overlaps:function(t){t=R(t);var e=this.min,i=this.max,n=t.min,o=t.max,s=o.x>e.x&&n.xe.y&&n.y=n.lat&&i.lat<=o.lat&&e.lng>=n.lng&&i.lng<=o.lng},intersects:function(t){t=B(t);var e=this._southWest,i=this._northEast,n=t.getSouthWest(),o=t.getNorthEast(),s=o.lat>=e.lat&&n.lat<=i.lat,r=o.lng>=e.lng&&n.lng<=i.lng;return s&&r},overlaps:function(t){t=B(t);var e=this._southWest,i=this._northEast,n=t.getSouthWest(),o=t.getNorthEast(),s=o.lat>e.lat&&n.late.lng&&n.lng1,At=function(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassiveEventSupport",h,e),window.removeEventListener("testPassiveEventSupport",h,e)}catch(t){}return t}(),Mt=!!document.createElement("canvas").getContext,Lt=!(!document.createElementNS||!$("svg").createSVGRect),Nt=!!Lt&&((K=document.createElement("div")).innerHTML="","http://www.w3.org/2000/svg"===(K.firstChild&&K.firstChild.namespaceURI)),It=!Lt&&function(){try{var t=document.createElement("div");t.innerHTML='';var e=t.firstChild;return e.style.behavior="url(#default#VML)",e&&"object"==typeof e.adj}catch(t){return!1}}();function Dt(t){return navigator.userAgent.toLowerCase().indexOf(t)>=0}var Ot={ie:J,ielt9:tt,edge:et,webkit:it,android:nt,android23:ot,androidStock:rt,opera:at,chrome:ht,gecko:lt,safari:ut,phantom:dt,opera12:ct,win:_t,ie3d:ft,webkit3d:gt,gecko3d:pt,any3d:mt,mobile:vt,mobileWebkit:yt,mobileWebkit3d:xt,msPointer:bt,pointer:wt,touch:Et,touchNative:St,mobileOpera:Tt,mobileGecko:Pt,retina:Ct,passiveEvents:At,canvas:Mt,svg:Lt,vml:It,inlineSvg:Nt},Rt=Ot.msPointer?"MSPointerDown":"pointerdown",zt=Ot.msPointer?"MSPointerMove":"pointermove",Bt=Ot.msPointer?"MSPointerUp":"pointerup",kt=Ot.msPointer?"MSPointerCancel":"pointercancel",Ut={touchstart:Rt,touchmove:zt,touchend:Bt,touchcancel:kt},jt={touchstart:function(t,e){e.MSPOINTER_TYPE_TOUCH&&e.pointerType===e.MSPOINTER_TYPE_TOUCH&&Be(e),Xt(t,e)},touchmove:Xt,touchend:Xt,touchcancel:Xt},Zt={},Ft=!1;function Gt(t,e,i){return"touchstart"===e&&(Ft||(document.addEventListener(Rt,Wt,!0),document.addEventListener(zt,Ht,!0),document.addEventListener(Bt,Vt,!0),document.addEventListener(kt,Vt,!0),Ft=!0)),jt[e]?(i=jt[e].bind(this,i),t.addEventListener(Ut[e],i,!1),i):(console.warn("wrong event specified:",e),L.Util.falseFn)}function Wt(t){Zt[t.pointerId]=t}function Ht(t){Zt[t.pointerId]&&(Zt[t.pointerId]=t)}function Vt(t){delete Zt[t.pointerId]}function Xt(t,e){if(e.pointerType!==(e.MSPOINTER_TYPE_MOUSE||"mouse")){for(var i in e.touches=[],Zt)e.touches.push(Zt[i]);e.changedTouches=[e],t(e)}}var qt,$t,Yt,Kt,Qt,Jt=ge(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),te=ge(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),ee="webkitTransition"===te||"OTransition"===te?te+"End":"transitionend";function ie(t){return"string"==typeof t?document.getElementById(t):t}function ne(t,e){var i=t.style[e]||t.currentStyle&&t.currentStyle[e];if((!i||"auto"===i)&&document.defaultView){var n=document.defaultView.getComputedStyle(t,null);i=n?n[e]:null}return"auto"===i?null:i}function oe(t,e,i){var n=document.createElement(t);return n.className=e||"",i&&i.appendChild(n),n}function se(t){var e=t.parentNode;e&&e.removeChild(t)}function re(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function ae(t){var e=t.parentNode;e&&e.lastChild!==t&&e.appendChild(t)}function he(t){var e=t.parentNode;e&&e.firstChild!==t&&e.insertBefore(t,e.firstChild)}function le(t,e){if(void 0!==t.classList)return t.classList.contains(e);var i=_e(t);return i.length>0&&new RegExp("(^|\\s)"+e+"(\\s|$)").test(i)}function ue(t,e){if(void 0!==t.classList)for(var i=d(e),n=0,o=i.length;nthis.options.maxZoom)?this.setZoom(t):this},panInsideBounds:function(t,e){this._enforcingBounds=!0;var i=this.getCenter(),n=this._limitCenter(i,this._zoom,B(t));return i.equals(n)||this.panTo(n,e),this._enforcingBounds=!1,this},panInside:function(t,e){var i=D((e=e||{}).paddingTopLeft||e.padding||[0,0]),n=D(e.paddingBottomRight||e.padding||[0,0]),o=this.project(this.getCenter()),s=this.project(t),r=this.getPixelBounds(),a=R([r.min.add(i),r.max.subtract(n)]),h=a.getSize();if(!a.contains(s)){this._enforcingBounds=!0;var l=s.subtract(a.getCenter()),u=a.extend(s).getSize().subtract(h);o.x+=l.x<0?-u.x:u.x,o.y+=l.y<0?-u.y:u.y,this.panTo(this.unproject(o),e),this._enforcingBounds=!1}return this},invalidateSize:function(t){if(!this._loaded)return this;t=e({animate:!1,pan:!0},!0===t?{animate:!0}:t);var i=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var o=this.getSize(),s=i.divideBy(2).round(),r=o.divideBy(2).round(),a=s.subtract(r);return a.x||a.y?(t.animate&&t.pan?this.panBy(a):(t.pan&&this._rawPanBy(a),this.fire("move"),t.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(n(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:i,newSize:o})):this},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(t){if(t=this._locateOptions=e({timeout:1e4,watch:!1},t),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var i=n(this._handleGeolocationResponse,this),o=n(this._handleGeolocationError,this);return t.watch?this._locationWatchId=navigator.geolocation.watchPosition(i,o,t):navigator.geolocation.getCurrentPosition(i,o,t),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(t){if(this._container._leaflet_id){var e=t.code,i=t.message||(1===e?"permission denied":2===e?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:e,message:"Geolocation error: "+i+"."})}},_handleGeolocationResponse:function(t){if(this._container._leaflet_id){var e=new k(t.coords.latitude,t.coords.longitude),i=e.toBounds(2*t.coords.accuracy),n=this._locateOptions;if(n.setView){var o=this.getBoundsZoom(i);this.setView(e,n.maxZoom?Math.min(o,n.maxZoom):o)}var s={latlng:e,bounds:i,timestamp:t.timestamp};for(var r in t.coords)"number"==typeof t.coords[r]&&(s[r]=t.coords[r]);this.fire("locationfound",s)}},addHandler:function(t,e){if(!e)return this;var i=this[t]=new e(this);return this._handlers.push(i),this.options[t]&&i.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch(t){this._container._leaflet_id=void 0,this._containerId=void 0}var t;for(t in void 0!==this._locationWatchId&&this.stopLocate(),this._stop(),se(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(T(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload"),this._layers)this._layers[t].remove();for(t in this._panes)se(this._panes[t]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(t,e){var i=oe("div","leaflet-pane"+(t?" leaflet-"+t.replace("Pane","")+"-pane":""),e||this._mapPane);return t&&(this._panes[t]=i),i},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter:this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var t=this.getPixelBounds();return new z(this.unproject(t.getBottomLeft()),this.unproject(t.getTopRight()))},getMinZoom:function(){return void 0===this.options.minZoom?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return void 0===this.options.maxZoom?void 0===this._layersMaxZoom?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(t,e,i){t=B(t),i=D(i||[0,0]);var n=this.getZoom()||0,o=this.getMinZoom(),s=this.getMaxZoom(),r=t.getNorthWest(),a=t.getSouthEast(),h=this.getSize().subtract(i),l=R(this.project(a,n),this.project(r,n)).getSize(),u=Ot.any3d?this.options.zoomSnap:1,d=h.x/l.x,c=h.y/l.y,_=e?Math.max(d,c):Math.min(d,c);return n=this.getScaleZoom(_,n),u&&(n=Math.round(n/(u/100))*(u/100),n=e?Math.ceil(n/u)*u:Math.floor(n/u)*u),Math.max(o,Math.min(s,n))},getSize:function(){return this._size&&!this._sizeChanged||(this._size=new N(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(t,e){var i=this._getTopLeftPoint(t,e);return new O(i,i.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(t){return this.options.crs.getProjectedBounds(void 0===t?this.getZoom():t)},getPane:function(t){return"string"==typeof t?this._panes[t]:t},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(t,e){var i=this.options.crs;return e=void 0===e?this._zoom:e,i.scale(t)/i.scale(e)},getScaleZoom:function(t,e){var i=this.options.crs;e=void 0===e?this._zoom:e;var n=i.zoom(t*i.scale(e));return isNaN(n)?1/0:n},project:function(t,e){return e=void 0===e?this._zoom:e,this.options.crs.latLngToPoint(U(t),e)},unproject:function(t,e){return e=void 0===e?this._zoom:e,this.options.crs.pointToLatLng(D(t),e)},layerPointToLatLng:function(t){var e=D(t).add(this.getPixelOrigin());return this.unproject(e)},latLngToLayerPoint:function(t){return this.project(U(t))._round()._subtract(this.getPixelOrigin())},wrapLatLng:function(t){return this.options.crs.wrapLatLng(U(t))},wrapLatLngBounds:function(t){return this.options.crs.wrapLatLngBounds(B(t))},distance:function(t,e){return this.options.crs.distance(U(t),U(e))},containerPointToLayerPoint:function(t){return D(t).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(t){return D(t).add(this._getMapPanePos())},containerPointToLatLng:function(t){var e=this.containerPointToLayerPoint(D(t));return this.layerPointToLatLng(e)},latLngToContainerPoint:function(t){return this.layerPointToContainerPoint(this.latLngToLayerPoint(U(t)))},mouseEventToContainerPoint:function(t){return Ue(t,this._container)},mouseEventToLayerPoint:function(t){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(t))},mouseEventToLatLng:function(t){return this.layerPointToLatLng(this.mouseEventToLayerPoint(t))},_initContainer:function(t){var e=this._container=ie(t);if(!e)throw new Error("Map container not found.");if(e._leaflet_id)throw new Error("Map container is already initialized.");Ce(e,"scroll",this._onScroll,this),this._containerId=s(e)},_initLayout:function(){var t=this._container;this._fadeAnimated=this.options.fadeAnimation&&Ot.any3d,ue(t,"leaflet-container"+(Ot.touch?" leaflet-touch":"")+(Ot.retina?" leaflet-retina":"")+(Ot.ielt9?" leaflet-oldie":"")+(Ot.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var e=ne(t,"position");"absolute"!==e&&"relative"!==e&&"fixed"!==e&&(t.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var t=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),me(this._mapPane,new N(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(ue(t.markerPane,"leaflet-zoom-hide"),ue(t.shadowPane,"leaflet-zoom-hide"))},_resetView:function(t,e){me(this._mapPane,new N(0,0));var i=!this._loaded;this._loaded=!0,e=this._limitZoom(e),this.fire("viewprereset");var n=this._zoom!==e;this._moveStart(n,!1)._move(t,e)._moveEnd(n),this.fire("viewreset"),i&&this.fire("load")},_moveStart:function(t,e){return t&&this.fire("zoomstart"),e||this.fire("movestart"),this},_move:function(t,e,i,n){void 0===e&&(e=this._zoom);var o=this._zoom!==e;return this._zoom=e,this._lastCenter=t,this._pixelOrigin=this._getNewPixelOrigin(t),n?i&&i.pinch&&this.fire("zoom",i):((o||i&&i.pinch)&&this.fire("zoom",i),this.fire("move",i)),this},_moveEnd:function(t){return t&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return T(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(t){me(this._mapPane,this._getMapPanePos().subtract(t))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(t){this._targets={},this._targets[s(this._container)]=this;var e=t?Me:Ce;e(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&e(window,"resize",this._onResize,this),Ot.any3d&&this.options.transform3DLimit&&(t?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){T(this._resizeRequest),this._resizeRequest=E(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var t=this._getMapPanePos();Math.max(Math.abs(t.x),Math.abs(t.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(t,e){for(var i,n=[],o="mouseout"===e||"mouseover"===e,r=t.target||t.srcElement,a=!1;r;){if((i=this._targets[s(r)])&&("click"===e||"preclick"===e)&&this._draggableMoved(i)){a=!0;break}if(i&&i.listens(e,!0)){if(o&&!Fe(r,t))break;if(n.push(i),o)break}if(r===this._container)break;r=r.parentNode}return n.length||a||o||!this.listens(e,!0)||(n=[this]),n},_isClickDisabled:function(t){for(;t!==this._container;){if(t._leaflet_disable_click)return!0;t=t.parentNode}},_handleDOMEvent:function(t){var e=t.target||t.srcElement;if(!(!this._loaded||e._leaflet_disable_events||"click"===t.type&&this._isClickDisabled(e))){var i=t.type;"mousedown"===i&&we(e),this._fireDOMEvent(t,i)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(t,i,n){if("click"===t.type){var o=e({},t);o.type="preclick",this._fireDOMEvent(o,o.type,n)}var s=this._findEventTargets(t,i);if(n){for(var r=[],a=0;a0?Math.round(t-e)/2:Math.max(0,Math.ceil(t))-Math.max(0,Math.floor(e))},_limitZoom:function(t){var e=this.getMinZoom(),i=this.getMaxZoom(),n=Ot.any3d?this.options.zoomSnap:1;return n&&(t=Math.round(t/n)*n),Math.max(e,Math.min(i,t))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){de(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(t,e){var i=this._getCenterOffset(t)._trunc();return!(!0!==(e&&e.animate)&&!this.getSize().contains(i)||(this.panBy(i,e),0))},_createAnimProxy:function(){var t=this._proxy=oe("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(t),this.on("zoomanim",function(t){var e=Jt,i=this._proxy.style[e];pe(this._proxy,this.project(t.center,t.zoom),this.getZoomScale(t.zoom,1)),i===this._proxy.style[e]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){se(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var t=this.getCenter(),e=this.getZoom();pe(this._proxy,this.project(t,e),this.getZoomScale(e,1))},_catchTransitionEnd:function(t){this._animatingZoom&&t.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(t,e,i){if(this._animatingZoom)return!0;if(i=i||{},!this._zoomAnimated||!1===i.animate||this._nothingToAnimate()||Math.abs(e-this._zoom)>this.options.zoomAnimationThreshold)return!1;var n=this.getZoomScale(e),o=this._getCenterOffset(t)._divideBy(1-1/n);return!(!0!==i.animate&&!this.getSize().contains(o)||(E(function(){this._moveStart(!0,!1)._animateZoom(t,e,!0)},this),0))},_animateZoom:function(t,e,i,o){this._mapPane&&(i&&(this._animatingZoom=!0,this._animateToCenter=t,this._animateToZoom=e,ue(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:t,zoom:e,noUpdate:o}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(n(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&de(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire("zoom"),delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0))}});var Ve=C.extend({options:{position:"topright"},initialize:function(t){c(this,t)},getPosition:function(){return this.options.position},setPosition:function(t){var e=this._map;return e&&e.removeControl(this),this.options.position=t,e&&e.addControl(this),this},getContainer:function(){return this._container},addTo:function(t){this.remove(),this._map=t;var e=this._container=this.onAdd(t),i=this.getPosition(),n=t._controlCorners[i];return ue(e,"leaflet-control"),-1!==i.indexOf("bottom")?n.insertBefore(e,n.firstChild):n.appendChild(e),this._map.on("unload",this.remove,this),this},remove:function(){return this._map?(se(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this):this},_refocusOnMap:function(t){this._map&&t&&t.screenX>0&&t.screenY>0&&this._map.getContainer().focus()}}),Xe=function(t){return new Ve(t)};He.include({addControl:function(t){return t.addTo(this),this},removeControl:function(t){return t.remove(),this},_initControlPos:function(){var t=this._controlCorners={},e="leaflet-",i=this._controlContainer=oe("div",e+"control-container",this._container);function n(n,o){var s=e+n+" "+e+o;t[n+o]=oe("div",s,i)}n("top","left"),n("top","right"),n("bottom","left"),n("bottom","right")},_clearControlPos:function(){for(var t in this._controlCorners)se(this._controlCorners[t]);se(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var qe=Ve.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(t,e,i,n){return i1,this._baseLayersList.style.display=t?"":"none"),this._separator.style.display=e&&t?"":"none",this},_onLayerChange:function(t){this._handlingClick||this._update();var e=this._getLayer(s(t.target)),i=e.overlay?"add"===t.type?"overlayadd":"overlayremove":"add"===t.type?"baselayerchange":null;i&&this._map.fire(i,e)},_createRadioElement:function(t,e){var i='",n=document.createElement("div");return n.innerHTML=i,n.firstChild},_addItem:function(t){var e,i=document.createElement("label"),n=this._map.hasLayer(t.layer);t.overlay?((e=document.createElement("input")).type="checkbox",e.className="leaflet-control-layers-selector",e.defaultChecked=n):e=this._createRadioElement("leaflet-base-layers_"+s(this),n),this._layerControlInputs.push(e),e.layerId=s(t.layer),Ce(e,"click",this._onInputClick,this);var o=document.createElement("span");o.innerHTML=" "+t.name;var r=document.createElement("span");return i.appendChild(r),r.appendChild(e),r.appendChild(o),(t.overlay?this._overlaysList:this._baseLayersList).appendChild(i),this._checkDisabledLayers(),i},_onInputClick:function(){var t,e,i=this._layerControlInputs,n=[],o=[];this._handlingClick=!0;for(var s=i.length-1;s>=0;s--)t=i[s],e=this._getLayer(t.layerId).layer,t.checked?n.push(e):t.checked||o.push(e);for(s=0;s=0;o--)t=i[o],e=this._getLayer(t.layerId).layer,t.disabled=void 0!==e.options.minZoom&&ne.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this}}),$e=Ve.extend({options:{position:"topleft",zoomInText:'',zoomInTitle:"Zoom in",zoomOutText:'',zoomOutTitle:"Zoom out"},onAdd:function(t){var e="leaflet-control-zoom",i=oe("div",e+" leaflet-bar"),n=this.options;return this._zoomInButton=this._createButton(n.zoomInText,n.zoomInTitle,e+"-in",i,this._zoomIn),this._zoomOutButton=this._createButton(n.zoomOutText,n.zoomOutTitle,e+"-out",i,this._zoomOut),this._updateDisabled(),t.on("zoomend zoomlevelschange",this._updateDisabled,this),i},onRemove:function(t){t.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(t){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(t.shiftKey?3:1))},_createButton:function(t,e,i,n,o){var s=oe("a",i,n);return s.innerHTML=t,s.href="#",s.title=e,s.setAttribute("role","button"),s.setAttribute("aria-label",e),ze(s),Ce(s,"click",ke),Ce(s,"click",o,this),Ce(s,"click",this._refocusOnMap,this),s},_updateDisabled:function(){var t=this._map,e="leaflet-disabled";de(this._zoomInButton,e),de(this._zoomOutButton,e),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),(this._disabled||t._zoom===t.getMinZoom())&&(ue(this._zoomOutButton,e),this._zoomOutButton.setAttribute("aria-disabled","true")),(this._disabled||t._zoom===t.getMaxZoom())&&(ue(this._zoomInButton,e),this._zoomInButton.setAttribute("aria-disabled","true"))}});He.mergeOptions({zoomControl:!0}),He.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new $e,this.addControl(this.zoomControl))});var Ye=Ve.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(t){var e="leaflet-control-scale",i=oe("div",e),n=this.options;return this._addScales(n,e+"-line",i),t.on(n.updateWhenIdle?"moveend":"move",this._update,this),t.whenReady(this._update,this),i},onRemove:function(t){t.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(t,e,i){t.metric&&(this._mScale=oe("div",e,i)),t.imperial&&(this._iScale=oe("div",e,i))},_update:function(){var t=this._map,e=t.getSize().y/2,i=t.distance(t.containerPointToLatLng([0,e]),t.containerPointToLatLng([this.options.maxWidth,e]));this._updateScales(i)},_updateScales:function(t){this.options.metric&&t&&this._updateMetric(t),this.options.imperial&&t&&this._updateImperial(t)},_updateMetric:function(t){var e=this._getRoundNum(t),i=e<1e3?e+" m":e/1e3+" km";this._updateScale(this._mScale,i,e/t)},_updateImperial:function(t){var e,i,n,o=3.2808399*t;o>5280?(e=o/5280,i=this._getRoundNum(e),this._updateScale(this._iScale,i+" mi",i/e)):(n=this._getRoundNum(o),this._updateScale(this._iScale,n+" ft",n/o))},_updateScale:function(t,e,i){t.style.width=Math.round(this.options.maxWidth*i)+"px",t.innerHTML=e},_getRoundNum:function(t){var e=Math.pow(10,(Math.floor(t)+"").length-1),i=t/e;return e*(i>=10?10:i>=5?5:i>=3?3:i>=2?2:1)}}),Ke=Ve.extend({options:{position:"bottomright",prefix:''+(Ot.inlineSvg?' ':"")+"Leaflet"},initialize:function(t){c(this,t),this._attributions={}},onAdd:function(t){for(var e in t.attributionControl=this,this._container=oe("div","leaflet-control-attribution"),ze(this._container),t._layers)t._layers[e].getAttribution&&this.addAttribution(t._layers[e].getAttribution());return this._update(),t.on("layeradd",this._addAttribution,this),this._container},onRemove:function(t){t.off("layeradd",this._addAttribution,this)},_addAttribution:function(t){t.layer.getAttribution&&(this.addAttribution(t.layer.getAttribution()),t.layer.once("remove",function(){this.removeAttribution(t.layer.getAttribution())},this))},setPrefix:function(t){return this.options.prefix=t,this._update(),this},addAttribution:function(t){return t?(this._attributions[t]||(this._attributions[t]=0),this._attributions[t]++,this._update(),this):this},removeAttribution:function(t){return t?(this._attributions[t]&&(this._attributions[t]--,this._update()),this):this},_update:function(){if(this._map){var t=[];for(var e in this._attributions)this._attributions[e]&&t.push(e);var i=[];this.options.prefix&&i.push(this.options.prefix),t.length&&i.push(t.join(", ")),this._container.innerHTML=i.join(' ')}}});He.mergeOptions({attributionControl:!0}),He.addInitHook(function(){this.options.attributionControl&&(new Ke).addTo(this)});Ve.Layers=qe,Ve.Zoom=$e,Ve.Scale=Ye,Ve.Attribution=Ke,Xe.layers=function(t,e,i){return new qe(t,e,i)},Xe.zoom=function(t){return new $e(t)},Xe.scale=function(t){return new Ye(t)},Xe.attribution=function(t){return new Ke(t)};var Qe=C.extend({initialize:function(t){this._map=t},enable:function(){return this._enabled||(this._enabled=!0,this.addHooks()),this},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}});Qe.addTo=function(t,e){return t.addHandler(e,this),this};var Je,ti={Events:A},ei=Ot.touch?"touchstart mousedown":"mousedown",ii=M.extend({options:{clickTolerance:3},initialize:function(t,e,i,n){c(this,n),this._element=t,this._dragStartTarget=e||t,this._preventOutline=i},enable:function(){this._enabled||(Ce(this._dragStartTarget,ei,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(ii._dragging===this&&this.finishDrag(!0),Me(this._dragStartTarget,ei,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(t){if(this._enabled&&(this._moved=!1,!le(this._element,"leaflet-zoom-anim")))if(t.touches&&1!==t.touches.length)ii._dragging===this&&this.finishDrag();else if(!(ii._dragging||t.shiftKey||1!==t.which&&1!==t.button&&!t.touches||(ii._dragging=this,this._preventOutline&&we(this._element),xe(),qt(),this._moving))){this.fire("down");var e=t.touches?t.touches[0]:t,i=Ee(this._element);this._startPoint=new N(e.clientX,e.clientY),this._startPos=ve(this._element),this._parentScale=Te(i);var n="mousedown"===t.type;Ce(document,n?"mousemove":"touchmove",this._onMove,this),Ce(document,n?"mouseup":"touchend touchcancel",this._onUp,this)}},_onMove:function(t){if(this._enabled)if(t.touches&&t.touches.length>1)this._moved=!0;else{var e=t.touches&&1===t.touches.length?t.touches[0]:t,i=new N(e.clientX,e.clientY)._subtract(this._startPoint);(i.x||i.y)&&(Math.abs(i.x)+Math.abs(i.y)e&&(i.push(t[n]),o=n);return oh&&(s=r,h=a);h>i&&(e[s]=1,si(t,e,i,n,s),si(t,e,i,s,o))}function ri(t,e,i,n,o){var s,r,a,h=n?Je:hi(t,i),l=hi(e,i);for(Je=l;;){if(!(h|l))return[t,e];if(h&l)return!1;a=hi(r=ai(t,e,s=h||l,i,o),i),s===h?(t=r,h=a):(e=r,l=a)}}function ai(t,e,i,n,o){var s,r,a=e.x-t.x,h=e.y-t.y,l=n.min,u=n.max;return 8&i?(s=t.x+a*(u.y-t.y)/h,r=u.y):4&i?(s=t.x+a*(l.y-t.y)/h,r=l.y):2&i?(s=u.x,r=t.y+h*(u.x-t.x)/a):1&i&&(s=l.x,r=t.y+h*(l.x-t.x)/a),new N(s,r,o)}function hi(t,e){var i=0;return t.xe.max.x&&(i|=2),t.ye.max.y&&(i|=8),i}function li(t,e){var i=e.x-t.x,n=e.y-t.y;return i*i+n*n}function ui(t,e,i,n){var o,s=e.x,r=e.y,a=i.x-s,h=i.y-r,l=a*a+h*h;return l>0&&((o=((t.x-s)*a+(t.y-r)*h)/l)>1?(s=i.x,r=i.y):o>0&&(s+=a*o,r+=h*o)),a=t.x-s,h=t.y-r,n?a*a+h*h:new N(s,r)}function di(t){return!p(t[0])||"object"!=typeof t[0][0]&&void 0!==t[0][0]}function ci(t){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),di(t)}var _i={__proto__:null,simplify:ni,pointToSegmentDistance:oi,closestPointOnSegment:function(t,e,i){return ui(t,e,i)},clipSegment:ri,_getEdgeIntersection:ai,_getBitCode:hi,_sqClosestPointOnSegment:ui,isFlat:di,_flat:ci};function fi(t,e,i){var n,o,s,r,a,h,l,u,d,c=[1,4,2,8];for(o=0,l=t.length;o1e-7;h++)e=s*Math.sin(a),e=Math.pow((1-e)/(1+e),s/2),a+=l=Math.PI/2-2*Math.atan(r*e)-a;return new k(a*i,t.x*i/n)}},vi={__proto__:null,LonLat:pi,Mercator:mi,SphericalMercator:W},yi=e({},F,{code:"EPSG:3395",projection:mi,transformation:function(){var t=.5/(Math.PI*mi.R);return V(t,.5,-t,.5)}()}),xi=e({},F,{code:"EPSG:4326",projection:pi,transformation:V(1/180,1,-1/180,.5)}),bi=e({},Z,{projection:pi,transformation:V(1,0,-1,0),scale:function(t){return Math.pow(2,t)},zoom:function(t){return Math.log(t)/Math.LN2},distance:function(t,e){var i=e.lng-t.lng,n=e.lat-t.lat;return Math.sqrt(i*i+n*n)},infinite:!0});Z.Earth=F,Z.EPSG3395=yi,Z.EPSG3857=X,Z.EPSG900913=q,Z.EPSG4326=xi,Z.Simple=bi;var wi=M.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(t){return t.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(t){return t&&t.removeLayer(this),this},getPane:function(t){return this._map.getPane(t?this.options[t]||t:this.options.pane)},addInteractiveTarget:function(t){return this._map._targets[s(t)]=this,this},removeInteractiveTarget:function(t){return delete this._map._targets[s(t)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(t){var e=t.target;if(e.hasLayer(this)){if(this._map=e,this._zoomAnimated=e._zoomAnimated,this.getEvents){var i=this.getEvents();e.on(i,this),this.once("remove",function(){e.off(i,this)},this)}this.onAdd(e),this.fire("add"),e.fire("layeradd",{layer:this})}}});He.include({addLayer:function(t){if(!t._layerAdd)throw new Error("The provided object is not a Layer.");var e=s(t);return this._layers[e]||(this._layers[e]=t,t._mapToAdd=this,t.beforeAdd&&t.beforeAdd(this),this.whenReady(t._layerAdd,t)),this},removeLayer:function(t){var e=s(t);return this._layers[e]?(this._loaded&&t.onRemove(this),delete this._layers[e],this._loaded&&(this.fire("layerremove",{layer:t}),t.fire("remove")),t._map=t._mapToAdd=null,this):this},hasLayer:function(t){return s(t)in this._layers},eachLayer:function(t,e){for(var i in this._layers)t.call(e,this._layers[i]);return this},_addLayers:function(t){for(var e=0,i=(t=t?p(t)?t:[t]:[]).length;ethis._layersMaxZoom&&this.setZoom(this._layersMaxZoom),void 0===this.options.minZoom&&this._layersMinZoom&&this.getZoom()e)return r=(n-e)/i,this._map.layerPointToLatLng([s.x-r*(s.x-o.x),s.y-r*(s.y-o.y)])},getBounds:function(){return this._bounds},addLatLng:function(t,e){return e=e||this._defaultShape(),t=U(t),e.push(t),this._bounds.extend(t),this.redraw()},_setLatLngs:function(t){this._bounds=new z,this._latlngs=this._convertLatLngs(t)},_defaultShape:function(){return di(this._latlngs)?this._latlngs:this._latlngs[0]},_convertLatLngs:function(t){for(var e=[],i=di(t),n=0,o=t.length;n=2&&e[0]instanceof k&&e[0].equals(e[i-1])&&e.pop(),e},_setLatLngs:function(t){Ii.prototype._setLatLngs.call(this,t),di(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return di(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var t=this._renderer._bounds,e=this.options.weight,i=new N(e,e);if(t=new O(t.min.subtract(i),t.max.add(i)),this._parts=[],this._pxBounds&&this._pxBounds.intersects(t))if(this.options.noClip)this._parts=this._rings;else for(var n,o=0,s=this._rings.length;ot.y!=n.y>t.y&&t.x<(n.x-i.x)*(t.y-i.y)/(n.y-i.y)+i.x&&(l=!l);return l||Ii.prototype._containsPoint.call(this,t,!0)}});var Oi=Ei.extend({initialize:function(t,e){c(this,e),this._layers={},t&&this.addData(t)},addData:function(t){var e,i,n,o=p(t)?t:t.features;if(o){for(e=0,i=o.length;e0?o:[e.src]}else{p(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(e.style,"objectFit")&&(e.style.objectFit="fill"),e.autoplay=!!this.options.autoplay,e.loop=!!this.options.loop,e.muted=!!this.options.muted,e.playsInline=!!this.options.playsInline;for(var r=0;ro?(e.height=o+"px",ue(t,s)):de(t,s),this._containerWidth=this._container.offsetWidth},_animateZoom:function(t){var e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center),i=this._getAnchor();me(this._container,e.add(i))},_adjustPan:function(t){if(this.options.autoPan){this._map._panAnim&&this._map._panAnim.stop();var e=this._map,i=parseInt(ne(this._container,"marginBottom"),10)||0,n=this._container.offsetHeight+i,o=this._containerWidth,s=new N(this._containerLeft,-n-this._containerBottom);s._add(ve(this._container));var r=e.layerPointToContainerPoint(s),a=D(this.options.autoPanPadding),h=D(this.options.autoPanPaddingTopLeft||a),l=D(this.options.autoPanPaddingBottomRight||a),u=e.getSize(),d=0,c=0;r.x+o+l.x>u.x&&(d=r.x+o-u.x+l.x),r.x-d-h.x<0&&(d=r.x-h.x),r.y+n+l.y>u.y&&(c=r.y+n-u.y+l.y),r.y-c-h.y<0&&(c=r.y-h.y),(d||c)&&e.fire("autopanstart").panBy([d,c],{animate:t&&"moveend"===t.type})}},_getAnchor:function(){return D(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}});He.mergeOptions({closePopupOnClick:!0}),He.include({openPopup:function(t,e,i){return this._initOverlay(Yi,t,e,i).openOn(this),this},closePopup:function(t){return(t=arguments.length?t:this._popup)&&t.close(),this}}),wi.include({bindPopup:function(t,e){return this._popup=this._initOverlay(Yi,this._popup,t,e),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(t){return this._popup&&this._popup._prepareOpen(t)&&this._popup.openOn(this._map),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return!!this._popup&&this._popup.isOpen()},setPopupContent:function(t){return this._popup&&this._popup.setContent(t),this},getPopup:function(){return this._popup},_openPopup:function(t){if(this._popup&&this._map){ke(t);var e=t.layer||t.target;this._popup._source!==e||e instanceof Mi?(this._popup._source=e,this.openPopup(t.latlng)):this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(t.latlng)}},_movePopup:function(t){this._popup.setLatLng(t.latlng)},_onKeyPress:function(t){13===t.originalEvent.keyCode&&this._openPopup(t)}});var Ki=$i.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(t){$i.prototype.onAdd.call(this,t),this.setOpacity(this.options.opacity),t.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(t){$i.prototype.onRemove.call(this,t),t.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var t=$i.prototype.getEvents.call(this);return this.options.permanent||(t.preclick=this.close),t},_initLayout:function(){var t="leaflet-tooltip "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=oe("div",t)},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(t){var e,i,n=this._map,o=this._container,s=n.latLngToContainerPoint(n.getCenter()),r=n.layerPointToContainerPoint(t),a=this.options.direction,h=o.offsetWidth,l=o.offsetHeight,u=D(this.options.offset),d=this._getAnchor();"top"===a?(e=h/2,i=l):"bottom"===a?(e=h/2,i=0):"center"===a?(e=h/2,i=l/2):"right"===a?(e=0,i=l/2):"left"===a?(e=h,i=l/2):r.xthis.options.maxZoom||in&&this._retainParent(o,s,r,n))},_retainChildren:function(t,e,i,n){for(var o=2*t;o<2*t+2;o++)for(var s=2*e;s<2*e+2;s++){var r=new N(o,s);r.z=i+1;var a=this._tileCoordsToKey(r),h=this._tiles[a];h&&h.active?h.retain=!0:(h&&h.loaded&&(h.retain=!0),i+1this.options.maxZoom||void 0!==this.options.minZoom&&o1)this._setView(t,i);else{for(var d=o.min.y;d<=o.max.y;d++)for(var c=o.min.x;c<=o.max.x;c++){var _=new N(c,d);if(_.z=this._tileZoom,this._isValidTile(_)){var f=this._tiles[this._tileCoordsToKey(_)];f?f.current=!0:r.push(_)}}if(r.sort(function(t,e){return t.distanceTo(s)-e.distanceTo(s)}),0!==r.length){this._loading||(this._loading=!0,this.fire("loading"));var g=document.createDocumentFragment();for(c=0;ci.max.x)||!e.wrapLat&&(t.yi.max.y))return!1}if(!this.options.bounds)return!0;var n=this._tileCoordsToBounds(t);return B(this.options.bounds).overlaps(n)},_keyToBounds:function(t){return this._tileCoordsToBounds(this._keyToTileCoords(t))},_tileCoordsToNwSe:function(t){var e=this._map,i=this.getTileSize(),n=t.scaleBy(i),o=n.add(i);return[e.unproject(n,t.z),e.unproject(o,t.z)]},_tileCoordsToBounds:function(t){var e=this._tileCoordsToNwSe(t),i=new z(e[0],e[1]);return this.options.noWrap||(i=this._map.wrapLatLngBounds(i)),i},_tileCoordsToKey:function(t){return t.x+":"+t.y+":"+t.z},_keyToTileCoords:function(t){var e=t.split(":"),i=new N(+e[0],+e[1]);return i.z=+e[2],i},_removeTile:function(t){var e=this._tiles[t];e&&(se(e.el),delete this._tiles[t],this.fire("tileunload",{tile:e.el,coords:this._keyToTileCoords(t)}))},_initTile:function(t){ue(t,"leaflet-tile");var e=this.getTileSize();t.style.width=e.x+"px",t.style.height=e.y+"px",t.onselectstart=h,t.onmousemove=h,Ot.ielt9&&this.options.opacity<1&&fe(t,this.options.opacity)},_addTile:function(t,e){var i=this._getTilePos(t),o=this._tileCoordsToKey(t),s=this.createTile(this._wrapCoords(t),n(this._tileReady,this,t));this._initTile(s),this.createTile.length<2&&E(n(this._tileReady,this,t,null,s)),me(s,i),this._tiles[o]={el:s,coords:t,current:!0},e.appendChild(s),this.fire("tileloadstart",{tile:s,coords:t})},_tileReady:function(t,e,i){e&&this.fire("tileerror",{error:e,tile:i,coords:t});var o=this._tileCoordsToKey(t);(i=this._tiles[o])&&(i.loaded=+new Date,this._map._fadeAnimated?(fe(i.el,0),T(this._fadeFrame),this._fadeFrame=E(this._updateOpacity,this)):(i.active=!0,this._pruneTiles()),e||(ue(i.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:i.el,coords:t})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),Ot.ielt9||!this._map._fadeAnimated?E(this._pruneTiles,this):setTimeout(n(this._pruneTiles,this),250)))},_getTilePos:function(t){return t.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(t){var e=new N(this._wrapX?a(t.x,this._wrapX):t.x,this._wrapY?a(t.y,this._wrapY):t.y);return e.z=t.z,e},_pxBoundsToTileRange:function(t){var e=this.getTileSize();return new O(t.min.unscaleBy(e).floor(),t.max.unscaleBy(e).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var t in this._tiles)if(!this._tiles[t].loaded)return!1;return!0}});var tn=Ji.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(t,e){this._url=t,(e=c(this,e)).detectRetina&&Ot.retina&&e.maxZoom>0&&(e.tileSize=Math.floor(e.tileSize/2),e.zoomReverse?(e.zoomOffset--,e.minZoom++):(e.zoomOffset++,e.maxZoom--),e.minZoom=Math.max(0,e.minZoom)),"string"==typeof e.subdomains&&(e.subdomains=e.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(t,e){return this._url===t&&void 0===e&&(e=!0),this._url=t,e||this.redraw(),this},createTile:function(t,e){var i=document.createElement("img");return Ce(i,"load",n(this._tileOnLoad,this,e,i)),Ce(i,"error",n(this._tileOnError,this,e,i)),(this.options.crossOrigin||""===this.options.crossOrigin)&&(i.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),"string"==typeof this.options.referrerPolicy&&(i.referrerPolicy=this.options.referrerPolicy),i.alt="",i.setAttribute("role","presentation"),i.src=this.getTileUrl(t),i},getTileUrl:function(t){var i={r:Ot.retina?"@2x":"",s:this._getSubdomain(t),x:t.x,y:t.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var n=this._globalTileRange.max.y-t.y;this.options.tms&&(i.y=n),i["-y"]=n}return g(this._url,e(i,this.options))},_tileOnLoad:function(t,e){Ot.ielt9?setTimeout(n(t,this,null,e),0):t(null,e)},_tileOnError:function(t,e,i){var n=this.options.errorTileUrl;n&&e.getAttribute("src")!==n&&(e.src=n),t(i,e)},_onTileRemove:function(t){t.tile.onload=null},_getZoomForUrl:function(){var t=this._tileZoom,e=this.options.maxZoom;return this.options.zoomReverse&&(t=e-t),t+this.options.zoomOffset},_getSubdomain:function(t){var e=Math.abs(t.x+t.y)%this.options.subdomains.length;return this.options.subdomains[e]},_abortLoading:function(){var t,e;for(t in this._tiles)if(this._tiles[t].coords.z!==this._tileZoom&&((e=this._tiles[t].el).onload=h,e.onerror=h,!e.complete)){e.src=v;var i=this._tiles[t].coords;se(e),delete this._tiles[t],this.fire("tileabort",{tile:e,coords:i})}},_removeTile:function(t){var e=this._tiles[t];if(e)return e.el.setAttribute("src",v),Ji.prototype._removeTile.call(this,t)},_tileReady:function(t,e,i){if(this._map&&(!i||i.getAttribute("src")!==v))return Ji.prototype._tileReady.call(this,t,e,i)}});function en(t,e){return new tn(t,e)}var nn=tn.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(t,i){this._url=t;var n=e({},this.defaultWmsParams);for(var o in i)o in this.options||(n[o]=i[o]);var s=(i=c(this,i)).detectRetina&&Ot.retina?2:1,r=this.getTileSize();n.width=r.x*s,n.height=r.y*s,this.wmsParams=n},onAdd:function(t){this._crs=this.options.crs||t.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var e=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[e]=this._crs.code,tn.prototype.onAdd.call(this,t)},getTileUrl:function(t){var e=this._tileCoordsToNwSe(t),i=this._crs,n=R(i.project(e[0]),i.project(e[1])),o=n.min,s=n.max,r=(this._wmsVersion>=1.3&&this._crs===xi?[o.y,o.x,s.y,s.x]:[o.x,o.y,s.x,s.y]).join(","),a=tn.prototype.getTileUrl.call(this,t);return a+_(this.wmsParams,a,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+r},setParams:function(t,i){return e(this.wmsParams,t),i||this.redraw(),this}});tn.WMS=nn,en.wms=function(t,e){return new nn(t,e)};var on=wi.extend({options:{padding:.1},initialize:function(t){c(this,t),s(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),this._zoomAnimated&&ue(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var t={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(t.zoomanim=this._onAnimZoom),t},_onAnimZoom:function(t){this._updateTransform(t.center,t.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(t,e){var i=this._map.getZoomScale(e,this._zoom),n=this._map.getSize().multiplyBy(.5+this.options.padding),o=this._map.project(this._center,e),s=n.multiplyBy(-i).add(o).subtract(this._map._getNewPixelOrigin(t,e));Ot.any3d?pe(this._container,s,i):me(this._container,s)},_reset:function(){for(var t in this._update(),this._updateTransform(this._center,this._zoom),this._layers)this._layers[t]._reset()},_onZoomEnd:function(){for(var t in this._layers)this._layers[t]._project()},_updatePaths:function(){for(var t in this._layers)this._layers[t]._update()},_update:function(){var t=this.options.padding,e=this._map.getSize(),i=this._map.containerPointToLayerPoint(e.multiplyBy(-t)).round();this._bounds=new O(i,i.add(e.multiplyBy(1+2*t)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),sn=on.extend({options:{tolerance:0},getEvents:function(){var t=on.prototype.getEvents.call(this);return t.viewprereset=this._onViewPreReset,t},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){on.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var t=this._container=document.createElement("canvas");Ce(t,"mousemove",this._onMouseMove,this),Ce(t,"click dblclick mousedown mouseup contextmenu",this._onClick,this),Ce(t,"mouseout",this._handleMouseOut,this),t._leaflet_disable_events=!0,this._ctx=t.getContext("2d")},_destroyContainer:function(){T(this._redrawRequest),delete this._ctx,se(this._container),Me(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){for(var t in this._redrawBounds=null,this._layers)this._layers[t]._update();this._redraw()}},_update:function(){if(!this._map._animatingZoom||!this._bounds){on.prototype._update.call(this);var t=this._bounds,e=this._container,i=t.getSize(),n=Ot.retina?2:1;me(e,t.min),e.width=n*i.x,e.height=n*i.y,e.style.width=i.x+"px",e.style.height=i.y+"px",Ot.retina&&this._ctx.scale(2,2),this._ctx.translate(-t.min.x,-t.min.y),this.fire("update")}},_reset:function(){on.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(t){this._updateDashArray(t),this._layers[s(t)]=t;var e=t._order={layer:t,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=e),this._drawLast=e,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(t){this._requestRedraw(t)},_removePath:function(t){var e=t._order,i=e.next,n=e.prev;i?i.prev=n:this._drawLast=n,n?n.next=i:this._drawFirst=i,delete t._order,delete this._layers[s(t)],this._requestRedraw(t)},_updatePath:function(t){this._extendRedrawBounds(t),t._project(),t._update(),this._requestRedraw(t)},_updateStyle:function(t){this._updateDashArray(t),this._requestRedraw(t)},_updateDashArray:function(t){if("string"==typeof t.options.dashArray){var e,i,n=t.options.dashArray.split(/[, ]+/),o=[];for(i=0;i')}}catch(t){}return function(t){return document.createElement("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}(),hn={_initContainer:function(){this._container=oe("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(on.prototype._update.call(this),this.fire("update"))},_initPath:function(t){var e=t._container=an("shape");ue(e,"leaflet-vml-shape "+(this.options.className||"")),e.coordsize="1 1",t._path=an("path"),e.appendChild(t._path),this._updateStyle(t),this._layers[s(t)]=t},_addPath:function(t){var e=t._container;this._container.appendChild(e),t.options.interactive&&t.addInteractiveTarget(e)},_removePath:function(t){var e=t._container;se(e),t.removeInteractiveTarget(e),delete this._layers[s(t)]},_updateStyle:function(t){var e=t._stroke,i=t._fill,n=t.options,o=t._container;o.stroked=!!n.stroke,o.filled=!!n.fill,n.stroke?(e||(e=t._stroke=an("stroke")),o.appendChild(e),e.weight=n.weight+"px",e.color=n.color,e.opacity=n.opacity,n.dashArray?e.dashStyle=p(n.dashArray)?n.dashArray.join(" "):n.dashArray.replace(/( *, *)/g," "):e.dashStyle="",e.endcap=n.lineCap.replace("butt","flat"),e.joinstyle=n.lineJoin):e&&(o.removeChild(e),t._stroke=null),n.fill?(i||(i=t._fill=an("fill")),o.appendChild(i),i.color=n.fillColor||n.color,i.opacity=n.fillOpacity):i&&(o.removeChild(i),t._fill=null)},_updateCircle:function(t){var e=t._point.round(),i=Math.round(t._radius),n=Math.round(t._radiusY||i);this._setPath(t,t._empty()?"M0 0":"AL "+e.x+","+e.y+" "+i+","+n+" 0,23592600")},_setPath:function(t,e){t._path.v=e},_bringToFront:function(t){ae(t._container)},_bringToBack:function(t){he(t._container)}},ln=Ot.vml?an:$,un=on.extend({_initContainer:function(){this._container=ln("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=ln("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){se(this._container),Me(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!this._map._animatingZoom||!this._bounds){on.prototype._update.call(this);var t=this._bounds,e=t.getSize(),i=this._container;this._svgSize&&this._svgSize.equals(e)||(this._svgSize=e,i.setAttribute("width",e.x),i.setAttribute("height",e.y)),me(i,t.min),i.setAttribute("viewBox",[t.min.x,t.min.y,e.x,e.y].join(" ")),this.fire("update")}},_initPath:function(t){var e=t._path=ln("path");t.options.className&&ue(e,t.options.className),t.options.interactive&&ue(e,"leaflet-interactive"),this._updateStyle(t),this._layers[s(t)]=t},_addPath:function(t){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(t._path),t.addInteractiveTarget(t._path)},_removePath:function(t){se(t._path),t.removeInteractiveTarget(t._path),delete this._layers[s(t)]},_updatePath:function(t){t._project(),t._update()},_updateStyle:function(t){var e=t._path,i=t.options;e&&(i.stroke?(e.setAttribute("stroke",i.color),e.setAttribute("stroke-opacity",i.opacity),e.setAttribute("stroke-width",i.weight),e.setAttribute("stroke-linecap",i.lineCap),e.setAttribute("stroke-linejoin",i.lineJoin),i.dashArray?e.setAttribute("stroke-dasharray",i.dashArray):e.removeAttribute("stroke-dasharray"),i.dashOffset?e.setAttribute("stroke-dashoffset",i.dashOffset):e.removeAttribute("stroke-dashoffset")):e.setAttribute("stroke","none"),i.fill?(e.setAttribute("fill",i.fillColor||i.color),e.setAttribute("fill-opacity",i.fillOpacity),e.setAttribute("fill-rule",i.fillRule||"evenodd")):e.setAttribute("fill","none"))},_updatePoly:function(t,e){this._setPath(t,Y(t._parts,e))},_updateCircle:function(t){var e=t._point,i=Math.max(Math.round(t._radius),1),n="a"+i+","+(Math.max(Math.round(t._radiusY),1)||i)+" 0 1,0 ",o=t._empty()?"M0 0":"M"+(e.x-i)+","+e.y+n+2*i+",0 "+n+2*-i+",0 ";this._setPath(t,o)},_setPath:function(t,e){t._path.setAttribute("d",e)},_bringToFront:function(t){ae(t._path)},_bringToBack:function(t){he(t._path)}});function dn(t){return Ot.svg||Ot.vml?new un(t):null}Ot.vml&&un.include(hn),He.include({getRenderer:function(t){var e=t.options.renderer||this._getPaneRenderer(t.options.pane)||this.options.renderer||this._renderer;return e||(e=this._renderer=this._createRenderer()),this.hasLayer(e)||this.addLayer(e),e},_getPaneRenderer:function(t){if("overlayPane"===t||void 0===t)return!1;var e=this._paneRenderers[t];return void 0===e&&(e=this._createRenderer({pane:t}),this._paneRenderers[t]=e),e},_createRenderer:function(t){return this.options.preferCanvas&&rn(t)||dn(t)}});var cn=Di.extend({initialize:function(t,e){Di.prototype.initialize.call(this,this._boundsToLatLngs(t),e)},setBounds:function(t){return this.setLatLngs(this._boundsToLatLngs(t))},_boundsToLatLngs:function(t){return[(t=B(t)).getSouthWest(),t.getNorthWest(),t.getNorthEast(),t.getSouthEast()]}});un.create=ln,un.pointsToPath=Y,Oi.geometryToLayer=Ri,Oi.coordsToLatLng=Bi,Oi.coordsToLatLngs=ki,Oi.latLngToCoords=Ui,Oi.latLngsToCoords=ji,Oi.getFeature=Zi,Oi.asFeature=Fi,He.mergeOptions({boxZoom:!0});var _n=Qe.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane,this._resetStateTimeout=0,t.on("unload",this._destroy,this)},addHooks:function(){Ce(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){Me(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){se(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){0!==this._resetStateTimeout&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(t){if(!t.shiftKey||1!==t.which&&1!==t.button)return!1;this._clearDeferredResetState(),this._resetState(),qt(),xe(),this._startPoint=this._map.mouseEventToContainerPoint(t),Ce(document,{contextmenu:ke,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(t){this._moved||(this._moved=!0,this._box=oe("div","leaflet-zoom-box",this._container),ue(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(t);var e=new O(this._point,this._startPoint),i=e.getSize();me(this._box,e.min),this._box.style.width=i.x+"px",this._box.style.height=i.y+"px"},_finish:function(){this._moved&&(se(this._box),de(this._container,"leaflet-crosshair")),$t(),be(),Me(document,{contextmenu:ke,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(t){if((1===t.which||1===t.button)&&(this._finish(),this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(n(this._resetState,this),0);var e=new z(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(e).fire("boxzoomend",{boxZoomBounds:e})}},_onKeyDown:function(t){27===t.keyCode&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});He.addInitHook("addHandler","boxZoom",_n),He.mergeOptions({doubleClickZoom:!0});var fn=Qe.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(t){var e=this._map,i=e.getZoom(),n=e.options.zoomDelta,o=t.originalEvent.shiftKey?i-n:i+n;"center"===e.options.doubleClickZoom?e.setZoom(o):e.setZoomAround(t.containerPoint,o)}});He.addInitHook("addHandler","doubleClickZoom",fn),He.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var gn=Qe.extend({addHooks:function(){if(!this._draggable){var t=this._map;this._draggable=new ii(t._mapPane,t._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),t.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),t.on("zoomend",this._onZoomEnd,this),t.whenReady(this._onZoomEnd,this))}ue(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){de(this._map._container,"leaflet-grab"),de(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var t=this._map;if(t._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var e=B(this._map.options.maxBounds);this._offsetLimit=R(this._map.latLngToContainerPoint(e.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(e.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;t.fire("movestart").fire("dragstart"),t.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(t){if(this._map.options.inertia){var e=this._lastTime=+new Date,i=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(i),this._times.push(e),this._prunePositions(e)}this._map.fire("move",t).fire("drag",t)},_prunePositions:function(t){for(;this._positions.length>1&&t-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var t=this._map.getSize().divideBy(2),e=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=e.subtract(t).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(t,e){return t-(t-e)*this._viscosity},_onPreDragLimit:function(){if(this._viscosity&&this._offsetLimit){var t=this._draggable._newPos.subtract(this._draggable._startPos),e=this._offsetLimit;t.xe.max.x&&(t.x=this._viscousLimit(t.x,e.max.x)),t.y>e.max.y&&(t.y=this._viscousLimit(t.y,e.max.y)),this._draggable._newPos=this._draggable._startPos.add(t)}},_onPreDragWrap:function(){var t=this._worldWidth,e=Math.round(t/2),i=this._initialWorldOffset,n=this._draggable._newPos.x,o=(n-e+i)%t+e-i,s=(n+e+i)%t-e-i,r=Math.abs(o+i)0?s:-s))-e;this._delta=0,this._startTime=null,r&&("center"===t.options.scrollWheelZoom?t.setZoom(e+r):t.setZoomAround(this._lastMousePos,e+r))}});He.addInitHook("addHandler","scrollWheelZoom",mn);He.mergeOptions({tapHold:Ot.touchNative&&Ot.safari&&Ot.mobile,tapTolerance:15});var vn=Qe.extend({addHooks:function(){Ce(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){Me(this._map._container,"touchstart",this._onDown,this)},_onDown:function(t){if(clearTimeout(this._holdTimeout),1===t.touches.length){var e=t.touches[0];this._startPos=this._newPos=new N(e.clientX,e.clientY),this._holdTimeout=setTimeout(n(function(){this._cancel(),this._isTapValid()&&(Ce(document,"touchend",Be),Ce(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",e))},this),600),Ce(document,"touchend touchcancel contextmenu",this._cancel,this),Ce(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function t(){Me(document,"touchend",Be),Me(document,"touchend touchcancel",t)},_cancel:function(){clearTimeout(this._holdTimeout),Me(document,"touchend touchcancel contextmenu",this._cancel,this),Me(document,"touchmove",this._onMove,this)},_onMove:function(t){var e=t.touches[0];this._newPos=new N(e.clientX,e.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(t,e){var i=new MouseEvent(t,{bubbles:!0,cancelable:!0,view:window,screenX:e.screenX,screenY:e.screenY,clientX:e.clientX,clientY:e.clientY});i._simulated=!0,e.target.dispatchEvent(i)}});He.addInitHook("addHandler","tapHold",vn),He.mergeOptions({touchZoom:Ot.touch,bounceAtZoomLimits:!0});var yn=Qe.extend({addHooks:function(){ue(this._map._container,"leaflet-touch-zoom"),Ce(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){de(this._map._container,"leaflet-touch-zoom"),Me(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(t){var e=this._map;if(t.touches&&2===t.touches.length&&!e._animatingZoom&&!this._zooming){var i=e.mouseEventToContainerPoint(t.touches[0]),n=e.mouseEventToContainerPoint(t.touches[1]);this._centerPoint=e.getSize()._divideBy(2),this._startLatLng=e.containerPointToLatLng(this._centerPoint),"center"!==e.options.touchZoom&&(this._pinchStartLatLng=e.containerPointToLatLng(i.add(n)._divideBy(2))),this._startDist=i.distanceTo(n),this._startZoom=e.getZoom(),this._moved=!1,this._zooming=!0,e._stop(),Ce(document,"touchmove",this._onTouchMove,this),Ce(document,"touchend touchcancel",this._onTouchEnd,this),Be(t)}},_onTouchMove:function(t){if(t.touches&&2===t.touches.length&&this._zooming){var e=this._map,i=e.mouseEventToContainerPoint(t.touches[0]),o=e.mouseEventToContainerPoint(t.touches[1]),s=i.distanceTo(o)/this._startDist;if(this._zoom=e.getScaleZoom(s,this._startZoom),!e.options.bounceAtZoomLimits&&(this._zoome.getMaxZoom()&&s>1)&&(this._zoom=e._limitZoom(this._zoom)),"center"===e.options.touchZoom){if(this._center=this._startLatLng,1===s)return}else{var r=i._add(o)._divideBy(2)._subtract(this._centerPoint);if(1===s&&0===r.x&&0===r.y)return;this._center=e.unproject(e.project(this._pinchStartLatLng,this._zoom).subtract(r),this._zoom)}this._moved||(e._moveStart(!0,!1),this._moved=!0),T(this._animRequest);var a=n(e._move,e,this._center,this._zoom,{pinch:!0,round:!1});this._animRequest=E(a,this,!0),Be(t)}},_onTouchEnd:function(){this._moved&&this._zooming?(this._zooming=!1,T(this._animRequest),Me(document,"touchmove",this._onTouchMove,this),Me(document,"touchend touchcancel",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))):this._zooming=!1}});He.addInitHook("addHandler","touchZoom",yn),He.BoxZoom=_n,He.DoubleClickZoom=fn,He.Drag=gn,He.Keyboard=pn,He.ScrollWheelZoom=mn,He.TapHold=vn,He.TouchZoom=yn,t.Bounds=O,t.Browser=Ot,t.CRS=Z,t.Canvas=sn,t.Circle=Ni,t.CircleMarker=Li,t.Class=C,t.Control=Ve,t.DivIcon=Qi,t.DivOverlay=$i,t.DomEvent=Ge,t.DomUtil=Pe,t.Draggable=ii,t.Evented=M,t.FeatureGroup=Ei,t.GeoJSON=Oi,t.GridLayer=Ji,t.Handler=Qe,t.Icon=Ti,t.ImageOverlay=Vi,t.LatLng=k,t.LatLngBounds=z,t.Layer=wi,t.LayerGroup=Si,t.LineUtil=_i,t.Map=He,t.Marker=Ai,t.Mixin=ti,t.Path=Mi,t.Point=N,t.PolyUtil=gi,t.Polygon=Di,t.Polyline=Ii,t.Popup=Yi,t.PosAnimation=We,t.Projection=vi,t.Rectangle=cn,t.Renderer=on,t.SVG=un,t.SVGOverlay=qi,t.TileLayer=tn,t.Tooltip=Ki,t.Transformation=H,t.Util=P,t.VideoOverlay=Xi,t.bind=n,t.bounds=R,t.canvas=rn,t.circle=function(t,e,i){return new Ni(t,e,i)},t.circleMarker=function(t,e){return new Li(t,e)},t.control=Xe,t.divIcon=function(t){return new Qi(t)},t.extend=e,t.featureGroup=function(t,e){return new Ei(t,e)},t.geoJSON=Wi,t.geoJson=Hi,t.gridLayer=function(t){return new Ji(t)},t.icon=function(t){return new Ti(t)},t.imageOverlay=function(t,e,i){return new Vi(t,e,i)},t.latLng=U,t.latLngBounds=B,t.layerGroup=function(t,e){return new Si(t,e)},t.map=function(t,e){return new He(t,e)},t.marker=function(t,e){return new Ai(t,e)},t.point=D,t.polygon=function(t,e){return new Di(t,e)},t.polyline=function(t,e){return new Ii(t,e)},t.popup=function(t,e){return new Yi(t,e)},t.rectangle=function(t,e){return new cn(t,e)},t.setOptions=c,t.stamp=s,t.svg=dn,t.svgOverlay=function(t,e,i){return new qi(t,e,i)},t.tileLayer=en,t.tooltip=function(t,e){return new Ki(t,e)},t.transformation=V,t.version="1.8.0",t.videoOverlay=function(t,e,i){return new Xi(t,e,i)};var xn=window.L;t.noConflict=function(){return window.L=xn,this},window.L=t}(e)}},e={};function i(n){var o=e[n];if(void 0!==o)return o.exports;var s=e[n]={exports:{}};return t[n].call(s.exports,s,s.exports,i),s.exports}i.m=t,i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.u=t=>{if(89===t)return"orb.worker.min.js"},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t;i.g.importScripts&&(t=i.g.location+"");var e=i.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var n=e.getElementsByTagName("script");if(n.length)for(var o=n.length-1;o>-1&&(!t||!/^http(s?):/.test(t));)t=n[o--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i.p=t})(),i.b="undefined"!=typeof document&&document.baseURI||self.location.href;var n={};return(()=>{"use strict";i.r(n),i.d(n,{Color:()=>U,EdgeLineStyleType:()=>M,EdgeType:()=>L,GraphObjectState:()=>r,NodeShapeType:()=>w,OrbError:()=>s,OrbEventType:()=>e,OrbMapView:()=>ar,OrbView:()=>sr,RendererType:()=>zo,getDefaultGraphStyle:()=>H,graphToSVG:()=>Ys,isEdge:()=>I,isNode:()=>E});class t{constructor(){this._listeners=new Map}once(t,e){const i={callable:e,isOnce:!0},n=this._listeners.get(t);return n?n.push(i):this._listeners.set(t,[i]),this}on(t,e){const i={callable:e},n=this._listeners.get(t);return n?n.push(i):this._listeners.set(t,[i]),this}off(t,e){const i=this._listeners.get(t);if(i){const n=i.filter(t=>t.callable!==e);this._listeners.set(t,n)}return this}emit(t,e){const i=this._listeners.get(t);if(!i||0===i.length)return!1;let n=!1;for(let t=0;t!t.isOnce);this._listeners.set(t,e)}return!0}eventNames(){return[...this._listeners.keys()]}listenerCount(t){const e=this._listeners.get(t);return e?e.length:0}listeners(t){const e=this._listeners.get(t);return e?e.map(t=>t.callable):[]}addListener(t,e){return this.on(t,e)}removeListener(t,e){return this.off(t,e)}removeAllListeners(t){return t?this._listeners.delete(t):this._listeners.clear(),this}}var e;!function(t){t.RENDER_START="render-start",t.RENDER_END="render-end",t.SIMULATION_START="simulation-start",t.SIMULATION_STEP="simulation-step",t.SIMULATION_END="simulation-end",t.NODE_CLICK="node-click",t.NODE_HOVER="node-hover",t.EDGE_CLICK="edge-click",t.EDGE_HOVER="edge-hover",t.MOUSE_CLICK="mouse-click",t.MOUSE_MOVE="mouse-move",t.TRANSFORM="transform",t.NODE_DRAG_START="node-drag-start",t.NODE_DRAG="node-drag",t.NODE_DRAG_END="node-drag-end",t.NODE_RIGHT_CLICK="node-right-click",t.EDGE_RIGHT_CLICK="edge-right-click",t.MOUSE_RIGHT_CLICK="mouse-right-click",t.NODE_DOUBLE_CLICK="node-double-click",t.EDGE_DOUBLE_CLICK="edge-double-click",t.MOUSE_DOUBLE_CLICK="mouse-double-click"}(e||(e={}));class o extends t{}class s extends Error{constructor(t){super(t),this.message=t,Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}}const r={NONE:0,SELECTED:1,HOVERED:2};class a{constructor(){this._imageByUrl={}}static getInstance(){return a._instance||(a._instance=new a),a._instance}getImage(t){return this._imageByUrl[t]}loadImage(t,e){const i=this.getImage(t);if(i)return i;const n=new Image;return this._imageByUrl[t]=n,n.onload=()=>{h(n),null==e||e()},n.onerror=()=>{null==e||e(new Error(`Image ${t} failed to load.`))},n.src=t,n}loadImages(t,e){const i=[],n=new Set(t),o=t=>{n.delete(t),0===n.size&&(null==e||e())};for(let e=0;e{h(a),o(s)},a.onerror=()=>{o(s)},a.src=s,i.push(a)}return i}}const h=t=>t&&0===t.width?(document.body.appendChild(t),t.width=t.offsetWidth,t.height=t.offsetHeight,document.body.removeChild(t),t):t;class l{constructor(){this.listeners=[]}addListener(t){this.listeners.push(t)}getListeners(){return[...this.listeners]}removeListener(t){const e=this.listeners.indexOf(t);-1!==e&&this.listeners.splice(e,1)}notifyListeners(t){for(let e=0;e"number"==typeof t,d=t=>"boolean"==typeof t,c=t=>t instanceof Date,_=t=>Array.isArray(t),f=t=>null!==t&&"object"==typeof t&&"Object"===t.constructor.name,g=t=>"function"==typeof t,p=t=>c(t)?v(t):_(t)?y(t):f(t)?x(t):t,m=(t,e)=>{const i=c(t),n=c(e);if(i&&!n||!i&&n)return!1;if(i&&n)return t.getTime()===e.getTime();const o=_(t),s=_(e);if(o&&!s||!o&&s)return!1;if(o&&s)return t.length===e.length&&t.every((t,i)=>m(t,e[i]));const r=f(t),a=f(e);if(r&&!a||!r&&a)return!1;if(r&&a){const i=Object.keys(t),n=Object.keys(e);return!!m(i,n)&&i.every(i=>m(t[i],e[i]))}return t===e},v=t=>new Date(t),y=t=>t.map(t=>p(t)),x=t=>{const e={};return Object.keys(t).forEach(i=>{e[i]=p(t[i])}),e},b=(t,e)=>{const i=Object.keys(e);for(let n=0;nt instanceof T;class T extends l{constructor(t,e){super(),this._style={},this._state=r.NONE,this._inEdgesById={},this._outEdgesById={},this.id=t.data.id,this._data=t.data,this._position={id:this.id},this._onLoadedImage=null==e?void 0:e.onLoadedImage,e&&e.listeners&&(this.listeners=e.listeners)}getId(){return this.id}getData(){return this._data}getPosition(){return this._position}getStyle(){return this._style}getState(){return this._state}clearPosition(){this._position.x=void 0,this._position.y=void 0,this.notifyListeners()}getCenter(){return void 0===this._position.x||void 0===this._position.y?{x:0,y:0}:{x:this._position.x,y:this._position.y}}getRadius(){var t;return null!==(t=this._style.size)&&void 0!==t?t:0}getBorderedRadius(){return this.getRadius()+this.getBorderWidth()/2}getBoundingBox(){const t=this.getCenter(),e=this.getBorderedRadius();return{x:t.x-e,y:t.y-e,width:2*e,height:2*e}}getInEdges(){return Object.values(this._inEdgesById)}getOutEdges(){return Object.values(this._outEdgesById)}getEdges(){const t={},e=this.getOutEdges();for(let i=0;i0}addEdge(t){t.start===this.id&&(this._outEdgesById[t.getId()]=t),t.end===this.id&&(this._inEdgesById[t.getId()]=t)}removeEdge(t){delete this._outEdgesById[t.getId()],delete this._inEdgesById[t.getId()]}isSelected(){return this._state===r.SELECTED}isHovered(){return this._state===r.HOVERED}clearState(){this.setState(r.NONE,{isNotifySkipped:!0})}getDistanceToBorder(){return this.getBorderedRadius()}includesPoint(t){const e=this._isPointInBoundingBox(t);if(!e)return!1;if(this._style.shape===w.SQUARE)return e;const i=this.getCenter(),n=this.getBorderedRadius(),o=t.x-i.x,s=t.y-i.y;return Math.sqrt(o*o+s*s)<=n}hasShadow(){var t,e,i;return(null!==(t=this._style.shadowSize)&&void 0!==t?t:0)>0||(null!==(e=this._style.shadowOffsetX)&&void 0!==e?e:0)>0||(null!==(i=this._style.shadowOffsetY)&&void 0!==i?i:0)>0}hasBorder(){var t,e;const i=(null!==(t=this._style.borderWidth)&&void 0!==t?t:0)>0,n=(null!==(e=this._style.borderWidthSelected)&&void 0!==e?e:0)>0;return i||this.isSelected()&&n}getLabel(){return this._style.label}getColor(){let t;return this._style.color&&(t=this._style.color),this.isHovered()&&this._style.colorHover&&(t=this._style.colorHover),this.isSelected()&&this._style.colorSelected&&(t=this._style.colorSelected),t}getBorderWidth(){let t=0;return this._style.borderWidth&&this._style.borderWidth>0&&(t=this._style.borderWidth),this.isSelected()&&this._style.borderWidthSelected&&this._style.borderWidthSelected>0&&(t=this._style.borderWidthSelected),t}getBorderColor(){if(!this.hasBorder())return;let t;return this._style.borderColor&&(t=this._style.borderColor),this.isHovered()&&this._style.borderColorHover&&(t=this._style.borderColorHover),this.isSelected()&&this._style.borderColorSelected&&(t=this._style.borderColorSelected.toString()),t}getBackgroundImage(){var t;if((null!==(t=this._style.size)&&void 0!==t?t:0)<=0)return;let e;if(this._style.imageUrl&&(e=this._style.imageUrl),this.isSelected()&&this._style.imageUrlSelected&&(e=this._style.imageUrlSelected),!e)return;return a.getInstance().getImage(e)||a.getInstance().loadImage(e,t=>{var e;t||null===(e=this._onLoadedImage)||void 0===e||e.call(this)})}setData(t){g(t)?this._data=t(this):this._data=t,this.notifyListeners()}patchData(t){let e;e=g(t)?t(this):t,b(this._data,e),this.notifyListeners()}setPosition(t,e){let i;i=g(t)?t(this):t,"x"in i&&"y"in i&&(this._position.x=i.x,this._position.y=i.y,"id"in i&&(this._position.id=i.id)),(null==e?void 0:e.isNotifySkipped)||this.notifyListeners(Object.assign({id:this.id},i))}setStyle(t,e){g(t)?this._style=t(this):this._style=t,(null==e?void 0:e.isNotifySkipped)||this.notifyListeners()}patchStyle(t,e){let i;i=g(t)?t(this):t,b(this._style,i),(null==e?void 0:e.isNotifySkipped)||this.notifyListeners()}setState(t,e){let i;if(i=g(t)?t(this):t,u(i))this._state=i;else if(f(i)){const t=i.options;if(this._state=this._handleState(i.state,t),t)return void this.notifyListeners({id:this.id,type:"node",options:t})}(null==e?void 0:e.isNotifySkipped)||this.notifyListeners()}_isPointInBoundingBox(t){return((t,e)=>{const i=t.x+t.width,n=t.y+t.height;return e.x>=t.x&&e.x<=i&&e.y>=t.y&&e.y<=n})(this.getBoundingBox(),t)}_handleState(t,e){return(null==e?void 0:e.isToggle)&&this._state===t?r.NONE:t}}const P=(t,e,i)=>{const n=e.x-t.x,o=e.y-t.y;let s=((i.x-t.x)*n+(i.y-t.y)*o)/(n*n+o*o);s>1&&(s=1),s<0&&(s=0);const r=t.x+s*n,a=t.y+s*o,h=r-i.x,l=a-i.y;return Math.sqrt(h*h+l*l)},C=[5,5],A=[1,1];var M,L;!function(t){t.SOLID="solid",t.DASHED="dashed",t.DOTTED="dotted",t.CUSTOM="custom"}(M||(M={})),function(t){t.STRAIGHT="straight",t.LOOPBACK="loopback",t.CURVED="curved"}(L||(L={}));class N{static create(t,e){switch(O(t)){case L.STRAIGHT:return new R(t,e);case L.LOOPBACK:return new B(t,e);case L.CURVED:return new z(t,e);default:return new R(t,e)}}static copy(t,e){const i=N.create({data:t.getData(),offset:void 0!==(null==e?void 0:e.offset)?e.offset:t.offset,startNode:t.startNode,endNode:t.endNode});i.setState(t.getState()),i.setStyle(t.getStyle());const n=t.getListeners();for(let t=0;tt instanceof R||t instanceof z||t instanceof B;class D extends l{constructor(t,e){var i;super(),this._style={},this._state=r.NONE,this._type=L.STRAIGHT,this.id=t.data.id,this._data=t.data,this.offset=null!==(i=t.offset)&&void 0!==i?i:0,this.startNode=t.startNode,this.endNode=t.endNode,this._type=O(t),this._position={id:this.id,source:this.startNode.getId(),target:this.endNode.getId()},this.startNode.addEdge(this),this.endNode.addEdge(this),e&&e.listeners&&(this.listeners=e.listeners)}getId(){return this.id}getData(){return this._data}getPosition(){return this._position}getStyle(){return this._style}getState(){return this._state}get type(){return this._type}get start(){return this._data.start}get end(){return this._data.end}hasStyle(){return this._style&&Object.keys(this._style).length>0}isSelected(){return this._state===r.SELECTED}isHovered(){return this._state===r.HOVERED}clearState(){this._state=r.NONE}isLoopback(){return this._type===L.LOOPBACK}isStraight(){return this._type===L.STRAIGHT}isCurved(){return this._type===L.CURVED}getCenter(){var t,e;const i=null===(t=this.startNode)||void 0===t?void 0:t.getCenter(),n=null===(e=this.endNode)||void 0===e?void 0:e.getCenter();return i&&n?{x:(i.x+n.x)/2,y:(i.y+n.y)/2}:{x:0,y:0}}getDistance(t){const e=this.startNode.getCenter(),i=this.endNode.getCenter();return e&&i?P(e,i,t):0}getLabel(){return this._style.label}hasShadow(){var t,e,i;return(null!==(t=this._style.shadowSize)&&void 0!==t?t:0)>0||(null!==(e=this._style.shadowOffsetX)&&void 0!==e?e:0)>0||(null!==(i=this._style.shadowOffsetY)&&void 0!==i?i:0)>0}getWidth(){let t=0;return void 0!==this._style.width&&(t=this._style.width),this.isHovered()&&void 0!==this._style.widthHover&&(t=this._style.widthHover),this.isSelected()&&void 0!==this._style.widthSelected&&(t=this._style.widthSelected),t}getColor(){let t;return this._style.color&&(t=this._style.color),this.isHovered()&&this._style.colorHover&&(t=this._style.colorHover),this.isSelected()&&this._style.colorSelected&&(t=this._style.colorSelected),t}getLineDashPattern(){const t=this._style.lineStyle;if(void 0===t||t.type===M.SOLID)return null;switch(t.type){case M.DASHED:return C;case M.DOTTED:return A;case M.CUSTOM:return e=t.pattern,_(e)&&e.every(t=>u(t))?t.pattern:null;default:return null}var e}setData(t){g(t)?this._data=t(this):this._data=t,this.notifyListeners()}patchData(t){let e;e=g(t)?t(this):t,b(this._data,e),this.notifyListeners()}setStyle(t,e){g(t)?this._style=t(this):this._style=t,(null==e?void 0:e.isNotifySkipped)||this.notifyListeners()}patchStyle(t,e){let i;i=g(t)?t(this):t,b(this._style,i),(null==e?void 0:e.isNotifySkipped)||this.notifyListeners()}setState(t,e){let i;if(i=g(t)?t(this):t,u(i))this._state=i;else if(f(i)){const t=i.options;if(this._state=this._handleState(i.state,t),t)return void this.notifyListeners({id:this.id,type:"edge",options:t})}(null==e?void 0:e.isNotifySkipped)||this.notifyListeners()}_handleState(t,e){return(null==e?void 0:e.isToggle)&&this._state===t?r.NONE:t}}const O=t=>{var e;return t.startNode.getId()===t.endNode.getId()?L.LOOPBACK:0===(null!==(e=t.offset)&&void 0!==e?e:0)?L.STRAIGHT:L.CURVED};class R extends D{getCenter(){var t,e;const i=null===(t=this.startNode)||void 0===t?void 0:t.getCenter(),n=null===(e=this.endNode)||void 0===e?void 0:e.getCenter();return i&&n?{x:(i.x+n.x)/2,y:(i.y+n.y)/2}:{x:0,y:0}}getDistance(t){var e,i;const n=null===(e=this.startNode)||void 0===e?void 0:e.getCenter(),o=null===(i=this.endNode)||void 0===i?void 0:i.getCenter();return n&&o?P(n,o,t):0}}class z extends D{getCenter(){return this.getCurvedControlPoint(2)}getDistance(t){var e,i;const n=null===(e=this.startNode)||void 0===e?void 0:e.getCenter(),o=null===(i=this.endNode)||void 0===i?void 0:i.getCenter();if(!n||!o)return 0;const s=this.getCurvedControlPoint();let r,a,h,l,u,d=1e9,c=n.x,_=n.y;for(a=1;a<10;a++)h=.1*a,l=Math.pow(1-h,2)*n.x+2*h*(1-h)*s.x+Math.pow(h,2)*o.x,u=Math.pow(1-h,2)*n.y+2*h*(1-h)*s.y+Math.pow(h,2)*o.y,a>0&&(r=P({x:c,y:_},{x:l,y:u},t),d=r({r:parseInt(t.substring(1,3),16),g:parseInt(t.substring(3,5),16),b:parseInt(t.substring(5,7),16)}),Z=t=>"#"+((1<<24)+(t.r<<16)+(t.g<<8)+t.b).toString(16).slice(1),F=["label","name"],G={size:5,color:new U("#1d87c9")},W={color:new U("#ababab"),width:.3},H=()=>({getNodeStyle:t=>Object.assign(Object.assign({},G),{label:V(t)}),getEdgeStyle:t=>Object.assign(Object.assign({},W),{label:V(t)})}),V=t=>{const e=t.getData();for(let t=0;t{}};function q(){for(var t,e=0,i=arguments.length,n={};e=0&&(e=t.slice(i+1),t=t.slice(0,i)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})),r=-1,a=s.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++r0)for(var i,n,o=new Array(i),s=0;se?1:t>=e?0:NaN}ut.prototype={constructor:ut,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};var pt="http://www.w3.org/1999/xhtml";const mt={svg:"http://www.w3.org/2000/svg",xhtml:pt,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function vt(t){var e=t+="",i=e.indexOf(":");return i>=0&&"xmlns"!==(e=t.slice(0,i))&&(t=t.slice(i+1)),mt.hasOwnProperty(e)?{space:mt[e],local:t}:t}function yt(t){return function(){this.removeAttribute(t)}}function xt(t){return function(){this.removeAttributeNS(t.space,t.local)}}function bt(t,e){return function(){this.setAttribute(t,e)}}function wt(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function St(t,e){return function(){var i=e.apply(this,arguments);null==i?this.removeAttribute(t):this.setAttribute(t,i)}}function Et(t,e){return function(){var i=e.apply(this,arguments);null==i?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,i)}}function Tt(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function Pt(t){return function(){this.style.removeProperty(t)}}function Ct(t,e,i){return function(){this.style.setProperty(t,e,i)}}function At(t,e,i){return function(){var n=e.apply(this,arguments);null==n?this.style.removeProperty(t):this.style.setProperty(t,n,i)}}function Mt(t,e){return t.style.getPropertyValue(e)||Tt(t).getComputedStyle(t,null).getPropertyValue(e)}function Lt(t){return function(){delete this[t]}}function Nt(t,e){return function(){this[t]=e}}function It(t,e){return function(){var i=e.apply(this,arguments);null==i?delete this[t]:this[t]=i}}function Dt(t){return t.trim().split(/^|\s+/)}function Ot(t){return t.classList||new Rt(t)}function Rt(t){this._node=t,this._names=Dt(t.getAttribute("class")||"")}function zt(t,e){for(var i=Ot(t),n=-1,o=e.length;++n=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var ae=[null];function he(t,e){this._groups=t,this._parents=e}function le(){return new he([[document.documentElement]],ae)}he.prototype=le.prototype={constructor:he,select:function(t){"function"!=typeof t&&(t=tt(t));for(var e=this._groups,i=e.length,n=new Array(i),o=0;o=x&&(x=y+1);!(v=p[x])&&++x=0;)(n=o[s])&&(r&&4^n.compareDocumentPosition(r)&&r.parentNode.insertBefore(n,r),r=n);return this},sort:function(t){function e(e,i){return e&&i?t(e.__data__,i.__data__):!e-!i}t||(t=gt);for(var i=this._groups,n=i.length,o=new Array(n),s=0;s1?this.each((null==e?Pt:"function"==typeof e?At:Ct)(t,e,null==i?"":i)):Mt(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?Lt:"function"==typeof e?It:Nt)(t,e)):this.node()[t]},classed:function(t,e){var i=Dt(t+"");if(arguments.length<2){for(var n=Ot(this.node()),o=-1,s=i.length;++o=0&&(e=t.slice(i+1),t=t.slice(0,i)),{type:t,name:e}})}(t+""),r=s.length;if(!(arguments.length<2)){for(a=e?ne:ie,n=0;n()=>t;function xe(t,{sourceEvent:e,subject:i,target:n,identifier:o,active:s,x:r,y:a,dx:h,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:i,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:r,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:h,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}function be(t){return!t.ctrlKey&&!t.button}function we(){return this.parentNode}function Se(t,e){return null==e?{x:t.x,y:t.y}:e}function Ee(){return navigator.maxTouchPoints||"ontouchstart"in this}xe.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};const Te=t=>+t;function Pe(t){return((t=Math.exp(t))+1/t)/2}const Ce=function t(e,i,n){function o(t,o){var s,r,a=t[0],h=t[1],l=t[2],u=o[0],d=o[1],c=o[2],_=u-a,f=d-h,g=_*_+f*f;if(g<1e-12)r=Math.log(c/l)/e,s=function(t){return[a+t*_,h+t*f,l*Math.exp(e*t*r)]};else{var p=Math.sqrt(g),m=(c*c-l*l+n*g)/(2*l*i*p),v=(c*c-l*l-n*g)/(2*c*i*p),y=Math.log(Math.sqrt(m*m+1)-m),x=Math.log(Math.sqrt(v*v+1)-v);r=(x-y)/e,s=function(t){var n=t*r,o=Pe(y),s=l/(i*p)*(o*function(t){return((t=Math.exp(2*t))-1)/(t+1)}(e*n+y)-function(t){return((t=Math.exp(t))-1/t)/2}(y));return[a+s*_,h+s*f,l*o/Pe(e*n+y)]}}return s.duration=1e3*r*e/Math.SQRT2,s}return o.rho=function(e){var i=Math.max(.001,+e),n=i*i;return t(i,n,n*n)},o}(Math.SQRT2,2,4);var Ae,Me,Le=0,Ne=0,Ie=0,De=0,Oe=0,Re=0,ze="object"==typeof performance&&performance.now?performance:Date,Be="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function ke(){return Oe||(Be(Ue),Oe=ze.now()+Re)}function Ue(){Oe=0}function je(){this._call=this._time=this._next=null}function Ze(t,e,i){var n=new je;return n.restart(t,e,i),n}function Fe(){Oe=(De=ze.now())+Re,Le=Ne=0;try{!function(){ke(),++Le;for(var t,e=Ae;e;)(t=Oe-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Le}()}finally{Le=0,function(){for(var t,e,i=Ae,n=1/0;i;)i._call?(n>i._time&&(n=i._time),t=i,i=i._next):(e=i._next,i._next=null,i=t?t._next=e:Ae=e);Me=t,We(n)}(),Oe=0}}function Ge(){var t=ze.now(),e=t-De;e>1e3&&(Re-=e,De=t)}function We(t){Le||(Ne&&(Ne=clearTimeout(Ne)),t-Oe>24?(t<1/0&&(Ne=setTimeout(Fe,t-ze.now()-Re)),Ie&&(Ie=clearInterval(Ie))):(Ie||(De=ze.now(),Ie=setInterval(Ge,1e3)),Le=1,Be(Fe)))}function He(t,e,i){var n=new je;return e=null==e?0:+e,n.restart(i=>{n.stop(),t(i+e)},e,i),n}je.prototype=Ze.prototype={constructor:je,restart:function(t,e,i){if("function"!=typeof t)throw new TypeError("callback is not a function");i=(null==i?ke():+i)+(null==e?0:+e),this._next||Me===this||(Me?Me._next=this:Ae=this,Me=this),this._call=t,this._time=i,We()},stop:function(){this._call&&(this._call=null,this._time=1/0,We())}};var Ve=Q("start","end","cancel","interrupt"),Xe=[];function qe(t,e,i,n,o,s){var r=t.__transition;if(r){if(i in r)return}else t.__transition={};!function(t,e,i){var n,o=t.__transition;function s(h){var l,u,d,c;if(1!==i.state)return a();for(l in o)if((c=o[l]).name===i.name){if(3===c.state)return He(s);4===c.state?(c.state=6,c.timer.stop(),c.on.call("interrupt",t,t.__data__,c.index,c.group),delete o[l]):+l0)throw new Error("too late; already scheduled");return i}function Ye(t,e){var i=Ke(t,e);if(i.state>3)throw new Error("too late; already running");return i}function Ke(t,e){var i=t.__transition;if(!i||!(i=i[e]))throw new Error("transition not found");return i}function Qe(t,e){var i,n,o,s=t.__transition,r=!0;if(s){for(o in e=null==e?null:e+"",s)(i=s[o]).name===e?(n=i.state>2&&i.state<5,i.state=6,i.timer.stop(),i.on.call(n?"interrupt":"cancel",t,t.__data__,i.index,i.group),delete s[o]):r=!1;r&&delete t.__transition}}function Je(t,e){return t=+t,e=+e,function(i){return t*(1-i)+e*i}}var ti,ei=180/Math.PI,ii={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ni(t,e,i,n,o,s){var r,a,h;return(r=Math.sqrt(t*t+e*e))&&(t/=r,e/=r),(h=t*i+e*n)&&(i-=t*h,n-=e*h),(a=Math.sqrt(i*i+n*n))&&(i/=a,n/=a,h/=a),t*n180?e+=360:e-t>180&&(t+=360),s.push({i:i.push(o(i)+"rotate(",null,n)-2,x:Je(t,e)})):e&&i.push(o(i)+"rotate("+e+n)}(s.rotate,r.rotate,a,h),function(t,e,i,s){t!==e?s.push({i:i.push(o(i)+"skewX(",null,n)-2,x:Je(t,e)}):e&&i.push(o(i)+"skewX("+e+n)}(s.skewX,r.skewX,a,h),function(t,e,i,n,s,r){if(t!==i||e!==n){var a=s.push(o(s)+"scale(",null,",",null,")");r.push({i:a-4,x:Je(t,i)},{i:a-2,x:Je(e,n)})}else 1===i&&1===n||s.push(o(s)+"scale("+i+","+n+")")}(s.scaleX,s.scaleY,r.scaleX,r.scaleY,a,h),s=r=null,function(t){for(var e,i=-1,n=h.length;++i>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===i?Li(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===i?Li(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=yi.exec(t))?new Ii(e[1],e[2],e[3],1):(e=xi.exec(t))?new Ii(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=bi.exec(t))?Li(e[1],e[2],e[3],e[4]):(e=wi.exec(t))?Li(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=Si.exec(t))?ki(e[1],e[2]/100,e[3]/100,1):(e=Ei.exec(t))?ki(e[1],e[2]/100,e[3]/100,e[4]):Ti.hasOwnProperty(t)?Mi(Ti[t]):"transparent"===t?new Ii(NaN,NaN,NaN,0):null}function Mi(t){return new Ii(t>>16&255,t>>8&255,255&t,1)}function Li(t,e,i,n){return n<=0&&(t=e=i=NaN),new Ii(t,e,i,n)}function Ni(t,e,i,n){return 1===arguments.length?((o=t)instanceof ci||(o=Ai(o)),o?new Ii((o=o.rgb()).r,o.g,o.b,o.opacity):new Ii):new Ii(t,e,i,null==n?1:n);var o}function Ii(t,e,i,n){this.r=+t,this.g=+e,this.b=+i,this.opacity=+n}function Di(){return`#${Bi(this.r)}${Bi(this.g)}${Bi(this.b)}`}function Oi(){const t=Ri(this.opacity);return`${1===t?"rgb(":"rgba("}${zi(this.r)}, ${zi(this.g)}, ${zi(this.b)}${1===t?")":`, ${t})`}`}function Ri(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function zi(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Bi(t){return((t=zi(t))<16?"0":"")+t.toString(16)}function ki(t,e,i,n){return n<=0?t=e=i=NaN:i<=0||i>=1?t=e=NaN:e<=0&&(t=NaN),new ji(t,e,i,n)}function Ui(t){if(t instanceof ji)return new ji(t.h,t.s,t.l,t.opacity);if(t instanceof ci||(t=Ai(t)),!t)return new ji;if(t instanceof ji)return t;var e=(t=t.rgb()).r/255,i=t.g/255,n=t.b/255,o=Math.min(e,i,n),s=Math.max(e,i,n),r=NaN,a=s-o,h=(s+o)/2;return a?(r=e===s?(i-n)/a+6*(i0&&h<1?0:r,new ji(r,a,h,t.opacity)}function ji(t,e,i,n){this.h=+t,this.s=+e,this.l=+i,this.opacity=+n}function Zi(t){return(t=(t||0)%360)<0?t+360:t}function Fi(t){return Math.max(0,Math.min(1,t||0))}function Gi(t,e,i){return 255*(t<60?e+(i-e)*t/60:t<180?i:t<240?e+(i-e)*(240-t)/60:e)}function Wi(t,e,i,n,o){var s=t*t,r=s*t;return((1-3*t+3*s-r)*e+(4-6*s+3*r)*i+(1+3*t+3*s-3*r)*n+r*o)/6}ui(ci,Ai,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Pi,formatHex:Pi,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return Ui(this).formatHsl()},formatRgb:Ci,toString:Ci}),ui(Ii,Ni,di(ci,{brighter(t){return t=null==t?fi:Math.pow(fi,t),new Ii(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?_i:Math.pow(_i,t),new Ii(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Ii(zi(this.r),zi(this.g),zi(this.b),Ri(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Di,formatHex:Di,formatHex8:function(){return`#${Bi(this.r)}${Bi(this.g)}${Bi(this.b)}${Bi(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:Oi,toString:Oi})),ui(ji,function(t,e,i,n){return 1===arguments.length?Ui(t):new ji(t,e,i,null==n?1:n)},di(ci,{brighter(t){return t=null==t?fi:Math.pow(fi,t),new ji(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?_i:Math.pow(_i,t),new ji(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,i=this.l,n=i+(i<.5?i:1-i)*e,o=2*i-n;return new Ii(Gi(t>=240?t-240:t+120,o,n),Gi(t,o,n),Gi(t<120?t+240:t-120,o,n),this.opacity)},clamp(){return new ji(Zi(this.h),Fi(this.s),Fi(this.l),Ri(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=Ri(this.opacity);return`${1===t?"hsl(":"hsla("}${Zi(this.h)}, ${100*Fi(this.s)}%, ${100*Fi(this.l)}%${1===t?")":`, ${t})`}`}}));const Hi=t=>()=>t;function Vi(t,e){var i=e-t;return i?function(t,e){return function(i){return t+i*e}}(t,i):Hi(isNaN(t)?e:t)}const Xi=function t(e){var i=function(t){return 1===(t=+t)?Vi:function(e,i){return i-e?function(t,e,i){return t=Math.pow(t,i),e=Math.pow(e,i)-t,i=1/i,function(n){return Math.pow(t+n*e,i)}}(e,i,t):Hi(isNaN(e)?i:e)}}(e);function n(t,e){var n=i((t=Ni(t)).r,(e=Ni(e)).r),o=i(t.g,e.g),s=i(t.b,e.b),r=Vi(t.opacity,e.opacity);return function(e){return t.r=n(e),t.g=o(e),t.b=s(e),t.opacity=r(e),t+""}}return n.gamma=t,n}(1);function qi(t){return function(e){var i,n,o=e.length,s=new Array(o),r=new Array(o),a=new Array(o);for(i=0;i=1?(i=1,e-1):Math.floor(i*e),o=t[n],s=t[n+1],r=n>0?t[n-1]:2*o-s,a=ns&&(o=e.slice(s,o),a[r]?a[r]+=o:a[++r]=o),(i=i[0])===(n=n[0])?a[r]?a[r]+=n:a[++r]=n:(a[++r]=null,h.push({i:r,x:Je(i,n)})),s=Yi.lastIndex;return s=0&&(t=t.slice(0,e)),!t||"start"===t})}(e)?$e:Ye;return function(){var r=s(this,t),a=r.on;a!==n&&(o=(n=a).copy()).on(e,i),r.on=o}}(i,t,e))},attr:function(t,e){var i=vt(t),n="transform"===i?ri:Qi;return this.attrTween(t,"function"==typeof e?(i.local?sn:on)(i,n,li(this,"attr."+t,e)):null==e?(i.local?tn:Ji)(i):(i.local?nn:en)(i,n,e))},attrTween:function(t,e){var i="attr."+t;if(arguments.length<2)return(i=this.tween(i))&&i._value;if(null==e)return this.tween(i,null);if("function"!=typeof e)throw new Error;var n=vt(t);return this.tween(i,(n.local?rn:an)(n,e))},style:function(t,e,i){var n="transform"==(t+="")?si:Qi;return null==e?this.styleTween(t,function(t,e){var i,n,o;return function(){var s=Mt(this,t),r=(this.style.removeProperty(t),Mt(this,t));return s===r?null:s===i&&r===n?o:o=e(i=s,n=r)}}(t,n)).on("end.style."+t,_n(t)):"function"==typeof e?this.styleTween(t,function(t,e,i){var n,o,s;return function(){var r=Mt(this,t),a=i(this),h=a+"";return null==a&&(this.style.removeProperty(t),h=a=Mt(this,t)),r===h?null:r===n&&h===o?s:(o=h,s=e(n=r,a))}}(t,n,li(this,"style."+t,e))).each(function(t,e){var i,n,o,s,r="style."+e,a="end."+r;return function(){var h=Ye(this,t),l=h.on,u=null==h.value[r]?s||(s=_n(e)):void 0;l===i&&o===u||(n=(i=l).copy()).on(a,o=u),h.on=n}}(this._id,t)):this.styleTween(t,function(t,e,i){var n,o,s=i+"";return function(){var r=Mt(this,t);return r===s?null:r===n?o:o=e(n=r,i)}}(t,n,e),i).on("end.style."+t,null)},styleTween:function(t,e,i){var n="style."+(t+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw new Error;return this.tween(n,function(t,e,i){var n,o;function s(){var s=e.apply(this,arguments);return s!==o&&(n=(o=s)&&function(t,e,i){return function(n){this.style.setProperty(t,e.call(this,n),i)}}(t,s,i)),n}return s._value=e,s}(t,e,null==i?"":i))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e}}(li(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,function(t){var e,i;function n(){var n=t.apply(this,arguments);return n!==i&&(e=(i=n)&&function(t){return function(e){this.textContent=t.call(this,e)}}(n)),e}return n._value=t,n}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var i in this.__transition)if(+i!==t)return;e&&e.removeChild(this)}}(this._id))},tween:function(t,e){var i=this._id;if(t+="",arguments.length<2){for(var n,o=Ke(this.node(),i).tween,s=0,r=o.length;s()=>t;function bn(t,{sourceEvent:e,target:i,transform:n,dispatch:o}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:o}})}function wn(t,e,i){this.k=t,this.x=e,this.y=i}wn.prototype={constructor:wn,scale:function(t){return 1===t?this:new wn(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new wn(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Sn=new wn(1,0,0);function En(t){t.stopImmediatePropagation()}function Tn(t){t.preventDefault(),t.stopImmediatePropagation()}function Pn(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function Cn(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function An(){return this.__zoom||Sn}function Mn(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Ln(){return navigator.maxTouchPoints||"ontouchstart"in this}function Nn(t,e,i){var n=t.invertX(e[0][0])-i[0][0],o=t.invertX(e[1][0])-i[1][0],s=t.invertY(e[0][1])-i[0][1],r=t.invertY(e[1][1])-i[1][1];return t.translate(o>n?(n+o)/2:Math.min(0,n)||Math.max(0,o),r>s?(s+r)/2:Math.min(0,s)||Math.max(0,r))}wn.prototype;const In=(t,e)=>!!t&&!!e&&t.x===e.x&&t.y===e.y;var Dn;function On(t){return function(){return t}}function Rn(t){return 1e-6*(t()-.5)}function zn(t){return t.index}function Bn(t,e){var i=t.get(e);if(!i)throw new Error("node not found: "+e);return i}!function(t){t.SIMULATION_START="simulation-start",t.SIMULATION_STEP="simulation-step",t.SIMULATION_PROGRESS="simulation-progress",t.SIMULATION_END="simulation-end",t.NODE_DRAG="node-drag",t.NODE_DRAG_END="node-drag-end",t.SETTINGS_UPDATE="settings-update"}(Dn||(Dn={}));const kn=4294967296;function Un(t){return t.x}function jn(t){return t.y}var Zn=Math.PI*(3-Math.sqrt(5));function Fn(t,e,i,n){if(isNaN(e)||isNaN(i))return t;var o,s,r,a,h,l,u,d,c,_=t._root,f={data:n},g=t._x0,p=t._y0,m=t._x1,v=t._y1;if(!_)return t._root=f,t;for(;_.length;)if((l=e>=(s=(g+m)/2))?g=s:m=s,(u=i>=(r=(p+v)/2))?p=r:v=r,o=_,!(_=_[d=u<<1|l]))return o[d]=f,t;if(a=+t._x.call(null,_.data),h=+t._y.call(null,_.data),e===a&&i===h)return f.next=_,o?o[d]=f:t._root=f,t;do{o=o?o[d]=new Array(4):t._root=new Array(4),(l=e>=(s=(g+m)/2))?g=s:m=s,(u=i>=(r=(p+v)/2))?p=r:v=r}while((d=u<<1|l)==(c=(h>=r)<<1|a>=s));return o[c]=_,o[d]=f,t}function Gn(t,e,i,n,o){this.node=t,this.x0=e,this.y0=i,this.x1=n,this.y1=o}function Wn(t){return t[0]}function Hn(t){return t[1]}function Vn(t,e,i){var n=new Xn(null==e?Wn:e,null==i?Hn:i,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function Xn(t,e,i,n,o,s){this._x=t,this._y=e,this._x0=i,this._y0=n,this._x1=o,this._y1=s,this._root=void 0}function qn(t){for(var e={data:t.data},i=e;t=t.next;)i=i.next={data:t.data};return e}var $n=Vn.prototype=Xn.prototype;function Yn(t){return t.x+t.vx}function Kn(t){return t.y+t.vy}$n.copy=function(){var t,e,i=new Xn(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root;if(!n)return i;if(!n.length)return i._root=qn(n),i;for(t=[{source:n,target:i._root=new Array(4)}];n=t.pop();)for(var o=0;o<4;++o)(e=n.source[o])&&(e.length?t.push({source:e,target:n.target[o]=new Array(4)}):n.target[o]=qn(e));return i},$n.add=function(t){const e=+this._x.call(null,t),i=+this._y.call(null,t);return Fn(this.cover(e,i),e,i,t)},$n.addAll=function(t){var e,i,n,o,s=t.length,r=new Array(s),a=new Array(s),h=1/0,l=1/0,u=-1/0,d=-1/0;for(i=0;iu&&(u=n),od&&(d=o));if(h>u||l>d)return this;for(this.cover(h,l).cover(u,d),i=0;it||t>=o||n>e||e>=s;)switch(a=(ec||(s=h.y0)>_||(r=h.x1)=m)<<1|t>=p)&&(h=f[f.length-1],f[f.length-1]=f[f.length-1-l],f[f.length-1-l]=h)}else{var v=t-+this._x.call(null,g.data),y=e-+this._y.call(null,g.data),x=v*v+y*y;if(x=(a=(f+p)/2))?f=a:p=a,(u=r>=(h=(g+m)/2))?g=h:m=h,e=_,!(_=_[d=u<<1|l]))return this;if(!_.length)break;(e[d+1&3]||e[d+2&3]||e[d+3&3])&&(i=e,c=d)}for(;_.data!==t;)if(n=_,!(_=_.next))return this;return(o=_.next)&&delete _.next,n?(o?n.next=o:delete n.next,this):e?(o?e[d]=o:delete e[d],(_=e[0]||e[1]||e[2]||e[3])&&_===(e[3]||e[2]||e[1]||e[0])&&!_.length&&(i?i[c]=_:this._root=_),this):(this._root=o,this)},$n.removeAll=function(t){for(var e=0,i=t.length;e100*(t>0?t:1),to={useGPU:!1,isSimulatingOnDataUpdate:!0,isSimulatingOnSettingsUpdate:!0,isSimulatingOnUnstick:!0,isPhysicsEnabled:!1,alpha:{alpha:1,alphaMin:.05,alphaDecay:.028,alphaTarget:0},centering:{x:0,y:0,strength:1},collision:{radius:15,strength:1,iterations:1},links:{distance:50,strength:1,iterations:1},manyBody:{strength:-100,theta:.9,distanceMin:1,distanceMax:Jn(50)},positioning:{forceX:{x:0,strength:.1},forceY:{y:0,strength:.1}},anchorX:"center",anchorY:"center"},eo={rowGap:50,colGap:50},io={nodeGap:50,levelGap:50,treeGap:100,orientation:"vertical",reversed:!1};class no extends t{constructor(){super(...arguments),this._nodes=[],this._edges=[],this._nodeIndexByNodeId={},this._cancelSimulation=!1,this._schedulerPort=null}terminate(){var t;this._cancelSimulation=!0,null===(t=this._schedulerPort)||void 0===t||t.close(),this._schedulerPort=null,this.removeAllListeners()}_scheduleNext(t){if("undefined"!=typeof MessageChannel){const e=new MessageChannel;this._schedulerPort=e.port2,e.port1.onmessage=()=>{this._schedulerPort=null,t()},e.port2.postMessage(null)}else setTimeout(t,0)}_rebuildNodeIndex(){this._nodeIndexByNodeId={};for(let t=0;t0&&this.activateSimulation())}setupData(t){this.clearData(),this._initializeNewData(t),this._settings.isSimulatingOnDataUpdate&&(this._updateSimulationData(),this._runSimulation())}mergeData(t){this._initializeNewData(t),this._settings.isPhysicsEnabled||this._pinNodes(),this._settings.isSimulatingOnDataUpdate&&(this._updateSimulationData(),this.activateSimulation())}updateData(t){const e=new Set(t.nodes.map(t=>t.id)),i=this._nodes.filter(t=>e.has(t.id)),n=t.nodes.filter(t=>void 0===this._nodeIndexByNodeId[t.id]);this._nodes=[...i,...n],this._rebuildNodeIndex(),this._edges=t.edges,this._settings.isSimulatingOnSettingsUpdate&&(this._updateSimulationData(),this.activateSimulation())}deleteData(t){if(t.nodeIds){const e=new Set(t.nodeIds);this._nodes=this._nodes.filter(t=>!e.has(t.id))}if(t.edgeIds){const e=new Set(t.edgeIds);this._edges=this._edges.filter(t=>!e.has(t.id))}this._rebuildNodeIndex(),this._settings.isSimulatingOnDataUpdate&&(this._updateSimulationData(),this.activateSimulation())}patchData(t){if(t.nodes){const e={};for(let t=0;t0&&this.activateSimulation()}terminate(){var t;super.terminate(),null===(t=this._simulation)||void 0===t||t.stop()}_resetSimulation(){this._simulation&&(this._simulation.stop(),this._simulation.on("tick",null).on("end",null)),this._linkForce=function(t){var e,i,n,o,s,r,a=zn,h=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},l=On(30),u=1;function d(n){for(var o=0,a=t.length;o[a(t,e,n),t]));for(r=0,o=new Array(l);rt.id),this._simulation=function(t){var e,i=1,n=.001,o=1-Math.pow(n,1/300),s=0,r=.6,a=new Map,h=Ze(d),l=Q("tick","end"),u=function(){let t=1;return()=>(t=(1664525*t+1013904223)%kn)/kn}();function d(){c(),l.call("tick",e),i1?(null==i?a.delete(t):a.set(t,f(i)),e):a.get(t)},find:function(e,i,n){var o,s,r,a,h,l=0,u=t.length;for(null==n?n=1/0:n*=n,l=0;l1?(l.on(t,i),e):l.on(t)}}}(this._nodes).force("link",this._linkForce).stop(),this._applySettingsToSimulation(this._settings),this._simulation.on("tick",()=>{this.emit(Dn.SIMULATION_STEP,{nodes:this._nodes,edges:this._edges})}),this._simulation.on("end",()=>{this._isDragging=!1,this._isStabilizing=!1,this.emit(Dn.SIMULATION_END,{nodes:this._nodes,edges:this._edges}),this._settings.isPhysicsEnabled||this._pinNodes()})}_runSimulation(t){if(this._isStabilizing||this._cancelSimulation)return;(this._settings.isPhysicsEnabled||(null==t?void 0:t.isUpdatingSettings))&&this._unpinNodes(),this.emit(Dn.SIMULATION_START,void 0),this._isStabilizing=!0,this._simulation.alpha(this._settings.alpha.alpha).alphaTarget(this._settings.alpha.alphaTarget).stop();const e=Math.min(500,Math.ceil(Math.log(this._settings.alpha.alphaMin)/Math.log(1-this._settings.alpha.alphaDecay)));let i=-1,n=0;const o=()=>{if(this._cancelSimulation)return this._isStabilizing=!1,void(this._cancelSimulation=!1);const t=Math.min(n+100,e);for(;ni&&(i=t,this.emit(Dn.SIMULATION_PROGRESS,{nodes:this._nodes,edges:this._edges,progress:t/100}))}nl+f||su+f||rh.index){var g=l-a.x-a.vx,p=u-a.y-a.vy,m=g*g+p*p;mt.r&&(t.r=t[e].r)}function h(){if(e){var n,o,s=e.length;for(i=new Array(s),n=0;n=a)){(t.data!==e||t.next)&&(0===d&&(f+=(d=Rn(i))*d),0===c&&(f+=(c=Rn(i))*c),f=o)continue;h<1&&(h=1);const d=-t*e/h;s.vx+=r*d,s.vy+=a*d}}}return s.initialize=t=>{n=t},s}(t.manyBody.strength,t.manyBody.distanceMax,()=>this._edges)):this._simulation.force("edgeMidpointRepulsion",null)}if(null===t.manyBody&&(this._simulation.force("charge",null),this._simulation.force("edgeMidpointRepulsion",null)),null===(e=t.positioning)||void 0===e?void 0:e.forceX){const e=function(t){var e,i,n,o=On(.1);function s(t){for(var o,s=0,r=e.length;s{const n=t.createShader(i===so.VERTEX?t.VERTEX_SHADER:t.FRAGMENT_SHADER);if(!n)throw new s("Failed to create shader.");if(t.shaderSource(n,e),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS)){const e=t.getShaderInfoLog(n);throw t.deleteShader(n),new s(`Failed to compile shader: ${e}`)}return n};class ao extends no{constructor(t){super(),this._isStabilizing=!1,this._isDragging=!1,this._dragLoopRunning=!1,this._pendingRestart=!1,this._simulationGeneration=0,this._currentAlpha=0,this._currentStep=0,this._totalSteps=0,this._dragAlpha=0,this._dragNeedsReheat=!1,this._dirtyNodes=new Set,this._forceProgram=null,this._quadBuffer=null,this._quadVAO=null,this._stateTexA=null,this._stateTexB=null,this._fixedTex=null,this._fboA=null,this._fboB=null,this._texWidth=0,this._treeDataTexture=null,this._treeChildrenTexture=null,this._treeGeometryTexture=null,this._adjOffsetsTexture=null,this._adjEdgesTexture=null,this._cachedAdjacency=null,this._treeTexWidth=1,this._treeNodeCount=0,this._pingPong=!0,this._uniforms={},this.type="force",this._settings=Object.assign(Object.assign({},to),t);const e=document.createElement("canvas").getContext("webgl2");if(!e)throw new s("Failed to create WebGL2 context for GPU force layout engine.");this._gl=e,this._initGPU(),this.clearData()}setSettings(t){const e=t;this._initialSettings||(this._initialSettings=Object.assign(p(to),e));const i=p(this._settings);Object.assign(this._settings,e),m(this._settings,i)||(this.emit(Dn.SETTINGS_UPDATE,{settings:{type:"force",options:this._settings}}),i.isPhysicsEnabled&&!e.isPhysicsEnabled?this.stopSimulation():this._settings.isSimulatingOnSettingsUpdate&&this._nodes.length>0&&this.activateSimulation())}setupData(t){this.clearData(),this._initializeNewData(t),this._settings.isSimulatingOnDataUpdate&&this._runSimulation()}mergeData(t){this._initializeNewData(t),this._settings.isPhysicsEnabled||this._pinNodes(),this._settings.isSimulatingOnDataUpdate&&this.activateSimulation()}updateData(t){const e=new Set(t.nodes.map(t=>t.id)),i=this._nodes.filter(t=>e.has(t.id)),n=t.nodes.filter(t=>void 0===this._nodeIndexByNodeId[t.id]);this._nodes=[...i,...n],this._rebuildNodeIndex(),this._edges=t.edges,this._cachedAdjacency=null,this._settings.isSimulatingOnSettingsUpdate&&this.activateSimulation()}deleteData(t){if(t.nodeIds){const e=new Set(t.nodeIds);this._nodes=this._nodes.filter(t=>!e.has(t.id))}if(t.edgeIds){const e=new Set(t.edgeIds);this._edges=this._edges.filter(t=>!e.has(t.id))}this._rebuildNodeIndex(),this._cachedAdjacency=null,this._settings.isSimulatingOnDataUpdate&&this.activateSimulation()}patchData(t){if(t.nodes){const e={};for(let t=0;t0&&this.activateSimulation()}terminate(){var t;super.terminate();const e=this._gl;e&&(e.deleteBuffer(this._quadBuffer),e.deleteVertexArray(this._quadVAO),e.deleteProgram(this._forceProgram),e.deleteTexture(this._stateTexA),e.deleteTexture(this._stateTexB),e.deleteTexture(this._fixedTex),e.deleteTexture(this._treeDataTexture),e.deleteTexture(this._treeChildrenTexture),e.deleteTexture(this._treeGeometryTexture),e.deleteTexture(this._adjOffsetsTexture),e.deleteTexture(this._adjEdgesTexture),e.deleteFramebuffer(this._fboA),e.deleteFramebuffer(this._fboB),null===(t=e.getExtension("WEBGL_lose_context"))||void 0===t||t.loseContext())}reheat(){const t=this._settings.alpha;this._currentAlpha=t.alpha,this._totalSteps=Math.min(500,Math.ceil(Math.log(t.alphaMin)/Math.log(1-t.alphaDecay))),this._currentStep=0,this._isStabilizing||(this._ensurePositions(),this._uploadDataToGPU(),this._cachedAdjacency||this._buildAndUploadAdjacency(),this._startSimulationLoop())}_runSimulation(){this._isStabilizing||this._cancelSimulation||(this._ensurePositions(),this._uploadDataToGPU(),this._buildAndUploadAdjacency(),this._startSimulationLoop())}_startDragLoop(){if(this._dragLoopRunning)return;this._dragLoopRunning=!0;const t=this._settings.alpha.alphaDecay,e=this._settings.alpha.alphaMin;this._dragAlpha=.3,this._dragNeedsReheat=!1;const i=()=>{this._isDragging?(this._dragNeedsReheat&&(this._dragAlpha=.3,this._dragNeedsReheat=!1),this._dragAlpha+=(0-this._dragAlpha)*t,this._dragAlpha{if(t!==this._simulationGeneration)return;if(this._cancelSimulation)return this._isStabilizing=!1,this._cancelSimulation=!1,void this.emit(Dn.SIMULATION_END,{nodes:this._nodes,edges:this._edges});if(this._readbackFromGPU(),this._pendingRestart)return this._isStabilizing=!1,this._pendingRestart=!1,this._ensurePositions(),this._uploadDataToGPU(),this._cachedAdjacency||this._buildAndUploadAdjacency(),void this._startSimulationLoop();this._flushDirtyNodes(),this._buildAndUploadQuadTree();const r=Math.min(this._currentStep+1,this._totalSteps);for(;this._currentStepo&&(o=a,this.emit(Dn.SIMULATION_PROGRESS,{nodes:this._nodes,edges:this._edges,progress:a/100})),this._currentStep0&&(o=o.concat(t))}const s=function(t,e){var i,n;const o=t.length;if(0===o)return{treeData:new Float32Array(0),treeChildren:new Float32Array(0),treeGeometry:new Float32Array(0),nodeCount:0,texWidth:1};let s=1/0,r=1/0,a=-1/0,h=-1/0;for(let e=0;ea&&(a=i),n>h&&(h=n)}let l=Math.max(a-s,h-r);l<1e-6&&(l=1),l*=1.01;const u=.5*l,d=.5*(s+a)-u,c=.5*(r+h)-u,_=[];function f(t){const e=_.length;return _.push({cx:0,cy:0,charge:0,size:t,bodyIndex:-1,children:[null,null,null,null]}),e}const g=f(l),p=[d],m=[c];function v(t,e,i,n,o){return 2*(e>=n+.5*o?1:0)+(t>=i+.5*o?1:0)}function y(t,e,i,n){const o=.5*n;return{cx0:1&t?e+o:e,cy0:2&t?i+o:i,csz:o}}function x(t,i,n){let o=g,s=d,r=c,a=l;for(let h=0;h<50;h++){const h=_[o];if(-1===h.bodyIndex&&null===h.children[0]&&null===h.children[1]&&null===h.children[2]&&null===h.children[3])return h.bodyIndex=t,h.cx=i,h.cy=n,void(h.charge=e);if(h.bodyIndex>=0){const t=h.bodyIndex,i=h.cx,n=h.cy;h.bodyIndex=-1;const o=v(i,n,s,r,a),{cx0:l,cy0:u,csz:d}=y(o,s,r,a),c=f(d);p[c]=l,m[c]=u,h.children[o]=c,_[c].bodyIndex=t,_[c].cx=i,_[c].cy=n,_[c].charge=e}const l=v(i,n,s,r,a);if(null===h.children[l]){const{cx0:o,cy0:u,csz:d}=y(l,s,r,a),c=f(d);return p[c]=o,m[c]=u,h.children[l]=c,_[c].bodyIndex=t,_[c].cx=i,_[c].cy=n,void(_[c].charge=e)}const{cx0:u,cy0:d,csz:c}=y(l,s,r,a);o=h.children[l],s=u,r=d,a=c}}for(let e=0;e=0)return;let n=0,o=0,s=0,r=0;for(let e=0;e<4;e++){const a=i.children[e];if(null===a)continue;t(a);const h=_[a],l=Math.abs(h.charge);n+=h.charge,o+=h.cx*l,s+=h.cy*l,r+=l}r>0&&(i.cx=o/r,i.cy=s/r),i.charge=n}(g);const b=_.length,w=Math.ceil(Math.sqrt(b)),S=w*w,E=new Float32Array(4*S),T=new Float32Array(4*S),P=new Float32Array(4*S);for(let t=0;t=0?E[o+3]=-(e.bodyIndex+1):E[o+3]=e.size,T[o]=null!==e.children[0]?e.children[0]:-1,T[o+1]=null!==e.children[1]?e.children[1]:-1,T[o+2]=null!==e.children[2]?e.children[2]:-1,T[o+3]=null!==e.children[3]?e.children[3]:-1,P[o]=null!==(i=p[t])&&void 0!==i?i:0,P[o+1]=null!==(n=m[t])&&void 0!==n?n:0,P[o+2]=e.size,P[o+3]=0}for(let t=b;t= uNodeCount) {\r\n fragColor = vec4(0.0);\r\n return;\r\n }\r\n\r\n vec4 fixedData = texelFetch(uFixed, fc, 0);\r\n if (fixedData.x > 0.5) {\r\n fragColor = vec4(fixedData.yz, 0.0, 0.0);\r\n return;\r\n }\r\n\r\n vec4 state = texelFetch(uState, fc, 0);\r\n vec2 pos = state.xy;\r\n vec2 vel = state.zw;\r\n\r\n if (uHasManyBody > 0.5 && uTreeNodeCount > 0) {\r\n int stack[128];\r\n int top = 0;\r\n stack[top++] = 0;\r\n\r\n while (top > 0) {\r\n int idx = stack[--top];\r\n vec4 data = texelFetch(uTreeData, texCoord(idx, uTreeTexWidth), 0);\r\n float w = data.w;\r\n\r\n if (w < -0.5) {\r\n int bodyIdx = int(-w - 0.5);\r\n if (bodyIdx != nodeId) {\r\n vec2 delta = data.xy - pos;\r\n float distSq = dot(delta, delta);\r\n\r\n if (distSq < 1e-8) {\r\n delta = vec2(float(nodeId) * 1e-4 - float(bodyIdx) * 1e-4 + 1e-4, 1e-4);\r\n distSq = dot(delta, delta);\r\n }\r\n\r\n if (distSq < uDistanceMax2) {\r\n float l = distSq;\r\n if (l < uDistanceMin2) l = sqrt(uDistanceMin2 * l);\r\n vel += delta * (data.z * uAlpha / max(l, 1e-6));\r\n }\r\n }\r\n } else {\r\n vec2 delta = data.xy - pos;\r\n float distSq = dot(delta, delta);\r\n\r\n if (distSq > 0.0 && w * w / distSq < uTheta2) {\r\n if (distSq < uDistanceMax2) {\r\n float l = distSq;\r\n if (l < uDistanceMin2) l = sqrt(uDistanceMin2 * l);\r\n vel += delta * (data.z * uAlpha / max(l, 1e-6));\r\n }\r\n } else {\r\n vec4 ch = texelFetch(uTreeChildren, texCoord(idx, uTreeTexWidth), 0);\r\n if (ch.w >= 0.0 && top < 64) stack[top++] = int(ch.w + 0.5);\r\n if (ch.z >= 0.0 && top < 64) stack[top++] = int(ch.z + 0.5);\r\n if (ch.y >= 0.0 && top < 64) stack[top++] = int(ch.y + 0.5);\r\n if (ch.x >= 0.0 && top < 64) stack[top++] = int(ch.x + 0.5);\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (uHasCollision > 0.5 && uCollisionRadius > 0.0 && uTreeNodeCount > 0) {\r\n float collisionDiam = uCollisionRadius * 2.0;\r\n vec2 predictedPos = state.xy + state.zw;\r\n int stack[64];\r\n int top = 0;\r\n stack[top++] = 0;\r\n\r\n while (top > 0) {\r\n int idx = stack[--top];\r\n vec4 data = texelFetch(uTreeData, texCoord(idx, uTreeTexWidth), 0);\r\n float w = data.w;\r\n\r\n if (w < -0.5) {\r\n int bodyIdx = int(-w - 0.5);\r\n if (bodyIdx != nodeId && bodyIdx < uNodeCount) {\r\n vec2 delta = data.xy - predictedPos;\r\n float dist = length(delta);\r\n\r\n if (dist < collisionDiam && dist > 0.0) {\r\n float push = (collisionDiam - dist) * uCollisionStrength;\r\n vel -= (delta / dist) * push * 0.5;\r\n }\r\n }\r\n } else {\r\n vec4 geo = texelFetch(uTreeGeometry, texCoord(idx, uTreeTexWidth), 0);\r\n float cellSize = geo.z;\r\n vec2 nearest = clamp(predictedPos, geo.xy, geo.xy + cellSize);\r\n float distToCell = length(nearest - predictedPos);\r\n\r\n if (distToCell < collisionDiam) {\r\n vec4 ch = texelFetch(uTreeChildren, texCoord(idx, uTreeTexWidth), 0);\r\n if (ch.w >= 0.0 && top < 64) stack[top++] = int(ch.w + 0.5);\r\n if (ch.z >= 0.0 && top < 64) stack[top++] = int(ch.z + 0.5);\r\n if (ch.y >= 0.0 && top < 64) stack[top++] = int(ch.y + 0.5);\r\n if (ch.x >= 0.0 && top < 64) stack[top++] = int(ch.x + 0.5);\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (uHasLinks > 0.5) {\r\n vec4 offData = texelFetch(uAdjOffsets, texCoord(nodeId, uAdjOffsetsTexWidth), 0);\r\n int start = int(offData.x + 0.5);\r\n int count = int(offData.y + 0.5);\r\n\r\n for (int e = 0; e < count; e++) {\r\n vec4 edgeData = texelFetch(uAdjEdges, texCoord(start + e, uAdjEdgesTexWidth), 0);\r\n int targetId = int(edgeData.x + 0.5);\r\n float restDist = edgeData.y;\r\n float strength = edgeData.z;\r\n float dirBias = edgeData.w;\r\n\r\n vec4 targetState = texelFetch(uState, texCoord(targetId, uTexWidth), 0);\r\n vec2 delta = (targetState.xy + targetState.zw) - (state.xy + state.zw);\r\n float d = length(delta);\r\n\r\n if (d < 1e-6) {\r\n delta = vec2(1e-3, 1e-3);\r\n d = length(delta);\r\n }\r\n\r\n float scale = (d - restDist) / d * uAlpha * strength;\r\n vel += delta * scale * dirBias;\r\n }\r\n }\r\n\r\n if (uHasCentering > 0.5) {\r\n vel += (uCenter - pos) * uCenterStrength * uAlpha;\r\n }\r\n\r\n if (uHasPositioning > 0.5) {\r\n vel.x += (uForceXTarget - pos.x) * uForceXStrength * uAlpha;\r\n vel.y += (uForceYTarget - pos.y) * uForceYStrength * uAlpha;\r\n }\r\n\r\n vel *= uDamping;\r\n pos += vel;\r\n\r\n fragColor = vec4(pos, vel);\r\n}\r\n",so.FRAGMENT),n=t.createProgram();if(!n)throw new s("Failed to create program.");if(this._forceProgram=n,t.attachShader(n,e),t.attachShader(n,i),t.linkProgram(n),!t.getProgramParameter(n,t.LINK_STATUS)){const e=t.getProgramInfoLog(n);throw new s(`Failed to link force program: ${e}`)}this._cacheUniformLocations(n),this._quadBuffer=t.createBuffer();const o=new Float32Array([-1,-1,1,-1,-1,1,1,1]);t.bindBuffer(t.ARRAY_BUFFER,this._quadBuffer),t.bufferData(t.ARRAY_BUFFER,o,t.STATIC_DRAW),this._quadVAO=t.createVertexArray(),t.bindVertexArray(this._quadVAO);const r=t.getAttribLocation(n,"aPosition");t.enableVertexAttribArray(r),t.vertexAttribPointer(r,2,t.FLOAT,!1,0,0),t.bindVertexArray(null),this._stateTexA=t.createTexture(),this._stateTexB=t.createTexture(),this._fixedTex=t.createTexture(),this._treeDataTexture=t.createTexture(),this._treeChildrenTexture=t.createTexture(),this._treeGeometryTexture=t.createTexture(),this._adjOffsetsTexture=t.createTexture(),this._adjEdgesTexture=t.createTexture(),this._fboA=t.createFramebuffer(),this._fboB=t.createFramebuffer()}_cacheUniformLocations(t){const e=this._gl,i=["uState","uFixed","uTreeData","uTreeChildren","uTreeGeometry","uAdjOffsets","uAdjEdges","uNodeCount","uTexWidth","uAlpha","uDamping","uManyBodyStrength","uTheta2","uDistanceMin2","uDistanceMax2","uTreeNodeCount","uTreeTexWidth","uAdjOffsetsTexWidth","uAdjEdgesTexWidth","uCenter","uCenterStrength","uCollisionRadius","uCollisionStrength","uForceXTarget","uForceXStrength","uForceYTarget","uForceYStrength","uHasManyBody","uHasLinks","uHasCentering","uHasCollision","uHasPositioning"];for(const n of i)this._uniforms[n]=e.getUniformLocation(t,n)}_uploadDataToGPU(){var t,e,i,n,o,s,r,a;const h=this._gl,l=this._nodes.length;this._texWidth=Math.max(1,Math.ceil(Math.sqrt(l)));const u=this._texWidth*this._texWidth,d=new Float32Array(4*u),c=new Float32Array(4*u);for(let h=0;h0?t.distanceMax:Jn(null!==(i=null===(e=this._settings.links)||void 0===e?void 0:e.distance)&&void 0!==i?i:50);c.uniform1f(g.uDistanceMax2,o*o),c.uniform1i(g.uTreeNodeCount,this._treeNodeCount),c.uniform1i(g.uTreeTexWidth,this._treeTexWidth)}const m=null!==this._cachedAdjacency&&this._edges.length>0;c.uniform1f(g.uHasLinks,m?1:0),m&&(c.uniform1i(g.uAdjOffsetsTexWidth,this._cachedAdjacency.offsetsTexWidth),c.uniform1i(g.uAdjEdgesTexWidth,this._cachedAdjacency.edgesTexWidth)),c.uniform1f(g.uHasCentering,0);const v=null!==this._settings.collision&&void 0!==this._settings.collision;c.uniform1f(g.uHasCollision,v?1:0),v&&(c.uniform1f(g.uCollisionRadius,this._settings.collision.radius),c.uniform1f(g.uCollisionStrength,this._settings.collision.strength));const y=null!==this._settings.positioning&&void 0!==this._settings.positioning;if(c.uniform1f(g.uHasPositioning,y?1:0),y){const t=this._settings.positioning;c.uniform1f(g.uForceXTarget,null!==(o=null===(n=t.forceX)||void 0===n?void 0:n.x)&&void 0!==o?o:0),c.uniform1f(g.uForceXStrength,null!==(a=null===(r=t.forceX)||void 0===r?void 0:r.strength)&&void 0!==a?a:0),c.uniform1f(g.uForceYTarget,null!==(l=null===(h=t.forceY)||void 0===h?void 0:h.y)&&void 0!==l?l:0),c.uniform1f(g.uForceYStrength,null!==(d=null===(u=t.forceY)||void 0===u?void 0:u.strength)&&void 0!==d?d:0)}const x=this._pingPong?this._stateTexA:this._stateTexB,b=this._pingPong?this._fboB:this._fboA;c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,x),c.uniform1i(g.uState,0),c.activeTexture(c.TEXTURE1),c.bindTexture(c.TEXTURE_2D,this._fixedTex),c.uniform1i(g.uFixed,1),c.activeTexture(c.TEXTURE2),c.bindTexture(c.TEXTURE_2D,this._treeDataTexture),c.uniform1i(g.uTreeData,2),c.activeTexture(c.TEXTURE3),c.bindTexture(c.TEXTURE_2D,this._treeChildrenTexture),c.uniform1i(g.uTreeChildren,3),c.activeTexture(c.TEXTURE4),c.bindTexture(c.TEXTURE_2D,this._adjOffsetsTexture),c.uniform1i(g.uAdjOffsets,4),c.activeTexture(c.TEXTURE5),c.bindTexture(c.TEXTURE_2D,this._adjEdgesTexture),c.uniform1i(g.uAdjEdges,5),c.activeTexture(c.TEXTURE6),c.bindTexture(c.TEXTURE_2D,this._treeGeometryTexture),c.uniform1i(g.uTreeGeometry,6),c.bindFramebuffer(c.FRAMEBUFFER,b),c.viewport(0,0,this._texWidth,this._texWidth),c.bindVertexArray(this._quadVAO),c.drawArrays(c.TRIANGLE_STRIP,0,4),c.bindVertexArray(null),c.bindFramebuffer(c.FRAMEBUFFER,null),this._pingPong=!this._pingPong}_readbackFromGPU(){const t=this._gl,e=this._nodes.length;if(0===e)return;const i=this._pingPong?this._fboA:this._fboB,n=this._texWidth*this._texWidth,o=new Float32Array(4*n);t.bindFramebuffer(t.FRAMEBUFFER,i),t.readPixels(0,0,this._texWidth,this._texWidth,t.RGBA,t.FLOAT,o),t.bindFramebuffer(t.FRAMEBUFFER,null);for(let t=0;tt.id)),i=this._nodes.filter(t=>e.has(t.id)),n=t.nodes.filter(t=>void 0===this._nodeIndexByNodeId[t.id]);this._nodes=[...i,...n],this._edges=t.edges,this._rebuildNodeIndex(),this._calculateAndEmit()}deleteData(t){if(t.nodeIds){const e=new Set(t.nodeIds);this._nodes=this._nodes.filter(t=>!e.has(t.id))}if(t.edgeIds){const e=new Set(t.edgeIds);this._edges=this._edges.filter(t=>!e.has(t.id))}this._rebuildNodeIndex(),this._calculateAndEmit()}patchData(t){if(t.nodes)for(let e=0;e0&&this._calculateAndEmit()}terminate(){this._pendingRecalculation=!1,super.terminate()}_calculateAndEmit(){0===this._nodes.length||this._cancelSimulation||(this._isCalculating?this._pendingRecalculation=!0:(this._isCalculating=!0,this.emit(Dn.SIMULATION_START,void 0),this.calculatePositions(this._nodes,this._edges,t=>{this.emit(Dn.SIMULATION_PROGRESS,{nodes:this._nodes,edges:this._edges,progress:t})},()=>this._cancelSimulation,()=>{this._isCalculating=!1,this._cancelSimulation||this.emit(Dn.SIMULATION_END,{nodes:this._nodes,edges:this._edges}),this._cancelSimulation=!1,this._pendingRecalculation&&(this._pendingRecalculation=!1,this._calculateAndEmit())})))}_emitProgress(t,e,i,n){const o=Math.round(100*t/e);return o>i?(n(o/100),o):i}}class lo extends ho{constructor(t){super(),this.type="circular",this._config=Object.assign(Object.assign({},Qn),t)}calculatePositions(t,e,i,n,o){const s=2*Math.PI/t.length;let r=-1,a=0;const h=()=>{if(n())return void o();const e=Math.min(a+5e3,t.length);for(;a{if(n())return void o();const e=Math.min(h+5e3,t.length);for(;h{if(n()||c>=a.length)return!n()&&this._config.reversed&&this._applyReversal(t,h,l),void o();const e=this._assignLevels(a[c],s,r),f=Math.max(...Array.from(e.values()).map(t=>t.length));e.size*this._config.levelGap>l&&(l=e.size*this._config.levelGap);let g=0===c?0:this._config.treeGap+h;c>0&&(g+=(f-1)*this._config.nodeGap/2);for(let i=0;ih&&(h=a),void 0!==r&&(t[r].x="horizontal"===this._config.orientation?n:a,t[r].y="horizontal"===this._config.orientation?a:n),u++}}c++,c0;){const t=h.pop();if(void 0===t)continue;a.push(t);const o=null!==(i=e.get(t))&&void 0!==i?i:[];for(let t=0;t{var e;return 0===(null!==(e=i.get(t))&&void 0!==e?e:0)});void 0===a&&(a=t.reduce((t,e)=>{var n,o;return(null!==(n=i.get(e))&&void 0!==n?n:0)<(null!==(o=i.get(t))&&void 0!==o?o:0)?e:t}));const h=[[a,0]];for(const[t,i]of h){if(r.has(t))continue;r.add(t),s.has(i)?null===(n=s.get(i))||void 0===n||n.push(t):s.set(i,[t]);const a=null!==(o=e.get(t))&&void 0!==o?o:[];for(let t=0;t{this.emit(Dn.SIMULATION_START,void 0),this._isSimulationRunning=!0}),this._engine.on(Dn.SIMULATION_PROGRESS,t=>{this.emit(Dn.SIMULATION_PROGRESS,t)}),this._engine.on(Dn.SIMULATION_END,t=>{this.emit(Dn.SIMULATION_END,t),this._isSimulationRunning=!1}),this._engine.on(Dn.SIMULATION_STEP,t=>{this.emit(Dn.SIMULATION_STEP,t)}),this._engine.on(Dn.NODE_DRAG,t=>{this.emit(Dn.NODE_DRAG,t)}),this._engine.on(Dn.SETTINGS_UPDATE,t=>{this.emit(Dn.SETTINGS_UPDATE,t)})}}var go,po;!function(t){t.SetupData="Set Data",t.MergeData="Add Data",t.UpdateData="Update Data",t.DeleteData="Delete Data",t.PatchData="Patch Data",t.ClearData="Clear Data",t.ActivateSimulation="Activate Simulation",t.UpdateSimulation="Update Simulation",t.StopSimulation="Stop Simulation",t.StartDragNode="Start Drag Node",t.DragNode="Drag Node",t.EndDragNode="End Drag Node",t.FixNodes="Fix Nodes",t.ReleaseNodes="Release Nodes",t.SetSettings="Set Settings"}(go||(go={})),function(t){t.SIMULATION_START="simulation-start",t.SIMULATION_STEP="simulation-step",t.SIMULATION_PROGRESS="simulation-progress",t.SIMULATION_END="simulation-end",t.SIMULATION_TICK="simulation-tick",t.NODE_DRAG="node-drag",t.NODE_DRAG_END="node-drag-end",t.SETTINGS_UPDATE="settings-update"}(po||(po={}));class mo extends t{constructor(t){super(),this._isSimulationRunning=!1,this._worker=new Worker(new URL(i.p+i.u(89),i.b),{type:void 0}),this.emitToWorker({type:go.SetSettings,data:t}),this._worker.onmessage=({data:t})=>{switch(t.type){case po.SIMULATION_START:this.emit(Dn.SIMULATION_START,void 0),this._isSimulationRunning=!0;break;case po.SIMULATION_PROGRESS:this.emit(Dn.SIMULATION_PROGRESS,t.data);break;case po.SIMULATION_END:this.emit(Dn.SIMULATION_END,t.data),this._isSimulationRunning=!1;break;case po.SIMULATION_STEP:this.emit(Dn.SIMULATION_STEP,t.data);break;case po.NODE_DRAG:this.emit(Dn.NODE_DRAG,t.data);break;case po.NODE_DRAG_END:this.emit(Dn.NODE_DRAG_END,t.data);break;case po.SETTINGS_UPDATE:this.emit(Dn.SETTINGS_UPDATE,t.data)}}}setupData(t){this.emitToWorker({type:go.SetupData,data:t})}mergeData(t){this.emitToWorker({type:go.MergeData,data:t})}updateData(t){this.emitToWorker({type:go.UpdateData,data:t})}deleteData(t){this.emitToWorker({type:go.DeleteData,data:t})}patchData(t){this.emitToWorker({type:go.PatchData,data:t})}clearData(){this.emitToWorker({type:go.ClearData})}activateSimulation(){this.emitToWorker({type:go.ActivateSimulation})}stopSimulation(){this.emitToWorker({type:go.StopSimulation})}updateSimulation(t,e){this.emitToWorker({type:go.UpdateSimulation,data:{nodes:t,edges:e}})}startDragNode(){this.emitToWorker({type:go.StartDragNode})}dragNode(t,e){this.emitToWorker({type:go.DragNode,data:Object.assign({id:t},e)})}endDragNode(t){this.emitToWorker({type:go.EndDragNode,data:{id:t}})}fixNodes(t){this.emitToWorker({type:go.FixNodes,data:{nodes:t}})}releaseNodes(t){this.emitToWorker({type:go.ReleaseNodes,data:{nodes:t}})}setSettings(t){this.emitToWorker({type:go.SetSettings,data:t})}isSimulationRunning(){return this._isSimulationRunning}terminate(){this._worker.terminate(),this.removeAllListeners()}emitToWorker(t){this._worker.postMessage(t)}}class vo{static getSimulator(t){const e=Object.assign({type:"force"},t),i=e.options;if("force"===e.type&&(null==i?void 0:i.useGPU))return new fo(e);try{if("undefined"!=typeof Worker)return new mo(e);throw new Error("WebWorkers are unavailable in your environment.")}catch(t){return console.error("Could not create simulator in a WebWorker context. All calculations will be done in the main thread.",t),new fo(e)}}}const yo=t=>{const e=t.start,i=t.end;return e{if(!this.sortBy)return 0;const i=this.getOne(t),n=this.getOne(e);return void 0===i||void 0===n?0:this.sortBy(i,n)})}get size(){return this.entityById.size}}const bo=(...t)=>{const e=t.reduce((t,e)=>t.concat(e),[]);return Array.from(new Set(e))};class wo extends l{constructor(t,e){var i,n;super(),this._nodes=new xo({getId:t=>t.getId(),sortBy:(t,e)=>{var i,n;return(null!==(i=t.getStyle().zIndex)&&void 0!==i?i:0)-(null!==(n=e.getStyle().zIndex)&&void 0!==n?n:0)}}),this._edges=new xo({getId:t=>t.getId(),sortBy:(t,e)=>{var i,n;return(null!==(i=t.getStyle().zIndex)&&void 0!==i?i:0)-(null!==(n=e.getStyle().zIndex)&&void 0!==n?n:0)}}),this._update=t=>{if(t&&"type"in t&&"options"in t&&"isSingle"in t.options){if("node"===t.type&&t.options.isSingle){const e=this._nodes.getAll();for(let i=0;it.isSelected())}getSelectedEdges(){return this.getEdges(t=>t.isSelected())}getHoveredNodes(){return this.getNodes(t=>t.isHovered())}getHoveredEdges(){return this.getEdges(t=>t.isHovered())}getNodePositions(t){const e=this.getNodes(t),i=new Array(e.length);for(let t=0;tt.id),e=this._edges.getAll().map(t=>t.id);this.remove({nodeIds:t,edgeIds:e})}removeAllEdges(){const t=this._edges.getAll().map(t=>t.id);this.remove({edgeIds:t})}removeAllNodes(){this.removeAll()}isEqual(t){if(this.getNodeCount()!==t.getNodeCount())return!1;if(this.getEdgeCount()!==t.getEdgeCount())return!1;const e=this.getNodes();for(let i=0;ii.x&&(i.x=o+r),o-ri.y&&(i.y=s+r),s-r=0;i--)if(e[i].includesPoint(t))return e[i]}getNearestEdge(t,e=3){let i,n=e;const o=this.getEdges();for(let e=0;e{var t,e;return null===(e=null===(t=this._settings)||void 0===t?void 0:t.onLoadedImages)||void 0===e?void 0:e.call(t)},listeners:[this._update]});this._nodes.setMany(e)}_insertEdges(t){const e=[];for(let i=0;i{var t,e;return null===(e=null===(t=this._settings)||void 0===t?void 0:t.onLoadedImages)||void 0===e?void 0:e.call(t)},listeners:[this._update]}))}this._nodes.setMany(e)}_upsertEdges(t){const e=[],i=[];for(let n=0;n{var e;const i=new Array(t.length),n=(t=>{var e;const i={},n=new Set;for(let o=0;oe+1);continue}if(r<=1)continue;const a=[];r%2!=0&&a.push(0);for(let t=2;t<=r;t+=2)a.push(t/2),a.push(t/2*-1);o[e]=a}return o})(t);for(let o=0;o{var t,e;null===(e=null===(t=this._settings)||void 0===t?void 0:t.onLoadedImages)||void 0===e||e.call(t)}),this._nodes.sort(),this._edges.sort()}}const So=(t,e)=>{var i;null===(i=null==e?void 0:e.cascade)||void 0===i||i?Io(t,r.SELECTED,{isStateOverride:!0}):t.setState(r.SELECTED,{isNotifySkipped:!0})},Eo=(t,e)=>{var i;null===(i=null==e?void 0:e.cascade)||void 0===i||i?Do(t,r.SELECTED,{isStateOverride:!0}):t.setState(r.SELECTED,{isNotifySkipped:!0})},To=(t,e)=>{var i;null===(i=null==e?void 0:e.cascade)||void 0===i||i?Io(t,r.NONE,{isStateOverride:!0}):t.clearState()},Po=(t,e)=>{var i;null===(i=null==e?void 0:e.cascade)||void 0===i||i?Do(t,r.NONE,{isStateOverride:!0}):t.clearState()},Co=(t,e,i)=>{Mo(t),So(e,i)},Ao=(t,e,i)=>{Mo(t),Eo(e,i)},Mo=t=>{const e=t.getNodes(t=>t.isSelected());for(let t=0;tt.isSelected());for(let t=0;t{Io(t,r.HOVERED)},No=t=>{const e=t.getNodes(t=>t.isHovered());for(let t=0;tt.isHovered());for(let t=0;t{Oo(t,i)&&t.setState(e,{isNotifySkipped:!0}),t.getInEdges().forEach(t=>{t&&Oo(t,i)&&t.setState(e,{isNotifySkipped:!0}),t.startNode&&Oo(t.startNode,i)&&t.startNode.setState(e,{isNotifySkipped:!0})}),t.getOutEdges().forEach(t=>{t&&Oo(t,i)&&t.setState(e,{isNotifySkipped:!0}),t.endNode&&Oo(t.endNode,i)&&t.endNode.setState(e,{isNotifySkipped:!0})})},Do=(t,e,i)=>{Oo(t,i)&&t.setState(e,{isNotifySkipped:!0}),t.startNode&&Oo(t.startNode,i)&&t.startNode.setState(e,{isNotifySkipped:!0}),t.endNode&&Oo(t.endNode,i)&&t.endNode.setState(e,{isNotifySkipped:!0})},Oo=(t,e)=>{const i=null==e?void 0:e.isStateOverride;return i||!i&&!t.getState()};class Ro{constructor(t){this.isSelectEnabled=t.isDefaultSelectEnabled,this.isHoverEnabled=t.isDefaultHoverEnabled,this.isMultiSelectEnabled=t.isDefaultMultiSelectEnabled,this.isSelectCascadeEnabled=t.isDefaultSelectCascadeEnabled}onMouseClick(t,e,i){var n;const o=this.isMultiSelectEnabled&&null!==(n=null==i?void 0:i.isAppend)&&void 0!==n&&n,s=t.getNearestNode(e);if(s)return this.isSelectEnabled&&(o?(t=>{t.isSelected()?To(t,{cascade:!1}):So(t,{cascade:!1})})(s):Co(t,s,{cascade:this.isSelectCascadeEnabled})),{isStateChanged:!0,changedSubject:s};const r=t.getNearestEdge(e);if(r)return this.isSelectEnabled&&(o?(t=>{t.isSelected()?Po(t,{cascade:!1}):Eo(t,{cascade:!1})})(r):Ao(t,r,{cascade:this.isSelectCascadeEnabled})),{isStateChanged:!0,changedSubject:r};if(!this.isSelectEnabled||o)return{isStateChanged:!1};const{changedCount:a}=Mo(t);return{isStateChanged:a>0}}onMouseMove(t,e){const i=t.getNearestNode(e);if(i&&(!this.isSelectEnabled||this.isSelectEnabled&&!i.isSelected()))return i===this._lastHoveredNode?{changedSubject:i,isStateChanged:!1}:(this.isHoverEnabled&&((t,e)=>{No(t),Lo(e)})(t,i),this._lastHoveredNode=i,{isStateChanged:!0,changedSubject:i});if(this._lastHoveredNode=void 0,!i&&this.isHoverEnabled){const{changedCount:e}=No(t);return{isStateChanged:e>0}}return{isStateChanged:!1}}onMouseRightClick(t,e){const i=t.getNearestNode(e);if(i)return this.isSelectEnabled&&Co(t,i,{cascade:this.isSelectCascadeEnabled}),{isStateChanged:!0,changedSubject:i};const n=t.getNearestEdge(e);if(n)return this.isSelectEnabled&&Ao(t,n,{cascade:this.isSelectCascadeEnabled}),{isStateChanged:!0,changedSubject:n};if(!this.isSelectEnabled)return{isStateChanged:!1};const{changedCount:o}=Mo(t);return{isStateChanged:o>0}}onMouseDoubleClick(t,e){const i=t.getNearestNode(e);if(i)return this.isSelectEnabled&&Co(t,i,{cascade:this.isSelectCascadeEnabled}),{isStateChanged:!0,changedSubject:i};const n=t.getNearestEdge(e);if(n)return this.isSelectEnabled&&Ao(t,n,{cascade:this.isSelectCascadeEnabled}),{isStateChanged:!0,changedSubject:n};if(!this.isSelectEnabled)return{isStateChanged:!1};const{changedCount:o}=Mo(t);return{isStateChanged:o>0}}}var zo,Bo;!function(t){t.CANVAS="canvas",t.WEBGL="webgl"}(zo||(zo={})),function(t){t.RESIZE="resize",t.RENDER_START="render-start",t.RENDER_END="render-end"}(Bo||(Bo={}));const ko={devicePixelRatio:null,fps:60,minZoom:.25,maxZoom:8,fitZoomMargin:.2,labelsIsEnabled:!0,labelsOnEventIsEnabled:!0,shadowIsEnabled:!0,shadowOnEventIsEnabled:!0,contextAlphaOnEvent:.3,contextAlphaOnEventIsEnabled:!0,backgroundColor:null,areCollapsedContainerDimensionsAllowed:!1},Uo="Roboto, sans-serif";var jo;!function(t){t.TOP="top",t.MIDDLE="middle"}(jo||(jo={}));class Zo{constructor(t,e){var i,n;this.textLines=[],this.fontSize=4,this.fontFamily=Ho(4,Uo),this.text=`${void 0===t?"":t}`,this.textLines=Vo(this.text),this.position=e.position,this.properties=e.properties,this.textBaseline=e.textBaseline,(void 0!==this.properties.fontSize||this.properties.fontFamily)&&(this.fontSize=Math.max(null!==(i=this.properties.fontSize)&&void 0!==i?i:0,0),this.fontFamily=Ho(this.fontSize,null!==(n=this.properties.fontFamily)&&void 0!==n?n:Uo)),this._fixPosition()}_fixPosition(){if(this.textBaseline===jo.MIDDLE&&this.textLines.length){const t=Math.floor(this.textLines.length/2),e=(this.textLines.length-1)/2;this.position.y-=e*this.fontSize-t*(1.2-1)}}}const Fo=(t,e)=>{e.textLines.length>0&&e.fontSize>0&&e.position&&(Go(t,e),Wo(t,e))},Go=(t,e)=>{if(!e.properties.fontBackgroundColor||!e.position)return;t.fillStyle=e.properties.fontBackgroundColor.toString();const i=.12*e.fontSize,n=e.fontSize+2*i,o=1.2*e.fontSize,s=e.textBaseline===jo.MIDDLE?e.fontSize/2:0;for(let r=0;r{var i;if(!e.position)return;t.fillStyle=(null!==(i=e.properties.fontColor)&&void 0!==i?i:"#000000").toString(),t.font=e.fontFamily,t.textBaseline=e.textBaseline,t.textAlign="center";const n=1.2*e.fontSize;for(let i=0;i`${t}px ${e}`,Vo=t=>{const e=t.split("\n"),i=[];for(let t=0;t{var e,i;const n=null!==(e=t.getStyle().arrowSize)&&void 0!==e?e:1,o=null!==(i=t.getWidth())&&void 0!==i?i:1,s=t.endNode,r=t.getCurvedControlPoint(),a=$o(t,s),h=qo(t,Math.max(0,Math.min(1,a.t+-.1)),r),l=Math.atan2(a.y-h.y,a.x-h.x),u=1.5*n+3*o;return{point:a,core:{x:a.x-.9*u*Math.cos(l),y:a.y-.9*u*Math.sin(l)},angle:l,length:u}},qo=(t,e,i)=>{const n=t.startNode.getCenter(),o=t.endNode.getCenter();if(!n||!o)return{x:0,y:0};const s=e;return{x:Math.pow(1-s,2)*n.x+2*s*(1-s)*i.x+Math.pow(s,2)*o.x,y:Math.pow(1-s,2)*n.y+2*s*(1-s)*i.y+Math.pow(s,2)*o.y}},$o=(t,e)=>{let i,n,o,s=0,r=0,a=1,h={x:0,y:0,t:0};const l=t.getCurvedControlPoint();let u=t.endNode,d=!1;e.getId()===t.startNode.getId()&&(u=t.startNode,d=!0);const c=u.getCenter();let _;for(;r<=a&&s<10&&(_=.5*(r+a),h=Object.assign(Object.assign({},qo(t,_,l)),{t:0}),i=u.getDistanceToBorder(),n=Math.sqrt(Math.pow(h.x-c.x,2)+Math.pow(h.y-c.y,2)),o=i-n,!(Math.abs(o)<.2));)o<0?!1===d?r=_:a=_:!1===d?a=_:r=_,s++;return h.t=null!=_?_:0,h},Yo=t=>{var e,i;const n=null!==(e=t.getStyle().arrowSize)&&void 0!==e?e:1,o=null!==(i=t.getWidth())&&void 0!==i?i:1,s=t.startNode,r=Qo(t,s),a=-2*r.t*Math.PI+.45*Math.PI,h=1.5*n+3*o;return{point:r,core:{x:r.x-.9*h*Math.cos(a),y:r.y-.9*h*Math.sin(a)},angle:a,length:h}},Ko=(t,e)=>{const i=2*e*Math.PI;return{x:t.x+t.radius*Math.cos(i),y:t.y-t.radius*Math.sin(i)}},Qo=(t,e)=>{const i=t.getCircularData();let n=.6,o=1;let s,r,a,h=0,l={x:0,y:0,t:0},u=.5*(n+o);const d=e.getCenter();for(;n<=o&&h<10&&(u=.5*(n+o),l=Object.assign(Object.assign({},Ko(i,u)),{t:0}),s=e.getDistanceToBorder(),r=Math.sqrt(Math.pow(l.x-d.x,2)+Math.pow(l.y-d.y,2)),a=s-r,!(Math.abs(a)<.05));)a>0?n=u:o=u,h++;return l.t=null!=u?u:0,l},Jo=t=>{var e,i;const n=null!==(e=t.getStyle().arrowSize)&&void 0!==e?e:1,o=null!==(i=t.getWidth())&&void 0!==i?i:1,s=t.startNode.getCenter(),r=t.endNode.getCenter(),a=Math.atan2(r.y-s.y,r.x-s.x),h=ts(t,t.endNode),l=1.5*n+3*o;return{point:h,core:{x:h.x-.9*l*Math.cos(a),y:h.y-.9*l*Math.sin(a)},angle:a,length:l}},ts=(t,e)=>{let i=t.endNode,n=t.startNode;e.getId()===t.startNode.getId()&&(i=t.startNode,n=t.endNode);const o=i.getCenter(),s=n.getCenter(),r=o.x-s.x,a=o.y-s.y,h=Math.sqrt(r*r+a*a),l=(h-e.getDistanceToBorder())/h;return{x:(1-l)*s.x+l*o.x,y:(1-l)*s.y+l*o.y,t:0}},es=t=>{if(t instanceof R)return Jo(t);if(t instanceof z)return Xo(t);if(t instanceof B)return Yo(t);throw new Error("Failed to draw unsupported edge type")},is=(t,e)=>{const i=e.point.x,n=e.point.y,o=e.angle,s=e.length;for(let e=0;e{const i=e.getCenter(),n=e.getRadius();switch(e.getStyle().shape){case w.SQUARE:((t,e,i,n)=>{t.beginPath(),t.rect(e-n,i-n,2*n,2*n),t.closePath()})(t,i.x,i.y,n);break;case w.DIAMOND:((t,e,i,n)=>{t.beginPath(),t.lineTo(e,i+n),t.lineTo(e+n,i),t.lineTo(e,i-n),t.lineTo(e-n,i),t.closePath()})(t,i.x,i.y,n);break;case w.TRIANGLE:((t,e,i,n)=>{t.beginPath(),i+=.275*(n*=1.15);const o=2*n,s=Math.sqrt(3)*o/6,r=Math.sqrt(o*o-n*n);t.moveTo(e,i-(r-s)),t.lineTo(e+n,i+s),t.lineTo(e-n,i+s),t.lineTo(e,i-(r-s)),t.closePath()})(t,i.x,i.y,n);break;case w.TRIANGLE_DOWN:((t,e,i,n)=>{t.beginPath(),i-=.275*(n*=1.15);const o=2*n,s=Math.sqrt(3)*o/6,r=Math.sqrt(o*o-n*n);t.moveTo(e,i+(r-s)),t.lineTo(e+n,i-s),t.lineTo(e-n,i-s),t.lineTo(e,i+(r-s)),t.closePath()})(t,i.x,i.y,n);break;case w.STAR:((t,e,i,n)=>{t.beginPath(),i+=.1*(n*=.82);for(let o=0;o<10;o++){const s=n*(o%2==0?1.3:.5),r=e+s*Math.sin(2*o*Math.PI/10),a=i-s*Math.cos(2*o*Math.PI/10);t.lineTo(r,a)}t.closePath()})(t,i.x,i.y,n);break;case w.HEXAGON:((t,e,i,n)=>{((t,e,i,n,o)=>{t.beginPath(),t.moveTo(e+n,i);const s=2*Math.PI/o;for(let r=1;r{t.beginPath(),t.arc(e,i,n,0,2*Math.PI,!1),t.closePath()})(t,i.x,i.y,n)}},os=(t,e=300)=>{let i=0,n=null;return function(){const o=arguments,s=Date.now(),r=e-(s-i);r<=0?(n&&(clearTimeout(n),n=null),i=s,t(...o)):n||(n=setTimeout(()=>{i=Date.now(),n=null,t(...o)},r))}},ss=t=>{const e=Math.max(t,1);return Math.round(1e3/e)},rs=(t,e=!1)=>{t.style.position="relative";const i=getComputedStyle(t);i.display||(t.style.display="block",console.warn("[Orb] Graph container doesn't have defined 'display' property. Setting 'display' to 'block'...")),!e&&hs(i.width)&&(t.style.width="100%",hs(getComputedStyle(t).width)?(t.style.width="400px",console.warn("[Orb] The graph container element and its parent don't have defined width properties.","If you are using percentage values,","please make sure that the parent element of the graph container has a defined position and width.","Setting the width of the graph container to an arbitrary value of '400px'...")):console.warn("[Orb] The graph container element doesn't have defined width. Setting width to 100%...")),!e&&hs(i.height)&&(t.style.height="100%",hs(getComputedStyle(t).height)?(t.style.height="400px",console.warn("[Orb] The graph container element and its parent don't have defined height properties.","If you are using percentage values,","please make sure that the parent element of the graph container has a defined position and height.","Setting the height of the graph container to an arbitrary value of '400px'...")):console.warn("[Orb] Graph container doesn't have defined height. Setting height to 100%..."))},as=/^\s*0+\s*(?:px|rem|em|vh|vw)?\s*$/i,hs=t=>null==t||""===t||as.test(t),ls=t=>{const e=document.createElement("canvas");return e.style.position="absolute",e.style.top="0",e.style.left="0",t.appendChild(e),e},us=t=>{let e=window.devicePixelRatio,i=()=>{};const n=()=>{i();const o=matchMedia(`(resolution: ${e}dppx)`);o.addEventListener("change",n),i=()=>o.removeEventListener("change",n),window.devicePixelRatio!==e&&(e=window.devicePixelRatio,t(e))};return n(),()=>i()};class ds extends t{constructor(t,e){super(),this._isOriginCentered=!1,this._isInitiallyRendered=!1,rs(t,null==e?void 0:e.areCollapsedContainerDimensionsAllowed),this._container=t,this._canvas=ls(t);const i=this._canvas.getContext("2d");if(!i)throw new s("Failed to create Canvas context.");this._context=i,this._width=640,this._height=480,this.transform=Sn,this._settings=Object.assign(Object.assign({},ko),e),this._resizeObs=new ResizeObserver(()=>this._resize()),this._resizeObs.observe(this._container),this._resize(),u(null==e?void 0:e.devicePixelRatio)||(this._dprObserveUnsubscribe=us(()=>this._resize())),this._throttleRender=os(t=>{this._render(t)},ss(this._settings.fps))}get width(){return this._width}get height(){return this._height}get container(){return this._container}get canvas(){return this._canvas}get isInitiallyRendered(){return this._isInitiallyRendered}getSettings(){return p(this._settings)}setSettings(t){var e;const i=t.fps&&t.fps!==this._settings.fps,n=this._settings.devicePixelRatio,o=t.devicePixelRatio;this._settings=Object.assign(Object.assign({},this._settings),t),i&&(this._throttleRender=os(t=>{this._render(t)},ss(this._settings.fps))),!u(n)&&u(o)&&(null===(e=this._dprObserveUnsubscribe)||void 0===e||e.call(this),this._resize()),u(n)&&null===o&&(this._dprObserveUnsubscribe=us(()=>this._resize()))}render(t){this._throttleRender(t)}_render(t){this.emit(Bo.RENDER_START,void 0);const e=Date.now();this._context.clearRect(0,0,this._width,this._height),this._settings.backgroundColor&&(this._context.fillStyle=this._settings.backgroundColor.toString(),this._context.fillRect(0,0,this._width,this._height)),this._context.save(),this._context.translate(this.transform.x,this.transform.y),this._context.scale(this.transform.k,this.transform.k),this._isOriginCentered&&this._context.translate(this._width/2,this._height/2),this.drawObjects(t.getEdges()),this.drawObjects(t.getNodes()),this._context.restore(),this.emit(Bo.RENDER_END,{durationMs:Date.now()-e}),this._isInitiallyRendered=!0}drawObjects(t){if(0===t.length)return;const e=[],i=[];for(let n=0;n{var n,o;const s=null===(n=null==i?void 0:i.isShadowEnabled)||void 0===n||n,r=null===(o=null==i?void 0:i.isLabelEnabled)||void 0===o||o,a=e.hasShadow();((t,e)=>{if(e.hasBorder()){t.lineWidth=e.getBorderWidth();const i=e.getBorderColor();i&&(t.strokeStyle=i.toString())}const i=e.getColor();i&&(t.fillStyle=i.toString())})(t,e),s&&a&&((t,e)=>{const i=e.getStyle();i.shadowColor&&(t.shadowColor=i.shadowColor.toString()),i.shadowSize&&(t.shadowBlur=i.shadowSize),i.shadowOffsetX&&(t.shadowOffsetX=i.shadowOffsetX),i.shadowOffsetY&&(t.shadowOffsetY=i.shadowOffsetY)})(t,e),ns(t,e),t.fill();const h=e.getBackgroundImage();h&&((t,e,i)=>{if(!i.width||!i.height)return;const n=e.getCenter(),o=e.getRadius(),s=Math.max(2*o/i.width,2*o/i.height),r=i.height*s,a=i.width*s;t.save(),t.clip(),t.drawImage(i,n.x-a/2,n.y-r/2,a,r),t.restore()})(t,e,h),s&&a&&((t,e)=>{const i=e.getStyle();i.shadowColor&&(t.shadowColor="rgba(0,0,0,0)"),i.shadowSize&&(t.shadowBlur=0),i.shadowOffsetX&&(t.shadowOffsetX=0),i.shadowOffsetY&&(t.shadowOffsetY=0)})(t,e),e.hasBorder()&&t.stroke(),r&&((t,e)=>{const i=e.getLabel();if(!i)return;const n=e.getCenter(),o=1.2*e.getBorderedRadius(),s=e.getStyle(),r=new Zo(i,{position:{x:n.x,y:n.y+o},textBaseline:jo.TOP,properties:{fontBackgroundColor:s.fontBackgroundColor,fontColor:s.fontColor,fontFamily:s.fontFamily,fontSize:s.fontSize}});Fo(t,r)})(t,e)})(this._context,t,e):((t,e,i)=>{var n,o;if(!e.getWidth())return;const s=null===(n=null==i?void 0:i.isShadowEnabled)||void 0===n||n,r=null===(o=null==i?void 0:i.isLabelEnabled)||void 0===o||o,a=e.hasShadow();((t,e)=>{const i=e.getWidth();i>0&&(t.lineWidth=i);const n=e.getColor();n&&(t.strokeStyle=n.toString(),t.fillStyle=n.toString())})(t,e),s&&a&&((t,e)=>{const i=e.getStyle();i.shadowColor&&(t.shadowColor=i.shadowColor.toString()),i.shadowSize&&(t.shadowBlur=i.shadowSize),i.shadowOffsetX&&(t.shadowOffsetX=i.shadowOffsetX),i.shadowOffsetY&&(t.shadowOffsetY=i.shadowOffsetY)})(t,e),((t,e)=>{if(0===e.getStyle().arrowSize)return;const i=es(e),n=is([{x:0,y:0},{x:-1,y:.4},{x:-1,y:-.4}],i);t.beginPath();for(let e=0;e{if(e instanceof R)return((t,e)=>{const i=e.startNode.getCenter(),n=e.endNode.getCenter();if(!i||!n)return;t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(n.x,n.y);const o=e.getLineDashPattern();t.setLineDash(null!=o?o:[]),t.stroke()})(t,e);if(e instanceof z)return((t,e)=>{const i=e.startNode.getCenter(),n=e.endNode.getCenter();if(!i||!n)return;const o=e.getCurvedControlPoint();t.beginPath(),t.moveTo(i.x,i.y),t.quadraticCurveTo(o.x,o.y,n.x,n.y);const s=e.getLineDashPattern();t.setLineDash(null!=s?s:[]),t.stroke()})(t,e);if(e instanceof B)return((t,e)=>{const{x:i,y:n,radius:o}=e.getCircularData();t.beginPath(),t.arc(i,n,o,0,2*Math.PI,!1),t.closePath();const s=e.getLineDashPattern();t.setLineDash(null!=s?s:[]),t.stroke()})(t,e);throw new Error("Failed to draw unsupported edge type")})(t,e),s&&a&&((t,e)=>{const i=e.getStyle();i.shadowColor&&(t.shadowColor="rgba(0,0,0,0)"),i.shadowSize&&(t.shadowBlur=0),i.shadowOffsetX&&(t.shadowOffsetX=0),i.shadowOffsetY&&(t.shadowOffsetY=0)})(t,e),r&&((t,e)=>{const i=e.getLabel();if(!i)return;const n=e.getStyle(),o=new Zo(i,{position:e.getCenter(),textBaseline:jo.MIDDLE,properties:{fontBackgroundColor:n.fontBackgroundColor,fontColor:n.fontColor,fontFamily:n.fontFamily,fontSize:n.fontSize}});Fo(t,o)})(t,e)})(this._context,t,e)}reset(){this.transform=Sn,this._context.clearRect(0,0,this._width,this._height),this._context.save()}getFitZoomTransform(t,e){const i=t.getBoundingBox(),n="center"===(null==e?void 0:e.anchorX)?i.x+i.width/2:"end"===(null==e?void 0:e.anchorX)?i.x+i.width:0,o="center"===(null==e?void 0:e.anchorY)?i.y+i.height/2:"end"===(null==e?void 0:e.anchorY)?i.y+i.height:0,s=this.getSimulationViewRectangle(),r=s.height/(i.height*(1+this._settings.fitZoomMargin)),a=s.width/(i.width*(1+this._settings.fitZoomMargin)),h=Math.min(r,a),l=this.transform.k,u=Math.max(Math.min(h*l,this._settings.maxZoom),this._settings.minZoom),d=s.width/2*l*(1-u)-n*u,c=s.height/2*l*(1-u)-o*u;return Sn.translate(d,c).scale(u)}getSimulationPosition(t){const[e,i]=this.transform.invert([t.x,t.y]);return{x:e-this._width/2,y:i-this._height/2}}getSimulationViewRectangle(){const t=this.getSimulationPosition({x:0,y:0}),e=this.getSimulationPosition({x:this._width,y:this._height});return{x:t.x,y:t.y,width:e.x-t.x,height:e.y-t.y}}translateOriginToCenter(){this._isOriginCentered=!0}destroy(){var t;this._resizeObs.unobserve(this._container),null===(t=this._dprObserveUnsubscribe)||void 0===t||t.call(this),this.removeAllListeners(),this._canvas.remove()}}const cs=(t,e,i)=>{const n=ro(t,e,so.VERTEX),o=ro(t,i,so.FRAGMENT),r=t.createProgram();if(!r)throw new s("Failed to create GL program.");if(t.attachShader(r,n),t.attachShader(r,o),t.linkProgram(r),!t.getProgramParameter(r,t.LINK_STATUS)){const e=t.getProgramInfoLog(r);throw t.deleteProgram(r),new s(`Failed to link GL program: ${e}`)}return t.deleteShader(n),t.deleteShader(o),r},_s=2048,fs=2048;class gs{constructor(t){this._texture=null,this._cache=new Map,this._shelves=[],this._isDirty=!1,this._isTextureAllocated=!1,this._gl=t,this._canvas=document.createElement("canvas"),this._canvas.width=_s,this._canvas.height=fs,this._ctx=this._canvas.getContext("2d",{willReadFrequently:!1}),this._texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this._texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.bindTexture(t.TEXTURE_2D,null)}getOrCreate(t,e,i,n,o){const s=`${t}|${e}|${i}|${n}|${null!=o?o:""}`,r=this._cache.get(s);if(r)return r;const a=t.split("\n").map(t=>t.trim());if(0===a.length||1===a.length&&""===a[0])return null;const h=this._ctx,l=`48px ${i}`;h.font=l;let u=0;for(let t=0;tu&&(u=e)}const d=48*1.2,c=48+(a.length-1)*d,_=Math.ceil(u+11.52)+4,f=Math.ceil(c+11.52)+4,g=this._allocate(_,f);if(!g)return null;const p=g.x+2,m=g.y+2;o&&(h.fillStyle=o,h.fillRect(p,m,_-4,f-4)),h.font=l,h.fillStyle=n,h.textBaseline="top",h.textAlign="center";const v=p+(_-4)/2;for(let t=0;tfs)return null;const n={y:i,height:e,x:t};return this._shelves.push(n),{x:0,y:i}}}const ps=2048,ms=2048;class vs{constructor(t){this._texture=null,this._cache=new Map,this._pending=new Map,this._shelves=[],this._isDirty=!1,this._isTextureAllocated=!1,this._gl=t,this._canvas=document.createElement("canvas"),this._canvas.width=ps,this._canvas.height=ms,this._ctx=this._canvas.getContext("2d",{willReadFrequently:!1}),this._texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this._texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.bindTexture(t.TEXTURE_2D,null)}getOrCreate(t){const e=this._cache.get(t);if(e)return e;const i=this._pending.get(t);if(i)return i.loaded?this._packImage(t,i.image):null;const n=new Image;n.crossOrigin="anonymous";const o={image:n,loaded:!1};return this._pending.set(t,o),n.onload=()=>{o.loaded=!0},n.onerror=()=>{this._pending.delete(t)},n.src=t,null}bind(t){const e=this._gl;e.activeTexture(e.TEXTURE0+t),e.bindTexture(e.TEXTURE_2D,this._texture)}uploadIfDirty(){if(!this._isDirty)return;const t=this._gl;t.bindTexture(t.TEXTURE_2D,this._texture),this._isTextureAllocated||(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,ps,ms,0,t.RGBA,t.UNSIGNED_BYTE,null),this._isTextureAllocated=!0),t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this._canvas),t.bindTexture(t.TEXTURE_2D,null),this._isDirty=!1}clear(){this._cache.clear(),this._pending.clear(),this._shelves=[],this._isDirty=!1,this._ctx.clearRect(0,0,ps,ms)}_packImage(t,e){if(!e.naturalWidth||!e.naturalHeight)return null;const i=e.naturalWidth/e.naturalHeight;let n,o;e.naturalWidth>=e.naturalHeight?(n=Math.min(e.naturalWidth,128),o=Math.round(n/i)):(o=Math.min(e.naturalHeight,128),n=Math.round(o*i));const s=n+4,r=o+4,a=this._allocate(s,r);if(!a)return null;this._ctx.drawImage(e,a.x+2,a.y+2,n,o);const h={u0:(a.x+2)/ps,v0:(a.y+2)/ms,u1:(a.x+2+n)/ps,v1:(a.y+2+o)/ms,aspect:i};return this._cache.set(t,h),this._pending.delete(t),this._isDirty=!0,h}_allocate(t,e){for(let i=0;ims)return null;const n={y:i,height:e,x:t};return this._shelves.push(n),{x:0,y:i}}}const ys=[0,0,0,0],xs=[.6,.6,.6,1],bs=[1,0,0,1],ws={[w.CIRCLE]:0,[w.DOT]:1,[w.SQUARE]:2,[w.DIAMOND]:3,[w.TRIANGLE]:4,[w.TRIANGLE_DOWN]:5,[w.STAR]:6,[w.HEXAGON]:7},Ss="Roboto, sans-serif",Es="#000000";class Ts extends t{constructor(t,e){super(),this._isOriginCentered=!1,this._isInitiallyRendered=!1,this._nodeProgram=null,this._edgeProgram=null,this._labelProgram=null,this._nodeVao=null,this._edgeVao=null,this._labelVao=null,this._nodeInstanceBuffer=null,this._edgeInstanceBuffer=null,this._labelInstanceBuffer=null,this._labelCache=null,this._imageAtlas=null,this._isColorCacheDirty=!0,this._nodeColorCache=new Map,this._nodeBorderColorCache=new Map,this._nodeShadowColorCache=new Map,this._edgeColorCache=new Map,this._edgeShadowColorCache=new Map,this._lastNodeCount=0,this._lastEdgeCount=0,this._edgeInstanceData=null,this._nodeInstanceData=null,this._buffersAreCurrent=!1,this._bufferCacheStats={hits:0,misses:0},this._timerExt=null,this._timerEdgeQueries=[],this._timerNodeQueries=[],this._timerQueryIdx=0,this._lastEdgeGpuMs=null,this._lastNodeGpuMs=null,rs(t,null==e?void 0:e.areCollapsedContainerDimensionsAllowed),this._container=t,this._canvas=ls(t);const i=this._canvas.getContext("webgl2",{antialias:!0});if(!i)throw new s("Failed to create WebGL context.");if(this._gl=i,this._width=640,this._height=480,this.transform=Sn,this._settings=Object.assign(Object.assign({},ko),e),"number"!=typeof(null==e?void 0:e.devicePixelRatio)&&(this._dprObserveUnsubscribe=us(()=>{this._isInitiallyRendered&&this.emit(Bo.RESIZE,void 0)})),this._initShaders(),this._initNodeBuffers(),this._initEdgeBuffers(),this._initLabelBuffers(),this._labelCache=new gs(this._gl),this._imageAtlas=new vs(this._gl),this._timerExt=i.getExtension("EXT_disjoint_timer_query_webgl2"),this._timerExt)for(let t=0;t<4;t++){const t=i.createQuery(),e=i.createQuery();t&&this._timerEdgeQueries.push(t),e&&this._timerNodeQueries.push(e)}}_pollTimerQuery(t){if(!this._timerExt)return null;const e=this._gl;return e.getQueryParameter(t,e.QUERY_RESULT_AVAILABLE)?e.getParameter(this._timerExt.GPU_DISJOINT_EXT)?null:e.getQueryParameter(t,e.QUERY_RESULT)/1e6:null}getGpuTimeStats(){return{edgeMs:this._lastEdgeGpuMs,nodeMs:this._lastNodeGpuMs,supported:null!==this._timerExt}}_initShaders(){this._nodeProgram=cs(this._gl,"#version 300 es\r\n\r\nprecision highp float;\r\n\r\nin vec2 aQuadPosition;\r\n\r\nin vec2 aCenter;\r\nin float aRadius;\r\nin vec4 aColor;\r\nin vec4 aBorderColor;\r\nin float aBorderWidth;\r\nin vec4 aShadowColor;\r\nin float aShadowSize;\r\nin float aShadowOffsetX;\r\nin float aShadowOffsetY;\r\nin float aShapeType;\r\nin vec2 aImageUV0;\r\nin vec2 aImageUV1;\r\nin float aImageAspect;\r\n\r\nuniform vec2 uResolution;\r\nuniform vec2 uTranslation;\r\nuniform float uScale;\r\nuniform vec2 uOriginOffset;\r\n\r\nout vec2 vUV;\r\nout vec4 vColor;\r\nout vec4 vBorderColor;\r\nout float vBorderThreshold;\r\nout vec4 vShadowColor;\r\nout float vNodeRadius;\r\nout vec2 vShadowOffset;\r\nout float vShadowBlur;\r\nflat out int vShapeType;\r\nout vec2 vImageUV0;\r\nout vec2 vImageUV1;\r\nout float vImageAspect;\r\n\r\nvoid main() {\r\n vShapeType = int(aShapeType + 0.5);\r\n vColor = aColor;\r\n vBorderColor = aBorderColor;\r\n vShadowColor = aShadowColor;\r\n vImageUV0 = aImageUV0;\r\n vImageUV1 = aImageUV1;\r\n vImageAspect = aImageAspect;\r\n\r\n float totalRadius = aRadius + aShadowSize + abs(aShadowOffsetX) + abs(aShadowOffsetY);\r\n\r\n vUV = aQuadPosition;\r\n vNodeRadius = aRadius / totalRadius;\r\n\r\n vBorderThreshold = vNodeRadius * (1.0 - aBorderWidth / aRadius);\r\n\r\n vShadowOffset = vec2(aShadowOffsetX, aShadowOffsetY) / totalRadius;\r\n\r\n vShadowBlur = aShadowSize / totalRadius;\r\n\r\n vec2 worldPos = aCenter + aQuadPosition * totalRadius;\r\n vec2 screenPos = (worldPos + uOriginOffset) * uScale + uTranslation;\r\n\r\n vec2 clip = (screenPos / uResolution) * 2.0 - 1.0;\r\n gl_Position = vec4(clip.x, -clip.y, 0.0, 1.0);\r\n}\r\n","#version 300 es\r\n\r\nprecision highp float;\r\n\r\nin vec2 vUV;\r\nin vec4 vColor;\r\nin vec4 vBorderColor;\r\nin float vBorderThreshold;\r\nin vec4 vShadowColor;\r\nin float vNodeRadius;\r\nin vec2 vShadowOffset;\r\nin float vShadowBlur;\r\nflat in int vShapeType;\r\nin vec2 vImageUV0;\r\nin vec2 vImageUV1;\r\nin float vImageAspect;\r\n\r\nuniform sampler2D uImageAtlas;\r\n\r\nout vec4 fragColor;\r\n\r\nconst int SHAPE_CIRCLE = 0;\r\nconst int SHAPE_DOT = 1;\r\nconst int SHAPE_SQUARE = 2;\r\nconst int SHAPE_DIAMOND = 3;\r\nconst int SHAPE_TRIANGLE = 4;\r\nconst int SHAPE_TRIANGLE_DOWN = 5;\r\nconst int SHAPE_STAR = 6;\r\nconst int SHAPE_HEXAGON = 7;\r\n\r\nfloat sdCircle(vec2 p, float r) {\r\n return length(p) - r;\r\n}\r\n\r\nfloat sdSquare(vec2 p, float r) {\r\n vec2 d = abs(p) - vec2(r);\r\n return max(d.x, d.y);\r\n}\r\n\r\nfloat sdDiamond(vec2 p, float r) {\r\n return (abs(p.x) + abs(p.y)) - r;\r\n}\r\n\r\nfloat sdTriangleDown(vec2 p, float r) {\r\n float sr = r * 1.15;\r\n vec2 q = vec2(p.x, p.y - 0.275 * sr);\r\n\r\n float k = sqrt(3.0);\r\n q.x = abs(q.x) - sr;\r\n q.y = q.y + sr / k;\r\n if (q.x + k * q.y > 0.0) {\r\n q = vec2(q.x - k * q.y, -k * q.x - q.y) / 2.0;\r\n }\r\n q.x -= clamp(q.x, -2.0 * sr, 0.0);\r\n return -length(q) * sign(q.y);\r\n}\r\n\r\nfloat sdTriangleUp(vec2 p, float r) {\r\n return sdTriangleDown(vec2(p.x, -p.y), r);\r\n}\r\n\r\nfloat sdStar(vec2 p, float r) {\r\n float sr = r * 0.82;\r\n vec2 q = vec2(p.x, p.y - 0.1 * sr);\r\n\r\n float outerR = sr * 1.3;\r\n float innerR = sr * 0.5;\r\n\r\n float angle = atan(q.x, -q.y);\r\n float sector = 6.2831853 / 5.0;\r\n float a = mod(angle + sector * 0.5, sector) - sector * 0.5;\r\n\r\n float cosA = cos(a);\r\n float sinA = abs(sin(a));\r\n\r\n float halfSector = sector * 0.5;\r\n vec2 outerPt = vec2(outerR, 0.0);\r\n vec2 innerPt = vec2(innerR * cos(halfSector), innerR * sin(halfSector));\r\n\r\n vec2 sp = vec2(cosA, sinA) * length(q);\r\n\r\n vec2 edge = innerPt - outerPt;\r\n vec2 toP = sp - outerPt;\r\n float t = clamp(dot(toP, edge) / dot(edge, edge), 0.0, 1.0);\r\n float dist = length(toP - edge * t);\r\n\r\n float cross2d = edge.x * toP.y - edge.y * toP.x;\r\n return cross2d > 0.0 ? -dist : dist;\r\n}\r\n\r\nfloat sdHexagon(vec2 p, float r) {\r\n vec2 q = abs(p);\r\n float k = sqrt(3.0);\r\n float d = max(q.x, (q.x * 0.5 + q.y * (k * 0.5)));\r\n return d - r;\r\n}\r\n\r\nfloat shapeSDF(vec2 p, float r, int shapeType) {\r\n if (shapeType == SHAPE_SQUARE) return sdSquare(p, r);\r\n if (shapeType == SHAPE_DIAMOND) return sdDiamond(p, r);\r\n if (shapeType == SHAPE_TRIANGLE) return sdTriangleUp(p, r);\r\n if (shapeType == SHAPE_TRIANGLE_DOWN) return sdTriangleDown(p, r);\r\n if (shapeType == SHAPE_STAR) return sdStar(p, r);\r\n if (shapeType == SHAPE_HEXAGON) return sdHexagon(p, r);\r\n\r\n return sdCircle(p, r);\r\n}\r\n\r\nvoid main() {\r\n // Body SDF - always needed.\r\n float dist = shapeSDF(vUV, vNodeRadius, vShapeType);\r\n\r\n float aa = 0.02 * vNodeRadius;\r\n float nodeAlpha = 1.0 - smoothstep(-aa, 0.0, dist);\r\n\r\n // Shadow SDF - skip entirely when no shadow. Avoids a second full shapeSDF() call\r\n // (which is a cascade of ifs) and the exp() per fragment.\r\n float shadowAlpha = 0.0;\r\n if (vShadowBlur > 0.0) {\r\n float shadowDist = shapeSDF(vUV - vShadowOffset, vNodeRadius, vShapeType);\r\n float t = max(shadowDist, 0.0) / vShadowBlur;\r\n shadowAlpha = exp(-t * t * 1.5) * 0.5 * vShadowColor.a;\r\n }\r\n\r\n vec4 fillColor = vColor;\r\n if (vImageAspect > 0.0 && dist < 0.0) {\r\n vec2 uv01 = (vUV / vNodeRadius) * 0.5 + 0.5;\r\n if (vImageAspect > 1.0) {\r\n uv01.x = (uv01.x - 0.5) / vImageAspect + 0.5;\r\n } else {\r\n uv01.y = (uv01.y - 0.5) * vImageAspect + 0.5;\r\n }\r\n if (uv01.x >= 0.0 && uv01.x <= 1.0 && uv01.y >= 0.0 && uv01.y <= 1.0) {\r\n vec2 atlasUV = mix(vImageUV0, vImageUV1, uv01);\r\n vec4 imgTexel = texture(uImageAtlas, atlasUV);\r\n fillColor = mix(fillColor, vec4(imgTexel.rgb, 1.0), imgTexel.a);\r\n }\r\n }\r\n\r\n vec4 nodeColor;\r\n if (vBorderThreshold < vNodeRadius) {\r\n float borderDist = shapeSDF(vUV, vBorderThreshold, vShapeType);\r\n float borderMix = smoothstep(-aa, aa, borderDist);\r\n nodeColor = mix(fillColor, vBorderColor, borderMix);\r\n } else {\r\n nodeColor = fillColor;\r\n }\r\n nodeColor.a *= nodeAlpha;\r\n\r\n float finalAlpha = nodeColor.a + shadowAlpha * (1.0 - nodeColor.a);\r\n\r\n if (finalAlpha < 0.001) {\r\n discard;\r\n }\r\n\r\n if (shadowAlpha > 0.0) {\r\n vec3 finalRGB = (nodeColor.rgb * nodeColor.a + vShadowColor.rgb * shadowAlpha * (1.0 - nodeColor.a)) / finalAlpha;\r\n fragColor = vec4(finalRGB, finalAlpha);\r\n } else {\r\n fragColor = nodeColor;\r\n }\r\n}\r\n"),this._edgeProgram=cs(this._gl,"#version 300 es\r\n\r\nprecision highp float;\r\n\r\nin vec2 aQuadPosition;\r\n\r\nin vec2 aStart;\r\nin vec2 aEnd;\r\nin vec2 aControl;\r\nin float aWidth;\r\nin float aEdgeType;\r\nin float aLoopbackRadius;\r\nin float aArrowSize;\r\nin vec2 aArrowTip;\r\nin vec2 aArrowDir;\r\nin vec4 aColor;\r\nin vec4 aShadowColor;\r\nin float aShadowSize;\r\nin float aShadowOffsetX;\r\nin float aShadowOffsetY;\r\n\r\nuniform vec2 uResolution;\r\nuniform vec2 uTranslation;\r\nuniform float uScale;\r\nuniform vec2 uOriginOffset;\r\n\r\nout vec2 vWorldPos;\r\nout vec2 vStart;\r\nout vec2 vEnd;\r\nout vec2 vControl;\r\nout float vHalfWidth;\r\nout float vWidthFade;\r\nout float vLoopbackRadius;\r\nout float vArrowSize;\r\nout vec2 vArrowTip;\r\nout vec2 vArrowDir;\r\nout vec4 vColor;\r\nout vec4 vShadowColor;\r\nout float vShadowSize;\r\nout vec2 vShadowOffset;\r\nflat out int vEdgeType;\r\n\r\nvoid main() {\r\n vEdgeType = int(aEdgeType + 0.5);\r\n vStart = aStart;\r\n vEnd = aEnd;\r\n vControl = aControl;\r\n // Keep a >=1px geometric floor so the SDF line rasterizes stably (no shimmer or gaps\r\n // between pixels), but fade its opacity by the true on-screen width. A sub-pixel-wide\r\n // edge then reads as faint coverage instead of a hard 1px line — matching the Canvas\r\n // renderer, which strokes at the real (sub-pixel) width and naturally fades when zoomed\r\n // out. aWidth * uScale is the edge's true width in device pixels.\r\n float effectiveWidth = max(aWidth, 1.0 / uScale);\r\n vHalfWidth = effectiveWidth * 0.5;\r\n vWidthFade = clamp(aWidth * uScale, 0.0, 1.0);\r\n vLoopbackRadius = aLoopbackRadius;\r\n vArrowSize = aArrowSize;\r\n vArrowTip = aArrowTip;\r\n vArrowDir = aArrowDir;\r\n vColor = aColor;\r\n vShadowColor = aShadowColor;\r\n vShadowSize = aShadowSize;\r\n vShadowOffset = vec2(aShadowOffsetX, aShadowOffsetY);\r\n\r\n float pad = vHalfWidth + aShadowSize + abs(aShadowOffsetX) + abs(aShadowOffsetY);\r\n\r\n vec2 worldPos;\r\n\r\n if (vEdgeType == 0) {\r\n vec2 dir = aEnd - aStart;\r\n float len = length(dir);\r\n vec2 unitDir = dir / max(len, 0.0001);\r\n vec2 perp = vec2(-unitDir.y, unitDir.x);\r\n float totalHalf = pad + aArrowSize;\r\n vec2 midpoint = (aStart + aEnd) * 0.5;\r\n worldPos = midpoint\r\n + unitDir * (len * 0.5 + totalHalf) * aQuadPosition.x\r\n + perp * totalHalf * aQuadPosition.y;\r\n } else if (vEdgeType == 1) {\r\n float margin = pad + aArrowSize;\r\n vec2 bboxMin = min(min(aStart, aEnd), aControl) - margin;\r\n vec2 bboxMax = max(max(aStart, aEnd), aControl) + margin;\r\n vec2 center = (bboxMin + bboxMax) * 0.5;\r\n vec2 halfSize = (bboxMax - bboxMin) * 0.5;\r\n worldPos = center + aQuadPosition * halfSize;\r\n } else {\r\n float margin = pad + aArrowSize;\r\n vec2 ctr = aControl;\r\n float r = aLoopbackRadius;\r\n vec2 bboxMin = min(ctr - (r + margin), aStart - margin);\r\n vec2 bboxMax = max(ctr + (r + margin), aStart + margin);\r\n vec2 center = (bboxMin + bboxMax) * 0.5;\r\n vec2 halfSize = (bboxMax - bboxMin) * 0.5;\r\n worldPos = center + aQuadPosition * halfSize;\r\n }\r\n\r\n vWorldPos = worldPos;\r\n vec2 screenPos = (worldPos + uOriginOffset) * uScale + uTranslation;\r\n vec2 clip = (screenPos / uResolution) * 2.0 - 1.0;\r\n gl_Position = vec4(clip.x, -clip.y, 0.0, 1.0);\r\n}\r\n","#version 300 es\r\n\r\nprecision highp float;\r\n\r\nin vec2 vWorldPos;\r\nin vec2 vStart;\r\nin vec2 vEnd;\r\nin vec2 vControl;\r\nin float vHalfWidth;\r\nin float vWidthFade;\r\nin float vLoopbackRadius;\r\nin float vArrowSize;\r\nin vec2 vArrowTip;\r\nin vec2 vArrowDir;\r\nin vec4 vColor;\r\nin vec4 vShadowColor;\r\nin float vShadowSize;\r\nin vec2 vShadowOffset;\r\nflat in int vEdgeType;\r\n\r\nuniform bool uSimpleMode;\r\n\r\nout vec4 fragColor;\r\n\r\nfloat sdSegment(vec2 p, vec2 a, vec2 b) {\r\n vec2 pa = p - a;\r\n vec2 ba = b - a;\r\n float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);\r\n return length(pa - ba * h);\r\n}\r\n\r\nfloat sdBezier(vec2 pos, vec2 A, vec2 B, vec2 C) {\r\n vec2 a = B - A;\r\n vec2 b = A - 2.0 * B + C;\r\n vec2 c = a * 2.0;\r\n vec2 d = A - pos;\r\n\r\n float kk = 1.0 / max(dot(b, b), 0.0001);\r\n float kx = kk * dot(a, b);\r\n float ky = kk * (2.0 * dot(a, a) + dot(d, b)) / 3.0;\r\n float kz = kk * dot(d, a);\r\n\r\n float p = ky - kx * kx;\r\n float q = kx * (2.0 * kx * kx - 3.0 * ky) + kz;\r\n float p3 = p * p * p;\r\n float q2 = q * q;\r\n float h = q2 + 4.0 * p3;\r\n\r\n float res;\r\n if (h >= 0.0) {\r\n h = sqrt(h);\r\n vec2 x = (vec2(h, -h) - q) / 2.0;\r\n vec2 uv = sign(x) * pow(abs(x), vec2(1.0 / 3.0));\r\n float t = clamp(uv.x + uv.y - kx, 0.0, 1.0);\r\n vec2 qo = d + (c + b * t) * t;\r\n res = dot(qo, qo);\r\n } else {\r\n float z = sqrt(-p);\r\n float v = acos(q / (p * z * 2.0)) / 3.0;\r\n float m = cos(v);\r\n float n = sin(v) * 1.732050808;\r\n vec3 t = clamp(vec3(m + m, -n - m, n - m) * z - kx, 0.0, 1.0);\r\n vec2 qx = d + (c + b * t.x) * t.x;\r\n float dx = dot(qx, qx);\r\n vec2 qy = d + (c + b * t.y) * t.y;\r\n float dy = dot(qy, qy);\r\n res = min(dx, dy);\r\n }\r\n\r\n return sqrt(res);\r\n}\r\n\r\nfloat sdArrow(vec2 p, vec2 tip, vec2 dir, float size) {\r\n if (size <= 0.0) return 1e6;\r\n\r\n vec2 perp = vec2(-dir.y, dir.x);\r\n vec2 rel = p - tip;\r\n float along = dot(rel, -dir);\r\n float across = dot(rel, perp);\r\n\r\n if (along < 0.0) return length(rel);\r\n if (along > size) {\r\n float hw = size * 0.4;\r\n float closest = clamp(across, -hw, hw);\r\n vec2 pt = tip - dir * size + perp * closest;\r\n return length(p - pt);\r\n }\r\n\r\n float halfW = (along / size) * size * 0.4;\r\n float d = abs(across) - halfW;\r\n return d;\r\n}\r\n\r\nvoid main() {\r\n if (uSimpleMode && vEdgeType == 0) {\r\n float d = sdSegment(vWorldPos, vStart, vEnd) - vHalfWidth;\r\n float aa = fwidth(d);\r\n float a = (1.0 - smoothstep(-aa, aa, d)) * vWidthFade;\r\n if (a < 0.001) discard;\r\n fragColor = vec4(vColor.rgb, vColor.a * a);\r\n return;\r\n }\r\n\r\n float dist;\r\n if (vEdgeType == 0) {\r\n dist = sdSegment(vWorldPos, vStart, vEnd);\r\n } else if (vEdgeType == 1) {\r\n dist = sdBezier(vWorldPos, vStart, vControl, vEnd);\r\n } else {\r\n dist = abs(length(vWorldPos - vControl) - vLoopbackRadius);\r\n }\r\n\r\n float edgeSdf = dist - vHalfWidth;\r\n float combinedSdf = edgeSdf;\r\n\r\n if (vArrowSize > 0.0) {\r\n float arrowDist = sdArrow(vWorldPos, vArrowTip, vArrowDir, vArrowSize);\r\n combinedSdf = min(edgeSdf, arrowDist);\r\n }\r\n\r\n float shadowAlpha = 0.0;\r\n if (vShadowSize > 0.0) {\r\n vec2 shadowPos = vWorldPos - vShadowOffset;\r\n float shadowDist;\r\n if (vEdgeType == 0) {\r\n shadowDist = sdSegment(shadowPos, vStart, vEnd);\r\n } else if (vEdgeType == 1) {\r\n shadowDist = sdBezier(shadowPos, vStart, vControl, vEnd);\r\n } else {\r\n shadowDist = abs(length(shadowPos - vControl) - vLoopbackRadius);\r\n }\r\n float shadowArrowDist = vArrowSize > 0.0\r\n ? sdArrow(shadowPos, vArrowTip, vArrowDir, vArrowSize)\r\n : 1.0e6;\r\n float shadowCombined = min(shadowDist - vHalfWidth, shadowArrowDist);\r\n float t = max(shadowCombined, 0.0) / vShadowSize;\r\n shadowAlpha = exp(-t * t * 1.5) * 0.5 * vShadowColor.a;\r\n }\r\n\r\n float aa = fwidth(combinedSdf);\r\n float edgeAlpha = (1.0 - smoothstep(-aa, aa, combinedSdf)) * vWidthFade;\r\n vec4 edgeColor = vColor;\r\n edgeColor.a *= edgeAlpha;\r\n\r\n float finalAlpha = edgeColor.a + shadowAlpha * (1.0 - edgeColor.a);\r\n\r\n if (finalAlpha < 0.001) discard;\r\n\r\n if (shadowAlpha > 0.0) {\r\n vec3 finalRGB = (edgeColor.rgb * edgeColor.a + vShadowColor.rgb * shadowAlpha * (1.0 - edgeColor.a)) / finalAlpha;\r\n fragColor = vec4(finalRGB, finalAlpha);\r\n } else {\r\n fragColor = edgeColor;\r\n }\r\n}\r\n"),this._labelProgram=cs(this._gl,"#version 300 es\r\n\r\nin vec2 aQuadPosition;\r\n\r\nin vec2 aLabelCenter;\r\nin vec2 aLabelSize;\r\nin vec2 aLabelUV0;\r\nin vec2 aLabelUV1;\r\n\r\nuniform vec2 uResolution;\r\nuniform vec2 uTranslation;\r\nuniform float uScale;\r\nuniform vec2 uOriginOffset;\r\n\r\nout vec2 vAtlasUV;\r\n\r\nvoid main() {\r\n vec2 worldPos = aLabelCenter + aQuadPosition * aLabelSize;\r\n vec2 screenPos = (worldPos + uOriginOffset) * uScale + uTranslation;\r\n vec2 clip = (screenPos / uResolution) * 2.0 - 1.0;\r\n gl_Position = vec4(clip.x, -clip.y, 0.0, 1.0);\r\n\r\n vec2 uv01 = aQuadPosition * 0.5 + 0.5;\r\n vAtlasUV = mix(aLabelUV0, aLabelUV1, uv01);\r\n}\r\n","#version 300 es\r\n\r\nprecision highp float;\r\n\r\nuniform sampler2D uAtlas;\r\n\r\nin vec2 vAtlasUV;\r\n\r\nout vec4 fragColor;\r\n\r\nvoid main() {\r\n vec4 texel = texture(uAtlas, vAtlasUV);\r\n if (texel.a < 0.01) discard;\r\n fragColor = texel;\r\n}\r\n")}_initNodeBuffers(){if(!this._nodeProgram)throw new s("Node program not initialized.");const t=this._gl;this._nodeVao=t.createVertexArray(),t.bindVertexArray(this._nodeVao);const e=new Float32Array([-1,-1,1,-1,-1,1,1,1]),i=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW);const n=t.getAttribLocation(this._nodeProgram,"aQuadPosition");t.enableVertexAttribArray(n),t.vertexAttribPointer(n,2,t.FLOAT,!1,0,0),this._nodeInstanceBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this._nodeInstanceBuffer);const o=25*Float32Array.BYTES_PER_ELEMENT,r=(e,i,n)=>{const s=t.getAttribLocation(this._nodeProgram,e);t.enableVertexAttribArray(s),t.vertexAttribPointer(s,i,t.FLOAT,!1,o,4*n),t.vertexAttribDivisor(s,1)};r("aCenter",2,0),r("aRadius",1,2),r("aColor",4,3),r("aBorderColor",4,7),r("aBorderWidth",1,11),r("aShadowColor",4,12),r("aShadowSize",1,16),r("aShadowOffsetX",1,17),r("aShadowOffsetY",1,18),r("aShapeType",1,19),r("aImageUV0",2,20),r("aImageUV1",2,22),r("aImageAspect",1,24),t.bindVertexArray(null)}_initEdgeBuffers(){if(!this._edgeProgram)throw new s("Edge program not initialized.");const t=this._gl;this._edgeVao=t.createVertexArray(),t.bindVertexArray(this._edgeVao);const e=new Float32Array([-1,-1,1,-1,-1,1,1,1]),i=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW);const n=t.getAttribLocation(this._edgeProgram,"aQuadPosition");t.enableVertexAttribArray(n),t.vertexAttribPointer(n,2,t.FLOAT,!1,0,0),this._edgeInstanceBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this._edgeInstanceBuffer);const o=(e,i,n)=>{const o=t.getAttribLocation(this._edgeProgram,e);t.enableVertexAttribArray(o),t.vertexAttribPointer(o,i,t.FLOAT,!1,100,4*n),t.vertexAttribDivisor(o,1)};o("aStart",2,0),o("aEnd",2,2),o("aControl",2,4),o("aWidth",1,6),o("aEdgeType",1,7),o("aLoopbackRadius",1,8),o("aArrowSize",1,9),o("aArrowTip",2,10),o("aArrowDir",2,12),o("aColor",4,14),o("aShadowColor",4,18),o("aShadowSize",1,22),o("aShadowOffsetX",1,23),o("aShadowOffsetY",1,24),t.bindVertexArray(null)}_initLabelBuffers(){if(!this._labelProgram)throw new s("Label program not initialized.");const t=this._gl;this._labelVao=t.createVertexArray(),t.bindVertexArray(this._labelVao);const e=new Float32Array([-1,-1,1,-1,-1,1,1,1]),i=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW);const n=t.getAttribLocation(this._labelProgram,"aQuadPosition");t.enableVertexAttribArray(n),t.vertexAttribPointer(n,2,t.FLOAT,!1,0,0),this._labelInstanceBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this._labelInstanceBuffer);const o=(e,i,n)=>{const o=t.getAttribLocation(this._labelProgram,e);t.enableVertexAttribArray(o),t.vertexAttribPointer(o,i,t.FLOAT,!1,32,4*n),t.vertexAttribDivisor(o,1)};o("aLabelCenter",2,0),o("aLabelSize",2,2),o("aLabelUV0",2,4),o("aLabelUV1",2,6),t.bindVertexArray(null)}_resolveColor(t){if(!t)return[1,0,0,1];if(t instanceof U)return[t.rgb.r/255,t.rgb.g/255,t.rgb.b/255,1];const e=t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)$/);if(e)return[parseInt(e[1])/255,parseInt(e[2])/255,parseInt(e[3])/255,void 0!==e[4]?parseFloat(e[4]):1];const i=new U(t);return[i.rgb.r/255,i.rgb.g/255,i.rgb.b/255,1]}_buildNodeColorCache(t){this._nodeColorCache.clear();for(let e=0;e0)if(M=1.5*O+3*(S||1),0===T){const t=a-s,e=h-r,i=Math.sqrt(t*t+e*e);i>0&&(I=t/i,D=e/i,L=a-I*l,N=h-D*l)}else if(1===T){let t=1,e=.5,i=1;for(let n=0;n<8;n++){const n=.5*(e+i),o=1-n,u=o*o*s+2*n*o*P+n*n*a,d=o*o*r+2*n*o*C+n*n*h,c=Math.sqrt(Math.pow(u-a,2)+Math.pow(d-h,2));if(Math.abs(c-l)<.1){t=n;break}c>l?e=n:i=n,t=n}const n=1-t;L=n*n*s+2*t*n*P+t*t*a,N=n*n*r+2*t*n*C+t*t*h;const o=2*n*(P-s)+2*t*(a-P),u=2*n*(C-r)+2*t*(h-C),d=Math.sqrt(o*o+u*u);d>0&&(I=o/d,D=u/d)}else{let t=.8,e=.6,i=1;for(let n=0;n<8;n++){const n=.5*(e+i),o=2*n*Math.PI,a=P+A*Math.cos(o),h=C-A*Math.sin(o),l=Math.sqrt(Math.pow(a-s,2)+Math.pow(h-r,2));if(Math.abs(l-u)<.1){t=n;break}l>u?i=n:e=n,t=n}const n=2*t*Math.PI;L=P+A*Math.cos(n),N=C-A*Math.sin(n);const o=-2*t*Math.PI+.45*Math.PI;I=Math.cos(o),D=Math.sin(o)}p[w]=s,p[w+1]=r,p[w+2]=a,p[w+3]=h,p[w+4]=P,p[w+5]=C,p[w+6]=S,p[w+7]=T,p[w+8]=A,p[w+9]=M,p[w+10]=L,p[w+11]=N,p[w+12]=I,p[w+13]=D,p[w+14]=E[0],p[w+15]=E[1],p[w+16]=E[2],p[w+17]=E[3],p[w+18]=m[0],p[w+19]=m[1],p[w+20]=m[2],p[w+21]=m[3],p[w+22]=c,p[w+23]=f,p[w+24]=g}h.useProgram(this._edgeProgram),this._setViewUniforms(this._edgeProgram),h.bindBuffer(h.ARRAY_BUFFER,this._edgeInstanceBuffer),m||(h.bufferData(h.ARRAY_BUFFER,p.byteLength,h.STREAM_DRAW),h.bufferSubData(h.ARRAY_BUFFER,0,p));const S=this.transform.k<=.2,E=h.getUniformLocation(this._edgeProgram,"uSimpleMode");if(h.uniform1i(E,S?1:0),h.bindVertexArray(this._edgeVao),this._timerExt&&this._timerEdgeQueries.length>0){const t=this._timerEdgeQueries[this._timerQueryIdx],e=this._pollTimerQuery(t);null!==e&&(this._lastEdgeGpuMs=e),h.beginQuery(this._timerExt.TIME_ELAPSED_EXT,t)}h.drawArraysInstanced(h.TRIANGLE_STRIP,0,4,_.length),this._timerExt&&this._timerEdgeQueries.length>0&&h.endQuery(this._timerExt.TIME_ELAPSED_EXT),h.bindVertexArray(null),S&&h.enable(h.BLEND),h.useProgram(this._nodeProgram),this._setViewUniforms(this._nodeProgram),this._imageAtlas&&(this._imageAtlas.uploadIfDirty(),this._imageAtlas.bind(0),h.uniform1i(h.getUniformLocation(this._nodeProgram,"uImageAtlas"),0));const T=t.getNodes(),P=this.transform.k,C=25*T.length,A=null===this._nodeInstanceData||this._nodeInstanceData.length!==C;A&&(this._nodeInstanceData=new Float32Array(C));const M=this._nodeInstanceData,L=m&&!A;if(L||T.length===this._lastNodeCount&&!this._isColorCacheDirty||(this._buildNodeColorCache(T),this._buildNodeBorderColorCache(T),this._buildNodeShadowColorCache(T),this._isColorCacheDirty=!1,this._lastNodeCount=T.length),!L)for(let t=0;t=4){const t=e.isSelected()&&r.imageUrlSelected||r.imageUrl;if(t&&this._imageAtlas){const e=this._imageAtlas.getOrCreate(t);e&&(g=e.u0,p=e.v0,m=e.u1,v=e.v1,y=e.aspect)}}M[d+20]=g,M[d+21]=p,M[d+22]=m,M[d+23]=v,M[d+24]=y}if(h.bindBuffer(h.ARRAY_BUFFER,this._nodeInstanceBuffer),L||(h.bufferData(h.ARRAY_BUFFER,M.byteLength,h.STREAM_DRAW),h.bufferSubData(h.ARRAY_BUFFER,0,M)),this._buffersAreCurrent=!0,h.bindVertexArray(this._nodeVao),this._timerExt&&this._timerNodeQueries.length>0){const t=this._timerNodeQueries[this._timerQueryIdx],e=this._pollTimerQuery(t);null!==e&&(this._lastNodeGpuMs=e),h.beginQuery(this._timerExt.TIME_ELAPSED_EXT,t)}if(h.drawArraysInstanced(h.TRIANGLE_STRIP,0,4,T.length),this._timerExt&&this._timerNodeQueries.length>0&&(h.endQuery(this._timerExt.TIME_ELAPSED_EXT),this._timerQueryIdx=(this._timerQueryIdx+1)%this._timerNodeQueries.length),h.bindVertexArray(null),this._labelProgram&&this._labelCache&&this._settings.labelsIsEnabled){const t=this._labelCache,e=t.rasterFontPx;let i=0;const n=T.length+_.length,s=new Float32Array(8*n);for(let n=0;n0&&(t.uploadIfDirty(),h.useProgram(this._labelProgram),this._setViewUniforms(this._labelProgram),t.bind(0),h.uniform1i(h.getUniformLocation(this._labelProgram,"uAtlas"),0),h.bindBuffer(h.ARRAY_BUFFER,this._labelInstanceBuffer),h.bufferData(h.ARRAY_BUFFER,s.subarray(0,8*i),h.DYNAMIC_DRAW),h.bindVertexArray(this._labelVao),h.drawArraysInstanced(h.TRIANGLE_STRIP,0,4,i),h.bindVertexArray(null))}this._isInitiallyRendered=!0,this.emit(Bo.RENDER_END,{durationMs:performance.now()-a})}reset(){this.transform=Sn;const t=this._gl;t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT)}getFitZoomTransform(t){const e=t.getBoundingBox(),i=e.x+e.width/2,n=e.y+e.height/2,o=this.getSimulationViewRectangle(),s=o.height/(e.height*(1+this._settings.fitZoomMargin)),r=o.width/(e.width*(1+this._settings.fitZoomMargin)),a=Math.min(s,r),h=this.transform.k,l=Math.max(Math.min(a*h,this._settings.maxZoom),this._settings.minZoom),u=o.width/2*h*(1-l)-i*l,d=o.height/2*h*(1-l)-n*l;return Sn.translate(u,d).scale(l)}getSimulationPosition(t){const[e,i]=this.transform.invert([t.x,t.y]);return{x:e-this._width/2,y:i-this._height/2}}getSimulationViewRectangle(){const t=this.getSimulationPosition({x:0,y:0}),e=this.getSimulationPosition({x:this._width,y:this._height});return{x:t.x,y:t.y,width:e.x-t.x,height:e.y-t.y}}translateOriginToCenter(){this._isOriginCentered=!0}destroy(){var t,e;null===(t=this._dprObserveUnsubscribe)||void 0===t||t.call(this),this.removeAllListeners(),null===(e=this._gl.getExtension("WEBGL_lose_context"))||void 0===e||e.loseContext(),this._canvas.remove()}_setViewUniforms(t){const e=this._gl,i=this._isOriginCentered?this._width/2:0,n=this._isOriginCentered?this._height/2:0;e.uniform2f(e.getUniformLocation(t,"uResolution"),this._width,this._height),e.uniform2f(e.getUniformLocation(t,"uTranslation"),this.transform.x,this.transform.y),e.uniform1f(e.getUniformLocation(t,"uScale"),this.transform.k),e.uniform2f(e.getUniformLocation(t,"uOriginOffset"),i,n)}}class Ps{static getRenderer(t,e=zo.CANVAS,i){return e===zo.WEBGL?new Ts(t,i):new ds(t,i)}}const Cs=t=>isFinite(t)?""+Math.round(1e3*t)/1e3:"0",As=t=>t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),Ms=(t,e,i)=>{const n=Object.keys(e).filter(t=>{const i=e[t];return null!=i&&""!==i}).map(t=>{const i=e[t];return`${t}="${"number"==typeof i?Cs(i):As(String(i))}"`}).join(" "),o=n?`${t} ${n}`:t;return void 0===i?`<${o}/>`:`<${o}>${i}`},Ls=t=>t.map(t=>`${Cs(t.x)},${Cs(t.y)}`).join(" "),Ns=t=>({tag:"polygon",attributes:{points:Ls(t)}}),Is=(t,e)=>{var i,n;if(null==t||""==`${t}`)return"";const o=new Zo(t,{position:e.position,textBaseline:e.textBaseline,properties:e.properties});if(!o.textLines.length||o.fontSize<=0)return"";const s=null!==(i=e.properties.fontFamily)&&void 0!==i?i:"Roboto, sans-serif",r=(null!==(n=e.properties.fontColor)&&void 0!==n?n:"#000000").toString(),a=1.2*o.fontSize,h=e.textBaseline===jo.MIDDLE?"middle":"text-before-edge",l=Ds(o,a),u=o.textLines.map((t,e)=>Ms("tspan",{x:o.position.x,dy:0===e?0:a},As(t))).join("");return`${l}${Ms("text",{x:o.position.x,y:o.position.y,"font-size":o.fontSize,"font-family":s,fill:r,"text-anchor":"middle","dominant-baseline":h},u)}`},Ds=(t,e)=>{const i=t.properties.fontBackgroundColor;if(!i)return"";const n=.12*t.fontSize,o=t.fontSize+2*n,s=t.textBaseline===jo.MIDDLE?t.fontSize/2:0,r=i.toString();return t.textLines.map((i,a)=>{const h=i.length*t.fontSize*.6+2*n;return Ms("rect",{x:t.position.x-h/2,y:t.position.y-s-n+a*e,width:h,height:o,fill:r})}).join("")},Os=t=>{if("undefined"!=typeof document)try{const e=document.createElement("canvas");e.width=t.naturalWidth||t.width,e.height=t.naturalHeight||t.height;const i=e.getContext("2d");if(!i)return;return i.drawImage(t,0,0),e.toDataURL()}catch(t){return}},Rs=t=>{var e,i,n;return t.shadowColor?{color:t.shadowColor,size:null!==(e=t.shadowSize)&&void 0!==e?e:0,offsetX:null!==(i=t.shadowOffsetX)&&void 0!==i?i:0,offsetY:null!==(n=t.shadowOffsetY)&&void 0!==n?n:0}:null},zs=(t,e)=>{const{color:i,opacity:n}=ks(e.color.toString()),o=Math.max(.5*e.size,0),s=`shadow:${i}:${n}:${o}:${e.offsetX}:${e.offsetY}`;return t.add(s,s=>Bs(s,i,n,o,e.offsetX,e.offsetY,t.filterRegion))},Bs=(t,e,i,n,o,s,r)=>{const a=r?`filterUnits="userSpaceOnUse" x="${Cs(r.x)}" y="${Cs(r.y)}" width="${Cs(r.width)}" height="${Cs(r.height)}"`:'filterUnits="objectBoundingBox" x="-50%" y="-50%" width="200%" height="200%"';return``},ks=t=>{const e=t.match(/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i);if(e)return{color:`rgb(${e[1]}, ${e[2]}, ${e[3]})`,opacity:Us(Number(e[4]))};const i=t.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i);if(i)return{color:`#${i[1]}${i[2]}${i[3]}`,opacity:parseInt(i[4],16)/255};const n=t.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])$/i);return n?{color:`#${n[1]}${n[2]}${n[3]}`,opacity:parseInt(n[4],16)/15}:{color:t,opacity:1}},Us=t=>isFinite(t)?Math.min(Math.max(t,0),1):1,js=(t,e,i)=>{var n,o,s,r,a,h;const l=null===(n=null==i?void 0:i.isLabelEnabled)||void 0===n||n,u=null===(o=null==i?void 0:i.isShadowEnabled)||void 0===o||o,d=null===(s=null==i?void 0:i.isImageEnabled)||void 0===s||s,c=t.getCenter(),_=t.getRadius();if(_<=0)return"";const f=((t,e,i,n)=>{switch(t){case w.SQUARE:return{tag:"rect",attributes:{x:e-n,y:i-n,width:2*n,height:2*n}};case w.DIAMOND:return Ns([{x:e,y:i+n},{x:e+n,y:i},{x:e,y:i-n},{x:e-n,y:i}]);case w.TRIANGLE:return Ns(((t,e,i)=>{e+=.275*(i*=1.15);const n=2*i,o=Math.sqrt(3)*n/6;return[{x:t,y:e-(Math.sqrt(n*n-i*i)-o)},{x:t+i,y:e+o},{x:t-i,y:e+o}]})(e,i,n));case w.TRIANGLE_DOWN:return Ns(((t,e,i)=>{e-=.275*(i*=1.15);const n=2*i,o=Math.sqrt(3)*n/6;return[{x:t,y:e+(Math.sqrt(n*n-i*i)-o)},{x:t+i,y:e-o},{x:t-i,y:e-o}]})(e,i,n));case w.STAR:return Ns(((t,e,i)=>{e+=.1*(i*=.82);const n=[];for(let o=0;o<10;o++){const s=i*(o%2==0?1.3:.5);n.push({x:t+s*Math.sin(2*o*Math.PI/10),y:e-s*Math.cos(2*o*Math.PI/10)})}return n})(e,i,n));case w.HEXAGON:return Ns(((t,e,i,n)=>{const o=[],s=2*Math.PI/n;for(let r=0;r{const n=t.getBackgroundImage();if(!n||!n.width||!n.height)return"";const o=((t,e)=>{var i,n;const o=Os(e);if(o)return o;const s=t.getStyle();return t.isSelected()&&s.imageUrlSelected?s.imageUrlSelected:null!==(n=null!==(i=s.imageUrl)&&void 0!==i?i:e.src)&&void 0!==n?n:void 0})(t,n);if(!o)return"";const s=t.getCenter(),r=t.getRadius(),a=Object.keys(i.attributes).map(t=>`${t}=${i.attributes[t]}`).join(","),h=e.add(`clip:${i.tag}:${a}`,t=>Ms("clipPath",{id:t},Ms(i.tag,i.attributes)));return Ms("image",{href:o,"xlink:href":o,x:s.x-r,y:s.y-r,width:2*r,height:2*r,preserveAspectRatio:"xMidYMid slice","clip-path":`url(#${h})`})})(t,e,f):"",y=u&&t.hasShadow()?Rs(t.getStyle()):null;let x;if(v||y){let t=`${Ms(f.tag,Object.assign(Object.assign({},f.attributes),{fill:g}))}${v}`;y&&(t=Ms("g",{filter:`url(#${zs(e,y)})`},t)),x=`${t}${p?Ms(f.tag,Object.assign(Object.assign(Object.assign({},f.attributes),{fill:"none"}),m)):""}`}else x=Ms(f.tag,Object.assign(Object.assign(Object.assign({},f.attributes),{fill:g}),m));const b=l?Zs(t):"";return Ms("g",{},`${x}${b}`)},Zs=t=>{const e=t.getLabel();if(!e)return"";const i=t.getCenter(),n=1.2*t.getBorderedRadius(),o=t.getStyle();return Is(e,{position:{x:i.x,y:i.y+n},textBaseline:jo.TOP,properties:{fontBackgroundColor:o.fontBackgroundColor,fontColor:o.fontColor,fontFamily:o.fontFamily,fontSize:o.fontSize}})},Fs=[{x:0,y:0},{x:-1,y:.4},{x:-1,y:-.4}],Gs=(t,e,i)=>{var n,o,s;const r=t.getWidth();if(!r)return"";const a=null===(n=null==i?void 0:i.isLabelEnabled)||void 0===n||n,h=null===(o=null==i?void 0:i.isShadowEnabled)||void 0===o||o,l=(null!==(s=t.getColor())&&void 0!==s?s:"#000000").toString(),u=Hs(t,l),d=Ws(t,r,l),c=h&&t.hasShadow()?Rs(t.getStyle()):null;let _=`${u}${d}`;c&&(_=Ms("g",{filter:`url(#${zs(e,c)})`},_));const f=a?qs(t):"";return Ms("g",{},`${_}${f}`)},Ws=(t,e,i)=>{const n=t.getLineDashPattern(),o={stroke:i,"stroke-width":e,fill:"none","stroke-dasharray":n?n.join(" "):void 0};if(t instanceof R){const e=t.startNode.getCenter(),i=t.endNode.getCenter(),n=`M ${Cs(e.x)} ${Cs(e.y)} L ${Cs(i.x)} ${Cs(i.y)}`;return Ms("path",Object.assign({d:n},o))}if(t instanceof z){const e=t.startNode.getCenter(),i=t.endNode.getCenter(),n=t.getCurvedControlPoint(),s=`M ${Cs(e.x)} ${Cs(e.y)} Q ${Cs(n.x)} ${Cs(n.y)} ${Cs(i.x)} ${Cs(i.y)}`;return Ms("path",Object.assign({d:s},o))}if(t instanceof B){const{x:e,y:i,radius:n}=t.getCircularData();return Ms("circle",Object.assign({cx:e,cy:i,r:n},o))}return""},Hs=(t,e)=>{if(0===t.getStyle().arrowSize)return"";const i=Vs(t);if(!i)return"";const n=Xs(Fs,i).map(t=>`${Cs(t.x)},${Cs(t.y)}`).join(" ");return Ms("polygon",{points:n,fill:e})},Vs=t=>t instanceof R?Jo(t):t instanceof z?Xo(t):t instanceof B?Yo(t):null,Xs=(t,e)=>t.map(t=>{const i=t.x*Math.cos(e.angle)-t.y*Math.sin(e.angle),n=t.x*Math.sin(e.angle)+t.y*Math.cos(e.angle);return{x:e.point.x+e.length*i,y:e.point.y+e.length*n}}),qs=t=>{const e=t.getLabel();if(!e)return"";const i=t.getStyle();return Is(e,{position:t.getCenter(),textBaseline:jo.MIDDLE,properties:{fontBackgroundColor:i.fontBackgroundColor,fontColor:i.fontColor,fontFamily:i.fontFamily,fontSize:i.fontSize}})};class $s{constructor(t){this.filterRegion=t,this._idBySignature=new Map,this._entries=[],this._counter=0}add(t,e){const i=this._idBySignature.get(t);if(void 0!==i)return i;const n=`orb-def-${this._counter}`;return this._counter+=1,this._idBySignature.set(t,n),this._entries.push(e(n)),n}toSVG(){return this._entries.length?`${this._entries.join("")}`:""}}const Ys=(t,e={})=>{var i,n,o,s;const r=null!==(i=e.padding)&&void 0!==i?i:20,a=null===(n=e.isLabelEnabled)||void 0===n||n,h=null===(o=e.isShadowEnabled)||void 0===o||o,l=null===(s=e.isImageEnabled)||void 0===s||s,u=t.getNodes(),d=t.getEdges(),c=Ks(u,d,a,h),_=c.x-r,f=c.y-r,g=Math.max(c.width+2*r,1),p=Math.max(c.height+2*r,1),m=new $s({x:_,y:f,width:g,height:p}),v=[];e.backgroundColor&&v.push(Ms("rect",{x:_,y:f,width:g,height:p,fill:e.backgroundColor.toString()}));for(let t=0;t{const o={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(let e=0;e{et.maxX&&(t.maxX=e),i>t.maxY&&(t.maxY=i)},Js=(t,e,i,n,o)=>{Qs(t,e-n,i-o),Qs(t,e+n,i+o)},tr=(t,e,i,n)=>{var o;if(e.getRadius()<=0)return;const s=e.getCenter(),r=e.getBorderedRadius(),a=n?nr(e.hasShadow(),e.getStyle()):0;if(Js(t,s.x,s.y,r+a,r+a),i&&e.getLabel()){const i=e.getStyle(),n=s.y+1.2*e.getBorderedRadius();ir(t,e.getLabel(),s.x,n,null!==(o=i.fontSize)&&void 0!==o?o:4,!1)}},er=(t,e,i,n)=>{var o;if(!e.getWidth())return;const s=e.getStyle(),r=n?nr(e.hasShadow(),s):0;if(e instanceof B){const i=e.getCircularData();Js(t,i.x,i.y,i.radius+r,i.radius+r)}else if(e instanceof z){const i=e.getCurvedControlPoint();Js(t,i.x,i.y,r,r)}if(i&&e.getLabel()){const i=e.getCenter();ir(t,e.getLabel(),i.x,i.y,null!==(o=s.fontSize)&&void 0!==o?o:4,!0)}},ir=(t,e,i,n,o,s)=>{if(o<=0)return;const r=`${e}`.split("\n"),a=.12*o,h=r.reduce((t,e)=>Math.max(t,e.trim().length),0)*o*.6+2*a,l=r.length*o*1.2+2*a,u=s?n-l/2:n;Qs(t,i-h/2,u),Qs(t,i+h/2,u+l)},nr=(t,e)=>{var i,n,o;return t&&e.shadowColor?(null!==(i=e.shadowSize)&&void 0!==i?i:0)+Math.max(Math.abs(null!==(n=e.shadowOffsetX)&&void 0!==n?n:0),Math.abs(null!==(o=e.shadowOffsetY)&&void 0!==o?o:0)):0};class or{constructor(t){this._graph=t}selectNodeById(t,e){const i=this._graph.getNodeById(t);return!!i&&(So(i,e),!0)}selectEdgeById(t,e){const i=this._graph.getEdgeById(t);return!!i&&(Eo(i,e),!0)}unselectNodeById(t,e){const i=this._graph.getNodeById(t);return!!i&&(To(i,e),!0)}unselectEdgeById(t,e){const i=this._graph.getEdgeById(t);return!!i&&(Po(i,e),!0)}unselectAll(){const{changedCount:t}=Mo(this._graph);return t}hoverNodeById(t){const e=this._graph.getNodeById(t);return!!e&&(Lo(e),!0)}hoverEdgeById(t){const e=this._graph.getEdgeById(t);return!!e&&((t=>{Do(t,r.HOVERED)})(e),!0)}unhoverAll(){const{changedCount:t}=No(this._graph);return t}}class sr{constructor(t,i){var n,s,r,a,h,l,u;this._simulatorUsesGPU=!1,this._simulationStartedAt=Date.now(),this._assignPositions=t=>{if(this._settings.getPosition)for(let e=0;e{var e;const i=this.getCanvasMousePosition(t.sourceEvent),n=null===(e=this._renderer)||void 0===e?void 0:e.getSimulationPosition(i);return this._graph.getNearestNode(n)},this.dragStarted=t=>{if(!this._settings.interaction.isDragEnabled)return;const i=this.getCanvasMousePosition(t.sourceEvent),n=this._renderer.getSimulationPosition(i);this._events.emit(e.NODE_DRAG_START,{node:t.subject,event:t.sourceEvent,localPoint:n,globalPoint:i}),this._dragStartPosition=i},this.dragged=t=>{if(!this._settings.interaction.isDragEnabled)return;const i=this.getCanvasMousePosition(t.sourceEvent),n=this._renderer.getSimulationPosition(i);In(this._dragStartPosition,i)||(this._dragStartPosition=void 0),this._simulator.dragNode(t.subject.getId(),n),this._events.emit(e.NODE_DRAG,{node:t.subject,event:t.sourceEvent,localPoint:n,globalPoint:i})},this.dragEnded=t=>{if(!this._settings.interaction.isDragEnabled)return;const i=this.getCanvasMousePosition(t.sourceEvent),n=this._renderer.getSimulationPosition(i);In(this._dragStartPosition,i)||this._simulator.endDragNode(t.subject.getId()),this._events.emit(e.NODE_DRAG_END,{node:t.subject,event:t.sourceEvent,localPoint:n,globalPoint:i})},this.zoomed=t=>{this._settings.interaction.isZoomEnabled&&(this._renderer.transform=t.transform,setTimeout(()=>{this.render(),this._events.emit(e.TRANSFORM,{transform:t.transform})},1))},this.mouseMoved=t=>{const i=this.getCanvasMousePosition(t),n=this._renderer.getSimulationPosition(i),o=this._strategy.onMouseMove(this._graph,n),s=o.changedSubject;s&&o.isStateChanged&&(E(s)&&this._events.emit(e.NODE_HOVER,{node:s,event:t,localPoint:n,globalPoint:i}),I(s)&&this._events.emit(e.EDGE_HOVER,{edge:s,event:t,localPoint:n,globalPoint:i})),this._events.emit(e.MOUSE_MOVE,{subject:s,event:t,localPoint:n,globalPoint:i}),o.isStateChanged&&(this._invalidateStyles(),this.render())},this.mouseClicked=t=>{const i=this.getCanvasMousePosition(t),n=this._renderer.getSimulationPosition(i),o=this._strategy.onMouseClick(this._graph,n,{isAppend:t.shiftKey}),s=o.changedSubject;s&&(E(s)&&this._events.emit(e.NODE_CLICK,{node:s,event:t,localPoint:n,globalPoint:i}),I(s)&&this._events.emit(e.EDGE_CLICK,{edge:s,event:t,localPoint:n,globalPoint:i})),this._events.emit(e.MOUSE_CLICK,{subject:s,event:t,localPoint:n,globalPoint:i}),(o.isStateChanged||o.changedSubject)&&(this._invalidateStyles(),this.render())},this.mouseRightClicked=t=>{const i=this.getCanvasMousePosition(t),n=this._renderer.getSimulationPosition(i),o=this._strategy.onMouseRightClick(this._graph,n),s=o.changedSubject;s&&(E(s)&&this._events.emit(e.NODE_RIGHT_CLICK,{node:s,event:t,localPoint:n,globalPoint:i}),I(s)&&this._events.emit(e.EDGE_RIGHT_CLICK,{edge:s,event:t,localPoint:n,globalPoint:i})),this._events.emit(e.MOUSE_RIGHT_CLICK,{subject:s,event:t,localPoint:n,globalPoint:i}),(o.isStateChanged||o.changedSubject)&&(this._invalidateStyles(),this.render())},this.mouseDoubleClicked=t=>{const i=this.getCanvasMousePosition(t),n=this._renderer.getSimulationPosition(i),o=this._strategy.onMouseDoubleClick(this._graph,n),s=o.changedSubject;s&&(E(s)&&this._events.emit(e.NODE_DOUBLE_CLICK,{node:s,event:t,localPoint:n,globalPoint:i}),I(s)&&this._events.emit(e.EDGE_DOUBLE_CLICK,{edge:s,event:t,localPoint:n,globalPoint:i})),this._events.emit(e.MOUSE_DOUBLE_CLICK,{subject:s,event:t,localPoint:n,globalPoint:i}),(o.isStateChanged||o.changedSubject)&&(this._invalidateStyles(),this.render())},this.zoomIn=t=>{de(this._renderer.canvas).transition().duration(this._settings.zoomFitTransitionMs).ease(Te).call(this._d3Zoom.scaleBy,1.2).on("end",()=>this.render(t))},this.zoomOut=t=>{de(this._renderer.canvas).transition().duration(this._settings.zoomFitTransitionMs).ease(Te).call(this._d3Zoom.scaleBy,.8).on("end",()=>this.render(t))},this._invalidateStyles=()=>{var t,e;null===(e=(t=this._renderer).invalidateStyles)||void 0===e||e.call(t)},this._update=t=>{t&&"x"in t&&"y"in t&&"id"in t&&this._simulator.patchData({nodes:[{x:t.x,y:t.y,sx:t.x,sy:t.y,fx:t.x,fy:t.y,id:t.id}],edges:[]}),this._invalidateStyles(),this.render()},this._initializeSimulationEvents=()=>{this._simulator.on(Dn.SIMULATION_START,()=>{this._simulationStartedAt=Date.now(),this._events.emit(e.SIMULATION_START,void 0)});const t=()=>{var t,e;return null===(e=(t=this._renderer).invalidateBuffers)||void 0===e?void 0:e.call(t)};this._simulator.on(Dn.SIMULATION_PROGRESS,i=>{this._graph.setNodePositions(i.nodes),t(),this._events.emit(e.SIMULATION_STEP,{progress:i.progress}),this.render()}),this._simulator.on(Dn.SIMULATION_END,i=>{this._graph.setNodePositions(i.nodes),t(),this.render(),this._events.emit(e.SIMULATION_END,{durationMs:Date.now()-this._simulationStartedAt})}),this._simulator.on(Dn.SIMULATION_STEP,e=>{this._graph.setNodePositions(e.nodes),t(),this.render()}),this._simulator.on(Dn.NODE_DRAG,e=>{this._graph.setNodePositions(e.nodes),t(),this.render()}),this._simulator.on(Dn.SETTINGS_UPDATE,t=>{var e;this._settings.layout.options=null===(e=t.settings)||void 0===e?void 0:e.options})},this._container=t,this._settings=Object.assign(Object.assign({getPosition:null==i?void 0:i.getPosition,zoomFitTransitionMs:200,isOutOfBoundsDragEnabled:!1,areCoordinatesRounded:!0},i),{layout:Object.assign({type:"force"},null!==(n=null==i?void 0:i.layout)&&void 0!==n?n:to),render:Object.assign({},null==i?void 0:i.render),strategy:Object.assign({isDefaultHoverEnabled:!0,isDefaultSelectEnabled:!0,isDefaultMultiSelectEnabled:!1,isDefaultSelectCascadeEnabled:!0},null==i?void 0:i.strategy),interaction:Object.assign({isDragEnabled:!0,isZoomEnabled:!0},null==i?void 0:i.interaction)}),this._graph=new wo(void 0,{onLoadedImages:()=>{this._renderer.isInitiallyRendered&&this.render()},listeners:[this._update]}),this._graph.setDefaultStyle(H()),this._events=new o,this._interaction=new or(this._graph),this._strategy=new Ro({isDefaultSelectEnabled:null!==(s=this._settings.strategy.isDefaultSelectEnabled)&&void 0!==s&&s,isDefaultHoverEnabled:null!==(r=this._settings.strategy.isDefaultHoverEnabled)&&void 0!==r&&r,isDefaultMultiSelectEnabled:null===(a=this._settings.strategy.isDefaultMultiSelectEnabled)||void 0===a||a,isDefaultSelectCascadeEnabled:null===(h=this._settings.strategy.isDefaultSelectCascadeEnabled)||void 0===h||h}),this._rendererType=null!==(u=null===(l=null==i?void 0:i.render)||void 0===l?void 0:l.type)&&void 0!==u?u:zo.CANVAS,this._initRenderer(this._rendererType),this._simulator=vo.getSimulator(this._settings.layout),this._simulatorUsesGPU=sr._needsGPU(this._settings.layout),this._initializeSimulationEvents(),this._graph.setSettings({onSetupData:()=>{this._assignPositions(this._graph.getNodes());const t=this._graph.getNodePositions(),e=this._graph.getEdgePositions();this._simulator.setupData({nodes:t,edges:e})},onMergeData:t=>{var e,i;const n=new Set(null===(e=t.nodes)||void 0===e?void 0:e.map(t=>t.id)),o=t=>n.has(t.getId()),s=new Set(null===(i=t.edges)||void 0===i?void 0:i.map(t=>t.id));this._assignPositions(this._graph.getNodes(o));const r=this._graph.getNodePositions(o),a=this._graph.getEdgePositions(t=>s.has(t.getId()));this._simulator.mergeData({nodes:r,edges:a})},onRemoveData:t=>{this._simulator.deleteData(t)}})}_initRenderer(t){try{this._renderer=Ps.getRenderer(this._container,t,this._settings.render)}catch(t){throw this._container.textContent=t.message,t}this._renderer.on(Bo.RENDER_START,()=>{this._events.emit(e.RENDER_START,void 0)}),this._renderer.on(Bo.RENDER_END,t=>{this._events.emit(e.RENDER_END,t)}),this._renderer.on(Bo.RESIZE,()=>{this._renderer.isInitiallyRendered&&this._renderer.render(this._graph)}),this._renderer.translateOriginToCenter(),this._settings.render=this._renderer.getSettings(),this._d3Zoom=function(){var t,e,i,n=Pn,o=Cn,s=Nn,r=Mn,a=Ln,h=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],u=250,d=Ce,c=Q("start","zoom","end"),_=0,f=10;function g(t){t.property("__zoom",An).on("wheel.zoom",w,{passive:!1}).on("mousedown.zoom",S).on("dblclick.zoom",E).filter(a).on("touchstart.zoom",T).on("touchmove.zoom",P).on("touchend.zoom touchcancel.zoom",C).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(t,e){return(e=Math.max(h[0],Math.min(h[1],e)))===t.k?t:new wn(e,t.x,t.y)}function m(t,e,i){var n=e[0]-i[0]*t.k,o=e[1]-i[1]*t.k;return n===t.x&&o===t.y?t:new wn(t.k,n,o)}function v(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function y(t,e,i,n){t.on("start.zoom",function(){x(this,arguments).event(n).start()}).on("interrupt.zoom end.zoom",function(){x(this,arguments).event(n).end()}).tween("zoom",function(){var t=this,s=arguments,r=x(t,s).event(n),a=o.apply(t,s),h=null==i?v(a):"function"==typeof i?i.apply(t,s):i,l=Math.max(a[1][0]-a[0][0],a[1][1]-a[0][1]),u=t.__zoom,c="function"==typeof e?e.apply(t,s):e,_=d(u.invert(h).concat(l/u.k),c.invert(h).concat(l/c.k));return function(t){if(1===t)t=c;else{var e=_(t),i=l/e[2];t=new wn(i,h[0]-e[0]*i,h[1]-e[1]*i)}r.zoom(null,t)}})}function x(t,e,i){return!i&&t.__zooming||new b(t,e)}function b(t,e){this.that=t,this.args=e,this.active=0,this.sourceEvent=null,this.extent=o.apply(t,e),this.taps=0}function w(t,...e){if(n.apply(this,arguments)){var i=x(this,e).event(t),o=this.__zoom,a=Math.max(h[0],Math.min(h[1],o.k*Math.pow(2,r.apply(this,arguments)))),u=ce(t);if(i.wheel)i.mouse[0][0]===u[0]&&i.mouse[0][1]===u[1]||(i.mouse[1]=o.invert(i.mouse[0]=u)),clearTimeout(i.wheel);else{if(o.k===a)return;i.mouse=[u,o.invert(u)],Qe(this),i.start()}Tn(t),i.wheel=setTimeout(function(){i.wheel=null,i.end()},150),i.zoom("mouse",s(m(p(o,a),i.mouse[0],i.mouse[1]),i.extent,l))}}function S(t,...e){if(!i&&n.apply(this,arguments)){var o=t.currentTarget,r=x(this,e,!0).event(t),a=de(t.view).on("mousemove.zoom",function(t){if(Tn(t),!r.moved){var e=t.clientX-u,i=t.clientY-d;r.moved=e*e+i*i>_}r.event(t).zoom("mouse",s(m(r.that.__zoom,r.mouse[0]=ce(t,o),r.mouse[1]),r.extent,l))},!0).on("mouseup.zoom",function(t){a.on("mousemove.zoom mouseup.zoom",null),ve(t.view,r.moved),Tn(t),r.event(t).end()},!0),h=ce(t,o),u=t.clientX,d=t.clientY;me(t.view),En(t),r.mouse=[h,this.__zoom.invert(h)],Qe(this),r.start()}}function E(t,...e){if(n.apply(this,arguments)){var i=this.__zoom,r=ce(t.changedTouches?t.changedTouches[0]:t,this),a=i.invert(r),h=i.k*(t.shiftKey?.5:2),d=s(m(p(i,h),r,a),o.apply(this,e),l);Tn(t),u>0?de(this).transition().duration(u).call(y,d,r,t):de(this).call(g.transform,d,r,t)}}function T(i,...o){if(n.apply(this,arguments)){var s,r,a,h,l=i.touches,u=l.length,d=x(this,o,i.changedTouches.length===u).event(i);for(En(i),r=0;rd}h.mouse("drag",n)}function g(t){de(t.view).on("mousemove.drag mouseup.drag",null),ve(t.view,i),pe(t),h.mouse("end",t)}function p(t,e){if(o.call(this,t,e)){var i,n,r=t.changedTouches,a=s.call(this,t,e),h=r.length;for(i=0;i{this.recenter()}),this._simulator.setupData({nodes:n,edges:o})}t.strategy&&(d(t.strategy.isDefaultHoverEnabled)&&(this._settings.strategy.isDefaultHoverEnabled=t.strategy.isDefaultHoverEnabled,this._strategy.isHoverEnabled=this._settings.strategy.isDefaultHoverEnabled),d(t.strategy.isDefaultSelectEnabled)&&(this._settings.strategy.isDefaultSelectEnabled=t.strategy.isDefaultSelectEnabled,this._strategy.isSelectEnabled=this._settings.strategy.isDefaultSelectEnabled),d(t.strategy.isDefaultMultiSelectEnabled)&&(this._settings.strategy.isDefaultMultiSelectEnabled=t.strategy.isDefaultMultiSelectEnabled,this._strategy.isMultiSelectEnabled=this._settings.strategy.isDefaultMultiSelectEnabled),d(t.strategy.isDefaultSelectCascadeEnabled)&&(this._settings.strategy.isDefaultSelectCascadeEnabled=t.strategy.isDefaultSelectCascadeEnabled,this._strategy.isSelectCascadeEnabled=this._settings.strategy.isDefaultSelectCascadeEnabled)),t.interaction&&(d(t.interaction.isDragEnabled)&&(this._settings.interaction.isDragEnabled=t.interaction.isDragEnabled),d(t.interaction.isZoomEnabled)&&(this._settings.interaction.isZoomEnabled=t.interaction.isZoomEnabled))}static _needsGPU(t){var e;return"force"===t.type&&!!(null===(e=t.options)||void 0===e?void 0:e.useGPU)}render(t){t&&(this._simulator.isSimulationRunning()?this._simulator.once(Dn.SIMULATION_END,()=>{this._renderer.once(Bo.RENDER_END,()=>t())}):this._renderer.once(Bo.RENDER_END,()=>t())),this._renderer.render(this._graph)}recenter(t,e){"function"==typeof t&&(e=t,t=void 0);const i=(t=>{var e,i,n,o,s,r;if("hierarchical"===t.type){const n=t.options;return{anchorX:null!==(e=n.anchorX)&&void 0!==e?e:"horizontal"===n.orientation?n.reversed?"end":"start":"center",anchorY:null!==(i=n.anchorY)&&void 0!==i?i:"vertical"===n.orientation?n.reversed?"end":"start":"center"}}return{anchorX:null!==(o=null===(n=t.options)||void 0===n?void 0:n.anchorX)&&void 0!==o?o:"center",anchorY:null!==(r=null===(s=t.options)||void 0===s?void 0:s.anchorY)&&void 0!==r?r:"center"}})(this._settings.layout),n=Object.assign(Object.assign({},i),t),o=this._renderer.getFitZoomTransform(this._graph,n);de(this._renderer.canvas).transition().duration(this._settings.zoomFitTransitionMs).ease(Te).call(this._d3Zoom.transform,o).on("end",()=>this.render(e))}getSVG(t){return Ys(this._graph,Object.assign({backgroundColor:this._settings.render.backgroundColor},t))}destroy(){this._renderer.destroy(),this._simulator.terminate()}getCanvasMousePosition(t){var e,i,n,o;const s=this._renderer.canvas.getBoundingClientRect();let r=null!==(i=null!==(e=t.clientX)&&void 0!==e?e:t.pageX)&&void 0!==i?i:t.x,a=null!==(o=null!==(n=t.clientY)&&void 0!==n?n:t.pageY)&&void 0!==o?o:t.y;return r-=s.left,a-=s.top,this._settings.areCoordinatesRounded&&(r=Math.floor(r),a=Math.floor(a)),this._settings.isOutOfBoundsDragEnabled||(r=Math.max(0,Math.min(this._renderer.width,r)),a=Math.max(0,Math.min(this._renderer.height,a))),{x:r,y:a}}fixNodes(){this._simulator.fixNodes()}releaseNodes(){this._simulator.releaseNodes()}}var rr=i(481);class ar{constructor(t,e){var i,n,s,r,a,h,l,u,d,c,_,f;this._invalidateStyles=()=>{var t,e;null===(e=(t=this._renderer).invalidateStyles)||void 0===e||e.call(t)},this._update=()=>{this._invalidateStyles(),this.render()},this._container=t,this._graph=new wo(void 0,{onLoadedImages:()=>{this._renderer.isInitiallyRendered&&this.render()},listeners:[this._update]}),this._graph.setDefaultStyle(H()),this._events=new o,this._interaction=new or(this._graph),this._settings=Object.assign(Object.assign({areCollapsedContainerDimensionsAllowed:!1},e),{map:{zoomLevel:null!==(n=null===(i=e.map)||void 0===i?void 0:i.zoomLevel)&&void 0!==n?n:2,tile:null!==(r=null===(s=e.map)||void 0===s?void 0:s.tile)&&void 0!==r?r:{instance:new rr.TileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"),attribution:'Leaflet | Map data © OpenStreetMap contributors'},nodeSizeMode:null!==(h=null===(a=e.map)||void 0===a?void 0:a.nodeSizeMode)&&void 0!==h?h:"geographic"},render:Object.assign({type:zo.CANVAS},e.render),strategy:Object.assign({isDefaultHoverEnabled:!0,isDefaultSelectEnabled:!0,isDefaultMultiSelectEnabled:!1,isDefaultSelectCascadeEnabled:!0},null==e?void 0:e.strategy)}),this._strategy=new Ro({isDefaultSelectEnabled:null!==(l=this._settings.strategy.isDefaultSelectEnabled)&&void 0!==l&&l,isDefaultHoverEnabled:null!==(u=this._settings.strategy.isDefaultHoverEnabled)&&void 0!==u&&u,isDefaultMultiSelectEnabled:null===(d=this._settings.strategy.isDefaultMultiSelectEnabled)||void 0===d||d,isDefaultSelectCascadeEnabled:null===(c=this._settings.strategy.isDefaultSelectCascadeEnabled)||void 0===c||c}),this._rendererType=null!==(f=null===(_=null==e?void 0:e.render)||void 0===_?void 0:_.type)&&void 0!==f?f:zo.CANVAS,this._initRenderer(this._rendererType),this._map=this._initMap(),this._leaflet=this._initLeaflet(),this._handleTileChange()}_initRenderer(t){try{this._renderer=Ps.getRenderer(this._container,t,this._settings.render)}catch(t){throw this._container.textContent=t.message,t}this._renderer.on(Bo.RENDER_END,t=>{this._events.emit(e.RENDER_END,t)}),this._renderer.on(Bo.RESIZE,()=>{this._renderer.isInitiallyRendered&&(this._leaflet.invalidateSize(!1),this._renderer.render(this._graph))}),this._settings.render=this._renderer.getSettings(),this._renderer.canvas.style.zIndex="2",this._renderer.canvas.style.pointerEvents="none"}setRenderer(t){if(t===this._rendererType)return;this._renderer.destroy(),this._initRenderer(t),this._rendererType=t;const e=this._leaflet._mapPane._leaflet_pos,i=this._getStyleScale();this._renderer.transform=Object.assign(Object.assign({},e),{k:i}),this.render()}get data(){return this._graph}get events(){return this._events}get interaction(){return this._interaction}get leaflet(){return this._leaflet}getSettings(){return p(this._settings)}setSettings(t){if(t.getGeoPosition&&(this._settings.getGeoPosition=t.getGeoPosition,this._updateGraphPositions()),t.map&&("number"==typeof t.map.zoomLevel&&(this._settings.map.zoomLevel=t.map.zoomLevel,this._leaflet.setZoom(t.map.zoomLevel)),t.map.tile&&(this._settings.map.tile=t.map.tile,this._handleTileChange()),t.map.nodeSizeMode&&t.map.nodeSizeMode!==this._settings.map.nodeSizeMode)){this._settings.map.nodeSizeMode=t.map.nodeSizeMode,this._updateGraphPositions();const e=this._leaflet._mapPane._leaflet_pos,i=this._getStyleScale();this._renderer.transform=Object.assign(Object.assign({},e),{k:i}),this._renderer.render(this._graph)}t.render&&(t.render.type&&t.render.type!==this._rendererType&&this.setRenderer(t.render.type),this._renderer.setSettings(t.render),this._settings.render=this._renderer.getSettings()),t.strategy&&(d(t.strategy.isDefaultHoverEnabled)&&(this._settings.strategy.isDefaultHoverEnabled=t.strategy.isDefaultHoverEnabled,this._strategy.isHoverEnabled=this._settings.strategy.isDefaultHoverEnabled),d(t.strategy.isDefaultSelectEnabled)&&(this._settings.strategy.isDefaultSelectEnabled=t.strategy.isDefaultSelectEnabled,this._strategy.isSelectEnabled=this._settings.strategy.isDefaultSelectEnabled),d(t.strategy.isDefaultMultiSelectEnabled)&&(this._settings.strategy.isDefaultMultiSelectEnabled=t.strategy.isDefaultMultiSelectEnabled,this._strategy.isMultiSelectEnabled=this._settings.strategy.isDefaultMultiSelectEnabled),d(t.strategy.isDefaultSelectCascadeEnabled)&&(this._settings.strategy.isDefaultSelectCascadeEnabled=t.strategy.isDefaultSelectCascadeEnabled,this._strategy.isSelectCascadeEnabled=this._settings.strategy.isDefaultSelectCascadeEnabled))}render(t){t&&this._renderer.once(Bo.RENDER_END,()=>t()),this._updateGraphPositions(),this._renderer.render(this._graph)}zoomIn(t){this._leaflet.zoomIn(),null==t||t()}recenter(t){const e=this._graph.getBoundingBox(),i=this._getStyleScale(),n=this._leaflet.layerPointToLatLng([e.x*i,e.y*i]),o=this._leaflet.layerPointToLatLng([(e.x+e.width)*i,(e.y+e.height)*i]);this._leaflet.fitBounds(rr.latLngBounds(n,o)),null==t||t()}zoomOut(t){this._leaflet.zoomOut(),null==t||t()}getSVG(){throw new Error("SVG export is not supported on OrbMapView.")}destroy(){this._renderer.destroy(),this._leaflet.off(),this._leaflet.remove(),this._leaflet.getContainer().outerHTML=""}_initMap(){const t=document.createElement("div");return t.style.position="absolute",t.style.width="100%",t.style.height="100%",t.style.zIndex="1",t.style.cursor="default",this._container.appendChild(t),t}_initLeaflet(){const t=rr.map(this._map,{doubleClickZoom:!1,zoomControl:!1}).setView([0,0],this._settings.map.zoomLevel);return t.on("zoomstart",()=>{this._renderer.reset()}),t.on("zoom",t=>{var i,n;this._updateGraphPositions(),null===(n=(i=this._renderer).invalidateBuffers)||void 0===n||n.call(i);const o=t.target._mapPane._leaflet_pos,s=this._getStyleScale();this._renderer.transform=Object.assign(Object.assign({},o),{k:s}),this._renderer.render(this._graph),this._events.emit(e.TRANSFORM,{transform:Object.assign(Object.assign({},o),{k:s})})}),t.on("mousemove",t=>{const i=this._toSimulationPoint(t.layerPoint),n={x:t.containerPoint.x,y:t.containerPoint.y},o=this._strategy.onMouseMove(this._graph,i),s=o.changedSubject;s&&o.isStateChanged&&(E(s)&&this._events.emit(e.NODE_HOVER,{node:s,event:t.originalEvent,localPoint:i,globalPoint:n}),I(s)&&this._events.emit(e.EDGE_HOVER,{edge:s,event:t.originalEvent,localPoint:i,globalPoint:n})),this._events.emit(e.MOUSE_MOVE,{subject:s,event:t.originalEvent,localPoint:i,globalPoint:n}),o.isStateChanged&&(this._invalidateStyles(),this._renderer.render(this._graph))}),t.on("click contextmenu dblclick",t=>{const i=this._toSimulationPoint(t.layerPoint),n={x:t.containerPoint.x,y:t.containerPoint.y};if("contextmenu"===t.type){const o=this._strategy.onMouseRightClick(this._graph,i),s=o.changedSubject;s&&(E(s)&&this._events.emit(e.NODE_RIGHT_CLICK,{node:s,event:t.originalEvent,localPoint:i,globalPoint:n}),I(s)&&this._events.emit(e.EDGE_RIGHT_CLICK,{edge:s,event:t.originalEvent,localPoint:i,globalPoint:n})),this._events.emit(e.MOUSE_RIGHT_CLICK,{subject:s,event:t.originalEvent,localPoint:i,globalPoint:n}),o.isStateChanged&&(this._invalidateStyles(),this._renderer.render(this._graph))}else if("click"===t.type){const o=this._strategy.onMouseClick(this._graph,i,{isAppend:t.originalEvent.shiftKey}),s=o.changedSubject;s&&(E(s)&&this._events.emit(e.NODE_CLICK,{node:s,event:t.originalEvent,localPoint:i,globalPoint:n}),I(s)&&this._events.emit(e.EDGE_CLICK,{edge:s,event:t.originalEvent,localPoint:i,globalPoint:n})),this._events.emit(e.MOUSE_CLICK,{subject:s,event:t.originalEvent,localPoint:i,globalPoint:n}),(o.isStateChanged||o.changedSubject)&&(this._invalidateStyles(),this._renderer.render(this._graph))}else if("dblclick"===t.type){const o=this._strategy.onMouseDoubleClick(this._graph,i),s=o.changedSubject;if(s&&(E(s)&&this._events.emit(e.NODE_DOUBLE_CLICK,{node:s,event:t.originalEvent,localPoint:i,globalPoint:n}),I(s)&&this._events.emit(e.EDGE_DOUBLE_CLICK,{edge:s,event:t.originalEvent,localPoint:i,globalPoint:n})),this._events.emit(e.MOUSE_DOUBLE_CLICK,{subject:s,event:t.originalEvent,localPoint:i,globalPoint:n}),!s){const e=t.target._zoom+1;t.target.setZoomAround(t.layerPoint,e)}(o.isStateChanged||o.changedSubject)&&(this._invalidateStyles(),this._renderer.render(this._graph))}}),t.on("moveend",t=>{const e=t.target._mapPane._leaflet_pos,i=this._getStyleScale();this._renderer.transform=Object.assign(Object.assign({},e),{k:i}),this._renderer.render(this._graph)}),t.on("drag",t=>{const i=t.target._mapPane._leaflet_pos,n=this._getStyleScale();this._renderer.transform=Object.assign(Object.assign({},i),{k:n}),this._renderer.render(this._graph),this._events.emit(e.TRANSFORM,{transform:Object.assign(Object.assign({},i),{k:n})})}),t}_updateGraphPositions(){const t=this._graph.getNodes(),e=this._getStyleScale();for(let i=0;i{this._leaflet.attributionControl.setPrefix(t.attribution),this._leaflet.eachLayer(t=>this._leaflet.removeLayer(t)),t.instance.addTo(this._leaflet)})}}})(),n})()); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Orb=e():t.Orb=e()}(self,()=>(()=>{var t={481(t,e){!function(t){"use strict";function e(t){var e,i,n,s;for(i=1,n=arguments.length;i0?Math.floor(t):Math.ceil(t)};function I(t,e,i){return t instanceof N?t:p(t)?new N(t[0],t[1]):null==t?t:"object"==typeof t&&"x"in t&&"y"in t?new N(t.x,t.y):new N(t,e,i)}function R(t,e){if(t)for(var i=e?[t,e]:t,n=0,s=i.length;n=this.min.x&&i.x<=this.max.x&&e.y>=this.min.y&&i.y<=this.max.y},intersects:function(t){t=O(t);var e=this.min,i=this.max,n=t.min,s=t.max,o=s.x>=e.x&&n.x<=i.x,r=s.y>=e.y&&n.y<=i.y;return o&&r},overlaps:function(t){t=O(t);var e=this.min,i=this.max,n=t.min,s=t.max,o=s.x>e.x&&n.xe.y&&n.y=n.lat&&i.lat<=s.lat&&e.lng>=n.lng&&i.lng<=s.lng},intersects:function(t){t=B(t);var e=this._southWest,i=this._northEast,n=t.getSouthWest(),s=t.getNorthEast(),o=s.lat>=e.lat&&n.lat<=i.lat,r=s.lng>=e.lng&&n.lng<=i.lng;return o&&r},overlaps:function(t){t=B(t);var e=this._southWest,i=this._northEast,n=t.getSouthWest(),s=t.getNorthEast(),o=s.lat>e.lat&&n.late.lng&&n.lng1,Ct=function(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassiveEventSupport",h,e),window.removeEventListener("testPassiveEventSupport",h,e)}catch(t){}return t}(),Mt=!!document.createElement("canvas").getContext,Nt=!(!document.createElementNS||!Y("svg").createSVGRect),Dt=!!Nt&&((K=document.createElement("div")).innerHTML="","http://www.w3.org/2000/svg"===(K.firstChild&&K.firstChild.namespaceURI)),It=!Nt&&function(){try{var t=document.createElement("div");t.innerHTML='';var e=t.firstChild;return e.style.behavior="url(#default#VML)",e&&"object"==typeof e.adj}catch(t){return!1}}();function Lt(t){return navigator.userAgent.toLowerCase().indexOf(t)>=0}var Rt={ie:J,ielt9:tt,edge:et,webkit:it,android:nt,android23:st,androidStock:rt,opera:at,chrome:ht,gecko:lt,safari:dt,phantom:ut,opera12:ct,win:_t,ie3d:ft,webkit3d:gt,gecko3d:pt,any3d:mt,mobile:vt,mobileWebkit:yt,mobileWebkit3d:xt,msPointer:bt,pointer:St,touch:Tt,touchNative:wt,mobileOpera:Et,mobileGecko:Pt,retina:At,passiveEvents:Ct,canvas:Mt,svg:Nt,vml:It,inlineSvg:Dt,mac:0===navigator.platform.indexOf("Mac"),linux:0===navigator.platform.indexOf("Linux")},Ot=Rt.msPointer?"MSPointerDown":"pointerdown",kt=Rt.msPointer?"MSPointerMove":"pointermove",Bt=Rt.msPointer?"MSPointerUp":"pointerup",zt=Rt.msPointer?"MSPointerCancel":"pointercancel",Ut={touchstart:Ot,touchmove:kt,touchend:Bt,touchcancel:zt},Ft={touchstart:function(t,e){e.MSPOINTER_TYPE_TOUCH&&e.pointerType===e.MSPOINTER_TYPE_TOUCH&&Be(e),qt(t,e)},touchmove:qt,touchend:qt,touchcancel:qt},jt={},Wt=!1;function Zt(t,e,i){return"touchstart"===e&&(Wt||(document.addEventListener(Ot,Gt,!0),document.addEventListener(kt,Ht,!0),document.addEventListener(Bt,Xt,!0),document.addEventListener(zt,Xt,!0),Wt=!0)),Ft[e]?(i=Ft[e].bind(this,i),t.addEventListener(Ut[e],i,!1),i):(console.warn("wrong event specified:",e),h)}function Gt(t){jt[t.pointerId]=t}function Ht(t){jt[t.pointerId]&&(jt[t.pointerId]=t)}function Xt(t){delete jt[t.pointerId]}function qt(t,e){if(e.pointerType!==(e.MSPOINTER_TYPE_MOUSE||"mouse")){for(var i in e.touches=[],jt)e.touches.push(jt[i]);e.changedTouches=[e],t(e)}}var Vt,Yt,$t,Kt,Qt,Jt=ge(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),te=ge(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),ee="webkitTransition"===te||"OTransition"===te?te+"End":"transitionend";function ie(t){return"string"==typeof t?document.getElementById(t):t}function ne(t,e){var i=t.style[e]||t.currentStyle&&t.currentStyle[e];if((!i||"auto"===i)&&document.defaultView){var n=document.defaultView.getComputedStyle(t,null);i=n?n[e]:null}return"auto"===i?null:i}function se(t,e,i){var n=document.createElement(t);return n.className=e||"",i&&i.appendChild(n),n}function oe(t){var e=t.parentNode;e&&e.removeChild(t)}function re(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function ae(t){var e=t.parentNode;e&&e.lastChild!==t&&e.appendChild(t)}function he(t){var e=t.parentNode;e&&e.firstChild!==t&&e.insertBefore(t,e.firstChild)}function le(t,e){if(void 0!==t.classList)return t.classList.contains(e);var i=_e(t);return i.length>0&&new RegExp("(^|\\s)"+e+"(\\s|$)").test(i)}function de(t,e){if(void 0!==t.classList)for(var i=u(e),n=0,s=i.length;n0?2*window.devicePixelRatio:1;function We(t){return Rt.edge?t.wheelDeltaY/2:t.deltaY&&0===t.deltaMode?-t.deltaY/je:t.deltaY&&1===t.deltaMode?20*-t.deltaY:t.deltaY&&2===t.deltaMode?60*-t.deltaY:t.deltaX||t.deltaZ?0:t.wheelDelta?(t.wheelDeltaY||t.wheelDelta)/2:t.detail&&Math.abs(t.detail)<32765?20*-t.detail:t.detail?t.detail/-32765*60:0}function Ze(t,e){var i=e.relatedTarget;if(!i)return!0;try{for(;i&&i!==t;)i=i.parentNode}catch(t){return!1}return i!==t}var Ge={__proto__:null,on:Ae,off:Me,stopPropagation:Re,disableScrollPropagation:Oe,disableClickPropagation:ke,preventDefault:Be,stop:ze,getPropagationPath:Ue,getMousePosition:Fe,getWheelDelta:We,isExternalTarget:Ze,addListener:Ae,removeListener:Me},He=M.extend({run:function(t,e,i,n){this.stop(),this._el=t,this._inProgress=!0,this._duration=i||.25,this._easeOutPower=1/Math.max(n||.5,.2),this._startPos=ve(t),this._offset=e.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=T(this._animate,this),this._step()},_step:function(t){var e=+new Date-this._startTime,i=1e3*this._duration;ethis.options.maxZoom)?this.setZoom(t):this},panInsideBounds:function(t,e){this._enforcingBounds=!0;var i=this.getCenter(),n=this._limitCenter(i,this._zoom,B(t));return i.equals(n)||this.panTo(n,e),this._enforcingBounds=!1,this},panInside:function(t,e){var i=I((e=e||{}).paddingTopLeft||e.padding||[0,0]),n=I(e.paddingBottomRight||e.padding||[0,0]),s=this.project(this.getCenter()),o=this.project(t),r=this.getPixelBounds(),a=O([r.min.add(i),r.max.subtract(n)]),h=a.getSize();if(!a.contains(o)){this._enforcingBounds=!0;var l=o.subtract(a.getCenter()),d=a.extend(o).getSize().subtract(h);s.x+=l.x<0?-d.x:d.x,s.y+=l.y<0?-d.y:d.y,this.panTo(this.unproject(s),e),this._enforcingBounds=!1}return this},invalidateSize:function(t){if(!this._loaded)return this;t=e({animate:!1,pan:!0},!0===t?{animate:!0}:t);var i=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var s=this.getSize(),o=i.divideBy(2).round(),r=s.divideBy(2).round(),a=o.subtract(r);return a.x||a.y?(t.animate&&t.pan?this.panBy(a):(t.pan&&this._rawPanBy(a),this.fire("move"),t.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(n(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:i,newSize:s})):this},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(t){if(t=this._locateOptions=e({timeout:1e4,watch:!1},t),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var i=n(this._handleGeolocationResponse,this),s=n(this._handleGeolocationError,this);return t.watch?this._locationWatchId=navigator.geolocation.watchPosition(i,s,t):navigator.geolocation.getCurrentPosition(i,s,t),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(t){if(this._container._leaflet_id){var e=t.code,i=t.message||(1===e?"permission denied":2===e?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:e,message:"Geolocation error: "+i+"."})}},_handleGeolocationResponse:function(t){if(this._container._leaflet_id){var e=new z(t.coords.latitude,t.coords.longitude),i=e.toBounds(2*t.coords.accuracy),n=this._locateOptions;if(n.setView){var s=this.getBoundsZoom(i);this.setView(e,n.maxZoom?Math.min(s,n.maxZoom):s)}var o={latlng:e,bounds:i,timestamp:t.timestamp};for(var r in t.coords)"number"==typeof t.coords[r]&&(o[r]=t.coords[r]);this.fire("locationfound",o)}},addHandler:function(t,e){if(!e)return this;var i=this[t]=new e(this);return this._handlers.push(i),this.options[t]&&i.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch(t){this._container._leaflet_id=void 0,this._containerId=void 0}var t;for(t in void 0!==this._locationWatchId&&this.stopLocate(),this._stop(),oe(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(E(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload"),this._layers)this._layers[t].remove();for(t in this._panes)oe(this._panes[t]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(t,e){var i=se("div","leaflet-pane"+(t?" leaflet-"+t.replace("Pane","")+"-pane":""),e||this._mapPane);return t&&(this._panes[t]=i),i},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var t=this.getPixelBounds();return new k(this.unproject(t.getBottomLeft()),this.unproject(t.getTopRight()))},getMinZoom:function(){return void 0===this.options.minZoom?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return void 0===this.options.maxZoom?void 0===this._layersMaxZoom?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(t,e,i){t=B(t),i=I(i||[0,0]);var n=this.getZoom()||0,s=this.getMinZoom(),o=this.getMaxZoom(),r=t.getNorthWest(),a=t.getSouthEast(),h=this.getSize().subtract(i),l=O(this.project(a,n),this.project(r,n)).getSize(),d=Rt.any3d?this.options.zoomSnap:1,u=h.x/l.x,c=h.y/l.y,_=e?Math.max(u,c):Math.min(u,c);return n=this.getScaleZoom(_,n),d&&(n=Math.round(n/(d/100))*(d/100),n=e?Math.ceil(n/d)*d:Math.floor(n/d)*d),Math.max(s,Math.min(o,n))},getSize:function(){return this._size&&!this._sizeChanged||(this._size=new N(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(t,e){var i=this._getTopLeftPoint(t,e);return new R(i,i.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(t){return this.options.crs.getProjectedBounds(void 0===t?this.getZoom():t)},getPane:function(t){return"string"==typeof t?this._panes[t]:t},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(t,e){var i=this.options.crs;return e=void 0===e?this._zoom:e,i.scale(t)/i.scale(e)},getScaleZoom:function(t,e){var i=this.options.crs;e=void 0===e?this._zoom:e;var n=i.zoom(t*i.scale(e));return isNaN(n)?1/0:n},project:function(t,e){return e=void 0===e?this._zoom:e,this.options.crs.latLngToPoint(U(t),e)},unproject:function(t,e){return e=void 0===e?this._zoom:e,this.options.crs.pointToLatLng(I(t),e)},layerPointToLatLng:function(t){var e=I(t).add(this.getPixelOrigin());return this.unproject(e)},latLngToLayerPoint:function(t){return this.project(U(t))._round()._subtract(this.getPixelOrigin())},wrapLatLng:function(t){return this.options.crs.wrapLatLng(U(t))},wrapLatLngBounds:function(t){return this.options.crs.wrapLatLngBounds(B(t))},distance:function(t,e){return this.options.crs.distance(U(t),U(e))},containerPointToLayerPoint:function(t){return I(t).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(t){return I(t).add(this._getMapPanePos())},containerPointToLatLng:function(t){var e=this.containerPointToLayerPoint(I(t));return this.layerPointToLatLng(e)},latLngToContainerPoint:function(t){return this.layerPointToContainerPoint(this.latLngToLayerPoint(U(t)))},mouseEventToContainerPoint:function(t){return Fe(t,this._container)},mouseEventToLayerPoint:function(t){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(t))},mouseEventToLatLng:function(t){return this.layerPointToLatLng(this.mouseEventToLayerPoint(t))},_initContainer:function(t){var e=this._container=ie(t);if(!e)throw new Error("Map container not found.");if(e._leaflet_id)throw new Error("Map container is already initialized.");Ae(e,"scroll",this._onScroll,this),this._containerId=o(e)},_initLayout:function(){var t=this._container;this._fadeAnimated=this.options.fadeAnimation&&Rt.any3d,de(t,"leaflet-container"+(Rt.touch?" leaflet-touch":"")+(Rt.retina?" leaflet-retina":"")+(Rt.ielt9?" leaflet-oldie":"")+(Rt.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var e=ne(t,"position");"absolute"!==e&&"relative"!==e&&"fixed"!==e&&"sticky"!==e&&(t.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var t=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),me(this._mapPane,new N(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(de(t.markerPane,"leaflet-zoom-hide"),de(t.shadowPane,"leaflet-zoom-hide"))},_resetView:function(t,e,i){me(this._mapPane,new N(0,0));var n=!this._loaded;this._loaded=!0,e=this._limitZoom(e),this.fire("viewprereset");var s=this._zoom!==e;this._moveStart(s,i)._move(t,e)._moveEnd(s),this.fire("viewreset"),n&&this.fire("load")},_moveStart:function(t,e){return t&&this.fire("zoomstart"),e||this.fire("movestart"),this},_move:function(t,e,i,n){void 0===e&&(e=this._zoom);var s=this._zoom!==e;return this._zoom=e,this._lastCenter=t,this._pixelOrigin=this._getNewPixelOrigin(t),n?i&&i.pinch&&this.fire("zoom",i):((s||i&&i.pinch)&&this.fire("zoom",i),this.fire("move",i)),this},_moveEnd:function(t){return t&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return E(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(t){me(this._mapPane,this._getMapPanePos().subtract(t))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(t){this._targets={},this._targets[o(this._container)]=this;var e=t?Me:Ae;e(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&e(window,"resize",this._onResize,this),Rt.any3d&&this.options.transform3DLimit&&(t?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){E(this._resizeRequest),this._resizeRequest=T(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var t=this._getMapPanePos();Math.max(Math.abs(t.x),Math.abs(t.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(t,e){for(var i,n=[],s="mouseout"===e||"mouseover"===e,r=t.target||t.srcElement,a=!1;r;){if((i=this._targets[o(r)])&&("click"===e||"preclick"===e)&&this._draggableMoved(i)){a=!0;break}if(i&&i.listens(e,!0)){if(s&&!Ze(r,t))break;if(n.push(i),s)break}if(r===this._container)break;r=r.parentNode}return n.length||a||s||!this.listens(e,!0)||(n=[this]),n},_isClickDisabled:function(t){for(;t&&t!==this._container;){if(t._leaflet_disable_click)return!0;t=t.parentNode}},_handleDOMEvent:function(t){var e=t.target||t.srcElement;if(!(!this._loaded||e._leaflet_disable_events||"click"===t.type&&this._isClickDisabled(e))){var i=t.type;"mousedown"===i&&Se(e),this._fireDOMEvent(t,i)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(t,i,n){if("click"===t.type){var s=e({},t);s.type="preclick",this._fireDOMEvent(s,s.type,n)}var o=this._findEventTargets(t,i);if(n){for(var r=[],a=0;a0?Math.round(t-e)/2:Math.max(0,Math.ceil(t))-Math.max(0,Math.floor(e))},_limitZoom:function(t){var e=this.getMinZoom(),i=this.getMaxZoom(),n=Rt.any3d?this.options.zoomSnap:1;return n&&(t=Math.round(t/n)*n),Math.max(e,Math.min(i,t))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){ue(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(t,e){var i=this._getCenterOffset(t)._trunc();return!(!0!==(e&&e.animate)&&!this.getSize().contains(i)||(this.panBy(i,e),0))},_createAnimProxy:function(){var t=this._proxy=se("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(t),this.on("zoomanim",function(t){var e=Jt,i=this._proxy.style[e];pe(this._proxy,this.project(t.center,t.zoom),this.getZoomScale(t.zoom,1)),i===this._proxy.style[e]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){oe(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var t=this.getCenter(),e=this.getZoom();pe(this._proxy,this.project(t,e),this.getZoomScale(e,1))},_catchTransitionEnd:function(t){this._animatingZoom&&t.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(t,e,i){if(this._animatingZoom)return!0;if(i=i||{},!this._zoomAnimated||!1===i.animate||this._nothingToAnimate()||Math.abs(e-this._zoom)>this.options.zoomAnimationThreshold)return!1;var n=this.getZoomScale(e),s=this._getCenterOffset(t)._divideBy(1-1/n);return!(!0!==i.animate&&!this.getSize().contains(s)||(T(function(){this._moveStart(!0,i.noMoveStart||!1)._animateZoom(t,e,!0)},this),0))},_animateZoom:function(t,e,i,s){this._mapPane&&(i&&(this._animatingZoom=!0,this._animateToCenter=t,this._animateToZoom=e,de(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:t,zoom:e,noUpdate:s}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(n(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&ue(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire("zoom"),delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0))}});var qe=A.extend({options:{position:"topright"},initialize:function(t){c(this,t)},getPosition:function(){return this.options.position},setPosition:function(t){var e=this._map;return e&&e.removeControl(this),this.options.position=t,e&&e.addControl(this),this},getContainer:function(){return this._container},addTo:function(t){this.remove(),this._map=t;var e=this._container=this.onAdd(t),i=this.getPosition(),n=t._controlCorners[i];return de(e,"leaflet-control"),-1!==i.indexOf("bottom")?n.insertBefore(e,n.firstChild):n.appendChild(e),this._map.on("unload",this.remove,this),this},remove:function(){return this._map?(oe(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this):this},_refocusOnMap:function(t){this._map&&t&&t.screenX>0&&t.screenY>0&&this._map.getContainer().focus()}}),Ve=function(t){return new qe(t)};Xe.include({addControl:function(t){return t.addTo(this),this},removeControl:function(t){return t.remove(),this},_initControlPos:function(){var t=this._controlCorners={},e="leaflet-",i=this._controlContainer=se("div",e+"control-container",this._container);function n(n,s){var o=e+n+" "+e+s;t[n+s]=se("div",o,i)}n("top","left"),n("top","right"),n("bottom","left"),n("bottom","right")},_clearControlPos:function(){for(var t in this._controlCorners)oe(this._controlCorners[t]);oe(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var Ye=qe.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(t,e,i,n){return i1,this._baseLayersList.style.display=t?"":"none"),this._separator.style.display=e&&t?"":"none",this},_onLayerChange:function(t){this._handlingClick||this._update();var e=this._getLayer(o(t.target)),i=e.overlay?"add"===t.type?"overlayadd":"overlayremove":"add"===t.type?"baselayerchange":null;i&&this._map.fire(i,e)},_createRadioElement:function(t,e){var i='",n=document.createElement("div");return n.innerHTML=i,n.firstChild},_addItem:function(t){var e,i=document.createElement("label"),n=this._map.hasLayer(t.layer);t.overlay?((e=document.createElement("input")).type="checkbox",e.className="leaflet-control-layers-selector",e.defaultChecked=n):e=this._createRadioElement("leaflet-base-layers_"+o(this),n),this._layerControlInputs.push(e),e.layerId=o(t.layer),Ae(e,"click",this._onInputClick,this);var s=document.createElement("span");s.innerHTML=" "+t.name;var r=document.createElement("span");return i.appendChild(r),r.appendChild(e),r.appendChild(s),(t.overlay?this._overlaysList:this._baseLayersList).appendChild(i),this._checkDisabledLayers(),i},_onInputClick:function(){if(!this._preventClick){var t,e,i=this._layerControlInputs,n=[],s=[];this._handlingClick=!0;for(var o=i.length-1;o>=0;o--)t=i[o],e=this._getLayer(t.layerId).layer,t.checked?n.push(e):t.checked||s.push(e);for(o=0;o=0;s--)t=i[s],e=this._getLayer(t.layerId).layer,t.disabled=void 0!==e.options.minZoom&&ne.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var t=this._section;this._preventClick=!0,Ae(t,"click",Be),this.expand();var e=this;setTimeout(function(){Me(t,"click",Be),e._preventClick=!1})}}),$e=qe.extend({options:{position:"topleft",zoomInText:'',zoomInTitle:"Zoom in",zoomOutText:'',zoomOutTitle:"Zoom out"},onAdd:function(t){var e="leaflet-control-zoom",i=se("div",e+" leaflet-bar"),n=this.options;return this._zoomInButton=this._createButton(n.zoomInText,n.zoomInTitle,e+"-in",i,this._zoomIn),this._zoomOutButton=this._createButton(n.zoomOutText,n.zoomOutTitle,e+"-out",i,this._zoomOut),this._updateDisabled(),t.on("zoomend zoomlevelschange",this._updateDisabled,this),i},onRemove:function(t){t.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(t){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(t.shiftKey?3:1))},_createButton:function(t,e,i,n,s){var o=se("a",i,n);return o.innerHTML=t,o.href="#",o.title=e,o.setAttribute("role","button"),o.setAttribute("aria-label",e),ke(o),Ae(o,"click",ze),Ae(o,"click",s,this),Ae(o,"click",this._refocusOnMap,this),o},_updateDisabled:function(){var t=this._map,e="leaflet-disabled";ue(this._zoomInButton,e),ue(this._zoomOutButton,e),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),(this._disabled||t._zoom===t.getMinZoom())&&(de(this._zoomOutButton,e),this._zoomOutButton.setAttribute("aria-disabled","true")),(this._disabled||t._zoom===t.getMaxZoom())&&(de(this._zoomInButton,e),this._zoomInButton.setAttribute("aria-disabled","true"))}});Xe.mergeOptions({zoomControl:!0}),Xe.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new $e,this.addControl(this.zoomControl))});var Ke=qe.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(t){var e="leaflet-control-scale",i=se("div",e),n=this.options;return this._addScales(n,e+"-line",i),t.on(n.updateWhenIdle?"moveend":"move",this._update,this),t.whenReady(this._update,this),i},onRemove:function(t){t.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(t,e,i){t.metric&&(this._mScale=se("div",e,i)),t.imperial&&(this._iScale=se("div",e,i))},_update:function(){var t=this._map,e=t.getSize().y/2,i=t.distance(t.containerPointToLatLng([0,e]),t.containerPointToLatLng([this.options.maxWidth,e]));this._updateScales(i)},_updateScales:function(t){this.options.metric&&t&&this._updateMetric(t),this.options.imperial&&t&&this._updateImperial(t)},_updateMetric:function(t){var e=this._getRoundNum(t),i=e<1e3?e+" m":e/1e3+" km";this._updateScale(this._mScale,i,e/t)},_updateImperial:function(t){var e,i,n,s=3.2808399*t;s>5280?(e=s/5280,i=this._getRoundNum(e),this._updateScale(this._iScale,i+" mi",i/e)):(n=this._getRoundNum(s),this._updateScale(this._iScale,n+" ft",n/s))},_updateScale:function(t,e,i){t.style.width=Math.round(this.options.maxWidth*i)+"px",t.innerHTML=e},_getRoundNum:function(t){var e=Math.pow(10,(Math.floor(t)+"").length-1),i=t/e;return e*(i>=10?10:i>=5?5:i>=3?3:i>=2?2:1)}}),Qe=qe.extend({options:{position:"bottomright",prefix:''+(Rt.inlineSvg?' ':"")+"Leaflet"},initialize:function(t){c(this,t),this._attributions={}},onAdd:function(t){for(var e in t.attributionControl=this,this._container=se("div","leaflet-control-attribution"),ke(this._container),t._layers)t._layers[e].getAttribution&&this.addAttribution(t._layers[e].getAttribution());return this._update(),t.on("layeradd",this._addAttribution,this),this._container},onRemove:function(t){t.off("layeradd",this._addAttribution,this)},_addAttribution:function(t){t.layer.getAttribution&&(this.addAttribution(t.layer.getAttribution()),t.layer.once("remove",function(){this.removeAttribution(t.layer.getAttribution())},this))},setPrefix:function(t){return this.options.prefix=t,this._update(),this},addAttribution:function(t){return t?(this._attributions[t]||(this._attributions[t]=0),this._attributions[t]++,this._update(),this):this},removeAttribution:function(t){return t?(this._attributions[t]&&(this._attributions[t]--,this._update()),this):this},_update:function(){if(this._map){var t=[];for(var e in this._attributions)this._attributions[e]&&t.push(e);var i=[];this.options.prefix&&i.push(this.options.prefix),t.length&&i.push(t.join(", ")),this._container.innerHTML=i.join(' ')}}});Xe.mergeOptions({attributionControl:!0}),Xe.addInitHook(function(){this.options.attributionControl&&(new Qe).addTo(this)});qe.Layers=Ye,qe.Zoom=$e,qe.Scale=Ke,qe.Attribution=Qe,Ve.layers=function(t,e,i){return new Ye(t,e,i)},Ve.zoom=function(t){return new $e(t)},Ve.scale=function(t){return new Ke(t)},Ve.attribution=function(t){return new Qe(t)};var Je=A.extend({initialize:function(t){this._map=t},enable:function(){return this._enabled||(this._enabled=!0,this.addHooks()),this},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}});Je.addTo=function(t,e){return t.addHandler(e,this),this};var ti={Events:C},ei=Rt.touch?"touchstart mousedown":"mousedown",ii=M.extend({options:{clickTolerance:3},initialize:function(t,e,i,n){c(this,n),this._element=t,this._dragStartTarget=e||t,this._preventOutline=i},enable:function(){this._enabled||(Ae(this._dragStartTarget,ei,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(ii._dragging===this&&this.finishDrag(!0),Me(this._dragStartTarget,ei,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(t){if(this._enabled&&(this._moved=!1,!le(this._element,"leaflet-zoom-anim")))if(t.touches&&1!==t.touches.length)ii._dragging===this&&this.finishDrag();else if(!(ii._dragging||t.shiftKey||1!==t.which&&1!==t.button&&!t.touches||(ii._dragging=this,this._preventOutline&&Se(this._element),xe(),Vt(),this._moving))){this.fire("down");var e=t.touches?t.touches[0]:t,i=Te(this._element);this._startPoint=new N(e.clientX,e.clientY),this._startPos=ve(this._element),this._parentScale=Ee(i);var n="mousedown"===t.type;Ae(document,n?"mousemove":"touchmove",this._onMove,this),Ae(document,n?"mouseup":"touchend touchcancel",this._onUp,this)}},_onMove:function(t){if(this._enabled)if(t.touches&&t.touches.length>1)this._moved=!0;else{var e=t.touches&&1===t.touches.length?t.touches[0]:t,i=new N(e.clientX,e.clientY)._subtract(this._startPoint);(i.x||i.y)&&(Math.abs(i.x)+Math.abs(i.y)e&&(i.push(t[n]),s=n);return sh&&(o=r,h=a);h>i&&(e[o]=1,di(t,e,i,n,o),di(t,e,i,o,s))}function ui(t,e,i,n,s){var o,r,a,h=n?ri:_i(t,i),l=_i(e,i);for(ri=l;;){if(!(h|l))return[t,e];if(h&l)return!1;a=_i(r=ci(t,e,o=h||l,i,s),i),o===h?(t=r,h=a):(e=r,l=a)}}function ci(t,e,i,n,s){var o,r,a=e.x-t.x,h=e.y-t.y,l=n.min,d=n.max;return 8&i?(o=t.x+a*(d.y-t.y)/h,r=d.y):4&i?(o=t.x+a*(l.y-t.y)/h,r=l.y):2&i?(o=d.x,r=t.y+h*(d.x-t.x)/a):1&i&&(o=l.x,r=t.y+h*(l.x-t.x)/a),new N(o,r,s)}function _i(t,e){var i=0;return t.xe.max.x&&(i|=2),t.ye.max.y&&(i|=8),i}function fi(t,e){var i=e.x-t.x,n=e.y-t.y;return i*i+n*n}function gi(t,e,i,n){var s,o=e.x,r=e.y,a=i.x-o,h=i.y-r,l=a*a+h*h;return l>0&&((s=((t.x-o)*a+(t.y-r)*h)/l)>1?(o=i.x,r=i.y):s>0&&(o+=a*s,r+=h*s)),a=t.x-o,h=t.y-r,n?a*a+h*h:new N(o,r)}function pi(t){return!p(t[0])||"object"!=typeof t[0][0]&&void 0!==t[0][0]}function mi(t){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),pi(t)}function vi(t,e){var i,n,s,o,r,a,h,l;if(!t||0===t.length)throw new Error("latlngs not passed");pi(t)||(console.warn("latlngs are not flat! Only the first ring will be used"),t=t[0]);var d=U([0,0]),u=B(t);u.getNorthWest().distanceTo(u.getSouthWest())*u.getNorthEast().distanceTo(u.getNorthWest())<1700&&(d=oi(t));var c=t.length,_=[];for(i=0;in){h=(o-n)/s,l=[a.x-h*(a.x-r.x),a.y-h*(a.y-r.y)];break}var g=e.unproject(I(l));return U([g.lat+d.lat,g.lng+d.lng])}var yi={__proto__:null,simplify:hi,pointToSegmentDistance:li,closestPointOnSegment:function(t,e,i){return gi(t,e,i)},clipSegment:ui,_getEdgeIntersection:ci,_getBitCode:_i,_sqClosestPointOnSegment:gi,isFlat:pi,_flat:mi,polylineCenter:vi},xi={project:function(t){return new N(t.lng,t.lat)},unproject:function(t){return new z(t.y,t.x)},bounds:new R([-180,-90],[180,90])},bi={R:6378137,R_MINOR:6356752.314245179,bounds:new R([-20037508.34279,-15496570.73972],[20037508.34279,18764656.23138]),project:function(t){var e=Math.PI/180,i=this.R,n=t.lat*e,s=this.R_MINOR/i,o=Math.sqrt(1-s*s),r=o*Math.sin(n),a=Math.tan(Math.PI/4-n/2)/Math.pow((1-r)/(1+r),o/2);return n=-i*Math.log(Math.max(a,1e-10)),new N(t.lng*e*i,n)},unproject:function(t){for(var e,i=180/Math.PI,n=this.R,s=this.R_MINOR/n,o=Math.sqrt(1-s*s),r=Math.exp(-t.y/n),a=Math.PI/2-2*Math.atan(r),h=0,l=.1;h<15&&Math.abs(l)>1e-7;h++)e=o*Math.sin(a),e=Math.pow((1-e)/(1+e),o/2),a+=l=Math.PI/2-2*Math.atan(r*e)-a;return new z(a*i,t.x*i/n)}},Si={__proto__:null,LonLat:xi,Mercator:bi,SphericalMercator:G},wi=e({},W,{code:"EPSG:3395",projection:bi,transformation:function(){var t=.5/(Math.PI*bi.R);return X(t,.5,-t,.5)}()}),Ti=e({},W,{code:"EPSG:4326",projection:xi,transformation:X(1/180,1,-1/180,.5)}),Ei=e({},j,{projection:xi,transformation:X(1,0,-1,0),scale:function(t){return Math.pow(2,t)},zoom:function(t){return Math.log(t)/Math.LN2},distance:function(t,e){var i=e.lng-t.lng,n=e.lat-t.lat;return Math.sqrt(i*i+n*n)},infinite:!0});j.Earth=W,j.EPSG3395=wi,j.EPSG3857=q,j.EPSG900913=V,j.EPSG4326=Ti,j.Simple=Ei;var Pi=M.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(t){return t.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(t){return t&&t.removeLayer(this),this},getPane:function(t){return this._map.getPane(t?this.options[t]||t:this.options.pane)},addInteractiveTarget:function(t){return this._map._targets[o(t)]=this,this},removeInteractiveTarget:function(t){return delete this._map._targets[o(t)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(t){var e=t.target;if(e.hasLayer(this)){if(this._map=e,this._zoomAnimated=e._zoomAnimated,this.getEvents){var i=this.getEvents();e.on(i,this),this.once("remove",function(){e.off(i,this)},this)}this.onAdd(e),this.fire("add"),e.fire("layeradd",{layer:this})}}});Xe.include({addLayer:function(t){if(!t._layerAdd)throw new Error("The provided object is not a Layer.");var e=o(t);return this._layers[e]||(this._layers[e]=t,t._mapToAdd=this,t.beforeAdd&&t.beforeAdd(this),this.whenReady(t._layerAdd,t)),this},removeLayer:function(t){var e=o(t);return this._layers[e]?(this._loaded&&t.onRemove(this),delete this._layers[e],this._loaded&&(this.fire("layerremove",{layer:t}),t.fire("remove")),t._map=t._mapToAdd=null,this):this},hasLayer:function(t){return o(t)in this._layers},eachLayer:function(t,e){for(var i in this._layers)t.call(e,this._layers[i]);return this},_addLayers:function(t){for(var e=0,i=(t=t?p(t)?t:[t]:[]).length;ethis._layersMaxZoom&&this.setZoom(this._layersMaxZoom),void 0===this.options.minZoom&&this._layersMinZoom&&this.getZoom()=2&&e[0]instanceof z&&e[0].equals(e[i-1])&&e.pop(),e},_setLatLngs:function(t){ki.prototype._setLatLngs.call(this,t),pi(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return pi(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var t=this._renderer._bounds,e=this.options.weight,i=new N(e,e);if(t=new R(t.min.subtract(i),t.max.add(i)),this._parts=[],this._pxBounds&&this._pxBounds.intersects(t))if(this.options.noClip)this._parts=this._rings;else for(var n,s=0,o=this._rings.length;st.y!=n.y>t.y&&t.x<(n.x-i.x)*(t.y-i.y)/(n.y-i.y)+i.x&&(l=!l);return l||ki.prototype._containsPoint.call(this,t,!0)}});var zi=Ci.extend({initialize:function(t,e){c(this,e),this._layers={},t&&this.addData(t)},addData:function(t){var e,i,n,s=p(t)?t:t.features;if(s){for(e=0,i=s.length;e0&&s.push(s[0].slice()),s}function Hi(t,i){return t.feature?e({},t.feature,{geometry:i}):Xi(i)}function Xi(t){return"Feature"===t.type||"FeatureCollection"===t.type?t:{type:"Feature",properties:{},geometry:t}}var qi={toGeoJSON:function(t){return Hi(this,{type:"Point",coordinates:Zi(this.getLatLng(),t)})}};function Vi(t,e){return new zi(t,e)}Ii.include(qi),Oi.include(qi),Ri.include(qi),ki.include({toGeoJSON:function(t){var e=!pi(this._latlngs);return Hi(this,{type:(e?"Multi":"")+"LineString",coordinates:Gi(this._latlngs,e?1:0,!1,t)})}}),Bi.include({toGeoJSON:function(t){var e=!pi(this._latlngs),i=e&&!pi(this._latlngs[0]),n=Gi(this._latlngs,i?2:e?1:0,!0,t);return e||(n=[n]),Hi(this,{type:(i?"Multi":"")+"Polygon",coordinates:n})}}),Ai.include({toMultiPoint:function(t){var e=[];return this.eachLayer(function(i){e.push(i.toGeoJSON(t).geometry.coordinates)}),Hi(this,{type:"MultiPoint",coordinates:e})},toGeoJSON:function(t){var e=this.feature&&this.feature.geometry&&this.feature.geometry.type;if("MultiPoint"===e)return this.toMultiPoint(t);var i="GeometryCollection"===e,n=[];return this.eachLayer(function(e){if(e.toGeoJSON){var s=e.toGeoJSON(t);if(i)n.push(s.geometry);else{var o=Xi(s);"FeatureCollection"===o.type?n.push.apply(n,o.features):n.push(o)}}}),i?Hi(this,{geometries:n,type:"GeometryCollection"}):{type:"FeatureCollection",features:n}}});var Yi=Vi,$i=Pi.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(t,e,i){this._url=t,this._bounds=B(e),c(this,i)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(de(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){oe(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(t){return this.options.opacity=t,this._image&&this._updateOpacity(),this},setStyle:function(t){return t.opacity&&this.setOpacity(t.opacity),this},bringToFront:function(){return this._map&&ae(this._image),this},bringToBack:function(){return this._map&&he(this._image),this},setUrl:function(t){return this._url=t,this._image&&(this._image.src=t),this},setBounds:function(t){return this._bounds=B(t),this._map&&this._reset(),this},getEvents:function(){var t={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(t.zoomanim=this._animateZoom),t},setZIndex:function(t){return this.options.zIndex=t,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var t="IMG"===this._url.tagName,e=this._image=t?this._url:se("img");de(e,"leaflet-image-layer"),this._zoomAnimated&&de(e,"leaflet-zoom-animated"),this.options.className&&de(e,this.options.className),e.onselectstart=h,e.onmousemove=h,e.onload=n(this.fire,this,"load"),e.onerror=n(this._overlayOnError,this,"error"),(this.options.crossOrigin||""===this.options.crossOrigin)&&(e.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),t?this._url=e.src:(e.src=this._url,e.alt=this.options.alt)},_animateZoom:function(t){var e=this._map.getZoomScale(t.zoom),i=this._map._latLngBoundsToNewLayerBounds(this._bounds,t.zoom,t.center).min;pe(this._image,i,e)},_reset:function(){var t=this._image,e=new R(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),i=e.getSize();me(t,e.min),t.style.width=i.x+"px",t.style.height=i.y+"px"},_updateOpacity:function(){fe(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&void 0!==this.options.zIndex&&null!==this.options.zIndex&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire("error");var t=this.options.errorOverlayUrl;t&&this._url!==t&&(this._url=t,this._image.src=t)},getCenter:function(){return this._bounds.getCenter()}}),Ki=$i.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var t="VIDEO"===this._url.tagName,e=this._image=t?this._url:se("video");if(de(e,"leaflet-image-layer"),this._zoomAnimated&&de(e,"leaflet-zoom-animated"),this.options.className&&de(e,this.options.className),e.onselectstart=h,e.onmousemove=h,e.onloadeddata=n(this.fire,this,"load"),t){for(var i=e.getElementsByTagName("source"),s=[],o=0;o0?s:[e.src]}else{p(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(e.style,"objectFit")&&(e.style.objectFit="fill"),e.autoplay=!!this.options.autoplay,e.loop=!!this.options.loop,e.muted=!!this.options.muted,e.playsInline=!!this.options.playsInline;for(var r=0;rs?(e.height=s+"px",de(t,o)):ue(t,o),this._containerWidth=this._container.offsetWidth},_animateZoom:function(t){var e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center),i=this._getAnchor();me(this._container,e.add(i))},_adjustPan:function(){if(this.options.autoPan)if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning)this._autopanning=!1;else{var t=this._map,e=parseInt(ne(this._container,"marginBottom"),10)||0,i=this._container.offsetHeight+e,n=this._containerWidth,s=new N(this._containerLeft,-i-this._containerBottom);s._add(ve(this._container));var o=t.layerPointToContainerPoint(s),r=I(this.options.autoPanPadding),a=I(this.options.autoPanPaddingTopLeft||r),h=I(this.options.autoPanPaddingBottomRight||r),l=t.getSize(),d=0,u=0;o.x+n+h.x>l.x&&(d=o.x+n-l.x+h.x),o.x-d-a.x<0&&(d=o.x-a.x),o.y+i+h.y>l.y&&(u=o.y+i-l.y+h.y),o.y-u-a.y<0&&(u=o.y-a.y),(d||u)&&(this.options.keepInView&&(this._autopanning=!0),t.fire("autopanstart").panBy([d,u]))}},_getAnchor:function(){return I(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}});Xe.mergeOptions({closePopupOnClick:!0}),Xe.include({openPopup:function(t,e,i){return this._initOverlay(tn,t,e,i).openOn(this),this},closePopup:function(t){return(t=arguments.length?t:this._popup)&&t.close(),this}}),Pi.include({bindPopup:function(t,e){return this._popup=this._initOverlay(tn,this._popup,t,e),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(t){return this._popup&&(this instanceof Ci||(this._popup._source=this),this._popup._prepareOpen(t||this._latlng)&&this._popup.openOn(this._map)),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return!!this._popup&&this._popup.isOpen()},setPopupContent:function(t){return this._popup&&this._popup.setContent(t),this},getPopup:function(){return this._popup},_openPopup:function(t){if(this._popup&&this._map){ze(t);var e=t.layer||t.target;this._popup._source!==e||e instanceof Li?(this._popup._source=e,this.openPopup(t.latlng)):this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(t.latlng)}},_movePopup:function(t){this._popup.setLatLng(t.latlng)},_onKeyPress:function(t){13===t.originalEvent.keyCode&&this._openPopup(t)}});var en=Ji.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(t){Ji.prototype.onAdd.call(this,t),this.setOpacity(this.options.opacity),t.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(t){Ji.prototype.onRemove.call(this,t),t.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var t=Ji.prototype.getEvents.call(this);return this.options.permanent||(t.preclick=this.close),t},_initLayout:function(){var t="leaflet-tooltip "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=se("div",t),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+o(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(t){var e,i,n=this._map,s=this._container,o=n.latLngToContainerPoint(n.getCenter()),r=n.layerPointToContainerPoint(t),a=this.options.direction,h=s.offsetWidth,l=s.offsetHeight,d=I(this.options.offset),u=this._getAnchor();"top"===a?(e=h/2,i=l):"bottom"===a?(e=h/2,i=0):"center"===a?(e=h/2,i=l/2):"right"===a?(e=0,i=l/2):"left"===a?(e=h,i=l/2):r.xthis.options.maxZoom||in&&this._retainParent(s,o,r,n))},_retainChildren:function(t,e,i,n){for(var s=2*t;s<2*t+2;s++)for(var o=2*e;o<2*e+2;o++){var r=new N(s,o);r.z=i+1;var a=this._tileCoordsToKey(r),h=this._tiles[a];h&&h.active?h.retain=!0:(h&&h.loaded&&(h.retain=!0),i+1this.options.maxZoom||void 0!==this.options.minZoom&&s1)this._setView(t,i);else{for(var u=s.min.y;u<=s.max.y;u++)for(var c=s.min.x;c<=s.max.x;c++){var _=new N(c,u);if(_.z=this._tileZoom,this._isValidTile(_)){var f=this._tiles[this._tileCoordsToKey(_)];f?f.current=!0:r.push(_)}}if(r.sort(function(t,e){return t.distanceTo(o)-e.distanceTo(o)}),0!==r.length){this._loading||(this._loading=!0,this.fire("loading"));var g=document.createDocumentFragment();for(c=0;ci.max.x)||!e.wrapLat&&(t.yi.max.y))return!1}if(!this.options.bounds)return!0;var n=this._tileCoordsToBounds(t);return B(this.options.bounds).overlaps(n)},_keyToBounds:function(t){return this._tileCoordsToBounds(this._keyToTileCoords(t))},_tileCoordsToNwSe:function(t){var e=this._map,i=this.getTileSize(),n=t.scaleBy(i),s=n.add(i);return[e.unproject(n,t.z),e.unproject(s,t.z)]},_tileCoordsToBounds:function(t){var e=this._tileCoordsToNwSe(t),i=new k(e[0],e[1]);return this.options.noWrap||(i=this._map.wrapLatLngBounds(i)),i},_tileCoordsToKey:function(t){return t.x+":"+t.y+":"+t.z},_keyToTileCoords:function(t){var e=t.split(":"),i=new N(+e[0],+e[1]);return i.z=+e[2],i},_removeTile:function(t){var e=this._tiles[t];e&&(oe(e.el),delete this._tiles[t],this.fire("tileunload",{tile:e.el,coords:this._keyToTileCoords(t)}))},_initTile:function(t){de(t,"leaflet-tile");var e=this.getTileSize();t.style.width=e.x+"px",t.style.height=e.y+"px",t.onselectstart=h,t.onmousemove=h,Rt.ielt9&&this.options.opacity<1&&fe(t,this.options.opacity)},_addTile:function(t,e){var i=this._getTilePos(t),s=this._tileCoordsToKey(t),o=this.createTile(this._wrapCoords(t),n(this._tileReady,this,t));this._initTile(o),this.createTile.length<2&&T(n(this._tileReady,this,t,null,o)),me(o,i),this._tiles[s]={el:o,coords:t,current:!0},e.appendChild(o),this.fire("tileloadstart",{tile:o,coords:t})},_tileReady:function(t,e,i){e&&this.fire("tileerror",{error:e,tile:i,coords:t});var s=this._tileCoordsToKey(t);(i=this._tiles[s])&&(i.loaded=+new Date,this._map._fadeAnimated?(fe(i.el,0),E(this._fadeFrame),this._fadeFrame=T(this._updateOpacity,this)):(i.active=!0,this._pruneTiles()),e||(de(i.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:i.el,coords:t})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),Rt.ielt9||!this._map._fadeAnimated?T(this._pruneTiles,this):setTimeout(n(this._pruneTiles,this),250)))},_getTilePos:function(t){return t.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(t){var e=new N(this._wrapX?a(t.x,this._wrapX):t.x,this._wrapY?a(t.y,this._wrapY):t.y);return e.z=t.z,e},_pxBoundsToTileRange:function(t){var e=this.getTileSize();return new R(t.min.unscaleBy(e).floor(),t.max.unscaleBy(e).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var t in this._tiles)if(!this._tiles[t].loaded)return!1;return!0}});var on=sn.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(t,e){this._url=t,(e=c(this,e)).detectRetina&&Rt.retina&&e.maxZoom>0?(e.tileSize=Math.floor(e.tileSize/2),e.zoomReverse?(e.zoomOffset--,e.minZoom=Math.min(e.maxZoom,e.minZoom+1)):(e.zoomOffset++,e.maxZoom=Math.max(e.minZoom,e.maxZoom-1)),e.minZoom=Math.max(0,e.minZoom)):e.zoomReverse?e.minZoom=Math.min(e.maxZoom,e.minZoom):e.maxZoom=Math.max(e.minZoom,e.maxZoom),"string"==typeof e.subdomains&&(e.subdomains=e.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(t,e){return this._url===t&&void 0===e&&(e=!0),this._url=t,e||this.redraw(),this},createTile:function(t,e){var i=document.createElement("img");return Ae(i,"load",n(this._tileOnLoad,this,e,i)),Ae(i,"error",n(this._tileOnError,this,e,i)),(this.options.crossOrigin||""===this.options.crossOrigin)&&(i.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),"string"==typeof this.options.referrerPolicy&&(i.referrerPolicy=this.options.referrerPolicy),i.alt="",i.src=this.getTileUrl(t),i},getTileUrl:function(t){var i={r:Rt.retina?"@2x":"",s:this._getSubdomain(t),x:t.x,y:t.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var n=this._globalTileRange.max.y-t.y;this.options.tms&&(i.y=n),i["-y"]=n}return g(this._url,e(i,this.options))},_tileOnLoad:function(t,e){Rt.ielt9?setTimeout(n(t,this,null,e),0):t(null,e)},_tileOnError:function(t,e,i){var n=this.options.errorTileUrl;n&&e.getAttribute("src")!==n&&(e.src=n),t(i,e)},_onTileRemove:function(t){t.tile.onload=null},_getZoomForUrl:function(){var t=this._tileZoom,e=this.options.maxZoom;return this.options.zoomReverse&&(t=e-t),t+this.options.zoomOffset},_getSubdomain:function(t){var e=Math.abs(t.x+t.y)%this.options.subdomains.length;return this.options.subdomains[e]},_abortLoading:function(){var t,e;for(t in this._tiles)if(this._tiles[t].coords.z!==this._tileZoom&&((e=this._tiles[t].el).onload=h,e.onerror=h,!e.complete)){e.src=v;var i=this._tiles[t].coords;oe(e),delete this._tiles[t],this.fire("tileabort",{tile:e,coords:i})}},_removeTile:function(t){var e=this._tiles[t];if(e)return e.el.setAttribute("src",v),sn.prototype._removeTile.call(this,t)},_tileReady:function(t,e,i){if(this._map&&(!i||i.getAttribute("src")!==v))return sn.prototype._tileReady.call(this,t,e,i)}});function rn(t,e){return new on(t,e)}var an=on.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(t,i){this._url=t;var n=e({},this.defaultWmsParams);for(var s in i)s in this.options||(n[s]=i[s]);var o=(i=c(this,i)).detectRetina&&Rt.retina?2:1,r=this.getTileSize();n.width=r.x*o,n.height=r.y*o,this.wmsParams=n},onAdd:function(t){this._crs=this.options.crs||t.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var e=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[e]=this._crs.code,on.prototype.onAdd.call(this,t)},getTileUrl:function(t){var e=this._tileCoordsToNwSe(t),i=this._crs,n=O(i.project(e[0]),i.project(e[1])),s=n.min,o=n.max,r=(this._wmsVersion>=1.3&&this._crs===Ti?[s.y,s.x,o.y,o.x]:[s.x,s.y,o.x,o.y]).join(","),a=on.prototype.getTileUrl.call(this,t);return a+_(this.wmsParams,a,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+r},setParams:function(t,i){return e(this.wmsParams,t),i||this.redraw(),this}});on.WMS=an,rn.wms=function(t,e){return new an(t,e)};var hn=Pi.extend({options:{padding:.1},initialize:function(t){c(this,t),o(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),de(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var t={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(t.zoomanim=this._onAnimZoom),t},_onAnimZoom:function(t){this._updateTransform(t.center,t.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(t,e){var i=this._map.getZoomScale(e,this._zoom),n=this._map.getSize().multiplyBy(.5+this.options.padding),s=this._map.project(this._center,e),o=n.multiplyBy(-i).add(s).subtract(this._map._getNewPixelOrigin(t,e));Rt.any3d?pe(this._container,o,i):me(this._container,o)},_reset:function(){for(var t in this._update(),this._updateTransform(this._center,this._zoom),this._layers)this._layers[t]._reset()},_onZoomEnd:function(){for(var t in this._layers)this._layers[t]._project()},_updatePaths:function(){for(var t in this._layers)this._layers[t]._update()},_update:function(){var t=this.options.padding,e=this._map.getSize(),i=this._map.containerPointToLayerPoint(e.multiplyBy(-t)).round();this._bounds=new R(i,i.add(e.multiplyBy(1+2*t)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),ln=hn.extend({options:{tolerance:0},getEvents:function(){var t=hn.prototype.getEvents.call(this);return t.viewprereset=this._onViewPreReset,t},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){hn.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var t=this._container=document.createElement("canvas");Ae(t,"mousemove",this._onMouseMove,this),Ae(t,"click dblclick mousedown mouseup contextmenu",this._onClick,this),Ae(t,"mouseout",this._handleMouseOut,this),t._leaflet_disable_events=!0,this._ctx=t.getContext("2d")},_destroyContainer:function(){E(this._redrawRequest),delete this._ctx,oe(this._container),Me(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){for(var t in this._redrawBounds=null,this._layers)this._layers[t]._update();this._redraw()}},_update:function(){if(!this._map._animatingZoom||!this._bounds){hn.prototype._update.call(this);var t=this._bounds,e=this._container,i=t.getSize(),n=Rt.retina?2:1;me(e,t.min),e.width=n*i.x,e.height=n*i.y,e.style.width=i.x+"px",e.style.height=i.y+"px",Rt.retina&&this._ctx.scale(2,2),this._ctx.translate(-t.min.x,-t.min.y),this.fire("update")}},_reset:function(){hn.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(t){this._updateDashArray(t),this._layers[o(t)]=t;var e=t._order={layer:t,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=e),this._drawLast=e,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(t){this._requestRedraw(t)},_removePath:function(t){var e=t._order,i=e.next,n=e.prev;i?i.prev=n:this._drawLast=n,n?n.next=i:this._drawFirst=i,delete t._order,delete this._layers[o(t)],this._requestRedraw(t)},_updatePath:function(t){this._extendRedrawBounds(t),t._project(),t._update(),this._requestRedraw(t)},_updateStyle:function(t){this._updateDashArray(t),this._requestRedraw(t)},_updateDashArray:function(t){if("string"==typeof t.options.dashArray){var e,i,n=t.options.dashArray.split(/[, ]+/),s=[];for(i=0;i')}}catch(t){}return function(t){return document.createElement("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}(),cn={_initContainer:function(){this._container=se("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(hn.prototype._update.call(this),this.fire("update"))},_initPath:function(t){var e=t._container=un("shape");de(e,"leaflet-vml-shape "+(this.options.className||"")),e.coordsize="1 1",t._path=un("path"),e.appendChild(t._path),this._updateStyle(t),this._layers[o(t)]=t},_addPath:function(t){var e=t._container;this._container.appendChild(e),t.options.interactive&&t.addInteractiveTarget(e)},_removePath:function(t){var e=t._container;oe(e),t.removeInteractiveTarget(e),delete this._layers[o(t)]},_updateStyle:function(t){var e=t._stroke,i=t._fill,n=t.options,s=t._container;s.stroked=!!n.stroke,s.filled=!!n.fill,n.stroke?(e||(e=t._stroke=un("stroke")),s.appendChild(e),e.weight=n.weight+"px",e.color=n.color,e.opacity=n.opacity,n.dashArray?e.dashStyle=p(n.dashArray)?n.dashArray.join(" "):n.dashArray.replace(/( *, *)/g," "):e.dashStyle="",e.endcap=n.lineCap.replace("butt","flat"),e.joinstyle=n.lineJoin):e&&(s.removeChild(e),t._stroke=null),n.fill?(i||(i=t._fill=un("fill")),s.appendChild(i),i.color=n.fillColor||n.color,i.opacity=n.fillOpacity):i&&(s.removeChild(i),t._fill=null)},_updateCircle:function(t){var e=t._point.round(),i=Math.round(t._radius),n=Math.round(t._radiusY||i);this._setPath(t,t._empty()?"M0 0":"AL "+e.x+","+e.y+" "+i+","+n+" 0,23592600")},_setPath:function(t,e){t._path.v=e},_bringToFront:function(t){ae(t._container)},_bringToBack:function(t){he(t._container)}},_n=Rt.vml?un:Y,fn=hn.extend({_initContainer:function(){this._container=_n("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=_n("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){oe(this._container),Me(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!this._map._animatingZoom||!this._bounds){hn.prototype._update.call(this);var t=this._bounds,e=t.getSize(),i=this._container;this._svgSize&&this._svgSize.equals(e)||(this._svgSize=e,i.setAttribute("width",e.x),i.setAttribute("height",e.y)),me(i,t.min),i.setAttribute("viewBox",[t.min.x,t.min.y,e.x,e.y].join(" ")),this.fire("update")}},_initPath:function(t){var e=t._path=_n("path");t.options.className&&de(e,t.options.className),t.options.interactive&&de(e,"leaflet-interactive"),this._updateStyle(t),this._layers[o(t)]=t},_addPath:function(t){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(t._path),t.addInteractiveTarget(t._path)},_removePath:function(t){oe(t._path),t.removeInteractiveTarget(t._path),delete this._layers[o(t)]},_updatePath:function(t){t._project(),t._update()},_updateStyle:function(t){var e=t._path,i=t.options;e&&(i.stroke?(e.setAttribute("stroke",i.color),e.setAttribute("stroke-opacity",i.opacity),e.setAttribute("stroke-width",i.weight),e.setAttribute("stroke-linecap",i.lineCap),e.setAttribute("stroke-linejoin",i.lineJoin),i.dashArray?e.setAttribute("stroke-dasharray",i.dashArray):e.removeAttribute("stroke-dasharray"),i.dashOffset?e.setAttribute("stroke-dashoffset",i.dashOffset):e.removeAttribute("stroke-dashoffset")):e.setAttribute("stroke","none"),i.fill?(e.setAttribute("fill",i.fillColor||i.color),e.setAttribute("fill-opacity",i.fillOpacity),e.setAttribute("fill-rule",i.fillRule||"evenodd")):e.setAttribute("fill","none"))},_updatePoly:function(t,e){this._setPath(t,$(t._parts,e))},_updateCircle:function(t){var e=t._point,i=Math.max(Math.round(t._radius),1),n="a"+i+","+(Math.max(Math.round(t._radiusY),1)||i)+" 0 1,0 ",s=t._empty()?"M0 0":"M"+(e.x-i)+","+e.y+n+2*i+",0 "+n+2*-i+",0 ";this._setPath(t,s)},_setPath:function(t,e){t._path.setAttribute("d",e)},_bringToFront:function(t){ae(t._path)},_bringToBack:function(t){he(t._path)}});function gn(t){return Rt.svg||Rt.vml?new fn(t):null}Rt.vml&&fn.include(cn),Xe.include({getRenderer:function(t){var e=t.options.renderer||this._getPaneRenderer(t.options.pane)||this.options.renderer||this._renderer;return e||(e=this._renderer=this._createRenderer()),this.hasLayer(e)||this.addLayer(e),e},_getPaneRenderer:function(t){if("overlayPane"===t||void 0===t)return!1;var e=this._paneRenderers[t];return void 0===e&&(e=this._createRenderer({pane:t}),this._paneRenderers[t]=e),e},_createRenderer:function(t){return this.options.preferCanvas&&dn(t)||gn(t)}});var pn=Bi.extend({initialize:function(t,e){Bi.prototype.initialize.call(this,this._boundsToLatLngs(t),e)},setBounds:function(t){return this.setLatLngs(this._boundsToLatLngs(t))},_boundsToLatLngs:function(t){return[(t=B(t)).getSouthWest(),t.getNorthWest(),t.getNorthEast(),t.getSouthEast()]}});fn.create=_n,fn.pointsToPath=$,zi.geometryToLayer=Ui,zi.coordsToLatLng=ji,zi.coordsToLatLngs=Wi,zi.latLngToCoords=Zi,zi.latLngsToCoords=Gi,zi.getFeature=Hi,zi.asFeature=Xi,Xe.mergeOptions({boxZoom:!0});var mn=Je.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane,this._resetStateTimeout=0,t.on("unload",this._destroy,this)},addHooks:function(){Ae(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){Me(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){oe(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){0!==this._resetStateTimeout&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(t){if(!t.shiftKey||1!==t.which&&1!==t.button)return!1;this._clearDeferredResetState(),this._resetState(),Vt(),xe(),this._startPoint=this._map.mouseEventToContainerPoint(t),Ae(document,{contextmenu:ze,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(t){this._moved||(this._moved=!0,this._box=se("div","leaflet-zoom-box",this._container),de(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(t);var e=new R(this._point,this._startPoint),i=e.getSize();me(this._box,e.min),this._box.style.width=i.x+"px",this._box.style.height=i.y+"px"},_finish:function(){this._moved&&(oe(this._box),ue(this._container,"leaflet-crosshair")),Yt(),be(),Me(document,{contextmenu:ze,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(t){if((1===t.which||1===t.button)&&(this._finish(),this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(n(this._resetState,this),0);var e=new k(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(e).fire("boxzoomend",{boxZoomBounds:e})}},_onKeyDown:function(t){27===t.keyCode&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});Xe.addInitHook("addHandler","boxZoom",mn),Xe.mergeOptions({doubleClickZoom:!0});var vn=Je.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(t){var e=this._map,i=e.getZoom(),n=e.options.zoomDelta,s=t.originalEvent.shiftKey?i-n:i+n;"center"===e.options.doubleClickZoom?e.setZoom(s):e.setZoomAround(t.containerPoint,s)}});Xe.addInitHook("addHandler","doubleClickZoom",vn),Xe.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var yn=Je.extend({addHooks:function(){if(!this._draggable){var t=this._map;this._draggable=new ii(t._mapPane,t._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),t.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),t.on("zoomend",this._onZoomEnd,this),t.whenReady(this._onZoomEnd,this))}de(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){ue(this._map._container,"leaflet-grab"),ue(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var t=this._map;if(t._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var e=B(this._map.options.maxBounds);this._offsetLimit=O(this._map.latLngToContainerPoint(e.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(e.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;t.fire("movestart").fire("dragstart"),t.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(t){if(this._map.options.inertia){var e=this._lastTime=+new Date,i=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(i),this._times.push(e),this._prunePositions(e)}this._map.fire("move",t).fire("drag",t)},_prunePositions:function(t){for(;this._positions.length>1&&t-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var t=this._map.getSize().divideBy(2),e=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=e.subtract(t).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(t,e){return t-(t-e)*this._viscosity},_onPreDragLimit:function(){if(this._viscosity&&this._offsetLimit){var t=this._draggable._newPos.subtract(this._draggable._startPos),e=this._offsetLimit;t.xe.max.x&&(t.x=this._viscousLimit(t.x,e.max.x)),t.y>e.max.y&&(t.y=this._viscousLimit(t.y,e.max.y)),this._draggable._newPos=this._draggable._startPos.add(t)}},_onPreDragWrap:function(){var t=this._worldWidth,e=Math.round(t/2),i=this._initialWorldOffset,n=this._draggable._newPos.x,s=(n-e+i)%t+e-i,o=(n+e+i)%t-e-i,r=Math.abs(s+i)0?o:-o))-e;this._delta=0,this._startTime=null,r&&("center"===t.options.scrollWheelZoom?t.setZoom(e+r):t.setZoomAround(this._lastMousePos,e+r))}});Xe.addInitHook("addHandler","scrollWheelZoom",bn);Xe.mergeOptions({tapHold:Rt.touchNative&&Rt.safari&&Rt.mobile,tapTolerance:15});var Sn=Je.extend({addHooks:function(){Ae(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){Me(this._map._container,"touchstart",this._onDown,this)},_onDown:function(t){if(clearTimeout(this._holdTimeout),1===t.touches.length){var e=t.touches[0];this._startPos=this._newPos=new N(e.clientX,e.clientY),this._holdTimeout=setTimeout(n(function(){this._cancel(),this._isTapValid()&&(Ae(document,"touchend",Be),Ae(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",e))},this),600),Ae(document,"touchend touchcancel contextmenu",this._cancel,this),Ae(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function t(){Me(document,"touchend",Be),Me(document,"touchend touchcancel",t)},_cancel:function(){clearTimeout(this._holdTimeout),Me(document,"touchend touchcancel contextmenu",this._cancel,this),Me(document,"touchmove",this._onMove,this)},_onMove:function(t){var e=t.touches[0];this._newPos=new N(e.clientX,e.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(t,e){var i=new MouseEvent(t,{bubbles:!0,cancelable:!0,view:window,screenX:e.screenX,screenY:e.screenY,clientX:e.clientX,clientY:e.clientY});i._simulated=!0,e.target.dispatchEvent(i)}});Xe.addInitHook("addHandler","tapHold",Sn),Xe.mergeOptions({touchZoom:Rt.touch,bounceAtZoomLimits:!0});var wn=Je.extend({addHooks:function(){de(this._map._container,"leaflet-touch-zoom"),Ae(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){ue(this._map._container,"leaflet-touch-zoom"),Me(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(t){var e=this._map;if(t.touches&&2===t.touches.length&&!e._animatingZoom&&!this._zooming){var i=e.mouseEventToContainerPoint(t.touches[0]),n=e.mouseEventToContainerPoint(t.touches[1]);this._centerPoint=e.getSize()._divideBy(2),this._startLatLng=e.containerPointToLatLng(this._centerPoint),"center"!==e.options.touchZoom&&(this._pinchStartLatLng=e.containerPointToLatLng(i.add(n)._divideBy(2))),this._startDist=i.distanceTo(n),this._startZoom=e.getZoom(),this._moved=!1,this._zooming=!0,e._stop(),Ae(document,"touchmove",this._onTouchMove,this),Ae(document,"touchend touchcancel",this._onTouchEnd,this),Be(t)}},_onTouchMove:function(t){if(t.touches&&2===t.touches.length&&this._zooming){var e=this._map,i=e.mouseEventToContainerPoint(t.touches[0]),s=e.mouseEventToContainerPoint(t.touches[1]),o=i.distanceTo(s)/this._startDist;if(this._zoom=e.getScaleZoom(o,this._startZoom),!e.options.bounceAtZoomLimits&&(this._zoome.getMaxZoom()&&o>1)&&(this._zoom=e._limitZoom(this._zoom)),"center"===e.options.touchZoom){if(this._center=this._startLatLng,1===o)return}else{var r=i._add(s)._divideBy(2)._subtract(this._centerPoint);if(1===o&&0===r.x&&0===r.y)return;this._center=e.unproject(e.project(this._pinchStartLatLng,this._zoom).subtract(r),this._zoom)}this._moved||(e._moveStart(!0,!1),this._moved=!0),E(this._animRequest);var a=n(e._move,e,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=T(a,this,!0),Be(t)}},_onTouchEnd:function(){this._moved&&this._zooming?(this._zooming=!1,E(this._animRequest),Me(document,"touchmove",this._onTouchMove,this),Me(document,"touchend touchcancel",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))):this._zooming=!1}});Xe.addInitHook("addHandler","touchZoom",wn),Xe.BoxZoom=mn,Xe.DoubleClickZoom=vn,Xe.Drag=yn,Xe.Keyboard=xn,Xe.ScrollWheelZoom=bn,Xe.TapHold=Sn,Xe.TouchZoom=wn,t.Bounds=R,t.Browser=Rt,t.CRS=j,t.Canvas=ln,t.Circle=Oi,t.CircleMarker=Ri,t.Class=A,t.Control=qe,t.DivIcon=nn,t.DivOverlay=Ji,t.DomEvent=Ge,t.DomUtil=Pe,t.Draggable=ii,t.Evented=M,t.FeatureGroup=Ci,t.GeoJSON=zi,t.GridLayer=sn,t.Handler=Je,t.Icon=Mi,t.ImageOverlay=$i,t.LatLng=z,t.LatLngBounds=k,t.Layer=Pi,t.LayerGroup=Ai,t.LineUtil=yi,t.Map=Xe,t.Marker=Ii,t.Mixin=ti,t.Path=Li,t.Point=N,t.PolyUtil=ai,t.Polygon=Bi,t.Polyline=ki,t.Popup=tn,t.PosAnimation=He,t.Projection=Si,t.Rectangle=pn,t.Renderer=hn,t.SVG=fn,t.SVGOverlay=Qi,t.TileLayer=on,t.Tooltip=en,t.Transformation=H,t.Util=P,t.VideoOverlay=Ki,t.bind=n,t.bounds=O,t.canvas=dn,t.circle=function(t,e,i){return new Oi(t,e,i)},t.circleMarker=function(t,e){return new Ri(t,e)},t.control=Ve,t.divIcon=function(t){return new nn(t)},t.extend=e,t.featureGroup=function(t,e){return new Ci(t,e)},t.geoJSON=Vi,t.geoJson=Yi,t.gridLayer=function(t){return new sn(t)},t.icon=function(t){return new Mi(t)},t.imageOverlay=function(t,e,i){return new $i(t,e,i)},t.latLng=U,t.latLngBounds=B,t.layerGroup=function(t,e){return new Ai(t,e)},t.map=function(t,e){return new Xe(t,e)},t.marker=function(t,e){return new Ii(t,e)},t.point=I,t.polygon=function(t,e){return new Bi(t,e)},t.polyline=function(t,e){return new ki(t,e)},t.popup=function(t,e){return new tn(t,e)},t.rectangle=function(t,e){return new pn(t,e)},t.setOptions=c,t.stamp=o,t.svg=gn,t.svgOverlay=function(t,e,i){return new Qi(t,e,i)},t.tileLayer=rn,t.tooltip=function(t,e){return new en(t,e)},t.transformation=X,t.version="1.9.4",t.videoOverlay=function(t,e,i){return new Ki(t,e,i)};var Tn=window.L;t.noConflict=function(){return window.L=Tn,this},window.L=t}(e)}};const e={};function i(n){const s=e[n];if(void 0!==s)return s.exports;const o=e[n]={exports:{}};return t[n].call(o.exports,o,o.exports,i),o.exports}i.d=(t,e)=>{if(Array.isArray(e))for(var n=0;nObject.prototype.hasOwnProperty.call(t,e),i.r=t=>{Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};let n={};return(()=>{"use strict";i.r(n),i.d(n,{Color:()=>U,EdgeLineStyleType:()=>M,EdgeType:()=>N,GraphObjectState:()=>r,NodeShapeType:()=>S,OrbError:()=>o,OrbEventType:()=>e,OrbMapView:()=>hr,OrbView:()=>rr,RendererType:()=>ks,getDefaultGraphStyle:()=>H,graphToSVG:()=>Ko,isEdge:()=>I,isNode:()=>T});class t{constructor(){this._listeners=new Map}once(t,e){const i={callable:e,isOnce:!0},n=this._listeners.get(t);return n?n.push(i):this._listeners.set(t,[i]),this}on(t,e){const i={callable:e},n=this._listeners.get(t);return n?n.push(i):this._listeners.set(t,[i]),this}off(t,e){const i=this._listeners.get(t);if(i){const n=i.filter(t=>t.callable!==e);this._listeners.set(t,n)}return this}emit(t,e){const i=this._listeners.get(t);if(!i||0===i.length)return!1;let n=!1;for(let t=0;t!t.isOnce);this._listeners.set(t,e)}return!0}eventNames(){return[...this._listeners.keys()]}listenerCount(t){const e=this._listeners.get(t);return e?e.length:0}listeners(t){const e=this._listeners.get(t);return e?e.map(t=>t.callable):[]}addListener(t,e){return this.on(t,e)}removeListener(t,e){return this.off(t,e)}removeAllListeners(t){return t?this._listeners.delete(t):this._listeners.clear(),this}}var e;!function(t){t.RENDER_START="render-start",t.RENDER_END="render-end",t.SIMULATION_START="simulation-start",t.SIMULATION_STEP="simulation-step",t.SIMULATION_END="simulation-end",t.NODE_CLICK="node-click",t.NODE_HOVER="node-hover",t.EDGE_CLICK="edge-click",t.EDGE_HOVER="edge-hover",t.MOUSE_CLICK="mouse-click",t.MOUSE_MOVE="mouse-move",t.TRANSFORM="transform",t.NODE_DRAG_START="node-drag-start",t.NODE_DRAG="node-drag",t.NODE_DRAG_END="node-drag-end",t.NODE_RIGHT_CLICK="node-right-click",t.EDGE_RIGHT_CLICK="edge-right-click",t.MOUSE_RIGHT_CLICK="mouse-right-click",t.NODE_DOUBLE_CLICK="node-double-click",t.EDGE_DOUBLE_CLICK="edge-double-click",t.MOUSE_DOUBLE_CLICK="mouse-double-click"}(e||(e={}));class s extends t{}class o extends Error{constructor(t){super(t),this.message=t,Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}}const r={NONE:0,SELECTED:1,HOVERED:2};class a{constructor(){this._imageByUrl={}}static getInstance(){return a._instance||(a._instance=new a),a._instance}getImage(t){return this._imageByUrl[t]}loadImage(t,e){const i=this.getImage(t);if(i)return i;const n=new Image;return this._imageByUrl[t]=n,n.onload=()=>{h(n),null==e||e()},n.onerror=()=>{null==e||e(new Error(`Image ${t} failed to load.`))},n.src=t,n}loadImages(t,e){const i=[],n=new Set(t),s=t=>{n.delete(t),0===n.size&&(null==e||e())};for(let e=0;e{h(a),s(o)},a.onerror=()=>{s(o)},a.src=o,i.push(a)}return i}}const h=t=>t&&0===t.width?(document.body.appendChild(t),t.width=t.offsetWidth,t.height=t.offsetHeight,document.body.removeChild(t),t):t;class l{constructor(){this.listeners=[]}addListener(t){this.listeners.push(t)}getListeners(){return[...this.listeners]}removeListener(t){const e=this.listeners.indexOf(t);-1!==e&&this.listeners.splice(e,1)}notifyListeners(t){for(let e=0;e"number"==typeof t,u=t=>"boolean"==typeof t,c=t=>t instanceof Date,_=t=>Array.isArray(t),f=t=>null!==t&&"object"==typeof t&&"Object"===t.constructor.name,g=t=>"function"==typeof t,p=t=>c(t)?v(t):_(t)?y(t):f(t)?x(t):t,m=(t,e)=>{const i=c(t),n=c(e);if(i&&!n||!i&&n)return!1;if(i&&n)return t.getTime()===e.getTime();const s=_(t),o=_(e);if(s&&!o||!s&&o)return!1;if(s&&o)return t.length===e.length&&t.every((t,i)=>m(t,e[i]));const r=f(t),a=f(e);if(r&&!a||!r&&a)return!1;if(r&&a){const i=Object.keys(t),n=Object.keys(e);return!!m(i,n)&&i.every(i=>m(t[i],e[i]))}return t===e},v=t=>new Date(t),y=t=>t.map(t=>p(t)),x=t=>{const e={};return Object.keys(t).forEach(i=>{e[i]=p(t[i])}),e},b=(t,e)=>{const i=Object.keys(e);for(let n=0;nt instanceof E;class E extends l{constructor(t,e){super(),this._style={},this._state=r.NONE,this._inEdgesById={},this._outEdgesById={},this.id=t.data.id,this._data=t.data,this._position={id:this.id},this._onLoadedImage=null==e?void 0:e.onLoadedImage,e&&e.listeners&&(this.listeners=e.listeners)}getId(){return this.id}getData(){return this._data}getPosition(){return this._position}getStyle(){return this._style}getState(){return this._state}clearPosition(){this._position.x=void 0,this._position.y=void 0,this.notifyListeners()}getCenter(){return void 0===this._position.x||void 0===this._position.y?{x:0,y:0}:{x:this._position.x,y:this._position.y}}getRadius(){var t;return null!==(t=this._style.size)&&void 0!==t?t:0}getBorderedRadius(){return this.getRadius()+this.getBorderWidth()/2}getBoundingBox(){const t=this.getCenter(),e=this.getBorderedRadius();return{x:t.x-e,y:t.y-e,width:2*e,height:2*e}}getInEdges(){return Object.values(this._inEdgesById)}getOutEdges(){return Object.values(this._outEdgesById)}getEdges(){const t={},e=this.getOutEdges();for(let i=0;i0}addEdge(t){t.start===this.id&&(this._outEdgesById[t.getId()]=t),t.end===this.id&&(this._inEdgesById[t.getId()]=t)}removeEdge(t){delete this._outEdgesById[t.getId()],delete this._inEdgesById[t.getId()]}isSelected(){return this._state===r.SELECTED}isHovered(){return this._state===r.HOVERED}clearState(){this.setState(r.NONE,{isNotifySkipped:!0})}getDistanceToBorder(){return this.getBorderedRadius()}includesPoint(t){const e=this._isPointInBoundingBox(t);if(!e)return!1;if(this._style.shape===S.SQUARE)return e;const i=this.getCenter(),n=this.getBorderedRadius(),s=t.x-i.x,o=t.y-i.y;return Math.sqrt(s*s+o*o)<=n}hasShadow(){var t,e,i;return(null!==(t=this._style.shadowSize)&&void 0!==t?t:0)>0||(null!==(e=this._style.shadowOffsetX)&&void 0!==e?e:0)>0||(null!==(i=this._style.shadowOffsetY)&&void 0!==i?i:0)>0}hasBorder(){var t,e;const i=(null!==(t=this._style.borderWidth)&&void 0!==t?t:0)>0,n=(null!==(e=this._style.borderWidthSelected)&&void 0!==e?e:0)>0;return i||this.isSelected()&&n}getLabel(){return this._style.label}getColor(){let t;return this._style.color&&(t=this._style.color),this.isHovered()&&this._style.colorHover&&(t=this._style.colorHover),this.isSelected()&&this._style.colorSelected&&(t=this._style.colorSelected),t}getBorderWidth(){let t=0;return this._style.borderWidth&&this._style.borderWidth>0&&(t=this._style.borderWidth),this.isSelected()&&this._style.borderWidthSelected&&this._style.borderWidthSelected>0&&(t=this._style.borderWidthSelected),t}getBorderColor(){if(!this.hasBorder())return;let t;return this._style.borderColor&&(t=this._style.borderColor),this.isHovered()&&this._style.borderColorHover&&(t=this._style.borderColorHover),this.isSelected()&&this._style.borderColorSelected&&(t=this._style.borderColorSelected.toString()),t}getBackgroundImage(){var t;if((null!==(t=this._style.size)&&void 0!==t?t:0)<=0)return;let e;if(this._style.imageUrl&&(e=this._style.imageUrl),this.isSelected()&&this._style.imageUrlSelected&&(e=this._style.imageUrlSelected),!e)return;return a.getInstance().getImage(e)||a.getInstance().loadImage(e,t=>{var e;t||null===(e=this._onLoadedImage)||void 0===e||e.call(this)})}setData(t){g(t)?this._data=t(this):this._data=t,this.notifyListeners()}patchData(t){let e;e=g(t)?t(this):t,b(this._data,e),this.notifyListeners()}setPosition(t,e){let i;i=g(t)?t(this):t,"x"in i&&"y"in i&&(this._position.x=i.x,this._position.y=i.y,"id"in i&&(this._position.id=i.id)),(null==e?void 0:e.isNotifySkipped)||this.notifyListeners(Object.assign({id:this.id},i))}setStyle(t,e){g(t)?this._style=t(this):this._style=t,(null==e?void 0:e.isNotifySkipped)||this.notifyListeners()}patchStyle(t,e){let i;i=g(t)?t(this):t,b(this._style,i),(null==e?void 0:e.isNotifySkipped)||this.notifyListeners()}setState(t,e){let i;if(i=g(t)?t(this):t,d(i))this._state=i;else if(f(i)){const t=i.options;if(this._state=this._handleState(i.state,t),t)return void this.notifyListeners({id:this.id,type:"node",options:t})}(null==e?void 0:e.isNotifySkipped)||this.notifyListeners()}_isPointInBoundingBox(t){return((t,e)=>{const i=t.x+t.width,n=t.y+t.height;return e.x>=t.x&&e.x<=i&&e.y>=t.y&&e.y<=n})(this.getBoundingBox(),t)}_handleState(t,e){return(null==e?void 0:e.isToggle)&&this._state===t?r.NONE:t}}const P=(t,e,i)=>{const n=e.x-t.x,s=e.y-t.y;let o=((i.x-t.x)*n+(i.y-t.y)*s)/(n*n+s*s);o>1&&(o=1),o<0&&(o=0);const r=t.x+o*n,a=t.y+o*s,h=r-i.x,l=a-i.y;return Math.sqrt(h*h+l*l)},A=[5,5],C=[1,1];var M,N;!function(t){t.SOLID="solid",t.DASHED="dashed",t.DOTTED="dotted",t.CUSTOM="custom"}(M||(M={})),function(t){t.STRAIGHT="straight",t.LOOPBACK="loopback",t.CURVED="curved"}(N||(N={}));class D{static create(t,e){switch(R(t)){case N.STRAIGHT:return new O(t,e);case N.LOOPBACK:return new B(t,e);case N.CURVED:return new k(t,e);default:return new O(t,e)}}static copy(t,e){const i=D.create({data:t.getData(),offset:void 0!==(null==e?void 0:e.offset)?e.offset:t.offset,startNode:t.startNode,endNode:t.endNode});i.setState(t.getState()),i.setStyle(t.getStyle());const n=t.getListeners();for(let t=0;tt instanceof O||t instanceof k||t instanceof B;class L extends l{constructor(t,e){var i;super(),this._style={},this._state=r.NONE,this._type=N.STRAIGHT,this.id=t.data.id,this._data=t.data,this.offset=null!==(i=t.offset)&&void 0!==i?i:0,this.startNode=t.startNode,this.endNode=t.endNode,this._type=R(t),this._position={id:this.id,source:this.startNode.getId(),target:this.endNode.getId()},this.startNode.addEdge(this),this.endNode.addEdge(this),e&&e.listeners&&(this.listeners=e.listeners)}getId(){return this.id}getData(){return this._data}getPosition(){return this._position}getStyle(){return this._style}getState(){return this._state}get type(){return this._type}get start(){return this._data.start}get end(){return this._data.end}hasStyle(){return this._style&&Object.keys(this._style).length>0}isSelected(){return this._state===r.SELECTED}isHovered(){return this._state===r.HOVERED}clearState(){this._state=r.NONE}isLoopback(){return this._type===N.LOOPBACK}isStraight(){return this._type===N.STRAIGHT}isCurved(){return this._type===N.CURVED}getCenter(){var t,e;const i=null===(t=this.startNode)||void 0===t?void 0:t.getCenter(),n=null===(e=this.endNode)||void 0===e?void 0:e.getCenter();return i&&n?{x:(i.x+n.x)/2,y:(i.y+n.y)/2}:{x:0,y:0}}getDistance(t){const e=this.startNode.getCenter(),i=this.endNode.getCenter();return e&&i?P(e,i,t):0}getLabel(){return this._style.label}hasShadow(){var t,e,i;return(null!==(t=this._style.shadowSize)&&void 0!==t?t:0)>0||(null!==(e=this._style.shadowOffsetX)&&void 0!==e?e:0)>0||(null!==(i=this._style.shadowOffsetY)&&void 0!==i?i:0)>0}getWidth(){let t=0;return void 0!==this._style.width&&(t=this._style.width),this.isHovered()&&void 0!==this._style.widthHover&&(t=this._style.widthHover),this.isSelected()&&void 0!==this._style.widthSelected&&(t=this._style.widthSelected),t}getColor(){let t;return this._style.color&&(t=this._style.color),this.isHovered()&&this._style.colorHover&&(t=this._style.colorHover),this.isSelected()&&this._style.colorSelected&&(t=this._style.colorSelected),t}getLineDashPattern(){const t=this._style.lineStyle;if(void 0===t||t.type===M.SOLID)return null;switch(t.type){case M.DASHED:return A;case M.DOTTED:return C;case M.CUSTOM:return e=t.pattern,_(e)&&e.every(t=>d(t))?t.pattern:null;default:return null}var e}setData(t){g(t)?this._data=t(this):this._data=t,this.notifyListeners()}patchData(t){let e;e=g(t)?t(this):t,b(this._data,e),this.notifyListeners()}setStyle(t,e){g(t)?this._style=t(this):this._style=t,(null==e?void 0:e.isNotifySkipped)||this.notifyListeners()}patchStyle(t,e){let i;i=g(t)?t(this):t,b(this._style,i),(null==e?void 0:e.isNotifySkipped)||this.notifyListeners()}setState(t,e){let i;if(i=g(t)?t(this):t,d(i))this._state=i;else if(f(i)){const t=i.options;if(this._state=this._handleState(i.state,t),t)return void this.notifyListeners({id:this.id,type:"edge",options:t})}(null==e?void 0:e.isNotifySkipped)||this.notifyListeners()}_handleState(t,e){return(null==e?void 0:e.isToggle)&&this._state===t?r.NONE:t}}const R=t=>{var e;return t.startNode.getId()===t.endNode.getId()?N.LOOPBACK:0===(null!==(e=t.offset)&&void 0!==e?e:0)?N.STRAIGHT:N.CURVED};class O extends L{getCenter(){var t,e;const i=null===(t=this.startNode)||void 0===t?void 0:t.getCenter(),n=null===(e=this.endNode)||void 0===e?void 0:e.getCenter();return i&&n?{x:(i.x+n.x)/2,y:(i.y+n.y)/2}:{x:0,y:0}}getDistance(t){var e,i;const n=null===(e=this.startNode)||void 0===e?void 0:e.getCenter(),s=null===(i=this.endNode)||void 0===i?void 0:i.getCenter();return n&&s?P(n,s,t):0}}class k extends L{getCenter(){return this.getCurvedControlPoint(2)}getDistance(t){var e,i;const n=null===(e=this.startNode)||void 0===e?void 0:e.getCenter(),s=null===(i=this.endNode)||void 0===i?void 0:i.getCenter();if(!n||!s)return 0;const o=this.getCurvedControlPoint();let r,a,h,l,d,u=1e9,c=n.x,_=n.y;for(a=1;a<10;a++)h=.1*a,l=Math.pow(1-h,2)*n.x+2*h*(1-h)*o.x+Math.pow(h,2)*s.x,d=Math.pow(1-h,2)*n.y+2*h*(1-h)*o.y+Math.pow(h,2)*s.y,a>0&&(r=P({x:c,y:_},{x:l,y:d},t),u=r({r:parseInt(t.substring(1,3),16),g:parseInt(t.substring(3,5),16),b:parseInt(t.substring(5,7),16)}),j=t=>"#"+((1<<24)+(t.r<<16)+(t.g<<8)+t.b).toString(16).slice(1),W=["label","name"],Z={size:5,color:new U("#1d87c9")},G={color:new U("#ababab"),width:.3},H=()=>({getNodeStyle:t=>Object.assign(Object.assign({},Z),{label:X(t)}),getEdgeStyle:t=>Object.assign(Object.assign({},G),{label:X(t)})}),X=t=>{const e=t.getData();for(let t=0;t{}};function V(){for(var t,e=0,i=arguments.length,n={};e=0&&(e=t.slice(i+1),t=t.slice(0,i)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})),r=-1,a=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++r0)for(var i,n,s=new Array(i),o=0;oe?1:t>=e?0:NaN}dt.prototype={constructor:dt,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};var pt="http://www.w3.org/1999/xhtml";const mt={svg:"http://www.w3.org/2000/svg",xhtml:pt,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function vt(t){var e=t+="",i=e.indexOf(":");return i>=0&&"xmlns"!==(e=t.slice(0,i))&&(t=t.slice(i+1)),mt.hasOwnProperty(e)?{space:mt[e],local:t}:t}function yt(t){return function(){this.removeAttribute(t)}}function xt(t){return function(){this.removeAttributeNS(t.space,t.local)}}function bt(t,e){return function(){this.setAttribute(t,e)}}function St(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function wt(t,e){return function(){var i=e.apply(this,arguments);null==i?this.removeAttribute(t):this.setAttribute(t,i)}}function Tt(t,e){return function(){var i=e.apply(this,arguments);null==i?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,i)}}function Et(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function Pt(t){return function(){this.style.removeProperty(t)}}function At(t,e,i){return function(){this.style.setProperty(t,e,i)}}function Ct(t,e,i){return function(){var n=e.apply(this,arguments);null==n?this.style.removeProperty(t):this.style.setProperty(t,n,i)}}function Mt(t,e){return t.style.getPropertyValue(e)||Et(t).getComputedStyle(t,null).getPropertyValue(e)}function Nt(t){return function(){delete this[t]}}function Dt(t,e){return function(){this[t]=e}}function It(t,e){return function(){var i=e.apply(this,arguments);null==i?delete this[t]:this[t]=i}}function Lt(t){return t.trim().split(/^|\s+/)}function Rt(t){return t.classList||new Ot(t)}function Ot(t){this._node=t,this._names=Lt(t.getAttribute("class")||"")}function kt(t,e){for(var i=Rt(t),n=-1,s=e.length;++n=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var ae=[null];function he(t,e){this._groups=t,this._parents=e}function le(){return new he([[document.documentElement]],ae)}he.prototype=le.prototype={constructor:he,select:function(t){"function"!=typeof t&&(t=tt(t));for(var e=this._groups,i=e.length,n=new Array(i),s=0;s=x&&(x=y+1);!(v=p[x])&&++x=0;)(n=s[o])&&(r&&4^n.compareDocumentPosition(r)&&r.parentNode.insertBefore(n,r),r=n);return this},sort:function(t){function e(e,i){return e&&i?t(e.__data__,i.__data__):!e-!i}t||(t=gt);for(var i=this._groups,n=i.length,s=new Array(n),o=0;o1?this.each((null==e?Pt:"function"==typeof e?Ct:At)(t,e,i??"")):Mt(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?Nt:"function"==typeof e?It:Dt)(t,e)):this.node()[t]},classed:function(t,e){var i=Lt(t+"");if(arguments.length<2){for(var n=Rt(this.node()),s=-1,o=i.length;++s=0&&(e=t.slice(i+1),t=t.slice(0,i)),{type:t,name:e}})}(t+""),r=o.length;if(!(arguments.length<2)){for(a=e?ne:ie,n=0;n()=>t;function xe(t,{sourceEvent:e,subject:i,target:n,identifier:s,active:o,x:r,y:a,dx:h,dy:l,dispatch:d}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:i,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:r,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:h,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:d}})}function be(t){return!t.ctrlKey&&!t.button}function Se(){return this.parentNode}function we(t,e){return e??{x:t.x,y:t.y}}function Te(){return navigator.maxTouchPoints||"ontouchstart"in this}xe.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};const Ee=t=>+t;function Pe(t){return((t=Math.exp(t))+1/t)/2}const Ae=function t(e,i,n){function s(t,s){var o,r,a=t[0],h=t[1],l=t[2],d=s[0],u=s[1],c=s[2],_=d-a,f=u-h,g=_*_+f*f;if(g<1e-12)r=Math.log(c/l)/e,o=function(t){return[a+t*_,h+t*f,l*Math.exp(e*t*r)]};else{var p=Math.sqrt(g),m=(c*c-l*l+n*g)/(2*l*i*p),v=(c*c-l*l-n*g)/(2*c*i*p),y=Math.log(Math.sqrt(m*m+1)-m),x=Math.log(Math.sqrt(v*v+1)-v);r=(x-y)/e,o=function(t){var n=t*r,s=Pe(y),o=l/(i*p)*(s*function(t){return((t=Math.exp(2*t))-1)/(t+1)}(e*n+y)-function(t){return((t=Math.exp(t))-1/t)/2}(y));return[a+o*_,h+o*f,l*s/Pe(e*n+y)]}}return o.duration=1e3*r*e/Math.SQRT2,o}return s.rho=function(e){var i=Math.max(.001,+e),n=i*i;return t(i,n,n*n)},s}(Math.SQRT2,2,4);var Ce,Me,Ne=0,De=0,Ie=0,Le=0,Re=0,Oe=0,ke="object"==typeof performance&&performance.now?performance:Date,Be="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function ze(){return Re||(Be(Ue),Re=ke.now()+Oe)}function Ue(){Re=0}function Fe(){this._call=this._time=this._next=null}function je(t,e,i){var n=new Fe;return n.restart(t,e,i),n}function We(){Re=(Le=ke.now())+Oe,Ne=De=0;try{!function(){ze(),++Ne;for(var t,e=Ce;e;)(t=Re-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ne}()}finally{Ne=0,function(){for(var t,e,i=Ce,n=1/0;i;)i._call?(n>i._time&&(n=i._time),t=i,i=i._next):(e=i._next,i._next=null,i=t?t._next=e:Ce=e);Me=t,Ge(n)}(),Re=0}}function Ze(){var t=ke.now(),e=t-Le;e>1e3&&(Oe-=e,Le=t)}function Ge(t){Ne||(De&&(De=clearTimeout(De)),t-Re>24?(t<1/0&&(De=setTimeout(We,t-ke.now()-Oe)),Ie&&(Ie=clearInterval(Ie))):(Ie||(Le=ke.now(),Ie=setInterval(Ze,1e3)),Ne=1,Be(We)))}function He(t,e,i){var n=new Fe;return e=null==e?0:+e,n.restart(i=>{n.stop(),t(i+e)},e,i),n}Fe.prototype=je.prototype={constructor:Fe,restart:function(t,e,i){if("function"!=typeof t)throw new TypeError("callback is not a function");i=(null==i?ze():+i)+(null==e?0:+e),this._next||Me===this||(Me?Me._next=this:Ce=this,Me=this),this._call=t,this._time=i,Ge()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ge())}};var Xe=Q("start","end","cancel","interrupt"),qe=[];function Ve(t,e,i,n,s,o){var r=t.__transition;if(r){if(i in r)return}else t.__transition={};!function(t,e,i){var n,s=t.__transition;function o(h){var l,d,u,c;if(1!==i.state)return a();for(l in s)if((c=s[l]).name===i.name){if(3===c.state)return He(o);4===c.state?(c.state=6,c.timer.stop(),c.on.call("interrupt",t,t.__data__,c.index,c.group),delete s[l]):+l0)throw new Error("too late; already scheduled");return i}function $e(t,e){var i=Ke(t,e);if(i.state>3)throw new Error("too late; already running");return i}function Ke(t,e){var i=t.__transition;if(!i||!(i=i[e]))throw new Error("transition not found");return i}function Qe(t,e){var i,n,s,o=t.__transition,r=!0;if(o){for(s in e=null==e?null:e+"",o)(i=o[s]).name===e?(n=i.state>2&&i.state<5,i.state=6,i.timer.stop(),i.on.call(n?"interrupt":"cancel",t,t.__data__,i.index,i.group),delete o[s]):r=!1;r&&delete t.__transition}}function Je(t,e){return t=+t,e=+e,function(i){return t*(1-i)+e*i}}var ti,ei=180/Math.PI,ii={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ni(t,e,i,n,s,o){var r,a,h;return(r=Math.sqrt(t*t+e*e))&&(t/=r,e/=r),(h=t*i+e*n)&&(i-=t*h,n-=e*h),(a=Math.sqrt(i*i+n*n))&&(i/=a,n/=a,h/=a),t*n180?e+=360:e-t>180&&(t+=360),o.push({i:i.push(s(i)+"rotate(",null,n)-2,x:Je(t,e)})):e&&i.push(s(i)+"rotate("+e+n)}(o.rotate,r.rotate,a,h),function(t,e,i,o){t!==e?o.push({i:i.push(s(i)+"skewX(",null,n)-2,x:Je(t,e)}):e&&i.push(s(i)+"skewX("+e+n)}(o.skewX,r.skewX,a,h),function(t,e,i,n,o,r){if(t!==i||e!==n){var a=o.push(s(o)+"scale(",null,",",null,")");r.push({i:a-4,x:Je(t,i)},{i:a-2,x:Je(e,n)})}else 1===i&&1===n||o.push(s(o)+"scale("+i+","+n+")")}(o.scaleX,o.scaleY,r.scaleX,r.scaleY,a,h),o=r=null,function(t){for(var e,i=-1,n=h.length;++i>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===i?Ni(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===i?Ni(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=yi.exec(t))?new Ii(e[1],e[2],e[3],1):(e=xi.exec(t))?new Ii(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=bi.exec(t))?Ni(e[1],e[2],e[3],e[4]):(e=Si.exec(t))?Ni(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=wi.exec(t))?zi(e[1],e[2]/100,e[3]/100,1):(e=Ti.exec(t))?zi(e[1],e[2]/100,e[3]/100,e[4]):Ei.hasOwnProperty(t)?Mi(Ei[t]):"transparent"===t?new Ii(NaN,NaN,NaN,0):null}function Mi(t){return new Ii(t>>16&255,t>>8&255,255&t,1)}function Ni(t,e,i,n){return n<=0&&(t=e=i=NaN),new Ii(t,e,i,n)}function Di(t,e,i,n){return 1===arguments.length?((s=t)instanceof ci||(s=Ci(s)),s?new Ii((s=s.rgb()).r,s.g,s.b,s.opacity):new Ii):new Ii(t,e,i,n??1);var s}function Ii(t,e,i,n){this.r=+t,this.g=+e,this.b=+i,this.opacity=+n}function Li(){return`#${Bi(this.r)}${Bi(this.g)}${Bi(this.b)}`}function Ri(){const t=Oi(this.opacity);return`${1===t?"rgb(":"rgba("}${ki(this.r)}, ${ki(this.g)}, ${ki(this.b)}${1===t?")":`, ${t})`}`}function Oi(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ki(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Bi(t){return((t=ki(t))<16?"0":"")+t.toString(16)}function zi(t,e,i,n){return n<=0?t=e=i=NaN:i<=0||i>=1?t=e=NaN:e<=0&&(t=NaN),new Fi(t,e,i,n)}function Ui(t){if(t instanceof Fi)return new Fi(t.h,t.s,t.l,t.opacity);if(t instanceof ci||(t=Ci(t)),!t)return new Fi;if(t instanceof Fi)return t;var e=(t=t.rgb()).r/255,i=t.g/255,n=t.b/255,s=Math.min(e,i,n),o=Math.max(e,i,n),r=NaN,a=o-s,h=(o+s)/2;return a?(r=e===o?(i-n)/a+6*(i0&&h<1?0:r,new Fi(r,a,h,t.opacity)}function Fi(t,e,i,n){this.h=+t,this.s=+e,this.l=+i,this.opacity=+n}function ji(t){return(t=(t||0)%360)<0?t+360:t}function Wi(t){return Math.max(0,Math.min(1,t||0))}function Zi(t,e,i){return 255*(t<60?e+(i-e)*t/60:t<180?i:t<240?e+(i-e)*(240-t)/60:e)}function Gi(t,e,i,n,s){var o=t*t,r=o*t;return((1-3*t+3*o-r)*e+(4-6*o+3*r)*i+(1+3*t+3*o-3*r)*n+r*s)/6}di(ci,Ci,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Pi,formatHex:Pi,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return Ui(this).formatHsl()},formatRgb:Ai,toString:Ai}),di(Ii,Di,ui(ci,{brighter(t){return t=null==t?fi:Math.pow(fi,t),new Ii(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?_i:Math.pow(_i,t),new Ii(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Ii(ki(this.r),ki(this.g),ki(this.b),Oi(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Li,formatHex:Li,formatHex8:function(){return`#${Bi(this.r)}${Bi(this.g)}${Bi(this.b)}${Bi(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:Ri,toString:Ri})),di(Fi,function(t,e,i,n){return 1===arguments.length?Ui(t):new Fi(t,e,i,n??1)},ui(ci,{brighter(t){return t=null==t?fi:Math.pow(fi,t),new Fi(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?_i:Math.pow(_i,t),new Fi(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,i=this.l,n=i+(i<.5?i:1-i)*e,s=2*i-n;return new Ii(Zi(t>=240?t-240:t+120,s,n),Zi(t,s,n),Zi(t<120?t+240:t-120,s,n),this.opacity)},clamp(){return new Fi(ji(this.h),Wi(this.s),Wi(this.l),Oi(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=Oi(this.opacity);return`${1===t?"hsl(":"hsla("}${ji(this.h)}, ${100*Wi(this.s)}%, ${100*Wi(this.l)}%${1===t?")":`, ${t})`}`}}));const Hi=t=>()=>t;function Xi(t,e){var i=e-t;return i?function(t,e){return function(i){return t+i*e}}(t,i):Hi(isNaN(t)?e:t)}const qi=function t(e){var i=function(t){return 1===(t=+t)?Xi:function(e,i){return i-e?function(t,e,i){return t=Math.pow(t,i),e=Math.pow(e,i)-t,i=1/i,function(n){return Math.pow(t+n*e,i)}}(e,i,t):Hi(isNaN(e)?i:e)}}(e);function n(t,e){var n=i((t=Di(t)).r,(e=Di(e)).r),s=i(t.g,e.g),o=i(t.b,e.b),r=Xi(t.opacity,e.opacity);return function(e){return t.r=n(e),t.g=s(e),t.b=o(e),t.opacity=r(e),t+""}}return n.gamma=t,n}(1);function Vi(t){return function(e){var i,n,s=e.length,o=new Array(s),r=new Array(s),a=new Array(s);for(i=0;i=1?(i=1,e-1):Math.floor(i*e),s=t[n],o=t[n+1],r=n>0?t[n-1]:2*s-o,a=no&&(s=e.slice(o,s),a[r]?a[r]+=s:a[++r]=s),(i=i[0])===(n=n[0])?a[r]?a[r]+=n:a[++r]=n:(a[++r]=null,h.push({i:r,x:Je(i,n)})),o=$i.lastIndex;return o=0&&(t=t.slice(0,e)),!t||"start"===t})}(e)?Ye:$e;return function(){var r=o(this,t),a=r.on;a!==n&&(s=(n=a).copy()).on(e,i),r.on=s}}(i,t,e))},attr:function(t,e){var i=vt(t),n="transform"===i?ri:Qi;return this.attrTween(t,"function"==typeof e?(i.local?on:sn)(i,n,li(this,"attr."+t,e)):null==e?(i.local?tn:Ji)(i):(i.local?nn:en)(i,n,e))},attrTween:function(t,e){var i="attr."+t;if(arguments.length<2)return(i=this.tween(i))&&i._value;if(null==e)return this.tween(i,null);if("function"!=typeof e)throw new Error;var n=vt(t);return this.tween(i,(n.local?rn:an)(n,e))},style:function(t,e,i){var n="transform"==(t+="")?oi:Qi;return null==e?this.styleTween(t,function(t,e){var i,n,s;return function(){var o=Mt(this,t),r=(this.style.removeProperty(t),Mt(this,t));return o===r?null:o===i&&r===n?s:s=e(i=o,n=r)}}(t,n)).on("end.style."+t,_n(t)):"function"==typeof e?this.styleTween(t,function(t,e,i){var n,s,o;return function(){var r=Mt(this,t),a=i(this),h=a+"";return null==a&&(this.style.removeProperty(t),h=a=Mt(this,t)),r===h?null:r===n&&h===s?o:(s=h,o=e(n=r,a))}}(t,n,li(this,"style."+t,e))).each(function(t,e){var i,n,s,o,r="style."+e,a="end."+r;return function(){var h=$e(this,t),l=h.on,d=null==h.value[r]?o||(o=_n(e)):void 0;l===i&&s===d||(n=(i=l).copy()).on(a,s=d),h.on=n}}(this._id,t)):this.styleTween(t,function(t,e,i){var n,s,o=i+"";return function(){var r=Mt(this,t);return r===o?null:r===n?s:s=e(n=r,i)}}(t,n,e),i).on("end.style."+t,null)},styleTween:function(t,e,i){var n="style."+(t+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw new Error;return this.tween(n,function(t,e,i){var n,s;function o(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&function(t,e,i){return function(n){this.style.setProperty(t,e.call(this,n),i)}}(t,o,i)),n}return o._value=e,o}(t,e,i??""))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=e??""}}(li(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,function(t){var e,i;function n(){var n=t.apply(this,arguments);return n!==i&&(e=(i=n)&&function(t){return function(e){this.textContent=t.call(this,e)}}(n)),e}return n._value=t,n}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var i in this.__transition)if(+i!==t)return;e&&e.removeChild(this)}}(this._id))},tween:function(t,e){var i=this._id;if(t+="",arguments.length<2){for(var n,s=Ke(this.node(),i).tween,o=0,r=s.length;o()=>t;function bn(t,{sourceEvent:e,target:i,transform:n,dispatch:s}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:s}})}function Sn(t,e,i){this.k=t,this.x=e,this.y=i}Sn.prototype={constructor:Sn,scale:function(t){return 1===t?this:new Sn(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new Sn(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var wn=new Sn(1,0,0);function Tn(t){t.stopImmediatePropagation()}function En(t){t.preventDefault(),t.stopImmediatePropagation()}function Pn(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function An(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function Cn(){return this.__zoom||wn}function Mn(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Nn(){return navigator.maxTouchPoints||"ontouchstart"in this}function Dn(t,e,i){var n=t.invertX(e[0][0])-i[0][0],s=t.invertX(e[1][0])-i[1][0],o=t.invertY(e[0][1])-i[0][1],r=t.invertY(e[1][1])-i[1][1];return t.translate(s>n?(n+s)/2:Math.min(0,n)||Math.max(0,s),r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r))}Sn.prototype;const In=(t,e)=>!!t&&!!e&&t.x===e.x&&t.y===e.y;var Ln;function Rn(t,e,i){t.on(Ln.SIMULATION_START,()=>{e.emit(Ln.SIMULATION_START,void 0),i(!0)}),t.on(Ln.SIMULATION_PROGRESS,t=>{e.emit(Ln.SIMULATION_PROGRESS,t)}),t.on(Ln.SIMULATION_END,t=>{e.emit(Ln.SIMULATION_END,t),i(!1)}),t.on(Ln.SIMULATION_STEP,t=>{e.emit(Ln.SIMULATION_STEP,t)}),t.on(Ln.NODE_DRAG,t=>{e.emit(Ln.NODE_DRAG,t)}),t.on(Ln.SETTINGS_UPDATE,t=>{e.emit(Ln.SETTINGS_UPDATE,t)})}function On(t){return function(){return t}}function kn(t){return 1e-6*(t()-.5)}function Bn(t){return t.index}function zn(t,e){var i=t.get(e);if(!i)throw new Error("node not found: "+e);return i}!function(t){t.SIMULATION_START="simulation-start",t.SIMULATION_STEP="simulation-step",t.SIMULATION_PROGRESS="simulation-progress",t.SIMULATION_END="simulation-end",t.NODE_DRAG="node-drag",t.NODE_DRAG_END="node-drag-end",t.SETTINGS_UPDATE="settings-update"}(Ln||(Ln={}));const Un=4294967296;function Fn(t){return t.x}function jn(t){return t.y}var Wn=Math.PI*(3-Math.sqrt(5));function Zn(t,e,i,n){if(isNaN(e)||isNaN(i))return t;var s,o,r,a,h,l,d,u,c,_=t._root,f={data:n},g=t._x0,p=t._y0,m=t._x1,v=t._y1;if(!_)return t._root=f,t;for(;_.length;)if((l=e>=(o=(g+m)/2))?g=o:m=o,(d=i>=(r=(p+v)/2))?p=r:v=r,s=_,!(_=_[u=d<<1|l]))return s[u]=f,t;if(a=+t._x.call(null,_.data),h=+t._y.call(null,_.data),e===a&&i===h)return f.next=_,s?s[u]=f:t._root=f,t;do{s=s?s[u]=new Array(4):t._root=new Array(4),(l=e>=(o=(g+m)/2))?g=o:m=o,(d=i>=(r=(p+v)/2))?p=r:v=r}while((u=d<<1|l)==(c=(h>=r)<<1|a>=o));return s[c]=_,s[u]=f,t}function Gn(t,e,i,n,s){this.node=t,this.x0=e,this.y0=i,this.x1=n,this.y1=s}function Hn(t){return t[0]}function Xn(t){return t[1]}function qn(t,e,i){var n=new Vn(e??Hn,i??Xn,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function Vn(t,e,i,n,s,o){this._x=t,this._y=e,this._x0=i,this._y0=n,this._x1=s,this._y1=o,this._root=void 0}function Yn(t){for(var e={data:t.data},i=e;t=t.next;)i=i.next={data:t.data};return e}var $n=qn.prototype=Vn.prototype;function Kn(t){return t.x+t.vx}function Qn(t){return t.y+t.vy}$n.copy=function(){var t,e,i=new Vn(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root;if(!n)return i;if(!n.length)return i._root=Yn(n),i;for(t=[{source:n,target:i._root=new Array(4)}];n=t.pop();)for(var s=0;s<4;++s)(e=n.source[s])&&(e.length?t.push({source:e,target:n.target[s]=new Array(4)}):n.target[s]=Yn(e));return i},$n.add=function(t){const e=+this._x.call(null,t),i=+this._y.call(null,t);return Zn(this.cover(e,i),e,i,t)},$n.addAll=function(t){var e,i,n,s,o=t.length,r=new Array(o),a=new Array(o),h=1/0,l=1/0,d=-1/0,u=-1/0;for(i=0;id&&(d=n),su&&(u=s));if(h>d||l>u)return this;for(this.cover(h,l).cover(d,u),i=0;it||t>=s||n>e||e>=o;)switch(a=(ec||(o=h.y0)>_||(r=h.x1)=m)<<1|t>=p)&&(h=f[f.length-1],f[f.length-1]=f[f.length-1-l],f[f.length-1-l]=h)}else{var v=t-+this._x.call(null,g.data),y=e-+this._y.call(null,g.data),x=v*v+y*y;if(x=(a=(f+p)/2))?f=a:p=a,(d=r>=(h=(g+m)/2))?g=h:m=h,e=_,!(_=_[u=d<<1|l]))return this;if(!_.length)break;(e[u+1&3]||e[u+2&3]||e[u+3&3])&&(i=e,c=u)}for(;_.data!==t;)if(n=_,!(_=_.next))return this;return(s=_.next)&&delete _.next,n?(s?n.next=s:delete n.next,this):e?(s?e[u]=s:delete e[u],(_=e[0]||e[1]||e[2]||e[3])&&_===(e[3]||e[2]||e[1]||e[0])&&!_.length&&(i?i[c]=_:this._root=_),this):(this._root=s,this)},$n.removeAll=function(t){for(var e=0,i=t.length;e100*(t>0?t:1),es={useGPU:!1,isSimulatingOnDataUpdate:!0,isSimulatingOnSettingsUpdate:!0,isSimulatingOnUnstick:!0,isPhysicsEnabled:!1,alpha:{alpha:1,alphaMin:.05,alphaDecay:.028,alphaTarget:0},centering:{x:0,y:0,strength:1},collision:{radius:15,strength:1,iterations:1},links:{distance:50,strength:1,iterations:1},manyBody:{strength:-100,theta:.9,distanceMin:1,distanceMax:ts(50)},positioning:{forceX:{x:0,strength:.1},forceY:{y:0,strength:.1}},anchorX:"center",anchorY:"center"},is={rowGap:50,colGap:50},ns={nodeGap:50,levelGap:50,treeGap:100,orientation:"vertical",reversed:!1};class ss extends t{constructor(){super(...arguments),this._nodes=[],this._edges=[],this._nodeIndexByNodeId={},this._cancelSimulation=!1,this._schedulerPort=null}terminate(){var t;this._cancelSimulation=!0,null===(t=this._schedulerPort)||void 0===t||t.close(),this._schedulerPort=null,this.removeAllListeners()}_scheduleNext(t){if("undefined"!=typeof MessageChannel){const e=new MessageChannel;this._schedulerPort=e.port2,e.port1.onmessage=()=>{this._schedulerPort=null,t()},e.port2.postMessage(null)}else setTimeout(t,0)}_rebuildNodeIndex(){this._nodeIndexByNodeId={};for(let t=0;t0&&this.activateSimulation())}setupData(t){this.clearData(),this._initializeNewData(t),this._settings.isSimulatingOnDataUpdate&&(this._updateSimulationData(),this._runSimulation())}mergeData(t){this._initializeNewData(t),this._settings.isPhysicsEnabled||this._pinNodes(),this._settings.isSimulatingOnDataUpdate&&(this._updateSimulationData(),this.activateSimulation())}updateData(t){const e=new Set(t.nodes.map(t=>t.id)),i=this._nodes.filter(t=>e.has(t.id)),n=t.nodes.filter(t=>void 0===this._nodeIndexByNodeId[t.id]);this._nodes=[...i,...n],this._rebuildNodeIndex(),this._edges=t.edges,this._settings.isSimulatingOnSettingsUpdate&&(this._updateSimulationData(),this.activateSimulation())}deleteData(t){if(t.nodeIds){const e=new Set(t.nodeIds);this._nodes=this._nodes.filter(t=>!e.has(t.id))}if(t.edgeIds){const e=new Set(t.edgeIds);this._edges=this._edges.filter(t=>!e.has(t.id))}this._rebuildNodeIndex(),this._settings.isSimulatingOnDataUpdate&&(this._updateSimulationData(),this.activateSimulation())}patchData(t){if(t.nodes){const e={};for(let t=0;t0&&this.activateSimulation()}terminate(){var t;super.terminate(),null===(t=this._simulation)||void 0===t||t.stop()}_resetSimulation(){this._simulation&&(this._simulation.stop(),this._simulation.on("tick",null).on("end",null)),this._linkForce=function(t){var e,i,n,s,o,r,a=Bn,h=function(t){return 1/Math.min(s[t.source.index],s[t.target.index])},l=On(30),d=1;function u(n){for(var s=0,a=t.length;s[a(t,e,n),t]));for(r=0,s=new Array(l);rt.id),this._simulation=function(t){var e,i=1,n=.001,s=1-Math.pow(n,1/300),o=0,r=.6,a=new Map,h=je(u),l=Q("tick","end"),d=function(){let t=1;return()=>(t=(1664525*t+1013904223)%Un)/Un}();function u(){c(),l.call("tick",e),i1?(null==i?a.delete(t):a.set(t,f(i)),e):a.get(t)},find:function(e,i,n){var s,o,r,a,h,l=0,d=t.length;for(null==n?n=1/0:n*=n,l=0;l1?(l.on(t,i),e):l.on(t)}}}(this._nodes).force("link",this._linkForce).stop(),this._applySettingsToSimulation(this._settings),this._simulation.on("tick",()=>{this.emit(Ln.SIMULATION_STEP,{nodes:this._nodes,edges:this._edges})}),this._simulation.on("end",()=>{this._isDragging=!1,this._isStabilizing=!1,this.emit(Ln.SIMULATION_END,{nodes:this._nodes,edges:this._edges}),this._settings.isPhysicsEnabled||this._pinNodes()})}_runSimulation(t){if(this._isStabilizing||this._cancelSimulation)return;(this._settings.isPhysicsEnabled||(null==t?void 0:t.isUpdatingSettings))&&this._unpinNodes(),this.emit(Ln.SIMULATION_START,void 0),this._isStabilizing=!0,this._simulation.alpha(this._settings.alpha.alpha).alphaTarget(this._settings.alpha.alphaTarget).stop();const e=Math.min(500,Math.ceil(Math.log(this._settings.alpha.alphaMin)/Math.log(1-this._settings.alpha.alphaDecay)));let i=-1,n=0;const s=()=>{if(this._cancelSimulation)return this._isStabilizing=!1,void(this._cancelSimulation=!1);const t=Math.min(n+100,e);for(;ni&&(i=t,this.emit(Ln.SIMULATION_PROGRESS,{nodes:this._nodes,edges:this._edges,progress:t/100}))}nl+f||od+f||rh.index){var g=l-a.x-a.vx,p=d-a.y-a.vy,m=g*g+p*p;mt.r&&(t.r=t[e].r)}function h(){if(e){var n,s,o=e.length;for(i=new Array(o),n=0;n=a)){(t.data!==e||t.next)&&(0===u&&(f+=(u=kn(i))*u),0===c&&(f+=(c=kn(i))*c),f=s)continue;h<1&&(h=1);const u=-t*e/h;o.vx+=r*u,o.vy+=a*u}}}return o.initialize=t=>{n=t},o}(t.manyBody.strength,t.manyBody.distanceMax,()=>this._edges)):this._simulation.force("edgeMidpointRepulsion",null)}if(null===t.manyBody&&(this._simulation.force("charge",null),this._simulation.force("edgeMidpointRepulsion",null)),null===(e=t.positioning)||void 0===e?void 0:e.forceX){const e=function(t){var e,i,n,s=On(.1);function o(t){for(var s,o=0,r=e.length;o{const n=t.createShader(i===rs.VERTEX?t.VERTEX_SHADER:t.FRAGMENT_SHADER);if(!n)throw new o("Failed to create shader.");if(t.shaderSource(n,e),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS)){const e=t.getShaderInfoLog(n);throw t.deleteShader(n),new o(`Failed to compile shader: ${e}`)}return n};class hs extends ss{constructor(t){super(),this._isStabilizing=!1,this._isDragging=!1,this._dragLoopRunning=!1,this._pendingRestart=!1,this._simulationGeneration=0,this._currentAlpha=0,this._currentStep=0,this._totalSteps=0,this._dragAlpha=0,this._dragNeedsReheat=!1,this._dirtyNodes=new Set,this._forceProgram=null,this._quadBuffer=null,this._quadVAO=null,this._stateTexA=null,this._stateTexB=null,this._fixedTex=null,this._fboA=null,this._fboB=null,this._texWidth=0,this._treeDataTexture=null,this._treeChildrenTexture=null,this._treeGeometryTexture=null,this._adjOffsetsTexture=null,this._adjEdgesTexture=null,this._cachedAdjacency=null,this._treeTexWidth=1,this._treeNodeCount=0,this._pingPong=!0,this._uniforms={},this.type="force",this._settings=Object.assign(Object.assign({},es),t);const e=document.createElement("canvas").getContext("webgl2");if(!e)throw new o("Failed to create WebGL2 context for GPU force layout engine.");this._gl=e,this._initGPU(),this.clearData()}setSettings(t){const e=t;this._initialSettings||(this._initialSettings=Object.assign(p(es),e));const i=p(this._settings);Object.assign(this._settings,e),m(this._settings,i)||(this.emit(Ln.SETTINGS_UPDATE,{settings:{type:"force",options:this._settings}}),i.isPhysicsEnabled&&!e.isPhysicsEnabled?this.stopSimulation():this._settings.isSimulatingOnSettingsUpdate&&this._nodes.length>0&&this.activateSimulation())}setupData(t){this.clearData(),this._initializeNewData(t),this._settings.isSimulatingOnDataUpdate&&this._runSimulation()}mergeData(t){this._initializeNewData(t),this._settings.isPhysicsEnabled||this._pinNodes(),this._settings.isSimulatingOnDataUpdate&&this.activateSimulation()}updateData(t){const e=new Set(t.nodes.map(t=>t.id)),i=this._nodes.filter(t=>e.has(t.id)),n=t.nodes.filter(t=>void 0===this._nodeIndexByNodeId[t.id]);this._nodes=[...i,...n],this._rebuildNodeIndex(),this._edges=t.edges,this._cachedAdjacency=null,this._settings.isSimulatingOnSettingsUpdate&&this.activateSimulation()}deleteData(t){if(t.nodeIds){const e=new Set(t.nodeIds);this._nodes=this._nodes.filter(t=>!e.has(t.id))}if(t.edgeIds){const e=new Set(t.edgeIds);this._edges=this._edges.filter(t=>!e.has(t.id))}this._rebuildNodeIndex(),this._cachedAdjacency=null,this._settings.isSimulatingOnDataUpdate&&this.activateSimulation()}patchData(t){if(t.nodes){const e={};for(let t=0;t0&&this.activateSimulation()}terminate(){var t;super.terminate();const e=this._gl;e&&(e.deleteBuffer(this._quadBuffer),e.deleteVertexArray(this._quadVAO),e.deleteProgram(this._forceProgram),e.deleteTexture(this._stateTexA),e.deleteTexture(this._stateTexB),e.deleteTexture(this._fixedTex),e.deleteTexture(this._treeDataTexture),e.deleteTexture(this._treeChildrenTexture),e.deleteTexture(this._treeGeometryTexture),e.deleteTexture(this._adjOffsetsTexture),e.deleteTexture(this._adjEdgesTexture),e.deleteFramebuffer(this._fboA),e.deleteFramebuffer(this._fboB),null===(t=e.getExtension("WEBGL_lose_context"))||void 0===t||t.loseContext())}reheat(){const t=this._settings.alpha;this._currentAlpha=t.alpha,this._totalSteps=Math.min(500,Math.ceil(Math.log(t.alphaMin)/Math.log(1-t.alphaDecay))),this._currentStep=0,this._isStabilizing||(this._ensurePositions(),this._uploadDataToGPU(),this._cachedAdjacency||this._buildAndUploadAdjacency(),this._startSimulationLoop())}_runSimulation(){this._isStabilizing||this._cancelSimulation||(this._ensurePositions(),this._uploadDataToGPU(),this._buildAndUploadAdjacency(),this._startSimulationLoop())}_startDragLoop(){if(this._dragLoopRunning)return;this._dragLoopRunning=!0;const t=this._settings.alpha.alphaDecay,e=this._settings.alpha.alphaMin;this._dragAlpha=.3,this._dragNeedsReheat=!1;const i=()=>{this._isDragging?(this._dragNeedsReheat&&(this._dragAlpha=.3,this._dragNeedsReheat=!1),this._dragAlpha+=(0-this._dragAlpha)*t,this._dragAlpha{if(t!==this._simulationGeneration)return;if(this._cancelSimulation)return this._isStabilizing=!1,this._cancelSimulation=!1,void this.emit(Ln.SIMULATION_END,{nodes:this._nodes,edges:this._edges});if(this._readbackFromGPU(),this._pendingRestart)return this._isStabilizing=!1,this._pendingRestart=!1,this._ensurePositions(),this._uploadDataToGPU(),this._cachedAdjacency||this._buildAndUploadAdjacency(),void this._startSimulationLoop();this._flushDirtyNodes(),this._buildAndUploadQuadTree();const r=Math.min(this._currentStep+1,this._totalSteps);for(;this._currentSteps&&(s=a,this.emit(Ln.SIMULATION_PROGRESS,{nodes:this._nodes,edges:this._edges,progress:a/100})),this._currentStep0&&(s=s.concat(t))}const o=function(t,e){var i,n;const s=t.length;if(0===s)return{treeData:new Float32Array(0),treeChildren:new Float32Array(0),treeGeometry:new Float32Array(0),nodeCount:0,texWidth:1};let o=1/0,r=1/0,a=-1/0,h=-1/0;for(let e=0;ea&&(a=i),n>h&&(h=n)}let l=Math.max(a-o,h-r);l<1e-6&&(l=1),l*=1.01;const d=.5*l,u=.5*(o+a)-d,c=.5*(r+h)-d,_=[];function f(t){const e=_.length;return _.push({cx:0,cy:0,charge:0,size:t,bodyIndex:-1,children:[null,null,null,null]}),e}const g=f(l),p=[u],m=[c];function v(t,e,i,n,s){return 2*(e>=n+.5*s?1:0)+(t>=i+.5*s?1:0)}function y(t,e,i,n){const s=.5*n;return{cx0:1&t?e+s:e,cy0:2&t?i+s:i,csz:s}}function x(t,i,n){let s=g,o=u,r=c,a=l;for(let h=0;h<50;h++){const h=_[s];if(-1===h.bodyIndex&&null===h.children[0]&&null===h.children[1]&&null===h.children[2]&&null===h.children[3])return h.bodyIndex=t,h.cx=i,h.cy=n,void(h.charge=e);if(h.bodyIndex>=0){const t=h.bodyIndex,i=h.cx,n=h.cy;h.bodyIndex=-1;const s=v(i,n,o,r,a),{cx0:l,cy0:d,csz:u}=y(s,o,r,a),c=f(u);p[c]=l,m[c]=d,h.children[s]=c,_[c].bodyIndex=t,_[c].cx=i,_[c].cy=n,_[c].charge=e}const l=v(i,n,o,r,a);if(null===h.children[l]){const{cx0:s,cy0:d,csz:u}=y(l,o,r,a),c=f(u);return p[c]=s,m[c]=d,h.children[l]=c,_[c].bodyIndex=t,_[c].cx=i,_[c].cy=n,void(_[c].charge=e)}const{cx0:d,cy0:u,csz:c}=y(l,o,r,a);s=h.children[l],o=d,r=u,a=c}}for(let e=0;e=0)return;let n=0,s=0,o=0,r=0;for(let e=0;e<4;e++){const a=i.children[e];if(null===a)continue;t(a);const h=_[a],l=Math.abs(h.charge);n+=h.charge,s+=h.cx*l,o+=h.cy*l,r+=l}r>0&&(i.cx=s/r,i.cy=o/r),i.charge=n}(g);const b=_.length,S=Math.ceil(Math.sqrt(b)),w=S*S,T=new Float32Array(4*w),E=new Float32Array(4*w),P=new Float32Array(4*w);for(let t=0;t=0?T[s+3]=-(e.bodyIndex+1):T[s+3]=e.size,E[s]=null!==e.children[0]?e.children[0]:-1,E[s+1]=null!==e.children[1]?e.children[1]:-1,E[s+2]=null!==e.children[2]?e.children[2]:-1,E[s+3]=null!==e.children[3]?e.children[3]:-1,P[s]=null!==(i=p[t])&&void 0!==i?i:0,P[s+1]=null!==(n=m[t])&&void 0!==n?n:0,P[s+2]=e.size,P[s+3]=0}for(let t=b;t= uNodeCount) {\n fragColor = vec4(0.0);\n return;\n }\n\n vec4 fixedData = texelFetch(uFixed, fc, 0);\n if (fixedData.x > 0.5) {\n fragColor = vec4(fixedData.yz, 0.0, 0.0);\n return;\n }\n\n vec4 state = texelFetch(uState, fc, 0);\n vec2 pos = state.xy;\n vec2 vel = state.zw;\n\n if (uHasManyBody > 0.5 && uTreeNodeCount > 0) {\n int stack[128];\n int top = 0;\n stack[top++] = 0;\n\n while (top > 0) {\n int idx = stack[--top];\n vec4 data = texelFetch(uTreeData, texCoord(idx, uTreeTexWidth), 0);\n float w = data.w;\n\n if (w < -0.5) {\n int bodyIdx = int(-w - 0.5);\n if (bodyIdx != nodeId) {\n vec2 delta = data.xy - pos;\n float distSq = dot(delta, delta);\n\n if (distSq < 1e-8) {\n delta = vec2(float(nodeId) * 1e-4 - float(bodyIdx) * 1e-4 + 1e-4, 1e-4);\n distSq = dot(delta, delta);\n }\n\n if (distSq < uDistanceMax2) {\n float l = distSq;\n if (l < uDistanceMin2) l = sqrt(uDistanceMin2 * l);\n vel += delta * (data.z * uAlpha / max(l, 1e-6));\n }\n }\n } else {\n vec2 delta = data.xy - pos;\n float distSq = dot(delta, delta);\n\n if (distSq > 0.0 && w * w / distSq < uTheta2) {\n if (distSq < uDistanceMax2) {\n float l = distSq;\n if (l < uDistanceMin2) l = sqrt(uDistanceMin2 * l);\n vel += delta * (data.z * uAlpha / max(l, 1e-6));\n }\n } else {\n vec4 ch = texelFetch(uTreeChildren, texCoord(idx, uTreeTexWidth), 0);\n if (ch.w >= 0.0 && top < 64) stack[top++] = int(ch.w + 0.5);\n if (ch.z >= 0.0 && top < 64) stack[top++] = int(ch.z + 0.5);\n if (ch.y >= 0.0 && top < 64) stack[top++] = int(ch.y + 0.5);\n if (ch.x >= 0.0 && top < 64) stack[top++] = int(ch.x + 0.5);\n }\n }\n }\n }\n\n if (uHasCollision > 0.5 && uCollisionRadius > 0.0 && uTreeNodeCount > 0) {\n float collisionDiam = uCollisionRadius * 2.0;\n vec2 predictedPos = state.xy + state.zw;\n int stack[64];\n int top = 0;\n stack[top++] = 0;\n\n while (top > 0) {\n int idx = stack[--top];\n vec4 data = texelFetch(uTreeData, texCoord(idx, uTreeTexWidth), 0);\n float w = data.w;\n\n if (w < -0.5) {\n int bodyIdx = int(-w - 0.5);\n if (bodyIdx != nodeId && bodyIdx < uNodeCount) {\n vec2 delta = data.xy - predictedPos;\n float dist = length(delta);\n\n if (dist < collisionDiam && dist > 0.0) {\n float push = (collisionDiam - dist) * uCollisionStrength;\n vel -= (delta / dist) * push * 0.5;\n }\n }\n } else {\n vec4 geo = texelFetch(uTreeGeometry, texCoord(idx, uTreeTexWidth), 0);\n float cellSize = geo.z;\n vec2 nearest = clamp(predictedPos, geo.xy, geo.xy + cellSize);\n float distToCell = length(nearest - predictedPos);\n\n if (distToCell < collisionDiam) {\n vec4 ch = texelFetch(uTreeChildren, texCoord(idx, uTreeTexWidth), 0);\n if (ch.w >= 0.0 && top < 64) stack[top++] = int(ch.w + 0.5);\n if (ch.z >= 0.0 && top < 64) stack[top++] = int(ch.z + 0.5);\n if (ch.y >= 0.0 && top < 64) stack[top++] = int(ch.y + 0.5);\n if (ch.x >= 0.0 && top < 64) stack[top++] = int(ch.x + 0.5);\n }\n }\n }\n }\n\n if (uHasLinks > 0.5) {\n vec4 offData = texelFetch(uAdjOffsets, texCoord(nodeId, uAdjOffsetsTexWidth), 0);\n int start = int(offData.x + 0.5);\n int count = int(offData.y + 0.5);\n\n for (int e = 0; e < count; e++) {\n vec4 edgeData = texelFetch(uAdjEdges, texCoord(start + e, uAdjEdgesTexWidth), 0);\n int targetId = int(edgeData.x + 0.5);\n float restDist = edgeData.y;\n float strength = edgeData.z;\n float dirBias = edgeData.w;\n\n vec4 targetState = texelFetch(uState, texCoord(targetId, uTexWidth), 0);\n vec2 delta = (targetState.xy + targetState.zw) - (state.xy + state.zw);\n float d = length(delta);\n\n if (d < 1e-6) {\n delta = vec2(1e-3, 1e-3);\n d = length(delta);\n }\n\n float scale = (d - restDist) / d * uAlpha * strength;\n vel += delta * scale * dirBias;\n }\n }\n\n if (uHasCentering > 0.5) {\n vel += (uCenter - pos) * uCenterStrength * uAlpha;\n }\n\n if (uHasPositioning > 0.5) {\n vel.x += (uForceXTarget - pos.x) * uForceXStrength * uAlpha;\n vel.y += (uForceYTarget - pos.y) * uForceYStrength * uAlpha;\n }\n\n vel *= uDamping;\n pos += vel;\n\n fragColor = vec4(pos, vel);\n}\n",rs.FRAGMENT),n=t.createProgram();if(!n)throw new o("Failed to create program.");if(this._forceProgram=n,t.attachShader(n,e),t.attachShader(n,i),t.linkProgram(n),!t.getProgramParameter(n,t.LINK_STATUS)){const e=t.getProgramInfoLog(n);throw new o(`Failed to link force program: ${e}`)}this._cacheUniformLocations(n),this._quadBuffer=t.createBuffer();const s=new Float32Array([-1,-1,1,-1,-1,1,1,1]);t.bindBuffer(t.ARRAY_BUFFER,this._quadBuffer),t.bufferData(t.ARRAY_BUFFER,s,t.STATIC_DRAW),this._quadVAO=t.createVertexArray(),t.bindVertexArray(this._quadVAO);const r=t.getAttribLocation(n,"aPosition");t.enableVertexAttribArray(r),t.vertexAttribPointer(r,2,t.FLOAT,!1,0,0),t.bindVertexArray(null),this._stateTexA=t.createTexture(),this._stateTexB=t.createTexture(),this._fixedTex=t.createTexture(),this._treeDataTexture=t.createTexture(),this._treeChildrenTexture=t.createTexture(),this._treeGeometryTexture=t.createTexture(),this._adjOffsetsTexture=t.createTexture(),this._adjEdgesTexture=t.createTexture(),this._fboA=t.createFramebuffer(),this._fboB=t.createFramebuffer()}_cacheUniformLocations(t){const e=this._gl,i=["uState","uFixed","uTreeData","uTreeChildren","uTreeGeometry","uAdjOffsets","uAdjEdges","uNodeCount","uTexWidth","uAlpha","uDamping","uManyBodyStrength","uTheta2","uDistanceMin2","uDistanceMax2","uTreeNodeCount","uTreeTexWidth","uAdjOffsetsTexWidth","uAdjEdgesTexWidth","uCenter","uCenterStrength","uCollisionRadius","uCollisionStrength","uForceXTarget","uForceXStrength","uForceYTarget","uForceYStrength","uHasManyBody","uHasLinks","uHasCentering","uHasCollision","uHasPositioning"];for(const n of i)this._uniforms[n]=e.getUniformLocation(t,n)}_uploadDataToGPU(){var t,e,i,n,s,o,r,a;const h=this._gl,l=this._nodes.length;this._texWidth=Math.max(1,Math.ceil(Math.sqrt(l)));const d=this._texWidth*this._texWidth,u=new Float32Array(4*d),c=new Float32Array(4*d);for(let h=0;h0?t.distanceMax:ts(null!==(i=null===(e=this._settings.links)||void 0===e?void 0:e.distance)&&void 0!==i?i:50);c.uniform1f(g.uDistanceMax2,s*s),c.uniform1i(g.uTreeNodeCount,this._treeNodeCount),c.uniform1i(g.uTreeTexWidth,this._treeTexWidth)}const m=null!==this._cachedAdjacency&&this._edges.length>0;c.uniform1f(g.uHasLinks,m?1:0),m&&(c.uniform1i(g.uAdjOffsetsTexWidth,this._cachedAdjacency.offsetsTexWidth),c.uniform1i(g.uAdjEdgesTexWidth,this._cachedAdjacency.edgesTexWidth)),c.uniform1f(g.uHasCentering,0);const v=null!==this._settings.collision&&void 0!==this._settings.collision;c.uniform1f(g.uHasCollision,v?1:0),v&&(c.uniform1f(g.uCollisionRadius,this._settings.collision.radius),c.uniform1f(g.uCollisionStrength,this._settings.collision.strength));const y=null!==this._settings.positioning&&void 0!==this._settings.positioning;if(c.uniform1f(g.uHasPositioning,y?1:0),y){const t=this._settings.positioning;c.uniform1f(g.uForceXTarget,null!==(s=null===(n=t.forceX)||void 0===n?void 0:n.x)&&void 0!==s?s:0),c.uniform1f(g.uForceXStrength,null!==(a=null===(r=t.forceX)||void 0===r?void 0:r.strength)&&void 0!==a?a:0),c.uniform1f(g.uForceYTarget,null!==(l=null===(h=t.forceY)||void 0===h?void 0:h.y)&&void 0!==l?l:0),c.uniform1f(g.uForceYStrength,null!==(u=null===(d=t.forceY)||void 0===d?void 0:d.strength)&&void 0!==u?u:0)}const x=this._pingPong?this._stateTexA:this._stateTexB,b=this._pingPong?this._fboB:this._fboA;c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,x),c.uniform1i(g.uState,0),c.activeTexture(c.TEXTURE1),c.bindTexture(c.TEXTURE_2D,this._fixedTex),c.uniform1i(g.uFixed,1),c.activeTexture(c.TEXTURE2),c.bindTexture(c.TEXTURE_2D,this._treeDataTexture),c.uniform1i(g.uTreeData,2),c.activeTexture(c.TEXTURE3),c.bindTexture(c.TEXTURE_2D,this._treeChildrenTexture),c.uniform1i(g.uTreeChildren,3),c.activeTexture(c.TEXTURE4),c.bindTexture(c.TEXTURE_2D,this._adjOffsetsTexture),c.uniform1i(g.uAdjOffsets,4),c.activeTexture(c.TEXTURE5),c.bindTexture(c.TEXTURE_2D,this._adjEdgesTexture),c.uniform1i(g.uAdjEdges,5),c.activeTexture(c.TEXTURE6),c.bindTexture(c.TEXTURE_2D,this._treeGeometryTexture),c.uniform1i(g.uTreeGeometry,6),c.bindFramebuffer(c.FRAMEBUFFER,b),c.viewport(0,0,this._texWidth,this._texWidth),c.bindVertexArray(this._quadVAO),c.drawArrays(c.TRIANGLE_STRIP,0,4),c.bindVertexArray(null),c.bindFramebuffer(c.FRAMEBUFFER,null),this._pingPong=!this._pingPong}_readbackFromGPU(){const t=this._gl,e=this._nodes.length;if(0===e)return;const i=this._pingPong?this._fboA:this._fboB,n=this._texWidth*this._texWidth,s=new Float32Array(4*n);t.bindFramebuffer(t.FRAMEBUFFER,i),t.readPixels(0,0,this._texWidth,this._texWidth,t.RGBA,t.FLOAT,s),t.bindFramebuffer(t.FRAMEBUFFER,null);for(let t=0;tt.id)),i=this._nodes.filter(t=>e.has(t.id)),n=t.nodes.filter(t=>void 0===this._nodeIndexByNodeId[t.id]);this._nodes=[...i,...n],this._edges=t.edges,this._rebuildNodeIndex(),this._calculateAndEmit()}deleteData(t){if(t.nodeIds){const e=new Set(t.nodeIds);this._nodes=this._nodes.filter(t=>!e.has(t.id))}if(t.edgeIds){const e=new Set(t.edgeIds);this._edges=this._edges.filter(t=>!e.has(t.id))}this._rebuildNodeIndex(),this._calculateAndEmit()}patchData(t){if(t.nodes)for(let e=0;e0&&this._calculateAndEmit()}terminate(){this._pendingRecalculation=!1,super.terminate()}_calculateAndEmit(){0===this._nodes.length||this._cancelSimulation||(this._isCalculating?this._pendingRecalculation=!0:(this._isCalculating=!0,this.emit(Ln.SIMULATION_START,void 0),this.calculatePositions(this._nodes,this._edges,t=>{this.emit(Ln.SIMULATION_PROGRESS,{nodes:this._nodes,edges:this._edges,progress:t})},()=>this._cancelSimulation,()=>{this._isCalculating=!1,this._cancelSimulation||this.emit(Ln.SIMULATION_END,{nodes:this._nodes,edges:this._edges}),this._cancelSimulation=!1,this._pendingRecalculation&&(this._pendingRecalculation=!1,this._calculateAndEmit())})))}_emitProgress(t,e,i,n){const s=Math.round(100*t/e);return s>i?(n(s/100),s):i}}class ds extends ls{constructor(t){super(),this.type="circular",this._config=Object.assign(Object.assign({},Jn),t)}calculatePositions(t,e,i,n,s){const o=2*Math.PI/t.length;let r=-1,a=0;const h=()=>{if(n())return void s();const e=Math.min(a+5e3,t.length);for(;a{if(n())return void s();const e=Math.min(h+5e3,t.length);for(;h{if(n()||c>=a.length)return!n()&&this._config.reversed&&this._applyReversal(t,h,l),void s();const e=this._assignLevels(a[c],o,r),f=Math.max(...Array.from(e.values()).map(t=>t.length));e.size*this._config.levelGap>l&&(l=e.size*this._config.levelGap);let g=0===c?0:this._config.treeGap+h;c>0&&(g+=(f-1)*this._config.nodeGap/2);for(let i=0;ih&&(h=a),void 0!==r&&(t[r].x="horizontal"===this._config.orientation?n:a,t[r].y="horizontal"===this._config.orientation?a:n),d++}}c++,c0;){const t=h.pop();if(void 0===t)continue;a.push(t);const s=null!==(i=e.get(t))&&void 0!==i?i:[];for(let t=0;t{var e;return 0===(null!==(e=i.get(t))&&void 0!==e?e:0)});void 0===a&&(a=t.reduce((t,e)=>{var n,s;return(null!==(n=i.get(e))&&void 0!==n?n:0)<(null!==(s=i.get(t))&&void 0!==s?s:0)?e:t}));const h=[[a,0]];for(const[t,i]of h){if(r.has(t))continue;r.add(t),o.has(i)?null===(n=o.get(i))||void 0===n||n.push(t):o.set(i,[t]);const a=null!==(s=e.get(t))&&void 0!==s?s:[];for(let t=0;t{this._isSimulationRunning=t})}}var gs,ps;!function(t){t.SetupData="Set Data",t.MergeData="Add Data",t.UpdateData="Update Data",t.DeleteData="Delete Data",t.PatchData="Patch Data",t.ClearData="Clear Data",t.ActivateSimulation="Activate Simulation",t.UpdateSimulation="Update Simulation",t.StopSimulation="Stop Simulation",t.StartDragNode="Start Drag Node",t.DragNode="Drag Node",t.EndDragNode="End Drag Node",t.FixNodes="Fix Nodes",t.ReleaseNodes="Release Nodes",t.SetSettings="Set Settings"}(gs||(gs={})),function(t){t.READY="ready",t.SIMULATION_START="simulation-start",t.SIMULATION_STEP="simulation-step",t.SIMULATION_PROGRESS="simulation-progress",t.SIMULATION_END="simulation-end",t.SIMULATION_TICK="simulation-tick",t.NODE_DRAG="node-drag",t.NODE_DRAG_END="node-drag-end",t.SETTINGS_UPDATE="settings-update"}(ps||(ps={}));class ms extends t{constructor(t){let e;super(),this._isSimulationRunning=!1,this._fallback=null,this._ready=!1,this._pending=[],this._hasWarned=!1,this._handleWorkerMessage=({data:t})=>{switch(t.type){case ps.READY:this._markReady();break;case ps.SIMULATION_START:this.emit(Ln.SIMULATION_START,void 0),this._isSimulationRunning=!0;break;case ps.SIMULATION_PROGRESS:this.emit(Ln.SIMULATION_PROGRESS,t.data);break;case ps.SIMULATION_END:this.emit(Ln.SIMULATION_END,t.data),this._isSimulationRunning=!1;break;case ps.SIMULATION_STEP:this.emit(Ln.SIMULATION_STEP,t.data);break;case ps.NODE_DRAG:this.emit(Ln.NODE_DRAG,t.data);break;case ps.NODE_DRAG_END:this.emit(Ln.NODE_DRAG_END,t.data);break;case ps.SETTINGS_UPDATE:this.emit(Ln.SETTINGS_UPDATE,t.data)}},this._settings=t;try{this._blobUrl=URL.createObjectURL(new Blob(['"use strict";(()=>{function Ee(n,r){var e,t=1;n==null&&(n=0),r==null&&(r=0);function i(){var o,s=e.length,a,u=0,l=0;for(o=0;o=(_=(a+l)/2))?a=_:l=_,(h=e>=(m=(u+c)/2))?u=m:c=m,i=o,!(o=o[p=h<<1|f]))return i[p]=s,n;if(d=+n._x.call(null,o.data),g=+n._y.call(null,o.data),r===d&&e===g)return s.next=o,i?i[p]=s:n._root=s,n;do i=i?i[p]=new Array(4):n._root=new Array(4),(f=r>=(_=(a+l)/2))?a=_:l=_,(h=e>=(m=(u+c)/2))?u=m:c=m;while((p=h<<1|f)===(y=(g>=m)<<1|d>=_));return i[y]=o,i[p]=s,n}function Be(n){var r,e,t=n.length,i,o,s=new Array(t),a=new Array(t),u=1/0,l=1/0,c=-1/0,_=-1/0;for(e=0;ec&&(c=i),o_&&(_=o));if(u>c||l>_)return this;for(this.cover(u,l).cover(c,_),e=0;en||n>=i||t>r||r>=o;)switch(l=(rc||(a=g.y0)>_||(u=g.x1)=p)<<1|n>=h)&&(g=m[m.length-1],m[m.length-1]=m[m.length-1-f],m[m.length-1-f]=g)}else{var y=n-+this._x.call(null,d.data),T=r-+this._y.call(null,d.data),x=y*y+T*T;if(x=(m=(s+u)/2))?s=m:u=m,(f=_>=(d=(a+l)/2))?a=d:l=d,r=e,!(e=e[h=f<<1|g]))return this;if(!e.length)break;(r[h+1&3]||r[h+2&3]||r[h+3&3])&&(t=r,p=h)}for(;e.data!==n;)if(i=e,!(e=e.next))return this;return(o=e.next)&&delete e.next,i?(o?i.next=o:delete i.next,this):r?(o?r[h]=o:delete r[h],(e=r[0]||r[1]||r[2]||r[3])&&e===(r[3]||r[2]||r[1]||r[0])&&!e.length&&(t?t[p]=e:this._root=e),this):(this._root=o,this)}function He(n){for(var r=0,e=n.length;rm.index){var M=d-D.x-D.vx,v=g-D.y-D.vy,S=M*M+v*v;Sd+b||Eg+b||Pl.r&&(l.r=l[c].r)}function u(){if(r){var l,c=r.length,_;for(e=new Array(c),l=0;l[r(I,E,s),I])),x;for(h=0,a=new Array(p);h{}};function rt(){for(var n=0,r=arguments.length,e={},t;n=0&&(t=e.slice(i+1),e=e.slice(0,i)),e&&!r.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:t}})}le.prototype=rt.prototype={constructor:le,on:function(n,r){var e=this._,t=Rt(n+"",e),i,o=-1,s=t.length;if(arguments.length<2){for(;++o0)for(var e=new Array(i),t=0,i,o;t=0&&n._call.call(void 0,r),n=n._next;--J}function st(){Z=(de=oe.now())+ce,J=ie=0;try{ut()}finally{J=0,Gt(),Z=0}}function Ft(){var n=oe.now(),r=n-de;r>at&&(ce-=r,de=n)}function Gt(){for(var n,r=ue,e,t=1/0;r;)r._call?(t>r._time&&(t=r._time),n=r,r=r._next):(e=r._next,r._next=null,r=n?n._next=e:ue=e);ne=n,Le(t)}function Le(n){if(!J){ie&&(ie=clearTimeout(ie));var r=n-Z;r>24?(n<1/0&&(ie=setTimeout(st,n-oe.now()-ce)),te&&(te=clearInterval(te))):(te||(de=oe.now(),te=setInterval(Ft,at)),J=1,lt(st))}}function dt(){let n=1;return()=>(n=(1664525*n+1013904223)%4294967296)/4294967296}function ct(n){return n.x}function ht(n){return n.y}var kt=10,Wt=Math.PI*(3-Math.sqrt(5));function Me(n){var r,e=1,t=.001,i=1-Math.pow(t,1/300),o=0,s=.6,a=new Map,u=he(_),l=Ae("tick","end"),c=dt();n==null&&(n=[]);function _(){m(),l.call("tick",r),e1?(h==null?a.delete(f):a.set(f,g(h)),r):a.get(f)},find:function(f,h,p){var y=0,T=n.length,x,I,E,P,D;for(p==null?p=1/0:p*=p,y=0;y1?(l.on(f,h),r):l.on(f)}}}function Re(){var n,r,e,t,i=O(-30),o,s=1,a=1/0,u=.81;function l(d){var g,f=n.length,h=Q(n,ct,ht).visitAfter(_);for(t=d,g=0;g=a)return;(d.data!==r||d.next)&&(p===0&&(p=k(e),x+=p*p),y===0&&(y=k(e),x+=y*y),xn instanceof Date,pe=n=>Array.isArray(n),me=n=>n!==null&&typeof n=="object"&&n.constructor.name==="Object";var C=n=>fe(n)?Ct(n):pe(n)?Bt(n):me(n)?Kt(n):n,j=(n,r)=>{let e=fe(n),t=fe(r);if(e&&!t||!e&&t)return!1;if(e&&t)return n.getTime()===r.getTime();let i=pe(n),o=pe(r);if(i&&!o||!i&&o)return!1;if(i&&o)return n.length!==r.length?!1:n.every((u,l)=>j(u,r[l]));let s=me(n),a=me(r);if(s&&!a||!s&&a)return!1;if(s&&a){let u=Object.keys(n),l=Object.keys(r);return j(u,l)?u.every(c=>j(n[c],r[c])):!1}return n===r},Ct=n=>new Date(n),Bt=n=>n.map(r=>C(r)),Kt=n=>{let r={};return Object.keys(n).forEach(e=>{r[e]=C(n[e])}),r};var pt={radius:100,centerX:0,centerY:0},zt=100,ft=50,Fe=n=>(n>0?n:1)*zt,ee={useGPU:!1,isSimulatingOnDataUpdate:!0,isSimulatingOnSettingsUpdate:!0,isSimulatingOnUnstick:!0,isPhysicsEnabled:!1,alpha:{alpha:1,alphaMin:.05,alphaDecay:.028,alphaTarget:0},centering:{x:0,y:0,strength:1},collision:{radius:15,strength:1,iterations:1},links:{distance:ft,strength:1,iterations:1},manyBody:{strength:-100,theta:.9,distanceMin:1,distanceMax:Fe(ft)},positioning:{forceX:{x:0,strength:.1},forceY:{y:0,strength:.1}},anchorX:"center",anchorY:"center"},mt={rowGap:50,colGap:50},gt={nodeGap:50,levelGap:50,treeGap:100,orientation:"vertical",reversed:!1};var ge=class{constructor(){this._listeners=new Map}once(r,e){let t={callable:e,isOnce:!0},i=this._listeners.get(r);return i?i.push(t):this._listeners.set(r,[t]),this}on(r,e){let t={callable:e},i=this._listeners.get(r);return i?i.push(t):this._listeners.set(r,[t]),this}off(r,e){let t=this._listeners.get(r);if(t){let i=t.filter(o=>o.callable!==e);this._listeners.set(r,i)}return this}emit(r,e){let t=this._listeners.get(r);if(!t||t.length===0)return!1;let i=!1;for(let o=0;o!s.isOnce);this._listeners.set(r,o)}return!0}eventNames(){return[...this._listeners.keys()]}listenerCount(r){let e=this._listeners.get(r);return e?e.length:0}listeners(r){let e=this._listeners.get(r);return e?e.map(t=>t.callable):[]}addListener(r,e){return this.on(r,e)}removeListener(r,e){return this.off(r,e)}removeAllListeners(r){return r?this._listeners.delete(r):this._listeners.clear(),this}};var Y=class extends ge{constructor(){super(...arguments);this._nodes=[];this._edges=[];this._nodeIndexByNodeId={};this._cancelSimulation=!1;this._schedulerPort=null}terminate(){this._cancelSimulation=!0,this._schedulerPort?.close(),this._schedulerPort=null,this.removeAllListeners()}_scheduleNext(e){if(typeof MessageChannel<"u"){let t=new MessageChannel;this._schedulerPort=t.port2,t.port1.onmessage=()=>{this._schedulerPort=null,e()},t.port2.postMessage(null)}else setTimeout(e,0)}_rebuildNodeIndex(){this._nodeIndexByNodeId={};for(let e=0;e=i)continue;p<1&&(p=1);let y=-n*s/p;g.vx+=f*y,g.vy+=h*y}}}return o.initialize=s=>{t=s},o}var re=class extends Y{constructor(e){super();this._isDragging=!1;this._isStabilizing=!1;this.type="force";this._settings={...ee,...e},this.clearData()}setSettings(e){let t=e;this._initialSettings||(this._initialSettings=Object.assign(C(ee),t));let i=C(this._settings);if(Object.assign(this._settings,t),j(this._settings,i))return;this._applySettingsToSimulation(t),this.emit("settings-update",{settings:{type:"force",options:this._settings}}),i.isPhysicsEnabled&&!t.isPhysicsEnabled?this._simulation.stop():this._settings.isSimulatingOnSettingsUpdate&&this._nodes.length>0&&this.activateSimulation()}setupData(e){this.clearData(),this._initializeNewData(e),this._settings.isSimulatingOnDataUpdate&&(this._updateSimulationData(),this._runSimulation())}mergeData(e){this._initializeNewData(e),this._settings.isPhysicsEnabled||this._pinNodes(),this._settings.isSimulatingOnDataUpdate&&(this._updateSimulationData(),this.activateSimulation())}updateData(e){let t=new Set(e.nodes.map(s=>s.id)),i=this._nodes.filter(s=>t.has(s.id)),o=e.nodes.filter(s=>this._nodeIndexByNodeId[s.id]===void 0);this._nodes=[...i,...o],this._rebuildNodeIndex(),this._edges=e.edges,this._settings.isSimulatingOnSettingsUpdate&&(this._updateSimulationData(),this.activateSimulation())}deleteData(e){if(e.nodeIds){let t=new Set(e.nodeIds);this._nodes=this._nodes.filter(i=>!t.has(i.id))}if(e.edgeIds){let t=new Set(e.edgeIds);this._edges=this._edges.filter(i=>!t.has(i.id))}this._rebuildNodeIndex(),this._settings.isSimulatingOnDataUpdate&&(this._updateSimulationData(),this.activateSimulation())}patchData(e){if(e.nodes){let t={};for(let i=0;i0&&this.activateSimulation()}terminate(){super.terminate(),this._simulation?.stop()}_resetSimulation(){this._simulation&&(this._simulation.stop(),this._simulation.on("tick",null).on("end",null)),this._linkForce=De(this._edges).id(e=>e.id),this._simulation=Me(this._nodes).force("link",this._linkForce).stop(),this._applySettingsToSimulation(this._settings),this._simulation.on("tick",()=>{this.emit("simulation-step",{nodes:this._nodes,edges:this._edges})}),this._simulation.on("end",()=>{this._isDragging=!1,this._isStabilizing=!1,this.emit("simulation-end",{nodes:this._nodes,edges:this._edges}),this._settings.isPhysicsEnabled||this._pinNodes()})}_runSimulation(e){if(this._isStabilizing||this._cancelSimulation)return;(this._settings.isPhysicsEnabled||e?.isUpdatingSettings)&&this._unpinNodes(),this.emit("simulation-start",void 0),this._isStabilizing=!0,this._simulation.alpha(this._settings.alpha.alpha).alphaTarget(this._settings.alpha.alphaTarget).stop();let t=Math.min(jt,Math.ceil(Math.log(this._settings.alpha.alphaMin)/Math.log(1-this._settings.alpha.alphaDecay))),i=-1,o=0,s=()=>{if(this._cancelSimulation){this._isStabilizing=!1,this._cancelSimulation=!1;return}let a=Math.min(o+Xt,t);for(;oi&&(i=u,this.emit("simulation-progress",{nodes:this._nodes,edges:this._edges,progress:u/100}))}othis._edges)):this._simulation.force("edgeMidpointRepulsion",null)}if(e.manyBody===null&&(this._simulation.force("charge",null),this._simulation.force("edgeMidpointRepulsion",null)),e.positioning?.forceX){let t=we(e.positioning.forceX.x).strength(e.positioning.forceX.strength);this._simulation.force("x",t)}if(e.positioning?.forceX===null&&this._simulation.force("x",null),e.positioning?.forceY){let t=Ue(e.positioning.forceY.y).strength(e.positioning.forceY.strength);this._simulation.force("y",t)}if(e.positioning?.forceY===null&&this._simulation.force("y",null),e.centering){let t=Ee(e.centering.x,e.centering.y).strength(e.centering.strength);this._simulation.force("center",t)}e.centering===null&&this._simulation.force("center",null)}};var B=class extends Error{constructor(r){super(r),this.message=r,Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}};var ke=(n,r,e)=>{let t=n.createShader(e==="vertex"?n.VERTEX_SHADER:n.FRAGMENT_SHADER);if(!t)throw new B("Failed to create shader.");if(n.shaderSource(t,r),n.compileShader(t),!n.getShaderParameter(t,n.COMPILE_STATUS)){let i=n.getShaderInfoLog(t);throw n.deleteShader(t),new B(`Failed to compile shader: ${i}`)}return t};var _t=`#version 300 es\n\nin vec2 aPosition;\n\nvoid main() {\n gl_Position = vec4(aPosition, 0.0, 1.0);\n}\n`;var yt=`#version 300 es\n\nprecision highp float;\n\nuniform sampler2D uState;\nuniform sampler2D uFixed;\nuniform sampler2D uTreeData;\nuniform sampler2D uTreeChildren;\nuniform sampler2D uTreeGeometry;\nuniform sampler2D uAdjOffsets;\nuniform sampler2D uAdjEdges;\n\nuniform int uNodeCount;\nuniform int uTexWidth;\nuniform float uAlpha;\nuniform float uDamping;\n\nuniform float uManyBodyStrength;\nuniform float uTheta2;\nuniform float uDistanceMin2;\nuniform float uDistanceMax2;\nuniform int uTreeNodeCount;\nuniform int uTreeTexWidth;\n\nuniform int uAdjOffsetsTexWidth;\nuniform int uAdjEdgesTexWidth;\n\nuniform vec2 uCenter;\nuniform float uCenterStrength;\n\nuniform float uCollisionRadius;\nuniform float uCollisionStrength;\n\nuniform float uForceXTarget;\nuniform float uForceXStrength;\nuniform float uForceYTarget;\nuniform float uForceYStrength;\n\nuniform float uHasManyBody;\nuniform float uHasLinks;\nuniform float uHasCentering;\nuniform float uHasCollision;\nuniform float uHasPositioning;\n\nout vec4 fragColor;\n\nivec2 texCoord(int idx, int tw) {\n return ivec2(idx % tw, idx / tw);\n}\n\nvoid main() {\n ivec2 fc = ivec2(gl_FragCoord.xy);\n int nodeId = fc.y * uTexWidth + fc.x;\n\n if (nodeId >= uNodeCount) {\n fragColor = vec4(0.0);\n return;\n }\n\n vec4 fixedData = texelFetch(uFixed, fc, 0);\n if (fixedData.x > 0.5) {\n fragColor = vec4(fixedData.yz, 0.0, 0.0);\n return;\n }\n\n vec4 state = texelFetch(uState, fc, 0);\n vec2 pos = state.xy;\n vec2 vel = state.zw;\n\n if (uHasManyBody > 0.5 && uTreeNodeCount > 0) {\n int stack[128];\n int top = 0;\n stack[top++] = 0;\n\n while (top > 0) {\n int idx = stack[--top];\n vec4 data = texelFetch(uTreeData, texCoord(idx, uTreeTexWidth), 0);\n float w = data.w;\n\n if (w < -0.5) {\n int bodyIdx = int(-w - 0.5);\n if (bodyIdx != nodeId) {\n vec2 delta = data.xy - pos;\n float distSq = dot(delta, delta);\n\n if (distSq < 1e-8) {\n delta = vec2(float(nodeId) * 1e-4 - float(bodyIdx) * 1e-4 + 1e-4, 1e-4);\n distSq = dot(delta, delta);\n }\n\n if (distSq < uDistanceMax2) {\n float l = distSq;\n if (l < uDistanceMin2) l = sqrt(uDistanceMin2 * l);\n vel += delta * (data.z * uAlpha / max(l, 1e-6));\n }\n }\n } else {\n vec2 delta = data.xy - pos;\n float distSq = dot(delta, delta);\n\n if (distSq > 0.0 && w * w / distSq < uTheta2) {\n if (distSq < uDistanceMax2) {\n float l = distSq;\n if (l < uDistanceMin2) l = sqrt(uDistanceMin2 * l);\n vel += delta * (data.z * uAlpha / max(l, 1e-6));\n }\n } else {\n vec4 ch = texelFetch(uTreeChildren, texCoord(idx, uTreeTexWidth), 0);\n if (ch.w >= 0.0 && top < 64) stack[top++] = int(ch.w + 0.5);\n if (ch.z >= 0.0 && top < 64) stack[top++] = int(ch.z + 0.5);\n if (ch.y >= 0.0 && top < 64) stack[top++] = int(ch.y + 0.5);\n if (ch.x >= 0.0 && top < 64) stack[top++] = int(ch.x + 0.5);\n }\n }\n }\n }\n\n if (uHasCollision > 0.5 && uCollisionRadius > 0.0 && uTreeNodeCount > 0) {\n float collisionDiam = uCollisionRadius * 2.0;\n vec2 predictedPos = state.xy + state.zw;\n int stack[64];\n int top = 0;\n stack[top++] = 0;\n\n while (top > 0) {\n int idx = stack[--top];\n vec4 data = texelFetch(uTreeData, texCoord(idx, uTreeTexWidth), 0);\n float w = data.w;\n\n if (w < -0.5) {\n int bodyIdx = int(-w - 0.5);\n if (bodyIdx != nodeId && bodyIdx < uNodeCount) {\n vec2 delta = data.xy - predictedPos;\n float dist = length(delta);\n\n if (dist < collisionDiam && dist > 0.0) {\n float push = (collisionDiam - dist) * uCollisionStrength;\n vel -= (delta / dist) * push * 0.5;\n }\n }\n } else {\n vec4 geo = texelFetch(uTreeGeometry, texCoord(idx, uTreeTexWidth), 0);\n float cellSize = geo.z;\n vec2 nearest = clamp(predictedPos, geo.xy, geo.xy + cellSize);\n float distToCell = length(nearest - predictedPos);\n\n if (distToCell < collisionDiam) {\n vec4 ch = texelFetch(uTreeChildren, texCoord(idx, uTreeTexWidth), 0);\n if (ch.w >= 0.0 && top < 64) stack[top++] = int(ch.w + 0.5);\n if (ch.z >= 0.0 && top < 64) stack[top++] = int(ch.z + 0.5);\n if (ch.y >= 0.0 && top < 64) stack[top++] = int(ch.y + 0.5);\n if (ch.x >= 0.0 && top < 64) stack[top++] = int(ch.x + 0.5);\n }\n }\n }\n }\n\n if (uHasLinks > 0.5) {\n vec4 offData = texelFetch(uAdjOffsets, texCoord(nodeId, uAdjOffsetsTexWidth), 0);\n int start = int(offData.x + 0.5);\n int count = int(offData.y + 0.5);\n\n for (int e = 0; e < count; e++) {\n vec4 edgeData = texelFetch(uAdjEdges, texCoord(start + e, uAdjEdgesTexWidth), 0);\n int targetId = int(edgeData.x + 0.5);\n float restDist = edgeData.y;\n float strength = edgeData.z;\n float dirBias = edgeData.w;\n\n vec4 targetState = texelFetch(uState, texCoord(targetId, uTexWidth), 0);\n vec2 delta = (targetState.xy + targetState.zw) - (state.xy + state.zw);\n float d = length(delta);\n\n if (d < 1e-6) {\n delta = vec2(1e-3, 1e-3);\n d = length(delta);\n }\n\n float scale = (d - restDist) / d * uAlpha * strength;\n vel += delta * scale * dirBias;\n }\n }\n\n if (uHasCentering > 0.5) {\n vel += (uCenter - pos) * uCenterStrength * uAlpha;\n }\n\n if (uHasPositioning > 0.5) {\n vel.x += (uForceXTarget - pos.x) * uForceXStrength * uAlpha;\n vel.y += (uForceYTarget - pos.y) * uForceYStrength * uAlpha;\n }\n\n vel *= uDamping;\n pos += vel;\n\n fragColor = vec4(pos, vel);\n}\n`;function It(n,r){let e=n.length;if(e===0)return{treeData:new Float32Array(0),treeChildren:new Float32Array(0),treeGeometry:new Float32Array(0),nodeCount:0,texWidth:1};let t=1/0,i=1/0,o=-1/0,s=-1/0;for(let v=0;vo&&(o=S),A>s&&(s=A)}let a=Math.max(o-t,s-i);a<1e-6&&(a=1),a*=1.01;let u=(t+o)*.5,l=(i+s)*.5,c=a*.5,_=u-c,m=l-c,d=[];function g(v){let S=d.length;return d.push({cx:0,cy:0,charge:0,size:v,bodyIndex:-1,children:[null,null,null,null]}),S}let f=g(a),h=[_],p=[m];function y(v,S,A,K,w){let U=A+w*.5,G=K+w*.5,X=v>=U?1:0;return(S>=G?1:0)*2+X}function T(v,S,A,K){let w=K*.5,U=v&1?S+w:S,G=v&2?A+w:A;return{cx0:U,cy0:G,csz:w}}function x(v,S,A){let K=f,w=_,U=m,G=a;for(let X=0;X<50;X++){let L=d[K];if(L.bodyIndex===-1&&L.children[0]===null&&L.children[1]===null&&L.children[2]===null&&L.children[3]===null){L.bodyIndex=v,L.cx=S,L.cy=A,L.charge=r;return}if(L.bodyIndex>=0){let ve=L.bodyIndex,se=L.cx,ae=L.cy;L.bodyIndex=-1;let W=y(se,ae,w,U,G),{cx0:bt,cy0:Dt,csz:At}=T(W,w,U,G),V=g(At);h[V]=bt,p[V]=Dt,L.children[W]=V,d[V].bodyIndex=ve,d[V].cx=se,d[V].cy=ae,d[V].charge=r}let z=y(S,A,w,U,G);if(L.children[z]===null){let{cx0:ve,cy0:se,csz:ae}=T(z,w,U,G),W=g(ae);h[W]=ve,p[W]=se,L.children[z]=W,d[W].bodyIndex=v,d[W].cx=S,d[W].cy=A,d[W].charge=r;return}let{cx0:vt,cy0:Et,csz:Nt}=T(z,w,U,G);K=L.children[z],w=vt,U=Et,G=Nt}}for(let v=0;v=0)return;let A=0,K=0,w=0,U=0;for(let G=0;G<4;G++){let X=S.children[G];if(X===null)continue;I(X);let L=d[X],z=Math.abs(L.charge);A+=L.charge,K+=L.cx*z,w+=L.cy*z,U+=z}U>0&&(S.cx=K/U,S.cy=w/U),S.charge=A}I(f);let E=d.length,P=Math.ceil(Math.sqrt(E)),D=P*P,N=new Float32Array(D*4),b=new Float32Array(D*4),M=new Float32Array(D*4);for(let v=0;v=0?N[A+3]=-(S.bodyIndex+1):N[A+3]=S.size,b[A]=S.children[0]!==null?S.children[0]:-1,b[A+1]=S.children[1]!==null?S.children[1]:-1,b[A+2]=S.children[2]!==null?S.children[2]:-1,b[A+3]=S.children[3]!==null?S.children[3]:-1,M[A]=h[v]??0,M[A+1]=p[v]??0,M[A+2]=S.size,M[A+3]=0}for(let v=E;v0&&this.activateSimulation()}setupData(e){this.clearData(),this._initializeNewData(e),this._settings.isSimulatingOnDataUpdate&&this._runSimulation()}mergeData(e){this._initializeNewData(e),this._settings.isPhysicsEnabled||this._pinNodes(),this._settings.isSimulatingOnDataUpdate&&this.activateSimulation()}updateData(e){let t=new Set(e.nodes.map(s=>s.id)),i=this._nodes.filter(s=>t.has(s.id)),o=e.nodes.filter(s=>this._nodeIndexByNodeId[s.id]===void 0);this._nodes=[...i,...o],this._rebuildNodeIndex(),this._edges=e.edges,this._cachedAdjacency=null,this._settings.isSimulatingOnSettingsUpdate&&this.activateSimulation()}deleteData(e){if(e.nodeIds){let t=new Set(e.nodeIds);this._nodes=this._nodes.filter(i=>!t.has(i.id))}if(e.edgeIds){let t=new Set(e.edgeIds);this._edges=this._edges.filter(i=>!t.has(i.id))}this._rebuildNodeIndex(),this._cachedAdjacency=null,this._settings.isSimulatingOnDataUpdate&&this.activateSimulation()}patchData(e){if(e.nodes){let t={};for(let i=0;i0&&this.activateSimulation()}terminate(){super.terminate();let e=this._gl;e&&(e.deleteBuffer(this._quadBuffer),e.deleteVertexArray(this._quadVAO),e.deleteProgram(this._forceProgram),e.deleteTexture(this._stateTexA),e.deleteTexture(this._stateTexB),e.deleteTexture(this._fixedTex),e.deleteTexture(this._treeDataTexture),e.deleteTexture(this._treeChildrenTexture),e.deleteTexture(this._treeGeometryTexture),e.deleteTexture(this._adjOffsetsTexture),e.deleteTexture(this._adjEdgesTexture),e.deleteFramebuffer(this._fboA),e.deleteFramebuffer(this._fboB),e.getExtension("WEBGL_lose_context")?.loseContext())}reheat(){let e=this._settings.alpha;this._currentAlpha=e.alpha,this._totalSteps=Math.min(St,Math.ceil(Math.log(e.alphaMin)/Math.log(1-e.alphaDecay))),this._currentStep=0,!this._isStabilizing&&(this._ensurePositions(),this._uploadDataToGPU(),this._cachedAdjacency||this._buildAndUploadAdjacency(),this._startSimulationLoop())}_runSimulation(){this._isStabilizing||this._cancelSimulation||(this._ensurePositions(),this._uploadDataToGPU(),this._buildAndUploadAdjacency(),this._startSimulationLoop())}_startDragLoop(){if(this._dragLoopRunning)return;this._dragLoopRunning=!0;let e=this._settings.alpha.alphaDecay,t=this._settings.alpha.alphaMin;this._dragAlpha=.3,this._dragNeedsReheat=!1;let i=()=>{if(!this._isDragging){this._dragLoopRunning=!1;return}if(this._dragNeedsReheat&&(this._dragAlpha=.3,this._dragNeedsReheat=!1),this._dragAlpha+=(0-this._dragAlpha)*e,this._dragAlpha{if(e!==this._simulationGeneration)return;if(this._cancelSimulation){this._isStabilizing=!1,this._cancelSimulation=!1,this.emit("simulation-end",{nodes:this._nodes,edges:this._edges});return}if(this._readbackFromGPU(),this._pendingRestart){this._isStabilizing=!1,this._pendingRestart=!1,this._ensurePositions(),this._uploadDataToGPU(),this._cachedAdjacency||this._buildAndUploadAdjacency(),this._startSimulationLoop();return}this._flushDirtyNodes(),this._buildAndUploadQuadTree();let u=Math.min(this._currentStep+Ht,this._totalSteps);for(;this._currentSteps&&(s=l,this.emit("simulation-progress",{nodes:this._nodes,edges:this._edges,progress:l/100})),this._currentStep0&&(i=i.concat(s))}let o=It(i,t);this._uploadTexture(this._treeDataTexture,o.treeData,o.texWidth),this._uploadTexture(this._treeChildrenTexture,o.treeChildren,o.texWidth),this._uploadTexture(this._treeGeometryTexture,o.treeGeometry,o.texWidth),this._treeTexWidth=o.texWidth,this._treeNodeCount=o.nodeCount}_getEdgeMidpoints(){let e=[];for(let t=0;t0?d.distanceMax:Fe(this._settings.links?.distance??50);t.uniform1f(s.uDistanceMax2,f*f),t.uniform1i(s.uTreeNodeCount,this._treeNodeCount),t.uniform1i(s.uTreeTexWidth,this._treeTexWidth)}let u=this._cachedAdjacency!==null&&this._edges.length>0;t.uniform1f(s.uHasLinks,u?1:0),u&&(t.uniform1i(s.uAdjOffsetsTexWidth,this._cachedAdjacency.offsetsTexWidth),t.uniform1i(s.uAdjEdgesTexWidth,this._cachedAdjacency.edgesTexWidth)),t.uniform1f(s.uHasCentering,0);let l=this._settings.collision!==null&&this._settings.collision!==void 0;t.uniform1f(s.uHasCollision,l?1:0),l&&(t.uniform1f(s.uCollisionRadius,this._settings.collision.radius),t.uniform1f(s.uCollisionStrength,this._settings.collision.strength));let c=this._settings.positioning!==null&&this._settings.positioning!==void 0;if(t.uniform1f(s.uHasPositioning,c?1:0),c){let d=this._settings.positioning;t.uniform1f(s.uForceXTarget,d.forceX?.x??0),t.uniform1f(s.uForceXStrength,d.forceX?.strength??0),t.uniform1f(s.uForceYTarget,d.forceY?.y??0),t.uniform1f(s.uForceYStrength,d.forceY?.strength??0)}let _=this._pingPong?this._stateTexA:this._stateTexB,m=this._pingPong?this._fboB:this._fboA;t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,_),t.uniform1i(s.uState,0),t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fixedTex),t.uniform1i(s.uFixed,1),t.activeTexture(t.TEXTURE2),t.bindTexture(t.TEXTURE_2D,this._treeDataTexture),t.uniform1i(s.uTreeData,2),t.activeTexture(t.TEXTURE3),t.bindTexture(t.TEXTURE_2D,this._treeChildrenTexture),t.uniform1i(s.uTreeChildren,3),t.activeTexture(t.TEXTURE4),t.bindTexture(t.TEXTURE_2D,this._adjOffsetsTexture),t.uniform1i(s.uAdjOffsets,4),t.activeTexture(t.TEXTURE5),t.bindTexture(t.TEXTURE_2D,this._adjEdgesTexture),t.uniform1i(s.uAdjEdges,5),t.activeTexture(t.TEXTURE6),t.bindTexture(t.TEXTURE_2D,this._treeGeometryTexture),t.uniform1i(s.uTreeGeometry,6),t.bindFramebuffer(t.FRAMEBUFFER,m),t.viewport(0,0,this._texWidth,this._texWidth),t.bindVertexArray(this._quadVAO),t.drawArrays(t.TRIANGLE_STRIP,0,4),t.bindVertexArray(null),t.bindFramebuffer(t.FRAMEBUFFER,null),this._pingPong=!this._pingPong}_readbackFromGPU(){let e=this._gl,t=this._nodes.length;if(t===0)return;let i=this._pingPong?this._fboA:this._fboB,o=this._texWidth*this._texWidth,s=new Float32Array(o*4);e.bindFramebuffer(e.FRAMEBUFFER,i),e.readPixels(0,0,this._texWidth,this._texWidth,e.RGBA,e.FLOAT,s),e.bindFramebuffer(e.FRAMEBUFFER,null);for(let a=0;as.id)),i=this._nodes.filter(s=>t.has(s.id)),o=e.nodes.filter(s=>this._nodeIndexByNodeId[s.id]===void 0);this._nodes=[...i,...o],this._edges=e.edges,this._rebuildNodeIndex(),this._calculateAndEmit()}deleteData(e){if(e.nodeIds){let t=new Set(e.nodeIds);this._nodes=this._nodes.filter(i=>!t.has(i.id))}if(e.edgeIds){let t=new Set(e.edgeIds);this._edges=this._edges.filter(i=>!t.has(i.id))}this._rebuildNodeIndex(),this._calculateAndEmit()}patchData(e){if(e.nodes)for(let t=0;t0&&this._calculateAndEmit()}terminate(){this._pendingRecalculation=!1,super.terminate()}_calculateAndEmit(){if(!(this._nodes.length===0||this._cancelSimulation)){if(this._isCalculating){this._pendingRecalculation=!0;return}this._isCalculating=!0,this.emit("simulation-start",void 0),this.calculatePositions(this._nodes,this._edges,e=>{this.emit("simulation-progress",{nodes:this._nodes,edges:this._edges,progress:e})},()=>this._cancelSimulation,()=>{this._isCalculating=!1,this._cancelSimulation||this.emit("simulation-end",{nodes:this._nodes,edges:this._edges}),this._cancelSimulation=!1,this._pendingRecalculation&&(this._pendingRecalculation=!1,this._calculateAndEmit())})}}_emitProgress(e,t,i,o){let s=Math.round(e*100/t);return s>i?(o(s/100),s):i}};var Ie=class extends H{constructor(e){super();this.type="circular";this._config={...pt,...e}}calculatePositions(e,t,i,o,s){let a=2*Math.PI/e.length,u=-1,l=0,c=()=>{if(o()){s();return}let _=Math.min(l+ye,e.length);for(;l<_;l++)e[l].x=this._config.centerX+this._config.radius*Math.cos(a*l),e[l].y=this._config.centerY+this._config.radius*Math.sin(a*l);l{if(o()){s();return}let m=Math.min(c+ye,e.length);for(;c{if(o()||g>=l.length){!o()&&this._config.reversed&&this._applyReversal(e,c,_),s();return}let h=this._assignLevels(l[g],a,u),p=Math.max(...Array.from(h.values()).map(T=>T.length));h.size*this._config.levelGap>_&&(_=h.size*this._config.levelGap);let y=g===0?0:this._config.treeGap+c;g>0&&(y+=(p-1)*this._config.nodeGap/2);for(let T=0;Tc&&(c=b),N!==void 0&&(e[N].x=this._config.orientation==="horizontal"?x:b,e[N].y=this._config.orientation==="horizontal"?b:x),m++}}g++,g0;){let c=l.pop();if(c===void 0)continue;u.push(c);let _=t.get(c)??[];for(let m=0;m<_.length;m++)i.has(_[m])||(i.add(_[m]),l.push(_[m]))}o.push(u)}return o}_assignLevels(e,t,i){let o=new Map,s=new Set,a=e.find(l=>(i.get(l)??0)===0);a===void 0&&(a=e.reduce((l,c)=>(i.get(c)??0)<(i.get(l)??0)?c:l));let u=[[a,0]];for(let[l,c]of u){if(s.has(l))continue;s.add(l),o.has(c)?o.get(c)?.push(l):o.set(c,[l]);let _=t.get(l)??[];for(let m=0;m<_.length;m++)u.push([_[m],c+1])}return o}_getEdgeEndpointId(e){return typeof e=="object"?e.id:e}};var Te=class{static create(r){switch(r?.type){case"circular":return new Ie(r.options);case"grid":return new xe(r.options);case"hierarchical":return new Se(r.options);default:{let e=r?.options;if(e?.useGPU)try{return new _e(e)}catch{return console.warn("WebGL2 unavailable, falling back to CPU force layout engine."),new re(e)}return new re(e)}}}};function Tt(n,r){switch(r.type){case"Set Data":n.setupData(r.data);break;case"Add Data":n.mergeData(r.data);break;case"Update Data":n.updateData(r.data);break;case"Delete Data":n.deleteData(r.data);break;case"Patch Data":n.patchData(r.data);break;case"Clear Data":n.clearData();break;case"Activate Simulation":n.activateSimulation();break;case"Stop Simulation":n.stopSimulation();break;case"Start Drag Node":n.startDragNode();break;case"Drag Node":n.dragNode(r.data.id,{x:r.data.x,y:r.data.y});break;case"End Drag Node":n.endDragNode(r.data.id);break;case"Fix Nodes":n.fixNodes(r.data.nodes);break;case"Release Nodes":n.releaseNodes(r.data.nodes);break;default:break}}var q=null,$=n=>postMessage(n);function Vt(n){n.on("simulation-start",()=>$({type:"simulation-start"})),n.on("simulation-progress",r=>$({type:"simulation-progress",data:r})),n.on("simulation-end",r=>$({type:"simulation-end",data:r})),n.on("simulation-step",r=>$({type:"simulation-step",data:r})),n.on("node-drag",r=>$({type:"node-drag",data:r})),n.on("settings-update",r=>$({type:"settings-update",data:r}))}$({type:"ready"});addEventListener("message",({data:n})=>{if(n.type==="Set Settings"){let r=n.data;if(r.type===q?.type&&r.options){q?.setSettings(r.options);return}q?.removeAllListeners(),q?.terminate(),q=Te.create(r),Vt(q);return}q&&Tt(q,n)});})();\n'],{type:"text/javascript"})),e=new Worker(this._blobUrl)}catch(t){return void this._activateFallback(t)}this._worker=e,e.onerror=t=>{this._ready?this._warnWorkerError(t):this._activateFallback(t)},e.onmessage=this._handleWorkerMessage,this._readyTimer=setTimeout(()=>{this._ready||this._fallback||this._activateFallback(new Error("Web Worker readiness handshake timed out."))},3e3),this.emitToWorker({type:gs.SetSettings,data:t})}setupData(t){this.emitToWorker({type:gs.SetupData,data:t})}mergeData(t){this.emitToWorker({type:gs.MergeData,data:t})}updateData(t){this.emitToWorker({type:gs.UpdateData,data:t})}deleteData(t){this.emitToWorker({type:gs.DeleteData,data:t})}patchData(t){this.emitToWorker({type:gs.PatchData,data:t})}clearData(){this.emitToWorker({type:gs.ClearData})}activateSimulation(){this.emitToWorker({type:gs.ActivateSimulation})}stopSimulation(){this.emitToWorker({type:gs.StopSimulation})}updateSimulation(t,e){this.emitToWorker({type:gs.UpdateSimulation,data:{nodes:t,edges:e}})}startDragNode(){this.emitToWorker({type:gs.StartDragNode})}dragNode(t,e){this.emitToWorker({type:gs.DragNode,data:Object.assign({id:t},e)})}endDragNode(t){this.emitToWorker({type:gs.EndDragNode,data:{id:t}})}fixNodes(t){this.emitToWorker({type:gs.FixNodes,data:{nodes:t}})}releaseNodes(t){this.emitToWorker({type:gs.ReleaseNodes,data:{nodes:t}})}setSettings(t){this.emitToWorker({type:gs.SetSettings,data:t})}isSimulationRunning(){return this._fallback?this._fallback.isSimulationRunning():this._isSimulationRunning}terminate(){var t;void 0!==this._readyTimer&&(clearTimeout(this._readyTimer),this._readyTimer=void 0),this._revokeBlobUrl(),this._worker&&(this._worker.onmessage=null,this._worker.onerror=null,this._worker.terminate(),this._worker=void 0),null===(t=this._fallback)||void 0===t||t.terminate(),this.removeAllListeners()}emitToWorker(t){var e;this._fallback?this._applyToFallback(this._fallback,t):(this._ready||this._pending.push(t),null===(e=this._worker)||void 0===e||e.postMessage(t))}_markReady(){this._ready||(this._ready=!0,this._pending=[],void 0!==this._readyTimer&&(clearTimeout(this._readyTimer),this._readyTimer=void 0),this._revokeBlobUrl())}_activateFallback(t){if(this._fallback)return;if(this._warnFallback(t),void 0!==this._readyTimer&&(clearTimeout(this._readyTimer),this._readyTimer=void 0),this._worker){this._worker.onmessage=null,this._worker.onerror=null;try{this._worker.terminate()}catch(t){}this._worker=void 0}this._revokeBlobUrl();const e=new fs(this._settings);this._wireFallbackEvents(e),this._fallback=e;const i=this._pending;this._pending=[];for(const t of i)this._applyToFallback(e,t)}_wireFallbackEvents(t){Rn(t,this,t=>{this._isSimulationRunning=t})}_applyToFallback(t,e){e.type!==gs.SetSettings?function(t,e){switch(e.type){case gs.SetupData:t.setupData(e.data);break;case gs.MergeData:t.mergeData(e.data);break;case gs.UpdateData:t.updateData(e.data);break;case gs.DeleteData:t.deleteData(e.data);break;case gs.PatchData:t.patchData(e.data);break;case gs.ClearData:t.clearData();break;case gs.ActivateSimulation:t.activateSimulation();break;case gs.StopSimulation:t.stopSimulation();break;case gs.StartDragNode:t.startDragNode();break;case gs.DragNode:t.dragNode(e.data.id,{x:e.data.x,y:e.data.y});break;case gs.EndDragNode:t.endDragNode(e.data.id);break;case gs.FixNodes:t.fixNodes(e.data.nodes);break;case gs.ReleaseNodes:t.releaseNodes(e.data.nodes)}}(t,e):t.setSettings(e.data)}_revokeBlobUrl(){this._blobUrl&&(URL.revokeObjectURL(this._blobUrl),this._blobUrl=void 0)}_warnWorkerError(t){this._hasWarned||(this._hasWarned=!0,console.warn("Orb: the layout Web Worker errored after it had started. The current layout is kept and no further updates will be simulated; reload the graph to recover.",t))}_warnFallback(t){this._hasWarned||(this._hasWarned=!0,console.warn("Orb: the layout Web Worker could not start; falling back to the main-thread simulator. Layout is still correct but runs on the main thread. Under a strict Content Security Policy, allow blob workers (e.g. `worker-src blob:` or `child-src blob:`) to re-enable off-main-thread layout.",t))}}class vs{static getSimulator(t){const e=Object.assign({type:"force"},t),i=e.options;if("force"===e.type&&(null==i?void 0:i.useGPU))return new fs(e);try{if("undefined"!=typeof Worker)return new ms(e);throw new Error("WebWorkers are unavailable in your environment.")}catch(t){return console.error("Could not create simulator in a WebWorker context. All calculations will be done in the main thread.",t),new fs(e)}}}const ys=t=>{const e=t.start,i=t.end;return e{if(!this.sortBy)return 0;const i=this.getOne(t),n=this.getOne(e);return void 0===i||void 0===n?0:this.sortBy(i,n)})}get size(){return this.entityById.size}}const bs=(...t)=>{const e=t.reduce((t,e)=>t.concat(e),[]);return Array.from(new Set(e))};class Ss extends l{constructor(t,e){var i,n;super(),this._nodes=new xs({getId:t=>t.getId(),sortBy:(t,e)=>{var i,n;return(null!==(i=t.getStyle().zIndex)&&void 0!==i?i:0)-(null!==(n=e.getStyle().zIndex)&&void 0!==n?n:0)}}),this._edges=new xs({getId:t=>t.getId(),sortBy:(t,e)=>{var i,n;return(null!==(i=t.getStyle().zIndex)&&void 0!==i?i:0)-(null!==(n=e.getStyle().zIndex)&&void 0!==n?n:0)}}),this._update=t=>{if(t&&"type"in t&&"options"in t&&"isSingle"in t.options){if("node"===t.type&&t.options.isSingle){const e=this._nodes.getAll();for(let i=0;it.isSelected())}getSelectedEdges(){return this.getEdges(t=>t.isSelected())}getHoveredNodes(){return this.getNodes(t=>t.isHovered())}getHoveredEdges(){return this.getEdges(t=>t.isHovered())}getNodePositions(t){const e=this.getNodes(t),i=new Array(e.length);for(let t=0;tt.id),e=this._edges.getAll().map(t=>t.id);this.remove({nodeIds:t,edgeIds:e})}removeAllEdges(){const t=this._edges.getAll().map(t=>t.id);this.remove({edgeIds:t})}removeAllNodes(){this.removeAll()}isEqual(t){if(this.getNodeCount()!==t.getNodeCount())return!1;if(this.getEdgeCount()!==t.getEdgeCount())return!1;const e=this.getNodes();for(let i=0;ii.x&&(i.x=s+r),s-ri.y&&(i.y=o+r),o-r=0;i--)if(e[i].includesPoint(t))return e[i]}getNearestEdge(t,e=3){let i,n=e;const s=this.getEdges();for(let e=0;e{var t,e;return null===(e=null===(t=this._settings)||void 0===t?void 0:t.onLoadedImages)||void 0===e?void 0:e.call(t)},listeners:[this._update]});this._nodes.setMany(e)}_insertEdges(t){const e=[];for(let i=0;i{var t,e;return null===(e=null===(t=this._settings)||void 0===t?void 0:t.onLoadedImages)||void 0===e?void 0:e.call(t)},listeners:[this._update]}))}this._nodes.setMany(e)}_upsertEdges(t){const e=[],i=[];for(let n=0;n{var e;const i=new Array(t.length),n=(t=>{var e;const i={},n=new Set;for(let s=0;se+1);continue}if(r<=1)continue;const a=[];r%2!=0&&a.push(0);for(let t=2;t<=r;t+=2)a.push(t/2),a.push(t/2*-1);s[e]=a}return s})(t);for(let s=0;s{var t,e;null===(e=null===(t=this._settings)||void 0===t?void 0:t.onLoadedImages)||void 0===e||e.call(t)}),this._nodes.sort(),this._edges.sort()}}const ws=(t,e)=>{var i;null===(i=null==e?void 0:e.cascade)||void 0===i||i?Is(t,r.SELECTED,{isStateOverride:!0}):t.setState(r.SELECTED,{isNotifySkipped:!0})},Ts=(t,e)=>{var i;null===(i=null==e?void 0:e.cascade)||void 0===i||i?Ls(t,r.SELECTED,{isStateOverride:!0}):t.setState(r.SELECTED,{isNotifySkipped:!0})},Es=(t,e)=>{var i;null===(i=null==e?void 0:e.cascade)||void 0===i||i?Is(t,r.NONE,{isStateOverride:!0}):t.clearState()},Ps=(t,e)=>{var i;null===(i=null==e?void 0:e.cascade)||void 0===i||i?Ls(t,r.NONE,{isStateOverride:!0}):t.clearState()},As=(t,e,i)=>{Ms(t),ws(e,i)},Cs=(t,e,i)=>{Ms(t),Ts(e,i)},Ms=t=>{const e=t.getNodes(t=>t.isSelected());for(let t=0;tt.isSelected());for(let t=0;t{Is(t,r.HOVERED)},Ds=t=>{const e=t.getNodes(t=>t.isHovered());for(let t=0;tt.isHovered());for(let t=0;t{Rs(t,i)&&t.setState(e,{isNotifySkipped:!0}),t.getInEdges().forEach(t=>{t&&Rs(t,i)&&t.setState(e,{isNotifySkipped:!0}),t.startNode&&Rs(t.startNode,i)&&t.startNode.setState(e,{isNotifySkipped:!0})}),t.getOutEdges().forEach(t=>{t&&Rs(t,i)&&t.setState(e,{isNotifySkipped:!0}),t.endNode&&Rs(t.endNode,i)&&t.endNode.setState(e,{isNotifySkipped:!0})})},Ls=(t,e,i)=>{Rs(t,i)&&t.setState(e,{isNotifySkipped:!0}),t.startNode&&Rs(t.startNode,i)&&t.startNode.setState(e,{isNotifySkipped:!0}),t.endNode&&Rs(t.endNode,i)&&t.endNode.setState(e,{isNotifySkipped:!0})},Rs=(t,e)=>{const i=null==e?void 0:e.isStateOverride;return i||!i&&!t.getState()};class Os{constructor(t){this.isSelectEnabled=t.isDefaultSelectEnabled,this.isHoverEnabled=t.isDefaultHoverEnabled,this.isMultiSelectEnabled=t.isDefaultMultiSelectEnabled,this.isSelectCascadeEnabled=t.isDefaultSelectCascadeEnabled}onMouseClick(t,e,i){var n;const s=this.isMultiSelectEnabled&&null!==(n=null==i?void 0:i.isAppend)&&void 0!==n&&n,o=t.getNearestNode(e);if(o)return this.isSelectEnabled&&(s?(t=>{t.isSelected()?Es(t,{cascade:!1}):ws(t,{cascade:!1})})(o):As(t,o,{cascade:this.isSelectCascadeEnabled})),{isStateChanged:!0,changedSubject:o};const r=t.getNearestEdge(e);if(r)return this.isSelectEnabled&&(s?(t=>{t.isSelected()?Ps(t,{cascade:!1}):Ts(t,{cascade:!1})})(r):Cs(t,r,{cascade:this.isSelectCascadeEnabled})),{isStateChanged:!0,changedSubject:r};if(!this.isSelectEnabled||s)return{isStateChanged:!1};const{changedCount:a}=Ms(t);return{isStateChanged:a>0}}onMouseMove(t,e){const i=t.getNearestNode(e);if(i&&(!this.isSelectEnabled||this.isSelectEnabled&&!i.isSelected()))return i===this._lastHoveredNode?{changedSubject:i,isStateChanged:!1}:(this.isHoverEnabled&&((t,e)=>{Ds(t),Ns(e)})(t,i),this._lastHoveredNode=i,{isStateChanged:!0,changedSubject:i});if(this._lastHoveredNode=void 0,!i&&this.isHoverEnabled){const{changedCount:e}=Ds(t);return{isStateChanged:e>0}}return{isStateChanged:!1}}onMouseRightClick(t,e){const i=t.getNearestNode(e);if(i)return this.isSelectEnabled&&As(t,i,{cascade:this.isSelectCascadeEnabled}),{isStateChanged:!0,changedSubject:i};const n=t.getNearestEdge(e);if(n)return this.isSelectEnabled&&Cs(t,n,{cascade:this.isSelectCascadeEnabled}),{isStateChanged:!0,changedSubject:n};if(!this.isSelectEnabled)return{isStateChanged:!1};const{changedCount:s}=Ms(t);return{isStateChanged:s>0}}onMouseDoubleClick(t,e){const i=t.getNearestNode(e);if(i)return this.isSelectEnabled&&As(t,i,{cascade:this.isSelectCascadeEnabled}),{isStateChanged:!0,changedSubject:i};const n=t.getNearestEdge(e);if(n)return this.isSelectEnabled&&Cs(t,n,{cascade:this.isSelectCascadeEnabled}),{isStateChanged:!0,changedSubject:n};if(!this.isSelectEnabled)return{isStateChanged:!1};const{changedCount:s}=Ms(t);return{isStateChanged:s>0}}}var ks,Bs;!function(t){t.CANVAS="canvas",t.WEBGL="webgl"}(ks||(ks={})),function(t){t.RESIZE="resize",t.RENDER_START="render-start",t.RENDER_END="render-end"}(Bs||(Bs={}));const zs={devicePixelRatio:null,fps:60,minZoom:.25,maxZoom:8,fitZoomMargin:.2,labelsIsEnabled:!0,labelsOnEventIsEnabled:!0,shadowIsEnabled:!0,shadowOnEventIsEnabled:!0,contextAlphaOnEvent:.3,contextAlphaOnEventIsEnabled:!0,backgroundColor:null,areCollapsedContainerDimensionsAllowed:!1},Us="Roboto, sans-serif";var Fs;!function(t){t.TOP="top",t.MIDDLE="middle"}(Fs||(Fs={}));class js{constructor(t,e){var i,n;this.textLines=[],this.fontSize=4,this.fontFamily=Hs(4,Us),this.text=`${void 0===t?"":t}`,this.textLines=Xs(this.text),this.position=e.position,this.properties=e.properties,this.textBaseline=e.textBaseline,(void 0!==this.properties.fontSize||this.properties.fontFamily)&&(this.fontSize=Math.max(null!==(i=this.properties.fontSize)&&void 0!==i?i:0,0),this.fontFamily=Hs(this.fontSize,null!==(n=this.properties.fontFamily)&&void 0!==n?n:Us)),this._fixPosition()}_fixPosition(){if(this.textBaseline===Fs.MIDDLE&&this.textLines.length){const t=Math.floor(this.textLines.length/2),e=(this.textLines.length-1)/2;this.position.y-=e*this.fontSize-t*(1.2-1)}}}const Ws=(t,e)=>{e.textLines.length>0&&e.fontSize>0&&e.position&&(Zs(t,e),Gs(t,e))},Zs=(t,e)=>{if(!e.properties.fontBackgroundColor||!e.position)return;t.fillStyle=e.properties.fontBackgroundColor.toString();const i=.12*e.fontSize,n=e.fontSize+2*i,s=1.2*e.fontSize,o=e.textBaseline===Fs.MIDDLE?e.fontSize/2:0;for(let r=0;r{var i;if(!e.position)return;t.fillStyle=(null!==(i=e.properties.fontColor)&&void 0!==i?i:"#000000").toString(),t.font=e.fontFamily,t.textBaseline=e.textBaseline,t.textAlign="center";const n=1.2*e.fontSize;for(let i=0;i`${t}px ${e}`,Xs=t=>{const e=t.split("\n"),i=[];for(let t=0;t{var e,i;const n=null!==(e=t.getStyle().arrowSize)&&void 0!==e?e:1,s=null!==(i=t.getWidth())&&void 0!==i?i:1,o=t.endNode,r=t.getCurvedControlPoint(),a=Ys(t,o),h=Vs(t,Math.max(0,Math.min(1,a.t+-.1)),r),l=Math.atan2(a.y-h.y,a.x-h.x),d=1.5*n+3*s;return{point:a,core:{x:a.x-.9*d*Math.cos(l),y:a.y-.9*d*Math.sin(l)},angle:l,length:d}},Vs=(t,e,i)=>{const n=t.startNode.getCenter(),s=t.endNode.getCenter();if(!n||!s)return{x:0,y:0};const o=e;return{x:Math.pow(1-o,2)*n.x+2*o*(1-o)*i.x+Math.pow(o,2)*s.x,y:Math.pow(1-o,2)*n.y+2*o*(1-o)*i.y+Math.pow(o,2)*s.y}},Ys=(t,e)=>{let i,n,s,o=0,r=0,a=1,h={x:0,y:0,t:0};const l=t.getCurvedControlPoint();let d=t.endNode,u=!1;e.getId()===t.startNode.getId()&&(d=t.startNode,u=!0);const c=d.getCenter();let _;for(;r<=a&&o<10&&(_=.5*(r+a),h=Object.assign(Object.assign({},Vs(t,_,l)),{t:0}),i=d.getDistanceToBorder(),n=Math.sqrt(Math.pow(h.x-c.x,2)+Math.pow(h.y-c.y,2)),s=i-n,!(Math.abs(s)<.2));)s<0?!1===u?r=_:a=_:!1===u?a=_:r=_,o++;return h.t=null!=_?_:0,h},$s=t=>{var e,i;const n=null!==(e=t.getStyle().arrowSize)&&void 0!==e?e:1,s=null!==(i=t.getWidth())&&void 0!==i?i:1,o=t.startNode,r=Qs(t,o),a=-2*r.t*Math.PI+.45*Math.PI,h=1.5*n+3*s;return{point:r,core:{x:r.x-.9*h*Math.cos(a),y:r.y-.9*h*Math.sin(a)},angle:a,length:h}},Ks=(t,e)=>{const i=2*e*Math.PI;return{x:t.x+t.radius*Math.cos(i),y:t.y-t.radius*Math.sin(i)}},Qs=(t,e)=>{const i=t.getCircularData();let n=.6,s=1;let o,r,a,h=0,l={x:0,y:0,t:0},d=.5*(n+s);const u=e.getCenter();for(;n<=s&&h<10&&(d=.5*(n+s),l=Object.assign(Object.assign({},Ks(i,d)),{t:0}),o=e.getDistanceToBorder(),r=Math.sqrt(Math.pow(l.x-u.x,2)+Math.pow(l.y-u.y,2)),a=o-r,!(Math.abs(a)<.05));)a>0?n=d:s=d,h++;return l.t=null!=d?d:0,l},Js=t=>{var e,i;const n=null!==(e=t.getStyle().arrowSize)&&void 0!==e?e:1,s=null!==(i=t.getWidth())&&void 0!==i?i:1,o=t.startNode.getCenter(),r=t.endNode.getCenter(),a=Math.atan2(r.y-o.y,r.x-o.x),h=to(t,t.endNode),l=1.5*n+3*s;return{point:h,core:{x:h.x-.9*l*Math.cos(a),y:h.y-.9*l*Math.sin(a)},angle:a,length:l}},to=(t,e)=>{let i=t.endNode,n=t.startNode;e.getId()===t.startNode.getId()&&(i=t.startNode,n=t.endNode);const s=i.getCenter(),o=n.getCenter(),r=s.x-o.x,a=s.y-o.y,h=Math.sqrt(r*r+a*a),l=(h-e.getDistanceToBorder())/h;return{x:(1-l)*o.x+l*s.x,y:(1-l)*o.y+l*s.y,t:0}},eo=t=>{if(t instanceof O)return Js(t);if(t instanceof k)return qs(t);if(t instanceof B)return $s(t);throw new Error("Failed to draw unsupported edge type")},io=(t,e)=>{const i=e.point.x,n=e.point.y,s=e.angle,o=e.length;for(let e=0;e{const i=e.getCenter(),n=e.getRadius();switch(e.getStyle().shape){case S.SQUARE:((t,e,i,n)=>{t.beginPath(),t.rect(e-n,i-n,2*n,2*n),t.closePath()})(t,i.x,i.y,n);break;case S.DIAMOND:((t,e,i,n)=>{t.beginPath(),t.lineTo(e,i+n),t.lineTo(e+n,i),t.lineTo(e,i-n),t.lineTo(e-n,i),t.closePath()})(t,i.x,i.y,n);break;case S.TRIANGLE:((t,e,i,n)=>{t.beginPath(),i+=.275*(n*=1.15);const s=2*n,o=Math.sqrt(3)*s/6,r=Math.sqrt(s*s-n*n);t.moveTo(e,i-(r-o)),t.lineTo(e+n,i+o),t.lineTo(e-n,i+o),t.lineTo(e,i-(r-o)),t.closePath()})(t,i.x,i.y,n);break;case S.TRIANGLE_DOWN:((t,e,i,n)=>{t.beginPath(),i-=.275*(n*=1.15);const s=2*n,o=Math.sqrt(3)*s/6,r=Math.sqrt(s*s-n*n);t.moveTo(e,i+(r-o)),t.lineTo(e+n,i-o),t.lineTo(e-n,i-o),t.lineTo(e,i+(r-o)),t.closePath()})(t,i.x,i.y,n);break;case S.STAR:((t,e,i,n)=>{t.beginPath(),i+=.1*(n*=.82);for(let s=0;s<10;s++){const o=n*(s%2==0?1.3:.5),r=e+o*Math.sin(2*s*Math.PI/10),a=i-o*Math.cos(2*s*Math.PI/10);t.lineTo(r,a)}t.closePath()})(t,i.x,i.y,n);break;case S.HEXAGON:((t,e,i,n)=>{((t,e,i,n,s)=>{t.beginPath(),t.moveTo(e+n,i);const o=2*Math.PI/s;for(let r=1;r{t.beginPath(),t.arc(e,i,n,0,2*Math.PI,!1),t.closePath()})(t,i.x,i.y,n)}},so=(t,e=300)=>{let i=0,n=null;return function(){const s=arguments,o=Date.now(),r=e-(o-i);r<=0?(n&&(clearTimeout(n),n=null),i=o,t(...s)):n||(n=setTimeout(()=>{i=Date.now(),n=null,t(...s)},r))}},oo=t=>{const e=Math.max(t,1);return Math.round(1e3/e)},ro=(t,e=!1)=>{t.style.position="relative";const i=getComputedStyle(t);i.display||(t.style.display="block",console.warn("[Orb] Graph container doesn't have defined 'display' property. Setting 'display' to 'block'...")),!e&&ho(i.width)&&(t.style.width="100%",ho(getComputedStyle(t).width)?(t.style.width="400px",console.warn("[Orb] The graph container element and its parent don't have defined width properties.","If you are using percentage values,","please make sure that the parent element of the graph container has a defined position and width.","Setting the width of the graph container to an arbitrary value of '400px'...")):console.warn("[Orb] The graph container element doesn't have defined width. Setting width to 100%...")),!e&&ho(i.height)&&(t.style.height="100%",ho(getComputedStyle(t).height)?(t.style.height="400px",console.warn("[Orb] The graph container element and its parent don't have defined height properties.","If you are using percentage values,","please make sure that the parent element of the graph container has a defined position and height.","Setting the height of the graph container to an arbitrary value of '400px'...")):console.warn("[Orb] Graph container doesn't have defined height. Setting height to 100%..."))},ao=/^\s*0+\s*(?:px|rem|em|vh|vw)?\s*$/i,ho=t=>null==t||""===t||ao.test(t),lo=t=>{const e=document.createElement("canvas");return e.style.position="absolute",e.style.top="0",e.style.left="0",t.appendChild(e),e},uo=t=>{let e=window.devicePixelRatio,i=()=>{};const n=()=>{i();const s=matchMedia(`(resolution: ${e}dppx)`);s.addEventListener("change",n),i=()=>s.removeEventListener("change",n),window.devicePixelRatio!==e&&(e=window.devicePixelRatio,t(e))};return n(),()=>i()};class co extends t{constructor(t,e){super(),this._isOriginCentered=!1,this._isInitiallyRendered=!1,ro(t,null==e?void 0:e.areCollapsedContainerDimensionsAllowed),this._container=t,this._canvas=lo(t);const i=this._canvas.getContext("2d");if(!i)throw new o("Failed to create Canvas context.");this._context=i,this._width=640,this._height=480,this.transform=wn,this._settings=Object.assign(Object.assign({},zs),e),this._resizeObs=new ResizeObserver(()=>this._resize()),this._resizeObs.observe(this._container),this._resize(),d(null==e?void 0:e.devicePixelRatio)||(this._dprObserveUnsubscribe=uo(()=>this._resize())),this._throttleRender=so(t=>{this._render(t)},oo(this._settings.fps))}get width(){return this._width}get height(){return this._height}get container(){return this._container}get canvas(){return this._canvas}get isInitiallyRendered(){return this._isInitiallyRendered}getSettings(){return p(this._settings)}setSettings(t){var e;const i=t.fps&&t.fps!==this._settings.fps,n=this._settings.devicePixelRatio,s=t.devicePixelRatio;this._settings=Object.assign(Object.assign({},this._settings),t),i&&(this._throttleRender=so(t=>{this._render(t)},oo(this._settings.fps))),!d(n)&&d(s)&&(null===(e=this._dprObserveUnsubscribe)||void 0===e||e.call(this),this._resize()),d(n)&&null===s&&(this._dprObserveUnsubscribe=uo(()=>this._resize()))}render(t){this._throttleRender(t)}_render(t){this.emit(Bs.RENDER_START,void 0);const e=Date.now();this._context.clearRect(0,0,this._width,this._height),this._settings.backgroundColor&&(this._context.fillStyle=this._settings.backgroundColor.toString(),this._context.fillRect(0,0,this._width,this._height)),this._context.save(),this._context.translate(this.transform.x,this.transform.y),this._context.scale(this.transform.k,this.transform.k),this._isOriginCentered&&this._context.translate(this._width/2,this._height/2),this.drawObjects(t.getEdges()),this.drawObjects(t.getNodes()),this._context.restore(),this.emit(Bs.RENDER_END,{durationMs:Date.now()-e}),this._isInitiallyRendered=!0}drawObjects(t){if(0===t.length)return;const e=[],i=[];for(let n=0;n{var n,s;const o=null===(n=null==i?void 0:i.isShadowEnabled)||void 0===n||n,r=null===(s=null==i?void 0:i.isLabelEnabled)||void 0===s||s,a=e.hasShadow();((t,e)=>{if(e.hasBorder()){t.lineWidth=e.getBorderWidth();const i=e.getBorderColor();i&&(t.strokeStyle=i.toString())}const i=e.getColor();i&&(t.fillStyle=i.toString())})(t,e),o&&a&&((t,e)=>{const i=e.getStyle();i.shadowColor&&(t.shadowColor=i.shadowColor.toString()),i.shadowSize&&(t.shadowBlur=i.shadowSize),i.shadowOffsetX&&(t.shadowOffsetX=i.shadowOffsetX),i.shadowOffsetY&&(t.shadowOffsetY=i.shadowOffsetY)})(t,e),no(t,e),t.fill();const h=e.getBackgroundImage();h&&((t,e,i)=>{if(!i.width||!i.height)return;const n=e.getCenter(),s=e.getRadius(),o=Math.max(2*s/i.width,2*s/i.height),r=i.height*o,a=i.width*o;t.save(),t.clip(),t.drawImage(i,n.x-a/2,n.y-r/2,a,r),t.restore()})(t,e,h),o&&a&&((t,e)=>{const i=e.getStyle();i.shadowColor&&(t.shadowColor="rgba(0,0,0,0)"),i.shadowSize&&(t.shadowBlur=0),i.shadowOffsetX&&(t.shadowOffsetX=0),i.shadowOffsetY&&(t.shadowOffsetY=0)})(t,e),e.hasBorder()&&t.stroke(),r&&((t,e)=>{const i=e.getLabel();if(!i)return;const n=e.getCenter(),s=1.2*e.getBorderedRadius(),o=e.getStyle(),r=new js(i,{position:{x:n.x,y:n.y+s},textBaseline:Fs.TOP,properties:{fontBackgroundColor:o.fontBackgroundColor,fontColor:o.fontColor,fontFamily:o.fontFamily,fontSize:o.fontSize}});Ws(t,r)})(t,e)})(this._context,t,e):((t,e,i)=>{var n,s;if(!e.getWidth())return;const o=null===(n=null==i?void 0:i.isShadowEnabled)||void 0===n||n,r=null===(s=null==i?void 0:i.isLabelEnabled)||void 0===s||s,a=e.hasShadow();((t,e)=>{const i=e.getWidth();i>0&&(t.lineWidth=i);const n=e.getColor();n&&(t.strokeStyle=n.toString(),t.fillStyle=n.toString())})(t,e),o&&a&&((t,e)=>{const i=e.getStyle();i.shadowColor&&(t.shadowColor=i.shadowColor.toString()),i.shadowSize&&(t.shadowBlur=i.shadowSize),i.shadowOffsetX&&(t.shadowOffsetX=i.shadowOffsetX),i.shadowOffsetY&&(t.shadowOffsetY=i.shadowOffsetY)})(t,e),((t,e)=>{if(0===e.getStyle().arrowSize)return;const i=eo(e),n=io([{x:0,y:0},{x:-1,y:.4},{x:-1,y:-.4}],i);t.beginPath();for(let e=0;e{if(e instanceof O)return((t,e)=>{const i=e.startNode.getCenter(),n=e.endNode.getCenter();if(!i||!n)return;t.beginPath(),t.moveTo(i.x,i.y),t.lineTo(n.x,n.y);const s=e.getLineDashPattern();t.setLineDash(null!=s?s:[]),t.stroke()})(t,e);if(e instanceof k)return((t,e)=>{const i=e.startNode.getCenter(),n=e.endNode.getCenter();if(!i||!n)return;const s=e.getCurvedControlPoint();t.beginPath(),t.moveTo(i.x,i.y),t.quadraticCurveTo(s.x,s.y,n.x,n.y);const o=e.getLineDashPattern();t.setLineDash(null!=o?o:[]),t.stroke()})(t,e);if(e instanceof B)return((t,e)=>{const{x:i,y:n,radius:s}=e.getCircularData();t.beginPath(),t.arc(i,n,s,0,2*Math.PI,!1),t.closePath();const o=e.getLineDashPattern();t.setLineDash(null!=o?o:[]),t.stroke()})(t,e);throw new Error("Failed to draw unsupported edge type")})(t,e),o&&a&&((t,e)=>{const i=e.getStyle();i.shadowColor&&(t.shadowColor="rgba(0,0,0,0)"),i.shadowSize&&(t.shadowBlur=0),i.shadowOffsetX&&(t.shadowOffsetX=0),i.shadowOffsetY&&(t.shadowOffsetY=0)})(t,e),r&&((t,e)=>{const i=e.getLabel();if(!i)return;const n=e.getStyle(),s=new js(i,{position:e.getCenter(),textBaseline:Fs.MIDDLE,properties:{fontBackgroundColor:n.fontBackgroundColor,fontColor:n.fontColor,fontFamily:n.fontFamily,fontSize:n.fontSize}});Ws(t,s)})(t,e)})(this._context,t,e)}reset(){this.transform=wn,this._context.clearRect(0,0,this._width,this._height),this._context.save()}getFitZoomTransform(t,e){const i=t.getBoundingBox(),n="center"===(null==e?void 0:e.anchorX)?i.x+i.width/2:"end"===(null==e?void 0:e.anchorX)?i.x+i.width:0,s="center"===(null==e?void 0:e.anchorY)?i.y+i.height/2:"end"===(null==e?void 0:e.anchorY)?i.y+i.height:0,o=this.getSimulationViewRectangle(),r=o.height/(i.height*(1+this._settings.fitZoomMargin)),a=o.width/(i.width*(1+this._settings.fitZoomMargin)),h=Math.min(r,a),l=this.transform.k,d=Math.max(Math.min(h*l,this._settings.maxZoom),this._settings.minZoom),u=o.width/2*l*(1-d)-n*d,c=o.height/2*l*(1-d)-s*d;return wn.translate(u,c).scale(d)}getSimulationPosition(t){const[e,i]=this.transform.invert([t.x,t.y]);return{x:e-this._width/2,y:i-this._height/2}}getSimulationViewRectangle(){const t=this.getSimulationPosition({x:0,y:0}),e=this.getSimulationPosition({x:this._width,y:this._height});return{x:t.x,y:t.y,width:e.x-t.x,height:e.y-t.y}}translateOriginToCenter(){this._isOriginCentered=!0}destroy(){var t;this._resizeObs.unobserve(this._container),null===(t=this._dprObserveUnsubscribe)||void 0===t||t.call(this),this.removeAllListeners(),this._canvas.remove()}}const _o=(t,e,i)=>{const n=as(t,e,rs.VERTEX),s=as(t,i,rs.FRAGMENT),r=t.createProgram();if(!r)throw new o("Failed to create GL program.");if(t.attachShader(r,n),t.attachShader(r,s),t.linkProgram(r),!t.getProgramParameter(r,t.LINK_STATUS)){const e=t.getProgramInfoLog(r);throw t.deleteProgram(r),new o(`Failed to link GL program: ${e}`)}return t.deleteShader(n),t.deleteShader(s),r},fo=2048,go=2048;class po{constructor(t){this._texture=null,this._cache=new Map,this._shelves=[],this._isDirty=!1,this._isTextureAllocated=!1,this._gl=t,this._canvas=document.createElement("canvas"),this._canvas.width=fo,this._canvas.height=go,this._ctx=this._canvas.getContext("2d",{willReadFrequently:!1}),this._texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this._texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.bindTexture(t.TEXTURE_2D,null)}getOrCreate(t,e,i,n,s){const o=`${t}|${e}|${i}|${n}|${null!=s?s:""}`,r=this._cache.get(o);if(r)return r;const a=t.split("\n").map(t=>t.trim());if(0===a.length||1===a.length&&""===a[0])return null;const h=this._ctx,l=`48px ${i}`;h.font=l;let d=0;for(let t=0;td&&(d=e)}const u=48*1.2,c=48+(a.length-1)*u,_=Math.ceil(d+11.52)+4,f=Math.ceil(c+11.52)+4,g=this._allocate(_,f);if(!g)return null;const p=g.x+2,m=g.y+2;s&&(h.fillStyle=s,h.fillRect(p,m,_-4,f-4)),h.font=l,h.fillStyle=n,h.textBaseline="top",h.textAlign="center";const v=p+(_-4)/2;for(let t=0;tgo)return null;const n={y:i,height:e,x:t};return this._shelves.push(n),{x:0,y:i}}}const mo=2048,vo=2048;class yo{constructor(t){this._texture=null,this._cache=new Map,this._pending=new Map,this._shelves=[],this._isDirty=!1,this._isTextureAllocated=!1,this._gl=t,this._canvas=document.createElement("canvas"),this._canvas.width=mo,this._canvas.height=vo,this._ctx=this._canvas.getContext("2d",{willReadFrequently:!1}),this._texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this._texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.bindTexture(t.TEXTURE_2D,null)}getOrCreate(t){const e=this._cache.get(t);if(e)return e;const i=this._pending.get(t);if(i)return i.loaded?this._packImage(t,i.image):null;const n=new Image;n.crossOrigin="anonymous";const s={image:n,loaded:!1};return this._pending.set(t,s),n.onload=()=>{s.loaded=!0},n.onerror=()=>{this._pending.delete(t)},n.src=t,null}bind(t){const e=this._gl;e.activeTexture(e.TEXTURE0+t),e.bindTexture(e.TEXTURE_2D,this._texture)}uploadIfDirty(){if(!this._isDirty)return;const t=this._gl;t.bindTexture(t.TEXTURE_2D,this._texture),this._isTextureAllocated||(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,mo,vo,0,t.RGBA,t.UNSIGNED_BYTE,null),this._isTextureAllocated=!0),t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this._canvas),t.bindTexture(t.TEXTURE_2D,null),this._isDirty=!1}clear(){this._cache.clear(),this._pending.clear(),this._shelves=[],this._isDirty=!1,this._ctx.clearRect(0,0,mo,vo)}_packImage(t,e){if(!e.naturalWidth||!e.naturalHeight)return null;const i=e.naturalWidth/e.naturalHeight;let n,s;e.naturalWidth>=e.naturalHeight?(n=Math.min(e.naturalWidth,128),s=Math.round(n/i)):(s=Math.min(e.naturalHeight,128),n=Math.round(s*i));const o=n+4,r=s+4,a=this._allocate(o,r);if(!a)return null;this._ctx.drawImage(e,a.x+2,a.y+2,n,s);const h={u0:(a.x+2)/mo,v0:(a.y+2)/vo,u1:(a.x+2+n)/mo,v1:(a.y+2+s)/vo,aspect:i};return this._cache.set(t,h),this._pending.delete(t),this._isDirty=!0,h}_allocate(t,e){for(let i=0;ivo)return null;const n={y:i,height:e,x:t};return this._shelves.push(n),{x:0,y:i}}}const xo=[0,0,0,0],bo=[.6,.6,.6,1],So=[1,0,0,1],wo={[S.CIRCLE]:0,[S.DOT]:1,[S.SQUARE]:2,[S.DIAMOND]:3,[S.TRIANGLE]:4,[S.TRIANGLE_DOWN]:5,[S.STAR]:6,[S.HEXAGON]:7},To="Roboto, sans-serif",Eo="#000000";class Po extends t{constructor(t,e){super(),this._isOriginCentered=!1,this._isInitiallyRendered=!1,this._nodeProgram=null,this._edgeProgram=null,this._labelProgram=null,this._nodeVao=null,this._edgeVao=null,this._labelVao=null,this._nodeInstanceBuffer=null,this._edgeInstanceBuffer=null,this._labelInstanceBuffer=null,this._labelCache=null,this._imageAtlas=null,this._isColorCacheDirty=!0,this._nodeColorCache=new Map,this._nodeBorderColorCache=new Map,this._nodeShadowColorCache=new Map,this._edgeColorCache=new Map,this._edgeShadowColorCache=new Map,this._lastNodeCount=0,this._lastEdgeCount=0,this._edgeInstanceData=null,this._nodeInstanceData=null,this._buffersAreCurrent=!1,this._bufferCacheStats={hits:0,misses:0},this._timerExt=null,this._timerEdgeQueries=[],this._timerNodeQueries=[],this._timerQueryIdx=0,this._lastEdgeGpuMs=null,this._lastNodeGpuMs=null,ro(t,null==e?void 0:e.areCollapsedContainerDimensionsAllowed),this._container=t,this._canvas=lo(t);const i=this._canvas.getContext("webgl2",{antialias:!0});if(!i)throw new o("Failed to create WebGL context.");if(this._gl=i,this._width=640,this._height=480,this.transform=wn,this._settings=Object.assign(Object.assign({},zs),e),"number"!=typeof(null==e?void 0:e.devicePixelRatio)&&(this._dprObserveUnsubscribe=uo(()=>{this._isInitiallyRendered&&this.emit(Bs.RESIZE,void 0)})),this._initShaders(),this._initNodeBuffers(),this._initEdgeBuffers(),this._initLabelBuffers(),this._labelCache=new po(this._gl),this._imageAtlas=new yo(this._gl),this._timerExt=i.getExtension("EXT_disjoint_timer_query_webgl2"),this._timerExt)for(let t=0;t<4;t++){const t=i.createQuery(),e=i.createQuery();t&&this._timerEdgeQueries.push(t),e&&this._timerNodeQueries.push(e)}}_pollTimerQuery(t){if(!this._timerExt)return null;const e=this._gl;return e.getQueryParameter(t,e.QUERY_RESULT_AVAILABLE)?e.getParameter(this._timerExt.GPU_DISJOINT_EXT)?null:e.getQueryParameter(t,e.QUERY_RESULT)/1e6:null}getGpuTimeStats(){return{edgeMs:this._lastEdgeGpuMs,nodeMs:this._lastNodeGpuMs,supported:null!==this._timerExt}}_initShaders(){this._nodeProgram=_o(this._gl,"#version 300 es\n\nprecision highp float;\n\nin vec2 aQuadPosition;\n\nin vec2 aCenter;\nin float aRadius;\nin vec4 aColor;\nin vec4 aBorderColor;\nin float aBorderWidth;\nin vec4 aShadowColor;\nin float aShadowSize;\nin float aShadowOffsetX;\nin float aShadowOffsetY;\nin float aShapeType;\nin vec2 aImageUV0;\nin vec2 aImageUV1;\nin float aImageAspect;\n\nuniform vec2 uResolution;\nuniform vec2 uTranslation;\nuniform float uScale;\nuniform vec2 uOriginOffset;\n\nout vec2 vUV;\nout vec4 vColor;\nout vec4 vBorderColor;\nout float vBorderThreshold;\nout vec4 vShadowColor;\nout float vNodeRadius;\nout vec2 vShadowOffset;\nout float vShadowBlur;\nflat out int vShapeType;\nout vec2 vImageUV0;\nout vec2 vImageUV1;\nout float vImageAspect;\n\nvoid main() {\n vShapeType = int(aShapeType + 0.5);\n vColor = aColor;\n vBorderColor = aBorderColor;\n vShadowColor = aShadowColor;\n vImageUV0 = aImageUV0;\n vImageUV1 = aImageUV1;\n vImageAspect = aImageAspect;\n\n float totalRadius = aRadius + aShadowSize + abs(aShadowOffsetX) + abs(aShadowOffsetY);\n\n vUV = aQuadPosition;\n vNodeRadius = aRadius / totalRadius;\n\n vBorderThreshold = vNodeRadius * (1.0 - aBorderWidth / aRadius);\n\n vShadowOffset = vec2(aShadowOffsetX, aShadowOffsetY) / totalRadius;\n\n vShadowBlur = aShadowSize / totalRadius;\n\n vec2 worldPos = aCenter + aQuadPosition * totalRadius;\n vec2 screenPos = (worldPos + uOriginOffset) * uScale + uTranslation;\n\n vec2 clip = (screenPos / uResolution) * 2.0 - 1.0;\n gl_Position = vec4(clip.x, -clip.y, 0.0, 1.0);\n}\n","#version 300 es\n\nprecision highp float;\n\nin vec2 vUV;\nin vec4 vColor;\nin vec4 vBorderColor;\nin float vBorderThreshold;\nin vec4 vShadowColor;\nin float vNodeRadius;\nin vec2 vShadowOffset;\nin float vShadowBlur;\nflat in int vShapeType;\nin vec2 vImageUV0;\nin vec2 vImageUV1;\nin float vImageAspect;\n\nuniform sampler2D uImageAtlas;\n\nout vec4 fragColor;\n\nconst int SHAPE_CIRCLE = 0;\nconst int SHAPE_DOT = 1;\nconst int SHAPE_SQUARE = 2;\nconst int SHAPE_DIAMOND = 3;\nconst int SHAPE_TRIANGLE = 4;\nconst int SHAPE_TRIANGLE_DOWN = 5;\nconst int SHAPE_STAR = 6;\nconst int SHAPE_HEXAGON = 7;\n\nfloat sdCircle(vec2 p, float r) {\n return length(p) - r;\n}\n\nfloat sdSquare(vec2 p, float r) {\n vec2 d = abs(p) - vec2(r);\n return max(d.x, d.y);\n}\n\nfloat sdDiamond(vec2 p, float r) {\n return (abs(p.x) + abs(p.y)) - r;\n}\n\nfloat sdTriangleDown(vec2 p, float r) {\n float sr = r * 1.15;\n vec2 q = vec2(p.x, p.y - 0.275 * sr);\n\n float k = sqrt(3.0);\n q.x = abs(q.x) - sr;\n q.y = q.y + sr / k;\n if (q.x + k * q.y > 0.0) {\n q = vec2(q.x - k * q.y, -k * q.x - q.y) / 2.0;\n }\n q.x -= clamp(q.x, -2.0 * sr, 0.0);\n return -length(q) * sign(q.y);\n}\n\nfloat sdTriangleUp(vec2 p, float r) {\n return sdTriangleDown(vec2(p.x, -p.y), r);\n}\n\nfloat sdStar(vec2 p, float r) {\n float sr = r * 0.82;\n vec2 q = vec2(p.x, p.y - 0.1 * sr);\n\n float outerR = sr * 1.3;\n float innerR = sr * 0.5;\n\n float angle = atan(q.x, -q.y);\n float sector = 6.2831853 / 5.0;\n float a = mod(angle + sector * 0.5, sector) - sector * 0.5;\n\n float cosA = cos(a);\n float sinA = abs(sin(a));\n\n float halfSector = sector * 0.5;\n vec2 outerPt = vec2(outerR, 0.0);\n vec2 innerPt = vec2(innerR * cos(halfSector), innerR * sin(halfSector));\n\n vec2 sp = vec2(cosA, sinA) * length(q);\n\n vec2 edge = innerPt - outerPt;\n vec2 toP = sp - outerPt;\n float t = clamp(dot(toP, edge) / dot(edge, edge), 0.0, 1.0);\n float dist = length(toP - edge * t);\n\n float cross2d = edge.x * toP.y - edge.y * toP.x;\n return cross2d > 0.0 ? -dist : dist;\n}\n\nfloat sdHexagon(vec2 p, float r) {\n vec2 q = abs(p);\n float k = sqrt(3.0);\n float d = max(q.x, (q.x * 0.5 + q.y * (k * 0.5)));\n return d - r;\n}\n\nfloat shapeSDF(vec2 p, float r, int shapeType) {\n if (shapeType == SHAPE_SQUARE) return sdSquare(p, r);\n if (shapeType == SHAPE_DIAMOND) return sdDiamond(p, r);\n if (shapeType == SHAPE_TRIANGLE) return sdTriangleUp(p, r);\n if (shapeType == SHAPE_TRIANGLE_DOWN) return sdTriangleDown(p, r);\n if (shapeType == SHAPE_STAR) return sdStar(p, r);\n if (shapeType == SHAPE_HEXAGON) return sdHexagon(p, r);\n\n return sdCircle(p, r);\n}\n\nvoid main() {\n // Body SDF - always needed.\n float dist = shapeSDF(vUV, vNodeRadius, vShapeType);\n\n float aa = 0.02 * vNodeRadius;\n float nodeAlpha = 1.0 - smoothstep(-aa, 0.0, dist);\n\n // Shadow SDF - skip entirely when no shadow. Avoids a second full shapeSDF() call\n // (which is a cascade of ifs) and the exp() per fragment.\n float shadowAlpha = 0.0;\n if (vShadowBlur > 0.0) {\n float shadowDist = shapeSDF(vUV - vShadowOffset, vNodeRadius, vShapeType);\n float t = max(shadowDist, 0.0) / vShadowBlur;\n shadowAlpha = exp(-t * t * 1.5) * 0.5 * vShadowColor.a;\n }\n\n vec4 fillColor = vColor;\n if (vImageAspect > 0.0 && dist < 0.0) {\n vec2 uv01 = (vUV / vNodeRadius) * 0.5 + 0.5;\n if (vImageAspect > 1.0) {\n uv01.x = (uv01.x - 0.5) / vImageAspect + 0.5;\n } else {\n uv01.y = (uv01.y - 0.5) * vImageAspect + 0.5;\n }\n if (uv01.x >= 0.0 && uv01.x <= 1.0 && uv01.y >= 0.0 && uv01.y <= 1.0) {\n vec2 atlasUV = mix(vImageUV0, vImageUV1, uv01);\n vec4 imgTexel = texture(uImageAtlas, atlasUV);\n fillColor = mix(fillColor, vec4(imgTexel.rgb, 1.0), imgTexel.a);\n }\n }\n\n vec4 nodeColor;\n if (vBorderThreshold < vNodeRadius) {\n float borderDist = shapeSDF(vUV, vBorderThreshold, vShapeType);\n float borderMix = smoothstep(-aa, aa, borderDist);\n nodeColor = mix(fillColor, vBorderColor, borderMix);\n } else {\n nodeColor = fillColor;\n }\n nodeColor.a *= nodeAlpha;\n\n float finalAlpha = nodeColor.a + shadowAlpha * (1.0 - nodeColor.a);\n\n if (finalAlpha < 0.001) {\n discard;\n }\n\n if (shadowAlpha > 0.0) {\n vec3 finalRGB = (nodeColor.rgb * nodeColor.a + vShadowColor.rgb * shadowAlpha * (1.0 - nodeColor.a)) / finalAlpha;\n fragColor = vec4(finalRGB, finalAlpha);\n } else {\n fragColor = nodeColor;\n }\n}\n"),this._edgeProgram=_o(this._gl,"#version 300 es\n\nprecision highp float;\n\nin vec2 aQuadPosition;\n\nin vec2 aStart;\nin vec2 aEnd;\nin vec2 aControl;\nin float aWidth;\nin float aEdgeType;\nin float aLoopbackRadius;\nin float aArrowSize;\nin vec2 aArrowTip;\nin vec2 aArrowDir;\nin vec4 aColor;\nin vec4 aShadowColor;\nin float aShadowSize;\nin float aShadowOffsetX;\nin float aShadowOffsetY;\n\nuniform vec2 uResolution;\nuniform vec2 uTranslation;\nuniform float uScale;\nuniform vec2 uOriginOffset;\n\nout vec2 vWorldPos;\nout vec2 vStart;\nout vec2 vEnd;\nout vec2 vControl;\nout float vHalfWidth;\nout float vWidthFade;\nout float vHalfWidthPx;\nout float vPerpPx;\nout float vLoopbackRadius;\nout float vArrowSize;\nout vec2 vArrowTip;\nout vec2 vArrowDir;\nout vec4 vColor;\nout vec4 vShadowColor;\nout float vShadowSize;\nout vec2 vShadowOffset;\nflat out int vEdgeType;\n\nvoid main() {\n vEdgeType = int(aEdgeType + 0.5);\n vStart = aStart;\n vEnd = aEnd;\n vControl = aControl;\n float effectiveWidth = max(aWidth, 1.0 / uScale);\n vHalfWidth = effectiveWidth * 0.5;\n vWidthFade = clamp(aWidth * uScale, 0.0, 1.0);\n vHalfWidthPx = vHalfWidth * uScale;\n vPerpPx = 0.0;\n vLoopbackRadius = aLoopbackRadius;\n vArrowSize = aArrowSize;\n vArrowTip = aArrowTip;\n vArrowDir = aArrowDir;\n vColor = aColor;\n vShadowColor = aShadowColor;\n vShadowSize = aShadowSize;\n vShadowOffset = vec2(aShadowOffsetX, aShadowOffsetY);\n\n float pad = vHalfWidth + aShadowSize + abs(aShadowOffsetX) + abs(aShadowOffsetY);\n\n vec2 worldPos;\n\n if (vEdgeType == 0) {\n vec2 dir = aEnd - aStart;\n float len = length(dir);\n vec2 unitDir = dir / max(len, 0.0001);\n vec2 perp = vec2(-unitDir.y, unitDir.x);\n float totalHalf = pad + aArrowSize;\n vec2 midpoint = (aStart + aEnd) * 0.5;\n worldPos = midpoint\n + unitDir * (len * 0.5 + totalHalf) * aQuadPosition.x\n + perp * totalHalf * aQuadPosition.y;\n vPerpPx = totalHalf * aQuadPosition.y * uScale;\n } else if (vEdgeType == 1) {\n float margin = pad + aArrowSize;\n vec2 bboxMin = min(min(aStart, aEnd), aControl) - margin;\n vec2 bboxMax = max(max(aStart, aEnd), aControl) + margin;\n vec2 center = (bboxMin + bboxMax) * 0.5;\n vec2 halfSize = (bboxMax - bboxMin) * 0.5;\n worldPos = center + aQuadPosition * halfSize;\n } else {\n float margin = pad + aArrowSize;\n vec2 ctr = aControl;\n float r = aLoopbackRadius;\n vec2 bboxMin = min(ctr - (r + margin), aStart - margin);\n vec2 bboxMax = max(ctr + (r + margin), aStart + margin);\n vec2 center = (bboxMin + bboxMax) * 0.5;\n vec2 halfSize = (bboxMax - bboxMin) * 0.5;\n worldPos = center + aQuadPosition * halfSize;\n }\n\n vWorldPos = worldPos;\n vec2 screenPos = (worldPos + uOriginOffset) * uScale + uTranslation;\n vec2 clip = (screenPos / uResolution) * 2.0 - 1.0;\n gl_Position = vec4(clip.x, -clip.y, 0.0, 1.0);\n}\n","#version 300 es\n\nprecision highp float;\n\nin vec2 vWorldPos;\nin vec2 vStart;\nin vec2 vEnd;\nin vec2 vControl;\nin float vHalfWidth;\nin float vWidthFade;\nin float vHalfWidthPx;\nin float vPerpPx;\nin float vLoopbackRadius;\nin float vArrowSize;\nin vec2 vArrowTip;\nin vec2 vArrowDir;\nin vec4 vColor;\nin vec4 vShadowColor;\nin float vShadowSize;\nin vec2 vShadowOffset;\nflat in int vEdgeType;\n\nuniform bool uSimpleMode;\n\nout vec4 fragColor;\n\nfloat sdSegment(vec2 p, vec2 a, vec2 b) {\n vec2 pa = p - a;\n vec2 ba = b - a;\n float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);\n return length(pa - ba * h);\n}\n\nfloat sdBezier(vec2 pos, vec2 A, vec2 B, vec2 C) {\n vec2 a = B - A;\n vec2 b = A - 2.0 * B + C;\n vec2 c = a * 2.0;\n vec2 d = A - pos;\n\n float kk = 1.0 / max(dot(b, b), 0.0001);\n float kx = kk * dot(a, b);\n float ky = kk * (2.0 * dot(a, a) + dot(d, b)) / 3.0;\n float kz = kk * dot(d, a);\n\n float p = ky - kx * kx;\n float q = kx * (2.0 * kx * kx - 3.0 * ky) + kz;\n float p3 = p * p * p;\n float q2 = q * q;\n float h = q2 + 4.0 * p3;\n\n float res;\n if (h >= 0.0) {\n h = sqrt(h);\n vec2 x = (vec2(h, -h) - q) / 2.0;\n vec2 uv = sign(x) * pow(abs(x), vec2(1.0 / 3.0));\n float t = clamp(uv.x + uv.y - kx, 0.0, 1.0);\n vec2 qo = d + (c + b * t) * t;\n res = dot(qo, qo);\n } else {\n float z = sqrt(-p);\n float v = acos(q / (p * z * 2.0)) / 3.0;\n float m = cos(v);\n float n = sin(v) * 1.732050808;\n vec3 t = clamp(vec3(m + m, -n - m, n - m) * z - kx, 0.0, 1.0);\n vec2 qx = d + (c + b * t.x) * t.x;\n float dx = dot(qx, qx);\n vec2 qy = d + (c + b * t.y) * t.y;\n float dy = dot(qy, qy);\n res = min(dx, dy);\n }\n\n return sqrt(res);\n}\n\nfloat sdArrow(vec2 p, vec2 tip, vec2 dir, float size) {\n if (size <= 0.0) return 1e6;\n\n vec2 perp = vec2(-dir.y, dir.x);\n vec2 rel = p - tip;\n float along = dot(rel, -dir);\n float across = dot(rel, perp);\n\n if (along < 0.0) return length(rel);\n if (along > size) {\n float hw = size * 0.4;\n float closest = clamp(across, -hw, hw);\n vec2 pt = tip - dir * size + perp * closest;\n return length(p - pt);\n }\n\n float halfW = (along / size) * size * 0.4;\n float d = abs(across) - halfW;\n return d;\n}\n\nvoid main() {\n if (uSimpleMode && vEdgeType == 0) {\n float cover = clamp(vHalfWidthPx - abs(vPerpPx) + 0.5, 0.0, 1.0);\n float a = cover * vWidthFade;\n if (a < 0.001) discard;\n fragColor = vec4(vColor.rgb, vColor.a * a);\n return;\n }\n\n float dist;\n if (vEdgeType == 0) {\n dist = sdSegment(vWorldPos, vStart, vEnd);\n } else if (vEdgeType == 1) {\n dist = sdBezier(vWorldPos, vStart, vControl, vEnd);\n } else {\n dist = abs(length(vWorldPos - vControl) - vLoopbackRadius);\n }\n\n float edgeSdf = dist - vHalfWidth;\n float combinedSdf = edgeSdf;\n\n if (vArrowSize > 0.0) {\n float arrowDist = sdArrow(vWorldPos, vArrowTip, vArrowDir, vArrowSize);\n combinedSdf = min(edgeSdf, arrowDist);\n }\n\n float shadowAlpha = 0.0;\n if (vShadowSize > 0.0) {\n vec2 shadowPos = vWorldPos - vShadowOffset;\n float shadowDist;\n if (vEdgeType == 0) {\n shadowDist = sdSegment(shadowPos, vStart, vEnd);\n } else if (vEdgeType == 1) {\n shadowDist = sdBezier(shadowPos, vStart, vControl, vEnd);\n } else {\n shadowDist = abs(length(shadowPos - vControl) - vLoopbackRadius);\n }\n float shadowArrowDist = vArrowSize > 0.0\n ? sdArrow(shadowPos, vArrowTip, vArrowDir, vArrowSize)\n : 1.0e6;\n float shadowCombined = min(shadowDist - vHalfWidth, shadowArrowDist);\n float t = max(shadowCombined, 0.0) / vShadowSize;\n shadowAlpha = exp(-t * t * 1.5) * 0.5 * vShadowColor.a;\n }\n\n float aa = fwidth(combinedSdf);\n float edgeAlpha = (1.0 - smoothstep(-aa, aa, combinedSdf)) * vWidthFade;\n vec4 edgeColor = vColor;\n edgeColor.a *= edgeAlpha;\n\n float finalAlpha = edgeColor.a + shadowAlpha * (1.0 - edgeColor.a);\n\n if (finalAlpha < 0.001) discard;\n\n if (shadowAlpha > 0.0) {\n vec3 finalRGB = (edgeColor.rgb * edgeColor.a + vShadowColor.rgb * shadowAlpha * (1.0 - edgeColor.a)) / finalAlpha;\n fragColor = vec4(finalRGB, finalAlpha);\n } else {\n fragColor = edgeColor;\n }\n}\n"),this._labelProgram=_o(this._gl,"#version 300 es\n\nin vec2 aQuadPosition;\n\nin vec2 aLabelCenter;\nin vec2 aLabelSize;\nin vec2 aLabelUV0;\nin vec2 aLabelUV1;\n\nuniform vec2 uResolution;\nuniform vec2 uTranslation;\nuniform float uScale;\nuniform vec2 uOriginOffset;\n\nout vec2 vAtlasUV;\n\nvoid main() {\n vec2 worldPos = aLabelCenter + aQuadPosition * aLabelSize;\n vec2 screenPos = (worldPos + uOriginOffset) * uScale + uTranslation;\n vec2 clip = (screenPos / uResolution) * 2.0 - 1.0;\n gl_Position = vec4(clip.x, -clip.y, 0.0, 1.0);\n\n vec2 uv01 = aQuadPosition * 0.5 + 0.5;\n vAtlasUV = mix(aLabelUV0, aLabelUV1, uv01);\n}\n","#version 300 es\n\nprecision highp float;\n\nuniform sampler2D uAtlas;\n\nin vec2 vAtlasUV;\n\nout vec4 fragColor;\n\nvoid main() {\n vec4 texel = texture(uAtlas, vAtlasUV);\n if (texel.a < 0.01) discard;\n fragColor = texel;\n}\n")}_initNodeBuffers(){if(!this._nodeProgram)throw new o("Node program not initialized.");const t=this._gl;this._nodeVao=t.createVertexArray(),t.bindVertexArray(this._nodeVao);const e=new Float32Array([-1,-1,1,-1,-1,1,1,1]),i=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW);const n=t.getAttribLocation(this._nodeProgram,"aQuadPosition");t.enableVertexAttribArray(n),t.vertexAttribPointer(n,2,t.FLOAT,!1,0,0),this._nodeInstanceBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this._nodeInstanceBuffer);const s=25*Float32Array.BYTES_PER_ELEMENT,r=(e,i,n)=>{const o=t.getAttribLocation(this._nodeProgram,e);t.enableVertexAttribArray(o),t.vertexAttribPointer(o,i,t.FLOAT,!1,s,4*n),t.vertexAttribDivisor(o,1)};r("aCenter",2,0),r("aRadius",1,2),r("aColor",4,3),r("aBorderColor",4,7),r("aBorderWidth",1,11),r("aShadowColor",4,12),r("aShadowSize",1,16),r("aShadowOffsetX",1,17),r("aShadowOffsetY",1,18),r("aShapeType",1,19),r("aImageUV0",2,20),r("aImageUV1",2,22),r("aImageAspect",1,24),t.bindVertexArray(null)}_initEdgeBuffers(){if(!this._edgeProgram)throw new o("Edge program not initialized.");const t=this._gl;this._edgeVao=t.createVertexArray(),t.bindVertexArray(this._edgeVao);const e=new Float32Array([-1,-1,1,-1,-1,1,1,1]),i=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW);const n=t.getAttribLocation(this._edgeProgram,"aQuadPosition");t.enableVertexAttribArray(n),t.vertexAttribPointer(n,2,t.FLOAT,!1,0,0),this._edgeInstanceBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this._edgeInstanceBuffer);const s=(e,i,n)=>{const s=t.getAttribLocation(this._edgeProgram,e);t.enableVertexAttribArray(s),t.vertexAttribPointer(s,i,t.FLOAT,!1,100,4*n),t.vertexAttribDivisor(s,1)};s("aStart",2,0),s("aEnd",2,2),s("aControl",2,4),s("aWidth",1,6),s("aEdgeType",1,7),s("aLoopbackRadius",1,8),s("aArrowSize",1,9),s("aArrowTip",2,10),s("aArrowDir",2,12),s("aColor",4,14),s("aShadowColor",4,18),s("aShadowSize",1,22),s("aShadowOffsetX",1,23),s("aShadowOffsetY",1,24),t.bindVertexArray(null)}_initLabelBuffers(){if(!this._labelProgram)throw new o("Label program not initialized.");const t=this._gl;this._labelVao=t.createVertexArray(),t.bindVertexArray(this._labelVao);const e=new Float32Array([-1,-1,1,-1,-1,1,1,1]),i=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,e,t.STATIC_DRAW);const n=t.getAttribLocation(this._labelProgram,"aQuadPosition");t.enableVertexAttribArray(n),t.vertexAttribPointer(n,2,t.FLOAT,!1,0,0),this._labelInstanceBuffer=t.createBuffer(),t.bindBuffer(t.ARRAY_BUFFER,this._labelInstanceBuffer);const s=(e,i,n)=>{const s=t.getAttribLocation(this._labelProgram,e);t.enableVertexAttribArray(s),t.vertexAttribPointer(s,i,t.FLOAT,!1,32,4*n),t.vertexAttribDivisor(s,1)};s("aLabelCenter",2,0),s("aLabelSize",2,2),s("aLabelUV0",2,4),s("aLabelUV1",2,6),t.bindVertexArray(null)}_resolveColor(t){if(!t)return[1,0,0,1];if(t instanceof U)return[t.rgb.r/255,t.rgb.g/255,t.rgb.b/255,1];const e=t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)$/);if(e)return[parseInt(e[1])/255,parseInt(e[2])/255,parseInt(e[3])/255,void 0!==e[4]?parseFloat(e[4]):1];const i=new U(t);return[i.rgb.r/255,i.rgb.g/255,i.rgb.b/255,1]}_buildNodeColorCache(t){this._nodeColorCache.clear();for(let e=0;e0)if(M=1.5*R+3*(w||1),0===E){const t=a-o,e=h-r,i=Math.sqrt(t*t+e*e);i>0&&(I=t/i,L=e/i,N=a-I*l,D=h-L*l)}else if(1===E){let t=1,e=.5,i=1;for(let n=0;n<8;n++){const n=.5*(e+i),s=1-n,d=s*s*o+2*n*s*P+n*n*a,u=s*s*r+2*n*s*A+n*n*h,c=Math.sqrt(Math.pow(d-a,2)+Math.pow(u-h,2));if(Math.abs(c-l)<.1){t=n;break}c>l?e=n:i=n,t=n}const n=1-t;N=n*n*o+2*t*n*P+t*t*a,D=n*n*r+2*t*n*A+t*t*h;const s=2*n*(P-o)+2*t*(a-P),d=2*n*(A-r)+2*t*(h-A),u=Math.sqrt(s*s+d*d);u>0&&(I=s/u,L=d/u)}else{let t=.8,e=.6,i=1;for(let n=0;n<8;n++){const n=.5*(e+i),s=2*n*Math.PI,a=P+C*Math.cos(s),h=A-C*Math.sin(s),l=Math.sqrt(Math.pow(a-o,2)+Math.pow(h-r,2));if(Math.abs(l-d)<.1){t=n;break}l>d?i=n:e=n,t=n}const n=2*t*Math.PI;N=P+C*Math.cos(n),D=A-C*Math.sin(n);const s=-2*t*Math.PI+.45*Math.PI;I=Math.cos(s),L=Math.sin(s)}p[S]=o,p[S+1]=r,p[S+2]=a,p[S+3]=h,p[S+4]=P,p[S+5]=A,p[S+6]=w,p[S+7]=E,p[S+8]=C,p[S+9]=M,p[S+10]=N,p[S+11]=D,p[S+12]=I,p[S+13]=L,p[S+14]=T[0],p[S+15]=T[1],p[S+16]=T[2],p[S+17]=T[3],p[S+18]=m[0],p[S+19]=m[1],p[S+20]=m[2],p[S+21]=m[3],p[S+22]=c,p[S+23]=f,p[S+24]=g}h.useProgram(this._edgeProgram),this._setViewUniforms(this._edgeProgram),h.bindBuffer(h.ARRAY_BUFFER,this._edgeInstanceBuffer),m||(h.bufferData(h.ARRAY_BUFFER,p.byteLength,h.STREAM_DRAW),h.bufferSubData(h.ARRAY_BUFFER,0,p));const w=this.transform.k<=.2,T=h.getUniformLocation(this._edgeProgram,"uSimpleMode");if(h.uniform1i(T,w?1:0),h.bindVertexArray(this._edgeVao),this._timerExt&&this._timerEdgeQueries.length>0){const t=this._timerEdgeQueries[this._timerQueryIdx],e=this._pollTimerQuery(t);null!==e&&(this._lastEdgeGpuMs=e),h.beginQuery(this._timerExt.TIME_ELAPSED_EXT,t)}h.drawArraysInstanced(h.TRIANGLE_STRIP,0,4,_.length),this._timerExt&&this._timerEdgeQueries.length>0&&h.endQuery(this._timerExt.TIME_ELAPSED_EXT),h.bindVertexArray(null),w&&h.enable(h.BLEND),h.useProgram(this._nodeProgram),this._setViewUniforms(this._nodeProgram),this._imageAtlas&&(this._imageAtlas.uploadIfDirty(),this._imageAtlas.bind(0),h.uniform1i(h.getUniformLocation(this._nodeProgram,"uImageAtlas"),0));const E=t.getNodes(),P=this.transform.k,A=25*E.length,C=null===this._nodeInstanceData||this._nodeInstanceData.length!==A;C&&(this._nodeInstanceData=new Float32Array(A));const M=this._nodeInstanceData,N=m&&!C;if(N||E.length===this._lastNodeCount&&!this._isColorCacheDirty||(this._buildNodeColorCache(E),this._buildNodeBorderColorCache(E),this._buildNodeShadowColorCache(E),this._isColorCacheDirty=!1,this._lastNodeCount=E.length),!N)for(let t=0;t=4){const t=e.isSelected()&&r.imageUrlSelected||r.imageUrl;if(t&&this._imageAtlas){const e=this._imageAtlas.getOrCreate(t);e&&(g=e.u0,p=e.v0,m=e.u1,v=e.v1,y=e.aspect)}}M[u+20]=g,M[u+21]=p,M[u+22]=m,M[u+23]=v,M[u+24]=y}if(h.bindBuffer(h.ARRAY_BUFFER,this._nodeInstanceBuffer),N||(h.bufferData(h.ARRAY_BUFFER,M.byteLength,h.STREAM_DRAW),h.bufferSubData(h.ARRAY_BUFFER,0,M)),this._buffersAreCurrent=!0,h.bindVertexArray(this._nodeVao),this._timerExt&&this._timerNodeQueries.length>0){const t=this._timerNodeQueries[this._timerQueryIdx],e=this._pollTimerQuery(t);null!==e&&(this._lastNodeGpuMs=e),h.beginQuery(this._timerExt.TIME_ELAPSED_EXT,t)}if(h.drawArraysInstanced(h.TRIANGLE_STRIP,0,4,E.length),this._timerExt&&this._timerNodeQueries.length>0&&(h.endQuery(this._timerExt.TIME_ELAPSED_EXT),this._timerQueryIdx=(this._timerQueryIdx+1)%this._timerNodeQueries.length),h.bindVertexArray(null),this._labelProgram&&this._labelCache&&this._settings.labelsIsEnabled){const t=this._labelCache,e=t.rasterFontPx;let i=0;const n=E.length+_.length,o=new Float32Array(8*n);for(let n=0;n0&&(t.uploadIfDirty(),h.useProgram(this._labelProgram),this._setViewUniforms(this._labelProgram),t.bind(0),h.uniform1i(h.getUniformLocation(this._labelProgram,"uAtlas"),0),h.bindBuffer(h.ARRAY_BUFFER,this._labelInstanceBuffer),h.bufferData(h.ARRAY_BUFFER,o.subarray(0,8*i),h.DYNAMIC_DRAW),h.bindVertexArray(this._labelVao),h.drawArraysInstanced(h.TRIANGLE_STRIP,0,4,i),h.bindVertexArray(null))}this._isInitiallyRendered=!0,this.emit(Bs.RENDER_END,{durationMs:performance.now()-a})}reset(){this.transform=wn;const t=this._gl;t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT)}getFitZoomTransform(t){const e=t.getBoundingBox(),i=e.x+e.width/2,n=e.y+e.height/2,s=this.getSimulationViewRectangle(),o=s.height/(e.height*(1+this._settings.fitZoomMargin)),r=s.width/(e.width*(1+this._settings.fitZoomMargin)),a=Math.min(o,r),h=this.transform.k,l=Math.max(Math.min(a*h,this._settings.maxZoom),this._settings.minZoom),d=s.width/2*h*(1-l)-i*l,u=s.height/2*h*(1-l)-n*l;return wn.translate(d,u).scale(l)}getSimulationPosition(t){const[e,i]=this.transform.invert([t.x,t.y]);return{x:e-this._width/2,y:i-this._height/2}}getSimulationViewRectangle(){const t=this.getSimulationPosition({x:0,y:0}),e=this.getSimulationPosition({x:this._width,y:this._height});return{x:t.x,y:t.y,width:e.x-t.x,height:e.y-t.y}}translateOriginToCenter(){this._isOriginCentered=!0}destroy(){var t,e;null===(t=this._dprObserveUnsubscribe)||void 0===t||t.call(this),this.removeAllListeners(),null===(e=this._gl.getExtension("WEBGL_lose_context"))||void 0===e||e.loseContext(),this._canvas.remove()}_setViewUniforms(t){const e=this._gl,i=this._isOriginCentered?this._width/2:0,n=this._isOriginCentered?this._height/2:0;e.uniform2f(e.getUniformLocation(t,"uResolution"),this._width,this._height),e.uniform2f(e.getUniformLocation(t,"uTranslation"),this.transform.x,this.transform.y),e.uniform1f(e.getUniformLocation(t,"uScale"),this.transform.k),e.uniform2f(e.getUniformLocation(t,"uOriginOffset"),i,n)}}class Ao{static getRenderer(t,e=ks.CANVAS,i){return e===ks.WEBGL?new Po(t,i):new co(t,i)}}const Co=t=>isFinite(t)?""+Math.round(1e3*t)/1e3:"0",Mo=t=>t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),No=(t,e,i)=>{const n=Object.keys(e).filter(t=>{const i=e[t];return null!=i&&""!==i}).map(t=>{const i=e[t];return`${t}="${"number"==typeof i?Co(i):Mo(String(i))}"`}).join(" "),s=n?`${t} ${n}`:t;return void 0===i?`<${s}/>`:`<${s}>${i}`},Do=t=>t.map(t=>`${Co(t.x)},${Co(t.y)}`).join(" "),Io=t=>({tag:"polygon",attributes:{points:Do(t)}}),Lo=(t,e)=>{var i,n;if(null==t||""==`${t}`)return"";const s=new js(t,{position:e.position,textBaseline:e.textBaseline,properties:e.properties});if(!s.textLines.length||s.fontSize<=0)return"";const o=null!==(i=e.properties.fontFamily)&&void 0!==i?i:"Roboto, sans-serif",r=(null!==(n=e.properties.fontColor)&&void 0!==n?n:"#000000").toString(),a=1.2*s.fontSize,h=e.textBaseline===Fs.MIDDLE?"middle":"text-before-edge",l=Ro(s,a),d=s.textLines.map((t,e)=>No("tspan",{x:s.position.x,dy:0===e?0:a},Mo(t))).join("");return`${l}${No("text",{x:s.position.x,y:s.position.y,"font-size":s.fontSize,"font-family":o,fill:r,"text-anchor":"middle","dominant-baseline":h},d)}`},Ro=(t,e)=>{const i=t.properties.fontBackgroundColor;if(!i)return"";const n=.12*t.fontSize,s=t.fontSize+2*n,o=t.textBaseline===Fs.MIDDLE?t.fontSize/2:0,r=i.toString();return t.textLines.map((i,a)=>{const h=i.length*t.fontSize*.6+2*n;return No("rect",{x:t.position.x-h/2,y:t.position.y-o-n+a*e,width:h,height:s,fill:r})}).join("")},Oo=t=>{if("undefined"!=typeof document)try{const e=document.createElement("canvas");e.width=t.naturalWidth||t.width,e.height=t.naturalHeight||t.height;const i=e.getContext("2d");if(!i)return;return i.drawImage(t,0,0),e.toDataURL()}catch(t){return}},ko=t=>{var e,i,n;return t.shadowColor?{color:t.shadowColor,size:null!==(e=t.shadowSize)&&void 0!==e?e:0,offsetX:null!==(i=t.shadowOffsetX)&&void 0!==i?i:0,offsetY:null!==(n=t.shadowOffsetY)&&void 0!==n?n:0}:null},Bo=(t,e)=>{const{color:i,opacity:n}=Uo(e.color.toString()),s=Math.max(.5*e.size,0),o=`shadow:${i}:${n}:${s}:${e.offsetX}:${e.offsetY}`;return t.add(o,o=>zo(o,i,n,s,e.offsetX,e.offsetY,t.filterRegion))},zo=(t,e,i,n,s,o,r)=>{const a=r?`filterUnits="userSpaceOnUse" x="${Co(r.x)}" y="${Co(r.y)}" width="${Co(r.width)}" height="${Co(r.height)}"`:'filterUnits="objectBoundingBox" x="-50%" y="-50%" width="200%" height="200%"';return``},Uo=t=>{const e=t.match(/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i);if(e)return{color:`rgb(${e[1]}, ${e[2]}, ${e[3]})`,opacity:Fo(Number(e[4]))};const i=t.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i);if(i)return{color:`#${i[1]}${i[2]}${i[3]}`,opacity:parseInt(i[4],16)/255};const n=t.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])$/i);return n?{color:`#${n[1]}${n[2]}${n[3]}`,opacity:parseInt(n[4],16)/15}:{color:t,opacity:1}},Fo=t=>isFinite(t)?Math.min(Math.max(t,0),1):1,jo=(t,e,i)=>{var n,s,o,r,a,h;const l=null===(n=null==i?void 0:i.isLabelEnabled)||void 0===n||n,d=null===(s=null==i?void 0:i.isShadowEnabled)||void 0===s||s,u=null===(o=null==i?void 0:i.isImageEnabled)||void 0===o||o,c=t.getCenter(),_=t.getRadius();if(_<=0)return"";const f=((t,e,i,n)=>{switch(t){case S.SQUARE:return{tag:"rect",attributes:{x:e-n,y:i-n,width:2*n,height:2*n}};case S.DIAMOND:return Io([{x:e,y:i+n},{x:e+n,y:i},{x:e,y:i-n},{x:e-n,y:i}]);case S.TRIANGLE:return Io(((t,e,i)=>{e+=.275*(i*=1.15);const n=2*i,s=Math.sqrt(3)*n/6;return[{x:t,y:e-(Math.sqrt(n*n-i*i)-s)},{x:t+i,y:e+s},{x:t-i,y:e+s}]})(e,i,n));case S.TRIANGLE_DOWN:return Io(((t,e,i)=>{e-=.275*(i*=1.15);const n=2*i,s=Math.sqrt(3)*n/6;return[{x:t,y:e+(Math.sqrt(n*n-i*i)-s)},{x:t+i,y:e-s},{x:t-i,y:e-s}]})(e,i,n));case S.STAR:return Io(((t,e,i)=>{e+=.1*(i*=.82);const n=[];for(let s=0;s<10;s++){const o=i*(s%2==0?1.3:.5);n.push({x:t+o*Math.sin(2*s*Math.PI/10),y:e-o*Math.cos(2*s*Math.PI/10)})}return n})(e,i,n));case S.HEXAGON:return Io(((t,e,i,n)=>{const s=[],o=2*Math.PI/n;for(let r=0;r{const n=t.getBackgroundImage();if(!n||!n.width||!n.height)return"";const s=((t,e)=>{var i,n;const s=Oo(e);if(s)return s;const o=t.getStyle();return t.isSelected()&&o.imageUrlSelected?o.imageUrlSelected:null!==(n=null!==(i=o.imageUrl)&&void 0!==i?i:e.src)&&void 0!==n?n:void 0})(t,n);if(!s)return"";const o=t.getCenter(),r=t.getRadius(),a=Object.keys(i.attributes).map(t=>`${t}=${i.attributes[t]}`).join(","),h=e.add(`clip:${i.tag}:${a}`,t=>No("clipPath",{id:t},No(i.tag,i.attributes)));return No("image",{href:s,"xlink:href":s,x:o.x-r,y:o.y-r,width:2*r,height:2*r,preserveAspectRatio:"xMidYMid slice","clip-path":`url(#${h})`})})(t,e,f):"",y=d&&t.hasShadow()?ko(t.getStyle()):null;let x;if(v||y){let t=`${No(f.tag,Object.assign(Object.assign({},f.attributes),{fill:g}))}${v}`;y&&(t=No("g",{filter:`url(#${Bo(e,y)})`},t)),x=`${t}${p?No(f.tag,Object.assign(Object.assign(Object.assign({},f.attributes),{fill:"none"}),m)):""}`}else x=No(f.tag,Object.assign(Object.assign(Object.assign({},f.attributes),{fill:g}),m));const b=l?Wo(t):"";return No("g",{},`${x}${b}`)},Wo=t=>{const e=t.getLabel();if(!e)return"";const i=t.getCenter(),n=1.2*t.getBorderedRadius(),s=t.getStyle();return Lo(e,{position:{x:i.x,y:i.y+n},textBaseline:Fs.TOP,properties:{fontBackgroundColor:s.fontBackgroundColor,fontColor:s.fontColor,fontFamily:s.fontFamily,fontSize:s.fontSize}})},Zo=[{x:0,y:0},{x:-1,y:.4},{x:-1,y:-.4}],Go=(t,e,i)=>{var n,s,o;const r=t.getWidth();if(!r)return"";const a=null===(n=null==i?void 0:i.isLabelEnabled)||void 0===n||n,h=null===(s=null==i?void 0:i.isShadowEnabled)||void 0===s||s,l=(null!==(o=t.getColor())&&void 0!==o?o:"#000000").toString(),d=Xo(t,l),u=Ho(t,r,l),c=h&&t.hasShadow()?ko(t.getStyle()):null;let _=`${d}${u}`;c&&(_=No("g",{filter:`url(#${Bo(e,c)})`},_));const f=a?Yo(t):"";return No("g",{},`${_}${f}`)},Ho=(t,e,i)=>{const n=t.getLineDashPattern(),s={stroke:i,"stroke-width":e,fill:"none","stroke-dasharray":n?n.join(" "):void 0};if(t instanceof O){const e=t.startNode.getCenter(),i=t.endNode.getCenter(),n=`M ${Co(e.x)} ${Co(e.y)} L ${Co(i.x)} ${Co(i.y)}`;return No("path",Object.assign({d:n},s))}if(t instanceof k){const e=t.startNode.getCenter(),i=t.endNode.getCenter(),n=t.getCurvedControlPoint(),o=`M ${Co(e.x)} ${Co(e.y)} Q ${Co(n.x)} ${Co(n.y)} ${Co(i.x)} ${Co(i.y)}`;return No("path",Object.assign({d:o},s))}if(t instanceof B){const{x:e,y:i,radius:n}=t.getCircularData();return No("circle",Object.assign({cx:e,cy:i,r:n},s))}return""},Xo=(t,e)=>{if(0===t.getStyle().arrowSize)return"";const i=qo(t);if(!i)return"";const n=Vo(Zo,i).map(t=>`${Co(t.x)},${Co(t.y)}`).join(" ");return No("polygon",{points:n,fill:e})},qo=t=>t instanceof O?Js(t):t instanceof k?qs(t):t instanceof B?$s(t):null,Vo=(t,e)=>t.map(t=>{const i=t.x*Math.cos(e.angle)-t.y*Math.sin(e.angle),n=t.x*Math.sin(e.angle)+t.y*Math.cos(e.angle);return{x:e.point.x+e.length*i,y:e.point.y+e.length*n}}),Yo=t=>{const e=t.getLabel();if(!e)return"";const i=t.getStyle();return Lo(e,{position:t.getCenter(),textBaseline:Fs.MIDDLE,properties:{fontBackgroundColor:i.fontBackgroundColor,fontColor:i.fontColor,fontFamily:i.fontFamily,fontSize:i.fontSize}})};class $o{constructor(t){this.filterRegion=t,this._idBySignature=new Map,this._entries=[],this._counter=0}add(t,e){const i=this._idBySignature.get(t);if(void 0!==i)return i;const n=`orb-def-${this._counter}`;return this._counter+=1,this._idBySignature.set(t,n),this._entries.push(e(n)),n}toSVG(){return this._entries.length?`${this._entries.join("")}`:""}}const Ko=(t,e={})=>{var i,n,s,o;const r=null!==(i=e.padding)&&void 0!==i?i:20,a=null===(n=e.isLabelEnabled)||void 0===n||n,h=null===(s=e.isShadowEnabled)||void 0===s||s,l=null===(o=e.isImageEnabled)||void 0===o||o,d=t.getNodes(),u=t.getEdges(),c=Qo(d,u,a,h),_=c.x-r,f=c.y-r,g=Math.max(c.width+2*r,1),p=Math.max(c.height+2*r,1),m=new $o({x:_,y:f,width:g,height:p}),v=[];e.backgroundColor&&v.push(No("rect",{x:_,y:f,width:g,height:p,fill:e.backgroundColor.toString()}));for(let t=0;t{const s={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(let e=0;e{et.maxX&&(t.maxX=e),i>t.maxY&&(t.maxY=i)},tr=(t,e,i,n,s)=>{Jo(t,e-n,i-s),Jo(t,e+n,i+s)},er=(t,e,i,n)=>{var s;if(e.getRadius()<=0)return;const o=e.getCenter(),r=e.getBorderedRadius(),a=n?sr(e.hasShadow(),e.getStyle()):0;if(tr(t,o.x,o.y,r+a,r+a),i&&e.getLabel()){const i=e.getStyle(),n=o.y+1.2*e.getBorderedRadius();nr(t,e.getLabel(),o.x,n,null!==(s=i.fontSize)&&void 0!==s?s:4,!1)}},ir=(t,e,i,n)=>{var s;if(!e.getWidth())return;const o=e.getStyle(),r=n?sr(e.hasShadow(),o):0;if(e instanceof B){const i=e.getCircularData();tr(t,i.x,i.y,i.radius+r,i.radius+r)}else if(e instanceof k){const i=e.getCurvedControlPoint();tr(t,i.x,i.y,r,r)}if(i&&e.getLabel()){const i=e.getCenter();nr(t,e.getLabel(),i.x,i.y,null!==(s=o.fontSize)&&void 0!==s?s:4,!0)}},nr=(t,e,i,n,s,o)=>{if(s<=0)return;const r=`${e}`.split("\n"),a=.12*s,h=r.reduce((t,e)=>Math.max(t,e.trim().length),0)*s*.6+2*a,l=r.length*s*1.2+2*a,d=o?n-l/2:n;Jo(t,i-h/2,d),Jo(t,i+h/2,d+l)},sr=(t,e)=>{var i,n,s;return t&&e.shadowColor?(null!==(i=e.shadowSize)&&void 0!==i?i:0)+Math.max(Math.abs(null!==(n=e.shadowOffsetX)&&void 0!==n?n:0),Math.abs(null!==(s=e.shadowOffsetY)&&void 0!==s?s:0)):0};class or{constructor(t){this._graph=t}selectNodeById(t,e){const i=this._graph.getNodeById(t);return!!i&&(ws(i,e),!0)}selectEdgeById(t,e){const i=this._graph.getEdgeById(t);return!!i&&(Ts(i,e),!0)}unselectNodeById(t,e){const i=this._graph.getNodeById(t);return!!i&&(Es(i,e),!0)}unselectEdgeById(t,e){const i=this._graph.getEdgeById(t);return!!i&&(Ps(i,e),!0)}unselectAll(){const{changedCount:t}=Ms(this._graph);return t}hoverNodeById(t){const e=this._graph.getNodeById(t);return!!e&&(Ns(e),!0)}hoverEdgeById(t){const e=this._graph.getEdgeById(t);return!!e&&((t=>{Ls(t,r.HOVERED)})(e),!0)}unhoverAll(){const{changedCount:t}=Ds(this._graph);return t}}class rr{constructor(t,i){var n,o,r,a,h,l,d;this._simulatorUsesGPU=!1,this._simulationStartedAt=Date.now(),this._assignPositions=t=>{if(this._settings.getPosition)for(let e=0;e{var e;const i=this.getCanvasMousePosition(t.sourceEvent),n=null===(e=this._renderer)||void 0===e?void 0:e.getSimulationPosition(i);return this._graph.getNearestNode(n)},this.dragStarted=t=>{if(!this._settings.interaction.isDragEnabled)return;const i=this.getCanvasMousePosition(t.sourceEvent),n=this._renderer.getSimulationPosition(i);this._events.emit(e.NODE_DRAG_START,{node:t.subject,event:t.sourceEvent,localPoint:n,globalPoint:i}),this._dragStartPosition=i},this.dragged=t=>{if(!this._settings.interaction.isDragEnabled)return;const i=this.getCanvasMousePosition(t.sourceEvent),n=this._renderer.getSimulationPosition(i);In(this._dragStartPosition,i)||(this._dragStartPosition=void 0),this._simulator.dragNode(t.subject.getId(),n),this._events.emit(e.NODE_DRAG,{node:t.subject,event:t.sourceEvent,localPoint:n,globalPoint:i})},this.dragEnded=t=>{if(!this._settings.interaction.isDragEnabled)return;const i=this.getCanvasMousePosition(t.sourceEvent),n=this._renderer.getSimulationPosition(i);In(this._dragStartPosition,i)||this._simulator.endDragNode(t.subject.getId()),this._events.emit(e.NODE_DRAG_END,{node:t.subject,event:t.sourceEvent,localPoint:n,globalPoint:i})},this.zoomed=t=>{this._settings.interaction.isZoomEnabled&&(this._renderer.transform=t.transform,setTimeout(()=>{this.render(),this._events.emit(e.TRANSFORM,{transform:t.transform})},1))},this.mouseMoved=t=>{const i=this.getCanvasMousePosition(t),n=this._renderer.getSimulationPosition(i),s=this._strategy.onMouseMove(this._graph,n),o=s.changedSubject;o&&s.isStateChanged&&(T(o)&&this._events.emit(e.NODE_HOVER,{node:o,event:t,localPoint:n,globalPoint:i}),I(o)&&this._events.emit(e.EDGE_HOVER,{edge:o,event:t,localPoint:n,globalPoint:i})),this._events.emit(e.MOUSE_MOVE,{subject:o,event:t,localPoint:n,globalPoint:i}),s.isStateChanged&&(this._invalidateStyles(),this.render())},this.mouseClicked=t=>{const i=this.getCanvasMousePosition(t),n=this._renderer.getSimulationPosition(i),s=this._strategy.onMouseClick(this._graph,n,{isAppend:t.shiftKey}),o=s.changedSubject;o&&(T(o)&&this._events.emit(e.NODE_CLICK,{node:o,event:t,localPoint:n,globalPoint:i}),I(o)&&this._events.emit(e.EDGE_CLICK,{edge:o,event:t,localPoint:n,globalPoint:i})),this._events.emit(e.MOUSE_CLICK,{subject:o,event:t,localPoint:n,globalPoint:i}),(s.isStateChanged||s.changedSubject)&&(this._invalidateStyles(),this.render())},this.mouseRightClicked=t=>{const i=this.getCanvasMousePosition(t),n=this._renderer.getSimulationPosition(i),s=this._strategy.onMouseRightClick(this._graph,n),o=s.changedSubject;o&&(T(o)&&this._events.emit(e.NODE_RIGHT_CLICK,{node:o,event:t,localPoint:n,globalPoint:i}),I(o)&&this._events.emit(e.EDGE_RIGHT_CLICK,{edge:o,event:t,localPoint:n,globalPoint:i})),this._events.emit(e.MOUSE_RIGHT_CLICK,{subject:o,event:t,localPoint:n,globalPoint:i}),(s.isStateChanged||s.changedSubject)&&(this._invalidateStyles(),this.render())},this.mouseDoubleClicked=t=>{const i=this.getCanvasMousePosition(t),n=this._renderer.getSimulationPosition(i),s=this._strategy.onMouseDoubleClick(this._graph,n),o=s.changedSubject;o&&(T(o)&&this._events.emit(e.NODE_DOUBLE_CLICK,{node:o,event:t,localPoint:n,globalPoint:i}),I(o)&&this._events.emit(e.EDGE_DOUBLE_CLICK,{edge:o,event:t,localPoint:n,globalPoint:i})),this._events.emit(e.MOUSE_DOUBLE_CLICK,{subject:o,event:t,localPoint:n,globalPoint:i}),(s.isStateChanged||s.changedSubject)&&(this._invalidateStyles(),this.render())},this.zoomIn=t=>{ue(this._renderer.canvas).transition().duration(this._settings.zoomFitTransitionMs).ease(Ee).call(this._d3Zoom.scaleBy,1.2).on("end",()=>this.render(t))},this.zoomOut=t=>{ue(this._renderer.canvas).transition().duration(this._settings.zoomFitTransitionMs).ease(Ee).call(this._d3Zoom.scaleBy,.8).on("end",()=>this.render(t))},this._invalidateStyles=()=>{var t,e;null===(e=(t=this._renderer).invalidateStyles)||void 0===e||e.call(t)},this._update=t=>{t&&"x"in t&&"y"in t&&"id"in t&&this._simulator.patchData({nodes:[{x:t.x,y:t.y,sx:t.x,sy:t.y,fx:t.x,fy:t.y,id:t.id}],edges:[]}),this._invalidateStyles(),this.render()},this._initializeSimulationEvents=()=>{this._simulator.on(Ln.SIMULATION_START,()=>{this._simulationStartedAt=Date.now(),this._events.emit(e.SIMULATION_START,void 0)});const t=()=>{var t,e;return null===(e=(t=this._renderer).invalidateBuffers)||void 0===e?void 0:e.call(t)};this._simulator.on(Ln.SIMULATION_PROGRESS,i=>{this._graph.setNodePositions(i.nodes),t(),this._events.emit(e.SIMULATION_STEP,{progress:i.progress}),this.render()}),this._simulator.on(Ln.SIMULATION_END,i=>{this._graph.setNodePositions(i.nodes),t(),this.render(),this._events.emit(e.SIMULATION_END,{durationMs:Date.now()-this._simulationStartedAt})}),this._simulator.on(Ln.SIMULATION_STEP,e=>{this._graph.setNodePositions(e.nodes),t(),this.render()}),this._simulator.on(Ln.NODE_DRAG,e=>{this._graph.setNodePositions(e.nodes),t(),this.render()}),this._simulator.on(Ln.SETTINGS_UPDATE,t=>{var e;this._settings.layout.options=null===(e=t.settings)||void 0===e?void 0:e.options})},this._container=t,this._settings=Object.assign(Object.assign({getPosition:null==i?void 0:i.getPosition,zoomFitTransitionMs:200,isOutOfBoundsDragEnabled:!1,areCoordinatesRounded:!0},i),{layout:Object.assign({type:"force"},null!==(n=null==i?void 0:i.layout)&&void 0!==n?n:es),render:Object.assign({},null==i?void 0:i.render),strategy:Object.assign({isDefaultHoverEnabled:!0,isDefaultSelectEnabled:!0,isDefaultMultiSelectEnabled:!1,isDefaultSelectCascadeEnabled:!0},null==i?void 0:i.strategy),interaction:Object.assign({isDragEnabled:!0,isZoomEnabled:!0},null==i?void 0:i.interaction)}),this._graph=new Ss(void 0,{onLoadedImages:()=>{this._renderer.isInitiallyRendered&&this.render()},listeners:[this._update]}),this._graph.setDefaultStyle(H()),this._events=new s,this._interaction=new or(this._graph),this._strategy=new Os({isDefaultSelectEnabled:null!==(o=this._settings.strategy.isDefaultSelectEnabled)&&void 0!==o&&o,isDefaultHoverEnabled:null!==(r=this._settings.strategy.isDefaultHoverEnabled)&&void 0!==r&&r,isDefaultMultiSelectEnabled:null===(a=this._settings.strategy.isDefaultMultiSelectEnabled)||void 0===a||a,isDefaultSelectCascadeEnabled:null===(h=this._settings.strategy.isDefaultSelectCascadeEnabled)||void 0===h||h}),this._rendererType=null!==(d=null===(l=null==i?void 0:i.render)||void 0===l?void 0:l.type)&&void 0!==d?d:ks.CANVAS,this._initRenderer(this._rendererType),this._simulator=vs.getSimulator(this._settings.layout),this._simulatorUsesGPU=rr._needsGPU(this._settings.layout),this._initializeSimulationEvents(),this._graph.setSettings({onSetupData:()=>{this._assignPositions(this._graph.getNodes());const t=this._graph.getNodePositions(),e=this._graph.getEdgePositions();this._simulator.setupData({nodes:t,edges:e})},onMergeData:t=>{var e,i;const n=new Set(null===(e=t.nodes)||void 0===e?void 0:e.map(t=>t.id)),s=t=>n.has(t.getId()),o=new Set(null===(i=t.edges)||void 0===i?void 0:i.map(t=>t.id));this._assignPositions(this._graph.getNodes(s));const r=this._graph.getNodePositions(s),a=this._graph.getEdgePositions(t=>o.has(t.getId()));this._simulator.mergeData({nodes:r,edges:a})},onRemoveData:t=>{this._simulator.deleteData(t)}})}_initRenderer(t){try{this._renderer=Ao.getRenderer(this._container,t,this._settings.render)}catch(t){throw this._container.textContent=t.message,t}this._renderer.on(Bs.RENDER_START,()=>{this._events.emit(e.RENDER_START,void 0)}),this._renderer.on(Bs.RENDER_END,t=>{this._events.emit(e.RENDER_END,t)}),this._renderer.on(Bs.RESIZE,()=>{this._renderer.isInitiallyRendered&&this._renderer.render(this._graph)}),this._renderer.translateOriginToCenter(),this._settings.render=this._renderer.getSettings(),this._d3Zoom=function(){var t,e,i,n=Pn,s=An,o=Dn,r=Mn,a=Nn,h=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],d=250,u=Ae,c=Q("start","zoom","end"),_=0,f=10;function g(t){t.property("__zoom",Cn).on("wheel.zoom",S,{passive:!1}).on("mousedown.zoom",w).on("dblclick.zoom",T).filter(a).on("touchstart.zoom",E).on("touchmove.zoom",P).on("touchend.zoom touchcancel.zoom",A).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(t,e){return(e=Math.max(h[0],Math.min(h[1],e)))===t.k?t:new Sn(e,t.x,t.y)}function m(t,e,i){var n=e[0]-i[0]*t.k,s=e[1]-i[1]*t.k;return n===t.x&&s===t.y?t:new Sn(t.k,n,s)}function v(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function y(t,e,i,n){t.on("start.zoom",function(){x(this,arguments).event(n).start()}).on("interrupt.zoom end.zoom",function(){x(this,arguments).event(n).end()}).tween("zoom",function(){var t=this,o=arguments,r=x(t,o).event(n),a=s.apply(t,o),h=null==i?v(a):"function"==typeof i?i.apply(t,o):i,l=Math.max(a[1][0]-a[0][0],a[1][1]-a[0][1]),d=t.__zoom,c="function"==typeof e?e.apply(t,o):e,_=u(d.invert(h).concat(l/d.k),c.invert(h).concat(l/c.k));return function(t){if(1===t)t=c;else{var e=_(t),i=l/e[2];t=new Sn(i,h[0]-e[0]*i,h[1]-e[1]*i)}r.zoom(null,t)}})}function x(t,e,i){return!i&&t.__zooming||new b(t,e)}function b(t,e){this.that=t,this.args=e,this.active=0,this.sourceEvent=null,this.extent=s.apply(t,e),this.taps=0}function S(t,...e){if(n.apply(this,arguments)){var i=x(this,e).event(t),s=this.__zoom,a=Math.max(h[0],Math.min(h[1],s.k*Math.pow(2,r.apply(this,arguments)))),d=ce(t);if(i.wheel)i.mouse[0][0]===d[0]&&i.mouse[0][1]===d[1]||(i.mouse[1]=s.invert(i.mouse[0]=d)),clearTimeout(i.wheel);else{if(s.k===a)return;i.mouse=[d,s.invert(d)],Qe(this),i.start()}En(t),i.wheel=setTimeout(function(){i.wheel=null,i.end()},150),i.zoom("mouse",o(m(p(s,a),i.mouse[0],i.mouse[1]),i.extent,l))}}function w(t,...e){if(!i&&n.apply(this,arguments)){var s=t.currentTarget,r=x(this,e,!0).event(t),a=ue(t.view).on("mousemove.zoom",function(t){if(En(t),!r.moved){var e=t.clientX-d,i=t.clientY-u;r.moved=e*e+i*i>_}r.event(t).zoom("mouse",o(m(r.that.__zoom,r.mouse[0]=ce(t,s),r.mouse[1]),r.extent,l))},!0).on("mouseup.zoom",function(t){a.on("mousemove.zoom mouseup.zoom",null),ve(t.view,r.moved),En(t),r.event(t).end()},!0),h=ce(t,s),d=t.clientX,u=t.clientY;me(t.view),Tn(t),r.mouse=[h,this.__zoom.invert(h)],Qe(this),r.start()}}function T(t,...e){if(n.apply(this,arguments)){var i=this.__zoom,r=ce(t.changedTouches?t.changedTouches[0]:t,this),a=i.invert(r),h=i.k*(t.shiftKey?.5:2),u=o(m(p(i,h),r,a),s.apply(this,e),l);En(t),d>0?ue(this).transition().duration(d).call(y,u,r,t):ue(this).call(g.transform,u,r,t)}}function E(i,...s){if(n.apply(this,arguments)){var o,r,a,h,l=i.touches,d=l.length,u=x(this,s,i.changedTouches.length===d).event(i);for(Tn(i),r=0;ru}h.mouse("drag",n)}function g(t){ue(t.view).on("mousemove.drag mouseup.drag",null),ve(t.view,i),pe(t),h.mouse("end",t)}function p(t,e){if(s.call(this,t,e)){var i,n,r=t.changedTouches,a=o.call(this,t,e),h=r.length;for(i=0;i{this.recenter()}),this._simulator.setupData({nodes:n,edges:s})}t.strategy&&(u(t.strategy.isDefaultHoverEnabled)&&(this._settings.strategy.isDefaultHoverEnabled=t.strategy.isDefaultHoverEnabled,this._strategy.isHoverEnabled=this._settings.strategy.isDefaultHoverEnabled),u(t.strategy.isDefaultSelectEnabled)&&(this._settings.strategy.isDefaultSelectEnabled=t.strategy.isDefaultSelectEnabled,this._strategy.isSelectEnabled=this._settings.strategy.isDefaultSelectEnabled),u(t.strategy.isDefaultMultiSelectEnabled)&&(this._settings.strategy.isDefaultMultiSelectEnabled=t.strategy.isDefaultMultiSelectEnabled,this._strategy.isMultiSelectEnabled=this._settings.strategy.isDefaultMultiSelectEnabled),u(t.strategy.isDefaultSelectCascadeEnabled)&&(this._settings.strategy.isDefaultSelectCascadeEnabled=t.strategy.isDefaultSelectCascadeEnabled,this._strategy.isSelectCascadeEnabled=this._settings.strategy.isDefaultSelectCascadeEnabled)),t.interaction&&(u(t.interaction.isDragEnabled)&&(this._settings.interaction.isDragEnabled=t.interaction.isDragEnabled),u(t.interaction.isZoomEnabled)&&(this._settings.interaction.isZoomEnabled=t.interaction.isZoomEnabled))}static _needsGPU(t){var e;return"force"===t.type&&!!(null===(e=t.options)||void 0===e?void 0:e.useGPU)}render(t){t&&(this._simulator.isSimulationRunning()?this._simulator.once(Ln.SIMULATION_END,()=>{this._renderer.once(Bs.RENDER_END,()=>t())}):this._renderer.once(Bs.RENDER_END,()=>t())),this._renderer.render(this._graph)}recenter(t,e){"function"==typeof t&&(e=t,t=void 0);const i=(t=>{var e,i,n,s,o,r;if("hierarchical"===t.type){const n=t.options;return{anchorX:null!==(e=n.anchorX)&&void 0!==e?e:"horizontal"===n.orientation?n.reversed?"end":"start":"center",anchorY:null!==(i=n.anchorY)&&void 0!==i?i:"vertical"===n.orientation?n.reversed?"end":"start":"center"}}return{anchorX:null!==(s=null===(n=t.options)||void 0===n?void 0:n.anchorX)&&void 0!==s?s:"center",anchorY:null!==(r=null===(o=t.options)||void 0===o?void 0:o.anchorY)&&void 0!==r?r:"center"}})(this._settings.layout),n=Object.assign(Object.assign({},i),t),s=this._renderer.getFitZoomTransform(this._graph,n);ue(this._renderer.canvas).transition().duration(this._settings.zoomFitTransitionMs).ease(Ee).call(this._d3Zoom.transform,s).on("end",()=>this.render(e))}getSVG(t){return Ko(this._graph,Object.assign({backgroundColor:this._settings.render.backgroundColor},t))}destroy(){this._renderer.destroy(),this._simulator.terminate()}getCanvasMousePosition(t){var e,i,n,s;const o=this._renderer.canvas.getBoundingClientRect();let r=null!==(i=null!==(e=t.clientX)&&void 0!==e?e:t.pageX)&&void 0!==i?i:t.x,a=null!==(s=null!==(n=t.clientY)&&void 0!==n?n:t.pageY)&&void 0!==s?s:t.y;return r-=o.left,a-=o.top,this._settings.areCoordinatesRounded&&(r=Math.floor(r),a=Math.floor(a)),this._settings.isOutOfBoundsDragEnabled||(r=Math.max(0,Math.min(this._renderer.width,r)),a=Math.max(0,Math.min(this._renderer.height,a))),{x:r,y:a}}fixNodes(){this._simulator.fixNodes()}releaseNodes(){this._simulator.releaseNodes()}}var ar=i(481);class hr{constructor(t,e){var i,n,o,r,a,h,l,d,u,c,_,f;this._invalidateStyles=()=>{var t,e;null===(e=(t=this._renderer).invalidateStyles)||void 0===e||e.call(t)},this._update=()=>{this._invalidateStyles(),this.render()},this._container=t,this._graph=new Ss(void 0,{onLoadedImages:()=>{this._renderer.isInitiallyRendered&&this.render()},listeners:[this._update]}),this._graph.setDefaultStyle(H()),this._events=new s,this._interaction=new or(this._graph),this._settings=Object.assign(Object.assign({areCollapsedContainerDimensionsAllowed:!1},e),{map:{zoomLevel:null!==(n=null===(i=e.map)||void 0===i?void 0:i.zoomLevel)&&void 0!==n?n:2,tile:null!==(r=null===(o=e.map)||void 0===o?void 0:o.tile)&&void 0!==r?r:{instance:new ar.TileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"),attribution:'Leaflet | Map data © OpenStreetMap contributors'},nodeSizeMode:null!==(h=null===(a=e.map)||void 0===a?void 0:a.nodeSizeMode)&&void 0!==h?h:"geographic"},render:Object.assign({type:ks.CANVAS},e.render),strategy:Object.assign({isDefaultHoverEnabled:!0,isDefaultSelectEnabled:!0,isDefaultMultiSelectEnabled:!1,isDefaultSelectCascadeEnabled:!0},null==e?void 0:e.strategy)}),this._strategy=new Os({isDefaultSelectEnabled:null!==(l=this._settings.strategy.isDefaultSelectEnabled)&&void 0!==l&&l,isDefaultHoverEnabled:null!==(d=this._settings.strategy.isDefaultHoverEnabled)&&void 0!==d&&d,isDefaultMultiSelectEnabled:null===(u=this._settings.strategy.isDefaultMultiSelectEnabled)||void 0===u||u,isDefaultSelectCascadeEnabled:null===(c=this._settings.strategy.isDefaultSelectCascadeEnabled)||void 0===c||c}),this._rendererType=null!==(f=null===(_=null==e?void 0:e.render)||void 0===_?void 0:_.type)&&void 0!==f?f:ks.CANVAS,this._initRenderer(this._rendererType),this._map=this._initMap(),this._leaflet=this._initLeaflet(),this._handleTileChange()}_initRenderer(t){try{this._renderer=Ao.getRenderer(this._container,t,this._settings.render)}catch(t){throw this._container.textContent=t.message,t}this._renderer.on(Bs.RENDER_END,t=>{this._events.emit(e.RENDER_END,t)}),this._renderer.on(Bs.RESIZE,()=>{this._renderer.isInitiallyRendered&&(this._leaflet.invalidateSize(!1),this._renderer.render(this._graph))}),this._settings.render=this._renderer.getSettings(),this._renderer.canvas.style.zIndex="2",this._renderer.canvas.style.pointerEvents="none"}setRenderer(t){if(t===this._rendererType)return;this._renderer.destroy(),this._initRenderer(t),this._rendererType=t;const e=this._leaflet._mapPane._leaflet_pos,i=this._getStyleScale();this._renderer.transform=Object.assign(Object.assign({},e),{k:i}),this.render()}get data(){return this._graph}get events(){return this._events}get interaction(){return this._interaction}get leaflet(){return this._leaflet}getSettings(){return p(this._settings)}setSettings(t){if(t.getGeoPosition&&(this._settings.getGeoPosition=t.getGeoPosition,this._updateGraphPositions()),t.map&&("number"==typeof t.map.zoomLevel&&(this._settings.map.zoomLevel=t.map.zoomLevel,this._leaflet.setZoom(t.map.zoomLevel)),t.map.tile&&(this._settings.map.tile=t.map.tile,this._handleTileChange()),t.map.nodeSizeMode&&t.map.nodeSizeMode!==this._settings.map.nodeSizeMode)){this._settings.map.nodeSizeMode=t.map.nodeSizeMode,this._updateGraphPositions();const e=this._leaflet._mapPane._leaflet_pos,i=this._getStyleScale();this._renderer.transform=Object.assign(Object.assign({},e),{k:i}),this._renderer.render(this._graph)}t.render&&(t.render.type&&t.render.type!==this._rendererType&&this.setRenderer(t.render.type),this._renderer.setSettings(t.render),this._settings.render=this._renderer.getSettings()),t.strategy&&(u(t.strategy.isDefaultHoverEnabled)&&(this._settings.strategy.isDefaultHoverEnabled=t.strategy.isDefaultHoverEnabled,this._strategy.isHoverEnabled=this._settings.strategy.isDefaultHoverEnabled),u(t.strategy.isDefaultSelectEnabled)&&(this._settings.strategy.isDefaultSelectEnabled=t.strategy.isDefaultSelectEnabled,this._strategy.isSelectEnabled=this._settings.strategy.isDefaultSelectEnabled),u(t.strategy.isDefaultMultiSelectEnabled)&&(this._settings.strategy.isDefaultMultiSelectEnabled=t.strategy.isDefaultMultiSelectEnabled,this._strategy.isMultiSelectEnabled=this._settings.strategy.isDefaultMultiSelectEnabled),u(t.strategy.isDefaultSelectCascadeEnabled)&&(this._settings.strategy.isDefaultSelectCascadeEnabled=t.strategy.isDefaultSelectCascadeEnabled,this._strategy.isSelectCascadeEnabled=this._settings.strategy.isDefaultSelectCascadeEnabled))}render(t){t&&this._renderer.once(Bs.RENDER_END,()=>t()),this._updateGraphPositions(),this._renderer.render(this._graph)}zoomIn(t){this._leaflet.zoomIn(),null==t||t()}recenter(t){const e=this._graph.getBoundingBox(),i=this._getStyleScale(),n=this._leaflet.layerPointToLatLng([e.x*i,e.y*i]),s=this._leaflet.layerPointToLatLng([(e.x+e.width)*i,(e.y+e.height)*i]);this._leaflet.fitBounds(ar.latLngBounds(n,s)),null==t||t()}zoomOut(t){this._leaflet.zoomOut(),null==t||t()}getSVG(){throw new Error("SVG export is not supported on OrbMapView.")}destroy(){this._renderer.destroy(),this._leaflet.off(),this._leaflet.remove(),this._leaflet.getContainer().outerHTML=""}_initMap(){const t=document.createElement("div");return t.style.position="absolute",t.style.width="100%",t.style.height="100%",t.style.zIndex="1",t.style.cursor="default",this._container.appendChild(t),t}_initLeaflet(){const t=ar.map(this._map,{doubleClickZoom:!1,zoomControl:!1}).setView([0,0],this._settings.map.zoomLevel);return t.on("zoomstart",()=>{this._renderer.reset()}),t.on("zoom",t=>{var i,n;this._updateGraphPositions(),null===(n=(i=this._renderer).invalidateBuffers)||void 0===n||n.call(i);const s=t.target._mapPane._leaflet_pos,o=this._getStyleScale();this._renderer.transform=Object.assign(Object.assign({},s),{k:o}),this._renderer.render(this._graph),this._events.emit(e.TRANSFORM,{transform:Object.assign(Object.assign({},s),{k:o})})}),t.on("mousemove",t=>{const i=this._toSimulationPoint(t.layerPoint),n={x:t.containerPoint.x,y:t.containerPoint.y},s=this._strategy.onMouseMove(this._graph,i),o=s.changedSubject;o&&s.isStateChanged&&(T(o)&&this._events.emit(e.NODE_HOVER,{node:o,event:t.originalEvent,localPoint:i,globalPoint:n}),I(o)&&this._events.emit(e.EDGE_HOVER,{edge:o,event:t.originalEvent,localPoint:i,globalPoint:n})),this._events.emit(e.MOUSE_MOVE,{subject:o,event:t.originalEvent,localPoint:i,globalPoint:n}),s.isStateChanged&&(this._invalidateStyles(),this._renderer.render(this._graph))}),t.on("click contextmenu dblclick",t=>{const i=this._toSimulationPoint(t.layerPoint),n={x:t.containerPoint.x,y:t.containerPoint.y};if("contextmenu"===t.type){const s=this._strategy.onMouseRightClick(this._graph,i),o=s.changedSubject;o&&(T(o)&&this._events.emit(e.NODE_RIGHT_CLICK,{node:o,event:t.originalEvent,localPoint:i,globalPoint:n}),I(o)&&this._events.emit(e.EDGE_RIGHT_CLICK,{edge:o,event:t.originalEvent,localPoint:i,globalPoint:n})),this._events.emit(e.MOUSE_RIGHT_CLICK,{subject:o,event:t.originalEvent,localPoint:i,globalPoint:n}),s.isStateChanged&&(this._invalidateStyles(),this._renderer.render(this._graph))}else if("click"===t.type){const s=this._strategy.onMouseClick(this._graph,i,{isAppend:t.originalEvent.shiftKey}),o=s.changedSubject;o&&(T(o)&&this._events.emit(e.NODE_CLICK,{node:o,event:t.originalEvent,localPoint:i,globalPoint:n}),I(o)&&this._events.emit(e.EDGE_CLICK,{edge:o,event:t.originalEvent,localPoint:i,globalPoint:n})),this._events.emit(e.MOUSE_CLICK,{subject:o,event:t.originalEvent,localPoint:i,globalPoint:n}),(s.isStateChanged||s.changedSubject)&&(this._invalidateStyles(),this._renderer.render(this._graph))}else if("dblclick"===t.type){const s=this._strategy.onMouseDoubleClick(this._graph,i),o=s.changedSubject;if(o&&(T(o)&&this._events.emit(e.NODE_DOUBLE_CLICK,{node:o,event:t.originalEvent,localPoint:i,globalPoint:n}),I(o)&&this._events.emit(e.EDGE_DOUBLE_CLICK,{edge:o,event:t.originalEvent,localPoint:i,globalPoint:n})),this._events.emit(e.MOUSE_DOUBLE_CLICK,{subject:o,event:t.originalEvent,localPoint:i,globalPoint:n}),!o){const e=t.target._zoom+1;t.target.setZoomAround(t.layerPoint,e)}(s.isStateChanged||s.changedSubject)&&(this._invalidateStyles(),this._renderer.render(this._graph))}}),t.on("moveend",t=>{const e=t.target._mapPane._leaflet_pos,i=this._getStyleScale();this._renderer.transform=Object.assign(Object.assign({},e),{k:i}),this._renderer.render(this._graph)}),t.on("drag",t=>{const i=t.target._mapPane._leaflet_pos,n=this._getStyleScale();this._renderer.transform=Object.assign(Object.assign({},i),{k:n}),this._renderer.render(this._graph),this._events.emit(e.TRANSFORM,{transform:Object.assign(Object.assign({},i),{k:n})})}),t}_updateGraphPositions(){const t=this._graph.getNodes(),e=this._getStyleScale();for(let i=0;i{this._leaflet.attributionControl.setPrefix(t.attribution),this._leaflet.eachLayer(t=>this._leaflet.removeLayer(t)),t.instance.addTo(this._leaflet)})}}})(),n})()); \ No newline at end of file diff --git a/docs/site/public/orb.worker.min.js b/docs/site/public/orb.worker.min.js deleted file mode 100644 index 297684e..0000000 --- a/docs/site/public/orb.worker.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Orb=e():t.Orb=e()}(self,()=>(()=>{"use strict";var t,e,i={491(t,e,i){var s,n=i(960),o=i(955),a=i(608),r=i(635),d=i(390),l=i(349),h=i(93);!function(t){t.SIMULATION_START="simulation-start",t.SIMULATION_STEP="simulation-step",t.SIMULATION_PROGRESS="simulation-progress",t.SIMULATION_END="simulation-end",t.NODE_DRAG="node-drag",t.NODE_DRAG_END="node-drag-end",t.SETTINGS_UPDATE="settings-update"}(s||(s={}));const u=t=>t instanceof Date,c=t=>Array.isArray(t),_=t=>null!==t&&"object"==typeof t&&"Object"===t.constructor.name,g=t=>u(t)?p(t):c(t)?x(t):_(t)?m(t):t,f=(t,e)=>{const i=u(t),s=u(e);if(i&&!s||!i&&s)return!1;if(i&&s)return t.getTime()===e.getTime();const n=c(t),o=c(e);if(n&&!o||!n&&o)return!1;if(n&&o)return t.length===e.length&&t.every((t,i)=>f(t,e[i]));const a=_(t),r=_(e);if(a&&!r||!a&&r)return!1;if(a&&r){const i=Object.keys(t),s=Object.keys(e);return!!f(i,s)&&i.every(i=>f(t[i],e[i]))}return t===e},p=t=>new Date(t),x=t=>t.map(t=>g(t)),m=t=>{const e={};return Object.keys(t).forEach(i=>{e[i]=g(t[i])}),e},y={radius:100,centerX:0,centerY:0},T=t=>100*(t>0?t:1),S={useGPU:!1,isSimulatingOnDataUpdate:!0,isSimulatingOnSettingsUpdate:!0,isSimulatingOnUnstick:!0,isPhysicsEnabled:!1,alpha:{alpha:1,alphaMin:.05,alphaDecay:.028,alphaTarget:0},centering:{x:0,y:0,strength:1},collision:{radius:15,strength:1,iterations:1},links:{distance:50,strength:1,iterations:1},manyBody:{strength:-100,theta:.9,distanceMin:1,distanceMax:T(50)},positioning:{forceX:{x:0,strength:.1},forceY:{y:0,strength:.1}},anchorX:"center",anchorY:"center"},v={rowGap:50,colGap:50},A={nodeGap:50,levelGap:50,treeGap:100,orientation:"vertical",reversed:!1};class D{constructor(){this._listeners=new Map}once(t,e){const i={callable:e,isOnce:!0},s=this._listeners.get(t);return s?s.push(i):this._listeners.set(t,[i]),this}on(t,e){const i={callable:e},s=this._listeners.get(t);return s?s.push(i):this._listeners.set(t,[i]),this}off(t,e){const i=this._listeners.get(t);if(i){const s=i.filter(t=>t.callable!==e);this._listeners.set(t,s)}return this}emit(t,e){const i=this._listeners.get(t);if(!i||0===i.length)return!1;let s=!1;for(let t=0;t!t.isOnce);this._listeners.set(t,e)}return!0}eventNames(){return[...this._listeners.keys()]}listenerCount(t){const e=this._listeners.get(t);return e?e.length:0}listeners(t){const e=this._listeners.get(t);return e?e.map(t=>t.callable):[]}addListener(t,e){return this.on(t,e)}removeListener(t,e){return this.off(t,e)}removeAllListeners(t){return t?this._listeners.delete(t):this._listeners.clear(),this}}class E extends D{constructor(){super(...arguments),this._nodes=[],this._edges=[],this._nodeIndexByNodeId={},this._cancelSimulation=!1,this._schedulerPort=null}terminate(){var t;this._cancelSimulation=!0,null===(t=this._schedulerPort)||void 0===t||t.close(),this._schedulerPort=null,this.removeAllListeners()}_scheduleNext(t){if("undefined"!=typeof MessageChannel){const e=new MessageChannel;this._schedulerPort=e.port2,e.port1.onmessage=()=>{this._schedulerPort=null,t()},e.port2.postMessage(null)}else setTimeout(t,0)}_rebuildNodeIndex(){this._nodeIndexByNodeId={};for(let t=0;t0&&this.activateSimulation())}setupData(t){this.clearData(),this._initializeNewData(t),this._settings.isSimulatingOnDataUpdate&&(this._updateSimulationData(),this._runSimulation())}mergeData(t){this._initializeNewData(t),this._settings.isPhysicsEnabled||this._pinNodes(),this._settings.isSimulatingOnDataUpdate&&(this._updateSimulationData(),this.activateSimulation())}updateData(t){const e=new Set(t.nodes.map(t=>t.id)),i=this._nodes.filter(t=>e.has(t.id)),s=t.nodes.filter(t=>void 0===this._nodeIndexByNodeId[t.id]);this._nodes=[...i,...s],this._rebuildNodeIndex(),this._edges=t.edges,this._settings.isSimulatingOnSettingsUpdate&&(this._updateSimulationData(),this.activateSimulation())}deleteData(t){if(t.nodeIds){const e=new Set(t.nodeIds);this._nodes=this._nodes.filter(t=>!e.has(t.id))}if(t.edgeIds){const e=new Set(t.edgeIds);this._edges=this._edges.filter(t=>!e.has(t.id))}this._rebuildNodeIndex(),this._settings.isSimulatingOnDataUpdate&&(this._updateSimulationData(),this.activateSimulation())}patchData(t){if(t.nodes){const e={};for(let t=0;t0&&this.activateSimulation()}terminate(){var t;super.terminate(),null===(t=this._simulation)||void 0===t||t.stop()}_resetSimulation(){this._simulation&&(this._simulation.stop(),this._simulation.on("tick",null).on("end",null)),this._linkForce=(0,n.A)(this._edges).id(t=>t.id),this._simulation=(0,o.A)(this._nodes).force("link",this._linkForce).stop(),this._applySettingsToSimulation(this._settings),this._simulation.on("tick",()=>{this.emit(s.SIMULATION_STEP,{nodes:this._nodes,edges:this._edges})}),this._simulation.on("end",()=>{this._isDragging=!1,this._isStabilizing=!1,this.emit(s.SIMULATION_END,{nodes:this._nodes,edges:this._edges}),this._settings.isPhysicsEnabled||this._pinNodes()})}_runSimulation(t){if(this._isStabilizing||this._cancelSimulation)return;(this._settings.isPhysicsEnabled||(null==t?void 0:t.isUpdatingSettings))&&this._unpinNodes(),this.emit(s.SIMULATION_START,void 0),this._isStabilizing=!0,this._simulation.alpha(this._settings.alpha.alpha).alphaTarget(this._settings.alpha.alphaTarget).stop();const e=Math.min(500,Math.ceil(Math.log(this._settings.alpha.alphaMin)/Math.log(1-this._settings.alpha.alphaDecay)));let i=-1,n=0;const o=()=>{if(this._cancelSimulation)return this._isStabilizing=!1,void(this._cancelSimulation=!1);const t=Math.min(n+100,e);for(;ni&&(i=t,this.emit(s.SIMULATION_PROGRESS,{nodes:this._nodes,edges:this._edges,progress:t/100}))}n=n)continue;d<1&&(d=1);const u=-t*e/d;o.vx+=a*u,o.vy+=r*u}}}return o.initialize=t=>{s=t},o}(t.manyBody.strength,t.manyBody.distanceMax,()=>this._edges)):this._simulation.force("edgeMidpointRepulsion",null)}if(null===t.manyBody&&(this._simulation.force("charge",null),this._simulation.force("edgeMidpointRepulsion",null)),null===(e=t.positioning)||void 0===e?void 0:e.forceX){const e=(0,d.A)(t.positioning.forceX.x).strength(t.positioning.forceX.strength);this._simulation.force("x",e)}if(null===(null===(i=t.positioning)||void 0===i?void 0:i.forceX)&&this._simulation.force("x",null),null===(s=t.positioning)||void 0===s?void 0:s.forceY){const e=(0,l.A)(t.positioning.forceY.y).strength(t.positioning.forceY.strength);this._simulation.force("y",e)}if(null===(null===(n=t.positioning)||void 0===n?void 0:n.forceY)&&this._simulation.force("y",null),t.centering){const e=(0,h.A)(t.centering.x,t.centering.y).strength(t.centering.strength);this._simulation.force("center",e)}null===t.centering&&this._simulation.force("center",null)}}class b extends Error{constructor(t){super(t),this.message=t,Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}}var I;!function(t){t.VERTEX="vertex",t.FRAGMENT="fragment"}(I||(I={}));const M=(t,e,i)=>{const s=t.createShader(i===I.VERTEX?t.VERTEX_SHADER:t.FRAGMENT_SHADER);if(!s)throw new b("Failed to create shader.");if(t.shaderSource(s,e),t.compileShader(s),!t.getShaderParameter(s,t.COMPILE_STATUS)){const e=t.getShaderInfoLog(s);throw t.deleteShader(s),new b(`Failed to compile shader: ${e}`)}return s};class R extends E{constructor(t){super(),this._isStabilizing=!1,this._isDragging=!1,this._dragLoopRunning=!1,this._pendingRestart=!1,this._simulationGeneration=0,this._currentAlpha=0,this._currentStep=0,this._totalSteps=0,this._dragAlpha=0,this._dragNeedsReheat=!1,this._dirtyNodes=new Set,this._forceProgram=null,this._quadBuffer=null,this._quadVAO=null,this._stateTexA=null,this._stateTexB=null,this._fixedTex=null,this._fboA=null,this._fboB=null,this._texWidth=0,this._treeDataTexture=null,this._treeChildrenTexture=null,this._treeGeometryTexture=null,this._adjOffsetsTexture=null,this._adjEdgesTexture=null,this._cachedAdjacency=null,this._treeTexWidth=1,this._treeNodeCount=0,this._pingPong=!0,this._uniforms={},this.type="force",this._settings=Object.assign(Object.assign({},S),t);const e=document.createElement("canvas").getContext("webgl2");if(!e)throw new b("Failed to create WebGL2 context for GPU force layout engine.");this._gl=e,this._initGPU(),this.clearData()}setSettings(t){const e=t;this._initialSettings||(this._initialSettings=Object.assign(g(S),e));const i=g(this._settings);Object.assign(this._settings,e),f(this._settings,i)||(this.emit(s.SETTINGS_UPDATE,{settings:{type:"force",options:this._settings}}),i.isPhysicsEnabled&&!e.isPhysicsEnabled?this.stopSimulation():this._settings.isSimulatingOnSettingsUpdate&&this._nodes.length>0&&this.activateSimulation())}setupData(t){this.clearData(),this._initializeNewData(t),this._settings.isSimulatingOnDataUpdate&&this._runSimulation()}mergeData(t){this._initializeNewData(t),this._settings.isPhysicsEnabled||this._pinNodes(),this._settings.isSimulatingOnDataUpdate&&this.activateSimulation()}updateData(t){const e=new Set(t.nodes.map(t=>t.id)),i=this._nodes.filter(t=>e.has(t.id)),s=t.nodes.filter(t=>void 0===this._nodeIndexByNodeId[t.id]);this._nodes=[...i,...s],this._rebuildNodeIndex(),this._edges=t.edges,this._cachedAdjacency=null,this._settings.isSimulatingOnSettingsUpdate&&this.activateSimulation()}deleteData(t){if(t.nodeIds){const e=new Set(t.nodeIds);this._nodes=this._nodes.filter(t=>!e.has(t.id))}if(t.edgeIds){const e=new Set(t.edgeIds);this._edges=this._edges.filter(t=>!e.has(t.id))}this._rebuildNodeIndex(),this._cachedAdjacency=null,this._settings.isSimulatingOnDataUpdate&&this.activateSimulation()}patchData(t){if(t.nodes){const e={};for(let t=0;t0&&this.activateSimulation()}terminate(){var t;super.terminate();const e=this._gl;e&&(e.deleteBuffer(this._quadBuffer),e.deleteVertexArray(this._quadVAO),e.deleteProgram(this._forceProgram),e.deleteTexture(this._stateTexA),e.deleteTexture(this._stateTexB),e.deleteTexture(this._fixedTex),e.deleteTexture(this._treeDataTexture),e.deleteTexture(this._treeChildrenTexture),e.deleteTexture(this._treeGeometryTexture),e.deleteTexture(this._adjOffsetsTexture),e.deleteTexture(this._adjEdgesTexture),e.deleteFramebuffer(this._fboA),e.deleteFramebuffer(this._fboB),null===(t=e.getExtension("WEBGL_lose_context"))||void 0===t||t.loseContext())}reheat(){const t=this._settings.alpha;this._currentAlpha=t.alpha,this._totalSteps=Math.min(500,Math.ceil(Math.log(t.alphaMin)/Math.log(1-t.alphaDecay))),this._currentStep=0,this._isStabilizing||(this._ensurePositions(),this._uploadDataToGPU(),this._cachedAdjacency||this._buildAndUploadAdjacency(),this._startSimulationLoop())}_runSimulation(){this._isStabilizing||this._cancelSimulation||(this._ensurePositions(),this._uploadDataToGPU(),this._buildAndUploadAdjacency(),this._startSimulationLoop())}_startDragLoop(){if(this._dragLoopRunning)return;this._dragLoopRunning=!0;const t=this._settings.alpha.alphaDecay,e=this._settings.alpha.alphaMin;this._dragAlpha=.3,this._dragNeedsReheat=!1;const i=()=>{this._isDragging?(this._dragNeedsReheat&&(this._dragAlpha=.3,this._dragNeedsReheat=!1),this._dragAlpha+=(0-this._dragAlpha)*t,this._dragAlpha{if(t!==this._simulationGeneration)return;if(this._cancelSimulation)return this._isStabilizing=!1,this._cancelSimulation=!1,void this.emit(s.SIMULATION_END,{nodes:this._nodes,edges:this._edges});if(this._readbackFromGPU(),this._pendingRestart)return this._isStabilizing=!1,this._pendingRestart=!1,this._ensurePositions(),this._uploadDataToGPU(),this._cachedAdjacency||this._buildAndUploadAdjacency(),void this._startSimulationLoop();this._flushDirtyNodes(),this._buildAndUploadQuadTree();const r=Math.min(this._currentStep+1,this._totalSteps);for(;this._currentStepo&&(o=d,this.emit(s.SIMULATION_PROGRESS,{nodes:this._nodes,edges:this._edges,progress:d/100})),this._currentStep0&&(n=n.concat(t))}const o=function(t,e){var i,s;const n=t.length;if(0===n)return{treeData:new Float32Array(0),treeChildren:new Float32Array(0),treeGeometry:new Float32Array(0),nodeCount:0,texWidth:1};let o=1/0,a=1/0,r=-1/0,d=-1/0;for(let e=0;er&&(r=i),s>d&&(d=s)}let l=Math.max(r-o,d-a);l<1e-6&&(l=1),l*=1.01;const h=.5*l,u=.5*(o+r)-h,c=.5*(a+d)-h,_=[];function g(t){const e=_.length;return _.push({cx:0,cy:0,charge:0,size:t,bodyIndex:-1,children:[null,null,null,null]}),e}const f=g(l),p=[u],x=[c];function m(t,e,i,s,n){return 2*(e>=s+.5*n?1:0)+(t>=i+.5*n?1:0)}function y(t,e,i,s){const n=.5*s;return{cx0:1&t?e+n:e,cy0:2&t?i+n:i,csz:n}}function T(t,i,s){let n=f,o=u,a=c,r=l;for(let d=0;d<50;d++){const d=_[n];if(-1===d.bodyIndex&&null===d.children[0]&&null===d.children[1]&&null===d.children[2]&&null===d.children[3])return d.bodyIndex=t,d.cx=i,d.cy=s,void(d.charge=e);if(d.bodyIndex>=0){const t=d.bodyIndex,i=d.cx,s=d.cy;d.bodyIndex=-1;const n=m(i,s,o,a,r),{cx0:l,cy0:h,csz:u}=y(n,o,a,r),c=g(u);p[c]=l,x[c]=h,d.children[n]=c,_[c].bodyIndex=t,_[c].cx=i,_[c].cy=s,_[c].charge=e}const l=m(i,s,o,a,r);if(null===d.children[l]){const{cx0:n,cy0:h,csz:u}=y(l,o,a,r),c=g(u);return p[c]=n,x[c]=h,d.children[l]=c,_[c].bodyIndex=t,_[c].cx=i,_[c].cy=s,void(_[c].charge=e)}const{cx0:h,cy0:u,csz:c}=y(l,o,a,r);n=d.children[l],o=h,a=u,r=c}}for(let e=0;e=0)return;let s=0,n=0,o=0,a=0;for(let e=0;e<4;e++){const r=i.children[e];if(null===r)continue;t(r);const d=_[r],l=Math.abs(d.charge);s+=d.charge,n+=d.cx*l,o+=d.cy*l,a+=l}a>0&&(i.cx=n/a,i.cy=o/a),i.charge=s}(f);const S=_.length,v=Math.ceil(Math.sqrt(S)),A=v*v,D=new Float32Array(4*A),E=new Float32Array(4*A),N=new Float32Array(4*A);for(let t=0;t=0?D[n+3]=-(e.bodyIndex+1):D[n+3]=e.size,E[n]=null!==e.children[0]?e.children[0]:-1,E[n+1]=null!==e.children[1]?e.children[1]:-1,E[n+2]=null!==e.children[2]?e.children[2]:-1,E[n+3]=null!==e.children[3]?e.children[3]:-1,N[n]=null!==(i=p[t])&&void 0!==i?i:0,N[n+1]=null!==(s=x[t])&&void 0!==s?s:0,N[n+2]=e.size,N[n+3]=0}for(let t=S;t= uNodeCount) {\r\n fragColor = vec4(0.0);\r\n return;\r\n }\r\n\r\n vec4 fixedData = texelFetch(uFixed, fc, 0);\r\n if (fixedData.x > 0.5) {\r\n fragColor = vec4(fixedData.yz, 0.0, 0.0);\r\n return;\r\n }\r\n\r\n vec4 state = texelFetch(uState, fc, 0);\r\n vec2 pos = state.xy;\r\n vec2 vel = state.zw;\r\n\r\n if (uHasManyBody > 0.5 && uTreeNodeCount > 0) {\r\n int stack[128];\r\n int top = 0;\r\n stack[top++] = 0;\r\n\r\n while (top > 0) {\r\n int idx = stack[--top];\r\n vec4 data = texelFetch(uTreeData, texCoord(idx, uTreeTexWidth), 0);\r\n float w = data.w;\r\n\r\n if (w < -0.5) {\r\n int bodyIdx = int(-w - 0.5);\r\n if (bodyIdx != nodeId) {\r\n vec2 delta = data.xy - pos;\r\n float distSq = dot(delta, delta);\r\n\r\n if (distSq < 1e-8) {\r\n delta = vec2(float(nodeId) * 1e-4 - float(bodyIdx) * 1e-4 + 1e-4, 1e-4);\r\n distSq = dot(delta, delta);\r\n }\r\n\r\n if (distSq < uDistanceMax2) {\r\n float l = distSq;\r\n if (l < uDistanceMin2) l = sqrt(uDistanceMin2 * l);\r\n vel += delta * (data.z * uAlpha / max(l, 1e-6));\r\n }\r\n }\r\n } else {\r\n vec2 delta = data.xy - pos;\r\n float distSq = dot(delta, delta);\r\n\r\n if (distSq > 0.0 && w * w / distSq < uTheta2) {\r\n if (distSq < uDistanceMax2) {\r\n float l = distSq;\r\n if (l < uDistanceMin2) l = sqrt(uDistanceMin2 * l);\r\n vel += delta * (data.z * uAlpha / max(l, 1e-6));\r\n }\r\n } else {\r\n vec4 ch = texelFetch(uTreeChildren, texCoord(idx, uTreeTexWidth), 0);\r\n if (ch.w >= 0.0 && top < 64) stack[top++] = int(ch.w + 0.5);\r\n if (ch.z >= 0.0 && top < 64) stack[top++] = int(ch.z + 0.5);\r\n if (ch.y >= 0.0 && top < 64) stack[top++] = int(ch.y + 0.5);\r\n if (ch.x >= 0.0 && top < 64) stack[top++] = int(ch.x + 0.5);\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (uHasCollision > 0.5 && uCollisionRadius > 0.0 && uTreeNodeCount > 0) {\r\n float collisionDiam = uCollisionRadius * 2.0;\r\n vec2 predictedPos = state.xy + state.zw;\r\n int stack[64];\r\n int top = 0;\r\n stack[top++] = 0;\r\n\r\n while (top > 0) {\r\n int idx = stack[--top];\r\n vec4 data = texelFetch(uTreeData, texCoord(idx, uTreeTexWidth), 0);\r\n float w = data.w;\r\n\r\n if (w < -0.5) {\r\n int bodyIdx = int(-w - 0.5);\r\n if (bodyIdx != nodeId && bodyIdx < uNodeCount) {\r\n vec2 delta = data.xy - predictedPos;\r\n float dist = length(delta);\r\n\r\n if (dist < collisionDiam && dist > 0.0) {\r\n float push = (collisionDiam - dist) * uCollisionStrength;\r\n vel -= (delta / dist) * push * 0.5;\r\n }\r\n }\r\n } else {\r\n vec4 geo = texelFetch(uTreeGeometry, texCoord(idx, uTreeTexWidth), 0);\r\n float cellSize = geo.z;\r\n vec2 nearest = clamp(predictedPos, geo.xy, geo.xy + cellSize);\r\n float distToCell = length(nearest - predictedPos);\r\n\r\n if (distToCell < collisionDiam) {\r\n vec4 ch = texelFetch(uTreeChildren, texCoord(idx, uTreeTexWidth), 0);\r\n if (ch.w >= 0.0 && top < 64) stack[top++] = int(ch.w + 0.5);\r\n if (ch.z >= 0.0 && top < 64) stack[top++] = int(ch.z + 0.5);\r\n if (ch.y >= 0.0 && top < 64) stack[top++] = int(ch.y + 0.5);\r\n if (ch.x >= 0.0 && top < 64) stack[top++] = int(ch.x + 0.5);\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (uHasLinks > 0.5) {\r\n vec4 offData = texelFetch(uAdjOffsets, texCoord(nodeId, uAdjOffsetsTexWidth), 0);\r\n int start = int(offData.x + 0.5);\r\n int count = int(offData.y + 0.5);\r\n\r\n for (int e = 0; e < count; e++) {\r\n vec4 edgeData = texelFetch(uAdjEdges, texCoord(start + e, uAdjEdgesTexWidth), 0);\r\n int targetId = int(edgeData.x + 0.5);\r\n float restDist = edgeData.y;\r\n float strength = edgeData.z;\r\n float dirBias = edgeData.w;\r\n\r\n vec4 targetState = texelFetch(uState, texCoord(targetId, uTexWidth), 0);\r\n vec2 delta = (targetState.xy + targetState.zw) - (state.xy + state.zw);\r\n float d = length(delta);\r\n\r\n if (d < 1e-6) {\r\n delta = vec2(1e-3, 1e-3);\r\n d = length(delta);\r\n }\r\n\r\n float scale = (d - restDist) / d * uAlpha * strength;\r\n vel += delta * scale * dirBias;\r\n }\r\n }\r\n\r\n if (uHasCentering > 0.5) {\r\n vel += (uCenter - pos) * uCenterStrength * uAlpha;\r\n }\r\n\r\n if (uHasPositioning > 0.5) {\r\n vel.x += (uForceXTarget - pos.x) * uForceXStrength * uAlpha;\r\n vel.y += (uForceYTarget - pos.y) * uForceYStrength * uAlpha;\r\n }\r\n\r\n vel *= uDamping;\r\n pos += vel;\r\n\r\n fragColor = vec4(pos, vel);\r\n}\r\n",I.FRAGMENT),s=t.createProgram();if(!s)throw new b("Failed to create program.");if(this._forceProgram=s,t.attachShader(s,e),t.attachShader(s,i),t.linkProgram(s),!t.getProgramParameter(s,t.LINK_STATUS)){const e=t.getProgramInfoLog(s);throw new b(`Failed to link force program: ${e}`)}this._cacheUniformLocations(s),this._quadBuffer=t.createBuffer();const n=new Float32Array([-1,-1,1,-1,-1,1,1,1]);t.bindBuffer(t.ARRAY_BUFFER,this._quadBuffer),t.bufferData(t.ARRAY_BUFFER,n,t.STATIC_DRAW),this._quadVAO=t.createVertexArray(),t.bindVertexArray(this._quadVAO);const o=t.getAttribLocation(s,"aPosition");t.enableVertexAttribArray(o),t.vertexAttribPointer(o,2,t.FLOAT,!1,0,0),t.bindVertexArray(null),this._stateTexA=t.createTexture(),this._stateTexB=t.createTexture(),this._fixedTex=t.createTexture(),this._treeDataTexture=t.createTexture(),this._treeChildrenTexture=t.createTexture(),this._treeGeometryTexture=t.createTexture(),this._adjOffsetsTexture=t.createTexture(),this._adjEdgesTexture=t.createTexture(),this._fboA=t.createFramebuffer(),this._fboB=t.createFramebuffer()}_cacheUniformLocations(t){const e=this._gl,i=["uState","uFixed","uTreeData","uTreeChildren","uTreeGeometry","uAdjOffsets","uAdjEdges","uNodeCount","uTexWidth","uAlpha","uDamping","uManyBodyStrength","uTheta2","uDistanceMin2","uDistanceMax2","uTreeNodeCount","uTreeTexWidth","uAdjOffsetsTexWidth","uAdjEdgesTexWidth","uCenter","uCenterStrength","uCollisionRadius","uCollisionStrength","uForceXTarget","uForceXStrength","uForceYTarget","uForceYStrength","uHasManyBody","uHasLinks","uHasCentering","uHasCollision","uHasPositioning"];for(const s of i)this._uniforms[s]=e.getUniformLocation(t,s)}_uploadDataToGPU(){var t,e,i,s,n,o,a,r;const d=this._gl,l=this._nodes.length;this._texWidth=Math.max(1,Math.ceil(Math.sqrt(l)));const h=this._texWidth*this._texWidth,u=new Float32Array(4*h),c=new Float32Array(4*h);for(let d=0;d0?t.distanceMax:T(null!==(i=null===(e=this._settings.links)||void 0===e?void 0:e.distance)&&void 0!==i?i:50);u.uniform1f(g.uDistanceMax2,n*n),u.uniform1i(g.uTreeNodeCount,this._treeNodeCount),u.uniform1i(g.uTreeTexWidth,this._treeTexWidth)}const p=null!==this._cachedAdjacency&&this._edges.length>0;u.uniform1f(g.uHasLinks,p?1:0),p&&(u.uniform1i(g.uAdjOffsetsTexWidth,this._cachedAdjacency.offsetsTexWidth),u.uniform1i(g.uAdjEdgesTexWidth,this._cachedAdjacency.edgesTexWidth)),u.uniform1f(g.uHasCentering,0);const x=null!==this._settings.collision&&void 0!==this._settings.collision;u.uniform1f(g.uHasCollision,x?1:0),x&&(u.uniform1f(g.uCollisionRadius,this._settings.collision.radius),u.uniform1f(g.uCollisionStrength,this._settings.collision.strength));const m=null!==this._settings.positioning&&void 0!==this._settings.positioning;if(u.uniform1f(g.uHasPositioning,m?1:0),m){const t=this._settings.positioning;u.uniform1f(g.uForceXTarget,null!==(n=null===(s=t.forceX)||void 0===s?void 0:s.x)&&void 0!==n?n:0),u.uniform1f(g.uForceXStrength,null!==(a=null===(o=t.forceX)||void 0===o?void 0:o.strength)&&void 0!==a?a:0),u.uniform1f(g.uForceYTarget,null!==(d=null===(r=t.forceY)||void 0===r?void 0:r.y)&&void 0!==d?d:0),u.uniform1f(g.uForceYStrength,null!==(h=null===(l=t.forceY)||void 0===l?void 0:l.strength)&&void 0!==h?h:0)}const y=this._pingPong?this._stateTexA:this._stateTexB,S=this._pingPong?this._fboB:this._fboA;u.activeTexture(u.TEXTURE0),u.bindTexture(u.TEXTURE_2D,y),u.uniform1i(g.uState,0),u.activeTexture(u.TEXTURE1),u.bindTexture(u.TEXTURE_2D,this._fixedTex),u.uniform1i(g.uFixed,1),u.activeTexture(u.TEXTURE2),u.bindTexture(u.TEXTURE_2D,this._treeDataTexture),u.uniform1i(g.uTreeData,2),u.activeTexture(u.TEXTURE3),u.bindTexture(u.TEXTURE_2D,this._treeChildrenTexture),u.uniform1i(g.uTreeChildren,3),u.activeTexture(u.TEXTURE4),u.bindTexture(u.TEXTURE_2D,this._adjOffsetsTexture),u.uniform1i(g.uAdjOffsets,4),u.activeTexture(u.TEXTURE5),u.bindTexture(u.TEXTURE_2D,this._adjEdgesTexture),u.uniform1i(g.uAdjEdges,5),u.activeTexture(u.TEXTURE6),u.bindTexture(u.TEXTURE_2D,this._treeGeometryTexture),u.uniform1i(g.uTreeGeometry,6),u.bindFramebuffer(u.FRAMEBUFFER,S),u.viewport(0,0,this._texWidth,this._texWidth),u.bindVertexArray(this._quadVAO),u.drawArrays(u.TRIANGLE_STRIP,0,4),u.bindVertexArray(null),u.bindFramebuffer(u.FRAMEBUFFER,null),this._pingPong=!this._pingPong}_readbackFromGPU(){const t=this._gl,e=this._nodes.length;if(0===e)return;const i=this._pingPong?this._fboA:this._fboB,s=this._texWidth*this._texWidth,n=new Float32Array(4*s);t.bindFramebuffer(t.FRAMEBUFFER,i),t.readPixels(0,0,this._texWidth,this._texWidth,t.RGBA,t.FLOAT,n),t.bindFramebuffer(t.FRAMEBUFFER,null);for(let t=0;tt.id)),i=this._nodes.filter(t=>e.has(t.id)),s=t.nodes.filter(t=>void 0===this._nodeIndexByNodeId[t.id]);this._nodes=[...i,...s],this._edges=t.edges,this._rebuildNodeIndex(),this._calculateAndEmit()}deleteData(t){if(t.nodeIds){const e=new Set(t.nodeIds);this._nodes=this._nodes.filter(t=>!e.has(t.id))}if(t.edgeIds){const e=new Set(t.edgeIds);this._edges=this._edges.filter(t=>!e.has(t.id))}this._rebuildNodeIndex(),this._calculateAndEmit()}patchData(t){if(t.nodes)for(let e=0;e0&&this._calculateAndEmit()}terminate(){this._pendingRecalculation=!1,super.terminate()}_calculateAndEmit(){0===this._nodes.length||this._cancelSimulation||(this._isCalculating?this._pendingRecalculation=!0:(this._isCalculating=!0,this.emit(s.SIMULATION_START,void 0),this.calculatePositions(this._nodes,this._edges,t=>{this.emit(s.SIMULATION_PROGRESS,{nodes:this._nodes,edges:this._edges,progress:t})},()=>this._cancelSimulation,()=>{this._isCalculating=!1,this._cancelSimulation||this.emit(s.SIMULATION_END,{nodes:this._nodes,edges:this._edges}),this._cancelSimulation=!1,this._pendingRecalculation&&(this._pendingRecalculation=!1,this._calculateAndEmit())})))}_emitProgress(t,e,i,s){const n=Math.round(100*t/e);return n>i?(s(n/100),n):i}}class P extends U{constructor(t){super(),this.type="circular",this._config=Object.assign(Object.assign({},y),t)}calculatePositions(t,e,i,s,n){const o=2*Math.PI/t.length;let a=-1,r=0;const d=()=>{if(s())return void n();const e=Math.min(r+5e3,t.length);for(;r{if(s())return void n();const e=Math.min(d+5e3,t.length);for(;d{if(s()||c>=r.length)return!s()&&this._config.reversed&&this._applyReversal(t,d,l),void n();const e=this._assignLevels(r[c],o,a),g=Math.max(...Array.from(e.values()).map(t=>t.length));e.size*this._config.levelGap>l&&(l=e.size*this._config.levelGap);let f=0===c?0:this._config.treeGap+d;c>0&&(f+=(g-1)*this._config.nodeGap/2);for(let i=0;id&&(d=r),void 0!==a&&(t[a].x="horizontal"===this._config.orientation?s:r,t[a].y="horizontal"===this._config.orientation?r:s),h++}}c++,c0;){const t=d.pop();if(void 0===t)continue;r.push(t);const n=null!==(i=e.get(t))&&void 0!==i?i:[];for(let t=0;t{var e;return 0===(null!==(e=i.get(t))&&void 0!==e?e:0)});void 0===r&&(r=t.reduce((t,e)=>{var s,n;return(null!==(s=i.get(e))&&void 0!==s?s:0)<(null!==(n=i.get(t))&&void 0!==n?n:0)?e:t}));const d=[[r,0]];for(const[t,i]of d){if(a.has(t))continue;a.add(t),o.has(i)?null===(s=o.get(i))||void 0===s||s.push(t):o.set(i,[t]);const r=null!==(n=e.get(t))&&void 0!==n?n:[];for(let t=0;tpostMessage(t),L={[C.SetupData]:(t,{data:e})=>t.setupData(e),[C.MergeData]:(t,{data:e})=>t.mergeData(e),[C.UpdateData]:(t,{data:e})=>t.updateData(e),[C.DeleteData]:(t,{data:e})=>t.deleteData(e),[C.PatchData]:(t,{data:e})=>t.patchData(e),[C.ClearData]:t=>t.clearData(),[C.ActivateSimulation]:t=>t.activateSimulation(),[C.StopSimulation]:t=>t.stopSimulation(),[C.StartDragNode]:t=>t.startDragNode(),[C.DragNode]:(t,{data:e})=>t.dragNode(e.id,{x:e.x,y:e.y}),[C.EndDragNode]:(t,{data:e})=>t.endDragNode(e.id),[C.FixNodes]:(t,{data:e})=>t.fixNodes(e.nodes),[C.ReleaseNodes]:(t,{data:e})=>t.releaseNodes(e.nodes)};addEventListener("message",({data:t})=>{if(t.type===C.SetSettings){const i=t.data;return i.type===(null==G?void 0:G.type)&&i.options?void(null==G||G.setSettings(i.options)):(null==G||G.removeAllListeners(),null==G||G.terminate(),G=w.create(i),(e=G).on(s.SIMULATION_START,()=>j({type:B.SIMULATION_START})),e.on(s.SIMULATION_PROGRESS,t=>j({type:B.SIMULATION_PROGRESS,data:t})),e.on(s.SIMULATION_END,t=>j({type:B.SIMULATION_END,data:t})),e.on(s.SIMULATION_STEP,t=>j({type:B.SIMULATION_STEP,data:t})),e.on(s.NODE_DRAG,t=>j({type:B.NODE_DRAG,data:t})),void e.on(s.SETTINGS_UPDATE,t=>j({type:B.SETTINGS_UPDATE,data:t})))}var e;if(G){const e=L[t.type];null==e||e(G,t)}})}},s={};function n(t){var e=s[t];if(void 0!==e)return e.exports;var o=s[t]={exports:{}};return i[t](o,o.exports,n),o.exports}return n.m=i,n.x=()=>{var t=n.O(void 0,[290],()=>n(491));return n.O(t)},t=[],n.O=(e,i,s,o)=>{if(!i){var a=1/0;for(h=0;h=o)&&Object.keys(n.O).every(t=>n.O[t](i[d]))?i.splice(d--,1):(r=!1,o0&&t[h-1][2]>o;h--)t[h]=t[h-1];t[h]=[i,s,o]},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.f={},n.e=t=>Promise.all(Object.keys(n.f).reduce((e,i)=>(n.f[i](t,e),e),[])),n.u=t=>{if(290===t)return"orb.worker.vendor.min.js"},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{var t;n.g.importScripts&&(t=n.g.location+"");var e=n.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var i=e.getElementsByTagName("script");if(i.length)for(var s=i.length-1;s>-1&&(!t||!/^http(s?):/.test(t));)t=i[s--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=t})(),(()=>{var t={89:1};n.f.i=(e,i)=>{t[e]||importScripts(n.p+n.u(e))};var e=self.webpackChunkOrb=self.webpackChunkOrb||[],i=e.push.bind(e);e.push=e=>{var[s,o,a]=e;for(var r in o)n.o(o,r)&&(n.m[r]=o[r]);for(a&&a(n);s.length;)t[s.pop()]=1;i(e)}})(),e=n.x,n.x=()=>n.e(290).then(e),n.x()})()); \ No newline at end of file diff --git a/docs/site/public/orb.worker.vendor.min.js b/docs/site/public/orb.worker.vendor.min.js deleted file mode 100644 index 4de2d0f..0000000 --- a/docs/site/public/orb.worker.vendor.min.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunkOrb=self.webpackChunkOrb||[]).push([[290],{89(t,n,r){r.d(n,{A:()=>f});var e={value:()=>{}};function i(){for(var t,n=0,r=arguments.length,e={};n=0&&(n=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})),f=-1,l=o.length;if(!(arguments.length<2)){if(null!=n&&"function"!=typeof n)throw new Error("invalid callback: "+n);for(;++f0)for(var r,e,i=new Array(r),o=0;oe})},608(t,n,r){r.d(n,{A:()=>f});var e=r(479),i=r(24),o=r(480);function u(t){return t.x+t.vx}function a(t){return t.y+t.vy}function f(t){var n,r,f,l=1,h=1;function s(){for(var t,i,s,v,y,x,d,_=n.length,A=0;Av+h||ey+h||is.index){var c=v-u.x-u.vx,_=y-u.y-u.vy,A=c*c+_*_;At.r&&(t.r=t[n].r)}function v(){if(n){var e,i,o=n.length;for(r=new Array(o),e=0;ee})},480(t,n,r){function e(t){return 1e-6*(t()-.5)}r.d(n,{A:()=>e})},856(t,n,r){r.d(n,{A:()=>i});const e=4294967296;function i(){let t=1;return()=>(t=(1664525*t+1013904223)%e)/e}},960(t,n,r){r.d(n,{A:()=>a});var e=r(24),i=r(480);function o(t){return t.index}function u(t,n){var r=t.get(n);if(!r)throw new Error("node not found: "+n);return r}function a(t){var n,r,a,f,l,h,s=o,c=function(t){return 1/Math.min(f[t.source.index],f[t.target.index])},v=(0,e.A)(30),y=1;function x(e){for(var o=0,u=t.length;o[s(t,n,a),t]));for(e=0,f=new Array(o);ea});var e=r(479),i=r(24),o=r(480),u=r(955);function a(){var t,n,r,a,f,l=(0,i.A)(-30),h=1,s=1/0,c=.81;function v(r){var i,o=t.length,f=(0,e.A)(t,u.x,u.y).visitAfter(x);for(a=r,i=0;i=s)){(t.data!==n||t.next)&&(0===l&&(x+=(l=(0,o.A)(r))*l),0===v&&(x+=(v=(0,o.A)(r))*v),xl,x:()=>u,y:()=>a});var e=r(89),i=r(29),o=r(856);function u(t){return t.x}function a(t){return t.y}var f=Math.PI*(3-Math.sqrt(5));function l(t){var n,r=1,u=.001,a=1-Math.pow(u,1/300),l=0,h=.6,s=new Map,c=(0,i.O1)(x),v=(0,e.A)("tick","end"),y=(0,o.A)();function x(){d(),v.call("tick",n),r1?(null==r?s.delete(t):s.set(t,A(r)),n):s.get(t)},find:function(n,r,e){var i,o,u,a,f,l=0,h=t.length;for(null==e?e=1/0:e*=e,l=0;l1?(v.on(t,r),n):v.on(t)}}}},390(t,n,r){r.d(n,{A:()=>i});var e=r(24);function i(t){var n,r,i,o=(0,e.A)(.1);function u(t){for(var e,o=0,u=n.length;oi});var e=r(24);function i(t){var n,r,i,o=(0,e.A)(.1);function u(t){for(var e,o=0,u=n.length;o=(o=(x+_)/2))?x=o:_=o,(h=r>=(u=(d+A)/2))?d=u:A=u,i=v,!(v=v[s=h<<1|l]))return i[s]=y,t;if(a=+t._x.call(null,v.data),f=+t._y.call(null,v.data),n===a&&r===f)return y.next=v,i?i[s]=y:t._root=y,t;do{i=i?i[s]=new Array(4):t._root=new Array(4),(l=n>=(o=(x+_)/2))?x=o:_=o,(h=r>=(u=(d+A)/2))?d=u:A=u}while((s=h<<1|l)==(c=(f>=u)<<1|a>=o));return i[c]=v,i[s]=y,t}function o(t){var n,r,e,o,u=t.length,a=new Array(u),f=new Array(u),l=1/0,h=1/0,s=-1/0,c=-1/0;for(r=0;rs&&(s=e),oc&&(c=o));if(l>s||h>c)return this;for(this.cover(l,h).cover(s,c),r=0;re,R:()=>o})},17(t,n,r){function e(t,n){if(isNaN(t=+t)||isNaN(n=+n))return this;var r=this._x0,e=this._y0,i=this._x1,o=this._y1;if(isNaN(r))i=(r=Math.floor(t))+1,o=(e=Math.floor(n))+1;else{for(var u,a,f=i-r||1,l=this._root;r>t||t>=i||e>n||n>=o;)switch(a=(ne})},892(t,n,r){function e(){var t=[];return this.visit(function(n){if(!n.length)do{t.push(n.data)}while(n=n.next)}),t}r.d(n,{A:()=>e})},980(t,n,r){function e(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}r.d(n,{A:()=>e})},539(t,n,r){r.d(n,{A:()=>i});var e=r(975);function i(t,n,r){var i,o,u,a,f,l,h,s=this._x0,c=this._y0,v=this._x1,y=this._y1,x=[],d=this._root;for(d&&x.push(new e.A(d,s,c,v,y)),null==r?r=1/0:(s=t-r,c=n-r,v=t+r,y=n+r,r*=r);l=x.pop();)if(!(!(d=l.node)||(o=l.x0)>v||(u=l.y0)>y||(a=l.x1)=A)<<1|t>=_)&&(l=x[x.length-1],x[x.length-1]=x[x.length-1-h],x[x.length-1-h]=l)}else{var g=t-+this._x.call(null,d.data),p=n-+this._y.call(null,d.data),w=g*g+p*p;if(we})},479(t,n,r){r.d(n,{A:()=>x});var e=r(277),i=r(17),o=r(892),u=r(980),a=r(539),f=r(616),l=r(232),h=r(977),s=r(621),c=r(759),v=r(86),y=r(437);function x(t,n,r){var e=new d(null==n?v.U:n,null==r?y.$:r,NaN,NaN,NaN,NaN);return null==t?e:e.addAll(t)}function d(t,n,r,e,i,o){this._x=t,this._y=n,this._x0=r,this._y0=e,this._x1=i,this._y1=o,this._root=void 0}function _(t){for(var n={data:t.data},r=n;t=t.next;)r=r.next={data:t.data};return n}var A=x.prototype=d.prototype;A.copy=function(){var t,n,r=new d(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root;if(!e)return r;if(!e.length)return r._root=_(e),r;for(t=[{source:e,target:r._root=new Array(4)}];e=t.pop();)for(var i=0;i<4;++i)(n=e.source[i])&&(n.length?t.push({source:n,target:e.target[i]=new Array(4)}):e.target[i]=_(n));return r},A.add=e.A,A.addAll=e.R,A.cover=i.A,A.data=o.A,A.extent=u.A,A.find=a.A,A.remove=f.A,A.removeAll=f.C,A.root=l.A,A.size=h.A,A.visit=s.A,A.visitAfter=c.A,A.x=v.A,A.y=y.A},616(t,n,r){function e(t){if(isNaN(o=+this._x.call(null,t))||isNaN(u=+this._y.call(null,t)))return this;var n,r,e,i,o,u,a,f,l,h,s,c,v=this._root,y=this._x0,x=this._y0,d=this._x1,_=this._y1;if(!v)return this;if(v.length)for(;;){if((l=o>=(a=(y+d)/2))?y=a:d=a,(h=u>=(f=(x+_)/2))?x=f:_=f,n=v,!(v=v[s=h<<1|l]))return this;if(!v.length)break;(n[s+1&3]||n[s+2&3]||n[s+3&3])&&(r=n,c=s)}for(;v.data!==t;)if(e=v,!(v=v.next))return this;return(i=v.next)&&delete v.next,e?(i?e.next=i:delete e.next,this):n?(i?n[s]=i:delete n[s],(v=n[0]||n[1]||n[2]||n[3])&&v===(n[3]||n[2]||n[1]||n[0])&&!v.length&&(r?r[c]=v:this._root=v),this):(this._root=i,this)}function i(t){for(var n=0,r=t.length;ne,C:()=>i})},232(t,n,r){function e(){return this._root}r.d(n,{A:()=>e})},977(t,n,r){function e(){var t=0;return this.visit(function(n){if(!n.length)do{++t}while(n=n.next)}),t}r.d(n,{A:()=>e})},621(t,n,r){r.d(n,{A:()=>i});var e=r(975);function i(t){var n,r,i,o,u,a,f=[],l=this._root;for(l&&f.push(new e.A(l,this._x0,this._y0,this._x1,this._y1));n=f.pop();)if(!t(l=n.node,i=n.x0,o=n.y0,u=n.x1,a=n.y1)&&l.length){var h=(i+u)/2,s=(o+a)/2;(r=l[3])&&f.push(new e.A(r,h,s,u,a)),(r=l[2])&&f.push(new e.A(r,i,s,h,a)),(r=l[1])&&f.push(new e.A(r,h,o,u,s)),(r=l[0])&&f.push(new e.A(r,i,o,h,s))}return this}},759(t,n,r){r.d(n,{A:()=>i});var e=r(975);function i(t){var n,r=[],i=[];for(this._root&&r.push(new e.A(this._root,this._x0,this._y0,this._x1,this._y1));n=r.pop();){var o=n.node;if(o.length){var u,a=n.x0,f=n.y0,l=n.x1,h=n.y1,s=(a+l)/2,c=(f+h)/2;(u=o[0])&&r.push(new e.A(u,a,f,s,c)),(u=o[1])&&r.push(new e.A(u,s,f,l,c)),(u=o[2])&&r.push(new e.A(u,a,c,s,h)),(u=o[3])&&r.push(new e.A(u,s,c,l,h))}i.push(n)}for(;n=i.pop();)t(n.node,n.x0,n.y0,n.x1,n.y1);return this}},86(t,n,r){function e(t){return t[0]}function i(t){return arguments.length?(this._x=t,this):this._x}r.d(n,{A:()=>i,U:()=>e})},437(t,n,r){function e(t){return t[1]}function i(t){return arguments.length?(this._y=t,this):this._y}r.d(n,{$:()=>e,A:()=>i})},29(t,n,r){r.d(n,{O1:()=>d});var e,i,o=0,u=0,a=0,f=0,l=0,h=0,s="object"==typeof performance&&performance.now?performance:Date,c="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function v(){return l||(c(y),l=s.now()+h)}function y(){l=0}function x(){this._call=this._time=this._next=null}function d(t,n,r){var e=new x;return e.restart(t,n,r),e}function _(){l=(f=s.now())+h,o=u=0;try{!function(){v(),++o;for(var t,n=e;n;)(t=l-n._time)>=0&&n._call.call(void 0,t),n=n._next;--o}()}finally{o=0,function(){for(var t,n,r=e,o=1/0;r;)r._call?(o>r._time&&(o=r._time),t=r,r=r._next):(n=r._next,r._next=null,r=t?t._next=n:e=n);i=t,g(o)}(),l=0}}function A(){var t=s.now(),n=t-f;n>1e3&&(h-=n,f=t)}function g(t){o||(u&&(u=clearTimeout(u)),t-l>24?(t<1/0&&(u=setTimeout(_,t-s.now()-h)),a&&(a=clearInterval(a))):(a||(f=s.now(),a=setInterval(A,1e3)),o=1,c(_)))}x.prototype=d.prototype={constructor:x,restart:function(t,n,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?v():+r)+(null==n?0:+n),this._next||i===this||(i?i._next=this:e=this,i=this),this._call=t,this._time=r,g()},stop:function(){this._call&&(this._call=null,this._time=1/0,g())}}}}]); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index d17790c..18d6e36 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@memgraph/orb", - "version": "0.4.3", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@memgraph/orb", - "version": "0.4.3", + "version": "1.0.0", "license": "Apache-2.0", "dependencies": { "d3-drag": "^3.0.0", @@ -35,6 +35,7 @@ "@typescript-eslint/parser": "^8.56.1", "conventional-changelog-eslint": "^6.1.0", "copy-webpack-plugin": "^14.0.0", + "esbuild": "^0.28.1", "eslint": "^8.57.1", "eslint-config-google": "^0.14.0", "eslint-config-prettier": "^10.1.8", @@ -992,6 +993,448 @@ "tslib": "^2.4.0" } }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.1.tgz", + "integrity": "sha512-Svl7tq8k/08+p6CXPpRjQ1fKX+1odH/BQbb48fV6fj3CWHhsoIOoY87w1oHXm0qEpkIK3ZfVgp0hed3XBXzXMQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.1.tgz", + "integrity": "sha512-0k2F129Xdio1TdJfzJ8sy1Q47vUD2NnwdhiAf7drUN1EBTfPf4hsFCtmMgu/6m8JSzsBrlmVjudMBQqOfG8usQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.1.tgz", + "integrity": "sha512-34EGEbCIAgosYz6goLcopX6Mo7NyGv9tfwEM2/7Ce2VcVRk568iSvniGWcUXIy7wEDR1wzolcxcriFVrWYcwBg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.1.tgz", + "integrity": "sha512-dbwY7ltSMDWsRatcRpCnES4F+im88OCUgGZjy52shC7GqHRE/cYlxNbB4Z4UpJswpcc4Qxd2oE/ufM0p61IKng==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.1.tgz", + "integrity": "sha512-TZbWkQY7kvTAXbXUT7uVACR5cMHsDiSz9z7ZKAX/RTq/WJEk3QyRr0wZpNhBDX+/0CtdqUIJlOiodQcta6tY3Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.1.tgz", + "integrity": "sha512-zfdzgK9ACBNZLI/CyHTOx81SyNbM6YXn7rxSgX97VjyiPl9W1i4Ka4fgKECEoFCKGpvBj5qArWIGgQjOwkgskQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.1.tgz", + "integrity": "sha512-wG2EA8ENdEI0qhkSZMjfqrdY+ziCYCPMmtZjjIwOmXFjmyzEHn+UUxk5of+SYsjtfs3VpnlC7QLzSI5hY/rOAw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.1.tgz", + "integrity": "sha512-i7dZ9vQgnvSCzi/rYCXNgtF/U+eKZNJBzu3eTQbRgHnM7tNSizLOkRFAl3qzVc/Op/u5YkHHa4pf/3DOYHthLQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.1.tgz", + "integrity": "sha512-qVXBOHQS+d5Y722GwJzJUtOLlX7km3CraOaGormF1pDtPd2C/l1SHRPgjLunLGe51Sh5YYWKMFDyV4SxgMQYTQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.1.tgz", + "integrity": "sha512-yHs+0uc8+nvEAfAfxrWQKK5peSNzBc4PegcMO0EJ2hT71uA7vB8Ihg2e77R2P7SG5uYjPbHlLLmve4LLLRCf0g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.1.tgz", + "integrity": "sha512-d1z4ZuP0ajrfz/FhGT4vv278rX8KnPPJx8i5+AtK7TYbx9Le9F1hyzurZpkEyjkGa9dUGhQow4C1NmeGvqxN2w==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.1.tgz", + "integrity": "sha512-M5sRjUVZrkm1OAPR3dlOYzNmN+loZKGVi1VUQGrwuqLcbR6qeAz+famMhjASeH3YVKvZz+zT1jlh/keC3Rj/lg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.1.tgz", + "integrity": "sha512-mRObBZeHh2OxcBFPWE/FjylkRgZdYuiTR3vaTozquCGOH14iP9oN4x4Ge81CoIDYQrXmIxpFumJBu5MtZpnQJQ==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.1.tgz", + "integrity": "sha512-slScBsMAb3GFDcdrCgLwZtPYRoH2H/youv10QiZyRjmsP48fznoveWytSgCI/R0ZcUgpc0ZhIUEx6LHts8yrfQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.1.tgz", + "integrity": "sha512-kw0owk1o0GFETUJyW0jc0G4Yzs0BHZn0JDZ8JRT088vjJYX777BAs1fDGxAC+q831qOs2DTC96mNsG2opdfyyQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.1.tgz", + "integrity": "sha512-/lAIjX8aYFRByhh6L5rYtPEDRqa9de/4V/juOXcta5frjvzXO4/sqEtyytse0g3zZFuWu5cDN0MkLz2qRDD2Ag==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.1.tgz", + "integrity": "sha512-u/anNYF2mmVOEDwLtnQ1wOr3EZ9sTNGLWrsYGYwHWzGA3Si84IOkHXlbWTD1NB+9/1lcnweYKO54uhxZydNzfA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.1.tgz", + "integrity": "sha512-oks0DYbLwWMmaakTsCb+zL4E+aHRVLom9IJZOAthMQEPiQmydXHkziYEsGYRx0uNV/IjEKGAV941JzH02pflqw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.1.tgz", + "integrity": "sha512-aeL6lAnN89Hz43Mlh1G8ARasbuoYvSITDEx0tHh5b7jJnHcssqgjy9Yx430GDpmCa6OyrKoS0aNRjKundRizGg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.1.tgz", + "integrity": "sha512-MEFJe5C3R8pwXdZ5Y21oo6m7ePiS0d9pWucn99O/wvyJZChoIQKrQDxKrGeW8F5+T0okTHesAmDeiHDTIq0V/Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.1.tgz", + "integrity": "sha512-i/ZLIOafE0Z8cI/XANJAixoJL/uRAoS2xOA3rb0xN+KK0K177cMAsQYkzHtBrtMXAKuAc7HGgcWiZ/sRC1Nxgw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.1.tgz", + "integrity": "sha512-ge+Z7EXFNt2BO1oAMsVpiQ8EwndV9i1xXerAeTIK7AtPs3bKFXQM7nlRxDSIUIMeueR1CNXxqztLzdNeReKBJg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.1.tgz", + "integrity": "sha512-BEjgtECkL3vY+SaSQ6nzVfiALUeFxpawyp8Jmf5PtYhf1Ug40N1h/hxlhts+f1FvSvarEigdxS3BlSMI2PJLcQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.1.tgz", + "integrity": "sha512-lCv9eK/H6ZJWbE7bh2nw54CZ9M2nupBxJcTsdk/QQnWkdSjKGuxmmH8/GWrlT1eMmZfn4dGcCjRte397WqfQXA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.1.tgz", + "integrity": "sha512-zvb/mB2bSCoJOpoCBgYKKpX6YM6mJBlBUVUtVj41DlZJVEB6/0CKlRYxP5wWl1C1ILiCoAU5wZZ4q1P3qeS6Eg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.1.tgz", + "integrity": "sha512-bm4Mowrv+GXMlpWX++EcXw/iLyd1o3+bJkC2DkWXYVvgZCqD/bSj9ctZeAMC3cIxgjRVR2Dufaiu4YPxr5gW1A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.10.1", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.10.1.tgz", @@ -5650,16 +6093,6 @@ "node": ">=18" } }, - "node_modules/conventional-commits-filter": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/conventional-commits-filter/-/conventional-commits-filter-6.0.1.tgz", - "integrity": "sha512-cs+LadpH7Kpw0M3k8wurk+sOVVDAENA0iK4OBOrkL94j5lEVYRJ4j3zd2bhY9qgzyrPqthdcYT3axzRN7AliMg==", - "extraneous": true, - "license": "MIT", - "engines": { - "node": ">=22" - } - }, "node_modules/conventional-commits-parser": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-7.1.1.tgz", @@ -6478,6 +6911,48 @@ "tests/types" ] }, + "node_modules/esbuild": { + "version": "0.28.1", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.1.tgz", + "integrity": "sha512-HrJrvZv5ayxBzPfwphOoNzkzOIIlifzk0KJrGK2c8R4+LKpMtpYLQeUdjnwjWv/LZlkH2laZk+4w78pi99D4Vw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.28.1", + "@esbuild/android-arm": "0.28.1", + "@esbuild/android-arm64": "0.28.1", + "@esbuild/android-x64": "0.28.1", + "@esbuild/darwin-arm64": "0.28.1", + "@esbuild/darwin-x64": "0.28.1", + "@esbuild/freebsd-arm64": "0.28.1", + "@esbuild/freebsd-x64": "0.28.1", + "@esbuild/linux-arm": "0.28.1", + "@esbuild/linux-arm64": "0.28.1", + "@esbuild/linux-ia32": "0.28.1", + "@esbuild/linux-loong64": "0.28.1", + "@esbuild/linux-mips64el": "0.28.1", + "@esbuild/linux-ppc64": "0.28.1", + "@esbuild/linux-riscv64": "0.28.1", + "@esbuild/linux-s390x": "0.28.1", + "@esbuild/linux-x64": "0.28.1", + "@esbuild/netbsd-arm64": "0.28.1", + "@esbuild/netbsd-x64": "0.28.1", + "@esbuild/openbsd-arm64": "0.28.1", + "@esbuild/openbsd-x64": "0.28.1", + "@esbuild/openharmony-arm64": "0.28.1", + "@esbuild/sunos-x64": "0.28.1", + "@esbuild/win32-arm64": "0.28.1", + "@esbuild/win32-ia32": "0.28.1", + "@esbuild/win32-x64": "0.28.1" + } + }, "node_modules/escalade": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", diff --git a/package.json b/package.json index 0dd472e..b7696ae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@memgraph/orb", - "version": "1.0.1", + "version": "1.0.2", "description": "Graph visualization library", "engines": { "node": ">=18.0.0" @@ -28,8 +28,8 @@ "author": "Memgraph Ltd. ", "license": "Apache-2.0", "scripts": { - "build": "tsc", - "build:release": "tsc && webpack", + "build": "tsc && node scripts/build-inline-worker.mjs", + "build:release": "npm run build && webpack", "webpack": "webpack", "webpack:watch": "webpack --watch", "serve": "http-server ./dist/browser/ -o -c-1 -p 8082", @@ -53,8 +53,6 @@ "dist", "!dist/browser/*.html", "!dist/browser/orb.js", - "!dist/browser/orb.worker.js", - "!dist/browser/orb.worker.vendor.js", "LICENSE", "README.md" ], @@ -79,6 +77,7 @@ "@typescript-eslint/parser": "^8.56.1", "conventional-changelog-eslint": "^6.1.0", "copy-webpack-plugin": "^14.0.0", + "esbuild": "^0.28.1", "eslint": "^8.57.1", "eslint-config-google": "^0.14.0", "eslint-config-prettier": "^10.1.8", @@ -104,6 +103,9 @@ "ts" ], "rootDir": "", + "moduleNameMapper": { + "simulator\\.worker\\.inline$": "/test/stubs/worker-inline.ts" + }, "testRegex": ".spec.ts$", "transform": { "^.+\\.(t|j)s$": "ts-jest" diff --git a/scripts/build-inline-worker.mjs b/scripts/build-inline-worker.mjs new file mode 100644 index 0000000..81d0b3a --- /dev/null +++ b/scripts/build-inline-worker.mjs @@ -0,0 +1,29 @@ +import { build } from 'esbuild'; +import { mkdir, writeFile } from 'node:fs/promises'; +import { dirname, join, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const root = resolve(dirname(fileURLToPath(import.meta.url)), '..'); +const entry = join(root, 'src/simulator/types/web-worker-simulator/simulator.worker.ts'); +const outDir = join(root, 'dist/simulator/types/web-worker-simulator'); +const outBase = join(outDir, 'simulator.worker.inline'); + +const result = await build({ + entryPoints: [entry], + bundle: true, + format: 'iife', + platform: 'browser', + target: 'es2020', + minify: true, + write: false, + legalComments: 'eof', +}); + +const source = result.outputFiles[0].text; + +await mkdir(outDir, { recursive: true }); +await writeFile(`${outBase}.js`, `export default ${JSON.stringify(source)};\n`, 'utf8'); +await writeFile(`${outBase}.d.ts`, 'declare const workerSource: string;\nexport default workerSource;\n', 'utf8'); + +const kb = (source.length / 1024).toFixed(1); +console.log(`[build-inline-worker] wrote ${outBase}.js (${kb} KB self-contained worker)`); diff --git a/src/simulator/shared.ts b/src/simulator/shared.ts index 683e444..cd38aba 100644 --- a/src/simulator/shared.ts +++ b/src/simulator/shared.ts @@ -80,6 +80,36 @@ export interface ISimulator extends IEmitter { terminate(): void; } +// Forwards every simulator event from `source` to `target`, toggling running state via +// `onRunningChange` on start/end. Shared by the main-thread simulator (engine -> self) +// and the web-worker simulator's fallback (fallback -> self). +export function relaySimulatorEvents( + source: IEmitter, + target: IEmitter, + onRunningChange: (isRunning: boolean) => void, +): void { + source.on(SimulatorEventType.SIMULATION_START, () => { + target.emit(SimulatorEventType.SIMULATION_START, undefined); + onRunningChange(true); + }); + source.on(SimulatorEventType.SIMULATION_PROGRESS, (data) => { + target.emit(SimulatorEventType.SIMULATION_PROGRESS, data); + }); + source.on(SimulatorEventType.SIMULATION_END, (data) => { + target.emit(SimulatorEventType.SIMULATION_END, data); + onRunningChange(false); + }); + source.on(SimulatorEventType.SIMULATION_STEP, (data) => { + target.emit(SimulatorEventType.SIMULATION_STEP, data); + }); + source.on(SimulatorEventType.NODE_DRAG, (data) => { + target.emit(SimulatorEventType.NODE_DRAG, data); + }); + source.on(SimulatorEventType.SETTINGS_UPDATE, (data) => { + target.emit(SimulatorEventType.SETTINGS_UPDATE, data); + }); +} + export interface ISimulatorEventGraph { nodes: ISimulationNode[]; edges: ISimulationEdge[]; diff --git a/src/simulator/types/main-thread-simulator.ts b/src/simulator/types/main-thread-simulator.ts index 9a930d5..88b5555 100644 --- a/src/simulator/types/main-thread-simulator.ts +++ b/src/simulator/types/main-thread-simulator.ts @@ -2,9 +2,9 @@ import { ISimulationNode, ISimulator, SimulatorEvents, - SimulatorEventType, ISimulationGraph, ISimulationIds, + relaySimulatorEvents, } from '../shared'; import { IPosition } from '../../common'; import { Emitter } from '../../utils/emitter.utils'; @@ -97,25 +97,8 @@ export class MainThreadSimulator extends Emitter implements ISi } private _wireEngineEvents() { - this._engine.on(SimulatorEventType.SIMULATION_START, () => { - this.emit(SimulatorEventType.SIMULATION_START, undefined); - this._isSimulationRunning = true; - }); - this._engine.on(SimulatorEventType.SIMULATION_PROGRESS, (data) => { - this.emit(SimulatorEventType.SIMULATION_PROGRESS, data); - }); - this._engine.on(SimulatorEventType.SIMULATION_END, (data) => { - this.emit(SimulatorEventType.SIMULATION_END, data); - this._isSimulationRunning = false; - }); - this._engine.on(SimulatorEventType.SIMULATION_STEP, (data) => { - this.emit(SimulatorEventType.SIMULATION_STEP, data); - }); - this._engine.on(SimulatorEventType.NODE_DRAG, (data) => { - this.emit(SimulatorEventType.NODE_DRAG, data); - }); - this._engine.on(SimulatorEventType.SETTINGS_UPDATE, (data) => { - this.emit(SimulatorEventType.SETTINGS_UPDATE, data); + relaySimulatorEvents(this._engine, this, (isRunning) => { + this._isSimulationRunning = isRunning; }); } } diff --git a/src/simulator/types/web-worker-simulator/message/input-dispatch.ts b/src/simulator/types/web-worker-simulator/message/input-dispatch.ts new file mode 100644 index 0000000..d665bce --- /dev/null +++ b/src/simulator/types/web-worker-simulator/message/input-dispatch.ts @@ -0,0 +1,65 @@ +import { IPosition } from '../../../../common'; +import { ISimulationNode, ISimulationGraph, ISimulationIds } from '../../../shared'; +import { IWorkerInputPayload, WorkerInputType } from './worker-input'; + +export interface ILayoutInputTarget { + setupData(data: ISimulationGraph): void; + mergeData(data: ISimulationGraph): void; + updateData(data: ISimulationGraph): void; + deleteData(data: Partial): void; + patchData(data: Partial): void; + clearData(): void; + activateSimulation(): void; + stopSimulation(): void; + startDragNode(): void; + dragNode(nodeId: number, position: IPosition): void; + endDragNode(nodeId: number): void; + fixNodes(nodes?: ISimulationNode[]): void; + releaseNodes(nodes?: ISimulationNode[]): void; +} + +export function dispatchLayoutInput(target: ILayoutInputTarget, message: IWorkerInputPayload): void { + switch (message.type) { + case WorkerInputType.SetupData: + target.setupData(message.data); + break; + case WorkerInputType.MergeData: + target.mergeData(message.data); + break; + case WorkerInputType.UpdateData: + target.updateData(message.data); + break; + case WorkerInputType.DeleteData: + target.deleteData(message.data); + break; + case WorkerInputType.PatchData: + target.patchData(message.data); + break; + case WorkerInputType.ClearData: + target.clearData(); + break; + case WorkerInputType.ActivateSimulation: + target.activateSimulation(); + break; + case WorkerInputType.StopSimulation: + target.stopSimulation(); + break; + case WorkerInputType.StartDragNode: + target.startDragNode(); + break; + case WorkerInputType.DragNode: + target.dragNode(message.data.id, { x: message.data.x, y: message.data.y }); + break; + case WorkerInputType.EndDragNode: + target.endDragNode(message.data.id); + break; + case WorkerInputType.FixNodes: + target.fixNodes(message.data.nodes); + break; + case WorkerInputType.ReleaseNodes: + target.releaseNodes(message.data.nodes); + break; + default: + break; + } +} diff --git a/src/simulator/types/web-worker-simulator/message/worker-output.ts b/src/simulator/types/web-worker-simulator/message/worker-output.ts index 7325e60..f75cc87 100644 --- a/src/simulator/types/web-worker-simulator/message/worker-output.ts +++ b/src/simulator/types/web-worker-simulator/message/worker-output.ts @@ -3,6 +3,7 @@ import { IWorkerPayload } from './worker-payload'; import { ILayoutSettings } from '../../../engine/shared'; export enum WorkerOutputType { + READY = 'ready', SIMULATION_START = 'simulation-start', SIMULATION_STEP = 'simulation-step', SIMULATION_PROGRESS = 'simulation-progress', @@ -13,6 +14,8 @@ export enum WorkerOutputType { SETTINGS_UPDATE = 'settings-update', } +type IWorkerOutputReadyPayload = IWorkerPayload; + type IWorkerOutputSimulationStartPayload = IWorkerPayload; type IWorkerOutputSimulationStepPayload = IWorkerPayload< @@ -64,6 +67,7 @@ type IWorkerOutputSettingsUpdatePayload = IWorkerPayload< >; export type IWorkerOutputPayload = + | IWorkerOutputReadyPayload | IWorkerOutputSimulationStartPayload | IWorkerOutputSimulationStepPayload | IWorkerOutputSimulationProgressPayload diff --git a/src/simulator/types/web-worker-simulator/simulator.worker.inline.d.ts b/src/simulator/types/web-worker-simulator/simulator.worker.inline.d.ts new file mode 100644 index 0000000..9adbd7a --- /dev/null +++ b/src/simulator/types/web-worker-simulator/simulator.worker.inline.d.ts @@ -0,0 +1,2 @@ +declare const workerSource: string; +export default workerSource; diff --git a/src/simulator/types/web-worker-simulator/simulator.worker.ts b/src/simulator/types/web-worker-simulator/simulator.worker.ts index e922c5c..7bfb64d 100644 --- a/src/simulator/types/web-worker-simulator/simulator.worker.ts +++ b/src/simulator/types/web-worker-simulator/simulator.worker.ts @@ -4,6 +4,7 @@ import { ILayoutEngine, ILayoutSettings } from '../../engine/shared'; import { SimulatorEventType } from '../../shared'; import { IWorkerInputPayload, WorkerInputType } from './message/worker-input'; import { IWorkerOutputPayload, WorkerOutputType } from './message/worker-output'; +import { dispatchLayoutInput } from './message/input-dispatch'; let engine: ILayoutEngine | null = null; @@ -20,24 +21,7 @@ function wireEngineEvents(target: ILayoutEngine) { target.on(SimulatorEventType.SETTINGS_UPDATE, (data) => emitToMain({ type: WorkerOutputType.SETTINGS_UPDATE, data })); } -type ExtractPayload = Extract; -type EngineHandler = (engine: ILayoutEngine, payload: ExtractPayload) => void; - -const handlers: { [T in WorkerInputType]?: EngineHandler } = { - [WorkerInputType.SetupData]: (e, { data }) => e.setupData(data), - [WorkerInputType.MergeData]: (e, { data }) => e.mergeData(data), - [WorkerInputType.UpdateData]: (e, { data }) => e.updateData(data), - [WorkerInputType.DeleteData]: (e, { data }) => e.deleteData(data), - [WorkerInputType.PatchData]: (e, { data }) => e.patchData(data), - [WorkerInputType.ClearData]: (e) => e.clearData(), - [WorkerInputType.ActivateSimulation]: (e) => e.activateSimulation(), - [WorkerInputType.StopSimulation]: (e) => e.stopSimulation(), - [WorkerInputType.StartDragNode]: (e) => e.startDragNode(), - [WorkerInputType.DragNode]: (e, { data }) => e.dragNode(data.id, { x: data.x, y: data.y }), - [WorkerInputType.EndDragNode]: (e, { data }) => e.endDragNode(data.id), - [WorkerInputType.FixNodes]: (e, { data }) => e.fixNodes(data.nodes), - [WorkerInputType.ReleaseNodes]: (e, { data }) => e.releaseNodes(data.nodes), -}; +emitToMain({ type: WorkerOutputType.READY }); addEventListener('message', ({ data }: MessageEvent) => { if (data.type === WorkerInputType.SetSettings) { @@ -55,7 +39,6 @@ addEventListener('message', ({ data }: MessageEvent) => { } if (engine) { - const handler = handlers[data.type] as EngineHandler | undefined; - handler?.(engine, data); + dispatchLayoutInput(engine, data); } }); diff --git a/src/simulator/types/web-worker-simulator/web-worker-simulator.ts b/src/simulator/types/web-worker-simulator/web-worker-simulator.ts index ce5cf3e..16e3fa3 100644 --- a/src/simulator/types/web-worker-simulator/web-worker-simulator.ts +++ b/src/simulator/types/web-worker-simulator/web-worker-simulator.ts @@ -7,66 +7,107 @@ import { SimulatorEvents, ISimulationGraph, ISimulationIds, + relaySimulatorEvents, } from '../../shared'; import { IWorkerInputPayload, WorkerInputType } from './message/worker-input'; import { IWorkerOutputPayload, WorkerOutputType } from './message/worker-output'; +import { dispatchLayoutInput } from './message/input-dispatch'; import { Emitter } from '../../../utils/emitter.utils'; import { ILayoutSettings } from '../../engine/shared'; import { DeepPartial } from '../../../utils/type.utils'; +import { MainThreadSimulator } from '../main-thread-simulator'; +import workerSource from './simulator.worker.inline'; + +const WORKER_READY_TIMEOUT_MS = 3000; export class WebWorkerSimulator extends Emitter implements ISimulator { - protected readonly _worker: Worker; + protected _worker?: Worker; + private _blobUrl?: string; + private _settings: DeepPartial; private _isSimulationRunning = false; + private _fallback: ISimulator | null = null; + private _ready = false; + private _pending: IWorkerInputPayload[] = []; + private _readyTimer?: ReturnType; + private _hasWarned = false; + constructor(settings: DeepPartial) { super(); - this._worker = new Worker( - new URL( - /* webpackChunkName: 'simulator.worker' */ - './simulator.worker', - import.meta.url, - ), - { type: 'module' }, - ); + this._settings = settings; - this.emitToWorker({ type: WorkerInputType.SetSettings, data: settings }); + let worker: Worker; + try { + this._blobUrl = URL.createObjectURL(new Blob([workerSource], { type: 'text/javascript' })); + worker = new Worker(this._blobUrl); + } catch (error) { + this._activateFallback(error); + return; + } - this._worker.onmessage = ({ data }: MessageEvent) => { - switch (data.type) { - case WorkerOutputType.SIMULATION_START: { - this.emit(SimulatorEventType.SIMULATION_START, undefined); - this._isSimulationRunning = true; - break; - } - case WorkerOutputType.SIMULATION_PROGRESS: { - this.emit(SimulatorEventType.SIMULATION_PROGRESS, data.data); - break; - } - case WorkerOutputType.SIMULATION_END: { - this.emit(SimulatorEventType.SIMULATION_END, data.data); - this._isSimulationRunning = false; - break; - } - case WorkerOutputType.SIMULATION_STEP: { - this.emit(SimulatorEventType.SIMULATION_STEP, data.data); - break; - } - case WorkerOutputType.NODE_DRAG: { - this.emit(SimulatorEventType.NODE_DRAG, data.data); - break; - } - case WorkerOutputType.NODE_DRAG_END: { - this.emit(SimulatorEventType.NODE_DRAG_END, data.data); - break; - } - case WorkerOutputType.SETTINGS_UPDATE: { - this.emit(SimulatorEventType.SETTINGS_UPDATE, data.data); - break; - } + this._worker = worker; + worker.onerror = (event) => { + // Only recover from failures before the worker has started. Once it has posted + // READY, the graph state lives in the worker and was never snapshotted, so swapping + // in a fresh main-thread simulator would blank the graph. A post-startup error is + // also rarely recoverable (the fallback runs the same engine), so keep the last + // layout and stop simulating instead. + if (this._ready) { + this._warnWorkerError(event); + return; } + this._activateFallback(event); }; + worker.onmessage = this._handleWorkerMessage; + + this._readyTimer = setTimeout(() => { + if (!this._ready && !this._fallback) { + this._activateFallback(new Error('Web Worker readiness handshake timed out.')); + } + }, WORKER_READY_TIMEOUT_MS); + + this.emitToWorker({ type: WorkerInputType.SetSettings, data: settings }); } + private _handleWorkerMessage = ({ data }: MessageEvent) => { + switch (data.type) { + case WorkerOutputType.READY: { + this._markReady(); + break; + } + case WorkerOutputType.SIMULATION_START: { + this.emit(SimulatorEventType.SIMULATION_START, undefined); + this._isSimulationRunning = true; + break; + } + case WorkerOutputType.SIMULATION_PROGRESS: { + this.emit(SimulatorEventType.SIMULATION_PROGRESS, data.data); + break; + } + case WorkerOutputType.SIMULATION_END: { + this.emit(SimulatorEventType.SIMULATION_END, data.data); + this._isSimulationRunning = false; + break; + } + case WorkerOutputType.SIMULATION_STEP: { + this.emit(SimulatorEventType.SIMULATION_STEP, data.data); + break; + } + case WorkerOutputType.NODE_DRAG: { + this.emit(SimulatorEventType.NODE_DRAG, data.data); + break; + } + case WorkerOutputType.NODE_DRAG_END: { + this.emit(SimulatorEventType.NODE_DRAG_END, data.data); + break; + } + case WorkerOutputType.SETTINGS_UPDATE: { + this.emit(SimulatorEventType.SETTINGS_UPDATE, data.data); + break; + } + } + }; + /** * Creates a new graph with the specified data. Any existing data gets discarded. * This action creates a new simulation object but keeps the existing simulation settings. @@ -142,15 +183,126 @@ export class WebWorkerSimulator extends Emitter implements ISim } isSimulationRunning(): boolean { - return this._isSimulationRunning; + return this._fallback ? this._fallback.isSimulationRunning() : this._isSimulationRunning; } terminate() { - this._worker.terminate(); + if (this._readyTimer !== undefined) { + clearTimeout(this._readyTimer); + this._readyTimer = undefined; + } + this._revokeBlobUrl(); + if (this._worker) { + this._worker.onmessage = null; + this._worker.onerror = null; + this._worker.terminate(); + this._worker = undefined; + } + this._fallback?.terminate(); this.removeAllListeners(); } protected emitToWorker(message: IWorkerInputPayload) { - this._worker.postMessage(message); + if (this._fallback) { + this._applyToFallback(this._fallback, message); + return; + } + if (!this._ready) { + this._pending.push(message); + } + this._worker?.postMessage(message); + } + + private _markReady() { + if (this._ready) { + return; + } + this._ready = true; + this._pending = []; + if (this._readyTimer !== undefined) { + clearTimeout(this._readyTimer); + this._readyTimer = undefined; + } + this._revokeBlobUrl(); + } + + private _activateFallback(reason: unknown) { + if (this._fallback) { + return; + } + this._warnFallback(reason); + + if (this._readyTimer !== undefined) { + clearTimeout(this._readyTimer); + this._readyTimer = undefined; + } + if (this._worker) { + this._worker.onmessage = null; + this._worker.onerror = null; + try { + this._worker.terminate(); + } catch { + /* empty */ + } + this._worker = undefined; + } + this._revokeBlobUrl(); + + const fallback = new MainThreadSimulator(this._settings); + this._wireFallbackEvents(fallback); + this._fallback = fallback; + + const pending = this._pending; + this._pending = []; + for (const message of pending) { + this._applyToFallback(fallback, message); + } + } + + private _wireFallbackEvents(fallback: ISimulator) { + relaySimulatorEvents(fallback, this, (isRunning) => { + this._isSimulationRunning = isRunning; + }); + } + + private _applyToFallback(fallback: ISimulator, message: IWorkerInputPayload) { + if (message.type === WorkerInputType.SetSettings) { + fallback.setSettings(message.data); + return; + } + dispatchLayoutInput(fallback, message); + } + + private _revokeBlobUrl() { + if (this._blobUrl) { + URL.revokeObjectURL(this._blobUrl); + this._blobUrl = undefined; + } + } + + private _warnWorkerError(reason: unknown) { + if (this._hasWarned) { + return; + } + this._hasWarned = true; + console.warn( + 'Orb: the layout Web Worker errored after it had started. The current layout is kept ' + + 'and no further updates will be simulated; reload the graph to recover.', + reason, + ); + } + + private _warnFallback(reason: unknown) { + if (this._hasWarned) { + return; + } + this._hasWarned = true; + console.warn( + 'Orb: the layout Web Worker could not start; falling back to the main-thread simulator. ' + + 'Layout is still correct but runs on the main thread. Under a strict Content Security ' + + 'Policy, allow blob workers (e.g. `worker-src blob:` or `child-src blob:`) to re-enable ' + + 'off-main-thread layout.', + reason, + ); } } diff --git a/test/stubs/worker-inline.ts b/test/stubs/worker-inline.ts new file mode 100644 index 0000000..08d725c --- /dev/null +++ b/test/stubs/worker-inline.ts @@ -0,0 +1 @@ +export default ''; diff --git a/webpack.config.js b/webpack.config.js index c09811a..6096e9e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,7 +1,21 @@ const path = require('path'); +const fs = require('fs'); +const webpack = require('webpack'); const CopyWebpackPlugin = require('copy-webpack-plugin'); const name = 'orb'; +const inlineWorkerPath = path.resolve(__dirname, 'dist/simulator/types/web-worker-simulator/simulator.worker.inline.js'); + +if (!fs.existsSync(inlineWorkerPath)) { + throw new Error( + `Missing generated worker bundle at ${inlineWorkerPath}.\n` + + 'Run "node scripts/build-inline-worker.mjs" (or "npm run build") before webpack. ' + + 'The "build:release" script does this automatically.', + ); +} + +const inlineWorkerReplacement = new webpack.NormalModuleReplacementPlugin(/simulator\.worker\.inline$/, inlineWorkerPath); + const commonConfiguration = { entry: './src/index.ts', module: { @@ -17,9 +31,6 @@ const commonConfiguration = { extensions: ['.tsx', '.ts', '.js'], }, output: { - chunkFilename(pathData) { - return pathData.chunk.name === 'simulator.worker' ? `${name}.worker.js` : `${name}.worker.vendor.js`; - }, filename: `${name}.js`, path: path.resolve(__dirname, 'dist/browser'), library: { @@ -35,6 +46,7 @@ const commonConfiguration = { port: 9000, }, plugins: [ + inlineWorkerReplacement, new CopyWebpackPlugin({ patterns: [ { @@ -61,9 +73,6 @@ const productionConfiguration = { mode: 'production', output: { ...commonConfiguration.output, - chunkFilename(pathData) { - return pathData.chunk.name === 'simulator.worker' ? `${name}.worker.min.js` : `${name}.worker.vendor.min.js`; - }, filename: `${name}.min.js`, }, }