@phren/cli 0.1.33 → 0.1.34

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.
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import * as fs from "fs";
5
5
  import * as path from "path";
6
6
  import { findPhrenPathWithArg, debugLog, runtimeDir, } from "./shared.js";
7
7
  import { log as structuredLog, logger } from "./logger.js";
8
- import { buildIndex, updateFileInIndex as updateFileInIndexFn, } from "./shared/index.js";
8
+ import { buildIndex, flushEmbeddingQueue, updateFileInIndex as updateFileInIndexFn, } from "./shared/index.js";
9
9
  import { runCustomHooks } from "./hooks.js";
10
10
  import { register as registerSearch } from "./tools/search.js";
11
11
  import { register as registerTask } from "./tools/tasks.js";
@@ -74,6 +74,7 @@ async function main() {
74
74
  cleanStaleLocks(phrenPath);
75
75
  let db = null;
76
76
  let indexReady = false;
77
+ let shuttingDown = false;
77
78
  try {
78
79
  db = await buildIndex(phrenPath, profile);
79
80
  indexReady = true;
@@ -173,8 +174,15 @@ async function main() {
173
174
  "get_findings",
174
175
  "get_tasks",
175
176
  ]);
177
+ const registeredToolNames = new Set();
176
178
  server.registerTool = function (name, config, handler) {
177
179
  const registeredName = name;
180
+ // Registration runs before server.connect, so throwing here fails fast at
181
+ // startup instead of letting a later module silently shadow an earlier tool.
182
+ if (registeredToolNames.has(registeredName)) {
183
+ throw new Error(`Duplicate MCP tool registration: "${String(registeredName)}"`);
184
+ }
185
+ registeredToolNames.add(registeredName);
178
186
  let finalConfig = config;
179
187
  if (ALWAYS_LOAD_TOOLS.has(registeredName)) {
180
188
  const cfgObj = config;
@@ -182,6 +190,17 @@ async function main() {
182
190
  finalConfig = { ...cfgObj, _meta: { ...existingMeta, "anthropic/alwaysLoad": true } };
183
191
  }
184
192
  const wrapped = async (...args) => {
193
+ if (shuttingDown) {
194
+ return {
195
+ content: [{
196
+ type: "text",
197
+ text: JSON.stringify({
198
+ ok: false,
199
+ error: "phren-mcp server is shutting down; retry in a new session",
200
+ }, null, 2),
201
+ }],
202
+ };
203
+ }
185
204
  if (!indexReady || !db) {
186
205
  return {
187
206
  content: [{
@@ -237,6 +256,7 @@ async function main() {
237
256
  console.error(`phren-mcp running (${phrenPath})`);
238
257
  // Graceful shutdown: drain write queue and close DB before exit
239
258
  async function shutdown(signal) {
259
+ shuttingDown = true;
240
260
  structuredLog("info", "shutdown", `Received ${signal}, draining write queue...`);
241
261
  try {
242
262
  await writeQueue;
@@ -244,6 +264,17 @@ async function main() {
244
264
  catch {
245
265
  // Write queue errors already logged
246
266
  }
267
+ // Persist any pending embeddings; bounded so a slow/unreachable Ollama
268
+ // can't stall shutdown.
269
+ try {
270
+ await Promise.race([
271
+ flushEmbeddingQueue(),
272
+ new Promise((resolve) => setTimeout(resolve, 3000)),
273
+ ]);
274
+ }
275
+ catch (err) {
276
+ logger.warn("shutdown", `embFlush: ${errorMessage(err)}`);
277
+ }
247
278
  try {
248
279
  db?.close();
249
280
  }
@@ -1,4 +1,4 @@
1
- "use strict";(()=>{var Cr=Object.create;var vt=Object.defineProperty;var wr=Object.getOwnPropertyDescriptor;var cr=Object.getOwnPropertyNames;var fr=Object.getPrototypeOf,hr=Object.prototype.hasOwnProperty;var KA=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var Qr=(i,e,A,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of cr(e))!hr.call(i,r)&&r!==A&&vt(i,r,{get:()=>e[r],enumerable:!(t=wr(e,r))||t.enumerable});return i};var TA=(i,e,A)=>(A=i!=null?Cr(fr(i)):{},Qr(e||!i||!i.__esModule?vt(A,"default",{value:i,enumerable:!0}):A,i));var le=KA((pg,Te)=>{"use strict";var SA=typeof Reflect=="object"?Reflect:null,It=SA&&typeof SA.apply=="function"?SA.apply:function(e,A,t){return Function.prototype.apply.call(e,A,t)},de;SA&&typeof SA.ownKeys=="function"?de=SA.ownKeys:Object.getOwnPropertySymbols?de=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:de=function(e){return Object.getOwnPropertyNames(e)};function Dr(i){console&&console.warn&&console.warn(i)}var Ft=Number.isNaN||function(e){return e!==e};function K(){K.init.call(this)}Te.exports=K;Te.exports.once=lr;K.EventEmitter=K;K.prototype._events=void 0;K.prototype._eventsCount=0;K.prototype._maxListeners=void 0;var Mt=10;function Ee(i){if(typeof i!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof i)}Object.defineProperty(K,"defaultMaxListeners",{enumerable:!0,get:function(){return Mt},set:function(i){if(typeof i!="number"||i<0||Ft(i))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+i+".");Mt=i}});K.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};K.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Ft(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Gt(i){return i._maxListeners===void 0?K.defaultMaxListeners:i._maxListeners}K.prototype.getMaxListeners=function(){return Gt(this)};K.prototype.emit=function(e){for(var A=[],t=1;t<arguments.length;t++)A.push(arguments[t]);var r=e==="error",n=this._events;if(n!==void 0)r=r&&n.error===void 0;else if(!r)return!1;if(r){var o;if(A.length>0&&(o=A[0]),o instanceof Error)throw o;var g=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw g.context=o,g}var s=n[e];if(s===void 0)return!1;if(typeof s=="function")It(s,this,A);else for(var B=s.length,C=pt(s,B),t=0;t<B;++t)It(C[t],this,A);return!0};function Pt(i,e,A,t){var r,n,o;if(Ee(A),n=i._events,n===void 0?(n=i._events=Object.create(null),i._eventsCount=0):(n.newListener!==void 0&&(i.emit("newListener",e,A.listener?A.listener:A),n=i._events),o=n[e]),o===void 0)o=n[e]=A,++i._eventsCount;else if(typeof o=="function"?o=n[e]=t?[A,o]:[o,A]:t?o.unshift(A):o.push(A),r=Gt(i),r>0&&o.length>r&&!o.warned){o.warned=!0;var g=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");g.name="MaxListenersExceededWarning",g.emitter=i,g.type=e,g.count=o.length,Dr(g)}return i}K.prototype.addListener=function(e,A){return Pt(this,e,A,!1)};K.prototype.on=K.prototype.addListener;K.prototype.prependListener=function(e,A){return Pt(this,e,A,!0)};function ur(){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 mt(i,e,A){var t={fired:!1,wrapFn:void 0,target:i,type:e,listener:A},r=ur.bind(t);return r.listener=A,t.wrapFn=r,r}K.prototype.once=function(e,A){return Ee(A),this.on(e,mt(this,e,A)),this};K.prototype.prependOnceListener=function(e,A){return Ee(A),this.prependListener(e,mt(this,e,A)),this};K.prototype.removeListener=function(e,A){var t,r,n,o,g;if(Ee(A),r=this._events,r===void 0)return this;if(t=r[e],t===void 0)return this;if(t===A||t.listener===A)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,t.listener||A));else if(typeof t!="function"){for(n=-1,o=t.length-1;o>=0;o--)if(t[o]===A||t[o].listener===A){g=t[o].listener,n=o;break}if(n<0)return this;n===0?t.shift():dr(t,n),t.length===1&&(r[e]=t[0]),r.removeListener!==void 0&&this.emit("removeListener",e,g||A)}return this};K.prototype.off=K.prototype.removeListener;K.prototype.removeAllListeners=function(e){var A,t,r;if(t=this._events,t===void 0)return this;if(t.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):t[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete t[e]),this;if(arguments.length===0){var n=Object.keys(t),o;for(r=0;r<n.length;++r)o=n[r],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(A=t[e],typeof A=="function")this.removeListener(e,A);else if(A!==void 0)for(r=A.length-1;r>=0;r--)this.removeListener(e,A[r]);return this};function Yt(i,e,A){var t=i._events;if(t===void 0)return[];var r=t[e];return r===void 0?[]:typeof r=="function"?A?[r.listener||r]:[r]:A?Er(r):pt(r,r.length)}K.prototype.listeners=function(e){return Yt(this,e,!0)};K.prototype.rawListeners=function(e){return Yt(this,e,!1)};K.listenerCount=function(i,e){return typeof i.listenerCount=="function"?i.listenerCount(e):yt.call(i,e)};K.prototype.listenerCount=yt;function yt(i){var e=this._events;if(e!==void 0){var A=e[i];if(typeof A=="function")return 1;if(A!==void 0)return A.length}return 0}K.prototype.eventNames=function(){return this._eventsCount>0?de(this._events):[]};function pt(i,e){for(var A=new Array(e),t=0;t<e;++t)A[t]=i[t];return A}function dr(i,e){for(;e+1<i.length;e++)i[e]=i[e+1];i.pop()}function Er(i){for(var e=new Array(i.length),A=0;A<e.length;++A)e[A]=i[A].listener||i[A];return e}function lr(i,e){return new Promise(function(A,t){function r(o){i.removeListener(e,n),t(o)}function n(){typeof i.removeListener=="function"&&i.removeListener("error",r),A([].slice.call(arguments))}Lt(i,e,n,{once:!0}),e!=="error"&&vr(i,r,{once:!0})})}function vr(i,e,A){typeof i.on=="function"&&Lt(i,"error",e,A)}function Lt(i,e,A,t){if(typeof i.on=="function")t.once?i.once(e,A):i.on(e,A);else if(typeof i.addEventListener=="function")i.addEventListener(e,function r(n){t.once&&i.removeEventListener(e,r),A(n)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof i)}});var Le=KA((Og,di)=>{di.exports=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"}});var Ui=KA(Re=>{function Uo(i){return typeof i!="number"||isNaN(i)?1:i}function Ro(i,e){var A={},t=function(o){return typeof o>"u"?e:o};typeof e=="function"&&(t=e);var r=function(o){return t(o[i])},n=function(){return t(void 0)};return typeof i=="string"?(A.fromAttributes=r,A.fromGraph=function(o,g){return r(o.getNodeAttributes(g))},A.fromEntry=function(o,g){return r(g)}):typeof i=="function"?(A.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},A.fromGraph=function(o,g){return t(i(g,o.getNodeAttributes(g)))},A.fromEntry=function(o,g){return t(i(o,g))}):(A.fromAttributes=n,A.fromGraph=n,A.fromEntry=n),A}function Ni(i,e){var A={},t=function(o){return typeof o>"u"?e:o};typeof e=="function"&&(t=e);var r=function(o){return t(o[i])},n=function(){return t(void 0)};return typeof i=="string"?(A.fromAttributes=r,A.fromGraph=function(o,g){return r(o.getEdgeAttributes(g))},A.fromEntry=function(o,g){return r(g)},A.fromPartialEntry=A.fromEntry,A.fromMinimalEntry=A.fromEntry):typeof i=="function"?(A.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},A.fromGraph=function(o,g){var s=o.extremities(g);return t(i(g,o.getEdgeAttributes(g),s[0],s[1],o.getNodeAttributes(s[0]),o.getNodeAttributes(s[1]),o.isUndirected(g)))},A.fromEntry=function(o,g,s,B,C,w,c){return t(i(o,g,s,B,C,w,c))},A.fromPartialEntry=function(o,g,s,B){return t(i(o,g,s,B))},A.fromMinimalEntry=function(o,g){return t(i(o,g))}):(A.fromAttributes=n,A.fromGraph=n,A.fromEntry=n,A.fromMinimalEntry=n),A}Re.createNodeValueGetter=Ro;Re.createEdgeValueGetter=Ni;Re.createEdgeWeightGetter=function(i){return Ni(i,Uo)}});var Si=KA((os,Ti)=>{var T=0,N=1,b=2,H=3,GA=4,PA=5,x=6,Ri=7,Oe=8,Oi=9,Oo=0,jo=1,To=2,W=0,wA=1,tA=2,UA=3,pA=4,O=5,nA=6,dA=7,EA=8,ji=3,uA=10,So=3,_=9,ft=10;Ti.exports=function(e,A,t){var r,n,o,g,s,B,C,w,c,f,D=A.length,h=t.length,d=e.adjustSizes,P=e.barnesHutTheta*e.barnesHutTheta,v,E,I,Y,L,M,m,u=[];for(o=0;o<D;o+=uA)A[o+GA]=A[o+b],A[o+PA]=A[o+H],A[o+b]=0,A[o+H]=0;if(e.outboundAttractionDistribution){for(v=0,o=0;o<D;o+=uA)v+=A[o+x];v/=D/uA}if(e.barnesHutOptimize){var U=1/0,j=-1/0,R=1/0,iA=-1/0,J,V,gA;for(o=0;o<D;o+=uA)U=Math.min(U,A[o+T]),j=Math.max(j,A[o+T]),R=Math.min(R,A[o+N]),iA=Math.max(iA,A[o+N]);var lA=j-U,fA=iA-R;for(lA>fA?(R-=(lA-fA)/2,iA=R+lA):(U-=(fA-lA)/2,j=U+fA),u[0+W]=-1,u[0+wA]=(U+j)/2,u[0+tA]=(R+iA)/2,u[0+UA]=Math.max(j-U,iA-R),u[0+pA]=-1,u[0+O]=-1,u[0+nA]=0,u[0+dA]=0,u[0+EA]=0,r=1,o=0;o<D;o+=uA)for(n=0,gA=ji;;)if(u[n+O]>=0){A[o+T]<u[n+wA]?A[o+N]<u[n+tA]?J=u[n+O]:J=u[n+O]+_:A[o+N]<u[n+tA]?J=u[n+O]+_*2:J=u[n+O]+_*3,u[n+dA]=(u[n+dA]*u[n+nA]+A[o+T]*A[o+x])/(u[n+nA]+A[o+x]),u[n+EA]=(u[n+EA]*u[n+nA]+A[o+N]*A[o+x])/(u[n+nA]+A[o+x]),u[n+nA]+=A[o+x],n=J;continue}else if(u[n+W]<0){u[n+W]=o;break}else{if(u[n+O]=r*_,w=u[n+UA]/2,c=u[n+O],u[c+W]=-1,u[c+wA]=u[n+wA]-w,u[c+tA]=u[n+tA]-w,u[c+UA]=w,u[c+pA]=c+_,u[c+O]=-1,u[c+nA]=0,u[c+dA]=0,u[c+EA]=0,c+=_,u[c+W]=-1,u[c+wA]=u[n+wA]-w,u[c+tA]=u[n+tA]+w,u[c+UA]=w,u[c+pA]=c+_,u[c+O]=-1,u[c+nA]=0,u[c+dA]=0,u[c+EA]=0,c+=_,u[c+W]=-1,u[c+wA]=u[n+wA]+w,u[c+tA]=u[n+tA]-w,u[c+UA]=w,u[c+pA]=c+_,u[c+O]=-1,u[c+nA]=0,u[c+dA]=0,u[c+EA]=0,c+=_,u[c+W]=-1,u[c+wA]=u[n+wA]+w,u[c+tA]=u[n+tA]+w,u[c+UA]=w,u[c+pA]=u[n+pA],u[c+O]=-1,u[c+nA]=0,u[c+dA]=0,u[c+EA]=0,r+=4,A[u[n+W]+T]<u[n+wA]?A[u[n+W]+N]<u[n+tA]?J=u[n+O]:J=u[n+O]+_:A[u[n+W]+N]<u[n+tA]?J=u[n+O]+_*2:J=u[n+O]+_*3,u[n+nA]=A[u[n+W]+x],u[n+dA]=A[u[n+W]+T],u[n+EA]=A[u[n+W]+N],u[J+W]=u[n+W],u[n+W]=-1,A[o+T]<u[n+wA]?A[o+N]<u[n+tA]?V=u[n+O]:V=u[n+O]+_:A[o+N]<u[n+tA]?V=u[n+O]+_*2:V=u[n+O]+_*3,J===V)if(gA--){n=J;continue}else{gA=ji;break}u[V+W]=o;break}}if(e.barnesHutOptimize)for(E=e.scalingRatio,o=0;o<D;o+=uA)for(n=0;;)if(u[n+O]>=0)if(M=Math.pow(A[o+T]-u[n+dA],2)+Math.pow(A[o+N]-u[n+EA],2),f=u[n+UA],4*f*f/M<P){if(I=A[o+T]-u[n+dA],Y=A[o+N]-u[n+EA],d===!0?M>0?(m=E*A[o+x]*u[n+nA]/M,A[o+b]+=I*m,A[o+H]+=Y*m):M<0&&(m=-E*A[o+x]*u[n+nA]/Math.sqrt(M),A[o+b]+=I*m,A[o+H]+=Y*m):M>0&&(m=E*A[o+x]*u[n+nA]/M,A[o+b]+=I*m,A[o+H]+=Y*m),n=u[n+pA],n<0)break;continue}else{n=u[n+O];continue}else{if(B=u[n+W],B>=0&&B!==o&&(I=A[o+T]-A[B+T],Y=A[o+N]-A[B+N],M=I*I+Y*Y,d===!0?M>0?(m=E*A[o+x]*A[B+x]/M,A[o+b]+=I*m,A[o+H]+=Y*m):M<0&&(m=-E*A[o+x]*A[B+x]/Math.sqrt(M),A[o+b]+=I*m,A[o+H]+=Y*m):M>0&&(m=E*A[o+x]*A[B+x]/M,A[o+b]+=I*m,A[o+H]+=Y*m)),n=u[n+pA],n<0)break;continue}else for(E=e.scalingRatio,g=0;g<D;g+=uA)for(s=0;s<g;s+=uA)I=A[g+T]-A[s+T],Y=A[g+N]-A[s+N],d===!0?(M=Math.sqrt(I*I+Y*Y)-A[g+Oe]-A[s+Oe],M>0?(m=E*A[g+x]*A[s+x]/M/M,A[g+b]+=I*m,A[g+H]+=Y*m,A[s+b]-=I*m,A[s+H]-=Y*m):M<0&&(m=100*E*A[g+x]*A[s+x],A[g+b]+=I*m,A[g+H]+=Y*m,A[s+b]-=I*m,A[s+H]-=Y*m)):(M=Math.sqrt(I*I+Y*Y),M>0&&(m=E*A[g+x]*A[s+x]/M/M,A[g+b]+=I*m,A[g+H]+=Y*m,A[s+b]-=I*m,A[s+H]-=Y*m));for(c=e.gravity/e.scalingRatio,E=e.scalingRatio,o=0;o<D;o+=uA)m=0,I=A[o+T],Y=A[o+N],M=Math.sqrt(Math.pow(I,2)+Math.pow(Y,2)),e.strongGravityMode?M>0&&(m=E*A[o+x]*c):M>0&&(m=E*A[o+x]*c/M),A[o+b]-=I*m,A[o+H]-=Y*m;for(E=1*(e.outboundAttractionDistribution?v:1),C=0;C<h;C+=So)g=t[C+Oo],s=t[C+jo],w=t[C+To],L=Math.pow(w,e.edgeWeightInfluence),I=A[g+T]-A[s+T],Y=A[g+N]-A[s+N],d===!0?(M=Math.sqrt(I*I+Y*Y)-A[g+Oe]-A[s+Oe],e.linLogMode?e.outboundAttractionDistribution?M>0&&(m=-E*L*Math.log(1+M)/M/A[g+x]):M>0&&(m=-E*L*Math.log(1+M)/M):e.outboundAttractionDistribution?M>0&&(m=-E*L/A[g+x]):M>0&&(m=-E*L)):(M=Math.sqrt(Math.pow(I,2)+Math.pow(Y,2)),e.linLogMode?e.outboundAttractionDistribution?M>0&&(m=-E*L*Math.log(1+M)/M/A[g+x]):M>0&&(m=-E*L*Math.log(1+M)/M):e.outboundAttractionDistribution?(M=1,m=-E*L/A[g+x]):(M=1,m=-E*L)),M>0&&(A[g+b]+=I*m,A[g+H]+=Y*m,A[s+b]-=I*m,A[s+H]-=Y*m);var sA,rA,oA,hA,$,jA;if(d===!0)for(o=0;o<D;o+=uA)A[o+Oi]!==1&&(sA=Math.sqrt(Math.pow(A[o+b],2)+Math.pow(A[o+H],2)),sA>ft&&(A[o+b]=A[o+b]*ft/sA,A[o+H]=A[o+H]*ft/sA),rA=A[o+x]*Math.sqrt((A[o+GA]-A[o+b])*(A[o+GA]-A[o+b])+(A[o+PA]-A[o+H])*(A[o+PA]-A[o+H])),oA=Math.sqrt((A[o+GA]+A[o+b])*(A[o+GA]+A[o+b])+(A[o+PA]+A[o+H])*(A[o+PA]+A[o+H]))/2,hA=.1*Math.log(1+oA)/(1+Math.sqrt(rA)),$=A[o+T]+A[o+b]*(hA/e.slowDown),A[o+T]=$,jA=A[o+N]+A[o+H]*(hA/e.slowDown),A[o+N]=jA);else for(o=0;o<D;o+=uA)A[o+Oi]!==1&&(rA=A[o+x]*Math.sqrt((A[o+GA]-A[o+b])*(A[o+GA]-A[o+b])+(A[o+PA]-A[o+H])*(A[o+PA]-A[o+H])),oA=Math.sqrt((A[o+GA]+A[o+b])*(A[o+GA]+A[o+b])+(A[o+PA]+A[o+H])*(A[o+PA]+A[o+H]))/2,hA=A[o+Ri]*Math.log(1+oA)/(1+Math.sqrt(rA)),A[o+Ri]=Math.min(1,Math.sqrt(hA*(Math.pow(A[o+b],2)+Math.pow(A[o+H],2))/(1+Math.sqrt(rA)))),$=A[o+T]+A[o+b]*(hA/e.slowDown),A[o+T]=$,jA=A[o+N]+A[o+H]*(hA/e.slowDown),A[o+N]=jA);return{}}});var Xi=KA(LA=>{var ce=10,zi=3;LA.assign=function(i){i=i||{};var e=Array.prototype.slice.call(arguments).slice(1),A,t,r;for(A=0,r=e.length;A<r;A++)if(e[A])for(t in e[A])i[t]=e[A][t];return i};LA.validateSettings=function(i){return"linLogMode"in i&&typeof i.linLogMode!="boolean"?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in i&&typeof i.outboundAttractionDistribution!="boolean"?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in i&&typeof i.adjustSizes!="boolean"?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in i&&typeof i.edgeWeightInfluence!="number"?{message:"the `edgeWeightInfluence` setting should be a number."}:"scalingRatio"in i&&!(typeof i.scalingRatio=="number"&&i.scalingRatio>=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in i&&typeof i.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in i&&!(typeof i.gravity=="number"&&i.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in i&&!(typeof i.slowDown=="number"||i.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in i&&typeof i.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in i&&!(typeof i.barnesHutTheta=="number"&&i.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null};LA.graphToByteArrays=function(i,e){var A=i.order,t=i.size,r={},n,o=new Float32Array(A*ce),g=new Float32Array(t*zi);return n=0,i.forEachNode(function(s,B){r[s]=n,o[n]=B.x,o[n+1]=B.y,o[n+2]=0,o[n+3]=0,o[n+4]=0,o[n+5]=0,o[n+6]=1,o[n+7]=1,o[n+8]=B.size||1,o[n+9]=B.fixed?1:0,n+=ce}),n=0,i.forEachEdge(function(s,B,C,w,c,f,D){var h=r[C],d=r[w],P=e(s,B,C,w,c,f,D);o[h+6]+=P,o[d+6]+=P,g[n]=h,g[n+1]=d,g[n+2]=P,n+=zi}),{nodes:o,edges:g}};LA.assignLayoutChanges=function(i,e,A){var t=0;i.updateEachNodeAttributes(function(r,n){return n.x=e[t],n.y=e[t+1],t+=ce,A?A(r,n):n})};LA.readGraphPositions=function(i,e){var A=0;i.forEachNode(function(t,r){e[A]=r.x,e[A+1]=r.y,A+=ce})};LA.collectLayoutChanges=function(i,e,A){for(var t=i.nodes(),r={},n=0,o=0,g=e.length;n<g;n+=ce){if(A){var s=Object.assign({},i.getNodeAttributes(t[o]));s.x=e[n],s.y=e[n+1],s=A(t[o],s),r[t[o]]={x:s.x,y:s.y}}else r[t[o]]={x:e[n],y:e[n+1]};o++}return r};LA.createWorker=function(e){var A=window.URL||window.webkitURL,t=e.toString(),r=A.createObjectURL(new Blob(["("+t+").call(this);"],{type:"text/javascript"})),n=new Worker(r);return A.revokeObjectURL(r),n}});var Wi=KA((ss,Vi)=>{Vi.exports={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}});var _i=KA((as,Zi)=>{var zo=Le(),Xo=Ui().createEdgeWeightGetter,Vo=Si(),fe=Xi(),Wo=Wi();function qi(i,e,A){if(!zo(e))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof A=="number"&&(A={iterations:A});var t=A.iterations;if(typeof t!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(t<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var r=Xo("getEdgeWeight"in A?A.getEdgeWeight:"weight").fromEntry,n=typeof A.outputReducer=="function"?A.outputReducer:null,o=fe.assign({},Wo,A.settings),g=fe.validateSettings(o);if(g)throw new Error("graphology-layout-forceatlas2: "+g.message);var s=fe.graphToByteArrays(e,r),B;for(B=0;B<t;B++)Vo(o,s.nodes,s.edges);if(i){fe.assignLayoutChanges(e,s.nodes,n);return}return fe.collectLayoutChanges(e,s.nodes)}function qo(i){var e=typeof i=="number"?i:i.order;return{barnesHutOptimize:e>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(e)}}var ht=qi.bind(null,!1);ht.assign=qi.bind(null,!0);ht.inferSettings=qo;Zi.exports=ht});var Kt=TA(le(),1);function Ir(){let i=arguments[0];for(let e=1,A=arguments.length;e<A;e++)if(arguments[e])for(let t in arguments[e])i[t]=arguments[e][t];return i}var S=Ir;typeof Object.assign=="function"&&(S=Object.assign);function BA(i,e,A,t){let r=i._nodes.get(e),n=null;return r&&(t==="mixed"?n=r.out&&r.out[A]||r.undirected&&r.undirected[A]:t==="directed"?n=r.out&&r.out[A]:n=r.undirected&&r.undirected[A]),n}function q(i){return typeof i=="object"&&i!==null}function kt(i){let e;for(e in i)return!1;return!0}function aA(i,e,A){Object.defineProperty(i,e,{enumerable:!1,configurable:!1,writable:!0,value:A})}function QA(i,e,A){let t={enumerable:!0,configurable:!0};typeof A=="function"?t.get=A:(t.value=A,t.writable=!1),Object.defineProperty(i,e,t)}function bt(i){return!(!q(i)||i.attributes&&!Array.isArray(i.attributes))}function Mr(){let i=Math.floor(Math.random()*256)&255;return()=>i++}function vA(){let i=arguments,e=null,A=-1;return{[Symbol.iterator](){return this},next(){let t=null;do{if(e===null){if(A++,A>=i.length)return{done:!0};e=i[A][Symbol.iterator]()}if(t=e.next(),t.done){e=null;continue}break}while(!0);return t}}}function XA(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var ge=class extends Error{constructor(e){super(),this.name="GraphError",this.message=e}},G=class i extends ge{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,i.prototype.constructor)}},F=class i extends ge{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,i.prototype.constructor)}},p=class i extends ge{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,i.prototype.constructor)}};function Jt(i,e){this.key=i,this.attributes=e,this.clear()}Jt.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 Nt(i,e){this.key=i,this.attributes=e,this.clear()}Nt.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Ut(i,e){this.key=i,this.attributes=e,this.clear()}Ut.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function VA(i,e,A,t,r){this.key=e,this.attributes=r,this.undirected=i,this.source=A,this.target=t}VA.prototype.attach=function(){let i="out",e="in";this.undirected&&(i=e="undirected");let A=this.source.key,t=this.target.key;this.source[i][t]=this,!(this.undirected&&A===t)&&(this.target[e][A]=this)};VA.prototype.attachMulti=function(){let i="out",e="in",A=this.source.key,t=this.target.key;this.undirected&&(i=e="undirected");let r=this.source[i],n=r[t];if(typeof n>"u"){r[t]=this,this.undirected&&A===t||(this.target[e][A]=this);return}n.previous=this,this.next=n,r[t]=this,this.target[e][A]=this};VA.prototype.detach=function(){let i=this.source.key,e=this.target.key,A="out",t="in";this.undirected&&(A=t="undirected"),delete this.source[A][e],delete this.target[t][i]};VA.prototype.detachMulti=function(){let i=this.source.key,e=this.target.key,A="out",t="in";this.undirected&&(A=t="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[A][e],delete this.target[t][i]):(this.next.previous=void 0,this.source[A][e]=this.next,this.target[t][i]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};var Rt=0,Ot=1,Fr=2,jt=3;function IA(i,e,A,t,r,n,o){let g,s,B,C;if(t=""+t,A===Rt){if(g=i._nodes.get(t),!g)throw new F(`Graph.${e}: could not find the "${t}" node in the graph.`);B=r,C=n}else if(A===jt){if(r=""+r,s=i._edges.get(r),!s)throw new F(`Graph.${e}: could not find the "${r}" edge in the graph.`);let w=s.source.key,c=s.target.key;if(t===w)g=s.target;else if(t===c)g=s.source;else throw new F(`Graph.${e}: the "${t}" node is not attached to the "${r}" edge (${w}, ${c}).`);B=n,C=o}else{if(s=i._edges.get(t),!s)throw new F(`Graph.${e}: could not find the "${t}" edge in the graph.`);A===Ot?g=s.source:g=s.target,B=r,C=n}return[g,B,C]}function Gr(i,e,A){i.prototype[e]=function(t,r,n){let[o,g]=IA(this,e,A,t,r,n);return o.attributes[g]}}function Pr(i,e,A){i.prototype[e]=function(t,r){let[n]=IA(this,e,A,t,r);return n.attributes}}function mr(i,e,A){i.prototype[e]=function(t,r,n){let[o,g]=IA(this,e,A,t,r,n);return o.attributes.hasOwnProperty(g)}}function Yr(i,e,A){i.prototype[e]=function(t,r,n,o){let[g,s,B]=IA(this,e,A,t,r,n,o);return g.attributes[s]=B,this.emit("nodeAttributesUpdated",{key:g.key,type:"set",attributes:g.attributes,name:s}),this}}function yr(i,e,A){i.prototype[e]=function(t,r,n,o){let[g,s,B]=IA(this,e,A,t,r,n,o);if(typeof B!="function")throw new G(`Graph.${e}: updater should be a function.`);let C=g.attributes,w=B(C[s]);return C[s]=w,this.emit("nodeAttributesUpdated",{key:g.key,type:"set",attributes:g.attributes,name:s}),this}}function pr(i,e,A){i.prototype[e]=function(t,r,n){let[o,g]=IA(this,e,A,t,r,n);return delete o.attributes[g],this.emit("nodeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:g}),this}}function Lr(i,e,A){i.prototype[e]=function(t,r,n){let[o,g]=IA(this,e,A,t,r,n);if(!q(g))throw new G(`Graph.${e}: provided attributes are not a plain object.`);return o.attributes=g,this.emit("nodeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function br(i,e,A){i.prototype[e]=function(t,r,n){let[o,g]=IA(this,e,A,t,r,n);if(!q(g))throw new G(`Graph.${e}: provided attributes are not a plain object.`);return S(o.attributes,g),this.emit("nodeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:g}),this}}function Hr(i,e,A){i.prototype[e]=function(t,r,n){let[o,g]=IA(this,e,A,t,r,n);if(typeof g!="function")throw new G(`Graph.${e}: provided updater is not a function.`);return o.attributes=g(o.attributes),this.emit("nodeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}var xr=[{name:i=>`get${i}Attribute`,attacher:Gr},{name:i=>`get${i}Attributes`,attacher:Pr},{name:i=>`has${i}Attribute`,attacher:mr},{name:i=>`set${i}Attribute`,attacher:Yr},{name:i=>`update${i}Attribute`,attacher:yr},{name:i=>`remove${i}Attribute`,attacher:pr},{name:i=>`replace${i}Attributes`,attacher:Lr},{name:i=>`merge${i}Attributes`,attacher:br},{name:i=>`update${i}Attributes`,attacher:Hr}];function Kr(i){xr.forEach(function({name:e,attacher:A}){A(i,e("Node"),Rt),A(i,e("Source"),Ot),A(i,e("Target"),Fr),A(i,e("Opposite"),jt)})}function kr(i,e,A){i.prototype[e]=function(t,r){let n;if(this.type!=="mixed"&&A!=="mixed"&&A!==this.type)throw new p(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new p(`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.`);let o=""+t,g=""+r;if(r=arguments[2],n=BA(this,o,g,A),!n)throw new F(`Graph.${e}: could not find an edge for the given path ("${o}" - "${g}").`)}else{if(A!=="mixed")throw new p(`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(t=""+t,n=this._edges.get(t),!n)throw new F(`Graph.${e}: could not find the "${t}" edge in the graph.`)}return n.attributes[r]}}function Jr(i,e,A){i.prototype[e]=function(t){let r;if(this.type!=="mixed"&&A!=="mixed"&&A!==this.type)throw new p(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new p(`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.`);let n=""+t,o=""+arguments[1];if(r=BA(this,n,o,A),!r)throw new F(`Graph.${e}: could not find an edge for the given path ("${n}" - "${o}").`)}else{if(A!=="mixed")throw new p(`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(t=""+t,r=this._edges.get(t),!r)throw new F(`Graph.${e}: could not find the "${t}" edge in the graph.`)}return r.attributes}}function Nr(i,e,A){i.prototype[e]=function(t,r){let n;if(this.type!=="mixed"&&A!=="mixed"&&A!==this.type)throw new p(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new p(`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.`);let o=""+t,g=""+r;if(r=arguments[2],n=BA(this,o,g,A),!n)throw new F(`Graph.${e}: could not find an edge for the given path ("${o}" - "${g}").`)}else{if(A!=="mixed")throw new p(`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(t=""+t,n=this._edges.get(t),!n)throw new F(`Graph.${e}: could not find the "${t}" edge in the graph.`)}return n.attributes.hasOwnProperty(r)}}function Ur(i,e,A){i.prototype[e]=function(t,r,n){let o;if(this.type!=="mixed"&&A!=="mixed"&&A!==this.type)throw new p(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new p(`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.`);let g=""+t,s=""+r;if(r=arguments[2],n=arguments[3],o=BA(this,g,s,A),!o)throw new F(`Graph.${e}: could not find an edge for the given path ("${g}" - "${s}").`)}else{if(A!=="mixed")throw new p(`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(t=""+t,o=this._edges.get(t),!o)throw new F(`Graph.${e}: could not find the "${t}" edge in the graph.`)}return o.attributes[r]=n,this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:r}),this}}function Rr(i,e,A){i.prototype[e]=function(t,r,n){let o;if(this.type!=="mixed"&&A!=="mixed"&&A!==this.type)throw new p(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new p(`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.`);let g=""+t,s=""+r;if(r=arguments[2],n=arguments[3],o=BA(this,g,s,A),!o)throw new F(`Graph.${e}: could not find an edge for the given path ("${g}" - "${s}").`)}else{if(A!=="mixed")throw new p(`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(t=""+t,o=this._edges.get(t),!o)throw new F(`Graph.${e}: could not find the "${t}" edge in the graph.`)}if(typeof n!="function")throw new G(`Graph.${e}: updater should be a function.`);return o.attributes[r]=n(o.attributes[r]),this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:r}),this}}function Or(i,e,A){i.prototype[e]=function(t,r){let n;if(this.type!=="mixed"&&A!=="mixed"&&A!==this.type)throw new p(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new p(`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.`);let o=""+t,g=""+r;if(r=arguments[2],n=BA(this,o,g,A),!n)throw new F(`Graph.${e}: could not find an edge for the given path ("${o}" - "${g}").`)}else{if(A!=="mixed")throw new p(`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(t=""+t,n=this._edges.get(t),!n)throw new F(`Graph.${e}: could not find the "${t}" edge in the graph.`)}return delete n.attributes[r],this.emit("edgeAttributesUpdated",{key:n.key,type:"remove",attributes:n.attributes,name:r}),this}}function jr(i,e,A){i.prototype[e]=function(t,r){let n;if(this.type!=="mixed"&&A!=="mixed"&&A!==this.type)throw new p(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new p(`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.`);let o=""+t,g=""+r;if(r=arguments[2],n=BA(this,o,g,A),!n)throw new F(`Graph.${e}: could not find an edge for the given path ("${o}" - "${g}").`)}else{if(A!=="mixed")throw new p(`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(t=""+t,n=this._edges.get(t),!n)throw new F(`Graph.${e}: could not find the "${t}" edge in the graph.`)}if(!q(r))throw new G(`Graph.${e}: provided attributes are not a plain object.`);return n.attributes=r,this.emit("edgeAttributesUpdated",{key:n.key,type:"replace",attributes:n.attributes}),this}}function Tr(i,e,A){i.prototype[e]=function(t,r){let n;if(this.type!=="mixed"&&A!=="mixed"&&A!==this.type)throw new p(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new p(`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.`);let o=""+t,g=""+r;if(r=arguments[2],n=BA(this,o,g,A),!n)throw new F(`Graph.${e}: could not find an edge for the given path ("${o}" - "${g}").`)}else{if(A!=="mixed")throw new p(`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(t=""+t,n=this._edges.get(t),!n)throw new F(`Graph.${e}: could not find the "${t}" edge in the graph.`)}if(!q(r))throw new G(`Graph.${e}: provided attributes are not a plain object.`);return S(n.attributes,r),this.emit("edgeAttributesUpdated",{key:n.key,type:"merge",attributes:n.attributes,data:r}),this}}function Sr(i,e,A){i.prototype[e]=function(t,r){let n;if(this.type!=="mixed"&&A!=="mixed"&&A!==this.type)throw new p(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new p(`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.`);let o=""+t,g=""+r;if(r=arguments[2],n=BA(this,o,g,A),!n)throw new F(`Graph.${e}: could not find an edge for the given path ("${o}" - "${g}").`)}else{if(A!=="mixed")throw new p(`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(t=""+t,n=this._edges.get(t),!n)throw new F(`Graph.${e}: could not find the "${t}" edge in the graph.`)}if(typeof r!="function")throw new G(`Graph.${e}: provided updater is not a function.`);return n.attributes=r(n.attributes),this.emit("edgeAttributesUpdated",{key:n.key,type:"update",attributes:n.attributes}),this}}var zr=[{name:i=>`get${i}Attribute`,attacher:kr},{name:i=>`get${i}Attributes`,attacher:Jr},{name:i=>`has${i}Attribute`,attacher:Nr},{name:i=>`set${i}Attribute`,attacher:Ur},{name:i=>`update${i}Attribute`,attacher:Rr},{name:i=>`remove${i}Attribute`,attacher:Or},{name:i=>`replace${i}Attributes`,attacher:jr},{name:i=>`merge${i}Attributes`,attacher:Tr},{name:i=>`update${i}Attributes`,attacher:Sr}];function Xr(i){zr.forEach(function({name:e,attacher:A}){A(i,e("Edge"),"mixed"),A(i,e("DirectedEdge"),"directed"),A(i,e("UndirectedEdge"),"undirected")})}var Vr=[{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 Wr(i,e,A,t){let r=!1;for(let n in e){if(n===t)continue;let o=e[n];if(r=A(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),i&&r)return o.key}}function qr(i,e,A,t){let r,n,o,g=!1;for(let s in e)if(s!==t){r=e[s];do{if(n=r.source,o=r.target,g=A(r.key,r.attributes,n.key,o.key,n.attributes,o.attributes,r.undirected),i&&g)return r.key;r=r.next}while(r!==void 0)}}function Se(i,e){let A=Object.keys(i),t=A.length,r,n=0;return{[Symbol.iterator](){return this},next(){do if(r)r=r.next;else{if(n>=t)return{done:!0};let o=A[n++];if(o===e){r=void 0;continue}r=i[o]}while(!r);return{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 Zr(i,e,A,t){let r=e[A];if(!r)return;let n=r.source,o=r.target;if(t(r.key,r.attributes,n.key,o.key,n.attributes,o.attributes,r.undirected)&&i)return r.key}function _r(i,e,A,t){let r=e[A];if(!r)return;let n=!1;do{if(n=t(r.key,r.attributes,r.source.key,r.target.key,r.source.attributes,r.target.attributes,r.undirected),i&&n)return r.key;r=r.next}while(r!==void 0)}function ze(i,e){let A=i[e];if(A.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!A)return{done:!0};let r={edge:A.key,attributes:A.attributes,source:A.source.key,target:A.target.key,sourceAttributes:A.source.attributes,targetAttributes:A.target.attributes,undirected:A.undirected};return A=A.next,{done:!1,value:r}}};let t=!1;return{[Symbol.iterator](){return this},next(){return t===!0?{done:!0}:(t=!0,{done:!1,value:{edge:A.key,attributes:A.attributes,source:A.source.key,target:A.target.key,sourceAttributes:A.source.attributes,targetAttributes:A.target.attributes,undirected:A.undirected}})}}}function $r(i,e){if(i.size===0)return[];if(e==="mixed"||e===i.type)return Array.from(i._edges.keys());let A=e==="undirected"?i.undirectedSize:i.directedSize,t=new Array(A),r=e==="undirected",n=i._edges.values(),o=0,g,s;for(;g=n.next(),g.done!==!0;)s=g.value,s.undirected===r&&(t[o++]=s.key);return t}function Tt(i,e,A,t){if(e.size===0)return;let r=A!=="mixed"&&A!==e.type,n=A==="undirected",o,g,s=!1,B=e._edges.values();for(;o=B.next(),o.done!==!0;){if(g=o.value,r&&g.undirected!==n)continue;let{key:C,attributes:w,source:c,target:f}=g;if(s=t(C,w,c.key,f.key,c.attributes,f.attributes,g.undirected),i&&s)return C}}function An(i,e){if(i.size===0)return XA();let A=e!=="mixed"&&e!==i.type,t=e==="undirected",r=i._edges.values();return{[Symbol.iterator](){return this},next(){let n,o;for(;;){if(n=r.next(),n.done)return n;if(o=n.value,!(A&&o.undirected!==t))break}return{value:{edge:o.key,attributes:o.attributes,source:o.source.key,target:o.target.key,sourceAttributes:o.source.attributes,targetAttributes:o.target.attributes,undirected:o.undirected},done:!1}}}}function Xe(i,e,A,t,r,n){let o=e?qr:Wr,g;if(A!=="undirected"&&(t!=="out"&&(g=o(i,r.in,n),i&&g)||t!=="in"&&(g=o(i,r.out,n,t?void 0:r.key),i&&g))||A!=="directed"&&(g=o(i,r.undirected,n),i&&g))return g}function en(i,e,A,t){let r=[];return Xe(!1,i,e,A,t,function(n){r.push(n)}),r}function tn(i,e,A){let t=XA();return i!=="undirected"&&(e!=="out"&&typeof A.in<"u"&&(t=vA(t,Se(A.in))),e!=="in"&&typeof A.out<"u"&&(t=vA(t,Se(A.out,e?void 0:A.key)))),i!=="directed"&&typeof A.undirected<"u"&&(t=vA(t,Se(A.undirected))),t}function Ve(i,e,A,t,r,n,o){let g=A?_r:Zr,s;if(e!=="undirected"&&(typeof r.in<"u"&&t!=="out"&&(s=g(i,r.in,n,o),i&&s)||typeof r.out<"u"&&t!=="in"&&(t||r.key!==n)&&(s=g(i,r.out,n,o),i&&s))||e!=="directed"&&typeof r.undirected<"u"&&(s=g(i,r.undirected,n,o),i&&s))return s}function rn(i,e,A,t,r){let n=[];return Ve(!1,i,e,A,t,r,function(o){n.push(o)}),n}function nn(i,e,A,t){let r=XA();return i!=="undirected"&&(typeof A.in<"u"&&e!=="out"&&t in A.in&&(r=vA(r,ze(A.in,t))),typeof A.out<"u"&&e!=="in"&&t in A.out&&(e||A.key!==t)&&(r=vA(r,ze(A.out,t)))),i!=="directed"&&typeof A.undirected<"u"&&t in A.undirected&&(r=vA(r,ze(A.undirected,t))),r}function on(i,e){let{name:A,type:t,direction:r}=e;i.prototype[A]=function(n,o){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return[];if(!arguments.length)return $r(this,t);if(arguments.length===1){n=""+n;let g=this._nodes.get(n);if(typeof g>"u")throw new F(`Graph.${A}: could not find the "${n}" node in the graph.`);return en(this.multi,t==="mixed"?this.type:t,r,g)}if(arguments.length===2){n=""+n,o=""+o;let g=this._nodes.get(n);if(!g)throw new F(`Graph.${A}: could not find the "${n}" source node in the graph.`);if(!this._nodes.has(o))throw new F(`Graph.${A}: could not find the "${o}" target node in the graph.`);return rn(t,this.multi,r,g,o)}throw new G(`Graph.${A}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function gn(i,e){let{name:A,type:t,direction:r}=e,n="forEach"+A[0].toUpperCase()+A.slice(1,-1);i.prototype[n]=function(B,C,w){if(!(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)){if(arguments.length===1)return w=B,Tt(!1,this,t,w);if(arguments.length===2){B=""+B,w=C;let c=this._nodes.get(B);if(typeof c>"u")throw new F(`Graph.${n}: could not find the "${B}" node in the graph.`);return Xe(!1,this.multi,t==="mixed"?this.type:t,r,c,w)}if(arguments.length===3){B=""+B,C=""+C;let c=this._nodes.get(B);if(!c)throw new F(`Graph.${n}: could not find the "${B}" source node in the graph.`);if(!this._nodes.has(C))throw new F(`Graph.${n}: could not find the "${C}" target node in the graph.`);return Ve(!1,t,this.multi,r,c,C,w)}throw new G(`Graph.${n}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let o="map"+A[0].toUpperCase()+A.slice(1);i.prototype[o]=function(){let B=Array.prototype.slice.call(arguments),C=B.pop(),w;if(B.length===0){let c=0;t!=="directed"&&(c+=this.undirectedSize),t!=="undirected"&&(c+=this.directedSize),w=new Array(c);let f=0;B.push((D,h,d,P,v,E,I)=>{w[f++]=C(D,h,d,P,v,E,I)})}else w=[],B.push((c,f,D,h,d,P,v)=>{w.push(C(c,f,D,h,d,P,v))});return this[n].apply(this,B),w};let g="filter"+A[0].toUpperCase()+A.slice(1);i.prototype[g]=function(){let B=Array.prototype.slice.call(arguments),C=B.pop(),w=[];return B.push((c,f,D,h,d,P,v)=>{C(c,f,D,h,d,P,v)&&w.push(c)}),this[n].apply(this,B),w};let s="reduce"+A[0].toUpperCase()+A.slice(1);i.prototype[s]=function(){let B=Array.prototype.slice.call(arguments);if(B.length<2||B.length>4)throw new G(`Graph.${s}: invalid number of arguments (expecting 2, 3 or 4 and got ${B.length}).`);if(typeof B[B.length-1]=="function"&&typeof B[B.length-2]!="function")throw new G(`Graph.${s}: 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 C,w;B.length===2?(C=B[0],w=B[1],B=[]):B.length===3?(C=B[1],w=B[2],B=[B[0]]):B.length===4&&(C=B[2],w=B[3],B=[B[0],B[1]]);let c=w;return B.push((f,D,h,d,P,v,E)=>{c=C(c,f,D,h,d,P,v,E)}),this[n].apply(this,B),c}}function sn(i,e){let{name:A,type:t,direction:r}=e,n="find"+A[0].toUpperCase()+A.slice(1,-1);i.prototype[n]=function(s,B,C){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return!1;if(arguments.length===1)return C=s,Tt(!0,this,t,C);if(arguments.length===2){s=""+s,C=B;let w=this._nodes.get(s);if(typeof w>"u")throw new F(`Graph.${n}: could not find the "${s}" node in the graph.`);return Xe(!0,this.multi,t==="mixed"?this.type:t,r,w,C)}if(arguments.length===3){s=""+s,B=""+B;let w=this._nodes.get(s);if(!w)throw new F(`Graph.${n}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(B))throw new F(`Graph.${n}: could not find the "${B}" target node in the graph.`);return Ve(!0,t,this.multi,r,w,B,C)}throw new G(`Graph.${n}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let o="some"+A[0].toUpperCase()+A.slice(1,-1);i.prototype[o]=function(){let s=Array.prototype.slice.call(arguments),B=s.pop();return s.push((w,c,f,D,h,d,P)=>B(w,c,f,D,h,d,P)),!!this[n].apply(this,s)};let g="every"+A[0].toUpperCase()+A.slice(1,-1);i.prototype[g]=function(){let s=Array.prototype.slice.call(arguments),B=s.pop();return s.push((w,c,f,D,h,d,P)=>!B(w,c,f,D,h,d,P)),!this[n].apply(this,s)}}function an(i,e){let{name:A,type:t,direction:r}=e,n=A.slice(0,-1)+"Entries";i.prototype[n]=function(o,g){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return XA();if(!arguments.length)return An(this,t);if(arguments.length===1){o=""+o;let s=this._nodes.get(o);if(!s)throw new F(`Graph.${n}: could not find the "${o}" node in the graph.`);return tn(t,r,s)}if(arguments.length===2){o=""+o,g=""+g;let s=this._nodes.get(o);if(!s)throw new F(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(g))throw new F(`Graph.${n}: could not find the "${g}" target node in the graph.`);return nn(t,r,s,g)}throw new G(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Bn(i){Vr.forEach(e=>{on(i,e),gn(i,e),sn(i,e),an(i,e)})}var Cn=[{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 me(){this.A=null,this.B=null}me.prototype.wrap=function(i){this.A===null?this.A=i:this.B===null&&(this.B=i)};me.prototype.has=function(i){return this.A!==null&&i in this.A||this.B!==null&&i in this.B};function ne(i,e,A,t,r){for(let n in t){let o=t[n],g=o.source,s=o.target,B=g===A?s:g;if(e&&e.has(B.key))continue;let C=r(B.key,B.attributes);if(i&&C)return B.key}}function We(i,e,A,t,r){if(e!=="mixed"){if(e==="undirected")return ne(i,null,t,t.undirected,r);if(typeof A=="string")return ne(i,null,t,t[A],r)}let n=new me,o;if(e!=="undirected"){if(A!=="out"){if(o=ne(i,null,t,t.in,r),i&&o)return o;n.wrap(t.in)}if(A!=="in"){if(o=ne(i,n,t,t.out,r),i&&o)return o;n.wrap(t.out)}}if(e!=="directed"&&(o=ne(i,n,t,t.undirected,r),i&&o))return o}function wn(i,e,A){if(i!=="mixed"){if(i==="undirected")return Object.keys(A.undirected);if(typeof e=="string")return Object.keys(A[e])}let t=[];return We(!1,i,e,A,function(r){t.push(r)}),t}function oe(i,e,A){let t=Object.keys(A),r=t.length,n=0;return{[Symbol.iterator](){return this},next(){let o=null;do{if(n>=r)return i&&i.wrap(A),{done:!0};let g=A[t[n++]],s=g.source,B=g.target;if(o=s===e?B:s,i&&i.has(o.key)){o=null;continue}}while(o===null);return{done:!1,value:{neighbor:o.key,attributes:o.attributes}}}}}function cn(i,e,A){if(i!=="mixed"){if(i==="undirected")return oe(null,A,A.undirected);if(typeof e=="string")return oe(null,A,A[e])}let t=XA(),r=new me;return i!=="undirected"&&(e!=="out"&&(t=vA(t,oe(r,A,A.in))),e!=="in"&&(t=vA(t,oe(r,A,A.out)))),i!=="directed"&&(t=vA(t,oe(r,A,A.undirected))),t}function fn(i,e){let{name:A,type:t,direction:r}=e;i.prototype[A]=function(n){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return[];n=""+n;let o=this._nodes.get(n);if(typeof o>"u")throw new F(`Graph.${A}: could not find the "${n}" node in the graph.`);return wn(t==="mixed"?this.type:t,r,o)}}function hn(i,e){let{name:A,type:t,direction:r}=e,n="forEach"+A[0].toUpperCase()+A.slice(1,-1);i.prototype[n]=function(B,C){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return;B=""+B;let w=this._nodes.get(B);if(typeof w>"u")throw new F(`Graph.${n}: could not find the "${B}" node in the graph.`);We(!1,t==="mixed"?this.type:t,r,w,C)};let o="map"+A[0].toUpperCase()+A.slice(1);i.prototype[o]=function(B,C){let w=[];return this[n](B,(c,f)=>{w.push(C(c,f))}),w};let g="filter"+A[0].toUpperCase()+A.slice(1);i.prototype[g]=function(B,C){let w=[];return this[n](B,(c,f)=>{C(c,f)&&w.push(c)}),w};let s="reduce"+A[0].toUpperCase()+A.slice(1);i.prototype[s]=function(B,C,w){if(arguments.length<3)throw new G(`Graph.${s}: 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 c=w;return this[n](B,(f,D)=>{c=C(c,f,D)}),c}}function Qn(i,e){let{name:A,type:t,direction:r}=e,n=A[0].toUpperCase()+A.slice(1,-1),o="find"+n;i.prototype[o]=function(B,C){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return;B=""+B;let w=this._nodes.get(B);if(typeof w>"u")throw new F(`Graph.${o}: could not find the "${B}" node in the graph.`);return We(!0,t==="mixed"?this.type:t,r,w,C)};let g="some"+n;i.prototype[g]=function(B,C){return!!this[o](B,C)};let s="every"+n;i.prototype[s]=function(B,C){return!this[o](B,(c,f)=>!C(c,f))}}function Dn(i,e){let{name:A,type:t,direction:r}=e,n=A.slice(0,-1)+"Entries";i.prototype[n]=function(o){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return XA();o=""+o;let g=this._nodes.get(o);if(typeof g>"u")throw new F(`Graph.${n}: could not find the "${o}" node in the graph.`);return cn(t==="mixed"?this.type:t,r,g)}}function un(i){Cn.forEach(e=>{fn(i,e),hn(i,e),Qn(i,e),Dn(i,e)})}function ve(i,e,A,t,r){let n=t._nodes.values(),o=t.type,g,s,B,C,w,c,f;for(;g=n.next(),g.done!==!0;){let D=!1;if(s=g.value,o!=="undirected"){C=s.out;for(B in C){w=C[B];do{if(c=w.target,D=!0,f=r(s.key,c.key,s.attributes,c.attributes,w.key,w.attributes,w.undirected),i&&f)return w;w=w.next}while(w)}}if(o!=="directed"){C=s.undirected;for(B in C)if(!(e&&s.key>B)){w=C[B];do{if(c=w.target,c.key!==B&&(c=w.source),D=!0,f=r(s.key,c.key,s.attributes,c.attributes,w.key,w.attributes,w.undirected),i&&f)return w;w=w.next}while(w)}}if(A&&!D&&(f=r(s.key,null,s.attributes,null,null,null,null),i&&f))return null}}function dn(i,e){let A={key:i};return kt(e.attributes)||(A.attributes=S({},e.attributes)),A}function En(i,e,A){let t={key:e,source:A.source.key,target:A.target.key};return kt(A.attributes)||(t.attributes=S({},A.attributes)),i==="mixed"&&A.undirected&&(t.undirected=!0),t}function ln(i){if(!q(i))throw new G('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in i))throw new G("Graph.import: serialized node is missing its key.");if("attributes"in i&&(!q(i.attributes)||i.attributes===null))throw new G("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function vn(i){if(!q(i))throw new G('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in i))throw new G("Graph.import: serialized edge is missing its source.");if(!("target"in i))throw new G("Graph.import: serialized edge is missing its target.");if("attributes"in i&&(!q(i.attributes)||i.attributes===null))throw new G("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in i&&typeof i.undirected!="boolean")throw new G("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}var In=Mr(),Mn=new Set(["directed","undirected","mixed"]),Ht=new Set(["domain","_events","_eventsCount","_maxListeners"]),Fn=[{name:i=>`${i}Edge`,generateKey:!0},{name:i=>`${i}DirectedEdge`,generateKey:!0,type:"directed"},{name:i=>`${i}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:i=>`${i}EdgeWithKey`},{name:i=>`${i}DirectedEdgeWithKey`,type:"directed"},{name:i=>`${i}UndirectedEdgeWithKey`,type:"undirected"}],Gn={allowSelfLoops:!0,multi:!1,type:"mixed"};function Pn(i,e,A){if(A&&!q(A))throw new G(`Graph.addNode: invalid attributes. Expecting an object but got "${A}"`);if(e=""+e,A=A||{},i._nodes.has(e))throw new p(`Graph.addNode: the "${e}" node already exist in the graph.`);let t=new i.NodeDataClass(e,A);return i._nodes.set(e,t),i.emit("nodeAdded",{key:e,attributes:A}),t}function xt(i,e,A){let t=new i.NodeDataClass(e,A);return i._nodes.set(e,t),i.emit("nodeAdded",{key:e,attributes:A}),t}function St(i,e,A,t,r,n,o,g){if(!t&&i.type==="undirected")throw new p(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(t&&i.type==="directed")throw new p(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(g&&!q(g))throw new G(`Graph.${e}: invalid attributes. Expecting an object but got "${g}"`);if(n=""+n,o=""+o,g=g||{},!i.allowSelfLoops&&n===o)throw new p(`Graph.${e}: source & target are the same ("${n}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let s=i._nodes.get(n),B=i._nodes.get(o);if(!s)throw new F(`Graph.${e}: source node "${n}" not found.`);if(!B)throw new F(`Graph.${e}: target node "${o}" not found.`);let C={key:null,undirected:t,source:n,target:o,attributes:g};if(A)r=i._edgeKeyGenerator();else if(r=""+r,i._edges.has(r))throw new p(`Graph.${e}: the "${r}" edge already exists in the graph.`);if(!i.multi&&(t?typeof s.undirected[o]<"u":typeof s.out[o]<"u"))throw new p(`Graph.${e}: an edge linking "${n}" to "${o}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);let w=new VA(t,r,s,B,g);i._edges.set(r,w);let c=n===o;return t?(s.undirectedDegree++,B.undirectedDegree++,c&&(s.undirectedLoops++,i._undirectedSelfLoopCount++)):(s.outDegree++,B.inDegree++,c&&(s.directedLoops++,i._directedSelfLoopCount++)),i.multi?w.attachMulti():w.attach(),t?i._undirectedSize++:i._directedSize++,C.key=r,i.emit("edgeAdded",C),r}function mn(i,e,A,t,r,n,o,g,s){if(!t&&i.type==="undirected")throw new p(`Graph.${e}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(t&&i.type==="directed")throw new p(`Graph.${e}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(g){if(s){if(typeof g!="function")throw new G(`Graph.${e}: invalid updater function. Expecting a function but got "${g}"`)}else if(!q(g))throw new G(`Graph.${e}: invalid attributes. Expecting an object but got "${g}"`)}n=""+n,o=""+o;let B;if(s&&(B=g,g=void 0),!i.allowSelfLoops&&n===o)throw new p(`Graph.${e}: source & target are the same ("${n}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let C=i._nodes.get(n),w=i._nodes.get(o),c,f;if(!A&&(c=i._edges.get(r),c)){if((c.source.key!==n||c.target.key!==o)&&(!t||c.source.key!==o||c.target.key!==n))throw new p(`Graph.${e}: inconsistency detected when attempting to merge the "${r}" edge with "${n}" source & "${o}" target vs. ("${c.source.key}", "${c.target.key}").`);f=c}if(!f&&!i.multi&&C&&(f=t?C.undirected[o]:C.out[o]),f){let v=[f.key,!1,!1,!1];if(s?!B:!g)return v;if(s){let E=f.attributes;f.attributes=B(E),i.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else S(f.attributes,g),i.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:g});return v}g=g||{},s&&B&&(g=B(g));let D={key:null,undirected:t,source:n,target:o,attributes:g};if(A)r=i._edgeKeyGenerator();else if(r=""+r,i._edges.has(r))throw new p(`Graph.${e}: the "${r}" edge already exists in the graph.`);let h=!1,d=!1;C||(C=xt(i,n,{}),h=!0,n===o&&(w=C,d=!0)),w||(w=xt(i,o,{}),d=!0),c=new VA(t,r,C,w,g),i._edges.set(r,c);let P=n===o;return t?(C.undirectedDegree++,w.undirectedDegree++,P&&(C.undirectedLoops++,i._undirectedSelfLoopCount++)):(C.outDegree++,w.inDegree++,P&&(C.directedLoops++,i._directedSelfLoopCount++)),i.multi?c.attachMulti():c.attach(),t?i._undirectedSize++:i._directedSize++,D.key=r,i.emit("edgeAdded",D),[r,!0,h,d]}function zA(i,e){i._edges.delete(e.key);let{source:A,target:t,attributes:r}=e,n=e.undirected,o=A===t;n?(A.undirectedDegree--,t.undirectedDegree--,o&&(A.undirectedLoops--,i._undirectedSelfLoopCount--)):(A.outDegree--,t.inDegree--,o&&(A.directedLoops--,i._directedSelfLoopCount--)),i.multi?e.detachMulti():e.detach(),n?i._undirectedSize--:i._directedSize--,i.emit("edgeDropped",{key:e.key,attributes:r,source:A.key,target:t.key,undirected:n})}var k=class i extends Kt.EventEmitter{constructor(e){if(super(),e=S({},Gn,e),typeof e.multi!="boolean")throw new G(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!Mn.has(e.type))throw new G(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new G(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);let A=e.type==="mixed"?Jt:e.type==="directed"?Nt:Ut;aA(this,"NodeDataClass",A);let t="geid_"+In()+"_",r=0,n=()=>{let o;do o=t+r++;while(this._edges.has(o));return o};aA(this,"_attributes",{}),aA(this,"_nodes",new Map),aA(this,"_edges",new Map),aA(this,"_directedSize",0),aA(this,"_undirectedSize",0),aA(this,"_directedSelfLoopCount",0),aA(this,"_undirectedSelfLoopCount",0),aA(this,"_edgeKeyGenerator",n),aA(this,"_options",e),Ht.forEach(o=>aA(this,o,this[o])),QA(this,"order",()=>this._nodes.size),QA(this,"size",()=>this._edges.size),QA(this,"directedSize",()=>this._directedSize),QA(this,"undirectedSize",()=>this._undirectedSize),QA(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),QA(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),QA(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),QA(this,"multi",this._options.multi),QA(this,"type",this._options.type),QA(this,"allowSelfLoops",this._options.allowSelfLoops),QA(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,A){if(this.type==="undirected")return!1;if(arguments.length===1){let t=""+e,r=this._edges.get(t);return!!r&&!r.undirected}else if(arguments.length===2){e=""+e,A=""+A;let t=this._nodes.get(e);return t?t.out.hasOwnProperty(A):!1}throw new G(`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,A){if(this.type==="directed")return!1;if(arguments.length===1){let t=""+e,r=this._edges.get(t);return!!r&&r.undirected}else if(arguments.length===2){e=""+e,A=""+A;let t=this._nodes.get(e);return t?t.undirected.hasOwnProperty(A):!1}throw new G(`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,A){if(arguments.length===1){let t=""+e;return this._edges.has(t)}else if(arguments.length===2){e=""+e,A=""+A;let t=this._nodes.get(e);return t?typeof t.out<"u"&&t.out.hasOwnProperty(A)||typeof t.undirected<"u"&&t.undirected.hasOwnProperty(A):!1}throw new G(`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,A){if(this.type==="undirected")return;if(e=""+e,A=""+A,this.multi)throw new p("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");let t=this._nodes.get(e);if(!t)throw new F(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(A))throw new F(`Graph.directedEdge: could not find the "${A}" target node in the graph.`);let r=t.out&&t.out[A]||void 0;if(r)return r.key}undirectedEdge(e,A){if(this.type==="directed")return;if(e=""+e,A=""+A,this.multi)throw new p("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");let t=this._nodes.get(e);if(!t)throw new F(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(A))throw new F(`Graph.undirectedEdge: could not find the "${A}" target node in the graph.`);let r=t.undirected&&t.undirected[A]||void 0;if(r)return r.key}edge(e,A){if(this.multi)throw new p("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,A=""+A;let t=this._nodes.get(e);if(!t)throw new F(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(A))throw new F(`Graph.edge: could not find the "${A}" target node in the graph.`);let r=t.out&&t.out[A]||t.undirected&&t.undirected[A]||void 0;if(r)return r.key}areDirectedNeighbors(e,A){e=""+e,A=""+A;let t=this._nodes.get(e);if(!t)throw new F(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:A in t.in||A in t.out}areOutNeighbors(e,A){e=""+e,A=""+A;let t=this._nodes.get(e);if(!t)throw new F(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:A in t.out}areInNeighbors(e,A){e=""+e,A=""+A;let t=this._nodes.get(e);if(!t)throw new F(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:A in t.in}areUndirectedNeighbors(e,A){e=""+e,A=""+A;let t=this._nodes.get(e);if(!t)throw new F(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="directed"?!1:A in t.undirected}areNeighbors(e,A){e=""+e,A=""+A;let t=this._nodes.get(e);if(!t)throw new F(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&(A in t.in||A in t.out)||this.type!=="directed"&&A in t.undirected}areInboundNeighbors(e,A){e=""+e,A=""+A;let t=this._nodes.get(e);if(!t)throw new F(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&A in t.in||this.type!=="directed"&&A in t.undirected}areOutboundNeighbors(e,A){e=""+e,A=""+A;let t=this._nodes.get(e);if(!t)throw new F(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&A in t.out||this.type!=="directed"&&A in t.undirected}inDegree(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:A.inDegree}outDegree(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:A.outDegree}directedDegree(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:A.inDegree+A.outDegree}undirectedDegree(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:A.undirectedDegree}inboundDegree(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let t=0;return this.type!=="directed"&&(t+=A.undirectedDegree),this.type!=="undirected"&&(t+=A.inDegree),t}outboundDegree(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let t=0;return this.type!=="directed"&&(t+=A.undirectedDegree),this.type!=="undirected"&&(t+=A.outDegree),t}degree(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.degree: could not find the "${e}" node in the graph.`);let t=0;return this.type!=="directed"&&(t+=A.undirectedDegree),this.type!=="undirected"&&(t+=A.inDegree+A.outDegree),t}inDegreeWithoutSelfLoops(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:A.inDegree-A.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:A.outDegree-A.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:A.inDegree+A.outDegree-A.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:A.undirectedDegree-A.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let t=0,r=0;return this.type!=="directed"&&(t+=A.undirectedDegree,r+=A.undirectedLoops*2),this.type!=="undirected"&&(t+=A.inDegree,r+=A.directedLoops),t-r}outboundDegreeWithoutSelfLoops(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let t=0,r=0;return this.type!=="directed"&&(t+=A.undirectedDegree,r+=A.undirectedLoops*2),this.type!=="undirected"&&(t+=A.outDegree,r+=A.directedLoops),t-r}degreeWithoutSelfLoops(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let t=0,r=0;return this.type!=="directed"&&(t+=A.undirectedDegree,r+=A.undirectedLoops*2),this.type!=="undirected"&&(t+=A.inDegree+A.outDegree,r+=A.directedLoops*2),t-r}source(e){e=""+e;let A=this._edges.get(e);if(!A)throw new F(`Graph.source: could not find the "${e}" edge in the graph.`);return A.source.key}target(e){e=""+e;let A=this._edges.get(e);if(!A)throw new F(`Graph.target: could not find the "${e}" edge in the graph.`);return A.target.key}extremities(e){e=""+e;let A=this._edges.get(e);if(!A)throw new F(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[A.source.key,A.target.key]}opposite(e,A){e=""+e,A=""+A;let t=this._edges.get(A);if(!t)throw new F(`Graph.opposite: could not find the "${A}" edge in the graph.`);let r=t.source.key,n=t.target.key;if(e===r)return n;if(e===n)return r;throw new F(`Graph.opposite: the "${e}" node is not attached to the "${A}" edge (${r}, ${n}).`)}hasExtremity(e,A){e=""+e,A=""+A;let t=this._edges.get(e);if(!t)throw new F(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return t.source.key===A||t.target.key===A}isUndirected(e){e=""+e;let A=this._edges.get(e);if(!A)throw new F(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return A.undirected}isDirected(e){e=""+e;let A=this._edges.get(e);if(!A)throw new F(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!A.undirected}isSelfLoop(e){e=""+e;let A=this._edges.get(e);if(!A)throw new F(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return A.source===A.target}addNode(e,A){return Pn(this,e,A).key}mergeNode(e,A){if(A&&!q(A))throw new G(`Graph.mergeNode: invalid attributes. Expecting an object but got "${A}"`);e=""+e,A=A||{};let t=this._nodes.get(e);return t?(A&&(S(t.attributes,A),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:t.attributes,data:A})),[e,!1]):(t=new this.NodeDataClass(e,A),this._nodes.set(e,t),this.emit("nodeAdded",{key:e,attributes:A}),[e,!0])}updateNode(e,A){if(A&&typeof A!="function")throw new G(`Graph.updateNode: invalid updater function. Expecting a function but got "${A}"`);e=""+e;let t=this._nodes.get(e);if(t){if(A){let n=t.attributes;t.attributes=A(n),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:t.attributes})}return[e,!1]}let r=A?A({}):{};return t=new this.NodeDataClass(e,r),this._nodes.set(e,t),this.emit("nodeAdded",{key:e,attributes:r}),[e,!0]}dropNode(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.dropNode: could not find the "${e}" node in the graph.`);let t;if(this.type!=="undirected"){for(let r in A.out){t=A.out[r];do zA(this,t),t=t.next;while(t)}for(let r in A.in){t=A.in[r];do zA(this,t),t=t.next;while(t)}}if(this.type!=="directed")for(let r in A.undirected){t=A.undirected[r];do zA(this,t),t=t.next;while(t)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:A.attributes})}dropEdge(e){let A;if(arguments.length>1){let t=""+arguments[0],r=""+arguments[1];if(A=BA(this,t,r,this.type),!A)throw new F(`Graph.dropEdge: could not find the "${t}" -> "${r}" edge in the graph.`)}else if(e=""+e,A=this._edges.get(e),!A)throw new F(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return zA(this,A),this}dropDirectedEdge(e,A){if(arguments.length<2)throw new p("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 p("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,A=""+A;let t=BA(this,e,A,"directed");if(!t)throw new F(`Graph.dropDirectedEdge: could not find a "${e}" -> "${A}" edge in the graph.`);return zA(this,t),this}dropUndirectedEdge(e,A){if(arguments.length<2)throw new p("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 p("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.");let t=BA(this,e,A,"undirected");if(!t)throw new F(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${A}" edge in the graph.`);return zA(this,t),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){let e=this._nodes.values(),A;for(;A=e.next(),A.done!==!0;)A.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,A){return this._attributes[e]=A,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,A){if(typeof A!="function")throw new G("Graph.updateAttribute: updater should be a function.");let t=this._attributes[e];return this._attributes[e]=A(t),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(!q(e))throw new G("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(!q(e))throw new G("Graph.mergeAttributes: provided attributes are not a plain object.");return S(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new G("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,A){if(typeof e!="function")throw new G("Graph.updateEachNodeAttributes: expecting an updater function.");if(A&&!bt(A))throw new G("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let t=this._nodes.values(),r,n;for(;r=t.next(),r.done!==!0;)n=r.value,n.attributes=e(n.key,n.attributes);this.emit("eachNodeAttributesUpdated",{hints:A||null})}updateEachEdgeAttributes(e,A){if(typeof e!="function")throw new G("Graph.updateEachEdgeAttributes: expecting an updater function.");if(A&&!bt(A))throw new G("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let t=this._edges.values(),r,n,o,g;for(;r=t.next(),r.done!==!0;)n=r.value,o=n.source,g=n.target,n.attributes=e(n.key,n.attributes,o.key,g.key,o.attributes,g.attributes,n.undirected);this.emit("eachEdgeAttributesUpdated",{hints:A||null})}forEachAdjacencyEntry(e){if(typeof e!="function")throw new G("Graph.forEachAdjacencyEntry: expecting a callback.");ve(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new G("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");ve(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new G("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");ve(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new G("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");ve(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!="function")throw new G("Graph.forEachNode: expecting a callback.");let A=this._nodes.values(),t,r;for(;t=A.next(),t.done!==!0;)r=t.value,e(r.key,r.attributes)}findNode(e){if(typeof e!="function")throw new G("Graph.findNode: expecting a callback.");let A=this._nodes.values(),t,r;for(;t=A.next(),t.done!==!0;)if(r=t.value,e(r.key,r.attributes))return r.key}mapNodes(e){if(typeof e!="function")throw new G("Graph.mapNode: expecting a callback.");let A=this._nodes.values(),t,r,n=new Array(this.order),o=0;for(;t=A.next(),t.done!==!0;)r=t.value,n[o++]=e(r.key,r.attributes);return n}someNode(e){if(typeof e!="function")throw new G("Graph.someNode: expecting a callback.");let A=this._nodes.values(),t,r;for(;t=A.next(),t.done!==!0;)if(r=t.value,e(r.key,r.attributes))return!0;return!1}everyNode(e){if(typeof e!="function")throw new G("Graph.everyNode: expecting a callback.");let A=this._nodes.values(),t,r;for(;t=A.next(),t.done!==!0;)if(r=t.value,!e(r.key,r.attributes))return!1;return!0}filterNodes(e){if(typeof e!="function")throw new G("Graph.filterNodes: expecting a callback.");let A=this._nodes.values(),t,r,n=[];for(;t=A.next(),t.done!==!0;)r=t.value,e(r.key,r.attributes)&&n.push(r.key);return n}reduceNodes(e,A){if(typeof e!="function")throw new G("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new G("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 t=A,r=this._nodes.values(),n,o;for(;n=r.next(),n.done!==!0;)o=n.value,t=e(t,o.key,o.attributes);return t}nodeEntries(){let e=this._nodes.values();return{[Symbol.iterator](){return this},next(){let A=e.next();if(A.done)return A;let t=A.value;return{value:{node:t.key,attributes:t.attributes},done:!1}}}}export(){let e=new Array(this._nodes.size),A=0;this._nodes.forEach((r,n)=>{e[A++]=dn(n,r)});let t=new Array(this._edges.size);return A=0,this._edges.forEach((r,n)=>{t[A++]=En(this.type,n,r)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:t}}import(e,A=!1){if(e instanceof i)return e.forEachNode((s,B)=>{A?this.mergeNode(s,B):this.addNode(s,B)}),e.forEachEdge((s,B,C,w,c,f,D)=>{A?D?this.mergeUndirectedEdgeWithKey(s,C,w,B):this.mergeDirectedEdgeWithKey(s,C,w,B):D?this.addUndirectedEdgeWithKey(s,C,w,B):this.addDirectedEdgeWithKey(s,C,w,B)}),this;if(!q(e))throw new G("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!q(e.attributes))throw new G("Graph.import: invalid attributes. Expecting a plain object.");A?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let t,r,n,o,g;if(e.nodes){if(n=e.nodes,!Array.isArray(n))throw new G("Graph.import: invalid nodes. Expecting an array.");for(t=0,r=n.length;t<r;t++){o=n[t],ln(o);let{key:s,attributes:B}=o;A?this.mergeNode(s,B):this.addNode(s,B)}}if(e.edges){let s=!1;if(this.type==="undirected"&&(s=!0),n=e.edges,!Array.isArray(n))throw new G("Graph.import: invalid edges. Expecting an array.");for(t=0,r=n.length;t<r;t++){g=n[t],vn(g);let{source:B,target:C,attributes:w,undirected:c=s}=g,f;"key"in g?(f=A?c?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:c?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,g.key,B,C,w)):(f=A?c?this.mergeUndirectedEdge:this.mergeDirectedEdge:c?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,B,C,w))}}return this}nullCopy(e){let A=new i(S({},this._options,e));return A.replaceAttributes(S({},this.getAttributes())),A}emptyCopy(e){let A=this.nullCopy(e);return this._nodes.forEach((t,r)=>{let n=S({},t.attributes);t=new A.NodeDataClass(r,n),A._nodes.set(r,t)}),A}copy(e){if(e=e||{},typeof e.type=="string"&&e.type!==this.type&&e.type!=="mixed")throw new p(`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 p("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 p("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.");let A=this.emptyCopy(e),t=this._edges.values(),r,n;for(;r=t.next(),r.done!==!0;)n=r.value,St(A,"copy",!1,n.undirected,n.key,n.source.key,n.target.key,S({},n.attributes));return A}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){let e={};this._nodes.forEach((n,o)=>{e[o]=n.attributes});let A={},t={};this._edges.forEach((n,o)=>{let g=n.undirected?"--":"->",s="",B=n.source.key,C=n.target.key,w;n.undirected&&B>C&&(w=B,B=C,C=w);let c=`(${B})${g}(${C})`;o.startsWith("geid_")?this.multi&&(typeof t[c]>"u"?t[c]=0:t[c]++,s+=`${t[c]}. `):s+=`[${o}]: `,s+=c,A[s]=n.attributes});let r={};for(let n in this)this.hasOwnProperty(n)&&!Ht.has(n)&&typeof this[n]!="function"&&typeof n!="symbol"&&(r[n]=this[n]);return r.attributes=this._attributes,r.nodes=e,r.edges=A,aA(r,"constructor",this.constructor),r}};typeof Symbol<"u"&&(k.prototype[Symbol.for("nodejs.util.inspect.custom")]=k.prototype.inspect);Fn.forEach(i=>{["add","merge","update"].forEach(e=>{let A=i.name(e),t=e==="add"?St:mn;i.generateKey?k.prototype[A]=function(r,n,o){return t(this,A,!0,(i.type||this.type)==="undirected",null,r,n,o,e==="update")}:k.prototype[A]=function(r,n,o,g){return t(this,A,!1,(i.type||this.type)==="undirected",r,n,o,g,e==="update")}})});Kr(k);Xr(k);Bn(k);un(k);var Ie=class extends k{constructor(e){let A=S({type:"directed"},e);if("multi"in A&&A.multi!==!1)throw new G("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(A.type!=="directed")throw new G('DirectedGraph.from: inconsistent "'+A.type+'" type in given options!');super(A)}},Me=class extends k{constructor(e){let A=S({type:"undirected"},e);if("multi"in A&&A.multi!==!1)throw new G("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(A.type!=="undirected")throw new G('UndirectedGraph.from: inconsistent "'+A.type+'" type in given options!');super(A)}},Fe=class extends k{constructor(e){let A=S({multi:!0},e);if("multi"in A&&A.multi!==!0)throw new G("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(A)}},Ge=class extends k{constructor(e){let A=S({type:"directed",multi:!0},e);if("multi"in A&&A.multi!==!0)throw new G("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(A.type!=="directed")throw new G('MultiDirectedGraph.from: inconsistent "'+A.type+'" type in given options!');super(A)}},Pe=class extends k{constructor(e){let A=S({type:"undirected",multi:!0},e);if("multi"in A&&A.multi!==!0)throw new G("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(A.type!=="undirected")throw new G('MultiUndirectedGraph.from: inconsistent "'+A.type+'" type in given options!');super(A)}};function WA(i){i.from=function(e,A){let t=S({},e.options,A),r=new i(t);return r.import(e),r}}WA(k);WA(Ie);WA(Me);WA(Fe);WA(Ge);WA(Pe);k.Graph=k;k.DirectedGraph=Ie;k.UndirectedGraph=Me;k.MultiGraph=Fe;k.MultiDirectedGraph=Ge;k.MultiUndirectedGraph=Pe;k.InvalidArgumentsGraphError=G;k.NotFoundGraphError=F;k.UsageGraphError=p;function Yn(i,e){if(typeof i!="object"||!i)return i;var A=i[Symbol.toPrimitive];if(A!==void 0){var t=A.call(i,e||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function JA(i){var e=Yn(i,"string");return typeof e=="symbol"?e:e+""}function z(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function zt(i,e){for(var A=0;A<e.length;A++){var t=e[A];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(i,JA(t.key),t)}}function X(i,e,A){return e&&zt(i.prototype,e),A&&zt(i,A),Object.defineProperty(i,"prototype",{writable:!1}),i}function kA(i){return kA=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},kA(i)}function Xt(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Xt=function(){return!!i})()}function yn(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function pn(i,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 yn(i)}function AA(i,e,A){return e=kA(e),pn(i,Xt()?Reflect.construct(e,A||[],kA(i).constructor):e.apply(i,A))}function qe(i,e){return qe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(A,t){return A.__proto__=t,A},qe(i,e)}function eA(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),e&&qe(i,e)}function Ln(i){if(Array.isArray(i))return i}function bn(i,e){var A=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(A!=null){var t,r,n,o,g=[],s=!0,B=!1;try{if(n=(A=A.call(i)).next,e===0){if(Object(A)!==A)return;s=!1}else for(;!(s=(t=n.call(A)).done)&&(g.push(t.value),g.length!==e);s=!0);}catch(C){B=!0,r=C}finally{try{if(!s&&A.return!=null&&(o=A.return(),Object(o)!==o))return}finally{if(B)throw r}}return g}}function Ye(i,e){(e==null||e>i.length)&&(e=i.length);for(var A=0,t=Array(e);A<e;A++)t[A]=i[A];return t}function At(i,e){if(i){if(typeof i=="string")return Ye(i,e);var A={}.toString.call(i).slice(8,-1);return A==="Object"&&i.constructor&&(A=i.constructor.name),A==="Map"||A==="Set"?Array.from(i):A==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(A)?Ye(i,e):void 0}}function Hn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ "use strict";(()=>{var Cr=Object.create;var vt=Object.defineProperty;var wr=Object.getOwnPropertyDescriptor;var cr=Object.getOwnPropertyNames;var fr=Object.getPrototypeOf,hr=Object.prototype.hasOwnProperty;var KA=(i,e)=>()=>{try{return e||i((e={exports:{}}).exports,e),e.exports}catch(A){throw e=0,A}};var Qr=(i,e,A,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of cr(e))!hr.call(i,r)&&r!==A&&vt(i,r,{get:()=>e[r],enumerable:!(t=wr(e,r))||t.enumerable});return i};var TA=(i,e,A)=>(A=i!=null?Cr(fr(i)):{},Qr(e||!i||!i.__esModule?vt(A,"default",{value:i,enumerable:!0}):A,i));var le=KA((pg,Te)=>{"use strict";var SA=typeof Reflect=="object"?Reflect:null,It=SA&&typeof SA.apply=="function"?SA.apply:function(e,A,t){return Function.prototype.apply.call(e,A,t)},de;SA&&typeof SA.ownKeys=="function"?de=SA.ownKeys:Object.getOwnPropertySymbols?de=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:de=function(e){return Object.getOwnPropertyNames(e)};function Dr(i){console&&console.warn&&console.warn(i)}var Ft=Number.isNaN||function(e){return e!==e};function K(){K.init.call(this)}Te.exports=K;Te.exports.once=lr;K.EventEmitter=K;K.prototype._events=void 0;K.prototype._eventsCount=0;K.prototype._maxListeners=void 0;var Mt=10;function Ee(i){if(typeof i!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof i)}Object.defineProperty(K,"defaultMaxListeners",{enumerable:!0,get:function(){return Mt},set:function(i){if(typeof i!="number"||i<0||Ft(i))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+i+".");Mt=i}});K.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};K.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Ft(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Gt(i){return i._maxListeners===void 0?K.defaultMaxListeners:i._maxListeners}K.prototype.getMaxListeners=function(){return Gt(this)};K.prototype.emit=function(e){for(var A=[],t=1;t<arguments.length;t++)A.push(arguments[t]);var r=e==="error",n=this._events;if(n!==void 0)r=r&&n.error===void 0;else if(!r)return!1;if(r){var o;if(A.length>0&&(o=A[0]),o instanceof Error)throw o;var g=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw g.context=o,g}var s=n[e];if(s===void 0)return!1;if(typeof s=="function")It(s,this,A);else for(var B=s.length,C=pt(s,B),t=0;t<B;++t)It(C[t],this,A);return!0};function Pt(i,e,A,t){var r,n,o;if(Ee(A),n=i._events,n===void 0?(n=i._events=Object.create(null),i._eventsCount=0):(n.newListener!==void 0&&(i.emit("newListener",e,A.listener?A.listener:A),n=i._events),o=n[e]),o===void 0)o=n[e]=A,++i._eventsCount;else if(typeof o=="function"?o=n[e]=t?[A,o]:[o,A]:t?o.unshift(A):o.push(A),r=Gt(i),r>0&&o.length>r&&!o.warned){o.warned=!0;var g=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");g.name="MaxListenersExceededWarning",g.emitter=i,g.type=e,g.count=o.length,Dr(g)}return i}K.prototype.addListener=function(e,A){return Pt(this,e,A,!1)};K.prototype.on=K.prototype.addListener;K.prototype.prependListener=function(e,A){return Pt(this,e,A,!0)};function ur(){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 mt(i,e,A){var t={fired:!1,wrapFn:void 0,target:i,type:e,listener:A},r=ur.bind(t);return r.listener=A,t.wrapFn=r,r}K.prototype.once=function(e,A){return Ee(A),this.on(e,mt(this,e,A)),this};K.prototype.prependOnceListener=function(e,A){return Ee(A),this.prependListener(e,mt(this,e,A)),this};K.prototype.removeListener=function(e,A){var t,r,n,o,g;if(Ee(A),r=this._events,r===void 0)return this;if(t=r[e],t===void 0)return this;if(t===A||t.listener===A)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,t.listener||A));else if(typeof t!="function"){for(n=-1,o=t.length-1;o>=0;o--)if(t[o]===A||t[o].listener===A){g=t[o].listener,n=o;break}if(n<0)return this;n===0?t.shift():dr(t,n),t.length===1&&(r[e]=t[0]),r.removeListener!==void 0&&this.emit("removeListener",e,g||A)}return this};K.prototype.off=K.prototype.removeListener;K.prototype.removeAllListeners=function(e){var A,t,r;if(t=this._events,t===void 0)return this;if(t.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):t[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete t[e]),this;if(arguments.length===0){var n=Object.keys(t),o;for(r=0;r<n.length;++r)o=n[r],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(A=t[e],typeof A=="function")this.removeListener(e,A);else if(A!==void 0)for(r=A.length-1;r>=0;r--)this.removeListener(e,A[r]);return this};function Yt(i,e,A){var t=i._events;if(t===void 0)return[];var r=t[e];return r===void 0?[]:typeof r=="function"?A?[r.listener||r]:[r]:A?Er(r):pt(r,r.length)}K.prototype.listeners=function(e){return Yt(this,e,!0)};K.prototype.rawListeners=function(e){return Yt(this,e,!1)};K.listenerCount=function(i,e){return typeof i.listenerCount=="function"?i.listenerCount(e):yt.call(i,e)};K.prototype.listenerCount=yt;function yt(i){var e=this._events;if(e!==void 0){var A=e[i];if(typeof A=="function")return 1;if(A!==void 0)return A.length}return 0}K.prototype.eventNames=function(){return this._eventsCount>0?de(this._events):[]};function pt(i,e){for(var A=new Array(e),t=0;t<e;++t)A[t]=i[t];return A}function dr(i,e){for(;e+1<i.length;e++)i[e]=i[e+1];i.pop()}function Er(i){for(var e=new Array(i.length),A=0;A<e.length;++A)e[A]=i[A].listener||i[A];return e}function lr(i,e){return new Promise(function(A,t){function r(o){i.removeListener(e,n),t(o)}function n(){typeof i.removeListener=="function"&&i.removeListener("error",r),A([].slice.call(arguments))}Lt(i,e,n,{once:!0}),e!=="error"&&vr(i,r,{once:!0})})}function vr(i,e,A){typeof i.on=="function"&&Lt(i,"error",e,A)}function Lt(i,e,A,t){if(typeof i.on=="function")t.once?i.once(e,A):i.on(e,A);else if(typeof i.addEventListener=="function")i.addEventListener(e,function r(n){t.once&&i.removeEventListener(e,r),A(n)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof i)}});var Le=KA((Og,di)=>{di.exports=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"}});var Ui=KA(Re=>{function Uo(i){return typeof i!="number"||isNaN(i)?1:i}function Ro(i,e){var A={},t=function(o){return typeof o>"u"?e:o};typeof e=="function"&&(t=e);var r=function(o){return t(o[i])},n=function(){return t(void 0)};return typeof i=="string"?(A.fromAttributes=r,A.fromGraph=function(o,g){return r(o.getNodeAttributes(g))},A.fromEntry=function(o,g){return r(g)}):typeof i=="function"?(A.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},A.fromGraph=function(o,g){return t(i(g,o.getNodeAttributes(g)))},A.fromEntry=function(o,g){return t(i(o,g))}):(A.fromAttributes=n,A.fromGraph=n,A.fromEntry=n),A}function Ni(i,e){var A={},t=function(o){return typeof o>"u"?e:o};typeof e=="function"&&(t=e);var r=function(o){return t(o[i])},n=function(){return t(void 0)};return typeof i=="string"?(A.fromAttributes=r,A.fromGraph=function(o,g){return r(o.getEdgeAttributes(g))},A.fromEntry=function(o,g){return r(g)},A.fromPartialEntry=A.fromEntry,A.fromMinimalEntry=A.fromEntry):typeof i=="function"?(A.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},A.fromGraph=function(o,g){var s=o.extremities(g);return t(i(g,o.getEdgeAttributes(g),s[0],s[1],o.getNodeAttributes(s[0]),o.getNodeAttributes(s[1]),o.isUndirected(g)))},A.fromEntry=function(o,g,s,B,C,w,c){return t(i(o,g,s,B,C,w,c))},A.fromPartialEntry=function(o,g,s,B){return t(i(o,g,s,B))},A.fromMinimalEntry=function(o,g){return t(i(o,g))}):(A.fromAttributes=n,A.fromGraph=n,A.fromEntry=n,A.fromMinimalEntry=n),A}Re.createNodeValueGetter=Ro;Re.createEdgeValueGetter=Ni;Re.createEdgeWeightGetter=function(i){return Ni(i,Uo)}});var Si=KA((os,Ti)=>{var T=0,N=1,b=2,H=3,GA=4,PA=5,x=6,Ri=7,Oe=8,Oi=9,Oo=0,jo=1,To=2,W=0,wA=1,tA=2,UA=3,pA=4,O=5,nA=6,dA=7,EA=8,ji=3,uA=10,So=3,_=9,ft=10;Ti.exports=function(e,A,t){var r,n,o,g,s,B,C,w,c,f,D=A.length,h=t.length,d=e.adjustSizes,P=e.barnesHutTheta*e.barnesHutTheta,v,E,I,Y,L,M,m,u=[];for(o=0;o<D;o+=uA)A[o+GA]=A[o+b],A[o+PA]=A[o+H],A[o+b]=0,A[o+H]=0;if(e.outboundAttractionDistribution){for(v=0,o=0;o<D;o+=uA)v+=A[o+x];v/=D/uA}if(e.barnesHutOptimize){var U=1/0,j=-1/0,R=1/0,iA=-1/0,J,V,gA;for(o=0;o<D;o+=uA)U=Math.min(U,A[o+T]),j=Math.max(j,A[o+T]),R=Math.min(R,A[o+N]),iA=Math.max(iA,A[o+N]);var lA=j-U,fA=iA-R;for(lA>fA?(R-=(lA-fA)/2,iA=R+lA):(U-=(fA-lA)/2,j=U+fA),u[0+W]=-1,u[0+wA]=(U+j)/2,u[0+tA]=(R+iA)/2,u[0+UA]=Math.max(j-U,iA-R),u[0+pA]=-1,u[0+O]=-1,u[0+nA]=0,u[0+dA]=0,u[0+EA]=0,r=1,o=0;o<D;o+=uA)for(n=0,gA=ji;;)if(u[n+O]>=0){A[o+T]<u[n+wA]?A[o+N]<u[n+tA]?J=u[n+O]:J=u[n+O]+_:A[o+N]<u[n+tA]?J=u[n+O]+_*2:J=u[n+O]+_*3,u[n+dA]=(u[n+dA]*u[n+nA]+A[o+T]*A[o+x])/(u[n+nA]+A[o+x]),u[n+EA]=(u[n+EA]*u[n+nA]+A[o+N]*A[o+x])/(u[n+nA]+A[o+x]),u[n+nA]+=A[o+x],n=J;continue}else if(u[n+W]<0){u[n+W]=o;break}else{if(u[n+O]=r*_,w=u[n+UA]/2,c=u[n+O],u[c+W]=-1,u[c+wA]=u[n+wA]-w,u[c+tA]=u[n+tA]-w,u[c+UA]=w,u[c+pA]=c+_,u[c+O]=-1,u[c+nA]=0,u[c+dA]=0,u[c+EA]=0,c+=_,u[c+W]=-1,u[c+wA]=u[n+wA]-w,u[c+tA]=u[n+tA]+w,u[c+UA]=w,u[c+pA]=c+_,u[c+O]=-1,u[c+nA]=0,u[c+dA]=0,u[c+EA]=0,c+=_,u[c+W]=-1,u[c+wA]=u[n+wA]+w,u[c+tA]=u[n+tA]-w,u[c+UA]=w,u[c+pA]=c+_,u[c+O]=-1,u[c+nA]=0,u[c+dA]=0,u[c+EA]=0,c+=_,u[c+W]=-1,u[c+wA]=u[n+wA]+w,u[c+tA]=u[n+tA]+w,u[c+UA]=w,u[c+pA]=u[n+pA],u[c+O]=-1,u[c+nA]=0,u[c+dA]=0,u[c+EA]=0,r+=4,A[u[n+W]+T]<u[n+wA]?A[u[n+W]+N]<u[n+tA]?J=u[n+O]:J=u[n+O]+_:A[u[n+W]+N]<u[n+tA]?J=u[n+O]+_*2:J=u[n+O]+_*3,u[n+nA]=A[u[n+W]+x],u[n+dA]=A[u[n+W]+T],u[n+EA]=A[u[n+W]+N],u[J+W]=u[n+W],u[n+W]=-1,A[o+T]<u[n+wA]?A[o+N]<u[n+tA]?V=u[n+O]:V=u[n+O]+_:A[o+N]<u[n+tA]?V=u[n+O]+_*2:V=u[n+O]+_*3,J===V)if(gA--){n=J;continue}else{gA=ji;break}u[V+W]=o;break}}if(e.barnesHutOptimize)for(E=e.scalingRatio,o=0;o<D;o+=uA)for(n=0;;)if(u[n+O]>=0)if(M=Math.pow(A[o+T]-u[n+dA],2)+Math.pow(A[o+N]-u[n+EA],2),f=u[n+UA],4*f*f/M<P){if(I=A[o+T]-u[n+dA],Y=A[o+N]-u[n+EA],d===!0?M>0?(m=E*A[o+x]*u[n+nA]/M,A[o+b]+=I*m,A[o+H]+=Y*m):M<0&&(m=-E*A[o+x]*u[n+nA]/Math.sqrt(M),A[o+b]+=I*m,A[o+H]+=Y*m):M>0&&(m=E*A[o+x]*u[n+nA]/M,A[o+b]+=I*m,A[o+H]+=Y*m),n=u[n+pA],n<0)break;continue}else{n=u[n+O];continue}else{if(B=u[n+W],B>=0&&B!==o&&(I=A[o+T]-A[B+T],Y=A[o+N]-A[B+N],M=I*I+Y*Y,d===!0?M>0?(m=E*A[o+x]*A[B+x]/M,A[o+b]+=I*m,A[o+H]+=Y*m):M<0&&(m=-E*A[o+x]*A[B+x]/Math.sqrt(M),A[o+b]+=I*m,A[o+H]+=Y*m):M>0&&(m=E*A[o+x]*A[B+x]/M,A[o+b]+=I*m,A[o+H]+=Y*m)),n=u[n+pA],n<0)break;continue}else for(E=e.scalingRatio,g=0;g<D;g+=uA)for(s=0;s<g;s+=uA)I=A[g+T]-A[s+T],Y=A[g+N]-A[s+N],d===!0?(M=Math.sqrt(I*I+Y*Y)-A[g+Oe]-A[s+Oe],M>0?(m=E*A[g+x]*A[s+x]/M/M,A[g+b]+=I*m,A[g+H]+=Y*m,A[s+b]-=I*m,A[s+H]-=Y*m):M<0&&(m=100*E*A[g+x]*A[s+x],A[g+b]+=I*m,A[g+H]+=Y*m,A[s+b]-=I*m,A[s+H]-=Y*m)):(M=Math.sqrt(I*I+Y*Y),M>0&&(m=E*A[g+x]*A[s+x]/M/M,A[g+b]+=I*m,A[g+H]+=Y*m,A[s+b]-=I*m,A[s+H]-=Y*m));for(c=e.gravity/e.scalingRatio,E=e.scalingRatio,o=0;o<D;o+=uA)m=0,I=A[o+T],Y=A[o+N],M=Math.sqrt(Math.pow(I,2)+Math.pow(Y,2)),e.strongGravityMode?M>0&&(m=E*A[o+x]*c):M>0&&(m=E*A[o+x]*c/M),A[o+b]-=I*m,A[o+H]-=Y*m;for(E=1*(e.outboundAttractionDistribution?v:1),C=0;C<h;C+=So)g=t[C+Oo],s=t[C+jo],w=t[C+To],L=Math.pow(w,e.edgeWeightInfluence),I=A[g+T]-A[s+T],Y=A[g+N]-A[s+N],d===!0?(M=Math.sqrt(I*I+Y*Y)-A[g+Oe]-A[s+Oe],e.linLogMode?e.outboundAttractionDistribution?M>0&&(m=-E*L*Math.log(1+M)/M/A[g+x]):M>0&&(m=-E*L*Math.log(1+M)/M):e.outboundAttractionDistribution?M>0&&(m=-E*L/A[g+x]):M>0&&(m=-E*L)):(M=Math.sqrt(Math.pow(I,2)+Math.pow(Y,2)),e.linLogMode?e.outboundAttractionDistribution?M>0&&(m=-E*L*Math.log(1+M)/M/A[g+x]):M>0&&(m=-E*L*Math.log(1+M)/M):e.outboundAttractionDistribution?(M=1,m=-E*L/A[g+x]):(M=1,m=-E*L)),M>0&&(A[g+b]+=I*m,A[g+H]+=Y*m,A[s+b]-=I*m,A[s+H]-=Y*m);var sA,rA,oA,hA,$,jA;if(d===!0)for(o=0;o<D;o+=uA)A[o+Oi]!==1&&(sA=Math.sqrt(Math.pow(A[o+b],2)+Math.pow(A[o+H],2)),sA>ft&&(A[o+b]=A[o+b]*ft/sA,A[o+H]=A[o+H]*ft/sA),rA=A[o+x]*Math.sqrt((A[o+GA]-A[o+b])*(A[o+GA]-A[o+b])+(A[o+PA]-A[o+H])*(A[o+PA]-A[o+H])),oA=Math.sqrt((A[o+GA]+A[o+b])*(A[o+GA]+A[o+b])+(A[o+PA]+A[o+H])*(A[o+PA]+A[o+H]))/2,hA=.1*Math.log(1+oA)/(1+Math.sqrt(rA)),$=A[o+T]+A[o+b]*(hA/e.slowDown),A[o+T]=$,jA=A[o+N]+A[o+H]*(hA/e.slowDown),A[o+N]=jA);else for(o=0;o<D;o+=uA)A[o+Oi]!==1&&(rA=A[o+x]*Math.sqrt((A[o+GA]-A[o+b])*(A[o+GA]-A[o+b])+(A[o+PA]-A[o+H])*(A[o+PA]-A[o+H])),oA=Math.sqrt((A[o+GA]+A[o+b])*(A[o+GA]+A[o+b])+(A[o+PA]+A[o+H])*(A[o+PA]+A[o+H]))/2,hA=A[o+Ri]*Math.log(1+oA)/(1+Math.sqrt(rA)),A[o+Ri]=Math.min(1,Math.sqrt(hA*(Math.pow(A[o+b],2)+Math.pow(A[o+H],2))/(1+Math.sqrt(rA)))),$=A[o+T]+A[o+b]*(hA/e.slowDown),A[o+T]=$,jA=A[o+N]+A[o+H]*(hA/e.slowDown),A[o+N]=jA);return{}}});var Xi=KA(LA=>{var ce=10,zi=3;LA.assign=function(i){i=i||{};var e=Array.prototype.slice.call(arguments).slice(1),A,t,r;for(A=0,r=e.length;A<r;A++)if(e[A])for(t in e[A])i[t]=e[A][t];return i};LA.validateSettings=function(i){return"linLogMode"in i&&typeof i.linLogMode!="boolean"?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in i&&typeof i.outboundAttractionDistribution!="boolean"?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in i&&typeof i.adjustSizes!="boolean"?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in i&&typeof i.edgeWeightInfluence!="number"?{message:"the `edgeWeightInfluence` setting should be a number."}:"scalingRatio"in i&&!(typeof i.scalingRatio=="number"&&i.scalingRatio>=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in i&&typeof i.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in i&&!(typeof i.gravity=="number"&&i.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in i&&!(typeof i.slowDown=="number"||i.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in i&&typeof i.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in i&&!(typeof i.barnesHutTheta=="number"&&i.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null};LA.graphToByteArrays=function(i,e){var A=i.order,t=i.size,r={},n,o=new Float32Array(A*ce),g=new Float32Array(t*zi);return n=0,i.forEachNode(function(s,B){r[s]=n,o[n]=B.x,o[n+1]=B.y,o[n+2]=0,o[n+3]=0,o[n+4]=0,o[n+5]=0,o[n+6]=1,o[n+7]=1,o[n+8]=B.size||1,o[n+9]=B.fixed?1:0,n+=ce}),n=0,i.forEachEdge(function(s,B,C,w,c,f,D){var h=r[C],d=r[w],P=e(s,B,C,w,c,f,D);o[h+6]+=P,o[d+6]+=P,g[n]=h,g[n+1]=d,g[n+2]=P,n+=zi}),{nodes:o,edges:g}};LA.assignLayoutChanges=function(i,e,A){var t=0;i.updateEachNodeAttributes(function(r,n){return n.x=e[t],n.y=e[t+1],t+=ce,A?A(r,n):n})};LA.readGraphPositions=function(i,e){var A=0;i.forEachNode(function(t,r){e[A]=r.x,e[A+1]=r.y,A+=ce})};LA.collectLayoutChanges=function(i,e,A){for(var t=i.nodes(),r={},n=0,o=0,g=e.length;n<g;n+=ce){if(A){var s=Object.assign({},i.getNodeAttributes(t[o]));s.x=e[n],s.y=e[n+1],s=A(t[o],s),r[t[o]]={x:s.x,y:s.y}}else r[t[o]]={x:e[n],y:e[n+1]};o++}return r};LA.createWorker=function(e){var A=window.URL||window.webkitURL,t=e.toString(),r=A.createObjectURL(new Blob(["("+t+").call(this);"],{type:"text/javascript"})),n=new Worker(r);return A.revokeObjectURL(r),n}});var Wi=KA((ss,Vi)=>{Vi.exports={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}});var _i=KA((as,Zi)=>{var zo=Le(),Xo=Ui().createEdgeWeightGetter,Vo=Si(),fe=Xi(),Wo=Wi();function qi(i,e,A){if(!zo(e))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof A=="number"&&(A={iterations:A});var t=A.iterations;if(typeof t!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(t<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var r=Xo("getEdgeWeight"in A?A.getEdgeWeight:"weight").fromEntry,n=typeof A.outputReducer=="function"?A.outputReducer:null,o=fe.assign({},Wo,A.settings),g=fe.validateSettings(o);if(g)throw new Error("graphology-layout-forceatlas2: "+g.message);var s=fe.graphToByteArrays(e,r),B;for(B=0;B<t;B++)Vo(o,s.nodes,s.edges);if(i){fe.assignLayoutChanges(e,s.nodes,n);return}return fe.collectLayoutChanges(e,s.nodes)}function qo(i){var e=typeof i=="number"?i:i.order;return{barnesHutOptimize:e>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(e)}}var ht=qi.bind(null,!1);ht.assign=qi.bind(null,!0);ht.inferSettings=qo;Zi.exports=ht});var Kt=TA(le(),1);function Ir(){let i=arguments[0];for(let e=1,A=arguments.length;e<A;e++)if(arguments[e])for(let t in arguments[e])i[t]=arguments[e][t];return i}var S=Ir;typeof Object.assign=="function"&&(S=Object.assign);function BA(i,e,A,t){let r=i._nodes.get(e),n=null;return r&&(t==="mixed"?n=r.out&&r.out[A]||r.undirected&&r.undirected[A]:t==="directed"?n=r.out&&r.out[A]:n=r.undirected&&r.undirected[A]),n}function q(i){return typeof i=="object"&&i!==null}function kt(i){let e;for(e in i)return!1;return!0}function aA(i,e,A){Object.defineProperty(i,e,{enumerable:!1,configurable:!1,writable:!0,value:A})}function QA(i,e,A){let t={enumerable:!0,configurable:!0};typeof A=="function"?t.get=A:(t.value=A,t.writable=!1),Object.defineProperty(i,e,t)}function bt(i){return!(!q(i)||i.attributes&&!Array.isArray(i.attributes))}function Mr(){let i=Math.floor(Math.random()*256)&255;return()=>i++}function vA(){let i=arguments,e=null,A=-1;return{[Symbol.iterator](){return this},next(){let t=null;do{if(e===null){if(A++,A>=i.length)return{done:!0};e=i[A][Symbol.iterator]()}if(t=e.next(),t.done){e=null;continue}break}while(!0);return t}}}function XA(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var ge=class extends Error{constructor(e){super(),this.name="GraphError",this.message=e}},G=class i extends ge{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,i.prototype.constructor)}},F=class i extends ge{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,i.prototype.constructor)}},p=class i extends ge{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,i.prototype.constructor)}};function Jt(i,e){this.key=i,this.attributes=e,this.clear()}Jt.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 Nt(i,e){this.key=i,this.attributes=e,this.clear()}Nt.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Ut(i,e){this.key=i,this.attributes=e,this.clear()}Ut.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function VA(i,e,A,t,r){this.key=e,this.attributes=r,this.undirected=i,this.source=A,this.target=t}VA.prototype.attach=function(){let i="out",e="in";this.undirected&&(i=e="undirected");let A=this.source.key,t=this.target.key;this.source[i][t]=this,!(this.undirected&&A===t)&&(this.target[e][A]=this)};VA.prototype.attachMulti=function(){let i="out",e="in",A=this.source.key,t=this.target.key;this.undirected&&(i=e="undirected");let r=this.source[i],n=r[t];if(typeof n>"u"){r[t]=this,this.undirected&&A===t||(this.target[e][A]=this);return}n.previous=this,this.next=n,r[t]=this,this.target[e][A]=this};VA.prototype.detach=function(){let i=this.source.key,e=this.target.key,A="out",t="in";this.undirected&&(A=t="undirected"),delete this.source[A][e],delete this.target[t][i]};VA.prototype.detachMulti=function(){let i=this.source.key,e=this.target.key,A="out",t="in";this.undirected&&(A=t="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[A][e],delete this.target[t][i]):(this.next.previous=void 0,this.source[A][e]=this.next,this.target[t][i]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};var Rt=0,Ot=1,Fr=2,jt=3;function IA(i,e,A,t,r,n,o){let g,s,B,C;if(t=""+t,A===Rt){if(g=i._nodes.get(t),!g)throw new F(`Graph.${e}: could not find the "${t}" node in the graph.`);B=r,C=n}else if(A===jt){if(r=""+r,s=i._edges.get(r),!s)throw new F(`Graph.${e}: could not find the "${r}" edge in the graph.`);let w=s.source.key,c=s.target.key;if(t===w)g=s.target;else if(t===c)g=s.source;else throw new F(`Graph.${e}: the "${t}" node is not attached to the "${r}" edge (${w}, ${c}).`);B=n,C=o}else{if(s=i._edges.get(t),!s)throw new F(`Graph.${e}: could not find the "${t}" edge in the graph.`);A===Ot?g=s.source:g=s.target,B=r,C=n}return[g,B,C]}function Gr(i,e,A){i.prototype[e]=function(t,r,n){let[o,g]=IA(this,e,A,t,r,n);return o.attributes[g]}}function Pr(i,e,A){i.prototype[e]=function(t,r){let[n]=IA(this,e,A,t,r);return n.attributes}}function mr(i,e,A){i.prototype[e]=function(t,r,n){let[o,g]=IA(this,e,A,t,r,n);return o.attributes.hasOwnProperty(g)}}function Yr(i,e,A){i.prototype[e]=function(t,r,n,o){let[g,s,B]=IA(this,e,A,t,r,n,o);return g.attributes[s]=B,this.emit("nodeAttributesUpdated",{key:g.key,type:"set",attributes:g.attributes,name:s}),this}}function yr(i,e,A){i.prototype[e]=function(t,r,n,o){let[g,s,B]=IA(this,e,A,t,r,n,o);if(typeof B!="function")throw new G(`Graph.${e}: updater should be a function.`);let C=g.attributes,w=B(C[s]);return C[s]=w,this.emit("nodeAttributesUpdated",{key:g.key,type:"set",attributes:g.attributes,name:s}),this}}function pr(i,e,A){i.prototype[e]=function(t,r,n){let[o,g]=IA(this,e,A,t,r,n);return delete o.attributes[g],this.emit("nodeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:g}),this}}function Lr(i,e,A){i.prototype[e]=function(t,r,n){let[o,g]=IA(this,e,A,t,r,n);if(!q(g))throw new G(`Graph.${e}: provided attributes are not a plain object.`);return o.attributes=g,this.emit("nodeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function br(i,e,A){i.prototype[e]=function(t,r,n){let[o,g]=IA(this,e,A,t,r,n);if(!q(g))throw new G(`Graph.${e}: provided attributes are not a plain object.`);return S(o.attributes,g),this.emit("nodeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:g}),this}}function Hr(i,e,A){i.prototype[e]=function(t,r,n){let[o,g]=IA(this,e,A,t,r,n);if(typeof g!="function")throw new G(`Graph.${e}: provided updater is not a function.`);return o.attributes=g(o.attributes),this.emit("nodeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}var xr=[{name:i=>`get${i}Attribute`,attacher:Gr},{name:i=>`get${i}Attributes`,attacher:Pr},{name:i=>`has${i}Attribute`,attacher:mr},{name:i=>`set${i}Attribute`,attacher:Yr},{name:i=>`update${i}Attribute`,attacher:yr},{name:i=>`remove${i}Attribute`,attacher:pr},{name:i=>`replace${i}Attributes`,attacher:Lr},{name:i=>`merge${i}Attributes`,attacher:br},{name:i=>`update${i}Attributes`,attacher:Hr}];function Kr(i){xr.forEach(function({name:e,attacher:A}){A(i,e("Node"),Rt),A(i,e("Source"),Ot),A(i,e("Target"),Fr),A(i,e("Opposite"),jt)})}function kr(i,e,A){i.prototype[e]=function(t,r){let n;if(this.type!=="mixed"&&A!=="mixed"&&A!==this.type)throw new p(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new p(`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.`);let o=""+t,g=""+r;if(r=arguments[2],n=BA(this,o,g,A),!n)throw new F(`Graph.${e}: could not find an edge for the given path ("${o}" - "${g}").`)}else{if(A!=="mixed")throw new p(`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(t=""+t,n=this._edges.get(t),!n)throw new F(`Graph.${e}: could not find the "${t}" edge in the graph.`)}return n.attributes[r]}}function Jr(i,e,A){i.prototype[e]=function(t){let r;if(this.type!=="mixed"&&A!=="mixed"&&A!==this.type)throw new p(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new p(`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.`);let n=""+t,o=""+arguments[1];if(r=BA(this,n,o,A),!r)throw new F(`Graph.${e}: could not find an edge for the given path ("${n}" - "${o}").`)}else{if(A!=="mixed")throw new p(`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(t=""+t,r=this._edges.get(t),!r)throw new F(`Graph.${e}: could not find the "${t}" edge in the graph.`)}return r.attributes}}function Nr(i,e,A){i.prototype[e]=function(t,r){let n;if(this.type!=="mixed"&&A!=="mixed"&&A!==this.type)throw new p(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new p(`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.`);let o=""+t,g=""+r;if(r=arguments[2],n=BA(this,o,g,A),!n)throw new F(`Graph.${e}: could not find an edge for the given path ("${o}" - "${g}").`)}else{if(A!=="mixed")throw new p(`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(t=""+t,n=this._edges.get(t),!n)throw new F(`Graph.${e}: could not find the "${t}" edge in the graph.`)}return n.attributes.hasOwnProperty(r)}}function Ur(i,e,A){i.prototype[e]=function(t,r,n){let o;if(this.type!=="mixed"&&A!=="mixed"&&A!==this.type)throw new p(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new p(`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.`);let g=""+t,s=""+r;if(r=arguments[2],n=arguments[3],o=BA(this,g,s,A),!o)throw new F(`Graph.${e}: could not find an edge for the given path ("${g}" - "${s}").`)}else{if(A!=="mixed")throw new p(`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(t=""+t,o=this._edges.get(t),!o)throw new F(`Graph.${e}: could not find the "${t}" edge in the graph.`)}return o.attributes[r]=n,this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:r}),this}}function Rr(i,e,A){i.prototype[e]=function(t,r,n){let o;if(this.type!=="mixed"&&A!=="mixed"&&A!==this.type)throw new p(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new p(`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.`);let g=""+t,s=""+r;if(r=arguments[2],n=arguments[3],o=BA(this,g,s,A),!o)throw new F(`Graph.${e}: could not find an edge for the given path ("${g}" - "${s}").`)}else{if(A!=="mixed")throw new p(`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(t=""+t,o=this._edges.get(t),!o)throw new F(`Graph.${e}: could not find the "${t}" edge in the graph.`)}if(typeof n!="function")throw new G(`Graph.${e}: updater should be a function.`);return o.attributes[r]=n(o.attributes[r]),this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:r}),this}}function Or(i,e,A){i.prototype[e]=function(t,r){let n;if(this.type!=="mixed"&&A!=="mixed"&&A!==this.type)throw new p(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new p(`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.`);let o=""+t,g=""+r;if(r=arguments[2],n=BA(this,o,g,A),!n)throw new F(`Graph.${e}: could not find an edge for the given path ("${o}" - "${g}").`)}else{if(A!=="mixed")throw new p(`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(t=""+t,n=this._edges.get(t),!n)throw new F(`Graph.${e}: could not find the "${t}" edge in the graph.`)}return delete n.attributes[r],this.emit("edgeAttributesUpdated",{key:n.key,type:"remove",attributes:n.attributes,name:r}),this}}function jr(i,e,A){i.prototype[e]=function(t,r){let n;if(this.type!=="mixed"&&A!=="mixed"&&A!==this.type)throw new p(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new p(`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.`);let o=""+t,g=""+r;if(r=arguments[2],n=BA(this,o,g,A),!n)throw new F(`Graph.${e}: could not find an edge for the given path ("${o}" - "${g}").`)}else{if(A!=="mixed")throw new p(`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(t=""+t,n=this._edges.get(t),!n)throw new F(`Graph.${e}: could not find the "${t}" edge in the graph.`)}if(!q(r))throw new G(`Graph.${e}: provided attributes are not a plain object.`);return n.attributes=r,this.emit("edgeAttributesUpdated",{key:n.key,type:"replace",attributes:n.attributes}),this}}function Tr(i,e,A){i.prototype[e]=function(t,r){let n;if(this.type!=="mixed"&&A!=="mixed"&&A!==this.type)throw new p(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new p(`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.`);let o=""+t,g=""+r;if(r=arguments[2],n=BA(this,o,g,A),!n)throw new F(`Graph.${e}: could not find an edge for the given path ("${o}" - "${g}").`)}else{if(A!=="mixed")throw new p(`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(t=""+t,n=this._edges.get(t),!n)throw new F(`Graph.${e}: could not find the "${t}" edge in the graph.`)}if(!q(r))throw new G(`Graph.${e}: provided attributes are not a plain object.`);return S(n.attributes,r),this.emit("edgeAttributesUpdated",{key:n.key,type:"merge",attributes:n.attributes,data:r}),this}}function Sr(i,e,A){i.prototype[e]=function(t,r){let n;if(this.type!=="mixed"&&A!=="mixed"&&A!==this.type)throw new p(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new p(`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.`);let o=""+t,g=""+r;if(r=arguments[2],n=BA(this,o,g,A),!n)throw new F(`Graph.${e}: could not find an edge for the given path ("${o}" - "${g}").`)}else{if(A!=="mixed")throw new p(`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(t=""+t,n=this._edges.get(t),!n)throw new F(`Graph.${e}: could not find the "${t}" edge in the graph.`)}if(typeof r!="function")throw new G(`Graph.${e}: provided updater is not a function.`);return n.attributes=r(n.attributes),this.emit("edgeAttributesUpdated",{key:n.key,type:"update",attributes:n.attributes}),this}}var zr=[{name:i=>`get${i}Attribute`,attacher:kr},{name:i=>`get${i}Attributes`,attacher:Jr},{name:i=>`has${i}Attribute`,attacher:Nr},{name:i=>`set${i}Attribute`,attacher:Ur},{name:i=>`update${i}Attribute`,attacher:Rr},{name:i=>`remove${i}Attribute`,attacher:Or},{name:i=>`replace${i}Attributes`,attacher:jr},{name:i=>`merge${i}Attributes`,attacher:Tr},{name:i=>`update${i}Attributes`,attacher:Sr}];function Xr(i){zr.forEach(function({name:e,attacher:A}){A(i,e("Edge"),"mixed"),A(i,e("DirectedEdge"),"directed"),A(i,e("UndirectedEdge"),"undirected")})}var Vr=[{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 Wr(i,e,A,t){let r=!1;for(let n in e){if(n===t)continue;let o=e[n];if(r=A(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),i&&r)return o.key}}function qr(i,e,A,t){let r,n,o,g=!1;for(let s in e)if(s!==t){r=e[s];do{if(n=r.source,o=r.target,g=A(r.key,r.attributes,n.key,o.key,n.attributes,o.attributes,r.undirected),i&&g)return r.key;r=r.next}while(r!==void 0)}}function Se(i,e){let A=Object.keys(i),t=A.length,r,n=0;return{[Symbol.iterator](){return this},next(){do if(r)r=r.next;else{if(n>=t)return{done:!0};let o=A[n++];if(o===e){r=void 0;continue}r=i[o]}while(!r);return{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 Zr(i,e,A,t){let r=e[A];if(!r)return;let n=r.source,o=r.target;if(t(r.key,r.attributes,n.key,o.key,n.attributes,o.attributes,r.undirected)&&i)return r.key}function _r(i,e,A,t){let r=e[A];if(!r)return;let n=!1;do{if(n=t(r.key,r.attributes,r.source.key,r.target.key,r.source.attributes,r.target.attributes,r.undirected),i&&n)return r.key;r=r.next}while(r!==void 0)}function ze(i,e){let A=i[e];if(A.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!A)return{done:!0};let r={edge:A.key,attributes:A.attributes,source:A.source.key,target:A.target.key,sourceAttributes:A.source.attributes,targetAttributes:A.target.attributes,undirected:A.undirected};return A=A.next,{done:!1,value:r}}};let t=!1;return{[Symbol.iterator](){return this},next(){return t===!0?{done:!0}:(t=!0,{done:!1,value:{edge:A.key,attributes:A.attributes,source:A.source.key,target:A.target.key,sourceAttributes:A.source.attributes,targetAttributes:A.target.attributes,undirected:A.undirected}})}}}function $r(i,e){if(i.size===0)return[];if(e==="mixed"||e===i.type)return Array.from(i._edges.keys());let A=e==="undirected"?i.undirectedSize:i.directedSize,t=new Array(A),r=e==="undirected",n=i._edges.values(),o=0,g,s;for(;g=n.next(),g.done!==!0;)s=g.value,s.undirected===r&&(t[o++]=s.key);return t}function Tt(i,e,A,t){if(e.size===0)return;let r=A!=="mixed"&&A!==e.type,n=A==="undirected",o,g,s=!1,B=e._edges.values();for(;o=B.next(),o.done!==!0;){if(g=o.value,r&&g.undirected!==n)continue;let{key:C,attributes:w,source:c,target:f}=g;if(s=t(C,w,c.key,f.key,c.attributes,f.attributes,g.undirected),i&&s)return C}}function An(i,e){if(i.size===0)return XA();let A=e!=="mixed"&&e!==i.type,t=e==="undirected",r=i._edges.values();return{[Symbol.iterator](){return this},next(){let n,o;for(;;){if(n=r.next(),n.done)return n;if(o=n.value,!(A&&o.undirected!==t))break}return{value:{edge:o.key,attributes:o.attributes,source:o.source.key,target:o.target.key,sourceAttributes:o.source.attributes,targetAttributes:o.target.attributes,undirected:o.undirected},done:!1}}}}function Xe(i,e,A,t,r,n){let o=e?qr:Wr,g;if(A!=="undirected"&&(t!=="out"&&(g=o(i,r.in,n),i&&g)||t!=="in"&&(g=o(i,r.out,n,t?void 0:r.key),i&&g))||A!=="directed"&&(g=o(i,r.undirected,n),i&&g))return g}function en(i,e,A,t){let r=[];return Xe(!1,i,e,A,t,function(n){r.push(n)}),r}function tn(i,e,A){let t=XA();return i!=="undirected"&&(e!=="out"&&typeof A.in<"u"&&(t=vA(t,Se(A.in))),e!=="in"&&typeof A.out<"u"&&(t=vA(t,Se(A.out,e?void 0:A.key)))),i!=="directed"&&typeof A.undirected<"u"&&(t=vA(t,Se(A.undirected))),t}function Ve(i,e,A,t,r,n,o){let g=A?_r:Zr,s;if(e!=="undirected"&&(typeof r.in<"u"&&t!=="out"&&(s=g(i,r.in,n,o),i&&s)||typeof r.out<"u"&&t!=="in"&&(t||r.key!==n)&&(s=g(i,r.out,n,o),i&&s))||e!=="directed"&&typeof r.undirected<"u"&&(s=g(i,r.undirected,n,o),i&&s))return s}function rn(i,e,A,t,r){let n=[];return Ve(!1,i,e,A,t,r,function(o){n.push(o)}),n}function nn(i,e,A,t){let r=XA();return i!=="undirected"&&(typeof A.in<"u"&&e!=="out"&&t in A.in&&(r=vA(r,ze(A.in,t))),typeof A.out<"u"&&e!=="in"&&t in A.out&&(e||A.key!==t)&&(r=vA(r,ze(A.out,t)))),i!=="directed"&&typeof A.undirected<"u"&&t in A.undirected&&(r=vA(r,ze(A.undirected,t))),r}function on(i,e){let{name:A,type:t,direction:r}=e;i.prototype[A]=function(n,o){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return[];if(!arguments.length)return $r(this,t);if(arguments.length===1){n=""+n;let g=this._nodes.get(n);if(typeof g>"u")throw new F(`Graph.${A}: could not find the "${n}" node in the graph.`);return en(this.multi,t==="mixed"?this.type:t,r,g)}if(arguments.length===2){n=""+n,o=""+o;let g=this._nodes.get(n);if(!g)throw new F(`Graph.${A}: could not find the "${n}" source node in the graph.`);if(!this._nodes.has(o))throw new F(`Graph.${A}: could not find the "${o}" target node in the graph.`);return rn(t,this.multi,r,g,o)}throw new G(`Graph.${A}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function gn(i,e){let{name:A,type:t,direction:r}=e,n="forEach"+A[0].toUpperCase()+A.slice(1,-1);i.prototype[n]=function(B,C,w){if(!(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)){if(arguments.length===1)return w=B,Tt(!1,this,t,w);if(arguments.length===2){B=""+B,w=C;let c=this._nodes.get(B);if(typeof c>"u")throw new F(`Graph.${n}: could not find the "${B}" node in the graph.`);return Xe(!1,this.multi,t==="mixed"?this.type:t,r,c,w)}if(arguments.length===3){B=""+B,C=""+C;let c=this._nodes.get(B);if(!c)throw new F(`Graph.${n}: could not find the "${B}" source node in the graph.`);if(!this._nodes.has(C))throw new F(`Graph.${n}: could not find the "${C}" target node in the graph.`);return Ve(!1,t,this.multi,r,c,C,w)}throw new G(`Graph.${n}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let o="map"+A[0].toUpperCase()+A.slice(1);i.prototype[o]=function(){let B=Array.prototype.slice.call(arguments),C=B.pop(),w;if(B.length===0){let c=0;t!=="directed"&&(c+=this.undirectedSize),t!=="undirected"&&(c+=this.directedSize),w=new Array(c);let f=0;B.push((D,h,d,P,v,E,I)=>{w[f++]=C(D,h,d,P,v,E,I)})}else w=[],B.push((c,f,D,h,d,P,v)=>{w.push(C(c,f,D,h,d,P,v))});return this[n].apply(this,B),w};let g="filter"+A[0].toUpperCase()+A.slice(1);i.prototype[g]=function(){let B=Array.prototype.slice.call(arguments),C=B.pop(),w=[];return B.push((c,f,D,h,d,P,v)=>{C(c,f,D,h,d,P,v)&&w.push(c)}),this[n].apply(this,B),w};let s="reduce"+A[0].toUpperCase()+A.slice(1);i.prototype[s]=function(){let B=Array.prototype.slice.call(arguments);if(B.length<2||B.length>4)throw new G(`Graph.${s}: invalid number of arguments (expecting 2, 3 or 4 and got ${B.length}).`);if(typeof B[B.length-1]=="function"&&typeof B[B.length-2]!="function")throw new G(`Graph.${s}: 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 C,w;B.length===2?(C=B[0],w=B[1],B=[]):B.length===3?(C=B[1],w=B[2],B=[B[0]]):B.length===4&&(C=B[2],w=B[3],B=[B[0],B[1]]);let c=w;return B.push((f,D,h,d,P,v,E)=>{c=C(c,f,D,h,d,P,v,E)}),this[n].apply(this,B),c}}function sn(i,e){let{name:A,type:t,direction:r}=e,n="find"+A[0].toUpperCase()+A.slice(1,-1);i.prototype[n]=function(s,B,C){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return!1;if(arguments.length===1)return C=s,Tt(!0,this,t,C);if(arguments.length===2){s=""+s,C=B;let w=this._nodes.get(s);if(typeof w>"u")throw new F(`Graph.${n}: could not find the "${s}" node in the graph.`);return Xe(!0,this.multi,t==="mixed"?this.type:t,r,w,C)}if(arguments.length===3){s=""+s,B=""+B;let w=this._nodes.get(s);if(!w)throw new F(`Graph.${n}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(B))throw new F(`Graph.${n}: could not find the "${B}" target node in the graph.`);return Ve(!0,t,this.multi,r,w,B,C)}throw new G(`Graph.${n}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let o="some"+A[0].toUpperCase()+A.slice(1,-1);i.prototype[o]=function(){let s=Array.prototype.slice.call(arguments),B=s.pop();return s.push((w,c,f,D,h,d,P)=>B(w,c,f,D,h,d,P)),!!this[n].apply(this,s)};let g="every"+A[0].toUpperCase()+A.slice(1,-1);i.prototype[g]=function(){let s=Array.prototype.slice.call(arguments),B=s.pop();return s.push((w,c,f,D,h,d,P)=>!B(w,c,f,D,h,d,P)),!this[n].apply(this,s)}}function an(i,e){let{name:A,type:t,direction:r}=e,n=A.slice(0,-1)+"Entries";i.prototype[n]=function(o,g){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return XA();if(!arguments.length)return An(this,t);if(arguments.length===1){o=""+o;let s=this._nodes.get(o);if(!s)throw new F(`Graph.${n}: could not find the "${o}" node in the graph.`);return tn(t,r,s)}if(arguments.length===2){o=""+o,g=""+g;let s=this._nodes.get(o);if(!s)throw new F(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(g))throw new F(`Graph.${n}: could not find the "${g}" target node in the graph.`);return nn(t,r,s,g)}throw new G(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Bn(i){Vr.forEach(e=>{on(i,e),gn(i,e),sn(i,e),an(i,e)})}var Cn=[{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 me(){this.A=null,this.B=null}me.prototype.wrap=function(i){this.A===null?this.A=i:this.B===null&&(this.B=i)};me.prototype.has=function(i){return this.A!==null&&i in this.A||this.B!==null&&i in this.B};function ne(i,e,A,t,r){for(let n in t){let o=t[n],g=o.source,s=o.target,B=g===A?s:g;if(e&&e.has(B.key))continue;let C=r(B.key,B.attributes);if(i&&C)return B.key}}function We(i,e,A,t,r){if(e!=="mixed"){if(e==="undirected")return ne(i,null,t,t.undirected,r);if(typeof A=="string")return ne(i,null,t,t[A],r)}let n=new me,o;if(e!=="undirected"){if(A!=="out"){if(o=ne(i,null,t,t.in,r),i&&o)return o;n.wrap(t.in)}if(A!=="in"){if(o=ne(i,n,t,t.out,r),i&&o)return o;n.wrap(t.out)}}if(e!=="directed"&&(o=ne(i,n,t,t.undirected,r),i&&o))return o}function wn(i,e,A){if(i!=="mixed"){if(i==="undirected")return Object.keys(A.undirected);if(typeof e=="string")return Object.keys(A[e])}let t=[];return We(!1,i,e,A,function(r){t.push(r)}),t}function oe(i,e,A){let t=Object.keys(A),r=t.length,n=0;return{[Symbol.iterator](){return this},next(){let o=null;do{if(n>=r)return i&&i.wrap(A),{done:!0};let g=A[t[n++]],s=g.source,B=g.target;if(o=s===e?B:s,i&&i.has(o.key)){o=null;continue}}while(o===null);return{done:!1,value:{neighbor:o.key,attributes:o.attributes}}}}}function cn(i,e,A){if(i!=="mixed"){if(i==="undirected")return oe(null,A,A.undirected);if(typeof e=="string")return oe(null,A,A[e])}let t=XA(),r=new me;return i!=="undirected"&&(e!=="out"&&(t=vA(t,oe(r,A,A.in))),e!=="in"&&(t=vA(t,oe(r,A,A.out)))),i!=="directed"&&(t=vA(t,oe(r,A,A.undirected))),t}function fn(i,e){let{name:A,type:t,direction:r}=e;i.prototype[A]=function(n){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return[];n=""+n;let o=this._nodes.get(n);if(typeof o>"u")throw new F(`Graph.${A}: could not find the "${n}" node in the graph.`);return wn(t==="mixed"?this.type:t,r,o)}}function hn(i,e){let{name:A,type:t,direction:r}=e,n="forEach"+A[0].toUpperCase()+A.slice(1,-1);i.prototype[n]=function(B,C){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return;B=""+B;let w=this._nodes.get(B);if(typeof w>"u")throw new F(`Graph.${n}: could not find the "${B}" node in the graph.`);We(!1,t==="mixed"?this.type:t,r,w,C)};let o="map"+A[0].toUpperCase()+A.slice(1);i.prototype[o]=function(B,C){let w=[];return this[n](B,(c,f)=>{w.push(C(c,f))}),w};let g="filter"+A[0].toUpperCase()+A.slice(1);i.prototype[g]=function(B,C){let w=[];return this[n](B,(c,f)=>{C(c,f)&&w.push(c)}),w};let s="reduce"+A[0].toUpperCase()+A.slice(1);i.prototype[s]=function(B,C,w){if(arguments.length<3)throw new G(`Graph.${s}: 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 c=w;return this[n](B,(f,D)=>{c=C(c,f,D)}),c}}function Qn(i,e){let{name:A,type:t,direction:r}=e,n=A[0].toUpperCase()+A.slice(1,-1),o="find"+n;i.prototype[o]=function(B,C){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return;B=""+B;let w=this._nodes.get(B);if(typeof w>"u")throw new F(`Graph.${o}: could not find the "${B}" node in the graph.`);return We(!0,t==="mixed"?this.type:t,r,w,C)};let g="some"+n;i.prototype[g]=function(B,C){return!!this[o](B,C)};let s="every"+n;i.prototype[s]=function(B,C){return!this[o](B,(c,f)=>!C(c,f))}}function Dn(i,e){let{name:A,type:t,direction:r}=e,n=A.slice(0,-1)+"Entries";i.prototype[n]=function(o){if(t!=="mixed"&&this.type!=="mixed"&&t!==this.type)return XA();o=""+o;let g=this._nodes.get(o);if(typeof g>"u")throw new F(`Graph.${n}: could not find the "${o}" node in the graph.`);return cn(t==="mixed"?this.type:t,r,g)}}function un(i){Cn.forEach(e=>{fn(i,e),hn(i,e),Qn(i,e),Dn(i,e)})}function ve(i,e,A,t,r){let n=t._nodes.values(),o=t.type,g,s,B,C,w,c,f;for(;g=n.next(),g.done!==!0;){let D=!1;if(s=g.value,o!=="undirected"){C=s.out;for(B in C){w=C[B];do{if(c=w.target,D=!0,f=r(s.key,c.key,s.attributes,c.attributes,w.key,w.attributes,w.undirected),i&&f)return w;w=w.next}while(w)}}if(o!=="directed"){C=s.undirected;for(B in C)if(!(e&&s.key>B)){w=C[B];do{if(c=w.target,c.key!==B&&(c=w.source),D=!0,f=r(s.key,c.key,s.attributes,c.attributes,w.key,w.attributes,w.undirected),i&&f)return w;w=w.next}while(w)}}if(A&&!D&&(f=r(s.key,null,s.attributes,null,null,null,null),i&&f))return null}}function dn(i,e){let A={key:i};return kt(e.attributes)||(A.attributes=S({},e.attributes)),A}function En(i,e,A){let t={key:e,source:A.source.key,target:A.target.key};return kt(A.attributes)||(t.attributes=S({},A.attributes)),i==="mixed"&&A.undirected&&(t.undirected=!0),t}function ln(i){if(!q(i))throw new G('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in i))throw new G("Graph.import: serialized node is missing its key.");if("attributes"in i&&(!q(i.attributes)||i.attributes===null))throw new G("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function vn(i){if(!q(i))throw new G('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in i))throw new G("Graph.import: serialized edge is missing its source.");if(!("target"in i))throw new G("Graph.import: serialized edge is missing its target.");if("attributes"in i&&(!q(i.attributes)||i.attributes===null))throw new G("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in i&&typeof i.undirected!="boolean")throw new G("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}var In=Mr(),Mn=new Set(["directed","undirected","mixed"]),Ht=new Set(["domain","_events","_eventsCount","_maxListeners"]),Fn=[{name:i=>`${i}Edge`,generateKey:!0},{name:i=>`${i}DirectedEdge`,generateKey:!0,type:"directed"},{name:i=>`${i}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:i=>`${i}EdgeWithKey`},{name:i=>`${i}DirectedEdgeWithKey`,type:"directed"},{name:i=>`${i}UndirectedEdgeWithKey`,type:"undirected"}],Gn={allowSelfLoops:!0,multi:!1,type:"mixed"};function Pn(i,e,A){if(A&&!q(A))throw new G(`Graph.addNode: invalid attributes. Expecting an object but got "${A}"`);if(e=""+e,A=A||{},i._nodes.has(e))throw new p(`Graph.addNode: the "${e}" node already exist in the graph.`);let t=new i.NodeDataClass(e,A);return i._nodes.set(e,t),i.emit("nodeAdded",{key:e,attributes:A}),t}function xt(i,e,A){let t=new i.NodeDataClass(e,A);return i._nodes.set(e,t),i.emit("nodeAdded",{key:e,attributes:A}),t}function St(i,e,A,t,r,n,o,g){if(!t&&i.type==="undirected")throw new p(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(t&&i.type==="directed")throw new p(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(g&&!q(g))throw new G(`Graph.${e}: invalid attributes. Expecting an object but got "${g}"`);if(n=""+n,o=""+o,g=g||{},!i.allowSelfLoops&&n===o)throw new p(`Graph.${e}: source & target are the same ("${n}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let s=i._nodes.get(n),B=i._nodes.get(o);if(!s)throw new F(`Graph.${e}: source node "${n}" not found.`);if(!B)throw new F(`Graph.${e}: target node "${o}" not found.`);let C={key:null,undirected:t,source:n,target:o,attributes:g};if(A)r=i._edgeKeyGenerator();else if(r=""+r,i._edges.has(r))throw new p(`Graph.${e}: the "${r}" edge already exists in the graph.`);if(!i.multi&&(t?typeof s.undirected[o]<"u":typeof s.out[o]<"u"))throw new p(`Graph.${e}: an edge linking "${n}" to "${o}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);let w=new VA(t,r,s,B,g);i._edges.set(r,w);let c=n===o;return t?(s.undirectedDegree++,B.undirectedDegree++,c&&(s.undirectedLoops++,i._undirectedSelfLoopCount++)):(s.outDegree++,B.inDegree++,c&&(s.directedLoops++,i._directedSelfLoopCount++)),i.multi?w.attachMulti():w.attach(),t?i._undirectedSize++:i._directedSize++,C.key=r,i.emit("edgeAdded",C),r}function mn(i,e,A,t,r,n,o,g,s){if(!t&&i.type==="undirected")throw new p(`Graph.${e}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(t&&i.type==="directed")throw new p(`Graph.${e}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(g){if(s){if(typeof g!="function")throw new G(`Graph.${e}: invalid updater function. Expecting a function but got "${g}"`)}else if(!q(g))throw new G(`Graph.${e}: invalid attributes. Expecting an object but got "${g}"`)}n=""+n,o=""+o;let B;if(s&&(B=g,g=void 0),!i.allowSelfLoops&&n===o)throw new p(`Graph.${e}: source & target are the same ("${n}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let C=i._nodes.get(n),w=i._nodes.get(o),c,f;if(!A&&(c=i._edges.get(r),c)){if((c.source.key!==n||c.target.key!==o)&&(!t||c.source.key!==o||c.target.key!==n))throw new p(`Graph.${e}: inconsistency detected when attempting to merge the "${r}" edge with "${n}" source & "${o}" target vs. ("${c.source.key}", "${c.target.key}").`);f=c}if(!f&&!i.multi&&C&&(f=t?C.undirected[o]:C.out[o]),f){let v=[f.key,!1,!1,!1];if(s?!B:!g)return v;if(s){let E=f.attributes;f.attributes=B(E),i.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else S(f.attributes,g),i.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:g});return v}g=g||{},s&&B&&(g=B(g));let D={key:null,undirected:t,source:n,target:o,attributes:g};if(A)r=i._edgeKeyGenerator();else if(r=""+r,i._edges.has(r))throw new p(`Graph.${e}: the "${r}" edge already exists in the graph.`);let h=!1,d=!1;C||(C=xt(i,n,{}),h=!0,n===o&&(w=C,d=!0)),w||(w=xt(i,o,{}),d=!0),c=new VA(t,r,C,w,g),i._edges.set(r,c);let P=n===o;return t?(C.undirectedDegree++,w.undirectedDegree++,P&&(C.undirectedLoops++,i._undirectedSelfLoopCount++)):(C.outDegree++,w.inDegree++,P&&(C.directedLoops++,i._directedSelfLoopCount++)),i.multi?c.attachMulti():c.attach(),t?i._undirectedSize++:i._directedSize++,D.key=r,i.emit("edgeAdded",D),[r,!0,h,d]}function zA(i,e){i._edges.delete(e.key);let{source:A,target:t,attributes:r}=e,n=e.undirected,o=A===t;n?(A.undirectedDegree--,t.undirectedDegree--,o&&(A.undirectedLoops--,i._undirectedSelfLoopCount--)):(A.outDegree--,t.inDegree--,o&&(A.directedLoops--,i._directedSelfLoopCount--)),i.multi?e.detachMulti():e.detach(),n?i._undirectedSize--:i._directedSize--,i.emit("edgeDropped",{key:e.key,attributes:r,source:A.key,target:t.key,undirected:n})}var k=class i extends Kt.EventEmitter{constructor(e){if(super(),e=S({},Gn,e),typeof e.multi!="boolean")throw new G(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!Mn.has(e.type))throw new G(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new G(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);let A=e.type==="mixed"?Jt:e.type==="directed"?Nt:Ut;aA(this,"NodeDataClass",A);let t="geid_"+In()+"_",r=0,n=()=>{let o;do o=t+r++;while(this._edges.has(o));return o};aA(this,"_attributes",{}),aA(this,"_nodes",new Map),aA(this,"_edges",new Map),aA(this,"_directedSize",0),aA(this,"_undirectedSize",0),aA(this,"_directedSelfLoopCount",0),aA(this,"_undirectedSelfLoopCount",0),aA(this,"_edgeKeyGenerator",n),aA(this,"_options",e),Ht.forEach(o=>aA(this,o,this[o])),QA(this,"order",()=>this._nodes.size),QA(this,"size",()=>this._edges.size),QA(this,"directedSize",()=>this._directedSize),QA(this,"undirectedSize",()=>this._undirectedSize),QA(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),QA(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),QA(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),QA(this,"multi",this._options.multi),QA(this,"type",this._options.type),QA(this,"allowSelfLoops",this._options.allowSelfLoops),QA(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,A){if(this.type==="undirected")return!1;if(arguments.length===1){let t=""+e,r=this._edges.get(t);return!!r&&!r.undirected}else if(arguments.length===2){e=""+e,A=""+A;let t=this._nodes.get(e);return t?t.out.hasOwnProperty(A):!1}throw new G(`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,A){if(this.type==="directed")return!1;if(arguments.length===1){let t=""+e,r=this._edges.get(t);return!!r&&r.undirected}else if(arguments.length===2){e=""+e,A=""+A;let t=this._nodes.get(e);return t?t.undirected.hasOwnProperty(A):!1}throw new G(`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,A){if(arguments.length===1){let t=""+e;return this._edges.has(t)}else if(arguments.length===2){e=""+e,A=""+A;let t=this._nodes.get(e);return t?typeof t.out<"u"&&t.out.hasOwnProperty(A)||typeof t.undirected<"u"&&t.undirected.hasOwnProperty(A):!1}throw new G(`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,A){if(this.type==="undirected")return;if(e=""+e,A=""+A,this.multi)throw new p("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");let t=this._nodes.get(e);if(!t)throw new F(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(A))throw new F(`Graph.directedEdge: could not find the "${A}" target node in the graph.`);let r=t.out&&t.out[A]||void 0;if(r)return r.key}undirectedEdge(e,A){if(this.type==="directed")return;if(e=""+e,A=""+A,this.multi)throw new p("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");let t=this._nodes.get(e);if(!t)throw new F(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(A))throw new F(`Graph.undirectedEdge: could not find the "${A}" target node in the graph.`);let r=t.undirected&&t.undirected[A]||void 0;if(r)return r.key}edge(e,A){if(this.multi)throw new p("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,A=""+A;let t=this._nodes.get(e);if(!t)throw new F(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(A))throw new F(`Graph.edge: could not find the "${A}" target node in the graph.`);let r=t.out&&t.out[A]||t.undirected&&t.undirected[A]||void 0;if(r)return r.key}areDirectedNeighbors(e,A){e=""+e,A=""+A;let t=this._nodes.get(e);if(!t)throw new F(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:A in t.in||A in t.out}areOutNeighbors(e,A){e=""+e,A=""+A;let t=this._nodes.get(e);if(!t)throw new F(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:A in t.out}areInNeighbors(e,A){e=""+e,A=""+A;let t=this._nodes.get(e);if(!t)throw new F(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:A in t.in}areUndirectedNeighbors(e,A){e=""+e,A=""+A;let t=this._nodes.get(e);if(!t)throw new F(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="directed"?!1:A in t.undirected}areNeighbors(e,A){e=""+e,A=""+A;let t=this._nodes.get(e);if(!t)throw new F(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&(A in t.in||A in t.out)||this.type!=="directed"&&A in t.undirected}areInboundNeighbors(e,A){e=""+e,A=""+A;let t=this._nodes.get(e);if(!t)throw new F(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&A in t.in||this.type!=="directed"&&A in t.undirected}areOutboundNeighbors(e,A){e=""+e,A=""+A;let t=this._nodes.get(e);if(!t)throw new F(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&A in t.out||this.type!=="directed"&&A in t.undirected}inDegree(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:A.inDegree}outDegree(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:A.outDegree}directedDegree(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:A.inDegree+A.outDegree}undirectedDegree(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:A.undirectedDegree}inboundDegree(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let t=0;return this.type!=="directed"&&(t+=A.undirectedDegree),this.type!=="undirected"&&(t+=A.inDegree),t}outboundDegree(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let t=0;return this.type!=="directed"&&(t+=A.undirectedDegree),this.type!=="undirected"&&(t+=A.outDegree),t}degree(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.degree: could not find the "${e}" node in the graph.`);let t=0;return this.type!=="directed"&&(t+=A.undirectedDegree),this.type!=="undirected"&&(t+=A.inDegree+A.outDegree),t}inDegreeWithoutSelfLoops(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:A.inDegree-A.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:A.outDegree-A.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:A.inDegree+A.outDegree-A.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:A.undirectedDegree-A.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let t=0,r=0;return this.type!=="directed"&&(t+=A.undirectedDegree,r+=A.undirectedLoops*2),this.type!=="undirected"&&(t+=A.inDegree,r+=A.directedLoops),t-r}outboundDegreeWithoutSelfLoops(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let t=0,r=0;return this.type!=="directed"&&(t+=A.undirectedDegree,r+=A.undirectedLoops*2),this.type!=="undirected"&&(t+=A.outDegree,r+=A.directedLoops),t-r}degreeWithoutSelfLoops(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let t=0,r=0;return this.type!=="directed"&&(t+=A.undirectedDegree,r+=A.undirectedLoops*2),this.type!=="undirected"&&(t+=A.inDegree+A.outDegree,r+=A.directedLoops*2),t-r}source(e){e=""+e;let A=this._edges.get(e);if(!A)throw new F(`Graph.source: could not find the "${e}" edge in the graph.`);return A.source.key}target(e){e=""+e;let A=this._edges.get(e);if(!A)throw new F(`Graph.target: could not find the "${e}" edge in the graph.`);return A.target.key}extremities(e){e=""+e;let A=this._edges.get(e);if(!A)throw new F(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[A.source.key,A.target.key]}opposite(e,A){e=""+e,A=""+A;let t=this._edges.get(A);if(!t)throw new F(`Graph.opposite: could not find the "${A}" edge in the graph.`);let r=t.source.key,n=t.target.key;if(e===r)return n;if(e===n)return r;throw new F(`Graph.opposite: the "${e}" node is not attached to the "${A}" edge (${r}, ${n}).`)}hasExtremity(e,A){e=""+e,A=""+A;let t=this._edges.get(e);if(!t)throw new F(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return t.source.key===A||t.target.key===A}isUndirected(e){e=""+e;let A=this._edges.get(e);if(!A)throw new F(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return A.undirected}isDirected(e){e=""+e;let A=this._edges.get(e);if(!A)throw new F(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!A.undirected}isSelfLoop(e){e=""+e;let A=this._edges.get(e);if(!A)throw new F(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return A.source===A.target}addNode(e,A){return Pn(this,e,A).key}mergeNode(e,A){if(A&&!q(A))throw new G(`Graph.mergeNode: invalid attributes. Expecting an object but got "${A}"`);e=""+e,A=A||{};let t=this._nodes.get(e);return t?(A&&(S(t.attributes,A),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:t.attributes,data:A})),[e,!1]):(t=new this.NodeDataClass(e,A),this._nodes.set(e,t),this.emit("nodeAdded",{key:e,attributes:A}),[e,!0])}updateNode(e,A){if(A&&typeof A!="function")throw new G(`Graph.updateNode: invalid updater function. Expecting a function but got "${A}"`);e=""+e;let t=this._nodes.get(e);if(t){if(A){let n=t.attributes;t.attributes=A(n),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:t.attributes})}return[e,!1]}let r=A?A({}):{};return t=new this.NodeDataClass(e,r),this._nodes.set(e,t),this.emit("nodeAdded",{key:e,attributes:r}),[e,!0]}dropNode(e){e=""+e;let A=this._nodes.get(e);if(!A)throw new F(`Graph.dropNode: could not find the "${e}" node in the graph.`);let t;if(this.type!=="undirected"){for(let r in A.out){t=A.out[r];do zA(this,t),t=t.next;while(t)}for(let r in A.in){t=A.in[r];do zA(this,t),t=t.next;while(t)}}if(this.type!=="directed")for(let r in A.undirected){t=A.undirected[r];do zA(this,t),t=t.next;while(t)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:A.attributes})}dropEdge(e){let A;if(arguments.length>1){let t=""+arguments[0],r=""+arguments[1];if(A=BA(this,t,r,this.type),!A)throw new F(`Graph.dropEdge: could not find the "${t}" -> "${r}" edge in the graph.`)}else if(e=""+e,A=this._edges.get(e),!A)throw new F(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return zA(this,A),this}dropDirectedEdge(e,A){if(arguments.length<2)throw new p("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 p("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,A=""+A;let t=BA(this,e,A,"directed");if(!t)throw new F(`Graph.dropDirectedEdge: could not find a "${e}" -> "${A}" edge in the graph.`);return zA(this,t),this}dropUndirectedEdge(e,A){if(arguments.length<2)throw new p("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 p("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.");let t=BA(this,e,A,"undirected");if(!t)throw new F(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${A}" edge in the graph.`);return zA(this,t),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){let e=this._nodes.values(),A;for(;A=e.next(),A.done!==!0;)A.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,A){return this._attributes[e]=A,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,A){if(typeof A!="function")throw new G("Graph.updateAttribute: updater should be a function.");let t=this._attributes[e];return this._attributes[e]=A(t),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(!q(e))throw new G("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(!q(e))throw new G("Graph.mergeAttributes: provided attributes are not a plain object.");return S(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new G("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,A){if(typeof e!="function")throw new G("Graph.updateEachNodeAttributes: expecting an updater function.");if(A&&!bt(A))throw new G("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let t=this._nodes.values(),r,n;for(;r=t.next(),r.done!==!0;)n=r.value,n.attributes=e(n.key,n.attributes);this.emit("eachNodeAttributesUpdated",{hints:A||null})}updateEachEdgeAttributes(e,A){if(typeof e!="function")throw new G("Graph.updateEachEdgeAttributes: expecting an updater function.");if(A&&!bt(A))throw new G("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let t=this._edges.values(),r,n,o,g;for(;r=t.next(),r.done!==!0;)n=r.value,o=n.source,g=n.target,n.attributes=e(n.key,n.attributes,o.key,g.key,o.attributes,g.attributes,n.undirected);this.emit("eachEdgeAttributesUpdated",{hints:A||null})}forEachAdjacencyEntry(e){if(typeof e!="function")throw new G("Graph.forEachAdjacencyEntry: expecting a callback.");ve(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new G("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");ve(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new G("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");ve(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new G("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");ve(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!="function")throw new G("Graph.forEachNode: expecting a callback.");let A=this._nodes.values(),t,r;for(;t=A.next(),t.done!==!0;)r=t.value,e(r.key,r.attributes)}findNode(e){if(typeof e!="function")throw new G("Graph.findNode: expecting a callback.");let A=this._nodes.values(),t,r;for(;t=A.next(),t.done!==!0;)if(r=t.value,e(r.key,r.attributes))return r.key}mapNodes(e){if(typeof e!="function")throw new G("Graph.mapNode: expecting a callback.");let A=this._nodes.values(),t,r,n=new Array(this.order),o=0;for(;t=A.next(),t.done!==!0;)r=t.value,n[o++]=e(r.key,r.attributes);return n}someNode(e){if(typeof e!="function")throw new G("Graph.someNode: expecting a callback.");let A=this._nodes.values(),t,r;for(;t=A.next(),t.done!==!0;)if(r=t.value,e(r.key,r.attributes))return!0;return!1}everyNode(e){if(typeof e!="function")throw new G("Graph.everyNode: expecting a callback.");let A=this._nodes.values(),t,r;for(;t=A.next(),t.done!==!0;)if(r=t.value,!e(r.key,r.attributes))return!1;return!0}filterNodes(e){if(typeof e!="function")throw new G("Graph.filterNodes: expecting a callback.");let A=this._nodes.values(),t,r,n=[];for(;t=A.next(),t.done!==!0;)r=t.value,e(r.key,r.attributes)&&n.push(r.key);return n}reduceNodes(e,A){if(typeof e!="function")throw new G("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new G("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 t=A,r=this._nodes.values(),n,o;for(;n=r.next(),n.done!==!0;)o=n.value,t=e(t,o.key,o.attributes);return t}nodeEntries(){let e=this._nodes.values();return{[Symbol.iterator](){return this},next(){let A=e.next();if(A.done)return A;let t=A.value;return{value:{node:t.key,attributes:t.attributes},done:!1}}}}export(){let e=new Array(this._nodes.size),A=0;this._nodes.forEach((r,n)=>{e[A++]=dn(n,r)});let t=new Array(this._edges.size);return A=0,this._edges.forEach((r,n)=>{t[A++]=En(this.type,n,r)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:t}}import(e,A=!1){if(e instanceof i)return e.forEachNode((s,B)=>{A?this.mergeNode(s,B):this.addNode(s,B)}),e.forEachEdge((s,B,C,w,c,f,D)=>{A?D?this.mergeUndirectedEdgeWithKey(s,C,w,B):this.mergeDirectedEdgeWithKey(s,C,w,B):D?this.addUndirectedEdgeWithKey(s,C,w,B):this.addDirectedEdgeWithKey(s,C,w,B)}),this;if(!q(e))throw new G("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!q(e.attributes))throw new G("Graph.import: invalid attributes. Expecting a plain object.");A?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let t,r,n,o,g;if(e.nodes){if(n=e.nodes,!Array.isArray(n))throw new G("Graph.import: invalid nodes. Expecting an array.");for(t=0,r=n.length;t<r;t++){o=n[t],ln(o);let{key:s,attributes:B}=o;A?this.mergeNode(s,B):this.addNode(s,B)}}if(e.edges){let s=!1;if(this.type==="undirected"&&(s=!0),n=e.edges,!Array.isArray(n))throw new G("Graph.import: invalid edges. Expecting an array.");for(t=0,r=n.length;t<r;t++){g=n[t],vn(g);let{source:B,target:C,attributes:w,undirected:c=s}=g,f;"key"in g?(f=A?c?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:c?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,g.key,B,C,w)):(f=A?c?this.mergeUndirectedEdge:this.mergeDirectedEdge:c?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,B,C,w))}}return this}nullCopy(e){let A=new i(S({},this._options,e));return A.replaceAttributes(S({},this.getAttributes())),A}emptyCopy(e){let A=this.nullCopy(e);return this._nodes.forEach((t,r)=>{let n=S({},t.attributes);t=new A.NodeDataClass(r,n),A._nodes.set(r,t)}),A}copy(e){if(e=e||{},typeof e.type=="string"&&e.type!==this.type&&e.type!=="mixed")throw new p(`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 p("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 p("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.");let A=this.emptyCopy(e),t=this._edges.values(),r,n;for(;r=t.next(),r.done!==!0;)n=r.value,St(A,"copy",!1,n.undirected,n.key,n.source.key,n.target.key,S({},n.attributes));return A}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){let e={};this._nodes.forEach((n,o)=>{e[o]=n.attributes});let A={},t={};this._edges.forEach((n,o)=>{let g=n.undirected?"--":"->",s="",B=n.source.key,C=n.target.key,w;n.undirected&&B>C&&(w=B,B=C,C=w);let c=`(${B})${g}(${C})`;o.startsWith("geid_")?this.multi&&(typeof t[c]>"u"?t[c]=0:t[c]++,s+=`${t[c]}. `):s+=`[${o}]: `,s+=c,A[s]=n.attributes});let r={};for(let n in this)this.hasOwnProperty(n)&&!Ht.has(n)&&typeof this[n]!="function"&&typeof n!="symbol"&&(r[n]=this[n]);return r.attributes=this._attributes,r.nodes=e,r.edges=A,aA(r,"constructor",this.constructor),r}};typeof Symbol<"u"&&(k.prototype[Symbol.for("nodejs.util.inspect.custom")]=k.prototype.inspect);Fn.forEach(i=>{["add","merge","update"].forEach(e=>{let A=i.name(e),t=e==="add"?St:mn;i.generateKey?k.prototype[A]=function(r,n,o){return t(this,A,!0,(i.type||this.type)==="undirected",null,r,n,o,e==="update")}:k.prototype[A]=function(r,n,o,g){return t(this,A,!1,(i.type||this.type)==="undirected",r,n,o,g,e==="update")}})});Kr(k);Xr(k);Bn(k);un(k);var Ie=class extends k{constructor(e){let A=S({type:"directed"},e);if("multi"in A&&A.multi!==!1)throw new G("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(A.type!=="directed")throw new G('DirectedGraph.from: inconsistent "'+A.type+'" type in given options!');super(A)}},Me=class extends k{constructor(e){let A=S({type:"undirected"},e);if("multi"in A&&A.multi!==!1)throw new G("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(A.type!=="undirected")throw new G('UndirectedGraph.from: inconsistent "'+A.type+'" type in given options!');super(A)}},Fe=class extends k{constructor(e){let A=S({multi:!0},e);if("multi"in A&&A.multi!==!0)throw new G("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(A)}},Ge=class extends k{constructor(e){let A=S({type:"directed",multi:!0},e);if("multi"in A&&A.multi!==!0)throw new G("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(A.type!=="directed")throw new G('MultiDirectedGraph.from: inconsistent "'+A.type+'" type in given options!');super(A)}},Pe=class extends k{constructor(e){let A=S({type:"undirected",multi:!0},e);if("multi"in A&&A.multi!==!0)throw new G("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(A.type!=="undirected")throw new G('MultiUndirectedGraph.from: inconsistent "'+A.type+'" type in given options!');super(A)}};function WA(i){i.from=function(e,A){let t=S({},e.options,A),r=new i(t);return r.import(e),r}}WA(k);WA(Ie);WA(Me);WA(Fe);WA(Ge);WA(Pe);k.Graph=k;k.DirectedGraph=Ie;k.UndirectedGraph=Me;k.MultiGraph=Fe;k.MultiDirectedGraph=Ge;k.MultiUndirectedGraph=Pe;k.InvalidArgumentsGraphError=G;k.NotFoundGraphError=F;k.UsageGraphError=p;function Yn(i,e){if(typeof i!="object"||!i)return i;var A=i[Symbol.toPrimitive];if(A!==void 0){var t=A.call(i,e||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function JA(i){var e=Yn(i,"string");return typeof e=="symbol"?e:e+""}function z(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function zt(i,e){for(var A=0;A<e.length;A++){var t=e[A];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(i,JA(t.key),t)}}function X(i,e,A){return e&&zt(i.prototype,e),A&&zt(i,A),Object.defineProperty(i,"prototype",{writable:!1}),i}function kA(i){return kA=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},kA(i)}function Xt(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Xt=function(){return!!i})()}function yn(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function pn(i,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 yn(i)}function AA(i,e,A){return e=kA(e),pn(i,Xt()?Reflect.construct(e,A||[],kA(i).constructor):e.apply(i,A))}function qe(i,e){return qe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(A,t){return A.__proto__=t,A},qe(i,e)}function eA(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),e&&qe(i,e)}function Ln(i){if(Array.isArray(i))return i}function bn(i,e){var A=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(A!=null){var t,r,n,o,g=[],s=!0,B=!1;try{if(n=(A=A.call(i)).next,e===0){if(Object(A)!==A)return;s=!1}else for(;!(s=(t=n.call(A)).done)&&(g.push(t.value),g.length!==e);s=!0);}catch(C){B=!0,r=C}finally{try{if(!s&&A.return!=null&&(o=A.return(),Object(o)!==o))return}finally{if(B)throw r}}return g}}function Ye(i,e){(e==null||e>i.length)&&(e=i.length);for(var A=0,t=Array(e);A<e;A++)t[A]=i[A];return t}function At(i,e){if(i){if(typeof i=="string")return Ye(i,e);var A={}.toString.call(i).slice(8,-1);return A==="Object"&&i.constructor&&(A=i.constructor.name),A==="Map"||A==="Set"?Array.from(i):A==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(A)?Ye(i,e):void 0}}function Hn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function YA(i,e){return Ln(i)||bn(i,e)||At(i,e)||Hn()}var Ze={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"};var Vt=new Int8Array(4),_e=new Int32Array(Vt.buffer,0,1),xn=new Float32Array(Vt.buffer,0,1),Kn=/^\s*rgba?\s*\(/,kn=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Jn(i){var e=0,A=0,t=0,r=1;if(i[0]==="#")i.length===4?(e=parseInt(i.charAt(1)+i.charAt(1),16),A=parseInt(i.charAt(2)+i.charAt(2),16),t=parseInt(i.charAt(3)+i.charAt(3),16)):(e=parseInt(i.charAt(1)+i.charAt(2),16),A=parseInt(i.charAt(3)+i.charAt(4),16),t=parseInt(i.charAt(5)+i.charAt(6),16)),i.length===9&&(r=parseInt(i.charAt(7)+i.charAt(8),16)/255);else if(Kn.test(i)){var n=i.match(kn);n&&(e=+n[1],A=+n[2],t=+n[3],n[4]&&(r=+n[4]))}return{r:e,g:A,b:t,a:r}}var qA={};for(se in Ze)qA[se]=ZA(Ze[se]),qA[Ze[se]]=qA[se];var se;function Wt(i,e,A,t,r){return _e[0]=t<<24|A<<16|e<<8|i,r&&(_e[0]=_e[0]&4278190079),xn[0]}function ZA(i){if(i=i.toLowerCase(),typeof qA[i]<"u")return qA[i];var e=Jn(i),A=e.r,t=e.g,r=e.b,n=e.a;n=n*255|0;var o=Wt(A,t,r,n,!0);return qA[i]=o,o}var $e={};function et(i){if(typeof $e[i]<"u")return $e[i];var e=(i&16711680)>>>16,A=(i&65280)>>>8,t=i&255,r=255,n=Wt(e,A,t,r,!0);return $e[i]=n,n}function tt(i,e,A,t){return A+(e<<8)+(i<<16)}function it(i,e,A,t,r,n){var o=Math.floor(A/n*r),g=Math.floor(i.drawingBufferHeight/n-t/n*r),s=new Uint8Array(4);i.bindFramebuffer(i.FRAMEBUFFER,e),i.readPixels(o,g,1,1,i.RGBA,i.UNSIGNED_BYTE,s);var B=YA(s,4),C=B[0],w=B[1],c=B[2],f=B[3];return[C,w,c,f]}function l(i,e,A){return(e=JA(e))in i?Object.defineProperty(i,e,{value:A,enumerable:!0,configurable:!0,writable:!0}):i[e]=A,i}function qt(i,e){var A=Object.keys(i);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(i);e&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),A.push.apply(A,t)}return A}function y(i){for(var e=1;e<arguments.length;e++){var A=arguments[e]!=null?arguments[e]:{};e%2?qt(Object(A),!0).forEach(function(t){l(i,t,A[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(A)):qt(Object(A)).forEach(function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(A,t))})}return i}function Nn(i,e){for(;!{}.hasOwnProperty.call(i,e)&&(i=kA(i))!==null;);return i}function ot(){return ot=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(i,e,A){var t=Nn(i,e);if(t){var r=Object.getOwnPropertyDescriptor(t,e);return r.get?r.get.call(arguments.length<3?i:A):r.value}},ot.apply(null,arguments)}function ii(i,e,A,t){var r=ot(kA(1&t?i.prototype:i),e,A);return 2&t&&typeof r=="function"?function(n){return r.apply(A,n)}:r}function Un(i){return i.normalized?1:i.size}function rt(i){var e=0;return i.forEach(function(A){return e+=Un(A)}),e}function ri(i,e,A){var t=i==="VERTEX"?e.VERTEX_SHADER:e.FRAGMENT_SHADER,r=e.createShader(t);if(r===null)throw new Error("loadShader: error while creating the shader");e.shaderSource(r,A),e.compileShader(r);var n=e.getShaderParameter(r,e.COMPILE_STATUS);if(!n){var o=e.getShaderInfoLog(r);throw e.deleteShader(r),new Error(`loadShader: error while compiling the shader:
3
3
  `.concat(o,`
4
4
  `).concat(A))}return r}function Rn(i,e){return ri("VERTEX",i,e)}function On(i,e){return ri("FRAGMENT",i,e)}function jn(i,e){var A=i.createProgram();if(A===null)throw new Error("loadProgram: error while creating the program.");var t,r;for(t=0,r=e.length;t<r;t++)i.attachShader(A,e[t]);i.linkProgram(A);var n=i.getProgramParameter(A,i.LINK_STATUS);if(!n){var o=i.getProgramInfoLog(A);throw i.deleteProgram(A),new Error("loadProgram: error while linking the program: ".concat(o))}return A}function Zt(i){var e=i.gl,A=i.buffer,t=i.program,r=i.vertexShader,n=i.fragmentShader;e.deleteShader(r),e.deleteShader(n),e.deleteProgram(t),e.deleteBuffer(A)}var _t=`#define PICKING_MODE
@@ -4,6 +4,8 @@ export { cosineFallback } from "./search-fallback.js";
4
4
  export { queryFragmentLinks, getFragmentBoostDocs, ensureGlobalEntitiesTable, queryCrossProjectFragments, logFragmentMiss, extractFragmentNames, } from "./fragment-graph.js";
5
5
  export { buildSourceDocKey, decodeFiniteNumber, decodeStringRow, extractSnippet, getDocSourceKey, normalizeMemoryId, queryDocBySourceKey, queryDocRows, queryRows, rowToDoc, rowToDocWithRowid, } from "../index-query.js";
6
6
  export type { SqlValue, DbRow, DocRow, SqlJsDatabase } from "../index-query.js";
7
+ /** Drain pending embeddings immediately (used by the MCP server's graceful shutdown). */
8
+ export declare function flushEmbeddingQueue(): Promise<void>;
7
9
  export declare function classifyFile(filename: string, relPath: string): string;
8
10
  /**
9
11
  * Resolve `@import shared/file.md` directives in document content.