@antv/layout 1.2.10 → 1.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/dist/747bfdc8efc94bc1fa90.worker.js +2 -0
  2. package/dist/747bfdc8efc94bc1fa90.worker.js.map +1 -0
  3. package/dist/index.min.js +1 -1
  4. package/dist/index.min.js.map +1 -1
  5. package/lib/bundle-entry.js +19 -0
  6. package/lib/bundle-entry.js.map +1 -0
  7. package/lib/bundle-supervisor.js +94 -0
  8. package/lib/bundle-supervisor.js.map +1 -0
  9. package/lib/bundle-worker.js +52 -0
  10. package/lib/bundle-worker.js.map +1 -0
  11. package/lib/circular.js +258 -0
  12. package/lib/circular.js.map +1 -0
  13. package/lib/comboCombined.js +440 -0
  14. package/lib/comboCombined.js.map +1 -0
  15. package/lib/concentric.js +229 -0
  16. package/lib/concentric.js.map +1 -0
  17. package/lib/d3Force/forceInBox.js +331 -0
  18. package/lib/d3Force/forceInBox.js.map +1 -0
  19. package/lib/d3Force/index.js +338 -0
  20. package/lib/d3Force/index.js.map +1 -0
  21. package/lib/dagre/acyclic.js +62 -0
  22. package/lib/dagre/acyclic.js.map +1 -0
  23. package/lib/dagre/add-border-segments.js +37 -0
  24. package/lib/dagre/add-border-segments.js.map +1 -0
  25. package/lib/dagre/coordinate-system.js +65 -0
  26. package/lib/dagre/coordinate-system.js.map +1 -0
  27. package/lib/dagre/data/list.d.ts +1 -1
  28. package/lib/dagre/data/list.js +50 -0
  29. package/lib/dagre/data/list.js.map +1 -0
  30. package/lib/dagre/greedy-fas.js +147 -0
  31. package/lib/dagre/greedy-fas.js.map +1 -0
  32. package/lib/dagre/layout.js +470 -0
  33. package/lib/dagre/layout.js.map +1 -0
  34. package/lib/dagre/nesting-graph.js +153 -0
  35. package/lib/dagre/nesting-graph.js.map +1 -0
  36. package/lib/dagre/normalize.js +98 -0
  37. package/lib/dagre/normalize.js.map +1 -0
  38. package/lib/dagre/order/add-subgraph-constraints.js +45 -0
  39. package/lib/dagre/order/add-subgraph-constraints.js.map +1 -0
  40. package/lib/dagre/order/barycenter.js +23 -0
  41. package/lib/dagre/order/barycenter.js.map +1 -0
  42. package/lib/dagre/order/build-layer-graph.js +96 -0
  43. package/lib/dagre/order/build-layer-graph.js.map +1 -0
  44. package/lib/dagre/order/cross-count.js +63 -0
  45. package/lib/dagre/order/cross-count.js.map +1 -0
  46. package/lib/dagre/order/index.js +91 -0
  47. package/lib/dagre/order/index.js.map +1 -0
  48. package/lib/dagre/order/init-data-order.js +28 -0
  49. package/lib/dagre/order/init-data-order.js.map +1 -0
  50. package/lib/dagre/order/init-order.js +50 -0
  51. package/lib/dagre/order/init-order.js.map +1 -0
  52. package/lib/dagre/order/resolve-conflicts.d.ts +1 -1
  53. package/lib/dagre/order/resolve-conflicts.js +121 -0
  54. package/lib/dagre/order/resolve-conflicts.js.map +1 -0
  55. package/lib/dagre/order/sort-subgraph.js +84 -0
  56. package/lib/dagre/order/sort-subgraph.js.map +1 -0
  57. package/lib/dagre/order/sort.js +74 -0
  58. package/lib/dagre/order/sort.js.map +1 -0
  59. package/lib/dagre/parent-dummy-chains.js +80 -0
  60. package/lib/dagre/parent-dummy-chains.js.map +1 -0
  61. package/lib/dagre/position/bk.d.ts +1 -1
  62. package/lib/dagre/position/bk.js +398 -0
  63. package/lib/dagre/position/bk.js.map +1 -0
  64. package/lib/dagre/position/index.js +54 -0
  65. package/lib/dagre/position/index.js.map +1 -0
  66. package/lib/dagre/rank/feasible-tree.js +164 -0
  67. package/lib/dagre/rank/feasible-tree.js.map +1 -0
  68. package/lib/dagre/rank/index.js +48 -0
  69. package/lib/dagre/rank/index.js.map +1 -0
  70. package/lib/dagre/rank/network-simplex.js +232 -0
  71. package/lib/dagre/rank/network-simplex.js.map +1 -0
  72. package/lib/dagre/rank/util.js +138 -0
  73. package/lib/dagre/rank/util.js.map +1 -0
  74. package/lib/dagre/util.js +289 -0
  75. package/lib/dagre/util.js.map +1 -0
  76. package/lib/dagre.js +545 -0
  77. package/lib/dagre.js.map +1 -0
  78. package/lib/force/forceNBody.js +123 -0
  79. package/lib/force/forceNBody.js.map +1 -0
  80. package/lib/force/index.js +805 -0
  81. package/lib/force/index.js.map +1 -0
  82. package/lib/force/types.d.ts +3 -3
  83. package/lib/force/types.js +2 -0
  84. package/lib/force/types.js.map +1 -0
  85. package/lib/forceAtlas2/body.d.ts +1 -1
  86. package/lib/forceAtlas2/body.js +91 -0
  87. package/lib/forceAtlas2/body.js.map +1 -0
  88. package/lib/forceAtlas2/index.js +562 -0
  89. package/lib/forceAtlas2/index.js.map +1 -0
  90. package/lib/forceAtlas2/quad.d.ts +1 -1
  91. package/lib/forceAtlas2/quad.js +98 -0
  92. package/lib/forceAtlas2/quad.js.map +1 -0
  93. package/lib/forceAtlas2/quadTree.js +105 -0
  94. package/lib/forceAtlas2/quadTree.js.map +1 -0
  95. package/lib/fruchterman.js +376 -0
  96. package/lib/fruchterman.js.map +1 -0
  97. package/lib/grid.js +308 -0
  98. package/lib/grid.js.map +1 -0
  99. package/lib/index.js +17 -0
  100. package/lib/index.js.map +1 -0
  101. package/lib/mds.js +137 -0
  102. package/lib/mds.js.map +1 -0
  103. package/lib/radial/index.js +355 -0
  104. package/lib/radial/index.js.map +1 -0
  105. package/lib/radial/mds.js +29 -0
  106. package/lib/radial/mds.js.map +1 -0
  107. package/lib/radial/radial-nonoverlap-force.d.ts +1 -1
  108. package/lib/radial/radial-nonoverlap-force.js +100 -0
  109. package/lib/radial/radial-nonoverlap-force.js.map +1 -0
  110. package/lib/random.js +98 -0
  111. package/lib/random.js.map +1 -0
  112. package/lib/registry.js +27 -0
  113. package/lib/registry.js.map +1 -0
  114. package/lib/supervisor.js +90 -0
  115. package/lib/supervisor.js.map +1 -0
  116. package/lib/types.d.ts +13 -13
  117. package/lib/types.js +4 -0
  118. package/lib/types.js.map +1 -0
  119. package/lib/util/array.js +2 -0
  120. package/lib/util/array.js.map +1 -0
  121. package/lib/util/common.d.ts +12 -0
  122. package/lib/util/common.js +32 -0
  123. package/lib/util/common.js.map +1 -0
  124. package/lib/util/function.js +126 -0
  125. package/lib/util/function.js.map +1 -0
  126. package/lib/util/gpu.js +214 -0
  127. package/lib/util/gpu.js.map +1 -0
  128. package/lib/util/index.js +7 -0
  129. package/lib/util/index.js.map +1 -0
  130. package/lib/util/math.js +257 -0
  131. package/lib/util/math.js.map +1 -0
  132. package/lib/util/number.js +5 -0
  133. package/lib/util/number.js.map +1 -0
  134. package/lib/util/object.js +42 -0
  135. package/lib/util/object.js.map +1 -0
  136. package/lib/util/string.js +15 -0
  137. package/lib/util/string.js.map +1 -0
  138. package/lib/worker.d.ts +1 -0
  139. package/lib/worker.js +45 -0
  140. package/lib/worker.js.map +1 -0
  141. package/package.json +2 -2
  142. package/dist/5fc550bbb6f708833d84.worker.js +0 -2
  143. package/dist/5fc550bbb6f708833d84.worker.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ (()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{calculateLayout:()=>Wn,stopLayout:()=>Gn});var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},r(t,e)};var n=function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)};function o(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}function i(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{u(n.next(t))}catch(t){i(t)}}function s(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}u((n=n.apply(t,e||[])).next())}))}function a(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function s(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function u(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;const d=function(){function t(){this._events={}}return t.prototype.on=function(t,e,r){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!r}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var o=this._events[t]||[],i=this._events["*"]||[],a=function(n){for(var o=n.length,i=0;i<o;i++)if(n[i]){var a=n[i],s=a.callback;a.once&&(n.splice(i,1),0===n.length&&delete e._events[t],o--,i--),s.apply(e,r)}};a(o),a(i)},t.prototype.off=function(t,e){if(t)if(e){for(var r=this._events[t]||[],n=r.length,o=0;o<n;o++)r[o].callback===e&&(r.splice(o,1),n--,o--);0===r.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();function h(t,e,r,n){for(;t.length;){const o=t.shift();if(r(o))return!0;e.add(o.id),n(o.id).forEach((r=>{e.has(r.id)||(e.add(r.id),t.push(r))}))}return!1}function c(t,e,r,n){if(r(t))return!0;e.add(t.id);for(const o of n(t.id))if(!e.has(o.id)&&c(o,e,r,n))return!0;return!1}const l=()=>!0;class f{graph;nodeFilter;edgeFilter;cacheEnabled;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;allNodesMap=new Map;allEdgesMap=new Map;constructor(t){this.graph=t.graph;const e=t.nodeFilter||l,r=t.edgeFilter||l;this.nodeFilter=e,this.edgeFilter=t=>{const{source:n,target:o}=this.graph.getEdgeDetail(t.id);return!(!e(n)||!e(o))&&r(t,n,o)},"auto"===t.cache?(this.cacheEnabled=!0,this.startAutoCache()):"manual"===t.cache?this.cacheEnabled=!0:this.cacheEnabled=!1}clearCache=()=>{this.inEdgesMap.clear(),this.outEdgesMap.clear(),this.bothEdgesMap.clear(),this.allNodesMap.clear(),this.allEdgesMap.clear()};refreshCache=()=>{this.clearCache(),this.updateCache(this.graph.getAllNodes().map((t=>t.id)))};updateCache=t=>{const e=new Set;t.forEach((t=>{const r=this.bothEdgesMap.get(t);if(r&&r.forEach((t=>e.add(t.id))),this.hasNode(t)){const r=this.graph.getRelatedEdges(t,"in").filter(this.edgeFilter),n=this.graph.getRelatedEdges(t,"out").filter(this.edgeFilter),o=Array.from(new Set([...r,...n]));o.forEach((t=>e.add(t.id))),this.inEdgesMap.set(t,r),this.outEdgesMap.set(t,n),this.bothEdgesMap.set(t,o),this.allNodesMap.set(t,this.graph.getNode(t))}else this.inEdgesMap.delete(t),this.outEdgesMap.delete(t),this.bothEdgesMap.delete(t),this.allNodesMap.delete(t)})),e.forEach((t=>{this.hasEdge(t)?this.allEdgesMap.set(t,this.graph.getEdge(t)):this.allEdgesMap.delete(t)}))};startAutoCache(){this.refreshCache(),this.graph.on("changed",this.handleGraphChanged)}stopAutoCache(){this.graph.off("changed",this.handleGraphChanged)}handleGraphChanged=t=>{const e=new Set;t.changes.forEach((r=>{switch(r.type){case"NodeAdded":case"NodeRemoved":e.add(r.value.id);break;case"NodeDataUpdated":e.add(r.id);break;case"EdgeAdded":case"EdgeRemoved":e.add(r.value.source),e.add(r.value.target);break;case"EdgeUpdated":"source"!==r.propertyName&&"target"!==r.propertyName||(e.add(r.oldValue),e.add(r.newValue));break;case"EdgeDataUpdated":if(t.graph.hasEdge(r.id)){const n=t.graph.getEdge(r.id);e.add(n.source),e.add(n.target)}}})),this.updateCache(e)};checkNodeExistence(t){this.getNode(t)}hasNode(t){if(!this.graph.hasNode(t))return!1;const e=this.graph.getNode(t);return this.nodeFilter(e)}areNeighbors(t,e){return this.checkNodeExistence(t),this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.graph.getNode(t);if(!this.nodeFilter(e))throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){return this.checkNodeExistence(t),this.cacheEnabled?"in"===e?this.inEdgesMap.get(t):"out"===e?this.outEdgesMap.get(t):this.bothEdgesMap.get(t):this.graph.getRelatedEdges(t,e).filter(this.edgeFilter)}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),r=this.getSuccessors(t);return Array.from(new Set([...e,...r]))}hasEdge(t){if(!this.graph.hasEdge(t))return!1;const e=this.graph.getEdge(t);return this.edgeFilter(e)}getEdge(t){const e=this.graph.getEdge(t);if(!this.edgeFilter(e))throw new Error("Edge not found for id: "+t);return e}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}hasTreeStructure(t){return this.graph.hasTreeStructure(t)}getRoots(t){return this.graph.getRoots(t).filter(this.nodeFilter)}getChildren(t,e){return this.checkNodeExistence(t),this.graph.getChildren(t,e).filter(this.nodeFilter)}getParent(t,e){this.checkNodeExistence(t);const r=this.graph.getParent(t,e);return r&&this.nodeFilter(r)?r:null}getAllNodes(){return this.cacheEnabled?Array.from(this.allNodesMap.values()):this.graph.getAllNodes().filter(this.nodeFilter)}getAllEdges(){return this.cacheEnabled?Array.from(this.allEdgesMap.values()):this.graph.getAllEdges().filter(this.edgeFilter)}bfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];h([this.getNode(t)],new Set,e,n)}dfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];c(this.getNode(t),new Set,e,n)}}class g extends d{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){super(),t&&(t.nodes&&this.addNodes(t.nodes),t.edges&&this.addEdges(t.edges),t.tree&&this.addTree(t.tree),t.onChanged&&(this.onChanged=t.onChanged))}batch=t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()};commit(){const t=this.changes;this.changes=[];const e={graph:this,changes:t};this.emit("changed",e),this.onChanged(e)}reduceChanges(t){let e=[];return t.forEach((t=>{switch(t.type){case"NodeRemoved":{let r=!1;e=e.filter((e=>{if("NodeAdded"===e.type){const n=e.value.id===t.value.id;return n&&(r=!0),!n}return"NodeDataUpdated"===e.type?e.id!==t.value.id:"TreeStructureChanged"!==e.type||e.nodeId!==t.value.id})),r||e.push(t);break}case"EdgeRemoved":{let r=!1;e=e.filter((e=>{if("EdgeAdded"===e.type){const n=e.value.id===t.value.id;return n&&(r=!0),!n}return"EdgeDataUpdated"!==e.type&&"EdgeUpdated"!==e.type||e.id!==t.value.id})),r||e.push(t);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const r=e.findIndex((e=>e.type===t.type&&e.id===t.id&&(void 0===t.propertyName||e.propertyName===t.propertyName))),n=e[r];n?void 0!==t.propertyName?n.newValue=t.newValue:(e.splice(r,1),e.push(t)):e.push(t);break}case"TreeStructureDetached":e=e.filter((e=>"TreeStructureAttached"===e.type?e.treeKey!==t.treeKey:"TreeStructureChanged"!==e.type||e.treeKey!==t.treeKey)),e.push(t);break;case"TreeStructureChanged":{const r=e.find((e=>"TreeStructureChanged"===e.type&&e.treeKey===t.treeKey&&e.nodeId===t.nodeId));r?r.newParentId=t.newParentId:e.push(t);break}default:e.push(t)}})),e}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.nodeMap.get(t);if(!e)throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),"in"===e){const e=this.inEdgesMap.get(t);return Array.from(e)}if("out"===e){const e=this.outEdgesMap.get(t);return Array.from(e)}{const e=this.bothEdgesMap.get(t);return Array.from(e)}}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),r=this.getSuccessors(t);return Array.from(new Set([...e,...r]))}doAddNode(t){if(this.hasNode(t.id))throw new Error("Node already exists: "+t.id);this.nodeMap.set(t.id,t),this.inEdgesMap.set(t.id,new Set),this.outEdgesMap.set(t.id,new Set),this.bothEdgesMap.set(t.id,new Set),this.treeIndices.forEach((e=>{e.childrenMap.set(t.id,new Set)})),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch((()=>{for(const e of t)this.doAddNode(e)}))}addNode(t){this.addNodes([t])}doRemoveNode(t){const e=this.getNode(t),r=this.bothEdgesMap.get(t);r?.forEach((t=>this.doRemoveEdge(t.id))),this.nodeMap.delete(t),this.treeIndices.forEach((e=>{e.childrenMap.get(t)?.forEach((t=>{e.parentMap.delete(t.id)})),e.parentMap.delete(t),e.childrenMap.delete(t)})),this.changes.push({type:"NodeRemoved",value:e})}removeNodes(t){this.batch((()=>{t.forEach((t=>this.doRemoveNode(t)))}))}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,e,r){const n=this.getNode(t);this.batch((()=>{const o=n.data[e],i=r;n.data[e]=i,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:e,oldValue:o,newValue:i})}))}mergeNodeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateNodeDataProperty(t,e,r)}))}))}updateNodeData(...t){const e=t[0],r=this.getNode(e);if("string"==typeof t[1])return void this.updateNodeDataProperty(e,t[1],t[2]);let n;if("function"==typeof t[1]){const e=t[1];n=e(r.data)}else"object"==typeof t[1]&&(n=t[1]);this.batch((()=>{const t=r.data,o=n;r.data=n,this.changes.push({type:"NodeDataUpdated",id:e,oldValue:t,newValue:o})}))}checkEdgeExistence(t){if(!this.hasEdge(t))throw new Error("Edge not found for id: "+t)}hasEdge(t){return this.edgeMap.has(t)}getEdge(t){return this.checkEdgeExistence(t),this.edgeMap.get(t)}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}doAddEdge(t){if(this.hasEdge(t.id))throw new Error("Edge already exists: "+t.id);this.checkNodeExistence(t.source),this.checkNodeExistence(t.target),this.edgeMap.set(t.id,t);const e=this.inEdgesMap.get(t.target),r=this.outEdgesMap.get(t.source),n=this.bothEdgesMap.get(t.source),o=this.bothEdgesMap.get(t.target);e.add(t),r.add(t),n.add(t),o.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch((()=>{for(const e of t)this.doAddEdge(e)}))}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const e=this.getEdge(t),r=this.outEdgesMap.get(e.source),n=this.inEdgesMap.get(e.target),o=this.bothEdgesMap.get(e.source),i=this.bothEdgesMap.get(e.target);r.delete(e),n.delete(e),o.delete(e),i.delete(e),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:e})}removeEdges(t){this.batch((()=>{t.forEach((t=>this.doRemoveEdge(t)))}))}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,e){const r=this.getEdge(t);this.checkNodeExistence(e);const n=r.source,o=e;this.outEdgesMap.get(n).delete(r),this.bothEdgesMap.get(n).delete(r),this.outEdgesMap.get(o).add(r),this.bothEdgesMap.get(o).add(r),r.source=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:n,newValue:o})}))}updateEdgeTarget(t,e){const r=this.getEdge(t);this.checkNodeExistence(e);const n=r.target,o=e;this.inEdgesMap.get(n).delete(r),this.bothEdgesMap.get(n).delete(r),this.inEdgesMap.get(o).add(r),this.bothEdgesMap.get(o).add(r),r.target=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:n,newValue:o})}))}updateEdgeDataProperty(t,e,r){const n=this.getEdge(t);this.batch((()=>{const o=n.data[e],i=r;n.data[e]=i,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:e,oldValue:o,newValue:i})}))}updateEdgeData(...t){const e=t[0],r=this.getEdge(e);if("string"==typeof t[1])return void this.updateEdgeDataProperty(e,t[1],t[2]);let n;if("function"==typeof t[1]){const e=t[1];n=e(r.data)}else"object"==typeof t[1]&&(n=t[1]);this.batch((()=>{const t=r.data,o=n;r.data=n,this.changes.push({type:"EdgeDataUpdated",id:e,oldValue:t,newValue:o})}))}mergeEdgeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateEdgeDataProperty(t,e,r)}))}))}checkTreeExistence(t){if(!this.hasTreeStructure(t))throw new Error("Tree structure not found for treeKey: "+t)}hasTreeStructure(t){return this.treeIndices.has(t)}attachTreeStructure(t){this.treeIndices.has(t)||(this.treeIndices.set(t,{parentMap:new Map,childrenMap:new Map}),this.batch((()=>{this.changes.push({type:"TreeStructureAttached",treeKey:t})})))}detachTreeStructure(t){this.checkTreeExistence(t),this.treeIndices.delete(t),this.batch((()=>{this.changes.push({type:"TreeStructureDetached",treeKey:t})}))}addTree(t,e){this.batch((()=>{this.attachTreeStructure(e);const r=[],n=Array.isArray(t)?t:[t];for(;n.length;){const t=n.shift();r.push(t),t.children&&n.push(...t.children)}this.addNodes(r),r.forEach((t=>{t.children?.forEach((r=>{this.setParent(r.id,t.id,e)}))}))}))}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter((e=>!this.getParent(e.id,t)))}getChildren(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);const r=this.treeIndices.get(e).childrenMap.get(t);return Array.from(r||[])}getParent(t,e){return this.checkNodeExistence(t),this.checkTreeExistence(e),this.treeIndices.get(e).parentMap.get(t)||null}getAncestors(t,e){const r=[];let n,o=this.getNode(t);for(;n=this.getParent(o.id,e);)r.push(n),o=n;return r}setParent(t,e,r){this.checkTreeExistence(r);const n=this.treeIndices.get(r),o=this.getNode(t),i=n.parentMap.get(t);if(i?.id===e)return;if(void 0===e)return i&&n.childrenMap.get(i.id)?.delete(o),void n.parentMap.delete(t);const a=this.getNode(e);n.parentMap.set(t,a),i&&n.childrenMap.get(i.id)?.delete(o);let s=n.childrenMap.get(a.id);s||(s=new Set,n.childrenMap.set(a.id,s)),s.add(o),this.batch((()=>{this.changes.push({type:"TreeStructureChanged",treeKey:r,nodeId:t,oldParentId:i?.id,newParentId:a.id})}))}dfsTree(t,e,r){return c(this.getNode(t),new Set,e,(t=>this.getChildren(t,r)))}bfsTree(t,e,r){return h([this.getNode(t)],new Set,e,(t=>this.getChildren(t,r)))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];return h([this.getNode(t)],new Set,e,n)}dfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];return c(this.getNode(t),new Set,e,n)}clone(){const t=this.getAllNodes().map((t=>({...t,data:{...t.data}}))),e=this.getAllEdges().map((t=>({...t,data:{...t.data}}))),r=new g({nodes:t,edges:e});return this.treeIndices.forEach((({parentMap:t,childrenMap:e},n)=>{const o=new Map;t.forEach(((t,e)=>{o.set(e,r.getNode(t.id))}));const i=new Map;e.forEach(((t,e)=>{i.set(e,new Set(Array.from(t).map((t=>r.getNode(t.id)))))})),r.treeIndices.set(n,{parentMap:o,childrenMap:i})})),r}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}createView(t){return new f({graph:this,...t})}}const p=function(t){return"function"==typeof t};var v={}.toString;const y=function(t,e){return v.call(t)==="[object "+e+"]"},m=function(t){return y(t,"Number")},w=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function x(t,e){return p(e)?e:m(e)?function(){return e}:function(){return t}}function E(t,e,r){return void 0===r&&(r=!0),e||0===e?p(e)?e:m(e)?function(){return e}:Array.isArray(e)?function(){if(r){var n=Math.max.apply(Math,u([],s(e),!1));return isNaN(n)?t:n}return e}:w(e)?function(){if(r){var n=Math.max(e.width,e.height);return isNaN(n)?t:n}return[e.width,e.height]}:function(){return t}:function(e){var r=(e.data||{}).size;return r?Array.isArray(r)?r[0]>r[1]?r[0]:r[1]:w(r)?r.width>r.height?r.width:r.height:r:t}}var N=function(t,e){var r;return r=m(e)?function(){return e}:p(e)?e:function(){return 0},t?Array.isArray(t)?function(e){return(t[0]>t[1]?t[0]:t[1])+r(e)}:p(t)?t:function(e){return t+r(e)}:function(t){var e,n;if(null===(e=t.data)||void 0===e?void 0:e.bboxSize)return Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t);if(null===(n=t.data)||void 0===n?void 0:n.size){if(Array.isArray(t.data.size))return Math.max(t.data.size[0],t.data.size[1])+r(t);var o=t.data.size;return w(o)?(o.width>o.height?o.width:o.height)+r(t):o+r(t)}return 10+r(t)}},b=function(t){if(null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array){var e=[];return t.forEach((function(t){e.push(t)})),e.map((function(t){return b(t)}))}if("object"==typeof t){var r={};return Object.keys(t).forEach((function(e){r[e]=b(t[e])})),r}return t},M=function(t,e){var r=b(t);return r.data=r.data||{},e&&(m(r.data.x)||(r.data.x=Math.random()*e[0]),m(r.data.y)||(r.data.y=Math.random()*e[1])),r},S=function(t,e,r){var o=t.getAllNodes(),i=t.getAllEdges();return(null==o?void 0:o.length)?1===o.length?(e&&t.mergeNodeData(o[0].id,{x:r[0],y:r[1]}),{nodes:[n(n({},o[0]),{data:n(n({},o[0].data),{x:r[0],y:r[1]})})],edges:i}):void 0:{nodes:[],edges:i}},A={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},k=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=n(n({},A),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericCircularLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,this.genericCircularLayout(!0,t,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.genericCircularLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,u,d,h,c,l,f,g,p,v,y,m,w,N,b,A,k,R,I,D,P,O,C,T,F,L,q,j,V,B,G,W,$,U;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.width,u=o.height,d=o.center,h=o.divisions,c=o.startAngle,l=void 0===c?0:c,f=o.endAngle,g=void 0===f?2*Math.PI:f,p=o.angleRatio,v=o.ordering,y=o.clockwise,m=o.nodeSpacing,w=o.nodeSize,N=e.getAllNodes(),b=e.getAllEdges(),A=s(z(i,u,d),3),k=A[0],R=A[1],I=A[2],!(D=null==N?void 0:N.length)||1===D)return[2,S(e,t,I)];for(P=(g-l)/D,O=o.radius,C=o.startRadius,T=o.endRadius,m?(F=x(10,m),L=E(10,w),q=-1/0,N.forEach((function(t){var e=L(t);q<e&&(q=e)})),j=0,N.forEach((function(t,e){j+=0===e?q||10:(F(t)||0)+(q||10)})),O=j/(2*Math.PI)):O||C||T?!C&&T?C=T:C&&!T&&(T=C):O=Math.min(R,k)/2,V=P*p,B=[],B="topology"===v?_(e,N):"topology-directed"===v?_(e,N,!0):"degree"===v?function(t,e){var r=[];return e.forEach((function(t,e){r.push(M(t))})),r.sort((function(e,r){return t.getDegree(e.id,"both")-t.getDegree(r.id,"both")})),r}(e,N):N.map((function(t){return M(t)})),G=Math.ceil(D/h),W=0;W<D;++W)($=O)||null===C||null===T||($=C+W*(T-C)/(D-1)),$||($=10+100*W/(D-1)),U=l+W%G*V+2*Math.PI/h*Math.floor(W/G),y||(U=g-W%G*V-2*Math.PI/h*Math.floor(W/G)),B[W].data.x=I[0]+Math.cos(U)*$,B[W].data.y=I[1]+Math.sin(U)*$;return t&&B.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:B,edges:b}]}))}))},t}(),_=function(t,e,r){void 0===r&&(r=!1);var n=[M(e[0])],o={},i=e.length;o[e[0].id]=!0;var a=0;return e.forEach((function(s,u){if(0!==u)if(u!==i-1&&t.getDegree(s.id,"both")===t.getDegree(e[u+1].id,"both")&&!t.areNeighbors(n[a].id,s.id)||o[s.id]){for(var d=r?t.getSuccessors(n[a].id):t.getNeighbors(n[a].id),h=!1,c=0;c<d.length;c++){var l=d[c];if(t.getDegree(l.id)===t.getDegree(s.id)&&!o[l.id]){n.push(M(l)),o[l.id]=!0,h=!0;break}}for(var f=0;!h&&(o[e[f].id]||(n.push(M(e[f])),o[e[f].id]=!0,h=!0),++f!==i););}else n.push(M(s)),o[s.id]=!0,a++})),n},z=function(t,e,r){var n=t,o=e,i=r;return n||"undefined"==typeof window||(n=window.innerWidth),o||"undefined"==typeof window||(o=window.innerHeight),i||(i=[n/2,o/2]),[n,o,i]},R=Array.isArray,I=function(t){for(var e=[],r=t.length,n=0;n<r;n+=1){e[n]=[];for(var o=0;o<r;o+=1)n===o?e[n][o]=0:0!==t[n][o]&&t[n][o]?e[n][o]=t[n][o]:e[n][o]=1/0}for(var i=0;i<r;i+=1)for(n=0;n<r;n+=1)for(o=0;o<r;o+=1)e[n][o]>e[n][i]+e[i][o]&&(e[n][o]=e[n][i]+e[i][o]);return e},D=function(t,e){var r=t.nodes,n=t.edges,o=[],i={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(t,e){i[t.id]=e,o.push([])})),null==n||n.forEach((function(t){var r=t.source,n=t.target,a=i[r],s=i[n];void 0!==a&&void 0!==s&&(o[a][s]=1,e||(o[s][a]=1))})),o},P=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},O=function(t,e,r,n,o,i){if(void 0===n&&(n="TB"),void 0===i&&(i={}),null==e?void 0:e.length)for(var a=i.stopBranchFn,s=i.stopAllFn,u=0;u<e.length;u++){var d=e[u];if(t.hasNode(d.id)&&!(null==a?void 0:a(d))){if(null==s?void 0:s(d))return;"TB"===n&&r(d),O(t,t.getChildren(d.id,o),r,n,o,i),"TB"!==n&&r(d)}}};const C=Object.prototype.toString;function T(t){const e=C.call(t);return e.endsWith("Array]")&&!e.includes("Big")}function F(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!T(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==r.output){if(!T(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!T(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[n],s=n+1;s<i;s++)t[s]<a&&(a=t[s]);return a}(t),o=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!T(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[n],s=n+1;s<i;s++)t[s]>a&&(a=t[s]);return a}(t);if(n===o)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=r.min,a=void 0===i?r.autoMinMax?n:0:i,s=r.max,u=void 0===s?r.autoMinMax?o:1:s;if(a>=u)throw new RangeError("min option must be smaller than max option");for(var d=(u-a)/(o-n),h=0;h<t.length;h++)e[h]=(t[h]-n)*d+a;return e}const L=" ".repeat(2),q=" ".repeat(4);function j(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\n${L}[\n${q}${function(t,e,r,n,o){const{rows:i,columns:a}=t,s=Math.min(i,e),u=Math.min(a,r),d=[];if("auto"===o){o=!1;t:for(let e=0;e<s;e++)for(let r=0;r<u;r++)if(t.get(e,r)<0){o=!0;break t}}for(let e=0;e<s;e++){let r=[];for(let i=0;i<u;i++)r.push(V(t.get(e,i),n,o));d.push(`${r.join(" ")}`)}return u!==a&&(d[d.length-1]+=` ... ${a-r} more columns`),s!==i&&d.push(`... ${i-e} more rows`),d.join(`\n${q}`)}(t,r,n,o,i)}\n${L}]\n${L}rows: ${t.rows}\n${L}columns: ${t.columns}\n}`}function V(t,e,r){return(t>=0&&r?` ${B(t,e-1)}`:B(t,e)).padEnd(e)}function B(t,e){let r=t.toString();if(r.length<=e)return r;let n=t.toFixed(e);if(n.length>e&&(n=t.toFixed(Math.max(0,e-(n.length-e)))),n.length<=e&&!n.startsWith("0.000")&&!n.startsWith("-0.000"))return n;let o=t.toExponential(e);return o.length>e&&(o=t.toExponential(Math.max(0,e-(o.length-e)))),o.slice(0)}function G(t,e,r){let n=r?t.rows:t.rows-1;if(e<0||e>n)throw new RangeError("Row index out of range")}function W(t,e,r){let n=r?t.columns:t.columns-1;if(e<0||e>n)throw new RangeError("Column index out of range")}function $(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function U(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function H(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(K("startRow",e),K("endRow",r),K("startColumn",n),K("endColumn",o),e>r||n>o||e<0||e>=t.rows||r<0||r>=t.rows||n<0||n>=t.columns||o<0||o>=t.columns)throw new RangeError("Submatrix indices are out of range")}function Y(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function K(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function J(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class X{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new Z(t,e);for(let o=0;o<t;o++)for(let t=0;t<e;t++)n.set(o,t,r[o*e+t]);return n}static rowVector(t){let e=new Z(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new Z(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new Z(t,e)}static ones(t,e){return new Z(t,e).fill(1)}static rand(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{random:n=Math.random}=r;let o=new Z(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)o.set(r,t,n());return o}static randInt(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{min:n=0,max:o=1e3,random:i=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(n>=o)throw new RangeError("min must be smaller than max");let a=o-n,s=new Z(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++){let e=n+Math.round(i()*a);s.set(r,t,e)}return s}static eye(t,e,r){void 0===e&&(e=t),void 0===r&&(r=1);let n=Math.min(t,e),o=this.zeros(t,e);for(let t=0;t<n;t++)o.set(t,t,r);return o}static diag(t,e,r){let n=t.length;void 0===e&&(e=n),void 0===r&&(r=e);let o=Math.min(n,e,r),i=this.zeros(e,r);for(let e=0;e<o;e++)i.set(e,e,t[e]);return i}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new Z(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.min(t.get(i,r),e.get(i,r)));return o}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new this(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.max(t.get(i,r),e.get(i,r)));return o}static checkMatrix(t){return X.isMatrix(t)?t:new Z(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);for(let r=e+1;r<this.rows;r++)0!==this.get(t,r)&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let o=e;o<t.rows;o++)t.get(o,r)>t.get(n,r)&&(n=o);if(0===t.get(n,r))r++;else{t.swapRows(e,n);let o=t.get(e,r);for(let n=r;n<t.columns;n++)t.set(e,n,t.get(e,n)/o);for(let n=e+1;n<t.rows;n++){let o=t.get(n,r)/t.get(e,r);t.set(n,r,0);for(let i=r+1;i<t.columns;i++)t.set(n,i,t.get(n,i)-t.get(e,i)*o)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(0===t.maxRow(n))n--;else{let o=0,i=!1;for(;o<r&&!1===i;)1===t.get(n,o)?i=!0:o++;for(let r=0;r<n;r++){let i=t.get(r,o);for(let a=o;a<e;a++){let e=t.get(r,a)-i*t.get(n,a);t.set(r,a,e)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new Z(this.rows*e,this.columns*r);for(let t=0;t<e;t++)for(let e=0;e<r;e++)n.setSubMatrix(this,this.rows*t,this.columns*e);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){G(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return Z.rowVector(this.getRow(t))}setRow(t,e){G(this,t),e=$(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){G(this,t),G(this,e);for(let r=0;r<this.columns;r++){let n=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,n)}return this}getColumn(t){W(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return Z.columnVector(this.getColumn(t))}setColumn(t,e){W(this,t),e=U(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){W(this,t),W(this,e);for(let r=0;r<this.rows;r++){let n=this.get(r,t);this.set(r,t,this.get(r,e)),this.set(r,e,n)}return this}addRowVector(t){t=$(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[r]);return this}subRowVector(t){t=$(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[r]);return this}mulRowVector(t){t=$(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[r]);return this}divRowVector(t){t=$(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[r]);return this}addColumnVector(t){t=U(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[e]);return this}subColumnVector(t){t=U(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[e]);return this}mulColumnVector(t){t=U(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[e]);return this}divColumnVector(t){t=U(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){G(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){W(this,t);for(let r=0;r<this.rows;r++)this.set(r,t,this.get(r,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){J(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){J(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}maxRow(t){if(G(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r));return e}maxRowIndex(t){G(this,t),J(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),r[1]=n);return r}minRow(t){if(G(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r));return e}minRowIndex(t){G(this,t),J(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),r[1]=n);return r}maxColumn(t){if(W(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t));return e}maxColumnIndex(t){W(this,t),J(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),r[0]=n);return r}minColumn(t){if(W(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t));return e}minColumnIndex(t){W(this,t),J(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),r[0]=n);return r}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let r=0;r<t;r++)e.push(this.get(r,r));return e}norm(t="frobenius"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${t}`)}}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t+=this.get(e,r),this.set(e,r,t);return this}dot(t){X.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=Z.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new Z(e,n),i=new Float64Array(r);for(let a=0;a<n;a++){for(let e=0;e<r;e++)i[e]=t.get(e,a);for(let t=0;t<e;t++){let e=0;for(let n=0;n<r;n++)e+=this.get(t,n)*i[n];o.set(t,a,e)}}return o}strassen2x2(t){t=Z.checkMatrix(t);let e=new Z(2,2);const r=this.get(0,0),n=t.get(0,0),o=this.get(0,1),i=t.get(0,1),a=this.get(1,0),s=t.get(1,0),u=this.get(1,1),d=t.get(1,1),h=(r+u)*(n+d),c=(a+u)*n,l=r*(i-d),f=u*(s-n),g=(r+o)*d,p=h+f-g+(o-u)*(s+d),v=l+g,y=c+f,m=h-c+l+(a-r)*(n+i);return e.set(0,0,p),e.set(0,1,v),e.set(1,0,y),e.set(1,1,m),e}strassen3x3(t){t=Z.checkMatrix(t);let e=new Z(3,3);const r=this.get(0,0),n=this.get(0,1),o=this.get(0,2),i=this.get(1,0),a=this.get(1,1),s=this.get(1,2),u=this.get(2,0),d=this.get(2,1),h=this.get(2,2),c=t.get(0,0),l=t.get(0,1),f=t.get(0,2),g=t.get(1,0),p=t.get(1,1),v=t.get(1,2),y=t.get(2,0),m=t.get(2,1),w=t.get(2,2),x=(r-i)*(-l+p),E=(-r+i+a)*(c-l+p),N=(i+a)*(-c+l),b=r*c,M=(-r+u+d)*(c-f+v),S=(-r+u)*(f-v),A=(u+d)*(-c+f),k=(-o+d+h)*(p+y-m),_=(o-h)*(p-m),z=o*y,R=(d+h)*(-y+m),I=(-o+a+s)*(v+y-w),D=(o-s)*(v-w),P=(a+s)*(-y+w),O=b+z+n*g,C=(r+n+o-i-a-d-h)*p+E+N+b+k+z+R,T=b+M+A+(r+n+o-a-s-u-d)*v+z+I+P,F=x+a*(-c+l+g-p-v-y+w)+E+b+z+I+D,L=x+E+N+b+s*m,q=z+I+D+P+i*f,j=b+M+S+d*(-c+f+g-p-v-y+m)+k+_+z,V=k+_+z+R+u*l,B=b+M+S+A+h*w;return e.set(0,0,O),e.set(0,1,C),e.set(0,2,T),e.set(1,0,F),e.set(1,1,L),e.set(1,2,q),e.set(2,0,j),e.set(2,1,V),e.set(2,2,B),e}mmulStrassen(t){t=Z.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,o=t.rows,i=t.columns;function a(t,e,r){let n=t.rows,o=t.columns;if(n===e&&o===r)return t;{let n=X.zeros(e,r);return n=n.setSubMatrix(t,0,0),n}}n!==o&&console.warn(`Multiplying ${r} x ${n} and ${o} x ${i} matrix: dimensions do not match.`);let s=Math.max(r,o),u=Math.max(n,i);return e=a(e,s,u),function t(e,r,n,o){if(n<=512||o<=512)return e.mmul(r);n%2==1&&o%2==1?(e=a(e,n+1,o+1),r=a(r,n+1,o+1)):n%2==1?(e=a(e,n+1,o),r=a(r,n+1,o)):o%2==1&&(e=a(e,n,o+1),r=a(r,n,o+1));let i=parseInt(e.rows/2,10),s=parseInt(e.columns/2,10),u=e.subMatrix(0,i-1,0,s-1),d=r.subMatrix(0,i-1,0,s-1),h=e.subMatrix(0,i-1,s,e.columns-1),c=r.subMatrix(0,i-1,s,r.columns-1),l=e.subMatrix(i,e.rows-1,0,s-1),f=r.subMatrix(i,r.rows-1,0,s-1),g=e.subMatrix(i,e.rows-1,s,e.columns-1),p=r.subMatrix(i,r.rows-1,s,r.columns-1),v=t(X.add(u,g),X.add(d,p),i,s),y=t(X.add(l,g),d,i,s),m=t(u,X.sub(c,p),i,s),w=t(g,X.sub(f,d),i,s),x=t(X.add(u,h),p,i,s),E=t(X.sub(l,u),X.add(d,c),i,s),N=t(X.sub(h,g),X.add(f,p),i,s),b=X.add(v,w);b.sub(x),b.add(N);let M=X.add(m,x),S=X.add(y,w),A=X.sub(v,y);A.add(m),A.add(E);let k=X.zeros(2*b.rows,2*b.columns);return k=k.setSubMatrix(b,0,0),k=k.setSubMatrix(M,b.rows,0),k=k.setSubMatrix(S,0,b.columns),k=k.setSubMatrix(A,b.rows,b.columns),k.subMatrix(0,n-1,0,o-1)}(e,t=a(t,s,u),s,u)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new Z(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&F(o,{min:e,max:r,output:o}),n.setRow(t,o)}return n}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new Z(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&F(o,{min:e,max:r,output:o}),n.setColumn(t,o)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let t=this.get(e,r),n=this.get(e,this.columns-1-r);this.set(e,r,n),this.set(e,this.columns-1-r,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let t=this.get(r,e),n=this.get(this.rows-1-r,e);this.set(r,e,n),this.set(this.rows-1-r,e,t)}return this}kroneckerProduct(t){t=Z.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new Z(e*n,r*o);for(let a=0;a<e;a++)for(let e=0;e<r;e++)for(let r=0;r<n;r++)for(let s=0;s<o;s++)i.set(n*a+r,o*e+s,this.get(a,e)*t.get(r,s));return i}kroneckerSum(t){if(t=Z.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(Z.eye(r,r)),o=Z.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new Z(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=Q){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=Q){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){H(this,t,e,r,n);let o=new Z(e-t+1,n-r+1);for(let i=t;i<=e;i++)for(let e=r;e<=n;e++)o.set(i-t,e-r,this.get(i,e));return o}subMatrixRow(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new Z(t.length,r-e+1);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.rows)throw new RangeError(`Row index out of range: ${t[o]}`);n.set(o,i-e,this.get(t[o],i))}return n}subMatrixColumn(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new Z(r-e+1,t.length);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.columns)throw new RangeError(`Column index out of range: ${t[o]}`);n.set(i-e,o,this.get(i,t[o]))}return n}setSubMatrix(t,e,r){if((t=Z.checkMatrix(t)).isEmpty())return this;H(this,e,e+t.rows-1,r,r+t.columns-1);for(let n=0;n<t.rows;n++)for(let o=0;o<t.columns;o++)this.set(e+n,r+o,t.get(n,o));return this}selection(t,e){!function(t,e){if(!T(e))throw new TypeError("row indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.rows)throw new RangeError("row indices are out of range")}(this,t),function(t,e){if(!T(e))throw new TypeError("column indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let r=new Z(t.length,e.length);for(let n=0;n<t.length;n++){let o=t[n];for(let t=0;t<e.length;t++){let i=e[t];r.set(n,t,this.get(o,i))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){let t=new Z(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(e,r,this.get(e,r));return t}sum(t){switch(t){case"row":return function(t){let e=Y(t.rows);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]+=t.get(r,n);return e}(this);case"column":return function(t){let e=Y(t.columns);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]+=t.get(r,n);return e}(this);case void 0:return function(t){let e=0;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e+=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=Y(t.rows,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]*=t.get(r,n);return e}(this);case"column":return function(t){let e=Y(t.columns,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]*=t.get(r,n);return e}(this);case void 0:return function(t){let e=1;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e*=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:r=!0,mean:n=this.mean(t)}=e;if("boolean"!=typeof r)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!T(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let a=0;a<n;a++){let n=0,s=0,u=0;for(let e=0;e<o;e++)u=t.get(a,e)-r[a],n+=u,s+=u*u;e?i.push((s-n*n/o)/(o-1)):i.push((s-n*n/o)/o)}return i}(this,r,n);case"column":if(!T(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let a=0;a<o;a++){let o=0,s=0,u=0;for(let e=0;e<n;e++)u=t.get(e,a)-r[a],o+=u,s+=u*u;e?i.push((s-o*o/n)/(n-1)):i.push((s-o*o/n)/n)}return i}(this,r,n);case void 0:if("number"!=typeof n)throw new TypeError("mean must be a number");return function(t,e,r){const n=t.rows,o=t.columns,i=n*o;let a=0,s=0,u=0;for(let e=0;e<n;e++)for(let n=0;n<o;n++)u=t.get(e,n)-r,a+=u,s+=u*u;return e?(s-a*a/i)/(i-1):(s-a*a/i)/i}(this,r,n);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const r=this.variance(t,e);if(void 0===t)return Math.sqrt(r);for(let t=0;t<r.length;t++)r[t]=Math.sqrt(r[t]);return r}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":if(!T(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[r])}(this,r),this;case"column":if(!T(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[n])}(this,r),this;case void 0:if("number"!=typeof r)throw new TypeError("center must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let r=e.scale;switch(t){case"row":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.rows;r++){let n=0;for(let e=0;e<t.columns;e++)n+=Math.pow(t.get(r,e),2)/(t.columns-1);e.push(Math.sqrt(n))}return e}(this);else if(!T(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[r])}(this,r),this;case"column":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.columns;r++){let n=0;for(let e=0;e<t.rows;e++)n+=Math.pow(t.get(e,r),2)/(t.rows-1);e.push(Math.sqrt(n))}return e}(this);else if(!T(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[n])}(this,r),this;case void 0:if(void 0===r)r=function(t){const e=t.size-1;let r=0;for(let n=0;n<t.columns;n++)for(let o=0;o<t.rows;o++)r+=Math.pow(t.get(o,n),2)/e;return Math.sqrt(r)}(this);else if("number"!=typeof r)throw new TypeError("scale must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return j(this,t)}}function Q(t,e){return t-e}X.prototype.klass="Matrix","undefined"!=typeof Symbol&&(X.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return j(this)}),X.random=X.rand,X.randomInt=X.randInt,X.diagonal=X.diag,X.prototype.diagonal=X.prototype.diag,X.identity=X.eye,X.prototype.negate=X.prototype.neg,X.prototype.tensorProduct=X.prototype.kroneckerProduct;class Z extends X{constructor(t,e){if(super(),Z.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let r=0;r<t;r++)this.data.push(new Float64Array(e))}else{if(!T(t))throw new TypeError("First argument must be a positive number or an array");{const r=t;if("number"!=typeof(e=(t=r.length)?r[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let n=0;n<t;n++){if(r[n].length!==e)throw new RangeError("Inconsistent array dimensions");if(!r[n].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(r[n]))}}}this.rows=t,this.columns=e}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}removeRow(t){return G(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),G(this,t,!0),e=Float64Array.from($(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){W(this,t);for(let e=0;e<this.rows;e++){const r=new Float64Array(this.columns-1);for(let n=0;n<t;n++)r[n]=this.data[e][n];for(let n=t+1;n<this.columns;n++)r[n-1]=this.data[e][n];this.data[e]=r}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),W(this,t,!0),e=U(this,e);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns+1);let o=0;for(;o<t;o++)n[o]=this.data[r][o];for(n[o++]=e[r];o<this.columns+1;o++)n[o]=this.data[r][o-1];this.data[r]=n}return this.columns+=1,this}}!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t.get(e,r));return this},t.add=function(t,r){return new e(t).add(r)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t.get(e,r));return this},t.sub=function(t,r){return new e(t).sub(r)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t.get(e,r));return this},t.mul=function(t,r){return new e(t).mul(r)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t.get(e,r));return this},t.div=function(t,r){return new e(t).div(r)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t.get(e,r));return this},t.mod=function(t,r){return new e(t).mod(r)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t.get(e,r));return this},t.and=function(t,r){return new e(t).and(r)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t.get(e,r));return this},t.or=function(t,r){return new e(t).or(r)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t.get(e,r));return this},t.xor=function(t,r){return new e(t).xor(r)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t.get(e,r));return this},t.leftShift=function(t,r){return new e(t).leftShift(r)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>t.get(e,r));return this},t.signPropagatingRightShift=function(t,r){return new e(t).signPropagatingRightShift(r)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>t.get(e,r));return this},t.rightShift=function(t,r){return new e(t).rightShift(r)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,r){return new e(t).pow(r)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,Math.pow(this.get(e,r),t));return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,Math.pow(this.get(e,r),t.get(e,r)));return this}}(X,Z);class tt extends X{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}}function et(t,e){let r=0;return Math.abs(t)>Math.abs(e)?(r=e/t,Math.abs(t)*Math.sqrt(1+r*r)):0!==e?(r=t/e,Math.abs(e)*Math.sqrt(1+r*r)):0}class rt{constructor(t,e={}){if((t=tt.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:i=!0,autoTranspose:a=!1}=e;let s,u=Boolean(o),d=Boolean(i),h=!1;if(r<n)if(a){s=t.transpose(),r=s.rows,n=s.columns,h=!0;let e=u;u=d,d=e}else s=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else s=t.clone();let c=Math.min(r,n),l=Math.min(r+1,n),f=new Float64Array(l),g=new Z(r,c),p=new Z(n,n),v=new Float64Array(n),y=new Float64Array(r),m=new Float64Array(l);for(let t=0;t<l;t++)m[t]=t;let w=Math.min(r-1,n),x=Math.max(0,Math.min(n-2,r)),E=Math.max(w,x);for(let t=0;t<E;t++){if(t<w){f[t]=0;for(let e=t;e<r;e++)f[t]=et(f[t],s.get(e,t));if(0!==f[t]){s.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<r;e++)s.set(e,t,s.get(e,t)/f[t]);s.set(t,t,s.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<n;e++){if(t<w&&0!==f[t]){let n=0;for(let o=t;o<r;o++)n+=s.get(o,t)*s.get(o,e);n=-n/s.get(t,t);for(let o=t;o<r;o++)s.set(o,e,s.get(o,e)+n*s.get(o,t))}v[e]=s.get(t,e)}if(u&&t<w)for(let e=t;e<r;e++)g.set(e,t,s.get(e,t));if(t<x){v[t]=0;for(let e=t+1;e<n;e++)v[t]=et(v[t],v[e]);if(0!==v[t]){v[t+1]<0&&(v[t]=0-v[t]);for(let e=t+1;e<n;e++)v[e]/=v[t];v[t+1]+=1}if(v[t]=-v[t],t+1<r&&0!==v[t]){for(let e=t+1;e<r;e++)y[e]=0;for(let e=t+1;e<r;e++)for(let r=t+1;r<n;r++)y[e]+=v[r]*s.get(e,r);for(let e=t+1;e<n;e++){let n=-v[e]/v[t+1];for(let o=t+1;o<r;o++)s.set(o,e,s.get(o,e)+n*y[o])}}if(d)for(let e=t+1;e<n;e++)p.set(e,t,v[e])}}let N=Math.min(n,r+1);if(w<n&&(f[w]=s.get(w,w)),r<N&&(f[N-1]=0),x+1<N&&(v[x]=s.get(x,N-1)),v[N-1]=0,u){for(let t=w;t<c;t++){for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}for(let t=w-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<c;e++){let n=0;for(let o=t;o<r;o++)n+=g.get(o,t)*g.get(o,e);n=-n/g.get(t,t);for(let o=t;o<r;o++)g.set(o,e,g.get(o,e)+n*g.get(o,t))}for(let e=t;e<r;e++)g.set(e,t,-g.get(e,t));g.set(t,t,1+g.get(t,t));for(let e=0;e<t-1;e++)g.set(e,t,0)}else{for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}}if(d)for(let t=n-1;t>=0;t--){if(t<x&&0!==v[t])for(let e=t+1;e<n;e++){let r=0;for(let o=t+1;o<n;o++)r+=p.get(o,t)*p.get(o,e);r=-r/p.get(t+1,t);for(let o=t+1;o<n;o++)p.set(o,e,p.get(o,e)+r*p.get(o,t))}for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}let b=N-1,M=0,S=Number.EPSILON;for(;N>0;){let t,e;for(t=N-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+S*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(v[t])<=e||Number.isNaN(v[t])){v[t]=0;break}}if(t===N-2)e=4;else{let r;for(r=N-1;r>=t&&r!==t;r--){let e=(r!==N?Math.abs(v[r]):0)+(r!==t+1?Math.abs(v[r-1]):0);if(Math.abs(f[r])<=S*e){f[r]=0;break}}r===t?e=3:r===N-1?e=1:(e=2,t=r)}switch(t++,e){case 1:{let e=v[N-2];v[N-2]=0;for(let r=N-2;r>=t;r--){let o=et(f[r],e),i=f[r]/o,a=e/o;if(f[r]=o,r!==t&&(e=-a*v[r-1],v[r-1]=i*v[r-1]),d)for(let t=0;t<n;t++)o=i*p.get(t,r)+a*p.get(t,N-1),p.set(t,N-1,-a*p.get(t,r)+i*p.get(t,N-1)),p.set(t,r,o)}break}case 2:{let e=v[t-1];v[t-1]=0;for(let n=t;n<N;n++){let o=et(f[n],e),i=f[n]/o,a=e/o;if(f[n]=o,e=-a*v[n],v[n]=i*v[n],u)for(let e=0;e<r;e++)o=i*g.get(e,n)+a*g.get(e,t-1),g.set(e,t-1,-a*g.get(e,n)+i*g.get(e,t-1)),g.set(e,n,o)}break}case 3:{const e=Math.max(Math.abs(f[N-1]),Math.abs(f[N-2]),Math.abs(v[N-2]),Math.abs(f[t]),Math.abs(v[t])),o=f[N-1]/e,i=f[N-2]/e,a=v[N-2]/e,s=f[t]/e,h=v[t]/e,c=((i+o)*(i-o)+a*a)/2,l=o*a*(o*a);let y=0;0===c&&0===l||(y=c<0?0-Math.sqrt(c*c+l):Math.sqrt(c*c+l),y=l/(c+y));let m=(s+o)*(s-o)+y,w=s*h;for(let e=t;e<N-1;e++){let o=et(m,w);0===o&&(o=Number.MIN_VALUE);let i=m/o,a=w/o;if(e!==t&&(v[e-1]=o),m=i*f[e]+a*v[e],v[e]=i*v[e]-a*f[e],w=a*f[e+1],f[e+1]=i*f[e+1],d)for(let t=0;t<n;t++)o=i*p.get(t,e)+a*p.get(t,e+1),p.set(t,e+1,-a*p.get(t,e)+i*p.get(t,e+1)),p.set(t,e,o);if(o=et(m,w),0===o&&(o=Number.MIN_VALUE),i=m/o,a=w/o,f[e]=o,m=i*v[e]+a*f[e+1],f[e+1]=-a*v[e]+i*f[e+1],w=a*v[e+1],v[e+1]=i*v[e+1],u&&e<r-1)for(let t=0;t<r;t++)o=i*g.get(t,e)+a*g.get(t,e+1),g.set(t,e+1,-a*g.get(t,e)+i*g.get(t,e+1)),g.set(t,e,o)}v[N-2]=m,M+=1;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,d))for(let e=0;e<=b;e++)p.set(e,t,-p.get(e,t));for(;t<b&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,d&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);if(u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);t++}M=0,N--}}if(h){let t=p;p=g,g=t}this.m=r,this.n=n,this.s=f,this.U=g,this.V=p}solve(t){let e=t,r=this.threshold,n=this.s.length,o=Z.zeros(n,n);for(let t=0;t<n;t++)Math.abs(this.s[t])<=r?o.set(t,t,0):o.set(t,t,1/this.s[t]);let i=this.U,a=this.rightSingularVectors,s=a.mmul(o),u=a.rows,d=i.rows,h=Z.zeros(u,d);for(let t=0;t<u;t++)for(let e=0;e<d;e++){let r=0;for(let o=0;o<n;o++)r+=s.get(t,o)*i.get(e,o);h.set(t,e,r)}return h.mmul(e)}solveForDiagonal(t){return this.solve(Z.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new Z(r,this.s.length);for(let i=0;i<r;i++)for(let r=0;r<n;r++)Math.abs(this.s[r])>e&&o.set(i,r,t.get(i,r)/this.s[r]);let i=this.U,a=i.rows,s=i.columns,u=new Z(r,a);for(let t=0;t<r;t++)for(let e=0;e<a;e++){let r=0;for(let n=0;n<s;n++)r+=o.get(t,n)*i.get(e,n);u.set(t,e,r)}return u}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,o=r.length;n<o;n++)r[n]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return Z.diag(this.s)}}var nt={center:[0,0],linkDistance:50},ot=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=n(n({},nt),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericMDSLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericMDSLayout(!0,t,e),[2]}))}))},t.prototype.genericMDSLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f,g,p;return a(this,(function(a){return o=n(n({},this.options),r),i=o.center,s=void 0===i?[0,0]:i,u=o.linkDistance,d=void 0===u?50:u,h=e.getAllNodes(),c=e.getAllEdges(),(null==h?void 0:h.length)&&1!==h.length?(l=D({nodes:h,edges:c},!1),f=I(l),it(f),v=d,y=[],f.forEach((function(t){var e=[];t.forEach((function(t){e.push(t*v)})),y.push(e)})),g=at(y),p=[],g.forEach((function(t,e){var r=M(h[e]);r.data.x=t[0]+s[0],r.data.y=t[1]+s[1],p.push(r)})),t&&p.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:p,edges:c}]):[2,S(e,t,s)];var v,y}))}))},t}(),it=function(t){var e=-999999;t.forEach((function(t){t.forEach((function(t){t!==1/0&&e<t&&(e=t)}))})),t.forEach((function(r,n){r.forEach((function(r,o){r===1/0&&(t[n][o]=e)}))}))},at=function(t){var e=Z.mul(Z.pow(t,2),-.5),r=e.mean("row"),n=e.mean("column"),o=e.mean();e.add(o).subRowVector(r).subColumnVector(n);var i=new rt(e),a=Z.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return Z.mul([t],[a]).toJSON()[0].splice(0,2)}))};function st(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,a,s,u,d,h,c,l,f=t._root,g={data:n},p=t._x0,v=t._y0,y=t._x1,m=t._y1;if(!f)return t._root=g,t;for(;f.length;)if((d=e>=(i=(p+y)/2))?p=i:y=i,(h=r>=(a=(v+m)/2))?v=a:m=a,o=f,!(f=f[c=h<<1|d]))return o[c]=g,t;if(s=+t._x.call(null,f.data),u=+t._y.call(null,f.data),e===s&&r===u)return g.next=f,o?o[c]=g:t._root=g,t;do{o=o?o[c]=new Array(4):t._root=new Array(4),(d=e>=(i=(p+y)/2))?p=i:y=i,(h=r>=(a=(v+m)/2))?v=a:m=a}while((c=h<<1|d)==(l=(u>=a)<<1|s>=i));return o[l]=f,o[c]=g,t}function ut(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function dt(t){return t[0]}function ht(t){return t[1]}function ct(t,e,r){var n=new lt(null==e?dt:e,null==r?ht:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function lt(t,e,r,n,o,i){this._x=t,this._y=e,this._x0=r,this._y0=n,this._x1=o,this._y1=i,this._root=void 0}function ft(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var gt=ct.prototype=lt.prototype;function pt(t,e,r,n,o){if(isNaN(e)||isNaN(r)||isNaN(n))return t;var i,a,s,u,d,h,c,l,f,g,p,v,y=t._root,m={data:o},w=t._x0,x=t._y0,E=t._z0,N=t._x1,b=t._y1,M=t._z1;if(!y)return t._root=m,t;for(;y.length;)if((l=e>=(a=(w+N)/2))?w=a:N=a,(f=r>=(s=(x+b)/2))?x=s:b=s,(g=n>=(u=(E+M)/2))?E=u:M=u,i=y,!(y=y[p=g<<2|f<<1|l]))return i[p]=m,t;if(d=+t._x.call(null,y.data),h=+t._y.call(null,y.data),c=+t._z.call(null,y.data),e===d&&r===h&&n===c)return m.next=y,i?i[p]=m:t._root=m,t;do{i=i?i[p]=new Array(8):t._root=new Array(8),(l=e>=(a=(w+N)/2))?w=a:N=a,(f=r>=(s=(x+b)/2))?x=s:b=s,(g=n>=(u=(E+M)/2))?E=u:M=u}while((p=g<<2|f<<1|l)==(v=(c>=u)<<2|(h>=s)<<1|d>=a));return i[v]=y,i[p]=m,t}function vt(t,e,r,n,o,i,a){this.node=t,this.x0=e,this.y0=r,this.z0=n,this.x1=o,this.y1=i,this.z1=a}function yt(t){return t[0]}function mt(t){return t[1]}function wt(t){return t[2]}function xt(t,e,r,n){var o=new Et(null==e?yt:e,null==r?mt:r,null==n?wt:n,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?o:o.addAll(t)}function Et(t,e,r,n,o,i,a,s,u){this._x=t,this._y=e,this._z=r,this._x0=n,this._y0=o,this._z0=i,this._x1=a,this._y1=s,this._z1=u,this._root=void 0}function Nt(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}gt.copy=function(){var t,e,r=new lt(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root;if(!n)return r;if(!n.length)return r._root=ft(n),r;for(t=[{source:n,target:r._root=new Array(4)}];n=t.pop();)for(var o=0;o<4;++o)(e=n.source[o])&&(e.length?t.push({source:e,target:n.target[o]=new Array(4)}):n.target[o]=ft(e));return r},gt.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t);return st(this.cover(e,r),e,r,t)},gt.addAll=function(t){var e,r,n,o,i=t.length,a=new Array(i),s=new Array(i),u=1/0,d=1/0,h=-1/0,c=-1/0;for(r=0;r<i;++r)isNaN(n=+this._x.call(null,e=t[r]))||isNaN(o=+this._y.call(null,e))||(a[r]=n,s[r]=o,n<u&&(u=n),n>h&&(h=n),o<d&&(d=o),o>c&&(c=o));if(u>h||d>c)return this;for(this.cover(u,d).cover(h,c),r=0;r<i;++r)st(this,a[r],s[r],t[r]);return this},gt.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var r=this._x0,n=this._y0,o=this._x1,i=this._y1;if(isNaN(r))o=(r=Math.floor(t))+1,i=(n=Math.floor(e))+1;else{for(var a,s,u=o-r||1,d=this._root;r>t||t>=o||n>e||e>=i;)switch(s=(e<n)<<1|t<r,(a=new Array(4))[s]=d,d=a,u*=2,s){case 0:o=r+u,i=n+u;break;case 1:r=o-u,i=n+u;break;case 2:o=r+u,n=i-u;break;case 3:r=o-u,n=i-u}this._root&&this._root.length&&(this._root=d)}return this._x0=r,this._y0=n,this._x1=o,this._y1=i,this},gt.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},gt.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},gt.find=function(t,e,r){var n,o,i,a,s,u,d,h=this._x0,c=this._y0,l=this._x1,f=this._y1,g=[],p=this._root;for(p&&g.push(new ut(p,h,c,l,f)),null==r?r=1/0:(h=t-r,c=e-r,l=t+r,f=e+r,r*=r);u=g.pop();)if(!(!(p=u.node)||(o=u.x0)>l||(i=u.y0)>f||(a=u.x1)<h||(s=u.y1)<c))if(p.length){var v=(o+a)/2,y=(i+s)/2;g.push(new ut(p[3],v,y,a,s),new ut(p[2],o,y,v,s),new ut(p[1],v,i,a,y),new ut(p[0],o,i,v,y)),(d=(e>=y)<<1|t>=v)&&(u=g[g.length-1],g[g.length-1]=g[g.length-1-d],g[g.length-1-d]=u)}else{var m=t-+this._x.call(null,p.data),w=e-+this._y.call(null,p.data),x=m*m+w*w;if(x<r){var E=Math.sqrt(r=x);h=t-E,c=e-E,l=t+E,f=e+E,n=p.data}}return n},gt.remove=function(t){if(isNaN(i=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t)))return this;var e,r,n,o,i,a,s,u,d,h,c,l,f=this._root,g=this._x0,p=this._y0,v=this._x1,y=this._y1;if(!f)return this;if(f.length)for(;;){if((d=i>=(s=(g+v)/2))?g=s:v=s,(h=a>=(u=(p+y)/2))?p=u:y=u,e=f,!(f=f[c=h<<1|d]))return this;if(!f.length)break;(e[c+1&3]||e[c+2&3]||e[c+3&3])&&(r=e,l=c)}for(;f.data!==t;)if(n=f,!(f=f.next))return this;return(o=f.next)&&delete f.next,n?(o?n.next=o:delete n.next,this):e?(o?e[c]=o:delete e[c],(f=e[0]||e[1]||e[2]||e[3])&&f===(e[3]||e[2]||e[1]||e[0])&&!f.length&&(r?r[l]=f:this._root=f),this):(this._root=o,this)},gt.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},gt.root=function(){return this._root},gt.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},gt.visit=function(t){var e,r,n,o,i,a,s=[],u=this._root;for(u&&s.push(new ut(u,this._x0,this._y0,this._x1,this._y1));e=s.pop();)if(!t(u=e.node,n=e.x0,o=e.y0,i=e.x1,a=e.y1)&&u.length){var d=(n+i)/2,h=(o+a)/2;(r=u[3])&&s.push(new ut(r,d,h,i,a)),(r=u[2])&&s.push(new ut(r,n,h,d,a)),(r=u[1])&&s.push(new ut(r,d,o,i,h)),(r=u[0])&&s.push(new ut(r,n,o,d,h))}return this},gt.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new ut(this._root,this._x0,this._y0,this._x1,this._y1));e=r.pop();){var o=e.node;if(o.length){var i,a=e.x0,s=e.y0,u=e.x1,d=e.y1,h=(a+u)/2,c=(s+d)/2;(i=o[0])&&r.push(new ut(i,a,s,h,c)),(i=o[1])&&r.push(new ut(i,h,s,u,c)),(i=o[2])&&r.push(new ut(i,a,c,h,d)),(i=o[3])&&r.push(new ut(i,h,c,u,d))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},gt.x=function(t){return arguments.length?(this._x=t,this):this._x},gt.y=function(t){return arguments.length?(this._y=t,this):this._y};var bt=xt.prototype=Et.prototype;function Mt(t){var e=0,r=0,n=0,o=0,i=0,a=t.length;if(a){for(var s=0;s<a;s++)(u=t[s])&&u.weight&&(e+=u.weight,r+=u.x*u.weight,n+=u.y*u.weight,o+=u.z*u.weight,i+=u.size*u.weight);t.x=r/e,t.y=n/e,t.z=o/e,t.size=i/e,t.weight=e}else{var u=t;t.x=u.data.x,t.y=u.data.y,t.z=u.data.z,t.size=u.data.size,t.weight=u.data.weight}}bt.copy=function(){var t,e,r=new Et(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),n=this._root;if(!n)return r;if(!n.length)return r._root=Nt(n),r;for(t=[{source:n,target:r._root=new Array(8)}];n=t.pop();)for(var o=0;o<8;++o)(e=n.source[o])&&(e.length?t.push({source:e,target:n.target[o]=new Array(8)}):n.target[o]=Nt(e));return r},bt.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t),n=+this._z.call(null,t);return pt(this.cover(e,r,n),e,r,n,t)},bt.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,r=new Float64Array(e),n=new Float64Array(e),o=new Float64Array(e);let i=1/0,a=1/0,s=1/0,u=-1/0,d=-1/0,h=-1/0;for(let c,l,f,g,p=0;p<e;++p)isNaN(l=+this._x.call(null,c=t[p]))||isNaN(f=+this._y.call(null,c))||isNaN(g=+this._z.call(null,c))||(r[p]=l,n[p]=f,o[p]=g,l<i&&(i=l),l>u&&(u=l),f<a&&(a=f),f>d&&(d=f),g<s&&(s=g),g>h&&(h=g));if(i>u||a>d||s>h)return this;this.cover(i,a,s).cover(u,d,h);for(let i=0;i<e;++i)pt(this,r[i],n[i],o[i],t[i]);return this},bt.cover=function(t,e,r){if(isNaN(t=+t)||isNaN(e=+e)||isNaN(r=+r))return this;var n=this._x0,o=this._y0,i=this._z0,a=this._x1,s=this._y1,u=this._z1;if(isNaN(n))a=(n=Math.floor(t))+1,s=(o=Math.floor(e))+1,u=(i=Math.floor(r))+1;else{for(var d,h,c=a-n||1,l=this._root;n>t||t>=a||o>e||e>=s||i>r||r>=u;)switch(h=(r<i)<<2|(e<o)<<1|t<n,(d=new Array(8))[h]=l,l=d,c*=2,h){case 0:a=n+c,s=o+c,u=i+c;break;case 1:n=a-c,s=o+c,u=i+c;break;case 2:a=n+c,o=s-c,u=i+c;break;case 3:n=a-c,o=s-c,u=i+c;break;case 4:a=n+c,s=o+c,i=u-c;break;case 5:n=a-c,s=o+c,i=u-c;break;case 6:a=n+c,o=s-c,i=u-c;break;case 7:n=a-c,o=s-c,i=u-c}this._root&&this._root.length&&(this._root=l)}return this._x0=n,this._y0=o,this._z0=i,this._x1=a,this._y1=s,this._z1=u,this},bt.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},bt.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1],+t[0][2]).cover(+t[1][0],+t[1][1],+t[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]},bt.find=function(t,e,r,n){var o,i,a,s,u,d,h,c,l,f=this._x0,g=this._y0,p=this._z0,v=this._x1,y=this._y1,m=this._z1,w=[],x=this._root;for(x&&w.push(new vt(x,f,g,p,v,y,m)),null==n?n=1/0:(f=t-n,g=e-n,p=r-n,v=t+n,y=e+n,m=r+n,n*=n);c=w.pop();)if(!(!(x=c.node)||(i=c.x0)>v||(a=c.y0)>y||(s=c.z0)>m||(u=c.x1)<f||(d=c.y1)<g||(h=c.z1)<p))if(x.length){var E=(i+u)/2,N=(a+d)/2,b=(s+h)/2;w.push(new vt(x[7],E,N,b,u,d,h),new vt(x[6],i,N,b,E,d,h),new vt(x[5],E,a,b,u,N,h),new vt(x[4],i,a,b,E,N,h),new vt(x[3],E,N,s,u,d,b),new vt(x[2],i,N,s,E,d,b),new vt(x[1],E,a,s,u,N,b),new vt(x[0],i,a,s,E,N,b)),(l=(r>=b)<<2|(e>=N)<<1|t>=E)&&(c=w[w.length-1],w[w.length-1]=w[w.length-1-l],w[w.length-1-l]=c)}else{var M=t-+this._x.call(null,x.data),S=e-+this._y.call(null,x.data),A=r-+this._z.call(null,x.data),k=M*M+S*S+A*A;if(k<n){var _=Math.sqrt(n=k);f=t-_,g=e-_,p=r-_,v=t+_,y=e+_,m=r+_,o=x.data}}return o},bt.remove=function(t){if(isNaN(i=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t))||isNaN(s=+this._z.call(null,t)))return this;var e,r,n,o,i,a,s,u,d,h,c,l,f,g,p,v=this._root,y=this._x0,m=this._y0,w=this._z0,x=this._x1,E=this._y1,N=this._z1;if(!v)return this;if(v.length)for(;;){if((c=i>=(u=(y+x)/2))?y=u:x=u,(l=a>=(d=(m+E)/2))?m=d:E=d,(f=s>=(h=(w+N)/2))?w=h:N=h,e=v,!(v=v[g=f<<2|l<<1|c]))return this;if(!v.length)break;(e[g+1&7]||e[g+2&7]||e[g+3&7]||e[g+4&7]||e[g+5&7]||e[g+6&7]||e[g+7&7])&&(r=e,p=g)}for(;v.data!==t;)if(n=v,!(v=v.next))return this;return(o=v.next)&&delete v.next,n?(o?n.next=o:delete n.next,this):e?(o?e[g]=o:delete e[g],(v=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&v===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!v.length&&(r?r[p]=v:this._root=v),this):(this._root=o,this)},bt.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},bt.root=function(){return this._root},bt.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},bt.visit=function(t){var e,r,n,o,i,a,s,u,d=[],h=this._root;for(h&&d.push(new vt(h,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=d.pop();)if(!t(h=e.node,n=e.x0,o=e.y0,i=e.z0,a=e.x1,s=e.y1,u=e.z1)&&h.length){var c=(n+a)/2,l=(o+s)/2,f=(i+u)/2;(r=h[7])&&d.push(new vt(r,c,l,f,a,s,u)),(r=h[6])&&d.push(new vt(r,n,l,f,c,s,u)),(r=h[5])&&d.push(new vt(r,c,o,f,a,l,u)),(r=h[4])&&d.push(new vt(r,n,o,f,c,l,u)),(r=h[3])&&d.push(new vt(r,c,l,i,a,s,f)),(r=h[2])&&d.push(new vt(r,n,l,i,c,s,f)),(r=h[1])&&d.push(new vt(r,c,o,i,a,l,f)),(r=h[0])&&d.push(new vt(r,n,o,i,c,l,f))}return this},bt.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new vt(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=r.pop();){var o=e.node;if(o.length){var i,a=e.x0,s=e.y0,u=e.z0,d=e.x1,h=e.y1,c=e.z1,l=(a+d)/2,f=(s+h)/2,g=(u+c)/2;(i=o[0])&&r.push(new vt(i,a,s,u,l,f,g)),(i=o[1])&&r.push(new vt(i,l,s,u,d,f,g)),(i=o[2])&&r.push(new vt(i,a,f,u,l,h,g)),(i=o[3])&&r.push(new vt(i,l,f,u,d,h,g)),(i=o[4])&&r.push(new vt(i,a,s,g,l,f,c)),(i=o[5])&&r.push(new vt(i,l,s,g,d,f,c)),(i=o[6])&&r.push(new vt(i,a,f,g,l,h,c)),(i=o[7])&&r.push(new vt(i,l,f,g,d,h,c))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.z0,e.x1,e.y1,e.z1);return this},bt.x=function(t){return arguments.length?(this._x=t,this):this._x},bt.y=function(t){return arguments.length?(this._y=t,this):this._y},bt.z=function(t){return arguments.length?(this._z=t,this):this._z};var St=function(t,e,r,n,o,i,a){var s;if((null===(s=t.data)||void 0===s?void 0:s.id)!==i.id){for(var u=[r,n,o][a-1],d=i.x-t.x||.1,h=i.y-t.y||.1,c=i.z-t.z||.1,l=[d,h,c],f=u-e,g=0,p=0;p<a;p++)g+=l[p]*l[p];var v=Math.sqrt(g)*g;if(f*f*.81<g){var y=t.weight/v;return i.vx+=d*y,i.vy+=h*y,i.vz+=c*y,!0}if(t.length)return!1;t.data!==i&&(y=t.data.weight/v,i.vx+=d*y,i.vy+=h*y,i.vz+=c*y)}},At={dimensions:2,maxIteration:500,gravity:10,factor:1,edgeStrength:50,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:200,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"},kt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=n(n({},At),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;(this.judgingDistance>this.lastOptions.minMovement||r<1)&&r<t;r++)this.runOneStep(this.lastCalcGraph,this.lastGraph,r,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===e.options.dimensions?t.data.z:void 0})})),n},t.prototype.genericForceLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f,p,v,y,w,x,E,N,b,M,S,A,k=this;return a(this,(function(a){return o=n(n({},this.options),r),i=e.getAllNodes(),s=e.getAllEdges(),u=this.formatOptions(o,e),d=u.dimensions,h=u.width,c=u.height,l=u.nodeSize,f=u.getMass,p=u.nodeStrength,v=u.edgeStrength,y=u.linkDistance,w=i.map((function(t,e){return n(n({},t),{data:n(n({},t.data),{x:m(t.data.x)?t.data.x:Math.random()*h,y:m(t.data.y)?t.data.y:Math.random()*c,z:m(t.data.z)?t.data.z:Math.random()*Math.sqrt(h*c),size:l(t)||30,mass:f(t),nodeStrength:p(t)})})})),x=s.map((function(t){return n(n({},t),{data:n(n({},t.data),{edgeStrength:v(t),linkDistance:y(t,e.getNode(t.source),e.getNode(t.target))})})})),(null==i?void 0:i.length)?(E={},i.forEach((function(t,e){E[t.id]={x:0,y:0,z:0}})),N=new g({nodes:w,edges:x}),this.formatCentripetal(u,N),b=u.maxIteration,M=u.minMovement,S=u.onTick,this.lastLayoutNodes=w,this.lastLayoutEdges=x,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=N,this.lastOptions=u,this.lastVelMap=E,"undefined"==typeof window?[2]:(A=0,[2,new Promise((function(r){k.timeInterval=window.setInterval((function(){i&&k.running||r({nodes:Dt(e,w),edges:s}),k.runOneStep(N,e,A,E,u),k.updatePosition(e,N,E,u),t&&w.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===d?t.data.z:void 0})})),null==S||S({nodes:Dt(e,w),edges:s}),(++A>=b||k.judgingDistance<M)&&(window.clearInterval(k.timeInterval),r({nodes:Dt(e,w),edges:s}))}),0),k.running=!0}))])):(this.lastResult={nodes:[],edges:s},[2,{nodes:[],edges:s}])}))}))},t.prototype.formatOptions=function(t,e){var r=n({},t),o=t.width,i=t.height,a=t.getMass,s=t.nodeSize;r.width=o||"undefined"==typeof window?o:window.innerWidth,r.height=i||"undefined"==typeof window?i:window.innerHeight,t.center||(r.center=[r.width/2,r.height/2]),a||(r.getMass=function(t){var r=1;m(null==t?void 0:t.data.mass)&&(r=null==t?void 0:t.data.mass);var n=e.getDegree(t.id,"both");return!n||n<5?r:5*n*r});var u,d=x(0,t.nodeSpacing);u=s?p(s)?function(t){return s(t)+d(t)}:R(s)?function(t){var e=s;return Math.max(e[0],e[1])+d(t)}:function(t){return s+d(t)}:function(t){var e=((null==t?void 0:t.data)||{}).size;return e?R(e)?Math.max(e[0],e[1])+d(t):w(e)?Math.max(e.width,e.height)+d(t):e+d(t):10+d(t)},r.nodeSize=u;var h=t.linkDistance?x(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))};return r.linkDistance=h,r.nodeStrength=x(1,t.nodeStrength),r.edgeStrength=x(1,t.edgeStrength),r},t.prototype.formatCentripetal=function(t,e){var r,n,o=t.dimensions,i=t.centripetalOptions,a=t.center,s=t.clusterNodeStrength,u=t.leafCluster,d=t.clustering,h=t.nodeClusterBy,c=e.getAllNodes(),l=i||{leaf:2,single:2,others:1,center:function(t){return{x:a[0],y:a[1],z:3===o?a[2]:void 0}}};if("function"!=typeof s&&(t.clusterNodeStrength=function(t){return s}),u&&h&&(r=_t(e,h),n=Array.from(new Set(null==c?void 0:c.map((function(t){return t.data[h]}))))||[],t.centripetalOptions=Object.assign(l,{single:100,leaf:function(e){var o=r[e.id]||{},i=o.siblingLeaves,a=o.sameTypeLeaves;return(null==a?void 0:a.length)===(null==i?void 0:i.length)||1===(null==n?void 0:n.length)?1:t.clusterNodeStrength(e)},others:1,center:function(t){var n,o=e.getDegree(t.id,"both");if(!o)return{x:100,y:100,z:0};if(1===o){var i=(r[t.id]||{}).sameTypeLeaves,a=void 0===i?[]:i;1===a.length?n=void 0:a.length>1&&(n=It(a))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y,z:null==n?void 0:n.z}}})),d&&h){r||(r=_t(e,h)),n||(n=Array.from(new Set(c.map((function(t){return t.data[h]}))))),n=n.filter((function(t){return void 0!==t}));var f={};n.forEach((function(t){var r=c.filter((function(e){return e.data[h]===t})).map((function(t){return e.getNode(t.id)}));f[t]=It(r)})),t.centripetalOptions=Object.assign(l,{single:function(e){return t.clusterNodeStrength(e)},leaf:function(e){return t.clusterNodeStrength(e)},others:function(e){return t.clusterNodeStrength(e)},center:function(t){var e=f[t.data[h]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y,z:null==e?void 0:e.z}}})}var g=t.centripetalOptions||{},p=g.leaf,v=g.single,y=g.others;p&&"function"!=typeof p&&(t.centripetalOptions.leaf=function(){return p}),v&&"function"!=typeof v&&(t.centripetalOptions.single=function(){return v}),y&&"function"!=typeof y&&(t.centripetalOptions.others=function(){return y})},t.prototype.runOneStep=function(t,e,r,n,o){var i={},a=t.getAllNodes(),s=t.getAllEdges();if(null==a?void 0:a.length){var u=o.monitor;this.calRepulsive(t,i,o),s&&this.calAttractive(t,i,o),this.calGravity(t,e,i,o),this.updateVelocity(t,i,n,o),u&&u({energy:this.calTotalEnergy(i,a),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:r})}},t.prototype.calTotalEnergy=function(t,e){var r=this;if(!(null==e?void 0:e.length))return 0;var n=0;return e.forEach((function(e,o){var i=t[e.id].x,a=t[e.id].y,s=3===r.options.dimensions?t[e.id].z:0,u=i*i+a*a+s*s,d=e.data.mass;n+=(void 0===d?1:d)*u*.5})),n},t.prototype.calRepulsive=function(t,e,r){var n=r.dimensions,o=r.factor,i=r.coulombDisScale;!function(t,e,r,n,o){void 0===o&&(o=2);var i=e/r,a=t.getAllNodes(),s=a.map((function(t,e){var r=t.data,n=r.nodeStrength;return{x:r.x,y:r.y,z:r.z,size:r.size,index:e,id:t.id,vx:0,vy:0,vz:0,weight:i*n}})),u=(2===o?ct(s,(function(t){return t.x}),(function(t){return t.y})):xt(s,(function(t){return t.x}),(function(t){return t.y}),(function(t){return t.z}))).visitAfter(Mt),d=new Map;s.forEach((function(t){d.set(t.id,t),function(t,e,r){e.visit((function(e,n,o,i,a){return St(e,n,o,i,a,t,r)}))}(t,u,o)})),s.map((function(t,e){var r=a[e],o=r.id,i=r.data.mass,s=void 0===i?1:i;n[o]={x:t.vx/s,y:t.vy/s,z:t.vz/s}}))}(t,o,i*i,e,n)},t.prototype.calAttractive=function(t,e,r){var n=r.dimensions,o=r.nodeSize;t.getAllEdges().forEach((function(r,i){var a=r.source,s=r.target,u=t.getNode(a),d=t.getNode(s);if(u&&d){var h=d.data.x-u.data.x,c=d.data.y-u.data.y,l=3===n?d.data.z-u.data.z:0;h||c||(h=.01*Math.random(),c=.01*Math.random(),3!==n||l||(l=.01*Math.random()));var f=Math.sqrt(h*h+c*c+l*l);if(!(f<o(u)+o(d))){var g=h/f,p=c/f,v=l/f,y=r.data||{},m=y.linkDistance,w=void 0===m?200:m,x=y.edgeStrength,E=(w-f)*(void 0===x?200:x),N=1/(u.data.mass||1),b=1/(d.data.mass||1),M=g*E,S=p*E,A=v*E;e[a].x-=M*N,e[a].y-=S*N,e[a].z-=A*N,e[s].x+=M*b,e[s].y+=S*b,e[s].z+=A*b}}}))},t.prototype.calGravity=function(t,e,r,n){var o=n.getCenter,i=t.getAllNodes(),a=e.getAllNodes(),u=e.getAllEdges(),d=n.width,h=n.height,c=n.center,l=n.gravity,f=n.centripetalOptions;i&&i.forEach((function(n){var i=n.id,g=n.data,p=g.mass,v=g.x,y=g.y,w=g.z,x=e.getNode(i),E=0,N=0,b=0,M=l,S=t.getDegree(i,"in"),A=t.getDegree(i,"out"),k=t.getDegree(i,"both"),_=null==o?void 0:o(x,k);if(_){var z=s(_,3);E=v-z[0],N=y-z[1],M=z[2]}else E=v-c[0],N=y-c[1],b=w-c[2];if(M&&(r[i].x-=M*E/p,r[i].y-=M*N/p,r[i].z-=M*b/p),f){var R=f.leaf,I=f.single,D=f.others,P=f.center,O=(null==P?void 0:P(x,a,u,d,h))||{x:0,y:0,z:0,centerStrength:0},C=O.x,T=O.y,F=O.z,L=O.centerStrength;if(!m(C)||!m(T))return;var q=(v-C)/p,j=(y-T)/p,V=(w-F)/p;if(L&&(r[i].x-=L*q,r[i].y-=L*j,r[i].z-=L*V),0===k){var B=I(x);if(!B)return;return r[i].x-=B*q,r[i].y-=B*j,void(r[i].z-=B*V)}if(0===S||0===A){var G=R(x,a,u);if(!G)return;return r[i].x-=G*q,r[i].y-=G*j,void(r[i].z-=G*V)}var W=D(x);if(!W)return;r[i].x-=W*q,r[i].y-=W*j,r[i].z-=W*V}}))},t.prototype.updateVelocity=function(t,e,r,n){var o=n.damping,i=n.maxSpeed,a=n.interval,s=n.dimensions,u=t.getAllNodes();(null==u?void 0:u.length)&&u.forEach((function(t){var n=t.id,u=(r[n].x+e[n].x*a)*o||.01,d=(r[n].y+e[n].y*a)*o||.01,h=3===s?(r[n].z+e[n].z*a)*o||.01:0,c=Math.sqrt(u*u+d*d+h*h);if(c>i){var l=i/c;u*=l,d*=l,h*=l}r[n]={x:u,y:d,z:h}}))},t.prototype.updatePosition=function(t,e,r,n){var o=this,i=n.distanceThresholdMode,a=n.interval,s=n.dimensions,u=e.getAllNodes();if(null==u?void 0:u.length){var d=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),u.forEach((function(n){var u=n.id,h=t.getNode(u);if(m(h.data.fx)&&m(h.data.fy))e.mergeNodeData(u,{x:h.data.fx,y:h.data.fy,z:3===s?h.data.fz:void 0});else{var c=r[u].x*a,l=r[u].y*a,f=3===s?r[u].z*a:0;e.mergeNodeData(u,{x:n.data.x+c,y:n.data.y+l,z:n.data.z+f});var g=Math.sqrt(c*c+l*l+f*f);switch(i){case"max":o.judgingDistance<g&&(o.judgingDistance=g);break;case"min":o.judgingDistance>g&&(o.judgingDistance=g);break;default:d+=g}}})),i&&"mean"!==i||(this.judgingDistance=d/u.length)}else this.judgingDistance=0},t}(),_t=function(t,e){var r=t.getAllNodes();if(!(null==r?void 0:r.length))return{};var n={};return r.forEach((function(r,o){1===t.getDegree(r.id,"both")&&(n[r.id]=zt(t,"leaf",r,e))})),n},zt=function(t,e,r,n){var o=t.getDegree(r.id,"in"),i=t.getDegree(r.id,"out"),a=r,s=[];return 0===o?(a=t.getSuccessors(r.id)[0],s=t.getNeighbors(a.id)):0===i&&(a=t.getPredecessors(r.id)[0],s=t.getNeighbors(a.id)),s=s.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")})),{coreNode:a,siblingLeaves:s,sameTypeLeaves:Rt(t,e,n,r,s)}},Rt=function(t,e,r,n,o){var i=n.data[r]||"",a=(null==o?void 0:o.filter((function(t){return t.data[r]===i})))||[];return"leaf"===e&&(a=a.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")}))),a},It=function(t){var e={x:0,y:0};t.forEach((function(t){var r=t.data,n=r.x,o=r.y;e.x+=n||0,e.y+=o||0}));var r=t.length||1;return{x:e.x/r,y:e.y/r}},Dt=function(t,e){return e.map((function(e){var r=e.id,o=e.data,i=t.getNode(r);return n(n({},i),{data:n(n({},i.data),{x:o.x,y:o.y,z:o.z})})}))};const Pt=function(t){return y(t,"String")};var Ot={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},Ct=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=n(n({},Ot),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericConcentricLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericConcentricLayout(!0,t,e),[2]}))}))},t.prototype.genericConcentricLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f,g,v,y,x,E,N,b,A,k,_,z,I,D,P,O,C,T,F,L,q,j,V,B,G,W,$,U,H,Y;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.center,s=o.width,u=o.height,d=o.sortBy,h=o.maxLevelDiff,c=o.sweep,l=o.clockwise,f=o.equidistant,g=o.preventOverlap,v=o.startAngle,y=void 0===v?1.5*Math.PI:v,x=o.nodeSize,E=o.nodeSpacing,N=e.getAllNodes(),b=e.getAllEdges(),A=s||"undefined"==typeof window?s:window.innerWidth,k=u||"undefined"==typeof window?u:window.innerHeight,_=i||[A/2,k/2],!(null==N?void 0:N.length)||1===N.length)return[2,S(e,t,_)];if(z=[],D=0,R(x)?I=Math.max(x[0],x[1]):p(x)?(I=-1/0,N.forEach((function(t){var e=x(t);e>I&&(I=e)}))):I=x,R(E)?D=Math.max(E[0],E[1]):m(E)&&(D=E),N.forEach((function(t){var e=M(t);z.push(e);var r=I,n=e.data;R(n.size)?r=Math.max(n.size[0],n.size[1]):m(n.size)?r=n.size:w(n.size)&&(r=Math.max(n.size.width,n.size.height)),I=Math.max(I,r),p(E)&&(D=Math.max(E(t),D))})),P={},z.forEach((function(t,e){P[t.id]=e})),Pt(O=d)&&void 0!==z[0].data[O]||(O="degree"),"degree"===O?z.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):z.sort((function(t,e){return e.data[O]-t.data[O]})),C=z[0],T=(h||("degree"===O?e.getDegree(C.id,"both"):C.data[O]))/4,L=(F=[{nodes:[]}])[0],z.forEach((function(t){if(L.nodes.length>0){var r="degree"===O?Math.abs(e.getDegree(L.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(L.nodes[0].data[O]-t.data[O]);T&&r>=T&&(L={nodes:[]},F.push(L))}L.nodes.push(t)})),q=I+D,g||(j=F.length>0&&F[0].nodes.length>1,V=Math.min(A,k)/2-q,B=V/(F.length+(j?1:0)),q=Math.min(q,B)),G=0,F.forEach((function(t){var e=void 0===c?2*Math.PI-2*Math.PI/t.nodes.length:c;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&g){var r=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),o=Math.sqrt(q*q/(r*r+n*n));G=Math.max(o,G)}t.r=G,G+=q})),f){for(W=0,$=0,U=0;U<F.length;U++)H=F[U],Y=(H.r||0)-$,W=Math.max(W,Y);$=0,F.forEach((function(t,e){0===e&&($=t.r||0),t.r=$,$+=W}))}return F.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=y+(l?1:-1)*e*n;t.data.x=_[0]+r*Math.cos(o),t.data.y=_[1]+r*Math.sin(o)}))})),t&&z.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:z,edges:b}]}))}))},t}(),Tt={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},Ft={center:[0,0],comboPadding:10,treeKey:"combo"},Lt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="comboCombined",this.options=n(n({},Ft),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericComboCombinedLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,this.genericComboCombinedLayout(!0,t,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.genericComboCombinedLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,d,h,c,l,f,p,v,y,m,w,x,E,N,b,M,A,k,_,z;return a(this,(function(a){switch(a.label){case 0:return o=this.initVals(n(n({},this.options),r)),i=o.center,d=o.treeKey,h=o.outerLayout,c=e.getAllNodes().filter((function(t){return!t.data._isCombo})),l=e.getAllNodes().filter((function(t){return t.data._isCombo})),f=e.getAllEdges(),(p=null==c?void 0:c.length)&&1!==p?(v=[],y=new Map,c.forEach((function(t){y.set(t.id,t)})),m=new Map,l.forEach((function(t){m.set(t.id,t)})),w=new Map,x=this.getInnerGraphs(e,d,y,m,f,o,w),[4,Promise.all(x)]):[2,S(e,t,i)];case 1:return a.sent(),E=new Map,N=[],b=new Map,M=!0,e.getRoots(d).forEach((function(t){var r=w.get(t.id),o=m.get(t.id)||y.get(t.id),i={id:t.id,data:n(n({},t.data),{x:r.data.x||o.data.x,y:r.data.y||o.data.y,fx:r.data.fx||o.data.fx,fy:r.data.fy||o.data.fy,mass:r.data.mass||o.data.mass,size:r.data.size})};N.push(i),E.set(t.id,!0),isNaN(i.data.x)||0===i.data.x||isNaN(i.data.y)||0===i.data.y?(i.data.x=100*Math.random(),i.data.y=100*Math.random()):M=!1,O(e,[t],(function(e){e.id!==t.id&&b.set(e.id,t.id)}),"TB",d)})),A=[],f.forEach((function(t){var e=b.get(t.source)||t.source,r=b.get(t.target)||t.target;e!==r&&E.has(e)&&E.has(r)&&A.push({id:t.id,source:e,target:r,data:{}})})),(null==N?void 0:N.length)?1!==N.length?[3,2]:(N[0].data.x=i[0],N[0].data.y=i[1],[3,6]):[3,7];case 2:return _=new g({nodes:N,edges:A}),z=h||new kt,M&&Tt[z.id]?[4,(N.length<100?new ot:new Ct).assign(_)]:[3,4];case 3:a.sent(),a.label=4;case 4:return[4,z.execute(_,n({center:i,kg:5,preventOverlap:!0,animate:!1},"force"===z.id?{gravity:1,factor:4,linkDistance:function(t,e,r){return(Math.max.apply(Math,u([],s(e.data.size),!1))||32)/2+(Math.max.apply(Math,u([],s(r.data.size),!1))||32)/2+200}}:{}))];case 5:k=a.sent(),a.label=6;case 6:w.forEach((function(t){var e,r=k.nodes.find((function(e){return e.id===t.id}));if(r){var n=r.data,o=n.x,i=n.y;t.data.visited=!0,t.data.x=o,t.data.y=i,v.push({id:t.id,data:{x:o,y:i}})}var a=t.data,s=a.x,u=a.y;null===(e=t.data.nodes)||void 0===e||e.forEach((function(t){v.push({id:t.id,data:{x:t.data.x+s,y:t.data.y+u}})}))})),w.forEach((function(t){var e=t.data,r=e.x,n=e.y,o=e.visited,i=e.nodes;null==i||i.forEach((function(t){if(!o){var e=v.find((function(e){return e.id===t.id}));e.data.x+=r||0,e.data.y+=n||0}}))})),a.label=7;case 7:return t&&v.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:v,edges:f}]}}))}))},t.prototype.initVals=function(t){var e,r,o,i=n({},t),a=t.nodeSize,s=t.spacing,u=t.comboPadding;if(r=m(s)?function(){return s}:p(s)?s:function(){return 0},i.spacing=r,a)if(p(a))e=function(t){var e=a(t),n=r(t);return R(t.size)?((t.size[0]>t.size[1]?t.size[0]:t.size[1])+n)/2:((e||32)+n)/2};else if(R(a)){var d=(a[0]>a[1]?a[0]:a[1])/2;e=function(t){return d+r(t)/2}}else{var h=a/2;e=function(t){return h+r(t)/2}}else e=function(t){var e=r(t);return t.size?R(t.size)?((t.size[0]>t.size[1]?t.size[0]:t.size[1])+e)/2:w(t.size)?((t.size.width>t.size.height?t.size.width:t.size.height)+e)/2:(t.size+e)/2:32+e/2};return i.nodeSize=e,o=m(u)?function(){return u}:R(u)?function(){return Math.max.apply(null,u)}:p(u)?u:function(){return 0},i.comboPadding=o,i},t.prototype.getInnerGraphs=function(t,e,r,o,d,h,c){var l=this,f=h.nodeSize,p=h.comboPadding,v=h.spacing,y=h.innerLayout||new Ct({}),w={center:[0,0],preventOverlap:!0,nodeSpacing:v},x=[],E=function(t){var e=(null==p?void 0:p(t))||10;return R(e)&&(e=Math.max.apply(Math,u([],s(e),!1))),{size:e?[2*e,2*e]:[30,30],padding:e}};return t.getRoots(e).forEach((function(u){c.set(u.id,{id:u.id,data:{nodes:[],size:E(u).size}});var h=Promise.resolve();O(t,[u],(function(u){var p;if(u.data._isCombo){var v=E(u),x=v.size,N=v.padding;if(null===(p=t.getChildren(u.id,e))||void 0===p?void 0:p.length){var b=c.get(u.id);c.set(u.id,{id:u.id,data:n({nodes:[]},null==b?void 0:b.data)});var M=new Map,S=t.getChildren(u.id,e).map((function(t){if(t.data._isCombo)return c.has(t.id)||c.set(t.id,{id:t.id,data:n({},t.data)}),M.set(t.id,!0),c.get(t.id);var e=r.get(t.id)||o.get(t.id);return M.set(t.id,!0),{id:t.id,data:n(n({},e.data),t.data)}})),A={nodes:S,edges:d.filter((function(t){return M.has(t.source)&&M.has(t.target)}))},k=1/0;S.forEach((function(t){var e,r=t.data.size;r||(r=(null===(e=c.get(t.id))||void 0===e?void 0:e.data.size)||(null==f?void 0:f(t))||[30,30]),m(r)&&(r=[r,r]);var n=s(r,2),o=n[0],i=n[1];k>o&&(k=o),k>i&&(k=i),t.data.size=r})),h=h.then((function(){return i(l,void 0,void 0,(function(){var t,e,r,n,o,i,s,d,h;return a(this,(function(a){switch(a.label){case 0:return t=new g(A),[4,y.assign(t,w)];case 1:return e=a.sent(),r=function(t){var e=1/0,r=1/0,n=-1/0,o=-1/0;return t.forEach((function(t){var i=t.data.size;R(i)?1===i.length&&(i=[i[0],i[0]]):m(i)?i=[i,i]:(void 0===i||isNaN(i))&&(i=[30,30]);var a=[i[0]/2,i[1]/2],s=t.data.x-a[0],u=t.data.x+a[0],d=t.data.y-a[1],h=t.data.y+a[1];e>s&&(e=s),r>d&&(r=d),n<u&&(n=u),o<h&&(o=h)})),{minX:e,minY:r,maxX:n,maxY:o}}(S),n=r.minX,o=r.minY,i=r.maxX,s=r.maxY,d={x:(i+n)/2,y:(s+o)/2},A.nodes.forEach((function(t){t.data.x-=d.x,t.data.y-=d.y})),h=[Math.max(i-n,k)+2*N,Math.max(s-o,k)+2*N],c.get(u.id).data.size=h,c.get(u.id).data.nodes=S,[2,e]}}))}))}))}else c.set(u.id,{id:u.id,data:n(n({},u.data),{size:x})});return!0}}),"BT",e),x.push(h)})),x},t}();function qt(t){return function(){return t}}function jt(t){return 1e-6*(t()-.5)}var Vt={value:()=>{}};function Bt(){for(var t,e=0,r=arguments.length,n={};e<r;++e){if(!(t=arguments[e]+"")||t in n||/[\s.]/.test(t))throw new Error("illegal type: "+t);n[t]=[]}return new Gt(n)}function Gt(t){this._=t}function Wt(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function $t(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=Vt,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}Gt.prototype=Bt.prototype={constructor:Gt,on:function(t,e){var r,n,o=this._,i=(n=o,(t+"").trim().split(/^|\s+/).map((function(t){var e="",r=t.indexOf(".");if(r>=0&&(e=t.slice(r+1),t=t.slice(0,r)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),a=-1,s=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<s;)if(r=(t=i[a]).type)o[r]=$t(o[r],t.name,e);else if(null==e)for(r in o)o[r]=$t(o[r],t.name,null);return this}for(;++a<s;)if((r=(t=i[a]).type)&&(r=Wt(o[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new Gt(t)},call:function(t,e){if((r=arguments.length-2)>0)for(var r,n,o=new Array(r),i=0;i<r;++i)o[i]=arguments[i+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(i=0,r=(n=this._[t]).length;i<r;++i)n[i].value.apply(e,o)},apply:function(t,e,r){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var n=this._[t],o=0,i=n.length;o<i;++o)n[o].value.apply(e,r)}};const Ut=Bt;var Ht,Yt,Kt=0,Jt=0,Xt=0,Qt=1e3,Zt=0,te=0,ee=0,re="object"==typeof performance&&performance.now?performance:Date,ne="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function oe(){return te||(ne(ie),te=re.now()+ee)}function ie(){te=0}function ae(){this._call=this._time=this._next=null}function se(t,e,r){var n=new ae;return n.restart(t,e,r),n}function ue(){te=(Zt=re.now())+ee,Kt=Jt=0;try{!function(){oe(),++Kt;for(var t,e=Ht;e;)(t=te-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Kt}()}finally{Kt=0,function(){for(var t,e,r=Ht,n=1/0;r;)r._call?(n>r._time&&(n=r._time),t=r,r=r._next):(e=r._next,r._next=null,r=t?t._next=e:Ht=e);Yt=t,he(n)}(),te=0}}function de(){var t=re.now(),e=t-Zt;e>Qt&&(ee-=e,Zt=t)}function he(t){Kt||(Jt&&(Jt=clearTimeout(Jt)),t-te>24?(t<1/0&&(Jt=setTimeout(ue,t-re.now()-ee)),Xt&&(Xt=clearInterval(Xt))):(Xt||(Zt=re.now(),Xt=setInterval(de,Qt)),Kt=1,ne(ue)))}ae.prototype=se.prototype={constructor:ae,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?oe():+r)+(null==e?0:+e),this._next||Yt===this||(Yt?Yt._next=this:Ht=this,Yt=this),this._call=t,this._time=r,he()},stop:function(){this._call&&(this._call=null,this._time=1/0,he())}};const ce=1664525,le=1013904223,fe=4294967296;function ge(t){return t.x}function pe(t){return t.y}var ve=10,ye=Math.PI*(3-Math.sqrt(5));function me(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,a=.6,s=new Map,u=se(c),d=Ut("tick","end"),h=function(){let t=1;return()=>(t=(ce*t+le)%fe)/fe}();function c(){l(),d.call("tick",e),r<n&&(u.stop(),d.call("end",e))}function l(n){var u,d,h=t.length;void 0===n&&(n=1);for(var c=0;c<n;++c)for(r+=(i-r)*o,s.forEach((function(t){t(r)})),u=0;u<h;++u)null==(d=t[u]).fx?d.x+=d.vx*=a:(d.x=d.fx,d.vx=0),null==d.fy?d.y+=d.vy*=a:(d.y=d.fy,d.vy=0);return e}function f(){for(var e,r=0,n=t.length;r<n;++r){if((e=t[r]).index=r,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var o=ve*Math.sqrt(.5+r),i=r*ye;e.x=o*Math.cos(i),e.y=o*Math.sin(i)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function g(e){return e.initialize&&e.initialize(t,h),e}return null==t&&(t=[]),f(),e={tick:l,restart:function(){return u.restart(c),e},stop:function(){return u.stop(),e},nodes:function(r){return arguments.length?(t=r,f(),s.forEach(g),e):t},alpha:function(t){return arguments.length?(r=+t,e):r},alphaMin:function(t){return arguments.length?(n=+t,e):n},alphaDecay:function(t){return arguments.length?(o=+t,e):+o},alphaTarget:function(t){return arguments.length?(i=+t,e):i},velocityDecay:function(t){return arguments.length?(a=1-t,e):1-a},randomSource:function(t){return arguments.length?(h=t,s.forEach(g),e):h},force:function(t,r){return arguments.length>1?(null==r?s.delete(t):s.set(t,g(r)),e):s.get(t)},find:function(e,r,n){var o,i,a,s,u,d=0,h=t.length;for(null==n?n=1/0:n*=n,d=0;d<h;++d)(a=(o=e-(s=t[d]).x)*o+(i=r-s.y)*i)<n&&(u=s,n=a);return u},on:function(t,r){return arguments.length>1?(d.on(t,r),e):d.on(t)}}}function we(){var t,e,r,n,o,i=qt(-30),a=1,s=1/0,u=.81;function d(r){var o,i=t.length,a=ct(t,ge,pe).visitAfter(c);for(n=r,o=0;o<i;++o)e=t[o],a.visit(l)}function h(){if(t){var e,r,n=t.length;for(o=new Array(n),e=0;e<n;++e)r=t[e],o[r.index]=+i(r,e,t)}}function c(t){var e,r,n,i,a,s=0,u=0;if(t.length){for(n=i=a=0;a<4;++a)(e=t[a])&&(r=Math.abs(e.value))&&(s+=e.value,u+=r,n+=r*e.x,i+=r*e.y);t.x=n/u,t.y=i/u}else{(e=t).x=e.data.x,e.y=e.data.y;do{s+=o[e.data.index]}while(e=e.next)}t.value=s}function l(t,i,d,h){if(!t.value)return!0;var c=t.x-e.x,l=t.y-e.y,f=h-i,g=c*c+l*l;if(f*f/u<g)return g<s&&(0===c&&(g+=(c=jt(r))*c),0===l&&(g+=(l=jt(r))*l),g<a&&(g=Math.sqrt(a*g)),e.vx+=c*t.value*n/g,e.vy+=l*t.value*n/g),!0;if(!(t.length||g>=s)){(t.data!==e||t.next)&&(0===c&&(g+=(c=jt(r))*c),0===l&&(g+=(l=jt(r))*l),g<a&&(g=Math.sqrt(a*g)));do{t.data!==e&&(f=o[t.data.index]*n/g,e.vx+=c*f,e.vy+=l*f)}while(t=t.next)}}return d.initialize=function(e,n){t=e,r=n,h()},d.strength=function(t){return arguments.length?(i="function"==typeof t?t:qt(+t),h(),d):i},d.distanceMin=function(t){return arguments.length?(a=t*t,d):Math.sqrt(a)},d.distanceMax=function(t){return arguments.length?(s=t*t,d):Math.sqrt(s)},d.theta=function(t){return arguments.length?(u=t*t,d):Math.sqrt(u)},d}function xe(t){return t.index}function Ee(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function Ne(t){var e,r,n,o,i,a,s=xe,u=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},d=qt(30),h=1;function c(n){for(var o=0,s=t.length;o<h;++o)for(var u,d,c,l,f,g,p,v=0;v<s;++v)d=(u=t[v]).source,l=(c=u.target).x+c.vx-d.x-d.vx||jt(a),f=c.y+c.vy-d.y-d.vy||jt(a),l*=g=((g=Math.sqrt(l*l+f*f))-r[v])/g*n*e[v],f*=g,c.vx-=l*(p=i[v]),c.vy-=f*p,d.vx+=l*(p=1-p),d.vy+=f*p}function l(){if(n){var a,u,d=n.length,h=t.length,c=new Map(n.map(((t,e)=>[s(t,e,n),t])));for(a=0,o=new Array(d);a<h;++a)(u=t[a]).index=a,"object"!=typeof u.source&&(u.source=Ee(c,u.source)),"object"!=typeof u.target&&(u.target=Ee(c,u.target)),o[u.source.index]=(o[u.source.index]||0)+1,o[u.target.index]=(o[u.target.index]||0)+1;for(a=0,i=new Array(h);a<h;++a)u=t[a],i[a]=o[u.source.index]/(o[u.source.index]+o[u.target.index]);e=new Array(h),f(),r=new Array(h),g()}}function f(){if(n)for(var r=0,o=t.length;r<o;++r)e[r]=+u(t[r],r,t)}function g(){if(n)for(var e=0,o=t.length;e<o;++e)r[e]=+d(t[e],e,t)}return null==t&&(t=[]),c.initialize=function(t,e){n=t,a=e,l()},c.links=function(e){return arguments.length?(t=e,l(),c):t},c.id=function(t){return arguments.length?(s=t,c):s},c.iterations=function(t){return arguments.length?(h=+t,c):h},c.strength=function(t){return arguments.length?(u="function"==typeof t?t:qt(+t),f(),c):u},c.distance=function(t){return arguments.length?(d="function"==typeof t?t:qt(+t),g(),c):d},c}function be(t){return t.x+t.vx}function Me(t){return t.y+t.vy}function Se(t){var e,r,n,o=1,i=1;function a(){for(var t,a,u,d,h,c,l,f=e.length,g=0;g<i;++g)for(a=ct(e,be,Me).visitAfter(s),t=0;t<f;++t)u=e[t],c=r[u.index],l=c*c,d=u.x+u.vx,h=u.y+u.vy,a.visit(p);function p(t,e,r,i,a){var s=t.data,f=t.r,g=c+f;if(!s)return e>d+g||i<d-g||r>h+g||a<h-g;if(s.index>u.index){var p=d-s.x-s.vx,v=h-s.y-s.vy,y=p*p+v*v;y<g*g&&(0===p&&(y+=(p=jt(n))*p),0===v&&(y+=(v=jt(n))*v),y=(g-(y=Math.sqrt(y)))/y*o,u.vx+=(p*=y)*(g=(f*=f)/(l+f)),u.vy+=(v*=y)*g,s.vx-=p*(g=1-g),s.vy-=v*g)}}}function s(t){if(t.data)return t.r=r[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function u(){if(e){var n,o,i=e.length;for(r=new Array(i),n=0;n<i;++n)o=e[n],r[o.index]=+t(o,n,e)}}return"function"!=typeof t&&(t=qt(null==t?1:+t)),a.initialize=function(t,r){e=t,n=r,u()},a.iterations=function(t){return arguments.length?(i=+t,a):i},a.strength=function(t){return arguments.length?(o=+t,a):o},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:qt(+e),u(),a):t},a}function Ae(t){var e,r,n,o=qt(.1);function i(t){for(var o,i=0,a=e.length;i<a;++i)(o=e[i]).vx+=(n[i]-o.x)*r[i]*t}function a(){if(e){var i,a=e.length;for(r=new Array(a),n=new Array(a),i=0;i<a;++i)r[i]=isNaN(n[i]=+t(e[i],i,e))?0:+o(e[i],i,e)}}return"function"!=typeof t&&(t=qt(null==t?0:+t)),i.initialize=function(t){e=t,a()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:qt(+t),a(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:qt(+e),a(),i):t},i}function ke(t){var e,r,n,o=qt(.1);function i(t){for(var o,i=0,a=e.length;i<a;++i)(o=e[i]).vy+=(n[i]-o.y)*r[i]*t}function a(){if(e){var i,a=e.length;for(r=new Array(a),n=new Array(a),i=0;i<a;++i)r[i]=isNaN(n[i]=+t(e[i],i,e))?0:+o(e[i],i,e)}}return"function"!=typeof t&&(t=qt(null==t?0:+t)),i.initialize=function(t){e=t,a()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:qt(+t),a(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:qt(+e),a(),i):t},i}function _e(){function t(t){return function(){return t}}var e,r=function(t){return t.cluster},n=t(1),o=t(-1),i=t(100),a=t(.1),u=[0,0],d=[],h={},c=[],l=100,f=100,g={none:{x:0,y:0}},p=[],v="force",y=!0,m=.1;function w(t){if(!y)return w;e.tick(),E();for(var n=0,o=d.length,i=void 0,a=t*m;n<o;++n)(i=d[n]).vx+=(g[r(i)].x-i.x)*a,i.vy+=(g[r(i)].y-i.y)*a}function x(){d&&function(){if(d&&d.length){if(void 0===r(d[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy('clusterAttr') before calling .links()");var t,u,g,v,y,m=(t=[],u=[],g={},{},y=[],v=function(t){var e={};return t.forEach((function(t){var n=r(t);e[n]||(e[n]={count:0,sumforceNodeSize:0})})),t.forEach((function(t){var o=r(t),i=n(t),a=e[o];a.count=a.count+1,a.sumforceNodeSize=a.sumforceNodeSize+Math.PI*(i*i)*1.3,e[o]=a})),e}(d),y=function(t){var e={},n=[];return t.forEach((function(t){var n,o,i,a,s,u=(o=(n=t).source,i=n.target,(a=r(h[o]))<=(s=r(h[i]))?"".concat(a,"~").concat(s):"".concat(s,"~").concat(a)),d=0;void 0!==e[u]&&(d=e[u]),d+=1,e[u]=d})),Object.entries(e).forEach((function(t){var e=s(t,2),r=e[0],o=e[1],i=r.split("~")[0],a=r.split("~")[1];void 0!==i&&void 0!==a&&n.push({source:i,target:a,count:o})})),n}(c),Object.keys(v).forEach((function(e,r){var n=v[e];t.push({id:e,size:n.count,r:Math.sqrt(n.sumforceNodeSize/Math.PI)}),g[e]=r})),y.forEach((function(t){var e=t.source,r=t.target,n=g[e],o=g[r];void 0!==n&&void 0!==o&&u.push({source:n,target:o,count:t.count})})),{nodes:t,links:u});e=me(m.nodes).force("x",Ae(l).strength(.1)).force("y",ke(f).strength(.1)).force("collide",Se((function(t){return t.r})).iterations(4)).force("charge",we().strength(o)).force("links",Ne(m.nodes.length?m.links:[]).distance(i).strength(a)),p=e.nodes(),E()}}()}function E(){return g={none:{x:0,y:0}},p.forEach((function(t){g[t.id]={x:t.x-u[0],y:t.y-u[1]}})),g}return w.initialize=function(t){d=t,x()},w.template=function(t){return arguments.length?(v=t,x(),w):v},w.groupBy=function(t){return arguments.length?"string"==typeof t?(r=function(e){return e[t]},w):(r=t,w):r},w.enableGrouping=function(t){return arguments.length?(y=t,w):y},w.strength=function(t){return arguments.length?(m=t,w):m},w.centerX=function(t){return arguments.length?(l=t,w):l},w.centerY=function(t){return arguments.length?(f=t,w):f},w.nodes=function(t){return arguments.length?(function(t){h={},t.forEach((function(t){h[t.id]=t}))}(t||[]),d=t||[],w):d},w.links=function(t){return arguments.length?(c=t||[],x(),w):c},w.forceNodeSize=function(e){return arguments.length?(n="function"==typeof e?e:t(+e),x(),w):n},w.nodeSize=w.forceNodeSize,w.forceCharge=function(e){return arguments.length?(o="function"==typeof e?e:t(+e),x(),w):o},w.forceLinkDistance=function(e){return arguments.length?(i="function"==typeof e?e:t(+e),x(),w):i},w.forceLinkStrength=function(e){return arguments.length?(a="function"==typeof e?e:t(+e),x(),w):a},w.offset=function(t){return arguments.length?(u=t,w):u},w.getFocis=E,w}var ze={center:[0,0],preventOverlap:!1,nodeSize:void 0,nodeSpacing:void 0,linkDistance:50,forceSimulation:null,alphaDecay:.028,alphaMin:.001,alpha:.3,collideStrength:1,clustering:!1,clusterNodeStrength:-1,clusterEdgeStrength:.1,clusterEdgeDistance:100,clusterFociStrength:.8,clusterNodeSize:10},Re=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.options=n(n({},ze),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop()},t.prototype.tick=function(t){var e=this;void 0===t&&(t=1),this.forceSimulation.tick(t);var r={nodes:Ie(this.lastLayoutNodes),edges:De(this.lastLayoutEdges)};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r},t.prototype.genericForceLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f,g,p,v,y,m,w,x,E,N,b,S,A,k,_,z,R,I,D=this;return a(this,(function(a){return o=n(n({},this.options),r),i=e.getAllNodes(),s=e.getAllEdges(),u=i.map((function(t){var e,r;return n(n({},M(t)),{x:null===(e=t.data)||void 0===e?void 0:e.x,y:null===(r=t.data)||void 0===r?void 0:r.y})})),d=s.map((function(t){return M(t)})),this.lastLayoutNodes=u,this.lastLayoutEdges=d,this.lastAssign=t,this.lastGraph=e,h=o.alphaMin,c=o.alphaDecay,l=o.alpha,f=o.nodeStrength,g=o.edgeStrength,p=o.linkDistance,v=o.clustering,y=o.clusterFociStrength,m=o.clusterEdgeDistance,w=o.clusterEdgeStrength,x=o.clusterNodeStrength,E=o.clusterNodeSize,N=o.collideStrength,b=void 0===N?1:N,S=o.center,A=void 0===S?[0,0]:S,k=o.preventOverlap,_=o.nodeSize,z=o.nodeSpacing,R=o.onTick,I=o.forceSimulation,[2,new Promise((function(r){if(I){v&&((i=_e()).nodes(u),i.links(d)),I.nodes(u),d&&(s=Ne().id((function(t){return t.id})).links(d),g&&s.strength(g),p&&s.distance(p),I.force("link",s)),k&&D.overlapProcess(I,{nodeSize:_,nodeSpacing:z,collideStrength:b}),I.alpha(l).restart();var n=Ie(u),o=De(d);t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r({nodes:n,edges:o})}else try{var i,a=we();if(f&&a.strength(f),I=me().nodes(u),v&&((i=_e()).centerX(A[0]).centerY(A[1]).template("force").strength(y),d&&i.links(d),u&&i.nodes(u),i.forceLinkDistance(m).forceLinkStrength(w).forceCharge(x).forceNodeSize(E),I.force("group",i)),I.force("center",function(t,e){var r,n=1;function o(){var o,i,a=r.length,s=0,u=0;for(o=0;o<a;++o)s+=(i=r[o]).x,u+=i.y;for(s=(s/a-t)*n,u=(u/a-e)*n,o=0;o<a;++o)(i=r[o]).x-=s,i.y-=u}return null==t&&(t=0),null==e&&(e=0),o.initialize=function(t){r=t},o.x=function(e){return arguments.length?(t=+e,o):t},o.y=function(t){return arguments.length?(e=+t,o):e},o.strength=function(t){return arguments.length?(n=+t,o):n},o}(A[0],A[1])).force("charge",a).alpha(l).alphaDecay(c).alphaMin(h),k&&D.overlapProcess(I,{nodeSize:_,nodeSpacing:z,collideStrength:b}),d){var s=Ne().id((function(t){return t.id})).links(d);g&&s.strength(g),p&&s.distance(p),I.force("link",s)}I.on("tick",(function(){var r=Ie(u);null==R||R({nodes:r,edges:De(d)}),t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})).on("end",(function(){var n=Ie(u);t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r({nodes:n,edges:De(d)})}))}catch(t){console.warn(t)}D.forceSimulation=I}))]}))}))},t.prototype.overlapProcess=function(t,e){var r,n,o=e.nodeSize,i=e.nodeSpacing,a=e.collideStrength;if(n=m(i)?function(){return i}:p(i)?i:function(){return 0},o)if(p(o))r=function(t){return o(t)+n(t)};else if(R(o)){var s=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return s+n(t)}}else if(m(o)){var u=o/2;r=function(t){return u+n(t)}}else r=function(){return 10};else r=function(t){return t.size?R(t.size)?(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+n(t):w(t.size)?(t.size.width>t.size.height?t.size.width:t.size.height)/2+n(t):t.size/2+n(t):10+n(t)};t.force("collisionForce",Se(r).strength(a))},t}(),Ie=function(t){return t.map((function(t){var e=t.x,r=t.y,i=o(t,["x","y"]);return n(n({},i),{data:n(n({},i.data),{x:e,y:r})})}))},De=function(t){return t.map((function(t){var e=t.source,r=t.target,i=o(t,["source","target"]);return n(n({},i),{source:e.id,target:r.id})}))};var Pe=function(t,e){if("next"!==t&&"prev"!==t)return e},Oe=function(t){t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev},Ce=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(e,t),e}(function(){function t(){var t={};t.prev=t,t.next=t.prev,this.shortcut=t}return t.prototype.dequeue=function(){var t=this.shortcut,e=t.prev;if(e&&e!==t)return Oe(e),e},t.prototype.enqueue=function(t){var e=this.shortcut;t.prev&&t.next&&Oe(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e},t.prototype.toString=function(){for(var t=[],e=this.shortcut,r=e.prev;r!==e;)t.push(JSON.stringify(r,Pe)),r=null==r?void 0:r.prev;return"[".concat(t.join(", "),"]")},t}()),Te=function(){return 1},Fe=function(t,e,r,o,i){var a,s,u=[];return t.hasNode(o.v)&&(null===(a=t.getRelatedEdges(o.v,"in"))||void 0===a||a.forEach((function(o){var a=o.data.weight,s=t.getNode(o.source);i&&u.push({v:o.source,w:o.target,in:0,out:0}),void 0===s.data.out&&(s.data.out=0),s.data.out-=a,Le(e,r,n({v:s.id},s.data))})),null===(s=t.getRelatedEdges(o.v,"out"))||void 0===s||s.forEach((function(o){var i=o.data.weight,a=o.target,s=t.getNode(a);void 0===s.data.in&&(s.data.in=0),s.data.in-=i,Le(e,r,n({v:s.id},s.data))})),t.removeNode(o.v)),i?u:void 0},Le=function(t,e,r){r.out?r.in?t[r.out-r.in+e].enqueue(r):t[t.length-1].enqueue(r):t[0].enqueue(r)},qe=function(t,e){var r="greedy"===e?function(t,e){var r;if(t.getAllNodes().length<=1)return[];var o=function(t,e){var r=new g,o=0,i=0;t.getAllNodes().forEach((function(t){r.addNode({id:t.id,data:{v:t.id,in:0,out:0}})})),t.getAllEdges().forEach((function(t){var a=r.getRelatedEdges(t.source,"out").find((function(e){return e.target===t.target})),s=(null==e?void 0:e(t))||1;a?r.updateEdgeData(null==a?void 0:a.id,n(n({},a.data),{weight:a.data.weight+s})):r.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:s}}),i=Math.max(i,r.getNode(t.source).data.out+=s),o=Math.max(o,r.getNode(t.target).data.in+=s)}));for(var a=[],s=i+o+3,u=0;u<s;u++)a.push(new Ce);var d=o+1;return r.getAllNodes().forEach((function(t){Le(a,d,n({v:t.id},r.getNode(t.id).data))})),{buckets:a,zeroIdx:d,graph:r}}(t,function(t){return t.data.weight||1}||Te);return null===(r=function(t,e,r){for(var n,o=[],i=e[e.length-1],a=e[0];t.getAllNodes().length;){for(;n=a.dequeue();)Fe(t,e,r,n);for(;n=i.dequeue();)Fe(t,e,r,n);if(t.getAllNodes().length)for(var s=e.length-2;s>0;--s)if(n=e[s].dequeue()){o=o.concat(Fe(t,e,r,n,!0));break}}return o}(o.graph,o.buckets,o.zeroIdx).map((function(e){return t.getRelatedEdges(e.v,"out").filter((function(t){return t.target===e.w}))})))||void 0===r?void 0:r.flat()}(t):je(t);null==r||r.forEach((function(e){var r=e.data;t.removeEdge(e.id),r.forwardName=e.data.name,r.reversed=!0,t.addEdge({id:e.id,source:e.target,target:e.source,data:n({},r)})}))},je=function(t){var e=[],r={},n={},o=function(i){n[i]||(n[i]=!0,r[i]=!0,t.getRelatedEdges(i,"out").forEach((function(t){r[t.target]?e.push(t):o(t.target)})),delete r[i])};return t.getAllNodes().forEach((function(t){return o(t.id)})),e},Ve=function(t,e,r,n){var o;do{o="".concat(n).concat(Math.random())}while(t.hasNode(o));return r.dummy=e,t.addNode({id:o,data:r}),o},Be=function(t){var e=new g;return t.getAllNodes().forEach((function(r){t.getChildren(r.id).length||e.addNode(n({},r))})),t.getAllEdges().forEach((function(t){e.addEdge(t)})),e},Ge=function(t,e){var r,n,o=Number(t.x),i=Number(t.y),a=Number(e.x)-o,s=Number(e.y)-i,u=Number(t.width)/2,d=Number(t.height)/2;return a||s?(Math.abs(s)*u>Math.abs(a)*d?(s<0&&(d=-d),r=d*a/s,n=d):(a<0&&(u=-u),r=u,n=u*s/a),{x:o+r,y:i+n}):{x:0,y:0}},We=function(t){for(var e=[],r=Ue(t)+1,n=0;n<r;n++)e.push([]);for(t.getAllNodes().forEach((function(t){var r=t.data.rank;void 0!==r&&e[r]&&e[r].push(t.id)})),n=0;n<r;n++)e[n]=e[n].sort((function(e,r){return n=t.getNode(e).data.order,o=t.getNode(r).data.order,Number(n)-Number(o);var n,o}));return e},$e=function(t,e,r,n){var o={width:0,height:0};return m(r)&&m(n)&&(o.rank=r,o.order=n),Ve(t,"border",o,e)},Ue=function(t){var e;return t.getAllNodes().forEach((function(t){var r=t.data.rank;void 0!==r&&(void 0===e||r>e)&&(e=r)})),e||(e=0),e},He=function(t,e){return t.reduce((function(t,r){return e(t)>e(r)?r:t}))},Ye=function(t,e,r,n,o,i){n.includes(e.id)||(n.push(e.id),r||i.push(e.id),o(e.id).forEach((function(e){return Ye(t,e,r,n,o,i)})),r&&i.push(e.id))},Ke=function(t,e,r,n){var o=Array.isArray(e)?e:[e],i=function(e){return n?t.getSuccessors(e):t.getNeighbors(e)},a=[],s=[];return o.forEach((function(e){if(!t.hasNode(e.id))throw new Error("Graph does not have node: ".concat(e));Ye(t,e,"post"===r,s,i,a)})),a},Je="edge-label",Xe=function(t){var e={},r=function(n){var o,i,a=t.getNode(n);return a?e[n]?a.data.rank:(e[n]=!0,null===(o=t.getRelatedEdges(n,"out"))||void 0===o||o.forEach((function(t){var e=r(t.target)-t.data.minlen;e&&(void 0===i||e<i)&&(i=e)})),i||(i=0),a.data.rank=i,i):0};t.getAllNodes().filter((function(e){return 0===t.getRelatedEdges(e.id,"in").length})).forEach((function(t){return r(t.id)}))},Qe=function(t,e){return t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen},Ze=function(t,e){var r=function(n){e.getRelatedEdges(n,"both").forEach((function(o){var i=o.source,a=n===i?o.target:i;t.hasNode(a)||Qe(e,o)||(t.addNode({id:a,data:{}}),t.addEdge({id:o.id,source:n,target:a,data:{}}),r(a))}))};return t.getAllNodes().forEach((function(t){return r(t.id)})),t.getAllNodes().length},tr=function(t,e){var r=function(n){var o;null===(o=e.getRelatedEdges(n,"both"))||void 0===o||o.forEach((function(o){var i=o.source,a=n===i?o.target:i;t.hasNode(a)||void 0===e.getNode(a).data.layer&&Qe(e,o)||(t.addNode({id:a,data:{}}),t.addEdge({id:o.id,source:n,target:a,data:{}}),r(a))}))};return t.getAllNodes().forEach((function(t){return r(t.id)})),t.getAllNodes().length},er=function(t,e){return He(e.getAllEdges(),(function(r){return t.hasNode(r.source)!==t.hasNode(r.target)?Qe(e,r):1/0}))},rr=function(t,e,r){t.getAllNodes().forEach((function(t){var n=e.getNode(t.id);n.data.rank||(n.data.rank=0),n.data.rank+=r}))},nr=function(t,e){var r=Ke(t,t.getAllNodes(),"post",!1);(r=r.slice(0,(null==r?void 0:r.length)-1)).forEach((function(r){or(t,e,r)}))},or=function(t,e,r){var n=t.getNode(r).data.parent;t.getRelatedEdges(r,"both").find((function(t){return t.target===n||t.source===n})).data.cutvalue=ir(t,e,r)},ir=function(t,e,r){var n=t.getNode(r).data.parent,o=!0,i=e.getRelatedEdges(r,"out").find((function(t){return t.target===n})),a=0;return i||(o=!1,i=e.getRelatedEdges(n,"out").find((function(t){return t.target===r}))),a=i.data.weight,e.getRelatedEdges(r,"both").forEach((function(e){var i=e.source===r,s=i?e.target:e.source;if(s!==n){var u=i===o,d=e.data.weight;if(a+=u?d:-d,lr(t,r,s)){var h=t.getRelatedEdges(r,"both").find((function(t){return t.source===s||t.target===s})).data.cutvalue;a+=u?-h:h}}})),a},ar=function(t,e){void 0===e&&(e=t.getAllNodes()[0].id),sr(t,{},1,e)},sr=function(t,e,r,n,o){var i,a=r,s=r,u=t.getNode(n);return e[n]=!0,null===(i=t.getNeighbors(n))||void 0===i||i.forEach((function(r){e[r.id]||(s=sr(t,e,s,r.id,n))})),u.data.low=a,u.data.lim=s++,o?u.data.parent=o:delete u.data.parent,s},ur=function(t){return t.getAllEdges().find((function(t){return t.data.cutvalue<0}))},dr=function(t,e,r){var n=r.source,o=r.target;e.getRelatedEdges(n,"out").find((function(t){return t.target===o}))||(n=r.target,o=r.source);var i=t.getNode(n),a=t.getNode(o),s=i,u=!1;i.data.lim>a.data.lim&&(s=a,u=!0);var d=e.getAllEdges().filter((function(e){return u===fr(t.getNode(e.source),s)&&u!==fr(t.getNode(e.target),s)}));return He(d,(function(t){return Qe(e,t)}))},hr=function(t,e,r,n){var o=t.getRelatedEdges(r.source,"both").find((function(t){return t.source===r.target||t.target===r.target}));o&&t.removeEdge(o.id),t.addEdge({id:"e".concat(Math.random()),source:n.source,target:n.target,data:{}}),ar(t),nr(t,e),cr(t,e)},cr=function(t,e){var r=t.getAllNodes().find((function(t){return!t.data.parent})),n=Ke(t,r,"pre",!1);(n=n.slice(1)).forEach((function(r){var n=t.getNode(r).data.parent,o=e.getRelatedEdges(r,"out").find((function(t){return t.target===n})),i=!1;!o&&e.hasNode(n)&&(o=e.getRelatedEdges(n,"out").find((function(t){return t.target===r})),i=!0),e.getNode(r).data.rank=(e.hasNode(n)&&e.getNode(n).data.rank||0)+(i?null==o?void 0:o.data.minlen:-(null==o?void 0:o.data.minlen))}))},lr=function(t,e,r){return t.getRelatedEdges(e,"both").find((function(t){return t.source===r||t.target===r}))},fr=function(t,e){return e.data.low<=t.data.lim&&t.data.lim<=e.data.lim},gr=Xe,pr=function(t){!function(t){var e=function(t){var e=new g;return t.getAllNodes().forEach((function(t){e.addNode(n({},t))})),t.getAllEdges().forEach((function(t){var r=e.getRelatedEdges(t.source,"out").find((function(e){return e.target===t.target}));r?e.updateEdgeData(null==r?void 0:r.id,n(n({},r.data),{weight:r.data.weight+t.data.weight||0,minlen:Math.max(r.data.minlen,t.data.minlen||1)})):e.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||0,minlen:t.data.minlen||1}})})),e}(t);Xe(e);var r,o,i=function(t){var e,r,n=new g({tree:[]}),o=t.getAllNodes()[0],i=t.getAllNodes().length;for(n.addNode(o);Ze(n,t)<i;)e=er(n,t),r=n.hasNode(e.source)?Qe(t,e):-Qe(t,e),rr(n,t,r);return n}(e);for(ar(i),nr(i,e);r=ur(i);)o=dr(i,e,r),hr(i,e,r,o)}(t)},vr=function(t,e,r,n,o,i,a){var s=t.getChildren(a);if(null==s?void 0:s.length){var u=$e(t,"_bt"),d=$e(t,"_bb"),h=t.getNode(a);t.setParent(u,a),h.data.borderTop=u,t.setParent(d,a),h.data.borderBottom=d,null==s||s.forEach((function(s){vr(t,e,r,n,o,i,s.id);var h=s.data.borderTop?s.data.borderTop:s.id,c=s.data.borderBottom?s.data.borderBottom:s.id,l=s.data.borderTop?n:2*n,f=h!==c?1:o-i[a]+1;t.addEdge({id:"e".concat(Math.random()),source:u,target:h,data:{minlen:f,weight:l,nestingEdge:!0}}),t.addEdge({id:"e".concat(Math.random()),source:c,target:d,data:{minlen:f,weight:l,nestingEdge:!0}})})),t.getParent(a)||t.addEdge({id:"e".concat(Math.random()),source:e,target:u,data:{weight:0,minlen:o+i[a]}})}else a!==e&&t.addEdge({id:"e".concat(Math.random()),source:e,target:a,data:{weight:0,minlen:r}})},yr=function(t,e,r,n,o,i){var a={rank:i,borderType:e,width:0,height:0},s=o.data[e][i-1],u=Ve(t,"border",a,r);o.data[e][i]=u,t.setParent(u,n),s&&t.addEdge({id:"e".concat(Math.random()),source:s,target:u,data:{weight:1}})},mr=function(t){t.getAllNodes().forEach((function(t){wr(t)})),t.getAllEdges().forEach((function(t){wr(t)}))},wr=function(t){var e=t.data.width;t.data.width=t.data.height,t.data.height=e},xr=function(t){(null==t?void 0:t.y)&&(t.y=-t.y)},Er=function(t){var e=t.x;t.x=t.y,t.y=e},Nr=function(t){for(var e={},r=t.getAllNodes(),n=r.map((function(t){var e;return null!==(e=t.data.rank)&&void 0!==e?e:-1/0})),o=Math.max.apply(Math,u([],s(n),!1)),i=[],a=0;a<o+1;a++)i.push([]);var d=r.sort((function(e,r){return t.getNode(e.id).data.rank-t.getNode(r.id).data.rank})),h=d.filter((function(e){return void 0!==t.getNode(e.id).data.fixorder})).sort((function(e,r){return t.getNode(e.id).data.fixorder-t.getNode(r.id).data.fixorder}));return null==h||h.forEach((function(r){isNaN(t.getNode(r.id).data.rank)||i[t.getNode(r.id).data.rank].push(r.id),e[r.id]=!0})),null==d||d.forEach((function(r){return t.dfsTree(r.id,(function(t){if(e.hasOwnProperty(t.id))return!0;e[t.id]=!0,isNaN(t.data.rank)||i[t.data.rank].push(t.id)}))})),i},br=function(t,e,r){for(var n=function(t,e){return null==t?void 0:t.reduce((function(t,r,n){return t[r]=e[n],t}),{})}(r,r.map((function(t,e){return e}))),o=e.map((function(e){var r=t.getRelatedEdges(e,"out").map((function(t){return{pos:n[t.target]||0,weight:t.data.weight}}));return null==r?void 0:r.sort((function(t,e){return t.pos-e.pos}))})),i=o.flat().filter((function(t){return void 0!==t})),a=1;a<r.length;)a<<=1;var s=2*a-1;a-=1;var u=Array(s).fill(0,0,s),d=0;return null==i||i.forEach((function(t){if(t){var e=t.pos+a;u[e]+=t.weight;for(var r=0;e>0;)e%2&&(r+=u[e+1]),u[e=e-1>>1]+=t.weight;d+=t.weight*r}})),d},Mr=function(t,e){for(var r=0,n=1;n<(null==e?void 0:e.length);n+=1)r+=br(t,e[n-1],e[n]);return r},Sr=function(t,e){var r,n=0,o=0;t.weight&&(n+=t.barycenter*t.weight,o+=t.weight),e.weight&&(n+=e.barycenter*e.weight,o+=e.weight),t.vs=null===(r=e.vs)||void 0===r?void 0:r.concat(t.vs),t.barycenter=n/o,t.weight=o,t.i=Math.min(e.i,t.i),e.merged=!0};const Ar=function(t,e){var r,n,o,i={};return null==t||t.forEach((function(t,e){i[t.v]={i:e,indegree:0,in:[],out:[],vs:[t.v]};var r=i[t.v];void 0!==t.barycenter&&(r.barycenter=t.barycenter,r.weight=t.weight)})),null===(r=e.getAllEdges())||void 0===r||r.forEach((function(t){var e=i[t.source],r=i[t.target];void 0!==e&&void 0!==r&&(r.indegree++,e.out.push(i[t.target]))})),function(t){for(var e,r,n=[],o=function(){var o=t.pop();n.push(o),null===(e=o.in.reverse())||void 0===e||e.forEach((function(t){return(e=o,function(t){t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&Sr(e,t)})(t);var e})),null===(r=o.out)||void 0===r||r.forEach((function(e){return(r=o,function(e){e.in.push(r),0==--e.indegree&&t.push(e)})(e);var r}))};null==t?void 0:t.length;)o();var i=n.filter((function(t){return!t.merged})),a=["vs","i","barycenter","weight"];return i.map((function(t){var e={};return null==a||a.forEach((function(r){void 0!==t[r]&&(e[r]=t[r])})),e}))}(null===(o=(n=Object.values(i)).filter)||void 0===o?void 0:o.call(n,(function(t){return!t.indegree})))};var kr=function(t,e,r){for(var n,o=r;e.length&&(n=e[e.length-1]).i<=o;)e.pop(),null==t||t.push(n.vs),o++;return o},_r=function(t,e,r,n,o,i){var a,s,u,d,h=t.getChildren(e).map((function(t){return t.id})),c=t.getNode(e),l=c?c.data.borderLeft:void 0,f=c?c.data.borderRight:void 0,g={};l&&(h=null==h?void 0:h.filter((function(t){return t!==l&&t!==f})));var p=function(t,e){return e.map((function(e){var r=t.getRelatedEdges(e,"in");if(!(null==r?void 0:r.length))return{v:e};var n={sum:0,weight:0};return null==r||r.forEach((function(e){var r=t.getNode(e.source);n.sum+=e.data.weight*r.data.order,n.weight+=e.data.weight})),{v:e,barycenter:n.sum/n.weight,weight:n.weight}}))}(t,h||[]);null==p||p.forEach((function(e){var o;if(null===(o=t.getChildren(e.v))||void 0===o?void 0:o.length){var a=_r(t,e.v,r,n,i);g[e.v]=a,a.hasOwnProperty("barycenter")&&Rr(e,a)}}));var v=Ar(p,r);zr(v,g),null===(a=v.filter((function(t){return t.vs.length>0})))||void 0===a||a.forEach((function(e){var r=t.getNode(e.vs[0]);r&&(e.fixorder=r.data.fixorder,e.order=r.data.order)}));var y=function(t,e,r,n){var o=function(t,e){var r={lhs:[],rhs:[]};return null==t||t.forEach((function(t){var e,o;o=(e=t).hasOwnProperty("fixorder")&&!isNaN(e.fixorder),(n?!o&&e.hasOwnProperty("barycenter"):o||e.hasOwnProperty("barycenter"))?r.lhs.push(t):r.rhs.push(t)})),r}(t),i=o.lhs,a=o.rhs.sort((function(t,e){return-t.i- -e.i})),s=[],u=0,d=0,h=0;null==i||i.sort(function(t,e){return function(r,n){if(void 0!==r.fixorder&&void 0!==n.fixorder)return r.fixorder-n.fixorder;if(r.barycenter<n.barycenter)return-1;if(r.barycenter>n.barycenter)return 1;if(e&&void 0!==r.order&&void 0!==n.order){if(r.order<n.order)return-1;if(r.order>n.order)return 1}return t?n.i-r.i:r.i-n.i}}(!!e,!!r)),h=kr(s,a,h),null==i||i.forEach((function(t){var e;h+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),u+=t.barycenter*t.weight,d+=t.weight,h=kr(s,a,h)}));var c={vs:s.flat()};return d&&(c.barycenter=u/d,c.weight=d),c}(v,n,o,i);if(l&&(y.vs=[l,y.vs,f].flat(),null===(s=t.getPredecessors(l))||void 0===s?void 0:s.length)){var m=t.getNode((null===(u=t.getPredecessors(l))||void 0===u?void 0:u[0].id)||""),w=t.getNode((null===(d=t.getPredecessors(f))||void 0===d?void 0:d[0].id)||"");y.hasOwnProperty("barycenter")||(y.barycenter=0,y.weight=0),y.barycenter=(y.barycenter*y.weight+m.data.order+w.data.order)/(y.weight+2),y.weight+=2}return y},zr=function(t,e){null==t||t.forEach((function(t){var r,n=null===(r=t.vs)||void 0===r?void 0:r.map((function(t){return e[t]?e[t].vs:t}));t.vs=n.flat()}))},Rr=function(t,e){void 0!==t.barycenter?(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight):(t.barycenter=e.barycenter,t.weight=e.weight)},Ir=function(t){if("object"!=typeof t||null===t)return t;var e,r;if(r=t,Array.isArray?Array.isArray(r):y(r,"Array")){e=[];for(var n=0,o=t.length;n<o;n++)"object"==typeof t[n]&&null!=t[n]?e[n]=Ir(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=Ir(t[i]):e[i]=t[i];return e};const Dr=Ir;var Pr=function(t,e,r){return e.map((function(e){return function(t,e,r){var o=function(t){for(var e;t.hasNode(e="_root".concat(Math.random())););return e}(t),i=new g({tree:[{id:o,children:[],data:{}}]});return t.getAllNodes().forEach((function(a){var s=t.getParent(a.id);(a.data.rank===e||a.data.minRank<=e&&e<=a.data.maxRank)&&(i.hasNode(a.id)||i.addNode(n({},a)),(null==s?void 0:s.id)&&!i.hasNode(null==s?void 0:s.id)&&i.addNode(n({},s)),i.setParent(a.id,(null==s?void 0:s.id)||o),t.getRelatedEdges(a.id,r).forEach((function(e){var r=e.source===a.id?e.target:e.source;i.hasNode(r)||i.addNode(n({},t.getNode(r)));var o=i.getRelatedEdges(r,"out").find((function(t){return t.target===a.id})),s=void 0!==o?o.data.weight:0;o?i.updateEdgeData(o.id,n(n({},o.data),{weight:e.data.weight+s})):i.addEdge({id:e.id,source:r,target:a.id,data:{weight:e.data.weight+s}})})),a.data.hasOwnProperty("minRank")&&i.updateNodeData(a.id,n(n({},a.data),{borderLeft:a.data.borderLeft[e],borderRight:a.data.borderRight[e]})))})),i}(t,e,r)}))},Or=function(t,e,r,n){var o=new g;null==t||t.forEach((function(t){for(var i,a=t.getRoots()[0].id,s=_r(t,a,o,e,r,n),u=0;u<(null===(i=s.vs)||void 0===i?void 0:i.length);u++){var d=t.getNode(s.vs[u]);d&&(d.data.order=u)}!function(t,e,r){var n,o={};null==r||r.forEach((function(r){for(var i,a,s=t.getParent(r);s;){if((i=t.getParent(s.id))?(a=o[i.id],o[i.id]=s.id):(a=n,n=s.id),a&&a!==s.id)return e.hasNode(a)||e.addNode({id:a,data:{}}),e.hasNode(s.id)||e.addNode({id:s.id,data:{}}),void(e.hasEdge("e".concat(a,"-").concat(s.id))||e.addEdge({id:"e".concat(a,"-").concat(s.id),source:a,target:s.id,data:{}}));s=i}}))}(t,o,s.vs)}))},Cr=function(t,e){null==e||e.forEach((function(e){null==e||e.forEach((function(e,r){t.getNode(e).data.order=r}))}))},Tr=function(t,e){var r={};function n(e,n,o,i,a){for(var s,u,d,h=n;h<o;h++)d=e[h],(null===(s=t.getNode(d))||void 0===s?void 0:s.data.dummy)&&(null===(u=t.getPredecessors(d))||void 0===u||u.forEach((function(e){var n=t.getNode(e.id);n.data.dummy&&(n.data.order<i||n.data.order>a)&&Lr(r,e.id,d)})))}function o(t,e){var r=function(t){return JSON.stringify(t.slice(1))}(t);e.get(r)||(n.apply(void 0,u([],s(t),!1)),e.set(r,!0))}return(null==e?void 0:e.length)&&e.reduce((function(e,r){var n,i=-1,a=0,s=new Map;return null==r||r.forEach((function(u,d){var h;if("border"===(null===(h=t.getNode(u))||void 0===h?void 0:h.data.dummy)){var c=t.getPredecessors(u)||[];c.length&&(n=t.getNode(c[0].id).data.order,o([r,a,d,i,n],s),a=d,i=n)}o([r,a,r.length,n,e.length],s)})),r})),r},Fr=function(t,e){var r,n;if(null===(r=t.getNode(e))||void 0===r?void 0:r.data.dummy)return null===(n=t.getPredecessors(e))||void 0===n?void 0:n.find((function(e){return t.getNode(e.id).data.dummy}))},Lr=function(t,e,r){var n=e,o=r;if(n>o){var i=n;n=o,o=i}var a=t[n];a||(t[n]=a={}),a[o]=!0},qr=function(t,e,r){var n=e;return n>r&&(n=r),!!t[n]},jr=function(t,e,r,o,i,a){var s=new g,u=Vr(o,i,a);return null==e||e.forEach((function(e){var o;null==e||e.forEach((function(e){var i=r[e];if(s.hasNode(i)||s.addNode({id:i,data:{}}),o){var a=r[o],d=s.getRelatedEdges(a,"out").find((function(t){return t.target===i}));d?s.updateEdgeData(d.id,n(n({},d.data),{weight:Math.max(u(t,e,o),d.data.weight||0)})):s.addEdge({id:"e".concat(Math.random()),source:a,target:i,data:{weight:Math.max(u(t,e,o),0)}})}o=e}))})),s};var Vr=function(t,e,r){return function(n,o,i){var a=n.getNode(o),s=n.getNode(i),u=0,d=0;if(u+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":d=-a.data.width/2;break;case"r":d=a.data.width/2}if(d&&(u+=r?d:-d),d=0,u+=(a.data.dummy?e:t)/2,u+=(s.data.dummy?e:t)/2,u+=s.data.width/2,s.data.labelpos)switch((s.data.labelpos||"").toLowerCase()){case"l":d=s.data.width/2;break;case"r":d=-s.data.width/2}return d&&(u+=r?d:-d),d=0,u}},Br=function(t,e){return t.getNode(e).data.width||0},Gr=function(t,e){var r,n=Be(t);!function(t,e){var r=(e||{}).ranksep,n=void 0===r?0:r,o=We(t),i=0;null==o||o.forEach((function(e){var r=e.map((function(e){return t.getNode(e).data.height})),o=Math.max.apply(Math,u(u([],s(r),!1),[0],!1));null==e||e.forEach((function(e){t.getNode(e).data.y=i+o/2})),i+=o+n}))}(n,e);var o=function(t,e){var r=e||{},n=r.align,o=r.nodesep,i=void 0===o?0:o,a=r.edgesep,d=void 0===a?0:a,h=We(t),c=Object.assign(function(t,e){var r={};return(null==e?void 0:e.length)&&e.reduce((function(e,n){var o=0,i=0,a=e.length,s=null==n?void 0:n[(null==n?void 0:n.length)-1];return null==n||n.forEach((function(e,u){var d,h=Fr(t,e),c=h?t.getNode(h.id).data.order:a;(h||e===s)&&(null===(d=n.slice(i,u+1))||void 0===d||d.forEach((function(e){var n;null===(n=t.getPredecessors(e))||void 0===n||n.forEach((function(n){var i,a=t.getNode(n.id),s=a.data.order;!(s<o||c<s)||a.data.dummy&&(null===(i=t.getNode(e))||void 0===i?void 0:i.data.dummy)||Lr(r,n.id,e)}))})),i=u+1,o=c)})),n})),r}(t,h),Tr(t,h)),l={},f=[];["u","d"].forEach((function(e){f="u"===e?h:Object.values(h).reverse(),["l","r"].forEach((function(r){"r"===r&&(f=f.map((function(t){return Object.values(t).reverse()})));var n=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),o=function(t,e,r,n){var o={},i={},a={};return null==e||e.forEach((function(t){null==t||t.forEach((function(t,e){o[t]=t,i[t]=t,a[t]=e}))})),null==e||e.forEach((function(t){var e=-1;null==t||t.forEach((function(t){var s=n(t).map((function(t){return t.id}));if(s.length){s=s.sort((function(t,e){return a[t]-a[e]}));for(var u=(s.length-1)/2,d=Math.floor(u),h=Math.ceil(u);d<=h;++d){var c=s[d];i[t]===t&&e<a[c]&&!qr(r,t,c)&&(i[c]=t,i[t]=o[t]=o[c],e=a[c])}}}))})),{root:o,align:i}}(0,f,c,n),a=function(t,e,r,n,o,i,a){var s,u={},d=jr(t,e,r,o,i,a),h=a?"borderLeft":"borderRight",c=function(t,e){for(var r=d.getAllNodes(),n=r.pop(),o={};n;)o[n.id]?t(n.id):(o[n.id]=!0,r.push(n),r=r.concat(e(n.id))),n=r.pop()};return c((function(t){u[t]=(d.getRelatedEdges(t,"in")||[]).reduce((function(t,e){return Math.max(t,(u[e.source]||0)+e.data.weight)}),0)}),d.getPredecessors.bind(d)),c((function(e){var r=(d.getRelatedEdges(e,"out")||[]).reduce((function(t,e){return Math.min(t,(u[e.target]||0)-e.data.weight)}),Number.POSITIVE_INFINITY),n=t.getNode(e);r!==Number.POSITIVE_INFINITY&&n.data.borderType!==h&&(u[e]=Math.max(u[e],r))}),d.getSuccessors.bind(d)),null===(s=Object.values(n))||void 0===s||s.forEach((function(t){u[t]=u[r[t]]})),u}(t,f,o.root,o.align,i,d,"r"===r);"r"===r&&Object.keys(a).forEach((function(t){return a[t]=-a[t]})),l[e+r]=a}))}));var g=function(t,e){return He(Object.values(e),(function(e){var r,n=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;return null===(r=Object.keys(e))||void 0===r||r.forEach((function(r){var i=e[r],a=Br(t,r)/2;n=Math.max(i+a,n),o=Math.min(i-a,o)})),n-o}))}(t,l);return g&&function(t,e){var r=Object.values(e),n=Math.min.apply(Math,u([],s(r),!1)),o=Math.max.apply(Math,u([],s(r),!1));["u","d"].forEach((function(r){["l","r"].forEach((function(i){var a,d=r+i,h=t[d];if(h!==e){var c=Object.values(h);(a="l"===i?n-Math.min.apply(Math,u([],s(c),!1)):o-Math.max.apply(Math,u([],s(c),!1)))&&(t[d]={},Object.keys(h).forEach((function(e){t[d][e]=h[e]+a})))}}))}))}(l,g),function(t,e){var r={};return Object.keys(t.ul).forEach((function(n){if(e)r[n]=t[e.toLowerCase()][n];else{var o=Object.values(t).map((function(t){return t[n]}));r[n]=(o[0]+o[1])/2}})),r}(l,n)}(n,e);null===(r=Object.keys(o))||void 0===r||r.forEach((function(t){n.getNode(t).data.x=o[t]}))},Wr=function(t,e){var r=e.acyclicer,o=e.ranker,i=e.rankdir,a=void 0===i?"tb":i,d=e.nodeOrder,h=e.keepNodeOrder,c=e.align,l=e.nodesep,f=void 0===l?50:l,p=e.edgesep,v=void 0===p?20:p,y=e.ranksep,m=void 0===y?50:y;on(t),qe(t,r);var w=function(t){var e=Ve(t,"root",{},"_root"),r=function(t){var e={},r=function(n,o){var i=t.getChildren(n);null==i||i.forEach((function(t){return r(t.id,o+1)})),e[n]=o};return t.getRoots().forEach((function(t){return r(t.id,1)})),e}(t),n=Math.max.apply(Math,u([],s(Object.values(r)),!1));Math.abs(n)===1/0&&(n=1);var o=n-1,i=2*o+1;t.getAllEdges().forEach((function(t){t.data.minlen*=i}));var a=function(t){var e=0;return t.getAllEdges().forEach((function(t){e+=t.data.weight})),e}(t)+1;return t.getRoots().forEach((function(n){vr(t,e,i,a,o,r,n.id)})),{nestingRoot:e,nodeRankFactor:i}}(t),x=w.nestingRoot,E=w.nodeRankFactor;!function(t,e){switch(e){case"network-simplex":pr(t);break;case"tight-tree":default:!function(t){!function(t){var e,r={},n=function(o){var i,a,s=t.getNode(o);return s?r[o]?s.data.rank:(r[o]=!0,null===(i=t.getRelatedEdges(o,"out"))||void 0===i||i.forEach((function(t){var e=n(t.target)-t.data.minlen;e&&(void 0===a||e<a)&&(a=e)})),a||(a=0),(void 0===e||a<e)&&(e=a),s.data.rank=a,a):0};t.getAllNodes().filter((function(e){return 0===t.getRelatedEdges(e.id,"in").length})).forEach((function(t){t&&n(t.id)})),void 0===e&&(e=0);var o={},i=function(e,r){var n,a=t.getNode(e),s=isNaN(a.data.layer)?r:a.data.layer;(void 0===a.data.rank||a.data.rank<s)&&(a.data.rank=s),o[e]||(o[e]=!0,null===(n=t.getRelatedEdges(e,"out"))||void 0===n||n.forEach((function(t){i(t.target,s+t.data.minlen)})))};t.getAllNodes().forEach((function(t){var r=t.data;r&&(isNaN(r.layer)?r.rank-=e:i(t.id,r.layer))}))}(t),function(t){var e,r,n=new g({tree:[]}),o=t.getAllNodes()[0],i=t.getAllNodes().length;for(n.addNode(o);tr(n,t)<i;)e=er(n,t),r=n.hasNode(e.source)?Qe(t,e):-Qe(t,e),rr(n,t,r)}(t)}(t);break;case"longest-path":gr(t)}}(Be(t),o),Jr(t),function(t,e){void 0===e&&(e=0);var r=t.getAllNodes(),n=r.filter((function(t){return void 0!==t.data.rank})).map((function(t){return t.data.rank})),o=Math.min.apply(Math,u([],s(n),!1)),i=[];r.forEach((function(t){var e=(t.data.rank||0)-o;i[e]||(i[e]=[]),i[e].push(t.id)}));for(var a=0,d=0;d<i.length;d++){var h=i[d];void 0===h?d%e!=0&&(a-=1):a&&(null==h||h.forEach((function(e){var r=t.getNode(e);r&&(r.data.rank=r.data.rank||0,r.data.rank+=a)})))}}(t,E),function(t,e){e&&t.removeNode(e),t.getAllEdges().forEach((function(e){e.data.nestingEdge&&t.removeEdge(e.id)}))}(t,x),function(t){var e=t.getAllNodes().filter((function(t){return void 0!==t.data.rank})).map((function(t){return t.data.rank})),r=Math.min.apply(Math,u([],s(e),!1));t.getAllNodes().forEach((function(t){t.data.hasOwnProperty("rank")&&r!==1/0&&(t.data.rank-=r)}))}(t),Xr(t),Qr(t);var N=[];!function(t,e){t.getAllEdges().forEach((function(r){return function(t,e,r){var n=e.source,o=t.getNode(n).data.rank,i=e.target,a=t.getNode(i).data.rank,s=e.data.labelRank;if(a!==o+1){var u,d,h;for(t.removeEdge(e.id),h=0,++o;o<a;++h,++o)e.data.points=[],u=Ve(t,"edge",d={originalEdge:e,width:0,height:0,rank:o},"_d"),o===s&&(d.width=e.data.width,d.height=e.data.height,d.dummy=Je,d.labelpos=e.data.labelpos),t.addEdge({id:"e".concat(Math.random()),source:n,target:u,data:{weight:e.data.weight}}),0===h&&r.push(u),n=u;t.addEdge({id:"e".concat(Math.random()),source:n,target:i,data:{weight:e.data.weight}})}}(t,r,e)}))}(t,N),function(t,e){var r=function(t){var e={},r=0,n=function(o){var i=r;t.getChildren(o).forEach((function(t){return n(t.id)})),e[o]={low:i,lim:r++}};return t.getRoots().forEach((function(t){return n(t.id)})),e}(t);e.forEach((function(e){var n,o,i=e,a=t.getNode(i),s=a.data.originalEdge;if(s)for(var u=function(t,e,r,n){var o,i,a,s,u=[],d=[],h=Math.min(e[r].low,e[n].low),c=Math.max(e[r].lim,e[n].lim);a=r;do{a=null===(o=t.getParent(a))||void 0===o?void 0:o.id,u.push(a)}while(a&&(e[a].low>h||c>e[a].lim));for(s=a,a=n;a&&a!==s;)d.push(a),a=null===(i=t.getParent(a))||void 0===i?void 0:i.id;return{lca:s,path:u.concat(d.reverse())}}(t,r,s.source,s.target),d=u.path,h=u.lca,c=0,l=d[c],f=!0;i!==s.target;){if(a=t.getNode(i),f){for(;l!==h&&(null===(n=t.getNode(l))||void 0===n?void 0:n.data.maxRank)<a.data.rank;)l=d[++c];l===h&&(f=!1)}if(!f){for(;c<d.length-1&&(null===(o=t.getNode(d[c+1]))||void 0===o?void 0:o.data.minRank)<=a.data.rank;)c++;l=d[c]}t.hasNode(l)&&t.setParent(i,l),i=t.getSuccessors(i)[0].id}}))}(t,N),function(t){var e=function(r){var n=t.getChildren(r),o=t.getNode(r);if((null==n?void 0:n.length)&&n.forEach((function(t){return e(t.id)})),o.data.hasOwnProperty("minRank")){o.data.borderLeft=[],o.data.borderRight=[];for(var i=o.data.minRank,a=o.data.maxRank+1;i<a;i+=1)yr(t,"borderLeft","_bl",r,o,i),yr(t,"borderRight","_br",r,o,i)}};t.getRoots().forEach((function(t){return e(t.id)}))}(t),h&&function(t,e){for(var r=t.getAllNodes().filter((function(e){var r;return!(null===(r=t.getChildren(e.id))||void 0===r?void 0:r.length)})).map((function(t){return t.data.rank})),n=Math.max.apply(Math,u([],s(r),!1)),o=[],i=0;i<n+1;i++)o[i]=[];null==e||e.forEach((function(e){var r=t.getNode(e);r&&!r.data.dummy&&(isNaN(r.data.rank)||(r.data.fixorder=o[r.data.rank].length,o[r.data.rank].push(e)))}))}(t,d),function(t,e){for(var r=Ue(t),n=[],o=[],i=1;i<r+1;i++)n.push(i);for(i=r-1;i>-1;i--)o.push(i);var a=Pr(t,n,"in"),s=Pr(t,o,"out"),u=Nr(t);Cr(t,u);for(var d,h=Number.POSITIVE_INFINITY,c=(i=0,0);c<4;++i,++c)Or(i%2?a:s,i%4>=2,!1,e),u=We(t),(l=Mr(t,u))<h&&(c=0,d=Dr(u),h=l);for(u=Nr(t),Cr(t,u),i=0,c=0;c<4;++i,++c){var l;Or(i%2?a:s,i%4>=2,!0,e),u=We(t),(l=Mr(t,u))<h&&(c=0,d=Dr(u),h=l)}Cr(t,d)}(t,h),an(t),function(t,e){var r=e.toLowerCase();"lr"!==r&&"rl"!==r||mr(t)}(t,a),Gr(t,{align:c,nodesep:f,edgesep:v,ranksep:m}),sn(t),nn(t),function(t,e){e.forEach((function(e){var r,n=t.getNode(e),o=n.data.originalEdge;o&&t.addEdge(o);for(var i=e;n.data.dummy;)r=t.getSuccessors(i)[0],t.removeNode(i),o.data.points.push({x:n.data.x,y:n.data.y}),n.data.dummy===Je&&(o.data.x=n.data.x,o.data.y=n.data.y,o.data.width=n.data.width,o.data.height=n.data.height),i=r.id,n=t.getNode(i)}))}(t,N),en(t),function(t,e){var r=e.toLowerCase();"bt"!==r&&"rl"!==r||function(t){t.getAllNodes().forEach((function(t){xr(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return xr(t)})),t.data.hasOwnProperty("y")&&xr(t.data)}))}(t),"lr"!==r&&"rl"!==r||(function(t){t.getAllNodes().forEach((function(t){Er(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return Er(t)})),t.data.hasOwnProperty("x")&&Er(t.data)}))}(t),mr(t))}(t,a);var b=Zr(t),M=b.width,S=b.height;return tn(t),rn(t),function(t){t.getAllEdges().forEach((function(e){var r=e.data;if(r.reversed){t.removeEdge(e.id);var o=r.forwardName;delete r.reversed,delete r.forwardName,t.addEdge({id:e.id,source:e.target,target:e.source,data:n(n({},r),{forwardName:o})})}}))}(t),{width:M,height:S}},$r=["width","height","layer","fixorder"],Ur={width:0,height:0},Hr=["minlen","weight","width","height","labeloffset"],Yr={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Kr=["labelpos"],Jr=function(t){t.getAllEdges().forEach((function(e){if(e.data.width&&e.data.height){var r=t.getNode(e.source),n={e,rank:(t.getNode(e.target).data.rank-r.data.rank)/2+r.data.rank};Ve(t,"edge-proxy",n,"_ep")}}))},Xr=function(t){var e=0;return t.getAllNodes().forEach((function(r){var n,o;r.data.borderTop&&(r.data.minRank=null===(n=t.getNode(r.data.borderTop))||void 0===n?void 0:n.data.rank,r.data.maxRank=null===(o=t.getNode(r.data.borderBottom))||void 0===o?void 0:o.data.rank,e=Math.max(e,r.data.maxRank||-1/0))})),e},Qr=function(t){t.getAllNodes().forEach((function(e){"edge-proxy"===e.data.dummy&&(t.getEdge(e.data.e.id).data.labelRank=e.data.rank,t.removeNode(e.id))}))},Zr=function(t,e){var r,n,o=0,i=0,a=e||{},s=a.marginx,u=void 0===s?0:s,d=a.marginy,h=void 0===d?0:d,c=function(t){if(t.data){var e=t.data.x,a=t.data.y,s=t.data.width,u=t.data.height;isNaN(e)||isNaN(s)||(void 0===r&&(r=e-s/2),r=Math.min(r,e-s/2),o=Math.max(o,e+s/2)),isNaN(a)||isNaN(u)||(void 0===n&&(n=a-u/2),n=Math.min(n,a-u/2),i=Math.max(i,a+u/2))}};return t.getAllNodes().forEach((function(t){c(t)})),t.getAllEdges().forEach((function(t){(null==t?void 0:t.data.hasOwnProperty("x"))&&c(t)})),r-=u,n-=h,t.getAllNodes().forEach((function(t){t.data.x-=r,t.data.y-=n})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){t.x-=r,t.y-=n})),t.data.hasOwnProperty("x")&&(t.data.x-=r),t.data.hasOwnProperty("y")&&(t.data.y-=n)})),{width:o-r+u,height:i-n+h}},tn=function(t){t.getAllEdges().forEach((function(e){var r,n,o=t.getNode(e.source),i=t.getNode(e.target);e.data.points?(r=e.data.points[0],n=e.data.points[e.data.points.length-1]):(e.data.points=[],r={x:i.data.x,y:i.data.y},n={x:o.data.x,y:o.data.y}),e.data.points.unshift(Ge(o.data,r)),e.data.points.push(Ge(i.data,n))}))},en=function(t){t.getAllEdges().forEach((function(t){if(t.data.hasOwnProperty("x"))switch("l"!==t.data.labelpos&&"r"!==t.data.labelpos||(t.data.width-=t.data.labeloffset),t.data.labelpos){case"l":t.data.x-=t.data.width/2+t.data.labeloffset;break;case"r":t.data.x+=t.data.width/2+t.data.labeloffset}}))},rn=function(t){t.getAllEdges().forEach((function(t){var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},nn=function(t){t.getAllNodes().forEach((function(e){var r,n,o;if(null===(r=t.getChildren(e.id))||void 0===r?void 0:r.length){var i=t.getNode(e.id),a=t.getNode(i.data.borderTop),s=t.getNode(i.data.borderBottom),u=t.getNode(i.data.borderLeft[(null===(n=i.data.borderLeft)||void 0===n?void 0:n.length)-1]),d=t.getNode(i.data.borderRight[(null===(o=i.data.borderRight)||void 0===o?void 0:o.length)-1]);i.data.width=Math.abs((null==d?void 0:d.data.x)-(null==u?void 0:u.data.x))||10,i.data.height=Math.abs((null==s?void 0:s.data.y)-(null==a?void 0:a.data.y))||10,i.data.x=((null==u?void 0:u.data.x)||0)+i.data.width/2,i.data.y=((null==a?void 0:a.data.y)||0)+i.data.height/2}})),t.getAllNodes().forEach((function(e){"border"===e.data.dummy&&t.removeNode(e.id)}))},on=function(t){t.getAllEdges().forEach((function(e){if(e.source===e.target){var r=t.getNode(e.source);r.data.selfEdges||(r.data.selfEdges=[]),r.data.selfEdges.push(e),t.removeEdge(e.id)}}))},an=function(t){var e=We(t);null==e||e.forEach((function(e){var r=0;null==e||e.forEach((function(e,n){var o,i=t.getNode(e);i.data.order=n+r,null===(o=i.data.selfEdges)||void 0===o||o.forEach((function(e){Ve(t,"selfedge",{width:e.data.width,height:e.data.height,rank:i.data.rank,order:n+ ++r,e},"_se")})),delete i.data.selfEdges}))}))},sn=function(t){t.getAllNodes().forEach((function(e){var r=t.getNode(e.id);if("selfedge"===r.data.dummy){var n=t.getNode(r.data.e.source),o=n.data.x+n.data.width/2,i=n.data.y,a=r.data.x-o,s=n.data.height/2;t.hasEdge(r.data.e.id)?t.updateEdgeData(r.data.e.id,r.data.e.data):t.addEdge({id:r.data.e.id,source:r.data.e.source,target:r.data.e.target,data:r.data.e.data}),t.removeNode(e.id),r.data.e.data.points=[{x:o+2*a/3,y:i-s},{x:o+5*a/6,y:i-s},{y:i,x:o+a},{x:o+5*a/6,y:i+s},{x:o+2*a/3,y:i+s}],r.data.e.data.x=r.data.x,r.data.e.data.y=r.data.y}}))},un=function(t,e){var r={};return null==e||e.forEach((function(e){void 0!==t[e]&&(r[e]=+t[e])})),r},dn=function(t){void 0===t&&(t={});var e={};return Object.keys(t).forEach((function(r){e[r.toLowerCase()]=t[r]})),e},hn={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,controlPoints:!1,radial:!1,focusNode:null},cn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="dagre",this.options=n(n({},hn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericDagreLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,this.genericDagreLayout(!0,t,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.genericDagreLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f,p,v,y,w,E,b,S,A,k,_,z,R,I,D,P,O,C,T,F,L,q,j,V,B,G;return a(this,(function(a){return o=n(n({},this.options),r),i=o.nodeSize,s=o.align,u=o.rankdir,d=void 0===u?"TB":u,h=o.ranksep,c=o.nodesep,l=o.ranksepFunc,f=o.nodesepFunc,p=o.edgeLabelSpace,v=o.nodeOrder,y=o.begin,w=o.controlPoints,E=o.radial,b=o.sortByCombo,S=new g({tree:[]}),A=x(h||50,l),k=x(c||50,f),_=k,z=A,"LR"!==d&&"RL"!==d||(_=A,z=k),R=N(i,void 0),I=e.getAllNodes(),D=e.getAllEdges(),I.forEach((function(t){var e=R(t),r=z(t),n=e+2*_(t),o=e+2*r,i=t.data.layer;m(i)?S.addNode({id:t.id,data:{width:n,height:o,layer:i}}):S.addNode({id:t.id,data:{width:n,height:o}})})),b&&(S.attachTreeStructure("combo"),I.forEach((function(t){var e=t.data.parentId;void 0!==e&&S.hasNode(e)&&S.setParent(t.id,e,"combo")}))),D.forEach((function(t){S.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||1}})})),function(t,e){var r,o,i=e.edgeLabelSpace,a=e.keepNodeOrder,s=e.prevGraph,u=e.rankdir,d=e.ranksep;!a&&s&&(o=s,(r=t).getAllNodes().forEach((function(t){var e=r.getNode(t.id),n=o.getNode(t.id);void 0!==n?(e.data.fixorder=n.data._order,delete n.data._order):delete e.data.fixorder})));var h=function(t){var e=new g({tree:[]});return t.getAllNodes().forEach((function(r){var o=dn(t.getNode(r.id).data),i=n(n({},Ur),o),a=un(i,$r);e.hasNode(r.id)||e.addNode({id:r.id,data:n({},a)});var s=t.hasTreeStructure("combo")?t.getParent(r.id,"combo"):t.getParent(r.id);null==s||(e.hasNode(s.id)||e.addNode(n({},s)),e.setParent(r.id,s.id))})),t.getAllEdges().forEach((function(r){var n=dn(t.getEdge(r.id).data),o={};null==Kr||Kr.forEach((function(t){void 0!==n[t]&&(o[t]=n[t])})),e.addEdge({id:r.id,source:r.source,target:r.target,data:Object.assign({},Yr,un(n,Hr),o)})})),e}(t);i&&(e.ranksep=function(t,e){var r=e.ranksep,n=void 0===r?0:r,o=e.rankdir;return t.getAllNodes().forEach((function(t){isNaN(t.data.layer)||t.data.layer||(t.data.layer=0)})),t.getAllEdges().forEach((function(t){var e;t.data.minlen*=2,"c"!==(null===(e=t.data.labelpos)||void 0===e?void 0:e.toLowerCase())&&("TB"===o||"BT"===o?t.data.width+=t.data.labeloffset:t.data.height+=t.data.labeloffset)})),n/2}(h,{rankdir:u,ranksep:d}));try{Wr(h,e)}catch(t){if("Not possible to find intersection inside of the rectangle"===t.message)return void console.error("The following error may be caused by improper layer setting, please make sure your manual layer setting does not violate the graph's structure:\n",t);throw t}!function(t,e){t.getAllNodes().forEach((function(r){var n,o=t.getNode(r.id);if(o){var i=e.getNode(r.id);o.data.x=i.data.x,o.data.y=i.data.y,o.data._order=i.data.order,o.data._rank=i.data.rank,(null===(n=e.getChildren(r.id))||void 0===n?void 0:n.length)&&(o.data.width=i.data.width,o.data.height=i.data.height)}})),t.getAllEdges().forEach((function(r){var n=t.getEdge(r.id),o=e.getEdge(r.id);n.data.points=o?o.data.points:[],o&&o.data.hasOwnProperty("x")&&(n.data.x=o.data.x,n.data.y=o.data.y)}))}(t,h)}(S,{prevGraph:null,edgeLabelSpace:p,keepNodeOrder:!!v,nodeOrder:v||[],acyclicer:"greedy",ranker:"network-simplex",rankdir:d,nodesep:c,align:s}),P=[0,0],y&&(O=1/0,C=1/0,S.getAllNodes().forEach((function(t){O>t.data.x&&(O=t.data.x),C>t.data.y&&(C=t.data.y)})),S.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){O>t.x&&(O=t.x),C>t.y&&(C=t.y)}))})),P[0]=y[0]-O,P[1]=y[1]-C),T="LR"===d||"RL"===d,E||(F=new Set,L="BT"===d||"RL"===d?function(t,e){return e-t}:function(t,e){return t-e},S.getAllNodes().forEach((function(t){t.data.x=t.data.x+P[0],t.data.y=t.data.y+P[1],F.add(T?t.data.x:t.data.y)})),q=Array.from(F).sort(L),j=T?function(t,e){return t.x!==e.x}:function(t,e){return t.y!==e.y},V=T?function(t,e,r){var n=Math.max(e.y,r.y),o=Math.min(e.y,r.y);return t.filter((function(t){return t.y<=n&&t.y>=o}))}:function(t,e,r){var n=Math.max(e.x,r.x),o=Math.min(e.x,r.x);return t.filter((function(t){return t.x<=n&&t.x>=o}))},S.getAllEdges().forEach((function(t,e){var r;p&&w&&"loop"!==t.data.type&&(t.data.controlPoints=ln(null===(r=t.data.points)||void 0===r?void 0:r.map((function(t){var e=t.x,r=t.y;return{x:e+P[0],y:r+P[1]}})),S.getNode(t.source),S.getNode(t.target),q,T,j,V))}))),B=[],B=S.getAllNodes().map((function(t){return M(t)})),G=S.getAllEdges(),t&&(B.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),G.forEach((function(t){e.mergeEdgeData(t.id,{controlPoints:t.data.controlPoints})}))),[2,{nodes:B,edges:G}]}))}))},t}(),ln=function(t,e,r,n,o,i,a){var s=(null==t?void 0:t.slice(1,t.length-1))||[];if(e&&r){var u=e.data,d=u.x,h=u.y,c=r.data,l=c.x,f=c.y;if(o&&(d=e.data.y,h=e.data.x,l=r.data.y,f=r.data.x),f!==h&&d!==l){var g=n.indexOf(h),p=n[g+1];if(p){var v=s[0],y=o?{x:(h+p)/2,y:(null==v?void 0:v.y)||l}:{x:(null==v?void 0:v.x)||l,y:(h+p)/2};v&&!i(v,y)||s.unshift(y)}var m=n.indexOf(f),w=Math.abs(m-g);if(1===w)(s=a(s,e.data,r.data)).length||s.push(o?{x:(h+f)/2,y:d}:{x:d,y:(h+f)/2});else if(w>1){var x=n[m-1];if(x){var E=s[s.length-1],N=o?{x:(f+x)/2,y:(null==E?void 0:E.y)||l}:{x:(null==E?void 0:E.x)||d,y:(f+x)/2};E&&!i(E,N)||s.push(N)}}}}return s},fn=function(){function t(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}return t.prototype.distanceTo=function(t){var e=this.rx-t.rx,r=this.ry-t.ry;return Math.hypot(e,r)},t.prototype.setPos=function(t,e){this.rx=t,this.ry=e},t.prototype.resetForce=function(){this.fx=0,this.fy=0},t.prototype.addForce=function(t){var e=t.rx-this.rx,r=t.ry-this.ry,n=Math.hypot(e,r);n=n<1e-4?1e-4:n;var o=this.g*(this.degree+1)*(t.degree+1)/n;this.fx+=o*e/n,this.fy+=o*r/n},t.prototype.in=function(t){return t.contains(this.rx,this.ry)},t.prototype.add=function(e){var r=this.mass+e.mass;return new t({rx:(this.rx*this.mass+e.rx*e.mass)/r,ry:(this.ry*this.mass+e.ry*e.mass)/r,mass:r,degree:this.degree+e.degree})},t}();const gn=fn;const pn=function(){function t(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}return t.prototype.getLength=function(){return this.length},t.prototype.contains=function(t,e){var r=this.length/2;return t<=this.xmid+r&&t>=this.xmid-r&&e<=this.ymid+r&&e>=this.ymid-r},t.prototype.NW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.NE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.SW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t.prototype.SE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t}(),vn=function(){function t(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}return t.prototype.insert=function(e){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new t(this.quad.NW()),this.NE=new t(this.quad.NE()),this.SW=new t(this.quad.SW()),this.SE=new t(this.quad.SE())),this._putBody(this.body),this._putBody(e),this.body=this.body.add(e)):(this.body=this.body.add(e),this._putBody(e)):this.body=e},t.prototype._putBody=function(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))},t.prototype._isExternal=function(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE},t.prototype.updateForce=function(t){null!=this.body&&t!==this.body&&(this._isExternal()||(this.quad?this.quad.getLength():0)/this.body.distanceTo(t)<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t)))},t}();var yn,mn={center:[0,0],width:300,height:300,kr:5,kg:1,mode:"normal",preventOverlap:!1,dissuadeHubs:!1,maxIteration:0,ks:.1,ksmax:10,tao:.1},wn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="forceAtlas2",this.options=n(n({},mn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericForceAtlas2Layout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericForceAtlas2Layout(!0,t,e),[2]}))}))},t.prototype.genericForceAtlas2Layout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f,p,v,y,m,w,x,E,N,b,A,k,_,z;return a(this,(function(a){if(o=e.getAllEdges(),i=e.getAllNodes(),s=this.formatOptions(r,i.length),u=s.width,d=s.height,h=s.prune,c=s.maxIteration,l=s.nodeSize,f=s.center,!(null==i?void 0:i.length)||1===i.length)return[2,S(e,t,f)];if(p=i.map((function(t){return M(t,[u,d])})),v=o.filter((function(t){return t.source!==t.target})),y=new g({nodes:p,edges:v}),m=this.getSizes(y,e,l),this.run(y,e,c,m,t,s),h){for(w=0;w<v.length;w+=1)x=v[w],E=x.source,N=x.target,b=y.getDegree(E),A=y.getDegree(E),b<=1?(k=y.getNode(N),y.mergeNodeData(E,{x:k.data.x,y:k.data.y})):A<=1&&(_=y.getNode(E),y.mergeNodeData(N,{x:_.data.x,y:_.data.y}));z=n(n({},s),{prune:!1,barnesHut:!1}),this.run(y,e,100,m,t,z)}return[2,{nodes:p,edges:o}]}))}))},t.prototype.getSizes=function(t,e,r){for(var n=t.getAllNodes(),o={},i=0;i<n.length;i+=1){var a=n[i],d=a.id,h=a.data;if(o[d]=10,m(h.size))o[d]=h.size;else if(R(h.size))isNaN(h.size[0])||(o[d]=Math.max(h.size[0])),isNaN(h.size[1])||(o[d]=Math.max(h.size[1]));else if(w(h.size))o[d]=Math.max(h.size.width,h.size.height);else if(p(r)){var c=r(e.getNode(d));R(c)?o[d]=Math.max.apply(Math,u([],s(c),!1)):o[d]=c}else R(r)?o[d]=Math.max.apply(Math,u([],s(r),!1)):m(r)&&(o[d]=r)}return o},t.prototype.formatOptions=function(t,e){void 0===t&&(t={});var r=n(n({},this.options),t),o=r.center,i=r.width,a=r.height,s=r.barnesHut,u=r.prune,d=r.maxIteration,h=r.kr,c=r.kg;return r.width=i||"undefined"==typeof window?i:window.innerWidth,r.height=a||"undefined"==typeof window?a:window.innerHeight,r.center=o||[r.width/2,r.height/2],void 0===s&&e>250&&(r.barnesHut=!0),void 0===u&&e>100&&(r.prune=!0),0!==d||u?0===d&&u&&(r.maxIteration=100,e<=200&&e>100?r.maxIteration=500:e>200&&(r.maxIteration=950)):(r.maxIteration=250,e<=200&&e>100?r.maxIteration=1e3:e>200&&(r.maxIteration=1200)),h||(r.kr=50,e>100&&e<=500?r.kr=20:e>500&&(r.kr=1)),c||(r.kg=20,e>100&&e<=500?r.kg=10:e>500&&(r.kg=1)),r},t.prototype.run=function(t,e,r,n,o,i){for(var a=i.kr,s=i.barnesHut,u=i.onTick,d=t.getAllNodes(),h=0,c=r,l={},f={},g={},p=0;p<d.length;p+=1){var v=d[p],y=v.data,m=v.id;if(l[m]=[0,0],s){var w={id:p,rx:y.x,ry:y.y,mass:1,g:a,degree:t.getDegree(m)};g[m]=new gn(w)}}for(;c>0;)h=this.oneStep(t,{iter:c,preventOverlapIters:50,krPrime:100,sg:h,forces:l,preForces:f,bodies:g,sizes:n},i),c--,null==u||u({nodes:d,edges:e.getAllEdges()});return t},t.prototype.oneStep=function(t,e,r){for(var n=e.iter,o=e.preventOverlapIters,i=e.krPrime,a=e.sg,d=e.preForces,h=e.bodies,c=e.sizes,l=e.forces,f=r.preventOverlap,g=r.barnesHut,p=t.getAllNodes(),v=0;v<p.length;v+=1){var y=p[v].id;d[y]=u([],s(l[y]),!1),l[y]=[0,0]}return l=this.getAttrForces(t,n,o,c,l,r),l=g&&(f&&n>o||!f)?this.getOptRepGraForces(t,l,h,r):this.getRepGraForces(t,n,o,l,i,c,r),this.updatePos(t,l,d,a,r)},t.prototype.getAttrForces=function(t,e,r,n,o,i){for(var a=i.preventOverlap,s=i.dissuadeHubs,u=i.mode,d=i.prune,h=t.getAllEdges(),c=0;c<h.length;c+=1){var l=h[c],f=l.source,g=l.target,p=t.getNode(f),v=t.getNode(g),y=t.getDegree(f),m=t.getDegree(g);if(!d||!(y<=1||m<=1)){var w=[v.data.x-p.data.x,v.data.y-p.data.y],x=Math.hypot(w[0],w[1]);x=x<1e-4?1e-4:x,w[0]=w[0]/x,w[1]=w[1]/x,a&&e<r&&(x=x-n[f]-n[g]);var E=x,N=E;"linlog"===u&&(N=E=Math.log(1+x)),s&&(E=x/y,N=x/m),a&&e<r&&x<=0?(E=0,N=0):a&&e<r&&x>0&&(E=x,N=x),o[f][0]+=E*w[0],o[g][0]-=N*w[0],o[f][1]+=E*w[1],o[g][1]-=N*w[1]}}return o},t.prototype.getOptRepGraForces=function(t,e,r,n){for(var o=n.kg,i=n.center,a=n.prune,s=t.getAllNodes(),u=s.length,d=9e10,h=-9e10,c=9e10,l=-9e10,f=0;f<u;f+=1){var g=s[f],p=g.id,v=g.data;a&&t.getDegree(p)<=1||(r[p].setPos(v.x,v.y),v.x>=h&&(h=v.x),v.x<=d&&(d=v.x),v.y>=l&&(l=v.y),v.y<=c&&(c=v.y))}var y=Math.max(h-d,l-c),m=new pn({xmid:(h+d)/2,ymid:(l+c)/2,length:y,massCenter:i,mass:u}),w=new vn(m);for(f=0;f<u;f+=1)p=s[f].id,a&&t.getDegree(p)<=1||r[p].in(m)&&w.insert(r[p]);for(f=0;f<u;f+=1){var x=s[f],E=(p=x.id,v=x.data,t.getDegree(p));if(!(a&&E<=1)){r[p].resetForce(),w.updateForce(r[p]),e[p][0]-=r[p].fx,e[p][1]-=r[p].fy;var N=[v.x-i[0],v.y-i[1]],b=Math.hypot(N[0],N[1]);b=b<1e-4?1e-4:b,N[0]=N[0]/b,N[1]=N[1]/b;var M=o*(E+1);e[p][0]-=M*N[0],e[p][1]-=M*N[1]}}return e},t.prototype.getRepGraForces=function(t,e,r,n,o,i,a){for(var s=a.preventOverlap,u=a.kr,d=a.kg,h=a.center,c=a.prune,l=t.getAllNodes(),f=l.length,g=0;g<f;g+=1){for(var p=l[g],v=t.getDegree(p.id),y=g+1;y<f;y+=1){var m=l[y],w=t.getDegree(m.id);if(!c||!(v<=1||w<=1)){var x=[m.data.x-p.data.x,m.data.y-p.data.y],E=Math.hypot(x[0],x[1]);E=E<1e-4?1e-4:E,x[0]=x[0]/E,x[1]=x[1]/E,s&&e<r&&(E=E-i[p.id]-i[m.id]);var N=u*(v+1)*(w+1)/E;s&&e<r&&E<0?N=o*(v+1)*(w+1):s&&e<r&&0===E?N=0:s&&e<r&&E>0&&(N=u*(v+1)*(w+1)/E),n[p.id][0]-=N*x[0],n[m.id][0]+=N*x[0],n[p.id][1]-=N*x[1],n[m.id][1]+=N*x[1]}}var b=[p.data.x-h[0],p.data.y-h[1]],M=Math.hypot(b[0],b[1]);b[0]=b[0]/M,b[1]=b[1]/M;var S=d*(v+1);n[p.id][0]-=S*b[0],n[p.id][1]-=S*b[1]}return n},t.prototype.updatePos=function(t,e,r,n,o){for(var i=o.ks,a=o.tao,s=o.prune,u=o.ksmax,d=t.getAllNodes(),h=d.length,c=[],l=[],f=0,g=0,p=n,v=0;v<h;v+=1){var y=d[v].id,w=t.getDegree(y);if(!(s&&w<=1)){var x=[e[y][0]-r[y][0],e[y][1]-r[y][1]],E=Math.hypot(x[0],x[1]),N=[e[y][0]+r[y][0],e[y][1]+r[y][1]],b=Math.hypot(N[0],N[1]);c[v]=E,l[v]=b/2,f+=(w+1)*c[v],g+=(w+1)*l[v]}}var M=p;for(p=a*g/f,0!==M&&(p=p>1.5*M?1.5*M:p),v=0;v<h;v+=1){var S=d[v],A=(y=S.id,S.data);if(w=t.getDegree(y),!(s&&w<=1||m(A.fx)&&m(A.fy))){var k=i*p/(1+p*Math.sqrt(c[v])),_=Math.hypot(e[y][0],e[y][1]),z=u/(_=_<1e-4?1e-4:_),R=(k=k>z?z:k)*e[y][0],I=k*e[y][1];t.mergeNodeData(y,{x:A.x+R,y:A.y+I})}}return p},t}(),xn={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},En=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=n(n({},xn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericFruchtermanLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericFruchtermanLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;r<t;r++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===e.options.dimensions?t.data.z:void 0})})),n},t.prototype.genericFruchtermanLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f,p,v,y,m,w,x,E,N=this;return a(this,(function(a){return this.running?[2]:(o=this.formatOptions(r),i=o.dimensions,s=o.width,u=o.height,d=o.center,h=o.clustering,c=o.nodeClusterBy,l=o.maxIteration,f=o.onTick,p=e.getAllNodes(),v=e.getAllEdges(),(null==p?void 0:p.length)?1===p.length?(t&&e.mergeNodeData(p[0].id,{x:d[0],y:d[1],z:3===i?d[2]:void 0}),y={nodes:[n(n({},p[0]),{data:n(n({},p[0].data),{x:d[0],y:d[1],z:3===i?d[2]:void 0})})],edges:v},this.lastResult=y,[2,y]):(m=p.map((function(t){return M(t,[s,u])})),w=new g({nodes:m,edges:v}),x={},h&&m.forEach((function(t){var e=t.data[c];x[e]||(x[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=m,this.lastLayoutEdges=v,this.lastAssign=t,this.lastGraph=w,this.lastOptions=o,this.lastClusterMap=x,"undefined"==typeof window?[2]:(E=0,[2,new Promise((function(r){N.timeInterval=window.setInterval((function(){N.running?(N.runOneStep(w,x,o),t&&m.forEach((function(t){var r=t.id,n=t.data;return e.mergeNodeData(r,{x:n.x,y:n.y,z:3===i?n.z:void 0})})),null==f||f({nodes:m,edges:v}),++E>=l&&(window.clearInterval(N.timeInterval),r({nodes:m,edges:v}))):r({nodes:m,edges:v})}),0),N.running=!0}))])):(y={nodes:[],edges:v},this.lastResult=y,[2,y]))}))}))},t.prototype.formatOptions=function(t){void 0===t&&(t={});var e=n(n({},this.options),t),r=e.clustering,o=e.nodeClusterBy,i=e.center,a=e.width,s=e.height;return e.width=a||"undefined"==typeof window?a:window.innerWidth,e.height=s||"undefined"==typeof window?s:window.innerHeight,e.center=i||[e.width/2,e.height/2],e.clustering=r&&!!o,e},t.prototype.runOneStep=function(t,e,r){var n=r.dimensions,o=r.height,i=r.width,a=r.gravity,s=r.center,u=r.speed,d=r.clustering,h=r.nodeClusterBy,c=r.clusterGravity,l=o*i,f=Math.sqrt(l)/10,g=t.getAllNodes(),p=l/(g.length+1),v=Math.sqrt(p),y={};if(this.applyCalculate(t,y,v,p),d){for(var w in e)e[w].cx=0,e[w].cy=0,e[w].count=0;for(var w in g.forEach((function(t){var r=t.data,n=e[r[h]];m(r.x)&&(n.cx+=r.x),m(r.y)&&(n.cy+=r.y),n.count++})),e)e[w].cx/=e[w].count,e[w].cy/=e[w].count;var x=c||a;g.forEach((function(t,r){var n=t.id,o=t.data;if(m(o.x)&&m(o.y)){var i=e[o[h]],a=Math.sqrt((o.x-i.cx)*(o.x-i.cx)+(o.y-i.cy)*(o.y-i.cy)),s=v*x;y[n].x-=s*(o.x-i.cx)/a,y[n].y-=s*(o.y-i.cy)/a}}))}g.forEach((function(t,e){var r=t.id,o=t.data;if(m(o.x)&&m(o.y)){var i=.01*v*a;y[r].x-=i*(o.x-s[0]),y[r].y-=i*(o.y-s[1]),3===n&&(y[r].z-=i*(o.z-s[2]))}})),g.forEach((function(e,r){var o=e.id,i=e.data;if(m(i.fx)&&m(i.fy))return i.x=i.fx,i.y=i.fy,void(3===n&&(i.z=i.fz));if(m(i.x)&&m(i.y)){var a=Math.sqrt(y[o].x*y[o].x+y[o].y*y[o].y+(3===n?y[o].z*y[o].z:0));if(a>0){var s=Math.min(f*(u/800),a);t.mergeNodeData(o,{x:i.x+y[o].x/a*s,y:i.y+y[o].y/a*s,z:3===n?i.z+y[o].z/a*s:void 0})}}}))},t.prototype.applyCalculate=function(t,e,r,n){this.calRepulsive(t,e,n),this.calAttractive(t,e,r)},t.prototype.calRepulsive=function(t,e,r){var n=this,o=t.getAllNodes();o.forEach((function(t,i){var a=t.data,s=t.id;e[s]={x:0,y:0,z:0},o.forEach((function(t,o){var u=t.data,d=t.id;if(!(i<=o)&&m(a.x)&&m(u.x)&&m(a.y)&&m(u.y)){var h=a.x-u.x,c=a.y-u.y,l=3===n.options.dimensions?a.z-u.z:0,f=h*h+c*c+l*l;0===f&&(f=1,h=.01,c=.01,l=.01);var g=r/f,p=h*g,v=c*g,y=l*g;e[s].x+=p,e[s].y+=v,e[d].x-=p,e[d].y-=v,3===n.options.dimensions&&(e[s].z+=y,e[d].z-=y)}}))}))},t.prototype.calAttractive=function(t,e,r){var n=this;t.getAllEdges().forEach((function(o){var i=o.source,a=o.target;if(i&&a&&i!==a){var s=t.getNode(i).data,u=t.getNode(a).data;if(m(u.x)&&m(s.x)&&m(u.y)&&m(s.y)){var d=u.x-s.x,h=u.y-s.y,c=3===n.options.dimensions?u.z-s.z:0,l=Math.sqrt(d*d+h*h+c*c)/r,f=d*l,g=h*l,p=c*l;e[i].x+=f,e[i].y+=g,e[a].x-=f,e[a].y-=g,3===n.options.dimensions&&(e[i].z+=p,e[a].z-=p)}}}))},t}(),Nn={begin:[0,0],preventOverlap:!0,preventOverlapPadding:10,condense:!1,rows:void 0,cols:void 0,position:void 0,sortBy:"degree",nodeSize:30,width:300,height:300},bn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=n(n({},Nn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericGridLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericGridLayout(!0,t,e),[2]}))}))},t.prototype.genericGridLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f,g,p,v,y,w,N,b,A,k,_,z,I,D,P,O,C,T,F,L,q,j,V,B,G,W,$,U,H;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.begin,s=void 0===i?[0,0]:i,u=o.condense,d=o.preventOverlapPadding,h=o.preventOverlap,c=o.rows,l=o.cols,f=o.nodeSpacing,g=o.nodeSize,p=o.width,v=o.height,y=o.position,w=o.sortBy,N=e.getAllNodes(),b=e.getAllEdges(),!(A=null==N?void 0:N.length)||1===A)return[2,S(e,t,s)];if(k=N.map((function(t){return M(t)})),"id"===w||Pt(w)&&void 0!==k[0].data[w]||(w="degree"),"degree"===w?k.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):"id"===w?k.sort((function(t,e){return m(e.id)&&m(t.id)?e.id-t.id:"".concat(t.id).localeCompare("".concat(e.id))})):k.sort((function(t,e){return e.data[w]-t.data[w]})),_=p||"undefined"==typeof window?p:window.innerWidth,z=v||"undefined"==typeof window?v:window.innerHeight,I=A,D={rows:c,cols:l},null!=c&&null!=l?(D.rows=c,D.cols=l):null!=c&&null==l?(D.rows=c,D.cols=Math.ceil(I/D.rows)):null==c&&null!=l?(D.cols=l,D.rows=Math.ceil(I/D.cols)):(P=Math.sqrt(I*z/_),D.rows=Math.round(P),D.cols=Math.round(_/z*P)),D.rows=Math.max(D.rows,1),D.cols=Math.max(D.cols,1),D.cols*D.rows>I)O=Mn(D),C=Sn(D),(O-1)*C>=I?Mn(D,O-1):(C-1)*O>=I&&Sn(D,C-1);else for(;D.cols*D.rows<I;)O=Mn(D),((C=Sn(D))+1)*O>=I?Sn(D,C+1):Mn(D,O+1);for(T=u?0:_/D.cols,F=u?0:z/D.rows,(h||f)&&(L=x(10,f),q=E(30,g,!1),k.forEach((function(t){t.data.x&&t.data.y||(t.data.x=0,t.data.y=0);var r,n,o=e.getNode(t.id),i=q(o)||30;R(i)?(r=i[0],n=i[1]):(r=i,n=i);var a=void 0!==L?L(t):d,s=r+a,u=n+a;T=Math.max(T,s),F=Math.max(F,u)}))),j={},V={row:0,col:0},B={},G=0;G<k.length;G++){if(W=k[G],$=void 0,y&&($=y(e.getNode(W.id))),$&&(void 0!==$.row||void 0!==$.col)){if(void 0===(U={row:$.row,col:$.col}).col)for(U.col=0;An(j,U);)U.col++;else if(void 0===U.row)for(U.row=0;An(j,U);)U.row++;B[W.id]=U,kn(j,U)}zn(W,s,T,F,B,D,V,j)}return H={nodes:k,edges:b},t&&k.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,H]}))}))},t}(),Mn=function(t,e){var r,n=t.rows||5,o=t.cols||5;return null==e?r=Math.min(n,o):Math.min(n,o)===t.rows?t.rows=e:t.cols=e,r},Sn=function(t,e){var r,n=t.rows||5,o=t.cols||5;return null==e?r=Math.max(n,o):Math.max(n,o)===t.rows?t.rows=e:t.cols=e,r},An=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]||!1},kn=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]=!0},_n=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},zn=function(t,e,r,n,o,i,a,s){var u,d,h=o[t.id];if(h)u=h.col*r+r/2+e[0],d=h.row*n+n/2+e[1];else{for(;An(s,a);)_n(i,a);u=a.col*r+r/2+e[0],d=a.row*n+n/2+e[1],kn(s,a),_n(i,a)}t.data.x=u,t.data.y=d},Rn={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},In=function(t,e,r,n,o,i){e.forEach((function(a,s){r[s]={x:0,y:0},e.forEach((function(e,u){if(s!==u&&o[s]===o[u]){var d=a.x-e.x,h=a.y-e.y,c=Math.sqrt(d*d+h*h);if(0===c){c=1;var l=s>u?1:-1;d=.01*l,h=.01*l}if(c<i(t[s])/2+i(t[u])/2){var f=n*n/c;r[s].x+=d/c*f,r[s].y+=h/c*f}}}))}))},Dn=function(t,e,r,n,o,i,a,s){var u=i||a/10;return n&&e.forEach((function(e,r){var n=t[r].x-t[o].x,i=t[r].y-t[o].y,a=Math.sqrt(n*n+i*i),s=i/a,u=-n/a,d=Math.sqrt(e.x*e.x+e.y*e.y),h=Math.acos((s*e.x+u*e.y)/d);h>Math.PI/2&&(h-=Math.PI/2,s*=-1,u*=-1);var c=Math.cos(h)*d;e.x=s*c,e.y=u*c})),t.forEach((function(i,a){if(a!==o){var d=Math.sqrt(e[a].x*e[a].x+e[a].y*e[a].y);if(d>0&&a!==o){var h=Math.min(u*(r/800),d);if(i.x+=e[a].x/d*h,i.y+=e[a].y/d*h,n){var c=i.x-t[o].x,l=i.y-t[o].y,f=Math.sqrt(c*c+l*l);c=c/f*s[a],l=l/f*s[a],i.x=t[o].x+c,i.y=t[o].y+l}}}})),t},Pn={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},On=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=n(n({},Pn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericRadialLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericRadialLayout(!0,t,e),[2]}))}))},t.prototype.genericRadialLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,d,h,c,l,f,g,p,v,y,m,w,x,E,b,A,k,_,z,R,P,O,C,T,F,L,q,j,V,B,G,W,$,U,H,Y,K,J,X,Q,tt,et;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.width,d=o.height,h=o.center,c=o.focusNode,l=o.unitRadius,f=o.nodeSize,g=o.nodeSpacing,p=o.strictRadial,v=o.preventOverlap,y=o.maxPreventOverlapIteration,m=o.sortBy,w=o.linkDistance,x=void 0===w?50:w,E=o.sortStrength,b=void 0===E?10:E,A=o.maxIteration,k=void 0===A?1e3:A,_=e.getAllNodes(),z=e.getAllEdges(),R=i||"undefined"==typeof window?i:window.innerWidth,P=d||"undefined"==typeof window?d:window.innerHeight,O=h||[R/2,P/2],!(null==_?void 0:_.length)||1===_.length)return[2,S(e,t,O)];if(C=_[0],Pt(c)){for(T=0;T<_.length;T++)if(_[T].id===c){C=_[T];break}}else C=c||_[0];return F=Fn(_,C.id),L=D({nodes:_,edges:z},!1),q=I(L),j=qn(q,F),Ln(q,F,j+1),V=q[F],B=R-O[0]>O[0]?O[0]:R-O[0],G=P-O[1]>O[1]?O[1]:P-O[1],0===B&&(B=R/2),0===G&&(G=P/2),W=Math.min(B,G),$=Math.max.apply(Math,u([],s(V),!1)),U=[],H=l||W/$,V.forEach((function(t,e){U[e]=t*H})),Y=Cn(_,q,x,U,H,m,b),K=Tn(Y),J=function(t,e,r){try{var n=Z.mul(Z.pow(e,2),-.5),o=n.mean("row"),i=n.mean("column"),a=n.mean();n.add(a).subRowVector(o).subColumnVector(i);var s=new rt(n),u=Z.sqrt(s.diagonalMatrix).diagonal();return s.leftSingularVectors.toJSON().map((function(e){return Z.mul([e],[u]).toJSON()[0].splice(0,t)}))}catch(t){for(var d=[],h=0;h<e.length;h++){var c=Math.random()*r,l=Math.random()*r;d.push([c,l])}return d}}(x,Y,x),X=J.map((function(t){var e=s(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*x:r)-J[F][0],y:(isNaN(n)?Math.random()*x:n)-J[F][1]}})),this.run(k,X,K,Y,U,F),v&&(Q=N(f,g),tt={nodes:_,nodeSizeFunc:Q,positions:X,radii:U,height:P,width:R,strictRadial:Boolean(p),focusIdx:F,iterations:y||200,k:X.length/4.5},X=function(t,e){for(var r=n(n({},Rn),e),o=r.positions,i=r.iterations,a=r.width,s=r.k,u=r.speed,d=void 0===u?100:u,h=r.strictRadial,c=r.focusIdx,l=r.radii,f=void 0===l?[]:l,g=r.nodeSizeFunc,p=t.getAllNodes(),v=[],y=a/10,m=0;m<i;m++)o.forEach((function(t,e){v[e]={x:0,y:0}})),In(p,o,v,s,f,g),Dn(o,v,d,h,c,y,a,f);return o}(e,tt)),et=[],X.forEach((function(t,e){var r=M(_[e]);r.data.x=t.x+O[0],r.data.y=t.y+O[1],et.push(r)})),t&&et.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:et,edges:z}]}))}))},t.prototype.run=function(t,e,r,n,o,i){for(var a=0;a<=t;a++){var s=a/t;this.oneIteration(s,e,o,n,r,i)}},t.prototype.oneIteration=function(t,e,r,n,o,i){var a=1-t;e.forEach((function(s,u){var d=P(s,{x:0,y:0}),h=0===d?0:1/d;if(u!==i){var c=0,l=0,f=0;e.forEach((function(t,e){if(u!==e){var r=P(s,t),i=0===r?0:1/r,a=n[e][u];f+=o[u][e],c+=o[u][e]*(t.x+a*(s.x-t.x)*i),l+=o[u][e]*(t.y+a*(s.y-t.y)*i)}}));var g=0===r[u]?0:1/r[u];f*=a,f+=t*g*g,c*=a,c+=t*g*s.x*h,s.x=c/f,l*=a,l+=t*g*s.y*h,s.y=l/f}}))},t}(),Cn=function(t,e,r,n,o,i,a){if(!t)return[];var s=[];if(e){var u={};e.forEach((function(e,d){var h=[];e.forEach((function(e,s){var c,l;if(d===s)h.push(0);else if(n[d]===n[s])if("data"===i)h.push(e*(Math.abs(d-s)*a)/(n[d]/o));else if(i){var f=void 0,g=void 0;if(u[t[d].id])f=u[t[d].id];else{var p=("id"===i?t[d].id:null===(c=t[d].data)||void 0===c?void 0:c[i])||0;f=Pt(p)?p.charCodeAt(0):p,u[t[d].id]=f}u[t[s].id]?g=u[t[s].id]:(p=("id"===i?t[s].id:null===(l=t[s].data)||void 0===l?void 0:l[i])||0,g=Pt(p)?p.charCodeAt(0):p,u[t[s].id]=g),h.push(e*(Math.abs(f-g)*a)/(n[d]/o))}else h.push(e*r/(n[d]/o));else{var v=(r+o)/2;h.push(e*v)}})),s.push(h)}))}return s},Tn=function(t){for(var e=t.length,r=t[0].length,n=[],o=0;o<e;o++){for(var i=[],a=0;a<r;a++)0!==t[o][a]?i.push(1/(t[o][a]*t[o][a])):i.push(0);n.push(i)}return n},Fn=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},Ln=function(t,e,r){for(var n=t.length,o=0;o<n;o++)if(t[e][o]===1/0){t[e][o]=r,t[o][e]=r;for(var i=0;i<n;i++)t[o][i]!==1/0&&t[e][i]===1/0&&(t[e][i]=r+t[o][i],t[i][e]=r+t[o][i])}for(o=0;o<n;o++)if(o!==e)for(i=0;i<n;i++)if(t[o][i]===1/0){var a=Math.abs(t[e][o]-t[e][i]);a=0===a?1:a,t[o][i]=a}},qn=function(t,e){for(var r=0,n=0;n<t[e].length;n++)t[e][n]!==1/0&&(r=t[e][n]>r?t[e][n]:r);return r},jn={center:[0,0],width:300,height:300},Vn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=n(n({},jn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericRandomLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericRandomLayout(!0,t,e),[2]}))}))},t.prototype.genericRandomLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f;return a(this,(function(a){return o=n(n({},this.options),r),i=o.center,s=o.width,u=o.height,d=e.getAllNodes(),h=s||"undefined"==typeof window?s:window.innerWidth,c=u||"undefined"==typeof window?u:window.innerHeight,l=i||[h/2,c/2],f=[],d&&d.forEach((function(t){f.push({id:t.id,data:{x:.9*(Math.random()-.5)*h+l[0],y:.9*(Math.random()-.5)*c+l[1]}})})),t&&f.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:f,edges:e.getAllEdges()}]}))}))},t}(),Bn={circular:k,concentric:Ct,mds:ot,random:Vn,grid:bn,radial:On,force:kt,d3force:Re,fruchterman:En,forceAtlas2:wn,dagre:cn,comboCombined:Lt};function Gn(){(null==yn?void 0:yn.stop)&&yn.stop()}function Wn(t,e){return i(this,void 0,void 0,(function(){var r,n,o,i,s,u,d,h,c;return a(this,(function(a){switch(a.label){case 0:if(r=t.layout,n=r.id,o=r.options,i=r.iterations,s=t.nodes,u=t.edges,d=new g({nodes:s,edges:u}),!(h=Bn[n]))throw new Error("Unknown layout id: ".concat(n));return[4,(yn=new h(o)).execute(d)];case 1:return c=a.sent(),!!(l=yn).tick&&!!l.stop&&(yn.stop(),c=yn.tick(i)),[2,[c,e]]}var l}))}))}addEventListener("message",(function(t){var r,n=t.data,o=n.type,i=n.method,a=n.id,s=n.params;"RPC"===o&&i&&((r=e[i])?Promise.resolve().then((function(){return r.apply(e,s)})):Promise.reject("No such method")).then((function(t){postMessage({type:"RPC",id:a,result:t})})).catch((function(t){var e={message:t};t.stack&&(e.message=t.message,e.stack=t.stack,e.name=t.name),postMessage({type:"RPC",id:a,error:e})}))})),postMessage({type:"RPC",method:"ready"})})();
2
+ //# sourceMappingURL=747bfdc8efc94bc1fa90.worker.js.map