paqad-ai
Version:
Spec-driven development framework — AI agents that think before they type
2 lines • 80.8 kB
JavaScript
function Oe(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Le={exports:{}},Xe;function Rt(){if(Xe)return Le.exports;Xe=1;var r=typeof Reflect=="object"?Reflect:null,e=r&&typeof r.apply=="function"?r.apply:function(g,E,G){return Function.prototype.apply.call(g,E,G)},t;r&&typeof r.ownKeys=="function"?t=r.ownKeys:Object.getOwnPropertySymbols?t=function(g){return Object.getOwnPropertyNames(g).concat(Object.getOwnPropertySymbols(g))}:t=function(g){return Object.getOwnPropertyNames(g)};function n(w){console&&console.warn&&console.warn(w)}var i=Number.isNaN||function(g){return g!==g};function o(){o.init.call(this)}Le.exports=o,Le.exports.once=T,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function u(w){if(typeof w!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof w)}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(w){if(typeof w!="number"||w<0||i(w))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+w+".");s=w}}),o.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},o.prototype.setMaxListeners=function(g){if(typeof g!="number"||g<0||i(g))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+g+".");return this._maxListeners=g,this};function h(w){return w._maxListeners===void 0?o.defaultMaxListeners:w._maxListeners}o.prototype.getMaxListeners=function(){return h(this)},o.prototype.emit=function(g){for(var E=[],G=1;G<arguments.length;G++)E.push(arguments[G]);var L=g==="error",S=this._events;if(S!==void 0)L=L&&S.error===void 0;else if(!L)return!1;if(L){var R;if(E.length>0&&(R=E[0]),R instanceof Error)throw R;var Y=new Error("Unhandled error."+(R?" ("+R.message+")":""));throw Y.context=R,Y}var j=S[g];if(j===void 0)return!1;if(typeof j=="function")e(j,this,E);else for(var d=j.length,ae=U(j,d),G=0;G<d;++G)e(ae[G],this,E);return!0};function a(w,g,E,G){var L,S,R;if(u(E),S=w._events,S===void 0?(S=w._events=Object.create(null),w._eventsCount=0):(S.newListener!==void 0&&(w.emit("newListener",g,E.listener?E.listener:E),S=w._events),R=S[g]),R===void 0)R=S[g]=E,++w._eventsCount;else if(typeof R=="function"?R=S[g]=G?[E,R]:[R,E]:G?R.unshift(E):R.push(E),L=h(w),L>0&&R.length>L&&!R.warned){R.warned=!0;var Y=new Error("Possible EventEmitter memory leak detected. "+R.length+" "+String(g)+" listeners added. Use emitter.setMaxListeners() to increase limit");Y.name="MaxListenersExceededWarning",Y.emitter=w,Y.type=g,Y.count=R.length,n(Y)}return w}o.prototype.addListener=function(g,E){return a(this,g,E,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(g,E){return a(this,g,E,!0)};function f(){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 l(w,g,E){var G={fired:!1,wrapFn:void 0,target:w,type:g,listener:E},L=f.bind(G);return L.listener=E,G.wrapFn=L,L}o.prototype.once=function(g,E){return u(E),this.on(g,l(this,g,E)),this},o.prototype.prependOnceListener=function(g,E){return u(E),this.prependListener(g,l(this,g,E)),this},o.prototype.removeListener=function(g,E){var G,L,S,R,Y;if(u(E),L=this._events,L===void 0)return this;if(G=L[g],G===void 0)return this;if(G===E||G.listener===E)--this._eventsCount===0?this._events=Object.create(null):(delete L[g],L.removeListener&&this.emit("removeListener",g,G.listener||E));else if(typeof G!="function"){for(S=-1,R=G.length-1;R>=0;R--)if(G[R]===E||G[R].listener===E){Y=G[R].listener,S=R;break}if(S<0)return this;S===0?G.shift():O(G,S),G.length===1&&(L[g]=G[0]),L.removeListener!==void 0&&this.emit("removeListener",g,Y||E)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(g){var E,G,L;if(G=this._events,G===void 0)return this;if(G.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):G[g]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete G[g]),this;if(arguments.length===0){var S=Object.keys(G),R;for(L=0;L<S.length;++L)R=S[L],R!=="removeListener"&&this.removeAllListeners(R);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(E=G[g],typeof E=="function")this.removeListener(g,E);else if(E!==void 0)for(L=E.length-1;L>=0;L--)this.removeListener(g,E[L]);return this};function y(w,g,E){var G=w._events;if(G===void 0)return[];var L=G[g];return L===void 0?[]:typeof L=="function"?E?[L.listener||L]:[L]:E?C(L):U(L,L.length)}o.prototype.listeners=function(g){return y(this,g,!0)},o.prototype.rawListeners=function(g){return y(this,g,!1)},o.listenerCount=function(w,g){return typeof w.listenerCount=="function"?w.listenerCount(g):v.call(w,g)},o.prototype.listenerCount=v;function v(w){var g=this._events;if(g!==void 0){var E=g[w];if(typeof E=="function")return 1;if(E!==void 0)return E.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function U(w,g){for(var E=new Array(g),G=0;G<g;++G)E[G]=w[G];return E}function O(w,g){for(;g+1<w.length;g++)w[g]=w[g+1];w.pop()}function C(w){for(var g=new Array(w.length),E=0;E<g.length;++E)g[E]=w[E].listener||w[E];return g}function T(w,g){return new Promise(function(E,G){function L(R){w.removeListener(g,S),G(R)}function S(){typeof w.removeListener=="function"&&w.removeListener("error",L),E([].slice.call(arguments))}x(w,g,S,{once:!0}),g!=="error"&&I(w,L,{once:!0})})}function I(w,g,E){typeof w.on=="function"&&x(w,"error",g,E)}function x(w,g,E,G){if(typeof w.on=="function")G.once?w.once(g,E):w.on(g,E);else if(typeof w.addEventListener=="function")w.addEventListener(g,function L(S){G.once&&w.removeEventListener(g,L),E(S)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof w)}return Le.exports}var It=Rt(),je,Me;function Ne(){if(Me)return je;Me=1;function r(e){if(typeof e!="function")throw new Error("obliterator/iterator: expecting a function!");this.next=e}return typeof Symbol<"u"&&(r.prototype[Symbol.iterator]=function(){return this}),r.of=function(){var e=arguments,t=e.length,n=0;return new r(function(){return n>=t?{done:!0}:{done:!1,value:e[n++]}})},r.empty=function(){var e=new r(function(){return{done:!0}});return e},r.fromSequence=function(e){var t=0,n=e.length;return new r(function(){return t>=n?{done:!0}:{done:!1,value:e[t++]}})},r.is=function(e){return e instanceof r?!0:typeof e=="object"&&e!==null&&typeof e.next=="function"},je=r,je}var Ct=Ne(),Q=Oe(Ct),Se={},et;function Tt(){return et||(et=1,Se.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<"u",Se.SYMBOL_SUPPORT=typeof Symbol<"u"),Se}var ze,tt;function pt(){if(tt)return ze;tt=1;var r=Ne(),e=Tt(),t=e.ARRAY_BUFFER_SUPPORT,n=e.SYMBOL_SUPPORT;function i(o){return typeof o=="string"||Array.isArray(o)||t&&ArrayBuffer.isView(o)?r.fromSequence(o):typeof o!="object"||o===null?null:n&&typeof o[Symbol.iterator]=="function"?o[Symbol.iterator]():typeof o.next=="function"?o:null}return ze=function(s){var u=i(s);if(!u)throw new Error("obliterator: target is not iterable nor a valid iterator.");return u},ze}var Pe,nt;function jt(){if(nt)return Pe;nt=1;var r=pt();return Pe=function(t,n){for(var i=arguments.length>1?n:1/0,o=i!==1/0?new Array(i):[],s,u=0,h=r(t);;){if(u===i)return o;if(s=h.next(),s.done)return u!==n&&(o.length=u),o;o[u++]=s.value}},Pe}var zt=jt(),gt=Oe(zt),We,rt;function Pt(){if(rt)return We;rt=1;var r=Ne(),e=pt();return We=function(){var n=arguments,i=null,o=-1;return new r(function(){var u=null;do{if(i===null){if(o++,o>=n.length)return{done:!0};i=e(n[o])}if(u=i.next(),u.done===!0){i=null;continue}break}while(!0);return u})},We}var Wt=Pt(),ne=Oe(Wt);function xt(){const r=arguments[0];for(let e=1,t=arguments.length;e<t;e++)if(arguments[e])for(const n in arguments[e])r[n]=arguments[e][n];return r}let q=xt;typeof Object.assign=="function"&&(q=Object.assign);function J(r,e,t,n){const i=r._nodes.get(e);let o=null;return i&&(n==="mixed"?o=i.out&&i.out[t]||i.undirected&&i.undirected[t]:n==="directed"?o=i.out&&i.out[t]:o=i.undirected&&i.undirected[t]),o}function H(r){return typeof r=="object"&&r!==null}function yt(r){let e;for(e in r)return!1;return!0}function Z(r,e,t){Object.defineProperty(r,e,{enumerable:!1,configurable:!1,writable:!0,value:t})}function X(r,e,t){const n={enumerable:!0,configurable:!0};typeof t=="function"?n.get=t:(n.value=t,n.writable=!1),Object.defineProperty(r,e,n)}function it(r){return!(!H(r)||r.attributes&&!Array.isArray(r.attributes))}function Kt(){let r=Math.floor(Math.random()*256)&255;return()=>r++}class Ye extends Error{constructor(e){super(),this.name="GraphError",this.message=e}}class _ extends Ye{constructor(e){super(e),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,_.prototype.constructor)}}class b extends Ye{constructor(e){super(e),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,b.prototype.constructor)}}class $ extends Ye{constructor(e){super(e),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,$.prototype.constructor)}}function wt(r,e){this.key=r,this.attributes=e,this.clear()}wt.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 bt(r,e){this.key=r,this.attributes=e,this.clear()}bt.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function mt(r,e){this.key=r,this.attributes=e,this.clear()}mt.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function pe(r,e,t,n,i){this.key=e,this.attributes=i,this.undirected=r,this.source=t,this.target=n}pe.prototype.attach=function(){let r="out",e="in";this.undirected&&(r=e="undirected");const t=this.source.key,n=this.target.key;this.source[r][n]=this,!(this.undirected&&t===n)&&(this.target[e][t]=this)};pe.prototype.attachMulti=function(){let r="out",e="in";const t=this.source.key,n=this.target.key;this.undirected&&(r=e="undirected");const i=this.source[r],o=i[n];if(typeof o>"u"){i[n]=this,this.undirected&&t===n||(this.target[e][t]=this);return}o.previous=this,this.next=o,i[n]=this,this.target[e][t]=this};pe.prototype.detach=function(){const r=this.source.key,e=this.target.key;let t="out",n="in";this.undirected&&(t=n="undirected"),delete this.source[t][e],delete this.target[n][r]};pe.prototype.detachMulti=function(){const r=this.source.key,e=this.target.key;let t="out",n="in";this.undirected&&(t=n="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[t][e],delete this.target[n][r]):(this.next.previous=void 0,this.source[t][e]=this.next,this.target[n][r]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const vt=0,Et=1,Ft=2,_t=3;function re(r,e,t,n,i,o,s){let u,h,a,f;if(n=""+n,t===vt){if(u=r._nodes.get(n),!u)throw new b(`Graph.${e}: could not find the "${n}" node in the graph.`);a=i,f=o}else if(t===_t){if(i=""+i,h=r._edges.get(i),!h)throw new b(`Graph.${e}: could not find the "${i}" edge in the graph.`);const l=h.source.key,y=h.target.key;if(n===l)u=h.target;else if(n===y)u=h.source;else throw new b(`Graph.${e}: the "${n}" node is not attached to the "${i}" edge (${l}, ${y}).`);a=o,f=s}else{if(h=r._edges.get(n),!h)throw new b(`Graph.${e}: could not find the "${n}" edge in the graph.`);t===Et?u=h.source:u=h.target,a=i,f=o}return[u,a,f]}function Bt(r,e,t){r.prototype[e]=function(n,i,o){const[s,u]=re(this,e,t,n,i,o);return s.attributes[u]}}function qt(r,e,t){r.prototype[e]=function(n,i){const[o]=re(this,e,t,n,i);return o.attributes}}function Ht(r,e,t){r.prototype[e]=function(n,i,o){const[s,u]=re(this,e,t,n,i,o);return s.attributes.hasOwnProperty(u)}}function Nt(r,e,t){r.prototype[e]=function(n,i,o,s){const[u,h,a]=re(this,e,t,n,i,o,s);return u.attributes[h]=a,this.emit("nodeAttributesUpdated",{key:u.key,type:"set",attributes:u.attributes,name:h}),this}}function Yt(r,e,t){r.prototype[e]=function(n,i,o,s){const[u,h,a]=re(this,e,t,n,i,o,s);if(typeof a!="function")throw new _(`Graph.${e}: updater should be a function.`);const f=u.attributes,l=a(f[h]);return f[h]=l,this.emit("nodeAttributesUpdated",{key:u.key,type:"set",attributes:u.attributes,name:h}),this}}function Vt(r,e,t){r.prototype[e]=function(n,i,o){const[s,u]=re(this,e,t,n,i,o);return delete s.attributes[u],this.emit("nodeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:u}),this}}function Zt(r,e,t){r.prototype[e]=function(n,i,o){const[s,u]=re(this,e,t,n,i,o);if(!H(u))throw new _(`Graph.${e}: provided attributes are not a plain object.`);return s.attributes=u,this.emit("nodeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}function Jt(r,e,t){r.prototype[e]=function(n,i,o){const[s,u]=re(this,e,t,n,i,o);if(!H(u))throw new _(`Graph.${e}: provided attributes are not a plain object.`);return q(s.attributes,u),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:u}),this}}function Qt(r,e,t){r.prototype[e]=function(n,i,o){const[s,u]=re(this,e,t,n,i,o);if(typeof u!="function")throw new _(`Graph.${e}: provided updater is not a function.`);return s.attributes=u(s.attributes),this.emit("nodeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}const Xt=[{name:r=>`get${r}Attribute`,attacher:Bt},{name:r=>`get${r}Attributes`,attacher:qt},{name:r=>`has${r}Attribute`,attacher:Ht},{name:r=>`set${r}Attribute`,attacher:Nt},{name:r=>`update${r}Attribute`,attacher:Yt},{name:r=>`remove${r}Attribute`,attacher:Vt},{name:r=>`replace${r}Attributes`,attacher:Zt},{name:r=>`merge${r}Attributes`,attacher:Jt},{name:r=>`update${r}Attributes`,attacher:Qt}];function Mt(r){Xt.forEach(function({name:e,attacher:t}){t(r,e("Node"),vt),t(r,e("Source"),Et),t(r,e("Target"),Ft),t(r,e("Opposite"),_t)})}function en(r,e,t){r.prototype[e]=function(n,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,u=""+i;if(i=arguments[2],o=J(this,s,u,t),!o)throw new b(`Graph.${e}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new b(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return o.attributes[i]}}function tn(r,e,t){r.prototype[e]=function(n){let i;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+n,s=""+arguments[1];if(i=J(this,o,s,t),!i)throw new b(`Graph.${e}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,i=this._edges.get(n),!i)throw new b(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return i.attributes}}function nn(r,e,t){r.prototype[e]=function(n,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,u=""+i;if(i=arguments[2],o=J(this,s,u,t),!o)throw new b(`Graph.${e}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new b(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function rn(r,e,t){r.prototype[e]=function(n,i,o){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const u=""+n,h=""+i;if(i=arguments[2],o=arguments[3],s=J(this,u,h,t),!s)throw new b(`Graph.${e}: could not find an edge for the given path ("${u}" - "${h}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new b(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return s.attributes[i]=o,this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:i}),this}}function on(r,e,t){r.prototype[e]=function(n,i,o){let s;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const u=""+n,h=""+i;if(i=arguments[2],o=arguments[3],s=J(this,u,h,t),!s)throw new b(`Graph.${e}: could not find an edge for the given path ("${u}" - "${h}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,s=this._edges.get(n),!s)throw new b(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(typeof o!="function")throw new _(`Graph.${e}: updater should be a function.`);return s.attributes[i]=o(s.attributes[i]),this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:i}),this}}function sn(r,e,t){r.prototype[e]=function(n,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,u=""+i;if(i=arguments[2],o=J(this,s,u,t),!o)throw new b(`Graph.${e}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new b(`Graph.${e}: could not find the "${n}" edge in the graph.`)}return delete o.attributes[i],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:i}),this}}function un(r,e,t){r.prototype[e]=function(n,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,u=""+i;if(i=arguments[2],o=J(this,s,u,t),!o)throw new b(`Graph.${e}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new b(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(!H(i))throw new _(`Graph.${e}: provided attributes are not a plain object.`);return o.attributes=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function an(r,e,t){r.prototype[e]=function(n,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,u=""+i;if(i=arguments[2],o=J(this,s,u,t),!o)throw new b(`Graph.${e}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new b(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(!H(i))throw new _(`Graph.${e}: provided attributes are not a plain object.`);return q(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function hn(r,e,t){r.prototype[e]=function(n,i){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new $(`Graph.${e}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new $(`Graph.${e}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+n,u=""+i;if(i=arguments[2],o=J(this,s,u,t),!o)throw new b(`Graph.${e}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new $(`Graph.${e}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(n=""+n,o=this._edges.get(n),!o)throw new b(`Graph.${e}: could not find the "${n}" edge in the graph.`)}if(typeof i!="function")throw new _(`Graph.${e}: provided updater is not a function.`);return o.attributes=i(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const dn=[{name:r=>`get${r}Attribute`,attacher:en},{name:r=>`get${r}Attributes`,attacher:tn},{name:r=>`has${r}Attribute`,attacher:nn},{name:r=>`set${r}Attribute`,attacher:rn},{name:r=>`update${r}Attribute`,attacher:on},{name:r=>`remove${r}Attribute`,attacher:sn},{name:r=>`replace${r}Attributes`,attacher:un},{name:r=>`merge${r}Attributes`,attacher:an},{name:r=>`update${r}Attributes`,attacher:hn}];function cn(r){dn.forEach(function({name:e,attacher:t}){t(r,e("Edge"),"mixed"),t(r,e("DirectedEdge"),"directed"),t(r,e("UndirectedEdge"),"undirected")})}const fn=[{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 ln(r,e,t,n){let i=!1;for(const o in e){if(o===n)continue;const s=e[o];if(i=t(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),r&&i)return s.key}}function pn(r,e,t,n){let i,o,s,u=!1;for(const h in e)if(h!==n){i=e[h];do{if(o=i.source,s=i.target,u=t(i.key,i.attributes,o.key,s.key,o.attributes,s.attributes,i.undirected),r&&u)return i.key;i=i.next}while(i!==void 0)}}function xe(r,e){const t=Object.keys(r),n=t.length;let i,o=0;return new Q(function(){do if(i)i=i.next;else{if(o>=n)return{done:!0};const u=t[o++];if(u===e){i=void 0;continue}i=r[u]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}})}function gn(r,e,t,n){const i=e[t];if(!i)return;const o=i.source,s=i.target;if(n(i.key,i.attributes,o.key,s.key,o.attributes,s.attributes,i.undirected)&&r)return i.key}function yn(r,e,t,n){let i=e[t];if(!i)return;let o=!1;do{if(o=n(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),r&&o)return i.key;i=i.next}while(i!==void 0)}function Ke(r,e){let t=r[e];return t.next!==void 0?new Q(function(){if(!t)return{done:!0};const n={edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected};return t=t.next,{done:!1,value:n}}):Q.of({edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected})}function wn(r,e){if(r.size===0)return[];if(e==="mixed"||e===r.type)return typeof Array.from=="function"?Array.from(r._edges.keys()):gt(r._edges.keys(),r._edges.size);const t=e==="undirected"?r.undirectedSize:r.directedSize,n=new Array(t),i=e==="undirected",o=r._edges.values();let s=0,u,h;for(;u=o.next(),u.done!==!0;)h=u.value,h.undirected===i&&(n[s++]=h.key);return n}function Gt(r,e,t,n){if(e.size===0)return;const i=t!=="mixed"&&t!==e.type,o=t==="undirected";let s,u,h=!1;const a=e._edges.values();for(;s=a.next(),s.done!==!0;){if(u=s.value,i&&u.undirected!==o)continue;const{key:f,attributes:l,source:y,target:v}=u;if(h=n(f,l,y.key,v.key,y.attributes,v.attributes,u.undirected),r&&h)return f}}function bn(r,e){if(r.size===0)return Q.empty();const t=e!=="mixed"&&e!==r.type,n=e==="undirected",i=r._edges.values();return new Q(function(){let s,u;for(;;){if(s=i.next(),s.done)return s;if(u=s.value,!(t&&u.undirected!==n))break}return{value:{edge:u.key,attributes:u.attributes,source:u.source.key,target:u.target.key,sourceAttributes:u.source.attributes,targetAttributes:u.target.attributes,undirected:u.undirected},done:!1}})}function Ve(r,e,t,n,i,o){const s=e?pn:ln;let u;if(t!=="undirected"&&(n!=="out"&&(u=s(r,i.in,o),r&&u)||n!=="in"&&(u=s(r,i.out,o,n?void 0:i.key),r&&u))||t!=="directed"&&(u=s(r,i.undirected,o),r&&u))return u}function mn(r,e,t,n){const i=[];return Ve(!1,r,e,t,n,function(o){i.push(o)}),i}function vn(r,e,t){let n=Q.empty();return r!=="undirected"&&(e!=="out"&&typeof t.in<"u"&&(n=ne(n,xe(t.in))),e!=="in"&&typeof t.out<"u"&&(n=ne(n,xe(t.out,e?void 0:t.key)))),r!=="directed"&&typeof t.undirected<"u"&&(n=ne(n,xe(t.undirected))),n}function Ze(r,e,t,n,i,o,s){const u=t?yn:gn;let h;if(e!=="undirected"&&(typeof i.in<"u"&&n!=="out"&&(h=u(r,i.in,o,s),r&&h)||typeof i.out<"u"&&n!=="in"&&(n||i.key!==o)&&(h=u(r,i.out,o,s),r&&h))||e!=="directed"&&typeof i.undirected<"u"&&(h=u(r,i.undirected,o,s),r&&h))return h}function En(r,e,t,n,i){const o=[];return Ze(!1,r,e,t,n,i,function(s){o.push(s)}),o}function _n(r,e,t,n){let i=Q.empty();return r!=="undirected"&&(typeof t.in<"u"&&e!=="out"&&n in t.in&&(i=ne(i,Ke(t.in,n))),typeof t.out<"u"&&e!=="in"&&n in t.out&&(e||t.key!==n)&&(i=ne(i,Ke(t.out,n)))),r!=="directed"&&typeof t.undirected<"u"&&n in t.undirected&&(i=ne(i,Ke(t.undirected,n))),i}function Gn(r,e){const{name:t,type:n,direction:i}=e;r.prototype[t]=function(o,s){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return[];if(!arguments.length)return wn(this,n);if(arguments.length===1){o=""+o;const u=this._nodes.get(o);if(typeof u>"u")throw new b(`Graph.${t}: could not find the "${o}" node in the graph.`);return mn(this.multi,n==="mixed"?this.type:n,i,u)}if(arguments.length===2){o=""+o,s=""+s;const u=this._nodes.get(o);if(!u)throw new b(`Graph.${t}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new b(`Graph.${t}: could not find the "${s}" target node in the graph.`);return En(n,this.multi,i,u,s)}throw new _(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function $n(r,e){const{name:t,type:n,direction:i}=e,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(a,f,l){if(!(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)){if(arguments.length===1)return l=a,Gt(!1,this,n,l);if(arguments.length===2){a=""+a,l=f;const y=this._nodes.get(a);if(typeof y>"u")throw new b(`Graph.${o}: could not find the "${a}" node in the graph.`);return Ve(!1,this.multi,n==="mixed"?this.type:n,i,y,l)}if(arguments.length===3){a=""+a,f=""+f;const y=this._nodes.get(a);if(!y)throw new b(`Graph.${o}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(f))throw new b(`Graph.${o}: could not find the "${f}" target node in the graph.`);return Ze(!1,n,this.multi,i,y,f,l)}throw new _(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const s="map"+t[0].toUpperCase()+t.slice(1);r.prototype[s]=function(){const a=Array.prototype.slice.call(arguments),f=a.pop();let l;if(a.length===0){let y=0;n!=="directed"&&(y+=this.undirectedSize),n!=="undirected"&&(y+=this.directedSize),l=new Array(y);let v=0;a.push((U,O,C,T,I,x,w)=>{l[v++]=f(U,O,C,T,I,x,w)})}else l=[],a.push((y,v,U,O,C,T,I)=>{l.push(f(y,v,U,O,C,T,I))});return this[o].apply(this,a),l};const u="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[u]=function(){const a=Array.prototype.slice.call(arguments),f=a.pop(),l=[];return a.push((y,v,U,O,C,T,I)=>{f(y,v,U,O,C,T,I)&&l.push(y)}),this[o].apply(this,a),l};const h="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[h]=function(){let a=Array.prototype.slice.call(arguments);if(a.length<2||a.length>4)throw new _(`Graph.${h}: invalid number of arguments (expecting 2, 3 or 4 and got ${a.length}).`);if(typeof a[a.length-1]=="function"&&typeof a[a.length-2]!="function")throw new _(`Graph.${h}: 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 f,l;a.length===2?(f=a[0],l=a[1],a=[]):a.length===3?(f=a[1],l=a[2],a=[a[0]]):a.length===4&&(f=a[2],l=a[3],a=[a[0],a[1]]);let y=l;return a.push((v,U,O,C,T,I,x)=>{y=f(y,v,U,O,C,T,I,x)}),this[o].apply(this,a),y}}function kn(r,e){const{name:t,type:n,direction:i}=e,o="find"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(h,a,f){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return!1;if(arguments.length===1)return f=h,Gt(!0,this,n,f);if(arguments.length===2){h=""+h,f=a;const l=this._nodes.get(h);if(typeof l>"u")throw new b(`Graph.${o}: could not find the "${h}" node in the graph.`);return Ve(!0,this.multi,n==="mixed"?this.type:n,i,l,f)}if(arguments.length===3){h=""+h,a=""+a;const l=this._nodes.get(h);if(!l)throw new b(`Graph.${o}: could not find the "${h}" source node in the graph.`);if(!this._nodes.has(a))throw new b(`Graph.${o}: could not find the "${a}" target node in the graph.`);return Ze(!0,n,this.multi,i,l,a,f)}throw new _(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const s="some"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[s]=function(){const h=Array.prototype.slice.call(arguments),a=h.pop();return h.push((l,y,v,U,O,C,T)=>a(l,y,v,U,O,C,T)),!!this[o].apply(this,h)};const u="every"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[u]=function(){const h=Array.prototype.slice.call(arguments),a=h.pop();return h.push((l,y,v,U,O,C,T)=>!a(l,y,v,U,O,C,T)),!this[o].apply(this,h)}}function Dn(r,e){const{name:t,type:n,direction:i}=e,o=t.slice(0,-1)+"Entries";r.prototype[o]=function(s,u){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return Q.empty();if(!arguments.length)return bn(this,n);if(arguments.length===1){s=""+s;const h=this._nodes.get(s);if(!h)throw new b(`Graph.${o}: could not find the "${s}" node in the graph.`);return vn(n,i,h)}if(arguments.length===2){s=""+s,u=""+u;const h=this._nodes.get(s);if(!h)throw new b(`Graph.${o}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(u))throw new b(`Graph.${o}: could not find the "${u}" target node in the graph.`);return _n(n,i,h,u)}throw new _(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function An(r){fn.forEach(e=>{Gn(r,e),$n(r,e),kn(r,e),Dn(r,e)})}const Ln=[{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 Re(){this.A=null,this.B=null}Re.prototype.wrap=function(r){this.A===null?this.A=r:this.B===null&&(this.B=r)};Re.prototype.has=function(r){return this.A!==null&&r in this.A||this.B!==null&&r in this.B};function be(r,e,t,n,i){for(const o in n){const s=n[o],u=s.source,h=s.target,a=u===t?h:u;if(e&&e.has(a.key))continue;const f=i(a.key,a.attributes);if(r&&f)return a.key}}function Je(r,e,t,n,i){if(e!=="mixed"){if(e==="undirected")return be(r,null,n,n.undirected,i);if(typeof t=="string")return be(r,null,n,n[t],i)}const o=new Re;let s;if(e!=="undirected"){if(t!=="out"){if(s=be(r,null,n,n.in,i),r&&s)return s;o.wrap(n.in)}if(t!=="in"){if(s=be(r,o,n,n.out,i),r&&s)return s;o.wrap(n.out)}}if(e!=="directed"&&(s=be(r,o,n,n.undirected,i),r&&s))return s}function Sn(r,e,t){if(r!=="mixed"){if(r==="undirected")return Object.keys(t.undirected);if(typeof e=="string")return Object.keys(t[e])}const n=[];return Je(!1,r,e,t,function(i){n.push(i)}),n}function me(r,e,t){const n=Object.keys(t),i=n.length;let o=0;return new Q(function(){let u=null;do{if(o>=i)return r&&r.wrap(t),{done:!0};const h=t[n[o++]],a=h.source,f=h.target;if(u=a===e?f:a,r&&r.has(u.key)){u=null;continue}}while(u===null);return{done:!1,value:{neighbor:u.key,attributes:u.attributes}}})}function Un(r,e,t){if(r!=="mixed"){if(r==="undirected")return me(null,t,t.undirected);if(typeof e=="string")return me(null,t,t[e])}let n=Q.empty();const i=new Re;return r!=="undirected"&&(e!=="out"&&(n=ne(n,me(i,t,t.in))),e!=="in"&&(n=ne(n,me(i,t,t.out)))),r!=="directed"&&(n=ne(n,me(i,t,t.undirected))),n}function On(r,e){const{name:t,type:n,direction:i}=e;r.prototype[t]=function(o){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return[];o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new b(`Graph.${t}: could not find the "${o}" node in the graph.`);return Sn(n==="mixed"?this.type:n,i,s)}}function Rn(r,e){const{name:t,type:n,direction:i}=e,o="forEach"+t[0].toUpperCase()+t.slice(1,-1);r.prototype[o]=function(a,f){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return;a=""+a;const l=this._nodes.get(a);if(typeof l>"u")throw new b(`Graph.${o}: could not find the "${a}" node in the graph.`);Je(!1,n==="mixed"?this.type:n,i,l,f)};const s="map"+t[0].toUpperCase()+t.slice(1);r.prototype[s]=function(a,f){const l=[];return this[o](a,(y,v)=>{l.push(f(y,v))}),l};const u="filter"+t[0].toUpperCase()+t.slice(1);r.prototype[u]=function(a,f){const l=[];return this[o](a,(y,v)=>{f(y,v)&&l.push(y)}),l};const h="reduce"+t[0].toUpperCase()+t.slice(1);r.prototype[h]=function(a,f,l){if(arguments.length<3)throw new _(`Graph.${h}: 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 y=l;return this[o](a,(v,U)=>{y=f(y,v,U)}),y}}function In(r,e){const{name:t,type:n,direction:i}=e,o=t[0].toUpperCase()+t.slice(1,-1),s="find"+o;r.prototype[s]=function(a,f){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return;a=""+a;const l=this._nodes.get(a);if(typeof l>"u")throw new b(`Graph.${s}: could not find the "${a}" node in the graph.`);return Je(!0,n==="mixed"?this.type:n,i,l,f)};const u="some"+o;r.prototype[u]=function(a,f){return!!this[s](a,f)};const h="every"+o;r.prototype[h]=function(a,f){return!this[s](a,(y,v)=>!f(y,v))}}function Cn(r,e){const{name:t,type:n,direction:i}=e,o=t.slice(0,-1)+"Entries";r.prototype[o]=function(s){if(n!=="mixed"&&this.type!=="mixed"&&n!==this.type)return Q.empty();s=""+s;const u=this._nodes.get(s);if(typeof u>"u")throw new b(`Graph.${o}: could not find the "${s}" node in the graph.`);return Un(n==="mixed"?this.type:n,i,u)}}function Tn(r){Ln.forEach(e=>{On(r,e),Rn(r,e),In(r,e),Cn(r,e)})}function Ue(r,e,t,n,i){const o=n._nodes.values(),s=n.type;let u,h,a,f,l,y;for(;u=o.next(),u.done!==!0;){let v=!1;if(h=u.value,s!=="undirected"){f=h.out;for(a in f){l=f[a];do y=l.target,v=!0,i(h.key,y.key,h.attributes,y.attributes,l.key,l.attributes,l.undirected),l=l.next;while(l)}}if(s!=="directed"){f=h.undirected;for(a in f)if(!(e&&h.key>a)){l=f[a];do y=l.target,y.key!==a&&(y=l.source),v=!0,i(h.key,y.key,h.attributes,y.attributes,l.key,l.attributes,l.undirected),l=l.next;while(l)}}t&&!v&&i(h.key,null,h.attributes,null,null,null,null)}}function jn(r,e){const t={key:r};return yt(e.attributes)||(t.attributes=q({},e.attributes)),t}function zn(r,e,t){const n={key:e,source:t.source.key,target:t.target.key};return yt(t.attributes)||(n.attributes=q({},t.attributes)),r==="mixed"&&t.undirected&&(n.undirected=!0),n}function Pn(r){if(!H(r))throw new _('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in r))throw new _("Graph.import: serialized node is missing its key.");if("attributes"in r&&(!H(r.attributes)||r.attributes===null))throw new _("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function Wn(r){if(!H(r))throw new _('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in r))throw new _("Graph.import: serialized edge is missing its source.");if(!("target"in r))throw new _("Graph.import: serialized edge is missing its target.");if("attributes"in r&&(!H(r.attributes)||r.attributes===null))throw new _("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in r&&typeof r.undirected!="boolean")throw new _("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const xn=Kt(),Kn=new Set(["directed","undirected","mixed"]),ot=new Set(["domain","_events","_eventsCount","_maxListeners"]),Fn=[{name:r=>`${r}Edge`,generateKey:!0},{name:r=>`${r}DirectedEdge`,generateKey:!0,type:"directed"},{name:r=>`${r}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:r=>`${r}EdgeWithKey`},{name:r=>`${r}DirectedEdgeWithKey`,type:"directed"},{name:r=>`${r}UndirectedEdgeWithKey`,type:"undirected"}],Bn={allowSelfLoops:!0,multi:!1,type:"mixed"};function qn(r,e,t){if(t&&!H(t))throw new _(`Graph.addNode: invalid attributes. Expecting an object but got "${t}"`);if(e=""+e,t=t||{},r._nodes.has(e))throw new $(`Graph.addNode: the "${e}" node already exist in the graph.`);const n=new r.NodeDataClass(e,t);return r._nodes.set(e,n),r.emit("nodeAdded",{key:e,attributes:t}),n}function st(r,e,t){const n=new r.NodeDataClass(e,t);return r._nodes.set(e,n),r.emit("nodeAdded",{key:e,attributes:t}),n}function $t(r,e,t,n,i,o,s,u){if(!n&&r.type==="undirected")throw new $(`Graph.${e}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(n&&r.type==="directed")throw new $(`Graph.${e}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(u&&!H(u))throw new _(`Graph.${e}: invalid attributes. Expecting an object but got "${u}"`);if(o=""+o,s=""+s,u=u||{},!r.allowSelfLoops&&o===s)throw new $(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const h=r._nodes.get(o),a=r._nodes.get(s);if(!h)throw new b(`Graph.${e}: source node "${o}" not found.`);if(!a)throw new b(`Graph.${e}: target node "${s}" not found.`);const f={key:null,undirected:n,source:o,target:s,attributes:u};if(t)i=r._edgeKeyGenerator();else if(i=""+i,r._edges.has(i))throw new $(`Graph.${e}: the "${i}" edge already exists in the graph.`);if(!r.multi&&(n?typeof h.undirected[s]<"u":typeof h.out[s]<"u"))throw new $(`Graph.${e}: an edge linking "${o}" to "${s}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const l=new pe(n,i,h,a,u);r._edges.set(i,l);const y=o===s;return n?(h.undirectedDegree++,a.undirectedDegree++,y&&(h.undirectedLoops++,r._undirectedSelfLoopCount++)):(h.outDegree++,a.inDegree++,y&&(h.directedLoops++,r._directedSelfLoopCount++)),r.multi?l.attachMulti():l.attach(),n?r._undirectedSize++:r._directedSize++,f.key=i,r.emit("edgeAdded",f),i}function Hn(r,e,t,n,i,o,s,u,h){if(!n&&r.type==="undirected")throw new $(`Graph.${e}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(n&&r.type==="directed")throw new $(`Graph.${e}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(u){if(h){if(typeof u!="function")throw new _(`Graph.${e}: invalid updater function. Expecting a function but got "${u}"`)}else if(!H(u))throw new _(`Graph.${e}: invalid attributes. Expecting an object but got "${u}"`)}o=""+o,s=""+s;let a;if(h&&(a=u,u=void 0),!r.allowSelfLoops&&o===s)throw new $(`Graph.${e}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let f=r._nodes.get(o),l=r._nodes.get(s),y,v;if(!t&&(y=r._edges.get(i),y)){if((y.source.key!==o||y.target.key!==s)&&(!n||y.source.key!==s||y.target.key!==o))throw new $(`Graph.${e}: inconsistency detected when attempting to merge the "${i}" edge with "${o}" source & "${s}" target vs. ("${y.source.key}", "${y.target.key}").`);v=y}if(!v&&!r.multi&&f&&(v=n?f.undirected[s]:f.out[s]),v){const I=[v.key,!1,!1,!1];if(h?!a:!u)return I;if(h){const x=v.attributes;v.attributes=a(x),r.emit("edgeAttributesUpdated",{type:"replace",key:v.key,attributes:v.attributes})}else q(v.attributes,u),r.emit("edgeAttributesUpdated",{type:"merge",key:v.key,attributes:v.attributes,data:u});return I}u=u||{},h&&a&&(u=a(u));const U={key:null,undirected:n,source:o,target:s,attributes:u};if(t)i=r._edgeKeyGenerator();else if(i=""+i,r._edges.has(i))throw new $(`Graph.${e}: the "${i}" edge already exists in the graph.`);let O=!1,C=!1;f||(f=st(r,o,{}),O=!0,o===s&&(l=f,C=!0)),l||(l=st(r,s,{}),C=!0),y=new pe(n,i,f,l,u),r._edges.set(i,y);const T=o===s;return n?(f.undirectedDegree++,l.undirectedDegree++,T&&(f.undirectedLoops++,r._undirectedSelfLoopCount++)):(f.outDegree++,l.inDegree++,T&&(f.directedLoops++,r._directedSelfLoopCount++)),r.multi?y.attachMulti():y.attach(),n?r._undirectedSize++:r._directedSize++,U.key=i,r.emit("edgeAdded",U),[i,!0,O,C]}function le(r,e){r._edges.delete(e.key);const{source:t,target:n,attributes:i}=e,o=e.undirected,s=t===n;o?(t.undirectedDegree--,n.undirectedDegree--,s&&(t.undirectedLoops--,r._undirectedSelfLoopCount--)):(t.outDegree--,n.inDegree--,s&&(t.directedLoops--,r._directedSelfLoopCount--)),r.multi?e.detachMulti():e.detach(),o?r._undirectedSize--:r._directedSize--,r.emit("edgeDropped",{key:e.key,attributes:i,source:t.key,target:n.key,undirected:o})}class W extends It.EventEmitter{constructor(e){if(super(),e=q({},Bn,e),typeof e.multi!="boolean")throw new _(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!Kn.has(e.type))throw new _(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!="boolean")throw new _(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);const t=e.type==="mixed"?wt:e.type==="directed"?bt:mt;Z(this,"NodeDataClass",t);const n="geid_"+xn()+"_";let i=0;const o=()=>{let s;do s=n+i++;while(this._edges.has(s));return s};Z(this,"_attributes",{}),Z(this,"_nodes",new Map),Z(this,"_edges",new Map),Z(this,"_directedSize",0),Z(this,"_undirectedSize",0),Z(this,"_directedSelfLoopCount",0),Z(this,"_undirectedSelfLoopCount",0),Z(this,"_edgeKeyGenerator",o),Z(this,"_options",e),ot.forEach(s=>Z(this,s,this[s])),X(this,"order",()=>this._nodes.size),X(this,"size",()=>this._edges.size),X(this,"directedSize",()=>this._directedSize),X(this,"undirectedSize",()=>this._undirectedSize),X(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),X(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),X(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),X(this,"multi",this._options.multi),X(this,"type",this._options.type),X(this,"allowSelfLoops",this._options.allowSelfLoops),X(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,t){if(this.type==="undirected")return!1;if(arguments.length===1){const n=""+e,i=this._edges.get(n);return!!i&&!i.undirected}else if(arguments.length===2){e=""+e,t=""+t;const n=this._nodes.get(e);return n?n.out.hasOwnProperty(t):!1}throw new _(`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,t){if(this.type==="directed")return!1;if(arguments.length===1){const n=""+e,i=this._edges.get(n);return!!i&&i.undirected}else if(arguments.length===2){e=""+e,t=""+t;const n=this._nodes.get(e);return n?n.undirected.hasOwnProperty(t):!1}throw new _(`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,t){if(arguments.length===1){const n=""+e;return this._edges.has(n)}else if(arguments.length===2){e=""+e,t=""+t;const n=this._nodes.get(e);return n?typeof n.out<"u"&&n.out.hasOwnProperty(t)||typeof n.undirected<"u"&&n.undirected.hasOwnProperty(t):!1}throw new _(`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,t){if(this.type==="undirected")return;if(e=""+e,t=""+t,this.multi)throw new $("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const n=this._nodes.get(e);if(!n)throw new b(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new b(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);const i=n.out&&n.out[t]||void 0;if(i)return i.key}undirectedEdge(e,t){if(this.type==="directed")return;if(e=""+e,t=""+t,this.multi)throw new $("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const n=this._nodes.get(e);if(!n)throw new b(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new b(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);const i=n.undirected&&n.undirected[t]||void 0;if(i)return i.key}edge(e,t){if(this.multi)throw new $("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new b(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new b(`Graph.edge: could not find the "${t}" target node in the graph.`);const i=n.out&&n.out[t]||n.undirected&&n.undirected[t]||void 0;if(i)return i.key}areDirectedNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new b(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in n.in||t in n.out}areOutNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new b(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in n.out}areInNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new b(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type==="undirected"?!1:t in n.in}areUndirectedNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new b(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type==="directed"?!1:t in n.undirected}areNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new b(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&(t in n.in||t in n.out)||this.type!=="directed"&&t in n.undirected}areInboundNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new b(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in n.in||this.type!=="directed"&&t in n.undirected}areOutboundNeighbors(e,t){e=""+e,t=""+t;const n=this._nodes.get(e);if(!n)throw new b(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!=="undirected"&&t in n.out||this.type!=="directed"&&t in n.undirected}inDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree}outDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree}directedDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree}undirectedDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree}inboundDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=t.undirectedDegree),this.type!=="undirected"&&(n+=t.inDegree),n}outboundDegree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=t.undirectedDegree),this.type!=="undirected"&&(n+=t.outDegree),n}degree(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.degree: could not find the "${e}" node in the graph.`);let n=0;return this.type!=="directed"&&(n+=t.undirectedDegree),this.type!=="undirected"&&(n+=t.inDegree+t.outDegree),n}inDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(n+=t.inDegree,i+=t.directedLoops),n-i}outboundDegreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(n+=t.outDegree,i+=t.directedLoops),n-i}degreeWithoutSelfLoops(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,i=0;return this.type!=="directed"&&(n+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(n+=t.inDegree+t.outDegree,i+=t.directedLoops*2),n-i}source(e){e=""+e;const t=this._edges.get(e);if(!t)throw new b(`Graph.source: could not find the "${e}" edge in the graph.`);return t.source.key}target(e){e=""+e;const t=this._edges.get(e);if(!t)throw new b(`Graph.target: could not find the "${e}" edge in the graph.`);return t.target.key}extremities(e){e=""+e;const t=this._edges.get(e);if(!t)throw new b(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(e,t){e=""+e,t=""+t;const n=this._edges.get(t);if(!n)throw new b(`Graph.opposite: could not find the "${t}" edge in the graph.`);const i=n.source.key,o=n.target.key;if(e===i)return o;if(e===o)return i;throw new b(`Graph.opposite: the "${e}" node is not attached to the "${t}" edge (${i}, ${o}).`)}hasExtremity(e,t){e=""+e,t=""+t;const n=this._edges.get(e);if(!n)throw new b(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return n.source.key===t||n.target.key===t}isUndirected(e){e=""+e;const t=this._edges.get(e);if(!t)throw new b(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return t.undirected}isDirected(e){e=""+e;const t=this._edges.get(e);if(!t)throw new b(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!t.undirected}isSelfLoop(e){e=""+e;const t=this._edges.get(e);if(!t)throw new b(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return t.source===t.target}addNode(e,t){return qn(this,e,t).key}mergeNode(e,t){if(t&&!H(t))throw new _(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);e=""+e,t=t||{};let n=this._nodes.get(e);return n?(t&&(q(n.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:n.attributes,data:t})),[e,!1]):(n=new this.NodeDataClass(e,t),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:t}),[e,!0])}updateNode(e,t){if(t&&typeof t!="function")throw new _(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);e=""+e;let n=this._nodes.get(e);if(n){if(t){const o=n.attributes;n.attributes=t(o),this.emit("nodeAttributesUpdated",{type:"replace",key:e,attributes:n.attributes})}return[e,!1]}const i=t?t({}):{};return n=new this.NodeDataClass(e,i),this._nodes.set(e,n),this.emit("nodeAdded",{key:e,attributes:i}),[e,!0]}dropNode(e){e=""+e;const t=this._nodes.get(e);if(!t)throw new b(`Graph.dropNode: could not find the "${e}" node in the graph.`);let n;if(this.type!=="undirected"){for(const i in t.out){n=t.out[i];do le(this,n),n=n.next;while(n)}for(const i in t.in){n=t.in[i];do le(this,n),n=n.next;while(n)}}if(this.type!=="directed")for(const i in t.undirected){n=t.undirected[i];do le(this,n),n=n.next;while(n)}this._nodes.delete(e),this.emit("nodeDropped",{key:e,attributes:t.attributes})}dropEdge(e){let t;if(arguments.length>1){const n=""+arguments[0],i=""+arguments[1];if(t=J(this,n,i,this.type),!t)throw new b(`Graph.dropEdge: could not find the "${n}" -> "${i}" edge in the graph.`)}else if(e=""+e,t=this._edges.get(e),!t)throw new b(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return le(this,t),this}dropDirectedEdge(e,t){if(arguments.length<2)throw new $("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 $("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,t=""+t;const n=J(this,e,t,"directed");if(!n)throw new b(`Graph.dropDirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return le(this,n),this}dropUndirectedEdge(e,t){if(arguments.length<2)throw new $("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 $("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const n=J(this,e,t,"undirected");if(!n)throw new b(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return le(this,n),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const e=this._nodes.values();let t;for(;t=e.next(),t.done!==!0;)t.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,t){return this._attributes[e]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}updateAttribute(e,t){if(typeof t!="function")throw new _("Graph.updateAttribute: updater should be a function.");const n=this._attributes[e];return this._attributes[e]=t(n),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!H(e))throw new _("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(!H(e))throw new _("Graph.mergeAttributes: provided attributes are not a plain object.");return q(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!="function")throw new _("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,t){if(typeof e!="function")throw new _("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!it(t))throw new _("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const n=this._nodes.values();let i,o;for(;i=n.next(),i.done!==!0;)o=i.value,o.attributes=e(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})}updateEachEdgeAttributes(e,t){if(typeof e!="function")throw new _("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!it(t))throw new _("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const n=this._edges.values();let i,o,s,u;for(;i=n.next(),i.done!==!0;)o=i.value,s=o.source,u=o.target,o.attributes=e(o.key,o.attributes,s.key,u.key,s.attributes,u.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})}forEachAdjacencyEntry(e){if(typeof e!="function")throw new _("Graph.forEachAdjacencyEntry: expecting a callback.");Ue(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new _("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Ue(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!="function")throw new _("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Ue(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!="function")throw new _("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Ue(!1,!0,!0,this,e)}nodes(){return typeof Array.from=="function"?Array.from(this._nodes.keys()):gt(this._nodes.keys(),this._nodes.size)}forEachNode(e){if(typeof e!="function")throw new _("Graph.forEachNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)i=n.value,e(i.key,i.attributes)}findNode(e){if(typeof e!="function")throw new _("Graph.findNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)if(i=n.value,e(i.key,i.attributes))return i.key}mapNodes(e){if(typeof e!="function")throw new _("Graph.mapNode: expecting a callback.");const t=this._nodes.values();let n,i;const o=new Array(this.order);let s=0;for(;n=t.next(),n.done!==!0;)i=n.value,o[s++]=e(i.key,i.attributes);return o}someNode(e){if(typeof e!="function")throw new _("Graph.someNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)if(i=n.value,e(i.key,i.attributes))return!0;return!1}everyNode(e){if(typeof e!="function")throw new _("Graph.everyNode: expecting a callback.");const t=this._nodes.values();let n,i;for(;n=t.next(),n.done!==!0;)if(i=n.value,!e(i.key,i.attributes))return!1;return!0}filterNodes(e){if(typeof e!="function")throw new _("Graph.filterNodes: expecting a callback.");const t=this._nodes.values();let n,i;const o=[];for(;n=t.next(),n.done!==!0;)i=n.value,e(i.key,i.attributes)&&o.push(i.key);return o}reduceNodes(e,t){if(typeof e!="function")throw new _("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new _("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let n=t;const i=this._nodes.values();let o,s;for(;o=i.next(),o.done!==!0;)s=o.value,n=e(n,s.key,s.attributes);return n}nodeEntries(){const e=this._nodes.values();return new Q(()=>{const t=e.next();if(t.done)return t;const n=t.value;return{value:{node:n.key,attributes:n.attributes},done:!1}})}export(){const e=new Array(this._nodes.size);let t=0;this._nodes.forEach((i,o)=>{e[t++]=jn(o,i)});const n=new Array(this._edges.size);return t=0,this._edges.forEach((i,o)=>{n[t++]=zn(this.type,o,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:n}}import(e,t=!1){if(e instanceof W)return e.forEachNode((h,a)=>{t?this.mergeNode(h,a):this.addNode(h,a)}),e.forEachEdge((h,a,f,l,y,v,U)=>{t?U?this.mergeUndirectedEdgeWithKey(h,f,l,a):this.mergeDirectedEdgeWithKey(h,f,l,a):U?this.addUndirectedEdgeWithKey(h,f,l,a):this.addDirectedEdgeWithKey(h,f,l,a)}),this;if(!H(e))throw new _("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!H(e.attributes))throw new _("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(e.attributes):this.replaceAttributes(e.attributes)}let n,i,o,s,u;if(e.nodes){if(o=e.nodes,!Array.isArray(o))throw new _("Graph.import: invalid nodes. Expecting an array.");for(n=0,i=o.length;n<i;n++){s=o[n],Pn(s);const{key:h,attributes:a}=s;t?this.mergeNode(h,a):this.addNode(h,a)}}if(e.edges){let h=!1;if(this.type==="undirected"&&(h=!0),o=e.edges,!Array.isArray(o))throw new _("Graph.import: invalid edges. Expecting an array.");for(n=0,i=o.length;n<i;n++){u=o[n],Wn(u);const{source:a,target:f,attributes:l,undirected:y=h}=u;let v;"key"in u?(v=t?y?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:y?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,v.call(this,u.key,a,f,l)):(v=t?y?this.mergeUndirectedEdge:this.mergeDirectedEdge:y?this.addUndirectedEdge:this.addDirectedEdge,v.call(this,a,f,l))}}return this}nullCopy(e){const t=new W(q({},this._options,e));return t.replaceAttributes(q({},this.getAttributes())),t}emptyCopy(e){const t=this.nullCopy(e);return this._nodes.forEach((n,i)=>{const o=q({},n.attributes);n=new t.NodeDataClass(i,o),t._nodes.set(i,n)}),t}copy(e){if(e=e||{},typeof e.type=="string"&&e.type!==this.type&&e.type!=="mixed")throw new $(`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 $("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 $("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const t=this.emptyCopy(e),n=this._edges.values();let i,o;for(;i=n.next(),i.done!==!0;)o=i.value,$t(t,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,q({},o.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const e={};this._nodes.forEach((o,s)=>{e[s]=o.attributes});const t={},n={};this._edges.forEach((o,s)=>{const u=o.undirected?"--":"->";let h="",a=o.source.key,f=o.target.key,l;o.undirected&&a>f&&(l=a,a=f,f=l);const y=`(${a})${u}(${f})`;s.startsWith("geid_")?this.multi&&(typeof n[y]>"u"?n[y]=0:n[y]++,h+=`${n[y]}. `):h+=`[${s}]: `,h+=y,t[h]=o.attributes});const i={};for(const o in this)this.hasOwnProperty(o)&&!ot.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=e,i.edges=t,Z(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(W.prototype[Symbol.for("nodejs.util.inspect.custom")]=W.prototype.inspect);Fn.forEach(r=>{["add","merge","update"].forEach(e=>{const t=r.name(e),n=e==="add"?$t:Hn;r.generateKey?W.prototype[t]=function(i,o,s){return n(this,t,!0,(r.type||this.type)==="undirected",null,i,o,s,e==="update")}:W.prototype[t]=function(i,o,s,u){return n(this,t,!1,(r.type||this.type)==="undirected",i,o,s,u,e==="update")}})});Mt(W);cn(W);An(W);Tn(W);class kt extends W{constructor(e){const t=q({type:"directed"},e);if("multi"in t&&t.multi!==!1)throw new _("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new _('DirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Dt extends W{constructor(e){const t=q({type:"undirected"},e);if("multi"in t&&t.multi!==!1)throw new _("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new _('UndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class At extends W{constructor(e){const t=q({multi:!0},e);if("multi"in t&&t.multi!==!0)throw new _("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(t)}}class Lt extends W{constructor(e){const t=q({type:"directed",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new _("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new _('MultiDirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class St extends W{constructor(e){const t=q({type:"undirected",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new _("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new _('MultiUndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}function ge(r){r.from=function(e,t){const n=q({},e.options,t),i=new r(n);return i.import(e),i}}ge(W);ge(kt);ge(Dt);ge(At);ge(Lt);ge(St);W.Graph=W;W.DirectedGraph=kt;W.UndirectedGraph=Dt;W.MultiGraph=At;W.MultiDirectedGraph=Lt;W.MultiUndirectedGraph=St;W.InvalidArgumentsGraphError=_;W.NotFoundGraphError=b;W.UsageGraphError=$;var Fe,ut;function Nn(){return ut||(ut=1,Fe=function(e){return e!==null&&typeof e=="object"&&typeof e.addUndirectedEdgeWithKey=="function"&&typeof e.dropNode=="function"&&typeof e.multi=="boolean"}),Fe}var ve={},at;function Yn(){if(at)return ve;at=1;function r(n){return typeof n!="number"||isNaN(n)?1:n}function e(n,i){var o={},s=function(a){return typeof a>"u"?i:a};typeof i=="function"&&(s=i);var u=function(a){return s(a[n])},h=function(){return s(void 0)};return typeof n=="string"?(o.fromAttributes=u,o.fromGraph=function(a,f){return u(a.getNodeAttributes(f))},o.fromEntry=function(a,f){return u(f)}):typeof n=="function"?(o.fromAttributes=function(){throw new Error("graphology-utils/getters/createNodeValueGetter: irrelevant usage.")},o.fromGraph=function(a,f){return s(n(f,a.getNodeAttributes(f)))},o.fromEntry=function(a,f){return s(n(a,f))}):(o.fromAttributes=h,o.fromGraph=h,o.fromEntry=h),o}function t(n,i){var o={},s=function(a){return typeof a>"u"?i:a};typeof i=="function"&&(s=i);var u=function(a){return s(a[n])},h=function(){return s(void 0)};return typeof n=="string"?(o.fromAttributes=u,o.fromGraph=function(a,f){return u(a.getEdgeAttributes(f))},o.fromEntry=function(a,f){return u(f)},o.fromPartialEntry=o.fromEntry,o.fromMinimalEntry=o.fromEntry):typeof n=="function"?(o.fromAttributes=function(){throw new Error("graphology-utils/getters/createEdgeValueGetter: irrelevant usage.")},o.fromGraph=function(a,f){var l=a.extremities(f);return s(n(f,a.getEdgeAttributes(f),l[0],l[1],a.getNodeAttributes(l[0]),a.getNodeAttributes(l[1]),a.isUndirected(f)))},o.fromEntry=function(a,f,l,y,v,U,O){return s(n(a,f,l,y,v,U,O))},o.fromPartialEntry=function(a,f,l,y){return s(n(a,f,l,y))},o.fromMinimalEntry=function(a,f){return s(n(a,f))}):(o.fromAttributes=h,o.fromGraph=h,o.fromEntry=h,o.fromMinimalEntry=h),o}return ve.createNodeValueGetter=e,ve.createEdgeValueGetter=t,ve.createEdgeWeightGetter=function(n){return t(n,r)},ve}var Be,ht;function Vn(){if(ht)return Be;ht=1;var r=0,e=1,t=2,n=3,i=4,o=5,s=6,u=7,h=8,a=9,f=0,l=1,y=2,v=0,U=1,O=2,C=3,T=4,I=5,x=6,w=7,g=8,E=3,G=10,L=3,S=9,R=10;return Be=function(j,d,ae){var Ie,m,c,K,B,ie,he,N,A,Ce,M=d.length,Ut=ae.length,ye=j.adjustSizes,Ot=j.barnesHutTheta*j.barnesHutTheta,Ee,F,z,P,ee,D,k,p=[];for(c=0;c<M;c+=G)d[c+i]=d[c+t],d[c+o]=d[c+n],d[c+t]=0,d[c+n]=0;if(j.outboundAttractionDistribution){for(Ee=0,c=0;c<M;c+=G)Ee+=d[c+s];Ee/=M/G}if(j.barnesHutOptimize){var oe=1/0,de=-1/0,se=1/0,ce=-1/0,V,fe,Te;for(c=0;c<M;c+=G)oe=Math.min(oe,d[c+r]),de=Math.max(de,d[c+r]),se=Math.min(se,d[c+e]),ce=Math.max(ce,d[c+e]);var _e=de-oe,Ge=ce-se;for(_e>Ge?(se-=(_e-Ge)/2,ce=se+_e):(oe-=(Ge-_e)/2,de=oe+Ge),p[0+v]=-1,p[0+U]=(oe+de)/2,p[0+O]=(se+ce)/2,p[0+C]=Math.max(de-oe,ce-se),p[0+T]=-1,p[0+I]=-1,p[0+x]=0,p[0+w]=0,p[0+g]=0,Ie=1,c=0;c<M;c+=G)for(m=0,Te=E;;)if(p[m+I]>=0){d[c+r]<p[m+U]?d[c+e]<p[m+O]?V=p[m+I]:V=p[m+I]+S:d[c+e]<p[m+O]?V=p[m+I]+S*2:V=p[m+I]+S*3,p[m+w]=(p[m+w]*p[m+x]+d[c+r]*d[c+s])/(p[m+x]+d[c+s]),p[m+g]=(p[m+g]*p[m+x]+d[c+e]*d[c+s])/(p[m+x]+d[c+s]),p[m+x]+=d[c+s],m=V;continue}else if(p[m+v]<0){p[m+v]=c;break}else{if(p[m+I]=Ie*S,N=p[m+C]/2,A=p[m+I],p[A+v]=-1,p[A+U]=p[m+U]-N,p[A+O]=p[m+O]-N,p[A+C]=N,p[A+T]=A+S,p[A+I]=-1,p[A+x]=0,p[A+w]=0,p[A+g]=0,A+=S,p[A+v]=-1,p[A+U]=p[m+U]-N,p[A+O]=p[m+O]+N,p[A+C]=N,p[A+T]=A+S,p[A+I]=-1,p[A+x]=0,p[A+w]=0,p[A+g]=0,A+=S,p[A+v]=-1,p[A+U]=p[m+U]+N,p[A+O]=p[m+O]-N,p[A+C]=N,p[A+T]=A+S,p[A+I]=-1,p[A+x]=0,p[A+w]=0,p[A+g]=0,A+=S,p[A+v]=-1,p[A+U]=p[m+U]+N,p[A+O]=p[m+O]+N,p[A+C]=N,p[A+T]=p[m+T],p[A+I]=-1,p[A+x]=0,p[A+w]=0,p[A+g]=0,Ie+=4,d[p[m+v]+r]<p[m+U]?d[p[m+v]+e]<p[m+O]?V=p[m+I]:V=p[m+I]+S:d[p[m+v]+e]<p[m+O]?V=p[m+I]+S*2:V=p[m+I]+S*3,p[m+x]=d[p[m+v]+s],p[m+w]=d[p[m+v]+r],p[m+g]=d[p[m+v]+e],p[V+v]=p[m+v],p[m+v]=-1,d[c+r]<p[m+U]?d[c+e]<p[m+O]?fe=p[m+I]:fe=p[m+I]+S:d[c+e]<p[m+O]?fe=p[m+I]+S*2:fe=p[m+I]+S*3,V===fe)if(Te--){m=V;continue}else{Te=E;break}p[fe+v]=c;break}}if(j.barnesHutOptimize)for(F=j.scalingRatio,c=0;c<M;c+=G)for(m=0;;)if(p[m+I]>=0)if(D=Math.pow(d[c+r]-p[m+w],2)+Math.pow(d[c+e]-p[m+g],2),Ce=p[m+C],4*Ce*Ce/D<Ot){if(z=d[c+r]-p[m+w],P=d[c+e]-p[m+g],ye===!0?D>0?(k=F*d[c+s]*p[m+x]/D,d[c+t]+=z*k,d[c+n]+=P*k):D<0&&(k=-F*d[c+s]*p[m+x]/Math.sqrt(D),d[c+t]+=z*k,d[c+n]+=P*k):D>0&&(k=F*d[c+s]*p[m+x]/D,d[c+t]+=z*k,d[c+n]+=P*k),m=p[m+T],m<0)break;continue}else{m=p[m+I];continue}else{if(ie=p[m+v],ie>=0&&ie!==c&&(z=d[c+r]-d[ie+r],P=d[c+e]-d[ie+e],D=z*z+P*P,ye===!0?D>0?(k=F*d[c+s]*d[ie+s]/D,d[c+t]+=z*k,d[c+n]+=P*k):D<0&&(k=-F*d[c+s]*d[ie+s]/Math.sqrt(D),d[c+t]+=z*k,d[c+n]+=P*k):D>0&&(k=F*d[c+s]*d[ie+s]/D,d[c+t]+=z*k,d[c+n]+=P*k)),m=p[m+T],m<0)break;continue}else for(F=j.scalingRatio,K=0;K<M;K+=G)for(B=0;B<K;B+=G)z=d[K+r]-d[B+r],P=d[K+e]-d[B+e],ye===!0?(D=Math.sqrt(z*z+P*P)-d[K+h]-d[B+h],D>0?(k=F*d[K+s]*d[B+s]/D/D,d[K+t]+=z*k,d[K+n]+=P*k,d[B+t]-=z*k,d[B+n]-=P*k):D<0&&(k=100*F*d[K+s]*d[B+s],d[K+t]+=z*k,d[K+n]+=P*k,d[B+t]-=z*k,d[B+n]-=P*k)):(D=Math.sqrt(z*z+P*P),D>0&&(k=F*d[K+s]*d[B+s]/D/D,d[K+t]+=z*k,d[K+n]+=P*k,d[B+t]-=z*k,d[B+n]-=P*k));for(A=j.gravity/j.scalingRatio,F=j.scalingRatio,c=0;c<M;c+=G)k=0,z=d[c+r],P=d[c+e],D=Math.sqrt(Math.pow(z,2)+Math.pow(P,2)),j.strongGravityMode?D>0&&(k=F*d[c+s]*A):D>0&&(k=F*d[c+s]*A/D),d[c+t]-=z*k,d[c+n]-=P*k;for(F=1*(j.outboundAttractionDistribution?Ee:1),he=0;he<Ut;he+=L)K=ae[he+f],B=ae[he+l],N=ae[he+y],ee=Math.pow(N,j.edgeWeightInfluence),z=d[K+r]-d[B+r],P=d[K+e]-d[B+e],ye===!0?(D=Math.sqrt(z*z+P*P)-d[K+h]-d[B+h],j.linLogMode?j.outboundAttractionDistribution?D>0&&(k=-F*ee*Math.log(1+D)/D/d[K+s]):D>0&&(k=-F*ee*Math.log(1+D)/D):j.outboundAttractionDistribution?D>0&&(k=-F*ee/d[K+s]):D>0&&(k=-F*ee)):(D=Math.sqrt(Math.pow(z,2)+Math.pow(P,2)),j.linLogMode?j.outboundAttractionDistribution?D>0&&(k=-F*ee*Math.log(1+D)/D/d[K+s]):D>0&&(k=-F*ee*Math.log(1+D)/D):j.outboundAttractionDistribution?(D=1,k=-F*ee/d[K+s]):(D=1,k=-F*ee)),D>0&&(d[K+t]+=z*k,d[K+n]+=P*k,d[B+t]-=z*k,d[B+n]-=P*k);var $e,we,ke,ue,De,Ae;if(ye===!0)for(c=0;c<M;c+=G)d[c+a]!==1&&($e=Math.sqrt(Math.pow(d[c+t],2)+Math.pow(d[c+n],2)),$e>R&&(d[c+t]=d[c+t]*R/$e,d[c+n]=d[c+n]*R/$e),we=d[c+s]*Math.sqrt((d[c+i]-d[c+t])*(d[c+i]-d[c+t])+(d[c+o]-d[c+n])*(d[c+o]-d[c+n])),ke=Math.sqrt((d[c+i]+d[c+t])*(d[c+i]+d[c+t])+(d[c+o]+d[c+n])*(d[c+o]+d[c+n]))/2,ue=.1*Math.log(1+ke)/(1+Math.sqrt(we)),De=d[c+r]+d[c+t]*(ue/j.slowDown),d[c+r]=De,Ae=d[c+e]+d[c+n]*(ue/j.slowDown),d[c+e]=Ae);else for(c=0;c<M;c+=G)d[c+a]!==1&&(we=d[c+s]*Math.sqrt((d[c+i]-d[c+t])*(d[c+i]-d[c+t])+(d[c+o]-d[c+n])*(d[c+o]-d[c+n])),ke=Math.sqrt((d[c+i]+d[c+t])*(d[c+i]+d[c+t])+(d[c+o]+d[c+n])*(d[c+o]+d[c+n]))/2,ue=d[c+u]*Math.log(1+ke)/(1+Math.sqrt(we)),d[c+u]=Math.min(1,Math.sqrt(ue*(Math.pow(d[c+t],2)+Math.pow(d[c+n],2))/(1+Math.sqrt(we)))),De=d[c+r]+d[c+t]*(ue/j.slowDown),d[c+r]=De,Ae=d[c+e]+d[c+n]*(ue/j.slowDown),d[c+e]=Ae);return{}},Be}var te={},dt;function Zn(){if(dt)return te;dt=1;var r=10,e=3;return te.assign=function(t){t=t||{};var n=Array.prototype.slice.call(arguments).slice(1),i,o,s;for(i=0,s=n.length;i<s;i++)if(n[i])for(o in n[i])t[o]=n[i][o];return t},te.validateSettings=function(t){return"linLogMode"in t&&typeof t.linLogMode!="boolean"?{message:"the `linLogMode` setting should be a boolean."}:"outboundAttractionDistribution"in t&&typeof t.outboundAttractionDistribution!="boolean"?{message:"the `outboundAttractionDistribution` setting should be a boolean."}:"adjustSizes"in t&&typeof t.adjustSizes!="boolean"?{message:"the `adjustSizes` setting should be a boolean."}:"edgeWeightInfluence"in t&&typeof t.edgeWeightInfluence!="number"?{message:"the `edgeWeightInfluence` setting should be a number."}:"scalingRatio"in t&&!(typeof t.scalingRatio=="number"&&t.scalingRatio>=0)?{message:"the `scalingRatio` setting should be a number >= 0."}:"strongGravityMode"in t&&typeof t.strongGravityMode!="boolean"?{message:"the `strongGravityMode` setting should be a boolean."}:"gravity"in t&&!(typeof t.gravity=="number"&&t.gravity>=0)?{message:"the `gravity` setting should be a number >= 0."}:"slowDown"in t&&!(typeof t.slowDown=="number"||t.slowDown>=0)?{message:"the `slowDown` setting should be a number >= 0."}:"barnesHutOptimize"in t&&typeof t.barnesHutOptimize!="boolean"?{message:"the `barnesHutOptimize` setting should be a boolean."}:"barnesHutTheta"in t&&!(typeof t.barnesHutTheta=="number"&&t.barnesHutTheta>=0)?{message:"the `barnesHutTheta` setting should be a number >= 0."}:null},te.graphToByteArrays=function(t,n){var i=t.order,o=t.size,s={},u,h=new Float32Array(i*r),a=new Float32Array(o*e);return u=0,t.forEachNode(function(f,l){s[f]=u,h[u]=l.x,h[u+1]=l.y,h[u+2]=0,h[u+3]=0,h[u+4]=0,h[u+5]=0,h[u+6]=1,h[u+7]=1,h[u+8]=l.size||1,h[u+9]=l.fixed?1:0,u+=r}),u=0,t.forEachEdge(function(f,l,y,v,U,O,C){var T=s[y],I=s[v],x=n(f,l,y,v,U,O,C);h[T+6]+=x,h[I+6]+=x,a[u]=T,a[u+1]=I,a[u+2]=x,u+=e}),{nodes:h,edges:a}},te.assignLayoutChanges=function(t,n,i){var o=0;t.updateEachNodeAttributes(function(s,u){return u.x=n[o],u.y=n[o+1],o+=r,i?i(s,u):u})},te.readGraphPositions=function(t,n){var i=0;t.forEachNode(function(o,s){n[i]=s.x,n[i+1]=s.y,i+=r})},te.collectLayoutChanges=function(t,n,i){for(var o=t.nodes(),s={},u=0,h=0,a=n.length;u<a;u+=r){if(i){var f=Object.assign({},t.getNodeAttributes(o[h]));f.x=n[u],f.y=n[u+1],f=i(o[h],f),s[o[h]]={x:f.x,y:f.y}}else s[o[h]]={x:n[u],y:n[u+1]};h++}return s},te.createWorker=function(n){var i=window.URL||window.webkitURL,o=n.toString(),s=i.createObjectURL(new Blob(["("+o+").call(this);"],{type:"text/javascript"})),u=new Worker(s);return i.revokeObjectURL(s),u},te}var qe,ct;function Jn(){return ct||(ct=1,qe={linLogMode:!1,outboundAttractionDistribution:!1,adjustSizes:!1,edgeWeightInfluence:1,scalingRatio:1,strongGravityMode:!1,gravity:1,slowDown:1,barnesHutOptimize:!1,barnesHutTheta:.5}),qe}var He,ft;function Qn(){if(ft)return He;ft=1;var r=Nn(),e=Yn().createEdgeWeightGetter,t=Vn(),n=Zn(),i=Jn();function o(h,a,f){if(!r(a))throw new Error("graphology-layout-forceatlas2: the given graph is not a valid graphology instance.");typeof f=="number"&&(f={iterations:f});var l=f.iterations;if(typeof l!="number")throw new Error("graphology-layout-forceatlas2: invalid number of iterations.");if(l<=0)throw new Error("graphology-layout-forceatlas2: you should provide a positive number of iterations.");var y=e("getEdgeWeight"in f?f.getEdgeWeight:"weight").fromEntry,v=typeof f.outputReducer=="function"?f.outputReducer:null,U=n.assign({},i,f.settings),O=n.validateSettings(U);if(O)throw new Error("graphology-layout-forceatlas2: "+O.message);var C=n.graphToByteArrays(a,y),T;for(T=0;T<l;T++)t(U,C.nodes,C.edges);if(h){n.assignLayoutChanges(a,C.nodes,v);return}return n.collectLayoutChanges(a,C.nodes)}function s(h){var a=typeof h=="number"?h:h.order;return{barnesHutOptimize:a>2e3,strongGravityMode:!0,gravity:.05,scalingRatio:10,slowDown:1+Math.log(a)}}var u=o.bind(null,!1);return u.assign=o.bind(null,!0),u.inferSettings=s,He=u,He}var Xn=Qn(),lt=Oe(Xn);function Qe(r){return typeof r=="object"&&r!==null}function Mn(r){return Qe(r)&&typeof r.id=="string"&&typeof r.x=="number"&&typeof r.y=="number"}function er(r){return Qe(r)&&typeof r.source=="string"&&typeof r.target=="string"}function tr(r){return Qe(r)&&Array.isArray(r.nodes)&&r.nodes.every(Mn)&&Array.isArray(r.edges)&&r.edges.every(er)&&typeof r.iterations=="number"&&Number.isFinite(r.iterations)&&r.iterations>=0}function nr(r,e){return r===""||r===e}self.onmessage=r=>{if(!nr(r.origin,self.location.origin)||!tr(r.data))return;const{nodes:e,edges:t,iterations:n}=r.data,i=new W({multi:!0});for(const h of e)i.addNode(h.id,{x:h.x,y:h.y,size:1});for(const h of t)i.hasNode(h.source)&&i.hasNode(h.target)&&i.addEdge(h.source,h.target);const o=lt.inferSettings(i);lt.assign(i,{iterations:n,settings:o});const s={};i.forEachNode((h,a)=>{s[h]={x:a.x,y:a.y}});const u={positions:s};self.postMessage(u)};