UNPKG

phaser4-rex-plugins

Version:
1 lines 1.7 MB
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n="undefined"!=typeof globalThis?globalThis:n||self).rexgraphplugin=t()}(void 0,(function(){class n{constructor(n){this.scene=n,n.sys.events.once("destroy",this.destroy,this)}destroy(){this.scene=null}static register(t,e){n.prototype[t]=e}}var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var i={exports:{}};!function(n){var t=Object.prototype.hasOwnProperty,e="~";function i(){}function r(n,t,e){this.fn=n,this.context=t,this.once=e||!1}function a(n,t,i,a,c){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new r(i,a||n,c),u=e?e+t:t;return n._events[u]?n._events[u].fn?n._events[u]=[n._events[u],o]:n._events[u].push(o):(n._events[u]=o,n._eventsCount++),n}function c(n,t){0==--n._eventsCount?n._events=new i:delete n._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(e=!1)),o.prototype.eventNames=function(){var n,i,r=[];if(0===this._eventsCount)return r;for(i in n=this._events)t.call(n,i)&&r.push(e?i.slice(1):i);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(n)):r},o.prototype.listeners=function(n){var t=e?e+n:n,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var r=0,a=i.length,c=new Array(a);r<a;r++)c[r]=i[r].fn;return c},o.prototype.listenerCount=function(n){var t=e?e+n:n,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(n,t,i,r,a,c){var o=e?e+n:n;if(!this._events[o])return!1;var u,s,h=this._events[o],f=arguments.length;if(h.fn){switch(h.once&&this.removeListener(n,h.fn,void 0,!0),f){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,t),!0;case 3:return h.fn.call(h.context,t,i),!0;case 4:return h.fn.call(h.context,t,i,r),!0;case 5:return h.fn.call(h.context,t,i,r,a),!0;case 6:return h.fn.call(h.context,t,i,r,a,c),!0}for(s=1,u=new Array(f-1);s<f;s++)u[s-1]=arguments[s];h.fn.apply(h.context,u)}else{var l,b=h.length;for(s=0;s<b;s++)switch(h[s].once&&this.removeListener(n,h[s].fn,void 0,!0),f){case 1:h[s].fn.call(h[s].context);break;case 2:h[s].fn.call(h[s].context,t);break;case 3:h[s].fn.call(h[s].context,t,i);break;case 4:h[s].fn.call(h[s].context,t,i,r);break;default:if(!u)for(l=1,u=new Array(f-1);l<f;l++)u[l-1]=arguments[l];h[s].fn.apply(h[s].context,u)}}return!0},o.prototype.on=function(n,t,e){return a(this,n,t,e,!1)},o.prototype.once=function(n,t,e){return a(this,n,t,e,!0)},o.prototype.removeListener=function(n,t,i,r){var a=e?e+n:n;if(!this._events[a])return this;if(!t)return c(this,a),this;var o=this._events[a];if(o.fn)o.fn!==t||r&&!o.once||i&&o.context!==i||c(this,a);else{for(var u=0,s=[],h=o.length;u<h;u++)(o[u].fn!==t||r&&!o[u].once||i&&o[u].context!==i)&&s.push(o[u]);s.length?this._events[a]=1===s.length?s[0]:s:c(this,a)}return this},o.prototype.removeAllListeners=function(n){var t;return n?(t=e?e+n:n,this._events[t]&&c(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,n.exports=o}(i);var r=e(i.exports);class a extends r{shutdown(){this.removeAllListeners()}destroy(){this.removeAllListeners()}}var c=function(n,t,e){if(!n||"number"==typeof n)return e;if("string"==typeof t){if(n.hasOwnProperty(t))return n[t];if(-1===t.indexOf("."))return e;t=t.split(".")}for(var i=t,r=n,a=e,c=0;c<i.length;c++){if(t=i[c],!r.hasOwnProperty(t)){a=e;break}r=a=r[t]}return a};var o=new class{constructor(n){this.nextId=c(n,"start",1),this.uidKey=c(n,"uidKey","$uid"),this.autoRemove=c(n,"remove",!0),this.refs={},this.count=0}add(n,t){var e=this.refs,i=this.uidKey;if(i&&n.hasOwnProperty("uidKey")&&null!=n[i])return this;if(null==t)do{t=this.nextId,this.nextId++}while(e.hasOwnProperty(t));return e.hasOwnProperty(t)?t=null:(e[t]=n,this.count++,i&&(n[i]=t),this.autoRemove&&n.on&&n.once("destroy",(function(){this.remove(t)}),this)),i?this:t}addMultiple(n){for(var t=0,e=n.length;t<e;t++)this.add(n[t]);return this}get(n){return this.refs[n]}has(n){return this.refs.hasOwnProperty(n)}remove(n){var t=this.refs;if(t.hasOwnProperty(n)){if(this.uidKey)t[n][this.uidKey]=void 0;delete t[n],this.count--}return this}forEach(n,t){var e,i=this.refs;for(var r in i)e=i[r],t?n.call(t,e,r):n(e,r)}clear(){this.forEach((function(n){this.remove(n)}),this)}}({uidKey:"$uid",remove:!1}),u={setEventEmitter(n,t){return void 0===t&&(t=Phaser.Events.EventEmitter),this._privateEE=!0===n||void 0===n,this._eventEmitter=this._privateEE?new t:n,this},destroyEventEmitter(){return this._eventEmitter&&this._privateEE&&this._eventEmitter.shutdown(),this},getEventEmitter(){return this._eventEmitter},on(){return this._eventEmitter&&this._eventEmitter.on.apply(this._eventEmitter,arguments),this},once(){return this._eventEmitter&&this._eventEmitter.once.apply(this._eventEmitter,arguments),this},off(){return this._eventEmitter&&this._eventEmitter.off.apply(this._eventEmitter,arguments),this},emit(n){return this._eventEmitter&&n&&this._eventEmitter.emit.apply(this._eventEmitter,arguments),this},addListener(){return this._eventEmitter&&this._eventEmitter.addListener.apply(this._eventEmitter,arguments),this},removeListener(){return this._eventEmitter&&this._eventEmitter.removeListener.apply(this._eventEmitter,arguments),this},removeAllListeners(){return this._eventEmitter&&this._eventEmitter.removeAllListeners.apply(this._eventEmitter,arguments),this},listenerCount(){return this._eventEmitter?this._eventEmitter.listenerCount.apply(this._eventEmitter,arguments):0},listeners(){return this._eventEmitter?this._eventEmitter.listeners.apply(this._eventEmitter,arguments):[]},eventNames(){return this._eventEmitter?this._eventEmitter.eventNames.apply(this._eventEmitter,arguments):[]}};const s=Phaser.Scene;var h=function(n){return n instanceof s};const f=Phaser.Game;var l=function(n){return n instanceof f};const b=Phaser.Utils.Objects.GetValue;class d{constructor(n,t){this.setParent(n),this.isShutdown=!1,this.setEventEmitter(b(t,"eventEmitter",!0)),this.parent&&(this.parent===this.scene?this.scene.sys.events.once("shutdown",this.onEnvDestroy,this):this.parent===this.game?this.game.events.once("shutdown",this.onEnvDestroy,this):this.parent.once&&this.parent.once("destroy",this.onParentDestroy,this))}shutdown(n){this.isShutdown||(this.parent&&(this.parent===this.scene?this.scene.sys.events.off("shutdown",this.onEnvDestroy,this):this.parent===this.game?this.game.events.off("shutdown",this.onEnvDestroy,this):this.parent.once&&this.parent.off("destroy",this.onParentDestroy,this)),this.destroyEventEmitter(),this.parent=void 0,this.scene=void 0,this.game=void 0,this.isShutdown=!0)}destroy(n){this.shutdown(n)}onEnvDestroy(){this.destroy(!0)}onParentDestroy(n,t){this.destroy(t)}setParent(n){var t;return this.parent=n,this.scene=null==(t=n)||"object"!=typeof t?null:h(t)?t:t.scene&&h(t.scene)?t.scene:t.parent&&t.parent.scene&&h(t.parent.scene)?t.parent.scene:null,this.game=function(n){return null==n||"object"!=typeof n?null:l(n)?n:l(n.game)?n.game:h(n)?n.sys.game:h(n.scene)?n.scene.sys.game:void 0}(n),this}}Object.assign(d.prototype,u);const w=o.uidKey;class g extends d{constructor(n,t){super(n,{eventEmitter:!1}),o.add(this,t),this.graph=null}shutdown(n){this.isShutdown||(this.graph&&this.graph.remove(this[w]),o.remove(this[w]),this.setGraph(null),super.shutdown(n))}setGraph(n){return this.graph=n,this}get isNode(){return!!this.graph&&this.graph.hasNode(this[w])}get isEdge(){return!!this.graph&&this.graph.hasEdge(this[w])}}Object.assign(g.prototype,{});var p=function(n){var t=typeof n;return"number"===t||"string"===t},v=function(n,t){return p(n)?o.get(n):(n.hasOwnProperty("rexGraph")||(n.rexGraph=new g(n,t)),n.rexGraph)};const m=o.uidKey;var y=function(n,t){return void 0===t&&(t=!0),p(n)?n:n.hasOwnProperty("rexGraph")?n.rexGraph[m]:t?v(n)[m]:null},k={isNode(n){var t=y(n,!1);return null!==t&&this.graph.hasNode(t)},addNode(n,t,e){return this.isNode(n)||(v(n,e).setGraph(this),void 0===e&&(e=y(n)),this.graph.addNode(e,t)),this},addNodes(n,t){for(var e=0,i=n.length;e<i;e++)this.addNode(n[e],{...t});return this}},E={removeNode(n,t){if(!this.isNode(n))return this;void 0===t&&(t=!1);var e=y(n);return this.graph.dropNode(e),v(n).setGraph(null),t&&n.destroy&&n.destroy(),this},removeAllNodes(n){for(var t in this.nodes)this.removeNode(t,n);return this}},j=function(n){return null==n?null:o.get(n).parent},S={getAllNodes(n){return void 0===n&&(n=[]),this.graph.forEachNode((function(t){var e=j(t);e&&n.push(e)})),n},getNodesOfEdge(n,t){void 0===t&&(t=[]);var e=y(n);return this.graph.hasEdge(e)?function(n,t){void 0===t&&(t=[]);for(var e=0,i=n.length;e<i;e++){var r=o.get(n[e]);r&&r.parent&&t.push(r.parent)}return t}([this.graph.source(e),this.graph.target(e)],t):t},getOppositeNode(n,t){var e=this.getNodesOfEdge(t);if(!(e.length<2))return n===e[0]?e[1]:e[0]}},M={areNeighborNodes(n,t){var e=y(n),i=y(t);return!(!e||!i)&&this.graph.areNeighbors(e,i)},getNeighborNodes(n,t){void 0===t&&(t=[]);var e=y(n);return e?(this.graph.forEachNeighbor(e,(function(n){var e=j(n);e&&t.push(e)})),t):t}};const T=Phaser.Utils.Objects.IsPlainObject;var P={getNodeAttribute(n,t){var e=y(n);return void 0===t?this.graph.getNodeAttributes(e):this.graph.getNodeAttribute(e,t)},setNodeAttribute(n,t,e){var i=y(n);if(T(t)){var r=t;for(var t in r)this.graph.setNodeAttribute(i,t,r[t])}else this.graph.setNodeAttribute(i,t,e);return this},setNodesAttribute(n,t,e){for(var i=0,r=n.length;i<r;i++)this.setNodeAttribute(n[i],t,e);return this}};Phaser.Utils.Objects.IsPlainObject;const O={"->":1,"<-":2,"<->":3};var C={isEdge(n){var t=y(n,!1);return null!==t&&this.graph.hasEdge(t)},addEdge(n,t,e,i,r,a){if(this.isEdge(n))return this;void 0===i?i=3:"string"==typeof i&&(i=O[i]),"string"!=typeof t&&this.addNode(t),"string"!=typeof e&&this.addNode(e),v(n,a).setGraph(this);a=y(n);var c=y(t),o=y(e);if(!a||!c||!o)return this;switch(i){case 1:this.graph.addDirectedEdgeWithKey(a,c,o,r);break;case 2:this.graph.addDirectedEdgeWithKey(a,o,c,r);break;default:this.graph.addUndirectedEdgeWithKey(a,c,o,r)}return this}},A={removeEdge(n,t){if(!this.isEdge(n))return this;void 0===t&&(t=!1);var e=y(n);return this.graph.dropEdge(e),v(n).setGraph(null),t&&n.destroy&&n.destroy(),this},removeAllEdges(n){for(var t in this.edges)this.removeEdge(t,n);return this}},I={getAllEdges(n){return void 0===n&&(n=[]),this.graph.forEachEdge((function(t){var e=j(t);e&&n.push(e)})),n},getEdgesOfNode(n,t){void 0===t&&(t=[]);var e=y(n);return this.graph.forEachEdge(e,(function(n){var e=j(n);e&&t.push(e)})),t}};const L=Phaser.Utils.Objects.IsPlainObject;var N={getEdgeAttribute(n,t){var e=y(n);return void 0===t?this.graph.getEdgeAttributes(e):this.graph.getEdgeAttribute(e,t)},setEdgeAttribute(n,t,e){var i=y(n);return L(t)?this.graph.updateEdgeAttribute(i,t):this.graph.setEdgeAttribute(i,t,e)},setEdgesAttribute(n,t,e){for(var i=0,r=n.length;i<r;i++)this.setEdgeAttribute(n[i],t,e);return this}},_={getEdgeLength:function(n){var t,e,i,r,a=this.getNodesOfEdge(n);return a.length<2?0:(t=a[0],e=a[1],i=t.x-e.x,r=t.y-e.y,Math.sqrt(i*i+r*r))}};Object.assign(_,k,E,S,M,P,C,A,I,N);var x={exports:{}};!function(n){n.exports=function(){function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(t)}function t(n,t){n.prototype=Object.create(t.prototype),n.prototype.constructor=n,i(n,t)}function e(n){return e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},e(n)}function i(n,t){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,t){return n.__proto__=t,n},i(n,t)}function r(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(n){return!1}}function a(n,t,e){return a=r()?Reflect.construct.bind():function(n,t,e){var r=[null];r.push.apply(r,t);var a=new(Function.bind.apply(n,r));return e&&i(a,e.prototype),a},a.apply(null,arguments)}function c(n){var t="function"==typeof Map?new Map:void 0;return c=function(n){if(null===n||(r=n,-1===Function.toString.call(r).indexOf("[native code]")))return n;var r;if("function"!=typeof n)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(n))return t.get(n);t.set(n,c)}function c(){return a(n,arguments,e(this).constructor)}return c.prototype=Object.create(n.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),i(c,n)},c(n)}function o(n){if(void 0===n)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}var u=function(){for(var n=arguments[0],t=1,e=arguments.length;t<e;t++)if(arguments[t])for(var i in arguments[t])n[i]=arguments[t][i];return n};function s(n,t,e,i){var r=n._nodes.get(t),a=null;return r?a="mixed"===i?r.out&&r.out[e]||r.undirected&&r.undirected[e]:"directed"===i?r.out&&r.out[e]:r.undirected&&r.undirected[e]:a}function h(t){return"object"===n(t)&&null!==t}function f(n){var t;for(t in n)return!1;return!0}function l(n,t,e){Object.defineProperty(n,t,{enumerable:!1,configurable:!1,writable:!0,value:e})}function b(n,t,e){var i={enumerable:!0,configurable:!0};"function"==typeof e?i.get=e:(i.value=e,i.writable=!1),Object.defineProperty(n,t,i)}function d(n){return!(!h(n)||n.attributes&&!Array.isArray(n.attributes))}"function"==typeof Object.assign&&(u=Object.assign);var w,g={exports:{}},p="object"==typeof Reflect?Reflect:null,v=p&&"function"==typeof p.apply?p.apply:function(n,t,e){return Function.prototype.apply.call(n,t,e)};w=p&&"function"==typeof p.ownKeys?p.ownKeys:Object.getOwnPropertySymbols?function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:function(n){return Object.getOwnPropertyNames(n)};var m=Number.isNaN||function(n){return n!=n};function y(){y.init.call(this)}g.exports=y,g.exports.once=function(n,t){return new Promise((function(e,i){function r(e){n.removeListener(t,a),i(e)}function a(){"function"==typeof n.removeListener&&n.removeListener("error",r),e([].slice.call(arguments))}A(n,t,a,{once:!0}),"error"!==t&&function(n,t,e){"function"==typeof n.on&&A(n,"error",t,e)}(n,r,{once:!0})}))},y.EventEmitter=y,y.prototype._events=void 0,y.prototype._eventsCount=0,y.prototype._maxListeners=void 0;var k=10;function E(n){if("function"!=typeof n)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}function j(n){return void 0===n._maxListeners?y.defaultMaxListeners:n._maxListeners}function S(n,t,e,i){var r,a,c,o;if(E(e),void 0===(a=n._events)?(a=n._events=Object.create(null),n._eventsCount=0):(void 0!==a.newListener&&(n.emit("newListener",t,e.listener?e.listener:e),a=n._events),c=a[t]),void 0===c)c=a[t]=e,++n._eventsCount;else if("function"==typeof c?c=a[t]=i?[e,c]:[c,e]:i?c.unshift(e):c.push(e),(r=j(n))>0&&c.length>r&&!c.warned){c.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+c.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=n,u.type=t,u.count=c.length,o=u,console&&console.warn&&console.warn(o)}return n}function M(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function T(n,t,e){var i={fired:!1,wrapFn:void 0,target:n,type:t,listener:e},r=M.bind(i);return r.listener=e,i.wrapFn=r,r}function P(n,t,e){var i=n._events;if(void 0===i)return[];var r=i[t];return void 0===r?[]:"function"==typeof r?e?[r.listener||r]:[r]:e?function(n){for(var t=new Array(n.length),e=0;e<t.length;++e)t[e]=n[e].listener||n[e];return t}(r):C(r,r.length)}function O(n){var t=this._events;if(void 0!==t){var e=t[n];if("function"==typeof e)return 1;if(void 0!==e)return e.length}return 0}function C(n,t){for(var e=new Array(t),i=0;i<t;++i)e[i]=n[i];return e}function A(n,t,e,i){if("function"==typeof n.on)i.once?n.once(t,e):n.on(t,e);else{if("function"!=typeof n.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n);n.addEventListener(t,(function r(a){i.once&&n.removeEventListener(t,r),e(a)}))}}function I(n){if("function"!=typeof n)throw new Error("obliterator/iterator: expecting a function!");this.next=n}Object.defineProperty(y,"defaultMaxListeners",{enumerable:!0,get:function(){return k},set:function(n){if("number"!=typeof n||n<0||m(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");k=n}}),y.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},y.prototype.setMaxListeners=function(n){if("number"!=typeof n||n<0||m(n))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".");return this._maxListeners=n,this},y.prototype.getMaxListeners=function(){return j(this)},y.prototype.emit=function(n){for(var t=[],e=1;e<arguments.length;e++)t.push(arguments[e]);var i="error"===n,r=this._events;if(void 0!==r)i=i&&void 0===r.error;else if(!i)return!1;if(i){var a;if(t.length>0&&(a=t[0]),a instanceof Error)throw a;var c=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw c.context=a,c}var o=r[n];if(void 0===o)return!1;if("function"==typeof o)v(o,this,t);else{var u=o.length,s=C(o,u);for(e=0;e<u;++e)v(s[e],this,t)}return!0},y.prototype.addListener=function(n,t){return S(this,n,t,!1)},y.prototype.on=y.prototype.addListener,y.prototype.prependListener=function(n,t){return S(this,n,t,!0)},y.prototype.once=function(n,t){return E(t),this.on(n,T(this,n,t)),this},y.prototype.prependOnceListener=function(n,t){return E(t),this.prependListener(n,T(this,n,t)),this},y.prototype.removeListener=function(n,t){var e,i,r,a,c;if(E(t),void 0===(i=this._events))return this;if(void 0===(e=i[n]))return this;if(e===t||e.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete i[n],i.removeListener&&this.emit("removeListener",n,e.listener||t));else if("function"!=typeof e){for(r=-1,a=e.length-1;a>=0;a--)if(e[a]===t||e[a].listener===t){c=e[a].listener,r=a;break}if(r<0)return this;0===r?e.shift():function(n,t){for(;t+1<n.length;t++)n[t]=n[t+1];n.pop()}(e,r),1===e.length&&(i[n]=e[0]),void 0!==i.removeListener&&this.emit("removeListener",n,c||t)}return this},y.prototype.off=y.prototype.removeListener,y.prototype.removeAllListeners=function(n){var t,e,i;if(void 0===(e=this._events))return this;if(void 0===e.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==e[n]&&(0==--this._eventsCount?this._events=Object.create(null):delete e[n]),this;if(0===arguments.length){var r,a=Object.keys(e);for(i=0;i<a.length;++i)"removeListener"!==(r=a[i])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=e[n]))this.removeListener(n,t);else if(void 0!==t)for(i=t.length-1;i>=0;i--)this.removeListener(n,t[i]);return this},y.prototype.listeners=function(n){return P(this,n,!0)},y.prototype.rawListeners=function(n){return P(this,n,!1)},y.listenerCount=function(n,t){return"function"==typeof n.listenerCount?n.listenerCount(t):O.call(n,t)},y.prototype.listenerCount=O,y.prototype.eventNames=function(){return this._eventsCount>0?w(this._events):[]},"undefined"!=typeof Symbol&&(I.prototype[Symbol.iterator]=function(){return this}),I.of=function(){var n=arguments,t=n.length,e=0;return new I((function(){return e>=t?{done:!0}:{done:!1,value:n[e++]}}))},I.empty=function(){return new I((function(){return{done:!0}}))},I.fromSequence=function(n){var t=0,e=n.length;return new I((function(){return t>=e?{done:!0}:{done:!1,value:n[t++]}}))},I.is=function(n){return n instanceof I||"object"==typeof n&&null!==n&&"function"==typeof n.next};var L=I,N={};N.ARRAY_BUFFER_SUPPORT="undefined"!=typeof ArrayBuffer,N.SYMBOL_SUPPORT="undefined"!=typeof Symbol;var _=L,x=N,D=x.ARRAY_BUFFER_SUPPORT,$=x.SYMBOL_SUPPORT,R=function(n){var t=function(n){return"string"==typeof n||Array.isArray(n)||D&&ArrayBuffer.isView(n)?_.fromSequence(n):"object"!=typeof n||null===n?null:$&&"function"==typeof n[Symbol.iterator]?n[Symbol.iterator]():"function"==typeof n.next?n:null}(n);if(!t)throw new Error("obliterator: target is not iterable nor a valid iterator.");return t},K=R,F=function(n,t){for(var e,i=arguments.length>1?t:1/0,r=i!==1/0?new Array(i):[],a=0,c=K(n);;){if(a===i)return r;if((e=c.next()).done)return a!==t&&(r.length=a),r;r[a++]=e.value}},B=function(n){function e(t){var e;return(e=n.call(this)||this).name="GraphError",e.message=t,e}return t(e,n),e}(c(Error)),G=function(n){function e(t){var i;return(i=n.call(this,t)||this).name="InvalidArgumentsGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(o(i),e.prototype.constructor),i}return t(e,n),e}(B),H=function(n){function e(t){var i;return(i=n.call(this,t)||this).name="NotFoundGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(o(i),e.prototype.constructor),i}return t(e,n),e}(B),U=function(n){function e(t){var i;return(i=n.call(this,t)||this).name="UsageGraphError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(o(i),e.prototype.constructor),i}return t(e,n),e}(B);function q(n,t){this.key=n,this.attributes=t,this.clear()}function z(n,t){this.key=n,this.attributes=t,this.clear()}function W(n,t){this.key=n,this.attributes=t,this.clear()}function X(n,t,e,i,r){this.key=t,this.attributes=r,this.undirected=n,this.source=e,this.target=i}function V(n,t,e,i,r,a,c){var o,u,s,h;if(i=""+i,0===e){if(!(o=n._nodes.get(i)))throw new H("Graph.".concat(t,': could not find the "').concat(i,'" node in the graph.'));s=r,h=a}else if(3===e){if(r=""+r,!(u=n._edges.get(r)))throw new H("Graph.".concat(t,': could not find the "').concat(r,'" edge in the graph.'));var f=u.source.key,l=u.target.key;if(i===f)o=u.target;else{if(i!==l)throw new H("Graph.".concat(t,': the "').concat(i,'" node is not attached to the "').concat(r,'" edge (').concat(f,", ").concat(l,")."));o=u.source}s=a,h=c}else{if(!(u=n._edges.get(i)))throw new H("Graph.".concat(t,': could not find the "').concat(i,'" edge in the graph.'));o=1===e?u.source:u.target,s=r,h=a}return[o,s,h]}q.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}},z.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}},W.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}},X.prototype.attach=function(){var n="out",t="in";this.undirected&&(n=t="undirected");var e=this.source.key,i=this.target.key;this.source[n][i]=this,this.undirected&&e===i||(this.target[t][e]=this)},X.prototype.attachMulti=function(){var n="out",t="in",e=this.source.key,i=this.target.key;this.undirected&&(n=t="undirected");var r=this.source[n],a=r[i];if(void 0===a)return r[i]=this,void(this.undirected&&e===i||(this.target[t][e]=this));a.previous=this,this.next=a,r[i]=this,this.target[t][e]=this},X.prototype.detach=function(){var n=this.source.key,t=this.target.key,e="out",i="in";this.undirected&&(e=i="undirected"),delete this.source[e][t],delete this.target[i][n]},X.prototype.detachMulti=function(){var n=this.source.key,t=this.target.key,e="out",i="in";this.undirected&&(e=i="undirected"),void 0===this.previous?void 0===this.next?(delete this.source[e][t],delete this.target[i][n]):(this.next.previous=void 0,this.source[e][t]=this.next,this.target[i][n]=this.next):(this.previous.next=this.next,void 0!==this.next&&(this.next.previous=this.previous))};var Q=[{name:function(n){return"get".concat(n,"Attribute")},attacher:function(n,t,e){n.prototype[t]=function(n,i,r){var a=V(this,t,e,n,i,r),c=a[0],o=a[1];return c.attributes[o]}}},{name:function(n){return"get".concat(n,"Attributes")},attacher:function(n,t,e){n.prototype[t]=function(n,i){return V(this,t,e,n,i)[0].attributes}}},{name:function(n){return"has".concat(n,"Attribute")},attacher:function(n,t,e){n.prototype[t]=function(n,i,r){var a=V(this,t,e,n,i,r),c=a[0],o=a[1];return c.attributes.hasOwnProperty(o)}}},{name:function(n){return"set".concat(n,"Attribute")},attacher:function(n,t,e){n.prototype[t]=function(n,i,r,a){var c=V(this,t,e,n,i,r,a),o=c[0],u=c[1],s=c[2];return o.attributes[u]=s,this.emit("nodeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:u}),this}}},{name:function(n){return"update".concat(n,"Attribute")},attacher:function(n,t,e){n.prototype[t]=function(n,i,r,a){var c=V(this,t,e,n,i,r,a),o=c[0],u=c[1],s=c[2];if("function"!=typeof s)throw new G("Graph.".concat(t,": updater should be a function."));var h=o.attributes,f=s(h[u]);return h[u]=f,this.emit("nodeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:u}),this}}},{name:function(n){return"remove".concat(n,"Attribute")},attacher:function(n,t,e){n.prototype[t]=function(n,i,r){var a=V(this,t,e,n,i,r),c=a[0],o=a[1];return delete c.attributes[o],this.emit("nodeAttributesUpdated",{key:c.key,type:"remove",attributes:c.attributes,name:o}),this}}},{name:function(n){return"replace".concat(n,"Attributes")},attacher:function(n,t,e){n.prototype[t]=function(n,i,r){var a=V(this,t,e,n,i,r),c=a[0],o=a[1];if(!h(o))throw new G("Graph.".concat(t,": provided attributes are not a plain object."));return c.attributes=o,this.emit("nodeAttributesUpdated",{key:c.key,type:"replace",attributes:c.attributes}),this}}},{name:function(n){return"merge".concat(n,"Attributes")},attacher:function(n,t,e){n.prototype[t]=function(n,i,r){var a=V(this,t,e,n,i,r),c=a[0],o=a[1];if(!h(o))throw new G("Graph.".concat(t,": provided attributes are not a plain object."));return u(c.attributes,o),this.emit("nodeAttributesUpdated",{key:c.key,type:"merge",attributes:c.attributes,data:o}),this}}},{name:function(n){return"update".concat(n,"Attributes")},attacher:function(n,t,e){n.prototype[t]=function(n,i,r){var a=V(this,t,e,n,i,r),c=a[0],o=a[1];if("function"!=typeof o)throw new G("Graph.".concat(t,": provided updater is not a function."));return c.attributes=o(c.attributes),this.emit("nodeAttributesUpdated",{key:c.key,type:"update",attributes:c.attributes}),this}}}],J=[{name:function(n){return"get".concat(n,"Attribute")},attacher:function(n,t,e){n.prototype[t]=function(n,i){var r;if("mixed"!==this.type&&"mixed"!==e&&e!==this.type)throw new U("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new U("Graph.".concat(t,": 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."));var a=""+n,c=""+i;if(i=arguments[2],!(r=s(this,a,c,e)))throw new H("Graph.".concat(t,': could not find an edge for the given path ("').concat(a,'" - "').concat(c,'").'))}else{if("mixed"!==e)throw new U("Graph.".concat(t,": 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,!(r=this._edges.get(n)))throw new H("Graph.".concat(t,': could not find the "').concat(n,'" edge in the graph.'))}return r.attributes[i]}}},{name:function(n){return"get".concat(n,"Attributes")},attacher:function(n,t,e){n.prototype[t]=function(n){var i;if("mixed"!==this.type&&"mixed"!==e&&e!==this.type)throw new U("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>1){if(this.multi)throw new U("Graph.".concat(t,": 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."));var r=""+n,a=""+arguments[1];if(!(i=s(this,r,a,e)))throw new H("Graph.".concat(t,': could not find an edge for the given path ("').concat(r,'" - "').concat(a,'").'))}else{if("mixed"!==e)throw new U("Graph.".concat(t,": 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)))throw new H("Graph.".concat(t,': could not find the "').concat(n,'" edge in the graph.'))}return i.attributes}}},{name:function(n){return"has".concat(n,"Attribute")},attacher:function(n,t,e){n.prototype[t]=function(n,i){var r;if("mixed"!==this.type&&"mixed"!==e&&e!==this.type)throw new U("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new U("Graph.".concat(t,": 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."));var a=""+n,c=""+i;if(i=arguments[2],!(r=s(this,a,c,e)))throw new H("Graph.".concat(t,': could not find an edge for the given path ("').concat(a,'" - "').concat(c,'").'))}else{if("mixed"!==e)throw new U("Graph.".concat(t,": 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,!(r=this._edges.get(n)))throw new H("Graph.".concat(t,': could not find the "').concat(n,'" edge in the graph.'))}return r.attributes.hasOwnProperty(i)}}},{name:function(n){return"set".concat(n,"Attribute")},attacher:function(n,t,e){n.prototype[t]=function(n,i,r){var a;if("mixed"!==this.type&&"mixed"!==e&&e!==this.type)throw new U("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new U("Graph.".concat(t,": 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."));var c=""+n,o=""+i;if(i=arguments[2],r=arguments[3],!(a=s(this,c,o,e)))throw new H("Graph.".concat(t,': could not find an edge for the given path ("').concat(c,'" - "').concat(o,'").'))}else{if("mixed"!==e)throw new U("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(n=""+n,!(a=this._edges.get(n)))throw new H("Graph.".concat(t,': could not find the "').concat(n,'" edge in the graph.'))}return a.attributes[i]=r,this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:i}),this}}},{name:function(n){return"update".concat(n,"Attribute")},attacher:function(n,t,e){n.prototype[t]=function(n,i,r){var a;if("mixed"!==this.type&&"mixed"!==e&&e!==this.type)throw new U("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>3){if(this.multi)throw new U("Graph.".concat(t,": 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."));var c=""+n,o=""+i;if(i=arguments[2],r=arguments[3],!(a=s(this,c,o,e)))throw new H("Graph.".concat(t,': could not find an edge for the given path ("').concat(c,'" - "').concat(o,'").'))}else{if("mixed"!==e)throw new U("Graph.".concat(t,": calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type."));if(n=""+n,!(a=this._edges.get(n)))throw new H("Graph.".concat(t,': could not find the "').concat(n,'" edge in the graph.'))}if("function"!=typeof r)throw new G("Graph.".concat(t,": updater should be a function."));return a.attributes[i]=r(a.attributes[i]),this.emit("edgeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:i}),this}}},{name:function(n){return"remove".concat(n,"Attribute")},attacher:function(n,t,e){n.prototype[t]=function(n,i){var r;if("mixed"!==this.type&&"mixed"!==e&&e!==this.type)throw new U("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new U("Graph.".concat(t,": 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."));var a=""+n,c=""+i;if(i=arguments[2],!(r=s(this,a,c,e)))throw new H("Graph.".concat(t,': could not find an edge for the given path ("').concat(a,'" - "').concat(c,'").'))}else{if("mixed"!==e)throw new U("Graph.".concat(t,": 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,!(r=this._edges.get(n)))throw new H("Graph.".concat(t,': could not find the "').concat(n,'" edge in the graph.'))}return delete r.attributes[i],this.emit("edgeAttributesUpdated",{key:r.key,type:"remove",attributes:r.attributes,name:i}),this}}},{name:function(n){return"replace".concat(n,"Attributes")},attacher:function(n,t,e){n.prototype[t]=function(n,i){var r;if("mixed"!==this.type&&"mixed"!==e&&e!==this.type)throw new U("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new U("Graph.".concat(t,": 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."));var a=""+n,c=""+i;if(i=arguments[2],!(r=s(this,a,c,e)))throw new H("Graph.".concat(t,': could not find an edge for the given path ("').concat(a,'" - "').concat(c,'").'))}else{if("mixed"!==e)throw new U("Graph.".concat(t,": 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,!(r=this._edges.get(n)))throw new H("Graph.".concat(t,': could not find the "').concat(n,'" edge in the graph.'))}if(!h(i))throw new G("Graph.".concat(t,": provided attributes are not a plain object."));return r.attributes=i,this.emit("edgeAttributesUpdated",{key:r.key,type:"replace",attributes:r.attributes}),this}}},{name:function(n){return"merge".concat(n,"Attributes")},attacher:function(n,t,e){n.prototype[t]=function(n,i){var r;if("mixed"!==this.type&&"mixed"!==e&&e!==this.type)throw new U("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new U("Graph.".concat(t,": 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."));var a=""+n,c=""+i;if(i=arguments[2],!(r=s(this,a,c,e)))throw new H("Graph.".concat(t,': could not find an edge for the given path ("').concat(a,'" - "').concat(c,'").'))}else{if("mixed"!==e)throw new U("Graph.".concat(t,": 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,!(r=this._edges.get(n)))throw new H("Graph.".concat(t,': could not find the "').concat(n,'" edge in the graph.'))}if(!h(i))throw new G("Graph.".concat(t,": provided attributes are not a plain object."));return u(r.attributes,i),this.emit("edgeAttributesUpdated",{key:r.key,type:"merge",attributes:r.attributes,data:i}),this}}},{name:function(n){return"update".concat(n,"Attributes")},attacher:function(n,t,e){n.prototype[t]=function(n,i){var r;if("mixed"!==this.type&&"mixed"!==e&&e!==this.type)throw new U("Graph.".concat(t,": cannot find this type of edges in your ").concat(this.type," graph."));if(arguments.length>2){if(this.multi)throw new U("Graph.".concat(t,": 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."));var a=""+n,c=""+i;if(i=arguments[2],!(r=s(this,a,c,e)))throw new H("Graph.".concat(t,': could not find an edge for the given path ("').concat(a,'" - "').concat(c,'").'))}else{if("mixed"!==e)throw new U("Graph.".concat(t,": 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,!(r=this._edges.get(n)))throw new H("Graph.".concat(t,': could not find the "').concat(n,'" edge in the graph.'))}if("function"!=typeof i)throw new G("Graph.".concat(t,": provided updater is not a function."));return r.attributes=i(r.attributes),this.emit("edgeAttributesUpdated",{key:r.key,type:"update",attributes:r.attributes}),this}}}],Y=L,Z=R,nn=function(){var n=arguments,t=null,e=-1;return new Y((function(){for(var i=null;;){if(null===t){if(++e>=n.length)return{done:!0};t=Z(n[e])}if(!0!==(i=t.next()).done)break;t=null}return i}))},tn=[{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 en(n,t,e,i){var r=!1;for(var a in t)if(a!==i){var c=t[a];if(r=e(c.key,c.attributes,c.source.key,c.target.key,c.source.attributes,c.target.attributes,c.undirected),n&&r)return c.key}}function rn(n,t,e,i){var r,a,c,o=!1;for(var u in t)if(u!==i){r=t[u];do{if(a=r.source,c=r.target,o=e(r.key,r.attributes,a.key,c.key,a.attributes,c.attributes,r.undirected),n&&o)return r.key;r=r.next}while(void 0!==r)}}function an(n,t){var e,i=Object.keys(n),r=i.length,a=0;return new L((function(){do{if(e)e=e.next;else{if(a>=r)return{done:!0};var c=i[a++];if(c===t){e=void 0;continue}e=n[c]}}while(!e);return{done:!1,value:{edge:e.key,attributes:e.attributes,source:e.source.key,target:e.target.key,sourceAttributes:e.source.attributes,targetAttributes:e.target.attributes,undirected:e.undirected}}}))}function cn(n,t,e,i){var r=t[e];if(r){var a=r.source,c=r.target;return i(r.key,r.attributes,a.key,c.key,a.attributes,c.attributes,r.undirected)&&n?r.key:void 0}}function on(n,t,e,i){var r=t[e];if(r){var a=!1;do{if(a=i(r.key,r.attributes,r.source.key,r.target.key,r.source.attributes,r.target.attributes,r.undirected),n&&a)return r.key;r=r.next}while(void 0!==r)}}function un(n,t){var e=n[t];return void 0!==e.next?new L((function(){if(!e)return{done:!0};var n={edge:e.key,attributes:e.attributes,source:e.source.key,target:e.target.key,sourceAttributes:e.source.attributes,targetAttributes:e.target.attributes,undirected:e.undirected};return e=e.next,{done:!1,value:n}})):L.of({edge:e.key,attributes:e.attributes,source:e.source.key,target:e.target.key,sourceAttributes:e.source.attributes,targetAttributes:e.target.attributes,undirected:e.undirected})}function sn(n,t){if(0===n.size)return[];if("mixed"===t||t===n.type)return"function"==typeof Array.from?Array.from(n._edges.keys()):F(n._edges.keys(),n._edges.size);for(var e,i,r="undirected"===t?n.undirectedSize:n.directedSize,a=new Array(r),c="undirected"===t,o=n._edges.values(),u=0;!0!==(e=o.next()).done;)(i=e.value).undirected===c&&(a[u++]=i.key);return a}function hn(n,t,e,i){if(0!==t.size)for(var r,a,c="mixed"!==e&&e!==t.type,o="undirected"===e,u=!1,s=t._edges.values();!0!==(r=s.next()).done;)if(a=r.value,!c||a.undirected===o){var h=a,f=h.key,l=h.attributes,b=h.source,d=h.target;if(u=i(f,l,b.key,d.key,b.attributes,d.attributes,a.undirected),n&&u)return f}}function fn(n,t){if(0===n.size)return L.empty();var e="mixed"!==t&&t!==n.type,i="undirected"===t,r=n._edges.values();return new L((function(){for(var n,t;;){if((n=r.next()).done)return n;if(t=n.value,!e||t.undirected===i)break}return{value:{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},done:!1}}))}function ln(n,t,e,i,r,a){var c,o=t?rn:en;if("undirected"!==e){if("out"!==i&&(c=o(n,r.in,a),n&&c))return c;if("in"!==i&&(c=o(n,r.out,a,i?void 0:r.key),n&&c))return c}if("directed"!==e&&(c=o(n,r.undirected,a),n&&c))return c}function bn(n,t,e,i){var r=[];return ln(!1,n,t,e,i,(function(n){r.push(n)})),r}function dn(n,t,e){var i=L.empty();return"undirected"!==n&&("out"!==t&&void 0!==e.in&&(i=nn(i,an(e.in))),"in"!==t&&void 0!==e.out&&(i=nn(i,an(e.out,t?void 0:e.key)))),"directed"!==n&&void 0!==e.undirected&&(i=nn(i,an(e.undirected))),i}function wn(n,t,e,i,r,a,c){var o,u=e?on:cn;if("undirected"!==t){if(void 0!==r.in&&"out"!==i&&(o=u(n,r.in,a,c),n&&o))return o;if(void 0!==r.out&&"in"!==i&&(i||r.key!==a)&&(o=u(n,r.out,a,c),n&&o))return o}if("directed"!==t&&void 0!==r.undirected&&(o=u(n,r.undirected,a,c),n&&o))return o}function gn(n,t,e,i,r){var a=[];return wn(!1,n,t,e,i,r,(function(n){a.push(n)})),a}function pn(n,t,e,i){var r=L.empty();return"undirected"!==n&&(void 0!==e.in&&"out"!==t&&i in e.in&&(r=nn(r,un(e.in,i))),void 0!==e.out&&"in"!==t&&i in e.out&&(t||e.key!==i)&&(r=nn(r,un(e.out,i)))),"directed"!==n&&void 0!==e.undirected&&i in e.undirected&&(r=nn(r,un(e.undirected,i))),r}var vn=[{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 mn(){this.A=null,this.B=null}function yn(n,t,e,i,r){for(var a in i){var c=i[a],o=c.source,u=c.target,s=o===e?u:o;if(!t||!t.has(s.key)){var h=r(s.key,s.attributes);if(n&&h)return s.key}}}function kn(n,t,e,i,r){if("mixed"!==t){if("undirected"===t)return yn(n,null,i,i.undirected,r);if("string"==typeof e)return yn(n,null,i,i[e],r)}var a,c=new mn;if("undirected"!==t){if("out"!==e){if(a=yn(n,null,i,i.in,r),n&&a)return a;c.wrap(i.in)}if("in"!==e){if(a=yn(n,c,i,i.out,r),n&&a)return a;c.wrap(i.out)}}if("directed"!==t&&(a=yn(n,c,i,i.undirected,r),n&&a))return a}function En(n,t,e){var i=Object.keys(e),r=i.length,a=0;return new L((function(){var c=null;do{if(a>=r)return n&&n.wrap(e),{done:!0};var o=e[i[a++]],u=o.source,s=o.target;c=u===t?s:u,n&&n.has(c.key)&&(c=null)}while(null===c);return{done:!1,value:{neighbor:c.key,attributes:c.attributes}}}))}function jn(n,t){var e=t.name,i=t.type,r=t.direction;n.prototype[e]=function(n){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return[];n=""+n;var t=this._nodes.get(n);if(void 0===t)throw new H("Graph.".concat(e,': could not find the "').concat(n,'" node in the graph.'));return function(n,t,e){if("mixed"!==n){if("undirected"===n)return Object.keys(e.undirected);if("string"==typeof t)return Object.keys(e[t])}var i=[];return kn(!1,n,t,e,(function(n){i.push(n)})),i}("mixed"===i?this.type:i,r,t)}}function Sn(n,t){var e=t.name,i=t.type,r=t.direction,a=e.slice(0,-1)+"Entries";n.prototype[a]=function(n){if("mixed"!==i&&"mixed"!==this.type&&i!==this.type)return L.empty();n=""+n;var t=this._nodes.get(n);if(void 0===t)throw new H("Graph.".concat(a,': could not find the "').concat(n,'" node in the graph.'));return function(n,t,e){if("mixed"!==n){if("undirected"===n)return En(null,e,e.undirected);if("string"==typeof t)return En(null,e,e[t])}var i=L.empty(),r=new mn;return"undirected"!==n&&("out"!==t&&(i=nn(i,En(r,e,e.in))),"in"!==t&&(i=nn(i,En(r,e,e.out)))),"directed"!==n&&(i=nn(i,En(r,e,e.undirected))),i}("mixed"===i?this.type:i,r,t)}}function Mn(n,t,e,i,r){for(var a,c,o,u,s,h,f,l=i._nodes.values(),b=i.type;!0!==(a=l.next()).done;){var d=!1;if(c=a.value,"undirected"!==b)for(o in u=c.out){s=u[o];do{if(h=s.target,d=!0,f=r(c.key,h.key,c.attributes,h.attributes,s.key,s.attributes,s.undirected),n&&f)return s;s=s.next}while(s)}if("directed"!==b)for(o in u=c.undirected)if(!(t&&c.key>o)){s=u[o];do{if((h=s.target).key!==o&&(h=s.source),d=!0,f=r(c.key,h.key,c.attributes,h.attributes,s.key,s.attributes,s.undirected),n&&f)return s;s=s.next}while(s)}if(e&&!d&&(f=r(c.key,null,c.attributes,null,null,null,null),n&&f))return null}}function Tn(n){if(!h(n))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 n))throw new G("Graph.import: serialized node is missing its key.");if("attributes"in n&&(!h(n.attributes)||null===n.attributes))throw new G("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function Pn(n){if(!h(n))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 n))throw new G("Graph.import: serialized edge is missing its source.");if(!("target"in n))throw new G("Graph.import: serialized edge is missing its target.");if("attributes"in n&&(!h(n.attributes)||null===n.attributes))throw new G("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in n&&"boolean"!=typeof n.undirected)throw new G("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}mn.prototype.wrap=function(n){null===this.A?this.A=n:null===this.B&&(this.B=n)},mn.prototype.has=function(n){return null!==this.A&&n in this.A||null!==this.B&&n in this.B};var On,Cn=(On=255&Math.floor(256*Math.random()),function(){return On++}),An=new Set(["directed","undirected","mixed"]),In=new Set(["domain","_events","_eventsCount","_maxListeners"]),Ln={allowSelfLoops:!0,multi:!1,type:"mixed"};function Nn(n,t,e){var i=new n.NodeDataClass(t,e);return n._nodes.set(t,i),n.emit("nodeAdded",{key:t,attributes:e}),i}function _n(n,t,e,i,r,a,c,o){if(!i&&"undirected"===n.type)throw new U("Graph.".concat(t,": you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead."));if(i&&"directed"===n.type)throw new U("Graph.".concat(t,": you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead."));if(o&&!h(o))throw new G("Graph.".concat(t,': invalid attributes. Expecting an object but got "').concat(o,'"'));if(a=""+a,c=""+c,o=o||{},!n.allowSelfLoops&&a===c)throw new U("Graph.".concat(t,': source & target are the same ("').concat(a,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var u=n._nodes.get(a),s=n._nodes.get(c);if(!u)throw new H("Graph.".concat(t,': source node "').concat(a,'" not found.'));if(!s)throw new H("Graph.".concat(t,': target node "').concat(c,'" not found.'));var f={key:null,undirected:i,source:a,target:c,attributes:o};if(e)r=n._edgeKeyGenerator();else if(r=""+r,n._edges.has(r))throw new U("Graph.".concat(t,': the "').concat(r,'" edge already exists in the graph.'));if(!n.multi&&(i?void 0!==u.undirected[c]:void 0!==u.out[c]))throw new U("Graph.".concat(t,': an edge linking "').concat(a,'" to "').concat(c,"\" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option."));var l=new X(i,r,u,s,o);n._edges.set(r,l);var b=a===c;return i?(u.undirectedDegree++,s.undirectedDegree++,b&&(u.undirectedLoops++,n._undirectedSelfLoopCount++)):(u.outDegree++,s.inDegree++,b&&(u.directedLoops++,n._directedSelfLoopCount++)),n.multi?l.attachMulti():l.attach(),i?n._undirectedSize++:n._directedSize++,f.key=r,n.emit("edgeAdded",f),r}function xn(n,t,e,i,r,a,c,o,s){if(!i&&"undirected"===n.type)throw new U("Graph.".concat(t,": you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead."));if(i&&"directed"===n.type)throw new U("Graph.".concat(t,": you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead."));if(o)if(s){if("function"!=typeof o)throw new G("Graph.".concat(t,': invalid updater function. Expecting a function but got "').concat(o,'"'))}else if(!h(o))throw new G("Graph.".concat(t,': invalid attributes. Expecting an object but got "').concat(o,'"'));var f;if(a=""+a,c=""+c,s&&(f=o,o=void 0),!n.allowSelfLoops&&a===c)throw new U("Graph.".concat(t,': source & target are the same ("').concat(a,"\"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false."));var l,b,d=n._nodes.get(a),w=n._nodes.get(c);if(!e&&(l=n._edges.get(r))){if(!(l.source.key===a&&l.target.key===c||i&&l.source.key===c&&l.target.key===a))throw new U("Graph.".concat(t,': inconsistency detected when attempting to merge the "').concat(r,'" edge with "').concat(a,'" source & "').concat(c,'" target vs. ("').concat(l.source.key,'", "').concat(l.target.key,'").'));b=l}if(b||n.multi||!d||(b=i?d.undirected[c]:d.out[c]),b){var g=[b.key,!1,!1,!1];if(s?!f:!o)return g;if(s){var p=b.attributes;b.attributes=f(p),n.emit("edgeAttributesUpdated",{type:"replace",key:b.key,attributes:b.attributes})}else u(b.attributes,o),n.emit("edgeAttributesUpdated",{type:"merge",key:b.key,attributes:b.attributes,data:o});return g}o=o||{},s&&f&&(o=f(o));var v={key:null,undirected:i,source:a,target:c,attributes:o};if(e)r=n._edgeKeyGenerator();else if(r=""+r,n._edges.has(r))throw new U("Graph.".concat(t,': the "').concat(r,'" edge already exists in the graph.'));var m=!1,y=!1;d||(d=Nn(n,a,{}),m=!0,a===c&&(w=d,y=!0)),w||(w=Nn(n,c,{}),y=!0),l=new X(i,r,d,w,o),n._edges.set(r,l);var k=a===c;return i?(d.undirectedDegree++,w.undirectedDegree++,k&&(d.undirectedLoops++,n._undirectedSelfLoopCount++)):(d.outDegree++,w.inDegree++,k&&(d.directedLoops++,n._directedSelfLoopCount++)),n.multi?l.attachMulti():l.attach(),i?n._undirectedSize++:n._directedSize++,v.key=r,n.emit("edgeAdded",v