diff --git a/fastadmin/static/assets/worker-6Z7niv9l.js b/fastadmin/static/assets/worker-6Z7niv9l.js new file mode 100644 index 0000000..9b9e5f3 --- /dev/null +++ b/fastadmin/static/assets/worker-6Z7niv9l.js @@ -0,0 +1,13 @@ +var aR=Object.defineProperty,uR=Object.defineProperties;var cR=Object.getOwnPropertyDescriptors;var x0=Object.getOwnPropertySymbols;var fR=Object.prototype.hasOwnProperty,lR=Object.prototype.propertyIsEnumerable;var N0=J=>{throw TypeError(J)},Ge=Math.pow,uc=(J,P,te)=>P in J?aR(J,P,{enumerable:!0,configurable:!0,writable:!0,value:te}):J[P]=te,jt=(J,P)=>{for(var te in P||(P={}))fR.call(P,te)&&uc(J,te,P[te]);if(x0)for(var te of x0(P))lR.call(P,te)&&uc(J,te,P[te]);return J},cc=(J,P)=>uR(J,cR(P));var ne=(J,P,te)=>uc(J,typeof P!="symbol"?P+"":P,te),fc=(J,P,te)=>P.has(J)||N0("Cannot "+te);var Oe=(J,P,te)=>(fc(J,P,"read from private field"),te?te.call(J):P.get(J)),lc=(J,P,te)=>P.has(J)?N0("Cannot add the same private member more than once"):P instanceof WeakSet?P.add(J):P.set(J,te),tn=(J,P,te,tr)=>(fc(J,P,"write to private field"),tr?tr.call(J,te):P.set(J,te),te),hc=(J,P,te)=>(fc(J,P,"access private method"),te);(function(){"use strict";var er,dc,ht,fe;function J(n,t){var e={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.indexOf(r)<0&&(e[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i{t.has(o.id)||(t.add(o.id),n.push(o))})}return!1}function rr(n,t,e,r){if(e(n))return!0;t.add(n.id);for(const s of r(n.id))if(!t.has(s.id)&&rr(s,t,e,r))return!0;return!1}const gc=()=>!0;class S0{constructor(t){ne(this,"graph");ne(this,"nodeFilter");ne(this,"edgeFilter");ne(this,"cacheEnabled");ne(this,"inEdgesMap",new Map);ne(this,"outEdgesMap",new Map);ne(this,"bothEdgesMap",new Map);ne(this,"allNodesMap",new Map);ne(this,"allEdgesMap",new Map);ne(this,"clearCache",()=>{this.inEdgesMap.clear(),this.outEdgesMap.clear(),this.bothEdgesMap.clear(),this.allNodesMap.clear(),this.allEdgesMap.clear()});ne(this,"refreshCache",()=>{this.clearCache(),this.updateCache(this.graph.getAllNodes().map(t=>t.id))});ne(this,"updateCache",t=>{const e=new Set;t.forEach(r=>{const i=this.bothEdgesMap.get(r);if(i&&i.forEach(s=>e.add(s.id)),!this.hasNode(r))this.inEdgesMap.delete(r),this.outEdgesMap.delete(r),this.bothEdgesMap.delete(r),this.allNodesMap.delete(r);else{const s=this.graph.getRelatedEdges(r,"in").filter(this.edgeFilter),o=this.graph.getRelatedEdges(r,"out").filter(this.edgeFilter),a=Array.from(new Set([...s,...o]));a.forEach(u=>e.add(u.id)),this.inEdgesMap.set(r,s),this.outEdgesMap.set(r,o),this.bothEdgesMap.set(r,a),this.allNodesMap.set(r,this.graph.getNode(r))}}),e.forEach(r=>{this.hasEdge(r)?this.allEdgesMap.set(r,this.graph.getEdge(r)):this.allEdgesMap.delete(r)})});ne(this,"handleGraphChanged",t=>{const e=new Set;t.changes.forEach(r=>{switch(r.type){case"NodeAdded":e.add(r.value.id);break;case"NodeDataUpdated":e.add(r.id);break;case"EdgeAdded":e.add(r.value.source),e.add(r.value.target);break;case"EdgeUpdated":(r.propertyName==="source"||r.propertyName==="target")&&(e.add(r.oldValue),e.add(r.newValue));break;case"EdgeDataUpdated":if(t.graph.hasEdge(r.id)){const i=t.graph.getEdge(r.id);e.add(i.source),e.add(i.target)}break;case"EdgeRemoved":e.add(r.value.source),e.add(r.value.target);break;case"NodeRemoved":e.add(r.value.id);break}}),this.updateCache(e)});this.graph=t.graph;const e=t.nodeFilter||gc,r=t.edgeFilter||gc;this.nodeFilter=e,this.edgeFilter=i=>{const{source:s,target:o}=this.graph.getEdgeDetail(i.id);return!e(s)||!e(o)?!1:r(i,s,o)},t.cache==="auto"?(this.cacheEnabled=!0,this.startAutoCache()):t.cache==="manual"?this.cacheEnabled=!0:this.cacheEnabled=!1}startAutoCache(){this.refreshCache(),this.graph.on("changed",this.handleGraphChanged)}stopAutoCache(){this.graph.off("changed",this.handleGraphChanged)}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(r=>r.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?e==="in"?this.inEdgesMap.get(t):e==="out"?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 r=this.getRelatedEdges(t,"out").map(i=>this.getNode(i.target));return Array.from(new Set(r))}getPredecessors(t){const r=this.getRelatedEdges(t,"in").map(i=>this.getNode(i.source));return Array.from(new Set(r))}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)?null:r}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 i={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];rn([this.getNode(t)],new Set,e,i)}dfs(t,e,r="out"){const i={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];rr(this.getNode(t),new Set,e,i)}}let ue=class M0 extends tr{constructor(e){super();ne(this,"nodeMap",new Map);ne(this,"edgeMap",new Map);ne(this,"inEdgesMap",new Map);ne(this,"outEdgesMap",new Map);ne(this,"bothEdgesMap",new Map);ne(this,"treeIndices",new Map);ne(this,"changes",[]);ne(this,"batchCount",0);ne(this,"onChanged",()=>{});ne(this,"batch",e=>{this.batchCount+=1,e(),this.batchCount-=1,this.batchCount||this.commit()});e&&(e.nodes&&this.addNodes(e.nodes),e.edges&&this.addEdges(e.edges),e.tree&&this.addTree(e.tree),e.onChanged&&(this.onChanged=e.onChanged))}commit(){const e=this.changes;this.changes=[];const r={graph:this,changes:e};this.emit("changed",r),this.onChanged(r)}reduceChanges(e){let r=[];return e.forEach(i=>{switch(i.type){case"NodeRemoved":{let s=!1;r=r.filter(o=>{if(o.type==="NodeAdded"){const a=o.value.id===i.value.id;return a&&(s=!0),!a}else{if(o.type==="NodeDataUpdated")return o.id!==i.value.id;if(o.type==="TreeStructureChanged")return o.nodeId!==i.value.id}return!0}),s||r.push(i);break}case"EdgeRemoved":{let s=!1;r=r.filter(o=>{if(o.type==="EdgeAdded"){const a=o.value.id===i.value.id;return a&&(s=!0),!a}else if(o.type==="EdgeDataUpdated"||o.type==="EdgeUpdated")return o.id!==i.value.id;return!0}),s||r.push(i);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const s=r.findIndex(a=>a.type===i.type&&a.id===i.id&&(i.propertyName===void 0||a.propertyName===i.propertyName)),o=r[s];o?i.propertyName!==void 0?o.newValue=i.newValue:(r.splice(s,1),r.push(i)):r.push(i);break}case"TreeStructureDetached":{r=r.filter(s=>s.type==="TreeStructureAttached"||s.type==="TreeStructureChanged"?s.treeKey!==i.treeKey:!0),r.push(i);break}case"TreeStructureChanged":{const s=r.find(o=>o.type==="TreeStructureChanged"&&o.treeKey===i.treeKey&&o.nodeId===i.nodeId);s?s.newParentId=i.newParentId:r.push(i);break}default:r.push(i);break}}),r}checkNodeExistence(e){this.getNode(e)}hasNode(e){return this.nodeMap.has(e)}areNeighbors(e,r){return this.getNeighbors(r).some(i=>i.id===e)}getNode(e){const r=this.nodeMap.get(e);if(!r)throw new Error("Node not found for id: "+e);return r}getRelatedEdges(e,r){if(this.checkNodeExistence(e),r==="in"){const i=this.inEdgesMap.get(e);return Array.from(i)}else if(r==="out"){const i=this.outEdgesMap.get(e);return Array.from(i)}else{const i=this.bothEdgesMap.get(e);return Array.from(i)}}getDegree(e,r){return this.getRelatedEdges(e,r).length}getSuccessors(e){const i=this.getRelatedEdges(e,"out").map(s=>this.getNode(s.target));return Array.from(new Set(i))}getPredecessors(e){const i=this.getRelatedEdges(e,"in").map(s=>this.getNode(s.source));return Array.from(new Set(i))}getNeighbors(e){const r=this.getPredecessors(e),i=this.getSuccessors(e);return Array.from(new Set([...r,...i]))}doAddNode(e){if(this.hasNode(e.id))throw new Error("Node already exists: "+e.id);this.nodeMap.set(e.id,e),this.inEdgesMap.set(e.id,new Set),this.outEdgesMap.set(e.id,new Set),this.bothEdgesMap.set(e.id,new Set),this.treeIndices.forEach(r=>{r.childrenMap.set(e.id,new Set)}),this.changes.push({type:"NodeAdded",value:e})}addNodes(e){this.batch(()=>{for(const r of e)this.doAddNode(r)})}addNode(e){this.addNodes([e])}doRemoveNode(e){const r=this.getNode(e),i=this.bothEdgesMap.get(e);i==null||i.forEach(s=>this.doRemoveEdge(s.id)),this.nodeMap.delete(e),this.treeIndices.forEach(s=>{var a,u;(a=s.childrenMap.get(e))==null||a.forEach(c=>{s.parentMap.delete(c.id)});const o=s.parentMap.get(e);o&&((u=s.childrenMap.get(o.id))==null||u.delete(r)),s.parentMap.delete(e),s.childrenMap.delete(e)}),this.bothEdgesMap.delete(e),this.inEdgesMap.delete(e),this.outEdgesMap.delete(e),this.changes.push({type:"NodeRemoved",value:r})}removeNodes(e){this.batch(()=>{e.forEach(r=>this.doRemoveNode(r))})}removeNode(e){this.removeNodes([e])}updateNodeDataProperty(e,r,i){const s=this.getNode(e);this.batch(()=>{const o=s.data[r],a=i;s.data[r]=a,this.changes.push({type:"NodeDataUpdated",id:e,propertyName:r,oldValue:o,newValue:a})})}mergeNodeData(e,r){this.batch(()=>{Object.entries(r).forEach(([i,s])=>{this.updateNodeDataProperty(e,i,s)})})}updateNodeData(...e){const r=e[0],i=this.getNode(r);if(typeof e[1]=="string"){this.updateNodeDataProperty(r,e[1],e[2]);return}let s;if(typeof e[1]=="function"){const o=e[1];s=o(i.data)}else typeof e[1]=="object"&&(s=e[1]);this.batch(()=>{const o=i.data,a=s;i.data=s,this.changes.push({type:"NodeDataUpdated",id:r,oldValue:o,newValue:a})})}checkEdgeExistence(e){if(!this.hasEdge(e))throw new Error("Edge not found for id: "+e)}hasEdge(e){return this.edgeMap.has(e)}getEdge(e){return this.checkEdgeExistence(e),this.edgeMap.get(e)}getEdgeDetail(e){const r=this.getEdge(e);return{edge:r,source:this.getNode(r.source),target:this.getNode(r.target)}}doAddEdge(e){if(this.hasEdge(e.id))throw new Error("Edge already exists: "+e.id);this.checkNodeExistence(e.source),this.checkNodeExistence(e.target),this.edgeMap.set(e.id,e);const r=this.inEdgesMap.get(e.target),i=this.outEdgesMap.get(e.source),s=this.bothEdgesMap.get(e.source),o=this.bothEdgesMap.get(e.target);r.add(e),i.add(e),s.add(e),o.add(e),this.changes.push({type:"EdgeAdded",value:e})}addEdges(e){this.batch(()=>{for(const r of e)this.doAddEdge(r)})}addEdge(e){this.addEdges([e])}doRemoveEdge(e){const r=this.getEdge(e),i=this.outEdgesMap.get(r.source),s=this.inEdgesMap.get(r.target),o=this.bothEdgesMap.get(r.source),a=this.bothEdgesMap.get(r.target);i.delete(r),s.delete(r),o.delete(r),a.delete(r),this.edgeMap.delete(e),this.changes.push({type:"EdgeRemoved",value:r})}removeEdges(e){this.batch(()=>{e.forEach(r=>this.doRemoveEdge(r))})}removeEdge(e){this.removeEdges([e])}updateEdgeSource(e,r){const i=this.getEdge(e);this.checkNodeExistence(r);const s=i.source,o=r;this.outEdgesMap.get(s).delete(i),this.bothEdgesMap.get(s).delete(i),this.outEdgesMap.get(o).add(i),this.bothEdgesMap.get(o).add(i),i.source=r,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:e,propertyName:"source",oldValue:s,newValue:o})})}updateEdgeTarget(e,r){const i=this.getEdge(e);this.checkNodeExistence(r);const s=i.target,o=r;this.inEdgesMap.get(s).delete(i),this.bothEdgesMap.get(s).delete(i),this.inEdgesMap.get(o).add(i),this.bothEdgesMap.get(o).add(i),i.target=r,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:e,propertyName:"target",oldValue:s,newValue:o})})}updateEdgeDataProperty(e,r,i){const s=this.getEdge(e);this.batch(()=>{const o=s.data[r],a=i;s.data[r]=a,this.changes.push({type:"EdgeDataUpdated",id:e,propertyName:r,oldValue:o,newValue:a})})}updateEdgeData(...e){const r=e[0],i=this.getEdge(r);if(typeof e[1]=="string"){this.updateEdgeDataProperty(r,e[1],e[2]);return}let s;if(typeof e[1]=="function"){const o=e[1];s=o(i.data)}else typeof e[1]=="object"&&(s=e[1]);this.batch(()=>{const o=i.data,a=s;i.data=s,this.changes.push({type:"EdgeDataUpdated",id:r,oldValue:o,newValue:a})})}mergeEdgeData(e,r){this.batch(()=>{Object.entries(r).forEach(([i,s])=>{this.updateEdgeDataProperty(e,i,s)})})}checkTreeExistence(e){if(!this.hasTreeStructure(e))throw new Error("Tree structure not found for treeKey: "+e)}hasTreeStructure(e){return this.treeIndices.has(e)}attachTreeStructure(e){this.treeIndices.has(e)||(this.treeIndices.set(e,{parentMap:new Map,childrenMap:new Map}),this.batch(()=>{this.changes.push({type:"TreeStructureAttached",treeKey:e})}))}detachTreeStructure(e){this.checkTreeExistence(e),this.treeIndices.delete(e),this.batch(()=>{this.changes.push({type:"TreeStructureDetached",treeKey:e})})}addTree(e,r){this.batch(()=>{this.attachTreeStructure(r);const i=[],s=Array.isArray(e)?e:[e];for(;s.length;){const o=s.shift();i.push(o),o.children&&s.push(...o.children)}this.addNodes(i),i.forEach(o=>{var a;(a=o.children)==null||a.forEach(u=>{this.setParent(u.id,o.id,r)})})})}getRoots(e){return this.checkTreeExistence(e),this.getAllNodes().filter(r=>!this.getParent(r.id,e))}getChildren(e,r){this.checkNodeExistence(e),this.checkTreeExistence(r);const s=this.treeIndices.get(r).childrenMap.get(e);return Array.from(s||[])}getParent(e,r){return this.checkNodeExistence(e),this.checkTreeExistence(r),this.treeIndices.get(r).parentMap.get(e)||null}getAncestors(e,r){const i=[];let s=this.getNode(e),o;for(;o=this.getParent(s.id,r);)i.push(o),s=o;return i}setParent(e,r,i){var f,l;this.checkTreeExistence(i);const s=this.treeIndices.get(i);if(!s)return;const o=this.getNode(e),a=s.parentMap.get(e);if((a==null?void 0:a.id)===r)return;if(r==null){a&&((f=s.childrenMap.get(a.id))==null||f.delete(o)),s.parentMap.delete(e);return}const u=this.getNode(r);s.parentMap.set(e,u),a&&((l=s.childrenMap.get(a.id))==null||l.delete(o));let c=s.childrenMap.get(u.id);c||(c=new Set,s.childrenMap.set(u.id,c)),c.add(o),this.batch(()=>{this.changes.push({type:"TreeStructureChanged",treeKey:i,nodeId:e,oldParentId:a==null?void 0:a.id,newParentId:u.id})})}dfsTree(e,r,i){const s=o=>this.getChildren(o,i);return rr(this.getNode(e),new Set,r,s)}bfsTree(e,r,i){const s=o=>this.getChildren(o,i);return rn([this.getNode(e)],new Set,r,s)}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(e,r,i="out"){const s={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[i];return rn([this.getNode(e)],new Set,r,s)}dfs(e,r,i="out"){const s={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[i];return rr(this.getNode(e),new Set,r,s)}clone(){const e=this.getAllNodes().map(s=>cc(jt({},s),{data:jt({},s.data)})),r=this.getAllEdges().map(s=>cc(jt({},s),{data:jt({},s.data)})),i=new M0({nodes:e,edges:r});return this.treeIndices.forEach(({parentMap:s,childrenMap:o},a)=>{const u=new Map;s.forEach((f,l)=>{u.set(l,i.getNode(f.id))});const c=new Map;o.forEach((f,l)=>{c.set(l,new Set(Array.from(f).map(h=>i.getNode(h.id))))}),i.treeIndices.set(a,{parentMap:u,childrenMap:c})}),i}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}createView(e){return new S0(jt({graph:this},e))}};/** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */const pc=Symbol("Comlink.proxy"),R0=Symbol("Comlink.endpoint"),q0=Symbol("Comlink.releaseProxy"),nn=Symbol("Comlink.finalizer"),nr=Symbol("Comlink.thrown"),vc=n=>typeof n=="object"&&n!==null||typeof n=="function",O0={canHandle:n=>vc(n)&&n[pc],serialize(n){const{port1:t,port2:e}=new MessageChannel;return sn(n,t),[e,[e]]},deserialize(n){return n.start(),k0(n)}},A0={canHandle:n=>vc(n)&&nr in n,serialize({value:n}){let t;return n instanceof Error?t={isError:!0,value:{message:n.message,name:n.name,stack:n.stack}}:t={isError:!1,value:n},[t,[]]},deserialize(n){throw n.isError?Object.assign(new Error(n.value.message),n.value):n.value}},mc=new Map([["proxy",O0],["throw",A0]]);function I0(n,t){for(const e of n)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function sn(n,t=globalThis,e=["*"]){t.addEventListener("message",function r(i){if(!i||!i.data)return;if(!I0(e,i.origin)){console.warn(`Invalid origin '${i.origin}' for comlink proxy`);return}const{id:s,type:o,path:a}=Object.assign({path:[]},i.data),u=(i.data.argumentList||[]).map(tt);let c;try{const f=a.slice(0,-1).reduce((h,g)=>h[g],n),l=a.reduce((h,g)=>h[g],n);switch(o){case"GET":c=l;break;case"SET":f[a.slice(-1)[0]]=tt(i.data.value),c=!0;break;case"APPLY":c=l.apply(f,u);break;case"CONSTRUCT":{const h=new l(...u);c=D0(h)}break;case"ENDPOINT":{const{port1:h,port2:g}=new MessageChannel;sn(n,g),c=L0(h,[h])}break;case"RELEASE":c=void 0;break;default:return}}catch(f){c={value:f,[nr]:0}}Promise.resolve(c).catch(f=>({value:f,[nr]:0})).then(f=>{const[l,h]=ar(f);t.postMessage(Object.assign(Object.assign({},l),{id:s}),h),o==="RELEASE"&&(t.removeEventListener("message",r),yc(t),nn in n&&typeof n[nn]=="function"&&n[nn]())}).catch(f=>{const[l,h]=ar({value:new TypeError("Unserializable return value"),[nr]:0});t.postMessage(Object.assign(Object.assign({},l),{id:s}),h)})}),t.start&&t.start()}function T0(n){return n.constructor.name==="MessagePort"}function yc(n){T0(n)&&n.close()}function k0(n,t){const e=new Map;return n.addEventListener("message",function(i){const{data:s}=i;if(!s||!s.id)return;const o=e.get(s.id);if(o)try{o(s)}finally{e.delete(s.id)}}),on(n,e,[],t)}function ir(n){if(n)throw new Error("Proxy has been released and is not useable")}function wc(n){return gt(n,new Map,{type:"RELEASE"}).then(()=>{yc(n)})}const sr=new WeakMap,or="FinalizationRegistry"in globalThis&&new FinalizationRegistry(n=>{const t=(sr.get(n)||0)-1;sr.set(n,t),t===0&&wc(n)});function j0(n,t){const e=(sr.get(t)||0)+1;sr.set(t,e),or&&or.register(n,t,n)}function C0(n){or&&or.unregister(n)}function on(n,t,e=[],r=function(){}){let i=!1;const s=new Proxy(r,{get(o,a){if(ir(i),a===q0)return()=>{C0(s),wc(n),t.clear(),i=!0};if(a==="then"){if(e.length===0)return{then:()=>s};const u=gt(n,t,{type:"GET",path:e.map(c=>c.toString())}).then(tt);return u.then.bind(u)}return on(n,t,[...e,a])},set(o,a,u){ir(i);const[c,f]=ar(u);return gt(n,t,{type:"SET",path:[...e,a].map(l=>l.toString()),value:c},f).then(tt)},apply(o,a,u){ir(i);const c=e[e.length-1];if(c===R0)return gt(n,t,{type:"ENDPOINT"}).then(tt);if(c==="bind")return on(n,t,e.slice(0,-1));const[f,l]=bc(u);return gt(n,t,{type:"APPLY",path:e.map(h=>h.toString()),argumentList:f},l).then(tt)},construct(o,a){ir(i);const[u,c]=bc(a);return gt(n,t,{type:"CONSTRUCT",path:e.map(f=>f.toString()),argumentList:u},c).then(tt)}});return j0(s,n),s}function P0(n){return Array.prototype.concat.apply([],n)}function bc(n){const t=n.map(ar);return[t.map(e=>e[0]),P0(t.map(e=>e[1]))]}const _c=new WeakMap;function L0(n,t){return _c.set(n,t),n}function D0(n){return Object.assign(n,{[pc]:!0})}function ar(n){for(const[t,e]of mc)if(e.canHandle(n)){const[r,i]=e.serialize(n);return[{type:"HANDLER",name:t,value:r},i]}return[{type:"RAW",value:n},_c.get(n)||[]]}function tt(n){switch(n.type){case"HANDLER":return mc.get(n.name).deserialize(n.value);case"RAW":return n.value}}function gt(n,t,e,r){return new Promise(i=>{const s=z0();t.set(s,i),n.start&&n.start(),n.postMessage(Object.assign({id:s},e),r)})}function z0(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}function Te(n){return typeof n=="function"}function $0(n){return n==null}function an(n){return Array.isArray(n)}var pt=function(n){var t=typeof n;return n!==null&&t==="object"||t==="function"};function F0(n,t){if(n){var e;if(an(n))for(var r=0,i=n.length;r{if(n!=="next"&&n!=="prev")return t},Mc=n=>{n.prev.next=n.next,n.next.prev=n.prev,delete n.next,delete n.prev};let X0=class{constructor(){const t={};t.prev=t,t.next=t.prev,this.shortcut=t}dequeue(){const t=this.shortcut,e=t.prev;if(e&&e!==t)return Mc(e),e}enqueue(t){const e=this.shortcut;t.prev&&t.next&&Mc(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e}toString(){const t=[],e=this.shortcut;let r=e.prev;for(;r!==e;)t.push(JSON.stringify(r,K0)),r=r==null?void 0:r.prev;return`[${t.join(", ")}]`}},Z0=class extends X0{};const J0=(n,t)=>{var e;if(n.getAllNodes().length<=1)return[];const r=H0(n,t);return(e=Q0(r.graph,r.buckets,r.zeroIdx).map(s=>n.getRelatedEdges(s.v,"out").filter(({target:o})=>o===s.w)))===null||e===void 0?void 0:e.flat()},Q0=(n,t,e)=>{let r=[];const i=t[t.length-1],s=t[0];let o;for(;n.getAllNodes().length;){for(;o=s.dequeue();)cn(n,t,e,o);for(;o=i.dequeue();)cn(n,t,e,o);if(n.getAllNodes().length){for(let a=t.length-2;a>0;--a)if(o=t[a].dequeue(),o){r=r.concat(cn(n,t,e,o,!0));break}}}return r},cn=(n,t,e,r,i)=>{var s,o;const a=[];return n.hasNode(r.v)&&((s=n.getRelatedEdges(r.v,"in"))===null||s===void 0||s.forEach(u=>{const c=u.data.weight,f=n.getNode(u.source);i&&a.push({v:u.source,w:u.target,in:0,out:0}),f.data.out===void 0&&(f.data.out=0),f.data.out-=c,fn(t,e,Object.assign({v:f.id},f.data))}),(o=n.getRelatedEdges(r.v,"out"))===null||o===void 0||o.forEach(u=>{const c=u.data.weight,f=u.target,l=n.getNode(f);l.data.in===void 0&&(l.data.in=0),l.data.in-=c,fn(t,e,Object.assign({v:l.id},l.data))}),n.removeNode(r.v)),i?a:void 0},H0=(n,t)=>{const e=new ue;let r=0,i=0;n.getAllNodes().forEach(u=>{e.addNode({id:u.id,data:{v:u.id,in:0,out:0}})}),n.getAllEdges().forEach(u=>{const c=e.getRelatedEdges(u.source,"out").find(l=>l.target===u.target),f=(t==null?void 0:t(u))||1;c?e.updateEdgeData(c==null?void 0:c.id,Object.assign(Object.assign({},c.data),{weight:c.data.weight+f})):e.addEdge({id:u.id,source:u.source,target:u.target,data:{weight:f}}),i=Math.max(i,e.getNode(u.source).data.out+=f),r=Math.max(r,e.getNode(u.target).data.in+=f)});const s=[],o=i+r+3;for(let u=0;u{fn(s,a,Object.assign({v:u.id},e.getNode(u.id).data))}),{buckets:s,zeroIdx:a,graph:e}},fn=(n,t,e)=>{e.out?e.in?n[e.out-e.in+t].enqueue(e):n[n.length-1].enqueue(e):n[0].enqueue(e)},em=(n,t)=>{const r=t==="greedy"?J0(n,(i=>s=>s.data.weight||1)()):tm(n);r==null||r.forEach(i=>{const s=i.data;n.removeEdge(i.id),s.forwardName=i.data.name,s.reversed=!0,n.addEdge({id:i.id,source:i.target,target:i.source,data:Object.assign({},s)})})},tm=n=>{const t=[],e={},r={},i=s=>{r[s]||(r[s]=!0,e[s]=!0,n.getRelatedEdges(s,"out").forEach(o=>{e[o.target]?t.push(o):i(o.target)}),delete e[s])};return n.getAllNodes().forEach(s=>i(s.id)),t},rm=n=>{n.getAllEdges().forEach(t=>{const e=t.data;if(e.reversed){n.removeEdge(t.id);const r=e.forwardName;delete e.reversed,delete e.forwardName,n.addEdge({id:t.id,source:t.target,target:t.source,data:Object.assign(Object.assign({},e),{forwardName:r})})}})},nm=(n,t)=>Number(n)-Number(t),vt=(n,t,e,r)=>{let i;do i=`${r}${Math.random()}`;while(n.hasNode(i));return e.dummy=t,n.addNode({id:i,data:e}),i},im=n=>{const t=new ue;return n.getAllNodes().forEach(e=>{t.addNode(Object.assign({},e))}),n.getAllEdges().forEach(e=>{const r=t.getRelatedEdges(e.source,"out").find(i=>i.target===e.target);r?t.updateEdgeData(r==null?void 0:r.id,Object.assign(Object.assign({},r.data),{weight:r.data.weight+e.data.weight||0,minlen:Math.max(r.data.minlen,e.data.minlen||1)})):t.addEdge({id:e.id,source:e.source,target:e.target,data:{weight:e.data.weight||0,minlen:e.data.minlen||1}})}),t},Sc=n=>{const t=new ue;return n.getAllNodes().forEach(e=>{n.getChildren(e.id).length||t.addNode(Object.assign({},e))}),n.getAllEdges().forEach(e=>{t.addEdge(e)}),t},sm=(n,t)=>n==null?void 0:n.reduce((e,r,i)=>(e[r]=t[i],e),{}),Rc=(n,t)=>{const e=Number(n.x),r=Number(n.y),i=Number(t.x)-e,s=Number(t.y)-r;let o=Number(n.width)/2,a=Number(n.height)/2;if(!i&&!s)return{x:0,y:0};let u,c;return Math.abs(s)*o>Math.abs(i)*a?(s<0&&(a=-a),u=a*i/s,c=a):(i<0&&(o=-o),u=o,c=o*s/i),{x:e+u,y:r+c}},Pt=n=>{const t=[],e=Oc(n)+1;for(let r=0;r{const i=r.data.rank;i!==void 0&&t[i]&&t[i].push(r.id)});for(let r=0;rnm(n.getNode(i).data.order,n.getNode(s).data.order));return t},om=n=>{const t=n.getAllNodes().filter(r=>r.data.rank!==void 0).map(r=>r.data.rank),e=Math.min(...t);n.getAllNodes().forEach(r=>{r.data.hasOwnProperty("rank")&&e!==1/0&&(r.data.rank-=e)})},am=(n,t=0)=>{const e=n.getAllNodes(),r=e.filter(a=>a.data.rank!==void 0).map(a=>a.data.rank),i=Math.min(...r),s=[];e.forEach(a=>{const u=(a.data.rank||0)-i;s[u]||(s[u]=[]),s[u].push(a.id)});let o=0;for(let a=0;a{const f=n.getNode(c);f&&(f.data.rank=f.data.rank||0,f.data.rank+=o)}))}},qc=(n,t,e,r)=>{const i={width:0,height:0};return V(e)&&V(r)&&(i.rank=e,i.order=r),vt(n,"border",i,t)},Oc=n=>{let t;return n.getAllNodes().forEach(e=>{const r=e.data.rank;r!==void 0&&(t===void 0||r>t)&&(t=r)}),t||(t=0),t},um=(n,t)=>{const e={lhs:[],rhs:[]};return n==null||n.forEach(r=>{t(r)?e.lhs.push(r):e.rhs.push(r)}),e},ln=(n,t)=>n.reduce((e,r)=>{const i=t(e),s=t(r);return i>s?r:e}),Ac=(n,t,e,r,i,s)=>{r.includes(t.id)||(r.push(t.id),e||s.push(t.id),i(t.id).forEach(o=>Ac(n,o,e,r,i,s)),e&&s.push(t.id))},Ic=(n,t,e,r)=>{const i=Array.isArray(t)?t:[t],s=u=>n.getNeighbors(u),o=[],a=[];return i.forEach(u=>{if(n.hasNode(u.id))Ac(n,u,e==="post",a,s,o);else throw new Error(`Graph does not have node: ${u}`)}),o},cm=n=>{const t=e=>{const r=n.getChildren(e),i=n.getNode(e);if(r!=null&&r.length&&r.forEach(s=>t(s.id)),i.data.hasOwnProperty("minRank")){i.data.borderLeft=[],i.data.borderRight=[];for(let s=i.data.minRank,o=i.data.maxRank+1;st(e.id))},Tc=(n,t,e,r,i,s)=>{const o={rank:s,borderType:t,width:0,height:0},a=i.data[t][s-1],u=vt(n,"border",o,e);i.data[t][s]=u,n.setParent(u,r),a&&n.addEdge({id:`e${Math.random()}`,source:a,target:u,data:{weight:1}})},fm=(n,t)=>{const e=t.toLowerCase();(e==="lr"||e==="rl")&&kc(n)},lm=(n,t)=>{const e=t.toLowerCase();(e==="bt"||e==="rl")&&hm(n),(e==="lr"||e==="rl")&&(dm(n),kc(n))},kc=n=>{n.getAllNodes().forEach(t=>{jc(t)}),n.getAllEdges().forEach(t=>{jc(t)})},jc=n=>{const t=n.data.width;n.data.width=n.data.height,n.data.height=t},hm=n=>{n.getAllNodes().forEach(t=>{hn(t.data)}),n.getAllEdges().forEach(t=>{var e;(e=t.data.points)===null||e===void 0||e.forEach(r=>hn(r)),t.data.hasOwnProperty("y")&&hn(t.data)})},hn=n=>{n!=null&&n.y&&(n.y=-n.y)},dm=n=>{n.getAllNodes().forEach(t=>{dn(t.data)}),n.getAllEdges().forEach(t=>{var e;(e=t.data.points)===null||e===void 0||e.forEach(r=>dn(r)),t.data.hasOwnProperty("x")&&dn(t.data)})},dn=n=>{const t=n.x;n.x=n.y,n.y=t},gm=n=>{const t=vt(n,"root",{},"_root"),e=pm(n);let r=Math.max(...Object.values(e));Math.abs(r)===1/0&&(r=1);const i=r-1,s=2*i+1;n.getAllEdges().forEach(a=>{a.data.minlen*=s});const o=vm(n)+1;return n.getRoots().forEach(a=>{Cc(n,t,s,o,i,e,a.id)}),{nestingRoot:t,nodeRankFactor:s}},Cc=(n,t,e,r,i,s,o)=>{const a=n.getChildren(o);if(!(a!=null&&a.length)){o!==t&&n.addEdge({id:`e${Math.random()}`,source:t,target:o,data:{weight:0,minlen:e}});return}const u=qc(n,"_bt"),c=qc(n,"_bb"),f=n.getNode(o);n.setParent(u,o),f.data.borderTop=u,n.setParent(c,o),f.data.borderBottom=c,a==null||a.forEach(l=>{Cc(n,t,e,r,i,s,l.id);const h=l.data.borderTop?l.data.borderTop:l.id,g=l.data.borderBottom?l.data.borderBottom:l.id,p=l.data.borderTop?r:2*r,v=h!==g?1:i-s[o]+1;n.addEdge({id:`e${Math.random()}`,source:u,target:h,data:{minlen:v,weight:p,nestingEdge:!0}}),n.addEdge({id:`e${Math.random()}`,source:g,target:c,data:{minlen:v,weight:p,nestingEdge:!0}})}),n.getParent(o)||n.addEdge({id:`e${Math.random()}`,source:t,target:u,data:{weight:0,minlen:i+s[o]}})},pm=n=>{const t={},e=(r,i)=>{const s=n.getChildren(r);s==null||s.forEach(o=>e(o.id,i+1)),t[r]=i};return n.getRoots().forEach(r=>e(r.id,1)),t},vm=n=>{let t=0;return n.getAllEdges().forEach(e=>{t+=e.data.weight}),t},mm=(n,t)=>{t&&n.removeNode(t),n.getAllEdges().forEach(e=>{e.data.nestingEdge&&n.removeEdge(e.id)})},ym="edge",Pc="edge-label",wm=(n,t)=>{n.getAllEdges().forEach(e=>bm(n,e,t))},bm=(n,t,e)=>{let r=t.source,i=n.getNode(r).data.rank;const s=t.target,o=n.getNode(s).data.rank,a=t.data.labelRank;if(o===i+1)return;n.removeEdge(t.id);let u,c,f;for(f=0,++i;i{t.forEach(e=>{let r=n.getNode(e);const{data:i}=r,s=i.originalEdge;let o;s&&n.addEdge(s);let a=e;for(;r.data.dummy;)o=n.getSuccessors(a)[0],n.removeNode(a),s.data.points.push({x:r.data.x,y:r.data.y}),r.data.dummy===Pc&&(s.data.x=r.data.x,s.data.y=r.data.y,s.data.width=r.data.width,s.data.height=r.data.height),a=o.id,r=n.getNode(a)})},Em=(n,t,e)=>{const r={};let i;e==null||e.forEach(s=>{let o=n.getParent(s),a,u;for(;o;){if(a=n.getParent(o.id),a?(u=r[a.id],r[a.id]=o.id):(u=i,i=o.id),u&&u!==o.id){t.hasNode(u)||t.addNode({id:u,data:{}}),t.hasNode(o.id)||t.addNode({id:o.id,data:{}}),t.hasEdge(`e${u}-${o.id}`)||t.addEdge({id:`e${u}-${o.id}`,source:u,target:o.id,data:{}});return}o=a}})},xm=(n,t,e)=>{const r=Nm(n),i=new ue({tree:[{id:r,children:[],data:{}}]});return n.getAllNodes().forEach(s=>{const o=n.getParent(s.id);(s.data.rank===t||s.data.minRank<=t&&t<=s.data.maxRank)&&(i.hasNode(s.id)||i.addNode(Object.assign({},s)),o!=null&&o.id&&!i.hasNode(o==null?void 0:o.id)&&i.addNode(Object.assign({},o)),i.setParent(s.id,(o==null?void 0:o.id)||r),n.getRelatedEdges(s.id,e).forEach(a=>{const u=a.source===s.id?a.target:a.source;i.hasNode(u)||i.addNode(Object.assign({},n.getNode(u)));const c=i.getRelatedEdges(u,"out").find(({target:l})=>l===s.id),f=c!==void 0?c.data.weight:0;c?i.updateEdgeData(c.id,Object.assign(Object.assign({},c.data),{weight:a.data.weight+f})):i.addEdge({id:a.id,source:u,target:s.id,data:{weight:a.data.weight+f}})}),s.data.hasOwnProperty("minRank")&&i.updateNodeData(s.id,Object.assign(Object.assign({},s.data),{borderLeft:s.data.borderLeft[t],borderRight:s.data.borderRight[t]})))}),i},Nm=n=>{let t;for(;n.hasNode(t=`_root${Math.random()}`););return t},Mm=(n,t,e)=>{const r=sm(e,e.map((f,l)=>l)),s=t.map(f=>{const l=n.getRelatedEdges(f,"out").map(h=>({pos:r[h.target]||0,weight:h.data.weight}));return l==null?void 0:l.sort((h,g)=>h.pos-g.pos)}).flat().filter(f=>f!==void 0);let o=1;for(;o{if(f){let l=f.pos+o;u[l]+=f.weight;let h=0;for(;l>0;)l%2&&(h+=u[l+1]),l=l-1>>1,u[l]+=f.weight;c+=f.weight*h}}),c},Lc=(n,t)=>{let e=0;for(let r=1;r<(t==null?void 0:t.length);r+=1)e+=Mm(n,t[r-1],t[r]);return e},Dc=n=>{const t={},e=n.getAllNodes(),r=e.map(c=>{var f;return(f=c.data.rank)!==null&&f!==void 0?f:-1/0}),i=Math.max(...r),s=[];for(let c=0;cn.getNode(c.id).data.rank-n.getNode(f.id).data.rank),u=o.filter(c=>n.getNode(c.id).data.fixorder!==void 0).sort((c,f)=>n.getNode(c.id).data.fixorder-n.getNode(f.id).data.fixorder);return u==null||u.forEach(c=>{isNaN(n.getNode(c.id).data.rank)||s[n.getNode(c.id).data.rank].push(c.id),t[c.id]=!0}),o==null||o.forEach(c=>n.dfsTree(c.id,f=>{if(t.hasOwnProperty(f.id))return!0;t[f.id]=!0,isNaN(f.data.rank)||s[f.data.rank].push(f.id)})),s},Sm=(n,t)=>t.map(e=>{const r=n.getRelatedEdges(e,"in");if(!(r!=null&&r.length))return{v:e};const i={sum:0,weight:0};return r==null||r.forEach(s=>{const o=n.getNode(s.source);i.sum+=s.data.weight*o.data.order,i.weight+=s.data.weight}),{v:e,barycenter:i.sum/i.weight,weight:i.weight}}),Rm=(n,t)=>{var e,r,i;const s={};n==null||n.forEach((a,u)=>{s[a.v]={i:u,indegree:0,in:[],out:[],vs:[a.v]};const c=s[a.v];a.barycenter!==void 0&&(c.barycenter=a.barycenter,c.weight=a.weight)}),(e=t.getAllEdges())===null||e===void 0||e.forEach(a=>{const u=s[a.source],c=s[a.target];u!==void 0&&c!==void 0&&(c.indegree++,u.out.push(s[a.target]))});const o=(i=(r=Object.values(s)).filter)===null||i===void 0?void 0:i.call(r,a=>!a.indegree);return qm(o)},qm=n=>{var t,e;const r=[],i=u=>c=>{c.merged||(c.barycenter===void 0||u.barycenter===void 0||c.barycenter>=u.barycenter)&&Om(u,c)},s=u=>c=>{c.in.push(u),--c.indegree===0&&n.push(c)};for(;n!=null&&n.length;){const u=n.pop();r.push(u),(t=u.in.reverse())===null||t===void 0||t.forEach(c=>i(u)(c)),(e=u.out)===null||e===void 0||e.forEach(c=>s(u)(c))}const o=r.filter(u=>!u.merged),a=["vs","i","barycenter","weight"];return o.map(u=>{const c={};return a==null||a.forEach(f=>{u[f]!==void 0&&(c[f]=u[f])}),c})},Om=(n,t)=>{var e;let r=0,i=0;n.weight&&(r+=n.barycenter*n.weight,i+=n.weight),t.weight&&(r+=t.barycenter*t.weight,i+=t.weight),n.vs=(e=t.vs)===null||e===void 0?void 0:e.concat(n.vs),n.barycenter=r/i,n.weight=i,n.i=Math.min(t.i,n.i),t.merged=!0},Am=(n,t,e,r)=>{const i=um(n,h=>{const g=h.hasOwnProperty("fixorder")&&!isNaN(h.fixorder);return r?!g&&h.hasOwnProperty("barycenter"):g||h.hasOwnProperty("barycenter")}),s=i.lhs,o=i.rhs.sort((h,g)=>-h.i- -g.i),a=[];let u=0,c=0,f=0;s==null||s.sort(Im(!!t,!!e)),f=zc(a,o,f),s==null||s.forEach(h=>{var g;f+=(g=h.vs)===null||g===void 0?void 0:g.length,a.push(h.vs),u+=h.barycenter*h.weight,c+=h.weight,f=zc(a,o,f)});const l={vs:a.flat()};return c&&(l.barycenter=u/c,l.weight=c),l},zc=(n,t,e)=>{let r=e,i;for(;t.length&&(i=t[t.length-1]).i<=r;)t.pop(),n==null||n.push(i.vs),r++;return r},Im=(n,t)=>(e,r)=>{if(e.fixorder!==void 0&&r.fixorder!==void 0)return e.fixorder-r.fixorder;if(e.barycenterr.barycenter)return 1;if(t&&e.order!==void 0&&r.order!==void 0){if(e.orderr.order)return 1}return n?r.i-e.i:e.i-r.i},$c=(n,t,e,r,i,s)=>{var o,a,u,c;let f=n.getChildren(t).map(y=>y.id);const l=n.getNode(t),h=l?l.data.borderLeft:void 0,g=l?l.data.borderRight:void 0,p={};h&&(f=f==null?void 0:f.filter(y=>y!==h&&y!==g));const v=Sm(n,f||[]);v==null||v.forEach(y=>{var w;if(!((w=n.getChildren(y.v))===null||w===void 0)&&w.length){const b=$c(n,y.v,e,r,s);p[y.v]=b,b.hasOwnProperty("barycenter")&&km(y,b)}});const m=Rm(v,e);Tm(m,p),(o=m.filter(y=>y.vs.length>0))===null||o===void 0||o.forEach(y=>{const w=n.getNode(y.vs[0]);w&&(y.fixorder=w.data.fixorder,y.order=w.data.order)});const d=Am(m,r,i,s);if(h&&(d.vs=[h,d.vs,g].flat(),!((a=n.getPredecessors(h))===null||a===void 0)&&a.length)){const y=n.getNode(((u=n.getPredecessors(h))===null||u===void 0?void 0:u[0].id)||""),w=n.getNode(((c=n.getPredecessors(g))===null||c===void 0?void 0:c[0].id)||"");d.hasOwnProperty("barycenter")||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+y.data.order+w.data.order)/(d.weight+2),d.weight+=2}return d},Tm=(n,t)=>{n==null||n.forEach(e=>{var r;const i=(r=e.vs)===null||r===void 0?void 0:r.map(s=>t[s]?t[s].vs:s);e.vs=i.flat()})},km=(n,t)=>{n.barycenter!==void 0?(n.barycenter=(n.barycenter*n.weight+t.barycenter*t.weight)/(n.weight+t.weight),n.weight+=t.weight):(n.barycenter=t.barycenter,n.weight=t.weight)},jm=(n,t)=>{const e=Oc(n),r=[],i=[];for(let f=1;f-1;f--)i.push(f);const s=Fc(n,r,"in"),o=Fc(n,i,"out");let a=Dc(n);gn(n,a);let u=Number.POSITIVE_INFINITY,c;for(let f=0,l=0;l<4;++f,++l){Bc(f%2?s:o,f%4>=2,!1,t),a=Pt(n);const h=Lc(n,a);h=2,!0,t),a=Pt(n);const h=Lc(n,a);ht.map(r=>xm(n,r,e)),Bc=(n,t,e,r)=>{const i=new ue;n==null||n.forEach(s=>{var o;const a=s.getRoots()[0].id,u=$c(s,a,i,t,e,r);for(let c=0;c<((o=u.vs)===null||o===void 0?void 0:o.length);c++){const f=s.getNode(u.vs[c]);f&&(f.data.order=c)}Em(s,i,u.vs)})},gn=(n,t)=>{t==null||t.forEach(e=>{e==null||e.forEach((r,i)=>{n.getNode(r).data.order=i})})},Cm=(n,t)=>{const r=n.getAllNodes().filter(o=>{var a;return!(!((a=n.getChildren(o.id))===null||a===void 0)&&a.length)}).map(o=>o.data.rank),i=Math.max(...r),s=[];for(let o=0;o{const a=n.getNode(o);!a||a.data.dummy||isNaN(a.data.rank)||(a.data.fixorder=s[a.data.rank].length,s[a.data.rank].push(o))})},Pm=n=>{const t={};let e=0;const r=i=>{const s=e;n.getChildren(i).forEach(o=>r(o.id)),t[i]={low:s,lim:e++}};return n.getRoots().forEach(i=>r(i.id)),t},Lm=(n,t,e,r)=>{var i,s;const o=[],a=[],u=Math.min(t[e].low,t[r].low),c=Math.max(t[e].lim,t[r].lim);let f,l;f=e;do f=(i=n.getParent(f))===null||i===void 0?void 0:i.id,o.push(f);while(f&&(t[f].low>u||c>t[f].lim));for(l=f,f=r;f&&f!==l;)a.push(f),f=(s=n.getParent(f))===null||s===void 0?void 0:s.id;return{lca:l,path:o.concat(a.reverse())}},Dm=(n,t)=>{const e=Pm(n);t.forEach(r=>{var i,s;let o=r,a=n.getNode(o);const u=a.data.originalEdge;if(!u)return;const c=Lm(n,e,u.source,u.target),f=c.path,l=c.lca;let h=0,g=f[h],p=!0;for(;o!==u.target;){if(a=n.getNode(o),p){for(;g!==l&&((i=n.getNode(g))===null||i===void 0?void 0:i.data.maxRank){const e={},r=(i,s)=>{let o=0,a=0;const u=i.length,c=s==null?void 0:s[(s==null?void 0:s.length)-1];return s==null||s.forEach((f,l)=>{var h;const g=Fm(n,f),p=g?n.getNode(g.id).data.order:u;(g||f===c)&&((h=s.slice(a,l+1))===null||h===void 0||h.forEach(v=>{var m;(m=n.getPredecessors(v))===null||m===void 0||m.forEach(d=>{var y;const w=n.getNode(d.id),b=w.data.order;(b{const e={};function r(a,u,c,f,l){var h,g;let p;for(let v=u;v{const d=n.getNode(m.id);d.data.dummy&&(d.data.orderl)&&Uc(e,m.id,p)}))}function i(a){return JSON.stringify(a.slice(1))}function s(a,u){const c=i(a);u.get(c)||(r(...a),u.set(c,!0))}const o=(a,u)=>{let c=-1,f,l=0;const h=new Map;return u==null||u.forEach((g,p)=>{var v;if(((v=n.getNode(g))===null||v===void 0?void 0:v.data.dummy)==="border"){const m=n.getPredecessors(g)||[];m.length&&(f=n.getNode(m[0].id).data.order,s([u,l,p,c,f],h),l=p,c=f)}s([u,l,u.length,f,a.length],h)}),u};return t!=null&&t.length&&t.reduce(o),e},Fm=(n,t)=>{var e,r;if(!((e=n.getNode(t))===null||e===void 0)&&e.data.dummy)return(r=n.getPredecessors(t))===null||r===void 0?void 0:r.find(i=>n.getNode(i.id).data.dummy)},Uc=(n,t,e)=>{let r=t,i=e;if(r>i){const o=r;r=i,i=o}let s=n[r];s||(n[r]=s={}),s[i]=!0},Bm=(n,t,e)=>{let r=t,i=e;if(r>i){const s=t;r=i,i=s}return!!n[r]},Um=(n,t,e,r)=>{const i={},s={},o={};return t==null||t.forEach(a=>{a==null||a.forEach((u,c)=>{i[u]=u,s[u]=u,o[u]=c})}),t==null||t.forEach(a=>{let u=-1;a==null||a.forEach(c=>{let f=r(c).map(l=>l.id);if(f.length){f=f.sort((h,g)=>o[h]-o[g]);const l=(f.length-1)/2;for(let h=Math.floor(l),g=Math.ceil(l);h<=g;++h){const p=f[h];s[c]===c&&u{var a;const u={},c=Vm(n,t,e,i,s,o),f=o?"borderLeft":"borderRight",l=(p,v)=>{let m=c.getAllNodes(),d=m.pop();const y={};for(;d;)y[d.id]?p(d.id):(y[d.id]=!0,m.push(d),m=m.concat(v(d.id))),d=m.pop()},h=p=>{u[p]=(c.getRelatedEdges(p,"in")||[]).reduce((v,m)=>Math.max(v,(u[m.source]||0)+m.data.weight),0)},g=p=>{const v=(c.getRelatedEdges(p,"out")||[]).reduce((d,y)=>Math.min(d,(u[y.target]||0)-y.data.weight),Number.POSITIVE_INFINITY),m=n.getNode(p);v!==Number.POSITIVE_INFINITY&&m.data.borderType!==f&&(u[p]=Math.max(u[p],v))};return l(h,c.getPredecessors.bind(c)),l(g,c.getSuccessors.bind(c)),(a=Object.values(r))===null||a===void 0||a.forEach(p=>{u[p]=u[e[p]]}),u},Vm=(n,t,e,r,i,s)=>{const o=new ue,a=Xm(r,i,s);return t==null||t.forEach(u=>{let c;u==null||u.forEach(f=>{const l=e[f];if(o.hasNode(l)||o.addNode({id:l,data:{}}),c){const h=e[c],g=o.getRelatedEdges(h,"out").find(p=>p.target===l);g?o.updateEdgeData(g.id,Object.assign(Object.assign({},g.data),{weight:Math.max(a(n,f,c),g.data.weight||0)})):o.addEdge({id:`e${Math.random()}`,source:h,target:l,data:{weight:Math.max(a(n,f,c),0)}})}c=f})}),o},Wm=(n,t)=>ln(Object.values(t),e=>{var r;let i=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY;return(r=Object.keys(e))===null||r===void 0||r.forEach(o=>{const a=e[o],u=Zm(n,o)/2;i=Math.max(a+u,i),s=Math.min(a-u,s)}),i-s});function Ym(n,t){const e=Object.values(t),r=Math.min(...e),i=Math.max(...e);["u","d"].forEach(s=>{["l","r"].forEach(o=>{const a=s+o,u=n[a];let c;if(u===t)return;const f=Object.values(u);c=o==="l"?r-Math.min(...f):i-Math.max(...f),c&&(n[a]={},Object.keys(u).forEach(l=>{n[a][l]=u[l]+c}))})})}const Km=(n,t)=>{const e={};return Object.keys(n.ul).forEach(r=>{if(t)e[r]=n[t.toLowerCase()][r];else{const i=Object.values(n).map(s=>s[r]);e[r]=(i[0]+i[1])/2}}),e},Xm=(n,t,e)=>(r,i,s)=>{const o=r.getNode(i),a=r.getNode(s);let u=0,c=0;if(u+=o.data.width/2,o.data.hasOwnProperty("labelpos"))switch((o.data.labelpos||"").toLowerCase()){case"l":c=-o.data.width/2;break;case"r":c=o.data.width/2;break}if(c&&(u+=e?c:-c),c=0,u+=(o.data.dummy?t:n)/2,u+=(a.data.dummy?t:n)/2,u+=a.data.width/2,a.data.labelpos)switch((a.data.labelpos||"").toLowerCase()){case"l":c=a.data.width/2;break;case"r":c=-a.data.width/2;break}return c&&(u+=e?c:-c),c=0,u},Zm=(n,t)=>n.getNode(t).data.width||0,Jm=(n,t)=>{const{ranksep:e=0}=t,r=Pt(n);let i=0;r==null||r.forEach(s=>{const o=s.map(u=>n.getNode(u).data.height),a=Math.max(...o,0);s==null||s.forEach(u=>{n.getNode(u).data.y=i+a/2}),i+=a+e})},Qm=(n,t)=>{const{align:e,nodesep:r=0,edgesep:i=0}=t,s=Pt(n),o=Object.assign(zm(n,s),$m(n,s)),a={};let u=[];["u","d"].forEach(f=>{u=f==="u"?s:Object.values(s).reverse(),["l","r"].forEach(l=>{l==="r"&&(u=u.map(v=>Object.values(v).reverse()));const h=(f==="u"?n.getPredecessors:n.getSuccessors).bind(n),g=Um(n,u,o,h),p=Gm(n,u,g.root,g.align,r,i,l==="r");l==="r"&&Object.keys(p).forEach(v=>p[v]=-p[v]),a[f+l]=p})});const c=Wm(n,a);return c&&Ym(a,c),Km(a,e)},Hm=(n,t)=>{var e;const r=Sc(n);Jm(r,t);const i=Qm(r,t);(e=Object.keys(i))===null||e===void 0||e.forEach(s=>{r.getNode(s).data.x=i[s]})},Gc=n=>{const t={},e=r=>{var i;const s=n.getNode(r);if(!s)return 0;if(t[r])return s.data.rank;t[r]=!0;let o;return(i=n.getRelatedEdges(r,"out"))===null||i===void 0||i.forEach(a=>{const u=e(a.target),c=a.data.minlen,f=u-c;f&&(o===void 0||fn.getRelatedEdges(r.id,"in").length===0).forEach(r=>e(r.id))},ey=n=>{const t={};let e;const r=o=>{var a;const u=n.getNode(o);if(!u)return 0;if(t[o])return u.data.rank;t[o]=!0;let c;return(a=n.getRelatedEdges(o,"out"))===null||a===void 0||a.forEach(f=>{const l=r(f.target),h=f.data.minlen,g=l-h;g&&(c===void 0||gn.getRelatedEdges(o.id,"in").length===0).forEach(o=>{o&&r(o.id)}),e===void 0&&(e=0);const i={},s=(o,a)=>{var u;const c=n.getNode(o),f=isNaN(c.data.layer)?a:c.data.layer;(c.data.rank===void 0||c.data.rank{s(l.target,f+l.data.minlen)}))};n.getAllNodes().forEach(o=>{const a=o.data;a&&(isNaN(a.layer)?a.rank-=e:s(o.id,a.layer))})},Ve=(n,t)=>n.getNode(t.target).data.rank-n.getNode(t.source).data.rank-t.data.minlen,ty=n=>{const t=new ue({tree:[]}),e=n.getAllNodes()[0],r=n.getAllNodes().length;t.addNode(e);let i,s;for(;ry(t,n){const e=r=>{t.getRelatedEdges(r,"both").forEach(i=>{const s=i.source,o=r===s?i.target:s;!n.hasNode(o)&&!Ve(t,i)&&(n.addNode({id:o,data:{}}),n.addEdge({id:i.id,source:r,target:o,data:{}}),e(o))})};return n.getAllNodes().forEach(r=>e(r.id)),n.getAllNodes().length},ny=n=>{const t=new ue({tree:[]}),e=n.getAllNodes()[0],r=n.getAllNodes().length;t.addNode(e);let i,s;for(;iy(t,n){const e=r=>{var i;(i=t.getRelatedEdges(r,"both"))===null||i===void 0||i.forEach(s=>{const o=s.source,a=r===o?s.target:o;!n.hasNode(a)&&(t.getNode(a).data.layer!==void 0||!Ve(t,s))&&(n.addNode({id:a,data:{}}),n.addEdge({id:s.id,source:r,target:a,data:{}}),e(a))})};return n.getAllNodes().forEach(r=>e(r.id)),n.getAllNodes().length},Vc=(n,t)=>ln(t.getAllEdges(),e=>n.hasNode(e.source)!==n.hasNode(e.target)?Ve(t,e):1/0),Wc=(n,t,e)=>{n.getAllNodes().forEach(r=>{const i=t.getNode(r.id);i.data.rank||(i.data.rank=0),i.data.rank+=e})},sy=n=>{const t=im(n);Gc(t);const e=ty(t);Kc(e),Yc(e,t);let r,i;for(;r=uy(e);)i=cy(e,t,r),fy(e,t,r,i)},Yc=(n,t)=>{let e=Ic(n,n.getAllNodes(),"post");e=e.slice(0,(e==null?void 0:e.length)-1),e.forEach(r=>{oy(n,t,r)})},oy=(n,t,e)=>{const i=n.getNode(e).data.parent,s=n.getRelatedEdges(e,"both").find(o=>o.target===i||o.source===i);s.data.cutvalue=ay(n,t,e)},ay=(n,t,e)=>{const i=n.getNode(e).data.parent;let s=!0,o=t.getRelatedEdges(e,"out").find(u=>u.target===i),a=0;return o||(s=!1,o=t.getRelatedEdges(i,"out").find(u=>u.target===e)),a=o.data.weight,t.getRelatedEdges(e,"both").forEach(u=>{const c=u.source===e,f=c?u.target:u.source;if(f!==i){const l=c===s,h=u.data.weight;if(a+=l?h:-h,hy(n,e,f)){const g=n.getRelatedEdges(e,"both").find(p=>p.source===f||p.target===f).data.cutvalue;a+=l?-g:g}}}),a},Kc=(n,t=n.getAllNodes()[0].id)=>{Xc(n,{},1,t)},Xc=(n,t,e,r,i)=>{var s;const o=e;let a=e;const u=n.getNode(r);return t[r]=!0,(s=n.getNeighbors(r))===null||s===void 0||s.forEach(c=>{t[c.id]||(a=Xc(n,t,a,c.id,r))}),u.data.low=o,u.data.lim=a++,i?u.data.parent=i:delete u.data.parent,a},uy=n=>n.getAllEdges().find(t=>t.data.cutvalue<0),cy=(n,t,e)=>{let r=e.source,i=e.target;t.getRelatedEdges(r,"out").find(f=>f.target===i)||(r=e.target,i=e.source);const s=n.getNode(r),o=n.getNode(i);let a=s,u=!1;s.data.lim>o.data.lim&&(a=o,u=!0);const c=t.getAllEdges().filter(f=>u===Zc(n.getNode(f.source),a)&&u!==Zc(n.getNode(f.target),a));return ln(c,f=>Ve(t,f))},fy=(n,t,e,r)=>{const i=n.getRelatedEdges(e.source,"both").find(s=>s.source===e.target||s.target===e.target);i&&n.removeEdge(i.id),n.addEdge({id:`e${Math.random()}`,source:r.source,target:r.target,data:{}}),Kc(n),Yc(n,t),ly(n,t)},ly=(n,t)=>{const e=n.getAllNodes().find(i=>!i.data.parent);let r=Ic(n,e,"pre");r=r.slice(1),r.forEach(i=>{const s=n.getNode(i).data.parent;let o=t.getRelatedEdges(i,"out").find(u=>u.target===s),a=!1;!o&&t.hasNode(s)&&(o=t.getRelatedEdges(s,"out").find(u=>u.target===i),a=!0),t.getNode(i).data.rank=(t.hasNode(s)&&t.getNode(s).data.rank||0)+(a?o==null?void 0:o.data.minlen:-(o==null?void 0:o.data.minlen))})},hy=(n,t,e)=>n.getRelatedEdges(t,"both").find(r=>r.source===e||r.target===e),Zc=(n,t)=>t.data.low<=n.data.lim&&n.data.lim<=t.data.lim,dy=(n,t)=>{switch(t){case"network-simplex":py(n);break;case"tight-tree":Jc(n);break;case"longest-path":gy(n);break;default:Jc(n)}},gy=Gc,Jc=n=>{ey(n),ny(n)},py=n=>{sy(n)},vy=(n,t)=>{const{edgeLabelSpace:e,keepNodeOrder:r,prevGraph:i,rankdir:s,ranksep:o}=t;!r&&i&&yy(n,i);const a=Ny(n);e&&(t.ranksep=My(a,{rankdir:s,ranksep:o}));let u;try{u=my(a,t)}catch(c){if(c.message==="Not possible to find intersection inside of the rectangle"){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: +`,c);return}throw c}return wy(n,a),u},my=(n,t)=>{const{acyclicer:e,ranker:r,rankdir:i="tb",nodeOrder:s,keepNodeOrder:o,align:a,nodesep:u=50,edgesep:c=20,ranksep:f=50}=t;jy(n),em(n,e);const{nestingRoot:l,nodeRankFactor:h}=gm(n);dy(Sc(n),r),Sy(n),am(n,h),mm(n,l),om(n),Ry(n),qy(n);const g=[];wm(n,g),Dm(n,g),cm(n),o&&Cm(n,s),jm(n,o),Cy(n),fm(n,i),Hm(n,{align:a,nodesep:u,edgesep:c,ranksep:f}),Py(n),ky(n),_m(n,g),Iy(n),lm(n,i);const{width:p,height:v}=Oy(n);return Ay(n),Ty(n),rm(n),{width:p,height:v}},yy=(n,t)=>{n.getAllNodes().forEach(e=>{const r=n.getNode(e.id);if(t.hasNode(e.id)){const i=t.getNode(e.id);r.data.fixorder=i.data._order,delete i.data._order}else delete r.data.fixorder})},wy=(n,t)=>{n.getAllNodes().forEach(e=>{var r;const i=n.getNode(e.id);if(i){const s=t.getNode(e.id);i.data.x=s.data.x,i.data.y=s.data.y,i.data._order=s.data.order,i.data._rank=s.data.rank,!((r=t.getChildren(e.id))===null||r===void 0)&&r.length&&(i.data.width=s.data.width,i.data.height=s.data.height)}}),n.getAllEdges().forEach(e=>{const r=n.getEdge(e.id),i=t.getEdge(e.id);r.data.points=i?i.data.points:[],i&&i.data.hasOwnProperty("x")&&(r.data.x=i.data.x,r.data.y=i.data.y)})},by=["width","height","layer","fixorder"],_y={width:0,height:0},Ey=["minlen","weight","width","height","labeloffset"],xy={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},pn=["labelpos"],Ny=n=>{const t=new ue({tree:[]});return n.getAllNodes().forEach(e=>{const r=Hc(n.getNode(e.id).data),i=Object.assign(Object.assign({},_y),r),s=Qc(i,by);t.hasNode(e.id)||t.addNode({id:e.id,data:Object.assign({},s)});const o=n.hasTreeStructure("combo")?n.getParent(e.id,"combo"):n.getParent(e.id);$0(o)||(t.hasNode(o.id)||t.addNode(Object.assign({},o)),t.setParent(e.id,o.id))}),n.getAllEdges().forEach(e=>{const r=Hc(n.getEdge(e.id).data),i={};pn==null||pn.forEach(s=>{r[s]!==void 0&&(i[s]=r[s])}),t.addEdge({id:e.id,source:e.source,target:e.target,data:Object.assign({},xy,Qc(r,Ey),i)})}),t},My=(n,t)=>{const{ranksep:e=0,rankdir:r}=t;return n.getAllNodes().forEach(i=>{isNaN(i.data.layer)||i.data.layer||(i.data.layer=0)}),n.getAllEdges().forEach(i=>{var s;i.data.minlen*=2,((s=i.data.labelpos)===null||s===void 0?void 0:s.toLowerCase())!=="c"&&(r==="TB"||r==="BT"?i.data.width+=i.data.labeloffset:i.data.height+=i.data.labeloffset)}),e/2},Sy=n=>{n.getAllEdges().forEach(t=>{if(t.data.width&&t.data.height){const e=n.getNode(t.source),r=n.getNode(t.target),i={e:t,rank:(r.data.rank-e.data.rank)/2+e.data.rank};vt(n,"edge-proxy",i,"_ep")}})},Ry=n=>{let t=0;return n.getAllNodes().forEach(e=>{var r,i;e.data.borderTop&&(e.data.minRank=(r=n.getNode(e.data.borderTop))===null||r===void 0?void 0:r.data.rank,e.data.maxRank=(i=n.getNode(e.data.borderBottom))===null||i===void 0?void 0:i.data.rank,t=Math.max(t,e.data.maxRank||-1/0))}),t},qy=n=>{n.getAllNodes().forEach(t=>{t.data.dummy==="edge-proxy"&&(n.getEdge(t.data.e.id).data.labelRank=t.data.rank,n.removeNode(t.id))})},Oy=(n,t)=>{let e,r=0,i,s=0;const{marginx:o=0,marginy:a=0}={},u=c=>{if(!c.data)return;const f=c.data.x,l=c.data.y,h=c.data.width,g=c.data.height;!isNaN(f)&&!isNaN(h)&&(e===void 0&&(e=f-h/2),e=Math.min(e,f-h/2),r=Math.max(r,f+h/2)),!isNaN(l)&&!isNaN(g)&&(i===void 0&&(i=l-g/2),i=Math.min(i,l-g/2),s=Math.max(s,l+g/2))};return n.getAllNodes().forEach(c=>{u(c)}),n.getAllEdges().forEach(c=>{c!=null&&c.data.hasOwnProperty("x")&&u(c)}),e-=o,i-=a,n.getAllNodes().forEach(c=>{c.data.x-=e,c.data.y-=i}),n.getAllEdges().forEach(c=>{var f;(f=c.data.points)===null||f===void 0||f.forEach(l=>{l.x-=e,l.y-=i}),c.data.hasOwnProperty("x")&&(c.data.x-=e),c.data.hasOwnProperty("y")&&(c.data.y-=i)}),{width:r-e+o,height:s-i+a}},Ay=n=>{n.getAllEdges().forEach(t=>{const e=n.getNode(t.source),r=n.getNode(t.target);let i,s;t.data.points?(i=t.data.points[0],s=t.data.points[t.data.points.length-1]):(t.data.points=[],i={x:r.data.x,y:r.data.y},s={x:e.data.x,y:e.data.y}),t.data.points.unshift(Rc(e.data,i)),t.data.points.push(Rc(r.data,s))})},Iy=n=>{n.getAllEdges().forEach(t=>{if(t.data.hasOwnProperty("x"))switch((t.data.labelpos==="l"||t.data.labelpos==="r")&&(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;break}})},Ty=n=>{n.getAllEdges().forEach(t=>{var e;t.data.reversed&&((e=t.data.points)===null||e===void 0||e.reverse())})},ky=n=>{n.getAllNodes().forEach(t=>{var e,r,i;if(!((e=n.getChildren(t.id))===null||e===void 0)&&e.length){const s=n.getNode(t.id),o=n.getNode(s.data.borderTop),a=n.getNode(s.data.borderBottom),u=n.getNode(s.data.borderLeft[((r=s.data.borderLeft)===null||r===void 0?void 0:r.length)-1]),c=n.getNode(s.data.borderRight[((i=s.data.borderRight)===null||i===void 0?void 0:i.length)-1]);s.data.width=Math.abs((c==null?void 0:c.data.x)-(u==null?void 0:u.data.x))||10,s.data.height=Math.abs((a==null?void 0:a.data.y)-(o==null?void 0:o.data.y))||10,s.data.x=((u==null?void 0:u.data.x)||0)+s.data.width/2,s.data.y=((o==null?void 0:o.data.y)||0)+s.data.height/2}}),n.getAllNodes().forEach(t=>{t.data.dummy==="border"&&n.removeNode(t.id)})},jy=n=>{n.getAllEdges().forEach(t=>{if(t.source===t.target){const e=n.getNode(t.source);e.data.selfEdges||(e.data.selfEdges=[]),e.data.selfEdges.push(t),n.removeEdge(t.id)}})},Cy=n=>{const t=Pt(n);t==null||t.forEach(e=>{let r=0;e==null||e.forEach((i,s)=>{var o;const a=n.getNode(i);a.data.order=s+r,(o=a.data.selfEdges)===null||o===void 0||o.forEach(u=>{vt(n,"selfedge",{width:u.data.width,height:u.data.height,rank:a.data.rank,order:s+ ++r,e:u},"_se")}),delete a.data.selfEdges})})},Py=n=>{n.getAllNodes().forEach(t=>{const e=n.getNode(t.id);if(e.data.dummy==="selfedge"){const r=n.getNode(e.data.e.source),i=r.data.x+r.data.width/2,s=r.data.y,o=e.data.x-i,a=r.data.height/2;n.hasEdge(e.data.e.id)?n.updateEdgeData(e.data.e.id,e.data.e.data):n.addEdge({id:e.data.e.id,source:e.data.e.source,target:e.data.e.target,data:e.data.e.data}),n.removeNode(t.id),e.data.e.data.points=[{x:i+2*o/3,y:s-a},{x:i+5*o/6,y:s-a},{y:s,x:i+o},{x:i+5*o/6,y:s+a},{x:i+2*o/3,y:s+a}],e.data.e.data.x=e.data.x,e.data.e.data.y=e.data.y}})},Qc=(n,t)=>{const e={};return t==null||t.forEach(r=>{n[r]!==void 0&&(e[r]=+n[r])}),e},Hc=(n={})=>{const t={};return Object.keys(n).forEach(e=>{t[e.toLowerCase()]=n[e]}),t},ke=Array.isArray,ef=n=>{const t=[],e=n.length;for(let r=0;rt[i][r]+t[r][s]&&(t[i][s]=t[i][r]+t[r][s]);return t},tf=(n,t)=>{const{nodes:e,edges:r}=n,i=[],s={};if(!e)throw new Error("invalid nodes data!");return e&&e.forEach((o,a)=>{s[o.id]=a;const u=[];i.push(u)}),r==null||r.forEach(o=>{const{source:a,target:u}=o,c=s[a],f=s[u];c===void 0||f===void 0||(i[c][f]=1,i[f][c]=1)}),i},Ly=(n,t)=>{const e=[];return n.forEach(r=>{const i=[];r.forEach(s=>{i.push(s*t)}),e.push(i)}),e},Dy=n=>{let t=1/0,e=1/0,r=-1/0,i=-1/0;return n.forEach(s=>{let o=s.data.size;ke(o)?o.length===1&&(o=[o[0],o[0]]):V(o)?o=[o,o]:(o===void 0||isNaN(o))&&(o=[30,30]);const a=[o[0]/2,o[1]/2],u=s.data.x-a[0],c=s.data.x+a[0],f=s.data.y-a[1],l=s.data.y+a[1];t>u&&(t=u),e>f&&(e=f),rMath.sqrt((n.x-t.x)*(n.x-t.x)+(n.y-t.y)*(n.y-t.y)),vn=(n,t,e,r="TB",i,s={})=>{if(!(t!=null&&t.length))return;const{stopBranchFn:o,stopAllFn:a}=s;for(let u=0;u{if(n===null)return n;if(n instanceof Date)return new Date(n.getTime());if(n instanceof Array){const t=[];return n.forEach(e=>{t.push(e)}),t.map(e=>mn(e))}if(typeof n=="object"){const t={};return Object.keys(n).forEach(e=>{t[e]=mn(n[e])}),t}return n},ye=(n,t)=>{const e=mn(n);return e.data=e.data||{},t&&(V(e.data.x)||(e.data.x=Math.random()*t[0]),V(e.data.y)||(e.data.y=Math.random()*t[1])),e};function Lt(n){if(!n)return[0,0,0];if(V(n))return[n,n,n];if(n.length===0)return[0,0,0];const[t,e=t,r=t]=n;return[t,e,r]}function rt(n,t){let e;return Te(t)?e=t:V(t)?e=()=>t:e=()=>n,e}function yn(n,t,e=!0){return!t&&t!==0?r=>{const{size:i}=r.data||{};return i?Array.isArray(i)?e?Math.max(...i)||n:i:pt(i)&&i.width&&i.height?e?Math.max(i.width,i.height)||n:[i.width,i.height]:i:n}:Te(t)?t:V(t)?()=>t:Array.isArray(t)?()=>e?Math.max(...t)||n:t:pt(t)&&t.width&&t.height?()=>e?Math.max(t.width,t.height)||n:[t.width,t.height]:()=>n}const wn=(n,t,e=10)=>{let r;const i=typeof t=="function"?t:()=>t||0;return n?Array.isArray(n)?r=o=>n:Te(n)?r=n:r=o=>n:r=o=>{var a,u,c;if(!((a=o.data)===null||a===void 0)&&a.bboxSize)return(u=o.data)===null||u===void 0?void 0:u.bboxSize;if(!((c=o.data)===null||c===void 0)&&c.size){const f=o.data.size;return Array.isArray(f)?f:pt(f)?[f.width,f.height]:f}return e},o=>{const a=r(o),u=i(o);return Math.max(...Lt(a))+u}},zy={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};class $y{constructor(t={}){this.options=t,this.id="antv-dagre",this.options=Object.assign(Object.assign({},zy),t)}execute(t,e){return P(this,void 0,void 0,function*(){return this.genericDagreLayout(!1,t,e)})}assign(t,e){return P(this,void 0,void 0,function*(){yield this.genericDagreLayout(!0,t,e)})}genericDagreLayout(t,e,r){return P(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),r),{nodeSize:s,align:o,rankdir:a="TB",ranksep:u,nodesep:c,ranksepFunc:f,nodesepFunc:l,edgeLabelSpace:h,ranker:g,nodeOrder:p,begin:v,controlPoints:m,radial:d,sortByCombo:y,preset:w}=i,b=new ue({tree:[]}),x=rt(u||50,f),M=rt(c||50,l);let N=M,E=x;(a==="LR"||a==="RL")&&(N=x,E=M);const O=yn(10,s,!1),_=e.getAllNodes(),S=e.getAllEdges();_.forEach(A=>{const C=Lt(O(A)),D=E(A),z=N(A),U=C[0]+2*z,L=C[1]+2*D,$=A.data.layer;V($)?b.addNode({id:A.id,data:{width:U,height:L,layer:$}}):b.addNode({id:A.id,data:{width:U,height:L}})}),y&&(b.attachTreeStructure("combo"),_.forEach(A=>{const{parentId:C}=A.data;C!==void 0&&b.hasNode(C)&&b.setParent(A.id,C,"combo")})),S.forEach(A=>{b.addEdge({id:A.id,source:A.source,target:A.target,data:{weight:A.data.weight||1}})});let q;w!=null&&w.length&&(q=new ue({nodes:w})),vy(b,{prevGraph:q,edgeLabelSpace:h,keepNodeOrder:!!p,nodeOrder:p||[],acyclicer:"greedy",ranker:g,rankdir:a,nodesep:c,align:o});const R=[0,0];if(v){let A=1/0,C=1/0;b.getAllNodes().forEach(D=>{A>D.data.x&&(A=D.data.x),C>D.data.y&&(C=D.data.y)}),b.getAllEdges().forEach(D=>{var z;(z=D.data.points)===null||z===void 0||z.forEach(U=>{A>U.x&&(A=U.x),C>U.y&&(C=U.y)})}),R[0]=v[0]-A,R[1]=v[1]-C}const T=a==="LR"||a==="RL";if(!d){const A=new Set,D=a==="BT"||a==="RL"?($,B)=>B-$:($,B)=>$-B;b.getAllNodes().forEach($=>{$.data.x=$.data.x+R[0],$.data.y=$.data.y+R[1],A.add(T?$.data.x:$.data.y)});const z=Array.from(A).sort(D),U=T?($,B)=>$.x!==B.x:($,B)=>$.y!==B.y,L=T?($,B,Z)=>{const G=Math.max(B.y,Z.y),le=Math.min(B.y,Z.y);return $.filter(_e=>_e.y<=G&&_e.y>=le)}:($,B,Z)=>{const G=Math.max(B.x,Z.x),le=Math.min(B.x,Z.x);return $.filter(_e=>_e.x<=G&&_e.x>=le)};b.getAllEdges().forEach(($,B)=>{var Z;h&&m&&$.data.type!=="loop"&&($.data.controlPoints=Fy((Z=$.data.points)===null||Z===void 0?void 0:Z.map(({x:G,y:le})=>({x:G+R[0],y:le+R[1]})),b.getNode($.source),b.getNode($.target),z,T,U,L))})}let I=[];I=b.getAllNodes().map(A=>ye(A));const k=b.getAllEdges();return t&&(I.forEach(A=>{e.mergeNodeData(A.id,{x:A.data.x,y:A.data.y})}),k.forEach(A=>{e.mergeEdgeData(A.id,{controlPoints:A.data.controlPoints})})),{nodes:I,edges:k}})}}const Fy=(n,t,e,r,i,s,o)=>{let a=(n==null?void 0:n.slice(1,n.length-1))||[];if(t&&e){let{x:u,y:c}=t.data,{x:f,y:l}=e.data;if(i&&(u=t.data.y,c=t.data.x,f=e.data.y,l=e.data.x),l!==c&&u!==f){const h=r.indexOf(c),g=r[h+1];if(g){const m=a[0],d=i?{x:(c+g)/2,y:(m==null?void 0:m.y)||f}:{x:(m==null?void 0:m.x)||f,y:(c+g)/2};(!m||s(m,d))&&a.unshift(d)}const p=r.indexOf(l),v=Math.abs(p-h);if(v===1)a=o(a,t.data,e.data),a.length||a.push(i?{x:(c+l)/2,y:u}:{x:u,y:(c+l)/2});else if(v>1){const m=r[p-1];if(m){const d=a[a.length-1],y=i?{x:(l+m)/2,y:(d==null?void 0:d.y)||f}:{x:(d==null?void 0:d.x)||u,y:(l+m)/2};(!d||s(d,y))&&a.push(y)}}}}return a},nt=(n,t,e)=>{const r=n.getAllNodes(),i=n.getAllEdges();if(!(r!=null&&r.length))return{nodes:[],edges:i};if(r.length===1)return t&&n.mergeNodeData(r[0].id,{x:e[0],y:e[1]}),{nodes:[Object.assign(Object.assign({},r[0]),{data:Object.assign(Object.assign({},r[0].data),{x:e[0],y:e[1]})})],edges:i}},By={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1};class Uy{constructor(t={}){this.options=t,this.id="circular",this.options=Object.assign(Object.assign({},By),t)}execute(t,e){return P(this,void 0,void 0,function*(){return this.genericCircularLayout(!1,t,e)})}assign(t,e){return P(this,void 0,void 0,function*(){yield this.genericCircularLayout(!0,t,e)})}genericCircularLayout(t,e,r){return P(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),r),{width:s,height:o,center:a,divisions:u,startAngle:c=0,endAngle:f=2*Math.PI,angleRatio:l,ordering:h,clockwise:g,nodeSpacing:p,nodeSize:v}=i,m=e.getAllNodes(),d=e.getAllEdges(),[y,w,b]=Vy(s,o,a),x=m==null?void 0:m.length;if(!x||x===1)return nt(e,t,b);const M=(f-c)/x;let{radius:N,startRadius:E,endRadius:O}=i;if(p){const T=rt(10,p),I=yn(10,v);let k=-1/0;m.forEach(A=>{const C=I(A);k{C===0?F+=k||10:F+=(T(A)||0)+(k||10)}),N=F/(2*Math.PI)}else!N&&!E&&!O?N=Math.min(w,y)/2:!E&&O?E=O:E&&!O&&(O=E);const _=M*l;let S=[];h==="topology"?S=nf(e,m):h==="topology-directed"?S=nf(e,m,!0):h==="degree"?S=Gy(e,m):S=m.map(T=>ye(T));const q=Math.ceil(x/u);for(let T=0;T{e.mergeNodeData(T.id,{x:T.data.x,y:T.data.y})}),{nodes:S,edges:d}})}}const nf=(n,t,e=!1)=>{const r=[ye(t[0])],i={},s=t.length;i[t[0].id]=!0;let o=0;return t.forEach((a,u)=>{if(u!==0)if((u===s-1||n.getDegree(a.id,"both")!==n.getDegree(t[u+1].id,"both")||n.areNeighbors(r[o].id,a.id))&&!i[a.id])r.push(ye(a)),i[a.id]=!0,o++;else{const c=e?n.getSuccessors(r[o].id):n.getNeighbors(r[o].id);let f=!1;for(let h=0;h{e.push(ye(r))}),e.sort((r,i)=>n.getDegree(r.id,"both")-n.getDegree(i.id,"both")),e}const Vy=(n,t,e)=>{let r=n,i=t,s=e;return!r&&typeof window!="undefined"&&(r=window.innerWidth),!i&&typeof window!="undefined"&&(i=window.innerHeight),s||(s=[r/2,i/2]),[r,i,s]},Wy={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:3/2*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"};class bn{constructor(t={}){this.options=t,this.id="concentric",this.options=Object.assign(Object.assign({},Wy),t)}execute(t,e){return P(this,void 0,void 0,function*(){return this.genericConcentricLayout(!1,t,e)})}assign(t,e){return P(this,void 0,void 0,function*(){yield this.genericConcentricLayout(!0,t,e)})}genericConcentricLayout(t,e,r){return P(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),r),{center:s,width:o,height:a,sortBy:u,maxLevelDiff:c,sweep:f,clockwise:l,equidistant:h,preventOverlap:g,startAngle:p=3/2*Math.PI,nodeSize:v,nodeSpacing:m}=i,d=e.getAllNodes(),y=e.getAllEdges(),w=!o&&typeof window!="undefined"?window.innerWidth:o,b=!a&&typeof window!="undefined"?window.innerHeight:a,x=s||[w/2,b/2];if(!(d!=null&&d.length)||d.length===1)return nt(e,t,x);const M=[];let N,E=0;ke(v)?N=Math.max(v[0],v[1]):Te(v)?(N=-1/0,d.forEach(A=>{const C=Math.max(...Lt(v(A)));C>N&&(N=C)})):N=v,ke(m)?E=Math.max(m[0],m[1]):V(m)&&(E=m),d.forEach(A=>{const C=ye(A);M.push(C);let D=N;const{data:z}=C;ke(z.size)?D=Math.max(z.size[0],z.size[1]):V(z.size)?D=z.size:pt(z.size)&&(D=Math.max(z.size.width,z.size.height)),N=Math.max(N,D),Te(m)&&(E=Math.max(m(A),E))});const O={};M.forEach((A,C)=>{O[A.id]=C});let _=u;(!Ct(_)||M[0].data[_]===void 0)&&(_="degree"),_==="degree"?M.sort((A,C)=>e.getDegree(C.id,"both")-e.getDegree(A.id,"both")):M.sort((A,C)=>C.data[_]-A.data[_]);const S=M[0],q=(c||(_==="degree"?e.getDegree(S.id,"both"):S.data[_]))/4,R=[{nodes:[]}];let T=R[0];M.forEach(A=>{if(T.nodes.length>0){const C=Math.abs(_==="degree"?e.getDegree(T.nodes[0].id,"both")-e.getDegree(A.id,"both"):T.nodes[0].data[_]-A.data[_]);q&&C>=q&&(T={nodes:[]},R.push(T))}T.nodes.push(A)});let I=N+E;if(!g){const A=R.length>0&&R[0].nodes.length>1,D=(Math.min(w,b)/2-I)/(R.length+(A?1:0));I=Math.min(I,D)}let k=0;if(R.forEach(A=>{const C=f===void 0?2*Math.PI-2*Math.PI/A.nodes.length:f;if(A.dTheta=C/Math.max(1,A.nodes.length-1),A.nodes.length>1&&g){const D=Math.cos(A.dTheta)-Math.cos(0),z=Math.sin(A.dTheta)-Math.sin(0),U=Math.sqrt(I*I/(D*D+z*z));k=Math.max(U,k)}A.r=k,k+=I}),h){let A=0,C=0;for(let D=0;D{z===0&&(C=D.r||0),D.r=C,C+=A})}return R.forEach(A=>{const C=A.dTheta||0,D=A.r||0;A.nodes.forEach((z,U)=>{const L=p+(l?1:-1)*C*U;z.data.x=x[0]+D*Math.cos(L),z.data.y=x[1]+D*Math.sin(L)})}),t&&M.forEach(A=>e.mergeNodeData(A.id,{x:A.data.x,y:A.data.y})),{nodes:M,edges:y}})}}function Yy(n){const t=+this._x.call(null,n),e=+this._y.call(null,n);return sf(this.cover(t,e),t,e,n)}function sf(n,t,e,r){if(isNaN(t)||isNaN(e))return n;var i,s=n._root,o={data:r},a=n._x0,u=n._y0,c=n._x1,f=n._y1,l,h,g,p,v,m,d,y;if(!s)return n._root=o,n;for(;s.length;)if((v=t>=(l=(a+c)/2))?a=l:c=l,(m=e>=(h=(u+f)/2))?u=h:f=h,i=s,!(s=s[d=m<<1|v]))return i[d]=o,n;if(g=+n._x.call(null,s.data),p=+n._y.call(null,s.data),t===g&&e===p)return o.next=s,i?i[d]=o:n._root=o,n;do i=i?i[d]=new Array(4):n._root=new Array(4),(v=t>=(l=(a+c)/2))?a=l:c=l,(m=e>=(h=(u+f)/2))?u=h:f=h;while((d=m<<1|v)===(y=(p>=h)<<1|g>=l));return i[y]=s,i[d]=o,n}function Ky(n){var t,e,r=n.length,i,s,o=new Array(r),a=new Array(r),u=1/0,c=1/0,f=-1/0,l=-1/0;for(e=0;ef&&(f=i),sl&&(l=s));if(u>f||c>l)return this;for(this.cover(u,c).cover(f,l),e=0;en||n>=i||r>t||t>=s;)switch(c=(tf||(a=p.y0)>l||(u=p.x1)=d)<<1|n>=m)&&(p=h[h.length-1],h[h.length-1]=h[h.length-1-v],h[h.length-1-v]=p)}else{var y=n-+this._x.call(null,g.data),w=t-+this._y.call(null,g.data),b=y*y+w*w;if(b=(h=(o+u)/2))?o=h:u=h,(v=l>=(g=(a+c)/2))?a=g:c=g,t=e,!(e=e[m=v<<1|p]))return this;if(!e.length)break;(t[m+1&3]||t[m+2&3]||t[m+3&3])&&(r=t,d=m)}for(;e.data!==n;)if(i=e,!(e=e.next))return this;return(s=e.next)&&delete e.next,i?(s?i.next=s:delete i.next,this):t?(s?t[m]=s:delete t[m],(e=t[0]||t[1]||t[2]||t[3])&&e===(t[3]||t[2]||t[1]||t[0])&&!e.length&&(r?r[d]=e:this._root=e),this):(this._root=s,this)}function ew(n){for(var t=0,e=n.length;t=(p=(u+l)/2))?u=p:l=p,(x=e>=(v=(c+h)/2))?c=v:h=v,(M=r>=(m=(f+g)/2))?f=m:g=m,s=o,!(o=o[N=M<<2|x<<1|b]))return s[N]=a,n;if(d=+n._x.call(null,o.data),y=+n._y.call(null,o.data),w=+n._z.call(null,o.data),t===d&&e===y&&r===w)return a.next=o,s?s[N]=a:n._root=a,n;do s=s?s[N]=new Array(8):n._root=new Array(8),(b=t>=(p=(u+l)/2))?u=p:l=p,(x=e>=(v=(c+h)/2))?c=v:h=v,(M=r>=(m=(f+g)/2))?f=m:g=m;while((N=M<<2|x<<1|b)===(E=(w>=m)<<2|(y>=v)<<1|d>=p));return s[E]=o,s[N]=a,n}function fw(n){Array.isArray(n)||(n=Array.from(n));const t=n.length,e=new Float64Array(t),r=new Float64Array(t),i=new Float64Array(t);let s=1/0,o=1/0,a=1/0,u=-1/0,c=-1/0,f=-1/0;for(let l=0,h,g,p,v;lu&&(u=g),pc&&(c=p),vf&&(f=v));if(s>u||o>c||a>f)return this;this.cover(s,o,a).cover(u,c,f);for(let l=0;ln||n>=o||i>t||t>=a||s>e||e>=u;)switch(h=(ep||(c=w.y0)>v||(f=w.z0)>m||(l=w.x1)=N)<<2|(t>=M)<<1|n>=x)&&(w=d[d.length-1],d[d.length-1]=d[d.length-1-b],d[d.length-1-b]=w)}else{var E=n-+this._x.call(null,y.data),O=t-+this._y.call(null,y.data),_=e-+this._z.call(null,y.data),S=E*E+O*O+_*_;if(SMath.sqrt(Ge(n-r,2)+Ge(t-i,2)+Ge(e-s,2));function vw(n,t,e,r){const i=[],s=n-r,o=t-r,a=e-r,u=n+r,c=t+r,f=e+r;return this.visit((l,h,g,p,v,m,d)=>{if(!l.length)do{const y=l.data;pw(n,t,e,this._x(y),this._y(y),this._z(y))<=r&&i.push(y)}while(l=l.next);return h>u||g>c||p>f||v=(v=(o+c)/2))?o=v:c=v,(w=g>=(m=(a+f)/2))?a=m:f=m,(b=p>=(d=(u+l)/2))?u=d:l=d,t=e,!(e=e[x=b<<2|w<<1|y]))return this;if(!e.length)break;(t[x+1&7]||t[x+2&7]||t[x+3&7]||t[x+4&7]||t[x+5&7]||t[x+6&7]||t[x+7&7])&&(r=t,M=x)}for(;e.data!==n;)if(i=e,!(e=e.next))return this;return(s=e.next)&&delete e.next,i?(s?i.next=s:delete i.next,this):t?(s?t[x]=s:delete t[x],(e=t[0]||t[1]||t[2]||t[3]||t[4]||t[5]||t[6]||t[7])&&e===(t[7]||t[6]||t[5]||t[4]||t[3]||t[2]||t[1]||t[0])&&!e.length&&(r?r[M]=e:this._root=e),this):(this._root=s,this)}function yw(n){for(var t=0,e=n.length;t{const{nodeStrength:h,x:g,y:p,z:v,size:m}=f.data;return{x:g,y:p,z:v,size:m,index:l,id:f.id,vx:0,vy:0,vz:0,weight:s*h}}),u=(i===2?mt(a,f=>f.x,f=>f.y):cr(a,f=>f.x,f=>f.y,f=>f.z)).visitAfter(Iw),c=new Map;return a.forEach(f=>{c.set(f.id,f),kw(f,u,i)}),a.map((f,l)=>{const{id:h,data:g}=o[l],{mass:p=1}=g;r[h]={x:f.vx/p,y:f.vy/p,z:f.vz/p}}),r}function Iw(n){let t=0,e=0,r=0,i=0,s=0;const o=n.length;if(o){for(let a=0;a{var a;if(((a=n.data)===null||a===void 0?void 0:a.id)===s.id)return;const u=[e,r,i][o-1],c=s.x-n.x||xn,f=s.y-n.y||xn,l=s.z-n.z||xn,h=[c,f,l],g=u-t;let p=0;for(let d=0;dTw(r,i,s,o,a,n,e))}const jw={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"};class cf{constructor(t={}){this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=Object.assign(Object.assign({},jw),t)}execute(t,e){return P(this,void 0,void 0,function*(){return this.genericForceLayout(!1,t,e)})}assign(t,e){return P(this,void 0,void 0,function*(){yield this.genericForceLayout(!0,t,e)})}stop(){this.timeInterval&&typeof window!="undefined"&&window.clearInterval(this.timeInterval),this.running=!1}tick(t=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let r=0;(this.judgingDistance>this.lastOptions.minMovement||r<1)&&rthis.lastGraph.mergeNodeData(r.id,{x:r.data.x,y:r.data.y,z:this.options.dimensions===3?r.data.z:void 0})),e}genericForceLayout(t,e,r){return P(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),r),s=e.getAllNodes(),o=e.getAllEdges(),a=this.formatOptions(i,e),{dimensions:u,width:c,height:f,nodeSize:l,getMass:h,nodeStrength:g,edgeStrength:p,linkDistance:v}=a,m=s.map((E,O)=>Object.assign(Object.assign({},E),{data:Object.assign(Object.assign({},E.data),{x:V(E.data.x)?E.data.x:Math.random()*c,y:V(E.data.y)?E.data.y:Math.random()*f,z:V(E.data.z)?E.data.z:Math.random()*Math.sqrt(c*f),size:l(E)||30,mass:h(E),nodeStrength:g(E)})})),d=o.map(E=>Object.assign(Object.assign({},E),{data:Object.assign(Object.assign({},E.data),{edgeStrength:p(E),linkDistance:v(E,e.getNode(E.source),e.getNode(E.target))})}));if(!(s!=null&&s.length))return this.lastResult={nodes:[],edges:o},{nodes:[],edges:o};const y={};s.forEach((E,O)=>{y[E.id]={x:0,y:0,z:0}});const w=new ue({nodes:m,edges:d});this.formatCentripetal(a,w);const{maxIteration:b,minMovement:x,onTick:M}=a;if(this.lastLayoutNodes=m,this.lastLayoutEdges=d,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=w,this.lastOptions=a,this.lastVelMap=y,typeof window=="undefined")return;let N=0;return new Promise(E=>{this.timeInterval=window.setInterval(()=>{(!s||!this.running)&&E({nodes:Nn(e,m),edges:o}),this.runOneStep(w,e,N,y,a),this.updatePosition(e,w,y,a),t&&m.forEach(O=>e.mergeNodeData(O.id,{x:O.data.x,y:O.data.y,z:u===3?O.data.z:void 0})),M==null||M({nodes:Nn(e,m),edges:o}),N++,(N>=b||this.judgingDistance{let c=1;V(u==null?void 0:u.data.mass)&&(c=u==null?void 0:u.data.mass);const f=e.getDegree(u.id,"both");return!f||f<5?c:f*5*c}),r.nodeSize=wn(t.nodeSize,t.nodeSpacing);const a=t.linkDistance?rt(1,t.linkDistance):u=>1+r.nodeSize(e.getNode(u.source))+r.nodeSize(e.getNode(u.target));return r.linkDistance=a,r.nodeStrength=rt(1,t.nodeStrength),r.edgeStrength=rt(1,t.edgeStrength),r}formatCentripetal(t,e){const{dimensions:r,centripetalOptions:i,center:s,clusterNodeStrength:o,leafCluster:a,clustering:u,nodeClusterBy:c}=t,f=e.getAllNodes(),l=i||{leaf:2,single:2,others:1,center:d=>({x:s[0],y:s[1],z:r===3?s[2]:void 0})};typeof o!="function"&&(t.clusterNodeStrength=d=>o);let h,g;if(a&&c&&(h=ff(e,c),g=Array.from(new Set(f==null?void 0:f.map(d=>d.data[c])))||[],t.centripetalOptions=Object.assign(l,{single:100,leaf:d=>{const{siblingLeaves:y,sameTypeLeaves:w}=h[d.id]||{};return(w==null?void 0:w.length)===(y==null?void 0:y.length)||(g==null?void 0:g.length)===1?1:t.clusterNodeStrength(d)},others:1,center:d=>{const y=e.getDegree(d.id,"both");if(!y)return{x:100,y:100,z:0};let w;if(y===1){const{sameTypeLeaves:b=[]}=h[d.id]||{};b.length===1?w=void 0:b.length>1&&(w=lf(b))}else w=void 0;return{x:w==null?void 0:w.x,y:w==null?void 0:w.y,z:w==null?void 0:w.z}}})),u&&c){h||(h=ff(e,c)),g||(g=Array.from(new Set(f.map(y=>y.data[c])))),g=g.filter(y=>y!==void 0);const d={};g.forEach(y=>{const w=f.filter(b=>b.data[c]===y).map(b=>e.getNode(b.id));d[y]=lf(w)}),t.centripetalOptions=Object.assign(l,{single:y=>t.clusterNodeStrength(y),leaf:y=>t.clusterNodeStrength(y),others:y=>t.clusterNodeStrength(y),center:y=>{const w=d[y.data[c]];return{x:w==null?void 0:w.x,y:w==null?void 0:w.y,z:w==null?void 0:w.z}}})}const{leaf:p,single:v,others:m}=t.centripetalOptions||{};p&&typeof p!="function"&&(t.centripetalOptions.leaf=()=>p),v&&typeof v!="function"&&(t.centripetalOptions.single=()=>v),m&&typeof m!="function"&&(t.centripetalOptions.others=()=>m)}runOneStep(t,e,r,i,s){const o={},a=t.getAllNodes(),u=t.getAllEdges();if(!(a!=null&&a.length))return;const{monitor:c}=s;if(this.calRepulsive(t,o,s),u&&this.calAttractive(t,o,s),this.calGravity(t,e,o,s),this.updateVelocity(t,o,i,s),c){const f=this.calTotalEnergy(o,a);c({energy:f,nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:r})}}calTotalEnergy(t,e){if(!(e!=null&&e.length))return 0;let r=0;return e.forEach((i,s)=>{const o=t[i.id].x,a=t[i.id].y,u=this.options.dimensions===3?t[i.id].z:0,c=o*o+a*a+u*u,{mass:f=1}=i.data;r+=f*c*.5}),r}calRepulsive(t,e,r){const{dimensions:i,factor:s,coulombDisScale:o}=r;Aw(t,s,o*o,e,i)}calAttractive(t,e,r){const{dimensions:i,nodeSize:s}=r;t.getAllEdges().forEach((o,a)=>{const{source:u,target:c}=o,f=t.getNode(u),l=t.getNode(c);if(!f||!l)return;let h=l.data.x-f.data.x,g=l.data.y-f.data.y,p=i===3?l.data.z-f.data.z:0;!h&&!g&&(h=Math.random()*.01,g=Math.random()*.01,i===3&&!p&&(p=Math.random()*.01));const v=Math.sqrt(h*h+g*g+p*p);if(v{const{id:v,data:m}=p,{mass:d,x:y,y:w,z:b}=m,x=e.getNode(v);let M=0,N=0,E=0,O=h;const _=t.getDegree(v,"in"),S=t.getDegree(v,"out"),q=t.getDegree(v,"both"),R=s==null?void 0:s(x,q);if(R){const[T,I,k]=R;M=y-T,N=w-I,O=k}else M=y-l[0],N=w-l[1],E=b-l[2];if(O&&(r[v].x-=O*M/d,r[v].y-=O*N/d,r[v].z-=O*E/d),g){const{leaf:T,single:I,others:k,center:F}=g,{x:A,y:C,z:D,centerStrength:z}=(F==null?void 0:F(x,a,u,c,f))||{x:0,y:0,z:0,centerStrength:0};if(!V(A)||!V(C))return;const U=(y-A)/d,L=(w-C)/d,$=(b-D)/d;if(z&&(r[v].x-=z*U,r[v].y-=z*L,r[v].z-=z*$),q===0){const Z=I(x);if(!Z)return;r[v].x-=Z*U,r[v].y-=Z*L,r[v].z-=Z*$;return}if(_===0||S===0){const Z=T(x,a,u);if(!Z)return;r[v].x-=Z*U,r[v].y-=Z*L,r[v].z-=Z*$;return}const B=k(x);if(!B)return;r[v].x-=B*U,r[v].y-=B*L,r[v].z-=B*$}})}updateVelocity(t,e,r,i){const{damping:s,maxSpeed:o,interval:a,dimensions:u}=i,c=t.getAllNodes();c!=null&&c.length&&c.forEach(f=>{const{id:l}=f;let h=(r[l].x+e[l].x*a)*s||.01,g=(r[l].y+e[l].y*a)*s||.01,p=u===3?(r[l].z+e[l].z*a)*s||.01:0;const v=Math.sqrt(h*h+g*g+p*p);if(v>o){const m=o/v;h=m*h,g=m*g,p=m*p}r[l]={x:h,y:g,z:p}})}updatePosition(t,e,r,i){const{distanceThresholdMode:s,interval:o,dimensions:a}=i,u=e.getAllNodes();if(!(u!=null&&u.length)){this.judgingDistance=0;return}let c=0;s==="max"?this.judgingDistance=-1/0:s==="min"&&(this.judgingDistance=1/0),u.forEach(f=>{const{id:l}=f,h=t.getNode(l);if(V(h.data.fx)&&V(h.data.fy)){e.mergeNodeData(l,{x:h.data.fx,y:h.data.fy,z:a===3?h.data.fz:void 0});return}const g=r[l].x*o,p=r[l].y*o,v=a===3?r[l].z*o:0;e.mergeNodeData(l,{x:f.data.x+g,y:f.data.y+p,z:f.data.z+v});const m=Math.sqrt(g*g+p*p+v*v);switch(s){case"max":this.judgingDistancem&&(this.judgingDistance=m);break;default:c=c+m;break}}),(!s||s==="mean")&&(this.judgingDistance=c/u.length)}}const ff=(n,t)=>{const e=n.getAllNodes();if(!(e!=null&&e.length))return{};const r={};return e.forEach((i,s)=>{n.getDegree(i.id,"both")===1&&(r[i.id]=Cw(n,"leaf",i,t))}),r},Cw=(n,t,e,r)=>{const i=n.getDegree(e.id,"in"),s=n.getDegree(e.id,"out");let o=e,a=[];i===0?(o=n.getSuccessors(e.id)[0],a=n.getNeighbors(o.id)):s===0&&(o=n.getPredecessors(e.id)[0],a=n.getNeighbors(o.id)),a=a.filter(c=>n.getDegree(c.id,"in")===0||n.getDegree(c.id,"out")===0);const u=Pw(n,t,r,e,a);return{coreNode:o,siblingLeaves:a,sameTypeLeaves:u}},Pw=(n,t,e,r,i)=>{const s=r.data[e]||"";let o=(i==null?void 0:i.filter(a=>a.data[e]===s))||[];return o=o.filter(a=>n.getDegree(a.id,"in")===0||n.getDegree(a.id,"out")===0),o},lf=n=>{const t={x:0,y:0};n.forEach(r=>{const{x:i,y:s}=r.data;t.x+=i||0,t.y+=s||0});const e=n.length||1;return{x:t.x/e,y:t.y/e}},Nn=(n,t)=>t.map(e=>{const{id:r,data:i}=e,s=n.getNode(r);return Object.assign(Object.assign({},s),{data:Object.assign(Object.assign({},s.data),{x:i.x,y:i.y,z:i.z})})});var fr=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Lw(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function hf(n){if(n.__esModule)return n;var t=n.default;if(typeof t=="function"){var e=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var i=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:function(){return n[r]}})}),e}var X={};const Dw=Object.prototype.toString;function Dt(n){const t=Dw.call(n);return t.endsWith("Array]")&&!t.includes("Big")}var zw=Object.freeze({__proto__:null,isAnyArray:Dt}),$w=hf(zw);function Fw(n){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Dt(n))throw new TypeError("input must be an array");if(n.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,i=t.toIndex,s=i===void 0?n.length:i;if(r<0||r>=n.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>n.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var o=n[r],a=r+1;ao&&(o=n[a]);return o}function Bw(n){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!Dt(n))throw new TypeError("input must be an array");if(n.length===0)throw new TypeError("input must not be empty");var e=t.fromIndex,r=e===void 0?0:e,i=t.toIndex,s=i===void 0?n.length:i;if(r<0||r>=n.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=r||s>n.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var o=n[r],a=r+1;a1&&arguments[1]!==void 0?arguments[1]:{};if(Dt(n)){if(n.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var e;if(t.output!==void 0){if(!Dt(t.output))throw new TypeError("output option must be an array if specified");e=t.output}else e=new Array(n.length);var r=Bw(n),i=Fw(n);if(r===i)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var s=t.min,o=s===void 0?t.autoMinMax?r:0:s,a=t.max,u=a===void 0?t.autoMinMax?i:1:a;if(o>=u)throw new RangeError("min option must be smaller than max option");for(var c=(u-o)/(i-r),f=0;f=0&&e?` ${vf(n,t-1)}`:vf(n,t)).padEnd(t)}function vf(n,t){let e=n.toString();if(e.length<=t)return e;let r=n.toFixed(t);if(r.length>t&&(r=n.toFixed(Math.max(0,t-(r.length-t)))),r.length<=t&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let i=n.toExponential(t);return i.length>t&&(i=n.toExponential(Math.max(0,t-(i.length-t)))),i.slice(0)}function Xw(n,t){n.prototype.add=function(r){return typeof r=="number"?this.addS(r):this.addM(r)},n.prototype.addS=function(r){for(let i=0;i>r);return this},n.prototype.signPropagatingRightShiftM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let i=0;i>r.get(i,s));return this},n.signPropagatingRightShift=function(r,i){return new t(r).signPropagatingRightShift(i)},n.prototype.rightShift=function(r){return typeof r=="number"?this.rightShiftS(r):this.rightShiftM(r)},n.prototype.rightShiftS=function(r){for(let i=0;i>>r);return this},n.prototype.rightShiftM=function(r){if(r=t.checkMatrix(r),this.rows!==r.rows||this.columns!==r.columns)throw new RangeError("Matrices dimensions must be equal");for(let i=0;i>>r.get(i,s));return this},n.rightShift=function(r,i){return new t(r).rightShift(i)},n.prototype.zeroFillRightShift=n.prototype.rightShift,n.prototype.zeroFillRightShiftS=n.prototype.rightShiftS,n.prototype.zeroFillRightShiftM=n.prototype.rightShiftM,n.zeroFillRightShift=n.rightShift,n.prototype.not=function(){for(let r=0;rr)throw new RangeError("Row index out of range")}function xe(n,t,e){let r=e?n.columns:n.columns-1;if(t<0||t>r)throw new RangeError("Column index out of range")}function yt(n,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==n.columns)throw new RangeError("vector size must be the same as the number of columns");return t}function wt(n,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==n.rows)throw new RangeError("vector size must be the same as the number of rows");return t}function Mn(n,t){if(!ge.isAnyArray(t))throw new TypeError("row indices must be an array");for(let e=0;e=n.rows)throw new RangeError("row indices are out of range")}function Sn(n,t){if(!ge.isAnyArray(t))throw new TypeError("column indices must be an array");for(let e=0;e=n.columns)throw new RangeError("column indices are out of range")}function Rn(n,t,e,r,i){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(dr("startRow",t),dr("endRow",e),dr("startColumn",r),dr("endColumn",i),t>e||r>i||t<0||t>=n.rows||e<0||e>=n.rows||r<0||r>=n.columns||i<0||i>=n.columns)throw new RangeError("Submatrix indices are out of range")}function hr(n,t=0){let e=[];for(let r=0;r=s)throw new RangeError("min must be smaller than max");let a=s-i,u=new j(t,e);for(let c=0;cr?(s=!0,r=e):(i=!1,s=!0);t++}return i}isReducedEchelonForm(){let t=0,e=0,r=-1,i=!0,s=!1;for(;tr?(s=!0,r=e):(i=!1,s=!0);for(let o=e+1;ot.get(i,r)&&(i=s);if(t.get(i,r)===0)r++;else{t.swapRows(e,i);let s=t.get(e,r);for(let o=r;o=0;)if(t.maxRow(i)===0)i--;else{let s=0,o=!1;for(;se[r]&&(e[r]=this.get(r,i));return e}case"column":{const e=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let r=0;re[i]&&(e[i]=this.get(r,i));return e}case void 0:{let e=this.get(0,0);for(let r=0;re&&(e=this.get(r,i));return e}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){bt(this);let t=this.get(0,0),e=[0,0];for(let r=0;rt&&(t=this.get(r,i),e[0]=r,e[1]=i);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const e=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let r=0;re&&(e=this.get(t,r));return e}maxRowIndex(t){Ee(this,t),bt(this);let e=this.get(t,0),r=[t,0];for(let i=1;ie&&(e=this.get(t,i),r[1]=i);return r}minRow(t){if(Ee(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;re&&(e=this.get(r,t));return e}maxColumnIndex(t){xe(this,t),bt(this);let e=this.get(0,t),r=[0,t];for(let i=1;ie&&(e=this.get(i,t),r[0]=i);return r}minColumn(t){if(xe(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r1;i/=2)i&1&&(e=e.mmul(r)),r=r.mmul(r);return e}strassen2x2(t){t=j.checkMatrix(t);let e=new j(2,2);const r=this.get(0,0),i=t.get(0,0),s=this.get(0,1),o=t.get(0,1),a=this.get(1,0),u=t.get(1,0),c=this.get(1,1),f=t.get(1,1),l=(r+c)*(i+f),h=(a+c)*i,g=r*(o-f),p=c*(u-i),v=(r+s)*f,m=(a-r)*(i+o),d=(s-c)*(u+f),y=l+p-v+d,w=g+v,b=h+p,x=l-h+g+m;return e.set(0,0,y),e.set(0,1,w),e.set(1,0,b),e.set(1,1,x),e}strassen3x3(t){t=j.checkMatrix(t);let e=new j(3,3);const r=this.get(0,0),i=this.get(0,1),s=this.get(0,2),o=this.get(1,0),a=this.get(1,1),u=this.get(1,2),c=this.get(2,0),f=this.get(2,1),l=this.get(2,2),h=t.get(0,0),g=t.get(0,1),p=t.get(0,2),v=t.get(1,0),m=t.get(1,1),d=t.get(1,2),y=t.get(2,0),w=t.get(2,1),b=t.get(2,2),x=(r+i+s-o-a-f-l)*m,M=(r-o)*(-g+m),N=a*(-h+g+v-m-d-y+b),E=(-r+o+a)*(h-g+m),O=(o+a)*(-h+g),_=r*h,S=(-r+c+f)*(h-p+d),q=(-r+c)*(p-d),R=(c+f)*(-h+p),T=(r+i+s-a-u-c-f)*d,I=f*(-h+p+v-m-d-y+w),k=(-s+f+l)*(m+y-w),F=(s-l)*(m-w),A=s*y,C=(f+l)*(-y+w),D=(-s+a+u)*(d+y-b),z=(s-u)*(d-b),U=(a+u)*(-y+b),L=i*v,$=u*w,B=o*p,Z=c*g,G=l*b,le=_+A+L,_e=x+E+O+_+k+A+C,nc=_+S+R+T+A+D+U,ic=M+N+E+_+A+D+z,sc=M+E+O+_+$,oc=A+D+z+U+B,ac=_+S+q+I+k+F+A,ee=k+F+A+C+Z,At=_+S+q+R+G;return e.set(0,0,le),e.set(0,1,_e),e.set(0,2,nc),e.set(1,0,ic),e.set(1,1,sc),e.set(1,2,oc),e.set(2,0,ac),e.set(2,1,ee),e.set(2,2,At),e}mmulStrassen(t){t=j.checkMatrix(t);let e=this.clone(),r=e.rows,i=e.columns,s=t.rows,o=t.columns;i!==s&&console.warn(`Multiplying ${r} x ${i} and ${s} x ${o} matrix: dimensions do not match.`);function a(l,h,g){let p=l.rows,v=l.columns;if(p===h&&v===g)return l;{let m=Y.zeros(h,g);return m=m.setSubMatrix(l,0,0),m}}let u=Math.max(r,s),c=Math.max(i,o);e=a(e,u,c),t=a(t,u,c);function f(l,h,g,p){if(g<=512||p<=512)return l.mmul(h);g%2===1&&p%2===1?(l=a(l,g+1,p+1),h=a(h,g+1,p+1)):g%2===1?(l=a(l,g+1,p),h=a(h,g+1,p)):p%2===1&&(l=a(l,g,p+1),h=a(h,g,p+1));let v=parseInt(l.rows/2,10),m=parseInt(l.columns/2,10),d=l.subMatrix(0,v-1,0,m-1),y=h.subMatrix(0,v-1,0,m-1),w=l.subMatrix(0,v-1,m,l.columns-1),b=h.subMatrix(0,v-1,m,h.columns-1),x=l.subMatrix(v,l.rows-1,0,m-1),M=h.subMatrix(v,h.rows-1,0,m-1),N=l.subMatrix(v,l.rows-1,m,l.columns-1),E=h.subMatrix(v,h.rows-1,m,h.columns-1),O=f(Y.add(d,N),Y.add(y,E),v,m),_=f(Y.add(x,N),y,v,m),S=f(d,Y.sub(b,E),v,m),q=f(N,Y.sub(M,y),v,m),R=f(Y.add(d,w),E,v,m),T=f(Y.sub(x,d),Y.add(y,b),v,m),I=f(Y.sub(w,N),Y.add(M,E),v,m),k=Y.add(O,q);k.sub(R),k.add(I);let F=Y.add(S,R),A=Y.add(_,q),C=Y.sub(O,_);C.add(S),C.add(T);let D=Y.zeros(2*k.rows,2*k.columns);return D=D.setSubMatrix(k,0,0),D=D.setSubMatrix(F,k.rows,0),D=D.setSubMatrix(A,0,k.columns),D=D.setSubMatrix(C,k.rows,k.columns),D.subMatrix(0,g-1,0,p-1)}return f(e,t,u,c)}scaleRows(t={}){if(typeof t!="object")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 i=new j(this.rows,this.columns);for(let s=0;s0&&df(o,{min:e,max:r,output:o}),i.setRow(s,o)}return i}scaleColumns(t={}){if(typeof t!="object")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 i=new j(this.rows,this.columns);for(let s=0;sr||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let i=new j(t.length,r-e+1);for(let s=0;s=this.rows)throw new RangeError(`Row index out of range: ${t[s]}`);i.set(s,o-e,this.get(t[s],o))}return i}subMatrixColumn(t,e,r){if(e===void 0&&(e=0),r===void 0&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let i=new j(r-e+1,t.length);for(let s=0;s=this.columns)throw new RangeError(`Column index out of range: ${t[s]}`);i.set(o-e,s,this.get(o,t[s]))}return i}setSubMatrix(t,e,r){if(t=j.checkMatrix(t),t.isEmpty())return this;let i=e+t.rows-1,s=r+t.columns-1;Rn(this,e,i,r,s);for(let o=0;otypeof t=="number")}Y.random=Y.rand,Y.randomInt=Y.randInt,Y.diagonal=Y.diag,Y.prototype.diagonal=Y.prototype.diag,Y.identity=Y.eye,Y.prototype.negate=Y.prototype.neg,Y.prototype.tensorProduct=Y.prototype.kroneckerProduct;let j=(ht=class extends Y{constructor(e,r){super();lc(this,er);ne(this,"data");if(ht.isMatrix(e))hc(this,er,dc).call(this,e.rows,e.columns),ht.copy(e,this);else if(Number.isInteger(e)&&e>=0)hc(this,er,dc).call(this,e,r);else if(ge.isAnyArray(e)){const i=e;if(e=i.length,r=e?i[0].length:0,typeof r!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let s=0;s=0)for(let i=0;i=0)tn(this,fe,new j(e,e));else if(tn(this,fe,new j(e)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return Oe(this,fe).size}get rows(){return Oe(this,fe).rows}get columns(){return Oe(this,fe).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(e){return j.isMatrix(e)&&e.klassType==="SymmetricMatrix"}static zeros(e){return new this(e)}static ones(e){return new this(e).fill(1)}clone(){const e=new Jr(this.diagonalSize);for(const[r,i,s]of this.upperRightEntries())e.set(r,i,s);return e}toMatrix(){return new j(this)}get(e,r){return Oe(this,fe).get(e,r)}set(e,r,i){return Oe(this,fe).set(e,r,i),Oe(this,fe).set(r,e,i),this}removeCross(e){return Oe(this,fe).removeRow(e),Oe(this,fe).removeColumn(e),this}addCross(e,r){r===void 0&&(r=e,e=this.diagonalSize);const i=r.slice();return i.splice(e,1),Oe(this,fe).addRow(e,i),Oe(this,fe).addColumn(e,r),this}applyMask(e){if(e.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const r=[];for(const[i,s]of e.entries())s||r.push(i);r.reverse();for(const i of r)this.removeCross(i);return this}toCompact(){const{diagonalSize:e}=this,r=new Array(e*(e+1)/2);for(let i=0,s=0,o=0;o=e&&(i=++s);return r}static fromCompact(e){const r=e.length,i=(Math.sqrt(8*r+1)-1)/2;if(!Number.isInteger(i))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(e)}`);const s=new Jr(i);for(let o=0,a=0,u=0;u=i&&(o=++a);return s}*upperRightEntries(){for(let e=0,r=0;e=this.diagonalSize&&(r=++e)}}*upperRightValues(){for(let e=0,r=0;e=this.diagonalSize&&(r=++e)}};fe=new WeakMap;let it=Jr;it.prototype.klassType="SymmetricMatrix";class gr extends it{static isDistanceMatrix(t){return it.isSymmetricMatrix(t)&&t.klassSubType==="DistanceMatrix"}constructor(t){if(super(t),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(t,e,r){return t===e&&(r=0),super.set(t,e,r)}addCross(t,e){return e===void 0&&(e=t,t=this.diagonalSize),e=e.slice(),e[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new it(this)}clone(){const t=new gr(this.diagonalSize);for(const[e,r,i]of this.upperRightEntries())e!==r&&t.set(e,r,i);return t}toCompact(){const{diagonalSize:t}=this,e=(t-1)*t/2,r=new Array(e);for(let i=1,s=0,o=0;o=t&&(i=++s+1);return r}static fromCompact(t){const e=t.length;if(e===0)return new this(0);const r=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(r))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);const i=new this(r);for(let s=1,o=0,a=0;a=r&&(s=++o+1);return i}}gr.prototype.klassSubType="DistanceMatrix";class je extends Y{constructor(t,e,r){super(),this.matrix=t,this.rows=e,this.columns=r}}class p1 extends je{constructor(t,e){xe(t,e),super(t,t.rows,1),this.column=e}set(t,e,r){return this.matrix.set(t,this.column,r),this}get(t){return this.matrix.get(t,this.column)}}class v1 extends je{constructor(t,e){Sn(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,r){return this.matrix.set(t,this.columnIndices[e],r),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}}class m1 extends je{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(t,this.columns-e-1,r),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}}class y1 extends je{constructor(t){super(t,t.rows,t.columns)}set(t,e,r){return this.matrix.set(this.rows-t-1,e,r),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}}class w1 extends je{constructor(t,e){Ee(t,e),super(t,1,t.columns),this.row=e}set(t,e,r){return this.matrix.set(this.row,e,r),this}get(t,e){return this.matrix.get(this.row,e)}}class b1 extends je{constructor(t,e){Mn(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,r){return this.matrix.set(this.rowIndices[t],e,r),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}}class pr extends je{constructor(t,e,r){Mn(t,e),Sn(t,r),super(t,e.length,r.length),this.rowIndices=e,this.columnIndices=r}set(t,e,r){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],r),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class _1 extends je{constructor(t,e,r,i,s){Rn(t,e,r,i,s),super(t,r-e+1,s-i+1),this.startRow=e,this.startColumn=i}set(t,e,r){return this.matrix.set(this.startRow+t,this.startColumn+e,r),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}}class E1 extends je{constructor(t){super(t,t.columns,t.rows)}set(t,e,r){return this.matrix.set(e,t,r),this}get(t,e){return this.matrix.get(e,t)}}class yf extends Y{constructor(t,e={}){const{rows:r=1}=e;if(t.length%r!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=r,this.columns=t.length/r,this.data=t}set(t,e,r){let i=this._calculateIndex(t,e);return this.data[i]=r,this}get(t,e){let r=this._calculateIndex(t,e);return this.data[r]}_calculateIndex(t,e){return t*this.columns+e}}class we extends Y{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 x1(n,t){if(ge.isAnyArray(n))return n[0]&&ge.isAnyArray(n[0])?new we(n):new yf(n,t);throw new Error("the argument is not an array")}class vr{constructor(t){t=we.checkMatrix(t);let e=t.clone(),r=e.rows,i=e.columns,s=new Float64Array(r),o=1,a,u,c,f,l,h,g,p,v;for(a=0;aMath.abs(p[f])&&(f=a);if(f!==u){for(c=0;c=0;c--){for(u=0;uo?i.set(s,o,t.get(s,o)):s===o?i.set(s,o,1):i.set(s,o,0);return i}get upperTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,i=new j(e,r);for(let s=0;sMath.abs(t)?(e=t/n,Math.abs(n)*Math.sqrt(1+e*e)):t!==0?(e=n/t,Math.abs(t)*Math.sqrt(1+e*e)):0}class qn{constructor(t){t=we.checkMatrix(t);let e=t.clone(),r=t.rows,i=t.columns,s=new Float64Array(i),o,a,u,c;for(u=0;u=0;c--){for(u=0;u=0;a--){for(s=0;s=0;_--)if(p[_]!==0){for(let S=_+1;S=0;_--){if(_0;){let _,S;for(_=N-2;_>=-1&&_!==-1;_--){const q=Number.MIN_VALUE+O*Math.abs(p[_]+Math.abs(p[_+1]));if(Math.abs(d[_])<=q||Number.isNaN(d[_])){d[_]=0;break}}if(_===N-2)S=4;else{let q;for(q=N-1;q>=_&&q!==_;q--){let R=(q!==N?Math.abs(d[q]):0)+(q!==_+1?Math.abs(d[q-1]):0);if(Math.abs(p[q])<=O*R){p[q]=0;break}}q===_?S=3:q===N-1?S=1:(S=2,_=q)}switch(_++,S){case 1:{let q=d[N-2];d[N-2]=0;for(let R=N-2;R>=_;R--){let T=Ce(p[R],q),I=p[R]/T,k=q/T;if(p[R]=T,R!==_&&(q=-k*d[R-1],d[R-1]=I*d[R-1]),c)for(let F=0;F=p[_+1]);){let q=p[_];if(p[_]=p[_+1],p[_+1]=q,c&&_e&&s.set(f,l,t.get(f,l)/this.s[l]);let o=this.U,a=o.rows,u=o.columns,c=new j(r,a);for(let f=0;ft&&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 j.diag(this.s)}};function N1(n,t=!1){return n=we.checkMatrix(n),t?new _t(n).inverse():wf(n,j.eye(n.rows))}function wf(n,t,e=!1){return n=we.checkMatrix(n),t=we.checkMatrix(t),e?new _t(n).solve(t):n.isSquare()?new vr(n).solve(t):new qn(n).solve(t)}function mr(n){if(n=j.checkMatrix(n),n.isSquare()){if(n.columns===0)return 1;let t,e,r,i;if(n.columns===2)return t=n.get(0,0),e=n.get(0,1),r=n.get(1,0),i=n.get(1,1),t*i-e*r;if(n.columns===3){let s,o,a;return s=new pr(n,[1,2],[1,2]),o=new pr(n,[1,2],[0,2]),a=new pr(n,[1,2],[0,1]),t=n.get(0,0),e=n.get(0,1),r=n.get(0,2),t*mr(s)-e*mr(o)+r*mr(a)}else return new vr(n).determinant}else throw Error("determinant can only be calculated for a square matrix")}function M1(n,t){let e=[];for(let r=0;ri)return new Array(t.rows+1).fill(0);{let s=t.addRow(e,[0]);for(let o=0;ot?s[o]=1/s[o]:s[o]=0;return i.mmul(j.diag(s).mmul(r.transpose()))}function O1(n,t=n,e={}){n=new j(n);let r=!1;if(typeof t=="object"&&!j.isMatrix(t)&&!ge.isAnyArray(t)?(e=t,t=n,r=!0):t=new j(t),n.rows!==t.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0}=e;i&&(n=n.center("column"),r||(t=t.center("column")));const s=n.transpose().mmul(t);for(let o=0;o0?i.set(s,s+1,e[s]):e[s]<0&&i.set(s,s-1,e[s])}return i}}function I1(n,t,e,r){let i,s,o,a,u,c,f,l;for(u=0;u0;a--){for(l=0,o=0,c=0;c0&&(s=-s),t[a]=l*s,o=o-i*s,e[a-1]=i-s,u=0;uc)do{for(i=e[c],l=(e[c+1]-i)/(2*t[c]),h=Ce(l,1),l<0&&(h=-h),e[c]=t[c]/(l+h),e[c+1]=t[c]*(l+h),g=e[c+1],s=i-e[c],o=c+2;o=c;o--)for(m=v,v=p,w=y,i=p*t[o],s=p*l,h=Ce(l,t[o]),t[o+1]=y*h,y=t[o]/h,p=l/h,l=p*e[o]-y*i,e[o+1]=s+y*(p*i+y*e[o]),u=0;uM*x);e[c]=e[c]+b,t[c]=0}for(o=0;o=l;c--)e[c]=t.get(c,l-1)/h,u+=e[c]*e[c];for(a=Math.sqrt(u),e[l]>0&&(a=-a),u=u-e[l]*a,e[l]=e[l]-a,f=l;f=l;c--)o+=e[c]*t.get(c,f);for(o=o/u,c=l;c<=s;c++)t.set(c,f,t.get(c,f)-o*e[c])}for(c=0;c<=s;c++){for(o=0,f=s;f>=l;f--)o+=e[f]*t.get(c,f);for(o=o/u,f=l;f<=s;f++)t.set(c,f,t.get(c,f)-o*e[f])}e[l]=h*e[l],t.set(l,l-1,h*a)}}for(c=0;c=i+1;l--)if(t.get(l,l-1)!==0){for(c=l+1;c<=s;c++)e[c]=t.get(c,l-1);for(f=l;f<=s;f++){for(a=0,c=l;c<=s;c++)a+=e[c]*r.get(c,f);for(a=a/e[l]/t.get(l,l-1),c=l;c<=s;c++)r.set(c,f,r.get(c,f)+a*e[c])}}}function j1(n,t,e,r,i){let s=n-1,o=0,a=n-1,u=Number.EPSILON,c=0,f=0,l=0,h=0,g=0,p=0,v=0,m=0,d,y,w,b,x,M,N,E,O,_,S,q,R,T,I;for(d=0;da)&&(e[d]=i.get(d,d),t[d]=0),y=Math.max(d-1,0);y=o;){for(b=s;b>o&&(p=Math.abs(i.get(b-1,b-1))+Math.abs(i.get(b,b)),p===0&&(p=f),!(Math.abs(i.get(b,b-1))=0){for(v=l>=0?l+v:l-v,e[s-1]=E+v,e[s]=e[s-1],v!==0&&(e[s]=E-N/v),t[s-1]=0,t[s]=0,E=i.get(s,s-1),p=Math.abs(E)+Math.abs(v),l=E/p,h=v/p,g=Math.sqrt(l*l+h*h),l=l/g,h=h/g,y=s-1;y0)){for(p=Math.sqrt(p),O=b&&(v=i.get(x,x),g=E-v,p=O-v,l=(g*p-N)/i.get(x+1,x)+i.get(x,x+1),h=i.get(x+1,x+1)-v-g-p,g=i.get(x+2,x+1),p=Math.abs(l)+Math.abs(h)+Math.abs(g),l=l/p,h=h/p,g=g/p,!(x===b||Math.abs(i.get(x,x-1))*(Math.abs(h)+Math.abs(g))x+2&&i.set(d,d-3,0);for(w=x;w<=s-1&&(T=w!==s-1,w!==x&&(l=i.get(w,w-1),h=i.get(w+1,w-1),g=T?i.get(w+2,w-1):0,E=Math.abs(l)+Math.abs(h)+Math.abs(g),E!==0&&(l=l/E,h=h/E,g=g/E)),E!==0);w++)if(p=Math.sqrt(l*l+h*h+g*g),l<0&&(p=-p),p!==0){for(w!==x?i.set(w,w-1,-p*E):b!==x&&i.set(w,w-1,-i.get(w,w-1)),l=l+p,E=l/p,O=h/p,v=g/p,h=h/l,g=g/l,y=w;y=0;s--)if(l=e[s],h=t[s],h===0)for(b=s,i.set(s,s,1),d=s-1;d>=0;d--){for(N=i.get(d,d)-l,g=0,y=b;y<=s;y++)g=g+i.get(d,y)*i.get(y,s);if(t[d]<0)v=N,p=g;else if(b=d,t[d]===0?i.set(d,s,N!==0?-g/N:-g/(u*f)):(E=i.get(d,d+1),O=i.get(d+1,d),h=(e[d]-l)*(e[d]-l)+t[d]*t[d],M=(E*p-v*g)/h,i.set(d,s,M),i.set(d+1,s,Math.abs(E)>Math.abs(v)?(-g-N*M)/E:(-p-O*M)/v)),M=Math.abs(i.get(d,s)),u*M*M>1)for(y=d;y<=s;y++)i.set(y,s,i.get(y,s)/M)}else if(h<0)for(b=s-1,Math.abs(i.get(s,s-1))>Math.abs(i.get(s-1,s))?(i.set(s-1,s-1,h/i.get(s,s-1)),i.set(s-1,s,-(i.get(s,s)-l)/i.get(s,s-1))):(I=yr(0,-i.get(s-1,s),i.get(s-1,s-1)-l,h),i.set(s-1,s-1,I[0]),i.set(s-1,s,I[1])),i.set(s,s-1,0),i.set(s,s,1),d=s-2;d>=0;d--){for(_=0,S=0,y=b;y<=s;y++)_=_+i.get(d,y)*i.get(y,s-1),S=S+i.get(d,y)*i.get(y,s);if(N=i.get(d,d)-l,t[d]<0)v=N,g=_,p=S;else if(b=d,t[d]===0?(I=yr(-_,-S,N,h),i.set(d,s-1,I[0]),i.set(d,s,I[1])):(E=i.get(d,d+1),O=i.get(d+1,d),q=(e[d]-l)*(e[d]-l)+t[d]*t[d]-h*h,R=(e[d]-l)*2*h,q===0&&R===0&&(q=u*f*(Math.abs(N)+Math.abs(h)+Math.abs(E)+Math.abs(O)+Math.abs(v))),I=yr(E*g-v*_+h*S,E*p-v*S-h*_,q,R),i.set(d,s-1,I[0]),i.set(d,s,I[1]),Math.abs(E)>Math.abs(v)+Math.abs(h)?(i.set(d+1,s-1,(-_-N*i.get(d,s-1)+h*i.get(d,s))/E),i.set(d+1,s,(-S-N*i.get(d,s)-h*i.get(d,s-1))/E)):(I=yr(-g-O*i.get(d,s-1),-p-O*i.get(d,s),v,h),i.set(d+1,s-1,I[0]),i.set(d+1,s,I[1]))),M=Math.max(Math.abs(i.get(d,s-1)),Math.abs(i.get(d,s))),u*M*M>1)for(y=d;y<=s;y++)i.set(y,s-1,i.get(y,s-1)/M),i.set(y,s,i.get(y,s)/M)}for(d=0;da)for(y=d;y=o;y--)for(d=o;d<=a;d++){for(v=0,w=o;w<=Math.min(y,a);w++)v=v+r.get(d,w)*i.get(w,y);r.set(d,y,v)}}}function yr(n,t,e,r){let i,s;return Math.abs(e)>Math.abs(r)?(i=r/e,s=e+i*r,[(n+i*t)/s,(t-i*n)/s]):(i=e/r,s=r+i*e,[(i*n+t)/s,(i*t-n)/s])}class _f{constructor(t){if(t=we.checkMatrix(t),!t.isSymmetric())throw new Error("Matrix is not symmetric");let e=t,r=e.rows,i=new j(r,r),s=!0,o,a,u;for(a=0;a0),i.set(a,a,Math.sqrt(Math.max(c,0))),u=a+1;u=0;u--)for(a=0;ao;g++)l=t.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),l=l.div(l.norm()),c=t.mmul(l).div(l.transpose().mmul(l).get(0,0)),g>0&&(u=c.clone().sub(h).pow(2).sum()),h=c.clone(),r?(f=r.transpose().mmul(c).div(c.transpose().mmul(c).get(0,0)),f=f.div(f.norm()),a=r.mmul(f).div(f.transpose().mmul(f).get(0,0))):a=c;if(r){let g=t.transpose().mmul(c).div(c.transpose().mmul(c).get(0,0));g=g.div(g.norm());let p=t.clone().sub(c.clone().mmul(g.transpose())),v=a.transpose().mmul(c).div(c.transpose().mmul(c).get(0,0)),m=r.clone().sub(c.clone().mulS(v.get(0,0)).mmul(f.transpose()));this.t=c,this.p=g.transpose(),this.w=l.transpose(),this.q=f,this.u=a,this.s=c.transpose().mmul(c),this.xResidual=p,this.yResidual=m,this.betas=v}else this.w=l.transpose(),this.s=c.transpose().mmul(c).sqrt(),i?this.t=c.clone().div(this.s.get(0,0)):this.t=c,this.xResidual=t.sub(c.mmul(l.transpose()))}}X.AbstractMatrix=Y,X.CHO=_f,X.CholeskyDecomposition=_f,X.DistanceMatrix=gr,X.EVD=bf,X.EigenvalueDecomposition=bf,X.LU=vr,X.LuDecomposition=vr;var xf=X.Matrix=j;X.MatrixColumnSelectionView=v1,X.MatrixColumnView=p1,X.MatrixFlipColumnView=m1,X.MatrixFlipRowView=y1,X.MatrixRowSelectionView=b1,X.MatrixRowView=w1,X.MatrixSelectionView=pr,X.MatrixSubView=_1,X.MatrixTransposeView=E1,X.NIPALS=Ef,X.Nipals=Ef,X.QR=qn,X.QrDecomposition=qn,X.SVD=_t;var C1=X.SingularValueDecomposition=_t;X.SymmetricMatrix=it,X.WrapperMatrix1D=yf,X.WrapperMatrix2D=we,X.correlation=A1,X.covariance=O1;var Nf=X.default=j;X.determinant=mr,X.inverse=N1,X.linearDependencies=R1,X.pseudoInverse=q1,X.solve=wf,X.wrap=x1;const We=xf,Mf=C1;Nf.Matrix&&Nf.Matrix;const P1={center:[0,0],linkDistance:50};class Sf{constructor(t={}){this.options=t,this.id="mds",this.options=Object.assign(Object.assign({},P1),t)}execute(t,e){return P(this,void 0,void 0,function*(){return this.genericMDSLayout(!1,t,e)})}assign(t,e){return P(this,void 0,void 0,function*(){yield this.genericMDSLayout(!0,t,e)})}genericMDSLayout(t,e,r){return P(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),r),{center:s=[0,0],linkDistance:o=50}=i,a=e.getAllNodes(),u=e.getAllEdges();if(!(a!=null&&a.length)||a.length===1)return nt(e,t,s);const c=tf({nodes:a,edges:u}),f=ef(c);L1(f);const l=Ly(f,o),h=D1(l),g=[];return h.forEach((v,m)=>{const d=ye(a[m]);d.data.x=v[0]+s[0],d.data.y=v[1]+s[1],g.push(d)}),t&&g.forEach(v=>e.mergeNodeData(v.id,{x:v.data.x,y:v.data.y})),{nodes:g,edges:u}})}}const L1=n=>{let t=-999999;n.forEach(e=>{e.forEach(r=>{r!==1/0&&t{e.forEach((i,s)=>{i===1/0&&(n[r][s]=t)})})},D1=n=>{const e=We.mul(We.pow(n,2),-.5),r=e.mean("row"),i=e.mean("column"),s=e.mean();e.add(s).subRowVector(r).subColumnVector(i);const o=new Mf(e),a=We.sqrt(o.diagonalMatrix).diagonal();return o.leftSingularVectors.toJSON().map(u=>We.mul([u],[a]).toJSON()[0].splice(0,2))};function Rf(n){return!!n.tick&&!!n.stop}const z1={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},$1={center:[0,0],comboPadding:10,treeKey:"combo"};class F1{constructor(t={}){this.options=t,this.id="comboCombined",this.options=Object.assign(Object.assign({},$1),t)}execute(t,e){return P(this,void 0,void 0,function*(){return this.genericComboCombinedLayout(!1,t,e)})}assign(t,e){return P(this,void 0,void 0,function*(){yield this.genericComboCombinedLayout(!0,t,e)})}genericComboCombinedLayout(t,e,r){return P(this,void 0,void 0,function*(){const i=this.initVals(Object.assign(Object.assign({},this.options),r)),{center:s,treeKey:o,outerLayout:a}=i,u=e.getAllNodes().filter(E=>!E.data._isCombo),c=e.getAllNodes().filter(E=>E.data._isCombo),f=e.getAllEdges(),l=u==null?void 0:u.length;if(!l||l===1)return nt(e,t,s);const h=[],g=new Map;u.forEach(E=>{g.set(E.id,E)});const p=new Map;c.forEach(E=>{p.set(E.id,E)});const v=new Map,m=this.getInnerGraphs(e,o,g,p,f,i,v);yield Promise.all(m);const d=new Map,y=[],w=new Map;let b=!0;e.getRoots(o).forEach(E=>{const O=v.get(E.id),_=p.get(E.id)||g.get(E.id),S={id:E.id,data:Object.assign(Object.assign({},E.data),{x:O.data.x||_.data.x,y:O.data.y||_.data.y,fx:O.data.fx||_.data.fx,fy:O.data.fy||_.data.fy,mass:O.data.mass||_.data.mass,size:O.data.size})};y.push(S),d.set(E.id,!0),!isNaN(S.data.x)&&S.data.x!==0&&!isNaN(S.data.y)&&S.data.y!==0?b=!1:(S.data.x=Math.random()*100,S.data.y=Math.random()*100),vn(e,[E],q=>{q.id!==E.id&&w.set(q.id,E.id)},"TB",o)});const x=[];f.forEach(E=>{const O=w.get(E.source)||E.source,_=w.get(E.target)||E.target;O!==_&&d.has(O)&&d.has(_)&&x.push({id:E.id,source:O,target:_,data:{}})});let M;if(y!=null&&y.length){if(y.length===1)y[0].data.x=s[0],y[0].data.y=s[1];else{const E=new ue({nodes:y,edges:x}),O=a||new cf;b&&z1[O.id]&&(yield(y.length<100?new Sf:new bn).assign(E));const _=Object.assign({center:s,kg:5,preventOverlap:!0,animate:!1},O.id==="force"?{gravity:1,factor:4,linkDistance:(S,q,R)=>{const T=Math.max(...q.data.size)||32,I=Math.max(...R.data.size)||32;return T/2+I/2+200}}:{});M=yield qf(O,E,_)}v.forEach(E=>{var O;const _=M.nodes.find(R=>R.id===E.id);if(_){const{x:R,y:T}=_.data;E.data.visited=!0,E.data.x=R,E.data.y=T,h.push({id:E.id,data:{x:R,y:T}})}const{x:S,y:q}=E.data;(O=E.data.nodes)===null||O===void 0||O.forEach(R=>{h.push({id:R.id,data:{x:R.data.x+S,y:R.data.y+q}})})}),v.forEach(({data:E})=>{const{x:O,y:_,visited:S,nodes:q}=E;q==null||q.forEach(R=>{if(!S){const T=h.find(I=>I.id===R.id);T.data.x+=O||0,T.data.y+=_||0}})})}return t&&h.forEach(E=>{e.mergeNodeData(E.id,{x:E.data.x,y:E.data.y})}),{nodes:h,edges:f}})}initVals(t){const e=Object.assign({},t),{nodeSize:r,spacing:i,comboPadding:s}=t;let o,a;if(V(i)?a=()=>i:Te(i)?a=i:a=()=>0,e.spacing=a,!r)o=c=>{const f=a(c);return c.size?ke(c.size)?((c.size[0]>c.size[1]?c.size[0]:c.size[1])+f)/2:pt(c.size)?((c.size.width>c.size.height?c.size.width:c.size.height)+f)/2:(c.size+f)/2:32+f/2};else if(Te(r))o=c=>{const f=r(c),l=a(c);return ke(c.size)?((c.size[0]>c.size[1]?c.size[0]:c.size[1])+l)/2:((f||32)+l)/2};else if(ke(r)){const f=(r[0]>r[1]?r[0]:r[1])/2;o=l=>f+a(l)/2}else{const c=r/2;o=f=>c+a(f)/2}e.nodeSize=o;let u;return V(s)?u=()=>s:ke(s)?u=()=>Math.max.apply(null,s):Te(s)?u=s:u=()=>0,e.comboPadding=u,e}getInnerGraphs(t,e,r,i,s,o,a){const{nodeSize:u,comboPadding:c,spacing:f,innerLayout:l}=o,h=l||new bn({}),g={center:[0,0],preventOverlap:!0,nodeSpacing:f},p=[],v=m=>{let d=(c==null?void 0:c(m))||10;return ke(d)&&(d=Math.max(...d)),{size:d?[d*2,d*2]:[30,30],padding:d}};return t.getRoots(e).forEach(m=>{a.set(m.id,{id:m.id,data:{nodes:[],size:v(m).size}});let d=Promise.resolve();vn(t,[m],y=>{var w;if(!y.data._isCombo)return;const{size:b,padding:x}=v(y);if(!(!((w=t.getChildren(y.id,e))===null||w===void 0)&&w.length))a.set(y.id,{id:y.id,data:Object.assign(Object.assign({},y.data),{size:b})});else{const M=a.get(y.id);a.set(y.id,{id:y.id,data:Object.assign({nodes:[]},M==null?void 0:M.data)});const N=new Map,E=t.getChildren(y.id,e).map(S=>{if(S.data._isCombo)return a.has(S.id)||a.set(S.id,{id:S.id,data:Object.assign({},S.data)}),N.set(S.id,!0),a.get(S.id);const q=r.get(S.id)||i.get(S.id);return N.set(S.id,!0),{id:S.id,data:Object.assign(Object.assign({},q.data),S.data)}}),O={nodes:E,edges:s.filter(S=>N.has(S.source)&&N.has(S.target))};let _=1/0;E.forEach(S=>{var q;let{size:R}=S.data;R||(R=((q=a.get(S.id))===null||q===void 0?void 0:q.data.size)||(u==null?void 0:u(S))||[30,30]),V(R)&&(R=[R,R]);const[T,I]=R;_>T&&(_=T),_>I&&(_=I),S.data.size=R}),d=d.then(()=>P(this,void 0,void 0,function*(){const S=new ue(O);yield qf(h,S,g,!0);const{minX:q,minY:R,maxX:T,maxY:I}=Dy(E),k={x:(T+q)/2,y:(I+R)/2};O.nodes.forEach(A=>{A.data.x-=k.x,A.data.y-=k.y});const F=[Math.max(T-q,_)+x*2,Math.max(I-R,_)+x*2];a.get(y.id).data.size=F,a.get(y.id).data.nodes=E}))}return!0},"BT",e),p.push(d)}),p}}function qf(n,t,e,r){var i;return P(this,void 0,void 0,function*(){return Rf(n)?(n.execute(t,e),n.stop(),n.tick((i=e.iterations)!==null&&i!==void 0?i:300)):r?yield n.assign(t,e):yield n.execute(t,e)})}function B1(n,t){var e,r=1;n==null&&(n=0),t==null&&(t=0);function i(){var s,o=e.length,a,u=0,c=0;for(s=0;sh.index){var S=g-E.x-E.vx,q=p-E.y-E.vy,R=S*S+q*q;R<_*_&&(S===0&&(S=Ye(r),R+=S*S),q===0&&(q=Ye(r),R+=q*q),R=(_-(R=Math.sqrt(R)))/R*i,h.vx+=(S*=R)*(_=(O*=O)/(m+O)),h.vy+=(q*=R)*_,E.vx-=S*(_=1-_),E.vy-=q*_)}return}return b>g+_||Mp+_||Nc.r&&(c.r=c[f].r)}function u(){if(t){var c,f=t.length,l;for(e=new Array(f),c=0;c[t(x,M,o),x])),b;for(m=0,a=new Array(d);m{}};function On(){for(var n=0,t=arguments.length,e={},r;n=0&&(r=e.slice(i+1),e=e.slice(0,i)),e&&!t.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:r}})}wr.prototype=On.prototype={constructor:wr,on:function(n,t){var e=this._,r=X1(n+"",e),i,s=-1,o=r.length;if(arguments.length<2){for(;++s0)for(var e=new Array(i),r=0,i,s;r=0&&n._call.call(void 0,t),n=n._next;--Et}function jf(){st=(_r=Bt.now())+Er,Et=zt=0;try{Q1()}finally{Et=0,eb(),st=0}}function H1(){var n=Bt.now(),t=n-_r;t>If&&(Er-=t,_r=n)}function eb(){for(var n,t=br,e,r=1/0;t;)t._call?(r>t._time&&(r=t._time),n=t,t=t._next):(e=t._next,t._next=null,t=n?n._next=e:br=e);Ft=n,Tn(r)}function Tn(n){if(!Et){zt&&(zt=clearTimeout(zt));var t=n-st;t>24?(n<1/0&&(zt=setTimeout(jf,n-Bt.now()-Er)),$t&&($t=clearInterval($t))):($t||(_r=Bt.now(),$t=setInterval(H1,If)),Et=1,Tf(jf))}}const tb=1664525,rb=1013904223,Cf=4294967296;function nb(){let n=1;return()=>(n=(tb*n+rb)%Cf)/Cf}function ib(n){return n.x}function sb(n){return n.y}var ob=10,ab=Math.PI*(3-Math.sqrt(5));function ub(n){var t,e=1,r=.001,i=1-Math.pow(r,1/300),s=0,o=.6,a=new Map,u=In(l),c=On("tick","end"),f=nb();n==null&&(n=[]);function l(){h(),c.call("tick",t),e1?(m==null?a.delete(v):a.set(v,p(m)),t):a.get(v)},find:function(v,m,d){var y=0,w=n.length,b,x,M,N,E;for(d==null?d=1/0:d*=d,y=0;y1?(c.on(v,m),t):c.on(v)}}}function cb(){var n,t,e,r,i=ae(-30),s,o=1,a=1/0,u=.81;function c(g){var p,v=n.length,m=mt(n,ib,sb).visitAfter(l);for(r=g,p=0;p=a)return;(g.data!==t||g.next)&&(d===0&&(d=Ye(e),b+=d*d),y===0&&(y=Ye(e),b+=y*y),be.id},manyBody:{},center:{x:0,y:0}},this.context={options:{},assign:!1,nodes:[],edges:[]},xc(this.options,t),this.options.forceSimulation&&(this.simulation=this.options.forceSimulation)}execute(t,e){return P(this,void 0,void 0,function*(){return this.genericLayout(!1,t,e)})}assign(t,e){return P(this,void 0,void 0,function*(){yield this.genericLayout(!0,t,e)})}stop(){this.simulation.stop()}tick(t){return this.simulation.tick(t),this.getResult()}restart(){this.simulation.restart()}setFixedPosition(t,e){const r=this.context.nodes.find(i=>i.id===t);r&&e.forEach((i,s)=>{if(typeof i=="number"||i===null){const o=["fx","fy","fz"][s];r[o]=i}})}getOptions(t){var e,r;const i=xc({},this.options,t);return i.collide&&((e=i.collide)===null||e===void 0?void 0:e.radius)===void 0&&(i.collide=i.collide||{},i.collide.radius=(r=i.nodeSize)!==null&&r!==void 0?r:10),i.iterations===void 0&&(i.link&&i.link.iterations===void 0&&(i.iterations=i.link.iterations),i.collide&&i.collide.iterations===void 0&&(i.iterations=i.collide.iterations)),this.context.options=i,i}genericLayout(t,e,r){var i;return P(this,void 0,void 0,function*(){const s=this.getOptions(r),o=e.getAllNodes().map(({id:f,data:l})=>Object.assign(Object.assign({id:f},l),Nc(l.data,this.config.inputNodeAttrs))),a=e.getAllEdges().map(f=>Object.assign({},f));Object.assign(this.context,{assign:t,nodes:o,edges:a,graph:e});const u=new Promise(f=>{this.resolver=f}),c=this.setSimulation(s);return c.nodes(o),(i=c.force("link"))===null||i===void 0||i.links(a),u})}getResult(){const{assign:t,nodes:e,edges:r,graph:i}=this.context,s=e.map(a=>({id:a.id,data:Object.assign(Object.assign({},a.data),Nc(a,this.config.outputNodeAttrs))})),o=r.map(({id:a,source:u,target:c,data:f})=>({id:a,source:typeof u=="object"?u.id:u,target:typeof c=="object"?c.id:c,data:f}));return t&&s.forEach(a=>i.mergeNodeData(a.id,a.data)),{nodes:s,edges:o}}initSimulation(){return ub()}setSimulation(t){const e=this.simulation||this.options.forceSimulation||this.initSimulation();return this.simulation||(this.simulation=e.on("tick",()=>{var r;return(r=t.onTick)===null||r===void 0?void 0:r.call(t,this.getResult())}).on("end",()=>{var r;return(r=this.resolver)===null||r===void 0?void 0:r.call(this,this.getResult())})),Lf(e,this.config.simulationAttrs.map(r=>[r,t[r]])),Object.entries(this.forceMap).forEach(([r,i])=>{const s=r;if(t[r]){let o=e.force(s);o||(o=i(),e.force(s,o)),Lf(o,Object.entries(t[s]))}else e.force(s,null)}),e}}const Lf=(n,t)=>t.reduce((e,[r,i])=>!e[r]||i===void 0?e:e[r].call(n,i),n);function db(n,t,e){var r,i=1;n==null&&(n=0),t==null&&(t=0),e==null&&(e=0);function s(){var o,a=r.length,u,c=0,f=0,l=0;for(o=0;o=(u=(o+a)/2))?o=u:a=u,r=i,!(i=i[l=+f]))return r[l]=s,n;if(c=+n._x.call(null,i.data),t===c)return s.next=i,r?r[l]=s:n._root=s,n;do r=r?r[l]=new Array(2):n._root=new Array(2),(f=t>=(u=(o+a)/2))?o=u:a=u;while((l=+f)==(h=+(c>=u)));return r[h]=i,r[l]=s,n}function pb(n){Array.isArray(n)||(n=Array.from(n));const t=n.length,e=new Float64Array(t);let r=1/0,i=-1/0;for(let s=0,o;si&&(i=o));if(r>i)return this;this.cover(r).cover(i);for(let s=0;sn||n>=e;)switch(o=+(no||(s=c.x1)=l))&&(c=a[a.length-1],a[a.length-1]=a[a.length-1-f],a[a.length-1-f]=c)}else{var h=Math.abs(n-+this._x.call(null,u.data));h=(c=(o+a)/2))?o=c:a=c,t=e,!(e=e[l=+f]))return this;if(!e.length)break;t[l+1&1]&&(r=t,h=l)}for(;e.data!==n;)if(i=e,!(e=e.next))return this;return(s=e.next)&&delete e.next,i?(s?i.next=s:delete i.next,this):t?(s?t[l]=s:delete t[l],(e=t[0]||t[1])&&e===(t[1]||t[0])&&!e.length&&(r?r[h]=e:this._root=e),this):(this._root=s,this)}function _b(n){for(var t=0,e=n.length;t1&&(v=g.y+g.vy),e>2&&(m=g.z+g.vz),h.visit(b);function b(x,M,N,E,O,_,S){var q=[M,N,E,O,_,S],R=q[0],T=q[1],I=q[2],k=q[e],F=q[e+1],A=q[e+2],C=x.data,D=x.r,z=d+D;if(C){if(C.index>g.index){var U=p-C.x-C.vx,L=e>1?v-C.y-C.vy:0,$=e>2?m-C.z-C.vz:0,B=U*U+L*L+$*$;B1&&L===0&&(L=Ne(i),B+=L*L),e>2&&$===0&&($=Ne(i),B+=$*$),B=(z-(B=Math.sqrt(B)))/B*s,g.vx+=(U*=B)*(z=(D*=D)/(y+D)),e>1&&(g.vy+=(L*=B)*z),e>2&&(g.vz+=($*=B)*z),C.vx-=U*(z=1-z),e>1&&(C.vy-=L*z),e>2&&(C.vz-=$*z))}return}return R>p+z||k1&&(T>v+z||F2&&(I>m+z||Af.r&&(f.r=f[l].r)}function c(){if(t){var f,l=t.length,h;for(r=new Array(l),f=0;ftypeof h=="function")||Math.random,e=l.find(h=>[1,2,3].includes(h))||2,c()},a.iterations=function(f){return arguments.length?(o=+f,a):o},a.strength=function(f){return arguments.length?(s=+f,a):s},a.radius=function(f){return arguments.length?(n=typeof f=="function"?f:se(+f),c(),a):n},a}function Ab(n){return n.index}function Ff(n,t){var e=n.get(t);if(!e)throw new Error("node not found: "+t);return e}function Ib(n){var t=Ab,e=h,r,i=se(30),s,o,a,u,c,f,l=1;n==null&&(n=[]);function h(d){return 1/Math.min(u[d.source.index],u[d.target.index])}function g(d){for(var y=0,w=n.length;y1&&(O=N.y+N.vy-M.y-M.vy||Ne(f)),a>2&&(_=N.z+N.vz-M.z-M.vz||Ne(f)),S=Math.sqrt(E*E+O*O+_*_),S=(S-s[b])/S*d*r[b],E*=S,O*=S,_*=S,N.vx-=E*(q=c[b]),a>1&&(N.vy-=O*q),a>2&&(N.vz-=_*q),M.vx+=E*(q=1-q),a>1&&(M.vy+=O*q),a>2&&(M.vz+=_*q)}function p(){if(o){var d,y=o.length,w=n.length,b=new Map(o.map((M,N)=>[t(M,N,o),M])),x;for(d=0,u=new Array(y);dtypeof w=="function")||Math.random,a=y.find(w=>[1,2,3].includes(w))||2,p()},g.links=function(d){return arguments.length?(n=d,p(),g):n},g.id=function(d){return arguments.length?(t=d,g):t},g.iterations=function(d){return arguments.length?(l=+d,g):l},g.strength=function(d){return arguments.length?(e=typeof d=="function"?d:se(+d),v(),g):e},g.distance=function(d){return arguments.length?(i=typeof d=="function"?d:se(+d),m(),g):i},g}const Tb=1664525,kb=1013904223,Bf=4294967296;function jb(){let n=1;return()=>(n=(Tb*n+kb)%Bf)/Bf}var Uf=3;function Pn(n){return n.x}function Gf(n){return n.y}function Cb(n){return n.z}var Pb=10,Lb=Math.PI*(3-Math.sqrt(5)),Db=Math.PI*20/(9+Math.sqrt(221));function zb(n,t){t=t||2;var e=Math.min(Uf,Math.max(1,Math.round(t))),r,i=1,s=.001,o=1-Math.pow(s,1/300),a=0,u=.6,c=new Map,f=In(g),l=On("tick","end"),h=jb();n==null&&(n=[]);function g(){p(),l.call("tick",r),i1&&(b.fy==null?b.y+=b.vy*=u:(b.y=b.fy,b.vy=0)),e>2&&(b.fz==null?b.z+=b.vz*=u:(b.z=b.fz,b.vz=0));return r}function v(){for(var d=0,y=n.length,w;d1&&isNaN(w.y)||e>2&&isNaN(w.z)){var b=Pb*(e>2?Math.cbrt(.5+d):e>1?Math.sqrt(.5+d):d),x=d*Lb,M=d*Db;e===1?w.x=b:e===2?(w.x=b*Math.cos(x),w.y=b*Math.sin(x)):(w.x=b*Math.sin(x)*Math.cos(M),w.y=b*Math.cos(x),w.z=b*Math.sin(x)*Math.sin(M))}(isNaN(w.vx)||e>1&&isNaN(w.vy)||e>2&&isNaN(w.vz))&&(w.vx=0,e>1&&(w.vy=0),e>2&&(w.vz=0))}}function m(d){return d.initialize&&d.initialize(n,h,e),d}return v(),r={tick:p,restart:function(){return f.restart(g),r},stop:function(){return f.stop(),r},numDimensions:function(d){return arguments.length?(e=Math.min(Uf,Math.max(1,Math.round(d))),c.forEach(m),r):e},nodes:function(d){return arguments.length?(n=d,v(),c.forEach(m),r):n},alpha:function(d){return arguments.length?(i=+d,r):i},alphaMin:function(d){return arguments.length?(s=+d,r):s},alphaDecay:function(d){return arguments.length?(o=+d,r):+o},alphaTarget:function(d){return arguments.length?(a=+d,r):a},velocityDecay:function(d){return arguments.length?(u=1-d,r):1-u},randomSource:function(d){return arguments.length?(h=d,c.forEach(m),r):h},force:function(d,y){return arguments.length>1?(y==null?c.delete(d):c.set(d,m(y)),r):c.get(d)},find:function(){var d=Array.prototype.slice.call(arguments),y=d.shift()||0,w=(e>1?d.shift():null)||0,b=(e>2?d.shift():null)||0,x=d.shift()||1/0,M=0,N=n.length,E,O,_,S,q,R;for(x*=x,M=0;M1?(l.on(d,y),r):l.on(d)}}}function $b(){var n,t,e,r,i,s=se(-30),o,a=1,u=1/0,c=.81;function f(p){var v,m=n.length,d=(t===1?kn(n,Pn):t===2?mt(n,Pn,Gf):t===3?cr(n,Pn,Gf,Cb):null).visitAfter(h);for(i=p,v=0;v1&&(p.y=b/y),t>2&&(p.z=x/y)}else{m=p,m.x=m.data.x,t>1&&(m.y=m.data.y),t>2&&(m.z=m.data.z);do v+=o[m.data.index];while(m=m.next)}p.value=v}function g(p,v,m,d,y){if(!p.value)return!0;var w=[m,d,y][t-1],b=p.x-e.x,x=t>1?p.y-e.y:0,M=t>2?p.z-e.z:0,N=w-v,E=b*b+x*x+M*M;if(N*N/c1&&x===0&&(x=Ne(r),E+=x*x),t>2&&M===0&&(M=Ne(r),E+=M*M),E1&&(e.vy+=x*p.value*i/E),t>2&&(e.vz+=M*p.value*i/E)),!0;if(p.length||E>=u)return;(p.data!==e||p.next)&&(b===0&&(b=Ne(r),E+=b*b),t>1&&x===0&&(x=Ne(r),E+=x*x),t>2&&M===0&&(M=Ne(r),E+=M*M),E1&&(e.vy+=x*N),t>2&&(e.vz+=M*N));while(p=p.next)}return f.initialize=function(p,...v){n=p,r=v.find(m=>typeof m=="function")||Math.random,t=v.find(m=>[1,2,3].includes(m))||2,l()},f.strength=function(p){return arguments.length?(s=typeof p=="function"?p:se(+p),l(),f):s},f.distanceMin=function(p){return arguments.length?(a=p*p,f):Math.sqrt(a)},f.distanceMax=function(p){return arguments.length?(u=p*p,f):Math.sqrt(u)},f.theta=function(p){return arguments.length?(c=p*p,f):Math.sqrt(c)},f}function Fb(n,t,e,r){var i,s,o=se(.1),a,u;typeof n!="function"&&(n=se(+n)),t==null&&(t=0),e==null&&(e=0),r==null&&(r=0);function c(l){for(var h=0,g=i.length;h1&&(p.vy+=m*w),s>2&&(p.vz+=d*w)}}function f(){if(i){var l,h=i.length;for(a=new Array(h),u=new Array(h),l=0;l[1,2,3].includes(g))||2,f()},c.strength=function(l){return arguments.length?(o=typeof l=="function"?l:se(+l),f(),c):o},c.radius=function(l){return arguments.length?(n=typeof l=="function"?l:se(+l),f(),c):n},c.x=function(l){return arguments.length?(t=+l,c):t},c.y=function(l){return arguments.length?(e=+l,c):e},c.z=function(l){return arguments.length?(r=+l,c):r},c}function Bb(n){var t=se(.1),e,r,i;typeof n!="function"&&(n=se(n==null?0:+n));function s(a){for(var u=0,c=e.length,f;ut.id},manyBody:{},center:{x:0,y:0,z:0}}}initSimulation(){return zb()}}function Ln(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Dn,Vf;function Wb(){if(Vf)return Dn;Vf=1;function n(){this.__data__=[],this.size=0}return Dn=n,Dn}var zn,Wf;function xt(){if(Wf)return zn;Wf=1;function n(t,e){return t===e||t!==t&&e!==e}return zn=n,zn}var $n,Yf;function xr(){if(Yf)return $n;Yf=1;var n=xt();function t(e,r){for(var i=e.length;i--;)if(n(e[i][0],r))return i;return-1}return $n=t,$n}var Fn,Kf;function Yb(){if(Kf)return Fn;Kf=1;var n=xr(),t=Array.prototype,e=t.splice;function r(i){var s=this.__data__,o=n(s,i);if(o<0)return!1;var a=s.length-1;return o==a?s.pop():e.call(s,o,1),--this.size,!0}return Fn=r,Fn}var Bn,Xf;function Kb(){if(Xf)return Bn;Xf=1;var n=xr();function t(e){var r=this.__data__,i=n(r,e);return i<0?void 0:r[i][1]}return Bn=t,Bn}var Un,Zf;function Xb(){if(Zf)return Un;Zf=1;var n=xr();function t(e){return n(this.__data__,e)>-1}return Un=t,Un}var Gn,Jf;function Zb(){if(Jf)return Gn;Jf=1;var n=xr();function t(e,r){var i=this.__data__,s=n(i,e);return s<0?(++this.size,i.push([e,r])):i[s][1]=r,this}return Gn=t,Gn}var Vn,Qf;function Nr(){if(Qf)return Vn;Qf=1;var n=Wb(),t=Yb(),e=Kb(),r=Xb(),i=Zb();function s(o){var a=-1,u=o==null?0:o.length;for(this.clear();++a-1&&r%1==0&&r-1&&e%1==0&&e<=n}return Ui=t,Ui}var Vi,Ql;function x_(){if(Ql)return Vi;Ql=1;var n=ot(),t=Gi(),e=Ae(),r="[object Arguments]",i="[object Array]",s="[object Boolean]",o="[object Date]",a="[object Error]",u="[object Function]",c="[object Map]",f="[object Number]",l="[object Object]",h="[object RegExp]",g="[object Set]",p="[object String]",v="[object WeakMap]",m="[object ArrayBuffer]",d="[object DataView]",y="[object Float32Array]",w="[object Float64Array]",b="[object Int8Array]",x="[object Int16Array]",M="[object Int32Array]",N="[object Uint8Array]",E="[object Uint8ClampedArray]",O="[object Uint16Array]",_="[object Uint32Array]",S={};S[y]=S[w]=S[b]=S[x]=S[M]=S[N]=S[E]=S[O]=S[_]=!0,S[r]=S[i]=S[m]=S[s]=S[d]=S[o]=S[a]=S[u]=S[c]=S[f]=S[l]=S[h]=S[g]=S[p]=S[v]=!1;function q(R){return e(R)&&t(R.length)&&!!S[n(R)]}return Vi=q,Vi}var Wi,Hl;function Ir(){if(Hl)return Wi;Hl=1;function n(t){return function(e){return t(e)}}return Wi=n,Wi}var Yt={exports:{}};Yt.exports;var eh;function Yi(){return eh||(eh=1,function(n,t){var e=il(),r=t&&!t.nodeType&&t,i=r&&!0&&n&&!n.nodeType&&n,s=i&&i.exports===r,o=s&&e.process,a=function(){try{var u=i&&i.require&&i.require("util").types;return u||o&&o.binding&&o.binding("util")}catch(c){}}();n.exports=a}(Yt,Yt.exports)),Yt.exports}var Ki,th;function Kt(){if(th)return Ki;th=1;var n=x_(),t=Ir(),e=Yi(),r=e&&e.isTypedArray,i=r?t(r):n;return Ki=i,Ki}var Xi,rh;function nh(){if(rh)return Xi;rh=1;var n=b_(),t=Vt(),e=oe(),r=Mt(),i=Ar(),s=Kt(),o=Object.prototype,a=o.hasOwnProperty;function u(c,f){var l=e(c),h=!l&&t(c),g=!l&&!h&&r(c),p=!l&&!h&&!g&&s(c),v=l||h||g||p,m=v?n(c.length,String):[],d=m.length;for(var y in c)(f||a.call(c,y))&&!(v&&(y=="length"||g&&(y=="offset"||y=="parent")||p&&(y=="buffer"||y=="byteLength"||y=="byteOffset")||i(y,d)))&&m.push(y);return m}return Xi=u,Xi}var Zi,ih;function Tr(){if(ih)return Zi;ih=1;var n=Object.prototype;function t(e){var r=e&&e.constructor,i=typeof r=="function"&&r.prototype||n;return e===i}return Zi=t,Zi}var Ji,sh;function oh(){if(sh)return Ji;sh=1;function n(t,e){return function(r){return t(e(r))}}return Ji=n,Ji}var Qi,ah;function N_(){if(ah)return Qi;ah=1;var n=oh(),t=n(Object.keys,Object);return Qi=t,Qi}var Hi,uh;function es(){if(uh)return Hi;uh=1;var n=Tr(),t=N_(),e=Object.prototype,r=e.hasOwnProperty;function i(s){if(!n(s))return t(s);var o=[];for(var a in Object(s))r.call(s,a)&&a!="constructor"&&o.push(a);return o}return Hi=i,Hi}var ts,ch;function Le(){if(ch)return ts;ch=1;var n=Ut(),t=Gi();function e(r){return r!=null&&t(r.length)&&!n(r)}return ts=e,ts}var rs,fh;function Ke(){if(fh)return rs;fh=1;var n=nh(),t=es(),e=Le();function r(i){return e(i)?n(i):t(i)}return rs=r,rs}var ns,lh;function M_(){if(lh)return ns;lh=1;var n=Gt(),t=Ke();function e(r,i){return r&&n(i,t(i),r)}return ns=e,ns}var is,hh;function S_(){if(hh)return is;hh=1;function n(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}return is=n,is}var ss,dh;function R_(){if(dh)return ss;dh=1;var n=Me(),t=Tr(),e=S_(),r=Object.prototype,i=r.hasOwnProperty;function s(o){if(!n(o))return e(o);var a=t(o),u=[];for(var c in o)c=="constructor"&&(a||!i.call(o,c))||u.push(c);return u}return ss=s,ss}var os,gh;function ut(){if(gh)return os;gh=1;var n=nh(),t=R_(),e=Le();function r(i){return e(i)?n(i,!0):t(i)}return os=r,os}var as,ph;function q_(){if(ph)return as;ph=1;var n=Gt(),t=ut();function e(r,i){return r&&n(i,t(i),r)}return as=e,as}var Xt={exports:{}};Xt.exports;var vh;function mh(){return vh||(vh=1,function(n,t){var e=Re(),r=t&&!t.nodeType&&t,i=r&&!0&&n&&!n.nodeType&&n,s=i&&i.exports===r,o=s?e.Buffer:void 0,a=o?o.allocUnsafe:void 0;function u(c,f){if(f)return c.slice();var l=c.length,h=a?a(l):new c.constructor(l);return c.copy(h),h}n.exports=u}(Xt,Xt.exports)),Xt.exports}var us,yh;function wh(){if(yh)return us;yh=1;function n(t,e){var r=-1,i=t.length;for(e||(e=Array(i));++rg))return!1;var v=l.get(o),m=l.get(a);if(v&&m)return v==a&&m==o;var d=-1,y=!0,w=u&i?new n:void 0;for(l.set(o,a),l.set(a,o);++d0&&s(f)?i>1?e(f,i-1,s,o,a):n(a,f):o||(a[a.length]=f)}return a}return ua=e,ua}var fa,Fg;function ME(){if(Fg)return fa;Fg=1;function n(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}return fa=n,fa}var la,Bg;function Ug(){if(Bg)return la;Bg=1;var n=ME(),t=Math.max;function e(r,i,s){return i=t(i===void 0?r.length-1:i,0),function(){for(var o=arguments,a=-1,u=t(o.length-i,0),c=Array(u);++a0){if(++s>=n)return arguments[0]}else s=0;return i.apply(void 0,arguments)}}return da=r,da}var ga,Wg;function Yg(){if(Wg)return ga;Wg=1;var n=SE(),t=RE(),e=t(n);return ga=e,ga}var pa,Kg;function Dr(){if(Kg)return pa;Kg=1;var n=ct(),t=Ug(),e=Yg();function r(i,s){return e(t(i,s,n),i+"")}return pa=r,pa}var va,Xg;function Zg(){if(Xg)return va;Xg=1;function n(t,e,r,i){for(var s=t.length,o=r+(i?1:-1);i?o--:++o-1}return ba=t,ba}var _a,tp;function TE(){if(tp)return _a;tp=1;function n(t,e,r){for(var i=-1,s=t==null?0:t.length;++i=o){var d=c?null:i(u);if(d)return s(d);p=!1,h=r,m=new n}else m=c?[]:v;e:for(;++l1?g.setNode(p,l):g.setNode(p)}),this},i.prototype.setNode=function(f,l){return n.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=l),this):(this._nodes[f]=arguments.length>1?l:this._defaultNodeLabelFn(f),this._isCompound&&(this._parent[f]=e,this._children[f]={},this._children[e][f]=!0),this._in[f]={},this._preds[f]={},this._out[f]={},this._sucs[f]={},++this._nodeCount,this)},i.prototype.node=function(f){return this._nodes[f]},i.prototype.hasNode=function(f){return n.has(this._nodes,f)},i.prototype.removeNode=function(f){var l=this;if(n.has(this._nodes,f)){var h=function(g){l.removeEdge(l._edgeObjs[g])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],n.each(this.children(f),function(g){l.setParent(g)}),delete this._children[f]),n.each(n.keys(this._in[f]),h),delete this._in[f],delete this._preds[f],n.each(n.keys(this._out[f]),h),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},i.prototype.setParent=function(f,l){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(n.isUndefined(l))l=e;else{l+="";for(var h=l;!n.isUndefined(h);h=this.parent(h))if(h===f)throw new Error("Setting "+l+" as parent of "+f+" would create a cycle");this.setNode(l)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=l,this._children[l][f]=!0,this},i.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},i.prototype.parent=function(f){if(this._isCompound){var l=this._parent[f];if(l!==e)return l}},i.prototype.children=function(f){if(n.isUndefined(f)&&(f=e),this._isCompound){var l=this._children[f];if(l)return n.keys(l)}else{if(f===e)return this.nodes();if(this.hasNode(f))return[]}},i.prototype.predecessors=function(f){var l=this._preds[f];if(l)return n.keys(l)},i.prototype.successors=function(f){var l=this._sucs[f];if(l)return n.keys(l)},i.prototype.neighbors=function(f){var l=this.predecessors(f);if(l)return n.union(l,this.successors(f))},i.prototype.isLeaf=function(f){var l;return this.isDirected()?l=this.successors(f):l=this.neighbors(f),l.length===0},i.prototype.filterNodes=function(f){var l=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});l.setGraph(this.graph());var h=this;n.each(this._nodes,function(v,m){f(m)&&l.setNode(m,v)}),n.each(this._edgeObjs,function(v){l.hasNode(v.v)&&l.hasNode(v.w)&&l.setEdge(v,h.edge(v))});var g={};function p(v){var m=h.parent(v);return m===void 0||l.hasNode(m)?(g[v]=m,m):m in g?g[m]:p(m)}return this._isCompound&&n.each(l.nodes(),function(v){l.setParent(v,p(v))}),l},i.prototype.setDefaultEdgeLabel=function(f){return n.isFunction(f)||(f=n.constant(f)),this._defaultEdgeLabelFn=f,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return n.values(this._edgeObjs)},i.prototype.setPath=function(f,l){var h=this,g=arguments;return n.reduce(f,function(p,v){return g.length>1?h.setEdge(p,v,l):h.setEdge(p,v),v}),this},i.prototype.setEdge=function(){var f,l,h,g,p=!1,v=arguments[0];typeof v=="object"&&v!==null&&"v"in v?(f=v.v,l=v.w,h=v.name,arguments.length===2&&(g=arguments[1],p=!0)):(f=v,l=arguments[1],h=arguments[3],arguments.length>2&&(g=arguments[2],p=!0)),f=""+f,l=""+l,n.isUndefined(h)||(h=""+h);var m=a(this._isDirected,f,l,h);if(n.has(this._edgeLabels,m))return p&&(this._edgeLabels[m]=g),this;if(!n.isUndefined(h)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(l),this._edgeLabels[m]=p?g:this._defaultEdgeLabelFn(f,l,h);var d=u(this._isDirected,f,l,h);return f=d.v,l=d.w,Object.freeze(d),this._edgeObjs[m]=d,s(this._preds[l],f),s(this._sucs[f],l),this._in[l][m]=d,this._out[f][m]=d,this._edgeCount++,this},i.prototype.edge=function(f,l,h){var g=arguments.length===1?c(this._isDirected,arguments[0]):a(this._isDirected,f,l,h);return this._edgeLabels[g]},i.prototype.hasEdge=function(f,l,h){var g=arguments.length===1?c(this._isDirected,arguments[0]):a(this._isDirected,f,l,h);return n.has(this._edgeLabels,g)},i.prototype.removeEdge=function(f,l,h){var g=arguments.length===1?c(this._isDirected,arguments[0]):a(this._isDirected,f,l,h),p=this._edgeObjs[g];return p&&(f=p.v,l=p.w,delete this._edgeLabels[g],delete this._edgeObjs[g],o(this._preds[l],f),o(this._sucs[f],l),delete this._in[l][g],delete this._out[f][g],this._edgeCount--),this},i.prototype.inEdges=function(f,l){var h=this._in[f];if(h){var g=n.values(h);return l?n.filter(g,function(p){return p.v===l}):g}},i.prototype.outEdges=function(f,l){var h=this._out[f];if(h){var g=n.values(h);return l?n.filter(g,function(p){return p.w===l}):g}},i.prototype.nodeEdges=function(f,l){var h=this.inEdges(f,l);if(h)return h.concat(this.outEdges(f,l))};function s(f,l){f[l]?f[l]++:f[l]=1}function o(f,l){--f[l]||delete f[l]}function a(f,l,h,g){var p=""+l,v=""+h;if(!f&&p>v){var m=p;p=v,v=m}return p+r+v+r+(n.isUndefined(g)?t:g)}function u(f,l,h,g){var p=""+l,v=""+h;if(!f&&p>v){var m=p;p=v,v=m}var d={v:p,w:v};return g&&(d.name=g),d}function c(f,l){return a(f,l.v,l.w,l.name)}return Aa}var Ta,dp;function DE(){return dp||(dp=1,Ta="2.1.8"),Ta}var ka,gp;function zE(){return gp||(gp=1,ka={Graph:Ia(),version:DE()}),ka}var ja,pp;function $E(){if(pp)return ja;pp=1;var n=Se(),t=Ia();ja={write:e,read:s};function e(o){var a={options:{directed:o.isDirected(),multigraph:o.isMultigraph(),compound:o.isCompound()},nodes:r(o),edges:i(o)};return n.isUndefined(o.graph())||(a.value=n.clone(o.graph())),a}function r(o){return n.map(o.nodes(),function(a){var u=o.node(a),c=o.parent(a),f={v:a};return n.isUndefined(u)||(f.value=u),n.isUndefined(c)||(f.parent=c),f})}function i(o){return n.map(o.edges(),function(a){var u=o.edge(a),c={v:a.v,w:a.w};return n.isUndefined(a.name)||(c.name=a.name),n.isUndefined(u)||(c.value=u),c})}function s(o){var a=new t(o.options).setGraph(o.value);return n.each(o.nodes,function(u){a.setNode(u.v,u.value),u.parent&&a.setParent(u.v,u.parent)}),n.each(o.edges,function(u){a.setEdge({v:u.v,w:u.w,name:u.name},u.value)}),a}return ja}var Ca,vp;function FE(){if(vp)return Ca;vp=1;var n=Se();Ca=t;function t(e){var r={},i=[],s;function o(a){n.has(r,a)||(r[a]=!0,s.push(a),n.each(e.successors(a),o),n.each(e.predecessors(a),o))}return n.each(e.nodes(),function(a){s=[],o(a),s.length&&i.push(s)}),i}return Ca}var Pa,mp;function yp(){if(mp)return Pa;mp=1;var n=Se();Pa=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(e){return e.key})},t.prototype.has=function(e){return n.has(this._keyIndices,e)},t.prototype.priority=function(e){var r=this._keyIndices[e];if(r!==void 0)return this._arr[r].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(e,r){var i=this._keyIndices;if(e=String(e),!n.has(i,e)){var s=this._arr,o=s.length;return i[e]=o,s.push({key:e,priority:r}),this._decrease(o),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key},t.prototype.decrease=function(e,r){var i=this._keyIndices[e];if(r>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+e+" Old: "+this._arr[i].priority+" New: "+r);this._arr[i].priority=r,this._decrease(i)},t.prototype._heapify=function(e){var r=this._arr,i=2*e,s=i+1,o=e;i>1,!(r[s].priority0&&(l=f.removeMin(),h=c[l],h.distance!==Number.POSITIVE_INFINITY);)u(l).forEach(g);return c}return La}var Da,_p;function BE(){if(_p)return Da;_p=1;var n=bp(),t=Se();Da=e;function e(r,i,s){return t.transform(r.nodes(),function(o,a){o[a]=n(r,a,i,s)},{})}return Da}var za,Ep;function xp(){if(Ep)return za;Ep=1;var n=Se();za=t;function t(e){var r=0,i=[],s={},o=[];function a(u){var c=s[u]={onStack:!0,lowlink:r,index:r++};if(i.push(u),e.successors(u).forEach(function(h){n.has(s,h)?s[h].onStack&&(c.lowlink=Math.min(c.lowlink,s[h].index)):(a(h),c.lowlink=Math.min(c.lowlink,s[h].lowlink))}),c.lowlink===c.index){var f=[],l;do l=i.pop(),s[l].onStack=!1,f.push(l);while(u!==l);o.push(f)}}return e.nodes().forEach(function(u){n.has(s,u)||a(u)}),o}return za}var $a,Np;function UE(){if(Np)return $a;Np=1;var n=Se(),t=xp();$a=e;function e(r){return n.filter(t(r),function(i){return i.length>1||i.length===1&&r.hasEdge(i[0],i[0])})}return $a}var Fa,Mp;function GE(){if(Mp)return Fa;Mp=1;var n=Se();Fa=e;var t=n.constant(1);function e(i,s,o){return r(i,s||t,o||function(a){return i.outEdges(a)})}function r(i,s,o){var a={},u=i.nodes();return u.forEach(function(c){a[c]={},a[c][c]={distance:0},u.forEach(function(f){c!==f&&(a[c][f]={distance:Number.POSITIVE_INFINITY})}),o(c).forEach(function(f){var l=f.v===c?f.w:f.v,h=s(f);a[c][l]={distance:h,predecessor:c}})}),u.forEach(function(c){var f=a[c];u.forEach(function(l){var h=a[l];u.forEach(function(g){var p=h[c],v=f[g],m=h[g],d=p.distance+v.distance;d0;){if(c=u.removeMin(),n.has(a,c))o.setEdge(c,a[c]);else{if(l)throw new Error("Input graph is not connected: "+i);l=!0}i.nodeEdges(c).forEach(f)}return o}return Ya}var Ka,jp;function XE(){return jp||(jp=1,Ka={components:FE(),dijkstra:bp(),dijkstraAll:BE(),findCycles:UE(),floydWarshall:GE(),isAcyclic:VE(),postorder:WE(),preorder:YE(),prim:KE(),tarjan:xp(),topsort:Rp()}),Ka}var Xa,Cp;function ZE(){if(Cp)return Xa;Cp=1;var n=zE();return Xa={Graph:n.Graph,json:$E(),alg:XE(),version:n.version},Xa}var zr;if(typeof Ln=="function")try{zr=ZE()}catch(n){}zr||(zr=window.graphlib);var qe=zr,Za,Pp;function JE(){if(Pp)return Za;Pp=1;var n=ad(),t=1,e=4;function r(i){return n(i,t|e)}return Za=r,Za}var Ja,Lp;function $r(){if(Lp)return Ja;Lp=1;var n=xt(),t=Le(),e=Ar(),r=Me();function i(s,o,a){if(!r(a))return!1;var u=typeof o;return(u=="number"?t(a)&&e(o,a.length):u=="string"&&o in a)?n(a[o],s):!1}return Ja=i,Ja}var Qa,Dp;function QE(){if(Dp)return Qa;Dp=1;var n=Dr(),t=xt(),e=$r(),r=ut(),i=Object.prototype,s=i.hasOwnProperty,o=n(function(a,u){a=Object(a);var c=-1,f=u.length,l=f>2?u[2]:void 0;for(l&&e(u[0],u[1],l)&&(f=1);++c-1?u[c?s[f]:f]:void 0}}return Ha=r,Ha}var eu,$p;function ex(){if($p)return eu;$p=1;var n=/\s/;function t(e){for(var r=e.length;r--&&n.test(e.charAt(r)););return r}return eu=t,eu}var tu,Fp;function tx(){if(Fp)return tu;Fp=1;var n=ex(),t=/^\s+/;function e(r){return r&&r.slice(0,n(r)+1).replace(t,"")}return tu=e,tu}var ru,Bp;function rx(){if(Bp)return ru;Bp=1;var n=tx(),t=Me(),e=Rt(),r=NaN,i=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt;function u(c){if(typeof c=="number")return c;if(e(c))return r;if(t(c)){var f=typeof c.valueOf=="function"?c.valueOf():c;c=t(f)?f+"":f}if(typeof c!="string")return c===0?c:+c;c=n(c);var l=s.test(c);return l||o.test(c)?a(c.slice(2),l?2:8):i.test(c)?r:+c}return ru=u,ru}var nu,Up;function Gp(){if(Up)return nu;Up=1;var n=rx(),t=1/0,e=17976931348623157e292;function r(i){if(!i)return i===0?i:0;if(i=n(i),i===t||i===-t){var s=i<0?-1:1;return s*e}return i===i?i:0}return nu=r,nu}var iu,Vp;function nx(){if(Vp)return iu;Vp=1;var n=Gp();function t(e){var r=n(e),i=r%1;return r===r?i?r-i:r:0}return iu=t,iu}var su,Wp;function ix(){if(Wp)return su;Wp=1;var n=Zg(),t=De(),e=nx(),r=Math.max;function i(s,o,a){var u=s==null?0:s.length;if(!u)return-1;var c=a==null?0:e(a);return c<0&&(c=r(u+c,0)),n(s,t(o,3),c)}return su=i,su}var ou,Yp;function sx(){if(Yp)return ou;Yp=1;var n=HE(),t=ix(),e=n(t);return ou=e,ou}var au,Kp;function Xp(){if(Kp)return au;Kp=1;var n=ca();function t(e){var r=e==null?0:e.length;return r?n(e,1):[]}return au=t,au}var uu,Zp;function ox(){if(Zp)return uu;Zp=1;var n=Ks(),t=md(),e=ut();function r(i,s){return i==null?i:n(i,t(s),e)}return uu=r,uu}var cu,Jp;function ax(){if(Jp)return cu;Jp=1;function n(t){var e=t==null?0:t.length;return e?t[e-1]:void 0}return cu=n,cu}var fu,Qp;function ux(){if(Qp)return fu;Qp=1;var n=qr(),t=Zs(),e=De();function r(i,s){var o={};return s=e(s,3),t(i,function(a,u,c){n(o,u,s(a,u,c))}),o}return fu=r,fu}var lu,Hp;function hu(){if(Hp)return lu;Hp=1;var n=Rt();function t(e,r,i){for(var s=-1,o=e.length;++se}return du=n,du}var gu,tv;function fx(){if(tv)return gu;tv=1;var n=hu(),t=cx(),e=ct();function r(i){return i&&i.length?n(i,e,t):void 0}return gu=r,gu}var pu,rv;function nv(){if(rv)return pu;rv=1;var n=qr(),t=xt();function e(r,i,s){(s!==void 0&&!t(r[i],s)||s===void 0&&!(i in r))&&n(r,i,s)}return pu=e,pu}var vu,iv;function lx(){if(iv)return vu;iv=1;var n=ot(),t=kr(),e=Ae(),r="[object Object]",i=Function.prototype,s=Object.prototype,o=i.toString,a=s.hasOwnProperty,u=o.call(Object);function c(f){if(!e(f)||n(f)!=r)return!1;var l=t(f);if(l===null)return!0;var h=a.call(l,"constructor")&&l.constructor;return typeof h=="function"&&h instanceof h&&o.call(h)==u}return vu=c,vu}var mu,sv;function ov(){if(sv)return mu;sv=1;function n(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}return mu=n,mu}var yu,av;function hx(){if(av)return yu;av=1;var n=Gt(),t=ut();function e(r){return n(r,t(r))}return yu=e,yu}var wu,uv;function dx(){if(uv)return wu;uv=1;var n=nv(),t=mh(),e=Zh(),r=wh(),i=td(),s=Vt(),o=oe(),a=op(),u=Mt(),c=Ut(),f=Me(),l=lx(),h=Kt(),g=ov(),p=hx();function v(m,d,y,w,b,x,M){var N=g(m,y),E=g(d,y),O=M.get(E);if(O){n(m,y,O);return}var _=x?x(N,E,y+"",m,d,M):void 0,S=_===void 0;if(S){var q=o(E),R=!q&&u(E),T=!q&&!R&&h(E);_=E,q||R||T?o(N)?_=N:a(N)?_=r(N):R?(S=!1,_=t(E,!0)):T?(S=!1,_=e(E,!0)):_=[]:l(E)||s(E)?(_=N,s(N)?_=p(N):(!f(N)||c(N))&&(_=i(E))):S=!1}S&&(M.set(E,_),b(_,E,w,x,M),M.delete(E)),n(m,y,_)}return wu=v,wu}var bu,cv;function gx(){if(cv)return bu;cv=1;var n=Rr(),t=nv(),e=Ks(),r=dx(),i=Me(),s=ut(),o=ov();function a(u,c,f,l,h){u!==c&&e(c,function(g,p){if(h||(h=new n),i(g))r(u,c,p,f,a,l,h);else{var v=l?l(o(u,p),g,p+"",u,c,h):void 0;v===void 0&&(v=g),t(u,p,v)}},s)}return bu=a,bu}var _u,fv;function px(){if(fv)return _u;fv=1;var n=Dr(),t=$r();function e(r){return n(function(i,s){var o=-1,a=s.length,u=a>1?s[a-1]:void 0,c=a>2?s[2]:void 0;for(u=r.length>3&&typeof u=="function"?(a--,u):void 0,c&&t(s[0],s[1],c)&&(u=a<3?void 0:u,a=1),i=Object(i);++or||a&&u&&f&&!c&&!l||s&&u&&f||!i&&f||!o)return 1;if(!s&&!a&&!l&&e=c)return f;var l=i[s];return f*(l=="desc"?-1:1)}}return e.index-r.index}return Lu=t,Lu}var Du,qv;function Ix(){if(qv)return Du;qv=1;var n=Cr(),t=Lr(),e=De(),r=Mg(),i=qx(),s=Ir(),o=Ax(),a=ct(),u=oe();function c(f,l,h){l.length?l=n(l,function(v){return u(v)?function(m){return t(m,v.length===1?v[0]:v)}:v}):l=[a];var g=-1;l=n(l,s(e));var p=r(f,function(v,m,d){var y=n(l,function(w){return w(v)});return{criteria:y,index:++g,value:v}});return i(p,function(v,m){return o(v,m,h)})}return Du=c,Du}var zu,Ov;function Tx(){if(Ov)return zu;Ov=1;var n=ca(),t=Ix(),e=Dr(),r=$r(),i=e(function(s,o){if(s==null)return[];var a=o.length;return a>1&&r(s,o[0],o[1])?o=[]:a>2&&r(o[0],o[1],o[2])&&(o=[o[0]]),t(s,n(o,1),[])});return zu=i,zu}var $u,Av;function kx(){if(Av)return $u;Av=1;var n=eg(),t=0;function e(r){var i=++t;return n(r)+i}return $u=e,$u}var Fu,Iv;function jx(){if(Iv)return Fu;Iv=1;function n(t,e,r){for(var i=-1,s=t.length,o=e.length,a={};++i0;--a)if(o=t[a].dequeue(),o){r=r.concat(Uu(n,t,e,o,!0));break}}}return r}function Uu(n,t,e,r,i){var s=i?[]:void 0;return ze.forEach(n.inEdges(r.v),function(o){var a=n.edge(o),u=n.node(o.v);i&&s.push({v:o.v,w:o.w}),u.out-=a,Gu(t,e,u)}),ze.forEach(n.outEdges(r.v),function(o){var a=n.edge(o),u=o.w,c=n.node(u);c.in-=a,Gu(t,e,c)}),n.removeNode(r.v),s}function Gx(n,t){var e=new Dx,r=0,i=0;ze.forEach(n.nodes(),function(a){e.setNode(a,{v:a,in:0,out:0})}),ze.forEach(n.edges(),function(a){var u=e.edge(a.v,a.w)||0,c=t(a),f=u+c;e.setEdge(a.v,a.w,f),i=Math.max(i,e.node(a.v).out+=c),r=Math.max(r,e.node(a.w).in+=c)});var s=ze.range(i+r+3).map(function(){return new zx}),o=r+1;return ze.forEach(e.nodes(),function(a){Gu(s,o,e.node(a))}),{graph:e,buckets:s,zeroIdx:o}}function Gu(n,t,e){e.out?e.in?n[e.out-e.in+t].enqueue(e):n[n.length-1].enqueue(e):n[0].enqueue(e)}var ft=ie,Vx=$x,Wx={run:Yx,undo:Xx};function Yx(n){var t=n.graph().acyclicer==="greedy"?Vx(n,e(n)):Kx(n);ft.forEach(t,function(r){var i=n.edge(r);n.removeEdge(r),i.forwardName=r.name,i.reversed=!0,n.setEdge(r.w,r.v,i,ft.uniqueId("rev"))});function e(r){return function(i){return r.edge(i).weight}}}function Kx(n){var t=[],e={},r={};function i(s){ft.has(r,s)||(r[s]=!0,e[s]=!0,ft.forEach(n.outEdges(s),function(o){ft.has(e,o.w)?t.push(o):i(o.w)}),delete e[s])}return ft.forEach(n.nodes(),i),t}function Xx(n){ft.forEach(n.edges(),function(t){var e=n.edge(t);if(e.reversed){n.removeEdge(t);var r=e.forwardName;delete e.reversed,delete e.forwardName,n.setEdge(t.w,t.v,e,r)}})}var Q=ie,jv=qe.Graph,ve={addDummyNode:Cv,simplify:Zx,asNonCompoundGraph:Jx,successorWeights:Qx,predecessorWeights:Hx,intersectRect:eN,buildLayerMatrix:tN,normalizeRanks:rN,removeEmptyRanks:nN,addBorderNode:iN,maxRank:Pv,partition:sN,time:oN,notime:aN};function Cv(n,t,e,r){var i;do i=Q.uniqueId(r);while(n.hasNode(i));return e.dummy=t,n.setNode(i,e),i}function Zx(n){var t=new jv().setGraph(n.graph());return Q.forEach(n.nodes(),function(e){t.setNode(e,n.node(e))}),Q.forEach(n.edges(),function(e){var r=t.edge(e.v,e.w)||{weight:0,minlen:1},i=n.edge(e);t.setEdge(e.v,e.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function Jx(n){var t=new jv({multigraph:n.isMultigraph()}).setGraph(n.graph());return Q.forEach(n.nodes(),function(e){n.children(e).length||t.setNode(e,n.node(e))}),Q.forEach(n.edges(),function(e){t.setEdge(e,n.edge(e))}),t}function Qx(n){var t=Q.map(n.nodes(),function(e){var r={};return Q.forEach(n.outEdges(e),function(i){r[i.w]=(r[i.w]||0)+n.edge(i).weight}),r});return Q.zipObject(n.nodes(),t)}function Hx(n){var t=Q.map(n.nodes(),function(e){var r={};return Q.forEach(n.inEdges(e),function(i){r[i.v]=(r[i.v]||0)+n.edge(i).weight}),r});return Q.zipObject(n.nodes(),t)}function eN(n,t){var e=n.x,r=n.y,i=t.x-e,s=t.y-r,o=n.width/2,a=n.height/2;if(!i&&!s)throw new Error("Not possible to find intersection inside of the rectangle");var u,c;return Math.abs(s)*o>Math.abs(i)*a?(s<0&&(a=-a),u=a*i/s,c=a):(i<0&&(o=-o),u=o,c=o*s/i),{x:e+u,y:r+c}}function tN(n){var t=Q.map(Q.range(Pv(n)+1),function(){return[]});return Q.forEach(n.nodes(),function(e){var r=n.node(e),i=r.rank;Q.isUndefined(i)||(t[i][r.order]=e)}),t}function rN(n){var t=Q.min(Q.map(n.nodes(),function(e){return n.node(e).rank}));Q.forEach(n.nodes(),function(e){var r=n.node(e);Q.has(r,"rank")&&(r.rank-=t)})}function nN(n){var t=Q.min(Q.map(n.nodes(),function(s){return n.node(s).rank})),e=[];Q.forEach(n.nodes(),function(s){var o=n.node(s).rank-t;e[o]||(e[o]=[]),e[o].push(s)});var r=0,i=n.graph().nodeRankFactor;Q.forEach(e,function(s,o){Q.isUndefined(s)&&o%i!==0?--r:r&&Q.forEach(s,function(a){n.node(a).rank+=r})})}function iN(n,t,e,r){var i={width:0,height:0};return arguments.length>=4&&(i.rank=e,i.order=r),Cv(n,"border",i,t)}function Pv(n){return Q.max(Q.map(n.nodes(),function(t){var e=n.node(t).rank;if(!Q.isUndefined(e))return e}))}function sN(n,t){var e={lhs:[],rhs:[]};return Q.forEach(n,function(r){t(r)?e.lhs.push(r):e.rhs.push(r)}),e}function oN(n,t){var e=Q.now();try{return t()}finally{console.log(n+" time: "+(Q.now()-e)+"ms")}}function aN(n,t){return t()}var Lv=ie,uN=ve,cN={run:fN,undo:hN};function fN(n){n.graph().dummyChains=[],Lv.forEach(n.edges(),function(t){lN(n,t)})}function lN(n,t){var e=t.v,r=n.node(e).rank,i=t.w,s=n.node(i).rank,o=t.name,a=n.edge(t),u=a.labelRank;if(s!==r+1){n.removeEdge(t);var c,f,l;for(l=0,++r;ro.lim&&(a=o,u=!0);var c=$e.filter(t.edges(),function(f){return u===Gv(n,n.node(f.v),a)&&u!==Gv(n,n.node(f.w),a)});return $e.minBy(c,function(f){return _N(t,f)})}function Uv(n,t,e,r){var i=e.v,s=e.w;n.removeEdge(i,s),n.setEdge(r.v,r.w,{}),Wu(n),Vu(n,t),qN(n,t)}function qN(n,t){var e=$e.find(n.nodes(),function(i){return!t.node(i).parent}),r=xN(n,e);r=r.slice(1),$e.forEach(r,function(i){var s=n.node(i).parent,o=t.edge(i,s),a=!1;o||(o=t.edge(s,i),a=!0),t.node(i).rank=t.node(s).rank+(a?o.minlen:-o.minlen)})}function ON(n,t,e){return n.hasEdge(t,e)}function Gv(n,t,e){return e.low<=t.lim&&t.lim<=e.lim}var AN=Gr,Vv=AN.longestPath,IN=Dv,TN=SN,kN=jN;function jN(n){switch(n.graph().ranker){case"network-simplex":Wv(n);break;case"tight-tree":PN(n);break;case"longest-path":CN(n);break;default:Wv(n)}}var CN=Vv;function PN(n){Vv(n),IN(n)}function Wv(n){TN(n)}var Yu=ie,LN=DN;function DN(n){var t=$N(n);Yu.forEach(n.graph().dummyChains,function(e){for(var r=n.node(e),i=r.edgeObj,s=zN(n,t,i.v,i.w),o=s.path,a=s.lca,u=0,c=o[u],f=!0;e!==i.w;){if(r=n.node(e),f){for(;(c=o[u])!==a&&n.node(c).maxRanko||a>t[u].lim));for(c=u,u=r;(u=n.parent(u))!==c;)s.push(u);return{path:i.concat(s.reverse()),lca:c}}function $N(n){var t={},e=0;function r(i){var s=e;Yu.forEach(n.children(i),r),t[i]={low:s,lim:e++}}return Yu.forEach(n.children(),r),t}var Fe=ie,Ku=ve,FN={run:BN,cleanup:VN};function BN(n){var t=Ku.addDummyNode(n,"root",{},"_root"),e=UN(n),r=Fe.max(Fe.values(e))-1,i=2*r+1;n.graph().nestingRoot=t,Fe.forEach(n.edges(),function(o){n.edge(o).minlen*=i});var s=GN(n)+1;Fe.forEach(n.children(),function(o){Yv(n,t,i,s,r,e,o)}),n.graph().nodeRankFactor=i}function Yv(n,t,e,r,i,s,o){var a=n.children(o);if(!a.length){o!==t&&n.setEdge(t,o,{weight:0,minlen:e});return}var u=Ku.addBorderNode(n,"_bt"),c=Ku.addBorderNode(n,"_bb"),f=n.node(o);n.setParent(u,o),f.borderTop=u,n.setParent(c,o),f.borderBottom=c,Fe.forEach(a,function(l){Yv(n,t,e,r,i,s,l);var h=n.node(l),g=h.borderTop?h.borderTop:l,p=h.borderBottom?h.borderBottom:l,v=h.borderTop?r:2*r,m=g!==p?1:i-s[o]+1;n.setEdge(u,g,{weight:v,minlen:m,nestingEdge:!0}),n.setEdge(p,c,{weight:v,minlen:m,nestingEdge:!0})}),n.parent(o)||n.setEdge(t,u,{weight:0,minlen:i+s[o]})}function UN(n){var t={};function e(r,i){var s=n.children(r);s&&s.length&&Fe.forEach(s,function(o){e(o,i+1)}),t[r]=i}return Fe.forEach(n.children(),function(r){e(r,1)}),t}function GN(n){return Fe.reduce(n.edges(),function(t,e){return t+n.edge(e).weight},0)}function VN(n){var t=n.graph();n.removeNode(t.nestingRoot),delete t.nestingRoot,Fe.forEach(n.edges(),function(e){var r=n.edge(e);r.nestingEdge&&n.removeEdge(e)})}var Xu=ie,WN=ve,YN=KN;function KN(n){function t(e){var r=n.children(e),i=n.node(e);if(r.length&&Xu.forEach(r,t),Xu.has(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(var s=i.minRank,o=i.maxRank+1;s0;)f%2&&(l+=a[f+1]),f=f-1>>1,a[f]+=c.weight;u+=c.weight*l})),u}var Jv=ie,sM=oM;function oM(n,t){return Jv.map(t,function(e){var r=n.inEdges(e);if(r.length){var i=Jv.reduce(r,function(s,o){var a=n.edge(o),u=n.node(o.v);return{sum:s.sum+a.weight*u.order,weight:s.weight+a.weight}},{sum:0,weight:0});return{v:e,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:e}})}var be=ie,aM=uM;function uM(n,t){var e={};be.forEach(n,function(i,s){var o=e[i.v]={indegree:0,in:[],out:[],vs:[i.v],i:s};be.isUndefined(i.barycenter)||(o.barycenter=i.barycenter,o.weight=i.weight)}),be.forEach(t.edges(),function(i){var s=e[i.v],o=e[i.w];!be.isUndefined(s)&&!be.isUndefined(o)&&(o.indegree++,s.out.push(e[i.w]))});var r=be.filter(e,function(i){return!i.indegree});return cM(r)}function cM(n){var t=[];function e(s){return function(o){o.merged||(be.isUndefined(o.barycenter)||be.isUndefined(s.barycenter)||o.barycenter>=s.barycenter)&&fM(s,o)}}function r(s){return function(o){o.in.push(s),--o.indegree===0&&n.push(o)}}for(;n.length;){var i=n.pop();t.push(i),be.forEach(i.in.reverse(),e(i)),be.forEach(i.out,r(i))}return be.map(be.filter(t,function(s){return!s.merged}),function(s){return be.pick(s,["vs","i","barycenter","weight"])})}function fM(n,t){var e=0,r=0;n.weight&&(e+=n.barycenter*n.weight,r+=n.weight),t.weight&&(e+=t.barycenter*t.weight,r+=t.weight),n.vs=t.vs.concat(n.vs),n.barycenter=e/r,n.weight=r,n.i=Math.min(t.i,n.i),t.merged=!0}var Jt=ie,lM=ve,hM=dM;function dM(n,t){var e=lM.partition(n,function(f){return Jt.has(f,"barycenter")}),r=e.lhs,i=Jt.sortBy(e.rhs,function(f){return-f.i}),s=[],o=0,a=0,u=0;r.sort(gM(!!t)),u=Qv(s,i,u),Jt.forEach(r,function(f){u+=f.vs.length,s.push(f.vs),o+=f.barycenter*f.weight,a+=f.weight,u=Qv(s,i,u)});var c={vs:Jt.flatten(s,!0)};return a&&(c.barycenter=o/a,c.weight=a),c}function Qv(n,t,e){for(var r;t.length&&(r=Jt.last(t)).i<=e;)t.pop(),n.push(r.vs),e++;return e}function gM(n){return function(t,e){return t.barycentere.barycenter?1:n?e.i-t.i:t.i-e.i}}var Ze=ie,pM=sM,vM=aM,mM=hM,yM=Hv;function Hv(n,t,e,r){var i=n.children(t),s=n.node(t),o=s?s.borderLeft:void 0,a=s?s.borderRight:void 0,u={};o&&(i=Ze.filter(i,function(p){return p!==o&&p!==a}));var c=pM(n,i);Ze.forEach(c,function(p){if(n.children(p.v).length){var v=Hv(n,p.v,e,r);u[p.v]=v,Ze.has(v,"barycenter")&&bM(p,v)}});var f=vM(c,e);wM(f,u);var l=mM(f,r);if(o&&(l.vs=Ze.flatten([o,l.vs,a],!0),n.predecessors(o).length)){var h=n.node(n.predecessors(o)[0]),g=n.node(n.predecessors(a)[0]);Ze.has(l,"barycenter")||(l.barycenter=0,l.weight=0),l.barycenter=(l.barycenter*l.weight+h.order+g.order)/(l.weight+2),l.weight+=2}return l}function wM(n,t){Ze.forEach(n,function(e){e.vs=Ze.flatten(e.vs.map(function(r){return t[r]?t[r].vs:r}),!0)})}function bM(n,t){Ze.isUndefined(n.barycenter)?(n.barycenter=t.barycenter,n.weight=t.weight):(n.barycenter=(n.barycenter*n.weight+t.barycenter*t.weight)/(n.weight+t.weight),n.weight+=t.weight)}var Qt=ie,_M=qe.Graph,EM=xM;function xM(n,t,e){var r=NM(n),i=new _M({compound:!0}).setGraph({root:r}).setDefaultNodeLabel(function(s){return n.node(s)});return Qt.forEach(n.nodes(),function(s){var o=n.node(s),a=n.parent(s);(o.rank===t||o.minRank<=t&&t<=o.maxRank)&&(i.setNode(s),i.setParent(s,a||r),Qt.forEach(n[e](s),function(u){var c=u.v===s?u.w:u.v,f=i.edge(c,s),l=Qt.isUndefined(f)?0:f.weight;i.setEdge(c,s,{weight:n.edge(u).weight+l})}),Qt.has(o,"minRank")&&i.setNode(s,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]}))}),i}function NM(n){for(var t;n.hasNode(t=Qt.uniqueId("_root")););return t}var MM=ie,SM=RM;function RM(n,t,e){var r={},i;MM.forEach(e,function(s){for(var o=n.parent(s),a,u;o;){if(a=n.parent(o),a?(u=r[a],r[a]=o):(u=i,i=o),u&&u!==o){t.setEdge(u,o);return}o=a}})}var Je=ie,qM=eM,OM=rM,AM=yM,IM=EM,TM=SM,kM=qe.Graph,e0=ve,jM=CM;function CM(n){var t=e0.maxRank(n),e=t0(n,Je.range(1,t+1),"inEdges"),r=t0(n,Je.range(t-1,-1,-1),"outEdges"),i=qM(n);r0(n,i);for(var s=Number.POSITIVE_INFINITY,o,a=0,u=0;u<4;++a,++u){PM(a%2?e:r,a%4>=2),i=e0.buildLayerMatrix(n);var c=OM(n,i);cc)&&Qu(e,h,f)})})}function i(s,o){var a=-1,u,c=0;return W.forEach(o,function(f,l){if(n.node(f).dummy==="border"){var h=n.predecessors(f);h.length&&(u=n.node(h[0]).order,r(o,c,l,a,u),c=l,a=u)}r(o,c,o.length,u,s.length)}),o}return W.reduce(t,i),e}function $M(n,t){if(n.node(t).dummy)return W.find(n.predecessors(t),function(e){return n.node(e).dummy})}function Qu(n,t,e){if(t>e){var r=t;t=e,e=r}var i=n[t];i||(n[t]=i={}),i[e]=!0}function s0(n,t,e){if(t>e){var r=t;t=e,e=r}return W.has(n[t],e)}function o0(n,t,e,r){var i={},s={},o={};return W.forEach(t,function(a){W.forEach(a,function(u,c){i[u]=u,s[u]=u,o[u]=c})}),W.forEach(t,function(a){var u=-1;W.forEach(a,function(c){var f=r(c);if(f.length){f=W.sortBy(f,function(v){return o[v]});for(var l=(f.length-1)/2,h=Math.floor(l),g=Math.ceil(l);h<=g;++h){var p=f[h];s[c]===c&&u({}));const o=e.getAllNodes(),a=e.getAllEdges();[...o,...a].some(({id:c})=>V(c))&&console.error("Dagre layout only support string id, it will convert number to string."),e.getAllNodes().forEach(c=>{const{id:f}=c,l=Object.assign({},c.data);if(i!==void 0){const[h,g]=Lt(Te(i)?i(c):i);Object.assign(l,{width:h,height:g})}s.setNode(f.toString(),l)}),e.getAllEdges().forEach(({id:c,source:f,target:l})=>{s.setEdge(f.toString(),l.toString(),{id:c})}),kS.layout(s);const u={nodes:[],edges:[]};return s.nodes().forEach(c=>{const f=s.node(c);u.nodes.push({id:c,data:f}),t&&e.mergeNodeData(c,f)}),s.edges().forEach(c=>{const f=s.edge(c),{id:l}=f,h=J(f,["id"]),{v:g,w:p}=c;u.edges.push({id:l,source:g,target:p,data:h}),t&&e.mergeEdgeData(l,h)}),u})}}Kr.defaultOptions={};class tc{constructor(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}distanceTo(t){const e=this.rx-t.rx,r=this.ry-t.ry;return Math.hypot(e,r)}setPos(t,e){this.rx=t,this.ry=e}resetForce(){this.fx=0,this.fy=0}addForce(t){const e=t.rx-this.rx,r=t.ry-this.ry;let i=Math.hypot(e,r);i=i<1e-4?1e-4:i;const s=this.g*(this.degree+1)*(t.degree+1)/i;this.fx+=s*e/i,this.fy+=s*r/i}in(t){return t.contains(this.rx,this.ry)}add(t){const e=this.mass+t.mass,r=(this.rx*this.mass+t.rx*t.mass)/e,i=(this.ry*this.mass+t.ry*t.mass)/e,s=this.degree+t.degree,o={rx:r,ry:i,mass:e,degree:s};return new tc(o)}}class qt{constructor(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}getLength(){return this.length}contains(t,e){const r=this.length/2;return t<=this.xmid+r&&t>=this.xmid-r&&e<=this.ymid+r&&e>=this.ymid-r}NW(){const t=this.xmid-this.length/4,e=this.ymid+this.length/4,r=this.length/2,i={xmid:t,ymid:e,length:r};return new qt(i)}NE(){const t=this.xmid+this.length/4,e=this.ymid+this.length/4,r=this.length/2,i={xmid:t,ymid:e,length:r};return new qt(i)}SW(){const t=this.xmid-this.length/4,e=this.ymid-this.length/4,r=this.length/2,i={xmid:t,ymid:e,length:r};return new qt(i)}SE(){const t=this.xmid+this.length/4,e=this.ymid-this.length/4,r=this.length/2,i={xmid:t,ymid:e,length:r};return new qt(i)}}class Ot{constructor(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,t!=null&&(this.quad=t)}insert(t){if(this.body==null){this.body=t;return}this._isExternal()?(this.quad&&(this.NW=new Ot(this.quad.NW()),this.NE=new Ot(this.quad.NE()),this.SW=new Ot(this.quad.SW()),this.SE=new Ot(this.quad.SE())),this._putBody(this.body),this._putBody(t),this.body=this.body.add(t)):(this.body=this.body.add(t),this._putBody(t))}_putBody(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))}_isExternal(){return this.NW==null&&this.NE==null&&this.SW==null&&this.SE==null}updateForce(t){if(!(this.body==null||t===this.body))if(this._isExternal())t.addForce(this.body);else{const e=this.quad?this.quad.getLength():0,r=this.body.distanceTo(t);e/rye(d,[a,u])),p=i.filter(d=>{const{source:y,target:w}=d;return y!==w}),v=new ue({nodes:g,edges:p}),m=this.getSizes(v,l);if(this.run(v,e,f,m,t,o),c){for(let y=0;y250&&(r.barnesHut=!0),u===void 0&&e>100&&(r.prune=!0),c===0&&!u?(r.maxIteration=250,e<=200&&e>100?r.maxIteration=1e3:e>200&&(r.maxIteration=1200)):c===0&&u&&(r.maxIteration=100,e<=200&&e>100?r.maxIteration=500:e>200&&(r.maxIteration=950)),f||(r.kr=50,e>100&&e<=500?r.kr=20:e>500&&(r.kr=1)),l||(r.kg=20,e>100&&e<=500?r.kg=10:e>500&&(r.kg=1)),r}run(t,e,r,i,s,o){const{kr:a,barnesHut:u,onTick:c}=o,f=t.getAllNodes();let l=0,h=r;const g={},p={},v={};for(let m=0;m0;)l=this.oneStep(t,{iter:h,preventOverlapIters:50,krPrime:100,sg:l,forces:g,preForces:p,bodies:v,sizes:i},o),h--,c==null||c({nodes:f,edges:e.getAllEdges()});return t}oneStep(t,e,r){const{iter:i,preventOverlapIters:s,krPrime:o,sg:a,preForces:u,bodies:c,sizes:f}=e;let{forces:l}=e;const{preventOverlap:h,barnesHut:g}=r,p=t.getAllNodes();for(let v=0;vs||!h)?l=this.getOptRepGraForces(t,l,c,r):l=this.getRepGraForces(t,i,s,l,o,f,r),this.updatePos(t,l,u,a,r)}getAttrForces(t,e,r,i,s,o){const{preventOverlap:a,dissuadeHubs:u,mode:c,prune:f}=o,l=t.getAllEdges();for(let h=0;h0&&(x=b,M=b),s[g][0]+=x*w[0],s[p][0]-=M*w[0],s[g][1]+=x*w[1],s[p][1]-=M*w[1]}return s}getOptRepGraForces(t,e,r,i){const{kg:s,center:o,prune:a}=i,u=t.getAllNodes(),c=u.length;let f=9e10,l=-9e10,h=9e10,g=-9e10;for(let y=0;y=l&&(l=b.x),b.x<=f&&(f=b.x),b.y>=g&&(g=b.y),b.y<=h&&(h=b.y))}const p=Math.max(l-f,g-h),v={xmid:(l+f)/2,ymid:(g+h)/2,length:p,massCenter:o,mass:c},m=new qt(v),d=new Ot(m);for(let y=0;y0&&(_=c*(d+1)*(N+1)/O),i[m.id][0]-=_*E[0],i[M.id][0]+=_*E[0],i[m.id][1]-=_*E[1],i[M.id][1]+=_*E[1]}const y=[m.data.x-l[0],m.data.y-l[1]],w=Math.hypot(y[0],y[1]);y[0]=y[0]/w,y[1]=y[1]/w;const b=f*(d+1);i[m.id][0]-=b*y[0],i[m.id][1]-=b*y[1]}return i}updatePos(t,e,r,i,s){const{ks:o,tao:a,prune:u,ksmax:c}=s,f=t.getAllNodes(),l=f.length,h=[],g=[];let p=0,v=0,m=i;for(let y=0;y1.5*d?1.5*d:m);for(let y=0;yE?E:M;const O=M*e[w][0],_=M*e[w][1];t.mergeNodeData(w,{x:b.x+O,y:b.y+_})}return m}}const PS={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},LS=800;class DS{constructor(t={}){this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=Object.assign(Object.assign({},PS),t)}execute(t,e){return P(this,void 0,void 0,function*(){return this.genericFruchtermanLayout(!1,t,e)})}assign(t,e){return P(this,void 0,void 0,function*(){yield this.genericFruchtermanLayout(!0,t,e)})}stop(){this.timeInterval&&typeof window!="undefined"&&window.clearInterval(this.timeInterval),this.running=!1}tick(t=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let r=0;rthis.lastGraph.mergeNodeData(r.id,{x:r.data.x,y:r.data.y,z:this.options.dimensions===3?r.data.z:void 0})),e}genericFruchtermanLayout(t,e,r){return P(this,void 0,void 0,function*(){if(this.running)return;const i=this.formatOptions(r),{dimensions:s,width:o,height:a,center:u,clustering:c,nodeClusterBy:f,maxIteration:l,onTick:h}=i,g=e.getAllNodes(),p=e.getAllEdges();if(!(g!=null&&g.length)){const w={nodes:[],edges:p};return this.lastResult=w,w}if(g.length===1){t&&e.mergeNodeData(g[0].id,{x:u[0],y:u[1],z:s===3?u[2]:void 0});const w={nodes:[Object.assign(Object.assign({},g[0]),{data:Object.assign(Object.assign({},g[0].data),{x:u[0],y:u[1],z:s===3?u[2]:void 0})})],edges:p};return this.lastResult=w,w}const v=g.map(w=>ye(w,[o,a])),m=new ue({nodes:v,edges:p}),d={};if(c&&v.forEach(w=>{const b=w.data[f];d[b]||(d[b]={name:b,cx:0,cy:0,count:0})}),this.lastLayoutNodes=v,this.lastLayoutEdges=p,this.lastAssign=t,this.lastGraph=m,this.lastOptions=i,this.lastClusterMap=d,typeof window=="undefined")return;let y=0;return new Promise(w=>{this.timeInterval=window.setInterval(()=>{if(!this.running){w({nodes:v,edges:p});return}this.runOneStep(m,d,i),t&&v.forEach(({id:b,data:x})=>e.mergeNodeData(b,{x:x.x,y:x.y,z:s===3?x.z:void 0})),h==null||h({nodes:v,edges:p}),y++,y>=l&&(window.clearInterval(this.timeInterval),w({nodes:v,edges:p}))},0),this.running=!0})})}formatOptions(t={}){const e=Object.assign(Object.assign({},this.options),t),{clustering:r,nodeClusterBy:i}=e,{center:s,width:o,height:a}=e;return e.width=!o&&typeof window!="undefined"?window.innerWidth:o,e.height=!a&&typeof window!="undefined"?window.innerHeight:a,e.center=s||[e.width/2,e.height/2],e.clustering=r&&!!i,e}runOneStep(t,e,r){const{dimensions:i,height:s,width:o,gravity:a,center:u,speed:c,clustering:f,nodeClusterBy:l,clusterGravity:h}=r,g=s*o,p=Math.sqrt(g)/10,v=t.getAllNodes(),m=g/(v.length+1),d=Math.sqrt(m),y={};if(this.applyCalculate(t,y,d,m),f){for(const b in e)e[b].cx=0,e[b].cy=0,e[b].count=0;v.forEach(b=>{const{data:x}=b,M=e[x[l]];V(x.x)&&(M.cx+=x.x),V(x.y)&&(M.cy+=x.y),M.count++});for(const b in e)e[b].cx/=e[b].count,e[b].cy/=e[b].count;const w=h||a;v.forEach((b,x)=>{const{id:M,data:N}=b;if(!V(N.x)||!V(N.y))return;const E=e[N[l]],O=Math.sqrt((N.x-E.cx)*(N.x-E.cx)+(N.y-E.cy)*(N.y-E.cy)),_=d*w;y[M].x-=_*(N.x-E.cx)/O,y[M].y-=_*(N.y-E.cy)/O})}v.forEach((w,b)=>{const{id:x,data:M}=w;if(!V(M.x)||!V(M.y))return;const N=.01*d*a;y[x].x-=N*(M.x-u[0]),y[x].y-=N*(M.y-u[1]),i===3&&(y[x].z-=N*(M.z-u[2]))}),v.forEach((w,b)=>{const{id:x,data:M}=w;if(V(M.fx)&&V(M.fy)){M.x=M.fx,M.y=M.fy,i===3&&(M.z=M.fz);return}if(!V(M.x)||!V(M.y))return;const N=Math.sqrt(y[x].x*y[x].x+y[x].y*y[x].y+(i===3?y[x].z*y[x].z:0));if(N>0){const E=Math.min(p*(c/LS),N);t.mergeNodeData(x,{x:M.x+y[x].x/N*E,y:M.y+y[x].y/N*E,z:i===3?M.z+y[x].z/N*E:void 0})}})}applyCalculate(t,e,r,i){this.calRepulsive(t,e,i),this.calAttractive(t,e,r)}calRepulsive(t,e,r){const i=t.getAllNodes();i.forEach(({data:s,id:o},a)=>{e[o]={x:0,y:0,z:0},i.forEach(({data:u,id:c},f)=>{if(a<=f||!V(s.x)||!V(u.x)||!V(s.y)||!V(u.y))return;let l=s.x-u.x,h=s.y-u.y,g=this.options.dimensions===3?s.z-u.z:0,p=l*l+h*h+g*g;p===0&&(p=1,l=.01,h=.01,g=.01);const v=r/p,m=l*v,d=h*v,y=g*v;e[o].x+=m,e[o].y+=d,e[c].x-=m,e[c].y-=d,this.options.dimensions===3&&(e[o].z+=y,e[c].z-=y)})})}calAttractive(t,e,r){t.getAllEdges().forEach(s=>{const{source:o,target:a}=s;if(!o||!a||o===a)return;const{data:u}=t.getNode(o),{data:c}=t.getNode(a);if(!V(c.x)||!V(u.x)||!V(c.y)||!V(u.y))return;const f=c.x-u.x,l=c.y-u.y,h=this.options.dimensions===3?c.z-u.z:0,g=Math.sqrt(f*f+l*l+h*h)/r,p=f*g,v=l*g,m=h*g;e[o].x+=p,e[o].y+=v,e[a].x-=p,e[a].y-=v,this.options.dimensions===3&&(e[o].z+=m,e[a].z-=m)})}}const zS={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};class $S{constructor(t={}){this.options=t,this.id="grid",this.options=Object.assign(Object.assign({},zS),t)}execute(t,e){return P(this,void 0,void 0,function*(){return this.genericGridLayout(!1,t,e)})}assign(t,e){return P(this,void 0,void 0,function*(){yield this.genericGridLayout(!0,t,e)})}genericGridLayout(t,e,r){return P(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),r),{begin:s=[0,0],condense:o,preventOverlapPadding:a,preventOverlap:u,rows:c,cols:f,nodeSpacing:l,nodeSize:h,width:g,height:p,position:v}=i;let{sortBy:m}=i;const d=e.getAllNodes(),y=e.getAllEdges(),w=d==null?void 0:d.length;if(!w||w===1)return nt(e,t,s);const b=d.map(I=>ye(I));m!=="id"&&(!Ct(m)||b[0].data[m]===void 0)&&(m="degree"),m==="degree"?b.sort((I,k)=>e.getDegree(k.id,"both")-e.getDegree(I.id,"both")):m==="id"?b.sort((I,k)=>V(k.id)&&V(I.id)?k.id-I.id:`${I.id}`.localeCompare(`${k.id}`)):b.sort((I,k)=>k.data[m]-I.data[m]);const x=!g&&typeof window!="undefined"?window.innerWidth:g,M=!p&&typeof window!="undefined"?window.innerHeight:p,N=w,E={rows:c,cols:f};if(c!=null&&f!=null)E.rows=c,E.cols=f;else if(c!=null&&f==null)E.rows=c,E.cols=Math.ceil(N/E.rows);else if(c==null&&f!=null)E.cols=f,E.rows=Math.ceil(N/E.cols);else{const I=Math.sqrt(N*M/x);E.rows=Math.round(I),E.cols=Math.round(x/M*I)}if(E.rows=Math.max(E.rows,1),E.cols=Math.max(E.cols,1),E.cols*E.rows>N){const I=Xr(E),k=Zr(E);(I-1)*k>=N?Xr(E,I-1):(k-1)*I>=N&&Zr(E,k-1)}else for(;E.cols*E.rows=N?Zr(E,k+1):Xr(E,I+1)}let O=o?0:x/E.cols,_=o?0:M/E.rows;if(u||l){const I=rt(10,l),k=yn(30,h,!1);b.forEach(F=>{(!F.data.x||!F.data.y)&&(F.data.x=0,F.data.y=0);const A=e.getNode(F.id),[C,D]=Lt(k(A)||30),z=I!==void 0?I(F):a,U=C+z,L=D+z;O=Math.max(O,U),_=Math.max(_,L)})}const S={},q={row:0,col:0},R={};for(let I=0;I{e.mergeNodeData(I.id,{x:I.data.x,y:I.data.y})}),T})}}const Xr=(n,t)=>{let e;const r=n.rows||5,i=n.cols||5;return t==null?e=Math.min(r,i):Math.min(r,i)===n.rows?n.rows=t:n.cols=t,e},Zr=(n,t)=>{let e;const r=n.rows||5,i=n.cols||5;return t==null?e=Math.max(r,i):Math.max(r,i)===n.rows?n.rows=t:n.cols=t,e},rc=(n,t)=>n[`c-${t.row}-${t.col}`]||!1,m0=(n,t)=>n[`c-${t.row}-${t.col}`]=!0,y0=(n,t)=>{const e=n.cols||5;t.col++,t.col>=e&&(t.col=0,t.row++)},FS=(n,t,e,r,i,s,o,a)=>{let u,c;const f=i[n.id];if(f)u=f.col*e+e/2+t[0],c=f.row*r+r/2+t[1];else{for(;rc(a,o);)y0(s,o);u=o.col*e+e/2+t[0],c=o.row*r+r/2+t[1],m0(a,o),y0(s,o)}n.data.x=u,n.data.y=c},BS=(n,t,e)=>{try{const r=We.mul(We.pow(t,2),-.5),i=r.mean("row"),s=r.mean("column"),o=r.mean();r.add(o).subRowVector(i).subColumnVector(s);const a=new Mf(r),u=We.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map(c=>We.mul([c],[u]).toJSON()[0].splice(0,n))}catch(r){const i=[];for(let s=0;s{const e=Object.assign(Object.assign({},GS),t),{positions:r,iterations:i,width:s,k:o,speed:a=100,strictRadial:u,focusIdx:c,radii:f=[],nodeSizeFunc:l}=e,h=n.getAllNodes(),g=[],p=s/10;for(let v=0;v{g[d]={x:0,y:0}}),WS(h,r,g,o,f,l),YS(r,g,a,u,c,p,s,f);return r},WS=(n,t,e,r,i,s)=>{t.forEach((o,a)=>{e[a]={x:0,y:0},t.forEach((u,c)=>{if(a===c||i[a]!==i[c])return;let f=o.x-u.x,l=o.y-u.y,h=Math.sqrt(f*f+l*l);if(h===0){h=1;const g=a>c?1:-1;f=.01*g,l=.01*g}if(h{const u=s||o/10;return r&&t.forEach((c,f)=>{const l=n[f].x-n[i].x,h=n[f].y-n[i].y,g=Math.sqrt(l*l+h*h);let p=h/g,v=-l/g;const m=Math.sqrt(c.x*c.x+c.y*c.y);let d=Math.acos((p*c.x+v*c.y)/m);d>Math.PI/2&&(d-=Math.PI/2,p*=-1,v*=-1);const y=Math.cos(d)*m;c.x=p*y,c.y=v*y}),n.forEach((c,f)=>{if(f===i)return;const l=Math.sqrt(t[f].x*t[f].x+t[f].y*t[f].y);if(l>0&&f!==i){const h=Math.min(u*(e/US),l);if(c.x+=t[f].x/l*h,c.y+=t[f].y/l*h,r){let g=c.x-n[i].x,p=c.y-n[i].y;const v=Math.sqrt(g*g+p*p);g=g/v*a[f],p=p/v*a[f],c.x=n[i].x+g,c.y=n[i].y+p}}}),n},KS={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10};class XS{constructor(t={}){this.options=t,this.id="radial",this.options=Object.assign(Object.assign({},KS),t)}execute(t,e){return P(this,void 0,void 0,function*(){return this.genericRadialLayout(!1,t,e)})}assign(t,e){return P(this,void 0,void 0,function*(){yield this.genericRadialLayout(!0,t,e)})}genericRadialLayout(t,e,r){return P(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),r),{width:s,height:o,center:a,focusNode:u,unitRadius:c,nodeSize:f,nodeSpacing:l,strictRadial:h,preventOverlap:g,maxPreventOverlapIteration:p,sortBy:v,linkDistance:m=50,sortStrength:d=10,maxIteration:y=1e3}=i,w=e.getAllNodes(),b=e.getAllEdges(),x=!s&&typeof window!="undefined"?window.innerWidth:s,M=!o&&typeof window!="undefined"?window.innerHeight:o,N=a||[x/2,M/2];if(!(w!=null&&w.length)||w.length===1)return nt(e,t,N);let E=w[0];if(Ct(u)){for(let G=0;GN[0]?N[0]:x-N[0],I=M-N[1]>N[1]?N[1]:M-N[1];T===0&&(T=x/2),I===0&&(I=M/2);const k=Math.min(T,I),F=Math.max(...R),A=[],C=c||k/F;R.forEach((G,le)=>{A[le]=G*C});const D=ZS(w,S,m,A,C,v,d),z=JS(D),U=BS(m,D,m);let L=U.map(([G,le])=>({x:(isNaN(G)?Math.random()*m:G)-U[O][0],y:(isNaN(le)?Math.random()*m:le)-U[O][1]}));this.run(y,L,z,D,A,O);let $;if(g){$=wn(f,l);const G={nodes:w,nodeSizeFunc:$,positions:L,radii:A,height:M,width:x,strictRadial:!!h,focusIdx:O,iterations:p||200,k:L.length/4.5};L=VS(e,G)}const B=[];return L.forEach((G,le)=>{const _e=ye(w[le]);_e.data.x=G.x+N[0],_e.data.y=G.y+N[1],B.push(_e)}),t&&B.forEach(G=>e.mergeNodeData(G.id,{x:G.data.x,y:G.data.y})),{nodes:B,edges:b}})}run(t,e,r,i,s,o){for(let a=0;a<=t;a++){const u=a/t;this.oneIteration(u,e,s,i,r,o)}}oneIteration(t,e,r,i,s,o){const a=1-t;e.forEach((u,c)=>{const f=rf(u,{x:0,y:0}),l=f===0?0:1/f;if(c===o)return;let h=0,g=0,p=0;e.forEach((m,d)=>{if(c===d)return;const y=rf(u,m),w=y===0?0:1/y,b=i[d][c];p+=s[c][d],h+=s[c][d]*(m.x+b*(u.x-m.x)*w),g+=s[c][d]*(m.y+b*(u.y-m.y)*w)});const v=r[c]===0?0:1/r[c];p*=a,p+=t*v*v,h*=a,h+=t*v*u.x*l,u.x=h/p,g*=a,g+=t*v*u.y*l,u.y=g/p})}}const ZS=(n,t,e,r,i,s,o)=>{if(!n)return[];const a=[];{const u={};t.forEach((c,f)=>{const l=[];c.forEach((h,g)=>{var p,v;if(f===g)l.push(0);else if(r[f]===r[g])if(s==="data")l.push(h*(Math.abs(f-g)*o)/(r[f]/i));else if(s){let m,d;if(u[n[f].id])m=u[n[f].id];else{const y=(s==="id"?n[f].id:(p=n[f].data)===null||p===void 0?void 0:p[s])||0;Ct(y)?m=y.charCodeAt(0):m=y,u[n[f].id]=m}if(u[n[g].id])d=u[n[g].id];else{const y=(s==="id"?n[g].id:(v=n[g].data)===null||v===void 0?void 0:v[s])||0;Ct(y)?d=y.charCodeAt(0):d=y,u[n[g].id]=d}l.push(h*(Math.abs(m-d)*o)/(r[f]/i))}else l.push(h*e/(r[f]/i));else{const m=(e+i)/2;l.push(h*m)}}),a.push(l)})}return a},JS=n=>{const t=n.length,e=n[0].length,r=[];for(let i=0;i{let e=-1;return n.forEach((r,i)=>{r.id===t&&(e=i)}),Math.max(e,0)},HS=(n,t,e)=>{const r=n.length;for(let i=0;i{let e=0;for(let r=0;re?n[t][r]:e);return e},tR={center:[0,0],width:300,height:300};class rR{constructor(t={}){this.options=t,this.id="random",this.options=Object.assign(Object.assign({},tR),t)}execute(t,e){return P(this,void 0,void 0,function*(){return this.genericRandomLayout(!1,t,e)})}assign(t,e){return P(this,void 0,void 0,function*(){yield this.genericRandomLayout(!0,t,e)})}genericRandomLayout(t,e,r){return P(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),r),{center:s,width:o,height:a}=i,u=e.getAllNodes(),c=.9,f=!o&&typeof window!="undefined"?window.innerWidth:o,l=!a&&typeof window!="undefined"?window.innerHeight:a,h=s||[f/2,l/2],g=[];return u&&u.forEach(v=>{g.push({id:v.id,data:{x:(Math.random()-.5)*c*f+h[0],y:(Math.random()-.5)*c*l+h[1]}})}),t&&g.forEach(v=>e.mergeNodeData(v.id,{x:v.data.x,y:v.data.y})),{nodes:g,edges:e.getAllEdges()}})}}const nR={circular:Uy,concentric:bn,mds:Sf,random:rR,grid:$S,radial:XS,force:cf,d3force:Pf,"d3-force-3d":Vb,fruchterman:DS,forceAtlas2:CS,dagre:Kr,antvDagre:$y,comboCombined:F1};let Ue;sn({stopLayout(){Ue!=null&&Ue.stop&&Ue.stop()},calculateLayout(n,t){return P(this,void 0,void 0,function*(){const{layout:{id:e,options:r,iterations:i},nodes:s,edges:o}=n,a=new ue({nodes:s,edges:o}),u=nR[e];if(u)Ue=new u(r);else throw new Error(`Unknown layout id: ${e}`);let c=yield Ue.execute(a);return Rf(Ue)&&(Ue.stop(),c=Ue.tick(i)),[c,t]})}})})();