nano-brain 2026.6.21 → 2026.6.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -175,7 +175,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
175
175
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function NV(t,e){if(t){if(typeof t=="string")return zC(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return zC(t,e)}}function zC(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function MV(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,i,a,s,l=[],c=!0,f=!1;try{if(a=(r=r.call(t)).next,e!==0)for(;!(c=(n=a.call(r)).done)&&(l.push(n.value),l.length!==e);c=!0);}catch(p){f=!0,i=p}finally{try{if(!c&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(f)throw i}}return l}}function LV(t){if(Array.isArray(t))return t}function Ob(){return Ob=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Ob.apply(this,arguments)}var $V=function(e,r){var n;return Q.isValidElement(e)?n=Q.cloneElement(e,r):ze(e)?n=e(r):n=Q.createElement("line",Ob({},r,{className:"recharts-reference-line-line"})),n},FV=function(e,r,n,i,a,s,l,c,f){var p=a.x,h=a.y,g=a.width,y=a.height;if(n){var S=f.y,w=e.y.apply(S,{position:s});if(Pn(f,"discard")&&!e.y.isInRange(w))return null;var b=[{x:p+g,y:w},{x:p,y:w}];return c==="left"?b.reverse():b}if(r){var E=f.x,P=e.x.apply(E,{position:s});if(Pn(f,"discard")&&!e.x.isInRange(P))return null;var T=[{x:P,y:h+y},{x:P,y:h}];return l==="top"?T.reverse():T}if(i){var O=f.segment,_=O.map(function(A){return e.apply(A,{position:s})});return Pn(f,"discard")&&I9(_,function(A){return!e.isInRange(A)})?null:_}return null};function BV(t){var e=t.x,r=t.y,n=t.segment,i=t.xAxisId,a=t.yAxisId,s=t.shape,l=t.className,c=t.alwaysShow,f=_V(),p=pj(i),h=vj(a),g=EV();if(!f||!g)return null;Pa(c===void 0,'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.');var y=Zw({x:p.scale,y:h.scale}),S=Tt(e),w=Tt(r),b=n&&n.length===2,E=FV(y,S,w,b,g,t.position,p.orientation,h.orientation,t);if(!E)return null;var P=jV(E,2),T=P[0],O=T.x,_=T.y,A=P[1],C=A.x,D=A.y,j=Pn(t,"hidden")?"url(#".concat(f,")"):void 0,G=GC(GC({clipPath:j},Ye(t,!0)),{},{x1:O,y1:_,x2:C,y2:D});return Q.createElement($t,{className:He("recharts-reference-line",l)},$V(s,G),Jt.renderCallByParent(t,dV({x1:O,y1:_,x2:C,y2:D})))}var ex=(function(t){function e(){return OV(this,e),TV(this,e,arguments)}return RV(e,t),PV(e,[{key:"render",value:function(){return Q.createElement(BV,this.props)}}])})(Q.Component);Jw(ex,"displayName","ReferenceLine");Jw(ex,"defaultProps",{isFront:!1,ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle"});function Ab(){return Ab=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Ab.apply(this,arguments)}function Zo(t){"@babel/helpers - typeof";return Zo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Zo(t)}function UC(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function qC(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?UC(Object(r),!0).forEach(function(n){Ud(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):UC(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function GV(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function zV(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,xj(n.key),n)}}function UV(t,e,r){return e&&zV(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function qV(t,e,r){return e=ad(e),WV(t,wj()?Reflect.construct(e,r||[],ad(t).constructor):e.apply(t,r))}function WV(t,e){if(e&&(Zo(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return HV(t)}function HV(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function wj(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(wj=function(){return!!t})()}function ad(t){return ad=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ad(t)}function VV(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Pb(t,e)}function Pb(t,e){return Pb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Pb(t,e)}function Ud(t,e,r){return e=xj(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function xj(t){var e=KV(t,"string");return Zo(e)=="symbol"?e:e+""}function KV(t,e){if(Zo(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(Zo(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var XV=function(e){var r=e.x,n=e.y,i=e.xAxis,a=e.yAxis,s=Zw({x:i.scale,y:a.scale}),l=s.apply({x:r,y:n},{bandAware:!0});return Pn(e,"discard")&&!s.isInRange(l)?null:l},qd=(function(t){function e(){return GV(this,e),qV(this,e,arguments)}return VV(e,t),UV(e,[{key:"render",value:function(){var n=this.props,i=n.x,a=n.y,s=n.r,l=n.alwaysShow,c=n.clipPathId,f=Tt(i),p=Tt(a);if(Pa(l===void 0,'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.'),!f||!p)return null;var h=XV(this.props);if(!h)return null;var g=h.x,y=h.y,S=this.props,w=S.shape,b=S.className,E=Pn(this.props,"hidden")?"url(#".concat(c,")"):void 0,P=qC(qC({clipPath:E},Ye(this.props,!0)),{},{cx:g,cy:y});return Q.createElement($t,{className:He("recharts-reference-dot",b)},e.renderDot(w,P),Jt.renderCallByParent(this.props,{x:g-s,y:y-s,width:2*s,height:2*s}))}}])})(Q.Component);Ud(qd,"displayName","ReferenceDot");Ud(qd,"defaultProps",{isFront:!1,ifOverflow:"discard",xAxisId:0,yAxisId:0,r:10,fill:"#fff",stroke:"#ccc",fillOpacity:1,strokeWidth:1});Ud(qd,"renderDot",function(t,e){var r;return Q.isValidElement(t)?r=Q.cloneElement(t,e):ze(t)?r=t(e):r=Q.createElement(Q2,Ab({},e,{cx:e.cx,cy:e.cy,className:"recharts-reference-dot-dot"})),r});function Tb(){return Tb=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Tb.apply(this,arguments)}function Jo(t){"@babel/helpers - typeof";return Jo=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Jo(t)}function WC(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function HC(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?WC(Object(r),!0).forEach(function(n){Wd(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):WC(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function YV(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function QV(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_j(n.key),n)}}function ZV(t,e,r){return e&&QV(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function JV(t,e,r){return e=od(e),eK(t,Sj()?Reflect.construct(e,r||[],od(t).constructor):e.apply(t,r))}function eK(t,e){if(e&&(Jo(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return tK(t)}function tK(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Sj(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Sj=function(){return!!t})()}function od(t){return od=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},od(t)}function rK(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Cb(t,e)}function Cb(t,e){return Cb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Cb(t,e)}function Wd(t,e,r){return e=_j(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _j(t){var e=nK(t,"string");return Jo(e)=="symbol"?e:e+""}function nK(t,e){if(Jo(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(Jo(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var iK=function(e,r,n,i,a){var s=a.x1,l=a.x2,c=a.y1,f=a.y2,p=a.xAxis,h=a.yAxis;if(!p||!h)return null;var g=Zw({x:p.scale,y:h.scale}),y={x:e?g.x.apply(s,{position:"start"}):g.x.rangeMin,y:n?g.y.apply(c,{position:"start"}):g.y.rangeMin},S={x:r?g.x.apply(l,{position:"end"}):g.x.rangeMax,y:i?g.y.apply(f,{position:"end"}):g.y.rangeMax};return Pn(a,"discard")&&(!g.isInRange(y)||!g.isInRange(S))?null:oj(y,S)},Hd=(function(t){function e(){return YV(this,e),JV(this,e,arguments)}return rK(e,t),ZV(e,[{key:"render",value:function(){var n=this.props,i=n.x1,a=n.x2,s=n.y1,l=n.y2,c=n.className,f=n.alwaysShow,p=n.clipPathId;Pa(f===void 0,'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.');var h=Tt(i),g=Tt(a),y=Tt(s),S=Tt(l),w=this.props.shape;if(!h&&!g&&!y&&!S&&!w)return null;var b=iK(h,g,y,S,this.props);if(!b&&!w)return null;var E=Pn(this.props,"hidden")?"url(#".concat(p,")"):void 0;return Q.createElement($t,{className:He("recharts-reference-area",c)},e.renderRect(w,HC(HC({clipPath:E},Ye(this.props,!0)),b)),Jt.renderCallByParent(this.props,b))}}])})(Q.Component);Wd(Hd,"displayName","ReferenceArea");Wd(Hd,"defaultProps",{isFront:!1,ifOverflow:"discard",xAxisId:0,yAxisId:0,r:10,fill:"#ccc",fillOpacity:.5,stroke:"none",strokeWidth:1});Wd(Hd,"renderRect",function(t,e){var r;return Q.isValidElement(t)?r=Q.cloneElement(t,e):ze(t)?r=t(e):r=Q.createElement(Qw,Tb({},e,{className:"recharts-reference-area-rect"})),r});function Ej(t,e,r){if(e<1)return[];if(e===1&&r===void 0)return t;for(var n=[],i=0;i<t.length;i+=e)n.push(t[i]);return n}function aK(t,e,r){var n={width:t.width+e.width,height:t.height+e.height};return pV(n,r)}function oK(t,e,r){var n=r==="width",i=t.x,a=t.y,s=t.width,l=t.height;return e===1?{start:n?i:a,end:n?i+s:a+l}:{start:n?i+s:a+l,end:n?i:a}}function sd(t,e,r,n,i){if(t*e<t*n||t*e>t*i)return!1;var a=r();return t*(e-t*a/2-n)>=0&&t*(e+t*a/2-i)<=0}function sK(t,e){return Ej(t,e+1)}function uK(t,e,r,n,i){for(var a=(n||[]).slice(),s=e.start,l=e.end,c=0,f=1,p=s,h=function(){var S=n==null?void 0:n[c];if(S===void 0)return{v:Ej(n,f)};var w=c,b,E=function(){return b===void 0&&(b=r(S,w)),b},P=S.coordinate,T=c===0||sd(t,P,E,p,l);T||(c=0,p=s,f+=1),T&&(p=P+t*(E()/2+i),c+=f)},g;f<=a.length;)if(g=h(),g)return g.v;return[]}function fl(t){"@babel/helpers - typeof";return fl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},fl(t)}function VC(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function Zt(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?VC(Object(r),!0).forEach(function(n){lK(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):VC(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function lK(t,e,r){return e=cK(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function cK(t){var e=fK(t,"string");return fl(e)=="symbol"?e:e+""}function fK(t,e){if(fl(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(fl(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function dK(t,e,r,n,i){for(var a=(n||[]).slice(),s=a.length,l=e.start,c=e.end,f=function(g){var y=a[g],S,w=function(){return S===void 0&&(S=r(y,g)),S};if(g===s-1){var b=t*(y.coordinate+t*w()/2-c);a[g]=y=Zt(Zt({},y),{},{tickCoord:b>0?y.coordinate-b*t:y.coordinate})}else a[g]=y=Zt(Zt({},y),{},{tickCoord:y.coordinate});var E=sd(t,y.tickCoord,w,l,c);E&&(c=y.tickCoord-t*(w()/2+i),a[g]=Zt(Zt({},y),{},{isShow:!0}))},p=s-1;p>=0;p--)f(p);return a}function hK(t,e,r,n,i,a){var s=(n||[]).slice(),l=s.length,c=e.start,f=e.end;if(a){var p=n[l-1],h=r(p,l-1),g=t*(p.coordinate+t*h/2-f);s[l-1]=p=Zt(Zt({},p),{},{tickCoord:g>0?p.coordinate-g*t:p.coordinate});var y=sd(t,p.tickCoord,function(){return h},c,f);y&&(f=p.tickCoord-t*(h/2+i),s[l-1]=Zt(Zt({},p),{},{isShow:!0}))}for(var S=a?l-1:l,w=function(P){var T=s[P],O,_=function(){return O===void 0&&(O=r(T,P)),O};if(P===0){var A=t*(T.coordinate-t*_()/2-c);s[P]=T=Zt(Zt({},T),{},{tickCoord:A<0?T.coordinate-A*t:T.coordinate})}else s[P]=T=Zt(Zt({},T),{},{tickCoord:T.coordinate});var C=sd(t,T.tickCoord,_,c,f);C&&(c=T.tickCoord+t*(_()/2+i),s[P]=Zt(Zt({},T),{},{isShow:!0}))},b=0;b<S;b++)w(b);return s}function pK(t,e,r){var n=t.tick,i=t.ticks,a=t.viewBox,s=t.minTickGap,l=t.orientation,c=t.interval,f=t.tickFormatter,p=t.unit,h=t.angle;if(!i||!i.length||!n)return[];if(me(c)||Pl.isSsr)return sK(i,typeof c=="number"&&me(c)?c:0);var g=[],y=l==="top"||l==="bottom"?"width":"height",S=p&&y==="width"?Eu(p,{fontSize:e,letterSpacing:r}):{width:0,height:0},w=function(T,O){var _=ze(f)?f(T.value,O):T.value;return y==="width"?aK(Eu(_,{fontSize:e,letterSpacing:r}),S,h):Eu(_,{fontSize:e,letterSpacing:r})[y]},b=i.length>=2?on(i[1].coordinate-i[0].coordinate):1,E=oK(a,b,y);return c==="equidistantPreserveStart"?uK(b,E,w,i,s):(c==="preserveStart"||c==="preserveStartEnd"?g=hK(b,E,w,i,s,c==="preserveStartEnd"):g=dK(b,E,w,i,s),g.filter(function(P){return P.isShow}))}var vK=["viewBox"],gK=["viewBox"],mK=["ticks"];function es(t){"@babel/helpers - typeof";return es=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},es(t)}function yo(){return yo=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},yo.apply(this,arguments)}function KC(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function Ot(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?KC(Object(r),!0).forEach(function(n){tx(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):KC(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function qy(t,e){if(t==null)return{};var r=yK(t,e),n,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function yK(t,e){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(e.indexOf(n)>=0)continue;r[n]=t[n]}return r}function bK(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function XC(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Aj(n.key),n)}}function wK(t,e,r){return e&&XC(t.prototype,e),r&&XC(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function xK(t,e,r){return e=ud(e),SK(t,Oj()?Reflect.construct(e,r||[],ud(t).constructor):e.apply(t,r))}function SK(t,e){if(e&&(es(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _K(t)}function _K(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Oj(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Oj=function(){return!!t})()}function ud(t){return ud=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ud(t)}function EK(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&kb(t,e)}function kb(t,e){return kb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},kb(t,e)}function tx(t,e,r){return e=Aj(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Aj(t){var e=OK(t,"string");return es(e)=="symbol"?e:e+""}function OK(t,e){if(es(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(es(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var Vd=(function(t){function e(r){var n;return bK(this,e),n=xK(this,e,[r]),n.state={fontSize:"",letterSpacing:""},n}return EK(e,t),wK(e,[{key:"shouldComponentUpdate",value:function(n,i){var a=n.viewBox,s=qy(n,vK),l=this.props,c=l.viewBox,f=qy(l,gK);return!wo(a,c)||!wo(s,f)||!wo(i,this.state)}},{key:"componentDidMount",value:function(){var n=this.layerReference;if(n){var i=n.getElementsByClassName("recharts-cartesian-axis-tick-value")[0];i&&this.setState({fontSize:window.getComputedStyle(i).fontSize,letterSpacing:window.getComputedStyle(i).letterSpacing})}}},{key:"getTickLineCoord",value:function(n){var i=this.props,a=i.x,s=i.y,l=i.width,c=i.height,f=i.orientation,p=i.tickSize,h=i.mirror,g=i.tickMargin,y,S,w,b,E,P,T=h?-1:1,O=n.tickSize||p,_=me(n.tickCoord)?n.tickCoord:n.coordinate;switch(f){case"top":y=S=n.coordinate,b=s+ +!h*c,w=b-T*O,P=w-T*g,E=_;break;case"left":w=b=n.coordinate,S=a+ +!h*l,y=S-T*O,E=y-T*g,P=_;break;case"right":w=b=n.coordinate,S=a+ +h*l,y=S+T*O,E=y+T*g,P=_;break;default:y=S=n.coordinate,b=s+ +h*c,w=b+T*O,P=w+T*g,E=_;break}return{line:{x1:y,y1:w,x2:S,y2:b},tick:{x:E,y:P}}}},{key:"getTickTextAnchor",value:function(){var n=this.props,i=n.orientation,a=n.mirror,s;switch(i){case"left":s=a?"start":"end";break;case"right":s=a?"end":"start";break;default:s="middle";break}return s}},{key:"getTickVerticalAnchor",value:function(){var n=this.props,i=n.orientation,a=n.mirror,s="end";switch(i){case"left":case"right":s="middle";break;case"top":s=a?"start":"end";break;default:s=a?"end":"start";break}return s}},{key:"renderAxisLine",value:function(){var n=this.props,i=n.x,a=n.y,s=n.width,l=n.height,c=n.orientation,f=n.mirror,p=n.axisLine,h=Ot(Ot(Ot({},Ye(this.props,!1)),Ye(p,!1)),{},{fill:"none"});if(c==="top"||c==="bottom"){var g=+(c==="top"&&!f||c==="bottom"&&f);h=Ot(Ot({},h),{},{x1:i,y1:a+g*l,x2:i+s,y2:a+g*l})}else{var y=+(c==="left"&&!f||c==="right"&&f);h=Ot(Ot({},h),{},{x1:i+y*s,y1:a,x2:i+y*s,y2:a+l})}return Q.createElement("line",yo({},h,{className:He("recharts-cartesian-axis-line",$r(p,"className"))}))}},{key:"renderTicks",value:function(n,i,a){var s=this,l=this.props,c=l.tickLine,f=l.stroke,p=l.tick,h=l.tickFormatter,g=l.unit,y=pK(Ot(Ot({},this.props),{},{ticks:n}),i,a),S=this.getTickTextAnchor(),w=this.getTickVerticalAnchor(),b=Ye(this.props,!1),E=Ye(p,!1),P=Ot(Ot({},b),{},{fill:"none"},Ye(c,!1)),T=y.map(function(O,_){var A=s.getTickLineCoord(O),C=A.line,D=A.tick,j=Ot(Ot(Ot(Ot({textAnchor:S,verticalAnchor:w},b),{},{stroke:"none",fill:f},E),D),{},{index:_,payload:O,visibleTicksCount:y.length,tickFormatter:h});return Q.createElement($t,yo({className:"recharts-cartesian-axis-tick",key:"tick-".concat(O.value,"-").concat(O.coordinate,"-").concat(O.tickCoord)},mf(s.props,O,_)),c&&Q.createElement("line",yo({},P,C,{className:He("recharts-cartesian-axis-tick-line",$r(c,"className"))})),p&&e.renderTickItem(p,j,"".concat(ze(h)?h(O.value,_):O.value).concat(g||"")))});return Q.createElement("g",{className:"recharts-cartesian-axis-ticks"},T)}},{key:"render",value:function(){var n=this,i=this.props,a=i.axisLine,s=i.width,l=i.height,c=i.ticksGenerator,f=i.className,p=i.hide;if(p)return null;var h=this.props,g=h.ticks,y=qy(h,mK),S=g;return ze(c)&&(S=g&&g.length>0?c(this.props):c(y)),s<=0||l<=0||!S||!S.length?null:Q.createElement($t,{className:He("recharts-cartesian-axis",f),ref:function(b){n.layerReference=b}},a&&this.renderAxisLine(),this.renderTicks(S,this.state.fontSize,this.state.letterSpacing),Jt.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(n,i,a){var s,l=He(i.className,"recharts-cartesian-axis-tick-value");return Q.isValidElement(n)?s=Q.cloneElement(n,Ot(Ot({},i),{},{className:l})):ze(n)?s=n(Ot(Ot({},i),{},{className:l})):s=Q.createElement(Tf,yo({},i,{className:"recharts-cartesian-axis-tick-value"}),a),s}}])})(N.Component);tx(Vd,"displayName","CartesianAxis");tx(Vd,"defaultProps",{x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd"});function ts(t){"@babel/helpers - typeof";return ts=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ts(t)}function AK(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function PK(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Cj(n.key),n)}}function TK(t,e,r){return e&&PK(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function CK(t,e,r){return e=ld(e),kK(t,Pj()?Reflect.construct(e,r||[],ld(t).constructor):e.apply(t,r))}function kK(t,e){if(e&&(ts(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return RK(t)}function RK(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Pj(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Pj=function(){return!!t})()}function ld(t){return ld=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ld(t)}function DK(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Rb(t,e)}function Rb(t,e){return Rb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Rb(t,e)}function Tj(t,e,r){return e=Cj(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Cj(t){var e=jK(t,"string");return ts(e)=="symbol"?e:e+""}function jK(t,e){if(ts(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(ts(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}function Db(){return Db=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Db.apply(this,arguments)}function IK(t){var e=t.xAxisId,r=gj(),n=mj(),i=pj(e);return i==null?null:N.createElement(Vd,Db({},i,{className:He("recharts-".concat(i.axisType," ").concat(i.axisType),i.className),viewBox:{x:0,y:0,width:r,height:n},ticksGenerator:function(s){return ma(s,!0)}}))}var dl=(function(t){function e(){return AK(this,e),CK(this,e,arguments)}return DK(e,t),TK(e,[{key:"render",value:function(){return N.createElement(IK,this.props)}}])})(N.Component);Tj(dl,"displayName","XAxis");Tj(dl,"defaultProps",{allowDecimals:!0,hide:!1,orientation:"bottom",width:0,height:30,mirror:!1,xAxisId:0,tickCount:5,type:"category",padding:{left:0,right:0},allowDataOverflow:!1,scale:"auto",reversed:!1,allowDuplicatedCategory:!0});function rs(t){"@babel/helpers - typeof";return rs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},rs(t)}function NK(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function MK(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Dj(n.key),n)}}function LK(t,e,r){return e&&MK(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function $K(t,e,r){return e=cd(e),FK(t,kj()?Reflect.construct(e,r||[],cd(t).constructor):e.apply(t,r))}function FK(t,e){if(e&&(rs(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return BK(t)}function BK(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function kj(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(kj=function(){return!!t})()}function cd(t){return cd=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},cd(t)}function GK(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&jb(t,e)}function jb(t,e){return jb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},jb(t,e)}function Rj(t,e,r){return e=Dj(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Dj(t){var e=zK(t,"string");return rs(e)=="symbol"?e:e+""}function zK(t,e){if(rs(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(rs(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}function Ib(){return Ib=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Ib.apply(this,arguments)}var UK=function(e){var r=e.yAxisId,n=gj(),i=mj(),a=vj(r);return a==null?null:N.createElement(Vd,Ib({},a,{className:He("recharts-".concat(a.axisType," ").concat(a.axisType),a.className),viewBox:{x:0,y:0,width:n,height:i},ticksGenerator:function(l){return ma(l,!0)}}))},hl=(function(t){function e(){return NK(this,e),$K(this,e,arguments)}return GK(e,t),LK(e,[{key:"render",value:function(){return N.createElement(UK,this.props)}}])})(N.Component);Rj(hl,"displayName","YAxis");Rj(hl,"defaultProps",{allowDuplicatedCategory:!0,allowDecimals:!0,hide:!1,orientation:"left",width:60,height:0,mirror:!1,yAxisId:0,tickCount:5,type:"number",padding:{top:0,bottom:0},allowDataOverflow:!1,scale:"auto",reversed:!1});function YC(t){return VK(t)||HK(t)||WK(t)||qK()}function qK(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
176
176
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function WK(t,e){if(t){if(typeof t=="string")return Nb(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Nb(t,e)}}function HK(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function VK(t){if(Array.isArray(t))return Nb(t)}function Nb(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var Mb=function(e,r,n,i,a){var s=sn(e,ex),l=sn(e,qd),c=[].concat(YC(s),YC(l)),f=sn(e,Hd),p="".concat(i,"Id"),h=i[0],g=r;if(c.length&&(g=c.reduce(function(w,b){if(b.props[p]===n&&Pn(b.props,"extendDomain")&&me(b.props[h])){var E=b.props[h];return[Math.min(w[0],E),Math.max(w[1],E)]}return w},g)),f.length){var y="".concat(h,"1"),S="".concat(h,"2");g=f.reduce(function(w,b){if(b.props[p]===n&&Pn(b.props,"extendDomain")&&me(b.props[y])&&me(b.props[S])){var E=b.props[y],P=b.props[S];return[Math.min(w[0],E,P),Math.max(w[1],E,P)]}return w},g)}return a&&a.length&&(g=a.reduce(function(w,b){return me(b)?[Math.min(w[0],b),Math.max(w[1],b)]:w},g)),g},Wy={exports:{}},QC;function KK(){return QC||(QC=1,(function(t){var e=Object.prototype.hasOwnProperty,r="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(r=!1));function i(c,f,p){this.fn=c,this.context=f,this.once=p||!1}function a(c,f,p,h,g){if(typeof p!="function")throw new TypeError("The listener must be a function");var y=new i(p,h||c,g),S=r?r+f:f;return c._events[S]?c._events[S].fn?c._events[S]=[c._events[S],y]:c._events[S].push(y):(c._events[S]=y,c._eventsCount++),c}function s(c,f){--c._eventsCount===0?c._events=new n:delete c._events[f]}function l(){this._events=new n,this._eventsCount=0}l.prototype.eventNames=function(){var f=[],p,h;if(this._eventsCount===0)return f;for(h in p=this._events)e.call(p,h)&&f.push(r?h.slice(1):h);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(p)):f},l.prototype.listeners=function(f){var p=r?r+f:f,h=this._events[p];if(!h)return[];if(h.fn)return[h.fn];for(var g=0,y=h.length,S=new Array(y);g<y;g++)S[g]=h[g].fn;return S},l.prototype.listenerCount=function(f){var p=r?r+f:f,h=this._events[p];return h?h.fn?1:h.length:0},l.prototype.emit=function(f,p,h,g,y,S){var w=r?r+f:f;if(!this._events[w])return!1;var b=this._events[w],E=arguments.length,P,T;if(b.fn){switch(b.once&&this.removeListener(f,b.fn,void 0,!0),E){case 1:return b.fn.call(b.context),!0;case 2:return b.fn.call(b.context,p),!0;case 3:return b.fn.call(b.context,p,h),!0;case 4:return b.fn.call(b.context,p,h,g),!0;case 5:return b.fn.call(b.context,p,h,g,y),!0;case 6:return b.fn.call(b.context,p,h,g,y,S),!0}for(T=1,P=new Array(E-1);T<E;T++)P[T-1]=arguments[T];b.fn.apply(b.context,P)}else{var O=b.length,_;for(T=0;T<O;T++)switch(b[T].once&&this.removeListener(f,b[T].fn,void 0,!0),E){case 1:b[T].fn.call(b[T].context);break;case 2:b[T].fn.call(b[T].context,p);break;case 3:b[T].fn.call(b[T].context,p,h);break;case 4:b[T].fn.call(b[T].context,p,h,g);break;default:if(!P)for(_=1,P=new Array(E-1);_<E;_++)P[_-1]=arguments[_];b[T].fn.apply(b[T].context,P)}}return!0},l.prototype.on=function(f,p,h){return a(this,f,p,h,!1)},l.prototype.once=function(f,p,h){return a(this,f,p,h,!0)},l.prototype.removeListener=function(f,p,h,g){var y=r?r+f:f;if(!this._events[y])return this;if(!p)return s(this,y),this;var S=this._events[y];if(S.fn)S.fn===p&&(!g||S.once)&&(!h||S.context===h)&&s(this,y);else{for(var w=0,b=[],E=S.length;w<E;w++)(S[w].fn!==p||g&&!S[w].once||h&&S[w].context!==h)&&b.push(S[w]);b.length?this._events[y]=b.length===1?b[0]:b:s(this,y)}return this},l.prototype.removeAllListeners=function(f){var p;return f?(p=r?r+f:f,this._events[p]&&s(this,p)):(this._events=new n,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=r,l.EventEmitter=l,t.exports=l})(Wy)),Wy.exports}var XK=KK();const YK=tt(XK);var Hy=new YK,Vy="recharts.syncMouseEvents";function pl(t){"@babel/helpers - typeof";return pl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},pl(t)}function QK(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ZK(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,jj(n.key),n)}}function JK(t,e,r){return e&&ZK(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function Ky(t,e,r){return e=jj(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function jj(t){var e=e7(t,"string");return pl(e)=="symbol"?e:e+""}function e7(t,e){if(pl(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(pl(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var t7=(function(){function t(){QK(this,t),Ky(this,"activeIndex",0),Ky(this,"coordinateList",[]),Ky(this,"layout","horizontal")}return JK(t,[{key:"setDetails",value:function(r){var n,i=r.coordinateList,a=i===void 0?null:i,s=r.container,l=s===void 0?null:s,c=r.layout,f=c===void 0?null:c,p=r.offset,h=p===void 0?null:p,g=r.mouseHandlerCallback,y=g===void 0?null:g;this.coordinateList=(n=a??this.coordinateList)!==null&&n!==void 0?n:[],this.container=l??this.container,this.layout=f??this.layout,this.offset=h??this.offset,this.mouseHandlerCallback=y??this.mouseHandlerCallback,this.activeIndex=Math.min(Math.max(this.activeIndex,0),this.coordinateList.length-1)}},{key:"focus",value:function(){this.spoofMouse()}},{key:"keyboardEvent",value:function(r){if(this.coordinateList.length!==0)switch(r.key){case"ArrowRight":{if(this.layout!=="horizontal")return;this.activeIndex=Math.min(this.activeIndex+1,this.coordinateList.length-1),this.spoofMouse();break}case"ArrowLeft":{if(this.layout!=="horizontal")return;this.activeIndex=Math.max(this.activeIndex-1,0),this.spoofMouse();break}}}},{key:"setIndex",value:function(r){this.activeIndex=r}},{key:"spoofMouse",value:function(){var r,n;if(this.layout==="horizontal"&&this.coordinateList.length!==0){var i=this.container.getBoundingClientRect(),a=i.x,s=i.y,l=i.height,c=this.coordinateList[this.activeIndex].coordinate,f=((r=window)===null||r===void 0?void 0:r.scrollX)||0,p=((n=window)===null||n===void 0?void 0:n.scrollY)||0,h=a+c+f,g=s+this.offset.top+l/2+p;this.mouseHandlerCallback({pageX:h,pageY:g})}}}])})();function r7(t,e,r){if(r==="number"&&e===!0&&Array.isArray(t)){var n=t==null?void 0:t[0],i=t==null?void 0:t[1];if(n&&i&&me(n)&&me(i))return!0}return!1}function n7(t,e,r,n){var i=n/2;return{stroke:"none",fill:"#ccc",x:t==="horizontal"?e.x-i:r.left+.5,y:t==="horizontal"?r.top+.5:e.y-i,width:t==="horizontal"?n:r.width-1,height:t==="horizontal"?r.height-1:n}}function Ij(t){var e=t.cx,r=t.cy,n=t.radius,i=t.startAngle,a=t.endAngle,s=Ht(e,r,n,i),l=Ht(e,r,n,a);return{points:[s,l],cx:e,cy:r,radius:n,startAngle:i,endAngle:a}}function i7(t,e,r){var n,i,a,s;if(t==="horizontal")n=e.x,a=n,i=r.top,s=r.top+r.height;else if(t==="vertical")i=e.y,s=i,n=r.left,a=r.left+r.width;else if(e.cx!=null&&e.cy!=null)if(t==="centric"){var l=e.cx,c=e.cy,f=e.innerRadius,p=e.outerRadius,h=e.angle,g=Ht(l,c,f,h),y=Ht(l,c,p,h);n=g.x,i=g.y,a=y.x,s=y.y}else return Ij(e);return[{x:n,y:i},{x:a,y:s}]}function vl(t){"@babel/helpers - typeof";return vl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},vl(t)}function ZC(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function rf(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ZC(Object(r),!0).forEach(function(n){a7(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ZC(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function a7(t,e,r){return e=o7(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o7(t){var e=s7(t,"string");return vl(e)=="symbol"?e:e+""}function s7(t,e){if(vl(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(vl(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function u7(t){var e,r,n=t.element,i=t.tooltipEventType,a=t.isActive,s=t.activeCoordinate,l=t.activePayload,c=t.offset,f=t.activeTooltipIndex,p=t.tooltipAxisBandSize,h=t.layout,g=t.chartName,y=(e=n.props.cursor)!==null&&e!==void 0?e:(r=n.type.defaultProps)===null||r===void 0?void 0:r.cursor;if(!n||!y||!a||!s||g!=="ScatterChart"&&i!=="axis")return null;var S,w=IT;if(g==="ScatterChart")S=s,w=IH;else if(g==="BarChart")S=n7(h,s,c,p),w=Qw;else if(h==="radial"){var b=Ij(s),E=b.cx,P=b.cy,T=b.radius,O=b.startAngle,_=b.endAngle;S={cx:E,cy:P,startAngle:O,endAngle:_,innerRadius:T,outerRadius:T},w=U2}else S={points:i7(h,s,c)},w=IT;var A=rf(rf(rf(rf({stroke:"#ccc",pointerEvents:"none"},c),S),Ye(y,!1)),{},{payload:l,payloadIndex:f,className:He("recharts-tooltip-cursor",y.className)});return N.isValidElement(y)?N.cloneElement(y,A):N.createElement(w,A)}var l7=["item"],c7=["children","className","width","height","style","compact","title","desc"];function ns(t){"@babel/helpers - typeof";return ns=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ns(t)}function bo(){return bo=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},bo.apply(this,arguments)}function JC(t,e){return h7(t)||d7(t,e)||Mj(t,e)||f7()}function f7(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
177
177
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function d7(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,i,a,s,l=[],c=!0,f=!1;try{if(a=(r=r.call(t)).next,e!==0)for(;!(c=(n=a.call(r)).done)&&(l.push(n.value),l.length!==e);c=!0);}catch(p){f=!0,i=p}finally{try{if(!c&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(f)throw i}}return l}}function h7(t){if(Array.isArray(t))return t}function ek(t,e){if(t==null)return{};var r=p7(t,e),n,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function p7(t,e){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(e.indexOf(n)>=0)continue;r[n]=t[n]}return r}function v7(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function g7(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Lj(n.key),n)}}function m7(t,e,r){return e&&g7(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function y7(t,e,r){return e=fd(e),b7(t,Nj()?Reflect.construct(e,r||[],fd(t).constructor):e.apply(t,r))}function b7(t,e){if(e&&(ns(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return w7(t)}function w7(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Nj(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Nj=function(){return!!t})()}function fd(t){return fd=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},fd(t)}function x7(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Lb(t,e)}function Lb(t,e){return Lb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Lb(t,e)}function is(t){return E7(t)||_7(t)||Mj(t)||S7()}function S7(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
178
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Mj(t,e){if(t){if(typeof t=="string")return $b(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return $b(t,e)}}function _7(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function E7(t){if(Array.isArray(t))return $b(t)}function $b(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function tk(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function ae(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?tk(Object(r),!0).forEach(function(n){je(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):tk(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function je(t,e,r){return e=Lj(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Lj(t){var e=O7(t,"string");return ns(e)=="symbol"?e:e+""}function O7(t,e){if(ns(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(ns(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var A7={xAxis:["bottom","top"],yAxis:["left","right"]},P7={width:"100%",height:"100%"},$j={x:0,y:0};function nf(t){return t}var T7=function(e,r){return r==="horizontal"?e.x:r==="vertical"?e.y:r==="centric"?e.angle:e.radius},C7=function(e,r,n,i){var a=r.find(function(p){return p&&p.index===n});if(a){if(e==="horizontal")return{x:a.coordinate,y:i.y};if(e==="vertical")return{x:i.x,y:a.coordinate};if(e==="centric"){var s=a.coordinate,l=i.radius;return ae(ae(ae({},i),Ht(i.cx,i.cy,l,s)),{},{angle:s,radius:l})}var c=a.coordinate,f=i.angle;return ae(ae(ae({},i),Ht(i.cx,i.cy,c,f)),{},{angle:f,radius:c})}return $j},Kd=function(e,r){var n=r.graphicalItems,i=r.dataStartIndex,a=r.dataEndIndex,s=(n??[]).reduce(function(l,c){var f=c.props.data;return f&&f.length?[].concat(is(l),is(f)):l},[]);return s.length>0?s:e&&e.length&&me(i)&&me(a)?e.slice(i,a+1):[]};function Fj(t){return t==="number"?[0,"auto"]:void 0}var Fb=function(e,r,n,i){var a=e.graphicalItems,s=e.tooltipAxis,l=Kd(r,e);return n<0||!a||!a.length||n>=l.length?null:a.reduce(function(c,f){var p,h=(p=f.props.data)!==null&&p!==void 0?p:r;h&&e.dataStartIndex+e.dataEndIndex!==0&&e.dataEndIndex-e.dataStartIndex>=n&&(h=h.slice(e.dataStartIndex,e.dataEndIndex+1));var g;if(s.dataKey&&!s.allowDuplicatedCategory){var y=h===void 0?l:h;g=O0(y,s.dataKey,i)}else g=h&&h[n]||l[n];return g?[].concat(is(c),[B2(f,g)]):c},[])},rk=function(e,r,n,i){var a=i||{x:e.chartX,y:e.chartY},s=T7(a,n),l=e.orderedTooltipTicks,c=e.tooltipAxis,f=e.tooltipTicks,p=h5(s,l,f,c);if(p>=0&&f){var h=f[p]&&f[p].value,g=Fb(e,r,p,h),y=C7(n,l,p,a);return{activeTooltipIndex:p,activeLabel:h,activePayload:g,activeCoordinate:y}}return null},k7=function(e,r){var n=r.axes,i=r.graphicalItems,a=r.axisType,s=r.axisIdKey,l=r.stackGroups,c=r.dataStartIndex,f=r.dataEndIndex,p=e.layout,h=e.children,g=e.stackOffset,y=$2(p,a);return n.reduce(function(S,w){var b,E=w.type.defaultProps!==void 0?ae(ae({},w.type.defaultProps),w.props):w.props,P=E.type,T=E.dataKey,O=E.allowDataOverflow,_=E.allowDuplicatedCategory,A=E.scale,C=E.ticks,D=E.includeHidden,j=E[s];if(S[j])return S;var G=Kd(e.data,{graphicalItems:i.filter(function(W){var te,we=s in W.props?W.props[s]:(te=W.type.defaultProps)===null||te===void 0?void 0:te[s];return we===j}),dataStartIndex:c,dataEndIndex:f}),z=G.length,$,R,X;r7(E.domain,O,P)&&($=ab(E.domain,null,O),y&&(P==="number"||A!=="auto")&&(X=Au(G,T,"category")));var K=Fj(P);if(!$||$.length===0){var B,I=(B=E.domain)!==null&&B!==void 0?B:K;if(T){if($=Au(G,T,P),P==="category"&&y){var V=aB($);_&&V?(R=$,$=Jf(0,z)):_||($=wT(I,$,w).reduce(function(W,te){return W.indexOf(te)>=0?W:[].concat(is(W),[te])},[]))}else if(P==="category")_?$=$.filter(function(W){return W!==""&&!Ve(W)}):$=wT(I,$,w).reduce(function(W,te){return W.indexOf(te)>=0||te===""||Ve(te)?W:[].concat(is(W),[te])},[]);else if(P==="number"){var J=y5(G,i.filter(function(W){var te,we,xe=s in W.props?W.props[s]:(te=W.type.defaultProps)===null||te===void 0?void 0:te[s],Ie="hide"in W.props?W.props.hide:(we=W.type.defaultProps)===null||we===void 0?void 0:we.hide;return xe===j&&(D||!Ie)}),T,a,p);J&&($=J)}y&&(P==="number"||A!=="auto")&&(X=Au(G,T,"category"))}else y?$=Jf(0,z):l&&l[j]&&l[j].hasStack&&P==="number"?$=g==="expand"?[0,1]:F2(l[j].stackGroups,c,f):$=L2(G,i.filter(function(W){var te=s in W.props?W.props[s]:W.type.defaultProps[s],we="hide"in W.props?W.props.hide:W.type.defaultProps.hide;return te===j&&(D||!we)}),P,p,!0);if(P==="number")$=Mb(h,$,j,a,C),I&&($=ab(I,$,O));else if(P==="category"&&I){var ee=I,L=$.every(function(W){return ee.indexOf(W)>=0});L&&($=ee)}}return ae(ae({},S),{},je({},j,ae(ae({},E),{},{axisType:a,domain:$,categoricalDomain:X,duplicateDomain:R,originalDomain:(b=E.domain)!==null&&b!==void 0?b:K,isCategorical:y,layout:p})))},{})},R7=function(e,r){var n=r.graphicalItems,i=r.Axis,a=r.axisType,s=r.axisIdKey,l=r.stackGroups,c=r.dataStartIndex,f=r.dataEndIndex,p=e.layout,h=e.children,g=Kd(e.data,{graphicalItems:n,dataStartIndex:c,dataEndIndex:f}),y=g.length,S=$2(p,a),w=-1;return n.reduce(function(b,E){var P=E.type.defaultProps!==void 0?ae(ae({},E.type.defaultProps),E.props):E.props,T=P[s],O=Fj("number");if(!b[T]){w++;var _;return S?_=Jf(0,y):l&&l[T]&&l[T].hasStack?(_=F2(l[T].stackGroups,c,f),_=Mb(h,_,T,a)):(_=ab(O,L2(g,n.filter(function(A){var C,D,j=s in A.props?A.props[s]:(C=A.type.defaultProps)===null||C===void 0?void 0:C[s],G="hide"in A.props?A.props.hide:(D=A.type.defaultProps)===null||D===void 0?void 0:D.hide;return j===T&&!G}),"number",p),i.defaultProps.allowDataOverflow),_=Mb(h,_,T,a)),ae(ae({},b),{},je({},T,ae(ae({axisType:a},i.defaultProps),{},{hide:!0,orientation:$r(A7,"".concat(a,".").concat(w%2),null),domain:_,originalDomain:O,isCategorical:S,layout:p})))}return b},{})},D7=function(e,r){var n=r.axisType,i=n===void 0?"xAxis":n,a=r.AxisComp,s=r.graphicalItems,l=r.stackGroups,c=r.dataStartIndex,f=r.dataEndIndex,p=e.children,h="".concat(i,"Id"),g=sn(p,a),y={};return g&&g.length?y=k7(e,{axes:g,graphicalItems:s,axisType:i,axisIdKey:h,stackGroups:l,dataStartIndex:c,dataEndIndex:f}):s&&s.length&&(y=R7(e,{Axis:a,graphicalItems:s,axisType:i,axisIdKey:h,stackGroups:l,dataStartIndex:c,dataEndIndex:f})),y},j7=function(e){var r=go(e),n=ma(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:_w(n,function(i){return i.coordinate}),tooltipAxis:r,tooltipAxisBandSize:Uf(r,n)}},nk=function(e){var r=e.children,n=e.defaultShowTooltip,i=xr(r,Xo),a=0,s=0;return e.data&&e.data.length!==0&&(s=e.data.length-1),i&&i.props&&(i.props.startIndex>=0&&(a=i.props.startIndex),i.props.endIndex>=0&&(s=i.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:a,dataEndIndex:s,activeTooltipIndex:-1,isTooltipActive:!!n}},I7=function(e){return!e||!e.length?!1:e.some(function(r){var n=Qn(r&&r.type);return n&&n.indexOf("Bar")>=0})},ik=function(e){return e==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:e==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:e==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},N7=function(e,r){var n=e.props,i=e.graphicalItems,a=e.xAxisMap,s=a===void 0?{}:a,l=e.yAxisMap,c=l===void 0?{}:l,f=n.width,p=n.height,h=n.children,g=n.margin||{},y=xr(h,Xo),S=xr(h,xo),w=Object.keys(c).reduce(function(_,A){var C=c[A],D=C.orientation;return!C.mirror&&!C.hide?ae(ae({},_),{},je({},D,_[D]+C.width)):_},{left:g.left||0,right:g.right||0}),b=Object.keys(s).reduce(function(_,A){var C=s[A],D=C.orientation;return!C.mirror&&!C.hide?ae(ae({},_),{},je({},D,$r(_,"".concat(D))+C.height)):_},{top:g.top||0,bottom:g.bottom||0}),E=ae(ae({},b),w),P=E.bottom;y&&(E.bottom+=y.props.height||Xo.defaultProps.height),S&&r&&(E=g5(E,i,n,r));var T=f-E.left-E.right,O=p-E.top-E.bottom;return ae(ae({brushBottom:P},E),{},{width:Math.max(T,0),height:Math.max(O,0)})},M7=function(e,r){if(r==="xAxis")return e[r].width;if(r==="yAxis")return e[r].height},L7=function(e){var r=e.chartName,n=e.GraphicalChild,i=e.defaultTooltipEventType,a=i===void 0?"axis":i,s=e.validateTooltipEventTypes,l=s===void 0?["axis"]:s,c=e.axisComponents,f=e.legendContent,p=e.formatAxisMap,h=e.defaultProps,g=function(E,P){var T=P.graphicalItems,O=P.stackGroups,_=P.offset,A=P.updateId,C=P.dataStartIndex,D=P.dataEndIndex,j=E.barSize,G=E.layout,z=E.barGap,$=E.barCategoryGap,R=E.maxBarSize,X=ik(G),K=X.numericAxisName,B=X.cateAxisName,I=I7(T),V=[];return T.forEach(function(J,ee){var L=Kd(E.data,{graphicalItems:[J],dataStartIndex:C,dataEndIndex:D}),W=J.type.defaultProps!==void 0?ae(ae({},J.type.defaultProps),J.props):J.props,te=W.dataKey,we=W.maxBarSize,xe=W["".concat(K,"Id")],Ie=W["".concat(B,"Id")],Le={},Me=c.reduce(function(rt,Dt){var cn=P["".concat(Dt.axisType,"Map")],fn=W["".concat(Dt.axisType,"Id")];cn&&cn[fn]||Dt.axisType==="zAxis"||Na();var dn=cn[fn];return ae(ae({},rt),{},je(je({},Dt.axisType,dn),"".concat(Dt.axisType,"Ticks"),ma(dn)))},Le),le=Me[B],pe=Me["".concat(B,"Ticks")],ve=O&&O[xe]&&O[xe].hasStack&&k5(J,O[xe].stackGroups),ie=Qn(J.type).indexOf("Bar")>=0,Fe=Uf(le,pe),de=[],ge=I&&p5({barSize:j,stackGroups:O,totalSize:M7(Me,B)});if(ie){var ne,it,kt=Ve(we)?R:we,Rt=(ne=(it=Uf(le,pe,!0))!==null&&it!==void 0?it:kt)!==null&&ne!==void 0?ne:0;de=v5({barGap:z,barCategoryGap:$,bandSize:Rt!==Fe?Rt:Fe,sizeList:ge[Ie],maxBarSize:kt}),Rt!==Fe&&(de=de.map(function(rt){return ae(ae({},rt),{},{position:ae(ae({},rt.position),{},{offset:rt.position.offset-Rt/2})})}))}var Bt=J&&J.type&&J.type.getComposedData;Bt&&V.push({props:ae(ae({},Bt(ae(ae({},Me),{},{displayedData:L,props:E,dataKey:te,item:J,bandSize:Fe,barPosition:de,offset:_,stackedData:ve,layout:G,dataStartIndex:C,dataEndIndex:D}))),{},je(je(je({key:J.key||"item-".concat(ee)},K,Me[K]),B,Me[B]),"animationId",A)),childIndex:mB(J,E.children),item:J})}),V},y=function(E,P){var T=E.props,O=E.dataStartIndex,_=E.dataEndIndex,A=E.updateId;if(!IE({props:T}))return null;var C=T.children,D=T.layout,j=T.stackOffset,G=T.data,z=T.reverseStackOrder,$=ik(D),R=$.numericAxisName,X=$.cateAxisName,K=sn(C,n),B=P5(G,K,"".concat(R,"Id"),"".concat(X,"Id"),j,z),I=c.reduce(function(W,te){var we="".concat(te.axisType,"Map");return ae(ae({},W),{},je({},we,D7(T,ae(ae({},te),{},{graphicalItems:K,stackGroups:te.axisType===R&&B,dataStartIndex:O,dataEndIndex:_}))))},{}),V=N7(ae(ae({},I),{},{props:T,graphicalItems:K}),P==null?void 0:P.legendBBox);Object.keys(I).forEach(function(W){I[W]=p(T,I[W],V,W.replace("Map",""),r)});var J=I["".concat(X,"Map")],ee=j7(J),L=g(T,ae(ae({},I),{},{dataStartIndex:O,dataEndIndex:_,updateId:A,graphicalItems:K,stackGroups:B,offset:V}));return ae(ae({formattedGraphicalItems:L,graphicalItems:K,offset:V,stackGroups:B},ee),I)},S=(function(b){function E(P){var T,O,_;return v7(this,E),_=y7(this,E,[P]),je(_,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),je(_,"accessibilityManager",new t7),je(_,"handleLegendBBoxUpdate",function(A){if(A){var C=_.state,D=C.dataStartIndex,j=C.dataEndIndex,G=C.updateId;_.setState(ae({legendBBox:A},y({props:_.props,dataStartIndex:D,dataEndIndex:j,updateId:G},ae(ae({},_.state),{},{legendBBox:A}))))}}),je(_,"handleReceiveSyncEvent",function(A,C,D){if(_.props.syncId===A){if(D===_.eventEmitterSymbol&&typeof _.props.syncMethod!="function")return;_.applySyncEvent(C)}}),je(_,"handleBrushChange",function(A){var C=A.startIndex,D=A.endIndex;if(C!==_.state.dataStartIndex||D!==_.state.dataEndIndex){var j=_.state.updateId;_.setState(function(){return ae({dataStartIndex:C,dataEndIndex:D},y({props:_.props,dataStartIndex:C,dataEndIndex:D,updateId:j},_.state))}),_.triggerSyncEvent({dataStartIndex:C,dataEndIndex:D})}}),je(_,"handleMouseEnter",function(A){var C=_.getMouseInfo(A);if(C){var D=ae(ae({},C),{},{isTooltipActive:!0});_.setState(D),_.triggerSyncEvent(D);var j=_.props.onMouseEnter;ze(j)&&j(D,A)}}),je(_,"triggeredAfterMouseMove",function(A){var C=_.getMouseInfo(A),D=C?ae(ae({},C),{},{isTooltipActive:!0}):{isTooltipActive:!1};_.setState(D),_.triggerSyncEvent(D);var j=_.props.onMouseMove;ze(j)&&j(D,A)}),je(_,"handleItemMouseEnter",function(A){_.setState(function(){return{isTooltipActive:!0,activeItem:A,activePayload:A.tooltipPayload,activeCoordinate:A.tooltipPosition||{x:A.cx,y:A.cy}}})}),je(_,"handleItemMouseLeave",function(){_.setState(function(){return{isTooltipActive:!1}})}),je(_,"handleMouseMove",function(A){A.persist(),_.throttleTriggeredAfterMouseMove(A)}),je(_,"handleMouseLeave",function(A){_.throttleTriggeredAfterMouseMove.cancel();var C={isTooltipActive:!1};_.setState(C),_.triggerSyncEvent(C);var D=_.props.onMouseLeave;ze(D)&&D(C,A)}),je(_,"handleOuterEvent",function(A){var C=gB(A),D=$r(_.props,"".concat(C));if(C&&ze(D)){var j,G;/.*touch.*/i.test(C)?G=_.getMouseInfo(A.changedTouches[0]):G=_.getMouseInfo(A),D((j=G)!==null&&j!==void 0?j:{},A)}}),je(_,"handleClick",function(A){var C=_.getMouseInfo(A);if(C){var D=ae(ae({},C),{},{isTooltipActive:!0});_.setState(D),_.triggerSyncEvent(D);var j=_.props.onClick;ze(j)&&j(D,A)}}),je(_,"handleMouseDown",function(A){var C=_.props.onMouseDown;if(ze(C)){var D=_.getMouseInfo(A);C(D,A)}}),je(_,"handleMouseUp",function(A){var C=_.props.onMouseUp;if(ze(C)){var D=_.getMouseInfo(A);C(D,A)}}),je(_,"handleTouchMove",function(A){A.changedTouches!=null&&A.changedTouches.length>0&&_.throttleTriggeredAfterMouseMove(A.changedTouches[0])}),je(_,"handleTouchStart",function(A){A.changedTouches!=null&&A.changedTouches.length>0&&_.handleMouseDown(A.changedTouches[0])}),je(_,"handleTouchEnd",function(A){A.changedTouches!=null&&A.changedTouches.length>0&&_.handleMouseUp(A.changedTouches[0])}),je(_,"handleDoubleClick",function(A){var C=_.props.onDoubleClick;if(ze(C)){var D=_.getMouseInfo(A);C(D,A)}}),je(_,"handleContextMenu",function(A){var C=_.props.onContextMenu;if(ze(C)){var D=_.getMouseInfo(A);C(D,A)}}),je(_,"triggerSyncEvent",function(A){_.props.syncId!==void 0&&Hy.emit(Vy,_.props.syncId,A,_.eventEmitterSymbol)}),je(_,"applySyncEvent",function(A){var C=_.props,D=C.layout,j=C.syncMethod,G=_.state.updateId,z=A.dataStartIndex,$=A.dataEndIndex;if(A.dataStartIndex!==void 0||A.dataEndIndex!==void 0)_.setState(ae({dataStartIndex:z,dataEndIndex:$},y({props:_.props,dataStartIndex:z,dataEndIndex:$,updateId:G},_.state)));else if(A.activeTooltipIndex!==void 0){var R=A.chartX,X=A.chartY,K=A.activeTooltipIndex,B=_.state,I=B.offset,V=B.tooltipTicks;if(!I)return;if(typeof j=="function")K=j(V,A);else if(j==="value"){K=-1;for(var J=0;J<V.length;J++)if(V[J].value===A.activeLabel){K=J;break}}var ee=ae(ae({},I),{},{x:I.left,y:I.top}),L=Math.min(R,ee.x+ee.width),W=Math.min(X,ee.y+ee.height),te=V[K]&&V[K].value,we=Fb(_.state,_.props.data,K),xe=V[K]?{x:D==="horizontal"?V[K].coordinate:L,y:D==="horizontal"?W:V[K].coordinate}:$j;_.setState(ae(ae({},A),{},{activeLabel:te,activeCoordinate:xe,activePayload:we,activeTooltipIndex:K}))}else _.setState(A)}),je(_,"renderCursor",function(A){var C,D=_.state,j=D.isTooltipActive,G=D.activeCoordinate,z=D.activePayload,$=D.offset,R=D.activeTooltipIndex,X=D.tooltipAxisBandSize,K=_.getTooltipEventType(),B=(C=A.props.active)!==null&&C!==void 0?C:j,I=_.props.layout,V=A.key||"_recharts-cursor";return Q.createElement(u7,{key:V,activeCoordinate:G,activePayload:z,activeTooltipIndex:R,chartName:r,element:A,isActive:B,layout:I,offset:$,tooltipAxisBandSize:X,tooltipEventType:K})}),je(_,"renderPolarAxis",function(A,C,D){var j=$r(A,"type.axisType"),G=$r(_.state,"".concat(j,"Map")),z=A.type.defaultProps,$=z!==void 0?ae(ae({},z),A.props):A.props,R=G&&G[$["".concat(j,"Id")]];return N.cloneElement(A,ae(ae({},R),{},{className:He(j,R.className),key:A.key||"".concat(C,"-").concat(D),ticks:ma(R,!0)}))}),je(_,"renderPolarGrid",function(A){var C=A.props,D=C.radialLines,j=C.polarAngles,G=C.polarRadius,z=_.state,$=z.radiusAxisMap,R=z.angleAxisMap,X=go($),K=go(R),B=K.cx,I=K.cy,V=K.innerRadius,J=K.outerRadius;return N.cloneElement(A,{polarAngles:Array.isArray(j)?j:ma(K,!0).map(function(ee){return ee.coordinate}),polarRadius:Array.isArray(G)?G:ma(X,!0).map(function(ee){return ee.coordinate}),cx:B,cy:I,innerRadius:V,outerRadius:J,key:A.key||"polar-grid",radialLines:D})}),je(_,"renderLegend",function(){var A=_.state.formattedGraphicalItems,C=_.props,D=C.children,j=C.width,G=C.height,z=_.props.margin||{},$=j-(z.left||0)-(z.right||0),R=N2({children:D,formattedGraphicalItems:A,legendWidth:$,legendContent:f});if(!R)return null;var X=R.item,K=ek(R,l7);return N.cloneElement(X,ae(ae({},K),{},{chartWidth:j,chartHeight:G,margin:z,onBBoxUpdate:_.handleLegendBBoxUpdate}))}),je(_,"renderTooltip",function(){var A,C=_.props,D=C.children,j=C.accessibilityLayer,G=xr(D,tn);if(!G)return null;var z=_.state,$=z.isTooltipActive,R=z.activeCoordinate,X=z.activePayload,K=z.activeLabel,B=z.offset,I=(A=G.props.active)!==null&&A!==void 0?A:$;return N.cloneElement(G,{viewBox:ae(ae({},B),{},{x:B.left,y:B.top}),active:I,label:K,payload:I?X:[],coordinate:R,accessibilityLayer:j})}),je(_,"renderBrush",function(A){var C=_.props,D=C.margin,j=C.data,G=_.state,z=G.offset,$=G.dataStartIndex,R=G.dataEndIndex,X=G.updateId;return N.cloneElement(A,{key:A.key||"_recharts-brush",onChange:Zc(_.handleBrushChange,A.props.onChange),data:j,x:me(A.props.x)?A.props.x:z.left,y:me(A.props.y)?A.props.y:z.top+z.height+z.brushBottom-(D.bottom||0),width:me(A.props.width)?A.props.width:z.width,startIndex:$,endIndex:R,updateId:"brush-".concat(X)})}),je(_,"renderReferenceElement",function(A,C,D){if(!A)return null;var j=_,G=j.clipPathId,z=_.state,$=z.xAxisMap,R=z.yAxisMap,X=z.offset,K=A.type.defaultProps||{},B=A.props,I=B.xAxisId,V=I===void 0?K.xAxisId:I,J=B.yAxisId,ee=J===void 0?K.yAxisId:J;return N.cloneElement(A,{key:A.key||"".concat(C,"-").concat(D),xAxis:$[V],yAxis:R[ee],viewBox:{x:X.left,y:X.top,width:X.width,height:X.height},clipPathId:G})}),je(_,"renderActivePoints",function(A){var C=A.item,D=A.activePoint,j=A.basePoint,G=A.childIndex,z=A.isRange,$=[],R=C.props.key,X=C.item.type.defaultProps!==void 0?ae(ae({},C.item.type.defaultProps),C.item.props):C.item.props,K=X.activeDot,B=X.dataKey,I=ae(ae({index:G,dataKey:B,cx:D.x,cy:D.y,r:4,fill:Yw(C.item),strokeWidth:2,stroke:"#fff",payload:D.payload,value:D.value},Ye(K,!1)),gf(K));return $.push(E.renderActiveDot(K,I,"".concat(R,"-activePoint-").concat(G))),j?$.push(E.renderActiveDot(K,ae(ae({},I),{},{cx:j.x,cy:j.y}),"".concat(R,"-basePoint-").concat(G))):z&&$.push(null),$}),je(_,"renderGraphicChild",function(A,C,D){var j=_.filterFormatItem(A,C,D);if(!j)return null;var G=_.getTooltipEventType(),z=_.state,$=z.isTooltipActive,R=z.tooltipAxis,X=z.activeTooltipIndex,K=z.activeLabel,B=_.props.children,I=xr(B,tn),V=j.props,J=V.points,ee=V.isRange,L=V.baseLine,W=j.item.type.defaultProps!==void 0?ae(ae({},j.item.type.defaultProps),j.item.props):j.item.props,te=W.activeDot,we=W.hide,xe=W.activeBar,Ie=W.activeShape,Le=!!(!we&&$&&I&&(te||xe||Ie)),Me={};G!=="axis"&&I&&I.props.trigger==="click"?Me={onClick:Zc(_.handleItemMouseEnter,A.props.onClick)}:G!=="axis"&&(Me={onMouseLeave:Zc(_.handleItemMouseLeave,A.props.onMouseLeave),onMouseEnter:Zc(_.handleItemMouseEnter,A.props.onMouseEnter)});var le=N.cloneElement(A,ae(ae({},j.props),Me));function pe(Dt){return typeof R.dataKey=="function"?R.dataKey(Dt.payload):null}if(Le)if(X>=0){var ve,ie;if(R.dataKey&&!R.allowDuplicatedCategory){var Fe=typeof R.dataKey=="function"?pe:"payload.".concat(R.dataKey.toString());ve=O0(J,Fe,K),ie=ee&&L&&O0(L,Fe,K)}else ve=J==null?void 0:J[X],ie=ee&&L&&L[X];if(Ie||xe){var de=A.props.activeIndex!==void 0?A.props.activeIndex:X;return[N.cloneElement(A,ae(ae(ae({},j.props),Me),{},{activeIndex:de})),null,null]}if(!Ve(ve))return[le].concat(is(_.renderActivePoints({item:j,activePoint:ve,basePoint:ie,childIndex:X,isRange:ee})))}else{var ge,ne=(ge=_.getItemByXY(_.state.activeCoordinate))!==null&&ge!==void 0?ge:{graphicalItem:le},it=ne.graphicalItem,kt=it.item,Rt=kt===void 0?A:kt,Bt=it.childIndex,rt=ae(ae(ae({},j.props),Me),{},{activeIndex:Bt});return[N.cloneElement(Rt,rt),null,null]}return ee?[le,null,null]:[le,null]}),je(_,"renderCustomized",function(A,C,D){return N.cloneElement(A,ae(ae({key:"recharts-customized-".concat(D)},_.props),_.state))}),je(_,"renderMap",{CartesianGrid:{handler:nf,once:!0},ReferenceArea:{handler:_.renderReferenceElement},ReferenceLine:{handler:nf},ReferenceDot:{handler:_.renderReferenceElement},XAxis:{handler:nf},YAxis:{handler:nf},Brush:{handler:_.renderBrush,once:!0},Bar:{handler:_.renderGraphicChild},Line:{handler:_.renderGraphicChild},Area:{handler:_.renderGraphicChild},Radar:{handler:_.renderGraphicChild},RadialBar:{handler:_.renderGraphicChild},Scatter:{handler:_.renderGraphicChild},Pie:{handler:_.renderGraphicChild},Funnel:{handler:_.renderGraphicChild},Tooltip:{handler:_.renderCursor,once:!0},PolarGrid:{handler:_.renderPolarGrid,once:!0},PolarAngleAxis:{handler:_.renderPolarAxis},PolarRadiusAxis:{handler:_.renderPolarAxis},Customized:{handler:_.renderCustomized}}),_.clipPathId="".concat((T=P.id)!==null&&T!==void 0?T:xd("recharts"),"-clip"),_.throttleTriggeredAfterMouseMove=ND(_.triggeredAfterMouseMove,(O=P.throttleDelay)!==null&&O!==void 0?O:1e3/60),_.state={},_}return x7(E,b),m7(E,[{key:"componentDidMount",value:function(){var T,O;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(T=this.props.margin.left)!==null&&T!==void 0?T:0,top:(O=this.props.margin.top)!==null&&O!==void 0?O:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var T=this.props,O=T.children,_=T.data,A=T.height,C=T.layout,D=xr(O,tn);if(D){var j=D.props.defaultIndex;if(!(typeof j!="number"||j<0||j>this.state.tooltipTicks.length-1)){var G=this.state.tooltipTicks[j]&&this.state.tooltipTicks[j].value,z=Fb(this.state,_,j,G),$=this.state.tooltipTicks[j].coordinate,R=(this.state.offset.top+A)/2,X=C==="horizontal",K=X?{x:$,y:R}:{y:$,x:R},B=this.state.formattedGraphicalItems.find(function(V){var J=V.item;return J.type.name==="Scatter"});B&&(K=ae(ae({},K),B.props.points[j].tooltipPosition),z=B.props.points[j].tooltipPayload);var I={activeTooltipIndex:j,isTooltipActive:!0,activeLabel:G,activePayload:z,activeCoordinate:K};this.setState(I),this.renderCursor(D),this.accessibilityManager.setIndex(j)}}}},{key:"getSnapshotBeforeUpdate",value:function(T,O){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==O.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==T.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==T.margin){var _,A;this.accessibilityManager.setDetails({offset:{left:(_=this.props.margin.left)!==null&&_!==void 0?_:0,top:(A=this.props.margin.top)!==null&&A!==void 0?A:0}})}return null}},{key:"componentDidUpdate",value:function(T){P0([xr(T.children,tn)],[xr(this.props.children,tn)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var T=xr(this.props.children,tn);if(T&&typeof T.props.shared=="boolean"){var O=T.props.shared?"axis":"item";return l.indexOf(O)>=0?O:a}return a}},{key:"getMouseInfo",value:function(T){if(!this.container)return null;var O=this.container,_=O.getBoundingClientRect(),A=n3(_),C={chartX:Math.round(T.pageX-A.left),chartY:Math.round(T.pageY-A.top)},D=_.width/O.offsetWidth||1,j=this.inRange(C.chartX,C.chartY,D);if(!j)return null;var G=this.state,z=G.xAxisMap,$=G.yAxisMap,R=this.getTooltipEventType(),X=rk(this.state,this.props.data,this.props.layout,j);if(R!=="axis"&&z&&$){var K=go(z).scale,B=go($).scale,I=K&&K.invert?K.invert(C.chartX):null,V=B&&B.invert?B.invert(C.chartY):null;return ae(ae({},C),{},{xValue:I,yValue:V},X)}return X?ae(ae({},C),X):null}},{key:"inRange",value:function(T,O){var _=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,A=this.props.layout,C=T/_,D=O/_;if(A==="horizontal"||A==="vertical"){var j=this.state.offset,G=C>=j.left&&C<=j.left+j.width&&D>=j.top&&D<=j.top+j.height;return G?{x:C,y:D}:null}var z=this.state,$=z.angleAxisMap,R=z.radiusAxisMap;if($&&R){var X=go($);return _T({x:C,y:D},X)}return null}},{key:"parseEventsOfWrapper",value:function(){var T=this.props.children,O=this.getTooltipEventType(),_=xr(T,tn),A={};_&&O==="axis"&&(_.props.trigger==="click"?A={onClick:this.handleClick}:A={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var C=gf(this.props,this.handleOuterEvent);return ae(ae({},C),A)}},{key:"addListener",value:function(){Hy.on(Vy,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){Hy.removeListener(Vy,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(T,O,_){for(var A=this.state.formattedGraphicalItems,C=0,D=A.length;C<D;C++){var j=A[C];if(j.item===T||j.props.key===T.key||O===Qn(j.item.type)&&_===j.childIndex)return j}return null}},{key:"renderClipPath",value:function(){var T=this.clipPathId,O=this.state.offset,_=O.left,A=O.top,C=O.height,D=O.width;return Q.createElement("defs",null,Q.createElement("clipPath",{id:T},Q.createElement("rect",{x:_,y:A,height:C,width:D})))}},{key:"getXScales",value:function(){var T=this.state.xAxisMap;return T?Object.entries(T).reduce(function(O,_){var A=JC(_,2),C=A[0],D=A[1];return ae(ae({},O),{},je({},C,D.scale))},{}):null}},{key:"getYScales",value:function(){var T=this.state.yAxisMap;return T?Object.entries(T).reduce(function(O,_){var A=JC(_,2),C=A[0],D=A[1];return ae(ae({},O),{},je({},C,D.scale))},{}):null}},{key:"getXScaleByAxisId",value:function(T){var O;return(O=this.state.xAxisMap)===null||O===void 0||(O=O[T])===null||O===void 0?void 0:O.scale}},{key:"getYScaleByAxisId",value:function(T){var O;return(O=this.state.yAxisMap)===null||O===void 0||(O=O[T])===null||O===void 0?void 0:O.scale}},{key:"getItemByXY",value:function(T){var O=this.state,_=O.formattedGraphicalItems,A=O.activeItem;if(_&&_.length)for(var C=0,D=_.length;C<D;C++){var j=_[C],G=j.props,z=j.item,$=z.type.defaultProps!==void 0?ae(ae({},z.type.defaultProps),z.props):z.props,R=Qn(z.type);if(R==="Bar"){var X=(G.data||[]).find(function(V){return EH(T,V)});if(X)return{graphicalItem:j,payload:X}}else if(R==="RadialBar"){var K=(G.data||[]).find(function(V){return _T(T,V)});if(K)return{graphicalItem:j,payload:K}}else if(Bd(j,A)||Gd(j,A)||sl(j,A)){var B=p9({graphicalItem:j,activeTooltipItem:A,itemData:$.data}),I=$.activeIndex===void 0?B:$.activeIndex;return{graphicalItem:ae(ae({},j),{},{childIndex:I}),payload:sl(j,A)?$.data[B]:j.props.data[B]}}}return null}},{key:"render",value:function(){var T=this;if(!IE(this))return null;var O=this.props,_=O.children,A=O.className,C=O.width,D=O.height,j=O.style,G=O.compact,z=O.title,$=O.desc,R=ek(O,c7),X=Ye(R,!1);if(G)return Q.createElement(FC,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},Q.createElement(C0,bo({},X,{width:C,height:D,title:z,desc:$}),this.renderClipPath(),ME(_,this.renderMap)));if(this.props.accessibilityLayer){var K,B;X.tabIndex=(K=this.props.tabIndex)!==null&&K!==void 0?K:0,X.role=(B=this.props.role)!==null&&B!==void 0?B:"application",X.onKeyDown=function(V){T.accessibilityManager.keyboardEvent(V)},X.onFocus=function(){T.accessibilityManager.focus()}}var I=this.parseEventsOfWrapper();return Q.createElement(FC,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},Q.createElement("div",bo({className:He("recharts-wrapper",A),style:ae({position:"relative",cursor:"default",width:C,height:D},j)},I,{ref:function(J){T.container=J}}),Q.createElement(C0,bo({},X,{width:C,height:D,title:z,desc:$,style:P7}),this.renderClipPath(),ME(_,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])})(N.Component);je(S,"displayName",r),je(S,"defaultProps",ae({layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:"index"},h)),je(S,"getDerivedStateFromProps",function(b,E){var P=b.dataKey,T=b.data,O=b.children,_=b.width,A=b.height,C=b.layout,D=b.stackOffset,j=b.margin,G=E.dataStartIndex,z=E.dataEndIndex;if(E.updateId===void 0){var $=nk(b);return ae(ae(ae({},$),{},{updateId:0},y(ae(ae({props:b},$),{},{updateId:0}),E)),{},{prevDataKey:P,prevData:T,prevWidth:_,prevHeight:A,prevLayout:C,prevStackOffset:D,prevMargin:j,prevChildren:O})}if(P!==E.prevDataKey||T!==E.prevData||_!==E.prevWidth||A!==E.prevHeight||C!==E.prevLayout||D!==E.prevStackOffset||!wo(j,E.prevMargin)){var R=nk(b),X={chartX:E.chartX,chartY:E.chartY,isTooltipActive:E.isTooltipActive},K=ae(ae({},rk(E,T,C)),{},{updateId:E.updateId+1}),B=ae(ae(ae({},R),X),K);return ae(ae(ae({},B),y(ae({props:b},B),E)),{},{prevDataKey:P,prevData:T,prevWidth:_,prevHeight:A,prevLayout:C,prevStackOffset:D,prevMargin:j,prevChildren:O})}if(!P0(O,E.prevChildren)){var I,V,J,ee,L=xr(O,Xo),W=L&&(I=(V=L.props)===null||V===void 0?void 0:V.startIndex)!==null&&I!==void 0?I:G,te=L&&(J=(ee=L.props)===null||ee===void 0?void 0:ee.endIndex)!==null&&J!==void 0?J:z,we=W!==G||te!==z,xe=!Ve(T),Ie=xe&&!we?E.updateId:E.updateId+1;return ae(ae({updateId:Ie},y(ae(ae({props:b},E),{},{updateId:Ie,dataStartIndex:W,dataEndIndex:te}),E)),{},{prevChildren:O,dataStartIndex:W,dataEndIndex:te})}return null}),je(S,"renderActiveDot",function(b,E,P){var T;return N.isValidElement(b)?T=N.cloneElement(b,E):ze(b)?T=b(E):T=Q.createElement(Q2,E),Q.createElement($t,{className:"recharts-active-dot",key:P},T)});var w=N.forwardRef(function(E,P){return Q.createElement(S,bo({},E,{ref:P}))});return w.displayName=S.displayName,w},ak=L7({chartName:"BarChart",GraphicalChild:Jn,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:dl},{axisType:"yAxis",AxisComp:hl}],formatAxisMap:fV});function $7(){var f,p;const t=Lo(h=>h.workspace);console.log("[Dashboard] render workspace=",t);const{data:e,error:r,isLoading:n}=Ra({queryKey:["status"],queryFn:IR}),{data:i,error:a,isLoading:s}=Ra({queryKey:["telemetry",t],queryFn:()=>lF(t)});n&&console.log("[Dashboard] status loading..."),r&&console.error("[Dashboard] status error:",r),e&&console.log("[Dashboard] status:",e),s&&console.log("[Dashboard] telemetry loading..."),a&&console.error("[Dashboard] telemetry error:",a),i&&console.log("[Dashboard] telemetry:",i);const l=i!=null&&i.banditStats?Object.entries(i.banditStats).map(([h,g])=>(console.log("[Dashboard] bandit variant:",h,g),{variant:h,success:g.success,failure:g.failure})):[];console.log("[Dashboard] banditData:",l.length,"variants");const c=i!=null&&i.preferenceWeights?Object.entries(i.preferenceWeights).map(([h,g])=>(console.log("[Dashboard] preference:",h,"=",g),{category:h,weight:g})):[];return console.log("[Dashboard] weightData:",c.length,"categories"),H.jsxs("div",{className:"space-y-6",children:[H.jsxs("div",{children:[H.jsx("h1",{className:"text-2xl font-semibold",children:"System Dashboard"}),H.jsx("p",{className:"mt-1 text-sm text-[#8888a0]",children:"Live view of nano-brain health, indexing, and learning telemetry."})]}),H.jsxs("div",{className:"grid-cards",children:[H.jsxs("div",{className:"card p-4",children:[H.jsx("p",{className:"text-xs uppercase text-[#8888a0]",children:"Version"}),H.jsx("p",{className:"mt-2 text-2xl font-semibold",children:(e==null?void 0:e.version)??"—"})]}),H.jsxs("div",{className:"card p-4",children:[H.jsx("p",{className:"text-xs uppercase text-[#8888a0]",children:"Uptime"}),H.jsx("p",{className:"mt-2 text-2xl font-semibold",children:e?`${Math.floor(e.uptime/60)}m`:"—"})]}),H.jsxs("div",{className:"card p-4",children:[H.jsx("p",{className:"text-xs uppercase text-[#8888a0]",children:"Documents"}),H.jsx("p",{className:"mt-2 text-2xl font-semibold",children:(e==null?void 0:e.documents)??"—"})]}),H.jsxs("div",{className:"card p-4",children:[H.jsx("p",{className:"text-xs uppercase text-[#8888a0]",children:"Embeddings"}),H.jsx("p",{className:"mt-2 text-2xl font-semibold",children:(e==null?void 0:e.embeddings)??"—"})]})]}),H.jsxs("div",{className:"grid-dense",children:[H.jsxs("div",{className:"card col-span-7 p-4",children:[H.jsxs("div",{className:"flex items-center justify-between",children:[H.jsxs("div",{children:[H.jsx("h2",{className:"text-lg font-semibold",children:"Bandit Stats"}),H.jsx("p",{className:"text-xs text-[#8888a0]",children:"Success vs failure per variant."})]}),H.jsx("span",{className:"text-xs text-[#8888a0]",children:isLoading?"loading":`${l.length} variants`})]}),H.jsx("div",{className:"mt-4 h-64",children:H.jsx(iP,{width:"100%",height:"100%",children:H.jsxs(ak,{data:l,margin:{top:10,right:10,left:-10,bottom:10},children:[H.jsx(dl,{dataKey:"variant",stroke:"#8888a0",fontSize:12}),H.jsx(hl,{stroke:"#8888a0",fontSize:12}),H.jsx(tn,{contentStyle:{background:"#111118",border:"1px solid #1f1f2c"}}),H.jsx(Jn,{dataKey:"success",stackId:"a",fill:"#3b82f6",radius:[6,6,0,0]}),H.jsx(Jn,{dataKey:"failure",stackId:"a",fill:"#f97316",radius:[6,6,0,0]})]})})})]}),H.jsxs("div",{className:"card col-span-5 p-4",children:[H.jsx("h2",{className:"text-lg font-semibold",children:"Expand Rate"}),H.jsx("p",{className:"text-xs text-[#8888a0]",children:"Queries that expanded into memory graph."}),H.jsxs("div",{className:"mt-6 flex items-end gap-3",children:[H.jsx("p",{className:"text-5xl font-semibold",children:i?`${Math.round(i.expandRate*100)}%`:"—"}),H.jsx("span",{className:"text-xs text-emerald-400",children:"+2.4% vs last window"})]}),H.jsxs("div",{className:"mt-6",children:[H.jsx("p",{className:"text-xs uppercase text-[#8888a0]",children:"Query volume"}),H.jsx("p",{className:"mt-1 text-xl font-semibold",children:(i==null?void 0:i.queryCount)??"—"})]}),H.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-3 text-xs text-[#8888a0]",children:[H.jsxs("div",{children:[H.jsx("p",{children:"Importance mean"}),H.jsx("p",{className:"text-sm text-[#e4e4ed]",children:((f=i==null?void 0:i.importanceStats.mean)==null?void 0:f.toFixed(2))??"—"})]}),H.jsxs("div",{children:[H.jsx("p",{children:"Importance median"}),H.jsx("p",{className:"text-sm text-[#e4e4ed]",children:((p=i==null?void 0:i.importanceStats.median)==null?void 0:p.toFixed(2))??"—"})]})]})]})]}),H.jsxs("div",{className:"card p-4",children:[H.jsxs("div",{className:"flex items-center justify-between",children:[H.jsxs("div",{children:[H.jsx("h2",{className:"text-lg font-semibold",children:"Preference Weights"}),H.jsx("p",{className:"text-xs text-[#8888a0]",children:"Current category weighting in ranking model."})]}),H.jsxs("span",{className:"text-xs text-[#8888a0]",children:[c.length," categories"]})]}),H.jsx("div",{className:"mt-4 h-64",children:H.jsx(iP,{width:"100%",height:"100%",children:H.jsxs(ak,{data:c,layout:"vertical",margin:{top:10,right:10,left:60,bottom:10},children:[H.jsx(dl,{type:"number",stroke:"#8888a0",fontSize:12}),H.jsx(hl,{dataKey:"category",type:"category",stroke:"#8888a0",fontSize:12,width:120}),H.jsx(tn,{contentStyle:{background:"#111118",border:"1px solid #1f1f2c"}}),H.jsx(Jn,{dataKey:"weight",fill:"#8b5cf6",radius:[0,6,6,0]})]})})})]})]})}var af={exports:{}},ok;function F7(){if(ok)return af.exports;ok=1;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(_,A,C){return Function.prototype.apply.call(_,A,C)},r;t&&typeof t.ownKeys=="function"?r=t.ownKeys:Object.getOwnPropertySymbols?r=function(_){return Object.getOwnPropertyNames(_).concat(Object.getOwnPropertySymbols(_))}:r=function(_){return Object.getOwnPropertyNames(_)};function n(O){console&&console.warn&&console.warn(O)}var i=Number.isNaN||function(_){return _!==_};function a(){a.init.call(this)}af.exports=a,af.exports.once=E,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var s=10;function l(O){if(typeof O!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof O)}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(O){if(typeof O!="number"||O<0||i(O))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+O+".");s=O}}),a.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(_){if(typeof _!="number"||_<0||i(_))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+_+".");return this._maxListeners=_,this};function c(O){return O._maxListeners===void 0?a.defaultMaxListeners:O._maxListeners}a.prototype.getMaxListeners=function(){return c(this)},a.prototype.emit=function(_){for(var A=[],C=1;C<arguments.length;C++)A.push(arguments[C]);var D=_==="error",j=this._events;if(j!==void 0)D=D&&j.error===void 0;else if(!D)return!1;if(D){var G;if(A.length>0&&(G=A[0]),G instanceof Error)throw G;var z=new Error("Unhandled error."+(G?" ("+G.message+")":""));throw z.context=G,z}var $=j[_];if($===void 0)return!1;if(typeof $=="function")e($,this,A);else for(var R=$.length,X=S($,R),C=0;C<R;++C)e(X[C],this,A);return!0};function f(O,_,A,C){var D,j,G;if(l(A),j=O._events,j===void 0?(j=O._events=Object.create(null),O._eventsCount=0):(j.newListener!==void 0&&(O.emit("newListener",_,A.listener?A.listener:A),j=O._events),G=j[_]),G===void 0)G=j[_]=A,++O._eventsCount;else if(typeof G=="function"?G=j[_]=C?[A,G]:[G,A]:C?G.unshift(A):G.push(A),D=c(O),D>0&&G.length>D&&!G.warned){G.warned=!0;var z=new Error("Possible EventEmitter memory leak detected. "+G.length+" "+String(_)+" listeners added. Use emitter.setMaxListeners() to increase limit");z.name="MaxListenersExceededWarning",z.emitter=O,z.type=_,z.count=G.length,n(z)}return O}a.prototype.addListener=function(_,A){return f(this,_,A,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(_,A){return f(this,_,A,!0)};function p(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(O,_,A){var C={fired:!1,wrapFn:void 0,target:O,type:_,listener:A},D=p.bind(C);return D.listener=A,C.wrapFn=D,D}a.prototype.once=function(_,A){return l(A),this.on(_,h(this,_,A)),this},a.prototype.prependOnceListener=function(_,A){return l(A),this.prependListener(_,h(this,_,A)),this},a.prototype.removeListener=function(_,A){var C,D,j,G,z;if(l(A),D=this._events,D===void 0)return this;if(C=D[_],C===void 0)return this;if(C===A||C.listener===A)--this._eventsCount===0?this._events=Object.create(null):(delete D[_],D.removeListener&&this.emit("removeListener",_,C.listener||A));else if(typeof C!="function"){for(j=-1,G=C.length-1;G>=0;G--)if(C[G]===A||C[G].listener===A){z=C[G].listener,j=G;break}if(j<0)return this;j===0?C.shift():w(C,j),C.length===1&&(D[_]=C[0]),D.removeListener!==void 0&&this.emit("removeListener",_,z||A)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(_){var A,C,D;if(C=this._events,C===void 0)return this;if(C.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):C[_]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete C[_]),this;if(arguments.length===0){var j=Object.keys(C),G;for(D=0;D<j.length;++D)G=j[D],G!=="removeListener"&&this.removeAllListeners(G);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(A=C[_],typeof A=="function")this.removeListener(_,A);else if(A!==void 0)for(D=A.length-1;D>=0;D--)this.removeListener(_,A[D]);return this};function g(O,_,A){var C=O._events;if(C===void 0)return[];var D=C[_];return D===void 0?[]:typeof D=="function"?A?[D.listener||D]:[D]:A?b(D):S(D,D.length)}a.prototype.listeners=function(_){return g(this,_,!0)},a.prototype.rawListeners=function(_){return g(this,_,!1)},a.listenerCount=function(O,_){return typeof O.listenerCount=="function"?O.listenerCount(_):y.call(O,_)},a.prototype.listenerCount=y;function y(O){var _=this._events;if(_!==void 0){var A=_[O];if(typeof A=="function")return 1;if(A!==void 0)return A.length}return 0}a.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]};function S(O,_){for(var A=new Array(_),C=0;C<_;++C)A[C]=O[C];return A}function w(O,_){for(;_+1<O.length;_++)O[_]=O[_+1];O.pop()}function b(O){for(var _=new Array(O.length),A=0;A<_.length;++A)_[A]=O[A].listener||O[A];return _}function E(O,_){return new Promise(function(A,C){function D(G){O.removeListener(_,j),C(G)}function j(){typeof O.removeListener=="function"&&O.removeListener("error",D),A([].slice.call(arguments))}T(O,_,j,{once:!0}),_!=="error"&&P(O,D,{once:!0})})}function P(O,_,A){typeof O.on=="function"&&T(O,"error",_,A)}function T(O,_,A,C){if(typeof O.on=="function")C.once?O.once(_,A):O.on(_,A);else if(typeof O.addEventListener=="function")O.addEventListener(_,function D(j){C.once&&O.removeEventListener(_,D),A(j)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof O)}return af.exports}var Bj=F7();function B7(){const t=arguments[0];for(let e=1,r=arguments.length;e<r;e++)if(arguments[e])for(const n in arguments[e])t[n]=arguments[e][n];return t}let Pt=B7;typeof Object.assign=="function"&&(Pt=Object.assign);function Fr(t,e,r,n){const i=t._nodes.get(e);let a=null;return i&&(n==="mixed"?a=i.out&&i.out[r]||i.undirected&&i.undirected[r]:n==="directed"?a=i.out&&i.out[r]:a=i.undirected&&i.undirected[r]),a}function Wt(t){return typeof t=="object"&&t!==null}function Gj(t){let e;for(e in t)return!1;return!0}function Ir(t,e,r){Object.defineProperty(t,e,{enumerable:!1,configurable:!1,writable:!0,value:r})}function Zr(t,e,r){const n={enumerable:!0,configurable:!0};typeof r=="function"?n.get=r:(n.value=r,n.writable=!1),Object.defineProperty(t,e,n)}function sk(t){return!(!Wt(t)||t.attributes&&!Array.isArray(t.attributes))}function G7(){let t=Math.floor(Math.random()*256)&255;return()=>t++}function ei(){const t=arguments;let e=null,r=-1;return{[Symbol.iterator](){return this},next(){let n=null;do{if(e===null){if(r++,r>=t.length)return{done:!0};e=t[r][Symbol.iterator]()}if(n=e.next(),n.done){e=null;continue}break}while(!0);return n}}}function ms(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class rx extends Error{constructor(e){super(),this.name="GraphError",this.message=e}}class ye extends rx{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,ye.prototype.constructor)}}class he extends rx{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,he.prototype.constructor)}}class De extends rx{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,De.prototype.constructor)}}function zj(t,e){this.key=t,this.attributes=e,this.clear()}zj.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function Uj(t,e){this.key=t,this.attributes=e,this.clear()}Uj.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function qj(t,e){this.key=t,this.attributes=e,this.clear()}qj.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function ys(t,e,r,n,i){this.key=e,this.attributes=i,this.undirected=t,this.source=r,this.target=n}ys.prototype.attach=function(){let t="out",e="in";this.undirected&&(t=e="undirected");const r=this.source.key,n=this.target.key;this.source[t][n]=this,!(this.undirected&&r===n)&&(this.target[e][r]=this)};ys.prototype.attachMulti=function(){let t="out",e="in";const r=this.source.key,n=this.target.key;this.undirected&&(t=e="undirected");const i=this.source[t],a=i[n];if(typeof a>"u"){i[n]=this,this.undirected&&r===n||(this.target[e][r]=this);return}a.previous=this,this.next=a,i[n]=this,this.target[e][r]=this};ys.prototype.detach=function(){const t=this.source.key,e=this.target.key;let r="out",n="in";this.undirected&&(r=n="undirected"),delete this.source[r][e],delete this.target[n][t]};ys.prototype.detachMulti=function(){const t=this.source.key,e=this.target.key;let r="out",n="in";this.undirected&&(r=n="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[r][e],delete this.target[n][t]):(this.next.previous=void 0,this.source[r][e]=this.next,this.target[n][t]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const Wj=0,Hj=1,z7=2,Vj=3;function li(t,e,r,n,i,a,s){let l,c,f,p;if(n=""+n,r===Wj){if(l=t._nodes.get(n),!l)throw new he(`Graph.${e}: could not find the "${n}" node in the graph.`);f=i,p=a}else if(r===Vj){if(i=""+i,c=t._edges.get(i),!c)throw new he(`Graph.${e}: could not find the "${i}" edge in the graph.`);const h=c.source.key,g=c.target.key;if(n===h)l=c.target;else if(n===g)l=c.source;else throw new he(`Graph.${e}: the "${n}" node is not attached to the "${i}" edge (${h}, ${g}).`);f=a,p=s}else{if(c=t._edges.get(n),!c)throw new he(`Graph.${e}: could not find the "${n}" edge in the graph.`);r===Hj?l=c.source:l=c.target,f=i,p=a}return[l,f,p]}function U7(t,e,r){t.prototype[e]=function(n,i,a){const[s,l]=li(this,e,r,n,i,a);return s.attributes[l]}}function q7(t,e,r){t.prototype[e]=function(n,i){const[a]=li(this,e,r,n,i);return a.attributes}}function W7(t,e,r){t.prototype[e]=function(n,i,a){const[s,l]=li(this,e,r,n,i,a);return s.attributes.hasOwnProperty(l)}}function H7(t,e,r){t.prototype[e]=function(n,i,a,s){const[l,c,f]=li(this,e,r,n,i,a,s);return l.attributes[c]=f,this.emit("nodeAttributesUpdated",{key:l.key,type:"set",attributes:l.attributes,name:c}),this}}function V7(t,e,r){t.prototype[e]=function(n,i,a,s){const[l,c,f]=li(this,e,r,n,i,a,s);if(typeof f!="function")throw new ye(`Graph.${e}: updater should be a function.`);const p=l.attributes,h=f(p[c]);return p[c]=h,this.emit("nodeAttributesUpdated",{key:l.key,type:"set",attributes:l.attributes,name:c}),this}}function K7(t,e,r){t.prototype[e]=function(n,i,a){const[s,l]=li(this,e,r,n,i,a);return delete s.attributes[l],this.emit("nodeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:l}),this}}function X7(t,e,r){t.prototype[e]=function(n,i,a){const[s,l]=li(this,e,r,n,i,a);if(!Wt(l))throw new ye(`Graph.${e}: provided attributes are not a plain object.`);return s.attributes=l,this.emit("nodeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}function Y7(t,e,r){t.prototype[e]=function(n,i,a){const[s,l]=li(this,e,r,n,i,a);if(!Wt(l))throw new ye(`Graph.${e}: provided attributes are not a plain object.`);return Pt(s.attributes,l),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:l}),this}}function Q7(t,e,r){t.prototype[e]=function(n,i,a){const[s,l]=li(this,e,r,n,i,a);if(typeof l!="function")throw new ye(`Graph.${e}: provided updater is not a function.`);return s.attributes=l(s.attributes),this.emit("nodeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}const Z7=[{name:t=>`get${t}Attribute`,attacher:U7},{name:t=>`get${t}Attributes`,attacher:q7},{name:t=>`has${t}Attribute`,attacher:W7},{name:t=>`set${t}Attribute`,attacher:H7},{name:t=>`update${t}Attribute`,attacher:V7},{name:t=>`remove${t}Attribute`,attacher:K7},{name:t=>`replace${t}Attributes`,attacher:X7},{name:t=>`merge${t}Attributes`,attacher:Y7},{name:t=>`update${t}Attributes`,attacher:Q7}];function J7(t){Z7.forEach(function({name:e,attacher:r}){r(t,e("Node"),Wj),r(t,e("Source"),Hj),r(t,e("Target"),z7),r(t,e("Opposite"),Vj)})}function eX(t,e,r){t.prototype[e]=function(n,i){let a;if(this.type!=="mixed"&&r!=="mixed"&&r!==this.type)throw new De(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new De(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,l=""+i;if(i=arguments[2],a=Fr(this,s,l,r),!a)throw new he(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(r!=="mixed")throw new De(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,a=this._edges.get(n),!a)throw new he(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return a.attributes[i]}}function tX(t,e,r){t.prototype[e]=function(n){let i;if(this.type!=="mixed"&&r!=="mixed"&&r!==this.type)throw new De(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new De(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+n,s=""+arguments[1];if(i=Fr(this,a,s,r),!i)throw new he(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(r!=="mixed")throw new De(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,i=this._edges.get(n),!i)throw new he(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return i.attributes}}function rX(t,e,r){t.prototype[e]=function(n,i){let a;if(this.type!=="mixed"&&r!=="mixed"&&r!==this.type)throw new De(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new De(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,l=""+i;if(i=arguments[2],a=Fr(this,s,l,r),!a)throw new he(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(r!=="mixed")throw new De(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,a=this._edges.get(n),!a)throw new he(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return a.attributes.hasOwnProperty(i)}}function nX(t,e,r){t.prototype[e]=function(n,i,a){let s;if(this.type!=="mixed"&&r!=="mixed"&&r!==this.type)throw new De(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new De(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const l=""+n,c=""+i;if(i=arguments[2],a=arguments[3],s=Fr(this,l,c,r),!s)throw new he(`Graph.${e}: could not find an edge for the given path ("${l}" - "${c}").`)}else{if(r!=="mixed")throw new De(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new he(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return s.attributes[i]=a,this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:i}),this}}function iX(t,e,r){t.prototype[e]=function(n,i,a){let s;if(this.type!=="mixed"&&r!=="mixed"&&r!==this.type)throw new De(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new De(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const l=""+n,c=""+i;if(i=arguments[2],a=arguments[3],s=Fr(this,l,c,r),!s)throw new he(`Graph.${e}: could not find an edge for the given path ("${l}" - "${c}").`)}else{if(r!=="mixed")throw new De(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new he(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(typeof a!="function")throw new ye(`Graph.${e}: updater should be a function.`);return s.attributes[i]=a(s.attributes[i]),this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:i}),this}}function aX(t,e,r){t.prototype[e]=function(n,i){let a;if(this.type!=="mixed"&&r!=="mixed"&&r!==this.type)throw new De(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new De(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,l=""+i;if(i=arguments[2],a=Fr(this,s,l,r),!a)throw new he(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(r!=="mixed")throw new De(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,a=this._edges.get(n),!a)throw new he(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return delete a.attributes[i],this.emit("edgeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:i}),this}}function oX(t,e,r){t.prototype[e]=function(n,i){let a;if(this.type!=="mixed"&&r!=="mixed"&&r!==this.type)throw new De(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new De(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,l=""+i;if(i=arguments[2],a=Fr(this,s,l,r),!a)throw new he(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(r!=="mixed")throw new De(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,a=this._edges.get(n),!a)throw new he(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(!Wt(i))throw new ye(`Graph.${e}: provided attributes are not a plain object.`);return a.attributes=i,this.emit("edgeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function sX(t,e,r){t.prototype[e]=function(n,i){let a;if(this.type!=="mixed"&&r!=="mixed"&&r!==this.type)throw new De(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new De(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,l=""+i;if(i=arguments[2],a=Fr(this,s,l,r),!a)throw new he(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(r!=="mixed")throw new De(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,a=this._edges.get(n),!a)throw new he(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(!Wt(i))throw new ye(`Graph.${e}: provided attributes are not a plain object.`);return Pt(a.attributes,i),this.emit("edgeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:i}),this}}function uX(t,e,r){t.prototype[e]=function(n,i){let a;if(this.type!=="mixed"&&r!=="mixed"&&r!==this.type)throw new De(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new De(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,l=""+i;if(i=arguments[2],a=Fr(this,s,l,r),!a)throw new he(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(r!=="mixed")throw new De(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,a=this._edges.get(n),!a)throw new he(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(typeof i!="function")throw new ye(`Graph.${e}: provided updater is not a function.`);return a.attributes=i(a.attributes),this.emit("edgeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}const lX=[{name:t=>`get${t}Attribute`,attacher:eX},{name:t=>`get${t}Attributes`,attacher:tX},{name:t=>`has${t}Attribute`,attacher:rX},{name:t=>`set${t}Attribute`,attacher:nX},{name:t=>`update${t}Attribute`,attacher:iX},{name:t=>`remove${t}Attribute`,attacher:aX},{name:t=>`replace${t}Attributes`,attacher:oX},{name:t=>`merge${t}Attributes`,attacher:sX},{name:t=>`update${t}Attributes`,attacher:uX}];function cX(t){lX.forEach(function({name:e,attacher:r}){r(t,e("Edge"),"mixed"),r(t,e("DirectedEdge"),"directed"),r(t,e("UndirectedEdge"),"undirected")})}const fX=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function dX(t,e,r,n){let i=!1;for(const a in e){if(a===n)continue;const s=e[a];if(i=r(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),t&&i)return s.key}}function hX(t,e,r,n){let i,a,s,l=!1;for(const c in e)if(c!==n){i=e[c];do{if(a=i.source,s=i.target,l=r(i.key,i.attributes,a.key,s.key,a.attributes,s.attributes,i.undirected),t&&l)return i.key;i=i.next}while(i!==void 0)}}function Xy(t,e){const r=Object.keys(t),n=r.length;let i,a=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(a>=n)return{done:!0};const s=r[a++];if(s===e){i=void 0;continue}i=t[s]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function pX(t,e,r,n){const i=e[r];if(!i)return;const a=i.source,s=i.target;if(n(i.key,i.attributes,a.key,s.key,a.attributes,s.attributes,i.undirected)&&t)return i.key}function vX(t,e,r,n){let i=e[r];if(!i)return;let a=!1;do{if(a=n(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),t&&a)return i.key;i=i.next}while(i!==void 0)}function Yy(t,e){let r=t[e];if(r.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!r)return{done:!0};const i={edge:r.key,attributes:r.attributes,source:r.source.key,target:r.target.key,sourceAttributes:r.source.attributes,targetAttributes:r.target.attributes,undirected:r.undirected};return r=r.next,{done:!1,value:i}}};let n=!1;return{[Symbol.iterator](){return this},next(){return n===!0?{done:!0}:(n=!0,{done:!1,value:{edge:r.key,attributes:r.attributes,source:r.source.key,target:r.target.key,sourceAttributes:r.source.attributes,targetAttributes:r.target.attributes,undirected:r.undirected}})}}}function gX(t,e){if(t.size===0)return[];if(e==="mixed"||e===t.type)return Array.from(t._edges.keys());const r=e==="undirected"?t.undirectedSize:t.directedSize,n=new Array(r),i=e==="undirected",a=t._edges.values();let s=0,l,c;for(;l=a.next(),l.done!==!0;)c=l.value,c.undirected===i&&(n[s++]=c.key);return n}function Kj(t,e,r,n){if(e.size===0)return;const i=r!=="mixed"&&r!==e.type,a=r==="undirected";let s,l,c=!1;const f=e._edges.values();for(;s=f.next(),s.done!==!0;){if(l=s.value,i&&l.undirected!==a)continue;const{key:p,attributes:h,source:g,target:y}=l;if(c=n(p,h,g.key,y.key,g.attributes,y.attributes,l.undirected),t&&c)return p}}function mX(t,e){if(t.size===0)return ms();const r=e!=="mixed"&&e!==t.type,n=e==="undirected",i=t._edges.values();return{[Symbol.iterator](){return this},next(){let a,s;for(;;){if(a=i.next(),a.done)return a;if(s=a.value,!(r&&s.undirected!==n))break}return{value:{edge:s.key,attributes:s.attributes,source:s.source.key,target:s.target.key,sourceAttributes:s.source.attributes,targetAttributes:s.target.attributes,undirected:s.undirected},done:!1}}}}function nx(t,e,r,n,i,a){const s=e?hX:dX;let l;if(r!=="undirected"&&(n!=="out"&&(l=s(t,i.in,a),t&&l)||n!=="in"&&(l=s(t,i.out,a,n?void 0:i.key),t&&l))||r!=="directed"&&(l=s(t,i.undirected,a),t&&l))return l}function yX(t,e,r,n){const i=[];return nx(!1,t,e,r,n,function(a){i.push(a)}),i}function bX(t,e,r){let n=ms();return t!=="undirected"&&(e!=="out"&&typeof r.in<"u"&&(n=ei(n,Xy(r.in))),e!=="in"&&typeof r.out<"u"&&(n=ei(n,Xy(r.out,e?void 0:r.key)))),t!=="directed"&&typeof r.undirected<"u"&&(n=ei(n,Xy(r.undirected))),n}function ix(t,e,r,n,i,a,s){const l=r?vX:pX;let c;if(e!=="undirected"&&(typeof i.in<"u"&&n!=="out"&&(c=l(t,i.in,a,s),t&&c)||typeof i.out<"u"&&n!=="in"&&(n||i.key!==a)&&(c=l(t,i.out,a,s),t&&c))||e!=="directed"&&typeof i.undirected<"u"&&(c=l(t,i.undirected,a,s),t&&c))return c}function wX(t,e,r,n,i){const a=[];return ix(!1,t,e,r,n,i,function(s){a.push(s)}),a}function xX(t,e,r,n){let i=ms();return t!=="undirected"&&(typeof r.in<"u"&&e!=="out"&&n in r.in&&(i=ei(i,Yy(r.in,n))),typeof r.out<"u"&&e!=="in"&&n in r.out&&(e||r.key!==n)&&(i=ei(i,Yy(r.out,n)))),t!=="directed"&&typeof r.undirected<"u"&&n in r.undirected&&(i=ei(i,Yy(r.undirected,n))),i}function SX(t,e){const{name:r,type:n,direction:i}=e;t.prototype[r]=function(a,s){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return[];if(!arguments.length)return gX(this,n);if(arguments.length===1){a=""+a;const l=this._nodes.get(a);if(typeof l>"u")throw new he(`Graph.${r}: could not find the "${a}" node in the graph.`);return yX(this.multi,n==="mixed"?this.type:n,i,l)}if(arguments.length===2){a=""+a,s=""+s;const l=this._nodes.get(a);if(!l)throw new he(`Graph.${r}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(s))throw new he(`Graph.${r}: could not find the "${s}" target node in the graph.`);return wX(n,this.multi,i,l,s)}throw new ye(`Graph.${r}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function _X(t,e){const{name:r,type:n,direction:i}=e,a="forEach"+r[0].toUpperCase()+r.slice(1,-1);t.prototype[a]=function(f,p,h){if(!(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)){if(arguments.length===1)return h=f,Kj(!1,this,n,h);if(arguments.length===2){f=""+f,h=p;const g=this._nodes.get(f);if(typeof g>"u")throw new he(`Graph.${a}: could not find the "${f}" node in the graph.`);return nx(!1,this.multi,n==="mixed"?this.type:n,i,g,h)}if(arguments.length===3){f=""+f,p=""+p;const g=this._nodes.get(f);if(!g)throw new he(`Graph.${a}: could not find the "${f}" source node in the graph.`);if(!this._nodes.has(p))throw new he(`Graph.${a}: could not find the "${p}" target node in the graph.`);return ix(!1,n,this.multi,i,g,p,h)}throw new ye(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const s="map"+r[0].toUpperCase()+r.slice(1);t.prototype[s]=function(){const f=Array.prototype.slice.call(arguments),p=f.pop();let h;if(f.length===0){let g=0;n!=="directed"&&(g+=this.undirectedSize),n!=="undirected"&&(g+=this.directedSize),h=new Array(g);let y=0;f.push((S,w,b,E,P,T,O)=>{h[y++]=p(S,w,b,E,P,T,O)})}else h=[],f.push((g,y,S,w,b,E,P)=>{h.push(p(g,y,S,w,b,E,P))});return this[a].apply(this,f),h};const l="filter"+r[0].toUpperCase()+r.slice(1);t.prototype[l]=function(){const f=Array.prototype.slice.call(arguments),p=f.pop(),h=[];return f.push((g,y,S,w,b,E,P)=>{p(g,y,S,w,b,E,P)&&h.push(g)}),this[a].apply(this,f),h};const c="reduce"+r[0].toUpperCase()+r.slice(1);t.prototype[c]=function(){let f=Array.prototype.slice.call(arguments);if(f.length<2||f.length>4)throw new ye(`Graph.${c}: invalid number of arguments (expecting 2, 3 or 4 and got ${f.length}).`);if(typeof f[f.length-1]=="function"&&typeof f[f.length-2]!="function")throw new ye(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let p,h;f.length===2?(p=f[0],h=f[1],f=[]):f.length===3?(p=f[1],h=f[2],f=[f[0]]):f.length===4&&(p=f[2],h=f[3],f=[f[0],f[1]]);let g=h;return f.push((y,S,w,b,E,P,T)=>{g=p(g,y,S,w,b,E,P,T)}),this[a].apply(this,f),g}}function EX(t,e){const{name:r,type:n,direction:i}=e,a="find"+r[0].toUpperCase()+r.slice(1,-1);t.prototype[a]=function(c,f,p){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return!1;if(arguments.length===1)return p=c,Kj(!0,this,n,p);if(arguments.length===2){c=""+c,p=f;const h=this._nodes.get(c);if(typeof h>"u")throw new he(`Graph.${a}: could not find the "${c}" node in the graph.`);return nx(!0,this.multi,n==="mixed"?this.type:n,i,h,p)}if(arguments.length===3){c=""+c,f=""+f;const h=this._nodes.get(c);if(!h)throw new he(`Graph.${a}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(f))throw new he(`Graph.${a}: could not find the "${f}" target node in the graph.`);return ix(!0,n,this.multi,i,h,f,p)}throw new ye(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const s="some"+r[0].toUpperCase()+r.slice(1,-1);t.prototype[s]=function(){const c=Array.prototype.slice.call(arguments),f=c.pop();return c.push((h,g,y,S,w,b,E)=>f(h,g,y,S,w,b,E)),!!this[a].apply(this,c)};const l="every"+r[0].toUpperCase()+r.slice(1,-1);t.prototype[l]=function(){const c=Array.prototype.slice.call(arguments),f=c.pop();return c.push((h,g,y,S,w,b,E)=>!f(h,g,y,S,w,b,E)),!this[a].apply(this,c)}}function OX(t,e){const{name:r,type:n,direction:i}=e,a=r.slice(0,-1)+"Entries";t.prototype[a]=function(s,l){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return ms();if(!arguments.length)return mX(this,n);if(arguments.length===1){s=""+s;const c=this._nodes.get(s);if(!c)throw new he(`Graph.${a}: could not find the "${s}" node in the graph.`);return bX(n,i,c)}if(arguments.length===2){s=""+s,l=""+l;const c=this._nodes.get(s);if(!c)throw new he(`Graph.${a}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(l))throw new he(`Graph.${a}: could not find the "${l}" target node in the graph.`);return xX(n,i,c,l)}throw new ye(`Graph.${a}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function AX(t){fX.forEach(e=>{SX(t,e),_X(t,e),EX(t,e),OX(t,e)})}const PX=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function Xd(){this.A=null,this.B=null}Xd.prototype.wrap=function(t){this.A===null?this.A=t:this.B===null&&(this.B=t)};Xd.prototype.has=function(t){return this.A!==null&&t in this.A||this.B!==null&&t in this.B};function hu(t,e,r,n,i){for(const a in n){const s=n[a],l=s.source,c=s.target,f=l===r?c:l;if(e&&e.has(f.key))continue;const p=i(f.key,f.attributes);if(t&&p)return f.key}}function ax(t,e,r,n,i){if(e!=="mixed"){if(e==="undirected")return hu(t,null,n,n.undirected,i);if(typeof r=="string")return hu(t,null,n,n[r],i)}const a=new Xd;let s;if(e!=="undirected"){if(r!=="out"){if(s=hu(t,null,n,n.in,i),t&&s)return s;a.wrap(n.in)}if(r!=="in"){if(s=hu(t,a,n,n.out,i),t&&s)return s;a.wrap(n.out)}}if(e!=="directed"&&(s=hu(t,a,n,n.undirected,i),t&&s))return s}function TX(t,e,r){if(t!=="mixed"){if(t==="undirected")return Object.keys(r.undirected);if(typeof e=="string")return Object.keys(r[e])}const n=[];return ax(!1,t,e,r,function(i){n.push(i)}),n}function pu(t,e,r){const n=Object.keys(r),i=n.length;let a=0;return{[Symbol.iterator](){return this},next(){let s=null;do{if(a>=i)return t&&t.wrap(r),{done:!0};const l=r[n[a++]],c=l.source,f=l.target;if(s=c===e?f:c,t&&t.has(s.key)){s=null;continue}}while(s===null);return{done:!1,value:{neighbor:s.key,attributes:s.attributes}}}}}function CX(t,e,r){if(t!=="mixed"){if(t==="undirected")return pu(null,r,r.undirected);if(typeof e=="string")return pu(null,r,r[e])}let n=ms();const i=new Xd;return t!=="undirected"&&(e!=="out"&&(n=ei(n,pu(i,r,r.in))),e!=="in"&&(n=ei(n,pu(i,r,r.out)))),t!=="directed"&&(n=ei(n,pu(i,r,r.undirected))),n}function kX(t,e){const{name:r,type:n,direction:i}=e;t.prototype[r]=function(a){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return[];a=""+a;const s=this._nodes.get(a);if(typeof s>"u")throw new he(`Graph.${r}: could not find the "${a}" node in the graph.`);return TX(n==="mixed"?this.type:n,i,s)}}function RX(t,e){const{name:r,type:n,direction:i}=e,a="forEach"+r[0].toUpperCase()+r.slice(1,-1);t.prototype[a]=function(f,p){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return;f=""+f;const h=this._nodes.get(f);if(typeof h>"u")throw new he(`Graph.${a}: could not find the "${f}" node in the graph.`);ax(!1,n==="mixed"?this.type:n,i,h,p)};const s="map"+r[0].toUpperCase()+r.slice(1);t.prototype[s]=function(f,p){const h=[];return this[a](f,(g,y)=>{h.push(p(g,y))}),h};const l="filter"+r[0].toUpperCase()+r.slice(1);t.prototype[l]=function(f,p){const h=[];return this[a](f,(g,y)=>{p(g,y)&&h.push(g)}),h};const c="reduce"+r[0].toUpperCase()+r.slice(1);t.prototype[c]=function(f,p,h){if(arguments.length<3)throw new ye(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let g=h;return this[a](f,(y,S)=>{g=p(g,y,S)}),g}}function DX(t,e){const{name:r,type:n,direction:i}=e,a=r[0].toUpperCase()+r.slice(1,-1),s="find"+a;t.prototype[s]=function(f,p){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return;f=""+f;const h=this._nodes.get(f);if(typeof h>"u")throw new he(`Graph.${s}: could not find the "${f}" node in the graph.`);return ax(!0,n==="mixed"?this.type:n,i,h,p)};const l="some"+a;t.prototype[l]=function(f,p){return!!this[s](f,p)};const c="every"+a;t.prototype[c]=function(f,p){return!this[s](f,(g,y)=>!p(g,y))}}function jX(t,e){const{name:r,type:n,direction:i}=e,a=r.slice(0,-1)+"Entries";t.prototype[a]=function(s){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return ms();s=""+s;const l=this._nodes.get(s);if(typeof l>"u")throw new he(`Graph.${a}: could not find the "${s}" node in the graph.`);return CX(n==="mixed"?this.type:n,i,l)}}function IX(t){PX.forEach(e=>{kX(t,e),RX(t,e),DX(t,e),jX(t,e)})}function of(t,e,r,n,i){const a=n._nodes.values(),s=n.type;let l,c,f,p,h,g;for(;l=a.next(),l.done!==!0;){let y=!1;if(c=l.value,s!=="undirected"){p=c.out;for(f in p){h=p[f];do g=h.target,y=!0,i(c.key,g.key,c.attributes,g.attributes,h.key,h.attributes,h.undirected),h=h.next;while(h)}}if(s!=="directed"){p=c.undirected;for(f in p)if(!(e&&c.key>f)){h=p[f];do g=h.target,g.key!==f&&(g=h.source),y=!0,i(c.key,g.key,c.attributes,g.attributes,h.key,h.attributes,h.undirected),h=h.next;while(h)}}r&&!y&&i(c.key,null,c.attributes,null,null,null,null)}}function NX(t,e){const r={key:t};return Gj(e.attributes)||(r.attributes=Pt({},e.attributes)),r}function MX(t,e,r){const n={key:e,source:r.source.key,target:r.target.key};return Gj(r.attributes)||(n.attributes=Pt({},r.attributes)),t==="mixed"&&r.undirected&&(n.undirected=!0),n}function LX(t){if(!Wt(t))throw new ye('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in t))throw new ye("Graph.import: serialized node is missing its key.");if("attributes"in t&&(!Wt(t.attributes)||t.attributes===null))throw new ye("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function $X(t){if(!Wt(t))throw new ye('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in t))throw new ye("Graph.import: serialized edge is missing its source.");if(!("target"in t))throw new ye("Graph.import: serialized edge is missing its target.");if("attributes"in t&&(!Wt(t.attributes)||t.attributes===null))throw new ye("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in t&&typeof t.undirected!="boolean")throw new ye("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const FX=G7(),BX=new Set(["directed","undirected","mixed"]),uk=new Set(["domain","_events","_eventsCount","_maxListeners"]),GX=[{name:t=>`${t}Edge`,generateKey:!0},{name:t=>`${t}DirectedEdge`,generateKey:!0,type:"directed"},{name:t=>`${t}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:t=>`${t}EdgeWithKey`},{name:t=>`${t}DirectedEdgeWithKey`,type:"directed"},{name:t=>`${t}UndirectedEdgeWithKey`,type:"undirected"}],zX={allowSelfLoops:!0,multi:!1,type:"mixed"};function UX(t,e,r){if(r&&!Wt(r))throw new ye(`Graph.addNode: invalid attributes. Expecting an object but got "${r}"`);if(e=""+e,r=r||{},t._nodes.has(e))throw new De(`Graph.addNode: the "${e}" node already exist in the graph.`);const n=new t.NodeDataClass(e,r);return t._nodes.set(e,n),t.emit("nodeAdded",{key:e,attributes:r}),n}function lk(t,e,r){const n=new t.NodeDataClass(e,r);return t._nodes.set(e,n),t.emit("nodeAdded",{key:e,attributes:r}),n}function Xj(t,e,r,n,i,a,s,l){if(!n&&t.type==="undirected")throw new De(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(n&&t.type==="directed")throw new De(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(l&&!Wt(l))throw new ye(`Graph.${e}: invalid attributes. Expecting an object but got "${l}"`);if(a=""+a,s=""+s,l=l||{},!t.allowSelfLoops&&a===s)throw new De(`Graph.${e}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const c=t._nodes.get(a),f=t._nodes.get(s);if(!c)throw new he(`Graph.${e}: source node "${a}" not found.`);if(!f)throw new he(`Graph.${e}: target node "${s}" not found.`);const p={key:null,undirected:n,source:a,target:s,attributes:l};if(r)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new De(`Graph.${e}: the "${i}" edge already exists in the graph.`);if(!t.multi&&(n?typeof c.undirected[s]<"u":typeof c.out[s]<"u"))throw new De(`Graph.${e}: an edge linking "${a}" to "${s}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const h=new ys(n,i,c,f,l);t._edges.set(i,h);const g=a===s;return n?(c.undirectedDegree++,f.undirectedDegree++,g&&(c.undirectedLoops++,t._undirectedSelfLoopCount++)):(c.outDegree++,f.inDegree++,g&&(c.directedLoops++,t._directedSelfLoopCount++)),t.multi?h.attachMulti():h.attach(),n?t._undirectedSize++:t._directedSize++,p.key=i,t.emit("edgeAdded",p),i}function qX(t,e,r,n,i,a,s,l,c){if(!n&&t.type==="undirected")throw new De(`Graph.${e}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(n&&t.type==="directed")throw new De(`Graph.${e}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(l){if(c){if(typeof l!="function")throw new ye(`Graph.${e}: invalid updater function. Expecting a function but got "${l}"`)}else if(!Wt(l))throw new ye(`Graph.${e}: invalid attributes. Expecting an object but got "${l}"`)}a=""+a,s=""+s;let f;if(c&&(f=l,l=void 0),!t.allowSelfLoops&&a===s)throw new De(`Graph.${e}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let p=t._nodes.get(a),h=t._nodes.get(s),g,y;if(!r&&(g=t._edges.get(i),g)){if((g.source.key!==a||g.target.key!==s)&&(!n||g.source.key!==s||g.target.key!==a))throw new De(`Graph.${e}: inconsistency detected when attempting to merge the "${i}" edge with "${a}" source & "${s}" target vs. ("${g.source.key}", "${g.target.key}").`);y=g}if(!y&&!t.multi&&p&&(y=n?p.undirected[s]:p.out[s]),y){const P=[y.key,!1,!1,!1];if(c?!f:!l)return P;if(c){const T=y.attributes;y.attributes=f(T),t.emit("edgeAttributesUpdated",{type:"replace",key:y.key,attributes:y.attributes})}else Pt(y.attributes,l),t.emit("edgeAttributesUpdated",{type:"merge",key:y.key,attributes:y.attributes,data:l});return P}l=l||{},c&&f&&(l=f(l));const S={key:null,undirected:n,source:a,target:s,attributes:l};if(r)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new De(`Graph.${e}: the "${i}" edge already exists in the graph.`);let w=!1,b=!1;p||(p=lk(t,a,{}),w=!0,a===s&&(h=p,b=!0)),h||(h=lk(t,s,{}),b=!0),g=new ys(n,i,p,h,l),t._edges.set(i,g);const E=a===s;return n?(p.undirectedDegree++,h.undirectedDegree++,E&&(p.undirectedLoops++,t._undirectedSelfLoopCount++)):(p.outDegree++,h.inDegree++,E&&(p.directedLoops++,t._directedSelfLoopCount++)),t.multi?g.attachMulti():g.attach(),n?t._undirectedSize++:t._directedSize++,S.key=i,t.emit("edgeAdded",S),[i,!0,w,b]}function po(t,e){t._edges.delete(e.key);const{source:r,target:n,attributes:i}=e,a=e.undirected,s=r===n;a?(r.undirectedDegree--,n.undirectedDegree--,s&&(r.undirectedLoops--,t._undirectedSelfLoopCount--)):(r.outDegree--,n.inDegree--,s&&(r.directedLoops--,t._directedSelfLoopCount--)),t.multi?e.detachMulti():e.detach(),a?t._undirectedSize--:t._directedSize--,t.emit("edgeDropped",{key:e.key,attributes:i,source:r.key,target:n.key,undirected:a})}class Ze extends Bj.EventEmitter{constructor(e){if(super(),e=Pt({},zX,e),typeof e.multi!="boolean")throw new ye(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!BX.has(e.type))throw new ye(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new ye(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);const r=e.type==="mixed"?zj:e.type==="directed"?Uj:qj;Ir(this,"NodeDataClass",r);const n="geid_"+FX()+"_";let i=0;const a=()=>{let s;do s=n+i++;while(this._edges.has(s));return s};Ir(this,"_attributes",{}),Ir(this,"_nodes",new Map),Ir(this,"_edges",new Map),Ir(this,"_directedSize",0),Ir(this,"_undirectedSize",0),Ir(this,"_directedSelfLoopCount",0),Ir(this,"_undirectedSelfLoopCount",0),Ir(this,"_edgeKeyGenerator",a),Ir(this,"_options",e),uk.forEach(s=>Ir(this,s,this[s])),Zr(this,"order",()=>this._nodes.size),Zr(this,"size",()=>this._edges.size),Zr(this,"directedSize",()=>this._directedSize),Zr(this,"undirectedSize",()=>this._undirectedSize),Zr(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Zr(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Zr(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Zr(this,"multi",this._options.multi),Zr(this,"type",this._options.type),Zr(this,"allowSelfLoops",this._options.allowSelfLoops),Zr(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(""+e)}hasDirectedEdge(e,r){if(this.type==="undirected")return!1;if(arguments.length===1){const n=""+e,i=this._edges.get(n);return!!i&&!i.undirected}else if(arguments.length===2){e=""+e,r=""+r;const n=this._nodes.get(e);return n?n.out.hasOwnProperty(r):!1}throw new ye(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(e,r){if(this.type==="directed")return!1;if(arguments.length===1){const n=""+e,i=this._edges.get(n);return!!i&&i.undirected}else if(arguments.length===2){e=""+e,r=""+r;const n=this._nodes.get(e);return n?n.undirected.hasOwnProperty(r):!1}throw new ye(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(e,r){if(arguments.length===1){const n=""+e;return this._edges.has(n)}else if(arguments.length===2){e=""+e,r=""+r;const n=this._nodes.get(e);return n?typeof n.out<"u"&&n.out.hasOwnProperty(r)||typeof n.undirected<"u"&&n.undirected.hasOwnProperty(r):!1}throw new ye(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(e,r){if(this.type==="undirected")return;if(e=""+e,r=""+r,this.multi)throw new De("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const n=this._nodes.get(e);if(!n)throw new he(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(r))throw new he(`Graph.directedEdge: could not find the "${r}" target node in the graph.`);const i=n.out&&n.out[r]||void 0;if(i)return i.key}undirectedEdge(e,r){if(this.type==="directed")return;if(e=""+e,r=""+r,this.multi)throw new De("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const n=this._nodes.get(e);if(!n)throw new he(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(r))throw new he(`Graph.undirectedEdge: could not find the "${r}" target node in the graph.`);const i=n.undirected&&n.undirected[r]||void 0;if(i)return i.key}edge(e,r){if(this.multi)throw new De("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,r=""+r;const n=this._nodes.get(e);if(!n)throw new he(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(r))throw new he(`Graph.edge: could not find the "${r}" target node in the graph.`);const i=n.out&&n.out[r]||n.undirected&&n.undirected[r]||void 0;if(i)return i.key}areDirectedNeighbors(e,r){e=""+e,r=""+r;const n=this._nodes.get(e);if(!n)throw new he(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:r in n.in||r in n.out}areOutNeighbors(e,r){e=""+e,r=""+r;const n=this._nodes.get(e);if(!n)throw new he(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:r in n.out}areInNeighbors(e,r){e=""+e,r=""+r;const n=this._nodes.get(e);if(!n)throw new he(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:r in n.in}areUndirectedNeighbors(e,r){e=""+e,r=""+r;const n=this._nodes.get(e);if(!n)throw new he(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="directed"?!1:r in n.undirected}areNeighbors(e,r){e=""+e,r=""+r;const n=this._nodes.get(e);if(!n)throw new he(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&(r in n.in||r in n.out)||this.type!=="directed"&&r in n.undirected}areInboundNeighbors(e,r){e=""+e,r=""+r;const n=this._nodes.get(e);if(!n)throw new he(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&r in n.in||this.type!=="directed"&&r in n.undirected}areOutboundNeighbors(e,r){e=""+e,r=""+r;const n=this._nodes.get(e);if(!n)throw new he(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&r in n.out||this.type!=="directed"&&r in n.undirected}inDegree(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:r.inDegree}outDegree(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:r.outDegree}directedDegree(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:r.inDegree+r.outDegree}undirectedDegree(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:r.undirectedDegree}inboundDegree(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=r.undirectedDegree),this.type!=="undirected"&&(n+=r.inDegree),n}outboundDegree(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=r.undirectedDegree),this.type!=="undirected"&&(n+=r.outDegree),n}degree(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.degree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=r.undirectedDegree),this.type!=="undirected"&&(n+=r.inDegree+r.outDegree),n}inDegreeWithoutSelfLoops(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:r.inDegree-r.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:r.outDegree-r.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:r.inDegree+r.outDegree-r.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:r.undirectedDegree-r.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=r.undirectedDegree,i+=r.undirectedLoops*2),this.type!=="undirected"&&(n+=r.inDegree,i+=r.directedLoops),n-i}outboundDegreeWithoutSelfLoops(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=r.undirectedDegree,i+=r.undirectedLoops*2),this.type!=="undirected"&&(n+=r.outDegree,i+=r.directedLoops),n-i}degreeWithoutSelfLoops(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=r.undirectedDegree,i+=r.undirectedLoops*2),this.type!=="undirected"&&(n+=r.inDegree+r.outDegree,i+=r.directedLoops*2),n-i}source(e){e=""+e;const r=this._edges.get(e);if(!r)throw new he(`Graph.source: could not find the "${e}" edge in the graph.`);return r.source.key}target(e){e=""+e;const r=this._edges.get(e);if(!r)throw new he(`Graph.target: could not find the "${e}" edge in the graph.`);return r.target.key}extremities(e){e=""+e;const r=this._edges.get(e);if(!r)throw new he(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[r.source.key,r.target.key]}opposite(e,r){e=""+e,r=""+r;const n=this._edges.get(r);if(!n)throw new he(`Graph.opposite: could not find the "${r}" edge in the graph.`);const i=n.source.key,a=n.target.key;if(e===i)return a;if(e===a)return i;throw new he(`Graph.opposite: the "${e}" node is not attached to the "${r}" edge (${i}, ${a}).`)}hasExtremity(e,r){e=""+e,r=""+r;const n=this._edges.get(e);if(!n)throw new he(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return n.source.key===r||n.target.key===r}isUndirected(e){e=""+e;const r=this._edges.get(e);if(!r)throw new he(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return r.undirected}isDirected(e){e=""+e;const r=this._edges.get(e);if(!r)throw new he(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!r.undirected}isSelfLoop(e){e=""+e;const r=this._edges.get(e);if(!r)throw new he(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return r.source===r.target}addNode(e,r){return UX(this,e,r).key}mergeNode(e,r){if(r&&!Wt(r))throw new ye(`Graph.mergeNode: invalid attributes. Expecting an object but got "${r}"`);e=""+e,r=r||{};let n=this._nodes.get(e);return n?(r&&(Pt(n.attributes,r),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:n.attributes,data:r})),[e,!1]):(n=new this.NodeDataClass(e,r),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:r}),[e,!0])}updateNode(e,r){if(r&&typeof r!="function")throw new ye(`Graph.updateNode: invalid updater function. Expecting a function but got "${r}"`);e=""+e;let n=this._nodes.get(e);if(n){if(r){const a=n.attributes;n.attributes=r(a),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:n.attributes})}return[e,!1]}const i=r?r({}):{};return n=new this.NodeDataClass(e,i),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:i}),[e,!0]}dropNode(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.dropNode: could not find the "${e}" node in the graph.`);let n;if(this.type!=="undirected"){for(const i in r.out){n=r.out[i];do po(this,n),n=n.next;while(n)}for(const i in r.in){n=r.in[i];do po(this,n),n=n.next;while(n)}}if(this.type!=="directed")for(const i in r.undirected){n=r.undirected[i];do po(this,n),n=n.next;while(n)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:r.attributes})}dropEdge(e){let r;if(arguments.length>1){const n=""+arguments[0],i=""+arguments[1];if(r=Fr(this,n,i,this.type),!r)throw new he(`Graph.dropEdge: could not find the "${n}" -> "${i}" edge in the graph.`)}else if(e=""+e,r=this._edges.get(e),!r)throw new he(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return po(this,r),this}dropDirectedEdge(e,r){if(arguments.length<2)throw new De("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new De("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");e=""+e,r=""+r;const n=Fr(this,e,r,"directed");if(!n)throw new he(`Graph.dropDirectedEdge: could not find a "${e}" -> "${r}" edge in the graph.`);return po(this,n),this}dropUndirectedEdge(e,r){if(arguments.length<2)throw new De("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new De("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const n=Fr(this,e,r,"undirected");if(!n)throw new he(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${r}" edge in the graph.`);return po(this,n),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const e=this._nodes.values();let r;for(;r=e.next(),r.done!==!0;)r.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,r){return this._attributes[e]=r,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,r){if(typeof r!="function")throw new ye("Graph.updateAttribute: updater should be a function.");const n=this._attributes[e];return this._attributes[e]=r(n),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!Wt(e))throw new ye("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=e,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(e){if(!Wt(e))throw new ye("Graph.mergeAttributes: provided attributes are not a plain object.");return Pt(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new ye("Graph.updateAttributes: provided updater is not a function.");return this._attributes=e(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(e,r){if(typeof e!="function")throw new ye("Graph.updateEachNodeAttributes: expecting an updater function.");if(r&&!sk(r))throw new ye("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const n=this._nodes.values();let i,a;for(;i=n.next(),i.done!==!0;)a=i.value,a.attributes=e(a.key,a.attributes);this.emit("eachNodeAttributesUpdated",{hints:r||null})}updateEachEdgeAttributes(e,r){if(typeof e!="function")throw new ye("Graph.updateEachEdgeAttributes: expecting an updater function.");if(r&&!sk(r))throw new ye("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const n=this._edges.values();let i,a,s,l;for(;i=n.next(),i.done!==!0;)a=i.value,s=a.source,l=a.target,a.attributes=e(a.key,a.attributes,s.key,l.key,s.attributes,l.attributes,a.undirected);this.emit("eachEdgeAttributesUpdated",{hints:r||null})}forEachAdjacencyEntry(e){if(typeof e!="function")throw new ye("Graph.forEachAdjacencyEntry: expecting a callback.");of(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new ye("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");of(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new ye("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");of(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new ye("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");of(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!="function")throw new ye("Graph.forEachNode: expecting a callback.");const r=this._nodes.values();let n,i;for(;n=r.next(),n.done!==!0;)i=n.value,e(i.key,i.attributes)}findNode(e){if(typeof e!="function")throw new ye("Graph.findNode: expecting a callback.");const r=this._nodes.values();let n,i;for(;n=r.next(),n.done!==!0;)if(i=n.value,e(i.key,i.attributes))return i.key}mapNodes(e){if(typeof e!="function")throw new ye("Graph.mapNode: expecting a callback.");const r=this._nodes.values();let n,i;const a=new Array(this.order);let s=0;for(;n=r.next(),n.done!==!0;)i=n.value,a[s++]=e(i.key,i.attributes);return a}someNode(e){if(typeof e!="function")throw new ye("Graph.someNode: expecting a callback.");const r=this._nodes.values();let n,i;for(;n=r.next(),n.done!==!0;)if(i=n.value,e(i.key,i.attributes))return!0;return!1}everyNode(e){if(typeof e!="function")throw new ye("Graph.everyNode: expecting a callback.");const r=this._nodes.values();let n,i;for(;n=r.next(),n.done!==!0;)if(i=n.value,!e(i.key,i.attributes))return!1;return!0}filterNodes(e){if(typeof e!="function")throw new ye("Graph.filterNodes: expecting a callback.");const r=this._nodes.values();let n,i;const a=[];for(;n=r.next(),n.done!==!0;)i=n.value,e(i.key,i.attributes)&&a.push(i.key);return a}reduceNodes(e,r){if(typeof e!="function")throw new ye("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new ye("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let n=r;const i=this._nodes.values();let a,s;for(;a=i.next(),a.done!==!0;)s=a.value,n=e(n,s.key,s.attributes);return n}nodeEntries(){const e=this._nodes.values();return{[Symbol.iterator](){return this},next(){const r=e.next();if(r.done)return r;const n=r.value;return{value:{node:n.key,attributes:n.attributes},done:!1}}}}export(){const e=new Array(this._nodes.size);let r=0;this._nodes.forEach((i,a)=>{e[r++]=NX(a,i)});const n=new Array(this._edges.size);return r=0,this._edges.forEach((i,a)=>{n[r++]=MX(this.type,a,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:n}}import(e,r=!1){if(e instanceof Ze)return e.forEachNode((c,f)=>{r?this.mergeNode(c,f):this.addNode(c,f)}),e.forEachEdge((c,f,p,h,g,y,S)=>{r?S?this.mergeUndirectedEdgeWithKey(c,p,h,f):this.mergeDirectedEdgeWithKey(c,p,h,f):S?this.addUndirectedEdgeWithKey(c,p,h,f):this.addDirectedEdgeWithKey(c,p,h,f)}),this;if(!Wt(e))throw new ye("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!Wt(e.attributes))throw new ye("Graph.import: invalid attributes. Expecting a plain object.");r?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let n,i,a,s,l;if(e.nodes){if(a=e.nodes,!Array.isArray(a))throw new ye("Graph.import: invalid nodes. Expecting an array.");for(n=0,i=a.length;n<i;n++){s=a[n],LX(s);const{key:c,attributes:f}=s;r?this.mergeNode(c,f):this.addNode(c,f)}}if(e.edges){let c=!1;if(this.type==="undirected"&&(c=!0),a=e.edges,!Array.isArray(a))throw new ye("Graph.import: invalid edges. Expecting an array.");for(n=0,i=a.length;n<i;n++){l=a[n],$X(l);const{source:f,target:p,attributes:h,undirected:g=c}=l;let y;"key"in l?(y=r?g?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:g?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,y.call(this,l.key,f,p,h)):(y=r?g?this.mergeUndirectedEdge:this.mergeDirectedEdge:g?this.addUndirectedEdge:this.addDirectedEdge,y.call(this,f,p,h))}}return this}nullCopy(e){const r=new Ze(Pt({},this._options,e));return r.replaceAttributes(Pt({},this.getAttributes())),r}emptyCopy(e){const r=this.nullCopy(e);return this._nodes.forEach((n,i)=>{const a=Pt({},n.attributes);n=new r.NodeDataClass(i,a),r._nodes.set(i,n)}),r}copy(e){if(e=e||{},typeof e.type=="string"&&e.type!==this.type&&e.type!=="mixed")throw new De(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi=="boolean"&&e.multi!==this.multi&&e.multi!==!0)throw new De("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof e.allowSelfLoops=="boolean"&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new De("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const r=this.emptyCopy(e),n=this._edges.values();let i,a;for(;i=n.next(),i.done!==!0;)a=i.value,Xj(r,"copy",!1,a.undirected,a.key,a.source.key,a.target.key,Pt({},a.attributes));return r}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const e={};this._nodes.forEach((a,s)=>{e[s]=a.attributes});const r={},n={};this._edges.forEach((a,s)=>{const l=a.undirected?"--":"->";let c="",f=a.source.key,p=a.target.key,h;a.undirected&&f>p&&(h=f,f=p,p=h);const g=`(${f})${l}(${p})`;s.startsWith("geid_")?this.multi&&(typeof n[g]>"u"?n[g]=0:n[g]++,c+=`${n[g]}. `):c+=`[${s}]: `,c+=g,r[c]=a.attributes});const i={};for(const a in this)this.hasOwnProperty(a)&&!uk.has(a)&&typeof this[a]!="function"&&typeof a!="symbol"&&(i[a]=this[a]);return i.attributes=this._attributes,i.nodes=e,i.edges=r,Ir(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(Ze.prototype[Symbol.for("nodejs.util.inspect.custom")]=Ze.prototype.inspect);GX.forEach(t=>{["add","merge","update"].forEach(e=>{const r=t.name(e),n=e==="add"?Xj:qX;t.generateKey?Ze.prototype[r]=function(i,a,s){return n(this,r,!0,(t.type||this.type)==="undirected",null,i,a,s,e==="update")}:Ze.prototype[r]=function(i,a,s,l){return n(this,r,!1,(t.type||this.type)==="undirected",i,a,s,l,e==="update")}})});J7(Ze);cX(Ze);AX(Ze);IX(Ze);class Yj extends Ze{constructor(e){const r=Pt({type:"directed"},e);if("multi"in r&&r.multi!==!1)throw new ye("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(r.type!=="directed")throw new ye('DirectedGraph.from: inconsistent "'+r.type+'" type in given options!');super(r)}}class Qj extends Ze{constructor(e){const r=Pt({type:"undirected"},e);if("multi"in r&&r.multi!==!1)throw new ye("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(r.type!=="undirected")throw new ye('UndirectedGraph.from: inconsistent "'+r.type+'" type in given options!');super(r)}}class Zj extends Ze{constructor(e){const r=Pt({multi:!0},e);if("multi"in r&&r.multi!==!0)throw new ye("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(r)}}class Jj extends Ze{constructor(e){const r=Pt({type:"directed",multi:!0},e);if("multi"in r&&r.multi!==!0)throw new ye("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(r.type!=="directed")throw new ye('MultiDirectedGraph.from: inconsistent "'+r.type+'" type in given options!');super(r)}}class eI extends Ze{constructor(e){const r=Pt({type:"undirected",multi:!0},e);if("multi"in r&&r.multi!==!0)throw new ye("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(r.type!=="undirected")throw new ye('MultiUndirectedGraph.from: inconsistent "'+r.type+'" type in given options!');super(r)}}function bs(t){t.from=function(e,r){const n=Pt({},e.options,r),i=new t(n);return i.import(e),i}}bs(Ze);bs(Yj);bs(Qj);bs(Zj);bs(Jj);bs(eI);Ze.Graph=Ze;Ze.DirectedGraph=Yj;Ze.UndirectedGraph=Qj;Ze.MultiGraph=Zj;Ze.MultiDirectedGraph=Jj;Ze.MultiUndirectedGraph=eI;Ze.InvalidArgumentsGraphError=ye;Ze.NotFoundGraphError=he;Ze.UsageGraphError=De;function WX(t,e){if(typeof t!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}function Tu(t){var e=WX(t,"string");return typeof e=="symbol"?e:e+""}function er(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ck(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Tu(n.key),n)}}function tr(t,e,r){return e&&ck(t.prototype,e),r&&ck(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function as(t){return as=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},as(t)}function tI(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(tI=function(){return!!t})()}function HX(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function VX(t,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return HX(t)}function zr(t,e,r){return e=as(e),VX(t,tI()?Reflect.construct(e,r||[],as(t).constructor):e.apply(t,r))}function Bb(t,e){return Bb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,n){return r.__proto__=n,r},Bb(t,e)}function Ur(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Bb(t,e)}function KX(t){if(Array.isArray(t))return t}function XX(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,i,a,s,l=[],c=!0,f=!1;try{if(a=(r=r.call(t)).next,e===0){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(l.push(n.value),l.length!==e);c=!0);}catch(p){f=!0,i=p}finally{try{if(!c&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(f)throw i}}return l}}function Gb(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function rI(t,e){if(t){if(typeof t=="string")return Gb(t,e);var r={}.toString.call(t).slice(8,-1);return r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set"?Array.from(t):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Gb(t,e):void 0}}function YX(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
178
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Mj(t,e){if(t){if(typeof t=="string")return $b(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return $b(t,e)}}function _7(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function E7(t){if(Array.isArray(t))return $b(t)}function $b(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function tk(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function ae(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?tk(Object(r),!0).forEach(function(n){je(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):tk(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function je(t,e,r){return e=Lj(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Lj(t){var e=O7(t,"string");return ns(e)=="symbol"?e:e+""}function O7(t,e){if(ns(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(ns(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var A7={xAxis:["bottom","top"],yAxis:["left","right"]},P7={width:"100%",height:"100%"},$j={x:0,y:0};function nf(t){return t}var T7=function(e,r){return r==="horizontal"?e.x:r==="vertical"?e.y:r==="centric"?e.angle:e.radius},C7=function(e,r,n,i){var a=r.find(function(p){return p&&p.index===n});if(a){if(e==="horizontal")return{x:a.coordinate,y:i.y};if(e==="vertical")return{x:i.x,y:a.coordinate};if(e==="centric"){var s=a.coordinate,l=i.radius;return ae(ae(ae({},i),Ht(i.cx,i.cy,l,s)),{},{angle:s,radius:l})}var c=a.coordinate,f=i.angle;return ae(ae(ae({},i),Ht(i.cx,i.cy,c,f)),{},{angle:f,radius:c})}return $j},Kd=function(e,r){var n=r.graphicalItems,i=r.dataStartIndex,a=r.dataEndIndex,s=(n??[]).reduce(function(l,c){var f=c.props.data;return f&&f.length?[].concat(is(l),is(f)):l},[]);return s.length>0?s:e&&e.length&&me(i)&&me(a)?e.slice(i,a+1):[]};function Fj(t){return t==="number"?[0,"auto"]:void 0}var Fb=function(e,r,n,i){var a=e.graphicalItems,s=e.tooltipAxis,l=Kd(r,e);return n<0||!a||!a.length||n>=l.length?null:a.reduce(function(c,f){var p,h=(p=f.props.data)!==null&&p!==void 0?p:r;h&&e.dataStartIndex+e.dataEndIndex!==0&&e.dataEndIndex-e.dataStartIndex>=n&&(h=h.slice(e.dataStartIndex,e.dataEndIndex+1));var g;if(s.dataKey&&!s.allowDuplicatedCategory){var y=h===void 0?l:h;g=O0(y,s.dataKey,i)}else g=h&&h[n]||l[n];return g?[].concat(is(c),[B2(f,g)]):c},[])},rk=function(e,r,n,i){var a=i||{x:e.chartX,y:e.chartY},s=T7(a,n),l=e.orderedTooltipTicks,c=e.tooltipAxis,f=e.tooltipTicks,p=h5(s,l,f,c);if(p>=0&&f){var h=f[p]&&f[p].value,g=Fb(e,r,p,h),y=C7(n,l,p,a);return{activeTooltipIndex:p,activeLabel:h,activePayload:g,activeCoordinate:y}}return null},k7=function(e,r){var n=r.axes,i=r.graphicalItems,a=r.axisType,s=r.axisIdKey,l=r.stackGroups,c=r.dataStartIndex,f=r.dataEndIndex,p=e.layout,h=e.children,g=e.stackOffset,y=$2(p,a);return n.reduce(function(S,w){var b,E=w.type.defaultProps!==void 0?ae(ae({},w.type.defaultProps),w.props):w.props,P=E.type,T=E.dataKey,O=E.allowDataOverflow,_=E.allowDuplicatedCategory,A=E.scale,C=E.ticks,D=E.includeHidden,j=E[s];if(S[j])return S;var G=Kd(e.data,{graphicalItems:i.filter(function(W){var te,we=s in W.props?W.props[s]:(te=W.type.defaultProps)===null||te===void 0?void 0:te[s];return we===j}),dataStartIndex:c,dataEndIndex:f}),z=G.length,$,R,X;r7(E.domain,O,P)&&($=ab(E.domain,null,O),y&&(P==="number"||A!=="auto")&&(X=Au(G,T,"category")));var K=Fj(P);if(!$||$.length===0){var B,I=(B=E.domain)!==null&&B!==void 0?B:K;if(T){if($=Au(G,T,P),P==="category"&&y){var V=aB($);_&&V?(R=$,$=Jf(0,z)):_||($=wT(I,$,w).reduce(function(W,te){return W.indexOf(te)>=0?W:[].concat(is(W),[te])},[]))}else if(P==="category")_?$=$.filter(function(W){return W!==""&&!Ve(W)}):$=wT(I,$,w).reduce(function(W,te){return W.indexOf(te)>=0||te===""||Ve(te)?W:[].concat(is(W),[te])},[]);else if(P==="number"){var J=y5(G,i.filter(function(W){var te,we,xe=s in W.props?W.props[s]:(te=W.type.defaultProps)===null||te===void 0?void 0:te[s],Ie="hide"in W.props?W.props.hide:(we=W.type.defaultProps)===null||we===void 0?void 0:we.hide;return xe===j&&(D||!Ie)}),T,a,p);J&&($=J)}y&&(P==="number"||A!=="auto")&&(X=Au(G,T,"category"))}else y?$=Jf(0,z):l&&l[j]&&l[j].hasStack&&P==="number"?$=g==="expand"?[0,1]:F2(l[j].stackGroups,c,f):$=L2(G,i.filter(function(W){var te=s in W.props?W.props[s]:W.type.defaultProps[s],we="hide"in W.props?W.props.hide:W.type.defaultProps.hide;return te===j&&(D||!we)}),P,p,!0);if(P==="number")$=Mb(h,$,j,a,C),I&&($=ab(I,$,O));else if(P==="category"&&I){var ee=I,L=$.every(function(W){return ee.indexOf(W)>=0});L&&($=ee)}}return ae(ae({},S),{},je({},j,ae(ae({},E),{},{axisType:a,domain:$,categoricalDomain:X,duplicateDomain:R,originalDomain:(b=E.domain)!==null&&b!==void 0?b:K,isCategorical:y,layout:p})))},{})},R7=function(e,r){var n=r.graphicalItems,i=r.Axis,a=r.axisType,s=r.axisIdKey,l=r.stackGroups,c=r.dataStartIndex,f=r.dataEndIndex,p=e.layout,h=e.children,g=Kd(e.data,{graphicalItems:n,dataStartIndex:c,dataEndIndex:f}),y=g.length,S=$2(p,a),w=-1;return n.reduce(function(b,E){var P=E.type.defaultProps!==void 0?ae(ae({},E.type.defaultProps),E.props):E.props,T=P[s],O=Fj("number");if(!b[T]){w++;var _;return S?_=Jf(0,y):l&&l[T]&&l[T].hasStack?(_=F2(l[T].stackGroups,c,f),_=Mb(h,_,T,a)):(_=ab(O,L2(g,n.filter(function(A){var C,D,j=s in A.props?A.props[s]:(C=A.type.defaultProps)===null||C===void 0?void 0:C[s],G="hide"in A.props?A.props.hide:(D=A.type.defaultProps)===null||D===void 0?void 0:D.hide;return j===T&&!G}),"number",p),i.defaultProps.allowDataOverflow),_=Mb(h,_,T,a)),ae(ae({},b),{},je({},T,ae(ae({axisType:a},i.defaultProps),{},{hide:!0,orientation:$r(A7,"".concat(a,".").concat(w%2),null),domain:_,originalDomain:O,isCategorical:S,layout:p})))}return b},{})},D7=function(e,r){var n=r.axisType,i=n===void 0?"xAxis":n,a=r.AxisComp,s=r.graphicalItems,l=r.stackGroups,c=r.dataStartIndex,f=r.dataEndIndex,p=e.children,h="".concat(i,"Id"),g=sn(p,a),y={};return g&&g.length?y=k7(e,{axes:g,graphicalItems:s,axisType:i,axisIdKey:h,stackGroups:l,dataStartIndex:c,dataEndIndex:f}):s&&s.length&&(y=R7(e,{Axis:a,graphicalItems:s,axisType:i,axisIdKey:h,stackGroups:l,dataStartIndex:c,dataEndIndex:f})),y},j7=function(e){var r=go(e),n=ma(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:_w(n,function(i){return i.coordinate}),tooltipAxis:r,tooltipAxisBandSize:Uf(r,n)}},nk=function(e){var r=e.children,n=e.defaultShowTooltip,i=xr(r,Xo),a=0,s=0;return e.data&&e.data.length!==0&&(s=e.data.length-1),i&&i.props&&(i.props.startIndex>=0&&(a=i.props.startIndex),i.props.endIndex>=0&&(s=i.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:a,dataEndIndex:s,activeTooltipIndex:-1,isTooltipActive:!!n}},I7=function(e){return!e||!e.length?!1:e.some(function(r){var n=Qn(r&&r.type);return n&&n.indexOf("Bar")>=0})},ik=function(e){return e==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:e==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:e==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},N7=function(e,r){var n=e.props,i=e.graphicalItems,a=e.xAxisMap,s=a===void 0?{}:a,l=e.yAxisMap,c=l===void 0?{}:l,f=n.width,p=n.height,h=n.children,g=n.margin||{},y=xr(h,Xo),S=xr(h,xo),w=Object.keys(c).reduce(function(_,A){var C=c[A],D=C.orientation;return!C.mirror&&!C.hide?ae(ae({},_),{},je({},D,_[D]+C.width)):_},{left:g.left||0,right:g.right||0}),b=Object.keys(s).reduce(function(_,A){var C=s[A],D=C.orientation;return!C.mirror&&!C.hide?ae(ae({},_),{},je({},D,$r(_,"".concat(D))+C.height)):_},{top:g.top||0,bottom:g.bottom||0}),E=ae(ae({},b),w),P=E.bottom;y&&(E.bottom+=y.props.height||Xo.defaultProps.height),S&&r&&(E=g5(E,i,n,r));var T=f-E.left-E.right,O=p-E.top-E.bottom;return ae(ae({brushBottom:P},E),{},{width:Math.max(T,0),height:Math.max(O,0)})},M7=function(e,r){if(r==="xAxis")return e[r].width;if(r==="yAxis")return e[r].height},L7=function(e){var r=e.chartName,n=e.GraphicalChild,i=e.defaultTooltipEventType,a=i===void 0?"axis":i,s=e.validateTooltipEventTypes,l=s===void 0?["axis"]:s,c=e.axisComponents,f=e.legendContent,p=e.formatAxisMap,h=e.defaultProps,g=function(E,P){var T=P.graphicalItems,O=P.stackGroups,_=P.offset,A=P.updateId,C=P.dataStartIndex,D=P.dataEndIndex,j=E.barSize,G=E.layout,z=E.barGap,$=E.barCategoryGap,R=E.maxBarSize,X=ik(G),K=X.numericAxisName,B=X.cateAxisName,I=I7(T),V=[];return T.forEach(function(J,ee){var L=Kd(E.data,{graphicalItems:[J],dataStartIndex:C,dataEndIndex:D}),W=J.type.defaultProps!==void 0?ae(ae({},J.type.defaultProps),J.props):J.props,te=W.dataKey,we=W.maxBarSize,xe=W["".concat(K,"Id")],Ie=W["".concat(B,"Id")],Le={},Me=c.reduce(function(rt,Dt){var cn=P["".concat(Dt.axisType,"Map")],fn=W["".concat(Dt.axisType,"Id")];cn&&cn[fn]||Dt.axisType==="zAxis"||Na();var dn=cn[fn];return ae(ae({},rt),{},je(je({},Dt.axisType,dn),"".concat(Dt.axisType,"Ticks"),ma(dn)))},Le),le=Me[B],pe=Me["".concat(B,"Ticks")],ve=O&&O[xe]&&O[xe].hasStack&&k5(J,O[xe].stackGroups),ie=Qn(J.type).indexOf("Bar")>=0,Fe=Uf(le,pe),de=[],ge=I&&p5({barSize:j,stackGroups:O,totalSize:M7(Me,B)});if(ie){var ne,it,kt=Ve(we)?R:we,Rt=(ne=(it=Uf(le,pe,!0))!==null&&it!==void 0?it:kt)!==null&&ne!==void 0?ne:0;de=v5({barGap:z,barCategoryGap:$,bandSize:Rt!==Fe?Rt:Fe,sizeList:ge[Ie],maxBarSize:kt}),Rt!==Fe&&(de=de.map(function(rt){return ae(ae({},rt),{},{position:ae(ae({},rt.position),{},{offset:rt.position.offset-Rt/2})})}))}var Bt=J&&J.type&&J.type.getComposedData;Bt&&V.push({props:ae(ae({},Bt(ae(ae({},Me),{},{displayedData:L,props:E,dataKey:te,item:J,bandSize:Fe,barPosition:de,offset:_,stackedData:ve,layout:G,dataStartIndex:C,dataEndIndex:D}))),{},je(je(je({key:J.key||"item-".concat(ee)},K,Me[K]),B,Me[B]),"animationId",A)),childIndex:mB(J,E.children),item:J})}),V},y=function(E,P){var T=E.props,O=E.dataStartIndex,_=E.dataEndIndex,A=E.updateId;if(!IE({props:T}))return null;var C=T.children,D=T.layout,j=T.stackOffset,G=T.data,z=T.reverseStackOrder,$=ik(D),R=$.numericAxisName,X=$.cateAxisName,K=sn(C,n),B=P5(G,K,"".concat(R,"Id"),"".concat(X,"Id"),j,z),I=c.reduce(function(W,te){var we="".concat(te.axisType,"Map");return ae(ae({},W),{},je({},we,D7(T,ae(ae({},te),{},{graphicalItems:K,stackGroups:te.axisType===R&&B,dataStartIndex:O,dataEndIndex:_}))))},{}),V=N7(ae(ae({},I),{},{props:T,graphicalItems:K}),P==null?void 0:P.legendBBox);Object.keys(I).forEach(function(W){I[W]=p(T,I[W],V,W.replace("Map",""),r)});var J=I["".concat(X,"Map")],ee=j7(J),L=g(T,ae(ae({},I),{},{dataStartIndex:O,dataEndIndex:_,updateId:A,graphicalItems:K,stackGroups:B,offset:V}));return ae(ae({formattedGraphicalItems:L,graphicalItems:K,offset:V,stackGroups:B},ee),I)},S=(function(b){function E(P){var T,O,_;return v7(this,E),_=y7(this,E,[P]),je(_,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),je(_,"accessibilityManager",new t7),je(_,"handleLegendBBoxUpdate",function(A){if(A){var C=_.state,D=C.dataStartIndex,j=C.dataEndIndex,G=C.updateId;_.setState(ae({legendBBox:A},y({props:_.props,dataStartIndex:D,dataEndIndex:j,updateId:G},ae(ae({},_.state),{},{legendBBox:A}))))}}),je(_,"handleReceiveSyncEvent",function(A,C,D){if(_.props.syncId===A){if(D===_.eventEmitterSymbol&&typeof _.props.syncMethod!="function")return;_.applySyncEvent(C)}}),je(_,"handleBrushChange",function(A){var C=A.startIndex,D=A.endIndex;if(C!==_.state.dataStartIndex||D!==_.state.dataEndIndex){var j=_.state.updateId;_.setState(function(){return ae({dataStartIndex:C,dataEndIndex:D},y({props:_.props,dataStartIndex:C,dataEndIndex:D,updateId:j},_.state))}),_.triggerSyncEvent({dataStartIndex:C,dataEndIndex:D})}}),je(_,"handleMouseEnter",function(A){var C=_.getMouseInfo(A);if(C){var D=ae(ae({},C),{},{isTooltipActive:!0});_.setState(D),_.triggerSyncEvent(D);var j=_.props.onMouseEnter;ze(j)&&j(D,A)}}),je(_,"triggeredAfterMouseMove",function(A){var C=_.getMouseInfo(A),D=C?ae(ae({},C),{},{isTooltipActive:!0}):{isTooltipActive:!1};_.setState(D),_.triggerSyncEvent(D);var j=_.props.onMouseMove;ze(j)&&j(D,A)}),je(_,"handleItemMouseEnter",function(A){_.setState(function(){return{isTooltipActive:!0,activeItem:A,activePayload:A.tooltipPayload,activeCoordinate:A.tooltipPosition||{x:A.cx,y:A.cy}}})}),je(_,"handleItemMouseLeave",function(){_.setState(function(){return{isTooltipActive:!1}})}),je(_,"handleMouseMove",function(A){A.persist(),_.throttleTriggeredAfterMouseMove(A)}),je(_,"handleMouseLeave",function(A){_.throttleTriggeredAfterMouseMove.cancel();var C={isTooltipActive:!1};_.setState(C),_.triggerSyncEvent(C);var D=_.props.onMouseLeave;ze(D)&&D(C,A)}),je(_,"handleOuterEvent",function(A){var C=gB(A),D=$r(_.props,"".concat(C));if(C&&ze(D)){var j,G;/.*touch.*/i.test(C)?G=_.getMouseInfo(A.changedTouches[0]):G=_.getMouseInfo(A),D((j=G)!==null&&j!==void 0?j:{},A)}}),je(_,"handleClick",function(A){var C=_.getMouseInfo(A);if(C){var D=ae(ae({},C),{},{isTooltipActive:!0});_.setState(D),_.triggerSyncEvent(D);var j=_.props.onClick;ze(j)&&j(D,A)}}),je(_,"handleMouseDown",function(A){var C=_.props.onMouseDown;if(ze(C)){var D=_.getMouseInfo(A);C(D,A)}}),je(_,"handleMouseUp",function(A){var C=_.props.onMouseUp;if(ze(C)){var D=_.getMouseInfo(A);C(D,A)}}),je(_,"handleTouchMove",function(A){A.changedTouches!=null&&A.changedTouches.length>0&&_.throttleTriggeredAfterMouseMove(A.changedTouches[0])}),je(_,"handleTouchStart",function(A){A.changedTouches!=null&&A.changedTouches.length>0&&_.handleMouseDown(A.changedTouches[0])}),je(_,"handleTouchEnd",function(A){A.changedTouches!=null&&A.changedTouches.length>0&&_.handleMouseUp(A.changedTouches[0])}),je(_,"handleDoubleClick",function(A){var C=_.props.onDoubleClick;if(ze(C)){var D=_.getMouseInfo(A);C(D,A)}}),je(_,"handleContextMenu",function(A){var C=_.props.onContextMenu;if(ze(C)){var D=_.getMouseInfo(A);C(D,A)}}),je(_,"triggerSyncEvent",function(A){_.props.syncId!==void 0&&Hy.emit(Vy,_.props.syncId,A,_.eventEmitterSymbol)}),je(_,"applySyncEvent",function(A){var C=_.props,D=C.layout,j=C.syncMethod,G=_.state.updateId,z=A.dataStartIndex,$=A.dataEndIndex;if(A.dataStartIndex!==void 0||A.dataEndIndex!==void 0)_.setState(ae({dataStartIndex:z,dataEndIndex:$},y({props:_.props,dataStartIndex:z,dataEndIndex:$,updateId:G},_.state)));else if(A.activeTooltipIndex!==void 0){var R=A.chartX,X=A.chartY,K=A.activeTooltipIndex,B=_.state,I=B.offset,V=B.tooltipTicks;if(!I)return;if(typeof j=="function")K=j(V,A);else if(j==="value"){K=-1;for(var J=0;J<V.length;J++)if(V[J].value===A.activeLabel){K=J;break}}var ee=ae(ae({},I),{},{x:I.left,y:I.top}),L=Math.min(R,ee.x+ee.width),W=Math.min(X,ee.y+ee.height),te=V[K]&&V[K].value,we=Fb(_.state,_.props.data,K),xe=V[K]?{x:D==="horizontal"?V[K].coordinate:L,y:D==="horizontal"?W:V[K].coordinate}:$j;_.setState(ae(ae({},A),{},{activeLabel:te,activeCoordinate:xe,activePayload:we,activeTooltipIndex:K}))}else _.setState(A)}),je(_,"renderCursor",function(A){var C,D=_.state,j=D.isTooltipActive,G=D.activeCoordinate,z=D.activePayload,$=D.offset,R=D.activeTooltipIndex,X=D.tooltipAxisBandSize,K=_.getTooltipEventType(),B=(C=A.props.active)!==null&&C!==void 0?C:j,I=_.props.layout,V=A.key||"_recharts-cursor";return Q.createElement(u7,{key:V,activeCoordinate:G,activePayload:z,activeTooltipIndex:R,chartName:r,element:A,isActive:B,layout:I,offset:$,tooltipAxisBandSize:X,tooltipEventType:K})}),je(_,"renderPolarAxis",function(A,C,D){var j=$r(A,"type.axisType"),G=$r(_.state,"".concat(j,"Map")),z=A.type.defaultProps,$=z!==void 0?ae(ae({},z),A.props):A.props,R=G&&G[$["".concat(j,"Id")]];return N.cloneElement(A,ae(ae({},R),{},{className:He(j,R.className),key:A.key||"".concat(C,"-").concat(D),ticks:ma(R,!0)}))}),je(_,"renderPolarGrid",function(A){var C=A.props,D=C.radialLines,j=C.polarAngles,G=C.polarRadius,z=_.state,$=z.radiusAxisMap,R=z.angleAxisMap,X=go($),K=go(R),B=K.cx,I=K.cy,V=K.innerRadius,J=K.outerRadius;return N.cloneElement(A,{polarAngles:Array.isArray(j)?j:ma(K,!0).map(function(ee){return ee.coordinate}),polarRadius:Array.isArray(G)?G:ma(X,!0).map(function(ee){return ee.coordinate}),cx:B,cy:I,innerRadius:V,outerRadius:J,key:A.key||"polar-grid",radialLines:D})}),je(_,"renderLegend",function(){var A=_.state.formattedGraphicalItems,C=_.props,D=C.children,j=C.width,G=C.height,z=_.props.margin||{},$=j-(z.left||0)-(z.right||0),R=N2({children:D,formattedGraphicalItems:A,legendWidth:$,legendContent:f});if(!R)return null;var X=R.item,K=ek(R,l7);return N.cloneElement(X,ae(ae({},K),{},{chartWidth:j,chartHeight:G,margin:z,onBBoxUpdate:_.handleLegendBBoxUpdate}))}),je(_,"renderTooltip",function(){var A,C=_.props,D=C.children,j=C.accessibilityLayer,G=xr(D,tn);if(!G)return null;var z=_.state,$=z.isTooltipActive,R=z.activeCoordinate,X=z.activePayload,K=z.activeLabel,B=z.offset,I=(A=G.props.active)!==null&&A!==void 0?A:$;return N.cloneElement(G,{viewBox:ae(ae({},B),{},{x:B.left,y:B.top}),active:I,label:K,payload:I?X:[],coordinate:R,accessibilityLayer:j})}),je(_,"renderBrush",function(A){var C=_.props,D=C.margin,j=C.data,G=_.state,z=G.offset,$=G.dataStartIndex,R=G.dataEndIndex,X=G.updateId;return N.cloneElement(A,{key:A.key||"_recharts-brush",onChange:Zc(_.handleBrushChange,A.props.onChange),data:j,x:me(A.props.x)?A.props.x:z.left,y:me(A.props.y)?A.props.y:z.top+z.height+z.brushBottom-(D.bottom||0),width:me(A.props.width)?A.props.width:z.width,startIndex:$,endIndex:R,updateId:"brush-".concat(X)})}),je(_,"renderReferenceElement",function(A,C,D){if(!A)return null;var j=_,G=j.clipPathId,z=_.state,$=z.xAxisMap,R=z.yAxisMap,X=z.offset,K=A.type.defaultProps||{},B=A.props,I=B.xAxisId,V=I===void 0?K.xAxisId:I,J=B.yAxisId,ee=J===void 0?K.yAxisId:J;return N.cloneElement(A,{key:A.key||"".concat(C,"-").concat(D),xAxis:$[V],yAxis:R[ee],viewBox:{x:X.left,y:X.top,width:X.width,height:X.height},clipPathId:G})}),je(_,"renderActivePoints",function(A){var C=A.item,D=A.activePoint,j=A.basePoint,G=A.childIndex,z=A.isRange,$=[],R=C.props.key,X=C.item.type.defaultProps!==void 0?ae(ae({},C.item.type.defaultProps),C.item.props):C.item.props,K=X.activeDot,B=X.dataKey,I=ae(ae({index:G,dataKey:B,cx:D.x,cy:D.y,r:4,fill:Yw(C.item),strokeWidth:2,stroke:"#fff",payload:D.payload,value:D.value},Ye(K,!1)),gf(K));return $.push(E.renderActiveDot(K,I,"".concat(R,"-activePoint-").concat(G))),j?$.push(E.renderActiveDot(K,ae(ae({},I),{},{cx:j.x,cy:j.y}),"".concat(R,"-basePoint-").concat(G))):z&&$.push(null),$}),je(_,"renderGraphicChild",function(A,C,D){var j=_.filterFormatItem(A,C,D);if(!j)return null;var G=_.getTooltipEventType(),z=_.state,$=z.isTooltipActive,R=z.tooltipAxis,X=z.activeTooltipIndex,K=z.activeLabel,B=_.props.children,I=xr(B,tn),V=j.props,J=V.points,ee=V.isRange,L=V.baseLine,W=j.item.type.defaultProps!==void 0?ae(ae({},j.item.type.defaultProps),j.item.props):j.item.props,te=W.activeDot,we=W.hide,xe=W.activeBar,Ie=W.activeShape,Le=!!(!we&&$&&I&&(te||xe||Ie)),Me={};G!=="axis"&&I&&I.props.trigger==="click"?Me={onClick:Zc(_.handleItemMouseEnter,A.props.onClick)}:G!=="axis"&&(Me={onMouseLeave:Zc(_.handleItemMouseLeave,A.props.onMouseLeave),onMouseEnter:Zc(_.handleItemMouseEnter,A.props.onMouseEnter)});var le=N.cloneElement(A,ae(ae({},j.props),Me));function pe(Dt){return typeof R.dataKey=="function"?R.dataKey(Dt.payload):null}if(Le)if(X>=0){var ve,ie;if(R.dataKey&&!R.allowDuplicatedCategory){var Fe=typeof R.dataKey=="function"?pe:"payload.".concat(R.dataKey.toString());ve=O0(J,Fe,K),ie=ee&&L&&O0(L,Fe,K)}else ve=J==null?void 0:J[X],ie=ee&&L&&L[X];if(Ie||xe){var de=A.props.activeIndex!==void 0?A.props.activeIndex:X;return[N.cloneElement(A,ae(ae(ae({},j.props),Me),{},{activeIndex:de})),null,null]}if(!Ve(ve))return[le].concat(is(_.renderActivePoints({item:j,activePoint:ve,basePoint:ie,childIndex:X,isRange:ee})))}else{var ge,ne=(ge=_.getItemByXY(_.state.activeCoordinate))!==null&&ge!==void 0?ge:{graphicalItem:le},it=ne.graphicalItem,kt=it.item,Rt=kt===void 0?A:kt,Bt=it.childIndex,rt=ae(ae(ae({},j.props),Me),{},{activeIndex:Bt});return[N.cloneElement(Rt,rt),null,null]}return ee?[le,null,null]:[le,null]}),je(_,"renderCustomized",function(A,C,D){return N.cloneElement(A,ae(ae({key:"recharts-customized-".concat(D)},_.props),_.state))}),je(_,"renderMap",{CartesianGrid:{handler:nf,once:!0},ReferenceArea:{handler:_.renderReferenceElement},ReferenceLine:{handler:nf},ReferenceDot:{handler:_.renderReferenceElement},XAxis:{handler:nf},YAxis:{handler:nf},Brush:{handler:_.renderBrush,once:!0},Bar:{handler:_.renderGraphicChild},Line:{handler:_.renderGraphicChild},Area:{handler:_.renderGraphicChild},Radar:{handler:_.renderGraphicChild},RadialBar:{handler:_.renderGraphicChild},Scatter:{handler:_.renderGraphicChild},Pie:{handler:_.renderGraphicChild},Funnel:{handler:_.renderGraphicChild},Tooltip:{handler:_.renderCursor,once:!0},PolarGrid:{handler:_.renderPolarGrid,once:!0},PolarAngleAxis:{handler:_.renderPolarAxis},PolarRadiusAxis:{handler:_.renderPolarAxis},Customized:{handler:_.renderCustomized}}),_.clipPathId="".concat((T=P.id)!==null&&T!==void 0?T:xd("recharts"),"-clip"),_.throttleTriggeredAfterMouseMove=ND(_.triggeredAfterMouseMove,(O=P.throttleDelay)!==null&&O!==void 0?O:1e3/60),_.state={},_}return x7(E,b),m7(E,[{key:"componentDidMount",value:function(){var T,O;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(T=this.props.margin.left)!==null&&T!==void 0?T:0,top:(O=this.props.margin.top)!==null&&O!==void 0?O:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var T=this.props,O=T.children,_=T.data,A=T.height,C=T.layout,D=xr(O,tn);if(D){var j=D.props.defaultIndex;if(!(typeof j!="number"||j<0||j>this.state.tooltipTicks.length-1)){var G=this.state.tooltipTicks[j]&&this.state.tooltipTicks[j].value,z=Fb(this.state,_,j,G),$=this.state.tooltipTicks[j].coordinate,R=(this.state.offset.top+A)/2,X=C==="horizontal",K=X?{x:$,y:R}:{y:$,x:R},B=this.state.formattedGraphicalItems.find(function(V){var J=V.item;return J.type.name==="Scatter"});B&&(K=ae(ae({},K),B.props.points[j].tooltipPosition),z=B.props.points[j].tooltipPayload);var I={activeTooltipIndex:j,isTooltipActive:!0,activeLabel:G,activePayload:z,activeCoordinate:K};this.setState(I),this.renderCursor(D),this.accessibilityManager.setIndex(j)}}}},{key:"getSnapshotBeforeUpdate",value:function(T,O){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==O.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==T.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==T.margin){var _,A;this.accessibilityManager.setDetails({offset:{left:(_=this.props.margin.left)!==null&&_!==void 0?_:0,top:(A=this.props.margin.top)!==null&&A!==void 0?A:0}})}return null}},{key:"componentDidUpdate",value:function(T){P0([xr(T.children,tn)],[xr(this.props.children,tn)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var T=xr(this.props.children,tn);if(T&&typeof T.props.shared=="boolean"){var O=T.props.shared?"axis":"item";return l.indexOf(O)>=0?O:a}return a}},{key:"getMouseInfo",value:function(T){if(!this.container)return null;var O=this.container,_=O.getBoundingClientRect(),A=n3(_),C={chartX:Math.round(T.pageX-A.left),chartY:Math.round(T.pageY-A.top)},D=_.width/O.offsetWidth||1,j=this.inRange(C.chartX,C.chartY,D);if(!j)return null;var G=this.state,z=G.xAxisMap,$=G.yAxisMap,R=this.getTooltipEventType(),X=rk(this.state,this.props.data,this.props.layout,j);if(R!=="axis"&&z&&$){var K=go(z).scale,B=go($).scale,I=K&&K.invert?K.invert(C.chartX):null,V=B&&B.invert?B.invert(C.chartY):null;return ae(ae({},C),{},{xValue:I,yValue:V},X)}return X?ae(ae({},C),X):null}},{key:"inRange",value:function(T,O){var _=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,A=this.props.layout,C=T/_,D=O/_;if(A==="horizontal"||A==="vertical"){var j=this.state.offset,G=C>=j.left&&C<=j.left+j.width&&D>=j.top&&D<=j.top+j.height;return G?{x:C,y:D}:null}var z=this.state,$=z.angleAxisMap,R=z.radiusAxisMap;if($&&R){var X=go($);return _T({x:C,y:D},X)}return null}},{key:"parseEventsOfWrapper",value:function(){var T=this.props.children,O=this.getTooltipEventType(),_=xr(T,tn),A={};_&&O==="axis"&&(_.props.trigger==="click"?A={onClick:this.handleClick}:A={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var C=gf(this.props,this.handleOuterEvent);return ae(ae({},C),A)}},{key:"addListener",value:function(){Hy.on(Vy,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){Hy.removeListener(Vy,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(T,O,_){for(var A=this.state.formattedGraphicalItems,C=0,D=A.length;C<D;C++){var j=A[C];if(j.item===T||j.props.key===T.key||O===Qn(j.item.type)&&_===j.childIndex)return j}return null}},{key:"renderClipPath",value:function(){var T=this.clipPathId,O=this.state.offset,_=O.left,A=O.top,C=O.height,D=O.width;return Q.createElement("defs",null,Q.createElement("clipPath",{id:T},Q.createElement("rect",{x:_,y:A,height:C,width:D})))}},{key:"getXScales",value:function(){var T=this.state.xAxisMap;return T?Object.entries(T).reduce(function(O,_){var A=JC(_,2),C=A[0],D=A[1];return ae(ae({},O),{},je({},C,D.scale))},{}):null}},{key:"getYScales",value:function(){var T=this.state.yAxisMap;return T?Object.entries(T).reduce(function(O,_){var A=JC(_,2),C=A[0],D=A[1];return ae(ae({},O),{},je({},C,D.scale))},{}):null}},{key:"getXScaleByAxisId",value:function(T){var O;return(O=this.state.xAxisMap)===null||O===void 0||(O=O[T])===null||O===void 0?void 0:O.scale}},{key:"getYScaleByAxisId",value:function(T){var O;return(O=this.state.yAxisMap)===null||O===void 0||(O=O[T])===null||O===void 0?void 0:O.scale}},{key:"getItemByXY",value:function(T){var O=this.state,_=O.formattedGraphicalItems,A=O.activeItem;if(_&&_.length)for(var C=0,D=_.length;C<D;C++){var j=_[C],G=j.props,z=j.item,$=z.type.defaultProps!==void 0?ae(ae({},z.type.defaultProps),z.props):z.props,R=Qn(z.type);if(R==="Bar"){var X=(G.data||[]).find(function(V){return EH(T,V)});if(X)return{graphicalItem:j,payload:X}}else if(R==="RadialBar"){var K=(G.data||[]).find(function(V){return _T(T,V)});if(K)return{graphicalItem:j,payload:K}}else if(Bd(j,A)||Gd(j,A)||sl(j,A)){var B=p9({graphicalItem:j,activeTooltipItem:A,itemData:$.data}),I=$.activeIndex===void 0?B:$.activeIndex;return{graphicalItem:ae(ae({},j),{},{childIndex:I}),payload:sl(j,A)?$.data[B]:j.props.data[B]}}}return null}},{key:"render",value:function(){var T=this;if(!IE(this))return null;var O=this.props,_=O.children,A=O.className,C=O.width,D=O.height,j=O.style,G=O.compact,z=O.title,$=O.desc,R=ek(O,c7),X=Ye(R,!1);if(G)return Q.createElement(FC,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},Q.createElement(C0,bo({},X,{width:C,height:D,title:z,desc:$}),this.renderClipPath(),ME(_,this.renderMap)));if(this.props.accessibilityLayer){var K,B;X.tabIndex=(K=this.props.tabIndex)!==null&&K!==void 0?K:0,X.role=(B=this.props.role)!==null&&B!==void 0?B:"application",X.onKeyDown=function(V){T.accessibilityManager.keyboardEvent(V)},X.onFocus=function(){T.accessibilityManager.focus()}}var I=this.parseEventsOfWrapper();return Q.createElement(FC,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},Q.createElement("div",bo({className:He("recharts-wrapper",A),style:ae({position:"relative",cursor:"default",width:C,height:D},j)},I,{ref:function(J){T.container=J}}),Q.createElement(C0,bo({},X,{width:C,height:D,title:z,desc:$,style:P7}),this.renderClipPath(),ME(_,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])})(N.Component);je(S,"displayName",r),je(S,"defaultProps",ae({layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:"index"},h)),je(S,"getDerivedStateFromProps",function(b,E){var P=b.dataKey,T=b.data,O=b.children,_=b.width,A=b.height,C=b.layout,D=b.stackOffset,j=b.margin,G=E.dataStartIndex,z=E.dataEndIndex;if(E.updateId===void 0){var $=nk(b);return ae(ae(ae({},$),{},{updateId:0},y(ae(ae({props:b},$),{},{updateId:0}),E)),{},{prevDataKey:P,prevData:T,prevWidth:_,prevHeight:A,prevLayout:C,prevStackOffset:D,prevMargin:j,prevChildren:O})}if(P!==E.prevDataKey||T!==E.prevData||_!==E.prevWidth||A!==E.prevHeight||C!==E.prevLayout||D!==E.prevStackOffset||!wo(j,E.prevMargin)){var R=nk(b),X={chartX:E.chartX,chartY:E.chartY,isTooltipActive:E.isTooltipActive},K=ae(ae({},rk(E,T,C)),{},{updateId:E.updateId+1}),B=ae(ae(ae({},R),X),K);return ae(ae(ae({},B),y(ae({props:b},B),E)),{},{prevDataKey:P,prevData:T,prevWidth:_,prevHeight:A,prevLayout:C,prevStackOffset:D,prevMargin:j,prevChildren:O})}if(!P0(O,E.prevChildren)){var I,V,J,ee,L=xr(O,Xo),W=L&&(I=(V=L.props)===null||V===void 0?void 0:V.startIndex)!==null&&I!==void 0?I:G,te=L&&(J=(ee=L.props)===null||ee===void 0?void 0:ee.endIndex)!==null&&J!==void 0?J:z,we=W!==G||te!==z,xe=!Ve(T),Ie=xe&&!we?E.updateId:E.updateId+1;return ae(ae({updateId:Ie},y(ae(ae({props:b},E),{},{updateId:Ie,dataStartIndex:W,dataEndIndex:te}),E)),{},{prevChildren:O,dataStartIndex:W,dataEndIndex:te})}return null}),je(S,"renderActiveDot",function(b,E,P){var T;return N.isValidElement(b)?T=N.cloneElement(b,E):ze(b)?T=b(E):T=Q.createElement(Q2,E),Q.createElement($t,{className:"recharts-active-dot",key:P},T)});var w=N.forwardRef(function(E,P){return Q.createElement(S,bo({},E,{ref:P}))});return w.displayName=S.displayName,w},ak=L7({chartName:"BarChart",GraphicalChild:Jn,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:dl},{axisType:"yAxis",AxisComp:hl}],formatAxisMap:fV});function $7(){var f,p;const t=Lo(h=>h.workspace);console.log("[Dashboard] render workspace=",t);const{data:e,error:r,isLoading:n}=Ra({queryKey:["status"],queryFn:IR}),{data:i,error:a,isLoading:s}=Ra({queryKey:["telemetry",t],queryFn:()=>lF(t)});n&&console.log("[Dashboard] status loading..."),r&&console.error("[Dashboard] status error:",r),e&&console.log("[Dashboard] status:",e),s&&console.log("[Dashboard] telemetry loading..."),a&&console.error("[Dashboard] telemetry error:",a),i&&console.log("[Dashboard] telemetry:",i);const l=i!=null&&i.banditStats?Object.entries(i.banditStats).map(([h,g])=>(console.log("[Dashboard] bandit variant:",h,g),{variant:h,success:g.success,failure:g.failure})):[];console.log("[Dashboard] banditData:",l.length,"variants");const c=i!=null&&i.preferenceWeights?Object.entries(i.preferenceWeights).map(([h,g])=>(console.log("[Dashboard] preference:",h,"=",g),{category:h,weight:g})):[];return console.log("[Dashboard] weightData:",c.length,"categories"),H.jsxs("div",{className:"space-y-6",children:[H.jsxs("div",{children:[H.jsx("h1",{className:"text-2xl font-semibold",children:"System Dashboard"}),H.jsx("p",{className:"mt-1 text-sm text-[#8888a0]",children:"Live view of nano-brain health, indexing, and learning telemetry."})]}),H.jsxs("div",{className:"grid-cards",children:[H.jsxs("div",{className:"card p-4",children:[H.jsx("p",{className:"text-xs uppercase text-[#8888a0]",children:"Version"}),H.jsx("p",{className:"mt-2 text-2xl font-semibold",children:(e==null?void 0:e.version)??"—"})]}),H.jsxs("div",{className:"card p-4",children:[H.jsx("p",{className:"text-xs uppercase text-[#8888a0]",children:"Uptime"}),H.jsx("p",{className:"mt-2 text-2xl font-semibold",children:e?`${Math.floor(e.uptime/60)}m`:"—"})]}),H.jsxs("div",{className:"card p-4",children:[H.jsx("p",{className:"text-xs uppercase text-[#8888a0]",children:"Documents"}),H.jsx("p",{className:"mt-2 text-2xl font-semibold",children:(e==null?void 0:e.documents)??"—"})]}),H.jsxs("div",{className:"card p-4",children:[H.jsx("p",{className:"text-xs uppercase text-[#8888a0]",children:"Embeddings"}),H.jsx("p",{className:"mt-2 text-2xl font-semibold",children:(e==null?void 0:e.embeddings)??"—"})]})]}),H.jsxs("div",{className:"grid-dense",children:[H.jsxs("div",{className:"card col-span-7 p-4",children:[H.jsxs("div",{className:"flex items-center justify-between",children:[H.jsxs("div",{children:[H.jsx("h2",{className:"text-lg font-semibold",children:"Bandit Stats"}),H.jsx("p",{className:"text-xs text-[#8888a0]",children:"Success vs failure per variant."})]}),H.jsx("span",{className:"text-xs text-[#8888a0]",children:s?"loading":`${l.length} variants`})]}),H.jsx("div",{className:"mt-4 h-64",children:H.jsx(iP,{width:"100%",height:"100%",children:H.jsxs(ak,{data:l,margin:{top:10,right:10,left:-10,bottom:10},children:[H.jsx(dl,{dataKey:"variant",stroke:"#8888a0",fontSize:12}),H.jsx(hl,{stroke:"#8888a0",fontSize:12}),H.jsx(tn,{contentStyle:{background:"#111118",border:"1px solid #1f1f2c"}}),H.jsx(Jn,{dataKey:"success",stackId:"a",fill:"#3b82f6",radius:[6,6,0,0]}),H.jsx(Jn,{dataKey:"failure",stackId:"a",fill:"#f97316",radius:[6,6,0,0]})]})})})]}),H.jsxs("div",{className:"card col-span-5 p-4",children:[H.jsx("h2",{className:"text-lg font-semibold",children:"Expand Rate"}),H.jsx("p",{className:"text-xs text-[#8888a0]",children:"Queries that expanded into memory graph."}),H.jsxs("div",{className:"mt-6 flex items-end gap-3",children:[H.jsx("p",{className:"text-5xl font-semibold",children:i?`${Math.round(i.expandRate*100)}%`:"—"}),H.jsx("span",{className:"text-xs text-emerald-400",children:"+2.4% vs last window"})]}),H.jsxs("div",{className:"mt-6",children:[H.jsx("p",{className:"text-xs uppercase text-[#8888a0]",children:"Query volume"}),H.jsx("p",{className:"mt-1 text-xl font-semibold",children:(i==null?void 0:i.queryCount)??"—"})]}),H.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-3 text-xs text-[#8888a0]",children:[H.jsxs("div",{children:[H.jsx("p",{children:"Importance mean"}),H.jsx("p",{className:"text-sm text-[#e4e4ed]",children:((f=i==null?void 0:i.importanceStats.mean)==null?void 0:f.toFixed(2))??"—"})]}),H.jsxs("div",{children:[H.jsx("p",{children:"Importance median"}),H.jsx("p",{className:"text-sm text-[#e4e4ed]",children:((p=i==null?void 0:i.importanceStats.median)==null?void 0:p.toFixed(2))??"—"})]})]})]})]}),H.jsxs("div",{className:"card p-4",children:[H.jsxs("div",{className:"flex items-center justify-between",children:[H.jsxs("div",{children:[H.jsx("h2",{className:"text-lg font-semibold",children:"Preference Weights"}),H.jsx("p",{className:"text-xs text-[#8888a0]",children:"Current category weighting in ranking model."})]}),H.jsxs("span",{className:"text-xs text-[#8888a0]",children:[c.length," categories"]})]}),H.jsx("div",{className:"mt-4 h-64",children:H.jsx(iP,{width:"100%",height:"100%",children:H.jsxs(ak,{data:c,layout:"vertical",margin:{top:10,right:10,left:60,bottom:10},children:[H.jsx(dl,{type:"number",stroke:"#8888a0",fontSize:12}),H.jsx(hl,{dataKey:"category",type:"category",stroke:"#8888a0",fontSize:12,width:120}),H.jsx(tn,{contentStyle:{background:"#111118",border:"1px solid #1f1f2c"}}),H.jsx(Jn,{dataKey:"weight",fill:"#8b5cf6",radius:[0,6,6,0]})]})})})]})]})}var af={exports:{}},ok;function F7(){if(ok)return af.exports;ok=1;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(_,A,C){return Function.prototype.apply.call(_,A,C)},r;t&&typeof t.ownKeys=="function"?r=t.ownKeys:Object.getOwnPropertySymbols?r=function(_){return Object.getOwnPropertyNames(_).concat(Object.getOwnPropertySymbols(_))}:r=function(_){return Object.getOwnPropertyNames(_)};function n(O){console&&console.warn&&console.warn(O)}var i=Number.isNaN||function(_){return _!==_};function a(){a.init.call(this)}af.exports=a,af.exports.once=E,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var s=10;function l(O){if(typeof O!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof O)}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(O){if(typeof O!="number"||O<0||i(O))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+O+".");s=O}}),a.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(_){if(typeof _!="number"||_<0||i(_))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+_+".");return this._maxListeners=_,this};function c(O){return O._maxListeners===void 0?a.defaultMaxListeners:O._maxListeners}a.prototype.getMaxListeners=function(){return c(this)},a.prototype.emit=function(_){for(var A=[],C=1;C<arguments.length;C++)A.push(arguments[C]);var D=_==="error",j=this._events;if(j!==void 0)D=D&&j.error===void 0;else if(!D)return!1;if(D){var G;if(A.length>0&&(G=A[0]),G instanceof Error)throw G;var z=new Error("Unhandled error."+(G?" ("+G.message+")":""));throw z.context=G,z}var $=j[_];if($===void 0)return!1;if(typeof $=="function")e($,this,A);else for(var R=$.length,X=S($,R),C=0;C<R;++C)e(X[C],this,A);return!0};function f(O,_,A,C){var D,j,G;if(l(A),j=O._events,j===void 0?(j=O._events=Object.create(null),O._eventsCount=0):(j.newListener!==void 0&&(O.emit("newListener",_,A.listener?A.listener:A),j=O._events),G=j[_]),G===void 0)G=j[_]=A,++O._eventsCount;else if(typeof G=="function"?G=j[_]=C?[A,G]:[G,A]:C?G.unshift(A):G.push(A),D=c(O),D>0&&G.length>D&&!G.warned){G.warned=!0;var z=new Error("Possible EventEmitter memory leak detected. "+G.length+" "+String(_)+" listeners added. Use emitter.setMaxListeners() to increase limit");z.name="MaxListenersExceededWarning",z.emitter=O,z.type=_,z.count=G.length,n(z)}return O}a.prototype.addListener=function(_,A){return f(this,_,A,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(_,A){return f(this,_,A,!0)};function p(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(O,_,A){var C={fired:!1,wrapFn:void 0,target:O,type:_,listener:A},D=p.bind(C);return D.listener=A,C.wrapFn=D,D}a.prototype.once=function(_,A){return l(A),this.on(_,h(this,_,A)),this},a.prototype.prependOnceListener=function(_,A){return l(A),this.prependListener(_,h(this,_,A)),this},a.prototype.removeListener=function(_,A){var C,D,j,G,z;if(l(A),D=this._events,D===void 0)return this;if(C=D[_],C===void 0)return this;if(C===A||C.listener===A)--this._eventsCount===0?this._events=Object.create(null):(delete D[_],D.removeListener&&this.emit("removeListener",_,C.listener||A));else if(typeof C!="function"){for(j=-1,G=C.length-1;G>=0;G--)if(C[G]===A||C[G].listener===A){z=C[G].listener,j=G;break}if(j<0)return this;j===0?C.shift():w(C,j),C.length===1&&(D[_]=C[0]),D.removeListener!==void 0&&this.emit("removeListener",_,z||A)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(_){var A,C,D;if(C=this._events,C===void 0)return this;if(C.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):C[_]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete C[_]),this;if(arguments.length===0){var j=Object.keys(C),G;for(D=0;D<j.length;++D)G=j[D],G!=="removeListener"&&this.removeAllListeners(G);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(A=C[_],typeof A=="function")this.removeListener(_,A);else if(A!==void 0)for(D=A.length-1;D>=0;D--)this.removeListener(_,A[D]);return this};function g(O,_,A){var C=O._events;if(C===void 0)return[];var D=C[_];return D===void 0?[]:typeof D=="function"?A?[D.listener||D]:[D]:A?b(D):S(D,D.length)}a.prototype.listeners=function(_){return g(this,_,!0)},a.prototype.rawListeners=function(_){return g(this,_,!1)},a.listenerCount=function(O,_){return typeof O.listenerCount=="function"?O.listenerCount(_):y.call(O,_)},a.prototype.listenerCount=y;function y(O){var _=this._events;if(_!==void 0){var A=_[O];if(typeof A=="function")return 1;if(A!==void 0)return A.length}return 0}a.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]};function S(O,_){for(var A=new Array(_),C=0;C<_;++C)A[C]=O[C];return A}function w(O,_){for(;_+1<O.length;_++)O[_]=O[_+1];O.pop()}function b(O){for(var _=new Array(O.length),A=0;A<_.length;++A)_[A]=O[A].listener||O[A];return _}function E(O,_){return new Promise(function(A,C){function D(G){O.removeListener(_,j),C(G)}function j(){typeof O.removeListener=="function"&&O.removeListener("error",D),A([].slice.call(arguments))}T(O,_,j,{once:!0}),_!=="error"&&P(O,D,{once:!0})})}function P(O,_,A){typeof O.on=="function"&&T(O,"error",_,A)}function T(O,_,A,C){if(typeof O.on=="function")C.once?O.once(_,A):O.on(_,A);else if(typeof O.addEventListener=="function")O.addEventListener(_,function D(j){C.once&&O.removeEventListener(_,D),A(j)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof O)}return af.exports}var Bj=F7();function B7(){const t=arguments[0];for(let e=1,r=arguments.length;e<r;e++)if(arguments[e])for(const n in arguments[e])t[n]=arguments[e][n];return t}let Pt=B7;typeof Object.assign=="function"&&(Pt=Object.assign);function Fr(t,e,r,n){const i=t._nodes.get(e);let a=null;return i&&(n==="mixed"?a=i.out&&i.out[r]||i.undirected&&i.undirected[r]:n==="directed"?a=i.out&&i.out[r]:a=i.undirected&&i.undirected[r]),a}function Wt(t){return typeof t=="object"&&t!==null}function Gj(t){let e;for(e in t)return!1;return!0}function Ir(t,e,r){Object.defineProperty(t,e,{enumerable:!1,configurable:!1,writable:!0,value:r})}function Zr(t,e,r){const n={enumerable:!0,configurable:!0};typeof r=="function"?n.get=r:(n.value=r,n.writable=!1),Object.defineProperty(t,e,n)}function sk(t){return!(!Wt(t)||t.attributes&&!Array.isArray(t.attributes))}function G7(){let t=Math.floor(Math.random()*256)&255;return()=>t++}function ei(){const t=arguments;let e=null,r=-1;return{[Symbol.iterator](){return this},next(){let n=null;do{if(e===null){if(r++,r>=t.length)return{done:!0};e=t[r][Symbol.iterator]()}if(n=e.next(),n.done){e=null;continue}break}while(!0);return n}}}function ms(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class rx extends Error{constructor(e){super(),this.name="GraphError",this.message=e}}class ye extends rx{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,ye.prototype.constructor)}}class he extends rx{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,he.prototype.constructor)}}class De extends rx{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,De.prototype.constructor)}}function zj(t,e){this.key=t,this.attributes=e,this.clear()}zj.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function Uj(t,e){this.key=t,this.attributes=e,this.clear()}Uj.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function qj(t,e){this.key=t,this.attributes=e,this.clear()}qj.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function ys(t,e,r,n,i){this.key=e,this.attributes=i,this.undirected=t,this.source=r,this.target=n}ys.prototype.attach=function(){let t="out",e="in";this.undirected&&(t=e="undirected");const r=this.source.key,n=this.target.key;this.source[t][n]=this,!(this.undirected&&r===n)&&(this.target[e][r]=this)};ys.prototype.attachMulti=function(){let t="out",e="in";const r=this.source.key,n=this.target.key;this.undirected&&(t=e="undirected");const i=this.source[t],a=i[n];if(typeof a>"u"){i[n]=this,this.undirected&&r===n||(this.target[e][r]=this);return}a.previous=this,this.next=a,i[n]=this,this.target[e][r]=this};ys.prototype.detach=function(){const t=this.source.key,e=this.target.key;let r="out",n="in";this.undirected&&(r=n="undirected"),delete this.source[r][e],delete this.target[n][t]};ys.prototype.detachMulti=function(){const t=this.source.key,e=this.target.key;let r="out",n="in";this.undirected&&(r=n="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[r][e],delete this.target[n][t]):(this.next.previous=void 0,this.source[r][e]=this.next,this.target[n][t]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const Wj=0,Hj=1,z7=2,Vj=3;function li(t,e,r,n,i,a,s){let l,c,f,p;if(n=""+n,r===Wj){if(l=t._nodes.get(n),!l)throw new he(`Graph.${e}: could not find the "${n}" node in the graph.`);f=i,p=a}else if(r===Vj){if(i=""+i,c=t._edges.get(i),!c)throw new he(`Graph.${e}: could not find the "${i}" edge in the graph.`);const h=c.source.key,g=c.target.key;if(n===h)l=c.target;else if(n===g)l=c.source;else throw new he(`Graph.${e}: the "${n}" node is not attached to the "${i}" edge (${h}, ${g}).`);f=a,p=s}else{if(c=t._edges.get(n),!c)throw new he(`Graph.${e}: could not find the "${n}" edge in the graph.`);r===Hj?l=c.source:l=c.target,f=i,p=a}return[l,f,p]}function U7(t,e,r){t.prototype[e]=function(n,i,a){const[s,l]=li(this,e,r,n,i,a);return s.attributes[l]}}function q7(t,e,r){t.prototype[e]=function(n,i){const[a]=li(this,e,r,n,i);return a.attributes}}function W7(t,e,r){t.prototype[e]=function(n,i,a){const[s,l]=li(this,e,r,n,i,a);return s.attributes.hasOwnProperty(l)}}function H7(t,e,r){t.prototype[e]=function(n,i,a,s){const[l,c,f]=li(this,e,r,n,i,a,s);return l.attributes[c]=f,this.emit("nodeAttributesUpdated",{key:l.key,type:"set",attributes:l.attributes,name:c}),this}}function V7(t,e,r){t.prototype[e]=function(n,i,a,s){const[l,c,f]=li(this,e,r,n,i,a,s);if(typeof f!="function")throw new ye(`Graph.${e}: updater should be a function.`);const p=l.attributes,h=f(p[c]);return p[c]=h,this.emit("nodeAttributesUpdated",{key:l.key,type:"set",attributes:l.attributes,name:c}),this}}function K7(t,e,r){t.prototype[e]=function(n,i,a){const[s,l]=li(this,e,r,n,i,a);return delete s.attributes[l],this.emit("nodeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:l}),this}}function X7(t,e,r){t.prototype[e]=function(n,i,a){const[s,l]=li(this,e,r,n,i,a);if(!Wt(l))throw new ye(`Graph.${e}: provided attributes are not a plain object.`);return s.attributes=l,this.emit("nodeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}function Y7(t,e,r){t.prototype[e]=function(n,i,a){const[s,l]=li(this,e,r,n,i,a);if(!Wt(l))throw new ye(`Graph.${e}: provided attributes are not a plain object.`);return Pt(s.attributes,l),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:l}),this}}function Q7(t,e,r){t.prototype[e]=function(n,i,a){const[s,l]=li(this,e,r,n,i,a);if(typeof l!="function")throw new ye(`Graph.${e}: provided updater is not a function.`);return s.attributes=l(s.attributes),this.emit("nodeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}const Z7=[{name:t=>`get${t}Attribute`,attacher:U7},{name:t=>`get${t}Attributes`,attacher:q7},{name:t=>`has${t}Attribute`,attacher:W7},{name:t=>`set${t}Attribute`,attacher:H7},{name:t=>`update${t}Attribute`,attacher:V7},{name:t=>`remove${t}Attribute`,attacher:K7},{name:t=>`replace${t}Attributes`,attacher:X7},{name:t=>`merge${t}Attributes`,attacher:Y7},{name:t=>`update${t}Attributes`,attacher:Q7}];function J7(t){Z7.forEach(function({name:e,attacher:r}){r(t,e("Node"),Wj),r(t,e("Source"),Hj),r(t,e("Target"),z7),r(t,e("Opposite"),Vj)})}function eX(t,e,r){t.prototype[e]=function(n,i){let a;if(this.type!=="mixed"&&r!=="mixed"&&r!==this.type)throw new De(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new De(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,l=""+i;if(i=arguments[2],a=Fr(this,s,l,r),!a)throw new he(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(r!=="mixed")throw new De(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,a=this._edges.get(n),!a)throw new he(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return a.attributes[i]}}function tX(t,e,r){t.prototype[e]=function(n){let i;if(this.type!=="mixed"&&r!=="mixed"&&r!==this.type)throw new De(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new De(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+n,s=""+arguments[1];if(i=Fr(this,a,s,r),!i)throw new he(`Graph.${e}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(r!=="mixed")throw new De(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,i=this._edges.get(n),!i)throw new he(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return i.attributes}}function rX(t,e,r){t.prototype[e]=function(n,i){let a;if(this.type!=="mixed"&&r!=="mixed"&&r!==this.type)throw new De(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new De(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,l=""+i;if(i=arguments[2],a=Fr(this,s,l,r),!a)throw new he(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(r!=="mixed")throw new De(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,a=this._edges.get(n),!a)throw new he(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return a.attributes.hasOwnProperty(i)}}function nX(t,e,r){t.prototype[e]=function(n,i,a){let s;if(this.type!=="mixed"&&r!=="mixed"&&r!==this.type)throw new De(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new De(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const l=""+n,c=""+i;if(i=arguments[2],a=arguments[3],s=Fr(this,l,c,r),!s)throw new he(`Graph.${e}: could not find an edge for the given path ("${l}" - "${c}").`)}else{if(r!=="mixed")throw new De(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new he(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return s.attributes[i]=a,this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:i}),this}}function iX(t,e,r){t.prototype[e]=function(n,i,a){let s;if(this.type!=="mixed"&&r!=="mixed"&&r!==this.type)throw new De(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new De(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const l=""+n,c=""+i;if(i=arguments[2],a=arguments[3],s=Fr(this,l,c,r),!s)throw new he(`Graph.${e}: could not find an edge for the given path ("${l}" - "${c}").`)}else{if(r!=="mixed")throw new De(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new he(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(typeof a!="function")throw new ye(`Graph.${e}: updater should be a function.`);return s.attributes[i]=a(s.attributes[i]),this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:i}),this}}function aX(t,e,r){t.prototype[e]=function(n,i){let a;if(this.type!=="mixed"&&r!=="mixed"&&r!==this.type)throw new De(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new De(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,l=""+i;if(i=arguments[2],a=Fr(this,s,l,r),!a)throw new he(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(r!=="mixed")throw new De(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,a=this._edges.get(n),!a)throw new he(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return delete a.attributes[i],this.emit("edgeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:i}),this}}function oX(t,e,r){t.prototype[e]=function(n,i){let a;if(this.type!=="mixed"&&r!=="mixed"&&r!==this.type)throw new De(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new De(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,l=""+i;if(i=arguments[2],a=Fr(this,s,l,r),!a)throw new he(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(r!=="mixed")throw new De(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,a=this._edges.get(n),!a)throw new he(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(!Wt(i))throw new ye(`Graph.${e}: provided attributes are not a plain object.`);return a.attributes=i,this.emit("edgeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function sX(t,e,r){t.prototype[e]=function(n,i){let a;if(this.type!=="mixed"&&r!=="mixed"&&r!==this.type)throw new De(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new De(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,l=""+i;if(i=arguments[2],a=Fr(this,s,l,r),!a)throw new he(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(r!=="mixed")throw new De(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,a=this._edges.get(n),!a)throw new he(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(!Wt(i))throw new ye(`Graph.${e}: provided attributes are not a plain object.`);return Pt(a.attributes,i),this.emit("edgeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:i}),this}}function uX(t,e,r){t.prototype[e]=function(n,i){let a;if(this.type!=="mixed"&&r!=="mixed"&&r!==this.type)throw new De(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new De(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,l=""+i;if(i=arguments[2],a=Fr(this,s,l,r),!a)throw new he(`Graph.${e}: could not find an edge for the given path ("${s}" - "${l}").`)}else{if(r!=="mixed")throw new De(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,a=this._edges.get(n),!a)throw new he(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(typeof i!="function")throw new ye(`Graph.${e}: provided updater is not a function.`);return a.attributes=i(a.attributes),this.emit("edgeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}const lX=[{name:t=>`get${t}Attribute`,attacher:eX},{name:t=>`get${t}Attributes`,attacher:tX},{name:t=>`has${t}Attribute`,attacher:rX},{name:t=>`set${t}Attribute`,attacher:nX},{name:t=>`update${t}Attribute`,attacher:iX},{name:t=>`remove${t}Attribute`,attacher:aX},{name:t=>`replace${t}Attributes`,attacher:oX},{name:t=>`merge${t}Attributes`,attacher:sX},{name:t=>`update${t}Attributes`,attacher:uX}];function cX(t){lX.forEach(function({name:e,attacher:r}){r(t,e("Edge"),"mixed"),r(t,e("DirectedEdge"),"directed"),r(t,e("UndirectedEdge"),"undirected")})}const fX=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function dX(t,e,r,n){let i=!1;for(const a in e){if(a===n)continue;const s=e[a];if(i=r(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),t&&i)return s.key}}function hX(t,e,r,n){let i,a,s,l=!1;for(const c in e)if(c!==n){i=e[c];do{if(a=i.source,s=i.target,l=r(i.key,i.attributes,a.key,s.key,a.attributes,s.attributes,i.undirected),t&&l)return i.key;i=i.next}while(i!==void 0)}}function Xy(t,e){const r=Object.keys(t),n=r.length;let i,a=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(a>=n)return{done:!0};const s=r[a++];if(s===e){i=void 0;continue}i=t[s]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function pX(t,e,r,n){const i=e[r];if(!i)return;const a=i.source,s=i.target;if(n(i.key,i.attributes,a.key,s.key,a.attributes,s.attributes,i.undirected)&&t)return i.key}function vX(t,e,r,n){let i=e[r];if(!i)return;let a=!1;do{if(a=n(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),t&&a)return i.key;i=i.next}while(i!==void 0)}function Yy(t,e){let r=t[e];if(r.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!r)return{done:!0};const i={edge:r.key,attributes:r.attributes,source:r.source.key,target:r.target.key,sourceAttributes:r.source.attributes,targetAttributes:r.target.attributes,undirected:r.undirected};return r=r.next,{done:!1,value:i}}};let n=!1;return{[Symbol.iterator](){return this},next(){return n===!0?{done:!0}:(n=!0,{done:!1,value:{edge:r.key,attributes:r.attributes,source:r.source.key,target:r.target.key,sourceAttributes:r.source.attributes,targetAttributes:r.target.attributes,undirected:r.undirected}})}}}function gX(t,e){if(t.size===0)return[];if(e==="mixed"||e===t.type)return Array.from(t._edges.keys());const r=e==="undirected"?t.undirectedSize:t.directedSize,n=new Array(r),i=e==="undirected",a=t._edges.values();let s=0,l,c;for(;l=a.next(),l.done!==!0;)c=l.value,c.undirected===i&&(n[s++]=c.key);return n}function Kj(t,e,r,n){if(e.size===0)return;const i=r!=="mixed"&&r!==e.type,a=r==="undirected";let s,l,c=!1;const f=e._edges.values();for(;s=f.next(),s.done!==!0;){if(l=s.value,i&&l.undirected!==a)continue;const{key:p,attributes:h,source:g,target:y}=l;if(c=n(p,h,g.key,y.key,g.attributes,y.attributes,l.undirected),t&&c)return p}}function mX(t,e){if(t.size===0)return ms();const r=e!=="mixed"&&e!==t.type,n=e==="undirected",i=t._edges.values();return{[Symbol.iterator](){return this},next(){let a,s;for(;;){if(a=i.next(),a.done)return a;if(s=a.value,!(r&&s.undirected!==n))break}return{value:{edge:s.key,attributes:s.attributes,source:s.source.key,target:s.target.key,sourceAttributes:s.source.attributes,targetAttributes:s.target.attributes,undirected:s.undirected},done:!1}}}}function nx(t,e,r,n,i,a){const s=e?hX:dX;let l;if(r!=="undirected"&&(n!=="out"&&(l=s(t,i.in,a),t&&l)||n!=="in"&&(l=s(t,i.out,a,n?void 0:i.key),t&&l))||r!=="directed"&&(l=s(t,i.undirected,a),t&&l))return l}function yX(t,e,r,n){const i=[];return nx(!1,t,e,r,n,function(a){i.push(a)}),i}function bX(t,e,r){let n=ms();return t!=="undirected"&&(e!=="out"&&typeof r.in<"u"&&(n=ei(n,Xy(r.in))),e!=="in"&&typeof r.out<"u"&&(n=ei(n,Xy(r.out,e?void 0:r.key)))),t!=="directed"&&typeof r.undirected<"u"&&(n=ei(n,Xy(r.undirected))),n}function ix(t,e,r,n,i,a,s){const l=r?vX:pX;let c;if(e!=="undirected"&&(typeof i.in<"u"&&n!=="out"&&(c=l(t,i.in,a,s),t&&c)||typeof i.out<"u"&&n!=="in"&&(n||i.key!==a)&&(c=l(t,i.out,a,s),t&&c))||e!=="directed"&&typeof i.undirected<"u"&&(c=l(t,i.undirected,a,s),t&&c))return c}function wX(t,e,r,n,i){const a=[];return ix(!1,t,e,r,n,i,function(s){a.push(s)}),a}function xX(t,e,r,n){let i=ms();return t!=="undirected"&&(typeof r.in<"u"&&e!=="out"&&n in r.in&&(i=ei(i,Yy(r.in,n))),typeof r.out<"u"&&e!=="in"&&n in r.out&&(e||r.key!==n)&&(i=ei(i,Yy(r.out,n)))),t!=="directed"&&typeof r.undirected<"u"&&n in r.undirected&&(i=ei(i,Yy(r.undirected,n))),i}function SX(t,e){const{name:r,type:n,direction:i}=e;t.prototype[r]=function(a,s){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return[];if(!arguments.length)return gX(this,n);if(arguments.length===1){a=""+a;const l=this._nodes.get(a);if(typeof l>"u")throw new he(`Graph.${r}: could not find the "${a}" node in the graph.`);return yX(this.multi,n==="mixed"?this.type:n,i,l)}if(arguments.length===2){a=""+a,s=""+s;const l=this._nodes.get(a);if(!l)throw new he(`Graph.${r}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(s))throw new he(`Graph.${r}: could not find the "${s}" target node in the graph.`);return wX(n,this.multi,i,l,s)}throw new ye(`Graph.${r}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function _X(t,e){const{name:r,type:n,direction:i}=e,a="forEach"+r[0].toUpperCase()+r.slice(1,-1);t.prototype[a]=function(f,p,h){if(!(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)){if(arguments.length===1)return h=f,Kj(!1,this,n,h);if(arguments.length===2){f=""+f,h=p;const g=this._nodes.get(f);if(typeof g>"u")throw new he(`Graph.${a}: could not find the "${f}" node in the graph.`);return nx(!1,this.multi,n==="mixed"?this.type:n,i,g,h)}if(arguments.length===3){f=""+f,p=""+p;const g=this._nodes.get(f);if(!g)throw new he(`Graph.${a}: could not find the "${f}" source node in the graph.`);if(!this._nodes.has(p))throw new he(`Graph.${a}: could not find the "${p}" target node in the graph.`);return ix(!1,n,this.multi,i,g,p,h)}throw new ye(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const s="map"+r[0].toUpperCase()+r.slice(1);t.prototype[s]=function(){const f=Array.prototype.slice.call(arguments),p=f.pop();let h;if(f.length===0){let g=0;n!=="directed"&&(g+=this.undirectedSize),n!=="undirected"&&(g+=this.directedSize),h=new Array(g);let y=0;f.push((S,w,b,E,P,T,O)=>{h[y++]=p(S,w,b,E,P,T,O)})}else h=[],f.push((g,y,S,w,b,E,P)=>{h.push(p(g,y,S,w,b,E,P))});return this[a].apply(this,f),h};const l="filter"+r[0].toUpperCase()+r.slice(1);t.prototype[l]=function(){const f=Array.prototype.slice.call(arguments),p=f.pop(),h=[];return f.push((g,y,S,w,b,E,P)=>{p(g,y,S,w,b,E,P)&&h.push(g)}),this[a].apply(this,f),h};const c="reduce"+r[0].toUpperCase()+r.slice(1);t.prototype[c]=function(){let f=Array.prototype.slice.call(arguments);if(f.length<2||f.length>4)throw new ye(`Graph.${c}: invalid number of arguments (expecting 2, 3 or 4 and got ${f.length}).`);if(typeof f[f.length-1]=="function"&&typeof f[f.length-2]!="function")throw new ye(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let p,h;f.length===2?(p=f[0],h=f[1],f=[]):f.length===3?(p=f[1],h=f[2],f=[f[0]]):f.length===4&&(p=f[2],h=f[3],f=[f[0],f[1]]);let g=h;return f.push((y,S,w,b,E,P,T)=>{g=p(g,y,S,w,b,E,P,T)}),this[a].apply(this,f),g}}function EX(t,e){const{name:r,type:n,direction:i}=e,a="find"+r[0].toUpperCase()+r.slice(1,-1);t.prototype[a]=function(c,f,p){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return!1;if(arguments.length===1)return p=c,Kj(!0,this,n,p);if(arguments.length===2){c=""+c,p=f;const h=this._nodes.get(c);if(typeof h>"u")throw new he(`Graph.${a}: could not find the "${c}" node in the graph.`);return nx(!0,this.multi,n==="mixed"?this.type:n,i,h,p)}if(arguments.length===3){c=""+c,f=""+f;const h=this._nodes.get(c);if(!h)throw new he(`Graph.${a}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(f))throw new he(`Graph.${a}: could not find the "${f}" target node in the graph.`);return ix(!0,n,this.multi,i,h,f,p)}throw new ye(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const s="some"+r[0].toUpperCase()+r.slice(1,-1);t.prototype[s]=function(){const c=Array.prototype.slice.call(arguments),f=c.pop();return c.push((h,g,y,S,w,b,E)=>f(h,g,y,S,w,b,E)),!!this[a].apply(this,c)};const l="every"+r[0].toUpperCase()+r.slice(1,-1);t.prototype[l]=function(){const c=Array.prototype.slice.call(arguments),f=c.pop();return c.push((h,g,y,S,w,b,E)=>!f(h,g,y,S,w,b,E)),!this[a].apply(this,c)}}function OX(t,e){const{name:r,type:n,direction:i}=e,a=r.slice(0,-1)+"Entries";t.prototype[a]=function(s,l){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return ms();if(!arguments.length)return mX(this,n);if(arguments.length===1){s=""+s;const c=this._nodes.get(s);if(!c)throw new he(`Graph.${a}: could not find the "${s}" node in the graph.`);return bX(n,i,c)}if(arguments.length===2){s=""+s,l=""+l;const c=this._nodes.get(s);if(!c)throw new he(`Graph.${a}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(l))throw new he(`Graph.${a}: could not find the "${l}" target node in the graph.`);return xX(n,i,c,l)}throw new ye(`Graph.${a}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function AX(t){fX.forEach(e=>{SX(t,e),_X(t,e),EX(t,e),OX(t,e)})}const PX=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function Xd(){this.A=null,this.B=null}Xd.prototype.wrap=function(t){this.A===null?this.A=t:this.B===null&&(this.B=t)};Xd.prototype.has=function(t){return this.A!==null&&t in this.A||this.B!==null&&t in this.B};function hu(t,e,r,n,i){for(const a in n){const s=n[a],l=s.source,c=s.target,f=l===r?c:l;if(e&&e.has(f.key))continue;const p=i(f.key,f.attributes);if(t&&p)return f.key}}function ax(t,e,r,n,i){if(e!=="mixed"){if(e==="undirected")return hu(t,null,n,n.undirected,i);if(typeof r=="string")return hu(t,null,n,n[r],i)}const a=new Xd;let s;if(e!=="undirected"){if(r!=="out"){if(s=hu(t,null,n,n.in,i),t&&s)return s;a.wrap(n.in)}if(r!=="in"){if(s=hu(t,a,n,n.out,i),t&&s)return s;a.wrap(n.out)}}if(e!=="directed"&&(s=hu(t,a,n,n.undirected,i),t&&s))return s}function TX(t,e,r){if(t!=="mixed"){if(t==="undirected")return Object.keys(r.undirected);if(typeof e=="string")return Object.keys(r[e])}const n=[];return ax(!1,t,e,r,function(i){n.push(i)}),n}function pu(t,e,r){const n=Object.keys(r),i=n.length;let a=0;return{[Symbol.iterator](){return this},next(){let s=null;do{if(a>=i)return t&&t.wrap(r),{done:!0};const l=r[n[a++]],c=l.source,f=l.target;if(s=c===e?f:c,t&&t.has(s.key)){s=null;continue}}while(s===null);return{done:!1,value:{neighbor:s.key,attributes:s.attributes}}}}}function CX(t,e,r){if(t!=="mixed"){if(t==="undirected")return pu(null,r,r.undirected);if(typeof e=="string")return pu(null,r,r[e])}let n=ms();const i=new Xd;return t!=="undirected"&&(e!=="out"&&(n=ei(n,pu(i,r,r.in))),e!=="in"&&(n=ei(n,pu(i,r,r.out)))),t!=="directed"&&(n=ei(n,pu(i,r,r.undirected))),n}function kX(t,e){const{name:r,type:n,direction:i}=e;t.prototype[r]=function(a){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return[];a=""+a;const s=this._nodes.get(a);if(typeof s>"u")throw new he(`Graph.${r}: could not find the "${a}" node in the graph.`);return TX(n==="mixed"?this.type:n,i,s)}}function RX(t,e){const{name:r,type:n,direction:i}=e,a="forEach"+r[0].toUpperCase()+r.slice(1,-1);t.prototype[a]=function(f,p){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return;f=""+f;const h=this._nodes.get(f);if(typeof h>"u")throw new he(`Graph.${a}: could not find the "${f}" node in the graph.`);ax(!1,n==="mixed"?this.type:n,i,h,p)};const s="map"+r[0].toUpperCase()+r.slice(1);t.prototype[s]=function(f,p){const h=[];return this[a](f,(g,y)=>{h.push(p(g,y))}),h};const l="filter"+r[0].toUpperCase()+r.slice(1);t.prototype[l]=function(f,p){const h=[];return this[a](f,(g,y)=>{p(g,y)&&h.push(g)}),h};const c="reduce"+r[0].toUpperCase()+r.slice(1);t.prototype[c]=function(f,p,h){if(arguments.length<3)throw new ye(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let g=h;return this[a](f,(y,S)=>{g=p(g,y,S)}),g}}function DX(t,e){const{name:r,type:n,direction:i}=e,a=r[0].toUpperCase()+r.slice(1,-1),s="find"+a;t.prototype[s]=function(f,p){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return;f=""+f;const h=this._nodes.get(f);if(typeof h>"u")throw new he(`Graph.${s}: could not find the "${f}" node in the graph.`);return ax(!0,n==="mixed"?this.type:n,i,h,p)};const l="some"+a;t.prototype[l]=function(f,p){return!!this[s](f,p)};const c="every"+a;t.prototype[c]=function(f,p){return!this[s](f,(g,y)=>!p(g,y))}}function jX(t,e){const{name:r,type:n,direction:i}=e,a=r.slice(0,-1)+"Entries";t.prototype[a]=function(s){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return ms();s=""+s;const l=this._nodes.get(s);if(typeof l>"u")throw new he(`Graph.${a}: could not find the "${s}" node in the graph.`);return CX(n==="mixed"?this.type:n,i,l)}}function IX(t){PX.forEach(e=>{kX(t,e),RX(t,e),DX(t,e),jX(t,e)})}function of(t,e,r,n,i){const a=n._nodes.values(),s=n.type;let l,c,f,p,h,g;for(;l=a.next(),l.done!==!0;){let y=!1;if(c=l.value,s!=="undirected"){p=c.out;for(f in p){h=p[f];do g=h.target,y=!0,i(c.key,g.key,c.attributes,g.attributes,h.key,h.attributes,h.undirected),h=h.next;while(h)}}if(s!=="directed"){p=c.undirected;for(f in p)if(!(e&&c.key>f)){h=p[f];do g=h.target,g.key!==f&&(g=h.source),y=!0,i(c.key,g.key,c.attributes,g.attributes,h.key,h.attributes,h.undirected),h=h.next;while(h)}}r&&!y&&i(c.key,null,c.attributes,null,null,null,null)}}function NX(t,e){const r={key:t};return Gj(e.attributes)||(r.attributes=Pt({},e.attributes)),r}function MX(t,e,r){const n={key:e,source:r.source.key,target:r.target.key};return Gj(r.attributes)||(n.attributes=Pt({},r.attributes)),t==="mixed"&&r.undirected&&(n.undirected=!0),n}function LX(t){if(!Wt(t))throw new ye('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in t))throw new ye("Graph.import: serialized node is missing its key.");if("attributes"in t&&(!Wt(t.attributes)||t.attributes===null))throw new ye("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function $X(t){if(!Wt(t))throw new ye('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in t))throw new ye("Graph.import: serialized edge is missing its source.");if(!("target"in t))throw new ye("Graph.import: serialized edge is missing its target.");if("attributes"in t&&(!Wt(t.attributes)||t.attributes===null))throw new ye("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in t&&typeof t.undirected!="boolean")throw new ye("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const FX=G7(),BX=new Set(["directed","undirected","mixed"]),uk=new Set(["domain","_events","_eventsCount","_maxListeners"]),GX=[{name:t=>`${t}Edge`,generateKey:!0},{name:t=>`${t}DirectedEdge`,generateKey:!0,type:"directed"},{name:t=>`${t}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:t=>`${t}EdgeWithKey`},{name:t=>`${t}DirectedEdgeWithKey`,type:"directed"},{name:t=>`${t}UndirectedEdgeWithKey`,type:"undirected"}],zX={allowSelfLoops:!0,multi:!1,type:"mixed"};function UX(t,e,r){if(r&&!Wt(r))throw new ye(`Graph.addNode: invalid attributes. Expecting an object but got "${r}"`);if(e=""+e,r=r||{},t._nodes.has(e))throw new De(`Graph.addNode: the "${e}" node already exist in the graph.`);const n=new t.NodeDataClass(e,r);return t._nodes.set(e,n),t.emit("nodeAdded",{key:e,attributes:r}),n}function lk(t,e,r){const n=new t.NodeDataClass(e,r);return t._nodes.set(e,n),t.emit("nodeAdded",{key:e,attributes:r}),n}function Xj(t,e,r,n,i,a,s,l){if(!n&&t.type==="undirected")throw new De(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(n&&t.type==="directed")throw new De(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(l&&!Wt(l))throw new ye(`Graph.${e}: invalid attributes. Expecting an object but got "${l}"`);if(a=""+a,s=""+s,l=l||{},!t.allowSelfLoops&&a===s)throw new De(`Graph.${e}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const c=t._nodes.get(a),f=t._nodes.get(s);if(!c)throw new he(`Graph.${e}: source node "${a}" not found.`);if(!f)throw new he(`Graph.${e}: target node "${s}" not found.`);const p={key:null,undirected:n,source:a,target:s,attributes:l};if(r)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new De(`Graph.${e}: the "${i}" edge already exists in the graph.`);if(!t.multi&&(n?typeof c.undirected[s]<"u":typeof c.out[s]<"u"))throw new De(`Graph.${e}: an edge linking "${a}" to "${s}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const h=new ys(n,i,c,f,l);t._edges.set(i,h);const g=a===s;return n?(c.undirectedDegree++,f.undirectedDegree++,g&&(c.undirectedLoops++,t._undirectedSelfLoopCount++)):(c.outDegree++,f.inDegree++,g&&(c.directedLoops++,t._directedSelfLoopCount++)),t.multi?h.attachMulti():h.attach(),n?t._undirectedSize++:t._directedSize++,p.key=i,t.emit("edgeAdded",p),i}function qX(t,e,r,n,i,a,s,l,c){if(!n&&t.type==="undirected")throw new De(`Graph.${e}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(n&&t.type==="directed")throw new De(`Graph.${e}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(l){if(c){if(typeof l!="function")throw new ye(`Graph.${e}: invalid updater function. Expecting a function but got "${l}"`)}else if(!Wt(l))throw new ye(`Graph.${e}: invalid attributes. Expecting an object but got "${l}"`)}a=""+a,s=""+s;let f;if(c&&(f=l,l=void 0),!t.allowSelfLoops&&a===s)throw new De(`Graph.${e}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let p=t._nodes.get(a),h=t._nodes.get(s),g,y;if(!r&&(g=t._edges.get(i),g)){if((g.source.key!==a||g.target.key!==s)&&(!n||g.source.key!==s||g.target.key!==a))throw new De(`Graph.${e}: inconsistency detected when attempting to merge the "${i}" edge with "${a}" source & "${s}" target vs. ("${g.source.key}", "${g.target.key}").`);y=g}if(!y&&!t.multi&&p&&(y=n?p.undirected[s]:p.out[s]),y){const P=[y.key,!1,!1,!1];if(c?!f:!l)return P;if(c){const T=y.attributes;y.attributes=f(T),t.emit("edgeAttributesUpdated",{type:"replace",key:y.key,attributes:y.attributes})}else Pt(y.attributes,l),t.emit("edgeAttributesUpdated",{type:"merge",key:y.key,attributes:y.attributes,data:l});return P}l=l||{},c&&f&&(l=f(l));const S={key:null,undirected:n,source:a,target:s,attributes:l};if(r)i=t._edgeKeyGenerator();else if(i=""+i,t._edges.has(i))throw new De(`Graph.${e}: the "${i}" edge already exists in the graph.`);let w=!1,b=!1;p||(p=lk(t,a,{}),w=!0,a===s&&(h=p,b=!0)),h||(h=lk(t,s,{}),b=!0),g=new ys(n,i,p,h,l),t._edges.set(i,g);const E=a===s;return n?(p.undirectedDegree++,h.undirectedDegree++,E&&(p.undirectedLoops++,t._undirectedSelfLoopCount++)):(p.outDegree++,h.inDegree++,E&&(p.directedLoops++,t._directedSelfLoopCount++)),t.multi?g.attachMulti():g.attach(),n?t._undirectedSize++:t._directedSize++,S.key=i,t.emit("edgeAdded",S),[i,!0,w,b]}function po(t,e){t._edges.delete(e.key);const{source:r,target:n,attributes:i}=e,a=e.undirected,s=r===n;a?(r.undirectedDegree--,n.undirectedDegree--,s&&(r.undirectedLoops--,t._undirectedSelfLoopCount--)):(r.outDegree--,n.inDegree--,s&&(r.directedLoops--,t._directedSelfLoopCount--)),t.multi?e.detachMulti():e.detach(),a?t._undirectedSize--:t._directedSize--,t.emit("edgeDropped",{key:e.key,attributes:i,source:r.key,target:n.key,undirected:a})}class Ze extends Bj.EventEmitter{constructor(e){if(super(),e=Pt({},zX,e),typeof e.multi!="boolean")throw new ye(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!BX.has(e.type))throw new ye(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new ye(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);const r=e.type==="mixed"?zj:e.type==="directed"?Uj:qj;Ir(this,"NodeDataClass",r);const n="geid_"+FX()+"_";let i=0;const a=()=>{let s;do s=n+i++;while(this._edges.has(s));return s};Ir(this,"_attributes",{}),Ir(this,"_nodes",new Map),Ir(this,"_edges",new Map),Ir(this,"_directedSize",0),Ir(this,"_undirectedSize",0),Ir(this,"_directedSelfLoopCount",0),Ir(this,"_undirectedSelfLoopCount",0),Ir(this,"_edgeKeyGenerator",a),Ir(this,"_options",e),uk.forEach(s=>Ir(this,s,this[s])),Zr(this,"order",()=>this._nodes.size),Zr(this,"size",()=>this._edges.size),Zr(this,"directedSize",()=>this._directedSize),Zr(this,"undirectedSize",()=>this._undirectedSize),Zr(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Zr(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Zr(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Zr(this,"multi",this._options.multi),Zr(this,"type",this._options.type),Zr(this,"allowSelfLoops",this._options.allowSelfLoops),Zr(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(""+e)}hasDirectedEdge(e,r){if(this.type==="undirected")return!1;if(arguments.length===1){const n=""+e,i=this._edges.get(n);return!!i&&!i.undirected}else if(arguments.length===2){e=""+e,r=""+r;const n=this._nodes.get(e);return n?n.out.hasOwnProperty(r):!1}throw new ye(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(e,r){if(this.type==="directed")return!1;if(arguments.length===1){const n=""+e,i=this._edges.get(n);return!!i&&i.undirected}else if(arguments.length===2){e=""+e,r=""+r;const n=this._nodes.get(e);return n?n.undirected.hasOwnProperty(r):!1}throw new ye(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(e,r){if(arguments.length===1){const n=""+e;return this._edges.has(n)}else if(arguments.length===2){e=""+e,r=""+r;const n=this._nodes.get(e);return n?typeof n.out<"u"&&n.out.hasOwnProperty(r)||typeof n.undirected<"u"&&n.undirected.hasOwnProperty(r):!1}throw new ye(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(e,r){if(this.type==="undirected")return;if(e=""+e,r=""+r,this.multi)throw new De("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const n=this._nodes.get(e);if(!n)throw new he(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(r))throw new he(`Graph.directedEdge: could not find the "${r}" target node in the graph.`);const i=n.out&&n.out[r]||void 0;if(i)return i.key}undirectedEdge(e,r){if(this.type==="directed")return;if(e=""+e,r=""+r,this.multi)throw new De("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const n=this._nodes.get(e);if(!n)throw new he(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(r))throw new he(`Graph.undirectedEdge: could not find the "${r}" target node in the graph.`);const i=n.undirected&&n.undirected[r]||void 0;if(i)return i.key}edge(e,r){if(this.multi)throw new De("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,r=""+r;const n=this._nodes.get(e);if(!n)throw new he(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(r))throw new he(`Graph.edge: could not find the "${r}" target node in the graph.`);const i=n.out&&n.out[r]||n.undirected&&n.undirected[r]||void 0;if(i)return i.key}areDirectedNeighbors(e,r){e=""+e,r=""+r;const n=this._nodes.get(e);if(!n)throw new he(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:r in n.in||r in n.out}areOutNeighbors(e,r){e=""+e,r=""+r;const n=this._nodes.get(e);if(!n)throw new he(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:r in n.out}areInNeighbors(e,r){e=""+e,r=""+r;const n=this._nodes.get(e);if(!n)throw new he(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:r in n.in}areUndirectedNeighbors(e,r){e=""+e,r=""+r;const n=this._nodes.get(e);if(!n)throw new he(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="directed"?!1:r in n.undirected}areNeighbors(e,r){e=""+e,r=""+r;const n=this._nodes.get(e);if(!n)throw new he(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&(r in n.in||r in n.out)||this.type!=="directed"&&r in n.undirected}areInboundNeighbors(e,r){e=""+e,r=""+r;const n=this._nodes.get(e);if(!n)throw new he(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&r in n.in||this.type!=="directed"&&r in n.undirected}areOutboundNeighbors(e,r){e=""+e,r=""+r;const n=this._nodes.get(e);if(!n)throw new he(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&r in n.out||this.type!=="directed"&&r in n.undirected}inDegree(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:r.inDegree}outDegree(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:r.outDegree}directedDegree(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:r.inDegree+r.outDegree}undirectedDegree(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:r.undirectedDegree}inboundDegree(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=r.undirectedDegree),this.type!=="undirected"&&(n+=r.inDegree),n}outboundDegree(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=r.undirectedDegree),this.type!=="undirected"&&(n+=r.outDegree),n}degree(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.degree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=r.undirectedDegree),this.type!=="undirected"&&(n+=r.inDegree+r.outDegree),n}inDegreeWithoutSelfLoops(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:r.inDegree-r.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:r.outDegree-r.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:r.inDegree+r.outDegree-r.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:r.undirectedDegree-r.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=r.undirectedDegree,i+=r.undirectedLoops*2),this.type!=="undirected"&&(n+=r.inDegree,i+=r.directedLoops),n-i}outboundDegreeWithoutSelfLoops(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=r.undirectedDegree,i+=r.undirectedLoops*2),this.type!=="undirected"&&(n+=r.outDegree,i+=r.directedLoops),n-i}degreeWithoutSelfLoops(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=r.undirectedDegree,i+=r.undirectedLoops*2),this.type!=="undirected"&&(n+=r.inDegree+r.outDegree,i+=r.directedLoops*2),n-i}source(e){e=""+e;const r=this._edges.get(e);if(!r)throw new he(`Graph.source: could not find the "${e}" edge in the graph.`);return r.source.key}target(e){e=""+e;const r=this._edges.get(e);if(!r)throw new he(`Graph.target: could not find the "${e}" edge in the graph.`);return r.target.key}extremities(e){e=""+e;const r=this._edges.get(e);if(!r)throw new he(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[r.source.key,r.target.key]}opposite(e,r){e=""+e,r=""+r;const n=this._edges.get(r);if(!n)throw new he(`Graph.opposite: could not find the "${r}" edge in the graph.`);const i=n.source.key,a=n.target.key;if(e===i)return a;if(e===a)return i;throw new he(`Graph.opposite: the "${e}" node is not attached to the "${r}" edge (${i}, ${a}).`)}hasExtremity(e,r){e=""+e,r=""+r;const n=this._edges.get(e);if(!n)throw new he(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return n.source.key===r||n.target.key===r}isUndirected(e){e=""+e;const r=this._edges.get(e);if(!r)throw new he(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return r.undirected}isDirected(e){e=""+e;const r=this._edges.get(e);if(!r)throw new he(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!r.undirected}isSelfLoop(e){e=""+e;const r=this._edges.get(e);if(!r)throw new he(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return r.source===r.target}addNode(e,r){return UX(this,e,r).key}mergeNode(e,r){if(r&&!Wt(r))throw new ye(`Graph.mergeNode: invalid attributes. Expecting an object but got "${r}"`);e=""+e,r=r||{};let n=this._nodes.get(e);return n?(r&&(Pt(n.attributes,r),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:n.attributes,data:r})),[e,!1]):(n=new this.NodeDataClass(e,r),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:r}),[e,!0])}updateNode(e,r){if(r&&typeof r!="function")throw new ye(`Graph.updateNode: invalid updater function. Expecting a function but got "${r}"`);e=""+e;let n=this._nodes.get(e);if(n){if(r){const a=n.attributes;n.attributes=r(a),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:n.attributes})}return[e,!1]}const i=r?r({}):{};return n=new this.NodeDataClass(e,i),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:i}),[e,!0]}dropNode(e){e=""+e;const r=this._nodes.get(e);if(!r)throw new he(`Graph.dropNode: could not find the "${e}" node in the graph.`);let n;if(this.type!=="undirected"){for(const i in r.out){n=r.out[i];do po(this,n),n=n.next;while(n)}for(const i in r.in){n=r.in[i];do po(this,n),n=n.next;while(n)}}if(this.type!=="directed")for(const i in r.undirected){n=r.undirected[i];do po(this,n),n=n.next;while(n)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:r.attributes})}dropEdge(e){let r;if(arguments.length>1){const n=""+arguments[0],i=""+arguments[1];if(r=Fr(this,n,i,this.type),!r)throw new he(`Graph.dropEdge: could not find the "${n}" -> "${i}" edge in the graph.`)}else if(e=""+e,r=this._edges.get(e),!r)throw new he(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return po(this,r),this}dropDirectedEdge(e,r){if(arguments.length<2)throw new De("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new De("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");e=""+e,r=""+r;const n=Fr(this,e,r,"directed");if(!n)throw new he(`Graph.dropDirectedEdge: could not find a "${e}" -> "${r}" edge in the graph.`);return po(this,n),this}dropUndirectedEdge(e,r){if(arguments.length<2)throw new De("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new De("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const n=Fr(this,e,r,"undirected");if(!n)throw new he(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${r}" edge in the graph.`);return po(this,n),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const e=this._nodes.values();let r;for(;r=e.next(),r.done!==!0;)r.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,r){return this._attributes[e]=r,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,r){if(typeof r!="function")throw new ye("Graph.updateAttribute: updater should be a function.");const n=this._attributes[e];return this._attributes[e]=r(n),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!Wt(e))throw new ye("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=e,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(e){if(!Wt(e))throw new ye("Graph.mergeAttributes: provided attributes are not a plain object.");return Pt(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new ye("Graph.updateAttributes: provided updater is not a function.");return this._attributes=e(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(e,r){if(typeof e!="function")throw new ye("Graph.updateEachNodeAttributes: expecting an updater function.");if(r&&!sk(r))throw new ye("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const n=this._nodes.values();let i,a;for(;i=n.next(),i.done!==!0;)a=i.value,a.attributes=e(a.key,a.attributes);this.emit("eachNodeAttributesUpdated",{hints:r||null})}updateEachEdgeAttributes(e,r){if(typeof e!="function")throw new ye("Graph.updateEachEdgeAttributes: expecting an updater function.");if(r&&!sk(r))throw new ye("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const n=this._edges.values();let i,a,s,l;for(;i=n.next(),i.done!==!0;)a=i.value,s=a.source,l=a.target,a.attributes=e(a.key,a.attributes,s.key,l.key,s.attributes,l.attributes,a.undirected);this.emit("eachEdgeAttributesUpdated",{hints:r||null})}forEachAdjacencyEntry(e){if(typeof e!="function")throw new ye("Graph.forEachAdjacencyEntry: expecting a callback.");of(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new ye("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");of(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new ye("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");of(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new ye("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");of(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!="function")throw new ye("Graph.forEachNode: expecting a callback.");const r=this._nodes.values();let n,i;for(;n=r.next(),n.done!==!0;)i=n.value,e(i.key,i.attributes)}findNode(e){if(typeof e!="function")throw new ye("Graph.findNode: expecting a callback.");const r=this._nodes.values();let n,i;for(;n=r.next(),n.done!==!0;)if(i=n.value,e(i.key,i.attributes))return i.key}mapNodes(e){if(typeof e!="function")throw new ye("Graph.mapNode: expecting a callback.");const r=this._nodes.values();let n,i;const a=new Array(this.order);let s=0;for(;n=r.next(),n.done!==!0;)i=n.value,a[s++]=e(i.key,i.attributes);return a}someNode(e){if(typeof e!="function")throw new ye("Graph.someNode: expecting a callback.");const r=this._nodes.values();let n,i;for(;n=r.next(),n.done!==!0;)if(i=n.value,e(i.key,i.attributes))return!0;return!1}everyNode(e){if(typeof e!="function")throw new ye("Graph.everyNode: expecting a callback.");const r=this._nodes.values();let n,i;for(;n=r.next(),n.done!==!0;)if(i=n.value,!e(i.key,i.attributes))return!1;return!0}filterNodes(e){if(typeof e!="function")throw new ye("Graph.filterNodes: expecting a callback.");const r=this._nodes.values();let n,i;const a=[];for(;n=r.next(),n.done!==!0;)i=n.value,e(i.key,i.attributes)&&a.push(i.key);return a}reduceNodes(e,r){if(typeof e!="function")throw new ye("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new ye("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let n=r;const i=this._nodes.values();let a,s;for(;a=i.next(),a.done!==!0;)s=a.value,n=e(n,s.key,s.attributes);return n}nodeEntries(){const e=this._nodes.values();return{[Symbol.iterator](){return this},next(){const r=e.next();if(r.done)return r;const n=r.value;return{value:{node:n.key,attributes:n.attributes},done:!1}}}}export(){const e=new Array(this._nodes.size);let r=0;this._nodes.forEach((i,a)=>{e[r++]=NX(a,i)});const n=new Array(this._edges.size);return r=0,this._edges.forEach((i,a)=>{n[r++]=MX(this.type,a,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:n}}import(e,r=!1){if(e instanceof Ze)return e.forEachNode((c,f)=>{r?this.mergeNode(c,f):this.addNode(c,f)}),e.forEachEdge((c,f,p,h,g,y,S)=>{r?S?this.mergeUndirectedEdgeWithKey(c,p,h,f):this.mergeDirectedEdgeWithKey(c,p,h,f):S?this.addUndirectedEdgeWithKey(c,p,h,f):this.addDirectedEdgeWithKey(c,p,h,f)}),this;if(!Wt(e))throw new ye("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!Wt(e.attributes))throw new ye("Graph.import: invalid attributes. Expecting a plain object.");r?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let n,i,a,s,l;if(e.nodes){if(a=e.nodes,!Array.isArray(a))throw new ye("Graph.import: invalid nodes. Expecting an array.");for(n=0,i=a.length;n<i;n++){s=a[n],LX(s);const{key:c,attributes:f}=s;r?this.mergeNode(c,f):this.addNode(c,f)}}if(e.edges){let c=!1;if(this.type==="undirected"&&(c=!0),a=e.edges,!Array.isArray(a))throw new ye("Graph.import: invalid edges. Expecting an array.");for(n=0,i=a.length;n<i;n++){l=a[n],$X(l);const{source:f,target:p,attributes:h,undirected:g=c}=l;let y;"key"in l?(y=r?g?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:g?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,y.call(this,l.key,f,p,h)):(y=r?g?this.mergeUndirectedEdge:this.mergeDirectedEdge:g?this.addUndirectedEdge:this.addDirectedEdge,y.call(this,f,p,h))}}return this}nullCopy(e){const r=new Ze(Pt({},this._options,e));return r.replaceAttributes(Pt({},this.getAttributes())),r}emptyCopy(e){const r=this.nullCopy(e);return this._nodes.forEach((n,i)=>{const a=Pt({},n.attributes);n=new r.NodeDataClass(i,a),r._nodes.set(i,n)}),r}copy(e){if(e=e||{},typeof e.type=="string"&&e.type!==this.type&&e.type!=="mixed")throw new De(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi=="boolean"&&e.multi!==this.multi&&e.multi!==!0)throw new De("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof e.allowSelfLoops=="boolean"&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new De("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const r=this.emptyCopy(e),n=this._edges.values();let i,a;for(;i=n.next(),i.done!==!0;)a=i.value,Xj(r,"copy",!1,a.undirected,a.key,a.source.key,a.target.key,Pt({},a.attributes));return r}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const e={};this._nodes.forEach((a,s)=>{e[s]=a.attributes});const r={},n={};this._edges.forEach((a,s)=>{const l=a.undirected?"--":"->";let c="",f=a.source.key,p=a.target.key,h;a.undirected&&f>p&&(h=f,f=p,p=h);const g=`(${f})${l}(${p})`;s.startsWith("geid_")?this.multi&&(typeof n[g]>"u"?n[g]=0:n[g]++,c+=`${n[g]}. `):c+=`[${s}]: `,c+=g,r[c]=a.attributes});const i={};for(const a in this)this.hasOwnProperty(a)&&!uk.has(a)&&typeof this[a]!="function"&&typeof a!="symbol"&&(i[a]=this[a]);return i.attributes=this._attributes,i.nodes=e,i.edges=r,Ir(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(Ze.prototype[Symbol.for("nodejs.util.inspect.custom")]=Ze.prototype.inspect);GX.forEach(t=>{["add","merge","update"].forEach(e=>{const r=t.name(e),n=e==="add"?Xj:qX;t.generateKey?Ze.prototype[r]=function(i,a,s){return n(this,r,!0,(t.type||this.type)==="undirected",null,i,a,s,e==="update")}:Ze.prototype[r]=function(i,a,s,l){return n(this,r,!1,(t.type||this.type)==="undirected",i,a,s,l,e==="update")}})});J7(Ze);cX(Ze);AX(Ze);IX(Ze);class Yj extends Ze{constructor(e){const r=Pt({type:"directed"},e);if("multi"in r&&r.multi!==!1)throw new ye("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(r.type!=="directed")throw new ye('DirectedGraph.from: inconsistent "'+r.type+'" type in given options!');super(r)}}class Qj extends Ze{constructor(e){const r=Pt({type:"undirected"},e);if("multi"in r&&r.multi!==!1)throw new ye("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(r.type!=="undirected")throw new ye('UndirectedGraph.from: inconsistent "'+r.type+'" type in given options!');super(r)}}class Zj extends Ze{constructor(e){const r=Pt({multi:!0},e);if("multi"in r&&r.multi!==!0)throw new ye("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(r)}}class Jj extends Ze{constructor(e){const r=Pt({type:"directed",multi:!0},e);if("multi"in r&&r.multi!==!0)throw new ye("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(r.type!=="directed")throw new ye('MultiDirectedGraph.from: inconsistent "'+r.type+'" type in given options!');super(r)}}class eI extends Ze{constructor(e){const r=Pt({type:"undirected",multi:!0},e);if("multi"in r&&r.multi!==!0)throw new ye("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(r.type!=="undirected")throw new ye('MultiUndirectedGraph.from: inconsistent "'+r.type+'" type in given options!');super(r)}}function bs(t){t.from=function(e,r){const n=Pt({},e.options,r),i=new t(n);return i.import(e),i}}bs(Ze);bs(Yj);bs(Qj);bs(Zj);bs(Jj);bs(eI);Ze.Graph=Ze;Ze.DirectedGraph=Yj;Ze.UndirectedGraph=Qj;Ze.MultiGraph=Zj;Ze.MultiDirectedGraph=Jj;Ze.MultiUndirectedGraph=eI;Ze.InvalidArgumentsGraphError=ye;Ze.NotFoundGraphError=he;Ze.UsageGraphError=De;function WX(t,e){if(typeof t!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}function Tu(t){var e=WX(t,"string");return typeof e=="symbol"?e:e+""}function er(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ck(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Tu(n.key),n)}}function tr(t,e,r){return e&&ck(t.prototype,e),r&&ck(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function as(t){return as=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},as(t)}function tI(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(tI=function(){return!!t})()}function HX(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function VX(t,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return HX(t)}function zr(t,e,r){return e=as(e),VX(t,tI()?Reflect.construct(e,r||[],as(t).constructor):e.apply(t,r))}function Bb(t,e){return Bb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,n){return r.__proto__=n,r},Bb(t,e)}function Ur(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Bb(t,e)}function KX(t){if(Array.isArray(t))return t}function XX(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,i,a,s,l=[],c=!0,f=!1;try{if(a=(r=r.call(t)).next,e===0){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=a.call(r)).done)&&(l.push(n.value),l.length!==e);c=!0);}catch(p){f=!0,i=p}finally{try{if(!c&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(f)throw i}}return l}}function Gb(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function rI(t,e){if(t){if(typeof t=="string")return Gb(t,e);var r={}.toString.call(t).slice(8,-1);return r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set"?Array.from(t):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Gb(t,e):void 0}}function YX(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
179
179
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function os(t,e){return KX(t)||XX(t,e)||rI(t,e)||YX()}var Qy={black:"#000000",silver:"#C0C0C0",gray:"#808080",grey:"#808080",white:"#FFFFFF",maroon:"#800000",red:"#FF0000",purple:"#800080",fuchsia:"#FF00FF",green:"#008000",lime:"#00FF00",olive:"#808000",yellow:"#FFFF00",navy:"#000080",blue:"#0000FF",teal:"#008080",aqua:"#00FFFF",darkblue:"#00008B",mediumblue:"#0000CD",darkgreen:"#006400",darkcyan:"#008B8B",deepskyblue:"#00BFFF",darkturquoise:"#00CED1",mediumspringgreen:"#00FA9A",springgreen:"#00FF7F",cyan:"#00FFFF",midnightblue:"#191970",dodgerblue:"#1E90FF",lightseagreen:"#20B2AA",forestgreen:"#228B22",seagreen:"#2E8B57",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",limegreen:"#32CD32",mediumseagreen:"#3CB371",turquoise:"#40E0D0",royalblue:"#4169E1",steelblue:"#4682B4",darkslateblue:"#483D8B",mediumturquoise:"#48D1CC",indigo:"#4B0082",darkolivegreen:"#556B2F",cadetblue:"#5F9EA0",cornflowerblue:"#6495ED",rebeccapurple:"#663399",mediumaquamarine:"#66CDAA",dimgray:"#696969",dimgrey:"#696969",slateblue:"#6A5ACD",olivedrab:"#6B8E23",slategray:"#708090",slategrey:"#708090",lightslategray:"#778899",lightslategrey:"#778899",mediumslateblue:"#7B68EE",lawngreen:"#7CFC00",chartreuse:"#7FFF00",aquamarine:"#7FFFD4",skyblue:"#87CEEB",lightskyblue:"#87CEFA",blueviolet:"#8A2BE2",darkred:"#8B0000",darkmagenta:"#8B008B",saddlebrown:"#8B4513",darkseagreen:"#8FBC8F",lightgreen:"#90EE90",mediumpurple:"#9370DB",darkviolet:"#9400D3",palegreen:"#98FB98",darkorchid:"#9932CC",yellowgreen:"#9ACD32",sienna:"#A0522D",brown:"#A52A2A",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",lightblue:"#ADD8E6",greenyellow:"#ADFF2F",paleturquoise:"#AFEEEE",lightsteelblue:"#B0C4DE",powderblue:"#B0E0E6",firebrick:"#B22222",darkgoldenrod:"#B8860B",mediumorchid:"#BA55D3",rosybrown:"#BC8F8F",darkkhaki:"#BDB76B",mediumvioletred:"#C71585",indianred:"#CD5C5C",peru:"#CD853F",chocolate:"#D2691E",tan:"#D2B48C",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",thistle:"#D8BFD8",orchid:"#DA70D6",goldenrod:"#DAA520",palevioletred:"#DB7093",crimson:"#DC143C",gainsboro:"#DCDCDC",plum:"#DDA0DD",burlywood:"#DEB887",lightcyan:"#E0FFFF",lavender:"#E6E6FA",darksalmon:"#E9967A",violet:"#EE82EE",palegoldenrod:"#EEE8AA",lightcoral:"#F08080",khaki:"#F0E68C",aliceblue:"#F0F8FF",honeydew:"#F0FFF0",azure:"#F0FFFF",sandybrown:"#F4A460",wheat:"#F5DEB3",beige:"#F5F5DC",whitesmoke:"#F5F5F5",mintcream:"#F5FFFA",ghostwhite:"#F8F8FF",salmon:"#FA8072",antiquewhite:"#FAEBD7",linen:"#FAF0E6",lightgoldenrodyellow:"#FAFAD2",oldlace:"#FDF5E6",magenta:"#FF00FF",deeppink:"#FF1493",orangered:"#FF4500",tomato:"#FF6347",hotpink:"#FF69B4",coral:"#FF7F50",darkorange:"#FF8C00",lightsalmon:"#FFA07A",orange:"#FFA500",lightpink:"#FFB6C1",pink:"#FFC0CB",gold:"#FFD700",peachpuff:"#FFDAB9",navajowhite:"#FFDEAD",moccasin:"#FFE4B5",bisque:"#FFE4C4",mistyrose:"#FFE4E1",blanchedalmond:"#FFEBCD",papayawhip:"#FFEFD5",lavenderblush:"#FFF0F5",seashell:"#FFF5EE",cornsilk:"#FFF8DC",lemonchiffon:"#FFFACD",floralwhite:"#FFFAF0",snow:"#FFFAFA",lightyellow:"#FFFFE0",ivory:"#FFFFF0"},nI=new Int8Array(4),Zy=new Int32Array(nI.buffer,0,1),QX=new Float32Array(nI.buffer,0,1),ZX=/^\s*rgba?\s*\(/,JX=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function eY(t){var e=0,r=0,n=0,i=1;if(t[0]==="#")t.length===4?(e=parseInt(t.charAt(1)+t.charAt(1),16),r=parseInt(t.charAt(2)+t.charAt(2),16),n=parseInt(t.charAt(3)+t.charAt(3),16)):(e=parseInt(t.charAt(1)+t.charAt(2),16),r=parseInt(t.charAt(3)+t.charAt(4),16),n=parseInt(t.charAt(5)+t.charAt(6),16)),t.length===9&&(i=parseInt(t.charAt(7)+t.charAt(8),16)/255);else if(ZX.test(t)){var a=t.match(JX);a&&(e=+a[1],r=+a[2],n=+a[3],a[4]&&(i=+a[4]))}return{r:e,g:r,b:n,a:i}}var Eo={};for(var sf in Qy)Eo[sf]=Dl(Qy[sf]),Eo[Qy[sf]]=Eo[sf];function iI(t,e,r,n,i){return Zy[0]=n<<24|r<<16|e<<8|t,Zy[0]=Zy[0]&4278190079,QX[0]}function Dl(t){if(t=t.toLowerCase(),typeof Eo[t]<"u")return Eo[t];var e=eY(t),r=e.r,n=e.g,i=e.b,a=e.a;a=a*255|0;var s=iI(r,n,i,a);return Eo[t]=s,s}var Jy={};function aI(t){if(typeof Jy[t]<"u")return Jy[t];var e=(t&16711680)>>>16,r=(t&65280)>>>8,n=t&255,i=255,a=iI(e,r,n,i);return Jy[t]=a,a}function fk(t,e,r,n){return r+(e<<8)+(t<<16)}function dk(t,e,r,n,i,a){var s=Math.floor(r/a*i),l=Math.floor(t.drawingBufferHeight/a-n/a*i),c=new Uint8Array(4);t.bindFramebuffer(t.FRAMEBUFFER,e),t.readPixels(s,l,1,1,t.RGBA,t.UNSIGNED_BYTE,c);var f=os(c,4),p=f[0],h=f[1],g=f[2],y=f[3];return[p,h,g,y]}function se(t,e,r){return(e=Tu(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function hk(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function Pe(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?hk(Object(r),!0).forEach(function(n){se(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):hk(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function tY(t,e){for(;!{}.hasOwnProperty.call(t,e)&&(t=as(t))!==null;);return t}function zb(){return zb=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=tY(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},zb.apply(null,arguments)}function oI(t,e,r,n){var i=zb(as(t.prototype),e,r);return typeof i=="function"?function(a){return i.apply(r,a)}:i}function rY(t){return t.normalized?1:t.size}function e0(t){var e=0;return t.forEach(function(r){return e+=rY(r)}),e}function sI(t,e,r){var n=t==="VERTEX"?e.VERTEX_SHADER:e.FRAGMENT_SHADER,i=e.createShader(n);if(i===null)throw new Error("loadShader: error while creating the shader");e.shaderSource(i,r),e.compileShader(i);var a=e.getShaderParameter(i,e.COMPILE_STATUS);if(!a){var s=e.getShaderInfoLog(i);throw e.deleteShader(i),new Error(`loadShader: error while compiling the shader:
|
|
180
180
|
`.concat(s,`
|
|
181
181
|
`).concat(r))}return i}function nY(t,e){return sI("VERTEX",t,e)}function iY(t,e){return sI("FRAGMENT",t,e)}function aY(t,e){var r=t.createProgram();if(r===null)throw new Error("loadProgram: error while creating the program.");var n,i;for(n=0,i=e.length;n<i;n++)t.attachShader(r,e[n]);t.linkProgram(r);var a=t.getProgramParameter(r,t.LINK_STATUS);if(!a)throw t.deleteProgram(r),new Error("loadProgram: error while linking the program.");return r}function pk(t){var e=t.gl,r=t.buffer,n=t.program,i=t.vertexShader,a=t.fragmentShader;e.deleteShader(i),e.deleteShader(a),e.deleteProgram(n),e.deleteBuffer(r)}var vk=`#define PICKING_MODE
|
|
@@ -486,4 +486,4 @@ void main() {
|
|
|
486
486
|
v_color.a *= bias;
|
|
487
487
|
}
|
|
488
488
|
`,kY=CY,mI=WebGLRenderingContext,bk=mI.UNSIGNED_BYTE,vu=mI.FLOAT,RY=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],DY=(function(t){function e(){return er(this,e),zr(this,e,arguments)}return Ur(e,t),tr(e,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:kY,FRAGMENT_SHADER_SOURCE:pI,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:RY,ATTRIBUTES:[{name:"a_positionStart",size:2,type:vu},{name:"a_positionEnd",size:2,type:vu},{name:"a_normal",size:2,type:vu},{name:"a_color",size:4,type:bk,normalized:!0},{name:"a_id",size:4,type:bk,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:vu},{name:"a_normalCoef",size:1,type:vu}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(n,i,a,s,l){var c=l.size||1,f=a.x,p=a.y,h=s.x,g=s.y,y=Dl(l.color),S=h-f,w=g-p,b=S*S+w*w,E=0,P=0;b&&(b=1/Math.sqrt(b),E=-w*b*c,P=S*b*c);var T=this.array;T[i++]=f,T[i++]=p,T[i++]=h,T[i++]=g,T[i++]=E,T[i++]=P,T[i++]=y,T[i++]=n}},{key:"setUniforms",value:function(n,i){var a=i.gl,s=i.uniformLocations,l=s.u_matrix,c=s.u_zoomRatio,f=s.u_feather,p=s.u_pixelRatio,h=s.u_correctionRatio,g=s.u_sizeRatio,y=s.u_minEdgeThickness;a.uniformMatrix3fv(l,!1,n.matrix),a.uniform1f(c,n.zoomRatio),a.uniform1f(g,n.sizeRatio),a.uniform1f(h,n.correctionRatio),a.uniform1f(p,n.pixelRatio),a.uniform1f(f,n.antiAliasingFeather),a.uniform1f(y,n.minEdgeThickness)}}])})(ox),sx=(function(t){function e(){var r;return er(this,e),r=zr(this,e),r.rawEmitter=r,r}return Ur(e,t),tr(e)})(Bj.EventEmitter),r0,wk;function yI(){return wk||(wk=1,r0=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"}),r0}var jY=yI();const IY=tt(jY);var NY=function(e){return e},MY=function(e){return e*e},LY=function(e){return e*(2-e)},$Y=function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},FY=function(e){return e*e*e},BY=function(e){return--e*e*e+1},GY=function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)},zY={linear:NY,quadraticIn:MY,quadraticOut:LY,quadraticInOut:$Y,cubicIn:FY,cubicOut:BY,cubicInOut:GY},UY={easing:"quadraticInOut",duration:150};function Jr(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function lf(t,e,r){return t[0]=e,t[4]=typeof r=="number"?r:e,t}function xk(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[3]=-r,t[4]=n,t}function Sk(t,e,r){return t[6]=e,t[7]=r,t}function Ci(t,e){var r=t[0],n=t[1],i=t[2],a=t[3],s=t[4],l=t[5],c=t[6],f=t[7],p=t[8],h=e[0],g=e[1],y=e[2],S=e[3],w=e[4],b=e[5],E=e[6],P=e[7],T=e[8];return t[0]=h*r+g*a+y*c,t[1]=h*n+g*s+y*f,t[2]=h*i+g*l+y*p,t[3]=S*r+w*a+b*c,t[4]=S*n+w*s+b*f,t[5]=S*i+w*l+b*p,t[6]=E*r+P*a+T*c,t[7]=E*n+P*s+T*f,t[8]=E*i+P*l+T*p,t}function Ub(t,e){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,n=t[0],i=t[1],a=t[3],s=t[4],l=t[6],c=t[7],f=e.x,p=e.y;return{x:f*n+p*a+l*r,y:f*i+p*s+c*r}}function qY(t,e){var r=t.height/t.width,n=e.height/e.width;return r<1&&n>1||r>1&&n<1?1:Math.min(Math.max(n,1/n),Math.max(1/r,r))}function gu(t,e,r,n,i){var a=t.angle,s=t.ratio,l=t.x,c=t.y,f=e.width,p=e.height,h=Jr(),g=Math.min(f,p)-2*n,y=qY(e,r);return i?(Ci(h,Sk(Jr(),l,c)),Ci(h,lf(Jr(),s)),Ci(h,xk(Jr(),a)),Ci(h,lf(Jr(),f/g/2/y,p/g/2/y))):(Ci(h,lf(Jr(),2*(g/f)*y,2*(g/p)*y)),Ci(h,xk(Jr(),-a)),Ci(h,lf(Jr(),1/s)),Ci(h,Sk(Jr(),-l,-c))),h}function WY(t,e,r){var n=Ub(t,{x:Math.cos(e.angle),y:Math.sin(e.angle)},0),i=n.x,a=n.y;return 1/Math.sqrt(Math.pow(i,2)+Math.pow(a,2))/r.width}function HY(t){if(!t.order)return{x:[0,1],y:[0,1]};var e=1/0,r=-1/0,n=1/0,i=-1/0;return t.forEachNode(function(a,s){var l=s.x,c=s.y;l<e&&(e=l),l>r&&(r=l),c<n&&(n=c),c>i&&(i=c)}),{x:[e,r],y:[n,i]}}function VY(t){if(!IY(t))throw new Error("Sigma: invalid graph instance.");t.forEachNode(function(e,r){if(!Number.isFinite(r.x)||!Number.isFinite(r.y))throw new Error("Sigma: Coordinates of node ".concat(e," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function KY(t,e,r){var n=document.createElement(t);if(e)for(var i in e)n.style[i]=e[i];if(r)for(var a in r)n.setAttribute(a,r[a]);return n}function _k(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function Ek(t,e,r){return r.sort(function(n,i){var a=e(n)||0,s=e(i)||0;return a<s?-1:a>s?1:0})}function Ok(t){var e=os(t.x,2),r=e[0],n=e[1],i=os(t.y,2),a=i[0],s=i[1],l=Math.max(n-r,s-a),c=(n+r)/2,f=(s+a)/2;(l===0||Math.abs(l)===1/0||isNaN(l))&&(l=1),isNaN(c)&&(c=0),isNaN(f)&&(f=0);var p=function(g){return{x:.5+(g.x-c)/l,y:.5+(g.y-f)/l}};return p.applyTo=function(h){h.x=.5+(h.x-c)/l,h.y=.5+(h.y-f)/l},p.inverse=function(h){return{x:c+l*(h.x-.5),y:f+l*(h.y-.5)}},p.ratio=l,p}function qb(t){"@babel/helpers - typeof";return qb=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},qb(t)}function Ak(t,e){var r=e.size;if(r!==0){var n=t.length;t.length+=r;var i=0;e.forEach(function(a){t[n+i]=a,i++})}}function n0(t){t=t||{};for(var e=0,r=arguments.length<=1?0:arguments.length-1;e<r;e++){var n=e+1<1||arguments.length<=e+1?void 0:arguments[e+1];n&&Object.assign(t,n)}return t}var ux={hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderLabels:!0,renderEdgeLabels:!1,enableEdgeEvents:!1,defaultNodeColor:"#999",defaultNodeType:"circle",defaultEdgeColor:"#ccc",defaultEdgeType:"line",labelFont:"Arial",labelSize:14,labelWeight:"normal",labelColor:{color:"#000"},edgeLabelFont:"Arial",edgeLabelSize:14,edgeLabelWeight:"normal",edgeLabelColor:{attribute:"color"},stagePadding:30,defaultDrawEdgeLabel:lY,defaultDrawNodeLabel:lI,defaultDrawNodeHover:cY,minEdgeThickness:1.7,antiAliasingFeather:1,dragTimeout:100,draggedEventsTolerance:3,inertiaDuration:200,inertiaRatio:3,zoomDuration:250,zoomingRatio:1.7,doubleClickTimeout:300,doubleClickZoomingRatio:2.2,doubleClickZoomingDuration:200,tapMoveTolerance:10,zoomToSizeRatioFunction:Math.sqrt,itemSizesReference:"screen",autoRescale:!0,autoCenter:!0,labelDensity:1,labelGridCellSize:100,labelRenderedSizeThreshold:6,nodeReducer:null,edgeReducer:null,zIndex:!1,minCameraRatio:null,maxCameraRatio:null,enableCameraZooming:!0,enableCameraPanning:!0,enableCameraRotation:!0,cameraPanBoundaries:null,allowInvalidContainer:!1,nodeProgramClasses:{},nodeHoverProgramClasses:{},edgeProgramClasses:{}},XY={circle:Yd},YY={arrow:TY,line:DY};function i0(t){if(typeof t.labelDensity!="number"||t.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var e=t.minCameraRatio,r=t.maxCameraRatio;if(typeof e=="number"&&typeof r=="number"&&r<e)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function QY(t){var e=n0({},ux,t);return e.nodeProgramClasses=n0({},XY,e.nodeProgramClasses),e.edgeProgramClasses=n0({},YY,e.edgeProgramClasses),e}var cf=1.5,Pk=(function(t){function e(){var r;return er(this,e),r=zr(this,e),se(r,"x",.5),se(r,"y",.5),se(r,"angle",0),se(r,"ratio",1),se(r,"minRatio",null),se(r,"maxRatio",null),se(r,"enabledZooming",!0),se(r,"enabledPanning",!0),se(r,"enabledRotation",!0),se(r,"clean",null),se(r,"nextFrame",null),se(r,"previousState",null),se(r,"enabled",!0),r.previousState=r.getState(),r}return Ur(e,t),tr(e,[{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"getState",value:function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}},{key:"hasState",value:function(n){return this.x===n.x&&this.y===n.y&&this.ratio===n.ratio&&this.angle===n.angle}},{key:"getPreviousState",value:function(){var n=this.previousState;return n?{x:n.x,y:n.y,angle:n.angle,ratio:n.ratio}:null}},{key:"getBoundedRatio",value:function(n){var i=n;return typeof this.minRatio=="number"&&(i=Math.max(i,this.minRatio)),typeof this.maxRatio=="number"&&(i=Math.min(i,this.maxRatio)),i}},{key:"validateState",value:function(n){var i={};return this.enabledPanning&&typeof n.x=="number"&&(i.x=n.x),this.enabledPanning&&typeof n.y=="number"&&(i.y=n.y),this.enabledZooming&&typeof n.ratio=="number"&&(i.ratio=this.getBoundedRatio(n.ratio)),this.enabledRotation&&typeof n.angle=="number"&&(i.angle=n.angle),this.clean?this.clean(Pe(Pe({},this.getState()),i)):i}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(n){if(!this.enabled)return this;this.previousState=this.getState();var i=this.validateState(n);return typeof i.x=="number"&&(this.x=i.x),typeof i.y=="number"&&(this.y=i.y),typeof i.ratio=="number"&&(this.ratio=i.ratio),typeof i.angle=="number"&&(this.angle=i.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(n){return this.setState(n(this.getState())),this}},{key:"animate",value:function(n){var i=this,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;if(!s)return new Promise(function(y){return i.animate(n,a,y)});if(this.enabled){var l=Pe(Pe({},UY),a),c=this.validateState(n),f=typeof l.easing=="function"?l.easing:zY[l.easing],p=Date.now(),h=this.getState(),g=function(){var S=(Date.now()-p)/l.duration;if(S>=1){i.nextFrame=null,i.setState(c),i.animationCallback&&(i.animationCallback.call(null),i.animationCallback=void 0);return}var w=f(S),b={};typeof c.x=="number"&&(b.x=h.x+(c.x-h.x)*w),typeof c.y=="number"&&(b.y=h.y+(c.y-h.y)*w),i.enabledRotation&&typeof c.angle=="number"&&(b.angle=h.angle+(c.angle-h.angle)*w),typeof c.ratio=="number"&&(b.ratio=h.ratio+(c.ratio-h.ratio)*w),i.setState(b),i.nextFrame=requestAnimationFrame(g)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(g)):g(),this.animationCallback=s}}},{key:"animatedZoom",value:function(n){return n?typeof n=="number"?this.animate({ratio:this.ratio/n}):this.animate({ratio:this.ratio/(n.factor||cf)},n):this.animate({ratio:this.ratio/cf})}},{key:"animatedUnzoom",value:function(n){return n?typeof n=="number"?this.animate({ratio:this.ratio*n}):this.animate({ratio:this.ratio*(n.factor||cf)},n):this.animate({ratio:this.ratio*cf})}},{key:"animatedReset",value:function(n){return this.animate({x:.5,y:.5,ratio:1,angle:0},n)}},{key:"copy",value:function(){return e.from(this.getState())}}],[{key:"from",value:function(n){var i=new e;return i.setState(n)}}])})(sx);function an(t,e){var r=e.getBoundingClientRect();return{x:t.clientX-r.left,y:t.clientY-r.top}}function Wn(t,e){var r=Pe(Pe({},an(t,e)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:t});return r}function mu(t){var e="x"in t?t:Pe(Pe({},t.touches[0]||t.previousTouches[0]),{},{original:t.original,sigmaDefaultPrevented:t.sigmaDefaultPrevented,preventSigmaDefault:function(){t.sigmaDefaultPrevented=!0,e.sigmaDefaultPrevented=!0}});return e}function ZY(t,e){return Pe(Pe({},Wn(t,e)),{},{delta:bI(t)})}var JY=2;function hf(t){for(var e=[],r=0,n=Math.min(t.length,JY);r<n;r++)e.push(t[r]);return e}function yu(t,e,r){var n={touches:hf(t.touches).map(function(i){return an(i,r)}),previousTouches:e.map(function(i){return an(i,r)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:t};return n}function bI(t){if(typeof t.deltaY<"u")return t.deltaY*-3/360;if(typeof t.detail<"u")return t.detail/-9;throw new Error("Captor: could not extract delta from event.")}var wI=(function(t){function e(r,n){var i;return er(this,e),i=zr(this,e),i.container=r,i.renderer=n,i}return Ur(e,t),tr(e)})(sx),eQ=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],tQ=eQ.reduce(function(t,e){return Pe(Pe({},t),{},se({},e,ux[e]))},{}),rQ=(function(t){function e(r,n){var i;return er(this,e),i=zr(this,e,[r,n]),se(i,"enabled",!0),se(i,"draggedEvents",0),se(i,"downStartTime",null),se(i,"lastMouseX",null),se(i,"lastMouseY",null),se(i,"isMouseDown",!1),se(i,"isMoving",!1),se(i,"movingTimeout",null),se(i,"startCameraState",null),se(i,"clicks",0),se(i,"doubleClickTimeout",null),se(i,"currentWheelDirection",0),se(i,"settings",tQ),i.handleClick=i.handleClick.bind(i),i.handleRightClick=i.handleRightClick.bind(i),i.handleDown=i.handleDown.bind(i),i.handleUp=i.handleUp.bind(i),i.handleMove=i.handleMove.bind(i),i.handleWheel=i.handleWheel.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleEnter=i.handleEnter.bind(i),r.addEventListener("click",i.handleClick,{capture:!1}),r.addEventListener("contextmenu",i.handleRightClick,{capture:!1}),r.addEventListener("mousedown",i.handleDown,{capture:!1}),r.addEventListener("wheel",i.handleWheel,{capture:!1}),r.addEventListener("mouseleave",i.handleLeave,{capture:!1}),r.addEventListener("mouseenter",i.handleEnter,{capture:!1}),document.addEventListener("mousemove",i.handleMove,{capture:!1}),document.addEventListener("mouseup",i.handleUp,{capture:!1}),i}return Ur(e,t),tr(e,[{key:"kill",value:function(){var n=this.container;n.removeEventListener("click",this.handleClick),n.removeEventListener("contextmenu",this.handleRightClick),n.removeEventListener("mousedown",this.handleDown),n.removeEventListener("wheel",this.handleWheel),n.removeEventListener("mouseleave",this.handleLeave),n.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(n){var i=this;if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout=="number"&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(n);setTimeout(function(){i.clicks=0,i.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",Wn(n,this.container))}}},{key:"handleRightClick",value:function(n){this.enabled&&this.emit("rightClick",Wn(n,this.container))}},{key:"handleDoubleClick",value:function(n){if(this.enabled){n.preventDefault(),n.stopPropagation();var i=Wn(n,this.container);if(this.emit("doubleClick",i),!i.sigmaDefaultPrevented){var a=this.renderer.getCamera(),s=a.getBoundedRatio(a.getState().ratio/this.settings.doubleClickZoomingRatio);a.animate(this.renderer.getViewportZoomedState(an(n,this.container),s),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(n){if(this.enabled){if(n.button===0){this.startCameraState=this.renderer.getCamera().getState();var i=an(n,this.container),a=i.x,s=i.y;this.lastMouseX=a,this.lastMouseY=s,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",Wn(n,this.container))}}},{key:"handleUp",value:function(n){var i=this;if(!(!this.enabled||!this.isMouseDown)){var a=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var s=an(n,this.container),l=s.x,c=s.y,f=a.getState(),p=a.getPreviousState()||{x:0,y:0};this.isMoving?a.animate({x:f.x+this.settings.inertiaRatio*(f.x-p.x),y:f.y+this.settings.inertiaRatio*(f.y-p.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==l||this.lastMouseY!==c)&&a.setState({x:f.x,y:f.y}),this.isMoving=!1,setTimeout(function(){var h=i.draggedEvents>0;i.draggedEvents=0,h&&i.renderer.getSetting("hideEdgesOnMove")&&i.renderer.refresh()},0),this.emit("mouseup",Wn(n,this.container))}}},{key:"handleMove",value:function(n){var i=this;if(this.enabled){var a=Wn(n,this.container);if(this.emit("mousemovebody",a),(n.target===this.container||n.composedPath()[0]===this.container)&&this.emit("mousemove",a),!a.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.movingTimeout=null,i.isMoving=!1},this.settings.dragTimeout);var s=this.renderer.getCamera(),l=an(n,this.container),c=l.x,f=l.y,p=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),h=this.renderer.viewportToFramedGraph({x:c,y:f}),g=p.x-h.x,y=p.y-h.y,S=s.getState(),w=S.x+g,b=S.y+y;s.setState({x:w,y:b}),this.lastMouseX=c,this.lastMouseY=f,n.preventDefault(),n.stopPropagation()}}}},{key:"handleLeave",value:function(n){this.emit("mouseleave",Wn(n,this.container))}},{key:"handleEnter",value:function(n){this.emit("mouseenter",Wn(n,this.container))}},{key:"handleWheel",value:function(n){var i=this,a=this.renderer.getCamera();if(!(!this.enabled||!a.enabledZooming)){var s=bI(n);if(s){var l=ZY(n,this.container);if(this.emit("wheel",l),l.sigmaDefaultPrevented){n.preventDefault(),n.stopPropagation();return}var c=a.getState().ratio,f=s>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,p=a.getBoundedRatio(c*f),h=s>0?1:-1,g=Date.now();c!==p&&(n.preventDefault(),n.stopPropagation(),!(this.currentWheelDirection===h&&this.lastWheelTriggerTime&&g-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(a.animate(this.renderer.getViewportZoomedState(an(n,this.container),p),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){i.currentWheelDirection=0}),this.currentWheelDirection=h,this.lastWheelTriggerTime=g))}}}},{key:"setSettings",value:function(n){this.settings=n}}])})(wI),nQ=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],iQ=nQ.reduce(function(t,e){return Pe(Pe({},t),{},se({},e,ux[e]))},{}),aQ=(function(t){function e(r,n){var i;return er(this,e),i=zr(this,e,[r,n]),se(i,"enabled",!0),se(i,"isMoving",!1),se(i,"hasMoved",!1),se(i,"touchMode",0),se(i,"startTouchesPositions",[]),se(i,"lastTouches",[]),se(i,"lastTap",null),se(i,"settings",iQ),i.handleStart=i.handleStart.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleMove=i.handleMove.bind(i),r.addEventListener("touchstart",i.handleStart,{capture:!1}),r.addEventListener("touchcancel",i.handleLeave,{capture:!1}),document.addEventListener("touchend",i.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",i.handleMove,{capture:!1,passive:!1}),i}return Ur(e,t),tr(e,[{key:"kill",value:function(){var n=this.container;n.removeEventListener("touchstart",this.handleStart),n.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}},{key:"getDimensions",value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:"handleStart",value:function(n){var i=this;if(this.enabled){n.preventDefault();var a=hf(n.touches);if(this.touchMode=a.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=a.map(function(y){return an(y,i.container)}),this.touchMode===2){var s=os(this.startTouchesPositions,2),l=s[0],c=l.x,f=l.y,p=s[1],h=p.x,g=p.y;this.startTouchesAngle=Math.atan2(g-f,h-c),this.startTouchesDistance=Math.sqrt(Math.pow(h-c,2)+Math.pow(g-f,2))}this.emit("touchdown",yu(n,this.lastTouches,this.container)),this.lastTouches=a,this.lastTouchesPositions=this.startTouchesPositions}}},{key:"handleLeave",value:function(n){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(n.cancelable&&n.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(n.touches.length===1){this.handleStart(n),n.preventDefault();break}case 1:if(this.isMoving){var i=this.renderer.getCamera(),a=i.getState(),s=i.getPreviousState()||{x:0,y:0};i.animate({x:a.x+this.settings.inertiaRatio*(a.x-s.x),y:a.y+this.settings.inertiaRatio*(a.y-s.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",yu(n,this.lastTouches,this.container)),!n.touches.length){var l=an(this.lastTouches[0],this.container),c=this.startTouchesPositions[0],f=Math.pow(l.x-c.x,2)+Math.pow(l.y-c.y,2);if(!n.touches.length&&f<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var p=yu(n,this.lastTouches,this.container);if(this.emit("doubletap",p),this.lastTap=null,!p.sigmaDefaultPrevented){var h=this.renderer.getCamera(),g=h.getBoundedRatio(h.getState().ratio/this.settings.doubleClickZoomingRatio);h.animate(this.renderer.getViewportZoomedState(l,g),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var y=yu(n,this.lastTouches,this.container);this.emit("tap",y),this.lastTap={time:Date.now(),position:y.touches[0]||y.previousTouches[0]}}}this.lastTouches=hf(n.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(n){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){n.preventDefault();var a=hf(n.touches),s=a.map(function(L){return an(L,i.container)}),l=this.lastTouches;this.lastTouches=a,this.lastTouchesPositions=s;var c=yu(n,l,this.container);if(this.emit("touchmove",c),!c.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=s.some(function(L,W){var te=i.startTouchesPositions[W];return te&&(L.x!==te.x||L.y!==te.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.isMoving=!1},this.settings.dragTimeout);var f=this.renderer.getCamera(),p=this.startCameraState,h=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var g=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),y=g.x,S=g.y,w=this.renderer.viewportToFramedGraph(s[0]),b=w.x,E=w.y;f.setState({x:p.x+y-b,y:p.y+S-E});break}case 2:{var P={x:.5,y:.5,angle:0,ratio:1},T=s[0],O=T.x,_=T.y,A=s[1],C=A.x,D=A.y,j=Math.atan2(D-_,C-O)-this.startTouchesAngle,G=Math.hypot(D-_,C-O)/this.startTouchesDistance,z=f.getBoundedRatio(p.ratio/G);P.ratio=z,P.angle=p.angle+j;var $=this.getDimensions(),R=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:p}),X=Math.min($.width,$.height)-2*h,K=X/$.width,B=X/$.height,I=z/X,V=O-X/2/K,J=_-X/2/B,ee=[V*Math.cos(-P.angle)-J*Math.sin(-P.angle),J*Math.cos(-P.angle)+V*Math.sin(-P.angle)];V=ee[0],J=ee[1],P.x=R.x-V*I,P.y=R.y+J*I,f.setState(P);break}}}}}},{key:"setSettings",value:function(n){this.settings=n}}])})(wI);function oQ(t){if(Array.isArray(t))return Gb(t)}function sQ(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function uQ(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
489
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Tk(t){return oQ(t)||sQ(t)||rI(t)||uQ()}function lQ(t,e){if(t==null)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(e.indexOf(n)!==-1)continue;r[n]=t[n]}return r}function a0(t,e){if(t==null)return{};var r,n,i=lQ(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(n=0;n<a.length;n++)r=a[n],e.indexOf(r)===-1&&{}.propertyIsEnumerable.call(t,r)&&(i[r]=t[r])}return i}var Ck=(function(){function t(e,r){er(this,t),this.key=e,this.size=r}return tr(t,null,[{key:"compare",value:function(r,n){return r.size>n.size?-1:r.size<n.size||r.key>n.key?1:-1}}])})(),kk=(function(){function t(){er(this,t),se(this,"width",0),se(this,"height",0),se(this,"cellSize",0),se(this,"columns",0),se(this,"rows",0),se(this,"cells",{})}return tr(t,[{key:"resizeAndClear",value:function(r,n){this.width=r.width,this.height=r.height,this.cellSize=n,this.columns=Math.ceil(r.width/n),this.rows=Math.ceil(r.height/n),this.cells={}}},{key:"getIndex",value:function(r){var n=Math.floor(r.x/this.cellSize),i=Math.floor(r.y/this.cellSize);return i*this.columns+n}},{key:"add",value:function(r,n,i){var a=new Ck(r,n),s=this.getIndex(i),l=this.cells[s];l||(l=[],this.cells[s]=l),l.push(a)}},{key:"organize",value:function(){for(var r in this.cells){var n=this.cells[r];n.sort(Ck.compare)}}},{key:"getLabelsToDisplay",value:function(r,n){var i=this.cellSize*this.cellSize,a=i/r/r,s=a*n/i,l=Math.ceil(s),c=[];for(var f in this.cells)for(var p=this.cells[f],h=0;h<Math.min(l,p.length);h++)c.push(p[h].key);return c}}])})();function cQ(t){var e=t.graph,r=t.hoveredNode,n=t.highlightedNodes,i=t.displayedNodeLabels,a=[];return e.forEachEdge(function(s,l,c,f){(c===r||f===r||n.has(c)||n.has(f)||i.has(c)&&i.has(f))&&a.push(s)}),a}var Rk=150,Dk=50,Kn=Object.prototype.hasOwnProperty;function fQ(t,e,r){if(!Kn.call(r,"x")||!Kn.call(r,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(e,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return r.color||(r.color=t.defaultNodeColor),!r.label&&r.label!==""&&(r.label=null),r.label!==void 0&&r.label!==null?r.label=""+r.label:r.label=null,r.size||(r.size=2),Kn.call(r,"hidden")||(r.hidden=!1),Kn.call(r,"highlighted")||(r.highlighted=!1),Kn.call(r,"forceLabel")||(r.forceLabel=!1),(!r.type||r.type==="")&&(r.type=t.defaultNodeType),r.zIndex||(r.zIndex=0),r}function dQ(t,e,r){return r.color||(r.color=t.defaultEdgeColor),r.label||(r.label=""),r.size||(r.size=.5),Kn.call(r,"hidden")||(r.hidden=!1),Kn.call(r,"forceLabel")||(r.forceLabel=!1),(!r.type||r.type==="")&&(r.type=t.defaultEdgeType),r.zIndex||(r.zIndex=0),r}var hQ=(function(t){function e(r,n){var i,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(er(this,e),i=zr(this,e),se(i,"elements",{}),se(i,"canvasContexts",{}),se(i,"webGLContexts",{}),se(i,"pickingLayers",new Set),se(i,"textures",{}),se(i,"frameBuffers",{}),se(i,"activeListeners",{}),se(i,"labelGrid",new kk),se(i,"nodeDataCache",{}),se(i,"edgeDataCache",{}),se(i,"nodeProgramIndex",{}),se(i,"edgeProgramIndex",{}),se(i,"nodesWithForcedLabels",new Set),se(i,"edgesWithForcedLabels",new Set),se(i,"nodeExtent",{x:[0,1],y:[0,1]}),se(i,"nodeZExtent",[1/0,-1/0]),se(i,"edgeZExtent",[1/0,-1/0]),se(i,"matrix",Jr()),se(i,"invMatrix",Jr()),se(i,"correctionRatio",1),se(i,"customBBox",null),se(i,"normalizationFunction",Ok({x:[0,1],y:[0,1]})),se(i,"graphToViewportRatio",1),se(i,"itemIDsIndex",{}),se(i,"nodeIndices",{}),se(i,"edgeIndices",{}),se(i,"width",0),se(i,"height",0),se(i,"pixelRatio",_k()),se(i,"pickingDownSizingRatio",2*i.pixelRatio),se(i,"displayedNodeLabels",new Set),se(i,"displayedEdgeLabels",new Set),se(i,"highlightedNodes",new Set),se(i,"hoveredNode",null),se(i,"hoveredEdge",null),se(i,"renderFrame",null),se(i,"renderHighlightedNodesFrame",null),se(i,"needToProcess",!1),se(i,"checkEdgesEventsFrame",null),se(i,"nodePrograms",{}),se(i,"nodeHoverPrograms",{}),se(i,"edgePrograms",{}),i.settings=QY(a),i0(i.settings),VY(r),!(n instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");i.graph=r,i.container=n,i.createWebGLContext("edges",{picking:a.enableEdgeEvents}),i.createCanvasContext("edgeLabels"),i.createWebGLContext("nodes",{picking:!0}),i.createCanvasContext("labels"),i.createCanvasContext("hovers"),i.createWebGLContext("hoverNodes"),i.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),i.resize();for(var s in i.settings.nodeProgramClasses)i.registerNodeProgram(s,i.settings.nodeProgramClasses[s],i.settings.nodeHoverProgramClasses[s]);for(var l in i.settings.edgeProgramClasses)i.registerEdgeProgram(l,i.settings.edgeProgramClasses[l]);return i.camera=new Pk,i.bindCameraHandlers(),i.mouseCaptor=new rQ(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new aQ(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return Ur(e,t),tr(e,[{key:"registerNodeProgram",value:function(n,i,a){return this.nodePrograms[n]&&this.nodePrograms[n].kill(),this.nodeHoverPrograms[n]&&this.nodeHoverPrograms[n].kill(),this.nodePrograms[n]=new i(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[n]=new(a||i)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(n,i){return this.edgePrograms[n]&&this.edgePrograms[n].kill(),this.edgePrograms[n]=new i(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(n){if(this.nodePrograms[n]){var i=this.nodePrograms,a=i[n],s=a0(i,[n].map(Tu));a.kill(),this.nodePrograms=s}if(this.nodeHoverPrograms[n]){var l=this.nodeHoverPrograms,c=l[n],f=a0(l,[n].map(Tu));c.kill(),this.nodePrograms=f}return this}},{key:"unregisterEdgeProgram",value:function(n){if(this.edgePrograms[n]){var i=this.edgePrograms,a=i[n],s=a0(i,[n].map(Tu));a.kill(),this.edgePrograms=s}return this}},{key:"resetWebGLTexture",value:function(n){var i=this.webGLContexts[n],a=this.frameBuffers[n],s=this.textures[n];s&&i.deleteTexture(s);var l=i.createTexture();return i.bindFramebuffer(i.FRAMEBUFFER,a),i.bindTexture(i.TEXTURE_2D,l),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,l,0),this.textures[n]=l,this}},{key:"bindCameraHandlers",value:function(){var n=this;return this.activeListeners.camera=function(){n.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(n){var i=n.x,a=n.y,s=dk(this.webGLContexts.nodes,this.frameBuffers.nodes,i,a,this.pixelRatio,this.pickingDownSizingRatio),l=fk.apply(void 0,Tk(s)),c=this.itemIDsIndex[l];return c&&c.type==="node"?c.id:null}},{key:"bindEventHandlers",value:function(){var n=this;this.activeListeners.handleResize=function(){n.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(a){var s=mu(a),l={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}},c=n.getNodeAtPosition(s);if(c&&n.hoveredNode!==c&&!n.nodeDataCache[c].hidden){n.hoveredNode&&n.emit("leaveNode",Pe(Pe({},l),{},{node:n.hoveredNode})),n.hoveredNode=c,n.emit("enterNode",Pe(Pe({},l),{},{node:c})),n.scheduleHighlightedNodesRender();return}if(n.hoveredNode&&n.getNodeAtPosition(s)!==n.hoveredNode){var f=n.hoveredNode;n.hoveredNode=null,n.emit("leaveNode",Pe(Pe({},l),{},{node:f})),n.scheduleHighlightedNodesRender();return}if(n.settings.enableEdgeEvents){var p=n.hoveredNode?null:n.getEdgeAtPoint(l.event.x,l.event.y);p!==n.hoveredEdge&&(n.hoveredEdge&&n.emit("leaveEdge",Pe(Pe({},l),{},{edge:n.hoveredEdge})),p&&n.emit("enterEdge",Pe(Pe({},l),{},{edge:p})),n.hoveredEdge=p)}},this.activeListeners.handleMoveBody=function(a){var s=mu(a);n.emit("moveBody",{event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(a){var s=mu(a),l={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};n.hoveredNode&&(n.emit("leaveNode",Pe(Pe({},l),{},{node:n.hoveredNode})),n.scheduleHighlightedNodesRender()),n.settings.enableEdgeEvents&&n.hoveredEdge&&(n.emit("leaveEdge",Pe(Pe({},l),{},{edge:n.hoveredEdge})),n.scheduleHighlightedNodesRender()),n.emit("leaveStage",Pe({},l))},this.activeListeners.handleEnter=function(a){var s=mu(a),l={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};n.emit("enterStage",Pe({},l))};var i=function(s){return function(l){var c=mu(l),f={event:c,preventSigmaDefault:function(){c.preventSigmaDefault()}},p=n.getNodeAtPosition(c);if(p)return n.emit("".concat(s,"Node"),Pe(Pe({},f),{},{node:p}));if(n.settings.enableEdgeEvents){var h=n.getEdgeAtPoint(c.x,c.y);if(h)return n.emit("".concat(s,"Edge"),Pe(Pe({},f),{},{edge:h}))}return n.emit("".concat(s,"Stage"),f)}};return this.activeListeners.handleClick=i("click"),this.activeListeners.handleRightClick=i("rightClick"),this.activeListeners.handleDoubleClick=i("doubleClick"),this.activeListeners.handleWheel=i("wheel"),this.activeListeners.handleDown=i("down"),this.activeListeners.handleUp=i("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}},{key:"bindGraphHandlers",value:function(){var n=this,i=this.graph,a=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(s){var l,c=(l=s.hints)===null||l===void 0?void 0:l.attributes;n.graph.forEachNode(function(p){return n.updateNode(p)});var f=!c||c.some(function(p){return a.has(p)});n.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!f,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(s){var l,c=(l=s.hints)===null||l===void 0?void 0:l.attributes;n.graph.forEachEdge(function(p){return n.updateEdge(p)});var f=c&&["zIndex","type"].some(function(p){return c==null?void 0:c.includes(p)});n.refresh({partialGraph:{edges:i.edges()},skipIndexation:!f,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(s){var l=s.key;n.addNode(l),n.refresh({partialGraph:{nodes:[l]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(s){var l=s.key;n.refresh({partialGraph:{nodes:[l]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(s){var l=s.key;n.removeNode(l),n.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(s){var l=s.key;n.addEdge(l),n.refresh({partialGraph:{edges:[l]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(s){var l=s.key;n.refresh({partialGraph:{edges:[l]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(s){var l=s.key;n.removeEdge(l),n.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){n.clearEdgeState(),n.clearEdgeIndices(),n.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){n.clearEdgeState(),n.clearNodeState(),n.clearEdgeIndices(),n.clearNodeIndices(),n.refresh({schedule:!0})},i.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),i.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),i.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),i.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),i.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),i.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),i.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),i.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),i.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),i.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var n=this.graph;n.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),n.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),n.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),n.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),n.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),n.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),n.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),n.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),n.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),n.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(n,i){var a=dk(this.webGLContexts.edges,this.frameBuffers.edges,n,i,this.pixelRatio,this.pickingDownSizingRatio),s=fk.apply(void 0,Tk(a)),l=this.itemIDsIndex[s];return l&&l.type==="edge"?l.id:null}},{key:"process",value:function(){var n=this;this.emit("beforeProcess");var i=this.graph,a=this.settings,s=this.getDimensions();if(this.nodeExtent=HY(this.graph),!this.settings.autoRescale){var l=s.width,c=s.height,f=this.nodeExtent,p=f.x,h=f.y;this.nodeExtent={x:[(p[0]+p[1])/2-l/2,(p[0]+p[1])/2+l/2],y:[(h[0]+h[1])/2-c/2,(h[0]+h[1])/2+c/2]}}this.normalizationFunction=Ok(this.customBBox||this.nodeExtent);var g=new Pk,y=gu(g.getState(),s,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(s,a.labelGridCellSize);for(var S={},w={},b={},E={},P=1,T=i.nodes(),O=0,_=T.length;O<_;O++){var A=T[O],C=this.nodeDataCache[A],D=i.getNodeAttributes(A);C.x=D.x,C.y=D.y,this.normalizationFunction.applyTo(C),typeof C.label=="string"&&!C.hidden&&this.labelGrid.add(A,C.size,this.framedGraphToViewport(C,{matrix:y})),S[C.type]=(S[C.type]||0)+1}this.labelGrid.organize();for(var j in this.nodePrograms){if(!Kn.call(this.nodePrograms,j))throw new Error('Sigma: could not find a suitable program for node type "'.concat(j,'"!'));this.nodePrograms[j].reallocate(S[j]||0),S[j]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(T=Ek(this.nodeZExtent,function(xe){return n.nodeDataCache[xe].zIndex},T));for(var G=0,z=T.length;G<z;G++){var $=T[G];w[$]=P,E[w[$]]={type:"node",id:$},P++;var R=this.nodeDataCache[$];this.addNodeToProgram($,w[$],S[R.type]++)}for(var X={},K=i.edges(),B=0,I=K.length;B<I;B++){var V=K[B],J=this.edgeDataCache[V];X[J.type]=(X[J.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(K=Ek(this.edgeZExtent,function(xe){return n.edgeDataCache[xe].zIndex},K));for(var ee in this.edgePrograms){if(!Kn.call(this.edgePrograms,ee))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(ee,'"!'));this.edgePrograms[ee].reallocate(X[ee]||0),X[ee]=0}for(var L=0,W=K.length;L<W;L++){var te=K[L];b[te]=P,E[b[te]]={type:"edge",id:te},P++;var we=this.edgeDataCache[te];this.addEdgeToProgram(te,b[te],X[we.type]++)}return this.itemIDsIndex=E,this.nodeIndices=w,this.edgeIndices=b,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(n){var i=this,a=this.settings;if(this.camera.minRatio=a.minCameraRatio,this.camera.maxRatio=a.maxCameraRatio,this.camera.enabledZooming=a.enableCameraZooming,this.camera.enabledPanning=a.enableCameraPanning,this.camera.enabledRotation=a.enableCameraRotation,a.cameraPanBoundaries?this.camera.clean=function(p){return i.cleanCameraState(p,a.cameraPanBoundaries&&qb(a.cameraPanBoundaries)==="object"?a.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),n){if(n.edgeProgramClasses!==a.edgeProgramClasses){for(var s in a.edgeProgramClasses)a.edgeProgramClasses[s]!==n.edgeProgramClasses[s]&&this.registerEdgeProgram(s,a.edgeProgramClasses[s]);for(var l in n.edgeProgramClasses)a.edgeProgramClasses[l]||this.unregisterEdgeProgram(l)}if(n.nodeProgramClasses!==a.nodeProgramClasses||n.nodeHoverProgramClasses!==a.nodeHoverProgramClasses){for(var c in a.nodeProgramClasses)(a.nodeProgramClasses[c]!==n.nodeProgramClasses[c]||a.nodeHoverProgramClasses[c]!==n.nodeHoverProgramClasses[c])&&this.registerNodeProgram(c,a.nodeProgramClasses[c],a.nodeHoverProgramClasses[c]);for(var f in n.nodeProgramClasses)a.nodeProgramClasses[f]||this.unregisterNodeProgram(f)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=i.tolerance,s=a===void 0?0:a,l=i.boundaries,c=Pe({},n),f=l||this.nodeExtent,p=os(f.x,2),h=p[0],g=p[1],y=os(f.y,2),S=y[0],w=y[1],b=[this.graphToViewport({x:h,y:S},{cameraState:n}),this.graphToViewport({x:g,y:S},{cameraState:n}),this.graphToViewport({x:h,y:w},{cameraState:n}),this.graphToViewport({x:g,y:w},{cameraState:n})],E=1/0,P=-1/0,T=1/0,O=-1/0;b.forEach(function(X){var K=X.x,B=X.y;E=Math.min(E,K),P=Math.max(P,K),T=Math.min(T,B),O=Math.max(O,B)});var _=P-E,A=O-T,C=this.getDimensions(),D=C.width,j=C.height,G=0,z=0;if(_>=D?P<D-s?G=P-(D-s):E>s&&(G=E-s):P>D+s?G=P-(D+s):E<-s&&(G=E+s),A>=j?O<j-s?z=O-(j-s):T>s&&(z=T-s):O>j+s?z=O-(j+s):T<-s&&(z=T+s),G||z){var $=this.viewportToFramedGraph({x:0,y:0},{cameraState:n}),R=this.viewportToFramedGraph({x:G,y:z},{cameraState:n});G=R.x-$.x,z=R.y-$.y,c.x+=G,c.y+=z}return c}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var n=this.camera.getState(),i=this.labelGrid.getLabelsToDisplay(n.ratio,this.settings.labelDensity);Ak(i,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var a=this.canvasContexts.labels,s=0,l=i.length;s<l;s++){var c=i[s],f=this.nodeDataCache[c];if(!this.displayedNodeLabels.has(c)&&!f.hidden){var p=this.framedGraphToViewport(f),h=p.x,g=p.y,y=this.scaleSize(f.size);if(!(!f.forceLabel&&y<this.settings.labelRenderedSizeThreshold)&&!(h<-Rk||h>this.width+Rk||g<-Dk||g>this.height+Dk)){this.displayedNodeLabels.add(c);var S=this.settings.defaultDrawNodeLabel,w=this.nodePrograms[f.type],b=(w==null?void 0:w.drawLabel)||S;b(a,Pe(Pe({key:c},f),{},{size:y,x:h,y:g}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var n=this.canvasContexts.edgeLabels;n.clearRect(0,0,this.width,this.height);var i=cQ({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});Ak(i,this.edgesWithForcedLabels);for(var a=new Set,s=0,l=i.length;s<l;s++){var c=i[s],f=this.graph.extremities(c),p=this.nodeDataCache[f[0]],h=this.nodeDataCache[f[1]],g=this.edgeDataCache[c];if(!a.has(c)&&!(g.hidden||p.hidden||h.hidden)){var y=this.settings.defaultDrawEdgeLabel,S=this.edgePrograms[g.type],w=(S==null?void 0:S.drawLabel)||y;w(n,Pe(Pe({key:c},g),{},{size:this.scaleSize(g.size)}),Pe(Pe(Pe({key:f[0]},p),this.framedGraphToViewport(p)),{},{size:this.scaleSize(p.size)}),Pe(Pe(Pe({key:f[1]},h),this.framedGraphToViewport(h)),{},{size:this.scaleSize(h.size)}),this.settings),a.add(c)}}return this.displayedEdgeLabels=a,this}},{key:"renderHighlightedNodes",value:function(){var n=this,i=this.canvasContexts.hovers;i.clearRect(0,0,this.width,this.height);var a=function(y){var S=n.nodeDataCache[y],w=n.framedGraphToViewport(S),b=w.x,E=w.y,P=n.scaleSize(S.size),T=n.settings.defaultDrawNodeHover,O=n.nodePrograms[S.type],_=(O==null?void 0:O.drawHover)||T;_(i,Pe(Pe({key:y},S),{},{size:P,x:b,y:E}),n.settings)},s=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&s.push(this.hoveredNode),this.highlightedNodes.forEach(function(g){g!==n.hoveredNode&&s.push(g)}),s.forEach(function(g){return a(g)});var l={};s.forEach(function(g){var y=n.nodeDataCache[g].type;l[y]=(l[y]||0)+1});for(var c in this.nodeHoverPrograms)this.nodeHoverPrograms[c].reallocate(l[c]||0),l[c]=0;s.forEach(function(g){var y=n.nodeDataCache[g];n.nodeHoverPrograms[y.type].process(0,l[y.type]++,y)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var f=this.getRenderParams();for(var p in this.nodeHoverPrograms){var h=this.nodeHoverPrograms[p];h.render(f)}}},{key:"scheduleHighlightedNodesRender",value:function(){var n=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){n.renderHighlightedNodesFrame=null,n.renderHighlightedNodes(),n.renderEdgeLabels()}))}},{key:"render",value:function(){var n=this;this.emit("beforeRender");var i=function(){return n.emit("afterRender"),n};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(b){return n.resetWebGLTexture(b)}),!this.graph.order)return i();var a=this.mouseCaptor,s=this.camera.isAnimated()||a.isMoving||a.draggedEvents||a.currentWheelDirection,l=this.camera.getState(),c=this.getDimensions(),f=this.getGraphDimensions(),p=this.getStagePadding();this.matrix=gu(l,c,f,p),this.invMatrix=gu(l,c,f,p,!0),this.correctionRatio=WY(this.matrix,l,c),this.graphToViewportRatio=this.getGraphToViewportRatio();var h=this.getRenderParams();for(var g in this.nodePrograms){var y=this.nodePrograms[g];y.render(h)}if(!this.settings.hideEdgesOnMove||!s)for(var S in this.edgePrograms){var w=this.edgePrograms[S];w.render(h)}return this.settings.hideLabelsOnMove&&s||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),i()}},{key:"addNode",value:function(n){var i=Object.assign({},this.graph.getNodeAttributes(n));this.settings.nodeReducer&&(i=this.settings.nodeReducer(n,i));var a=fQ(this.settings,n,i);this.nodeDataCache[n]=a,this.nodesWithForcedLabels.delete(n),a.forceLabel&&!a.hidden&&this.nodesWithForcedLabels.add(n),this.highlightedNodes.delete(n),a.highlighted&&!a.hidden&&this.highlightedNodes.add(n),this.settings.zIndex&&(a.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=a.zIndex),a.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=a.zIndex))}},{key:"updateNode",value:function(n){this.addNode(n);var i=this.nodeDataCache[n];this.normalizationFunction.applyTo(i)}},{key:"removeNode",value:function(n){delete this.nodeDataCache[n],delete this.nodeProgramIndex[n],this.highlightedNodes.delete(n),this.hoveredNode===n&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(n)}},{key:"addEdge",value:function(n){var i=Object.assign({},this.graph.getEdgeAttributes(n));this.settings.edgeReducer&&(i=this.settings.edgeReducer(n,i));var a=dQ(this.settings,n,i);this.edgeDataCache[n]=a,this.edgesWithForcedLabels.delete(n),a.forceLabel&&!a.hidden&&this.edgesWithForcedLabels.add(n),this.settings.zIndex&&(a.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=a.zIndex),a.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=a.zIndex))}},{key:"updateEdge",value:function(n){this.addEdge(n)}},{key:"removeEdge",value:function(n){delete this.edgeDataCache[n],delete this.edgeProgramIndex[n],this.hoveredEdge===n&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(n)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new kk,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(n,i,a){var s=this.nodeDataCache[n],l=this.nodePrograms[s.type];if(!l)throw new Error('Sigma: could not find a suitable program for node type "'.concat(s.type,'"!'));l.process(i,a,s),this.nodeProgramIndex[n]=a}},{key:"addEdgeToProgram",value:function(n,i,a){var s=this.edgeDataCache[n],l=this.edgePrograms[s.type];if(!l)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(s.type,'"!'));var c=this.graph.extremities(n),f=this.nodeDataCache[c[0]],p=this.nodeDataCache[c[1]];l.process(i,a,f,p,s),this.edgeProgramIndex[n]=a}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var n=this.settings,i=n.stagePadding,a=n.autoRescale;return a&&i||0}},{key:"createLayer",value:function(n,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[n])throw new Error('Sigma: a layer named "'.concat(n,'" already exists'));var s=KY(i,{position:"absolute"},{class:"sigma-".concat(n)});return a.style&&Object.assign(s.style,a.style),this.elements[n]=s,"beforeLayer"in a&&a.beforeLayer?this.elements[a.beforeLayer].before(s):"afterLayer"in a&&a.afterLayer?this.elements[a.afterLayer].after(s):this.container.appendChild(s),s}},{key:"createCanvas",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(n,"canvas",i)}},{key:"createCanvasContext",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=this.createCanvas(n,i),s={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[n]=a.getContext("2d",s),this}},{key:"createWebGLContext",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=(i==null?void 0:i.canvas)||this.createCanvas(n,i);i.hidden&&a.remove();var s=Pe({preserveDrawingBuffer:!1,antialias:!1},i),l;l=a.getContext("webgl2",s),l||(l=a.getContext("webgl",s)),l||(l=a.getContext("experimental-webgl",s));var c=l;if(this.webGLContexts[n]=c,c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA),i.picking){this.pickingLayers.add(n);var f=c.createFramebuffer();if(!f)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(n));this.frameBuffers[n]=f}return c}},{key:"killLayer",value:function(n){var i=this.elements[n];if(!i)throw new Error("Sigma: cannot kill layer ".concat(n,", which does not exist"));if(this.webGLContexts[n]){var a,s=this.webGLContexts[n];(a=s.getExtension("WEBGL_lose_context"))===null||a===void 0||a.loseContext(),delete this.webGLContexts[n]}else this.canvasContexts[n]&&delete this.canvasContexts[n];return i.remove(),delete this.elements[n],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(n){this.unbindCameraHandlers(),this.camera=n,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(n){n!==this.graph&&(this.hoveredNode&&!n.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!n.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=n,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var n=this.customBBox||this.nodeExtent;return{width:n.x[1]-n.x[0]||1,height:n.y[1]-n.y[0]||1}}},{key:"getNodeDisplayData",value:function(n){var i=this.nodeDataCache[n];return i?Object.assign({},i):void 0}},{key:"getEdgeDisplayData",value:function(n){var i=this.edgeDataCache[n];return i?Object.assign({},i):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return Pe({},this.settings)}},{key:"getSetting",value:function(n){return this.settings[n]}},{key:"setSetting",value:function(n,i){var a=Pe({},this.settings);return this.settings[n]=i,i0(this.settings),this.handleSettingsUpdate(a),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(n,i){return this.setSetting(n,i(this.settings[n])),this}},{key:"setSettings",value:function(n){var i=Pe({},this.settings);return this.settings=Pe(Pe({},this.settings),n),i0(this.settings),this.handleSettingsUpdate(i),this.scheduleRefresh(),this}},{key:"resize",value:function(n){var i=this.width,a=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=_k(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!n&&i===this.width&&a===this.height)return this;for(var s in this.elements){var l=this.elements[s];l.style.width=this.width+"px",l.style.height=this.height+"px"}for(var c in this.canvasContexts)this.elements[c].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[c].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[c].scale(this.pixelRatio,this.pixelRatio);for(var f in this.webGLContexts){this.elements[f].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[f].setAttribute("height",this.height*this.pixelRatio+"px");var p=this.webGLContexts[f];if(p.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(f)){var h=this.textures[f];h&&p.deleteTexture(h)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(n){var i=this,a=(n==null?void 0:n.skipIndexation)!==void 0?n==null?void 0:n.skipIndexation:!1,s=(n==null?void 0:n.schedule)!==void 0?n.schedule:!1,l=!n||!n.partialGraph;if(l)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(O){return i.addNode(O)}),this.graph.forEachEdge(function(O){return i.addEdge(O)});else{for(var c,f,p=((c=n.partialGraph)===null||c===void 0?void 0:c.nodes)||[],h=0,g=(p==null?void 0:p.length)||0;h<g;h++){var y=p[h];if(this.updateNode(y),a){var S=this.nodeProgramIndex[y];if(S===void 0)throw new Error('Sigma: node "'.concat(y,`" can't be repaint`));this.addNodeToProgram(y,this.nodeIndices[y],S)}}for(var w=(n==null||(f=n.partialGraph)===null||f===void 0?void 0:f.edges)||[],b=0,E=w.length;b<E;b++){var P=w[b];if(this.updateEdge(P),a){var T=this.edgeProgramIndex[P];if(T===void 0)throw new Error('Sigma: edge "'.concat(P,`" can't be repaint`));this.addEdgeToProgram(P,this.edgeIndices[P],T)}}}return(l||!a)&&(this.needToProcess=!0),s?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var n=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){n.render()})),this}},{key:"scheduleRefresh",value:function(n){return this.refresh(Pe(Pe({},n),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(n,i){var a=this.camera.getState(),s=a.ratio,l=a.angle,c=a.x,f=a.y,p=this.settings,h=p.minCameraRatio,g=p.maxCameraRatio;typeof g=="number"&&(i=Math.min(i,g)),typeof h=="number"&&(i=Math.max(i,h));var y=i/s,S={x:this.width/2,y:this.height/2},w=this.viewportToFramedGraph(n),b=this.viewportToFramedGraph(S);return{angle:l,x:(w.x-b.x)*(1-y)+c,y:(w.y-b.y)*(1-y)+f,ratio:i}}},{key:"viewRectangle",value:function(){var n=this.viewportToFramedGraph({x:0,y:0}),i=this.viewportToFramedGraph({x:this.width,y:0}),a=this.viewportToFramedGraph({x:0,y:this.height});return{x1:n.x,y1:n.y,x2:i.x,y2:i.y,height:i.y-a.y}}},{key:"framedGraphToViewport",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=!!i.cameraState||!!i.viewportDimensions||!!i.graphDimensions,s=i.matrix?i.matrix:a?gu(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,l=Ub(s,n);return{x:(1+l.x)*this.width/2,y:(1-l.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=!!i.cameraState||!!i.viewportDimensions||!i.graphDimensions,s=i.matrix?i.matrix:a?gu(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,l=Ub(s,{x:n.x/this.width*2-1,y:1-n.y/this.height*2});return isNaN(l.x)&&(l.x=0),isNaN(l.y)&&(l.y=0),l}},{key:"viewportToGraph",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(n,i))}},{key:"graphToViewport",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(n),i)}},{key:"getGraphToViewportRatio",value:function(){var n={x:0,y:0},i={x:1,y:1},a=Math.sqrt(Math.pow(n.x-i.x,2)+Math.pow(n.y-i.y,2)),s=this.graphToViewport(n),l=this.graphToViewport(i),c=Math.sqrt(Math.pow(s.x-l.x,2)+Math.pow(s.y-l.y,2));return c/a}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(n){return this.customBBox=n,this.scheduleRender(),this}},{key:"kill",value:function(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);for(var n=this.container;n.firstChild;)n.removeChild(n.firstChild);for(var i in this.nodePrograms)this.nodePrograms[i].kill();for(var a in this.nodeHoverPrograms)this.nodeHoverPrograms[a].kill();for(var s in this.edgePrograms)this.edgePrograms[s].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var l in this.elements)this.killLayer(l);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return n/this.settings.zoomToSizeRatioFunction(i)*(this.getSetting("itemSizesReference")==="positions"?i*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var n={};for(var i in this.elements)this.elements[i]instanceof HTMLCanvasElement&&(n[i]=this.elements[i]);return n}}])})(sx);const xI=N.createContext(null),pQ=xI.Provider;function SI(){const t=N.useContext(xI);if(t==null)throw new Error("No context provided: useSigmaContext() can only be used in a descendant of <SigmaContainer>");return t}function lx(){return SI().sigma}function vQ(){const{sigma:t}=SI();return N.useCallback((e=>{t&&Object.keys(e).forEach((r=>{t.setSetting(r,e[r])}))}),[t])}function Qd(t){return new Set(Object.keys(t))}const jk=Qd({clickNode:!0,rightClickNode:!0,downNode:!0,enterNode:!0,leaveNode:!0,doubleClickNode:!0,wheelNode:!0,clickEdge:!0,rightClickEdge:!0,downEdge:!0,enterEdge:!0,leaveEdge:!0,doubleClickEdge:!0,wheelEdge:!0,clickStage:!0,rightClickStage:!0,downStage:!0,doubleClickStage:!0,wheelStage:!0,beforeRender:!0,afterRender:!0,kill:!0,upStage:!0,upEdge:!0,upNode:!0,enterStage:!0,leaveStage:!0,resize:!0,afterClear:!0,afterProcess:!0,beforeClear:!0,beforeProcess:!0,moveBody:!0}),Ik=Qd({click:!0,rightClick:!0,doubleClick:!0,mouseup:!0,mousedown:!0,mousemove:!0,mousemovebody:!0,mouseleave:!0,mouseenter:!0,wheel:!0}),Nk=Qd({touchup:!0,touchdown:!0,touchmove:!0,touchmovebody:!0,tap:!0,doubletap:!0}),Mk=Qd({updated:!0});function gQ(){const t=lx(),e=vQ(),[r,n]=N.useState({});return N.useEffect((()=>{if(!t||!r)return;const i=r,a=Object.keys(i);return a.forEach((s=>{const l=i[s];jk.has(s)&&t.on(s,l),Ik.has(s)&&t.getMouseCaptor().on(s,l),Nk.has(s)&&t.getTouchCaptor().on(s,l),Mk.has(s)&&t.getCamera().on(s,l)})),()=>{t&&a.forEach((s=>{const l=i[s];jk.has(s)&&t.off(s,l),Ik.has(s)&&t.getMouseCaptor().off(s,l),Nk.has(s)&&t.getTouchCaptor().off(s,l),Mk.has(s)&&t.getCamera().off(s,l)}))}}),[t,r,e]),n}function mQ(){const t=lx();return N.useCallback(((e,r=!0)=>{t&&e&&(r&&t.getGraph().order>0&&t.getGraph().clear(),t.getGraph().import(e),t.refresh())}),[t])}function _I(t,e){if(t===e)return!0;if(typeof t=="object"&&t!=null&&typeof e=="object"&&e!=null){if(Object.keys(t).length!=Object.keys(e).length)return!1;for(const r in t)if(!Object.hasOwn(e,r)||!_I(t[r],e[r]))return!1;return!0}return!1}const yQ=N.forwardRef((({graph:t,id:e,className:r,style:n,settings:i={},children:a},s)=>{const l=N.useRef(null),c=N.useRef(null),f={className:`react-sigma ${r||""}`,id:e,style:n},[p,h]=N.useState(null),[g,y]=N.useState(i);N.useEffect((()=>{y((b=>_I(b,i)?b:i))}),[i]),N.useEffect((()=>{let b=null;if(c.current!==null){let E=new Ze;t&&(E=typeof t=="function"?new t:t),b=new hQ(E,c.current,g),h((P=>{let T=null;return P&&(T=P.getCamera().getState()),T&&b.getCamera().setState(T),b}))}return()=>{b&&b.kill()}}),[c,t,g]),N.useImperativeHandle(s,(()=>p),[p]);const S=N.useMemo((()=>p&&l.current?{sigma:p,container:l.current}:null),[p,l]),w=S!==null?Q.createElement(pQ,{value:S},a):null;return Q.createElement("div",Object.assign({},f,{ref:l}),Q.createElement("div",{className:"sigma-container",ref:c}),w)}));var bu={},Lk;function bQ(){if(Lk)return bu;Lk=1;function t(n){return typeof n!="number"||isNaN(n)?1:n}function e(n,i){var a={},s=function(f){return typeof f>"u"?i:f};typeof i=="function"&&(s=i);var l=function(f){return s(f[n])},c=function(){return s(void 0)};return typeof n=="string"?(a.fromAttributes=l,a.fromGraph=function(f,p){return l(f.getNodeAttributes(p))},a.fromEntry=function(f,p){return l(p)}):typeof n=="function"?(a.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},a.fromGraph=function(f,p){return s(n(p,f.getNodeAttributes(p)))},a.fromEntry=function(f,p){return s(n(f,p))}):(a.fromAttributes=c,a.fromGraph=c,a.fromEntry=c),a}function r(n,i){var a={},s=function(f){return typeof f>"u"?i:f};typeof i=="function"&&(s=i);var l=function(f){return s(f[n])},c=function(){return s(void 0)};return typeof n=="string"?(a.fromAttributes=l,a.fromGraph=function(f,p){return l(f.getEdgeAttributes(p))},a.fromEntry=function(f,p){return l(p)},a.fromPartialEntry=a.fromEntry,a.fromMinimalEntry=a.fromEntry):typeof n=="function"?(a.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},a.fromGraph=function(f,p){var h=f.extremities(p);return s(n(p,f.getEdgeAttributes(p),h[0],h[1],f.getNodeAttributes(h[0]),f.getNodeAttributes(h[1]),f.isUndirected(p)))},a.fromEntry=function(f,p,h,g,y,S,w){return s(n(f,p,h,g,y,S,w))},a.fromPartialEntry=function(f,p,h,g){return s(n(f,p,h,g))},a.fromMinimalEntry=function(f,p){return s(n(f,p))}):(a.fromAttributes=c,a.fromGraph=c,a.fromEntry=c,a.fromMinimalEntry=c),a}return bu.createNodeValueGetter=e,bu.createEdgeValueGetter=r,bu.createEdgeWeightGetter=function(n){return r(n,t)},bu}var o0,$k;function wQ(){if($k)return o0;$k=1;var t=0,e=1,r=2,n=3,i=4,a=5,s=6,l=7,c=8,f=9,p=0,h=1,g=2,y=0,S=1,w=2,b=3,E=4,P=5,T=6,O=7,_=8,A=3,C=10,D=3,j=9,G=10;return o0=function($,R,X){var K,B,I,V,J,ee,L,W,te,we,xe=R.length,Ie=X.length,Le=$.adjustSizes,Me=$.barnesHutTheta*$.barnesHutTheta,le,pe,ve,ie,Fe,de,ge,ne=[];for(I=0;I<xe;I+=C)R[I+i]=R[I+r],R[I+a]=R[I+n],R[I+r]=0,R[I+n]=0;if($.outboundAttractionDistribution){for(le=0,I=0;I<xe;I+=C)le+=R[I+s];le/=xe/C}if($.barnesHutOptimize){var it=1/0,kt=-1/0,Rt=1/0,Bt=-1/0,rt,Dt,cn;for(I=0;I<xe;I+=C)it=Math.min(it,R[I+t]),kt=Math.max(kt,R[I+t]),Rt=Math.min(Rt,R[I+e]),Bt=Math.max(Bt,R[I+e]);var fn=kt-it,dn=Bt-Rt;for(fn>dn?(Rt-=(fn-dn)/2,Bt=Rt+fn):(it-=(dn-fn)/2,kt=it+dn),ne[0+y]=-1,ne[0+S]=(it+kt)/2,ne[0+w]=(Rt+Bt)/2,ne[0+b]=Math.max(kt-it,Bt-Rt),ne[0+E]=-1,ne[0+P]=-1,ne[0+T]=0,ne[0+O]=0,ne[0+_]=0,K=1,I=0;I<xe;I+=C)for(B=0,cn=A;;)if(ne[B+P]>=0){R[I+t]<ne[B+S]?R[I+e]<ne[B+w]?rt=ne[B+P]:rt=ne[B+P]+j:R[I+e]<ne[B+w]?rt=ne[B+P]+j*2:rt=ne[B+P]+j*3,ne[B+O]=(ne[B+O]*ne[B+T]+R[I+t]*R[I+s])/(ne[B+T]+R[I+s]),ne[B+_]=(ne[B+_]*ne[B+T]+R[I+e]*R[I+s])/(ne[B+T]+R[I+s]),ne[B+T]+=R[I+s],B=rt;continue}else if(ne[B+y]<0){ne[B+y]=I;break}else{if(ne[B+P]=K*j,W=ne[B+b]/2,te=ne[B+P],ne[te+y]=-1,ne[te+S]=ne[B+S]-W,ne[te+w]=ne[B+w]-W,ne[te+b]=W,ne[te+E]=te+j,ne[te+P]=-1,ne[te+T]=0,ne[te+O]=0,ne[te+_]=0,te+=j,ne[te+y]=-1,ne[te+S]=ne[B+S]-W,ne[te+w]=ne[B+w]+W,ne[te+b]=W,ne[te+E]=te+j,ne[te+P]=-1,ne[te+T]=0,ne[te+O]=0,ne[te+_]=0,te+=j,ne[te+y]=-1,ne[te+S]=ne[B+S]+W,ne[te+w]=ne[B+w]-W,ne[te+b]=W,ne[te+E]=te+j,ne[te+P]=-1,ne[te+T]=0,ne[te+O]=0,ne[te+_]=0,te+=j,ne[te+y]=-1,ne[te+S]=ne[B+S]+W,ne[te+w]=ne[B+w]+W,ne[te+b]=W,ne[te+E]=ne[B+E],ne[te+P]=-1,ne[te+T]=0,ne[te+O]=0,ne[te+_]=0,K+=4,R[ne[B+y]+t]<ne[B+S]?R[ne[B+y]+e]<ne[B+w]?rt=ne[B+P]:rt=ne[B+P]+j:R[ne[B+y]+e]<ne[B+w]?rt=ne[B+P]+j*2:rt=ne[B+P]+j*3,ne[B+T]=R[ne[B+y]+s],ne[B+O]=R[ne[B+y]+t],ne[B+_]=R[ne[B+y]+e],ne[rt+y]=ne[B+y],ne[B+y]=-1,R[I+t]<ne[B+S]?R[I+e]<ne[B+w]?Dt=ne[B+P]:Dt=ne[B+P]+j:R[I+e]<ne[B+w]?Dt=ne[B+P]+j*2:Dt=ne[B+P]+j*3,rt===Dt)if(cn--){B=rt;continue}else{cn=A;break}ne[Dt+y]=I;break}}if($.barnesHutOptimize)for(pe=$.scalingRatio,I=0;I<xe;I+=C)for(B=0;;)if(ne[B+P]>=0)if(de=Math.pow(R[I+t]-ne[B+O],2)+Math.pow(R[I+e]-ne[B+_],2),we=ne[B+b],4*we*we/de<Me){if(ve=R[I+t]-ne[B+O],ie=R[I+e]-ne[B+_],Le===!0?de>0?(ge=pe*R[I+s]*ne[B+T]/de,R[I+r]+=ve*ge,R[I+n]+=ie*ge):de<0&&(ge=-pe*R[I+s]*ne[B+T]/Math.sqrt(de),R[I+r]+=ve*ge,R[I+n]+=ie*ge):de>0&&(ge=pe*R[I+s]*ne[B+T]/de,R[I+r]+=ve*ge,R[I+n]+=ie*ge),B=ne[B+E],B<0)break;continue}else{B=ne[B+P];continue}else{if(ee=ne[B+y],ee>=0&&ee!==I&&(ve=R[I+t]-R[ee+t],ie=R[I+e]-R[ee+e],de=ve*ve+ie*ie,Le===!0?de>0?(ge=pe*R[I+s]*R[ee+s]/de,R[I+r]+=ve*ge,R[I+n]+=ie*ge):de<0&&(ge=-pe*R[I+s]*R[ee+s]/Math.sqrt(de),R[I+r]+=ve*ge,R[I+n]+=ie*ge):de>0&&(ge=pe*R[I+s]*R[ee+s]/de,R[I+r]+=ve*ge,R[I+n]+=ie*ge)),B=ne[B+E],B<0)break;continue}else for(pe=$.scalingRatio,V=0;V<xe;V+=C)for(J=0;J<V;J+=C)ve=R[V+t]-R[J+t],ie=R[V+e]-R[J+e],Le===!0?(de=Math.sqrt(ve*ve+ie*ie)-R[V+c]-R[J+c],de>0?(ge=pe*R[V+s]*R[J+s]/de/de,R[V+r]+=ve*ge,R[V+n]+=ie*ge,R[J+r]-=ve*ge,R[J+n]-=ie*ge):de<0&&(ge=100*pe*R[V+s]*R[J+s],R[V+r]+=ve*ge,R[V+n]+=ie*ge,R[J+r]-=ve*ge,R[J+n]-=ie*ge)):(de=Math.sqrt(ve*ve+ie*ie),de>0&&(ge=pe*R[V+s]*R[J+s]/de/de,R[V+r]+=ve*ge,R[V+n]+=ie*ge,R[J+r]-=ve*ge,R[J+n]-=ie*ge));for(te=$.gravity/$.scalingRatio,pe=$.scalingRatio,I=0;I<xe;I+=C)ge=0,ve=R[I+t],ie=R[I+e],de=Math.sqrt(Math.pow(ve,2)+Math.pow(ie,2)),$.strongGravityMode?de>0&&(ge=pe*R[I+s]*te):de>0&&(ge=pe*R[I+s]*te/de),R[I+r]-=ve*ge,R[I+n]-=ie*ge;for(pe=1*($.outboundAttractionDistribution?le:1),L=0;L<Ie;L+=D)V=X[L+p],J=X[L+h],W=X[L+g],Fe=Math.pow(W,$.edgeWeightInfluence),ve=R[V+t]-R[J+t],ie=R[V+e]-R[J+e],Le===!0?(de=Math.sqrt(ve*ve+ie*ie)-R[V+c]-R[J+c],$.linLogMode?$.outboundAttractionDistribution?de>0&&(ge=-pe*Fe*Math.log(1+de)/de/R[V+s]):de>0&&(ge=-pe*Fe*Math.log(1+de)/de):$.outboundAttractionDistribution?de>0&&(ge=-pe*Fe/R[V+s]):de>0&&(ge=-pe*Fe)):(de=Math.sqrt(Math.pow(ve,2)+Math.pow(ie,2)),$.linLogMode?$.outboundAttractionDistribution?de>0&&(ge=-pe*Fe*Math.log(1+de)/de/R[V+s]):de>0&&(ge=-pe*Fe*Math.log(1+de)/de):$.outboundAttractionDistribution?(de=1,ge=-pe*Fe/R[V+s]):(de=1,ge=-pe*Fe)),de>0&&(R[V+r]+=ve*ge,R[V+n]+=ie*ge,R[J+r]-=ve*ge,R[J+n]-=ie*ge);var Xi,Dn,jn,hn,pn,vn;if(Le===!0)for(I=0;I<xe;I+=C)R[I+f]!==1&&(Xi=Math.sqrt(Math.pow(R[I+r],2)+Math.pow(R[I+n],2)),Xi>G&&(R[I+r]=R[I+r]*G/Xi,R[I+n]=R[I+n]*G/Xi),Dn=R[I+s]*Math.sqrt((R[I+i]-R[I+r])*(R[I+i]-R[I+r])+(R[I+a]-R[I+n])*(R[I+a]-R[I+n])),jn=Math.sqrt((R[I+i]+R[I+r])*(R[I+i]+R[I+r])+(R[I+a]+R[I+n])*(R[I+a]+R[I+n]))/2,hn=.1*Math.log(1+jn)/(1+Math.sqrt(Dn)),pn=R[I+t]+R[I+r]*(hn/$.slowDown),R[I+t]=pn,vn=R[I+e]+R[I+n]*(hn/$.slowDown),R[I+e]=vn);else for(I=0;I<xe;I+=C)R[I+f]!==1&&(Dn=R[I+s]*Math.sqrt((R[I+i]-R[I+r])*(R[I+i]-R[I+r])+(R[I+a]-R[I+n])*(R[I+a]-R[I+n])),jn=Math.sqrt((R[I+i]+R[I+r])*(R[I+i]+R[I+r])+(R[I+a]+R[I+n])*(R[I+a]+R[I+n]))/2,hn=R[I+l]*Math.log(1+jn)/(1+Math.sqrt(Dn)),R[I+l]=Math.min(1,Math.sqrt(hn*(Math.pow(R[I+r],2)+Math.pow(R[I+n],2))/(1+Math.sqrt(Dn)))),pn=R[I+t]+R[I+r]*(hn/$.slowDown),R[I+t]=pn,vn=R[I+e]+R[I+n]*(hn/$.slowDown),R[I+e]=vn);return{}},o0}var Un={},Fk;function xQ(){if(Fk)return Un;Fk=1;var t=10,e=3;return Un.assign=function(r){r=r||{};var n=Array.prototype.slice.call(arguments).slice(1),i,a,s;for(i=0,s=n.length;i<s;i++)if(n[i])for(a in n[i])r[a]=n[i][a];return r},Un.validateSettings=function(r){return"linLogMode"in r&&typeof r.linLogMode!="boolean"?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in r&&typeof r.outboundAttractionDistribution!="boolean"?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in r&&typeof r.adjustSizes!="boolean"?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in r&&typeof r.edgeWeightInfluence!="number"?{message:"the `edgeWeightInfluence` setting should be a number."}:"scalingRatio"in r&&!(typeof r.scalingRatio=="number"&&r.scalingRatio>=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in r&&typeof r.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in r&&!(typeof r.gravity=="number"&&r.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in r&&!(typeof r.slowDown=="number"||r.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in r&&typeof r.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in r&&!(typeof r.barnesHutTheta=="number"&&r.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null},Un.graphToByteArrays=function(r,n){var i=r.order,a=r.size,s={},l,c=new Float32Array(i*t),f=new Float32Array(a*e);return l=0,r.forEachNode(function(p,h){s[p]=l,c[l]=h.x,c[l+1]=h.y,c[l+2]=0,c[l+3]=0,c[l+4]=0,c[l+5]=0,c[l+6]=1,c[l+7]=1,c[l+8]=h.size||1,c[l+9]=h.fixed?1:0,l+=t}),l=0,r.forEachEdge(function(p,h,g,y,S,w,b){var E=s[g],P=s[y],T=n(p,h,g,y,S,w,b);c[E+6]+=T,c[P+6]+=T,f[l]=E,f[l+1]=P,f[l+2]=T,l+=e}),{nodes:c,edges:f}},Un.assignLayoutChanges=function(r,n,i){var a=0;r.updateEachNodeAttributes(function(s,l){return l.x=n[a],l.y=n[a+1],a+=t,i?i(s,l):l})},Un.readGraphPositions=function(r,n){var i=0;r.forEachNode(function(a,s){n[i]=s.x,n[i+1]=s.y,i+=t})},Un.collectLayoutChanges=function(r,n,i){for(var a=r.nodes(),s={},l=0,c=0,f=n.length;l<f;l+=t){if(i){var p=Object.assign({},r.getNodeAttributes(a[c]));p.x=n[l],p.y=n[l+1],p=i(a[c],p),s[a[c]]={x:p.x,y:p.y}}else s[a[c]]={x:n[l],y:n[l+1]};c++}return s},Un.createWorker=function(n){var i=window.URL||window.webkitURL,a=n.toString(),s=i.createObjectURL(new Blob(["("+a+").call(this);"],{type:"text/javascript"})),l=new Worker(s);return i.revokeObjectURL(s),l},Un}var s0,Bk;function SQ(){return Bk||(Bk=1,s0={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}),s0}var u0,Gk;function _Q(){if(Gk)return u0;Gk=1;var t=yI(),e=bQ().createEdgeWeightGetter,r=wQ(),n=xQ(),i=SQ();function a(c,f,p){if(!t(f))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof p=="number"&&(p={iterations:p});var h=p.iterations;if(typeof h!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(h<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var g=e("getEdgeWeight"in p?p.getEdgeWeight:"weight").fromEntry,y=typeof p.outputReducer=="function"?p.outputReducer:null,S=n.assign({},i,p.settings),w=n.validateSettings(S);if(w)throw new Error("graphology-layout-forceatlas2: "+w.message);var b=n.graphToByteArrays(f,g),E;for(E=0;E<h;E++)r(S,b.nodes,b.edges);if(c){n.assignLayoutChanges(f,b.nodes,y);return}return n.collectLayoutChanges(f,b.nodes)}function s(c){var f=typeof c=="number"?c:c.order;return{barnesHutOptimize:f>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(f)}}var l=a.bind(null,!1);return l.assign=a.bind(null,!0),l.inferSettings=s,u0=l,u0}var EQ=_Q();const zk=tt(EQ);function OQ({graph:t}){const e=mQ();return N.useEffect(()=>{e(t)},[t,e]),null}function AQ({onNodeClick:t,onNodeHover:e}){const r=lx(),n=gQ();return N.useEffect(()=>{n({clickNode:i=>t==null?void 0:t(i.node),enterNode:i=>e==null?void 0:e(i.node),leaveNode:()=>e==null?void 0:e(void 0)})},[n,t,e]),N.useEffect(()=>{r.setSetting("labelRenderedSizeThreshold",10),r.setSetting("labelFont","Space Grotesk"),r.setSetting("labelColor",{color:"#e4e4ed"}),r.setSetting("edgeLabelColor",{color:"#94a3b8"})},[r]),null}function PQ({graph:t}){return N.useEffect(()=>{if(!(t.order<2))try{const e=zk.inferSettings(t);zk.assign(t,{iterations:Math.min(120,Math.max(40,t.order)),settings:{...e??{},gravity:.6,scalingRatio:10,slowDown:10}})}catch{}},[t]),null}function EI({graph:t,onNodeClick:e,onNodeHover:r}){const[n,i]=N.useState(0);N.useEffect(()=>{i(s=>s+1)},[t]);const a=N.useMemo(()=>({renderEdgeLabels:!0,labelDensity:.5,zIndex:!0}),[]);return H.jsxs(yQ,{graph:t,settings:a,className:"h-full w-full",children:[H.jsx(OQ,{graph:t}),H.jsx(PQ,{graph:t}),H.jsx(AQ,{onNodeClick:e,onNodeHover:r})]},n)}function OI({title:t,subtitle:e,meta:r=[],description:n}){return H.jsxs("div",{className:"card p-4",children:[H.jsx("div",{className:"flex items-start justify-between",children:H.jsxs("div",{children:[H.jsx("p",{className:"text-sm uppercase tracking-[0.3em] text-[#8888a0]",children:"Selected"}),H.jsx("h3",{className:"mt-2 text-lg font-semibold",children:t}),e&&H.jsx("p",{className:"mt-1 text-sm text-[#8888a0]",children:e})]})}),n&&H.jsx("p",{className:"mt-3 text-sm text-[#c2c2d6]",children:n}),H.jsx("div",{className:"mt-4 grid gap-3 text-sm",children:r.map(i=>H.jsxs("div",{className:"flex items-center justify-between border-b border-[#1f1f2c] pb-2",children:[H.jsx("span",{className:"text-[#8888a0]",children:i.label}),H.jsx("span",{className:"text-right text-[#e4e4ed]",children:i.value??"—"})]},i.label))})]})}const TQ={tool:"#3b82f6",service:"#10b981",concept:"#8b5cf6",decision:"#f59e0b",person:"#ec4899",file:"#6366f1",library:"#14b8a6"},Uk=["#38bdf8","#34d399","#f472b6","#facc15","#a78bfa","#f87171","#22d3ee","#c4b5fd","#fb7185","#4ade80"];function AI(t,e){t.forEachNode(r=>{t.setNodeAttribute(r,"x",(Math.random()-.5)*e),t.setNodeAttribute(r,"y",(Math.random()-.5)*e)})}function CQ(t){const e=new Ze,r=new Map;for(const n of t.edges)r.set(n.sourceId,(r.get(n.sourceId)||0)+1),r.set(n.targetId,(r.get(n.targetId)||0)+1);for(const n of t.nodes){const i=r.get(n.id)||0,a=Math.max(5,Math.min(25,5+i*1.2));e.addNode(String(n.id),{id:String(n.id),label:n.name,entityType:n.type,size:a,color:TQ[n.type]||"#64748b",description:n.description,firstLearnedAt:n.firstLearnedAt,lastConfirmedAt:n.lastConfirmedAt,contradictedAt:n.contradictedAt})}for(const n of t.edges){const i=String(n.sourceId),a=String(n.targetId);e.hasNode(i)&&e.hasNode(a)&&e.addEdgeWithKey(String(n.id),i,a,{label:n.edgeType,edgeType:n.edgeType,size:1,color:"rgba(148, 163, 184, 0.4)"})}return AI(e,800),e}function kQ(t,e,r){const n=new Ze;for(const i of t){const a=Math.max(4,Math.min(20,4+i.centrality*24)),s=i.clusterId!==null?r[i.clusterId]:"#64748b";n.addNode(i.path,{id:i.path,label:i.path.split("/").slice(-2).join("/"),fullPath:i.path,clusterId:i.clusterId,size:a,color:s})}for(const i of e)n.hasNode(i.source)&&n.hasNode(i.target)&&n.addEdge(i.source,i.target,{label:"imports",size:1,color:"rgba(148, 163, 184, 0.35)"});return AI(n,900),n}function RQ(){const t=Lo(c=>c.workspace);console.log("[GraphExplorer] render workspace=",t);const{data:e,isLoading:r,error:n}=Ra({queryKey:["graph-entities",t],queryFn:()=>oF(t)}),[i,a]=N.useState(null);r&&console.log("[GraphExplorer] loading..."),n&&console.error("[GraphExplorer] error:",n),e&&console.log("[GraphExplorer] data: nodes=",e.nodes.length,"edges=",e.edges.length,"stats=",e.stats);const s=N.useMemo(()=>{if(!e)return console.log("[GraphExplorer] no data, skipping graph build"),null;console.log("[GraphExplorer] building graph from",e.nodes.length,"nodes",e.edges.length,"edges");try{const c=CQ(e);return console.log("[GraphExplorer] graph built: order=",c.order,"size=",c.size),c}catch(c){return console.error("[GraphExplorer] graph build FAILED:",c),null}},[e]),l=e==null?void 0:e.nodes.find(c=>String(c.id)===i);return i&&console.log("[GraphExplorer] selected:",i,l==null?void 0:l.name),H.jsxs("div",{className:"space-y-6",children:[H.jsxs("div",{className:"flex items-start justify-between",children:[H.jsxs("div",{children:[H.jsx("h1",{className:"text-2xl font-semibold",children:"Knowledge Graph"}),H.jsx("p",{className:"mt-1 text-sm text-[#8888a0]",children:"Explore memory entities and their relationships."})]}),H.jsxs("div",{className:"text-right text-xs text-[#8888a0]",children:[H.jsxs("p",{children:["Nodes: ",(e==null?void 0:e.stats.nodeCount)??"—"]}),H.jsxs("p",{children:["Edges: ",(e==null?void 0:e.stats.edgeCount)??"—"]})]})]}),H.jsxs("div",{className:"grid grid-cols-[1fr_320px] gap-6",children:[H.jsx("div",{className:"card graph-shell overflow-hidden",children:s?H.jsx(EI,{graph:s,onNodeClick:c=>a(c)}):H.jsx("div",{className:"flex h-full items-center justify-center text-sm text-[#8888a0]",children:r?"Loading graph...":"No graph data."})}),H.jsxs("div",{className:"space-y-4",children:[l?H.jsx(OI,{title:l.name,subtitle:l.type,description:l.description,meta:[{label:"First learned",value:l.firstLearnedAt},{label:"Last confirmed",value:l.lastConfirmedAt},{label:"Contradicted",value:l.contradictedAt}]}):H.jsx("div",{className:"card p-4 text-sm text-[#8888a0]",children:"Select a node to inspect details."}),H.jsxs("div",{className:"card p-4",children:[H.jsx("h3",{className:"text-sm font-semibold",children:"Type distribution"}),H.jsx("div",{className:"mt-3 grid gap-2 text-xs text-[#8888a0]",children:e!=null&&e.stats.typeDistribution?Object.entries(e.stats.typeDistribution).map(([c,f])=>H.jsxs("div",{className:"flex items-center justify-between",children:[H.jsx("span",{children:c}),H.jsx("span",{className:"text-[#e4e4ed]",children:f})]},c)):"—"})]})]})]})]})}function DQ(){const t=Lo(p=>p.workspace),{data:e,isLoading:r}=Ra({queryKey:["code-deps",t],queryFn:()=>sF(t)}),[n,i]=N.useState(null),a=N.useMemo(()=>{const p=new Map;return e==null||e.files.forEach(h=>{if(h.clusterId===null||p.has(h.clusterId))return;const g=Uk[p.size%Uk.length];p.set(h.clusterId,g)}),Object.fromEntries(p.entries())},[e]),s=N.useMemo(()=>e?kQ(e.files,e.edges,a):null,[e,a]),l=e==null?void 0:e.files.find(p=>p.path===n),c=(e==null?void 0:e.edges.filter(p=>p.source===n).length)??0,f=(e==null?void 0:e.edges.filter(p=>p.target===n).length)??0;return H.jsxs("div",{className:"space-y-6",children:[H.jsxs("div",{className:"flex items-start justify-between",children:[H.jsxs("div",{children:[H.jsx("h1",{className:"text-2xl font-semibold",children:"Code Dependencies"}),H.jsx("p",{className:"mt-1 text-sm text-[#8888a0]",children:"File-level dependency graph with centrality sizing."})]}),H.jsxs("div",{className:"text-right text-xs text-[#8888a0]",children:[H.jsxs("p",{children:["Files: ",(e==null?void 0:e.files.length)??"—"]}),H.jsxs("p",{children:["Edges: ",(e==null?void 0:e.edges.length)??"—"]})]})]}),H.jsxs("div",{className:"grid grid-cols-[1fr_320px] gap-6",children:[H.jsx("div",{className:"card graph-shell overflow-hidden",children:s?H.jsx(EI,{graph:s,onNodeClick:p=>i(p)}):H.jsx("div",{className:"flex h-full items-center justify-center text-sm text-[#8888a0]",children:r?"Loading code graph...":"No dependency data."})}),H.jsxs("div",{className:"space-y-4",children:[l?H.jsx(OI,{title:l.path.split("/").slice(-2).join("/"),subtitle:l.path,meta:[{label:"Centrality",value:l.centrality.toFixed(3)},{label:"Cluster",value:l.clusterId??"—"},{label:"Imports",value:c},{label:"Dependents",value:f}]}):H.jsx("div",{className:"card p-4 text-sm text-[#8888a0]",children:"Select a file to inspect details."}),H.jsxs("div",{className:"card p-4 text-sm text-[#8888a0]",children:[H.jsx("p",{className:"font-semibold text-[#e4e4ed]",children:"Cluster legend"}),H.jsx("div",{className:"mt-3 grid gap-2",children:Object.entries(a).map(([p,h])=>H.jsxs("div",{className:"flex items-center justify-between",children:[H.jsxs("span",{children:["Cluster ",p]}),H.jsx("span",{className:"h-3 w-6 rounded-full",style:{background:h}})]},p))})]})]})]})]})}function jQ({result:t,expanded:e,onToggle:r}){const n=Math.min(100,Math.max(5,t.score*100));return H.jsxs("button",{type:"button",onClick:r,className:"card w-full cursor-pointer p-4 text-left transition hover:border-[#2a2a38]",children:[H.jsxs("div",{className:"flex items-start justify-between gap-4",children:[H.jsxs("div",{children:[H.jsx("h3",{className:"text-base font-semibold",children:t.title||t.path}),H.jsx("p",{className:"mt-1 text-xs text-[#8888a0]",children:t.path})]}),H.jsxs("div",{className:"min-w-[120px]",children:[H.jsx("p",{className:"text-xs uppercase text-[#8888a0]",children:"Score"}),H.jsx("div",{className:"mt-1 h-2 w-full rounded-full bg-[#1f1f2c]",children:H.jsx("div",{className:"h-2 rounded-full bg-gradient-to-r from-sky-500 via-indigo-500 to-fuchsia-500",style:{width:`${n}%`}})})]})]}),H.jsx("p",{className:"mt-3 text-sm text-[#c2c2d6]",children:t.snippet}),H.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 text-xs text-[#8888a0]",children:[H.jsx("span",{className:"rounded-full border border-[#2a2a38] px-2 py-1",children:t.collection}),H.jsxs("span",{className:"rounded-full border border-[#2a2a38] px-2 py-1",children:["doc: ",t.docid]})]}),e&&H.jsxs("div",{className:"mt-4 border-t border-[#1f1f2c] pt-3 text-sm text-[#e4e4ed]",children:[H.jsx("p",{className:"text-xs uppercase text-[#8888a0]",children:"Expanded"}),H.jsx("p",{className:"mt-2 text-sm text-[#c2c2d6]",children:t.snippet}),H.jsxs("div",{className:"mt-3 text-xs text-[#8888a0]",children:["Doc ID: ",t.docid]})]})]})}function IQ(){const t=Lo(f=>f.workspace),[e,r]=N.useState(""),[n,i]=N.useState(""),[a,s]=N.useState(null);N.useEffect(()=>{const f=window.setTimeout(()=>i(e),300);return()=>window.clearTimeout(f)},[e]);const{data:l,isFetching:c}=Ra({queryKey:["search",n,t],queryFn:()=>uF(n,20,t),enabled:n.trim().length>1});return H.jsxs("div",{className:"space-y-6",children:[H.jsxs("div",{children:[H.jsx("h1",{className:"text-2xl font-semibold",children:"Hybrid Search"}),H.jsx("p",{className:"mt-1 text-sm text-[#8888a0]",children:"BM25 + vector + knowledge graph reranking."})]}),H.jsxs("div",{className:"card p-4",children:[H.jsx("label",{className:"text-xs uppercase text-[#8888a0]",children:"Search query"}),H.jsx("input",{value:e,onChange:f=>r(f.target.value),placeholder:"Search docs, entities, code...",className:"mt-2 w-full rounded-xl border border-[#26263a] bg-[#0f0f16] px-3 py-2 text-sm text-[#e4e4ed]"}),H.jsxs("div",{className:"mt-3 flex items-center justify-between text-xs text-[#8888a0]",children:[H.jsx("span",{children:c?"Searching...":l?`${l.results.length} results`:"Idle"}),H.jsx("span",{children:l?`${l.executionMs} ms`:"—"})]})]}),H.jsxs("div",{className:"space-y-4",children:[l==null?void 0:l.results.map(f=>H.jsx(jQ,{result:f,expanded:a===f.id,onToggle:()=>s(a===f.id?null:f.id)},f.id)),l&&l.results.length===0&&H.jsx("div",{className:"card p-6 text-sm text-[#8888a0]",children:"No results found."}),n.trim().length<=1&&H.jsx("div",{className:"card p-6 text-sm text-[#8888a0]",children:"Type at least 2 characters to search."})]})]})}function NQ(){return H.jsx(gF,{children:H.jsxs(CL,{children:[H.jsx(vo,{path:"/",element:H.jsx(PL,{to:"/dashboard",replace:!0})}),H.jsx(vo,{path:"/dashboard",element:H.jsx($7,{})}),H.jsx(vo,{path:"/graph",element:H.jsx(RQ,{})}),H.jsx(vo,{path:"/code",element:H.jsx(DQ,{})}),H.jsx(vo,{path:"/search",element:H.jsx(IQ,{})})]})})}const MQ=new D$({defaultOptions:{queries:{staleTime:1e3*60*5,retry:1}}}),qk=document.getElementById("root");qk&&RM.createRoot(qk).render(H.jsx(Q.StrictMode,{children:H.jsx(I$,{client:MQ,children:H.jsx(JL,{basename:"/web",children:H.jsx(NQ,{})})})}));
|
|
489
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Tk(t){return oQ(t)||sQ(t)||rI(t)||uQ()}function lQ(t,e){if(t==null)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(e.indexOf(n)!==-1)continue;r[n]=t[n]}return r}function a0(t,e){if(t==null)return{};var r,n,i=lQ(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(n=0;n<a.length;n++)r=a[n],e.indexOf(r)===-1&&{}.propertyIsEnumerable.call(t,r)&&(i[r]=t[r])}return i}var Ck=(function(){function t(e,r){er(this,t),this.key=e,this.size=r}return tr(t,null,[{key:"compare",value:function(r,n){return r.size>n.size?-1:r.size<n.size||r.key>n.key?1:-1}}])})(),kk=(function(){function t(){er(this,t),se(this,"width",0),se(this,"height",0),se(this,"cellSize",0),se(this,"columns",0),se(this,"rows",0),se(this,"cells",{})}return tr(t,[{key:"resizeAndClear",value:function(r,n){this.width=r.width,this.height=r.height,this.cellSize=n,this.columns=Math.ceil(r.width/n),this.rows=Math.ceil(r.height/n),this.cells={}}},{key:"getIndex",value:function(r){var n=Math.floor(r.x/this.cellSize),i=Math.floor(r.y/this.cellSize);return i*this.columns+n}},{key:"add",value:function(r,n,i){var a=new Ck(r,n),s=this.getIndex(i),l=this.cells[s];l||(l=[],this.cells[s]=l),l.push(a)}},{key:"organize",value:function(){for(var r in this.cells){var n=this.cells[r];n.sort(Ck.compare)}}},{key:"getLabelsToDisplay",value:function(r,n){var i=this.cellSize*this.cellSize,a=i/r/r,s=a*n/i,l=Math.ceil(s),c=[];for(var f in this.cells)for(var p=this.cells[f],h=0;h<Math.min(l,p.length);h++)c.push(p[h].key);return c}}])})();function cQ(t){var e=t.graph,r=t.hoveredNode,n=t.highlightedNodes,i=t.displayedNodeLabels,a=[];return e.forEachEdge(function(s,l,c,f){(c===r||f===r||n.has(c)||n.has(f)||i.has(c)&&i.has(f))&&a.push(s)}),a}var Rk=150,Dk=50,Kn=Object.prototype.hasOwnProperty;function fQ(t,e,r){if(!Kn.call(r,"x")||!Kn.call(r,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(e,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return r.color||(r.color=t.defaultNodeColor),!r.label&&r.label!==""&&(r.label=null),r.label!==void 0&&r.label!==null?r.label=""+r.label:r.label=null,r.size||(r.size=2),Kn.call(r,"hidden")||(r.hidden=!1),Kn.call(r,"highlighted")||(r.highlighted=!1),Kn.call(r,"forceLabel")||(r.forceLabel=!1),(!r.type||r.type==="")&&(r.type=t.defaultNodeType),r.zIndex||(r.zIndex=0),r}function dQ(t,e,r){return r.color||(r.color=t.defaultEdgeColor),r.label||(r.label=""),r.size||(r.size=.5),Kn.call(r,"hidden")||(r.hidden=!1),Kn.call(r,"forceLabel")||(r.forceLabel=!1),(!r.type||r.type==="")&&(r.type=t.defaultEdgeType),r.zIndex||(r.zIndex=0),r}var hQ=(function(t){function e(r,n){var i,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(er(this,e),i=zr(this,e),se(i,"elements",{}),se(i,"canvasContexts",{}),se(i,"webGLContexts",{}),se(i,"pickingLayers",new Set),se(i,"textures",{}),se(i,"frameBuffers",{}),se(i,"activeListeners",{}),se(i,"labelGrid",new kk),se(i,"nodeDataCache",{}),se(i,"edgeDataCache",{}),se(i,"nodeProgramIndex",{}),se(i,"edgeProgramIndex",{}),se(i,"nodesWithForcedLabels",new Set),se(i,"edgesWithForcedLabels",new Set),se(i,"nodeExtent",{x:[0,1],y:[0,1]}),se(i,"nodeZExtent",[1/0,-1/0]),se(i,"edgeZExtent",[1/0,-1/0]),se(i,"matrix",Jr()),se(i,"invMatrix",Jr()),se(i,"correctionRatio",1),se(i,"customBBox",null),se(i,"normalizationFunction",Ok({x:[0,1],y:[0,1]})),se(i,"graphToViewportRatio",1),se(i,"itemIDsIndex",{}),se(i,"nodeIndices",{}),se(i,"edgeIndices",{}),se(i,"width",0),se(i,"height",0),se(i,"pixelRatio",_k()),se(i,"pickingDownSizingRatio",2*i.pixelRatio),se(i,"displayedNodeLabels",new Set),se(i,"displayedEdgeLabels",new Set),se(i,"highlightedNodes",new Set),se(i,"hoveredNode",null),se(i,"hoveredEdge",null),se(i,"renderFrame",null),se(i,"renderHighlightedNodesFrame",null),se(i,"needToProcess",!1),se(i,"checkEdgesEventsFrame",null),se(i,"nodePrograms",{}),se(i,"nodeHoverPrograms",{}),se(i,"edgePrograms",{}),i.settings=QY(a),i0(i.settings),VY(r),!(n instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");i.graph=r,i.container=n,i.createWebGLContext("edges",{picking:a.enableEdgeEvents}),i.createCanvasContext("edgeLabels"),i.createWebGLContext("nodes",{picking:!0}),i.createCanvasContext("labels"),i.createCanvasContext("hovers"),i.createWebGLContext("hoverNodes"),i.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),i.resize();for(var s in i.settings.nodeProgramClasses)i.registerNodeProgram(s,i.settings.nodeProgramClasses[s],i.settings.nodeHoverProgramClasses[s]);for(var l in i.settings.edgeProgramClasses)i.registerEdgeProgram(l,i.settings.edgeProgramClasses[l]);return i.camera=new Pk,i.bindCameraHandlers(),i.mouseCaptor=new rQ(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new aQ(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return Ur(e,t),tr(e,[{key:"registerNodeProgram",value:function(n,i,a){return this.nodePrograms[n]&&this.nodePrograms[n].kill(),this.nodeHoverPrograms[n]&&this.nodeHoverPrograms[n].kill(),this.nodePrograms[n]=new i(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[n]=new(a||i)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(n,i){return this.edgePrograms[n]&&this.edgePrograms[n].kill(),this.edgePrograms[n]=new i(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(n){if(this.nodePrograms[n]){var i=this.nodePrograms,a=i[n],s=a0(i,[n].map(Tu));a.kill(),this.nodePrograms=s}if(this.nodeHoverPrograms[n]){var l=this.nodeHoverPrograms,c=l[n],f=a0(l,[n].map(Tu));c.kill(),this.nodePrograms=f}return this}},{key:"unregisterEdgeProgram",value:function(n){if(this.edgePrograms[n]){var i=this.edgePrograms,a=i[n],s=a0(i,[n].map(Tu));a.kill(),this.edgePrograms=s}return this}},{key:"resetWebGLTexture",value:function(n){var i=this.webGLContexts[n],a=this.frameBuffers[n],s=this.textures[n];s&&i.deleteTexture(s);var l=i.createTexture();return i.bindFramebuffer(i.FRAMEBUFFER,a),i.bindTexture(i.TEXTURE_2D,l),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,l,0),this.textures[n]=l,this}},{key:"bindCameraHandlers",value:function(){var n=this;return this.activeListeners.camera=function(){n.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(n){var i=n.x,a=n.y,s=dk(this.webGLContexts.nodes,this.frameBuffers.nodes,i,a,this.pixelRatio,this.pickingDownSizingRatio),l=fk.apply(void 0,Tk(s)),c=this.itemIDsIndex[l];return c&&c.type==="node"?c.id:null}},{key:"bindEventHandlers",value:function(){var n=this;this.activeListeners.handleResize=function(){n.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(a){var s=mu(a),l={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}},c=n.getNodeAtPosition(s);if(c&&n.hoveredNode!==c&&!n.nodeDataCache[c].hidden){n.hoveredNode&&n.emit("leaveNode",Pe(Pe({},l),{},{node:n.hoveredNode})),n.hoveredNode=c,n.emit("enterNode",Pe(Pe({},l),{},{node:c})),n.scheduleHighlightedNodesRender();return}if(n.hoveredNode&&n.getNodeAtPosition(s)!==n.hoveredNode){var f=n.hoveredNode;n.hoveredNode=null,n.emit("leaveNode",Pe(Pe({},l),{},{node:f})),n.scheduleHighlightedNodesRender();return}if(n.settings.enableEdgeEvents){var p=n.hoveredNode?null:n.getEdgeAtPoint(l.event.x,l.event.y);p!==n.hoveredEdge&&(n.hoveredEdge&&n.emit("leaveEdge",Pe(Pe({},l),{},{edge:n.hoveredEdge})),p&&n.emit("enterEdge",Pe(Pe({},l),{},{edge:p})),n.hoveredEdge=p)}},this.activeListeners.handleMoveBody=function(a){var s=mu(a);n.emit("moveBody",{event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(a){var s=mu(a),l={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};n.hoveredNode&&(n.emit("leaveNode",Pe(Pe({},l),{},{node:n.hoveredNode})),n.scheduleHighlightedNodesRender()),n.settings.enableEdgeEvents&&n.hoveredEdge&&(n.emit("leaveEdge",Pe(Pe({},l),{},{edge:n.hoveredEdge})),n.scheduleHighlightedNodesRender()),n.emit("leaveStage",Pe({},l))},this.activeListeners.handleEnter=function(a){var s=mu(a),l={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};n.emit("enterStage",Pe({},l))};var i=function(s){return function(l){var c=mu(l),f={event:c,preventSigmaDefault:function(){c.preventSigmaDefault()}},p=n.getNodeAtPosition(c);if(p)return n.emit("".concat(s,"Node"),Pe(Pe({},f),{},{node:p}));if(n.settings.enableEdgeEvents){var h=n.getEdgeAtPoint(c.x,c.y);if(h)return n.emit("".concat(s,"Edge"),Pe(Pe({},f),{},{edge:h}))}return n.emit("".concat(s,"Stage"),f)}};return this.activeListeners.handleClick=i("click"),this.activeListeners.handleRightClick=i("rightClick"),this.activeListeners.handleDoubleClick=i("doubleClick"),this.activeListeners.handleWheel=i("wheel"),this.activeListeners.handleDown=i("down"),this.activeListeners.handleUp=i("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}},{key:"bindGraphHandlers",value:function(){var n=this,i=this.graph,a=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(s){var l,c=(l=s.hints)===null||l===void 0?void 0:l.attributes;n.graph.forEachNode(function(p){return n.updateNode(p)});var f=!c||c.some(function(p){return a.has(p)});n.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!f,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(s){var l,c=(l=s.hints)===null||l===void 0?void 0:l.attributes;n.graph.forEachEdge(function(p){return n.updateEdge(p)});var f=c&&["zIndex","type"].some(function(p){return c==null?void 0:c.includes(p)});n.refresh({partialGraph:{edges:i.edges()},skipIndexation:!f,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(s){var l=s.key;n.addNode(l),n.refresh({partialGraph:{nodes:[l]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(s){var l=s.key;n.refresh({partialGraph:{nodes:[l]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(s){var l=s.key;n.removeNode(l),n.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(s){var l=s.key;n.addEdge(l),n.refresh({partialGraph:{edges:[l]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(s){var l=s.key;n.refresh({partialGraph:{edges:[l]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(s){var l=s.key;n.removeEdge(l),n.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){n.clearEdgeState(),n.clearEdgeIndices(),n.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){n.clearEdgeState(),n.clearNodeState(),n.clearEdgeIndices(),n.clearNodeIndices(),n.refresh({schedule:!0})},i.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),i.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),i.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),i.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),i.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),i.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),i.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),i.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),i.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),i.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var n=this.graph;n.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),n.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),n.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),n.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),n.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),n.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),n.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),n.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),n.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),n.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(n,i){var a=dk(this.webGLContexts.edges,this.frameBuffers.edges,n,i,this.pixelRatio,this.pickingDownSizingRatio),s=fk.apply(void 0,Tk(a)),l=this.itemIDsIndex[s];return l&&l.type==="edge"?l.id:null}},{key:"process",value:function(){var n=this;this.emit("beforeProcess");var i=this.graph,a=this.settings,s=this.getDimensions();if(this.nodeExtent=HY(this.graph),!this.settings.autoRescale){var l=s.width,c=s.height,f=this.nodeExtent,p=f.x,h=f.y;this.nodeExtent={x:[(p[0]+p[1])/2-l/2,(p[0]+p[1])/2+l/2],y:[(h[0]+h[1])/2-c/2,(h[0]+h[1])/2+c/2]}}this.normalizationFunction=Ok(this.customBBox||this.nodeExtent);var g=new Pk,y=gu(g.getState(),s,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(s,a.labelGridCellSize);for(var S={},w={},b={},E={},P=1,T=i.nodes(),O=0,_=T.length;O<_;O++){var A=T[O],C=this.nodeDataCache[A],D=i.getNodeAttributes(A);C.x=D.x,C.y=D.y,this.normalizationFunction.applyTo(C),typeof C.label=="string"&&!C.hidden&&this.labelGrid.add(A,C.size,this.framedGraphToViewport(C,{matrix:y})),S[C.type]=(S[C.type]||0)+1}this.labelGrid.organize();for(var j in this.nodePrograms){if(!Kn.call(this.nodePrograms,j))throw new Error('Sigma: could not find a suitable program for node type "'.concat(j,'"!'));this.nodePrograms[j].reallocate(S[j]||0),S[j]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(T=Ek(this.nodeZExtent,function(xe){return n.nodeDataCache[xe].zIndex},T));for(var G=0,z=T.length;G<z;G++){var $=T[G];w[$]=P,E[w[$]]={type:"node",id:$},P++;var R=this.nodeDataCache[$];this.addNodeToProgram($,w[$],S[R.type]++)}for(var X={},K=i.edges(),B=0,I=K.length;B<I;B++){var V=K[B],J=this.edgeDataCache[V];X[J.type]=(X[J.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(K=Ek(this.edgeZExtent,function(xe){return n.edgeDataCache[xe].zIndex},K));for(var ee in this.edgePrograms){if(!Kn.call(this.edgePrograms,ee))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(ee,'"!'));this.edgePrograms[ee].reallocate(X[ee]||0),X[ee]=0}for(var L=0,W=K.length;L<W;L++){var te=K[L];b[te]=P,E[b[te]]={type:"edge",id:te},P++;var we=this.edgeDataCache[te];this.addEdgeToProgram(te,b[te],X[we.type]++)}return this.itemIDsIndex=E,this.nodeIndices=w,this.edgeIndices=b,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(n){var i=this,a=this.settings;if(this.camera.minRatio=a.minCameraRatio,this.camera.maxRatio=a.maxCameraRatio,this.camera.enabledZooming=a.enableCameraZooming,this.camera.enabledPanning=a.enableCameraPanning,this.camera.enabledRotation=a.enableCameraRotation,a.cameraPanBoundaries?this.camera.clean=function(p){return i.cleanCameraState(p,a.cameraPanBoundaries&&qb(a.cameraPanBoundaries)==="object"?a.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),n){if(n.edgeProgramClasses!==a.edgeProgramClasses){for(var s in a.edgeProgramClasses)a.edgeProgramClasses[s]!==n.edgeProgramClasses[s]&&this.registerEdgeProgram(s,a.edgeProgramClasses[s]);for(var l in n.edgeProgramClasses)a.edgeProgramClasses[l]||this.unregisterEdgeProgram(l)}if(n.nodeProgramClasses!==a.nodeProgramClasses||n.nodeHoverProgramClasses!==a.nodeHoverProgramClasses){for(var c in a.nodeProgramClasses)(a.nodeProgramClasses[c]!==n.nodeProgramClasses[c]||a.nodeHoverProgramClasses[c]!==n.nodeHoverProgramClasses[c])&&this.registerNodeProgram(c,a.nodeProgramClasses[c],a.nodeHoverProgramClasses[c]);for(var f in n.nodeProgramClasses)a.nodeProgramClasses[f]||this.unregisterNodeProgram(f)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=i.tolerance,s=a===void 0?0:a,l=i.boundaries,c=Pe({},n),f=l||this.nodeExtent,p=os(f.x,2),h=p[0],g=p[1],y=os(f.y,2),S=y[0],w=y[1],b=[this.graphToViewport({x:h,y:S},{cameraState:n}),this.graphToViewport({x:g,y:S},{cameraState:n}),this.graphToViewport({x:h,y:w},{cameraState:n}),this.graphToViewport({x:g,y:w},{cameraState:n})],E=1/0,P=-1/0,T=1/0,O=-1/0;b.forEach(function(X){var K=X.x,B=X.y;E=Math.min(E,K),P=Math.max(P,K),T=Math.min(T,B),O=Math.max(O,B)});var _=P-E,A=O-T,C=this.getDimensions(),D=C.width,j=C.height,G=0,z=0;if(_>=D?P<D-s?G=P-(D-s):E>s&&(G=E-s):P>D+s?G=P-(D+s):E<-s&&(G=E+s),A>=j?O<j-s?z=O-(j-s):T>s&&(z=T-s):O>j+s?z=O-(j+s):T<-s&&(z=T+s),G||z){var $=this.viewportToFramedGraph({x:0,y:0},{cameraState:n}),R=this.viewportToFramedGraph({x:G,y:z},{cameraState:n});G=R.x-$.x,z=R.y-$.y,c.x+=G,c.y+=z}return c}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var n=this.camera.getState(),i=this.labelGrid.getLabelsToDisplay(n.ratio,this.settings.labelDensity);Ak(i,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var a=this.canvasContexts.labels,s=0,l=i.length;s<l;s++){var c=i[s],f=this.nodeDataCache[c];if(!this.displayedNodeLabels.has(c)&&!f.hidden){var p=this.framedGraphToViewport(f),h=p.x,g=p.y,y=this.scaleSize(f.size);if(!(!f.forceLabel&&y<this.settings.labelRenderedSizeThreshold)&&!(h<-Rk||h>this.width+Rk||g<-Dk||g>this.height+Dk)){this.displayedNodeLabels.add(c);var S=this.settings.defaultDrawNodeLabel,w=this.nodePrograms[f.type],b=(w==null?void 0:w.drawLabel)||S;b(a,Pe(Pe({key:c},f),{},{size:y,x:h,y:g}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var n=this.canvasContexts.edgeLabels;n.clearRect(0,0,this.width,this.height);var i=cQ({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});Ak(i,this.edgesWithForcedLabels);for(var a=new Set,s=0,l=i.length;s<l;s++){var c=i[s],f=this.graph.extremities(c),p=this.nodeDataCache[f[0]],h=this.nodeDataCache[f[1]],g=this.edgeDataCache[c];if(!a.has(c)&&!(g.hidden||p.hidden||h.hidden)){var y=this.settings.defaultDrawEdgeLabel,S=this.edgePrograms[g.type],w=(S==null?void 0:S.drawLabel)||y;w(n,Pe(Pe({key:c},g),{},{size:this.scaleSize(g.size)}),Pe(Pe(Pe({key:f[0]},p),this.framedGraphToViewport(p)),{},{size:this.scaleSize(p.size)}),Pe(Pe(Pe({key:f[1]},h),this.framedGraphToViewport(h)),{},{size:this.scaleSize(h.size)}),this.settings),a.add(c)}}return this.displayedEdgeLabels=a,this}},{key:"renderHighlightedNodes",value:function(){var n=this,i=this.canvasContexts.hovers;i.clearRect(0,0,this.width,this.height);var a=function(y){var S=n.nodeDataCache[y],w=n.framedGraphToViewport(S),b=w.x,E=w.y,P=n.scaleSize(S.size),T=n.settings.defaultDrawNodeHover,O=n.nodePrograms[S.type],_=(O==null?void 0:O.drawHover)||T;_(i,Pe(Pe({key:y},S),{},{size:P,x:b,y:E}),n.settings)},s=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&s.push(this.hoveredNode),this.highlightedNodes.forEach(function(g){g!==n.hoveredNode&&s.push(g)}),s.forEach(function(g){return a(g)});var l={};s.forEach(function(g){var y=n.nodeDataCache[g].type;l[y]=(l[y]||0)+1});for(var c in this.nodeHoverPrograms)this.nodeHoverPrograms[c].reallocate(l[c]||0),l[c]=0;s.forEach(function(g){var y=n.nodeDataCache[g];n.nodeHoverPrograms[y.type].process(0,l[y.type]++,y)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var f=this.getRenderParams();for(var p in this.nodeHoverPrograms){var h=this.nodeHoverPrograms[p];h.render(f)}}},{key:"scheduleHighlightedNodesRender",value:function(){var n=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){n.renderHighlightedNodesFrame=null,n.renderHighlightedNodes(),n.renderEdgeLabels()}))}},{key:"render",value:function(){var n=this;this.emit("beforeRender");var i=function(){return n.emit("afterRender"),n};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(b){return n.resetWebGLTexture(b)}),!this.graph.order)return i();var a=this.mouseCaptor,s=this.camera.isAnimated()||a.isMoving||a.draggedEvents||a.currentWheelDirection,l=this.camera.getState(),c=this.getDimensions(),f=this.getGraphDimensions(),p=this.getStagePadding();this.matrix=gu(l,c,f,p),this.invMatrix=gu(l,c,f,p,!0),this.correctionRatio=WY(this.matrix,l,c),this.graphToViewportRatio=this.getGraphToViewportRatio();var h=this.getRenderParams();for(var g in this.nodePrograms){var y=this.nodePrograms[g];y.render(h)}if(!this.settings.hideEdgesOnMove||!s)for(var S in this.edgePrograms){var w=this.edgePrograms[S];w.render(h)}return this.settings.hideLabelsOnMove&&s||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),i()}},{key:"addNode",value:function(n){var i=Object.assign({},this.graph.getNodeAttributes(n));this.settings.nodeReducer&&(i=this.settings.nodeReducer(n,i));var a=fQ(this.settings,n,i);this.nodeDataCache[n]=a,this.nodesWithForcedLabels.delete(n),a.forceLabel&&!a.hidden&&this.nodesWithForcedLabels.add(n),this.highlightedNodes.delete(n),a.highlighted&&!a.hidden&&this.highlightedNodes.add(n),this.settings.zIndex&&(a.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=a.zIndex),a.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=a.zIndex))}},{key:"updateNode",value:function(n){this.addNode(n);var i=this.nodeDataCache[n];this.normalizationFunction.applyTo(i)}},{key:"removeNode",value:function(n){delete this.nodeDataCache[n],delete this.nodeProgramIndex[n],this.highlightedNodes.delete(n),this.hoveredNode===n&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(n)}},{key:"addEdge",value:function(n){var i=Object.assign({},this.graph.getEdgeAttributes(n));this.settings.edgeReducer&&(i=this.settings.edgeReducer(n,i));var a=dQ(this.settings,n,i);this.edgeDataCache[n]=a,this.edgesWithForcedLabels.delete(n),a.forceLabel&&!a.hidden&&this.edgesWithForcedLabels.add(n),this.settings.zIndex&&(a.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=a.zIndex),a.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=a.zIndex))}},{key:"updateEdge",value:function(n){this.addEdge(n)}},{key:"removeEdge",value:function(n){delete this.edgeDataCache[n],delete this.edgeProgramIndex[n],this.hoveredEdge===n&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(n)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new kk,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(n,i,a){var s=this.nodeDataCache[n],l=this.nodePrograms[s.type];if(!l)throw new Error('Sigma: could not find a suitable program for node type "'.concat(s.type,'"!'));l.process(i,a,s),this.nodeProgramIndex[n]=a}},{key:"addEdgeToProgram",value:function(n,i,a){var s=this.edgeDataCache[n],l=this.edgePrograms[s.type];if(!l)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(s.type,'"!'));var c=this.graph.extremities(n),f=this.nodeDataCache[c[0]],p=this.nodeDataCache[c[1]];l.process(i,a,f,p,s),this.edgeProgramIndex[n]=a}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var n=this.settings,i=n.stagePadding,a=n.autoRescale;return a&&i||0}},{key:"createLayer",value:function(n,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[n])throw new Error('Sigma: a layer named "'.concat(n,'" already exists'));var s=KY(i,{position:"absolute"},{class:"sigma-".concat(n)});return a.style&&Object.assign(s.style,a.style),this.elements[n]=s,"beforeLayer"in a&&a.beforeLayer?this.elements[a.beforeLayer].before(s):"afterLayer"in a&&a.afterLayer?this.elements[a.afterLayer].after(s):this.container.appendChild(s),s}},{key:"createCanvas",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(n,"canvas",i)}},{key:"createCanvasContext",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=this.createCanvas(n,i),s={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[n]=a.getContext("2d",s),this}},{key:"createWebGLContext",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=(i==null?void 0:i.canvas)||this.createCanvas(n,i);i.hidden&&a.remove();var s=Pe({preserveDrawingBuffer:!1,antialias:!1},i),l;l=a.getContext("webgl2",s),l||(l=a.getContext("webgl",s)),l||(l=a.getContext("experimental-webgl",s));var c=l;if(this.webGLContexts[n]=c,c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA),i.picking){this.pickingLayers.add(n);var f=c.createFramebuffer();if(!f)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(n));this.frameBuffers[n]=f}return c}},{key:"killLayer",value:function(n){var i=this.elements[n];if(!i)throw new Error("Sigma: cannot kill layer ".concat(n,", which does not exist"));if(this.webGLContexts[n]){var a,s=this.webGLContexts[n];(a=s.getExtension("WEBGL_lose_context"))===null||a===void 0||a.loseContext(),delete this.webGLContexts[n]}else this.canvasContexts[n]&&delete this.canvasContexts[n];return i.remove(),delete this.elements[n],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(n){this.unbindCameraHandlers(),this.camera=n,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(n){n!==this.graph&&(this.hoveredNode&&!n.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!n.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=n,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var n=this.customBBox||this.nodeExtent;return{width:n.x[1]-n.x[0]||1,height:n.y[1]-n.y[0]||1}}},{key:"getNodeDisplayData",value:function(n){var i=this.nodeDataCache[n];return i?Object.assign({},i):void 0}},{key:"getEdgeDisplayData",value:function(n){var i=this.edgeDataCache[n];return i?Object.assign({},i):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return Pe({},this.settings)}},{key:"getSetting",value:function(n){return this.settings[n]}},{key:"setSetting",value:function(n,i){var a=Pe({},this.settings);return this.settings[n]=i,i0(this.settings),this.handleSettingsUpdate(a),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(n,i){return this.setSetting(n,i(this.settings[n])),this}},{key:"setSettings",value:function(n){var i=Pe({},this.settings);return this.settings=Pe(Pe({},this.settings),n),i0(this.settings),this.handleSettingsUpdate(i),this.scheduleRefresh(),this}},{key:"resize",value:function(n){var i=this.width,a=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=_k(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!n&&i===this.width&&a===this.height)return this;for(var s in this.elements){var l=this.elements[s];l.style.width=this.width+"px",l.style.height=this.height+"px"}for(var c in this.canvasContexts)this.elements[c].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[c].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[c].scale(this.pixelRatio,this.pixelRatio);for(var f in this.webGLContexts){this.elements[f].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[f].setAttribute("height",this.height*this.pixelRatio+"px");var p=this.webGLContexts[f];if(p.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(f)){var h=this.textures[f];h&&p.deleteTexture(h)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(n){var i=this,a=(n==null?void 0:n.skipIndexation)!==void 0?n==null?void 0:n.skipIndexation:!1,s=(n==null?void 0:n.schedule)!==void 0?n.schedule:!1,l=!n||!n.partialGraph;if(l)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(O){return i.addNode(O)}),this.graph.forEachEdge(function(O){return i.addEdge(O)});else{for(var c,f,p=((c=n.partialGraph)===null||c===void 0?void 0:c.nodes)||[],h=0,g=(p==null?void 0:p.length)||0;h<g;h++){var y=p[h];if(this.updateNode(y),a){var S=this.nodeProgramIndex[y];if(S===void 0)throw new Error('Sigma: node "'.concat(y,`" can't be repaint`));this.addNodeToProgram(y,this.nodeIndices[y],S)}}for(var w=(n==null||(f=n.partialGraph)===null||f===void 0?void 0:f.edges)||[],b=0,E=w.length;b<E;b++){var P=w[b];if(this.updateEdge(P),a){var T=this.edgeProgramIndex[P];if(T===void 0)throw new Error('Sigma: edge "'.concat(P,`" can't be repaint`));this.addEdgeToProgram(P,this.edgeIndices[P],T)}}}return(l||!a)&&(this.needToProcess=!0),s?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var n=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){n.render()})),this}},{key:"scheduleRefresh",value:function(n){return this.refresh(Pe(Pe({},n),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(n,i){var a=this.camera.getState(),s=a.ratio,l=a.angle,c=a.x,f=a.y,p=this.settings,h=p.minCameraRatio,g=p.maxCameraRatio;typeof g=="number"&&(i=Math.min(i,g)),typeof h=="number"&&(i=Math.max(i,h));var y=i/s,S={x:this.width/2,y:this.height/2},w=this.viewportToFramedGraph(n),b=this.viewportToFramedGraph(S);return{angle:l,x:(w.x-b.x)*(1-y)+c,y:(w.y-b.y)*(1-y)+f,ratio:i}}},{key:"viewRectangle",value:function(){var n=this.viewportToFramedGraph({x:0,y:0}),i=this.viewportToFramedGraph({x:this.width,y:0}),a=this.viewportToFramedGraph({x:0,y:this.height});return{x1:n.x,y1:n.y,x2:i.x,y2:i.y,height:i.y-a.y}}},{key:"framedGraphToViewport",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=!!i.cameraState||!!i.viewportDimensions||!!i.graphDimensions,s=i.matrix?i.matrix:a?gu(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,l=Ub(s,n);return{x:(1+l.x)*this.width/2,y:(1-l.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=!!i.cameraState||!!i.viewportDimensions||!i.graphDimensions,s=i.matrix?i.matrix:a?gu(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,l=Ub(s,{x:n.x/this.width*2-1,y:1-n.y/this.height*2});return isNaN(l.x)&&(l.x=0),isNaN(l.y)&&(l.y=0),l}},{key:"viewportToGraph",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(n,i))}},{key:"graphToViewport",value:function(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(n),i)}},{key:"getGraphToViewportRatio",value:function(){var n={x:0,y:0},i={x:1,y:1},a=Math.sqrt(Math.pow(n.x-i.x,2)+Math.pow(n.y-i.y,2)),s=this.graphToViewport(n),l=this.graphToViewport(i),c=Math.sqrt(Math.pow(s.x-l.x,2)+Math.pow(s.y-l.y,2));return c/a}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(n){return this.customBBox=n,this.scheduleRender(),this}},{key:"kill",value:function(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);for(var n=this.container;n.firstChild;)n.removeChild(n.firstChild);for(var i in this.nodePrograms)this.nodePrograms[i].kill();for(var a in this.nodeHoverPrograms)this.nodeHoverPrograms[a].kill();for(var s in this.edgePrograms)this.edgePrograms[s].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var l in this.elements)this.killLayer(l);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return n/this.settings.zoomToSizeRatioFunction(i)*(this.getSetting("itemSizesReference")==="positions"?i*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var n={};for(var i in this.elements)this.elements[i]instanceof HTMLCanvasElement&&(n[i]=this.elements[i]);return n}}])})(sx);const xI=N.createContext(null),pQ=xI.Provider;function SI(){const t=N.useContext(xI);if(t==null)throw new Error("No context provided: useSigmaContext() can only be used in a descendant of <SigmaContainer>");return t}function lx(){return SI().sigma}function vQ(){const{sigma:t}=SI();return N.useCallback((e=>{t&&Object.keys(e).forEach((r=>{t.setSetting(r,e[r])}))}),[t])}function Qd(t){return new Set(Object.keys(t))}const jk=Qd({clickNode:!0,rightClickNode:!0,downNode:!0,enterNode:!0,leaveNode:!0,doubleClickNode:!0,wheelNode:!0,clickEdge:!0,rightClickEdge:!0,downEdge:!0,enterEdge:!0,leaveEdge:!0,doubleClickEdge:!0,wheelEdge:!0,clickStage:!0,rightClickStage:!0,downStage:!0,doubleClickStage:!0,wheelStage:!0,beforeRender:!0,afterRender:!0,kill:!0,upStage:!0,upEdge:!0,upNode:!0,enterStage:!0,leaveStage:!0,resize:!0,afterClear:!0,afterProcess:!0,beforeClear:!0,beforeProcess:!0,moveBody:!0}),Ik=Qd({click:!0,rightClick:!0,doubleClick:!0,mouseup:!0,mousedown:!0,mousemove:!0,mousemovebody:!0,mouseleave:!0,mouseenter:!0,wheel:!0}),Nk=Qd({touchup:!0,touchdown:!0,touchmove:!0,touchmovebody:!0,tap:!0,doubletap:!0}),Mk=Qd({updated:!0});function gQ(){const t=lx(),e=vQ(),[r,n]=N.useState({});return N.useEffect((()=>{if(!t||!r)return;const i=r,a=Object.keys(i);return a.forEach((s=>{const l=i[s];jk.has(s)&&t.on(s,l),Ik.has(s)&&t.getMouseCaptor().on(s,l),Nk.has(s)&&t.getTouchCaptor().on(s,l),Mk.has(s)&&t.getCamera().on(s,l)})),()=>{t&&a.forEach((s=>{const l=i[s];jk.has(s)&&t.off(s,l),Ik.has(s)&&t.getMouseCaptor().off(s,l),Nk.has(s)&&t.getTouchCaptor().off(s,l),Mk.has(s)&&t.getCamera().off(s,l)}))}}),[t,r,e]),n}function mQ(){const t=lx();return N.useCallback(((e,r=!0)=>{t&&e&&(r&&t.getGraph().order>0&&t.getGraph().clear(),t.getGraph().import(e),t.refresh())}),[t])}function _I(t,e){if(t===e)return!0;if(typeof t=="object"&&t!=null&&typeof e=="object"&&e!=null){if(Object.keys(t).length!=Object.keys(e).length)return!1;for(const r in t)if(!Object.hasOwn(e,r)||!_I(t[r],e[r]))return!1;return!0}return!1}const yQ=N.forwardRef((({graph:t,id:e,className:r,style:n,settings:i={},children:a},s)=>{const l=N.useRef(null),c=N.useRef(null),f={className:`react-sigma ${r||""}`,id:e,style:n},[p,h]=N.useState(null),[g,y]=N.useState(i);N.useEffect((()=>{y((b=>_I(b,i)?b:i))}),[i]),N.useEffect((()=>{let b=null;if(c.current!==null){let E=new Ze;t&&(E=typeof t=="function"?new t:t),b=new hQ(E,c.current,g),h((P=>{let T=null;return P&&(T=P.getCamera().getState()),T&&b.getCamera().setState(T),b}))}return()=>{b&&b.kill()}}),[c,t,g]),N.useImperativeHandle(s,(()=>p),[p]);const S=N.useMemo((()=>p&&l.current?{sigma:p,container:l.current}:null),[p,l]),w=S!==null?Q.createElement(pQ,{value:S},a):null;return Q.createElement("div",Object.assign({},f,{ref:l}),Q.createElement("div",{className:"sigma-container",ref:c}),w)}));var bu={},Lk;function bQ(){if(Lk)return bu;Lk=1;function t(n){return typeof n!="number"||isNaN(n)?1:n}function e(n,i){var a={},s=function(f){return typeof f>"u"?i:f};typeof i=="function"&&(s=i);var l=function(f){return s(f[n])},c=function(){return s(void 0)};return typeof n=="string"?(a.fromAttributes=l,a.fromGraph=function(f,p){return l(f.getNodeAttributes(p))},a.fromEntry=function(f,p){return l(p)}):typeof n=="function"?(a.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},a.fromGraph=function(f,p){return s(n(p,f.getNodeAttributes(p)))},a.fromEntry=function(f,p){return s(n(f,p))}):(a.fromAttributes=c,a.fromGraph=c,a.fromEntry=c),a}function r(n,i){var a={},s=function(f){return typeof f>"u"?i:f};typeof i=="function"&&(s=i);var l=function(f){return s(f[n])},c=function(){return s(void 0)};return typeof n=="string"?(a.fromAttributes=l,a.fromGraph=function(f,p){return l(f.getEdgeAttributes(p))},a.fromEntry=function(f,p){return l(p)},a.fromPartialEntry=a.fromEntry,a.fromMinimalEntry=a.fromEntry):typeof n=="function"?(a.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},a.fromGraph=function(f,p){var h=f.extremities(p);return s(n(p,f.getEdgeAttributes(p),h[0],h[1],f.getNodeAttributes(h[0]),f.getNodeAttributes(h[1]),f.isUndirected(p)))},a.fromEntry=function(f,p,h,g,y,S,w){return s(n(f,p,h,g,y,S,w))},a.fromPartialEntry=function(f,p,h,g){return s(n(f,p,h,g))},a.fromMinimalEntry=function(f,p){return s(n(f,p))}):(a.fromAttributes=c,a.fromGraph=c,a.fromEntry=c,a.fromMinimalEntry=c),a}return bu.createNodeValueGetter=e,bu.createEdgeValueGetter=r,bu.createEdgeWeightGetter=function(n){return r(n,t)},bu}var o0,$k;function wQ(){if($k)return o0;$k=1;var t=0,e=1,r=2,n=3,i=4,a=5,s=6,l=7,c=8,f=9,p=0,h=1,g=2,y=0,S=1,w=2,b=3,E=4,P=5,T=6,O=7,_=8,A=3,C=10,D=3,j=9,G=10;return o0=function($,R,X){var K,B,I,V,J,ee,L,W,te,we,xe=R.length,Ie=X.length,Le=$.adjustSizes,Me=$.barnesHutTheta*$.barnesHutTheta,le,pe,ve,ie,Fe,de,ge,ne=[];for(I=0;I<xe;I+=C)R[I+i]=R[I+r],R[I+a]=R[I+n],R[I+r]=0,R[I+n]=0;if($.outboundAttractionDistribution){for(le=0,I=0;I<xe;I+=C)le+=R[I+s];le/=xe/C}if($.barnesHutOptimize){var it=1/0,kt=-1/0,Rt=1/0,Bt=-1/0,rt,Dt,cn;for(I=0;I<xe;I+=C)it=Math.min(it,R[I+t]),kt=Math.max(kt,R[I+t]),Rt=Math.min(Rt,R[I+e]),Bt=Math.max(Bt,R[I+e]);var fn=kt-it,dn=Bt-Rt;for(fn>dn?(Rt-=(fn-dn)/2,Bt=Rt+fn):(it-=(dn-fn)/2,kt=it+dn),ne[0+y]=-1,ne[0+S]=(it+kt)/2,ne[0+w]=(Rt+Bt)/2,ne[0+b]=Math.max(kt-it,Bt-Rt),ne[0+E]=-1,ne[0+P]=-1,ne[0+T]=0,ne[0+O]=0,ne[0+_]=0,K=1,I=0;I<xe;I+=C)for(B=0,cn=A;;)if(ne[B+P]>=0){R[I+t]<ne[B+S]?R[I+e]<ne[B+w]?rt=ne[B+P]:rt=ne[B+P]+j:R[I+e]<ne[B+w]?rt=ne[B+P]+j*2:rt=ne[B+P]+j*3,ne[B+O]=(ne[B+O]*ne[B+T]+R[I+t]*R[I+s])/(ne[B+T]+R[I+s]),ne[B+_]=(ne[B+_]*ne[B+T]+R[I+e]*R[I+s])/(ne[B+T]+R[I+s]),ne[B+T]+=R[I+s],B=rt;continue}else if(ne[B+y]<0){ne[B+y]=I;break}else{if(ne[B+P]=K*j,W=ne[B+b]/2,te=ne[B+P],ne[te+y]=-1,ne[te+S]=ne[B+S]-W,ne[te+w]=ne[B+w]-W,ne[te+b]=W,ne[te+E]=te+j,ne[te+P]=-1,ne[te+T]=0,ne[te+O]=0,ne[te+_]=0,te+=j,ne[te+y]=-1,ne[te+S]=ne[B+S]-W,ne[te+w]=ne[B+w]+W,ne[te+b]=W,ne[te+E]=te+j,ne[te+P]=-1,ne[te+T]=0,ne[te+O]=0,ne[te+_]=0,te+=j,ne[te+y]=-1,ne[te+S]=ne[B+S]+W,ne[te+w]=ne[B+w]-W,ne[te+b]=W,ne[te+E]=te+j,ne[te+P]=-1,ne[te+T]=0,ne[te+O]=0,ne[te+_]=0,te+=j,ne[te+y]=-1,ne[te+S]=ne[B+S]+W,ne[te+w]=ne[B+w]+W,ne[te+b]=W,ne[te+E]=ne[B+E],ne[te+P]=-1,ne[te+T]=0,ne[te+O]=0,ne[te+_]=0,K+=4,R[ne[B+y]+t]<ne[B+S]?R[ne[B+y]+e]<ne[B+w]?rt=ne[B+P]:rt=ne[B+P]+j:R[ne[B+y]+e]<ne[B+w]?rt=ne[B+P]+j*2:rt=ne[B+P]+j*3,ne[B+T]=R[ne[B+y]+s],ne[B+O]=R[ne[B+y]+t],ne[B+_]=R[ne[B+y]+e],ne[rt+y]=ne[B+y],ne[B+y]=-1,R[I+t]<ne[B+S]?R[I+e]<ne[B+w]?Dt=ne[B+P]:Dt=ne[B+P]+j:R[I+e]<ne[B+w]?Dt=ne[B+P]+j*2:Dt=ne[B+P]+j*3,rt===Dt)if(cn--){B=rt;continue}else{cn=A;break}ne[Dt+y]=I;break}}if($.barnesHutOptimize)for(pe=$.scalingRatio,I=0;I<xe;I+=C)for(B=0;;)if(ne[B+P]>=0)if(de=Math.pow(R[I+t]-ne[B+O],2)+Math.pow(R[I+e]-ne[B+_],2),we=ne[B+b],4*we*we/de<Me){if(ve=R[I+t]-ne[B+O],ie=R[I+e]-ne[B+_],Le===!0?de>0?(ge=pe*R[I+s]*ne[B+T]/de,R[I+r]+=ve*ge,R[I+n]+=ie*ge):de<0&&(ge=-pe*R[I+s]*ne[B+T]/Math.sqrt(de),R[I+r]+=ve*ge,R[I+n]+=ie*ge):de>0&&(ge=pe*R[I+s]*ne[B+T]/de,R[I+r]+=ve*ge,R[I+n]+=ie*ge),B=ne[B+E],B<0)break;continue}else{B=ne[B+P];continue}else{if(ee=ne[B+y],ee>=0&&ee!==I&&(ve=R[I+t]-R[ee+t],ie=R[I+e]-R[ee+e],de=ve*ve+ie*ie,Le===!0?de>0?(ge=pe*R[I+s]*R[ee+s]/de,R[I+r]+=ve*ge,R[I+n]+=ie*ge):de<0&&(ge=-pe*R[I+s]*R[ee+s]/Math.sqrt(de),R[I+r]+=ve*ge,R[I+n]+=ie*ge):de>0&&(ge=pe*R[I+s]*R[ee+s]/de,R[I+r]+=ve*ge,R[I+n]+=ie*ge)),B=ne[B+E],B<0)break;continue}else for(pe=$.scalingRatio,V=0;V<xe;V+=C)for(J=0;J<V;J+=C)ve=R[V+t]-R[J+t],ie=R[V+e]-R[J+e],Le===!0?(de=Math.sqrt(ve*ve+ie*ie)-R[V+c]-R[J+c],de>0?(ge=pe*R[V+s]*R[J+s]/de/de,R[V+r]+=ve*ge,R[V+n]+=ie*ge,R[J+r]-=ve*ge,R[J+n]-=ie*ge):de<0&&(ge=100*pe*R[V+s]*R[J+s],R[V+r]+=ve*ge,R[V+n]+=ie*ge,R[J+r]-=ve*ge,R[J+n]-=ie*ge)):(de=Math.sqrt(ve*ve+ie*ie),de>0&&(ge=pe*R[V+s]*R[J+s]/de/de,R[V+r]+=ve*ge,R[V+n]+=ie*ge,R[J+r]-=ve*ge,R[J+n]-=ie*ge));for(te=$.gravity/$.scalingRatio,pe=$.scalingRatio,I=0;I<xe;I+=C)ge=0,ve=R[I+t],ie=R[I+e],de=Math.sqrt(Math.pow(ve,2)+Math.pow(ie,2)),$.strongGravityMode?de>0&&(ge=pe*R[I+s]*te):de>0&&(ge=pe*R[I+s]*te/de),R[I+r]-=ve*ge,R[I+n]-=ie*ge;for(pe=1*($.outboundAttractionDistribution?le:1),L=0;L<Ie;L+=D)V=X[L+p],J=X[L+h],W=X[L+g],Fe=Math.pow(W,$.edgeWeightInfluence),ve=R[V+t]-R[J+t],ie=R[V+e]-R[J+e],Le===!0?(de=Math.sqrt(ve*ve+ie*ie)-R[V+c]-R[J+c],$.linLogMode?$.outboundAttractionDistribution?de>0&&(ge=-pe*Fe*Math.log(1+de)/de/R[V+s]):de>0&&(ge=-pe*Fe*Math.log(1+de)/de):$.outboundAttractionDistribution?de>0&&(ge=-pe*Fe/R[V+s]):de>0&&(ge=-pe*Fe)):(de=Math.sqrt(Math.pow(ve,2)+Math.pow(ie,2)),$.linLogMode?$.outboundAttractionDistribution?de>0&&(ge=-pe*Fe*Math.log(1+de)/de/R[V+s]):de>0&&(ge=-pe*Fe*Math.log(1+de)/de):$.outboundAttractionDistribution?(de=1,ge=-pe*Fe/R[V+s]):(de=1,ge=-pe*Fe)),de>0&&(R[V+r]+=ve*ge,R[V+n]+=ie*ge,R[J+r]-=ve*ge,R[J+n]-=ie*ge);var Xi,Dn,jn,hn,pn,vn;if(Le===!0)for(I=0;I<xe;I+=C)R[I+f]!==1&&(Xi=Math.sqrt(Math.pow(R[I+r],2)+Math.pow(R[I+n],2)),Xi>G&&(R[I+r]=R[I+r]*G/Xi,R[I+n]=R[I+n]*G/Xi),Dn=R[I+s]*Math.sqrt((R[I+i]-R[I+r])*(R[I+i]-R[I+r])+(R[I+a]-R[I+n])*(R[I+a]-R[I+n])),jn=Math.sqrt((R[I+i]+R[I+r])*(R[I+i]+R[I+r])+(R[I+a]+R[I+n])*(R[I+a]+R[I+n]))/2,hn=.1*Math.log(1+jn)/(1+Math.sqrt(Dn)),pn=R[I+t]+R[I+r]*(hn/$.slowDown),R[I+t]=pn,vn=R[I+e]+R[I+n]*(hn/$.slowDown),R[I+e]=vn);else for(I=0;I<xe;I+=C)R[I+f]!==1&&(Dn=R[I+s]*Math.sqrt((R[I+i]-R[I+r])*(R[I+i]-R[I+r])+(R[I+a]-R[I+n])*(R[I+a]-R[I+n])),jn=Math.sqrt((R[I+i]+R[I+r])*(R[I+i]+R[I+r])+(R[I+a]+R[I+n])*(R[I+a]+R[I+n]))/2,hn=R[I+l]*Math.log(1+jn)/(1+Math.sqrt(Dn)),R[I+l]=Math.min(1,Math.sqrt(hn*(Math.pow(R[I+r],2)+Math.pow(R[I+n],2))/(1+Math.sqrt(Dn)))),pn=R[I+t]+R[I+r]*(hn/$.slowDown),R[I+t]=pn,vn=R[I+e]+R[I+n]*(hn/$.slowDown),R[I+e]=vn);return{}},o0}var Un={},Fk;function xQ(){if(Fk)return Un;Fk=1;var t=10,e=3;return Un.assign=function(r){r=r||{};var n=Array.prototype.slice.call(arguments).slice(1),i,a,s;for(i=0,s=n.length;i<s;i++)if(n[i])for(a in n[i])r[a]=n[i][a];return r},Un.validateSettings=function(r){return"linLogMode"in r&&typeof r.linLogMode!="boolean"?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in r&&typeof r.outboundAttractionDistribution!="boolean"?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in r&&typeof r.adjustSizes!="boolean"?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in r&&typeof r.edgeWeightInfluence!="number"?{message:"the `edgeWeightInfluence` setting should be a number."}:"scalingRatio"in r&&!(typeof r.scalingRatio=="number"&&r.scalingRatio>=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in r&&typeof r.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in r&&!(typeof r.gravity=="number"&&r.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in r&&!(typeof r.slowDown=="number"||r.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in r&&typeof r.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in r&&!(typeof r.barnesHutTheta=="number"&&r.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null},Un.graphToByteArrays=function(r,n){var i=r.order,a=r.size,s={},l,c=new Float32Array(i*t),f=new Float32Array(a*e);return l=0,r.forEachNode(function(p,h){s[p]=l,c[l]=h.x,c[l+1]=h.y,c[l+2]=0,c[l+3]=0,c[l+4]=0,c[l+5]=0,c[l+6]=1,c[l+7]=1,c[l+8]=h.size||1,c[l+9]=h.fixed?1:0,l+=t}),l=0,r.forEachEdge(function(p,h,g,y,S,w,b){var E=s[g],P=s[y],T=n(p,h,g,y,S,w,b);c[E+6]+=T,c[P+6]+=T,f[l]=E,f[l+1]=P,f[l+2]=T,l+=e}),{nodes:c,edges:f}},Un.assignLayoutChanges=function(r,n,i){var a=0;r.updateEachNodeAttributes(function(s,l){return l.x=n[a],l.y=n[a+1],a+=t,i?i(s,l):l})},Un.readGraphPositions=function(r,n){var i=0;r.forEachNode(function(a,s){n[i]=s.x,n[i+1]=s.y,i+=t})},Un.collectLayoutChanges=function(r,n,i){for(var a=r.nodes(),s={},l=0,c=0,f=n.length;l<f;l+=t){if(i){var p=Object.assign({},r.getNodeAttributes(a[c]));p.x=n[l],p.y=n[l+1],p=i(a[c],p),s[a[c]]={x:p.x,y:p.y}}else s[a[c]]={x:n[l],y:n[l+1]};c++}return s},Un.createWorker=function(n){var i=window.URL||window.webkitURL,a=n.toString(),s=i.createObjectURL(new Blob(["("+a+").call(this);"],{type:"text/javascript"})),l=new Worker(s);return i.revokeObjectURL(s),l},Un}var s0,Bk;function SQ(){return Bk||(Bk=1,s0={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}),s0}var u0,Gk;function _Q(){if(Gk)return u0;Gk=1;var t=yI(),e=bQ().createEdgeWeightGetter,r=wQ(),n=xQ(),i=SQ();function a(c,f,p){if(!t(f))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof p=="number"&&(p={iterations:p});var h=p.iterations;if(typeof h!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(h<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var g=e("getEdgeWeight"in p?p.getEdgeWeight:"weight").fromEntry,y=typeof p.outputReducer=="function"?p.outputReducer:null,S=n.assign({},i,p.settings),w=n.validateSettings(S);if(w)throw new Error("graphology-layout-forceatlas2: "+w.message);var b=n.graphToByteArrays(f,g),E;for(E=0;E<h;E++)r(S,b.nodes,b.edges);if(c){n.assignLayoutChanges(f,b.nodes,y);return}return n.collectLayoutChanges(f,b.nodes)}function s(c){var f=typeof c=="number"?c:c.order;return{barnesHutOptimize:f>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(f)}}var l=a.bind(null,!1);return l.assign=a.bind(null,!0),l.inferSettings=s,u0=l,u0}var EQ=_Q();const zk=tt(EQ);function OQ({graph:t}){const e=mQ();return N.useEffect(()=>{e(t)},[t,e]),null}function AQ({onNodeClick:t,onNodeHover:e}){const r=lx(),n=gQ();return N.useEffect(()=>{n({clickNode:i=>t==null?void 0:t(i.node),enterNode:i=>e==null?void 0:e(i.node),leaveNode:()=>e==null?void 0:e(void 0)})},[n,t,e]),N.useEffect(()=>{r.setSetting("labelRenderedSizeThreshold",10),r.setSetting("labelFont","Space Grotesk"),r.setSetting("labelColor",{color:"#e4e4ed"}),r.setSetting("edgeLabelColor",{color:"#94a3b8"})},[r]),null}function PQ({graph:t}){return N.useEffect(()=>{if(!(t.order<2))try{const e=zk.inferSettings(t);zk.assign(t,{iterations:Math.min(120,Math.max(40,t.order)),settings:{...e??{},gravity:.6,scalingRatio:10,slowDown:10}})}catch{}},[t]),null}function EI({graph:t,onNodeClick:e,onNodeHover:r}){const[n,i]=N.useState(0);N.useEffect(()=>{i(s=>s+1)},[t]);const a=N.useMemo(()=>({renderEdgeLabels:!0,labelDensity:.5,zIndex:!0,defaultNodeColor:"#64748b",defaultEdgeColor:"rgba(148, 163, 184, 0.4)",labelColor:{color:"#e4e4ed"},labelFont:"Space Grotesk, system-ui, sans-serif",labelRenderedSizeThreshold:8}),[]);return H.jsxs(yQ,{settings:a,className:"h-full w-full",style:{background:"#0d0d14"},children:[H.jsx(OQ,{graph:t}),H.jsx(PQ,{graph:t}),H.jsx(AQ,{onNodeClick:e,onNodeHover:r})]},n)}function OI({title:t,subtitle:e,meta:r=[],description:n}){return H.jsxs("div",{className:"card p-4",children:[H.jsx("div",{className:"flex items-start justify-between",children:H.jsxs("div",{children:[H.jsx("p",{className:"text-sm uppercase tracking-[0.3em] text-[#8888a0]",children:"Selected"}),H.jsx("h3",{className:"mt-2 text-lg font-semibold",children:t}),e&&H.jsx("p",{className:"mt-1 text-sm text-[#8888a0]",children:e})]})}),n&&H.jsx("p",{className:"mt-3 text-sm text-[#c2c2d6]",children:n}),H.jsx("div",{className:"mt-4 grid gap-3 text-sm",children:r.map(i=>H.jsxs("div",{className:"flex items-center justify-between border-b border-[#1f1f2c] pb-2",children:[H.jsx("span",{className:"text-[#8888a0]",children:i.label}),H.jsx("span",{className:"text-right text-[#e4e4ed]",children:i.value??"—"})]},i.label))})]})}const TQ={tool:"#3b82f6",service:"#10b981",concept:"#8b5cf6",decision:"#f59e0b",person:"#ec4899",file:"#6366f1",library:"#14b8a6"},Uk=["#38bdf8","#34d399","#f472b6","#facc15","#a78bfa","#f87171","#22d3ee","#c4b5fd","#fb7185","#4ade80"];function AI(t,e){t.forEachNode(r=>{t.setNodeAttribute(r,"x",(Math.random()-.5)*e),t.setNodeAttribute(r,"y",(Math.random()-.5)*e)})}function CQ(t){const e=new Ze,r=new Map;for(const n of t.edges)r.set(n.sourceId,(r.get(n.sourceId)||0)+1),r.set(n.targetId,(r.get(n.targetId)||0)+1);for(const n of t.nodes){const i=r.get(n.id)||0,a=Math.max(5,Math.min(25,5+i*1.2));e.addNode(String(n.id),{id:String(n.id),label:n.name,entityType:n.type,size:a,color:TQ[n.type]||"#64748b",description:n.description,firstLearnedAt:n.firstLearnedAt,lastConfirmedAt:n.lastConfirmedAt,contradictedAt:n.contradictedAt})}for(const n of t.edges){const i=String(n.sourceId),a=String(n.targetId);e.hasNode(i)&&e.hasNode(a)&&e.addEdgeWithKey(String(n.id),i,a,{label:n.edgeType,edgeType:n.edgeType,size:1,color:"rgba(148, 163, 184, 0.4)"})}return AI(e,800),e}function kQ(t,e,r){const n=new Ze;for(const i of t){const a=Math.max(4,Math.min(20,4+i.centrality*24)),s=i.clusterId!==null?r[i.clusterId]:"#64748b";n.addNode(i.path,{id:i.path,label:i.path.split("/").slice(-2).join("/"),fullPath:i.path,clusterId:i.clusterId,size:a,color:s})}for(const i of e)n.hasNode(i.source)&&n.hasNode(i.target)&&n.addEdge(i.source,i.target,{label:"imports",size:1,color:"rgba(148, 163, 184, 0.35)"});return AI(n,900),n}function RQ(){const t=Lo(c=>c.workspace);console.log("[GraphExplorer] render workspace=",t);const{data:e,isLoading:r,error:n}=Ra({queryKey:["graph-entities",t],queryFn:()=>oF(t)}),[i,a]=N.useState(null);r&&console.log("[GraphExplorer] loading..."),n&&console.error("[GraphExplorer] error:",n),e&&console.log("[GraphExplorer] data: nodes=",e.nodes.length,"edges=",e.edges.length,"stats=",e.stats);const s=N.useMemo(()=>{if(!e)return console.log("[GraphExplorer] no data, skipping graph build"),null;console.log("[GraphExplorer] building graph from",e.nodes.length,"nodes",e.edges.length,"edges");try{const c=CQ(e);return console.log("[GraphExplorer] graph built: order=",c.order,"size=",c.size),c}catch(c){return console.error("[GraphExplorer] graph build FAILED:",c),null}},[e]),l=e==null?void 0:e.nodes.find(c=>String(c.id)===i);return i&&console.log("[GraphExplorer] selected:",i,l==null?void 0:l.name),H.jsxs("div",{className:"space-y-6",children:[H.jsxs("div",{className:"flex items-start justify-between",children:[H.jsxs("div",{children:[H.jsx("h1",{className:"text-2xl font-semibold",children:"Knowledge Graph"}),H.jsx("p",{className:"mt-1 text-sm text-[#8888a0]",children:"Explore memory entities and their relationships."})]}),H.jsxs("div",{className:"text-right text-xs text-[#8888a0]",children:[H.jsxs("p",{children:["Nodes: ",(e==null?void 0:e.stats.nodeCount)??"—"]}),H.jsxs("p",{children:["Edges: ",(e==null?void 0:e.stats.edgeCount)??"—"]})]})]}),H.jsxs("div",{className:"grid grid-cols-[1fr_320px] gap-6",children:[H.jsx("div",{className:"card graph-shell overflow-hidden",children:s?H.jsx(EI,{graph:s,onNodeClick:c=>a(c)}):H.jsx("div",{className:"flex h-full items-center justify-center text-sm text-[#8888a0]",children:r?"Loading graph...":"No graph data."})}),H.jsxs("div",{className:"space-y-4",children:[l?H.jsx(OI,{title:l.name,subtitle:l.type,description:l.description,meta:[{label:"First learned",value:l.firstLearnedAt},{label:"Last confirmed",value:l.lastConfirmedAt},{label:"Contradicted",value:l.contradictedAt}]}):H.jsx("div",{className:"card p-4 text-sm text-[#8888a0]",children:"Select a node to inspect details."}),H.jsxs("div",{className:"card p-4",children:[H.jsx("h3",{className:"text-sm font-semibold",children:"Type distribution"}),H.jsx("div",{className:"mt-3 grid gap-2 text-xs text-[#8888a0]",children:e!=null&&e.stats.typeDistribution?Object.entries(e.stats.typeDistribution).map(([c,f])=>H.jsxs("div",{className:"flex items-center justify-between",children:[H.jsx("span",{children:c}),H.jsx("span",{className:"text-[#e4e4ed]",children:f})]},c)):"—"})]})]})]})]})}function DQ(){const t=Lo(p=>p.workspace),{data:e,isLoading:r}=Ra({queryKey:["code-deps",t],queryFn:()=>sF(t)}),[n,i]=N.useState(null),a=N.useMemo(()=>{const p=new Map;return e==null||e.files.forEach(h=>{if(h.clusterId===null||p.has(h.clusterId))return;const g=Uk[p.size%Uk.length];p.set(h.clusterId,g)}),Object.fromEntries(p.entries())},[e]),s=N.useMemo(()=>e?kQ(e.files,e.edges,a):null,[e,a]),l=e==null?void 0:e.files.find(p=>p.path===n),c=(e==null?void 0:e.edges.filter(p=>p.source===n).length)??0,f=(e==null?void 0:e.edges.filter(p=>p.target===n).length)??0;return H.jsxs("div",{className:"space-y-6",children:[H.jsxs("div",{className:"flex items-start justify-between",children:[H.jsxs("div",{children:[H.jsx("h1",{className:"text-2xl font-semibold",children:"Code Dependencies"}),H.jsx("p",{className:"mt-1 text-sm text-[#8888a0]",children:"File-level dependency graph with centrality sizing."})]}),H.jsxs("div",{className:"text-right text-xs text-[#8888a0]",children:[H.jsxs("p",{children:["Files: ",(e==null?void 0:e.files.length)??"—"]}),H.jsxs("p",{children:["Edges: ",(e==null?void 0:e.edges.length)??"—"]})]})]}),H.jsxs("div",{className:"grid grid-cols-[1fr_320px] gap-6",children:[H.jsx("div",{className:"card graph-shell overflow-hidden",children:s?H.jsx(EI,{graph:s,onNodeClick:p=>i(p)}):H.jsx("div",{className:"flex h-full items-center justify-center text-sm text-[#8888a0]",children:r?"Loading code graph...":"No dependency data."})}),H.jsxs("div",{className:"space-y-4",children:[l?H.jsx(OI,{title:l.path.split("/").slice(-2).join("/"),subtitle:l.path,meta:[{label:"Centrality",value:l.centrality.toFixed(3)},{label:"Cluster",value:l.clusterId??"—"},{label:"Imports",value:c},{label:"Dependents",value:f}]}):H.jsx("div",{className:"card p-4 text-sm text-[#8888a0]",children:"Select a file to inspect details."}),H.jsxs("div",{className:"card p-4 text-sm text-[#8888a0]",children:[H.jsx("p",{className:"font-semibold text-[#e4e4ed]",children:"Cluster legend"}),H.jsx("div",{className:"mt-3 grid gap-2",children:Object.entries(a).map(([p,h])=>H.jsxs("div",{className:"flex items-center justify-between",children:[H.jsxs("span",{children:["Cluster ",p]}),H.jsx("span",{className:"h-3 w-6 rounded-full",style:{background:h}})]},p))})]})]})]})]})}function jQ({result:t,expanded:e,onToggle:r}){const n=Math.min(100,Math.max(5,t.score*100));return H.jsxs("button",{type:"button",onClick:r,className:"card w-full cursor-pointer p-4 text-left transition hover:border-[#2a2a38]",children:[H.jsxs("div",{className:"flex items-start justify-between gap-4",children:[H.jsxs("div",{children:[H.jsx("h3",{className:"text-base font-semibold",children:t.title||t.path}),H.jsx("p",{className:"mt-1 text-xs text-[#8888a0]",children:t.path})]}),H.jsxs("div",{className:"min-w-[120px]",children:[H.jsx("p",{className:"text-xs uppercase text-[#8888a0]",children:"Score"}),H.jsx("div",{className:"mt-1 h-2 w-full rounded-full bg-[#1f1f2c]",children:H.jsx("div",{className:"h-2 rounded-full bg-gradient-to-r from-sky-500 via-indigo-500 to-fuchsia-500",style:{width:`${n}%`}})})]})]}),H.jsx("p",{className:"mt-3 text-sm text-[#c2c2d6]",children:t.snippet}),H.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 text-xs text-[#8888a0]",children:[H.jsx("span",{className:"rounded-full border border-[#2a2a38] px-2 py-1",children:t.collection}),H.jsxs("span",{className:"rounded-full border border-[#2a2a38] px-2 py-1",children:["doc: ",t.docid]})]}),e&&H.jsxs("div",{className:"mt-4 border-t border-[#1f1f2c] pt-3 text-sm text-[#e4e4ed]",children:[H.jsx("p",{className:"text-xs uppercase text-[#8888a0]",children:"Expanded"}),H.jsx("p",{className:"mt-2 text-sm text-[#c2c2d6]",children:t.snippet}),H.jsxs("div",{className:"mt-3 text-xs text-[#8888a0]",children:["Doc ID: ",t.docid]})]})]})}function IQ(){const t=Lo(f=>f.workspace),[e,r]=N.useState(""),[n,i]=N.useState(""),[a,s]=N.useState(null);N.useEffect(()=>{const f=window.setTimeout(()=>i(e),300);return()=>window.clearTimeout(f)},[e]);const{data:l,isFetching:c}=Ra({queryKey:["search",n,t],queryFn:()=>uF(n,20,t),enabled:n.trim().length>1});return H.jsxs("div",{className:"space-y-6",children:[H.jsxs("div",{children:[H.jsx("h1",{className:"text-2xl font-semibold",children:"Hybrid Search"}),H.jsx("p",{className:"mt-1 text-sm text-[#8888a0]",children:"BM25 + vector + knowledge graph reranking."})]}),H.jsxs("div",{className:"card p-4",children:[H.jsx("label",{className:"text-xs uppercase text-[#8888a0]",children:"Search query"}),H.jsx("input",{value:e,onChange:f=>r(f.target.value),placeholder:"Search docs, entities, code...",className:"mt-2 w-full rounded-xl border border-[#26263a] bg-[#0f0f16] px-3 py-2 text-sm text-[#e4e4ed]"}),H.jsxs("div",{className:"mt-3 flex items-center justify-between text-xs text-[#8888a0]",children:[H.jsx("span",{children:c?"Searching...":l?`${l.results.length} results`:"Idle"}),H.jsx("span",{children:l?`${l.executionMs} ms`:"—"})]})]}),H.jsxs("div",{className:"space-y-4",children:[l==null?void 0:l.results.map(f=>H.jsx(jQ,{result:f,expanded:a===f.id,onToggle:()=>s(a===f.id?null:f.id)},f.id)),l&&l.results.length===0&&H.jsx("div",{className:"card p-6 text-sm text-[#8888a0]",children:"No results found."}),n.trim().length<=1&&H.jsx("div",{className:"card p-6 text-sm text-[#8888a0]",children:"Type at least 2 characters to search."})]})]})}function NQ(){return H.jsx(gF,{children:H.jsxs(CL,{children:[H.jsx(vo,{path:"/",element:H.jsx(PL,{to:"/dashboard",replace:!0})}),H.jsx(vo,{path:"/dashboard",element:H.jsx($7,{})}),H.jsx(vo,{path:"/graph",element:H.jsx(RQ,{})}),H.jsx(vo,{path:"/code",element:H.jsx(DQ,{})}),H.jsx(vo,{path:"/search",element:H.jsx(IQ,{})})]})})}const MQ=new D$({defaultOptions:{queries:{staleTime:1e3*60*5,retry:1}}}),qk=document.getElementById("root");qk&&RM.createRoot(qk).render(H.jsx(Q.StrictMode,{children:H.jsx(I$,{client:MQ,children:H.jsx(JL,{basename:"/web",children:H.jsx(NQ,{})})})}));
|
package/dist/web/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>nano-brain dashboard</title>
|
|
7
|
-
<script type="module" crossorigin src="/web/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/web/assets/index-BfQ3_Twc.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/web/assets/index-BhJ8fAaB.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body class="bg-slate-950 text-slate-200">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nano-brain",
|
|
3
|
-
"version": "2026.6.
|
|
3
|
+
"version": "2026.6.23",
|
|
4
4
|
"description": "Persistent memory and code intelligence for AI coding agents. Local MCP server with self-learning hybrid search (BM25 + vector + knowledge graph + LLM reranking), automatic session ingestion, codebase indexing, and 22 tools. Learns your preferences over time. Works with OpenCode, Claude, Cursor, Windsurf, and any MCP client.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -78,12 +78,22 @@ export default function GraphCanvas({ graph, onNodeClick, onNodeHover }: GraphCa
|
|
|
78
78
|
renderEdgeLabels: true,
|
|
79
79
|
labelDensity: 0.5,
|
|
80
80
|
zIndex: true,
|
|
81
|
+
defaultNodeColor: '#64748b',
|
|
82
|
+
defaultEdgeColor: 'rgba(148, 163, 184, 0.4)',
|
|
83
|
+
labelColor: { color: '#e4e4ed' },
|
|
84
|
+
labelFont: 'Space Grotesk, system-ui, sans-serif',
|
|
85
|
+
labelRenderedSizeThreshold: 8,
|
|
81
86
|
}),
|
|
82
87
|
[]
|
|
83
88
|
);
|
|
84
89
|
|
|
85
90
|
return (
|
|
86
|
-
<SigmaContainer
|
|
91
|
+
<SigmaContainer
|
|
92
|
+
key={key}
|
|
93
|
+
settings={settings}
|
|
94
|
+
className="h-full w-full"
|
|
95
|
+
style={{ background: '#0d0d14' }}
|
|
96
|
+
>
|
|
87
97
|
<GraphLoader graph={graph} />
|
|
88
98
|
<GraphLayout graph={graph} />
|
|
89
99
|
<GraphInteractions onNodeClick={onNodeClick} onNodeHover={onNodeHover} />
|
|
@@ -72,7 +72,7 @@ export default function Dashboard() {
|
|
|
72
72
|
<h2 className="text-lg font-semibold">Bandit Stats</h2>
|
|
73
73
|
<p className="text-xs text-[#8888a0]">Success vs failure per variant.</p>
|
|
74
74
|
</div>
|
|
75
|
-
<span className="text-xs text-[#8888a0]">{
|
|
75
|
+
<span className="text-xs text-[#8888a0]">{telemetryLoading ? 'loading' : `${banditData.length} variants`}</span>
|
|
76
76
|
</div>
|
|
77
77
|
<div className="mt-4 h-64">
|
|
78
78
|
<ResponsiveContainer width="100%" height="100%">
|