irr-gh 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ (function(){"use strict";function c0(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r}function ye(e,t,r,n){function i(s){return s instanceof r?s:new r(function(a){a(s)})}return new(r||(r=Promise))(function(s,a){function o(l){try{f(n.next(l))}catch(p){a(p)}}function c(l){try{f(n.throw(l))}catch(p){a(p)}}function f(l){l.done?s(l.value):i(l.value).then(o,c)}f((n=n.apply(e,t||[])).next())})}typeof SuppressedError=="function"&&SuppressedError;var f0="*",l0=(function(){function e(){this._events={}}return e.prototype.on=function(t,r,n){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:r,once:!!n}),this},e.prototype.once=function(t,r){return this.on(t,r,!0)},e.prototype.emit=function(t){for(var r=this,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var s=this._events[t]||[],a=this._events[f0]||[],o=function(c){for(var f=c.length,l=0;l<f;l++)if(c[l]){var p=c[l],v=p.callback,y=p.once;y&&(c.splice(l,1),c.length===0&&delete r._events[t],f--,l--),v.apply(r,n)}};o(s),o(a)},e.prototype.off=function(t,r){if(!t)this._events={};else if(!r)delete this._events[t];else{for(var n=this._events[t]||[],i=n.length,s=0;s<i;s++)n[s].callback===r&&(n.splice(s,1),i--,s--);n.length===0&&delete this._events[t]}return this},e.prototype.getEvents=function(){return this._events},e})();function en(e,t,r,n){for(;e.length;){const i=e.shift();if(r(i))return!0;t.add(i.id),n(i.id).forEach(a=>{t.has(a.id)||(t.add(a.id),e.push(a))})}return!1}function gr(e,t,r,n){if(r(e))return!0;t.add(e.id);for(const s of n(e.id))if(!t.has(s.id)&&gr(s,t,r,n))return!0;return!1}const mc=()=>!0;class h0{graph;nodeFilter;edgeFilter;cacheEnabled;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;allNodesMap=new Map;allEdgesMap=new Map;constructor(t){this.graph=t.graph;const r=t.nodeFilter||mc,n=t.edgeFilter||mc;this.nodeFilter=r,this.edgeFilter=i=>{const{source:s,target:a}=this.graph.getEdgeDetail(i.id);return!r(s)||!r(a)?!1:n(i,s,a)},t.cache==="auto"?(this.cacheEnabled=!0,this.startAutoCache()):t.cache==="manual"?this.cacheEnabled=!0:this.cacheEnabled=!1}clearCache=()=>{this.inEdgesMap.clear(),this.outEdgesMap.clear(),this.bothEdgesMap.clear(),this.allNodesMap.clear(),this.allEdgesMap.clear()};refreshCache=()=>{this.clearCache(),this.updateCache(this.graph.getAllNodes().map(t=>t.id))};updateCache=t=>{const r=new Set;t.forEach(n=>{const i=this.bothEdgesMap.get(n);if(i&&i.forEach(s=>r.add(s.id)),!this.hasNode(n))this.inEdgesMap.delete(n),this.outEdgesMap.delete(n),this.bothEdgesMap.delete(n),this.allNodesMap.delete(n);else{const s=this.graph.getRelatedEdges(n,"in").filter(this.edgeFilter),a=this.graph.getRelatedEdges(n,"out").filter(this.edgeFilter),o=Array.from(new Set([...s,...a]));o.forEach(c=>r.add(c.id)),this.inEdgesMap.set(n,s),this.outEdgesMap.set(n,a),this.bothEdgesMap.set(n,o),this.allNodesMap.set(n,this.graph.getNode(n))}}),r.forEach(n=>{this.hasEdge(n)?this.allEdgesMap.set(n,this.graph.getEdge(n)):this.allEdgesMap.delete(n)})};startAutoCache(){this.refreshCache(),this.graph.on("changed",this.handleGraphChanged)}stopAutoCache(){this.graph.off("changed",this.handleGraphChanged)}handleGraphChanged=t=>{const r=new Set;t.changes.forEach(n=>{switch(n.type){case"NodeAdded":r.add(n.value.id);break;case"NodeDataUpdated":r.add(n.id);break;case"EdgeAdded":r.add(n.value.source),r.add(n.value.target);break;case"EdgeUpdated":(n.propertyName==="source"||n.propertyName==="target")&&(r.add(n.oldValue),r.add(n.newValue));break;case"EdgeDataUpdated":if(t.graph.hasEdge(n.id)){const i=t.graph.getEdge(n.id);r.add(i.source),r.add(i.target)}break;case"EdgeRemoved":r.add(n.value.source),r.add(n.value.target);break;case"NodeRemoved":r.add(n.value.id);break}}),this.updateCache(r)};checkNodeExistence(t){this.getNode(t)}hasNode(t){if(!this.graph.hasNode(t))return!1;const r=this.graph.getNode(t);return this.nodeFilter(r)}areNeighbors(t,r){return this.checkNodeExistence(t),this.getNeighbors(r).some(n=>n.id===t)}getNode(t){const r=this.graph.getNode(t);if(!this.nodeFilter(r))throw new Error("Node not found for id: "+t);return r}getRelatedEdges(t,r){return this.checkNodeExistence(t),this.cacheEnabled?r==="in"?this.inEdgesMap.get(t):r==="out"?this.outEdgesMap.get(t):this.bothEdgesMap.get(t):this.graph.getRelatedEdges(t,r).filter(this.edgeFilter)}getDegree(t,r){return this.getRelatedEdges(t,r).length}getSuccessors(t){const n=this.getRelatedEdges(t,"out").map(i=>this.getNode(i.target));return Array.from(new Set(n))}getPredecessors(t){const n=this.getRelatedEdges(t,"in").map(i=>this.getNode(i.source));return Array.from(new Set(n))}getNeighbors(t){const r=this.getPredecessors(t),n=this.getSuccessors(t);return Array.from(new Set([...r,...n]))}hasEdge(t){if(!this.graph.hasEdge(t))return!1;const r=this.graph.getEdge(t);return this.edgeFilter(r)}getEdge(t){const r=this.graph.getEdge(t);if(!this.edgeFilter(r))throw new Error("Edge not found for id: "+t);return r}getEdgeDetail(t){const r=this.getEdge(t);return{edge:r,source:this.getNode(r.source),target:this.getNode(r.target)}}hasTreeStructure(t){return this.graph.hasTreeStructure(t)}getRoots(t){return this.graph.getRoots(t).filter(this.nodeFilter)}getChildren(t,r){return this.checkNodeExistence(t),this.graph.getChildren(t,r).filter(this.nodeFilter)}getParent(t,r){this.checkNodeExistence(t);const n=this.graph.getParent(t,r);return!n||!this.nodeFilter(n)?null:n}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,r,n="out"){const i={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];en([this.getNode(t)],new Set,r,i)}dfs(t,r,n="out"){const i={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];gr(this.getNode(t),new Set,r,i)}}class De extends l0{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){super(),t&&(t.nodes&&this.addNodes(t.nodes),t.edges&&this.addEdges(t.edges),t.tree&&this.addTree(t.tree),t.onChanged&&(this.onChanged=t.onChanged))}batch=t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()};commit(){const t=this.changes;this.changes=[];const r={graph:this,changes:t};this.emit("changed",r),this.onChanged(r)}reduceChanges(t){let r=[];return t.forEach(n=>{switch(n.type){case"NodeRemoved":{let i=!1;r=r.filter(s=>{if(s.type==="NodeAdded"){const a=s.value.id===n.value.id;return a&&(i=!0),!a}else{if(s.type==="NodeDataUpdated")return s.id!==n.value.id;if(s.type==="TreeStructureChanged")return s.nodeId!==n.value.id}return!0}),i||r.push(n);break}case"EdgeRemoved":{let i=!1;r=r.filter(s=>{if(s.type==="EdgeAdded"){const a=s.value.id===n.value.id;return a&&(i=!0),!a}else if(s.type==="EdgeDataUpdated"||s.type==="EdgeUpdated")return s.id!==n.value.id;return!0}),i||r.push(n);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const i=r.findIndex(a=>a.type===n.type&&a.id===n.id&&(n.propertyName===void 0||a.propertyName===n.propertyName)),s=r[i];s?n.propertyName!==void 0?s.newValue=n.newValue:(r.splice(i,1),r.push(n)):r.push(n);break}case"TreeStructureDetached":{r=r.filter(i=>i.type==="TreeStructureAttached"||i.type==="TreeStructureChanged"?i.treeKey!==n.treeKey:!0),r.push(n);break}case"TreeStructureChanged":{const i=r.find(s=>s.type==="TreeStructureChanged"&&s.treeKey===n.treeKey&&s.nodeId===n.nodeId);i?i.newParentId=n.newParentId:r.push(n);break}default:r.push(n);break}}),r}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,r){return this.getNeighbors(r).some(n=>n.id===t)}getNode(t){const r=this.nodeMap.get(t);if(!r)throw new Error("Node not found for id: "+t);return r}getRelatedEdges(t,r){if(this.checkNodeExistence(t),r==="in"){const n=this.inEdgesMap.get(t);return Array.from(n)}else if(r==="out"){const n=this.outEdgesMap.get(t);return Array.from(n)}else{const n=this.bothEdgesMap.get(t);return Array.from(n)}}getDegree(t,r){return this.getRelatedEdges(t,r).length}getSuccessors(t){const n=this.getRelatedEdges(t,"out").map(i=>this.getNode(i.target));return Array.from(new Set(n))}getPredecessors(t){const n=this.getRelatedEdges(t,"in").map(i=>this.getNode(i.source));return Array.from(new Set(n))}getNeighbors(t){const r=this.getPredecessors(t),n=this.getSuccessors(t);return Array.from(new Set([...r,...n]))}doAddNode(t){if(this.hasNode(t.id))throw new Error("Node already exists: "+t.id);this.nodeMap.set(t.id,t),this.inEdgesMap.set(t.id,new Set),this.outEdgesMap.set(t.id,new Set),this.bothEdgesMap.set(t.id,new Set),this.treeIndices.forEach(r=>{r.childrenMap.set(t.id,new Set)}),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch(()=>{for(const r of t)this.doAddNode(r)})}addNode(t){this.addNodes([t])}doRemoveNode(t){const r=this.getNode(t);this.bothEdgesMap.get(t)?.forEach(i=>this.doRemoveEdge(i.id)),this.nodeMap.delete(t),this.treeIndices.forEach(i=>{i.childrenMap.get(t)?.forEach(a=>{i.parentMap.delete(a.id)});const s=i.parentMap.get(t);s&&i.childrenMap.get(s.id)?.delete(r),i.parentMap.delete(t),i.childrenMap.delete(t)}),this.bothEdgesMap.delete(t),this.inEdgesMap.delete(t),this.outEdgesMap.delete(t),this.changes.push({type:"NodeRemoved",value:r})}removeNodes(t){this.batch(()=>{t.forEach(r=>this.doRemoveNode(r))})}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,r,n){const i=this.getNode(t);this.batch(()=>{const s=i.data[r],a=n;i.data[r]=a,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:r,oldValue:s,newValue:a})})}mergeNodeData(t,r){this.batch(()=>{Object.entries(r).forEach(([n,i])=>{this.updateNodeDataProperty(t,n,i)})})}updateNodeData(...t){const r=t[0],n=this.getNode(r);if(typeof t[1]=="string"){this.updateNodeDataProperty(r,t[1],t[2]);return}let i;if(typeof t[1]=="function"){const s=t[1];i=s(n.data)}else typeof t[1]=="object"&&(i=t[1]);this.batch(()=>{const s=n.data,a=i;n.data=i,this.changes.push({type:"NodeDataUpdated",id:r,oldValue:s,newValue:a})})}checkEdgeExistence(t){if(!this.hasEdge(t))throw new Error("Edge not found for id: "+t)}hasEdge(t){return this.edgeMap.has(t)}getEdge(t){return this.checkEdgeExistence(t),this.edgeMap.get(t)}getEdgeDetail(t){const r=this.getEdge(t);return{edge:r,source:this.getNode(r.source),target:this.getNode(r.target)}}doAddEdge(t){if(this.hasEdge(t.id))throw new Error("Edge already exists: "+t.id);this.checkNodeExistence(t.source),this.checkNodeExistence(t.target),this.edgeMap.set(t.id,t);const r=this.inEdgesMap.get(t.target),n=this.outEdgesMap.get(t.source),i=this.bothEdgesMap.get(t.source),s=this.bothEdgesMap.get(t.target);r.add(t),n.add(t),i.add(t),s.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch(()=>{for(const r of t)this.doAddEdge(r)})}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const r=this.getEdge(t),n=this.outEdgesMap.get(r.source),i=this.inEdgesMap.get(r.target),s=this.bothEdgesMap.get(r.source),a=this.bothEdgesMap.get(r.target);n.delete(r),i.delete(r),s.delete(r),a.delete(r),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:r})}removeEdges(t){this.batch(()=>{t.forEach(r=>this.doRemoveEdge(r))})}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,r){const n=this.getEdge(t);this.checkNodeExistence(r);const i=n.source,s=r;this.outEdgesMap.get(i).delete(n),this.bothEdgesMap.get(i).delete(n),this.outEdgesMap.get(s).add(n),this.bothEdgesMap.get(s).add(n),n.source=r,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:i,newValue:s})})}updateEdgeTarget(t,r){const n=this.getEdge(t);this.checkNodeExistence(r);const i=n.target,s=r;this.inEdgesMap.get(i).delete(n),this.bothEdgesMap.get(i).delete(n),this.inEdgesMap.get(s).add(n),this.bothEdgesMap.get(s).add(n),n.target=r,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:i,newValue:s})})}updateEdgeDataProperty(t,r,n){const i=this.getEdge(t);this.batch(()=>{const s=i.data[r],a=n;i.data[r]=a,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:r,oldValue:s,newValue:a})})}updateEdgeData(...t){const r=t[0],n=this.getEdge(r);if(typeof t[1]=="string"){this.updateEdgeDataProperty(r,t[1],t[2]);return}let i;if(typeof t[1]=="function"){const s=t[1];i=s(n.data)}else typeof t[1]=="object"&&(i=t[1]);this.batch(()=>{const s=n.data,a=i;n.data=i,this.changes.push({type:"EdgeDataUpdated",id:r,oldValue:s,newValue:a})})}mergeEdgeData(t,r){this.batch(()=>{Object.entries(r).forEach(([n,i])=>{this.updateEdgeDataProperty(t,n,i)})})}checkTreeExistence(t){if(!this.hasTreeStructure(t))throw new Error("Tree structure not found for treeKey: "+t)}hasTreeStructure(t){return this.treeIndices.has(t)}attachTreeStructure(t){this.treeIndices.has(t)||(this.treeIndices.set(t,{parentMap:new Map,childrenMap:new Map}),this.batch(()=>{this.changes.push({type:"TreeStructureAttached",treeKey:t})}))}detachTreeStructure(t){this.checkTreeExistence(t),this.treeIndices.delete(t),this.batch(()=>{this.changes.push({type:"TreeStructureDetached",treeKey:t})})}addTree(t,r){this.batch(()=>{this.attachTreeStructure(r);const n=[],i=Array.isArray(t)?t:[t];for(;i.length;){const s=i.shift();n.push(s),s.children&&i.push(...s.children)}this.addNodes(n),n.forEach(s=>{s.children?.forEach(a=>{this.setParent(a.id,s.id,r)})})})}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter(r=>!this.getParent(r.id,t))}getChildren(t,r){this.checkNodeExistence(t),this.checkTreeExistence(r);const i=this.treeIndices.get(r).childrenMap.get(t);return Array.from(i||[])}getParent(t,r){return this.checkNodeExistence(t),this.checkTreeExistence(r),this.treeIndices.get(r).parentMap.get(t)||null}getAncestors(t,r){const n=[];let i=this.getNode(t),s;for(;s=this.getParent(i.id,r);)n.push(s),i=s;return n}setParent(t,r,n){this.checkTreeExistence(n);const i=this.treeIndices.get(n);if(!i)return;const s=this.getNode(t),a=i.parentMap.get(t);if(a?.id===r)return;if(r==null){a&&i.childrenMap.get(a.id)?.delete(s),i.parentMap.delete(t);return}const o=this.getNode(r);i.parentMap.set(t,o),a&&i.childrenMap.get(a.id)?.delete(s);let c=i.childrenMap.get(o.id);c||(c=new Set,i.childrenMap.set(o.id,c)),c.add(s),this.batch(()=>{this.changes.push({type:"TreeStructureChanged",treeKey:n,nodeId:t,oldParentId:a?.id,newParentId:o.id})})}dfsTree(t,r,n){const i=s=>this.getChildren(s,n);return gr(this.getNode(t),new Set,r,i)}bfsTree(t,r,n){const i=s=>this.getChildren(s,n);return en([this.getNode(t)],new Set,r,i)}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,r,n="out"){const i={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return en([this.getNode(t)],new Set,r,i)}dfs(t,r,n="out"){const i={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return gr(this.getNode(t),new Set,r,i)}clone(){const t=this.getAllNodes().map(i=>({...i,data:{...i.data}})),r=this.getAllEdges().map(i=>({...i,data:{...i.data}})),n=new De({nodes:t,edges:r});return this.treeIndices.forEach(({parentMap:i,childrenMap:s},a)=>{const o=new Map;i.forEach((f,l)=>{o.set(l,n.getNode(f.id))});const c=new Map;s.forEach((f,l)=>{c.set(l,new Set(Array.from(f).map(p=>n.getNode(p.id))))}),n.treeIndices.set(a,{parentMap:o,childrenMap:c})}),n}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}createView(t){return new h0({graph:this,...t})}}const yc=Symbol("Comlink.proxy"),d0=Symbol("Comlink.endpoint"),g0=Symbol("Comlink.releaseProxy"),tn=Symbol("Comlink.finalizer"),pr=Symbol("Comlink.thrown"),wc=e=>typeof e=="object"&&e!==null||typeof e=="function",p0={canHandle:e=>wc(e)&&e[yc],serialize(e){const{port1:t,port2:r}=new MessageChannel;return rn(e,t),[r,[r]]},deserialize(e){return e.start(),w0(e)}},v0={canHandle:e=>wc(e)&&pr in e,serialize({value:e}){let t;return e instanceof Error?t={isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:t={isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}},bc=new Map([["proxy",p0],["throw",v0]]);function m0(e,t){for(const r of e)if(t===r||r==="*"||r instanceof RegExp&&r.test(t))return!0;return!1}function rn(e,t=globalThis,r=["*"]){t.addEventListener("message",function n(i){if(!i||!i.data)return;if(!m0(r,i.origin)){console.warn(`Invalid origin '${i.origin}' for comlink proxy`);return}const{id:s,type:a,path:o}=Object.assign({path:[]},i.data),c=(i.data.argumentList||[]).map(Ot);let f;try{const l=o.slice(0,-1).reduce((v,y)=>v[y],e),p=o.reduce((v,y)=>v[y],e);switch(a){case"GET":f=p;break;case"SET":l[o.slice(-1)[0]]=Ot(i.data.value),f=!0;break;case"APPLY":f=p.apply(l,c);break;case"CONSTRUCT":{const v=new p(...c);f=N0(v)}break;case"ENDPOINT":{const{port1:v,port2:y}=new MessageChannel;rn(e,y),f=x0(v,[v])}break;case"RELEASE":f=void 0;break;default:return}}catch(l){f={value:l,[pr]:0}}Promise.resolve(f).catch(l=>({value:l,[pr]:0})).then(l=>{const[p,v]=wr(l);t.postMessage(Object.assign(Object.assign({},p),{id:s}),v),a==="RELEASE"&&(t.removeEventListener("message",n),_c(t),tn in e&&typeof e[tn]=="function"&&e[tn]())}).catch(l=>{const[p,v]=wr({value:new TypeError("Unserializable return value"),[pr]:0});t.postMessage(Object.assign(Object.assign({},p),{id:s}),v)})}),t.start&&t.start()}function y0(e){return e.constructor.name==="MessagePort"}function _c(e){y0(e)&&e.close()}function w0(e,t){const r=new Map;return e.addEventListener("message",function(i){const{data:s}=i;if(!s||!s.id)return;const a=r.get(s.id);if(a)try{a(s)}finally{r.delete(s.id)}}),nn(e,r,[],t)}function vr(e){if(e)throw new Error("Proxy has been released and is not useable")}function Ec(e){return Dt(e,new Map,{type:"RELEASE"}).then(()=>{_c(e)})}const mr=new WeakMap,yr="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{const t=(mr.get(e)||0)-1;mr.set(e,t),t===0&&Ec(e)});function b0(e,t){const r=(mr.get(t)||0)+1;mr.set(t,r),yr&&yr.register(e,t,e)}function _0(e){yr&&yr.unregister(e)}function nn(e,t,r=[],n=function(){}){let i=!1;const s=new Proxy(n,{get(a,o){if(vr(i),o===g0)return()=>{_0(s),Ec(e),t.clear(),i=!0};if(o==="then"){if(r.length===0)return{then:()=>s};const c=Dt(e,t,{type:"GET",path:r.map(f=>f.toString())}).then(Ot);return c.then.bind(c)}return nn(e,t,[...r,o])},set(a,o,c){vr(i);const[f,l]=wr(c);return Dt(e,t,{type:"SET",path:[...r,o].map(p=>p.toString()),value:f},l).then(Ot)},apply(a,o,c){vr(i);const f=r[r.length-1];if(f===d0)return Dt(e,t,{type:"ENDPOINT"}).then(Ot);if(f==="bind")return nn(e,t,r.slice(0,-1));const[l,p]=xc(c);return Dt(e,t,{type:"APPLY",path:r.map(v=>v.toString()),argumentList:l},p).then(Ot)},construct(a,o){vr(i);const[c,f]=xc(o);return Dt(e,t,{type:"CONSTRUCT",path:r.map(l=>l.toString()),argumentList:c},f).then(Ot)}});return b0(s,e),s}function E0(e){return Array.prototype.concat.apply([],e)}function xc(e){const t=e.map(wr);return[t.map(r=>r[0]),E0(t.map(r=>r[1]))]}const Nc=new WeakMap;function x0(e,t){return Nc.set(e,t),e}function N0(e){return Object.assign(e,{[yc]:!0})}function wr(e){for(const[t,r]of bc)if(r.canHandle(e)){const[n,i]=r.serialize(e);return[{type:"HANDLER",name:t,value:n},i]}return[{type:"RAW",value:e},Nc.get(e)||[]]}function Ot(e){switch(e.type){case"HANDLER":return bc.get(e.name).deserialize(e.value);case"RAW":return e.value}}function Dt(e,t,r,n){return new Promise(i=>{const s=M0();t.set(s,i),e.start&&e.start(),e.postMessage(Object.assign({id:s},r),n)})}function M0(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}function gt(e){return typeof e=="function"}function S0(e){return e==null}function sn(e){return Array.isArray(e)}var zt=(function(e){var t=typeof e;return e!==null&&t==="object"||t==="function"});function q0(e,t){if(e){var r;if(sn(e))for(var n=0,i=e.length;n<i&&(r=t(e[n],n),r!==!1);n++);else if(zt(e)){for(var s in e)if(e.hasOwnProperty(s)&&(r=t(e[s],s),r===!1))break}}}var R0=function(e){return typeof e=="object"&&e!==null},O0={}.toString,A0=function(e,t){return O0.call(e)==="[object "+t+"]"},on=function(e){if(!R0(e)||!A0(e,"Object"))return!1;if(Object.getPrototypeOf(e)===null)return!0;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t};function Qt(e){return typeof e=="string"}function ve(e){return typeof e=="number"}var br=function(e){if(typeof e!="object"||e===null)return e;var t;if(sn(e)){t=[];for(var r=0,n=e.length;r<n;r++)typeof e[r]=="object"&&e[r]!=null?t[r]=br(e[r]):t[r]=e[r]}else{t={};for(var i in e)typeof e[i]=="object"&&e[i]!=null?t[i]=br(e[i]):t[i]=e[i]}return t},I0=5;function T0(e,t){if(Object.hasOwn)return Object.hasOwn(e,t);if(e==null)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(Object(e),t)}function Mc(e,t,r,n){r=r||0,n=n||I0;for(var i in t)if(T0(t,i)){var s=t[i];s!==null&&on(s)?(on(e[i])||(e[i]={}),r<n?Mc(e[i],s,r+1,n):e[i]=t[i]):sn(s)?(e[i]=[],e[i]=e[i].concat(s)):s!==void 0&&(e[i]=s)}}var Sc=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];for(var n=0;n<t.length;n+=1)Mc(e,t[n]);return e},k0=Object.prototype.hasOwnProperty,qc=(function(e,t){if(e===null||!on(e))return{};var r={};return q0(t,function(n){k0.call(e,n)&&(r[n]=e[n])}),r});const j0=(e,t)=>{if(e!=="next"&&e!=="prev")return t},Rc=e=>{e.prev.next=e.next,e.next.prev=e.prev,delete e.next,delete e.prev};let C0=class{constructor(){const t={};t.prev=t,t.next=t.prev,this.shortcut=t}dequeue(){const t=this.shortcut,r=t.prev;if(r&&r!==t)return Rc(r),r}enqueue(t){const r=this.shortcut;t.prev&&t.next&&Rc(t),t.next=r.next,r.next.prev=t,r.next=t,t.prev=r}toString(){const t=[],r=this.shortcut;let n=r.prev;for(;n!==r;)t.push(JSON.stringify(n,j0)),n=n?.prev;return`[${t.join(", ")}]`}};class P0 extends C0{}const L0=()=>1,D0=(e,t)=>{var r;if(e.getAllNodes().length<=1)return[];const n=F0(e,t||L0);return(r=z0(n.graph,n.buckets,n.zeroIdx).map(s=>e.getRelatedEdges(s.v,"out").filter(({target:a})=>a===s.w)))===null||r===void 0?void 0:r.flat()},z0=(e,t,r)=>{let n=[];const i=t[t.length-1],s=t[0];let a;for(;e.getAllNodes().length;){for(;a=s.dequeue();)an(e,t,r,a);for(;a=i.dequeue();)an(e,t,r,a);if(e.getAllNodes().length){for(let o=t.length-2;o>0;--o)if(a=t[o].dequeue(),a){n=n.concat(an(e,t,r,a,!0));break}}}return n},an=(e,t,r,n,i)=>{var s,a;const o=[];return e.hasNode(n.v)&&((s=e.getRelatedEdges(n.v,"in"))===null||s===void 0||s.forEach(c=>{const f=c.data.weight,l=e.getNode(c.source);i&&o.push({v:c.source,w:c.target,in:0,out:0}),l.data.out===void 0&&(l.data.out=0),l.data.out-=f,un(t,r,Object.assign({v:l.id},l.data))}),(a=e.getRelatedEdges(n.v,"out"))===null||a===void 0||a.forEach(c=>{const f=c.data.weight,l=c.target,p=e.getNode(l);p.data.in===void 0&&(p.data.in=0),p.data.in-=f,un(t,r,Object.assign({v:p.id},p.data))}),e.removeNode(n.v)),i?o:void 0},F0=(e,t)=>{const r=new De;let n=0,i=0;e.getAllNodes().forEach(c=>{r.addNode({id:c.id,data:{v:c.id,in:0,out:0}})}),e.getAllEdges().forEach(c=>{const f=r.getRelatedEdges(c.source,"out").find(p=>p.target===c.target),l=t?.(c)||1;f?r.updateEdgeData(f?.id,Object.assign(Object.assign({},f.data),{weight:f.data.weight+l})):r.addEdge({id:c.id,source:c.source,target:c.target,data:{weight:l}}),i=Math.max(i,r.getNode(c.source).data.out+=l),n=Math.max(n,r.getNode(c.target).data.in+=l)});const s=[],a=i+n+3;for(let c=0;c<a;c++)s.push(new P0);const o=n+1;return r.getAllNodes().forEach(c=>{un(s,o,Object.assign({v:c.id},r.getNode(c.id).data))}),{buckets:s,zeroIdx:o,graph:r}},un=(e,t,r)=>{r.out?r.in?e[r.out-r.in+t].enqueue(r):e[e.length-1].enqueue(r):e[0].enqueue(r)},B0=(e,t)=>{const n=D0(e,(i=>s=>s.data.weight||1)());n?.forEach(i=>{const s=i.data;e.removeEdge(i.id),s.forwardName=i.data.name,s.reversed=!0,e.addEdge({id:i.id,source:i.target,target:i.source,data:Object.assign({},s)})})},$0=e=>{e.getAllEdges().forEach(t=>{const r=t.data;if(r.reversed){e.removeEdge(t.id);const n=r.forwardName;delete r.reversed,delete r.forwardName,e.addEdge({id:t.id,source:t.target,target:t.source,data:Object.assign(Object.assign({},r),{forwardName:n})})}})},G0=(e,t)=>Number(e)-Number(t),Ft=(e,t,r,n)=>{let i;do i=`${n}${Math.random()}`;while(e.hasNode(i));return r.dummy=t,e.addNode({id:i,data:r}),i},U0=e=>{const t=new De;return e.getAllNodes().forEach(r=>{t.addNode(Object.assign({},r))}),e.getAllEdges().forEach(r=>{const n=t.getRelatedEdges(r.source,"out").find(i=>i.target===r.target);n?t.updateEdgeData(n?.id,Object.assign(Object.assign({},n.data),{weight:n.data.weight+r.data.weight||0,minlen:Math.max(n.data.minlen,r.data.minlen||1)})):t.addEdge({id:r.id,source:r.source,target:r.target,data:{weight:r.data.weight||0,minlen:r.data.minlen||1}})}),t},Oc=e=>{const t=new De;return e.getAllNodes().forEach(r=>{e.getChildren(r.id).length||t.addNode(Object.assign({},r))}),e.getAllEdges().forEach(r=>{t.addEdge(r)}),t},V0=(e,t)=>e?.reduce((r,n,i)=>(r[n]=t[i],r),{}),Ac=(e,t)=>{const r=Number(e.x),n=Number(e.y),i=Number(t.x)-r,s=Number(t.y)-n;let a=Number(e.width)/2,o=Number(e.height)/2;if(!i&&!s)return{x:0,y:0};let c,f;return Math.abs(s)*a>Math.abs(i)*o?(s<0&&(o=-o),c=o*i/s,f=o):(i<0&&(a=-a),c=a,f=a*s/i),{x:r+c,y:n+f}},Ht=e=>{const t=[],r=Tc(e)+1;for(let n=0;n<r;n++)t.push([]);e.getAllNodes().forEach(n=>{const i=n.data.rank;i!==void 0&&t[i]&&t[i].push(n.id)});for(let n=0;n<r;n++)t[n]=t[n].sort((i,s)=>G0(e.getNode(i).data.order,e.getNode(s).data.order));return t},W0=e=>{const t=e.getAllNodes().filter(n=>n.data.rank!==void 0).map(n=>n.data.rank),r=Math.min(...t);e.getAllNodes().forEach(n=>{n.data.hasOwnProperty("rank")&&r!==1/0&&(n.data.rank-=r)})},Y0=(e,t=0)=>{const r=e.getAllNodes(),n=r.filter(o=>o.data.rank!==void 0).map(o=>o.data.rank),i=Math.min(...n),s=[];r.forEach(o=>{const c=(o.data.rank||0)-i;s[c]||(s[c]=[]),s[c].push(o.id)});let a=0;for(let o=0;o<s.length;o++){const c=s[o];c===void 0?o%t!==0&&(a-=1):a&&c?.forEach(f=>{const l=e.getNode(f);l&&(l.data.rank=l.data.rank||0,l.data.rank+=a)})}},Ic=(e,t,r,n)=>{const i={width:0,height:0};return ve(r)&&ve(n)&&(i.rank=r,i.order=n),Ft(e,"border",i,t)},Tc=e=>{let t;return e.getAllNodes().forEach(r=>{const n=r.data.rank;n!==void 0&&(t===void 0||n>t)&&(t=n)}),t||(t=0),t},K0=(e,t)=>{const r={lhs:[],rhs:[]};return e?.forEach(n=>{t(n)?r.lhs.push(n):r.rhs.push(n)}),r},cn=(e,t)=>e.reduce((r,n)=>{const i=t(r),s=t(n);return i>s?n:r}),kc=(e,t,r,n,i,s)=>{n.includes(t.id)||(n.push(t.id),r||s.push(t.id),i(t.id).forEach(a=>kc(e,a,r,n,i,s)),r&&s.push(t.id))},jc=(e,t,r,n)=>{const i=Array.isArray(t)?t:[t],s=c=>e.getNeighbors(c),a=[],o=[];return i.forEach(c=>{if(e.hasNode(c.id))kc(e,c,r==="post",o,s,a);else throw new Error(`Graph does not have node: ${c}`)}),a},X0=e=>{const t=r=>{const n=e.getChildren(r),i=e.getNode(r);if(n?.length&&n.forEach(s=>t(s.id)),i.data.hasOwnProperty("minRank")){i.data.borderLeft=[],i.data.borderRight=[];for(let s=i.data.minRank,a=i.data.maxRank+1;s<a;s+=1)Cc(e,"borderLeft","_bl",r,i,s),Cc(e,"borderRight","_br",r,i,s)}};e.getRoots().forEach(r=>t(r.id))},Cc=(e,t,r,n,i,s)=>{const a={rank:s,borderType:t,width:0,height:0},o=i.data[t][s-1],c=Ft(e,"border",a,r);i.data[t][s]=c,e.setParent(c,n),o&&e.addEdge({id:`e${Math.random()}`,source:o,target:c,data:{weight:1}})},Z0=(e,t)=>{const r=t.toLowerCase();(r==="lr"||r==="rl")&&Pc(e)},J0=(e,t)=>{const r=t.toLowerCase();(r==="bt"||r==="rl")&&Q0(e),(r==="lr"||r==="rl")&&(H0(e),Pc(e))},Pc=e=>{e.getAllNodes().forEach(t=>{Lc(t)}),e.getAllEdges().forEach(t=>{Lc(t)})},Lc=e=>{const t=e.data.width;e.data.width=e.data.height,e.data.height=t},Q0=e=>{e.getAllNodes().forEach(t=>{fn(t.data)}),e.getAllEdges().forEach(t=>{var r;(r=t.data.points)===null||r===void 0||r.forEach(n=>fn(n)),t.data.hasOwnProperty("y")&&fn(t.data)})},fn=e=>{e?.y&&(e.y=-e.y)},H0=e=>{e.getAllNodes().forEach(t=>{ln(t.data)}),e.getAllEdges().forEach(t=>{var r;(r=t.data.points)===null||r===void 0||r.forEach(n=>ln(n)),t.data.hasOwnProperty("x")&&ln(t.data)})},ln=e=>{const t=e.x;e.x=e.y,e.y=t},em=e=>{const t=Ft(e,"root",{},"_root"),r=tm(e);let n=Math.max(...Object.values(r));Math.abs(n)===1/0&&(n=1);const i=n-1,s=2*i+1;e.getAllEdges().forEach(o=>{o.data.minlen*=s});const a=rm(e)+1;return e.getRoots().forEach(o=>{Dc(e,t,s,a,i,r,o.id)}),{nestingRoot:t,nodeRankFactor:s}},Dc=(e,t,r,n,i,s,a)=>{const o=e.getChildren(a);if(!o?.length){a!==t&&e.addEdge({id:`e${Math.random()}`,source:t,target:a,data:{weight:0,minlen:r}});return}const c=Ic(e,"_bt"),f=Ic(e,"_bb"),l=e.getNode(a);e.setParent(c,a),l.data.borderTop=c,e.setParent(f,a),l.data.borderBottom=f,o?.forEach(p=>{Dc(e,t,r,n,i,s,p.id);const v=p.data.borderTop?p.data.borderTop:p.id,y=p.data.borderBottom?p.data.borderBottom:p.id,x=p.data.borderTop?n:2*n,_=v!==y?1:i-s[a]+1;e.addEdge({id:`e${Math.random()}`,source:c,target:v,data:{minlen:_,weight:x,nestingEdge:!0}}),e.addEdge({id:`e${Math.random()}`,source:y,target:f,data:{minlen:_,weight:x,nestingEdge:!0}})}),e.getParent(a)||e.addEdge({id:`e${Math.random()}`,source:t,target:c,data:{weight:0,minlen:i+s[a]}})},tm=e=>{const t={},r=(n,i)=>{const s=e.getChildren(n);s?.forEach(a=>r(a.id,i+1)),t[n]=i};return e.getRoots().forEach(n=>r(n.id,1)),t},rm=e=>{let t=0;return e.getAllEdges().forEach(r=>{t+=r.data.weight}),t},nm=(e,t)=>{t&&e.removeNode(t),e.getAllEdges().forEach(r=>{r.data.nestingEdge&&e.removeEdge(r.id)})},im="edge",zc="edge-label",sm=(e,t)=>{e.getAllEdges().forEach(r=>om(e,r,t))},om=(e,t,r)=>{let n=t.source,i=e.getNode(n).data.rank;const s=t.target,a=e.getNode(s).data.rank,o=t.data.labelRank;if(a===i+1)return;e.removeEdge(t.id);let c,f,l;for(l=0,++i;i<a;++l,++i)t.data.points=[],f={originalEdge:t,width:0,height:0,rank:i},c=Ft(e,im,f,"_d"),i===o&&(f.width=t.data.width,f.height=t.data.height,f.dummy=zc,f.labelpos=t.data.labelpos),e.addEdge({id:`e${Math.random()}`,source:n,target:c,data:{weight:t.data.weight}}),l===0&&r.push(c),n=c;e.addEdge({id:`e${Math.random()}`,source:n,target:s,data:{weight:t.data.weight}})},am=(e,t)=>{t.forEach(r=>{let n=e.getNode(r);const{data:i}=n,s=i.originalEdge;let a;s&&e.addEdge(s);let o=r;for(;n.data.dummy;)a=e.getSuccessors(o)[0],e.removeNode(o),s.data.points.push({x:n.data.x,y:n.data.y}),n.data.dummy===zc&&(s.data.x=n.data.x,s.data.y=n.data.y,s.data.width=n.data.width,s.data.height=n.data.height),o=a.id,n=e.getNode(o)})},um=(e,t,r)=>{const n={};let i;r?.forEach(s=>{let a=e.getParent(s),o,c;for(;a;){if(o=e.getParent(a.id),o?(c=n[o.id],n[o.id]=a.id):(c=i,i=a.id),c&&c!==a.id){t.hasNode(c)||t.addNode({id:c,data:{}}),t.hasNode(a.id)||t.addNode({id:a.id,data:{}}),t.hasEdge(`e${c}-${a.id}`)||t.addEdge({id:`e${c}-${a.id}`,source:c,target:a.id,data:{}});return}a=o}})},cm=(e,t,r)=>{const n=fm(e),i=new De({tree:[{id:n,children:[],data:{}}]});return e.getAllNodes().forEach(s=>{const a=e.getParent(s.id);(s.data.rank===t||s.data.minRank<=t&&t<=s.data.maxRank)&&(i.hasNode(s.id)||i.addNode(Object.assign({},s)),a?.id&&!i.hasNode(a?.id)&&i.addNode(Object.assign({},a)),i.setParent(s.id,a?.id||n),e.getRelatedEdges(s.id,r).forEach(o=>{const c=o.source===s.id?o.target:o.source;i.hasNode(c)||i.addNode(Object.assign({},e.getNode(c)));const f=i.getRelatedEdges(c,"out").find(({target:p})=>p===s.id),l=f!==void 0?f.data.weight:0;f?i.updateEdgeData(f.id,Object.assign(Object.assign({},f.data),{weight:o.data.weight+l})):i.addEdge({id:o.id,source:c,target:s.id,data:{weight:o.data.weight+l}})}),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},fm=e=>{let t;for(;e.hasNode(t=`_root${Math.random()}`););return t},lm=(e,t,r)=>{const n=V0(r,r.map((l,p)=>p)),s=t.map(l=>{const p=e.getRelatedEdges(l,"out").map(v=>({pos:n[v.target]||0,weight:v.data.weight}));return p?.sort((v,y)=>v.pos-y.pos)}).flat().filter(l=>l!==void 0);let a=1;for(;a<r.length;)a<<=1;const o=2*a-1;a-=1;const c=Array(o).fill(0,0,o);let f=0;return s?.forEach(l=>{if(l){let p=l.pos+a;c[p]+=l.weight;let v=0;for(;p>0;)p%2&&(v+=c[p+1]),p=p-1>>1,c[p]+=l.weight;f+=l.weight*v}}),f},Fc=(e,t)=>{let r=0;for(let n=1;n<t?.length;n+=1)r+=lm(e,t[n-1],t[n]);return r},Bc=e=>{const t={},r=e.getAllNodes(),n=r.map(f=>{var l;return(l=f.data.rank)!==null&&l!==void 0?l:-1/0}),i=Math.max(...n),s=[];for(let f=0;f<i+1;f++)s.push([]);const a=r.sort((f,l)=>e.getNode(f.id).data.rank-e.getNode(l.id).data.rank),c=a.filter(f=>e.getNode(f.id).data.fixorder!==void 0).sort((f,l)=>e.getNode(f.id).data.fixorder-e.getNode(l.id).data.fixorder);return c?.forEach(f=>{isNaN(e.getNode(f.id).data.rank)||s[e.getNode(f.id).data.rank].push(f.id),t[f.id]=!0}),a?.forEach(f=>e.dfsTree(f.id,l=>{if(t.hasOwnProperty(l.id))return!0;t[l.id]=!0,isNaN(l.data.rank)||s[l.data.rank].push(l.id)})),s},hm=(e,t)=>t.map(r=>{const n=e.getRelatedEdges(r,"in");if(!n?.length)return{v:r};const i={sum:0,weight:0};return n?.forEach(s=>{const a=e.getNode(s.source);i.sum+=s.data.weight*a.data.order,i.weight+=s.data.weight}),{v:r,barycenter:i.sum/i.weight,weight:i.weight}}),dm=(e,t)=>{var r,n,i;const s={};e?.forEach((o,c)=>{s[o.v]={i:c,indegree:0,in:[],out:[],vs:[o.v]};const f=s[o.v];o.barycenter!==void 0&&(f.barycenter=o.barycenter,f.weight=o.weight)}),(r=t.getAllEdges())===null||r===void 0||r.forEach(o=>{const c=s[o.source],f=s[o.target];c!==void 0&&f!==void 0&&(f.indegree++,c.out.push(s[o.target]))});const a=(i=(n=Object.values(s)).filter)===null||i===void 0?void 0:i.call(n,o=>!o.indegree);return gm(a)},gm=e=>{var t,r;const n=[],i=c=>f=>{f.merged||(f.barycenter===void 0||c.barycenter===void 0||f.barycenter>=c.barycenter)&&pm(c,f)},s=c=>f=>{f.in.push(c),--f.indegree===0&&e.push(f)};for(;e?.length;){const c=e.pop();n.push(c),(t=c.in.reverse())===null||t===void 0||t.forEach(f=>i(c)(f)),(r=c.out)===null||r===void 0||r.forEach(f=>s(c)(f))}const a=n.filter(c=>!c.merged),o=["vs","i","barycenter","weight"];return a.map(c=>{const f={};return o?.forEach(l=>{c[l]!==void 0&&(f[l]=c[l])}),f})},pm=(e,t)=>{var r;let n=0,i=0;e.weight&&(n+=e.barycenter*e.weight,i+=e.weight),t.weight&&(n+=t.barycenter*t.weight,i+=t.weight),e.vs=(r=t.vs)===null||r===void 0?void 0:r.concat(e.vs),e.barycenter=n/i,e.weight=i,e.i=Math.min(t.i,e.i),t.merged=!0},vm=(e,t,r,n)=>{const i=K0(e,v=>{const y=v.hasOwnProperty("fixorder")&&!isNaN(v.fixorder);return n?!y&&v.hasOwnProperty("barycenter"):y||v.hasOwnProperty("barycenter")}),s=i.lhs,a=i.rhs.sort((v,y)=>-v.i- -y.i),o=[];let c=0,f=0,l=0;s?.sort(mm(!!t,!!r)),l=$c(o,a,l),s?.forEach(v=>{var y;l+=(y=v.vs)===null||y===void 0?void 0:y.length,o.push(v.vs),c+=v.barycenter*v.weight,f+=v.weight,l=$c(o,a,l)});const p={vs:o.flat()};return f&&(p.barycenter=c/f,p.weight=f),p},$c=(e,t,r)=>{let n=r,i;for(;t.length&&(i=t[t.length-1]).i<=n;)t.pop(),e?.push(i.vs),n++;return n},mm=(e,t)=>(r,n)=>{if(r.fixorder!==void 0&&n.fixorder!==void 0)return r.fixorder-n.fixorder;if(r.barycenter<n.barycenter)return-1;if(r.barycenter>n.barycenter)return 1;if(t&&r.order!==void 0&&n.order!==void 0){if(r.order<n.order)return-1;if(r.order>n.order)return 1}return e?n.i-r.i:r.i-n.i},Gc=(e,t,r,n,i,s)=>{var a,o,c,f;let l=e.getChildren(t).map(E=>E.id);const p=e.getNode(t),v=p?p.data.borderLeft:void 0,y=p?p.data.borderRight:void 0,x={};v&&(l=l?.filter(E=>E!==v&&E!==y));const _=hm(e,l||[]);_?.forEach(E=>{var N;if(!((N=e.getChildren(E.v))===null||N===void 0)&&N.length){const S=Gc(e,E.v,r,n,s);x[E.v]=S,S.hasOwnProperty("barycenter")&&wm(E,S)}});const b=dm(_,r);ym(b,x),(a=b.filter(E=>E.vs.length>0))===null||a===void 0||a.forEach(E=>{const N=e.getNode(E.vs[0]);N&&(E.fixorder=N.data.fixorder,E.order=N.data.order)});const w=vm(b,n,i,s);if(v&&(w.vs=[v,w.vs,y].flat(),!((o=e.getPredecessors(v))===null||o===void 0)&&o.length)){const E=e.getNode(((c=e.getPredecessors(v))===null||c===void 0?void 0:c[0].id)||""),N=e.getNode(((f=e.getPredecessors(y))===null||f===void 0?void 0:f[0].id)||"");w.hasOwnProperty("barycenter")||(w.barycenter=0,w.weight=0),w.barycenter=(w.barycenter*w.weight+E.data.order+N.data.order)/(w.weight+2),w.weight+=2}return w},ym=(e,t)=>{e?.forEach(r=>{var n;const i=(n=r.vs)===null||n===void 0?void 0:n.map(s=>t[s]?t[s].vs:s);r.vs=i.flat()})},wm=(e,t)=>{e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)},bm=(e,t)=>{const r=Tc(e),n=[],i=[];for(let l=1;l<r+1;l++)n.push(l);for(let l=r-1;l>-1;l--)i.push(l);const s=Uc(e,n,"in"),a=Uc(e,i,"out");let o=Bc(e);hn(e,o);let c=Number.POSITIVE_INFINITY,f;for(let l=0,p=0;p<4;++l,++p){Vc(l%2?s:a,l%4>=2,!1,t),o=Ht(e);const v=Fc(e,o);v<c&&(p=0,f=br(o),c=v)}o=Bc(e),hn(e,o);for(let l=0,p=0;p<4;++l,++p){Vc(l%2?s:a,l%4>=2,!0,t),o=Ht(e);const v=Fc(e,o);v<c&&(p=0,f=br(o),c=v)}hn(e,f)},Uc=(e,t,r)=>t.map(n=>cm(e,n,r)),Vc=(e,t,r,n)=>{const i=new De;e?.forEach(s=>{var a;const o=s.getRoots()[0].id,c=Gc(s,o,i,t,r,n);for(let f=0;f<((a=c.vs)===null||a===void 0?void 0:a.length);f++){const l=s.getNode(c.vs[f]);l&&(l.data.order=f)}um(s,i,c.vs)})},hn=(e,t)=>{t?.forEach(r=>{r?.forEach((n,i)=>{e.getNode(n).data.order=i})})},_m=(e,t)=>{const n=e.getAllNodes().filter(a=>{var o;return!(!((o=e.getChildren(a.id))===null||o===void 0)&&o.length)}).map(a=>a.data.rank),i=Math.max(...n),s=[];for(let a=0;a<i+1;a++)s[a]=[];t?.forEach(a=>{const o=e.getNode(a);!o||o.data.dummy||isNaN(o.data.rank)||(o.data.fixorder=s[o.data.rank].length,s[o.data.rank].push(a))})},Em=e=>{const t={};let r=0;const n=i=>{const s=r;e.getChildren(i).forEach(a=>n(a.id)),t[i]={low:s,lim:r++}};return e.getRoots().forEach(i=>n(i.id)),t},xm=(e,t,r,n)=>{var i,s;const a=[],o=[],c=Math.min(t[r].low,t[n].low),f=Math.max(t[r].lim,t[n].lim);let l,p;l=r;do l=(i=e.getParent(l))===null||i===void 0?void 0:i.id,a.push(l);while(l&&(t[l].low>c||f>t[l].lim));for(p=l,l=n;l&&l!==p;)o.push(l),l=(s=e.getParent(l))===null||s===void 0?void 0:s.id;return{lca:p,path:a.concat(o.reverse())}},Nm=(e,t)=>{const r=Em(e);t.forEach(n=>{var i,s;let a=n,o=e.getNode(a);const c=o.data.originalEdge;if(!c)return;const f=xm(e,r,c.source,c.target),l=f.path,p=f.lca;let v=0,y=l[v],x=!0;for(;a!==c.target;){if(o=e.getNode(a),x){for(;y!==p&&((i=e.getNode(y))===null||i===void 0?void 0:i.data.maxRank)<o.data.rank;)v++,y=l[v];y===p&&(x=!1)}if(!x){for(;v<l.length-1&&((s=e.getNode(l[v+1]))===null||s===void 0?void 0:s.data.minRank)<=o.data.rank;)v++;y=l[v]}e.hasNode(y)&&e.setParent(a,y),a=e.getSuccessors(a)[0].id}})},Mm=(e,t)=>{const r={},n=(i,s)=>{let a=0,o=0;const c=i.length,f=s?.[s?.length-1];return s?.forEach((l,p)=>{var v;const y=qm(e,l),x=y?e.getNode(y.id).data.order:c;(y||l===f)&&((v=s.slice(o,p+1))===null||v===void 0||v.forEach(_=>{var b;(b=e.getPredecessors(_))===null||b===void 0||b.forEach(w=>{var E;const N=e.getNode(w.id),S=N.data.order;(S<a||x<S)&&!(N.data.dummy&&(!((E=e.getNode(_))===null||E===void 0)&&E.data.dummy))&&Wc(r,w.id,_)})}),o=p+1,a=x)}),s};return t?.length&&t.reduce(n),r},Sm=(e,t)=>{const r={};function n(o,c,f,l,p){var v,y;let x;for(let _=c;_<f;_++)x=o[_],!((v=e.getNode(x))===null||v===void 0)&&v.data.dummy&&((y=e.getPredecessors(x))===null||y===void 0||y.forEach(b=>{const w=e.getNode(b.id);w.data.dummy&&(w.data.order<l||w.data.order>p)&&Wc(r,b.id,x)}))}function i(o){return JSON.stringify(o.slice(1))}function s(o,c){const f=i(o);c.get(f)||(n(...o),c.set(f,!0))}const a=(o,c)=>{let f=-1,l,p=0;const v=new Map;return c?.forEach((y,x)=>{var _;if(((_=e.getNode(y))===null||_===void 0?void 0:_.data.dummy)==="border"){const b=e.getPredecessors(y)||[];b.length&&(l=e.getNode(b[0].id).data.order,s([c,p,x,f,l],v),p=x,f=l)}s([c,p,c.length,l,o.length],v)}),c};return t?.length&&t.reduce(a),r},qm=(e,t)=>{var r,n;if(!((r=e.getNode(t))===null||r===void 0)&&r.data.dummy)return(n=e.getPredecessors(t))===null||n===void 0?void 0:n.find(i=>e.getNode(i.id).data.dummy)},Wc=(e,t,r)=>{let n=t,i=r;if(n>i){const a=n;n=i,i=a}let s=e[n];s||(e[n]=s={}),s[i]=!0},Rm=(e,t,r)=>{let n=t,i=r;if(n>i){const s=t;n=i,i=s}return!!e[n]},Om=(e,t,r,n)=>{const i={},s={},a={};return t?.forEach(o=>{o?.forEach((c,f)=>{i[c]=c,s[c]=c,a[c]=f})}),t?.forEach(o=>{let c=-1;o?.forEach(f=>{let l=n(f).map(p=>p.id);if(l.length){l=l.sort((v,y)=>a[v]-a[y]);const p=(l.length-1)/2;for(let v=Math.floor(p),y=Math.ceil(p);v<=y;++v){const x=l[v];s[f]===f&&c<a[x]&&!Rm(r,f,x)&&(s[x]=f,s[f]=i[f]=i[x],c=a[x])}}})}),{root:i,align:s}},Am=(e,t,r,n,i,s,a)=>{var o;const c={},f=Im(e,t,r,i,s,a),l=a?"borderLeft":"borderRight",p=(x,_)=>{let b=f.getAllNodes(),w=b.pop();const E={};for(;w;)E[w.id]?x(w.id):(E[w.id]=!0,b.push(w),b=b.concat(_(w.id))),w=b.pop()},v=x=>{c[x]=(f.getRelatedEdges(x,"in")||[]).reduce((_,b)=>Math.max(_,(c[b.source]||0)+b.data.weight),0)},y=x=>{const _=(f.getRelatedEdges(x,"out")||[]).reduce((w,E)=>Math.min(w,(c[E.target]||0)-E.data.weight),Number.POSITIVE_INFINITY),b=e.getNode(x);_!==Number.POSITIVE_INFINITY&&b.data.borderType!==l&&(c[x]=Math.max(c[x],_))};return p(v,f.getPredecessors.bind(f)),p(y,f.getSuccessors.bind(f)),(o=Object.values(n))===null||o===void 0||o.forEach(x=>{c[x]=c[r[x]]}),c},Im=(e,t,r,n,i,s)=>{const a=new De,o=Cm(n,i,s);return t?.forEach(c=>{let f;c?.forEach(l=>{const p=r[l];if(a.hasNode(p)||a.addNode({id:p,data:{}}),f){const v=r[f],y=a.getRelatedEdges(v,"out").find(x=>x.target===p);y?a.updateEdgeData(y.id,Object.assign(Object.assign({},y.data),{weight:Math.max(o(e,l,f),y.data.weight||0)})):a.addEdge({id:`e${Math.random()}`,source:v,target:p,data:{weight:Math.max(o(e,l,f),0)}})}f=l})}),a},Tm=(e,t)=>cn(Object.values(t),r=>{var n;let i=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY;return(n=Object.keys(r))===null||n===void 0||n.forEach(a=>{const o=r[a],c=Pm(e,a)/2;i=Math.max(o+c,i),s=Math.min(o-c,s)}),i-s});function km(e,t){const r=Object.values(t),n=Math.min(...r),i=Math.max(...r);["u","d"].forEach(s=>{["l","r"].forEach(a=>{const o=s+a,c=e[o];let f;if(c===t)return;const l=Object.values(c);f=a==="l"?n-Math.min(...l):i-Math.max(...l),f&&(e[o]={},Object.keys(c).forEach(p=>{e[o][p]=c[p]+f}))})})}const jm=(e,t)=>{const r={};return Object.keys(e.ul).forEach(n=>{if(t)r[n]=e[t.toLowerCase()][n];else{const i=Object.values(e).map(s=>s[n]);r[n]=(i[0]+i[1])/2}}),r},Cm=(e,t,r)=>(n,i,s)=>{const a=n.getNode(i),o=n.getNode(s);let c=0,f=0;if(c+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":f=-a.data.width/2;break;case"r":f=a.data.width/2;break}if(f&&(c+=r?f:-f),f=0,c+=(a.data.dummy?t:e)/2,c+=(o.data.dummy?t:e)/2,c+=o.data.width/2,o.data.labelpos)switch((o.data.labelpos||"").toLowerCase()){case"l":f=o.data.width/2;break;case"r":f=-o.data.width/2;break}return f&&(c+=r?f:-f),f=0,c},Pm=(e,t)=>e.getNode(t).data.width||0,Lm=(e,t)=>{const{ranksep:r=0}=t||{},n=Ht(e);let i=0;n?.forEach(s=>{const a=s.map(c=>e.getNode(c).data.height),o=Math.max(...a,0);s?.forEach(c=>{e.getNode(c).data.y=i+o/2}),i+=o+r})},Dm=(e,t)=>{const{align:r,nodesep:n=0,edgesep:i=0}=t||{},s=Ht(e),a=Object.assign(Mm(e,s),Sm(e,s)),o={};let c=[];["u","d"].forEach(l=>{c=l==="u"?s:Object.values(s).reverse(),["l","r"].forEach(p=>{p==="r"&&(c=c.map(_=>Object.values(_).reverse()));const v=(l==="u"?e.getPredecessors:e.getSuccessors).bind(e),y=Om(e,c,a,v),x=Am(e,c,y.root,y.align,n,i,p==="r");p==="r"&&Object.keys(x).forEach(_=>x[_]=-x[_]),o[l+p]=x})});const f=Tm(e,o);return f&&km(o,f),jm(o,r)},zm=(e,t)=>{var r;const n=Oc(e);Lm(n,t);const i=Dm(n,t);(r=Object.keys(i))===null||r===void 0||r.forEach(s=>{n.getNode(s).data.x=i[s]})},Yc=e=>{const t={},r=n=>{var i;const s=e.getNode(n);if(!s)return 0;if(t[n])return s.data.rank;t[n]=!0;let a;return(i=e.getRelatedEdges(n,"out"))===null||i===void 0||i.forEach(o=>{const c=r(o.target),f=o.data.minlen,l=c-f;l&&(a===void 0||l<a)&&(a=l)}),a||(a=0),s.data.rank=a,a};e.getAllNodes().filter(n=>e.getRelatedEdges(n.id,"in").length===0).forEach(n=>r(n.id))},Fm=e=>{const t={};let r;const n=a=>{var o;const c=e.getNode(a);if(!c)return 0;if(t[a])return c.data.rank;t[a]=!0;let f;return(o=e.getRelatedEdges(a,"out"))===null||o===void 0||o.forEach(l=>{const p=n(l.target),v=l.data.minlen,y=p-v;y&&(f===void 0||y<f)&&(f=y)}),f||(f=0),(r===void 0||f<r)&&(r=f),c.data.rank=f,f};e.getAllNodes().filter(a=>e.getRelatedEdges(a.id,"in").length===0).forEach(a=>{a&&n(a.id)}),r===void 0&&(r=0);const i={},s=(a,o)=>{var c;const f=e.getNode(a),l=isNaN(f.data.layer)?o:f.data.layer;(f.data.rank===void 0||f.data.rank<l)&&(f.data.rank=l),!i[a]&&(i[a]=!0,(c=e.getRelatedEdges(a,"out"))===null||c===void 0||c.forEach(p=>{s(p.target,l+p.data.minlen)}))};e.getAllNodes().forEach(a=>{const o=a.data;o&&(isNaN(o.layer)?o.rank-=r:s(a.id,o.layer))})},Nt=(e,t)=>e.getNode(t.target).data.rank-e.getNode(t.source).data.rank-t.data.minlen,Bm=e=>{const t=new De({tree:[]}),r=e.getAllNodes()[0],n=e.getAllNodes().length;t.addNode(r);let i,s;for(;$m(t,e)<n;)i=Kc(t,e),s=t.hasNode(i.source)?Nt(e,i):-Nt(e,i),Xc(t,e,s);return t},$m=(e,t)=>{const r=n=>{t.getRelatedEdges(n,"both").forEach(i=>{const s=i.source,a=n===s?i.target:s;!e.hasNode(a)&&!Nt(t,i)&&(e.addNode({id:a,data:{}}),e.addEdge({id:i.id,source:n,target:a,data:{}}),r(a))})};return e.getAllNodes().forEach(n=>r(n.id)),e.getAllNodes().length},Gm=e=>{const t=new De({tree:[]}),r=e.getAllNodes()[0],n=e.getAllNodes().length;t.addNode(r);let i,s;for(;Um(t,e)<n;)i=Kc(t,e),s=t.hasNode(i.source)?Nt(e,i):-Nt(e,i),Xc(t,e,s);return t},Um=(e,t)=>{const r=n=>{var i;(i=t.getRelatedEdges(n,"both"))===null||i===void 0||i.forEach(s=>{const a=s.source,o=n===a?s.target:a;!e.hasNode(o)&&(t.getNode(o).data.layer!==void 0||!Nt(t,s))&&(e.addNode({id:o,data:{}}),e.addEdge({id:s.id,source:n,target:o,data:{}}),r(o))})};return e.getAllNodes().forEach(n=>r(n.id)),e.getAllNodes().length},Kc=(e,t)=>cn(t.getAllEdges(),r=>e.hasNode(r.source)!==e.hasNode(r.target)?Nt(t,r):1/0),Xc=(e,t,r)=>{e.getAllNodes().forEach(n=>{const i=t.getNode(n.id);i.data.rank||(i.data.rank=0),i.data.rank+=r})},Vm=e=>{const t=U0(e);Yc(t);const r=Bm(t);Jc(r),Zc(r,t);let n,i;for(;n=Km(r);)i=Xm(r,t,n),Zm(r,t,n,i)},Zc=(e,t)=>{let r=jc(e,e.getAllNodes(),"post");r=r.slice(0,r?.length-1),r.forEach(n=>{Wm(e,t,n)})},Wm=(e,t,r)=>{const i=e.getNode(r).data.parent,s=e.getRelatedEdges(r,"both").find(a=>a.target===i||a.source===i);s.data.cutvalue=Ym(e,t,r)},Ym=(e,t,r)=>{const i=e.getNode(r).data.parent;let s=!0,a=t.getRelatedEdges(r,"out").find(c=>c.target===i),o=0;return a||(s=!1,a=t.getRelatedEdges(i,"out").find(c=>c.target===r)),o=a.data.weight,t.getRelatedEdges(r,"both").forEach(c=>{const f=c.source===r,l=f?c.target:c.source;if(l!==i){const p=f===s,v=c.data.weight;if(o+=p?v:-v,Qm(e,r,l)){const y=e.getRelatedEdges(r,"both").find(x=>x.source===l||x.target===l).data.cutvalue;o+=p?-y:y}}}),o},Jc=(e,t=e.getAllNodes()[0].id)=>{Qc(e,{},1,t)},Qc=(e,t,r,n,i)=>{var s;const a=r;let o=r;const c=e.getNode(n);return t[n]=!0,(s=e.getNeighbors(n))===null||s===void 0||s.forEach(f=>{t[f.id]||(o=Qc(e,t,o,f.id,n))}),c.data.low=a,c.data.lim=o++,i?c.data.parent=i:delete c.data.parent,o},Km=e=>e.getAllEdges().find(t=>t.data.cutvalue<0),Xm=(e,t,r)=>{let n=r.source,i=r.target;t.getRelatedEdges(n,"out").find(l=>l.target===i)||(n=r.target,i=r.source);const s=e.getNode(n),a=e.getNode(i);let o=s,c=!1;s.data.lim>a.data.lim&&(o=a,c=!0);const f=t.getAllEdges().filter(l=>c===Hc(e.getNode(l.source),o)&&c!==Hc(e.getNode(l.target),o));return cn(f,l=>Nt(t,l))},Zm=(e,t,r,n)=>{const i=e.getRelatedEdges(r.source,"both").find(s=>s.source===r.target||s.target===r.target);i&&e.removeEdge(i.id),e.addEdge({id:`e${Math.random()}`,source:n.source,target:n.target,data:{}}),Jc(e),Zc(e,t),Jm(e,t)},Jm=(e,t)=>{const r=e.getAllNodes().find(i=>!i.data.parent);let n=jc(e,r,"pre");n=n.slice(1),n.forEach(i=>{const s=e.getNode(i).data.parent;let a=t.getRelatedEdges(i,"out").find(c=>c.target===s),o=!1;!a&&t.hasNode(s)&&(a=t.getRelatedEdges(s,"out").find(c=>c.target===i),o=!0),t.getNode(i).data.rank=(t.hasNode(s)&&t.getNode(s).data.rank||0)+(o?a?.data.minlen:-a?.data.minlen)})},Qm=(e,t,r)=>e.getRelatedEdges(t,"both").find(n=>n.source===r||n.target===r),Hc=(e,t)=>t.data.low<=e.data.lim&&e.data.lim<=t.data.lim,Hm=(e,t)=>{switch(t){case"network-simplex":ty(e);break;case"tight-tree":ef(e);break;case"longest-path":ey(e);break;default:ef(e)}},ey=Yc,ef=e=>{Fm(e),Gm(e)},ty=e=>{Vm(e)},ry=(e,t)=>{const{edgeLabelSpace:r,keepNodeOrder:n,prevGraph:i,rankdir:s,ranksep:a}=t;!n&&i&&iy(e,i);const o=fy(e);r&&(t.ranksep=ly(o,{rankdir:s,ranksep:a}));let c;try{c=ny(o,t)}catch(f){if(f.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:
2
+ `,f);return}throw f}return sy(e,o),c},ny=(e,t)=>{const{ranker:r,rankdir:n="tb",nodeOrder:i,keepNodeOrder:s,align:a,nodesep:o=50,edgesep:c=20,ranksep:f=50}=t;by(e),B0(e);const{nestingRoot:l,nodeRankFactor:p}=em(e);Hm(Oc(e),r),hy(e),Y0(e,p),nm(e,l),W0(e),dy(e),gy(e);const v=[];sm(e,v),Nm(e,v),X0(e),s&&_m(e,i),bm(e,s),_y(e),Z0(e,n),zm(e,{align:a,nodesep:o,edgesep:c,ranksep:f}),Ey(e),wy(e),am(e,v),my(e),J0(e,n);const{width:y,height:x}=py(e);return vy(e),yy(e),$0(e),{width:y,height:x}},iy=(e,t)=>{e.getAllNodes().forEach(r=>{const n=e.getNode(r.id);if(t.hasNode(r.id)){const i=t.getNode(r.id);n.data.fixorder=i.data._order,delete i.data._order}else delete n.data.fixorder})},sy=(e,t)=>{e.getAllNodes().forEach(r=>{var n;const i=e.getNode(r.id);if(i){const s=t.getNode(r.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,!((n=t.getChildren(r.id))===null||n===void 0)&&n.length&&(i.data.width=s.data.width,i.data.height=s.data.height)}}),e.getAllEdges().forEach(r=>{const n=e.getEdge(r.id),i=t.getEdge(r.id);n.data.points=i?i.data.points:[],i&&i.data.hasOwnProperty("x")&&(n.data.x=i.data.x,n.data.y=i.data.y)})},oy=["width","height","layer","fixorder"],ay={width:0,height:0},uy=["minlen","weight","width","height","labeloffset"],cy={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},dn=["labelpos"],fy=e=>{const t=new De({tree:[]});return e.getAllNodes().forEach(r=>{const n=rf(e.getNode(r.id).data),i=Object.assign(Object.assign({},ay),n),s=tf(i,oy);t.hasNode(r.id)||t.addNode({id:r.id,data:Object.assign({},s)});const a=e.hasTreeStructure("combo")?e.getParent(r.id,"combo"):e.getParent(r.id);S0(a)||(t.hasNode(a.id)||t.addNode(Object.assign({},a)),t.setParent(r.id,a.id))}),e.getAllEdges().forEach(r=>{const n=rf(e.getEdge(r.id).data),i={};dn?.forEach(s=>{n[s]!==void 0&&(i[s]=n[s])}),t.addEdge({id:r.id,source:r.source,target:r.target,data:Object.assign({},cy,tf(n,uy),i)})}),t},ly=(e,t)=>{const{ranksep:r=0,rankdir:n}=t;return e.getAllNodes().forEach(i=>{isNaN(i.data.layer)||i.data.layer||(i.data.layer=0)}),e.getAllEdges().forEach(i=>{var s;i.data.minlen*=2,((s=i.data.labelpos)===null||s===void 0?void 0:s.toLowerCase())!=="c"&&(n==="TB"||n==="BT"?i.data.width+=i.data.labeloffset:i.data.height+=i.data.labeloffset)}),r/2},hy=e=>{e.getAllEdges().forEach(t=>{if(t.data.width&&t.data.height){const r=e.getNode(t.source),n=e.getNode(t.target),i={e:t,rank:(n.data.rank-r.data.rank)/2+r.data.rank};Ft(e,"edge-proxy",i,"_ep")}})},dy=e=>{let t=0;return e.getAllNodes().forEach(r=>{var n,i;r.data.borderTop&&(r.data.minRank=(n=e.getNode(r.data.borderTop))===null||n===void 0?void 0:n.data.rank,r.data.maxRank=(i=e.getNode(r.data.borderBottom))===null||i===void 0?void 0:i.data.rank,t=Math.max(t,r.data.maxRank||-1/0))}),t},gy=e=>{e.getAllNodes().forEach(t=>{t.data.dummy==="edge-proxy"&&(e.getEdge(t.data.e.id).data.labelRank=t.data.rank,e.removeNode(t.id))})},py=(e,t)=>{let r,n=0,i,s=0;const{marginx:a=0,marginy:o=0}={},c=f=>{if(!f.data)return;const l=f.data.x,p=f.data.y,v=f.data.width,y=f.data.height;!isNaN(l)&&!isNaN(v)&&(r===void 0&&(r=l-v/2),r=Math.min(r,l-v/2),n=Math.max(n,l+v/2)),!isNaN(p)&&!isNaN(y)&&(i===void 0&&(i=p-y/2),i=Math.min(i,p-y/2),s=Math.max(s,p+y/2))};return e.getAllNodes().forEach(f=>{c(f)}),e.getAllEdges().forEach(f=>{f?.data.hasOwnProperty("x")&&c(f)}),r-=a,i-=o,e.getAllNodes().forEach(f=>{f.data.x-=r,f.data.y-=i}),e.getAllEdges().forEach(f=>{var l;(l=f.data.points)===null||l===void 0||l.forEach(p=>{p.x-=r,p.y-=i}),f.data.hasOwnProperty("x")&&(f.data.x-=r),f.data.hasOwnProperty("y")&&(f.data.y-=i)}),{width:n-r+a,height:s-i+o}},vy=e=>{e.getAllEdges().forEach(t=>{const r=e.getNode(t.source),n=e.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:n.data.x,y:n.data.y},s={x:r.data.x,y:r.data.y}),t.data.points.unshift(Ac(r.data,i)),t.data.points.push(Ac(n.data,s))})},my=e=>{e.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}})},yy=e=>{e.getAllEdges().forEach(t=>{var r;t.data.reversed&&((r=t.data.points)===null||r===void 0||r.reverse())})},wy=e=>{e.getAllNodes().forEach(t=>{var r,n,i;if(!((r=e.getChildren(t.id))===null||r===void 0)&&r.length){const s=e.getNode(t.id),a=e.getNode(s.data.borderTop),o=e.getNode(s.data.borderBottom),c=e.getNode(s.data.borderLeft[((n=s.data.borderLeft)===null||n===void 0?void 0:n.length)-1]),f=e.getNode(s.data.borderRight[((i=s.data.borderRight)===null||i===void 0?void 0:i.length)-1]);s.data.width=Math.abs(f?.data.x-c?.data.x)||10,s.data.height=Math.abs(o?.data.y-a?.data.y)||10,s.data.x=(c?.data.x||0)+s.data.width/2,s.data.y=(a?.data.y||0)+s.data.height/2}}),e.getAllNodes().forEach(t=>{t.data.dummy==="border"&&e.removeNode(t.id)})},by=e=>{e.getAllEdges().forEach(t=>{if(t.source===t.target){const r=e.getNode(t.source);r.data.selfEdges||(r.data.selfEdges=[]),r.data.selfEdges.push(t),e.removeEdge(t.id)}})},_y=e=>{const t=Ht(e);t?.forEach(r=>{let n=0;r?.forEach((i,s)=>{var a;const o=e.getNode(i);o.data.order=s+n,(a=o.data.selfEdges)===null||a===void 0||a.forEach(c=>{Ft(e,"selfedge",{width:c.data.width,height:c.data.height,rank:o.data.rank,order:s+ ++n,e:c},"_se")}),delete o.data.selfEdges})})},Ey=e=>{e.getAllNodes().forEach(t=>{const r=e.getNode(t.id);if(r.data.dummy==="selfedge"){const n=e.getNode(r.data.e.source),i=n.data.x+n.data.width/2,s=n.data.y,a=r.data.x-i,o=n.data.height/2;e.hasEdge(r.data.e.id)?e.updateEdgeData(r.data.e.id,r.data.e.data):e.addEdge({id:r.data.e.id,source:r.data.e.source,target:r.data.e.target,data:r.data.e.data}),e.removeNode(t.id),r.data.e.data.points=[{x:i+2*a/3,y:s-o},{x:i+5*a/6,y:s-o},{y:s,x:i+a},{x:i+5*a/6,y:s+o},{x:i+2*a/3,y:s+o}],r.data.e.data.x=r.data.x,r.data.e.data.y=r.data.y}})},tf=(e,t)=>{const r={};return t?.forEach(n=>{e[n]!==void 0&&(r[n]=+e[n])}),r},rf=(e={})=>{const t={};return Object.keys(e).forEach(r=>{t[r.toLowerCase()]=e[r]}),t},pt=Array.isArray,nf=e=>{const t=[],r=e.length;for(let n=0;n<r;n+=1){t[n]=[];for(let i=0;i<r;i+=1)n===i?t[n][i]=0:e[n][i]===0||!e[n][i]?t[n][i]=1/0:t[n][i]=e[n][i]}for(let n=0;n<r;n+=1)for(let i=0;i<r;i+=1)for(let s=0;s<r;s+=1)t[i][s]>t[i][n]+t[n][s]&&(t[i][s]=t[i][n]+t[n][s]);return t},sf=(e,t)=>{const{nodes:r,edges:n}=e,i=[],s={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((a,o)=>{s[a.id]=o;const c=[];i.push(c)}),n?.forEach(a=>{const{source:o,target:c}=a,f=s[o],l=s[c];f===void 0||l===void 0||(i[f][l]=1,i[l][f]=1)}),i},xy=(e,t)=>{const r=[];return e.forEach(n=>{const i=[];n.forEach(s=>{i.push(s*t)}),r.push(i)}),r},Ny=e=>{let t=1/0,r=1/0,n=-1/0,i=-1/0;return e.forEach(s=>{let a=s.data.size;pt(a)?a.length===1&&(a=[a[0],a[0]]):ve(a)?a=[a,a]:(a===void 0||isNaN(a))&&(a=[30,30]);const o=[a[0]/2,a[1]/2],c=s.data.x-o[0],f=s.data.x+o[0],l=s.data.y-o[1],p=s.data.y+o[1];t>c&&(t=c),r>l&&(r=l),n<f&&(n=f),i<p&&(i=p)}),{minX:t,minY:r,maxX:n,maxY:i}},of=(e,t)=>Math.sqrt((e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y)),gn=(e,t,r,n="TB",i,s={})=>{if(!t?.length)return;const{stopBranchFn:a,stopAllFn:o}=s;for(let c=0;c<t.length;c++){const f=t[c];if(e.hasNode(f.id)&&!a?.(f)){if(o?.(f))return;n==="TB"&&r(f),gn(e,e.getChildren(f.id,i),r,n,i,s),n!=="TB"&&r(f)}}},pn=e=>{if(e===null)return e;if(e instanceof Date)return new Date(e.getTime());if(e instanceof Array){const t=[];return e.forEach(r=>{t.push(r)}),t.map(r=>pn(r))}if(typeof e=="object"){const t={};return Object.keys(e).forEach(r=>{t[r]=pn(e[r])}),t}return e},et=(e,t)=>{const r=pn(e);return r.data=r.data||{},t&&(ve(r.data.x)||(r.data.x=Math.random()*t[0]),ve(r.data.y)||(r.data.y=Math.random()*t[1])),r};function er(e){if(!e)return[0,0,0];if(ve(e))return[e,e,e];if(e.length===0)return[0,0,0];const[t,r=t,n=t]=e;return[t,r,n]}function At(e,t){let r;return gt(t)?r=t:ve(t)?r=()=>t:r=()=>e,r}function vn(e,t,r=!0){return!t&&t!==0?n=>{const{size:i}=n.data||{};return i?Array.isArray(i)?r?Math.max(...i)||e:i:zt(i)&&i.width&&i.height?r?Math.max(i.width,i.height)||e:[i.width,i.height]:i:e}:gt(t)?t:ve(t)?()=>t:Array.isArray(t)?()=>r?Math.max(...t)||e:t:zt(t)&&t.width&&t.height?()=>r?Math.max(t.width,t.height)||e:[t.width,t.height]:()=>e}const mn=(e,t,r=10)=>{let n;const i=typeof t=="function"?t:()=>t||0;return e?Array.isArray(e)?n=a=>e:gt(e)?n=e:n=a=>e:n=a=>{var o,c,f;if(!((o=a.data)===null||o===void 0)&&o.bboxSize)return(c=a.data)===null||c===void 0?void 0:c.bboxSize;if(!((f=a.data)===null||f===void 0)&&f.size){const l=a.data.size;return Array.isArray(l)?l:zt(l)?[l.width,l.height]:l}return r},a=>{const o=n(a),c=i(a);return Math.max(...er(o))+c}},My={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};class Sy{constructor(t={}){this.options=t,this.id="antv-dagre",this.options=Object.assign(Object.assign({},My),t)}execute(t,r){return ye(this,void 0,void 0,function*(){return this.genericDagreLayout(!1,t,r)})}assign(t,r){return ye(this,void 0,void 0,function*(){yield this.genericDagreLayout(!0,t,r)})}genericDagreLayout(t,r,n){return ye(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),n),{nodeSize:s,align:a,rankdir:o="TB",ranksep:c,nodesep:f,ranksepFunc:l,nodesepFunc:p,edgeLabelSpace:v,ranker:y,nodeOrder:x,begin:_,controlPoints:b,radial:w,sortByCombo:E,preset:N}=i,S=new De({tree:[]}),q=At(c||50,l),A=At(f||50,p);let j=A,I=q;(o==="LR"||o==="RL")&&(j=q,I=A);const D=vn(10,s,!1),z=r.getAllNodes(),$=r.getAllEdges();z.forEach(Z=>{const ue=er(D(Z)),ge=I(Z),le=j(Z),ie=ue[0]+2*le,_e=ue[1]+2*ge,G=Z.data.layer;ve(G)?S.addNode({id:Z.id,data:{width:ie,height:_e,layer:G}}):S.addNode({id:Z.id,data:{width:ie,height:_e}})}),E&&(S.attachTreeStructure("combo"),z.forEach(Z=>{const{parentId:ue}=Z.data;ue!==void 0&&S.hasNode(ue)&&S.setParent(Z.id,ue,"combo")})),$.forEach(Z=>{S.addEdge({id:Z.id,source:Z.source,target:Z.target,data:{weight:Z.data.weight||1}})});let V;N?.length&&(V=new De({nodes:N})),ry(S,{prevGraph:V,edgeLabelSpace:v,keepNodeOrder:!!x,nodeOrder:x||[],acyclicer:"greedy",ranker:y,rankdir:o,nodesep:f,align:a});const Y=[0,0];if(_){let Z=1/0,ue=1/0;S.getAllNodes().forEach(ge=>{Z>ge.data.x&&(Z=ge.data.x),ue>ge.data.y&&(ue=ge.data.y)}),S.getAllEdges().forEach(ge=>{var le;(le=ge.data.points)===null||le===void 0||le.forEach(ie=>{Z>ie.x&&(Z=ie.x),ue>ie.y&&(ue=ie.y)})}),Y[0]=_[0]-Z,Y[1]=_[1]-ue}const ee=o==="LR"||o==="RL";if(!w){const Z=new Set,ge=o==="BT"||o==="RL"?(G,P)=>P-G:(G,P)=>G-P;S.getAllNodes().forEach(G=>{G.data.x=G.data.x+Y[0],G.data.y=G.data.y+Y[1],Z.add(ee?G.data.x:G.data.y)});const le=Array.from(Z).sort(ge),ie=ee?(G,P)=>G.x!==P.x:(G,P)=>G.y!==P.y,_e=ee?(G,P,X)=>{const te=Math.max(P.y,X.y),fe=Math.min(P.y,X.y);return G.filter(xe=>xe.y<=te&&xe.y>=fe)}:(G,P,X)=>{const te=Math.max(P.x,X.x),fe=Math.min(P.x,X.x);return G.filter(xe=>xe.x<=te&&xe.x>=fe)};S.getAllEdges().forEach((G,P)=>{var X;v&&b&&G.data.type!=="loop"&&(G.data.controlPoints=qy((X=G.data.points)===null||X===void 0?void 0:X.map(({x:te,y:fe})=>({x:te+Y[0],y:fe+Y[1]})),S.getNode(G.source),S.getNode(G.target),le,ee,ie,_e))})}let J=[];J=S.getAllNodes().map(Z=>et(Z));const ae=S.getAllEdges();return t&&(J.forEach(Z=>{r.mergeNodeData(Z.id,{x:Z.data.x,y:Z.data.y})}),ae.forEach(Z=>{r.mergeEdgeData(Z.id,{controlPoints:Z.data.controlPoints})})),{nodes:J,edges:ae}})}}const qy=(e,t,r,n,i,s,a)=>{let o=e?.slice(1,e.length-1)||[];if(t&&r){let{x:c,y:f}=t.data,{x:l,y:p}=r.data;if(i&&(c=t.data.y,f=t.data.x,l=r.data.y,p=r.data.x),p!==f&&c!==l){const v=n.indexOf(f),y=n[v+1];if(y){const b=o[0],w=i?{x:(f+y)/2,y:b?.y||l}:{x:b?.x||l,y:(f+y)/2};(!b||s(b,w))&&o.unshift(w)}const x=n.indexOf(p),_=Math.abs(x-v);if(_===1)o=a(o,t.data,r.data),o.length||o.push(i?{x:(f+p)/2,y:c}:{x:c,y:(f+p)/2});else if(_>1){const b=n[x-1];if(b){const w=o[o.length-1],E=i?{x:(p+b)/2,y:w?.y||l}:{x:w?.x||c,y:(p+b)/2};(!w||s(w,E))&&o.push(E)}}}}return o},It=(e,t,r)=>{const n=e.getAllNodes(),i=e.getAllEdges();if(!n?.length)return{nodes:[],edges:i};if(n.length===1)return t&&e.mergeNodeData(n[0].id,{x:r[0],y:r[1]}),{nodes:[Object.assign(Object.assign({},n[0]),{data:Object.assign(Object.assign({},n[0].data),{x:r[0],y:r[1]})})],edges:i}},Ry={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1};class Oy{constructor(t={}){this.options=t,this.id="circular",this.options=Object.assign(Object.assign({},Ry),t)}execute(t,r){return ye(this,void 0,void 0,function*(){return this.genericCircularLayout(!1,t,r)})}assign(t,r){return ye(this,void 0,void 0,function*(){yield this.genericCircularLayout(!0,t,r)})}genericCircularLayout(t,r,n){return ye(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),n),{width:s,height:a,center:o,divisions:c,startAngle:f=0,endAngle:l=2*Math.PI,angleRatio:p,ordering:v,clockwise:y,nodeSpacing:x,nodeSize:_}=i,b=r.getAllNodes(),w=r.getAllEdges(),[E,N,S]=Iy(s,a,o),q=b?.length;if(!q||q===1)return It(r,t,S);const A=(l-f)/q;let{radius:j,startRadius:I,endRadius:D}=i;if(x){const ee=At(10,x),J=vn(10,_);let ae=-1/0;b.forEach(Z=>{const ue=J(Z);ae<ue&&(ae=ue)});let be=0;b.forEach((Z,ue)=>{ue===0?be+=ae||10:be+=(ee(Z)||0)+(ae||10)}),j=be/(2*Math.PI)}else!j&&!I&&!D?j=Math.min(N,E)/2:!I&&D?I=D:I&&!D&&(D=I);const z=A*p;let $=[];v==="topology"?$=af(r,b):v==="topology-directed"?$=af(r,b,!0):v==="degree"?$=Ay(r,b):$=b.map(ee=>et(ee));const V=Math.ceil(q/c);for(let ee=0;ee<q;++ee){let J=j;!J&&I!==null&&D!==null&&(J=I+ee*(D-I)/(q-1)),J||(J=10+ee*100/(q-1));let ae=f+ee%V*z+2*Math.PI/c*Math.floor(ee/V);y||(ae=l-ee%V*z-2*Math.PI/c*Math.floor(ee/V)),$[ee].data.x=S[0]+Math.cos(ae)*J,$[ee].data.y=S[1]+Math.sin(ae)*J}return t&&$.forEach(ee=>{r.mergeNodeData(ee.id,{x:ee.data.x,y:ee.data.y})}),{nodes:$,edges:w}})}}const af=(e,t,r=!1)=>{const n=[et(t[0])],i={},s=t.length;i[t[0].id]=!0;let a=0;return t.forEach((o,c)=>{if(c!==0)if((c===s-1||e.getDegree(o.id,"both")!==e.getDegree(t[c+1].id,"both")||e.areNeighbors(n[a].id,o.id))&&!i[o.id])n.push(et(o)),i[o.id]=!0,a++;else{const f=r?e.getSuccessors(n[a].id):e.getNeighbors(n[a].id);let l=!1;for(let v=0;v<f.length;v++){const y=f[v];if(e.getDegree(y.id)===e.getDegree(o.id)&&!i[y.id]){n.push(et(y)),i[y.id]=!0,l=!0;break}}let p=0;for(;!l&&(i[t[p].id]||(n.push(et(t[p])),i[t[p].id]=!0,l=!0),p++,p!==s););}}),n};function Ay(e,t){const r=[];return t.forEach((n,i)=>{r.push(et(n))}),r.sort((n,i)=>e.getDegree(n.id,"both")-e.getDegree(i.id,"both")),r}const Iy=(e,t,r)=>{let n=e,i=t,s=r;return!n&&typeof window<"u"&&(n=window.innerWidth),!i&&typeof window<"u"&&(i=window.innerHeight),s||(s=[n/2,i/2]),[n,i,s]},Ty={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:3/2*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"};class yn{constructor(t={}){this.options=t,this.id="concentric",this.options=Object.assign(Object.assign({},Ty),t)}execute(t,r){return ye(this,void 0,void 0,function*(){return this.genericConcentricLayout(!1,t,r)})}assign(t,r){return ye(this,void 0,void 0,function*(){yield this.genericConcentricLayout(!0,t,r)})}genericConcentricLayout(t,r,n){return ye(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),n),{center:s,width:a,height:o,sortBy:c,maxLevelDiff:f,sweep:l,clockwise:p,equidistant:v,preventOverlap:y,startAngle:x=3/2*Math.PI,nodeSize:_,nodeSpacing:b}=i,w=r.getAllNodes(),E=r.getAllEdges(),N=!a&&typeof window<"u"?window.innerWidth:a,S=!o&&typeof window<"u"?window.innerHeight:o,q=s||[N/2,S/2];if(!w?.length||w.length===1)return It(r,t,q);const A=[];let j,I=0;pt(_)?j=Math.max(_[0],_[1]):gt(_)?(j=-1/0,w.forEach(Z=>{const ue=Math.max(...er(_(Z)));ue>j&&(j=ue)})):j=_,pt(b)?I=Math.max(b[0],b[1]):ve(b)&&(I=b),w.forEach(Z=>{const ue=et(Z);A.push(ue);let ge=j;const{data:le}=ue;pt(le.size)?ge=Math.max(le.size[0],le.size[1]):ve(le.size)?ge=le.size:zt(le.size)&&(ge=Math.max(le.size.width,le.size.height)),j=Math.max(j,ge),gt(b)&&(I=Math.max(b(Z),I))});const D={};A.forEach((Z,ue)=>{D[Z.id]=ue});let z=c;(!Qt(z)||A[0].data[z]===void 0)&&(z="degree"),z==="degree"?A.sort((Z,ue)=>r.getDegree(ue.id,"both")-r.getDegree(Z.id,"both")):A.sort((Z,ue)=>ue.data[z]-Z.data[z]);const $=A[0],V=(f||(z==="degree"?r.getDegree($.id,"both"):$.data[z]))/4,Y=[{nodes:[]}];let ee=Y[0];A.forEach(Z=>{if(ee.nodes.length>0){const ue=Math.abs(z==="degree"?r.getDegree(ee.nodes[0].id,"both")-r.getDegree(Z.id,"both"):ee.nodes[0].data[z]-Z.data[z]);V&&ue>=V&&(ee={nodes:[]},Y.push(ee))}ee.nodes.push(Z)});let J=j+I;if(!y){const Z=Y.length>0&&Y[0].nodes.length>1,ge=(Math.min(N,S)/2-J)/(Y.length+(Z?1:0));J=Math.min(J,ge)}let ae=0;if(Y.forEach(Z=>{const ue=l===void 0?2*Math.PI-2*Math.PI/Z.nodes.length:l;if(Z.dTheta=ue/Math.max(1,Z.nodes.length-1),Z.nodes.length>1&&y){const ge=Math.cos(Z.dTheta)-Math.cos(0),le=Math.sin(Z.dTheta)-Math.sin(0),ie=Math.sqrt(J*J/(ge*ge+le*le));ae=Math.max(ie,ae)}Z.r=ae,ae+=J}),v){let Z=0,ue=0;for(let ge=0;ge<Y.length;ge++){const ie=(Y[ge].r||0)-ue;Z=Math.max(Z,ie)}ue=0,Y.forEach((ge,le)=>{le===0&&(ue=ge.r||0),ge.r=ue,ue+=Z})}return Y.forEach(Z=>{const ue=Z.dTheta||0,ge=Z.r||0;Z.nodes.forEach((le,ie)=>{const _e=x+(p?1:-1)*ue*ie;le.data.x=q[0]+ge*Math.cos(_e),le.data.y=q[1]+ge*Math.sin(_e)})}),t&&A.forEach(Z=>r.mergeNodeData(Z.id,{x:Z.data.x,y:Z.data.y})),{nodes:A,edges:E}})}}function ky(e){const t=+this._x.call(null,e),r=+this._y.call(null,e);return uf(this.cover(t,r),t,r,e)}function uf(e,t,r,n){if(isNaN(t)||isNaN(r))return e;var i,s=e._root,a={data:n},o=e._x0,c=e._y0,f=e._x1,l=e._y1,p,v,y,x,_,b,w,E;if(!s)return e._root=a,e;for(;s.length;)if((_=t>=(p=(o+f)/2))?o=p:f=p,(b=r>=(v=(c+l)/2))?c=v:l=v,i=s,!(s=s[w=b<<1|_]))return i[w]=a,e;if(y=+e._x.call(null,s.data),x=+e._y.call(null,s.data),t===y&&r===x)return a.next=s,i?i[w]=a:e._root=a,e;do i=i?i[w]=new Array(4):e._root=new Array(4),(_=t>=(p=(o+f)/2))?o=p:f=p,(b=r>=(v=(c+l)/2))?c=v:l=v;while((w=b<<1|_)===(E=(x>=v)<<1|y>=p));return i[E]=s,i[w]=a,e}function jy(e){var t,r,n=e.length,i,s,a=new Array(n),o=new Array(n),c=1/0,f=1/0,l=-1/0,p=-1/0;for(r=0;r<n;++r)isNaN(i=+this._x.call(null,t=e[r]))||isNaN(s=+this._y.call(null,t))||(a[r]=i,o[r]=s,i<c&&(c=i),i>l&&(l=i),s<f&&(f=s),s>p&&(p=s));if(c>l||f>p)return this;for(this.cover(c,f).cover(l,p),r=0;r<n;++r)uf(this,a[r],o[r],e[r]);return this}function Cy(e,t){if(isNaN(e=+e)||isNaN(t=+t))return this;var r=this._x0,n=this._y0,i=this._x1,s=this._y1;if(isNaN(r))i=(r=Math.floor(e))+1,s=(n=Math.floor(t))+1;else{for(var a=i-r||1,o=this._root,c,f;r>e||e>=i||n>t||t>=s;)switch(f=(t<n)<<1|e<r,c=new Array(4),c[f]=o,o=c,a*=2,f){case 0:i=r+a,s=n+a;break;case 1:r=i-a,s=n+a;break;case 2:i=r+a,n=s-a;break;case 3:r=i-a,n=s-a;break}this._root&&this._root.length&&(this._root=o)}return this._x0=r,this._y0=n,this._x1=i,this._y1=s,this}function Py(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function Ly(e){return arguments.length?this.cover(+e[0][0],+e[0][1]).cover(+e[1][0],+e[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function Ze(e,t,r,n,i){this.node=e,this.x0=t,this.y0=r,this.x1=n,this.y1=i}function Dy(e,t,r){var n,i=this._x0,s=this._y0,a,o,c,f,l=this._x1,p=this._y1,v=[],y=this._root,x,_;for(y&&v.push(new Ze(y,i,s,l,p)),r==null?r=1/0:(i=e-r,s=t-r,l=e+r,p=t+r,r*=r);x=v.pop();)if(!(!(y=x.node)||(a=x.x0)>l||(o=x.y0)>p||(c=x.x1)<i||(f=x.y1)<s))if(y.length){var b=(a+c)/2,w=(o+f)/2;v.push(new Ze(y[3],b,w,c,f),new Ze(y[2],a,w,b,f),new Ze(y[1],b,o,c,w),new Ze(y[0],a,o,b,w)),(_=(t>=w)<<1|e>=b)&&(x=v[v.length-1],v[v.length-1]=v[v.length-1-_],v[v.length-1-_]=x)}else{var E=e-+this._x.call(null,y.data),N=t-+this._y.call(null,y.data),S=E*E+N*N;if(S<r){var q=Math.sqrt(r=S);i=e-q,s=t-q,l=e+q,p=t+q,n=y.data}}return n}function zy(e){if(isNaN(l=+this._x.call(null,e))||isNaN(p=+this._y.call(null,e)))return this;var t,r=this._root,n,i,s,a=this._x0,o=this._y0,c=this._x1,f=this._y1,l,p,v,y,x,_,b,w;if(!r)return this;if(r.length)for(;;){if((x=l>=(v=(a+c)/2))?a=v:c=v,(_=p>=(y=(o+f)/2))?o=y:f=y,t=r,!(r=r[b=_<<1|x]))return this;if(!r.length)break;(t[b+1&3]||t[b+2&3]||t[b+3&3])&&(n=t,w=b)}for(;r.data!==e;)if(i=r,!(r=r.next))return this;return(s=r.next)&&delete r.next,i?(s?i.next=s:delete i.next,this):t?(s?t[b]=s:delete t[b],(r=t[0]||t[1]||t[2]||t[3])&&r===(t[3]||t[2]||t[1]||t[0])&&!r.length&&(n?n[w]=r:this._root=r),this):(this._root=s,this)}function Fy(e){for(var t=0,r=e.length;t<r;++t)this.remove(e[t]);return this}function By(){return this._root}function $y(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function Gy(e){var t=[],r,n=this._root,i,s,a,o,c;for(n&&t.push(new Ze(n,this._x0,this._y0,this._x1,this._y1));r=t.pop();)if(!e(n=r.node,s=r.x0,a=r.y0,o=r.x1,c=r.y1)&&n.length){var f=(s+o)/2,l=(a+c)/2;(i=n[3])&&t.push(new Ze(i,f,l,o,c)),(i=n[2])&&t.push(new Ze(i,s,l,f,c)),(i=n[1])&&t.push(new Ze(i,f,a,o,l)),(i=n[0])&&t.push(new Ze(i,s,a,f,l))}return this}function Uy(e){var t=[],r=[],n;for(this._root&&t.push(new Ze(this._root,this._x0,this._y0,this._x1,this._y1));n=t.pop();){var i=n.node;if(i.length){var s,a=n.x0,o=n.y0,c=n.x1,f=n.y1,l=(a+c)/2,p=(o+f)/2;(s=i[0])&&t.push(new Ze(s,a,o,l,p)),(s=i[1])&&t.push(new Ze(s,l,o,c,p)),(s=i[2])&&t.push(new Ze(s,a,p,l,f)),(s=i[3])&&t.push(new Ze(s,l,p,c,f))}r.push(n)}for(;n=r.pop();)e(n.node,n.x0,n.y0,n.x1,n.y1);return this}function Vy(e){return e[0]}function Wy(e){return arguments.length?(this._x=e,this):this._x}function Yy(e){return e[1]}function Ky(e){return arguments.length?(this._y=e,this):this._y}function Bt(e,t,r){var n=new wn(t??Vy,r??Yy,NaN,NaN,NaN,NaN);return e==null?n:n.addAll(e)}function wn(e,t,r,n,i,s){this._x=e,this._y=t,this._x0=r,this._y0=n,this._x1=i,this._y1=s,this._root=void 0}function cf(e){for(var t={data:e.data},r=t;e=e.next;)r=r.next={data:e.data};return t}var Je=Bt.prototype=wn.prototype;Je.copy=function(){var e=new wn(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,r,n;if(!t)return e;if(!t.length)return e._root=cf(t),e;for(r=[{source:t,target:e._root=new Array(4)}];t=r.pop();)for(var i=0;i<4;++i)(n=t.source[i])&&(n.length?r.push({source:n,target:t.target[i]=new Array(4)}):t.target[i]=cf(n));return e},Je.add=ky,Je.addAll=jy,Je.cover=Cy,Je.data=Py,Je.extent=Ly,Je.find=Dy,Je.remove=zy,Je.removeAll=Fy,Je.root=By,Je.size=$y,Je.visit=Gy,Je.visitAfter=Uy,Je.x=Wy,Je.y=Ky;function Xy(e){const t=+this._x.call(null,e),r=+this._y.call(null,e),n=+this._z.call(null,e);return ff(this.cover(t,r,n),t,r,n,e)}function ff(e,t,r,n,i){if(isNaN(t)||isNaN(r)||isNaN(n))return e;var s,a=e._root,o={data:i},c=e._x0,f=e._y0,l=e._z0,p=e._x1,v=e._y1,y=e._z1,x,_,b,w,E,N,S,q,A,j,I;if(!a)return e._root=o,e;for(;a.length;)if((S=t>=(x=(c+p)/2))?c=x:p=x,(q=r>=(_=(f+v)/2))?f=_:v=_,(A=n>=(b=(l+y)/2))?l=b:y=b,s=a,!(a=a[j=A<<2|q<<1|S]))return s[j]=o,e;if(w=+e._x.call(null,a.data),E=+e._y.call(null,a.data),N=+e._z.call(null,a.data),t===w&&r===E&&n===N)return o.next=a,s?s[j]=o:e._root=o,e;do s=s?s[j]=new Array(8):e._root=new Array(8),(S=t>=(x=(c+p)/2))?c=x:p=x,(q=r>=(_=(f+v)/2))?f=_:v=_,(A=n>=(b=(l+y)/2))?l=b:y=b;while((j=A<<2|q<<1|S)===(I=(N>=b)<<2|(E>=_)<<1|w>=x));return s[I]=a,s[j]=o,e}function Zy(e){Array.isArray(e)||(e=Array.from(e));const t=e.length,r=new Float64Array(t),n=new Float64Array(t),i=new Float64Array(t);let s=1/0,a=1/0,o=1/0,c=-1/0,f=-1/0,l=-1/0;for(let p=0,v,y,x,_;p<t;++p)isNaN(y=+this._x.call(null,v=e[p]))||isNaN(x=+this._y.call(null,v))||isNaN(_=+this._z.call(null,v))||(r[p]=y,n[p]=x,i[p]=_,y<s&&(s=y),y>c&&(c=y),x<a&&(a=x),x>f&&(f=x),_<o&&(o=_),_>l&&(l=_));if(s>c||a>f||o>l)return this;this.cover(s,a,o).cover(c,f,l);for(let p=0;p<t;++p)ff(this,r[p],n[p],i[p],e[p]);return this}function Jy(e,t,r){if(isNaN(e=+e)||isNaN(t=+t)||isNaN(r=+r))return this;var n=this._x0,i=this._y0,s=this._z0,a=this._x1,o=this._y1,c=this._z1;if(isNaN(n))a=(n=Math.floor(e))+1,o=(i=Math.floor(t))+1,c=(s=Math.floor(r))+1;else{for(var f=a-n||1,l=this._root,p,v;n>e||e>=a||i>t||t>=o||s>r||r>=c;)switch(v=(r<s)<<2|(t<i)<<1|e<n,p=new Array(8),p[v]=l,l=p,f*=2,v){case 0:a=n+f,o=i+f,c=s+f;break;case 1:n=a-f,o=i+f,c=s+f;break;case 2:a=n+f,i=o-f,c=s+f;break;case 3:n=a-f,i=o-f,c=s+f;break;case 4:a=n+f,o=i+f,s=c-f;break;case 5:n=a-f,o=i+f,s=c-f;break;case 6:a=n+f,i=o-f,s=c-f;break;case 7:n=a-f,i=o-f,s=c-f;break}this._root&&this._root.length&&(this._root=l)}return this._x0=n,this._y0=i,this._z0=s,this._x1=a,this._y1=o,this._z1=c,this}function Qy(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function Hy(e){return arguments.length?this.cover(+e[0][0],+e[0][1],+e[0][2]).cover(+e[1][0],+e[1][1],+e[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}function qe(e,t,r,n,i,s,a){this.node=e,this.x0=t,this.y0=r,this.z0=n,this.x1=i,this.y1=s,this.z1=a}function ew(e,t,r,n){var i,s=this._x0,a=this._y0,o=this._z0,c,f,l,p,v,y,x=this._x1,_=this._y1,b=this._z1,w=[],E=this._root,N,S;for(E&&w.push(new qe(E,s,a,o,x,_,b)),n==null?n=1/0:(s=e-n,a=t-n,o=r-n,x=e+n,_=t+n,b=r+n,n*=n);N=w.pop();)if(!(!(E=N.node)||(c=N.x0)>x||(f=N.y0)>_||(l=N.z0)>b||(p=N.x1)<s||(v=N.y1)<a||(y=N.z1)<o))if(E.length){var q=(c+p)/2,A=(f+v)/2,j=(l+y)/2;w.push(new qe(E[7],q,A,j,p,v,y),new qe(E[6],c,A,j,q,v,y),new qe(E[5],q,f,j,p,A,y),new qe(E[4],c,f,j,q,A,y),new qe(E[3],q,A,l,p,v,j),new qe(E[2],c,A,l,q,v,j),new qe(E[1],q,f,l,p,A,j),new qe(E[0],c,f,l,q,A,j)),(S=(r>=j)<<2|(t>=A)<<1|e>=q)&&(N=w[w.length-1],w[w.length-1]=w[w.length-1-S],w[w.length-1-S]=N)}else{var I=e-+this._x.call(null,E.data),D=t-+this._y.call(null,E.data),z=r-+this._z.call(null,E.data),$=I*I+D*D+z*z;if($<n){var V=Math.sqrt(n=$);s=e-V,a=t-V,o=r-V,x=e+V,_=t+V,b=r+V,i=E.data}}return i}const tw=(e,t,r,n,i,s)=>Math.sqrt((e-n)**2+(t-i)**2+(r-s)**2);function rw(e,t,r,n){const i=[],s=e-n,a=t-n,o=r-n,c=e+n,f=t+n,l=r+n;return this.visit((p,v,y,x,_,b,w)=>{if(!p.length)do{const E=p.data;tw(e,t,r,this._x(E),this._y(E),this._z(E))<=n&&i.push(E)}while(p=p.next);return v>c||y>f||x>l||_<s||b<a||w<o}),i}function nw(e){if(isNaN(v=+this._x.call(null,e))||isNaN(y=+this._y.call(null,e))||isNaN(x=+this._z.call(null,e)))return this;var t,r=this._root,n,i,s,a=this._x0,o=this._y0,c=this._z0,f=this._x1,l=this._y1,p=this._z1,v,y,x,_,b,w,E,N,S,q,A;if(!r)return this;if(r.length)for(;;){if((E=v>=(_=(a+f)/2))?a=_:f=_,(N=y>=(b=(o+l)/2))?o=b:l=b,(S=x>=(w=(c+p)/2))?c=w:p=w,t=r,!(r=r[q=S<<2|N<<1|E]))return this;if(!r.length)break;(t[q+1&7]||t[q+2&7]||t[q+3&7]||t[q+4&7]||t[q+5&7]||t[q+6&7]||t[q+7&7])&&(n=t,A=q)}for(;r.data!==e;)if(i=r,!(r=r.next))return this;return(s=r.next)&&delete r.next,i?(s?i.next=s:delete i.next,this):t?(s?t[q]=s:delete t[q],(r=t[0]||t[1]||t[2]||t[3]||t[4]||t[5]||t[6]||t[7])&&r===(t[7]||t[6]||t[5]||t[4]||t[3]||t[2]||t[1]||t[0])&&!r.length&&(n?n[A]=r:this._root=r),this):(this._root=s,this)}function iw(e){for(var t=0,r=e.length;t<r;++t)this.remove(e[t]);return this}function sw(){return this._root}function ow(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function aw(e){var t=[],r,n=this._root,i,s,a,o,c,f,l;for(n&&t.push(new qe(n,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));r=t.pop();)if(!e(n=r.node,s=r.x0,a=r.y0,o=r.z0,c=r.x1,f=r.y1,l=r.z1)&&n.length){var p=(s+c)/2,v=(a+f)/2,y=(o+l)/2;(i=n[7])&&t.push(new qe(i,p,v,y,c,f,l)),(i=n[6])&&t.push(new qe(i,s,v,y,p,f,l)),(i=n[5])&&t.push(new qe(i,p,a,y,c,v,l)),(i=n[4])&&t.push(new qe(i,s,a,y,p,v,l)),(i=n[3])&&t.push(new qe(i,p,v,o,c,f,y)),(i=n[2])&&t.push(new qe(i,s,v,o,p,f,y)),(i=n[1])&&t.push(new qe(i,p,a,o,c,v,y)),(i=n[0])&&t.push(new qe(i,s,a,o,p,v,y))}return this}function uw(e){var t=[],r=[],n;for(this._root&&t.push(new qe(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));n=t.pop();){var i=n.node;if(i.length){var s,a=n.x0,o=n.y0,c=n.z0,f=n.x1,l=n.y1,p=n.z1,v=(a+f)/2,y=(o+l)/2,x=(c+p)/2;(s=i[0])&&t.push(new qe(s,a,o,c,v,y,x)),(s=i[1])&&t.push(new qe(s,v,o,c,f,y,x)),(s=i[2])&&t.push(new qe(s,a,y,c,v,l,x)),(s=i[3])&&t.push(new qe(s,v,y,c,f,l,x)),(s=i[4])&&t.push(new qe(s,a,o,x,v,y,p)),(s=i[5])&&t.push(new qe(s,v,o,x,f,y,p)),(s=i[6])&&t.push(new qe(s,a,y,x,v,l,p)),(s=i[7])&&t.push(new qe(s,v,y,x,f,l,p))}r.push(n)}for(;n=r.pop();)e(n.node,n.x0,n.y0,n.z0,n.x1,n.y1,n.z1);return this}function cw(e){return e[0]}function fw(e){return arguments.length?(this._x=e,this):this._x}function lw(e){return e[1]}function hw(e){return arguments.length?(this._y=e,this):this._y}function dw(e){return e[2]}function gw(e){return arguments.length?(this._z=e,this):this._z}function _r(e,t,r,n){var i=new bn(t??cw,r??lw,n??dw,NaN,NaN,NaN,NaN,NaN,NaN);return e==null?i:i.addAll(e)}function bn(e,t,r,n,i,s,a,o,c){this._x=e,this._y=t,this._z=r,this._x0=n,this._y0=i,this._z0=s,this._x1=a,this._y1=o,this._z1=c,this._root=void 0}function lf(e){for(var t={data:e.data},r=t;e=e.next;)r=r.next={data:e.data};return t}var Ve=_r.prototype=bn.prototype;Ve.copy=function(){var e=new bn(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),t=this._root,r,n;if(!t)return e;if(!t.length)return e._root=lf(t),e;for(r=[{source:t,target:e._root=new Array(8)}];t=r.pop();)for(var i=0;i<8;++i)(n=t.source[i])&&(n.length?r.push({source:n,target:t.target[i]=new Array(8)}):t.target[i]=lf(n));return e},Ve.add=Xy,Ve.addAll=Zy,Ve.cover=Jy,Ve.data=Qy,Ve.extent=Hy,Ve.find=ew,Ve.findAllWithinRadius=rw,Ve.remove=nw,Ve.removeAll=iw,Ve.root=sw,Ve.size=ow,Ve.visit=aw,Ve.visitAfter=uw,Ve.x=fw,Ve.y=hw,Ve.z=gw;const pw=.81,_n=.1;function vw(e,t,r,n,i=2){const s=t/r,a=e.getAllNodes(),o=a.map((l,p)=>{const{nodeStrength:v,x:y,y:x,z:_,size:b}=l.data;return{x:y,y:x,z:_,size:b,index:p,id:l.id,vx:0,vy:0,vz:0,weight:s*v}}),c=(i===2?Bt(o,l=>l.x,l=>l.y):_r(o,l=>l.x,l=>l.y,l=>l.z)).visitAfter(mw),f=new Map;return o.forEach(l=>{f.set(l.id,l),ww(l,c,i)}),o.map((l,p)=>{const{id:v,data:y}=a[p],{mass:x=1}=y;n[v]={x:l.vx/x,y:l.vy/x,z:l.vz/x}}),n}function mw(e){let t=0,r=0,n=0,i=0,s=0;const a=e.length;if(a){for(let o=0;o<a;o++){const c=e[o];c&&c.weight&&(t+=c.weight,r+=c.x*c.weight,n+=c.y*c.weight,i+=c.z*c.weight,s+=c.size*c.weight)}e.x=r/t,e.y=n/t,e.z=i/t,e.size=s/t,e.weight=t}else{const o=e;e.x=o.data.x,e.y=o.data.y,e.z=o.data.z,e.size=o.data.size,e.weight=o.data.weight}}const yw=(e,t,r,n,i,s,a)=>{var o;if(((o=e.data)===null||o===void 0?void 0:o.id)===s.id)return;const c=[r,n,i][a-1],f=s.x-e.x||_n,l=s.y-e.y||_n,p=s.z-e.z||_n,v=[f,l,p],y=c-t;let x=0;for(let w=0;w<a;w++)x+=v[w]*v[w];const b=Math.sqrt(x)*x;if(y*y*pw<x){const w=e.weight/b;return s.vx+=f*w,s.vy+=l*w,s.vz+=p*w,!0}if(e.length)return!1;if(e.data!==s){const w=e.data.weight/b;s.vx+=f*w,s.vy+=l*w,s.vz+=p*w}};function ww(e,t,r){t.visit((n,i,s,a,o)=>yw(n,i,s,a,o,e,r))}const bw={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 hf{constructor(t={}){this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=Object.assign(Object.assign({},bw),t)}execute(t,r){return ye(this,void 0,void 0,function*(){return this.genericForceLayout(!1,t,r)})}assign(t,r){return ye(this,void 0,void 0,function*(){yield this.genericForceLayout(!0,t,r)})}stop(){this.timeInterval&&typeof window<"u"&&window.clearInterval(this.timeInterval),this.running=!1}tick(t=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let n=0;(this.judgingDistance>this.lastOptions.minMovement||n<1)&&n<t;n++)this.runOneStep(this.lastCalcGraph,this.lastGraph,n,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);const r={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&r.nodes.forEach(n=>this.lastGraph.mergeNodeData(n.id,{x:n.data.x,y:n.data.y,z:this.options.dimensions===3?n.data.z:void 0})),r}genericForceLayout(t,r,n){return ye(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),n),s=r.getAllNodes(),a=r.getAllEdges(),o=this.formatOptions(i,r),{dimensions:c,width:f,height:l,nodeSize:p,getMass:v,nodeStrength:y,edgeStrength:x,linkDistance:_}=o,b=s.map((I,D)=>Object.assign(Object.assign({},I),{data:Object.assign(Object.assign({},I.data),{x:ve(I.data.x)?I.data.x:Math.random()*f,y:ve(I.data.y)?I.data.y:Math.random()*l,z:ve(I.data.z)?I.data.z:Math.random()*Math.sqrt(f*l),size:p(I)||30,mass:v(I),nodeStrength:y(I)})})),w=a.map(I=>Object.assign(Object.assign({},I),{data:Object.assign(Object.assign({},I.data),{edgeStrength:x(I),linkDistance:_(I,r.getNode(I.source),r.getNode(I.target))})}));if(!s?.length)return this.lastResult={nodes:[],edges:a},{nodes:[],edges:a};const E={};s.forEach((I,D)=>{E[I.id]={x:0,y:0,z:0}});const N=new De({nodes:b,edges:w});this.formatCentripetal(o,N);const{maxIteration:S,minMovement:q,onTick:A}=o;if(this.lastLayoutNodes=b,this.lastLayoutEdges=w,this.lastAssign=t,this.lastGraph=r,this.lastCalcGraph=N,this.lastOptions=o,this.lastVelMap=E,typeof window>"u")return;let j=0;return new Promise(I=>{this.timeInterval=window.setInterval(()=>{(!s||!this.running)&&I({nodes:En(r,b),edges:a}),this.runOneStep(N,r,j,E,o),this.updatePosition(r,N,E,o),t&&b.forEach(D=>r.mergeNodeData(D.id,{x:D.data.x,y:D.data.y,z:c===3?D.data.z:void 0})),A?.({nodes:En(r,b),edges:a}),j++,(j>=S||this.judgingDistance<q)&&(window.clearInterval(this.timeInterval),I({nodes:En(r,b),edges:a}))},0),this.running=!0})})}formatOptions(t,r){const n=Object.assign({},t),{width:i,height:s,getMass:a}=t;n.width=!i&&typeof window<"u"?window.innerWidth:i,n.height=!s&&typeof window<"u"?window.innerHeight:s,t.center||(n.center=[n.width/2,n.height/2]),a||(n.getMass=c=>{let f=1;ve(c?.data.mass)&&(f=c?.data.mass);const l=r.getDegree(c.id,"both");return!l||l<5?f:l*5*f}),n.nodeSize=mn(t.nodeSize,t.nodeSpacing);const o=t.linkDistance?At(1,t.linkDistance):c=>1+n.nodeSize(r.getNode(c.source))+n.nodeSize(r.getNode(c.target));return n.linkDistance=o,n.nodeStrength=At(1,t.nodeStrength),n.edgeStrength=At(1,t.edgeStrength),n}formatCentripetal(t,r){const{dimensions:n,centripetalOptions:i,center:s,clusterNodeStrength:a,leafCluster:o,clustering:c,nodeClusterBy:f}=t,l=r.getAllNodes(),p=i||{leaf:2,single:2,others:1,center:w=>({x:s[0],y:s[1],z:n===3?s[2]:void 0})};typeof a!="function"&&(t.clusterNodeStrength=w=>a);let v,y;if(o&&f&&(v=df(r,f),y=Array.from(new Set(l?.map(w=>w.data[f])))||[],t.centripetalOptions=Object.assign(p,{single:100,leaf:w=>{const{siblingLeaves:E,sameTypeLeaves:N}=v[w.id]||{};return N?.length===E?.length||y?.length===1?1:t.clusterNodeStrength(w)},others:1,center:w=>{const E=r.getDegree(w.id,"both");if(!E)return{x:100,y:100,z:0};let N;if(E===1){const{sameTypeLeaves:S=[]}=v[w.id]||{};S.length===1?N=void 0:S.length>1&&(N=gf(S))}else N=void 0;return{x:N?.x,y:N?.y,z:N?.z}}})),c&&f){v||(v=df(r,f)),y||(y=Array.from(new Set(l.map(E=>E.data[f])))),y=y.filter(E=>E!==void 0);const w={};y.forEach(E=>{const N=l.filter(S=>S.data[f]===E).map(S=>r.getNode(S.id));w[E]=gf(N)}),t.centripetalOptions=Object.assign(p,{single:E=>t.clusterNodeStrength(E),leaf:E=>t.clusterNodeStrength(E),others:E=>t.clusterNodeStrength(E),center:E=>{const N=w[E.data[f]];return{x:N?.x,y:N?.y,z:N?.z}}})}const{leaf:x,single:_,others:b}=t.centripetalOptions||{};x&&typeof x!="function"&&(t.centripetalOptions.leaf=()=>x),_&&typeof _!="function"&&(t.centripetalOptions.single=()=>_),b&&typeof b!="function"&&(t.centripetalOptions.others=()=>b)}runOneStep(t,r,n,i,s){const a={},o=t.getAllNodes(),c=t.getAllEdges();if(!o?.length)return;const{monitor:f}=s;if(this.calRepulsive(t,a,s),c&&this.calAttractive(t,a,s),this.calGravity(t,r,a,s),this.updateVelocity(t,a,i,s),f){const l=this.calTotalEnergy(a,o);f({energy:l,nodes:r.getAllNodes(),edges:r.getAllEdges(),iterations:n})}}calTotalEnergy(t,r){if(!r?.length)return 0;let n=0;return r.forEach((i,s)=>{const a=t[i.id].x,o=t[i.id].y,c=this.options.dimensions===3?t[i.id].z:0,f=a*a+o*o+c*c,{mass:l=1}=i.data;n+=l*f*.5}),n}calRepulsive(t,r,n){const{dimensions:i,factor:s,coulombDisScale:a}=n;vw(t,s,a*a,r,i)}calAttractive(t,r,n){const{dimensions:i,nodeSize:s}=n;t.getAllEdges().forEach((a,o)=>{const{source:c,target:f}=a,l=t.getNode(c),p=t.getNode(f);if(!l||!p)return;let v=p.data.x-l.data.x,y=p.data.y-l.data.y,x=i===3?p.data.z-l.data.z:0;!v&&!y&&(v=Math.random()*.01,y=Math.random()*.01,i===3&&!x&&(x=Math.random()*.01));const _=Math.sqrt(v*v+y*y+x*x);if(_<s(l)+s(p))return;const b=v/_,w=y/_,E=x/_,{linkDistance:N=200,edgeStrength:S=200}=a.data||{},A=(N-_)*S,j=l.data.mass||1,I=p.data.mass||1,D=1/j,z=1/I,$=b*A,V=w*A,Y=E*A;r[c].x-=$*D,r[c].y-=V*D,r[c].z-=Y*D,r[f].x+=$*z,r[f].y+=V*z,r[f].z+=Y*z})}calGravity(t,r,n,i){const{getCenter:s}=i,a=t.getAllNodes(),o=r.getAllNodes(),c=r.getAllEdges(),{width:f,height:l,center:p,gravity:v,centripetalOptions:y}=i;a&&a.forEach(x=>{const{id:_,data:b}=x,{mass:w,x:E,y:N,z:S}=b,q=r.getNode(_);let A=0,j=0,I=0,D=v;const z=t.getDegree(_,"in"),$=t.getDegree(_,"out"),V=t.getDegree(_,"both"),Y=s?.(q,V);if(Y){const[ee,J,ae]=Y;A=E-ee,j=N-J,D=ae}else A=E-p[0],j=N-p[1],I=S-p[2];if(D&&(n[_].x-=D*A/w,n[_].y-=D*j/w,n[_].z-=D*I/w),y){const{leaf:ee,single:J,others:ae,center:be}=y,{x:Z,y:ue,z:ge,centerStrength:le}=be?.(q,o,c,f,l)||{x:0,y:0,z:0,centerStrength:0};if(!ve(Z)||!ve(ue))return;const ie=(E-Z)/w,_e=(N-ue)/w,G=(S-ge)/w;if(le&&(n[_].x-=le*ie,n[_].y-=le*_e,n[_].z-=le*G),V===0){const X=J(q);if(!X)return;n[_].x-=X*ie,n[_].y-=X*_e,n[_].z-=X*G;return}if(z===0||$===0){const X=ee(q,o,c);if(!X)return;n[_].x-=X*ie,n[_].y-=X*_e,n[_].z-=X*G;return}const P=ae(q);if(!P)return;n[_].x-=P*ie,n[_].y-=P*_e,n[_].z-=P*G}})}updateVelocity(t,r,n,i){const{damping:s,maxSpeed:a,interval:o,dimensions:c}=i,f=t.getAllNodes();f?.length&&f.forEach(l=>{const{id:p}=l;let v=(n[p].x+r[p].x*o)*s||.01,y=(n[p].y+r[p].y*o)*s||.01,x=c===3?(n[p].z+r[p].z*o)*s||.01:0;const _=Math.sqrt(v*v+y*y+x*x);if(_>a){const b=a/_;v=b*v,y=b*y,x=b*x}n[p]={x:v,y,z:x}})}updatePosition(t,r,n,i){const{distanceThresholdMode:s,interval:a,dimensions:o}=i,c=r.getAllNodes();if(!c?.length){this.judgingDistance=0;return}let f=0;s==="max"?this.judgingDistance=-1/0:s==="min"&&(this.judgingDistance=1/0),c.forEach(l=>{const{id:p}=l,v=t.getNode(p);if(ve(v.data.fx)&&ve(v.data.fy)){r.mergeNodeData(p,{x:v.data.fx,y:v.data.fy,z:o===3?v.data.fz:void 0});return}const y=n[p].x*a,x=n[p].y*a,_=o===3?n[p].z*a:0;r.mergeNodeData(p,{x:l.data.x+y,y:l.data.y+x,z:l.data.z+_});const b=Math.sqrt(y*y+x*x+_*_);switch(s){case"max":this.judgingDistance<b&&(this.judgingDistance=b);break;case"min":this.judgingDistance>b&&(this.judgingDistance=b);break;default:f=f+b;break}}),(!s||s==="mean")&&(this.judgingDistance=f/c.length)}}const df=(e,t)=>{const r=e.getAllNodes();if(!r?.length)return{};const n={};return r.forEach((i,s)=>{e.getDegree(i.id,"both")===1&&(n[i.id]=_w(e,"leaf",i,t))}),n},_w=(e,t,r,n)=>{const i=e.getDegree(r.id,"in"),s=e.getDegree(r.id,"out");let a=r,o=[];i===0?(a=e.getSuccessors(r.id)[0],o=e.getNeighbors(a.id)):s===0&&(a=e.getPredecessors(r.id)[0],o=e.getNeighbors(a.id)),o=o.filter(f=>e.getDegree(f.id,"in")===0||e.getDegree(f.id,"out")===0);const c=Ew(e,t,n,r,o);return{coreNode:a,siblingLeaves:o,sameTypeLeaves:c}},Ew=(e,t,r,n,i)=>{const s=n.data[r]||"";let a=i?.filter(o=>o.data[r]===s)||[];return a=a.filter(o=>e.getDegree(o.id,"in")===0||e.getDegree(o.id,"out")===0),a},gf=e=>{const t={x:0,y:0};e.forEach(n=>{const{x:i,y:s}=n.data;t.x+=i||0,t.y+=s||0});const r=e.length||1;return{x:t.x/r,y:t.y/r}},En=(e,t)=>t.map(r=>{const{id:n,data:i}=r,s=e.getNode(n);return Object.assign(Object.assign({},s),{data:Object.assign(Object.assign({},s.data),{x:i.x,y:i.y,z:i.z})})});var Er=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function pf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function vf(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var r=function n(){var i=!1;try{i=this instanceof n}catch{}return i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}),r}var we={};const xw=Object.prototype.toString;function tr(e){const t=xw.call(e);return t.endsWith("Array]")&&!t.includes("Big")}var Nw=Object.freeze({__proto__:null,isAnyArray:tr}),Mw=vf(Nw);function Sw(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!tr(e))throw new TypeError("input must be an array");if(e.length===0)throw new TypeError("input must not be empty");var r=t.fromIndex,n=r===void 0?0:r,i=t.toIndex,s=i===void 0?e.length:i;if(n<0||n>=e.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=n||s>e.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=e[n],o=n+1;o<s;o++)e[o]>a&&(a=e[o]);return a}function qw(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!tr(e))throw new TypeError("input must be an array");if(e.length===0)throw new TypeError("input must not be empty");var r=t.fromIndex,n=r===void 0?0:r,i=t.toIndex,s=i===void 0?e.length:i;if(n<0||n>=e.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(s<=n||s>e.length||!Number.isInteger(s))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=e[n],o=n+1;o<s;o++)e[o]<a&&(a=e[o]);return a}function Rw(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(tr(e)){if(e.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var r;if(t.output!==void 0){if(!tr(t.output))throw new TypeError("output option must be an array if specified");r=t.output}else r=new Array(e.length);var n=qw(e),i=Sw(e);if(n===i)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var s=t.min,a=s===void 0?t.autoMinMax?n:0:s,o=t.max,c=o===void 0?t.autoMinMax?i:1:o;if(a>=c)throw new RangeError("min option must be smaller than max option");for(var f=(c-a)/(i-n),l=0;l<e.length;l++)r[l]=(e[l]-n)*f+a;return r}var Ow=Object.freeze({__proto__:null,default:Rw}),Aw=vf(Ow),mf;function Iw(){if(mf)return we;mf=1,Object.defineProperty(we,"__esModule",{value:!0});var e=Mw,t=Aw;const r=" ".repeat(2),n=" ".repeat(4);function i(){return s(this)}function s(M,h={}){const{maxRows:d=15,maxColumns:u=10,maxNumSize:g=8,padMinus:m="auto"}=h;return`${M.constructor.name} {
3
+ ${r}[
4
+ ${n}${a(M,d,u,g,m)}
5
+ ${r}]
6
+ ${r}rows: ${M.rows}
7
+ ${r}columns: ${M.columns}
8
+ }`}function a(M,h,d,u,g){const{rows:m,columns:R}=M,O=Math.min(m,h),T=Math.min(R,d),k=[];if(g==="auto"){g=!1;e:for(let B=0;B<O;B++)for(let C=0;C<T;C++)if(M.get(B,C)<0){g=!0;break e}}for(let B=0;B<O;B++){let C=[];for(let W=0;W<T;W++)C.push(o(M.get(B,W),u,g));k.push(`${C.join(" ")}`)}return T!==R&&(k[k.length-1]+=` ... ${R-d} more columns`),O!==m&&k.push(`... ${m-h} more rows`),k.join(`
9
+ ${n}`)}function o(M,h,d){return(M>=0&&d?` ${c(M,h-1)}`:c(M,h)).padEnd(h)}function c(M,h){let d=M.toString();if(d.length<=h)return d;let u=M.toFixed(h);if(u.length>h&&(u=M.toFixed(Math.max(0,h-(u.length-h)))),u.length<=h&&!u.startsWith("0.000")&&!u.startsWith("-0.000"))return u;let g=M.toExponential(h);return g.length>h&&(g=M.toExponential(Math.max(0,h-(g.length-h)))),g.slice(0)}function f(M,h){M.prototype.add=function(u){return typeof u=="number"?this.addS(u):this.addM(u)},M.prototype.addS=function(u){for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)+u);return this},M.prototype.addM=function(u){if(u=h.checkMatrix(u),this.rows!==u.rows||this.columns!==u.columns)throw new RangeError("Matrices dimensions must be equal");for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)+u.get(g,m));return this},M.add=function(u,g){return new h(u).add(g)},M.prototype.sub=function(u){return typeof u=="number"?this.subS(u):this.subM(u)},M.prototype.subS=function(u){for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)-u);return this},M.prototype.subM=function(u){if(u=h.checkMatrix(u),this.rows!==u.rows||this.columns!==u.columns)throw new RangeError("Matrices dimensions must be equal");for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)-u.get(g,m));return this},M.sub=function(u,g){return new h(u).sub(g)},M.prototype.subtract=M.prototype.sub,M.prototype.subtractS=M.prototype.subS,M.prototype.subtractM=M.prototype.subM,M.subtract=M.sub,M.prototype.mul=function(u){return typeof u=="number"?this.mulS(u):this.mulM(u)},M.prototype.mulS=function(u){for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)*u);return this},M.prototype.mulM=function(u){if(u=h.checkMatrix(u),this.rows!==u.rows||this.columns!==u.columns)throw new RangeError("Matrices dimensions must be equal");for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)*u.get(g,m));return this},M.mul=function(u,g){return new h(u).mul(g)},M.prototype.multiply=M.prototype.mul,M.prototype.multiplyS=M.prototype.mulS,M.prototype.multiplyM=M.prototype.mulM,M.multiply=M.mul,M.prototype.div=function(u){return typeof u=="number"?this.divS(u):this.divM(u)},M.prototype.divS=function(u){for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)/u);return this},M.prototype.divM=function(u){if(u=h.checkMatrix(u),this.rows!==u.rows||this.columns!==u.columns)throw new RangeError("Matrices dimensions must be equal");for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)/u.get(g,m));return this},M.div=function(u,g){return new h(u).div(g)},M.prototype.divide=M.prototype.div,M.prototype.divideS=M.prototype.divS,M.prototype.divideM=M.prototype.divM,M.divide=M.div,M.prototype.mod=function(u){return typeof u=="number"?this.modS(u):this.modM(u)},M.prototype.modS=function(u){for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)%u);return this},M.prototype.modM=function(u){if(u=h.checkMatrix(u),this.rows!==u.rows||this.columns!==u.columns)throw new RangeError("Matrices dimensions must be equal");for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)%u.get(g,m));return this},M.mod=function(u,g){return new h(u).mod(g)},M.prototype.modulus=M.prototype.mod,M.prototype.modulusS=M.prototype.modS,M.prototype.modulusM=M.prototype.modM,M.modulus=M.mod,M.prototype.and=function(u){return typeof u=="number"?this.andS(u):this.andM(u)},M.prototype.andS=function(u){for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)&u);return this},M.prototype.andM=function(u){if(u=h.checkMatrix(u),this.rows!==u.rows||this.columns!==u.columns)throw new RangeError("Matrices dimensions must be equal");for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)&u.get(g,m));return this},M.and=function(u,g){return new h(u).and(g)},M.prototype.or=function(u){return typeof u=="number"?this.orS(u):this.orM(u)},M.prototype.orS=function(u){for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)|u);return this},M.prototype.orM=function(u){if(u=h.checkMatrix(u),this.rows!==u.rows||this.columns!==u.columns)throw new RangeError("Matrices dimensions must be equal");for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)|u.get(g,m));return this},M.or=function(u,g){return new h(u).or(g)},M.prototype.xor=function(u){return typeof u=="number"?this.xorS(u):this.xorM(u)},M.prototype.xorS=function(u){for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)^u);return this},M.prototype.xorM=function(u){if(u=h.checkMatrix(u),this.rows!==u.rows||this.columns!==u.columns)throw new RangeError("Matrices dimensions must be equal");for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)^u.get(g,m));return this},M.xor=function(u,g){return new h(u).xor(g)},M.prototype.leftShift=function(u){return typeof u=="number"?this.leftShiftS(u):this.leftShiftM(u)},M.prototype.leftShiftS=function(u){for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)<<u);return this},M.prototype.leftShiftM=function(u){if(u=h.checkMatrix(u),this.rows!==u.rows||this.columns!==u.columns)throw new RangeError("Matrices dimensions must be equal");for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)<<u.get(g,m));return this},M.leftShift=function(u,g){return new h(u).leftShift(g)},M.prototype.signPropagatingRightShift=function(u){return typeof u=="number"?this.signPropagatingRightShiftS(u):this.signPropagatingRightShiftM(u)},M.prototype.signPropagatingRightShiftS=function(u){for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)>>u);return this},M.prototype.signPropagatingRightShiftM=function(u){if(u=h.checkMatrix(u),this.rows!==u.rows||this.columns!==u.columns)throw new RangeError("Matrices dimensions must be equal");for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)>>u.get(g,m));return this},M.signPropagatingRightShift=function(u,g){return new h(u).signPropagatingRightShift(g)},M.prototype.rightShift=function(u){return typeof u=="number"?this.rightShiftS(u):this.rightShiftM(u)},M.prototype.rightShiftS=function(u){for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)>>>u);return this},M.prototype.rightShiftM=function(u){if(u=h.checkMatrix(u),this.rows!==u.rows||this.columns!==u.columns)throw new RangeError("Matrices dimensions must be equal");for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)>>>u.get(g,m));return this},M.rightShift=function(u,g){return new h(u).rightShift(g)},M.prototype.zeroFillRightShift=M.prototype.rightShift,M.prototype.zeroFillRightShiftS=M.prototype.rightShiftS,M.prototype.zeroFillRightShiftM=M.prototype.rightShiftM,M.zeroFillRightShift=M.rightShift,M.prototype.not=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,~this.get(u,g));return this},M.not=function(u){return new h(u).not()},M.prototype.abs=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.abs(this.get(u,g)));return this},M.abs=function(u){return new h(u).abs()},M.prototype.acos=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.acos(this.get(u,g)));return this},M.acos=function(u){return new h(u).acos()},M.prototype.acosh=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.acosh(this.get(u,g)));return this},M.acosh=function(u){return new h(u).acosh()},M.prototype.asin=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.asin(this.get(u,g)));return this},M.asin=function(u){return new h(u).asin()},M.prototype.asinh=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.asinh(this.get(u,g)));return this},M.asinh=function(u){return new h(u).asinh()},M.prototype.atan=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.atan(this.get(u,g)));return this},M.atan=function(u){return new h(u).atan()},M.prototype.atanh=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.atanh(this.get(u,g)));return this},M.atanh=function(u){return new h(u).atanh()},M.prototype.cbrt=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.cbrt(this.get(u,g)));return this},M.cbrt=function(u){return new h(u).cbrt()},M.prototype.ceil=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.ceil(this.get(u,g)));return this},M.ceil=function(u){return new h(u).ceil()},M.prototype.clz32=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.clz32(this.get(u,g)));return this},M.clz32=function(u){return new h(u).clz32()},M.prototype.cos=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.cos(this.get(u,g)));return this},M.cos=function(u){return new h(u).cos()},M.prototype.cosh=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.cosh(this.get(u,g)));return this},M.cosh=function(u){return new h(u).cosh()},M.prototype.exp=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.exp(this.get(u,g)));return this},M.exp=function(u){return new h(u).exp()},M.prototype.expm1=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.expm1(this.get(u,g)));return this},M.expm1=function(u){return new h(u).expm1()},M.prototype.floor=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.floor(this.get(u,g)));return this},M.floor=function(u){return new h(u).floor()},M.prototype.fround=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.fround(this.get(u,g)));return this},M.fround=function(u){return new h(u).fround()},M.prototype.log=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.log(this.get(u,g)));return this},M.log=function(u){return new h(u).log()},M.prototype.log1p=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.log1p(this.get(u,g)));return this},M.log1p=function(u){return new h(u).log1p()},M.prototype.log10=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.log10(this.get(u,g)));return this},M.log10=function(u){return new h(u).log10()},M.prototype.log2=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.log2(this.get(u,g)));return this},M.log2=function(u){return new h(u).log2()},M.prototype.round=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.round(this.get(u,g)));return this},M.round=function(u){return new h(u).round()},M.prototype.sign=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.sign(this.get(u,g)));return this},M.sign=function(u){return new h(u).sign()},M.prototype.sin=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.sin(this.get(u,g)));return this},M.sin=function(u){return new h(u).sin()},M.prototype.sinh=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.sinh(this.get(u,g)));return this},M.sinh=function(u){return new h(u).sinh()},M.prototype.sqrt=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.sqrt(this.get(u,g)));return this},M.sqrt=function(u){return new h(u).sqrt()},M.prototype.tan=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.tan(this.get(u,g)));return this},M.tan=function(u){return new h(u).tan()},M.prototype.tanh=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.tanh(this.get(u,g)));return this},M.tanh=function(u){return new h(u).tanh()},M.prototype.trunc=function(){for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.set(u,g,Math.trunc(this.get(u,g)));return this},M.trunc=function(u){return new h(u).trunc()},M.pow=function(u,g){return new h(u).pow(g)},M.prototype.pow=function(u){return typeof u=="number"?this.powS(u):this.powM(u)},M.prototype.powS=function(u){for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)**u);return this},M.prototype.powM=function(u){if(u=h.checkMatrix(u),this.rows!==u.rows||this.columns!==u.columns)throw new RangeError("Matrices dimensions must be equal");for(let g=0;g<this.rows;g++)for(let m=0;m<this.columns;m++)this.set(g,m,this.get(g,m)**u.get(g,m));return this}}function l(M,h,d){let u=d?M.rows:M.rows-1;if(h<0||h>u)throw new RangeError("Row index out of range")}function p(M,h,d){let u=d?M.columns:M.columns-1;if(h<0||h>u)throw new RangeError("Column index out of range")}function v(M,h){if(h.to1DArray&&(h=h.to1DArray()),h.length!==M.columns)throw new RangeError("vector size must be the same as the number of columns");return h}function y(M,h){if(h.to1DArray&&(h=h.to1DArray()),h.length!==M.rows)throw new RangeError("vector size must be the same as the number of rows");return h}function x(M,h){if(!e.isAnyArray(h))throw new TypeError("row indices must be an array");for(let d=0;d<h.length;d++)if(h[d]<0||h[d]>=M.rows)throw new RangeError("row indices are out of range")}function _(M,h){if(!e.isAnyArray(h))throw new TypeError("column indices must be an array");for(let d=0;d<h.length;d++)if(h[d]<0||h[d]>=M.columns)throw new RangeError("column indices are out of range")}function b(M,h,d,u,g){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(E("startRow",h),E("endRow",d),E("startColumn",u),E("endColumn",g),h>d||u>g||h<0||h>=M.rows||d<0||d>=M.rows||u<0||u>=M.columns||g<0||g>=M.columns)throw new RangeError("Submatrix indices are out of range")}function w(M,h=0){let d=[];for(let u=0;u<M;u++)d.push(h);return d}function E(M,h){if(typeof h!="number")throw new TypeError(`${M} must be a number`)}function N(M){if(M.isEmpty())throw new Error("Empty matrix has no elements to index")}function S(M){let h=w(M.rows);for(let d=0;d<M.rows;++d)for(let u=0;u<M.columns;++u)h[d]+=M.get(d,u);return h}function q(M){let h=w(M.columns);for(let d=0;d<M.rows;++d)for(let u=0;u<M.columns;++u)h[u]+=M.get(d,u);return h}function A(M){let h=0;for(let d=0;d<M.rows;d++)for(let u=0;u<M.columns;u++)h+=M.get(d,u);return h}function j(M){let h=w(M.rows,1);for(let d=0;d<M.rows;++d)for(let u=0;u<M.columns;++u)h[d]*=M.get(d,u);return h}function I(M){let h=w(M.columns,1);for(let d=0;d<M.rows;++d)for(let u=0;u<M.columns;++u)h[u]*=M.get(d,u);return h}function D(M){let h=1;for(let d=0;d<M.rows;d++)for(let u=0;u<M.columns;u++)h*=M.get(d,u);return h}function z(M,h,d){const u=M.rows,g=M.columns,m=[];for(let R=0;R<u;R++){let O=0,T=0,k=0;for(let B=0;B<g;B++)k=M.get(R,B)-d[R],O+=k,T+=k*k;h?m.push((T-O*O/g)/(g-1)):m.push((T-O*O/g)/g)}return m}function $(M,h,d){const u=M.rows,g=M.columns,m=[];for(let R=0;R<g;R++){let O=0,T=0,k=0;for(let B=0;B<u;B++)k=M.get(B,R)-d[R],O+=k,T+=k*k;h?m.push((T-O*O/u)/(u-1)):m.push((T-O*O/u)/u)}return m}function V(M,h,d){const u=M.rows,g=M.columns,m=u*g;let R=0,O=0,T=0;for(let k=0;k<u;k++)for(let B=0;B<g;B++)T=M.get(k,B)-d,R+=T,O+=T*T;return h?(O-R*R/m)/(m-1):(O-R*R/m)/m}function Y(M,h){for(let d=0;d<M.rows;d++)for(let u=0;u<M.columns;u++)M.set(d,u,M.get(d,u)-h[d])}function ee(M,h){for(let d=0;d<M.rows;d++)for(let u=0;u<M.columns;u++)M.set(d,u,M.get(d,u)-h[u])}function J(M,h){for(let d=0;d<M.rows;d++)for(let u=0;u<M.columns;u++)M.set(d,u,M.get(d,u)-h)}function ae(M){const h=[];for(let d=0;d<M.rows;d++){let u=0;for(let g=0;g<M.columns;g++)u+=M.get(d,g)**2/(M.columns-1);h.push(Math.sqrt(u))}return h}function be(M,h){for(let d=0;d<M.rows;d++)for(let u=0;u<M.columns;u++)M.set(d,u,M.get(d,u)/h[d])}function Z(M){const h=[];for(let d=0;d<M.columns;d++){let u=0;for(let g=0;g<M.rows;g++)u+=M.get(g,d)**2/(M.rows-1);h.push(Math.sqrt(u))}return h}function ue(M,h){for(let d=0;d<M.rows;d++)for(let u=0;u<M.columns;u++)M.set(d,u,M.get(d,u)/h[u])}function ge(M){const h=M.size-1;let d=0;for(let u=0;u<M.columns;u++)for(let g=0;g<M.rows;g++)d+=M.get(g,u)**2/h;return Math.sqrt(d)}function le(M,h){for(let d=0;d<M.rows;d++)for(let u=0;u<M.columns;u++)M.set(d,u,M.get(d,u)/h)}class ie{static from1DArray(h,d,u){if(h*d!==u.length)throw new RangeError("data length does not match given dimensions");let m=new P(h,d);for(let R=0;R<h;R++)for(let O=0;O<d;O++)m.set(R,O,u[R*d+O]);return m}static rowVector(h){let d=new P(1,h.length);for(let u=0;u<h.length;u++)d.set(0,u,h[u]);return d}static columnVector(h){let d=new P(h.length,1);for(let u=0;u<h.length;u++)d.set(u,0,h[u]);return d}static zeros(h,d){return new P(h,d)}static ones(h,d){return new P(h,d).fill(1)}static rand(h,d,u={}){if(typeof u!="object")throw new TypeError("options must be an object");const{random:g=Math.random}=u;let m=new P(h,d);for(let R=0;R<h;R++)for(let O=0;O<d;O++)m.set(R,O,g());return m}static randInt(h,d,u={}){if(typeof u!="object")throw new TypeError("options must be an object");const{min:g=0,max:m=1e3,random:R=Math.random}=u;if(!Number.isInteger(g))throw new TypeError("min must be an integer");if(!Number.isInteger(m))throw new TypeError("max must be an integer");if(g>=m)throw new RangeError("min must be smaller than max");let O=m-g,T=new P(h,d);for(let k=0;k<h;k++)for(let B=0;B<d;B++){let C=g+Math.round(R()*O);T.set(k,B,C)}return T}static eye(h,d,u){d===void 0&&(d=h),u===void 0&&(u=1);let g=Math.min(h,d),m=this.zeros(h,d);for(let R=0;R<g;R++)m.set(R,R,u);return m}static diag(h,d,u){let g=h.length;d===void 0&&(d=g),u===void 0&&(u=d);let m=Math.min(g,d,u),R=this.zeros(d,u);for(let O=0;O<m;O++)R.set(O,O,h[O]);return R}static min(h,d){h=this.checkMatrix(h),d=this.checkMatrix(d);let u=h.rows,g=h.columns,m=new P(u,g);for(let R=0;R<u;R++)for(let O=0;O<g;O++)m.set(R,O,Math.min(h.get(R,O),d.get(R,O)));return m}static max(h,d){h=this.checkMatrix(h),d=this.checkMatrix(d);let u=h.rows,g=h.columns,m=new this(u,g);for(let R=0;R<u;R++)for(let O=0;O<g;O++)m.set(R,O,Math.max(h.get(R,O),d.get(R,O)));return m}static checkMatrix(h){return ie.isMatrix(h)?h:new P(h)}static isMatrix(h){return h!=null&&h.klass==="Matrix"}get size(){return this.rows*this.columns}apply(h){if(typeof h!="function")throw new TypeError("callback must be a function");for(let d=0;d<this.rows;d++)for(let u=0;u<this.columns;u++)h.call(this,d,u);return this}to1DArray(){let h=[];for(let d=0;d<this.rows;d++)for(let u=0;u<this.columns;u++)h.push(this.get(d,u));return h}to2DArray(){let h=[];for(let d=0;d<this.rows;d++){h.push([]);for(let u=0;u<this.columns;u++)h[d].push(this.get(d,u))}return h}toJSON(){return this.to2DArray()}isRowVector(){return this.rows===1}isColumnVector(){return this.columns===1}isVector(){return this.rows===1||this.columns===1}isSquare(){return this.rows===this.columns}isEmpty(){return this.rows===0||this.columns===0}isSymmetric(){if(this.isSquare()){for(let h=0;h<this.rows;h++)for(let d=0;d<=h;d++)if(this.get(h,d)!==this.get(d,h))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let h=0;h<this.rows;h++)if(this.get(h,h)!==0)return!1;return!0}isEchelonForm(){let h=0,d=0,u=-1,g=!0,m=!1;for(;h<this.rows&&g;){for(d=0,m=!1;d<this.columns&&m===!1;)this.get(h,d)===0?d++:this.get(h,d)===1&&d>u?(m=!0,u=d):(g=!1,m=!0);h++}return g}isReducedEchelonForm(){let h=0,d=0,u=-1,g=!0,m=!1;for(;h<this.rows&&g;){for(d=0,m=!1;d<this.columns&&m===!1;)this.get(h,d)===0?d++:this.get(h,d)===1&&d>u?(m=!0,u=d):(g=!1,m=!0);for(let R=d+1;R<this.rows;R++)this.get(h,R)!==0&&(g=!1);h++}return g}echelonForm(){let h=this.clone(),d=0,u=0;for(;d<h.rows&&u<h.columns;){let g=d;for(let m=d;m<h.rows;m++)h.get(m,u)>h.get(g,u)&&(g=m);if(h.get(g,u)===0)u++;else{h.swapRows(d,g);let m=h.get(d,u);for(let R=u;R<h.columns;R++)h.set(d,R,h.get(d,R)/m);for(let R=d+1;R<h.rows;R++){let O=h.get(R,u)/h.get(d,u);h.set(R,u,0);for(let T=u+1;T<h.columns;T++)h.set(R,T,h.get(R,T)-h.get(d,T)*O)}d++,u++}}return h}reducedEchelonForm(){let h=this.echelonForm(),d=h.columns,u=h.rows,g=u-1;for(;g>=0;)if(h.maxRow(g)===0)g--;else{let m=0,R=!1;for(;m<u&&R===!1;)h.get(g,m)===1?R=!0:m++;for(let O=0;O<g;O++){let T=h.get(O,m);for(let k=m;k<d;k++){let B=h.get(O,k)-T*h.get(g,k);h.set(O,k,B)}}g--}return h}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(h={}){if(typeof h!="object")throw new TypeError("options must be an object");const{rows:d=1,columns:u=1}=h;if(!Number.isInteger(d)||d<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(u)||u<=0)throw new TypeError("columns must be a positive integer");let g=new P(this.rows*d,this.columns*u);for(let m=0;m<d;m++)for(let R=0;R<u;R++)g.setSubMatrix(this,this.rows*m,this.columns*R);return g}fill(h){for(let d=0;d<this.rows;d++)for(let u=0;u<this.columns;u++)this.set(d,u,h);return this}neg(){return this.mulS(-1)}getRow(h){l(this,h);let d=[];for(let u=0;u<this.columns;u++)d.push(this.get(h,u));return d}getRowVector(h){return P.rowVector(this.getRow(h))}setRow(h,d){l(this,h),d=v(this,d);for(let u=0;u<this.columns;u++)this.set(h,u,d[u]);return this}swapRows(h,d){l(this,h),l(this,d);for(let u=0;u<this.columns;u++){let g=this.get(h,u);this.set(h,u,this.get(d,u)),this.set(d,u,g)}return this}getColumn(h){p(this,h);let d=[];for(let u=0;u<this.rows;u++)d.push(this.get(u,h));return d}getColumnVector(h){return P.columnVector(this.getColumn(h))}setColumn(h,d){p(this,h),d=y(this,d);for(let u=0;u<this.rows;u++)this.set(u,h,d[u]);return this}swapColumns(h,d){p(this,h),p(this,d);for(let u=0;u<this.rows;u++){let g=this.get(u,h);this.set(u,h,this.get(u,d)),this.set(u,d,g)}return this}addRowVector(h){h=v(this,h);for(let d=0;d<this.rows;d++)for(let u=0;u<this.columns;u++)this.set(d,u,this.get(d,u)+h[u]);return this}subRowVector(h){h=v(this,h);for(let d=0;d<this.rows;d++)for(let u=0;u<this.columns;u++)this.set(d,u,this.get(d,u)-h[u]);return this}mulRowVector(h){h=v(this,h);for(let d=0;d<this.rows;d++)for(let u=0;u<this.columns;u++)this.set(d,u,this.get(d,u)*h[u]);return this}divRowVector(h){h=v(this,h);for(let d=0;d<this.rows;d++)for(let u=0;u<this.columns;u++)this.set(d,u,this.get(d,u)/h[u]);return this}addColumnVector(h){h=y(this,h);for(let d=0;d<this.rows;d++)for(let u=0;u<this.columns;u++)this.set(d,u,this.get(d,u)+h[d]);return this}subColumnVector(h){h=y(this,h);for(let d=0;d<this.rows;d++)for(let u=0;u<this.columns;u++)this.set(d,u,this.get(d,u)-h[d]);return this}mulColumnVector(h){h=y(this,h);for(let d=0;d<this.rows;d++)for(let u=0;u<this.columns;u++)this.set(d,u,this.get(d,u)*h[d]);return this}divColumnVector(h){h=y(this,h);for(let d=0;d<this.rows;d++)for(let u=0;u<this.columns;u++)this.set(d,u,this.get(d,u)/h[d]);return this}mulRow(h,d){l(this,h);for(let u=0;u<this.columns;u++)this.set(h,u,this.get(h,u)*d);return this}mulColumn(h,d){p(this,h);for(let u=0;u<this.rows;u++)this.set(u,h,this.get(u,h)*d);return this}max(h){if(this.isEmpty())return NaN;switch(h){case"row":{const d=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.get(u,g)>d[u]&&(d[u]=this.get(u,g));return d}case"column":{const d=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.get(u,g)>d[g]&&(d[g]=this.get(u,g));return d}case void 0:{let d=this.get(0,0);for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.get(u,g)>d&&(d=this.get(u,g));return d}default:throw new Error(`invalid option: ${h}`)}}maxIndex(){N(this);let h=this.get(0,0),d=[0,0];for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.get(u,g)>h&&(h=this.get(u,g),d[0]=u,d[1]=g);return d}min(h){if(this.isEmpty())return NaN;switch(h){case"row":{const d=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.get(u,g)<d[u]&&(d[u]=this.get(u,g));return d}case"column":{const d=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.get(u,g)<d[g]&&(d[g]=this.get(u,g));return d}case void 0:{let d=this.get(0,0);for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.get(u,g)<d&&(d=this.get(u,g));return d}default:throw new Error(`invalid option: ${h}`)}}minIndex(){N(this);let h=this.get(0,0),d=[0,0];for(let u=0;u<this.rows;u++)for(let g=0;g<this.columns;g++)this.get(u,g)<h&&(h=this.get(u,g),d[0]=u,d[1]=g);return d}maxRow(h){if(l(this,h),this.isEmpty())return NaN;let d=this.get(h,0);for(let u=1;u<this.columns;u++)this.get(h,u)>d&&(d=this.get(h,u));return d}maxRowIndex(h){l(this,h),N(this);let d=this.get(h,0),u=[h,0];for(let g=1;g<this.columns;g++)this.get(h,g)>d&&(d=this.get(h,g),u[1]=g);return u}minRow(h){if(l(this,h),this.isEmpty())return NaN;let d=this.get(h,0);for(let u=1;u<this.columns;u++)this.get(h,u)<d&&(d=this.get(h,u));return d}minRowIndex(h){l(this,h),N(this);let d=this.get(h,0),u=[h,0];for(let g=1;g<this.columns;g++)this.get(h,g)<d&&(d=this.get(h,g),u[1]=g);return u}maxColumn(h){if(p(this,h),this.isEmpty())return NaN;let d=this.get(0,h);for(let u=1;u<this.rows;u++)this.get(u,h)>d&&(d=this.get(u,h));return d}maxColumnIndex(h){p(this,h),N(this);let d=this.get(0,h),u=[0,h];for(let g=1;g<this.rows;g++)this.get(g,h)>d&&(d=this.get(g,h),u[0]=g);return u}minColumn(h){if(p(this,h),this.isEmpty())return NaN;let d=this.get(0,h);for(let u=1;u<this.rows;u++)this.get(u,h)<d&&(d=this.get(u,h));return d}minColumnIndex(h){p(this,h),N(this);let d=this.get(0,h),u=[0,h];for(let g=1;g<this.rows;g++)this.get(g,h)<d&&(d=this.get(g,h),u[0]=g);return u}diag(){let h=Math.min(this.rows,this.columns),d=[];for(let u=0;u<h;u++)d.push(this.get(u,u));return d}norm(h="frobenius"){switch(h){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${h}`)}}cumulativeSum(){let h=0;for(let d=0;d<this.rows;d++)for(let u=0;u<this.columns;u++)h+=this.get(d,u),this.set(d,u,h);return this}dot(h){ie.isMatrix(h)&&(h=h.to1DArray());let d=this.to1DArray();if(d.length!==h.length)throw new RangeError("vectors do not have the same size");let u=0;for(let g=0;g<d.length;g++)u+=d[g]*h[g];return u}mmul(h){h=P.checkMatrix(h);let d=this.rows,u=this.columns,g=h.columns,m=new P(d,g),R=new Float64Array(u);for(let O=0;O<g;O++){for(let T=0;T<u;T++)R[T]=h.get(T,O);for(let T=0;T<d;T++){let k=0;for(let B=0;B<u;B++)k+=this.get(T,B)*R[B];m.set(T,O,k)}}return m}mpow(h){if(!this.isSquare())throw new RangeError("Matrix must be square");if(!Number.isInteger(h)||h<0)throw new RangeError("Exponent must be a non-negative integer");let d=P.eye(this.rows),u=this;for(let g=h;g>=1;g/=2)(g&1)!==0&&(d=d.mmul(u)),u=u.mmul(u);return d}strassen2x2(h){h=P.checkMatrix(h);let d=new P(2,2);const u=this.get(0,0),g=h.get(0,0),m=this.get(0,1),R=h.get(0,1),O=this.get(1,0),T=h.get(1,0),k=this.get(1,1),B=h.get(1,1),C=(u+k)*(g+B),W=(O+k)*g,ne=u*(R-B),U=k*(T-g),K=(u+m)*B,se=(O-u)*(g+R),L=(m-k)*(T+B),re=C+U-K+L,ce=ne+K,pe=W+U,me=C-W+ne+se;return d.set(0,0,re),d.set(0,1,ce),d.set(1,0,pe),d.set(1,1,me),d}strassen3x3(h){h=P.checkMatrix(h);let d=new P(3,3);const u=this.get(0,0),g=this.get(0,1),m=this.get(0,2),R=this.get(1,0),O=this.get(1,1),T=this.get(1,2),k=this.get(2,0),B=this.get(2,1),C=this.get(2,2),W=h.get(0,0),ne=h.get(0,1),U=h.get(0,2),K=h.get(1,0),se=h.get(1,1),L=h.get(1,2),re=h.get(2,0),ce=h.get(2,1),pe=h.get(2,2),me=(u+g+m-R-O-B-C)*se,Ie=(u-R)*(-ne+se),he=O*(-W+ne+K-se-L-re+pe),de=(-u+R+O)*(W-ne+se),Re=(R+O)*(-W+ne),F=u*W,Q=(-u+k+B)*(W-U+L),oe=(-u+k)*(U-L),H=(k+B)*(-W+U),Te=(u+g+m-O-T-k-B)*L,Se=B*(-W+U+K-se-L-re+ce),Oe=(-m+B+C)*(se+re-ce),ke=(m-C)*(se-ce),We=m*re,ct=(B+C)*(-re+ce),Fe=(-m+O+T)*(L+re-pe),dt=(m-T)*(L-pe),xt=(O+T)*(-re+pe),Ne=g*K,Ye=T*ce,tt=R*U,rt=k*ne,Be=C*pe,Tx=F+We+Ne,kx=me+de+Re+F+Oe+We+ct,jx=F+Q+H+Te+We+Fe+xt,Cx=Ie+he+de+F+We+Fe+dt,Px=Ie+de+Re+F+Ye,Lx=We+Fe+dt+xt+tt,Dx=F+Q+oe+Se+Oe+ke+We,zx=Oe+ke+We+ct+rt,Fx=F+Q+oe+H+Be;return d.set(0,0,Tx),d.set(0,1,kx),d.set(0,2,jx),d.set(1,0,Cx),d.set(1,1,Px),d.set(1,2,Lx),d.set(2,0,Dx),d.set(2,1,zx),d.set(2,2,Fx),d}mmulStrassen(h){h=P.checkMatrix(h);let d=this.clone(),u=d.rows,g=d.columns,m=h.rows,R=h.columns;g!==m&&console.warn(`Multiplying ${u} x ${g} and ${m} x ${R} matrix: dimensions do not match.`);function O(C,W,ne){let U=C.rows,K=C.columns;if(U===W&&K===ne)return C;{let se=ie.zeros(W,ne);return se=se.setSubMatrix(C,0,0),se}}let T=Math.max(u,m),k=Math.max(g,R);d=O(d,T,k),h=O(h,T,k);function B(C,W,ne,U){if(ne<=512||U<=512)return C.mmul(W);ne%2===1&&U%2===1?(C=O(C,ne+1,U+1),W=O(W,ne+1,U+1)):ne%2===1?(C=O(C,ne+1,U),W=O(W,ne+1,U)):U%2===1&&(C=O(C,ne,U+1),W=O(W,ne,U+1));let K=parseInt(C.rows/2,10),se=parseInt(C.columns/2,10),L=C.subMatrix(0,K-1,0,se-1),re=W.subMatrix(0,K-1,0,se-1),ce=C.subMatrix(0,K-1,se,C.columns-1),pe=W.subMatrix(0,K-1,se,W.columns-1),me=C.subMatrix(K,C.rows-1,0,se-1),Ie=W.subMatrix(K,W.rows-1,0,se-1),he=C.subMatrix(K,C.rows-1,se,C.columns-1),de=W.subMatrix(K,W.rows-1,se,W.columns-1),Re=B(ie.add(L,he),ie.add(re,de),K,se),F=B(ie.add(me,he),re,K,se),Q=B(L,ie.sub(pe,de),K,se),oe=B(he,ie.sub(Ie,re),K,se),H=B(ie.add(L,ce),de,K,se),Te=B(ie.sub(me,L),ie.add(re,pe),K,se),Se=B(ie.sub(ce,he),ie.add(Ie,de),K,se),Oe=ie.add(Re,oe);Oe.sub(H),Oe.add(Se);let ke=ie.add(Q,H),We=ie.add(F,oe),ct=ie.sub(Re,F);ct.add(Q),ct.add(Te);let Fe=ie.zeros(2*Oe.rows,2*Oe.columns);return Fe=Fe.setSubMatrix(Oe,0,0),Fe=Fe.setSubMatrix(ke,Oe.rows,0),Fe=Fe.setSubMatrix(We,0,Oe.columns),Fe=Fe.setSubMatrix(ct,Oe.rows,Oe.columns),Fe.subMatrix(0,ne-1,0,U-1)}return B(d,h,T,k)}scaleRows(h={}){if(typeof h!="object")throw new TypeError("options must be an object");const{min:d=0,max:u=1}=h;if(!Number.isFinite(d))throw new TypeError("min must be a number");if(!Number.isFinite(u))throw new TypeError("max must be a number");if(d>=u)throw new RangeError("min must be smaller than max");let g=new P(this.rows,this.columns);for(let m=0;m<this.rows;m++){const R=this.getRow(m);R.length>0&&t(R,{min:d,max:u,output:R}),g.setRow(m,R)}return g}scaleColumns(h={}){if(typeof h!="object")throw new TypeError("options must be an object");const{min:d=0,max:u=1}=h;if(!Number.isFinite(d))throw new TypeError("min must be a number");if(!Number.isFinite(u))throw new TypeError("max must be a number");if(d>=u)throw new RangeError("min must be smaller than max");let g=new P(this.rows,this.columns);for(let m=0;m<this.columns;m++){const R=this.getColumn(m);R.length&&t(R,{min:d,max:u,output:R}),g.setColumn(m,R)}return g}flipRows(){const h=Math.ceil(this.columns/2);for(let d=0;d<this.rows;d++)for(let u=0;u<h;u++){let g=this.get(d,u),m=this.get(d,this.columns-1-u);this.set(d,u,m),this.set(d,this.columns-1-u,g)}return this}flipColumns(){const h=Math.ceil(this.rows/2);for(let d=0;d<this.columns;d++)for(let u=0;u<h;u++){let g=this.get(u,d),m=this.get(this.rows-1-u,d);this.set(u,d,m),this.set(this.rows-1-u,d,g)}return this}kroneckerProduct(h){h=P.checkMatrix(h);let d=this.rows,u=this.columns,g=h.rows,m=h.columns,R=new P(d*g,u*m);for(let O=0;O<d;O++)for(let T=0;T<u;T++)for(let k=0;k<g;k++)for(let B=0;B<m;B++)R.set(g*O+k,m*T+B,this.get(O,T)*h.get(k,B));return R}kroneckerSum(h){if(h=P.checkMatrix(h),!this.isSquare()||!h.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let d=this.rows,u=h.rows,g=this.kroneckerProduct(P.eye(u,u)),m=P.eye(d,d).kroneckerProduct(h);return g.add(m)}transpose(){let h=new P(this.columns,this.rows);for(let d=0;d<this.rows;d++)for(let u=0;u<this.columns;u++)h.set(u,d,this.get(d,u));return h}sortRows(h=_e){for(let d=0;d<this.rows;d++)this.setRow(d,this.getRow(d).sort(h));return this}sortColumns(h=_e){for(let d=0;d<this.columns;d++)this.setColumn(d,this.getColumn(d).sort(h));return this}subMatrix(h,d,u,g){b(this,h,d,u,g);let m=new P(d-h+1,g-u+1);for(let R=h;R<=d;R++)for(let O=u;O<=g;O++)m.set(R-h,O-u,this.get(R,O));return m}subMatrixRow(h,d,u){if(d===void 0&&(d=0),u===void 0&&(u=this.columns-1),d>u||d<0||d>=this.columns||u<0||u>=this.columns)throw new RangeError("Argument out of range");let g=new P(h.length,u-d+1);for(let m=0;m<h.length;m++)for(let R=d;R<=u;R++){if(h[m]<0||h[m]>=this.rows)throw new RangeError(`Row index out of range: ${h[m]}`);g.set(m,R-d,this.get(h[m],R))}return g}subMatrixColumn(h,d,u){if(d===void 0&&(d=0),u===void 0&&(u=this.rows-1),d>u||d<0||d>=this.rows||u<0||u>=this.rows)throw new RangeError("Argument out of range");let g=new P(u-d+1,h.length);for(let m=0;m<h.length;m++)for(let R=d;R<=u;R++){if(h[m]<0||h[m]>=this.columns)throw new RangeError(`Column index out of range: ${h[m]}`);g.set(R-d,m,this.get(R,h[m]))}return g}setSubMatrix(h,d,u){if(h=P.checkMatrix(h),h.isEmpty())return this;let g=d+h.rows-1,m=u+h.columns-1;b(this,d,g,u,m);for(let R=0;R<h.rows;R++)for(let O=0;O<h.columns;O++)this.set(d+R,u+O,h.get(R,O));return this}selection(h,d){x(this,h),_(this,d);let u=new P(h.length,d.length);for(let g=0;g<h.length;g++){let m=h[g];for(let R=0;R<d.length;R++){let O=d[R];u.set(g,R,this.get(m,O))}}return u}trace(){let h=Math.min(this.rows,this.columns),d=0;for(let u=0;u<h;u++)d+=this.get(u,u);return d}clone(){return this.constructor.copy(this,new P(this.rows,this.columns))}static copy(h,d){for(const[u,g,m]of h.entries())d.set(u,g,m);return d}sum(h){switch(h){case"row":return S(this);case"column":return q(this);case void 0:return A(this);default:throw new Error(`invalid option: ${h}`)}}product(h){switch(h){case"row":return j(this);case"column":return I(this);case void 0:return D(this);default:throw new Error(`invalid option: ${h}`)}}mean(h){const d=this.sum(h);switch(h){case"row":{for(let u=0;u<this.rows;u++)d[u]/=this.columns;return d}case"column":{for(let u=0;u<this.columns;u++)d[u]/=this.rows;return d}case void 0:return d/this.size;default:throw new Error(`invalid option: ${h}`)}}variance(h,d={}){if(typeof h=="object"&&(d=h,h=void 0),typeof d!="object")throw new TypeError("options must be an object");const{unbiased:u=!0,mean:g=this.mean(h)}=d;if(typeof u!="boolean")throw new TypeError("unbiased must be a boolean");switch(h){case"row":{if(!e.isAnyArray(g))throw new TypeError("mean must be an array");return z(this,u,g)}case"column":{if(!e.isAnyArray(g))throw new TypeError("mean must be an array");return $(this,u,g)}case void 0:{if(typeof g!="number")throw new TypeError("mean must be a number");return V(this,u,g)}default:throw new Error(`invalid option: ${h}`)}}standardDeviation(h,d){typeof h=="object"&&(d=h,h=void 0);const u=this.variance(h,d);if(h===void 0)return Math.sqrt(u);for(let g=0;g<u.length;g++)u[g]=Math.sqrt(u[g]);return u}center(h,d={}){if(typeof h=="object"&&(d=h,h=void 0),typeof d!="object")throw new TypeError("options must be an object");const{center:u=this.mean(h)}=d;switch(h){case"row":{if(!e.isAnyArray(u))throw new TypeError("center must be an array");return Y(this,u),this}case"column":{if(!e.isAnyArray(u))throw new TypeError("center must be an array");return ee(this,u),this}case void 0:{if(typeof u!="number")throw new TypeError("center must be a number");return J(this,u),this}default:throw new Error(`invalid option: ${h}`)}}scale(h,d={}){if(typeof h=="object"&&(d=h,h=void 0),typeof d!="object")throw new TypeError("options must be an object");let u=d.scale;switch(h){case"row":{if(u===void 0)u=ae(this);else if(!e.isAnyArray(u))throw new TypeError("scale must be an array");return be(this,u),this}case"column":{if(u===void 0)u=Z(this);else if(!e.isAnyArray(u))throw new TypeError("scale must be an array");return ue(this,u),this}case void 0:{if(u===void 0)u=ge(this);else if(typeof u!="number")throw new TypeError("scale must be a number");return le(this,u),this}default:throw new Error(`invalid option: ${h}`)}}toString(h){return s(this,h)}[Symbol.iterator](){return this.entries()}*entries(){for(let h=0;h<this.rows;h++)for(let d=0;d<this.columns;d++)yield[h,d,this.get(h,d)]}*values(){for(let h=0;h<this.rows;h++)for(let d=0;d<this.columns;d++)yield this.get(h,d)}}ie.prototype.klass="Matrix",typeof Symbol<"u"&&(ie.prototype[Symbol.for("nodejs.util.inspect.custom")]=i);function _e(M,h){return M-h}function G(M){return M.every(h=>typeof h=="number")}ie.random=ie.rand,ie.randomInt=ie.randInt,ie.diagonal=ie.diag,ie.prototype.diagonal=ie.prototype.diag,ie.identity=ie.eye,ie.prototype.negate=ie.prototype.neg,ie.prototype.tensorProduct=ie.prototype.kroneckerProduct;class P extends ie{data;#e(h,d){if(this.data=[],Number.isInteger(d)&&d>=0)for(let u=0;u<h;u++)this.data.push(new Float64Array(d));else throw new TypeError("nColumns must be a positive integer");this.rows=h,this.columns=d}constructor(h,d){if(super(),P.isMatrix(h))this.#e(h.rows,h.columns),P.copy(h,this);else if(Number.isInteger(h)&&h>=0)this.#e(h,d);else if(e.isAnyArray(h)){const u=h;if(h=u.length,d=h?u[0].length:0,typeof d!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let g=0;g<h;g++){if(u[g].length!==d)throw new RangeError("Inconsistent array dimensions");if(!G(u[g]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(u[g]))}this.rows=h,this.columns=d}else throw new TypeError("First argument must be a positive number or an array")}set(h,d,u){return this.data[h][d]=u,this}get(h,d){return this.data[h][d]}removeRow(h){return l(this,h),this.data.splice(h,1),this.rows-=1,this}addRow(h,d){return d===void 0&&(d=h,h=this.rows),l(this,h,!0),d=Float64Array.from(v(this,d)),this.data.splice(h,0,d),this.rows+=1,this}removeColumn(h){p(this,h);for(let d=0;d<this.rows;d++){const u=new Float64Array(this.columns-1);for(let g=0;g<h;g++)u[g]=this.data[d][g];for(let g=h+1;g<this.columns;g++)u[g-1]=this.data[d][g];this.data[d]=u}return this.columns-=1,this}addColumn(h,d){typeof d>"u"&&(d=h,h=this.columns),p(this,h,!0),d=y(this,d);for(let u=0;u<this.rows;u++){const g=new Float64Array(this.columns+1);let m=0;for(;m<h;m++)g[m]=this.data[u][m];for(g[m++]=d[u];m<this.columns+1;m++)g[m]=this.data[u][m-1];this.data[u]=g}return this.columns+=1,this}}f(ie,P);class X extends ie{#e;get size(){return this.#e.size}get rows(){return this.#e.rows}get columns(){return this.#e.columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(h){return P.isMatrix(h)&&h.klassType==="SymmetricMatrix"}static zeros(h){return new this(h)}static ones(h){return new this(h).fill(1)}constructor(h){if(super(),P.isMatrix(h)){if(!h.isSymmetric())throw new TypeError("not symmetric data");this.#e=P.copy(h,new P(h.rows,h.rows))}else if(Number.isInteger(h)&&h>=0)this.#e=new P(h,h);else if(this.#e=new P(h),!this.isSymmetric())throw new TypeError("not symmetric data")}clone(){const h=new X(this.diagonalSize);for(const[d,u,g]of this.upperRightEntries())h.set(d,u,g);return h}toMatrix(){return new P(this)}get(h,d){return this.#e.get(h,d)}set(h,d,u){return this.#e.set(h,d,u),this.#e.set(d,h,u),this}removeCross(h){return this.#e.removeRow(h),this.#e.removeColumn(h),this}addCross(h,d){d===void 0&&(d=h,h=this.diagonalSize);const u=d.slice();return u.splice(h,1),this.#e.addRow(h,u),this.#e.addColumn(h,d),this}applyMask(h){if(h.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const d=[];for(const[u,g]of h.entries())g||d.push(u);d.reverse();for(const u of d)this.removeCross(u);return this}toCompact(){const{diagonalSize:h}=this,d=new Array(h*(h+1)/2);for(let u=0,g=0,m=0;m<d.length;m++)d[m]=this.get(g,u),++u>=h&&(u=++g);return d}static fromCompact(h){const d=h.length,u=(Math.sqrt(8*d+1)-1)/2;if(!Number.isInteger(u))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(h)}`);const g=new X(u);for(let m=0,R=0,O=0;O<d;O++)g.set(m,R,h[O]),++m>=u&&(m=++R);return g}*upperRightEntries(){for(let h=0,d=0;h<this.diagonalSize;void 0){const u=this.get(h,d);yield[h,d,u],++d>=this.diagonalSize&&(d=++h)}}*upperRightValues(){for(let h=0,d=0;h<this.diagonalSize;void 0)yield this.get(h,d),++d>=this.diagonalSize&&(d=++h)}}X.prototype.klassType="SymmetricMatrix";class te extends X{static isDistanceMatrix(h){return X.isSymmetricMatrix(h)&&h.klassSubType==="DistanceMatrix"}constructor(h){if(super(h),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(h,d,u){return h===d&&(u=0),super.set(h,d,u)}addCross(h,d){return d===void 0&&(d=h,h=this.diagonalSize),d=d.slice(),d[h]=0,super.addCross(h,d)}toSymmetricMatrix(){return new X(this)}clone(){const h=new te(this.diagonalSize);for(const[d,u,g]of this.upperRightEntries())d!==u&&h.set(d,u,g);return h}toCompact(){const{diagonalSize:h}=this,d=(h-1)*h/2,u=new Array(d);for(let g=1,m=0,R=0;R<u.length;R++)u[R]=this.get(m,g),++g>=h&&(g=++m+1);return u}static fromCompact(h){const d=h.length;if(d===0)return new this(0);const u=(Math.sqrt(8*d+1)+1)/2;if(!Number.isInteger(u))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(h)}`);const g=new this(u);for(let m=1,R=0,O=0;O<d;O++)g.set(m,R,h[O]),++m>=u&&(m=++R+1);return g}}te.prototype.klassSubType="DistanceMatrix";class fe extends ie{constructor(h,d,u){super(),this.matrix=h,this.rows=d,this.columns=u}}class xe extends fe{constructor(h,d){p(h,d),super(h,h.rows,1),this.column=d}set(h,d,u){return this.matrix.set(h,this.column,u),this}get(h){return this.matrix.get(h,this.column)}}class Ce extends fe{constructor(h,d){_(h,d),super(h,h.rows,d.length),this.columnIndices=d}set(h,d,u){return this.matrix.set(h,this.columnIndices[d],u),this}get(h,d){return this.matrix.get(h,this.columnIndices[d])}}class Ke extends fe{constructor(h){super(h,h.rows,h.columns)}set(h,d,u){return this.matrix.set(h,this.columns-d-1,u),this}get(h,d){return this.matrix.get(h,this.columns-d-1)}}class Zt extends fe{constructor(h){super(h,h.rows,h.columns)}set(h,d,u){return this.matrix.set(this.rows-h-1,d,u),this}get(h,d){return this.matrix.get(this.rows-h-1,d)}}class Xe extends fe{constructor(h,d){l(h,d),super(h,1,h.columns),this.row=d}set(h,d,u){return this.matrix.set(this.row,d,u),this}get(h,d){return this.matrix.get(this.row,d)}}class $e extends fe{constructor(h,d){x(h,d),super(h,d.length,h.columns),this.rowIndices=d}set(h,d,u){return this.matrix.set(this.rowIndices[h],d,u),this}get(h,d){return this.matrix.get(this.rowIndices[h],d)}}class Ee extends fe{constructor(h,d,u){x(h,d),_(h,u),super(h,d.length,u.length),this.rowIndices=d,this.columnIndices=u}set(h,d,u){return this.matrix.set(this.rowIndices[h],this.columnIndices[d],u),this}get(h,d){return this.matrix.get(this.rowIndices[h],this.columnIndices[d])}}class bt extends fe{constructor(h,d,u,g,m){b(h,d,u,g,m),super(h,u-d+1,m-g+1),this.startRow=d,this.startColumn=g}set(h,d,u){return this.matrix.set(this.startRow+h,this.startColumn+d,u),this}get(h,d){return this.matrix.get(this.startRow+h,this.startColumn+d)}}class Me extends fe{constructor(h){super(h,h.columns,h.rows)}set(h,d,u){return this.matrix.set(d,h,u),this}get(h,d){return this.matrix.get(d,h)}}class _t extends ie{constructor(h,d={}){const{rows:u=1}=d;if(h.length%u!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=u,this.columns=h.length/u,this.data=h}set(h,d,u){let g=this._calculateIndex(h,d);return this.data[g]=u,this}get(h,d){let u=this._calculateIndex(h,d);return this.data[u]}_calculateIndex(h,d){return h*this.columns+d}}class Le extends ie{constructor(h){super(),this.data=h,this.rows=h.length,this.columns=h[0].length}set(h,d,u){return this.data[h][d]=u,this}get(h,d){return this.data[h][d]}}function pc(M,h){if(e.isAnyArray(M))return M[0]&&e.isAnyArray(M[0])?new Le(M):new _t(M,h);throw new Error("the argument is not an array")}class Et{constructor(h){h=Le.checkMatrix(h);let d=h.clone(),u=d.rows,g=d.columns,m=new Float64Array(u),R=1,O,T,k,B,C,W,ne,U,K;for(O=0;O<u;O++)m[O]=O;for(U=new Float64Array(u),T=0;T<g;T++){for(O=0;O<u;O++)U[O]=d.get(O,T);for(O=0;O<u;O++){for(K=Math.min(O,T),C=0,k=0;k<K;k++)C+=d.get(O,k)*U[k];U[O]-=C,d.set(O,T,U[O])}for(B=T,O=T+1;O<u;O++)Math.abs(U[O])>Math.abs(U[B])&&(B=O);if(B!==T){for(k=0;k<g;k++)W=d.get(B,k),d.set(B,k,d.get(T,k)),d.set(T,k,W);ne=m[B],m[B]=m[T],m[T]=ne,R=-R}if(T<u&&d.get(T,T)!==0)for(O=T+1;O<u;O++)d.set(O,T,d.get(O,T)/d.get(T,T))}this.LU=d,this.pivotVector=m,this.pivotSign=R}isSingular(){let h=this.LU,d=h.columns;for(let u=0;u<d;u++)if(h.get(u,u)===0)return!0;return!1}solve(h){h=P.checkMatrix(h);let d=this.LU;if(d.rows!==h.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let g=h.columns,m=h.subMatrixRow(this.pivotVector,0,g-1),R=d.columns,O,T,k;for(k=0;k<R;k++)for(O=k+1;O<R;O++)for(T=0;T<g;T++)m.set(O,T,m.get(O,T)-m.get(k,T)*d.get(O,k));for(k=R-1;k>=0;k--){for(T=0;T<g;T++)m.set(k,T,m.get(k,T)/d.get(k,k));for(O=0;O<k;O++)for(T=0;T<g;T++)m.set(O,T,m.get(O,T)-m.get(k,T)*d.get(O,k))}return m}get determinant(){let h=this.LU;if(!h.isSquare())throw new Error("Matrix must be square");let d=this.pivotSign,u=h.columns;for(let g=0;g<u;g++)d*=h.get(g,g);return d}get lowerTriangularMatrix(){let h=this.LU,d=h.rows,u=h.columns,g=new P(d,u);for(let m=0;m<d;m++)for(let R=0;R<u;R++)m>R?g.set(m,R,h.get(m,R)):m===R?g.set(m,R,1):g.set(m,R,0);return g}get upperTriangularMatrix(){let h=this.LU,d=h.rows,u=h.columns,g=new P(d,u);for(let m=0;m<d;m++)for(let R=0;R<u;R++)m<=R?g.set(m,R,h.get(m,R)):g.set(m,R,0);return g}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function Ge(M,h){let d=0;return Math.abs(M)>Math.abs(h)?(d=h/M,Math.abs(M)*Math.sqrt(1+d*d)):h!==0?(d=M/h,Math.abs(h)*Math.sqrt(1+d*d)):0}class Ue{constructor(h){h=Le.checkMatrix(h);let d=h.clone(),u=h.rows,g=h.columns,m=new Float64Array(g),R,O,T,k;for(T=0;T<g;T++){let B=0;for(R=T;R<u;R++)B=Ge(B,d.get(R,T));if(B!==0){for(d.get(T,T)<0&&(B=-B),R=T;R<u;R++)d.set(R,T,d.get(R,T)/B);for(d.set(T,T,d.get(T,T)+1),O=T+1;O<g;O++){for(k=0,R=T;R<u;R++)k+=d.get(R,T)*d.get(R,O);for(k=-k/d.get(T,T),R=T;R<u;R++)d.set(R,O,d.get(R,O)+k*d.get(R,T))}}m[T]=-B}this.QR=d,this.Rdiag=m}solve(h){h=P.checkMatrix(h);let d=this.QR,u=d.rows;if(h.rows!==u)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let g=h.columns,m=h.clone(),R=d.columns,O,T,k,B;for(k=0;k<R;k++)for(T=0;T<g;T++){for(B=0,O=k;O<u;O++)B+=d.get(O,k)*m.get(O,T);for(B=-B/d.get(k,k),O=k;O<u;O++)m.set(O,T,m.get(O,T)+B*d.get(O,k))}for(k=R-1;k>=0;k--){for(T=0;T<g;T++)m.set(k,T,m.get(k,T)/this.Rdiag[k]);for(O=0;O<k;O++)for(T=0;T<g;T++)m.set(O,T,m.get(O,T)-m.get(k,T)*d.get(O,k))}return m.subMatrix(0,R-1,0,g-1)}isFullRank(){let h=this.QR.columns;for(let d=0;d<h;d++)if(this.Rdiag[d]===0)return!1;return!0}get upperTriangularMatrix(){let h=this.QR,d=h.columns,u=new P(d,d),g,m;for(g=0;g<d;g++)for(m=0;m<d;m++)g<m?u.set(g,m,h.get(g,m)):g===m?u.set(g,m,this.Rdiag[g]):u.set(g,m,0);return u}get orthogonalMatrix(){let h=this.QR,d=h.rows,u=h.columns,g=new P(d,u),m,R,O,T;for(O=u-1;O>=0;O--){for(m=0;m<d;m++)g.set(m,O,0);for(g.set(O,O,1),R=O;R<u;R++)if(h.get(O,O)!==0){for(T=0,m=O;m<d;m++)T+=h.get(m,O)*g.get(m,R);for(T=-T/h.get(O,O),m=O;m<d;m++)g.set(m,R,g.get(m,R)+T*h.get(m,O))}}return g}}class ut{constructor(h,d={}){if(h=Le.checkMatrix(h),h.isEmpty())throw new Error("Matrix must be non-empty");let u=h.rows,g=h.columns;const{computeLeftSingularVectors:m=!0,computeRightSingularVectors:R=!0,autoTranspose:O=!1}=d;let T=!!m,k=!!R,B=!1,C;if(u<g)if(!O)C=h.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else{C=h.transpose(),u=C.rows,g=C.columns,B=!0;let F=T;T=k,k=F}else C=h.clone();let W=Math.min(u,g),ne=Math.min(u+1,g),U=new Float64Array(ne),K=new P(u,W),se=new P(g,g),L=new Float64Array(g),re=new Float64Array(u),ce=new Float64Array(ne);for(let F=0;F<ne;F++)ce[F]=F;let pe=Math.min(u-1,g),me=Math.max(0,Math.min(g-2,u)),Ie=Math.max(pe,me);for(let F=0;F<Ie;F++){if(F<pe){U[F]=0;for(let Q=F;Q<u;Q++)U[F]=Ge(U[F],C.get(Q,F));if(U[F]!==0){C.get(F,F)<0&&(U[F]=-U[F]);for(let Q=F;Q<u;Q++)C.set(Q,F,C.get(Q,F)/U[F]);C.set(F,F,C.get(F,F)+1)}U[F]=-U[F]}for(let Q=F+1;Q<g;Q++){if(F<pe&&U[F]!==0){let oe=0;for(let H=F;H<u;H++)oe+=C.get(H,F)*C.get(H,Q);oe=-oe/C.get(F,F);for(let H=F;H<u;H++)C.set(H,Q,C.get(H,Q)+oe*C.get(H,F))}L[Q]=C.get(F,Q)}if(T&&F<pe)for(let Q=F;Q<u;Q++)K.set(Q,F,C.get(Q,F));if(F<me){L[F]=0;for(let Q=F+1;Q<g;Q++)L[F]=Ge(L[F],L[Q]);if(L[F]!==0){L[F+1]<0&&(L[F]=0-L[F]);for(let Q=F+1;Q<g;Q++)L[Q]/=L[F];L[F+1]+=1}if(L[F]=-L[F],F+1<u&&L[F]!==0){for(let Q=F+1;Q<u;Q++)re[Q]=0;for(let Q=F+1;Q<u;Q++)for(let oe=F+1;oe<g;oe++)re[Q]+=L[oe]*C.get(Q,oe);for(let Q=F+1;Q<g;Q++){let oe=-L[Q]/L[F+1];for(let H=F+1;H<u;H++)C.set(H,Q,C.get(H,Q)+oe*re[H])}}if(k)for(let Q=F+1;Q<g;Q++)se.set(Q,F,L[Q])}}let he=Math.min(g,u+1);if(pe<g&&(U[pe]=C.get(pe,pe)),u<he&&(U[he-1]=0),me+1<he&&(L[me]=C.get(me,he-1)),L[he-1]=0,T){for(let F=pe;F<W;F++){for(let Q=0;Q<u;Q++)K.set(Q,F,0);K.set(F,F,1)}for(let F=pe-1;F>=0;F--)if(U[F]!==0){for(let Q=F+1;Q<W;Q++){let oe=0;for(let H=F;H<u;H++)oe+=K.get(H,F)*K.get(H,Q);oe=-oe/K.get(F,F);for(let H=F;H<u;H++)K.set(H,Q,K.get(H,Q)+oe*K.get(H,F))}for(let Q=F;Q<u;Q++)K.set(Q,F,-K.get(Q,F));K.set(F,F,1+K.get(F,F));for(let Q=0;Q<F-1;Q++)K.set(Q,F,0)}else{for(let Q=0;Q<u;Q++)K.set(Q,F,0);K.set(F,F,1)}}if(k)for(let F=g-1;F>=0;F--){if(F<me&&L[F]!==0)for(let Q=F+1;Q<g;Q++){let oe=0;for(let H=F+1;H<g;H++)oe+=se.get(H,F)*se.get(H,Q);oe=-oe/se.get(F+1,F);for(let H=F+1;H<g;H++)se.set(H,Q,se.get(H,Q)+oe*se.get(H,F))}for(let Q=0;Q<g;Q++)se.set(Q,F,0);se.set(F,F,1)}let de=he-1,Re=Number.EPSILON;for(;he>0;){let F,Q;for(F=he-2;F>=-1&&F!==-1;F--){const oe=Number.MIN_VALUE+Re*Math.abs(U[F]+Math.abs(U[F+1]));if(Math.abs(L[F])<=oe||Number.isNaN(L[F])){L[F]=0;break}}if(F===he-2)Q=4;else{let oe;for(oe=he-1;oe>=F&&oe!==F;oe--){let H=(oe!==he?Math.abs(L[oe]):0)+(oe!==F+1?Math.abs(L[oe-1]):0);if(Math.abs(U[oe])<=Re*H){U[oe]=0;break}}oe===F?Q=3:oe===he-1?Q=1:(Q=2,F=oe)}switch(F++,Q){case 1:{let oe=L[he-2];L[he-2]=0;for(let H=he-2;H>=F;H--){let Te=Ge(U[H],oe),Se=U[H]/Te,Oe=oe/Te;if(U[H]=Te,H!==F&&(oe=-Oe*L[H-1],L[H-1]=Se*L[H-1]),k)for(let ke=0;ke<g;ke++)Te=Se*se.get(ke,H)+Oe*se.get(ke,he-1),se.set(ke,he-1,-Oe*se.get(ke,H)+Se*se.get(ke,he-1)),se.set(ke,H,Te)}break}case 2:{let oe=L[F-1];L[F-1]=0;for(let H=F;H<he;H++){let Te=Ge(U[H],oe),Se=U[H]/Te,Oe=oe/Te;if(U[H]=Te,oe=-Oe*L[H],L[H]=Se*L[H],T)for(let ke=0;ke<u;ke++)Te=Se*K.get(ke,H)+Oe*K.get(ke,F-1),K.set(ke,F-1,-Oe*K.get(ke,H)+Se*K.get(ke,F-1)),K.set(ke,H,Te)}break}case 3:{const oe=Math.max(Math.abs(U[he-1]),Math.abs(U[he-2]),Math.abs(L[he-2]),Math.abs(U[F]),Math.abs(L[F])),H=U[he-1]/oe,Te=U[he-2]/oe,Se=L[he-2]/oe,Oe=U[F]/oe,ke=L[F]/oe,We=((Te+H)*(Te-H)+Se*Se)/2,ct=H*Se*(H*Se);let Fe=0;(We!==0||ct!==0)&&(We<0?Fe=0-Math.sqrt(We*We+ct):Fe=Math.sqrt(We*We+ct),Fe=ct/(We+Fe));let dt=(Oe+H)*(Oe-H)+Fe,xt=Oe*ke;for(let Ne=F;Ne<he-1;Ne++){let Ye=Ge(dt,xt);Ye===0&&(Ye=Number.MIN_VALUE);let tt=dt/Ye,rt=xt/Ye;if(Ne!==F&&(L[Ne-1]=Ye),dt=tt*U[Ne]+rt*L[Ne],L[Ne]=tt*L[Ne]-rt*U[Ne],xt=rt*U[Ne+1],U[Ne+1]=tt*U[Ne+1],k)for(let Be=0;Be<g;Be++)Ye=tt*se.get(Be,Ne)+rt*se.get(Be,Ne+1),se.set(Be,Ne+1,-rt*se.get(Be,Ne)+tt*se.get(Be,Ne+1)),se.set(Be,Ne,Ye);if(Ye=Ge(dt,xt),Ye===0&&(Ye=Number.MIN_VALUE),tt=dt/Ye,rt=xt/Ye,U[Ne]=Ye,dt=tt*L[Ne]+rt*U[Ne+1],U[Ne+1]=-rt*L[Ne]+tt*U[Ne+1],xt=rt*L[Ne+1],L[Ne+1]=tt*L[Ne+1],T&&Ne<u-1)for(let Be=0;Be<u;Be++)Ye=tt*K.get(Be,Ne)+rt*K.get(Be,Ne+1),K.set(Be,Ne+1,-rt*K.get(Be,Ne)+tt*K.get(Be,Ne+1)),K.set(Be,Ne,Ye)}L[he-2]=dt;break}case 4:{if(U[F]<=0&&(U[F]=U[F]<0?-U[F]:0,k))for(let oe=0;oe<=de;oe++)se.set(oe,F,-se.get(oe,F));for(;F<de&&!(U[F]>=U[F+1]);){let oe=U[F];if(U[F]=U[F+1],U[F+1]=oe,k&&F<g-1)for(let H=0;H<g;H++)oe=se.get(H,F+1),se.set(H,F+1,se.get(H,F)),se.set(H,F,oe);if(T&&F<u-1)for(let H=0;H<u;H++)oe=K.get(H,F+1),K.set(H,F+1,K.get(H,F)),K.set(H,F,oe);F++}he--;break}}}if(B){let F=se;se=K,K=F}this.m=u,this.n=g,this.s=U,this.U=K,this.V=se}solve(h){let d=h,u=this.threshold,g=this.s.length,m=P.zeros(g,g);for(let W=0;W<g;W++)Math.abs(this.s[W])<=u?m.set(W,W,0):m.set(W,W,1/this.s[W]);let R=this.U,O=this.rightSingularVectors,T=O.mmul(m),k=O.rows,B=R.rows,C=P.zeros(k,B);for(let W=0;W<k;W++)for(let ne=0;ne<B;ne++){let U=0;for(let K=0;K<g;K++)U+=T.get(W,K)*R.get(ne,K);C.set(W,ne,U)}return C.mmul(d)}solveForDiagonal(h){return this.solve(P.diag(h))}inverse(){let h=this.V,d=this.threshold,u=h.rows,g=h.columns,m=new P(u,this.s.length);for(let B=0;B<u;B++)for(let C=0;C<g;C++)Math.abs(this.s[C])>d&&m.set(B,C,h.get(B,C)/this.s[C]);let R=this.U,O=R.rows,T=R.columns,k=new P(u,O);for(let B=0;B<u;B++)for(let C=0;C<O;C++){let W=0;for(let ne=0;ne<T;ne++)W+=m.get(B,ne)*R.get(C,ne);k.set(B,C,W)}return k}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let h=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,d=0,u=this.s;for(let g=0,m=u.length;g<m;g++)u[g]>h&&d++;return d}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 P.diag(this.s)}}function Jt(M,h=!1){return M=Le.checkMatrix(M),h?new ut(M).inverse():Xr(M,P.eye(M.rows))}function Xr(M,h,d=!1){return M=Le.checkMatrix(M),h=Le.checkMatrix(h),d?new ut(M).solve(h):M.isSquare()?new Et(M).solve(h):new Ue(M).solve(h)}function Lt(M){if(M=P.checkMatrix(M),M.isSquare()){if(M.columns===0)return 1;let h,d,u,g;if(M.columns===2)return h=M.get(0,0),d=M.get(0,1),u=M.get(1,0),g=M.get(1,1),h*g-d*u;if(M.columns===3){let m,R,O;return m=new Ee(M,[1,2],[1,2]),R=new Ee(M,[1,2],[0,2]),O=new Ee(M,[1,2],[0,1]),h=M.get(0,0),d=M.get(0,1),u=M.get(0,2),h*Lt(m)-d*Lt(R)+u*Lt(O)}else return new Et(M).determinant}else throw Error("determinant can only be calculated for a square matrix")}function Rt(M,h){let d=[];for(let u=0;u<M;u++)u!==h&&d.push(u);return d}function Zr(M,h,d,u=1e-9,g=1e-9){if(M>g)return new Array(h.rows+1).fill(0);{let m=h.addRow(d,[0]);for(let R=0;R<m.rows;R++)Math.abs(m.get(R,0))<u&&m.set(R,0,0);return m.to1DArray()}}function Jr(M,h={}){const{thresholdValue:d=1e-9,thresholdError:u=1e-9}=h;M=P.checkMatrix(M);let g=M.rows,m=new P(g,g);for(let R=0;R<g;R++){let O=P.columnVector(M.getRow(R)),T=M.subMatrixRow(Rt(g,R)).transpose(),B=new ut(T).solve(O),C=P.sub(O,T.mmul(B)).abs().max();m.setRow(R,Zr(C,B,R,d,u))}return m}function vc(M,h=Number.EPSILON){if(M=P.checkMatrix(M),M.isEmpty())return M.transpose();let d=new ut(M,{autoTranspose:!0}),u=d.leftSingularVectors,g=d.rightSingularVectors,m=d.diagonal;for(let R=0;R<m.length;R++)Math.abs(m[R])>h?m[R]=1/m[R]:m[R]=0;return g.mmul(P.diag(m).mmul(u.transpose()))}function Qr(M,h=M,d={}){M=new P(M);let u=!1;if(typeof h=="object"&&!P.isMatrix(h)&&!e.isAnyArray(h)?(d=h,h=M,u=!0):h=new P(h),M.rows!==h.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:g=!0}=d;g&&(M=M.center("column"),u||(h=h.center("column")));const m=M.transpose().mmul(h);for(let R=0;R<m.rows;R++)for(let O=0;O<m.columns;O++)m.set(R,O,m.get(R,O)*(1/(M.rows-1)));return m}function lt(M,h=M,d={}){M=new P(M);let u=!1;if(typeof h=="object"&&!P.isMatrix(h)&&!e.isAnyArray(h)?(d=h,h=M,u=!0):h=new P(h),M.rows!==h.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:g=!0,scale:m=!0}=d;g&&(M.center("column"),u||h.center("column")),m&&(M.scale("column"),u||h.scale("column"));const R=M.standardDeviation("column",{unbiased:!0}),O=u?R:h.standardDeviation("column",{unbiased:!0}),T=M.transpose().mmul(h);for(let k=0;k<T.rows;k++)for(let B=0;B<T.columns;B++)T.set(k,B,T.get(k,B)*(1/(R[k]*O[B]))*(1/(M.rows-1)));return T}class ht{constructor(h,d={}){const{assumeSymmetric:u=!1}=d;if(h=Le.checkMatrix(h),!h.isSquare())throw new Error("Matrix is not a square matrix");if(h.isEmpty())throw new Error("Matrix must be non-empty");let g=h.columns,m=new P(g,g),R=new Float64Array(g),O=new Float64Array(g),T=h,k,B,C=!1;if(u?C=!0:C=h.isSymmetric(),C){for(k=0;k<g;k++)for(B=0;B<g;B++)m.set(k,B,T.get(k,B));Rx(g,O,R,m),Ox(g,O,R,m)}else{let W=new P(g,g),ne=new Float64Array(g);for(B=0;B<g;B++)for(k=0;k<g;k++)W.set(k,B,T.get(k,B));Ax(g,W,ne,m),Ix(g,O,R,m,W)}this.n=g,this.e=O,this.d=R,this.V=m}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let h=this.n,d=this.e,u=this.d,g=new P(h,h),m,R;for(m=0;m<h;m++){for(R=0;R<h;R++)g.set(m,R,0);g.set(m,m,u[m]),d[m]>0?g.set(m,m+1,d[m]):d[m]<0&&g.set(m,m-1,d[m])}return g}}function Rx(M,h,d,u){let g,m,R,O,T,k,B,C;for(T=0;T<M;T++)d[T]=u.get(M-1,T);for(O=M-1;O>0;O--){for(C=0,R=0,k=0;k<O;k++)C=C+Math.abs(d[k]);if(C===0)for(h[O]=d[O-1],T=0;T<O;T++)d[T]=u.get(O-1,T),u.set(O,T,0),u.set(T,O,0);else{for(k=0;k<O;k++)d[k]/=C,R+=d[k]*d[k];for(g=d[O-1],m=Math.sqrt(R),g>0&&(m=-m),h[O]=C*m,R=R-g*m,d[O-1]=g-m,T=0;T<O;T++)h[T]=0;for(T=0;T<O;T++){for(g=d[T],u.set(T,O,g),m=h[T]+u.get(T,T)*g,k=T+1;k<=O-1;k++)m+=u.get(k,T)*d[k],h[k]+=u.get(k,T)*g;h[T]=m}for(g=0,T=0;T<O;T++)h[T]/=R,g+=h[T]*d[T];for(B=g/(R+R),T=0;T<O;T++)h[T]-=B*d[T];for(T=0;T<O;T++){for(g=d[T],m=h[T],k=T;k<=O-1;k++)u.set(k,T,u.get(k,T)-(g*h[k]+m*d[k]));d[T]=u.get(O-1,T),u.set(O,T,0)}}d[O]=R}for(O=0;O<M-1;O++){if(u.set(M-1,O,u.get(O,O)),u.set(O,O,1),R=d[O+1],R!==0){for(k=0;k<=O;k++)d[k]=u.get(k,O+1)/R;for(T=0;T<=O;T++){for(m=0,k=0;k<=O;k++)m+=u.get(k,O+1)*u.get(k,T);for(k=0;k<=O;k++)u.set(k,T,u.get(k,T)-m*d[k])}}for(k=0;k<=O;k++)u.set(k,O+1,0)}for(T=0;T<M;T++)d[T]=u.get(M-1,T),u.set(M-1,T,0);u.set(M-1,M-1,1),h[0]=0}function Ox(M,h,d,u){let g,m,R,O,T,k,B,C,W,ne,U,K,se,L,re,ce;for(R=1;R<M;R++)h[R-1]=h[R];h[M-1]=0;let pe=0,me=0,Ie=Number.EPSILON;for(k=0;k<M;k++){for(me=Math.max(me,Math.abs(d[k])+Math.abs(h[k])),B=k;B<M&&!(Math.abs(h[B])<=Ie*me);)B++;if(B>k)do{for(g=d[k],C=(d[k+1]-g)/(2*h[k]),W=Ge(C,1),C<0&&(W=-W),d[k]=h[k]/(C+W),d[k+1]=h[k]*(C+W),ne=d[k+1],m=g-d[k],R=k+2;R<M;R++)d[R]-=m;for(pe=pe+m,C=d[B],U=1,K=U,se=U,L=h[k+1],re=0,ce=0,R=B-1;R>=k;R--)for(se=K,K=U,ce=re,g=U*h[R],m=U*C,W=Ge(C,h[R]),h[R+1]=re*W,re=h[R]/W,U=C/W,C=U*d[R]-re*g,d[R+1]=m+re*(U*g+re*d[R]),T=0;T<M;T++)m=u.get(T,R+1),u.set(T,R+1,re*u.get(T,R)+U*m),u.set(T,R,U*u.get(T,R)-re*m);C=-re*ce*se*L*h[k]/ne,h[k]=re*C,d[k]=U*C}while(Math.abs(h[k])>Ie*me);d[k]=d[k]+pe,h[k]=0}for(R=0;R<M-1;R++){for(T=R,C=d[R],O=R+1;O<M;O++)d[O]<C&&(T=O,C=d[O]);if(T!==R)for(d[T]=d[R],d[R]=C,O=0;O<M;O++)C=u.get(O,R),u.set(O,R,u.get(O,T)),u.set(O,T,C)}}function Ax(M,h,d,u){let g=0,m=M-1,R,O,T,k,B,C,W;for(C=g+1;C<=m-1;C++){for(W=0,k=C;k<=m;k++)W=W+Math.abs(h.get(k,C-1));if(W!==0){for(T=0,k=m;k>=C;k--)d[k]=h.get(k,C-1)/W,T+=d[k]*d[k];for(O=Math.sqrt(T),d[C]>0&&(O=-O),T=T-d[C]*O,d[C]=d[C]-O,B=C;B<M;B++){for(R=0,k=m;k>=C;k--)R+=d[k]*h.get(k,B);for(R=R/T,k=C;k<=m;k++)h.set(k,B,h.get(k,B)-R*d[k])}for(k=0;k<=m;k++){for(R=0,B=m;B>=C;B--)R+=d[B]*h.get(k,B);for(R=R/T,B=C;B<=m;B++)h.set(k,B,h.get(k,B)-R*d[B])}d[C]=W*d[C],h.set(C,C-1,W*O)}}for(k=0;k<M;k++)for(B=0;B<M;B++)u.set(k,B,k===B?1:0);for(C=m-1;C>=g+1;C--)if(h.get(C,C-1)!==0){for(k=C+1;k<=m;k++)d[k]=h.get(k,C-1);for(B=C;B<=m;B++){for(O=0,k=C;k<=m;k++)O+=d[k]*u.get(k,B);for(O=O/d[C]/h.get(C,C-1),k=C;k<=m;k++)u.set(k,B,u.get(k,B)+O*d[k])}}}function Ix(M,h,d,u,g){let m=M-1,R=0,O=M-1,T=Number.EPSILON,k=0,B=0,C=0,W=0,ne=0,U=0,K=0,se=0,L,re,ce,pe,me,Ie,he,de,Re,F,Q,oe,H,Te,Se;for(L=0;L<M;L++)for((L<R||L>O)&&(d[L]=g.get(L,L),h[L]=0),re=Math.max(L-1,0);re<M;re++)B=B+Math.abs(g.get(L,re));for(;m>=R;){for(pe=m;pe>R&&(U=Math.abs(g.get(pe-1,pe-1))+Math.abs(g.get(pe,pe)),U===0&&(U=B),!(Math.abs(g.get(pe,pe-1))<T*U));)pe--;if(pe===m)g.set(m,m,g.get(m,m)+k),d[m]=g.get(m,m),h[m]=0,m--,se=0;else if(pe===m-1){if(he=g.get(m,m-1)*g.get(m-1,m),C=(g.get(m-1,m-1)-g.get(m,m))/2,W=C*C+he,K=Math.sqrt(Math.abs(W)),g.set(m,m,g.get(m,m)+k),g.set(m-1,m-1,g.get(m-1,m-1)+k),de=g.get(m,m),W>=0){for(K=C>=0?C+K:C-K,d[m-1]=de+K,d[m]=d[m-1],K!==0&&(d[m]=de-he/K),h[m-1]=0,h[m]=0,de=g.get(m,m-1),U=Math.abs(de)+Math.abs(K),C=de/U,W=K/U,ne=Math.sqrt(C*C+W*W),C=C/ne,W=W/ne,re=m-1;re<M;re++)K=g.get(m-1,re),g.set(m-1,re,W*K+C*g.get(m,re)),g.set(m,re,W*g.get(m,re)-C*K);for(L=0;L<=m;L++)K=g.get(L,m-1),g.set(L,m-1,W*K+C*g.get(L,m)),g.set(L,m,W*g.get(L,m)-C*K);for(L=R;L<=O;L++)K=u.get(L,m-1),u.set(L,m-1,W*K+C*u.get(L,m)),u.set(L,m,W*u.get(L,m)-C*K)}else d[m-1]=de+C,d[m]=de+C,h[m-1]=K,h[m]=-K;m=m-2,se=0}else{if(de=g.get(m,m),Re=0,he=0,pe<m&&(Re=g.get(m-1,m-1),he=g.get(m,m-1)*g.get(m-1,m)),se===10){for(k+=de,L=R;L<=m;L++)g.set(L,L,g.get(L,L)-de);U=Math.abs(g.get(m,m-1))+Math.abs(g.get(m-1,m-2)),de=Re=.75*U,he=-.4375*U*U}if(se===30&&(U=(Re-de)/2,U=U*U+he,U>0)){for(U=Math.sqrt(U),Re<de&&(U=-U),U=de-he/((Re-de)/2+U),L=R;L<=m;L++)g.set(L,L,g.get(L,L)-U);k+=U,de=Re=he=.964}for(se=se+1,me=m-2;me>=pe&&(K=g.get(me,me),ne=de-K,U=Re-K,C=(ne*U-he)/g.get(me+1,me)+g.get(me,me+1),W=g.get(me+1,me+1)-K-ne-U,ne=g.get(me+2,me+1),U=Math.abs(C)+Math.abs(W)+Math.abs(ne),C=C/U,W=W/U,ne=ne/U,!(me===pe||Math.abs(g.get(me,me-1))*(Math.abs(W)+Math.abs(ne))<T*(Math.abs(C)*(Math.abs(g.get(me-1,me-1))+Math.abs(K)+Math.abs(g.get(me+1,me+1))))));)me--;for(L=me+2;L<=m;L++)g.set(L,L-2,0),L>me+2&&g.set(L,L-3,0);for(ce=me;ce<=m-1&&(Te=ce!==m-1,ce!==me&&(C=g.get(ce,ce-1),W=g.get(ce+1,ce-1),ne=Te?g.get(ce+2,ce-1):0,de=Math.abs(C)+Math.abs(W)+Math.abs(ne),de!==0&&(C=C/de,W=W/de,ne=ne/de)),de!==0);ce++)if(U=Math.sqrt(C*C+W*W+ne*ne),C<0&&(U=-U),U!==0){for(ce!==me?g.set(ce,ce-1,-U*de):pe!==me&&g.set(ce,ce-1,-g.get(ce,ce-1)),C=C+U,de=C/U,Re=W/U,K=ne/U,W=W/C,ne=ne/C,re=ce;re<M;re++)C=g.get(ce,re)+W*g.get(ce+1,re),Te&&(C=C+ne*g.get(ce+2,re),g.set(ce+2,re,g.get(ce+2,re)-C*K)),g.set(ce,re,g.get(ce,re)-C*de),g.set(ce+1,re,g.get(ce+1,re)-C*Re);for(L=0;L<=Math.min(m,ce+3);L++)C=de*g.get(L,ce)+Re*g.get(L,ce+1),Te&&(C=C+K*g.get(L,ce+2),g.set(L,ce+2,g.get(L,ce+2)-C*ne)),g.set(L,ce,g.get(L,ce)-C),g.set(L,ce+1,g.get(L,ce+1)-C*W);for(L=R;L<=O;L++)C=de*u.get(L,ce)+Re*u.get(L,ce+1),Te&&(C=C+K*u.get(L,ce+2),u.set(L,ce+2,u.get(L,ce+2)-C*ne)),u.set(L,ce,u.get(L,ce)-C),u.set(L,ce+1,u.get(L,ce+1)-C*W)}}}if(B!==0){for(m=M-1;m>=0;m--)if(C=d[m],W=h[m],W===0)for(pe=m,g.set(m,m,1),L=m-1;L>=0;L--){for(he=g.get(L,L)-C,ne=0,re=pe;re<=m;re++)ne=ne+g.get(L,re)*g.get(re,m);if(h[L]<0)K=he,U=ne;else if(pe=L,h[L]===0?g.set(L,m,he!==0?-ne/he:-ne/(T*B)):(de=g.get(L,L+1),Re=g.get(L+1,L),W=(d[L]-C)*(d[L]-C)+h[L]*h[L],Ie=(de*U-K*ne)/W,g.set(L,m,Ie),g.set(L+1,m,Math.abs(de)>Math.abs(K)?(-ne-he*Ie)/de:(-U-Re*Ie)/K)),Ie=Math.abs(g.get(L,m)),T*Ie*Ie>1)for(re=L;re<=m;re++)g.set(re,m,g.get(re,m)/Ie)}else if(W<0)for(pe=m-1,Math.abs(g.get(m,m-1))>Math.abs(g.get(m-1,m))?(g.set(m-1,m-1,W/g.get(m,m-1)),g.set(m-1,m,-(g.get(m,m)-C)/g.get(m,m-1))):(Se=Hr(0,-g.get(m-1,m),g.get(m-1,m-1)-C,W),g.set(m-1,m-1,Se[0]),g.set(m-1,m,Se[1])),g.set(m,m-1,0),g.set(m,m,1),L=m-2;L>=0;L--){for(F=0,Q=0,re=pe;re<=m;re++)F=F+g.get(L,re)*g.get(re,m-1),Q=Q+g.get(L,re)*g.get(re,m);if(he=g.get(L,L)-C,h[L]<0)K=he,ne=F,U=Q;else if(pe=L,h[L]===0?(Se=Hr(-F,-Q,he,W),g.set(L,m-1,Se[0]),g.set(L,m,Se[1])):(de=g.get(L,L+1),Re=g.get(L+1,L),oe=(d[L]-C)*(d[L]-C)+h[L]*h[L]-W*W,H=(d[L]-C)*2*W,oe===0&&H===0&&(oe=T*B*(Math.abs(he)+Math.abs(W)+Math.abs(de)+Math.abs(Re)+Math.abs(K))),Se=Hr(de*ne-K*F+W*Q,de*U-K*Q-W*F,oe,H),g.set(L,m-1,Se[0]),g.set(L,m,Se[1]),Math.abs(de)>Math.abs(K)+Math.abs(W)?(g.set(L+1,m-1,(-F-he*g.get(L,m-1)+W*g.get(L,m))/de),g.set(L+1,m,(-Q-he*g.get(L,m)-W*g.get(L,m-1))/de)):(Se=Hr(-ne-Re*g.get(L,m-1),-U-Re*g.get(L,m),K,W),g.set(L+1,m-1,Se[0]),g.set(L+1,m,Se[1]))),Ie=Math.max(Math.abs(g.get(L,m-1)),Math.abs(g.get(L,m))),T*Ie*Ie>1)for(re=L;re<=m;re++)g.set(re,m-1,g.get(re,m-1)/Ie),g.set(re,m,g.get(re,m)/Ie)}for(L=0;L<M;L++)if(L<R||L>O)for(re=L;re<M;re++)u.set(L,re,g.get(L,re));for(re=M-1;re>=R;re--)for(L=R;L<=O;L++){for(K=0,ce=R;ce<=Math.min(re,O);ce++)K=K+u.get(L,ce)*g.get(ce,re);u.set(L,re,K)}}}function Hr(M,h,d,u){let g,m;return Math.abs(d)>Math.abs(u)?(g=u/d,m=d+g*u,[(M+g*h)/m,(h-g*M)/m]):(g=d/u,m=u+g*d,[(g*M+h)/m,(g*h-M)/m])}class a0{constructor(h){if(h=Le.checkMatrix(h),!h.isSymmetric())throw new Error("Matrix is not symmetric");let d=h,u=d.rows,g=new P(u,u),m=!0,R,O,T;for(O=0;O<u;O++){let k=0;for(T=0;T<O;T++){let B=0;for(R=0;R<T;R++)B+=g.get(T,R)*g.get(O,R);B=(d.get(O,T)-B)/g.get(T,T),g.set(O,T,B),k=k+B*B}for(k=d.get(O,O)-k,m&&=k>0,g.set(O,O,Math.sqrt(Math.max(k,0))),T=O+1;T<u;T++)g.set(O,T,0)}this.L=g,this.positiveDefinite=m}isPositiveDefinite(){return this.positiveDefinite}solve(h){h=Le.checkMatrix(h);let d=this.L,u=d.rows;if(h.rows!==u)throw new Error("Matrix dimensions do not match");if(this.isPositiveDefinite()===!1)throw new Error("Matrix is not positive definite");let g=h.columns,m=h.clone(),R,O,T;for(T=0;T<u;T++)for(O=0;O<g;O++){for(R=0;R<T;R++)m.set(T,O,m.get(T,O)-m.get(R,O)*d.get(T,R));m.set(T,O,m.get(T,O)/d.get(T,T))}for(T=u-1;T>=0;T--)for(O=0;O<g;O++){for(R=T+1;R<u;R++)m.set(T,O,m.get(T,O)-m.get(R,O)*d.get(R,T));m.set(T,O,m.get(T,O)/d.get(T,T))}return m}get lowerTriangularMatrix(){return this.L}}class u0{constructor(h,d={}){h=Le.checkMatrix(h);let{Y:u}=d;const{scaleScores:g=!1,maxIterations:m=1e3,terminationCriteria:R=1e-10}=d;let O;if(u){if(e.isAnyArray(u)&&typeof u[0]=="number"?u=P.columnVector(u):u=Le.checkMatrix(u),u.rows!==h.rows)throw new Error("Y should have the same number of rows as X");O=u.getColumnVector(0)}else O=h.getColumnVector(0);let T=1,k,B,C,W;for(let ne=0;ne<m&&T>R;ne++)C=h.transpose().mmul(O).div(O.transpose().mmul(O).get(0,0)),C=C.div(C.norm()),k=h.mmul(C).div(C.transpose().mmul(C).get(0,0)),ne>0&&(T=k.clone().sub(W).pow(2).sum()),W=k.clone(),u?(B=u.transpose().mmul(k).div(k.transpose().mmul(k).get(0,0)),B=B.div(B.norm()),O=u.mmul(B).div(B.transpose().mmul(B).get(0,0))):O=k;if(u){let ne=h.transpose().mmul(k).div(k.transpose().mmul(k).get(0,0));ne=ne.div(ne.norm());let U=h.clone().sub(k.clone().mmul(ne.transpose())),K=O.transpose().mmul(k).div(k.transpose().mmul(k).get(0,0)),se=u.clone().sub(k.clone().mulS(K.get(0,0)).mmul(B.transpose()));this.t=k,this.p=ne.transpose(),this.w=C.transpose(),this.q=B,this.u=O,this.s=k.transpose().mmul(k),this.xResidual=U,this.yResidual=se,this.betas=K}else this.w=C.transpose(),this.s=k.transpose().mmul(k).sqrt(),g?this.t=k.clone().div(this.s.get(0,0)):this.t=k,this.xResidual=h.sub(k.mmul(C.transpose()))}}return we.AbstractMatrix=ie,we.CHO=a0,we.CholeskyDecomposition=a0,we.DistanceMatrix=te,we.EVD=ht,we.EigenvalueDecomposition=ht,we.LU=Et,we.LuDecomposition=Et,we.Matrix=P,we.MatrixColumnSelectionView=Ce,we.MatrixColumnView=xe,we.MatrixFlipColumnView=Ke,we.MatrixFlipRowView=Zt,we.MatrixRowSelectionView=$e,we.MatrixRowView=Xe,we.MatrixSelectionView=Ee,we.MatrixSubView=bt,we.MatrixTransposeView=Me,we.NIPALS=u0,we.Nipals=u0,we.QR=Ue,we.QrDecomposition=Ue,we.SVD=ut,we.SingularValueDecomposition=ut,we.SymmetricMatrix=X,we.WrapperMatrix1D=_t,we.WrapperMatrix2D=Le,we.correlation=lt,we.covariance=Qr,we.default=P,we.determinant=Lt,we.inverse=Jt,we.linearDependencies=Jr,we.pseudoInverse=vc,we.solve=Xr,we.wrap=pc,we}var xr=Iw(),yf=pf(xr);const Mt=xr.Matrix,wf=xr.SingularValueDecomposition;yf.Matrix?yf.Matrix:xr.Matrix;const Tw={center:[0,0],linkDistance:50};class bf{constructor(t={}){this.options=t,this.id="mds",this.options=Object.assign(Object.assign({},Tw),t)}execute(t,r){return ye(this,void 0,void 0,function*(){return this.genericMDSLayout(!1,t,r)})}assign(t,r){return ye(this,void 0,void 0,function*(){yield this.genericMDSLayout(!0,t,r)})}genericMDSLayout(t,r,n){return ye(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),n),{center:s=[0,0],linkDistance:a=50}=i,o=r.getAllNodes(),c=r.getAllEdges();if(!o?.length||o.length===1)return It(r,t,s);const f=sf({nodes:o,edges:c}),l=nf(f);kw(l);const p=xy(l,a),v=jw(p),y=[];return v.forEach((_,b)=>{const w=et(o[b]);w.data.x=_[0]+s[0],w.data.y=_[1]+s[1],y.push(w)}),t&&y.forEach(_=>r.mergeNodeData(_.id,{x:_.data.x,y:_.data.y})),{nodes:y,edges:c}})}}const kw=e=>{let t=-999999;e.forEach(r=>{r.forEach(n=>{n!==1/0&&t<n&&(t=n)})}),e.forEach((r,n)=>{r.forEach((i,s)=>{i===1/0&&(e[n][s]=t)})})},jw=e=>{const r=Mt.mul(Mt.pow(e,2),-.5),n=r.mean("row"),i=r.mean("column"),s=r.mean();r.add(s).subRowVector(n).subColumnVector(i);const a=new wf(r),o=Mt.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map(c=>Mt.mul([c],[o]).toJSON()[0].splice(0,2))};function _f(e){return!!e.tick&&!!e.stop}const Cw={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},Pw={center:[0,0],comboPadding:10,treeKey:"combo"};class Lw{constructor(t={}){this.options=t,this.id="comboCombined",this.options=Object.assign(Object.assign({},Pw),t)}execute(t,r){return ye(this,void 0,void 0,function*(){return this.genericComboCombinedLayout(!1,t,r)})}assign(t,r){return ye(this,void 0,void 0,function*(){yield this.genericComboCombinedLayout(!0,t,r)})}genericComboCombinedLayout(t,r,n){return ye(this,void 0,void 0,function*(){const i=this.initVals(Object.assign(Object.assign({},this.options),n)),{center:s,treeKey:a,outerLayout:o}=i,c=r.getAllNodes().filter(I=>!I.data._isCombo),f=r.getAllNodes().filter(I=>I.data._isCombo),l=r.getAllEdges(),p=c?.length;if(!p||p===1)return It(r,t,s);const v=[],y=new Map;c.forEach(I=>{y.set(I.id,I)});const x=new Map;f.forEach(I=>{x.set(I.id,I)});const _=new Map,b=this.getInnerGraphs(r,a,y,x,l,i,_);yield Promise.all(b);const w=new Map,E=[],N=new Map;let S=!0;r.getRoots(a).forEach(I=>{const D=_.get(I.id),z=x.get(I.id)||y.get(I.id),$={id:I.id,data:Object.assign(Object.assign({},I.data),{x:D.data.x||z.data.x,y:D.data.y||z.data.y,fx:D.data.fx||z.data.fx,fy:D.data.fy||z.data.fy,mass:D.data.mass||z.data.mass,size:D.data.size})};E.push($),w.set(I.id,!0),!isNaN($.data.x)&&$.data.x!==0&&!isNaN($.data.y)&&$.data.y!==0?S=!1:($.data.x=Math.random()*100,$.data.y=Math.random()*100),gn(r,[I],V=>{V.id!==I.id&&N.set(V.id,I.id)},"TB",a)});const q=[];l.forEach(I=>{const D=N.get(I.source)||I.source,z=N.get(I.target)||I.target;D!==z&&w.has(D)&&w.has(z)&&q.push({id:I.id,source:D,target:z,data:{}})});let A;if(E?.length){if(E.length===1)E[0].data.x=s[0],E[0].data.y=s[1];else{const I=new De({nodes:E,edges:q}),D=o||new hf;S&&Cw[D.id]&&(yield(E.length<100?new bf:new yn).assign(I));const z=Object.assign({center:s,kg:5,preventOverlap:!0,animate:!1},D.id==="force"?{gravity:1,factor:4,linkDistance:($,V,Y)=>{const ee=Math.max(...V.data.size)||32,J=Math.max(...Y.data.size)||32;return ee/2+J/2+200}}:{});A=yield Ef(D,I,z)}_.forEach(I=>{var D;const z=A.nodes.find(Y=>Y.id===I.id);if(z){const{x:Y,y:ee}=z.data;I.data.visited=!0,I.data.x=Y,I.data.y=ee,v.push({id:I.id,data:{x:Y,y:ee}})}const{x:$,y:V}=I.data;(D=I.data.nodes)===null||D===void 0||D.forEach(Y=>{v.push({id:Y.id,data:{x:Y.data.x+$,y:Y.data.y+V}})})}),_.forEach(({data:I})=>{const{x:D,y:z,visited:$,nodes:V}=I;V?.forEach(Y=>{if(!$){const ee=v.find(J=>J.id===Y.id);ee.data.x+=D||0,ee.data.y+=z||0}})})}return t&&v.forEach(I=>{r.mergeNodeData(I.id,{x:I.data.x,y:I.data.y})}),{nodes:v,edges:l}})}initVals(t){const r=Object.assign({},t),{nodeSize:n,spacing:i,comboPadding:s}=t;let a,o;if(ve(i)?o=()=>i:gt(i)?o=i:o=()=>0,r.spacing=o,!n)a=f=>{const l=o(f);return f.size?pt(f.size)?((f.size[0]>f.size[1]?f.size[0]:f.size[1])+l)/2:zt(f.size)?((f.size.width>f.size.height?f.size.width:f.size.height)+l)/2:(f.size+l)/2:32+l/2};else if(gt(n))a=f=>{const l=n(f),p=o(f);return pt(f.size)?((f.size[0]>f.size[1]?f.size[0]:f.size[1])+p)/2:((l||32)+p)/2};else if(pt(n)){const l=(n[0]>n[1]?n[0]:n[1])/2;a=p=>l+o(p)/2}else{const f=n/2;a=l=>f+o(l)/2}r.nodeSize=a;let c;return ve(s)?c=()=>s:pt(s)?c=()=>Math.max.apply(null,s):gt(s)?c=s:c=()=>0,r.comboPadding=c,r}getInnerGraphs(t,r,n,i,s,a,o){const{nodeSize:c,comboPadding:f,spacing:l,innerLayout:p}=a,v=p||new yn({}),y={center:[0,0],preventOverlap:!0,nodeSpacing:l},x=[],_=b=>{let w=f?.(b)||10;return pt(w)&&(w=Math.max(...w)),{size:w?[w*2,w*2]:[30,30],padding:w}};return t.getRoots(r).forEach(b=>{o.set(b.id,{id:b.id,data:{nodes:[],size:_(b).size}});let w=Promise.resolve();gn(t,[b],E=>{var N;if(!E.data._isCombo)return;const{size:S,padding:q}=_(E);if(!(!((N=t.getChildren(E.id,r))===null||N===void 0)&&N.length))o.set(E.id,{id:E.id,data:Object.assign(Object.assign({},E.data),{size:S})});else{const A=o.get(E.id);o.set(E.id,{id:E.id,data:Object.assign({nodes:[]},A?.data)});const j=new Map,I=t.getChildren(E.id,r).map($=>{if($.data._isCombo)return o.has($.id)||o.set($.id,{id:$.id,data:Object.assign({},$.data)}),j.set($.id,!0),o.get($.id);const V=n.get($.id)||i.get($.id);return j.set($.id,!0),{id:$.id,data:Object.assign(Object.assign({},V.data),$.data)}}),D={nodes:I,edges:s.filter($=>j.has($.source)&&j.has($.target))};let z=1/0;I.forEach($=>{var V;let{size:Y}=$.data;Y||(Y=((V=o.get($.id))===null||V===void 0?void 0:V.data.size)||c?.($)||[30,30]),ve(Y)&&(Y=[Y,Y]);const[ee,J]=Y;z>ee&&(z=ee),z>J&&(z=J),$.data.size=Y}),w=w.then(()=>ye(this,void 0,void 0,function*(){const $=new De(D);yield Ef(v,$,y,!0);const{minX:V,minY:Y,maxX:ee,maxY:J}=Ny(I),ae={x:(ee+V)/2,y:(J+Y)/2};D.nodes.forEach(Z=>{Z.data.x-=ae.x,Z.data.y-=ae.y});const be=[Math.max(ee-V,z)+q*2,Math.max(J-Y,z)+q*2];o.get(E.id).data.size=be,o.get(E.id).data.nodes=I}))}return!0},"BT",r),x.push(w)}),x}}function Ef(e,t,r,n){var i;return ye(this,void 0,void 0,function*(){return _f(e)?(e.execute(t,r),e.stop(),e.tick((i=r.iterations)!==null&&i!==void 0?i:300)):n?yield e.assign(t,r):yield e.execute(t,r)})}function Dw(e,t){var r,n=1;e==null&&(e=0),t==null&&(t=0);function i(){var s,a=r.length,o,c=0,f=0;for(s=0;s<a;++s)o=r[s],c+=o.x,f+=o.y;for(c=(c/a-e)*n,f=(f/a-t)*n,s=0;s<a;++s)o=r[s],o.x-=c,o.y-=f}return i.initialize=function(s){r=s},i.x=function(s){return arguments.length?(e=+s,i):e},i.y=function(s){return arguments.length?(t=+s,i):t},i.strength=function(s){return arguments.length?(n=+s,i):n},i}function ze(e){return function(){return e}}function St(e){return(e()-.5)*1e-6}function zw(e){return e.x+e.vx}function Fw(e){return e.y+e.vy}function Bw(e){var t,r,n,i=1,s=1;typeof e!="function"&&(e=ze(e==null?1:+e));function a(){for(var f,l=t.length,p,v,y,x,_,b,w=0;w<s;++w)for(p=Bt(t,zw,Fw).visitAfter(o),f=0;f<l;++f)v=t[f],_=r[v.index],b=_*_,y=v.x+v.vx,x=v.y+v.vy,p.visit(E);function E(N,S,q,A,j){var I=N.data,D=N.r,z=_+D;if(I){if(I.index>v.index){var $=y-I.x-I.vx,V=x-I.y-I.vy,Y=$*$+V*V;Y<z*z&&($===0&&($=St(n),Y+=$*$),V===0&&(V=St(n),Y+=V*V),Y=(z-(Y=Math.sqrt(Y)))/Y*i,v.vx+=($*=Y)*(z=(D*=D)/(b+D)),v.vy+=(V*=Y)*z,I.vx-=$*(z=1-z),I.vy-=V*z)}return}return S>y+z||A<y-z||q>x+z||j<x-z}}function o(f){if(f.data)return f.r=r[f.data.index];for(var l=f.r=0;l<4;++l)f[l]&&f[l].r>f.r&&(f.r=f[l].r)}function c(){if(t){var f,l=t.length,p;for(r=new Array(l),f=0;f<l;++f)p=t[f],r[p.index]=+e(p,f,t)}}return a.initialize=function(f,l){t=f,n=l,c()},a.iterations=function(f){return arguments.length?(s=+f,a):s},a.strength=function(f){return arguments.length?(i=+f,a):i},a.radius=function(f){return arguments.length?(e=typeof f=="function"?f:ze(+f),c(),a):e},a}function $w(e){return e.index}function xf(e,t){var r=e.get(t);if(!r)throw new Error("node not found: "+t);return r}function Gw(e){var t=$w,r=p,n,i=ze(30),s,a,o,c,f,l=1;e==null&&(e=[]);function p(b){return 1/Math.min(o[b.source.index],o[b.target.index])}function v(b){for(var w=0,E=e.length;w<l;++w)for(var N=0,S,q,A,j,I,D,z;N<E;++N)S=e[N],q=S.source,A=S.target,j=A.x+A.vx-q.x-q.vx||St(f),I=A.y+A.vy-q.y-q.vy||St(f),D=Math.sqrt(j*j+I*I),D=(D-s[N])/D*b*n[N],j*=D,I*=D,A.vx-=j*(z=c[N]),A.vy-=I*z,q.vx+=j*(z=1-z),q.vy+=I*z}function y(){if(a){var b,w=a.length,E=e.length,N=new Map(a.map((q,A)=>[t(q,A,a),q])),S;for(b=0,o=new Array(w);b<E;++b)S=e[b],S.index=b,typeof S.source!="object"&&(S.source=xf(N,S.source)),typeof S.target!="object"&&(S.target=xf(N,S.target)),o[S.source.index]=(o[S.source.index]||0)+1,o[S.target.index]=(o[S.target.index]||0)+1;for(b=0,c=new Array(E);b<E;++b)S=e[b],c[b]=o[S.source.index]/(o[S.source.index]+o[S.target.index]);n=new Array(E),x(),s=new Array(E),_()}}function x(){if(a)for(var b=0,w=e.length;b<w;++b)n[b]=+r(e[b],b,e)}function _(){if(a)for(var b=0,w=e.length;b<w;++b)s[b]=+i(e[b],b,e)}return v.initialize=function(b,w){a=b,f=w,y()},v.links=function(b){return arguments.length?(e=b,y(),v):e},v.id=function(b){return arguments.length?(t=b,v):t},v.iterations=function(b){return arguments.length?(l=+b,v):l},v.strength=function(b){return arguments.length?(r=typeof b=="function"?b:ze(+b),x(),v):r},v.distance=function(b){return arguments.length?(i=typeof b=="function"?b:ze(+b),_(),v):i},v}var Uw={value:()=>{}};function xn(){for(var e=0,t=arguments.length,r={},n;e<t;++e){if(!(n=arguments[e]+"")||n in r||/[\s.]/.test(n))throw new Error("illegal type: "+n);r[n]=[]}return new Nr(r)}function Nr(e){this._=e}function Vw(e,t){return e.trim().split(/^|\s+/).map(function(r){var n="",i=r.indexOf(".");if(i>=0&&(n=r.slice(i+1),r=r.slice(0,i)),r&&!t.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:n}})}Nr.prototype=xn.prototype={constructor:Nr,on:function(e,t){var r=this._,n=Vw(e+"",r),i,s=-1,a=n.length;if(arguments.length<2){for(;++s<a;)if((i=(e=n[s]).type)&&(i=Ww(r[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<a;)if(i=(e=n[s]).type)r[i]=Nf(r[i],e.name,t);else if(t==null)for(i in r)r[i]=Nf(r[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var r in t)e[r]=t[r].slice();return new Nr(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var r=new Array(i),n=0,i,s;n<i;++n)r[n]=arguments[n+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],n=0,i=s.length;n<i;++n)s[n].value.apply(t,r)},apply:function(e,t,r){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var n=this._[e],i=0,s=n.length;i<s;++i)n[i].value.apply(t,r)}};function Ww(e,t){for(var r=0,n=e.length,i;r<n;++r)if((i=e[r]).name===t)return i.value}function Nf(e,t,r){for(var n=0,i=e.length;n<i;++n)if(e[n].name===t){e[n]=Uw,e=e.slice(0,n).concat(e.slice(n+1));break}return r!=null&&e.push({name:t,value:r}),e}var $t=0,rr=0,nr=0,Mf=1e3,Mr,ir,Sr=0,Tt=0,qr=0,sr=typeof performance=="object"&&performance.now?performance:Date,Sf=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function qf(){return Tt||(Sf(Yw),Tt=sr.now()+qr)}function Yw(){Tt=0}function Nn(){this._call=this._time=this._next=null}Nn.prototype=Mn.prototype={constructor:Nn,restart:function(e,t,r){if(typeof e!="function")throw new TypeError("callback is not a function");r=(r==null?qf():+r)+(t==null?0:+t),!this._next&&ir!==this&&(ir?ir._next=this:Mr=this,ir=this),this._call=e,this._time=r,Sn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Sn())}};function Mn(e,t,r){var n=new Nn;return n.restart(e,t,r),n}function Kw(){qf(),++$t;for(var e=Mr,t;e;)(t=Tt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--$t}function Rf(){Tt=(Sr=sr.now())+qr,$t=rr=0;try{Kw()}finally{$t=0,Zw(),Tt=0}}function Xw(){var e=sr.now(),t=e-Sr;t>Mf&&(qr-=t,Sr=e)}function Zw(){for(var e,t=Mr,r,n=1/0;t;)t._call?(n>t._time&&(n=t._time),e=t,t=t._next):(r=t._next,t._next=null,t=e?e._next=r:Mr=r);ir=e,Sn(n)}function Sn(e){if(!$t){rr&&(rr=clearTimeout(rr));var t=e-Tt;t>24?(e<1/0&&(rr=setTimeout(Rf,e-sr.now()-qr)),nr&&(nr=clearInterval(nr))):(nr||(Sr=sr.now(),nr=setInterval(Xw,Mf)),$t=1,Sf(Rf))}}const Jw=1664525,Qw=1013904223,Of=4294967296;function Hw(){let e=1;return()=>(e=(Jw*e+Qw)%Of)/Of}function e1(e){return e.x}function t1(e){return e.y}var r1=10,n1=Math.PI*(3-Math.sqrt(5));function i1(e){var t,r=1,n=.001,i=1-Math.pow(n,1/300),s=0,a=.6,o=new Map,c=Mn(p),f=xn("tick","end"),l=Hw();e==null&&(e=[]);function p(){v(),f.call("tick",t),r<n&&(c.stop(),f.call("end",t))}function v(_){var b,w=e.length,E;_===void 0&&(_=1);for(var N=0;N<_;++N)for(r+=(s-r)*i,o.forEach(function(S){S(r)}),b=0;b<w;++b)E=e[b],E.fx==null?E.x+=E.vx*=a:(E.x=E.fx,E.vx=0),E.fy==null?E.y+=E.vy*=a:(E.y=E.fy,E.vy=0);return t}function y(){for(var _=0,b=e.length,w;_<b;++_){if(w=e[_],w.index=_,w.fx!=null&&(w.x=w.fx),w.fy!=null&&(w.y=w.fy),isNaN(w.x)||isNaN(w.y)){var E=r1*Math.sqrt(.5+_),N=_*n1;w.x=E*Math.cos(N),w.y=E*Math.sin(N)}(isNaN(w.vx)||isNaN(w.vy))&&(w.vx=w.vy=0)}}function x(_){return _.initialize&&_.initialize(e,l),_}return y(),t={tick:v,restart:function(){return c.restart(p),t},stop:function(){return c.stop(),t},nodes:function(_){return arguments.length?(e=_,y(),o.forEach(x),t):e},alpha:function(_){return arguments.length?(r=+_,t):r},alphaMin:function(_){return arguments.length?(n=+_,t):n},alphaDecay:function(_){return arguments.length?(i=+_,t):+i},alphaTarget:function(_){return arguments.length?(s=+_,t):s},velocityDecay:function(_){return arguments.length?(a=1-_,t):1-a},randomSource:function(_){return arguments.length?(l=_,o.forEach(x),t):l},force:function(_,b){return arguments.length>1?(b==null?o.delete(_):o.set(_,x(b)),t):o.get(_)},find:function(_,b,w){var E=0,N=e.length,S,q,A,j,I;for(w==null?w=1/0:w*=w,E=0;E<N;++E)j=e[E],S=_-j.x,q=b-j.y,A=S*S+q*q,A<w&&(I=j,w=A);return I},on:function(_,b){return arguments.length>1?(f.on(_,b),t):f.on(_)}}}function s1(){var e,t,r,n,i=ze(-30),s,a=1,o=1/0,c=.81;function f(y){var x,_=e.length,b=Bt(e,e1,t1).visitAfter(p);for(n=y,x=0;x<_;++x)t=e[x],b.visit(v)}function l(){if(e){var y,x=e.length,_;for(s=new Array(x),y=0;y<x;++y)_=e[y],s[_.index]=+i(_,y,e)}}function p(y){var x=0,_,b,w=0,E,N,S;if(y.length){for(E=N=S=0;S<4;++S)(_=y[S])&&(b=Math.abs(_.value))&&(x+=_.value,w+=b,E+=b*_.x,N+=b*_.y);y.x=E/w,y.y=N/w}else{_=y,_.x=_.data.x,_.y=_.data.y;do x+=s[_.data.index];while(_=_.next)}y.value=x}function v(y,x,_,b){if(!y.value)return!0;var w=y.x-t.x,E=y.y-t.y,N=b-x,S=w*w+E*E;if(N*N/c<S)return S<o&&(w===0&&(w=St(r),S+=w*w),E===0&&(E=St(r),S+=E*E),S<a&&(S=Math.sqrt(a*S)),t.vx+=w*y.value*n/S,t.vy+=E*y.value*n/S),!0;if(y.length||S>=o)return;(y.data!==t||y.next)&&(w===0&&(w=St(r),S+=w*w),E===0&&(E=St(r),S+=E*E),S<a&&(S=Math.sqrt(a*S)));do y.data!==t&&(N=s[y.data.index]*n/S,t.vx+=w*N,t.vy+=E*N);while(y=y.next)}return f.initialize=function(y,x){e=y,r=x,l()},f.strength=function(y){return arguments.length?(i=typeof y=="function"?y:ze(+y),l(),f):i},f.distanceMin=function(y){return arguments.length?(a=y*y,f):Math.sqrt(a)},f.distanceMax=function(y){return arguments.length?(o=y*y,f):Math.sqrt(o)},f.theta=function(y){return arguments.length?(c=y*y,f):Math.sqrt(c)},f}function o1(e,t,r){var n,i=ze(.1),s,a;typeof e!="function"&&(e=ze(+e)),t==null&&(t=0),r==null&&(r=0);function o(f){for(var l=0,p=n.length;l<p;++l){var v=n[l],y=v.x-t||1e-6,x=v.y-r||1e-6,_=Math.sqrt(y*y+x*x),b=(a[l]-_)*s[l]*f/_;v.vx+=y*b,v.vy+=x*b}}function c(){if(n){var f,l=n.length;for(s=new Array(l),a=new Array(l),f=0;f<l;++f)a[f]=+e(n[f],f,n),s[f]=isNaN(a[f])?0:+i(n[f],f,n)}}return o.initialize=function(f){n=f,c()},o.strength=function(f){return arguments.length?(i=typeof f=="function"?f:ze(+f),c(),o):i},o.radius=function(f){return arguments.length?(e=typeof f=="function"?f:ze(+f),c(),o):e},o.x=function(f){return arguments.length?(t=+f,o):t},o.y=function(f){return arguments.length?(r=+f,o):r},o}function a1(e){var t=ze(.1),r,n,i;typeof e!="function"&&(e=ze(e==null?0:+e));function s(o){for(var c=0,f=r.length,l;c<f;++c)l=r[c],l.vx+=(i[c]-l.x)*n[c]*o}function a(){if(r){var o,c=r.length;for(n=new Array(c),i=new Array(c),o=0;o<c;++o)n[o]=isNaN(i[o]=+e(r[o],o,r))?0:+t(r[o],o,r)}}return s.initialize=function(o){r=o,a()},s.strength=function(o){return arguments.length?(t=typeof o=="function"?o:ze(+o),a(),s):t},s.x=function(o){return arguments.length?(e=typeof o=="function"?o:ze(+o),a(),s):e},s}function u1(e){var t=ze(.1),r,n,i;typeof e!="function"&&(e=ze(e==null?0:+e));function s(o){for(var c=0,f=r.length,l;c<f;++c)l=r[c],l.vy+=(i[c]-l.y)*n[c]*o}function a(){if(r){var o,c=r.length;for(n=new Array(c),i=new Array(c),o=0;o<c;++o)n[o]=isNaN(i[o]=+e(r[o],o,r))?0:+t(r[o],o,r)}}return s.initialize=function(o){r=o,a()},s.strength=function(o){return arguments.length?(t=typeof o=="function"?o:ze(+o),a(),s):t},s.y=function(o){return arguments.length?(e=typeof o=="function"?o:ze(+o),a(),s):e},s}class Af{constructor(t){this.id="d3-force",this.config={inputNodeAttrs:["x","y","vx","vy","fx","fy"],outputNodeAttrs:["x","y","vx","vy"],simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource"]},this.forceMap={link:Gw,manyBody:s1,center:Dw,collide:Bw,radial:o1,x:a1,y:u1},this.options={link:{id:r=>r.id},manyBody:{},center:{x:0,y:0}},this.context={options:{},assign:!1,nodes:[],edges:[]},Sc(this.options,t),this.options.forceSimulation&&(this.simulation=this.options.forceSimulation)}execute(t,r){return ye(this,void 0,void 0,function*(){return this.genericLayout(!1,t,r)})}assign(t,r){return ye(this,void 0,void 0,function*(){yield this.genericLayout(!0,t,r)})}stop(){this.simulation.stop()}tick(t){return this.simulation.tick(t),this.getResult()}restart(){this.simulation.restart()}setFixedPosition(t,r){const n=this.context.nodes.find(i=>i.id===t);n&&r.forEach((i,s)=>{if(typeof i=="number"||i===null){const a=["fx","fy","fz"][s];n[a]=i}})}getOptions(t){var r,n;const i=Sc({},this.options,t);return i.collide&&((r=i.collide)===null||r===void 0?void 0:r.radius)===void 0&&(i.collide=i.collide||{},i.collide.radius=(n=i.nodeSize)!==null&&n!==void 0?n: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,r,n){var i;return ye(this,void 0,void 0,function*(){const s=this.getOptions(n),a=r.getAllNodes().map(({id:l,data:p})=>Object.assign(Object.assign({id:l},p),qc(p.data,this.config.inputNodeAttrs))),o=r.getAllEdges().map(l=>Object.assign({},l));Object.assign(this.context,{assign:t,nodes:a,edges:o,graph:r});const c=new Promise(l=>{this.resolver=l}),f=this.setSimulation(s);return f.nodes(a),(i=f.force("link"))===null||i===void 0||i.links(o),c})}getResult(){const{assign:t,nodes:r,edges:n,graph:i}=this.context,s=r.map(o=>({id:o.id,data:Object.assign(Object.assign({},o.data),qc(o,this.config.outputNodeAttrs))})),a=n.map(({id:o,source:c,target:f,data:l})=>({id:o,source:typeof c=="object"?c.id:c,target:typeof f=="object"?f.id:f,data:l}));return t&&s.forEach(o=>i.mergeNodeData(o.id,o.data)),{nodes:s,edges:a}}initSimulation(){return i1()}setSimulation(t){const r=this.simulation||this.options.forceSimulation||this.initSimulation();return this.simulation||(this.simulation=r.on("tick",()=>{var n;return(n=t.onTick)===null||n===void 0?void 0:n.call(t,this.getResult())}).on("end",()=>{var n;return(n=this.resolver)===null||n===void 0?void 0:n.call(this,this.getResult())})),If(r,this.config.simulationAttrs.map(n=>[n,t[n]])),Object.entries(this.forceMap).forEach(([n,i])=>{const s=n;if(t[n]){let a=r.force(s);a||(a=i(),r.force(s,a)),If(a,Object.entries(t[s]))}else r.force(s,null)}),r}}const If=(e,t)=>t.reduce((r,[n,i])=>!r[n]||i===void 0?r:r[n].call(e,i),e);function c1(e,t,r){var n,i=1;e==null&&(e=0),t==null&&(t=0),r==null&&(r=0);function s(){var a,o=n.length,c,f=0,l=0,p=0;for(a=0;a<o;++a)c=n[a],f+=c.x||0,l+=c.y||0,p+=c.z||0;for(f=(f/o-e)*i,l=(l/o-t)*i,p=(p/o-r)*i,a=0;a<o;++a)c=n[a],f&&(c.x-=f),l&&(c.y-=l),p&&(c.z-=p)}return s.initialize=function(a){n=a},s.x=function(a){return arguments.length?(e=+a,s):e},s.y=function(a){return arguments.length?(t=+a,s):t},s.z=function(a){return arguments.length?(r=+a,s):r},s.strength=function(a){return arguments.length?(i=+a,s):i},s}function f1(e){const t=+this._x.call(null,e);return Tf(this.cover(t),t,e)}function Tf(e,t,r){if(isNaN(t))return e;var n,i=e._root,s={data:r},a=e._x0,o=e._x1,c,f,l,p,v;if(!i)return e._root=s,e;for(;i.length;)if((l=t>=(c=(a+o)/2))?a=c:o=c,n=i,!(i=i[p=+l]))return n[p]=s,e;if(f=+e._x.call(null,i.data),t===f)return s.next=i,n?n[p]=s:e._root=s,e;do n=n?n[p]=new Array(2):e._root=new Array(2),(l=t>=(c=(a+o)/2))?a=c:o=c;while((p=+l)==(v=+(f>=c)));return n[v]=i,n[p]=s,e}function l1(e){Array.isArray(e)||(e=Array.from(e));const t=e.length,r=new Float64Array(t);let n=1/0,i=-1/0;for(let s=0,a;s<t;++s)isNaN(a=+this._x.call(null,e[s]))||(r[s]=a,a<n&&(n=a),a>i&&(i=a));if(n>i)return this;this.cover(n).cover(i);for(let s=0;s<t;++s)Tf(this,r[s],e[s]);return this}function h1(e){if(isNaN(e=+e))return this;var t=this._x0,r=this._x1;if(isNaN(t))r=(t=Math.floor(e))+1;else{for(var n=r-t||1,i=this._root,s,a;t>e||e>=r;)switch(a=+(e<t),s=new Array(2),s[a]=i,i=s,n*=2,a){case 0:r=t+n;break;case 1:t=r-n;break}this._root&&this._root.length&&(this._root=i)}return this._x0=t,this._x1=r,this}function d1(){var e=[];return this.visit(function(t){if(!t.length)do e.push(t.data);while(t=t.next)}),e}function g1(e){return arguments.length?this.cover(+e[0][0]).cover(+e[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}function vt(e,t,r){this.node=e,this.x0=t,this.x1=r}function p1(e,t){var r,n=this._x0,i,s,a=this._x1,o=[],c=this._root,f,l;for(c&&o.push(new vt(c,n,a)),t==null?t=1/0:(n=e-t,a=e+t);f=o.pop();)if(!(!(c=f.node)||(i=f.x0)>a||(s=f.x1)<n))if(c.length){var p=(i+s)/2;o.push(new vt(c[1],p,s),new vt(c[0],i,p)),(l=+(e>=p))&&(f=o[o.length-1],o[o.length-1]=o[o.length-1-l],o[o.length-1-l]=f)}else{var v=Math.abs(e-+this._x.call(null,c.data));v<t&&(t=v,n=e-v,a=e+v,r=c.data)}return r}function v1(e){if(isNaN(c=+this._x.call(null,e)))return this;var t,r=this._root,n,i,s,a=this._x0,o=this._x1,c,f,l,p,v;if(!r)return this;if(r.length)for(;;){if((l=c>=(f=(a+o)/2))?a=f:o=f,t=r,!(r=r[p=+l]))return this;if(!r.length)break;t[p+1&1]&&(n=t,v=p)}for(;r.data!==e;)if(i=r,!(r=r.next))return this;return(s=r.next)&&delete r.next,i?(s?i.next=s:delete i.next,this):t?(s?t[p]=s:delete t[p],(r=t[0]||t[1])&&r===(t[1]||t[0])&&!r.length&&(n?n[v]=r:this._root=r),this):(this._root=s,this)}function m1(e){for(var t=0,r=e.length;t<r;++t)this.remove(e[t]);return this}function y1(){return this._root}function w1(){var e=0;return this.visit(function(t){if(!t.length)do++e;while(t=t.next)}),e}function b1(e){var t=[],r,n=this._root,i,s,a;for(n&&t.push(new vt(n,this._x0,this._x1));r=t.pop();)if(!e(n=r.node,s=r.x0,a=r.x1)&&n.length){var o=(s+a)/2;(i=n[1])&&t.push(new vt(i,o,a)),(i=n[0])&&t.push(new vt(i,s,o))}return this}function _1(e){var t=[],r=[],n;for(this._root&&t.push(new vt(this._root,this._x0,this._x1));n=t.pop();){var i=n.node;if(i.length){var s,a=n.x0,o=n.x1,c=(a+o)/2;(s=i[0])&&t.push(new vt(s,a,c)),(s=i[1])&&t.push(new vt(s,c,o))}r.push(n)}for(;n=r.pop();)e(n.node,n.x0,n.x1);return this}function E1(e){return e[0]}function x1(e){return arguments.length?(this._x=e,this):this._x}function qn(e,t){var r=new Rn(t??E1,NaN,NaN);return e==null?r:r.addAll(e)}function Rn(e,t,r){this._x=e,this._x0=t,this._x1=r,this._root=void 0}function kf(e){for(var t={data:e.data},r=t;e=e.next;)r=r.next={data:e.data};return t}var Qe=qn.prototype=Rn.prototype;Qe.copy=function(){var e=new Rn(this._x,this._x0,this._x1),t=this._root,r,n;if(!t)return e;if(!t.length)return e._root=kf(t),e;for(r=[{source:t,target:e._root=new Array(2)}];t=r.pop();)for(var i=0;i<2;++i)(n=t.source[i])&&(n.length?r.push({source:n,target:t.target[i]=new Array(2)}):t.target[i]=kf(n));return e},Qe.add=f1,Qe.addAll=l1,Qe.cover=h1,Qe.data=d1,Qe.extent=g1,Qe.find=p1,Qe.remove=v1,Qe.removeAll=m1,Qe.root=y1,Qe.size=w1,Qe.visit=b1,Qe.visitAfter=_1,Qe.x=x1;function je(e){return function(){return e}}function nt(e){return(e()-.5)*1e-6}function On(e){return e.x+e.vx}function jf(e){return e.y+e.vy}function N1(e){return e.z+e.vz}function M1(e){var t,r,n,i,s=1,a=1;typeof e!="function"&&(e=je(e==null?1:+e));function o(){for(var l,p=t.length,v,y,x,_,b,w,E,N=0;N<a;++N)for(v=(r===1?qn(t,On):r===2?Bt(t,On,jf):r===3?_r(t,On,jf,N1):null).visitAfter(c),l=0;l<p;++l)y=t[l],w=n[y.index],E=w*w,x=y.x+y.vx,r>1&&(_=y.y+y.vy),r>2&&(b=y.z+y.vz),v.visit(S);function S(q,A,j,I,D,z,$){var V=[A,j,I,D,z,$],Y=V[0],ee=V[1],J=V[2],ae=V[r],be=V[r+1],Z=V[r+2],ue=q.data,ge=q.r,le=w+ge;if(ue){if(ue.index>y.index){var ie=x-ue.x-ue.vx,_e=r>1?_-ue.y-ue.vy:0,G=r>2?b-ue.z-ue.vz:0,P=ie*ie+_e*_e+G*G;P<le*le&&(ie===0&&(ie=nt(i),P+=ie*ie),r>1&&_e===0&&(_e=nt(i),P+=_e*_e),r>2&&G===0&&(G=nt(i),P+=G*G),P=(le-(P=Math.sqrt(P)))/P*s,y.vx+=(ie*=P)*(le=(ge*=ge)/(E+ge)),r>1&&(y.vy+=(_e*=P)*le),r>2&&(y.vz+=(G*=P)*le),ue.vx-=ie*(le=1-le),r>1&&(ue.vy-=_e*le),r>2&&(ue.vz-=G*le))}return}return Y>x+le||ae<x-le||r>1&&(ee>_+le||be<_-le)||r>2&&(J>b+le||Z<b-le)}}function c(l){if(l.data)return l.r=n[l.data.index];for(var p=l.r=0;p<Math.pow(2,r);++p)l[p]&&l[p].r>l.r&&(l.r=l[p].r)}function f(){if(t){var l,p=t.length,v;for(n=new Array(p),l=0;l<p;++l)v=t[l],n[v.index]=+e(v,l,t)}}return o.initialize=function(l,...p){t=l,i=p.find(v=>typeof v=="function")||Math.random,r=p.find(v=>[1,2,3].includes(v))||2,f()},o.iterations=function(l){return arguments.length?(a=+l,o):a},o.strength=function(l){return arguments.length?(s=+l,o):s},o.radius=function(l){return arguments.length?(e=typeof l=="function"?l:je(+l),f(),o):e},o}function S1(e){return e.index}function Cf(e,t){var r=e.get(t);if(!r)throw new Error("node not found: "+t);return r}function q1(e){var t=S1,r=v,n,i=je(30),s,a,o,c,f,l,p=1;e==null&&(e=[]);function v(w){return 1/Math.min(c[w.source.index],c[w.target.index])}function y(w){for(var E=0,N=e.length;E<p;++E)for(var S=0,q,A,j,I=0,D=0,z=0,$,V;S<N;++S)q=e[S],A=q.source,j=q.target,I=j.x+j.vx-A.x-A.vx||nt(l),o>1&&(D=j.y+j.vy-A.y-A.vy||nt(l)),o>2&&(z=j.z+j.vz-A.z-A.vz||nt(l)),$=Math.sqrt(I*I+D*D+z*z),$=($-s[S])/$*w*n[S],I*=$,D*=$,z*=$,j.vx-=I*(V=f[S]),o>1&&(j.vy-=D*V),o>2&&(j.vz-=z*V),A.vx+=I*(V=1-V),o>1&&(A.vy+=D*V),o>2&&(A.vz+=z*V)}function x(){if(a){var w,E=a.length,N=e.length,S=new Map(a.map((A,j)=>[t(A,j,a),A])),q;for(w=0,c=new Array(E);w<N;++w)q=e[w],q.index=w,typeof q.source!="object"&&(q.source=Cf(S,q.source)),typeof q.target!="object"&&(q.target=Cf(S,q.target)),c[q.source.index]=(c[q.source.index]||0)+1,c[q.target.index]=(c[q.target.index]||0)+1;for(w=0,f=new Array(N);w<N;++w)q=e[w],f[w]=c[q.source.index]/(c[q.source.index]+c[q.target.index]);n=new Array(N),_(),s=new Array(N),b()}}function _(){if(a)for(var w=0,E=e.length;w<E;++w)n[w]=+r(e[w],w,e)}function b(){if(a)for(var w=0,E=e.length;w<E;++w)s[w]=+i(e[w],w,e)}return y.initialize=function(w,...E){a=w,l=E.find(N=>typeof N=="function")||Math.random,o=E.find(N=>[1,2,3].includes(N))||2,x()},y.links=function(w){return arguments.length?(e=w,x(),y):e},y.id=function(w){return arguments.length?(t=w,y):t},y.iterations=function(w){return arguments.length?(p=+w,y):p},y.strength=function(w){return arguments.length?(r=typeof w=="function"?w:je(+w),_(),y):r},y.distance=function(w){return arguments.length?(i=typeof w=="function"?w:je(+w),b(),y):i},y}const R1=1664525,O1=1013904223,Pf=4294967296;function A1(){let e=1;return()=>(e=(R1*e+O1)%Pf)/Pf}var Lf=3;function An(e){return e.x}function Df(e){return e.y}function I1(e){return e.z}var T1=10,k1=Math.PI*(3-Math.sqrt(5)),j1=Math.PI*20/(9+Math.sqrt(221));function C1(e,t){t=t||2;var r=Math.min(Lf,Math.max(1,Math.round(t))),n,i=1,s=.001,a=1-Math.pow(s,1/300),o=0,c=.6,f=new Map,l=Mn(y),p=xn("tick","end"),v=A1();e==null&&(e=[]);function y(){x(),p.call("tick",n),i<s&&(l.stop(),p.call("end",n))}function x(w){var E,N=e.length,S;w===void 0&&(w=1);for(var q=0;q<w;++q)for(i+=(o-i)*a,f.forEach(function(A){A(i)}),E=0;E<N;++E)S=e[E],S.fx==null?S.x+=S.vx*=c:(S.x=S.fx,S.vx=0),r>1&&(S.fy==null?S.y+=S.vy*=c:(S.y=S.fy,S.vy=0)),r>2&&(S.fz==null?S.z+=S.vz*=c:(S.z=S.fz,S.vz=0));return n}function _(){for(var w=0,E=e.length,N;w<E;++w){if(N=e[w],N.index=w,N.fx!=null&&(N.x=N.fx),N.fy!=null&&(N.y=N.fy),N.fz!=null&&(N.z=N.fz),isNaN(N.x)||r>1&&isNaN(N.y)||r>2&&isNaN(N.z)){var S=T1*(r>2?Math.cbrt(.5+w):r>1?Math.sqrt(.5+w):w),q=w*k1,A=w*j1;r===1?N.x=S:r===2?(N.x=S*Math.cos(q),N.y=S*Math.sin(q)):(N.x=S*Math.sin(q)*Math.cos(A),N.y=S*Math.cos(q),N.z=S*Math.sin(q)*Math.sin(A))}(isNaN(N.vx)||r>1&&isNaN(N.vy)||r>2&&isNaN(N.vz))&&(N.vx=0,r>1&&(N.vy=0),r>2&&(N.vz=0))}}function b(w){return w.initialize&&w.initialize(e,v,r),w}return _(),n={tick:x,restart:function(){return l.restart(y),n},stop:function(){return l.stop(),n},numDimensions:function(w){return arguments.length?(r=Math.min(Lf,Math.max(1,Math.round(w))),f.forEach(b),n):r},nodes:function(w){return arguments.length?(e=w,_(),f.forEach(b),n):e},alpha:function(w){return arguments.length?(i=+w,n):i},alphaMin:function(w){return arguments.length?(s=+w,n):s},alphaDecay:function(w){return arguments.length?(a=+w,n):+a},alphaTarget:function(w){return arguments.length?(o=+w,n):o},velocityDecay:function(w){return arguments.length?(c=1-w,n):1-c},randomSource:function(w){return arguments.length?(v=w,f.forEach(b),n):v},force:function(w,E){return arguments.length>1?(E==null?f.delete(w):f.set(w,b(E)),n):f.get(w)},find:function(){var w=Array.prototype.slice.call(arguments),E=w.shift()||0,N=(r>1?w.shift():null)||0,S=(r>2?w.shift():null)||0,q=w.shift()||1/0,A=0,j=e.length,I,D,z,$,V,Y;for(q*=q,A=0;A<j;++A)V=e[A],I=E-V.x,D=N-(V.y||0),z=S-(V.z||0),$=I*I+D*D+z*z,$<q&&(Y=V,q=$);return Y},on:function(w,E){return arguments.length>1?(p.on(w,E),n):p.on(w)}}}function P1(){var e,t,r,n,i,s=je(-30),a,o=1,c=1/0,f=.81;function l(x){var _,b=e.length,w=(t===1?qn(e,An):t===2?Bt(e,An,Df):t===3?_r(e,An,Df,I1):null).visitAfter(v);for(i=x,_=0;_<b;++_)r=e[_],w.visit(y)}function p(){if(e){var x,_=e.length,b;for(a=new Array(_),x=0;x<_;++x)b=e[x],a[b.index]=+s(b,x,e)}}function v(x){var _=0,b,w,E=0,N,S,q,A,j=x.length;if(j){for(N=S=q=A=0;A<j;++A)(b=x[A])&&(w=Math.abs(b.value))&&(_+=b.value,E+=w,N+=w*(b.x||0),S+=w*(b.y||0),q+=w*(b.z||0));_*=Math.sqrt(4/j),x.x=N/E,t>1&&(x.y=S/E),t>2&&(x.z=q/E)}else{b=x,b.x=b.data.x,t>1&&(b.y=b.data.y),t>2&&(b.z=b.data.z);do _+=a[b.data.index];while(b=b.next)}x.value=_}function y(x,_,b,w,E){if(!x.value)return!0;var N=[b,w,E][t-1],S=x.x-r.x,q=t>1?x.y-r.y:0,A=t>2?x.z-r.z:0,j=N-_,I=S*S+q*q+A*A;if(j*j/f<I)return I<c&&(S===0&&(S=nt(n),I+=S*S),t>1&&q===0&&(q=nt(n),I+=q*q),t>2&&A===0&&(A=nt(n),I+=A*A),I<o&&(I=Math.sqrt(o*I)),r.vx+=S*x.value*i/I,t>1&&(r.vy+=q*x.value*i/I),t>2&&(r.vz+=A*x.value*i/I)),!0;if(x.length||I>=c)return;(x.data!==r||x.next)&&(S===0&&(S=nt(n),I+=S*S),t>1&&q===0&&(q=nt(n),I+=q*q),t>2&&A===0&&(A=nt(n),I+=A*A),I<o&&(I=Math.sqrt(o*I)));do x.data!==r&&(j=a[x.data.index]*i/I,r.vx+=S*j,t>1&&(r.vy+=q*j),t>2&&(r.vz+=A*j));while(x=x.next)}return l.initialize=function(x,..._){e=x,n=_.find(b=>typeof b=="function")||Math.random,t=_.find(b=>[1,2,3].includes(b))||2,p()},l.strength=function(x){return arguments.length?(s=typeof x=="function"?x:je(+x),p(),l):s},l.distanceMin=function(x){return arguments.length?(o=x*x,l):Math.sqrt(o)},l.distanceMax=function(x){return arguments.length?(c=x*x,l):Math.sqrt(c)},l.theta=function(x){return arguments.length?(f=x*x,l):Math.sqrt(f)},l}function L1(e,t,r,n){var i,s,a=je(.1),o,c;typeof e!="function"&&(e=je(+e)),t==null&&(t=0),r==null&&(r=0),n==null&&(n=0);function f(p){for(var v=0,y=i.length;v<y;++v){var x=i[v],_=x.x-t||1e-6,b=(x.y||0)-r||1e-6,w=(x.z||0)-n||1e-6,E=Math.sqrt(_*_+b*b+w*w),N=(c[v]-E)*o[v]*p/E;x.vx+=_*N,s>1&&(x.vy+=b*N),s>2&&(x.vz+=w*N)}}function l(){if(i){var p,v=i.length;for(o=new Array(v),c=new Array(v),p=0;p<v;++p)c[p]=+e(i[p],p,i),o[p]=isNaN(c[p])?0:+a(i[p],p,i)}}return f.initialize=function(p,...v){i=p,s=v.find(y=>[1,2,3].includes(y))||2,l()},f.strength=function(p){return arguments.length?(a=typeof p=="function"?p:je(+p),l(),f):a},f.radius=function(p){return arguments.length?(e=typeof p=="function"?p:je(+p),l(),f):e},f.x=function(p){return arguments.length?(t=+p,f):t},f.y=function(p){return arguments.length?(r=+p,f):r},f.z=function(p){return arguments.length?(n=+p,f):n},f}function D1(e){var t=je(.1),r,n,i;typeof e!="function"&&(e=je(e==null?0:+e));function s(o){for(var c=0,f=r.length,l;c<f;++c)l=r[c],l.vx+=(i[c]-l.x)*n[c]*o}function a(){if(r){var o,c=r.length;for(n=new Array(c),i=new Array(c),o=0;o<c;++o)n[o]=isNaN(i[o]=+e(r[o],o,r))?0:+t(r[o],o,r)}}return s.initialize=function(o){r=o,a()},s.strength=function(o){return arguments.length?(t=typeof o=="function"?o:je(+o),a(),s):t},s.x=function(o){return arguments.length?(e=typeof o=="function"?o:je(+o),a(),s):e},s}function z1(e){var t=je(.1),r,n,i;typeof e!="function"&&(e=je(e==null?0:+e));function s(o){for(var c=0,f=r.length,l;c<f;++c)l=r[c],l.vy+=(i[c]-l.y)*n[c]*o}function a(){if(r){var o,c=r.length;for(n=new Array(c),i=new Array(c),o=0;o<c;++o)n[o]=isNaN(i[o]=+e(r[o],o,r))?0:+t(r[o],o,r)}}return s.initialize=function(o){r=o,a()},s.strength=function(o){return arguments.length?(t=typeof o=="function"?o:je(+o),a(),s):t},s.y=function(o){return arguments.length?(e=typeof o=="function"?o:je(+o),a(),s):e},s}function F1(e){var t=je(.1),r,n,i;typeof e!="function"&&(e=je(e==null?0:+e));function s(o){for(var c=0,f=r.length,l;c<f;++c)l=r[c],l.vz+=(i[c]-l.z)*n[c]*o}function a(){if(r){var o,c=r.length;for(n=new Array(c),i=new Array(c),o=0;o<c;++o)n[o]=isNaN(i[o]=+e(r[o],o,r))?0:+t(r[o],o,r)}}return s.initialize=function(o){r=o,a()},s.strength=function(o){return arguments.length?(t=typeof o=="function"?o:je(+o),a(),s):t},s.z=function(o){return arguments.length?(e=typeof o=="function"?o:je(+o),a(),s):e},s}class B1 extends Af{constructor(){super(...arguments),this.id="d3-force-3d",this.config={inputNodeAttrs:["x","y","z","vx","vy","vz","fx","fy","fz"],outputNodeAttrs:["x","y","z","vx","vy","vz"],simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource","numDimensions"]},this.forceMap={link:q1,manyBody:P1,center:c1,collide:M1,radial:L1,x:D1,y:z1,z:F1},this.options={numDimensions:3,link:{id:t=>t.id},manyBody:{},center:{x:0,y:0,z:0}}}initSimulation(){return C1()}}function In(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Tn,zf;function $1(){if(zf)return Tn;zf=1;function e(){this.__data__=[],this.size=0}return Tn=e,Tn}var kn,Ff;function Gt(){if(Ff)return kn;Ff=1;function e(t,r){return t===r||t!==t&&r!==r}return kn=e,kn}var jn,Bf;function Rr(){if(Bf)return jn;Bf=1;var e=Gt();function t(r,n){for(var i=r.length;i--;)if(e(r[i][0],n))return i;return-1}return jn=t,jn}var Cn,$f;function G1(){if($f)return Cn;$f=1;var e=Rr(),t=Array.prototype,r=t.splice;function n(i){var s=this.__data__,a=e(s,i);if(a<0)return!1;var o=s.length-1;return a==o?s.pop():r.call(s,a,1),--this.size,!0}return Cn=n,Cn}var Pn,Gf;function U1(){if(Gf)return Pn;Gf=1;var e=Rr();function t(r){var n=this.__data__,i=e(n,r);return i<0?void 0:n[i][1]}return Pn=t,Pn}var Ln,Uf;function V1(){if(Uf)return Ln;Uf=1;var e=Rr();function t(r){return e(this.__data__,r)>-1}return Ln=t,Ln}var Dn,Vf;function W1(){if(Vf)return Dn;Vf=1;var e=Rr();function t(r,n){var i=this.__data__,s=e(i,r);return s<0?(++this.size,i.push([r,n])):i[s][1]=n,this}return Dn=t,Dn}var zn,Wf;function Or(){if(Wf)return zn;Wf=1;var e=$1(),t=G1(),r=U1(),n=V1(),i=W1();function s(a){var o=-1,c=a==null?0:a.length;for(this.clear();++o<c;){var f=a[o];this.set(f[0],f[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=r,s.prototype.has=n,s.prototype.set=i,zn=s,zn}var Fn,Yf;function Y1(){if(Yf)return Fn;Yf=1;var e=Or();function t(){this.__data__=new e,this.size=0}return Fn=t,Fn}var Bn,Kf;function K1(){if(Kf)return Bn;Kf=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return Bn=e,Bn}var $n,Xf;function X1(){if(Xf)return $n;Xf=1;function e(t){return this.__data__.get(t)}return $n=e,$n}var Gn,Zf;function Z1(){if(Zf)return Gn;Zf=1;function e(t){return this.__data__.has(t)}return Gn=e,Gn}var Un,Jf;function Qf(){if(Jf)return Un;Jf=1;var e=typeof Er=="object"&&Er&&Er.Object===Object&&Er;return Un=e,Un}var Vn,Hf;function ot(){if(Hf)return Vn;Hf=1;var e=Qf(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return Vn=r,Vn}var Wn,el;function Ut(){if(el)return Wn;el=1;var e=ot(),t=e.Symbol;return Wn=t,Wn}var Yn,tl;function J1(){if(tl)return Yn;tl=1;var e=Ut(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,i=e?e.toStringTag:void 0;function s(a){var o=r.call(a,i),c=a[i];try{a[i]=void 0;var f=!0}catch{}var l=n.call(a);return f&&(o?a[i]=c:delete a[i]),l}return Yn=s,Yn}var Kn,rl;function Q1(){if(rl)return Kn;rl=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return Kn=r,Kn}var Xn,nl;function kt(){if(nl)return Xn;nl=1;var e=Ut(),t=J1(),r=Q1(),n="[object Null]",i="[object Undefined]",s=e?e.toStringTag:void 0;function a(o){return o==null?o===void 0?i:n:s&&s in Object(o)?t(o):r(o)}return Xn=a,Xn}var Zn,il;function it(){if(il)return Zn;il=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return Zn=e,Zn}var Jn,sl;function or(){if(sl)return Jn;sl=1;var e=kt(),t=it(),r="[object AsyncFunction]",n="[object Function]",i="[object GeneratorFunction]",s="[object Proxy]";function a(o){if(!t(o))return!1;var c=e(o);return c==n||c==i||c==r||c==s}return Jn=a,Jn}var Qn,ol;function H1(){if(ol)return Qn;ol=1;var e=ot(),t=e["__core-js_shared__"];return Qn=t,Qn}var Hn,al;function eb(){if(al)return Hn;al=1;var e=H1(),t=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function r(n){return!!t&&t in n}return Hn=r,Hn}var ei,ul;function cl(){if(ul)return ei;ul=1;var e=Function.prototype,t=e.toString;function r(n){if(n!=null){try{return t.call(n)}catch{}try{return n+""}catch{}}return""}return ei=r,ei}var ti,fl;function tb(){if(fl)return ti;fl=1;var e=or(),t=eb(),r=it(),n=cl(),i=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,a=Function.prototype,o=Object.prototype,c=a.toString,f=o.hasOwnProperty,l=RegExp("^"+c.call(f).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function p(v){if(!r(v)||t(v))return!1;var y=e(v)?l:s;return y.test(n(v))}return ti=p,ti}var ri,ll;function rb(){if(ll)return ri;ll=1;function e(t,r){return t?.[r]}return ri=e,ri}var ni,hl;function jt(){if(hl)return ni;hl=1;var e=tb(),t=rb();function r(n,i){var s=t(n,i);return e(s)?s:void 0}return ni=r,ni}var ii,dl;function si(){if(dl)return ii;dl=1;var e=jt(),t=ot(),r=e(t,"Map");return ii=r,ii}var oi,gl;function Ar(){if(gl)return oi;gl=1;var e=jt(),t=e(Object,"create");return oi=t,oi}var ai,pl;function nb(){if(pl)return ai;pl=1;var e=Ar();function t(){this.__data__=e?e(null):{},this.size=0}return ai=t,ai}var ui,vl;function ib(){if(vl)return ui;vl=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return ui=e,ui}var ci,ml;function sb(){if(ml)return ci;ml=1;var e=Ar(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function i(s){var a=this.__data__;if(e){var o=a[s];return o===t?void 0:o}return n.call(a,s)?a[s]:void 0}return ci=i,ci}var fi,yl;function ob(){if(yl)return fi;yl=1;var e=Ar(),t=Object.prototype,r=t.hasOwnProperty;function n(i){var s=this.__data__;return e?s[i]!==void 0:r.call(s,i)}return fi=n,fi}var li,wl;function ab(){if(wl)return li;wl=1;var e=Ar(),t="__lodash_hash_undefined__";function r(n,i){var s=this.__data__;return this.size+=this.has(n)?0:1,s[n]=e&&i===void 0?t:i,this}return li=r,li}var hi,bl;function ub(){if(bl)return hi;bl=1;var e=nb(),t=ib(),r=sb(),n=ob(),i=ab();function s(a){var o=-1,c=a==null?0:a.length;for(this.clear();++o<c;){var f=a[o];this.set(f[0],f[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=r,s.prototype.has=n,s.prototype.set=i,hi=s,hi}var di,_l;function cb(){if(_l)return di;_l=1;var e=ub(),t=Or(),r=si();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return di=n,di}var gi,El;function fb(){if(El)return gi;El=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return gi=e,gi}var pi,xl;function Ir(){if(xl)return pi;xl=1;var e=fb();function t(r,n){var i=r.__data__;return e(n)?i[typeof n=="string"?"string":"hash"]:i.map}return pi=t,pi}var vi,Nl;function lb(){if(Nl)return vi;Nl=1;var e=Ir();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return vi=t,vi}var mi,Ml;function hb(){if(Ml)return mi;Ml=1;var e=Ir();function t(r){return e(this,r).get(r)}return mi=t,mi}var yi,Sl;function db(){if(Sl)return yi;Sl=1;var e=Ir();function t(r){return e(this,r).has(r)}return yi=t,yi}var wi,ql;function gb(){if(ql)return wi;ql=1;var e=Ir();function t(r,n){var i=e(this,r),s=i.size;return i.set(r,n),this.size+=i.size==s?0:1,this}return wi=t,wi}var bi,Rl;function _i(){if(Rl)return bi;Rl=1;var e=cb(),t=lb(),r=hb(),n=db(),i=gb();function s(a){var o=-1,c=a==null?0:a.length;for(this.clear();++o<c;){var f=a[o];this.set(f[0],f[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=r,s.prototype.has=n,s.prototype.set=i,bi=s,bi}var Ei,Ol;function pb(){if(Ol)return Ei;Ol=1;var e=Or(),t=si(),r=_i(),n=200;function i(s,a){var o=this.__data__;if(o instanceof e){var c=o.__data__;if(!t||c.length<n-1)return c.push([s,a]),this.size=++o.size,this;o=this.__data__=new r(c)}return o.set(s,a),this.size=o.size,this}return Ei=i,Ei}var xi,Al;function Tr(){if(Al)return xi;Al=1;var e=Or(),t=Y1(),r=K1(),n=X1(),i=Z1(),s=pb();function a(o){var c=this.__data__=new e(o);this.size=c.size}return a.prototype.clear=t,a.prototype.delete=r,a.prototype.get=n,a.prototype.has=i,a.prototype.set=s,xi=a,xi}var Ni,Il;function Mi(){if(Il)return Ni;Il=1;function e(t,r){for(var n=-1,i=t==null?0:t.length;++n<i&&r(t[n],n,t)!==!1;);return t}return Ni=e,Ni}var Si,Tl;function kl(){if(Tl)return Si;Tl=1;var e=jt(),t=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return Si=t,Si}var qi,jl;function kr(){if(jl)return qi;jl=1;var e=kl();function t(r,n,i){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:i,writable:!0}):r[n]=i}return qi=t,qi}var Ri,Cl;function jr(){if(Cl)return Ri;Cl=1;var e=kr(),t=Gt(),r=Object.prototype,n=r.hasOwnProperty;function i(s,a,o){var c=s[a];(!(n.call(s,a)&&t(c,o))||o===void 0&&!(a in s))&&e(s,a,o)}return Ri=i,Ri}var Oi,Pl;function ar(){if(Pl)return Oi;Pl=1;var e=jr(),t=kr();function r(n,i,s,a){var o=!s;s||(s={});for(var c=-1,f=i.length;++c<f;){var l=i[c],p=a?a(s[l],n[l],l,s,n):void 0;p===void 0&&(p=n[l]),o?t(s,l,p):e(s,l,p)}return s}return Oi=r,Oi}var Ai,Ll;function vb(){if(Ll)return Ai;Ll=1;function e(t,r){for(var n=-1,i=Array(t);++n<t;)i[n]=r(n);return i}return Ai=e,Ai}var Ii,Dl;function ft(){if(Dl)return Ii;Dl=1;function e(t){return t!=null&&typeof t=="object"}return Ii=e,Ii}var Ti,zl;function mb(){if(zl)return Ti;zl=1;var e=kt(),t=ft(),r="[object Arguments]";function n(i){return t(i)&&e(i)==r}return Ti=n,Ti}var ki,Fl;function ur(){if(Fl)return ki;Fl=1;var e=mb(),t=ft(),r=Object.prototype,n=r.hasOwnProperty,i=r.propertyIsEnumerable,s=e((function(){return arguments})())?e:function(a){return t(a)&&n.call(a,"callee")&&!i.call(a,"callee")};return ki=s,ki}var ji,Bl;function Pe(){if(Bl)return ji;Bl=1;var e=Array.isArray;return ji=e,ji}var cr={exports:{}},Ci,$l;function yb(){if($l)return Ci;$l=1;function e(){return!1}return Ci=e,Ci}cr.exports;var Gl;function Vt(){return Gl||(Gl=1,(function(e,t){var r=ot(),n=yb(),i=t&&!t.nodeType&&t,s=i&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===i,o=a?r.Buffer:void 0,c=o?o.isBuffer:void 0,f=c||n;e.exports=f})(cr,cr.exports)),cr.exports}var Pi,Ul;function Cr(){if(Ul)return Pi;Ul=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function r(n,i){var s=typeof n;return i=i??e,!!i&&(s=="number"||s!="symbol"&&t.test(n))&&n>-1&&n%1==0&&n<i}return Pi=r,Pi}var Li,Vl;function Di(){if(Vl)return Li;Vl=1;var e=9007199254740991;function t(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return Li=t,Li}var zi,Wl;function wb(){if(Wl)return zi;Wl=1;var e=kt(),t=Di(),r=ft(),n="[object Arguments]",i="[object Array]",s="[object Boolean]",a="[object Date]",o="[object Error]",c="[object Function]",f="[object Map]",l="[object Number]",p="[object Object]",v="[object RegExp]",y="[object Set]",x="[object String]",_="[object WeakMap]",b="[object ArrayBuffer]",w="[object DataView]",E="[object Float32Array]",N="[object Float64Array]",S="[object Int8Array]",q="[object Int16Array]",A="[object Int32Array]",j="[object Uint8Array]",I="[object Uint8ClampedArray]",D="[object Uint16Array]",z="[object Uint32Array]",$={};$[E]=$[N]=$[S]=$[q]=$[A]=$[j]=$[I]=$[D]=$[z]=!0,$[n]=$[i]=$[b]=$[s]=$[w]=$[a]=$[o]=$[c]=$[f]=$[l]=$[p]=$[v]=$[y]=$[x]=$[_]=!1;function V(Y){return r(Y)&&t(Y.length)&&!!$[e(Y)]}return zi=V,zi}var Fi,Yl;function Pr(){if(Yl)return Fi;Yl=1;function e(t){return function(r){return t(r)}}return Fi=e,Fi}var fr={exports:{}};fr.exports;var Kl;function Bi(){return Kl||(Kl=1,(function(e,t){var r=Qf(),n=t&&!t.nodeType&&t,i=n&&!0&&e&&!e.nodeType&&e,s=i&&i.exports===n,a=s&&r.process,o=(function(){try{var c=i&&i.require&&i.require("util").types;return c||a&&a.binding&&a.binding("util")}catch{}})();e.exports=o})(fr,fr.exports)),fr.exports}var $i,Xl;function lr(){if(Xl)return $i;Xl=1;var e=wb(),t=Pr(),r=Bi(),n=r&&r.isTypedArray,i=n?t(n):e;return $i=i,$i}var Gi,Zl;function Jl(){if(Zl)return Gi;Zl=1;var e=vb(),t=ur(),r=Pe(),n=Vt(),i=Cr(),s=lr(),a=Object.prototype,o=a.hasOwnProperty;function c(f,l){var p=r(f),v=!p&&t(f),y=!p&&!v&&n(f),x=!p&&!v&&!y&&s(f),_=p||v||y||x,b=_?e(f.length,String):[],w=b.length;for(var E in f)(l||o.call(f,E))&&!(_&&(E=="length"||y&&(E=="offset"||E=="parent")||x&&(E=="buffer"||E=="byteLength"||E=="byteOffset")||i(E,w)))&&b.push(E);return b}return Gi=c,Gi}var Ui,Ql;function Lr(){if(Ql)return Ui;Ql=1;var e=Object.prototype;function t(r){var n=r&&r.constructor,i=typeof n=="function"&&n.prototype||e;return r===i}return Ui=t,Ui}var Vi,Hl;function eh(){if(Hl)return Vi;Hl=1;function e(t,r){return function(n){return t(r(n))}}return Vi=e,Vi}var Wi,th;function bb(){if(th)return Wi;th=1;var e=eh(),t=e(Object.keys,Object);return Wi=t,Wi}var Yi,rh;function Ki(){if(rh)return Yi;rh=1;var e=Lr(),t=bb(),r=Object.prototype,n=r.hasOwnProperty;function i(s){if(!e(s))return t(s);var a=[];for(var o in Object(s))n.call(s,o)&&o!="constructor"&&a.push(o);return a}return Yi=i,Yi}var Xi,nh;function mt(){if(nh)return Xi;nh=1;var e=or(),t=Di();function r(n){return n!=null&&t(n.length)&&!e(n)}return Xi=r,Xi}var Zi,ih;function qt(){if(ih)return Zi;ih=1;var e=Jl(),t=Ki(),r=mt();function n(i){return r(i)?e(i):t(i)}return Zi=n,Zi}var Ji,sh;function _b(){if(sh)return Ji;sh=1;var e=ar(),t=qt();function r(n,i){return n&&e(i,t(i),n)}return Ji=r,Ji}var Qi,oh;function Eb(){if(oh)return Qi;oh=1;function e(t){var r=[];if(t!=null)for(var n in Object(t))r.push(n);return r}return Qi=e,Qi}var Hi,ah;function xb(){if(ah)return Hi;ah=1;var e=it(),t=Lr(),r=Eb(),n=Object.prototype,i=n.hasOwnProperty;function s(a){if(!e(a))return r(a);var o=t(a),c=[];for(var f in a)f=="constructor"&&(o||!i.call(a,f))||c.push(f);return c}return Hi=s,Hi}var es,uh;function Ct(){if(uh)return es;uh=1;var e=Jl(),t=xb(),r=mt();function n(i){return r(i)?e(i,!0):t(i)}return es=n,es}var ts,ch;function Nb(){if(ch)return ts;ch=1;var e=ar(),t=Ct();function r(n,i){return n&&e(i,t(i),n)}return ts=r,ts}var hr={exports:{}};hr.exports;var fh;function lh(){return fh||(fh=1,(function(e,t){var r=ot(),n=t&&!t.nodeType&&t,i=n&&!0&&e&&!e.nodeType&&e,s=i&&i.exports===n,a=s?r.Buffer:void 0,o=a?a.allocUnsafe:void 0;function c(f,l){if(l)return f.slice();var p=f.length,v=o?o(p):new f.constructor(p);return f.copy(v),v}e.exports=c})(hr,hr.exports)),hr.exports}var rs,hh;function dh(){if(hh)return rs;hh=1;function e(t,r){var n=-1,i=t.length;for(r||(r=Array(i));++n<i;)r[n]=t[n];return r}return rs=e,rs}var ns,gh;function ph(){if(gh)return ns;gh=1;function e(t,r){for(var n=-1,i=t==null?0:t.length,s=0,a=[];++n<i;){var o=t[n];r(o,n,t)&&(a[s++]=o)}return a}return ns=e,ns}var is,vh;function mh(){if(vh)return is;vh=1;function e(){return[]}return is=e,is}var ss,yh;function os(){if(yh)return ss;yh=1;var e=ph(),t=mh(),r=Object.prototype,n=r.propertyIsEnumerable,i=Object.getOwnPropertySymbols,s=i?function(a){return a==null?[]:(a=Object(a),e(i(a),function(o){return n.call(a,o)}))}:t;return ss=s,ss}var as,wh;function Mb(){if(wh)return as;wh=1;var e=ar(),t=os();function r(n,i){return e(n,t(n),i)}return as=r,as}var us,bh;function cs(){if(bh)return us;bh=1;function e(t,r){for(var n=-1,i=r.length,s=t.length;++n<i;)t[s+n]=r[n];return t}return us=e,us}var fs,_h;function Dr(){if(_h)return fs;_h=1;var e=eh(),t=e(Object.getPrototypeOf,Object);return fs=t,fs}var ls,Eh;function xh(){if(Eh)return ls;Eh=1;var e=cs(),t=Dr(),r=os(),n=mh(),i=Object.getOwnPropertySymbols,s=i?function(a){for(var o=[];a;)e(o,r(a)),a=t(a);return o}:n;return ls=s,ls}var hs,Nh;function Sb(){if(Nh)return hs;Nh=1;var e=ar(),t=xh();function r(n,i){return e(n,t(n),i)}return hs=r,hs}var ds,Mh;function Sh(){if(Mh)return ds;Mh=1;var e=cs(),t=Pe();function r(n,i,s){var a=i(n);return t(n)?a:e(a,s(n))}return ds=r,ds}var gs,qh;function Rh(){if(qh)return gs;qh=1;var e=Sh(),t=os(),r=qt();function n(i){return e(i,r,t)}return gs=n,gs}var ps,Oh;function qb(){if(Oh)return ps;Oh=1;var e=Sh(),t=xh(),r=Ct();function n(i){return e(i,r,t)}return ps=n,ps}var vs,Ah;function Rb(){if(Ah)return vs;Ah=1;var e=jt(),t=ot(),r=e(t,"DataView");return vs=r,vs}var ms,Ih;function Ob(){if(Ih)return ms;Ih=1;var e=jt(),t=ot(),r=e(t,"Promise");return ms=r,ms}var ys,Th;function kh(){if(Th)return ys;Th=1;var e=jt(),t=ot(),r=e(t,"Set");return ys=r,ys}var ws,jh;function Ab(){if(jh)return ws;jh=1;var e=jt(),t=ot(),r=e(t,"WeakMap");return ws=r,ws}var bs,Ch;function Wt(){if(Ch)return bs;Ch=1;var e=Rb(),t=si(),r=Ob(),n=kh(),i=Ab(),s=kt(),a=cl(),o="[object Map]",c="[object Object]",f="[object Promise]",l="[object Set]",p="[object WeakMap]",v="[object DataView]",y=a(e),x=a(t),_=a(r),b=a(n),w=a(i),E=s;return(e&&E(new e(new ArrayBuffer(1)))!=v||t&&E(new t)!=o||r&&E(r.resolve())!=f||n&&E(new n)!=l||i&&E(new i)!=p)&&(E=function(N){var S=s(N),q=S==c?N.constructor:void 0,A=q?a(q):"";if(A)switch(A){case y:return v;case x:return o;case _:return f;case b:return l;case w:return p}return S}),bs=E,bs}var _s,Ph;function Ib(){if(Ph)return _s;Ph=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n){var i=n.length,s=new n.constructor(i);return i&&typeof n[0]=="string"&&t.call(n,"index")&&(s.index=n.index,s.input=n.input),s}return _s=r,_s}var Es,Lh;function Dh(){if(Lh)return Es;Lh=1;var e=ot(),t=e.Uint8Array;return Es=t,Es}var xs,zh;function Ns(){if(zh)return xs;zh=1;var e=Dh();function t(r){var n=new r.constructor(r.byteLength);return new e(n).set(new e(r)),n}return xs=t,xs}var Ms,Fh;function Tb(){if(Fh)return Ms;Fh=1;var e=Ns();function t(r,n){var i=n?e(r.buffer):r.buffer;return new r.constructor(i,r.byteOffset,r.byteLength)}return Ms=t,Ms}var Ss,Bh;function kb(){if(Bh)return Ss;Bh=1;var e=/\w*$/;function t(r){var n=new r.constructor(r.source,e.exec(r));return n.lastIndex=r.lastIndex,n}return Ss=t,Ss}var qs,$h;function jb(){if($h)return qs;$h=1;var e=Ut(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;function n(i){return r?Object(r.call(i)):{}}return qs=n,qs}var Rs,Gh;function Uh(){if(Gh)return Rs;Gh=1;var e=Ns();function t(r,n){var i=n?e(r.buffer):r.buffer;return new r.constructor(i,r.byteOffset,r.length)}return Rs=t,Rs}var Os,Vh;function Cb(){if(Vh)return Os;Vh=1;var e=Ns(),t=Tb(),r=kb(),n=jb(),i=Uh(),s="[object Boolean]",a="[object Date]",o="[object Map]",c="[object Number]",f="[object RegExp]",l="[object Set]",p="[object String]",v="[object Symbol]",y="[object ArrayBuffer]",x="[object DataView]",_="[object Float32Array]",b="[object Float64Array]",w="[object Int8Array]",E="[object Int16Array]",N="[object Int32Array]",S="[object Uint8Array]",q="[object Uint8ClampedArray]",A="[object Uint16Array]",j="[object Uint32Array]";function I(D,z,$){var V=D.constructor;switch(z){case y:return e(D);case s:case a:return new V(+D);case x:return t(D,$);case _:case b:case w:case E:case N:case S:case q:case A:case j:return i(D,$);case o:return new V;case c:case p:return new V(D);case f:return r(D);case l:return new V;case v:return n(D)}}return Os=I,Os}var As,Wh;function Yh(){if(Wh)return As;Wh=1;var e=it(),t=Object.create,r=(function(){function n(){}return function(i){if(!e(i))return{};if(t)return t(i);n.prototype=i;var s=new n;return n.prototype=void 0,s}})();return As=r,As}var Is,Kh;function Xh(){if(Kh)return Is;Kh=1;var e=Yh(),t=Dr(),r=Lr();function n(i){return typeof i.constructor=="function"&&!r(i)?e(t(i)):{}}return Is=n,Is}var Ts,Zh;function Pb(){if(Zh)return Ts;Zh=1;var e=Wt(),t=ft(),r="[object Map]";function n(i){return t(i)&&e(i)==r}return Ts=n,Ts}var ks,Jh;function Lb(){if(Jh)return ks;Jh=1;var e=Pb(),t=Pr(),r=Bi(),n=r&&r.isMap,i=n?t(n):e;return ks=i,ks}var js,Qh;function Db(){if(Qh)return js;Qh=1;var e=Wt(),t=ft(),r="[object Set]";function n(i){return t(i)&&e(i)==r}return js=n,js}var Cs,Hh;function zb(){if(Hh)return Cs;Hh=1;var e=Db(),t=Pr(),r=Bi(),n=r&&r.isSet,i=n?t(n):e;return Cs=i,Cs}var Ps,ed;function td(){if(ed)return Ps;ed=1;var e=Tr(),t=Mi(),r=jr(),n=_b(),i=Nb(),s=lh(),a=dh(),o=Mb(),c=Sb(),f=Rh(),l=qb(),p=Wt(),v=Ib(),y=Cb(),x=Xh(),_=Pe(),b=Vt(),w=Lb(),E=it(),N=zb(),S=qt(),q=Ct(),A=1,j=2,I=4,D="[object Arguments]",z="[object Array]",$="[object Boolean]",V="[object Date]",Y="[object Error]",ee="[object Function]",J="[object GeneratorFunction]",ae="[object Map]",be="[object Number]",Z="[object Object]",ue="[object RegExp]",ge="[object Set]",le="[object String]",ie="[object Symbol]",_e="[object WeakMap]",G="[object ArrayBuffer]",P="[object DataView]",X="[object Float32Array]",te="[object Float64Array]",fe="[object Int8Array]",xe="[object Int16Array]",Ce="[object Int32Array]",Ke="[object Uint8Array]",Zt="[object Uint8ClampedArray]",Xe="[object Uint16Array]",$e="[object Uint32Array]",Ee={};Ee[D]=Ee[z]=Ee[G]=Ee[P]=Ee[$]=Ee[V]=Ee[X]=Ee[te]=Ee[fe]=Ee[xe]=Ee[Ce]=Ee[ae]=Ee[be]=Ee[Z]=Ee[ue]=Ee[ge]=Ee[le]=Ee[ie]=Ee[Ke]=Ee[Zt]=Ee[Xe]=Ee[$e]=!0,Ee[Y]=Ee[ee]=Ee[_e]=!1;function bt(Me,_t,Le,pc,Et,Ge){var Ue,ut=_t&A,Jt=_t&j,Xr=_t&I;if(Le&&(Ue=Et?Le(Me,pc,Et,Ge):Le(Me)),Ue!==void 0)return Ue;if(!E(Me))return Me;var Lt=_(Me);if(Lt){if(Ue=v(Me),!ut)return a(Me,Ue)}else{var Rt=p(Me),Zr=Rt==ee||Rt==J;if(b(Me))return s(Me,ut);if(Rt==Z||Rt==D||Zr&&!Et){if(Ue=Jt||Zr?{}:x(Me),!ut)return Jt?c(Me,i(Ue,Me)):o(Me,n(Ue,Me))}else{if(!Ee[Rt])return Et?Me:{};Ue=y(Me,Rt,ut)}}Ge||(Ge=new e);var Jr=Ge.get(Me);if(Jr)return Jr;Ge.set(Me,Ue),N(Me)?Me.forEach(function(lt){Ue.add(bt(lt,_t,Le,lt,Me,Ge))}):w(Me)&&Me.forEach(function(lt,ht){Ue.set(ht,bt(lt,_t,Le,ht,Me,Ge))});var vc=Xr?Jt?l:f:Jt?q:S,Qr=Lt?void 0:vc(Me);return t(Qr||Me,function(lt,ht){Qr&&(ht=lt,lt=Me[ht]),r(Ue,ht,bt(lt,_t,Le,ht,Me,Ge))}),Ue}return Ps=bt,Ps}var Ls,rd;function Fb(){if(rd)return Ls;rd=1;var e=td(),t=4;function r(n){return e(n,t)}return Ls=r,Ls}var Ds,nd;function zs(){if(nd)return Ds;nd=1;function e(t){return function(){return t}}return Ds=e,Ds}var Fs,id;function Bb(){if(id)return Fs;id=1;function e(t){return function(r,n,i){for(var s=-1,a=Object(r),o=i(r),c=o.length;c--;){var f=o[t?c:++s];if(n(a[f],f,a)===!1)break}return r}}return Fs=e,Fs}var Bs,sd;function $s(){if(sd)return Bs;sd=1;var e=Bb(),t=e();return Bs=t,Bs}var Gs,od;function Us(){if(od)return Gs;od=1;var e=$s(),t=qt();function r(n,i){return n&&e(n,i,t)}return Gs=r,Gs}var Vs,ad;function $b(){if(ad)return Vs;ad=1;var e=mt();function t(r,n){return function(i,s){if(i==null)return i;if(!e(i))return r(i,s);for(var a=i.length,o=n?a:-1,c=Object(i);(n?o--:++o<a)&&s(c[o],o,c)!==!1;);return i}}return Vs=t,Vs}var Ws,ud;function zr(){if(ud)return Ws;ud=1;var e=Us(),t=$b(),r=t(e);return Ws=r,Ws}var Ys,cd;function Pt(){if(cd)return Ys;cd=1;function e(t){return t}return Ys=e,Ys}var Ks,fd;function ld(){if(fd)return Ks;fd=1;var e=Pt();function t(r){return typeof r=="function"?r:e}return Ks=t,Ks}var Xs,hd;function dd(){if(hd)return Xs;hd=1;var e=Mi(),t=zr(),r=ld(),n=Pe();function i(s,a){var o=n(s)?e:t;return o(s,r(a))}return Xs=i,Xs}var Zs,gd;function pd(){return gd||(gd=1,Zs=dd()),Zs}var Js,vd;function Gb(){if(vd)return Js;vd=1;var e=zr();function t(r,n){var i=[];return e(r,function(s,a,o){n(s,a,o)&&i.push(s)}),i}return Js=t,Js}var Qs,md;function Ub(){if(md)return Qs;md=1;var e="__lodash_hash_undefined__";function t(r){return this.__data__.set(r,e),this}return Qs=t,Qs}var Hs,yd;function Vb(){if(yd)return Hs;yd=1;function e(t){return this.__data__.has(t)}return Hs=e,Hs}var eo,wd;function bd(){if(wd)return eo;wd=1;var e=_i(),t=Ub(),r=Vb();function n(i){var s=-1,a=i==null?0:i.length;for(this.__data__=new e;++s<a;)this.add(i[s])}return n.prototype.add=n.prototype.push=t,n.prototype.has=r,eo=n,eo}var to,_d;function Wb(){if(_d)return to;_d=1;function e(t,r){for(var n=-1,i=t==null?0:t.length;++n<i;)if(r(t[n],n,t))return!0;return!1}return to=e,to}var ro,Ed;function xd(){if(Ed)return ro;Ed=1;function e(t,r){return t.has(r)}return ro=e,ro}var no,Nd;function Md(){if(Nd)return no;Nd=1;var e=bd(),t=Wb(),r=xd(),n=1,i=2;function s(a,o,c,f,l,p){var v=c&n,y=a.length,x=o.length;if(y!=x&&!(v&&x>y))return!1;var _=p.get(a),b=p.get(o);if(_&&b)return _==o&&b==a;var w=-1,E=!0,N=c&i?new e:void 0;for(p.set(a,o),p.set(o,a);++w<y;){var S=a[w],q=o[w];if(f)var A=v?f(q,S,w,o,a,p):f(S,q,w,a,o,p);if(A!==void 0){if(A)continue;E=!1;break}if(N){if(!t(o,function(j,I){if(!r(N,I)&&(S===j||l(S,j,c,f,p)))return N.push(I)})){E=!1;break}}else if(!(S===q||l(S,q,c,f,p))){E=!1;break}}return p.delete(a),p.delete(o),E}return no=s,no}var io,Sd;function Yb(){if(Sd)return io;Sd=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(i,s){n[++r]=[s,i]}),n}return io=e,io}var so,qd;function oo(){if(qd)return so;qd=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(i){n[++r]=i}),n}return so=e,so}var ao,Rd;function Kb(){if(Rd)return ao;Rd=1;var e=Ut(),t=Dh(),r=Gt(),n=Md(),i=Yb(),s=oo(),a=1,o=2,c="[object Boolean]",f="[object Date]",l="[object Error]",p="[object Map]",v="[object Number]",y="[object RegExp]",x="[object Set]",_="[object String]",b="[object Symbol]",w="[object ArrayBuffer]",E="[object DataView]",N=e?e.prototype:void 0,S=N?N.valueOf:void 0;function q(A,j,I,D,z,$,V){switch(I){case E:if(A.byteLength!=j.byteLength||A.byteOffset!=j.byteOffset)return!1;A=A.buffer,j=j.buffer;case w:return!(A.byteLength!=j.byteLength||!$(new t(A),new t(j)));case c:case f:case v:return r(+A,+j);case l:return A.name==j.name&&A.message==j.message;case y:case _:return A==j+"";case p:var Y=i;case x:var ee=D&a;if(Y||(Y=s),A.size!=j.size&&!ee)return!1;var J=V.get(A);if(J)return J==j;D|=o,V.set(A,j);var ae=n(Y(A),Y(j),D,z,$,V);return V.delete(A),ae;case b:if(S)return S.call(A)==S.call(j)}return!1}return ao=q,ao}var uo,Od;function Xb(){if(Od)return uo;Od=1;var e=Rh(),t=1,r=Object.prototype,n=r.hasOwnProperty;function i(s,a,o,c,f,l){var p=o&t,v=e(s),y=v.length,x=e(a),_=x.length;if(y!=_&&!p)return!1;for(var b=y;b--;){var w=v[b];if(!(p?w in a:n.call(a,w)))return!1}var E=l.get(s),N=l.get(a);if(E&&N)return E==a&&N==s;var S=!0;l.set(s,a),l.set(a,s);for(var q=p;++b<y;){w=v[b];var A=s[w],j=a[w];if(c)var I=p?c(j,A,w,a,s,l):c(A,j,w,s,a,l);if(!(I===void 0?A===j||f(A,j,o,c,l):I)){S=!1;break}q||(q=w=="constructor")}if(S&&!q){var D=s.constructor,z=a.constructor;D!=z&&"constructor"in s&&"constructor"in a&&!(typeof D=="function"&&D instanceof D&&typeof z=="function"&&z instanceof z)&&(S=!1)}return l.delete(s),l.delete(a),S}return uo=i,uo}var co,Ad;function Zb(){if(Ad)return co;Ad=1;var e=Tr(),t=Md(),r=Kb(),n=Xb(),i=Wt(),s=Pe(),a=Vt(),o=lr(),c=1,f="[object Arguments]",l="[object Array]",p="[object Object]",v=Object.prototype,y=v.hasOwnProperty;function x(_,b,w,E,N,S){var q=s(_),A=s(b),j=q?l:i(_),I=A?l:i(b);j=j==f?p:j,I=I==f?p:I;var D=j==p,z=I==p,$=j==I;if($&&a(_)){if(!a(b))return!1;q=!0,D=!1}if($&&!D)return S||(S=new e),q||o(_)?t(_,b,w,E,N,S):r(_,b,j,w,E,N,S);if(!(w&c)){var V=D&&y.call(_,"__wrapped__"),Y=z&&y.call(b,"__wrapped__");if(V||Y){var ee=V?_.value():_,J=Y?b.value():b;return S||(S=new e),N(ee,J,w,E,S)}}return $?(S||(S=new e),n(_,b,w,E,N,S)):!1}return co=x,co}var fo,Id;function Td(){if(Id)return fo;Id=1;var e=Zb(),t=ft();function r(n,i,s,a,o){return n===i?!0:n==null||i==null||!t(n)&&!t(i)?n!==n&&i!==i:e(n,i,s,a,r,o)}return fo=r,fo}var lo,kd;function Jb(){if(kd)return lo;kd=1;var e=Tr(),t=Td(),r=1,n=2;function i(s,a,o,c){var f=o.length,l=f,p=!c;if(s==null)return!l;for(s=Object(s);f--;){var v=o[f];if(p&&v[2]?v[1]!==s[v[0]]:!(v[0]in s))return!1}for(;++f<l;){v=o[f];var y=v[0],x=s[y],_=v[1];if(p&&v[2]){if(x===void 0&&!(y in s))return!1}else{var b=new e;if(c)var w=c(x,_,y,s,a,b);if(!(w===void 0?t(_,x,r|n,c,b):w))return!1}}return!0}return lo=i,lo}var ho,jd;function Cd(){if(jd)return ho;jd=1;var e=it();function t(r){return r===r&&!e(r)}return ho=t,ho}var go,Pd;function Qb(){if(Pd)return go;Pd=1;var e=Cd(),t=qt();function r(n){for(var i=t(n),s=i.length;s--;){var a=i[s],o=n[a];i[s]=[a,o,e(o)]}return i}return go=r,go}var po,Ld;function Dd(){if(Ld)return po;Ld=1;function e(t,r){return function(n){return n==null?!1:n[t]===r&&(r!==void 0||t in Object(n))}}return po=e,po}var vo,zd;function Hb(){if(zd)return vo;zd=1;var e=Jb(),t=Qb(),r=Dd();function n(i){var s=t(i);return s.length==1&&s[0][2]?r(s[0][0],s[0][1]):function(a){return a===i||e(a,i,s)}}return vo=n,vo}var mo,Fd;function Yt(){if(Fd)return mo;Fd=1;var e=kt(),t=ft(),r="[object Symbol]";function n(i){return typeof i=="symbol"||t(i)&&e(i)==r}return mo=n,mo}var yo,Bd;function wo(){if(Bd)return yo;Bd=1;var e=Pe(),t=Yt(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function i(s,a){if(e(s))return!1;var o=typeof s;return o=="number"||o=="symbol"||o=="boolean"||s==null||t(s)?!0:n.test(s)||!r.test(s)||a!=null&&s in Object(a)}return yo=i,yo}var bo,$d;function e_(){if($d)return bo;$d=1;var e=_i(),t="Expected a function";function r(n,i){if(typeof n!="function"||i!=null&&typeof i!="function")throw new TypeError(t);var s=function(){var a=arguments,o=i?i.apply(this,a):a[0],c=s.cache;if(c.has(o))return c.get(o);var f=n.apply(this,a);return s.cache=c.set(o,f)||c,f};return s.cache=new(r.Cache||e),s}return r.Cache=e,bo=r,bo}var _o,Gd;function t_(){if(Gd)return _o;Gd=1;var e=e_(),t=500;function r(n){var i=e(n,function(a){return s.size===t&&s.clear(),a}),s=i.cache;return i}return _o=r,_o}var Eo,Ud;function r_(){if(Ud)return Eo;Ud=1;var e=t_(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(i){var s=[];return i.charCodeAt(0)===46&&s.push(""),i.replace(t,function(a,o,c,f){s.push(c?f.replace(r,"$1"):o||a)}),s});return Eo=n,Eo}var xo,Vd;function Fr(){if(Vd)return xo;Vd=1;function e(t,r){for(var n=-1,i=t==null?0:t.length,s=Array(i);++n<i;)s[n]=r(t[n],n,t);return s}return xo=e,xo}var No,Wd;function n_(){if(Wd)return No;Wd=1;var e=Ut(),t=Fr(),r=Pe(),n=Yt(),i=e?e.prototype:void 0,s=i?i.toString:void 0;function a(o){if(typeof o=="string")return o;if(r(o))return t(o,a)+"";if(n(o))return s?s.call(o):"";var c=o+"";return c=="0"&&1/o==-1/0?"-0":c}return No=a,No}var Mo,Yd;function Kd(){if(Yd)return Mo;Yd=1;var e=n_();function t(r){return r==null?"":e(r)}return Mo=t,Mo}var So,Xd;function Br(){if(Xd)return So;Xd=1;var e=Pe(),t=wo(),r=r_(),n=Kd();function i(s,a){return e(s)?s:t(s,a)?[s]:r(n(s))}return So=i,So}var qo,Zd;function dr(){if(Zd)return qo;Zd=1;var e=Yt();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return qo=t,qo}var Ro,Jd;function $r(){if(Jd)return Ro;Jd=1;var e=Br(),t=dr();function r(n,i){i=e(i,n);for(var s=0,a=i.length;n!=null&&s<a;)n=n[t(i[s++])];return s&&s==a?n:void 0}return Ro=r,Ro}var Oo,Qd;function i_(){if(Qd)return Oo;Qd=1;var e=$r();function t(r,n,i){var s=r==null?void 0:e(r,n);return s===void 0?i:s}return Oo=t,Oo}var Ao,Hd;function s_(){if(Hd)return Ao;Hd=1;function e(t,r){return t!=null&&r in Object(t)}return Ao=e,Ao}var Io,eg;function tg(){if(eg)return Io;eg=1;var e=Br(),t=ur(),r=Pe(),n=Cr(),i=Di(),s=dr();function a(o,c,f){c=e(c,o);for(var l=-1,p=c.length,v=!1;++l<p;){var y=s(c[l]);if(!(v=o!=null&&f(o,y)))break;o=o[y]}return v||++l!=p?v:(p=o==null?0:o.length,!!p&&i(p)&&n(y,p)&&(r(o)||t(o)))}return Io=a,Io}var To,rg;function ng(){if(rg)return To;rg=1;var e=s_(),t=tg();function r(n,i){return n!=null&&t(n,i,e)}return To=r,To}var ko,ig;function o_(){if(ig)return ko;ig=1;var e=Td(),t=i_(),r=ng(),n=wo(),i=Cd(),s=Dd(),a=dr(),o=1,c=2;function f(l,p){return n(l)&&i(p)?s(a(l),p):function(v){var y=t(v,l);return y===void 0&&y===p?r(v,l):e(p,y,o|c)}}return ko=f,ko}var jo,sg;function og(){if(sg)return jo;sg=1;function e(t){return function(r){return r?.[t]}}return jo=e,jo}var Co,ag;function a_(){if(ag)return Co;ag=1;var e=$r();function t(r){return function(n){return e(n,r)}}return Co=t,Co}var Po,ug;function u_(){if(ug)return Po;ug=1;var e=og(),t=a_(),r=wo(),n=dr();function i(s){return r(s)?e(n(s)):t(s)}return Po=i,Po}var Lo,cg;function yt(){if(cg)return Lo;cg=1;var e=Hb(),t=o_(),r=Pt(),n=Pe(),i=u_();function s(a){return typeof a=="function"?a:a==null?r:typeof a=="object"?n(a)?t(a[0],a[1]):e(a):i(a)}return Lo=s,Lo}var Do,fg;function lg(){if(fg)return Do;fg=1;var e=ph(),t=Gb(),r=yt(),n=Pe();function i(s,a){var o=n(s)?e:t;return o(s,r(a,3))}return Do=i,Do}var zo,hg;function c_(){if(hg)return zo;hg=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n,i){return n!=null&&t.call(n,i)}return zo=r,zo}var Fo,dg;function gg(){if(dg)return Fo;dg=1;var e=c_(),t=tg();function r(n,i){return n!=null&&t(n,i,e)}return Fo=r,Fo}var Bo,pg;function f_(){if(pg)return Bo;pg=1;var e=Ki(),t=Wt(),r=ur(),n=Pe(),i=mt(),s=Vt(),a=Lr(),o=lr(),c="[object Map]",f="[object Set]",l=Object.prototype,p=l.hasOwnProperty;function v(y){if(y==null)return!0;if(i(y)&&(n(y)||typeof y=="string"||typeof y.splice=="function"||s(y)||o(y)||r(y)))return!y.length;var x=t(y);if(x==c||x==f)return!y.size;if(a(y))return!e(y).length;for(var _ in y)if(p.call(y,_))return!1;return!0}return Bo=v,Bo}var $o,vg;function mg(){if(vg)return $o;vg=1;function e(t){return t===void 0}return $o=e,$o}var Go,yg;function wg(){if(yg)return Go;yg=1;var e=zr(),t=mt();function r(n,i){var s=-1,a=t(n)?Array(n.length):[];return e(n,function(o,c,f){a[++s]=i(o,c,f)}),a}return Go=r,Go}var Uo,bg;function _g(){if(bg)return Uo;bg=1;var e=Fr(),t=yt(),r=wg(),n=Pe();function i(s,a){var o=n(s)?e:r;return o(s,t(a,3))}return Uo=i,Uo}var Vo,Eg;function l_(){if(Eg)return Vo;Eg=1;function e(t,r,n,i){var s=-1,a=t==null?0:t.length;for(i&&a&&(n=t[++s]);++s<a;)n=r(n,t[s],s,t);return n}return Vo=e,Vo}var Wo,xg;function h_(){if(xg)return Wo;xg=1;function e(t,r,n,i,s){return s(t,function(a,o,c){n=i?(i=!1,a):r(n,a,o,c)}),n}return Wo=e,Wo}var Yo,Ng;function Mg(){if(Ng)return Yo;Ng=1;var e=l_(),t=zr(),r=yt(),n=h_(),i=Pe();function s(a,o,c){var f=i(a)?e:n,l=arguments.length<3;return f(a,r(o,4),c,l,t)}return Yo=s,Yo}var Ko,Sg;function d_(){if(Sg)return Ko;Sg=1;var e=kt(),t=Pe(),r=ft(),n="[object String]";function i(s){return typeof s=="string"||!t(s)&&r(s)&&e(s)==n}return Ko=i,Ko}var Xo,qg;function g_(){if(qg)return Xo;qg=1;var e=og(),t=e("length");return Xo=t,Xo}var Zo,Rg;function p_(){if(Rg)return Zo;Rg=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",i=t+r+n,s="\\ufe0e\\ufe0f",a="\\u200d",o=RegExp("["+a+e+i+s+"]");function c(f){return o.test(f)}return Zo=c,Zo}var Jo,Og;function v_(){if(Og)return Jo;Og=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",i=t+r+n,s="\\ufe0e\\ufe0f",a="["+e+"]",o="["+i+"]",c="\\ud83c[\\udffb-\\udfff]",f="(?:"+o+"|"+c+")",l="[^"+e+"]",p="(?:\\ud83c[\\udde6-\\uddff]){2}",v="[\\ud800-\\udbff][\\udc00-\\udfff]",y="\\u200d",x=f+"?",_="["+s+"]?",b="(?:"+y+"(?:"+[l,p,v].join("|")+")"+_+x+")*",w=_+x+b,E="(?:"+[l+o+"?",o,p,v,a].join("|")+")",N=RegExp(c+"(?="+c+")|"+E+w,"g");function S(q){for(var A=N.lastIndex=0;N.test(q);)++A;return A}return Jo=S,Jo}var Qo,Ag;function m_(){if(Ag)return Qo;Ag=1;var e=g_(),t=p_(),r=v_();function n(i){return t(i)?r(i):e(i)}return Qo=n,Qo}var Ho,Ig;function y_(){if(Ig)return Ho;Ig=1;var e=Ki(),t=Wt(),r=mt(),n=d_(),i=m_(),s="[object Map]",a="[object Set]";function o(c){if(c==null)return 0;if(r(c))return n(c)?i(c):c.length;var f=t(c);return f==s||f==a?c.size:e(c).length}return Ho=o,Ho}var ea,Tg;function w_(){if(Tg)return ea;Tg=1;var e=Mi(),t=Yh(),r=Us(),n=yt(),i=Dr(),s=Pe(),a=Vt(),o=or(),c=it(),f=lr();function l(p,v,y){var x=s(p),_=x||a(p)||f(p);if(v=n(v,4),y==null){var b=p&&p.constructor;_?y=x?new b:[]:c(p)?y=o(b)?t(i(p)):{}:y={}}return(_?e:r)(p,function(w,E,N){return v(y,w,E,N)}),y}return ea=l,ea}var ta,kg;function b_(){if(kg)return ta;kg=1;var e=Ut(),t=ur(),r=Pe(),n=e?e.isConcatSpreadable:void 0;function i(s){return r(s)||t(s)||!!(n&&s&&s[n])}return ta=i,ta}var ra,jg;function na(){if(jg)return ra;jg=1;var e=cs(),t=b_();function r(n,i,s,a,o){var c=-1,f=n.length;for(s||(s=t),o||(o=[]);++c<f;){var l=n[c];i>0&&s(l)?i>1?r(l,i-1,s,a,o):e(o,l):a||(o[o.length]=l)}return o}return ra=r,ra}var ia,Cg;function __(){if(Cg)return ia;Cg=1;function e(t,r,n){switch(n.length){case 0:return t.call(r);case 1:return t.call(r,n[0]);case 2:return t.call(r,n[0],n[1]);case 3:return t.call(r,n[0],n[1],n[2])}return t.apply(r,n)}return ia=e,ia}var sa,Pg;function Lg(){if(Pg)return sa;Pg=1;var e=__(),t=Math.max;function r(n,i,s){return i=t(i===void 0?n.length-1:i,0),function(){for(var a=arguments,o=-1,c=t(a.length-i,0),f=Array(c);++o<c;)f[o]=a[i+o];o=-1;for(var l=Array(i+1);++o<i;)l[o]=a[o];return l[i]=s(f),e(n,this,l)}}return sa=r,sa}var oa,Dg;function E_(){if(Dg)return oa;Dg=1;var e=zs(),t=kl(),r=Pt(),n=t?function(i,s){return t(i,"toString",{configurable:!0,enumerable:!1,value:e(s),writable:!0})}:r;return oa=n,oa}var aa,zg;function x_(){if(zg)return aa;zg=1;var e=800,t=16,r=Date.now;function n(i){var s=0,a=0;return function(){var o=r(),c=t-(o-a);if(a=o,c>0){if(++s>=e)return arguments[0]}else s=0;return i.apply(void 0,arguments)}}return aa=n,aa}var ua,Fg;function Bg(){if(Fg)return ua;Fg=1;var e=E_(),t=x_(),r=t(e);return ua=r,ua}var ca,$g;function Gr(){if($g)return ca;$g=1;var e=Pt(),t=Lg(),r=Bg();function n(i,s){return r(t(i,s,e),i+"")}return ca=n,ca}var fa,Gg;function Ug(){if(Gg)return fa;Gg=1;function e(t,r,n,i){for(var s=t.length,a=n+(i?1:-1);i?a--:++a<s;)if(r(t[a],a,t))return a;return-1}return fa=e,fa}var la,Vg;function N_(){if(Vg)return la;Vg=1;function e(t){return t!==t}return la=e,la}var ha,Wg;function M_(){if(Wg)return ha;Wg=1;function e(t,r,n){for(var i=n-1,s=t.length;++i<s;)if(t[i]===r)return i;return-1}return ha=e,ha}var da,Yg;function S_(){if(Yg)return da;Yg=1;var e=Ug(),t=N_(),r=M_();function n(i,s,a){return s===s?r(i,s,a):e(i,t,a)}return da=n,da}var ga,Kg;function q_(){if(Kg)return ga;Kg=1;var e=S_();function t(r,n){var i=r==null?0:r.length;return!!i&&e(r,n,0)>-1}return ga=t,ga}var pa,Xg;function R_(){if(Xg)return pa;Xg=1;function e(t,r,n){for(var i=-1,s=t==null?0:t.length;++i<s;)if(n(r,t[i]))return!0;return!1}return pa=e,pa}var va,Zg;function O_(){if(Zg)return va;Zg=1;function e(){}return va=e,va}var ma,Jg;function A_(){if(Jg)return ma;Jg=1;var e=kh(),t=O_(),r=oo(),n=1/0,i=e&&1/r(new e([,-0]))[1]==n?function(s){return new e(s)}:t;return ma=i,ma}var ya,Qg;function I_(){if(Qg)return ya;Qg=1;var e=bd(),t=q_(),r=R_(),n=xd(),i=A_(),s=oo(),a=200;function o(c,f,l){var p=-1,v=t,y=c.length,x=!0,_=[],b=_;if(l)x=!1,v=r;else if(y>=a){var w=f?null:i(c);if(w)return s(w);x=!1,v=n,b=new e}else b=f?[]:_;e:for(;++p<y;){var E=c[p],N=f?f(E):E;if(E=l||E!==0?E:0,x&&N===N){for(var S=b.length;S--;)if(b[S]===N)continue e;f&&b.push(N),_.push(E)}else v(b,N,l)||(b!==_&&b.push(N),_.push(E))}return _}return ya=o,ya}var wa,Hg;function ep(){if(Hg)return wa;Hg=1;var e=mt(),t=ft();function r(n){return t(n)&&e(n)}return wa=r,wa}var ba,tp;function T_(){if(tp)return ba;tp=1;var e=na(),t=Gr(),r=I_(),n=ep(),i=t(function(s){return r(e(s,1,n,!0))});return ba=i,ba}var _a,rp;function k_(){if(rp)return _a;rp=1;var e=Fr();function t(r,n){return e(n,function(i){return r[i]})}return _a=t,_a}var Ea,np;function ip(){if(np)return Ea;np=1;var e=k_(),t=qt();function r(n){return n==null?[]:e(n,t(n))}return Ea=r,Ea}var xa,sp;function st(){if(sp)return xa;sp=1;var e;if(typeof In=="function")try{e={clone:Fb(),constant:zs(),each:pd(),filter:lg(),has:gg(),isArray:Pe(),isEmpty:f_(),isFunction:or(),isUndefined:mg(),keys:qt(),map:_g(),reduce:Mg(),size:y_(),transform:w_(),union:T_(),values:ip()}}catch{}return e||(e=window._),xa=e,xa}var Na,op;function Ma(){if(op)return Na;op=1;var e=st();Na=i;var t="\0",r="\0",n="";function i(l){this._isDirected=e.has(l,"directed")?l.directed:!0,this._isMultigraph=e.has(l,"multigraph")?l.multigraph:!1,this._isCompound=e.has(l,"compound")?l.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[r]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}i.prototype._nodeCount=0,i.prototype._edgeCount=0,i.prototype.isDirected=function(){return this._isDirected},i.prototype.isMultigraph=function(){return this._isMultigraph},i.prototype.isCompound=function(){return this._isCompound},i.prototype.setGraph=function(l){return this._label=l,this},i.prototype.graph=function(){return this._label},i.prototype.setDefaultNodeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultNodeLabelFn=l,this},i.prototype.nodeCount=function(){return this._nodeCount},i.prototype.nodes=function(){return e.keys(this._nodes)},i.prototype.sources=function(){var l=this;return e.filter(this.nodes(),function(p){return e.isEmpty(l._in[p])})},i.prototype.sinks=function(){var l=this;return e.filter(this.nodes(),function(p){return e.isEmpty(l._out[p])})},i.prototype.setNodes=function(l,p){var v=arguments,y=this;return e.each(l,function(x){v.length>1?y.setNode(x,p):y.setNode(x)}),this},i.prototype.setNode=function(l,p){return e.has(this._nodes,l)?(arguments.length>1&&(this._nodes[l]=p),this):(this._nodes[l]=arguments.length>1?p:this._defaultNodeLabelFn(l),this._isCompound&&(this._parent[l]=r,this._children[l]={},this._children[r][l]=!0),this._in[l]={},this._preds[l]={},this._out[l]={},this._sucs[l]={},++this._nodeCount,this)},i.prototype.node=function(l){return this._nodes[l]},i.prototype.hasNode=function(l){return e.has(this._nodes,l)},i.prototype.removeNode=function(l){var p=this;if(e.has(this._nodes,l)){var v=function(y){p.removeEdge(p._edgeObjs[y])};delete this._nodes[l],this._isCompound&&(this._removeFromParentsChildList(l),delete this._parent[l],e.each(this.children(l),function(y){p.setParent(y)}),delete this._children[l]),e.each(e.keys(this._in[l]),v),delete this._in[l],delete this._preds[l],e.each(e.keys(this._out[l]),v),delete this._out[l],delete this._sucs[l],--this._nodeCount}return this},i.prototype.setParent=function(l,p){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(p))p=r;else{p+="";for(var v=p;!e.isUndefined(v);v=this.parent(v))if(v===l)throw new Error("Setting "+p+" as parent of "+l+" would create a cycle");this.setNode(p)}return this.setNode(l),this._removeFromParentsChildList(l),this._parent[l]=p,this._children[p][l]=!0,this},i.prototype._removeFromParentsChildList=function(l){delete this._children[this._parent[l]][l]},i.prototype.parent=function(l){if(this._isCompound){var p=this._parent[l];if(p!==r)return p}},i.prototype.children=function(l){if(e.isUndefined(l)&&(l=r),this._isCompound){var p=this._children[l];if(p)return e.keys(p)}else{if(l===r)return this.nodes();if(this.hasNode(l))return[]}},i.prototype.predecessors=function(l){var p=this._preds[l];if(p)return e.keys(p)},i.prototype.successors=function(l){var p=this._sucs[l];if(p)return e.keys(p)},i.prototype.neighbors=function(l){var p=this.predecessors(l);if(p)return e.union(p,this.successors(l))},i.prototype.isLeaf=function(l){var p;return this.isDirected()?p=this.successors(l):p=this.neighbors(l),p.length===0},i.prototype.filterNodes=function(l){var p=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});p.setGraph(this.graph());var v=this;e.each(this._nodes,function(_,b){l(b)&&p.setNode(b,_)}),e.each(this._edgeObjs,function(_){p.hasNode(_.v)&&p.hasNode(_.w)&&p.setEdge(_,v.edge(_))});var y={};function x(_){var b=v.parent(_);return b===void 0||p.hasNode(b)?(y[_]=b,b):b in y?y[b]:x(b)}return this._isCompound&&e.each(p.nodes(),function(_){p.setParent(_,x(_))}),p},i.prototype.setDefaultEdgeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultEdgeLabelFn=l,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return e.values(this._edgeObjs)},i.prototype.setPath=function(l,p){var v=this,y=arguments;return e.reduce(l,function(x,_){return y.length>1?v.setEdge(x,_,p):v.setEdge(x,_),_}),this},i.prototype.setEdge=function(){var l,p,v,y,x=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(l=_.v,p=_.w,v=_.name,arguments.length===2&&(y=arguments[1],x=!0)):(l=_,p=arguments[1],v=arguments[3],arguments.length>2&&(y=arguments[2],x=!0)),l=""+l,p=""+p,e.isUndefined(v)||(v=""+v);var b=o(this._isDirected,l,p,v);if(e.has(this._edgeLabels,b))return x&&(this._edgeLabels[b]=y),this;if(!e.isUndefined(v)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(l),this.setNode(p),this._edgeLabels[b]=x?y:this._defaultEdgeLabelFn(l,p,v);var w=c(this._isDirected,l,p,v);return l=w.v,p=w.w,Object.freeze(w),this._edgeObjs[b]=w,s(this._preds[p],l),s(this._sucs[l],p),this._in[p][b]=w,this._out[l][b]=w,this._edgeCount++,this},i.prototype.edge=function(l,p,v){var y=arguments.length===1?f(this._isDirected,arguments[0]):o(this._isDirected,l,p,v);return this._edgeLabels[y]},i.prototype.hasEdge=function(l,p,v){var y=arguments.length===1?f(this._isDirected,arguments[0]):o(this._isDirected,l,p,v);return e.has(this._edgeLabels,y)},i.prototype.removeEdge=function(l,p,v){var y=arguments.length===1?f(this._isDirected,arguments[0]):o(this._isDirected,l,p,v),x=this._edgeObjs[y];return x&&(l=x.v,p=x.w,delete this._edgeLabels[y],delete this._edgeObjs[y],a(this._preds[p],l),a(this._sucs[l],p),delete this._in[p][y],delete this._out[l][y],this._edgeCount--),this},i.prototype.inEdges=function(l,p){var v=this._in[l];if(v){var y=e.values(v);return p?e.filter(y,function(x){return x.v===p}):y}},i.prototype.outEdges=function(l,p){var v=this._out[l];if(v){var y=e.values(v);return p?e.filter(y,function(x){return x.w===p}):y}},i.prototype.nodeEdges=function(l,p){var v=this.inEdges(l,p);if(v)return v.concat(this.outEdges(l,p))};function s(l,p){l[p]?l[p]++:l[p]=1}function a(l,p){--l[p]||delete l[p]}function o(l,p,v,y){var x=""+p,_=""+v;if(!l&&x>_){var b=x;x=_,_=b}return x+n+_+n+(e.isUndefined(y)?t:y)}function c(l,p,v,y){var x=""+p,_=""+v;if(!l&&x>_){var b=x;x=_,_=b}var w={v:x,w:_};return y&&(w.name=y),w}function f(l,p){return o(l,p.v,p.w,p.name)}return Na}var Sa,ap;function j_(){return ap||(ap=1,Sa="2.1.8"),Sa}var qa,up;function C_(){return up||(up=1,qa={Graph:Ma(),version:j_()}),qa}var Ra,cp;function P_(){if(cp)return Ra;cp=1;var e=st(),t=Ma();Ra={write:r,read:s};function r(a){var o={options:{directed:a.isDirected(),multigraph:a.isMultigraph(),compound:a.isCompound()},nodes:n(a),edges:i(a)};return e.isUndefined(a.graph())||(o.value=e.clone(a.graph())),o}function n(a){return e.map(a.nodes(),function(o){var c=a.node(o),f=a.parent(o),l={v:o};return e.isUndefined(c)||(l.value=c),e.isUndefined(f)||(l.parent=f),l})}function i(a){return e.map(a.edges(),function(o){var c=a.edge(o),f={v:o.v,w:o.w};return e.isUndefined(o.name)||(f.name=o.name),e.isUndefined(c)||(f.value=c),f})}function s(a){var o=new t(a.options).setGraph(a.value);return e.each(a.nodes,function(c){o.setNode(c.v,c.value),c.parent&&o.setParent(c.v,c.parent)}),e.each(a.edges,function(c){o.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),o}return Ra}var Oa,fp;function L_(){if(fp)return Oa;fp=1;var e=st();Oa=t;function t(r){var n={},i=[],s;function a(o){e.has(n,o)||(n[o]=!0,s.push(o),e.each(r.successors(o),a),e.each(r.predecessors(o),a))}return e.each(r.nodes(),function(o){s=[],a(o),s.length&&i.push(s)}),i}return Oa}var Aa,lp;function hp(){if(lp)return Aa;lp=1;var e=st();Aa=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(r){return r.key})},t.prototype.has=function(r){return e.has(this._keyIndices,r)},t.prototype.priority=function(r){var n=this._keyIndices[r];if(n!==void 0)return this._arr[n].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(r,n){var i=this._keyIndices;if(r=String(r),!e.has(i,r)){var s=this._arr,a=s.length;return i[r]=a,s.push({key:r,priority:n}),this._decrease(a),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key},t.prototype.decrease=function(r,n){var i=this._keyIndices[r];if(n>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[i].priority+" New: "+n);this._arr[i].priority=n,this._decrease(i)},t.prototype._heapify=function(r){var n=this._arr,i=2*r,s=i+1,a=r;i<n.length&&(a=n[i].priority<n[a].priority?i:a,s<n.length&&(a=n[s].priority<n[a].priority?s:a),a!==r&&(this._swap(r,a),this._heapify(a)))},t.prototype._decrease=function(r){for(var n=this._arr,i=n[r].priority,s;r!==0&&(s=r>>1,!(n[s].priority<i));)this._swap(r,s),r=s},t.prototype._swap=function(r,n){var i=this._arr,s=this._keyIndices,a=i[r],o=i[n];i[r]=o,i[n]=a,s[o.key]=r,s[a.key]=n},Aa}var Ia,dp;function gp(){if(dp)return Ia;dp=1;var e=st(),t=hp();Ia=n;var r=e.constant(1);function n(s,a,o,c){return i(s,String(a),o||r,c||function(f){return s.outEdges(f)})}function i(s,a,o,c){var f={},l=new t,p,v,y=function(x){var _=x.v!==p?x.v:x.w,b=f[_],w=o(x),E=v.distance+w;if(w<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+x+" Weight: "+w);E<b.distance&&(b.distance=E,b.predecessor=p,l.decrease(_,E))};for(s.nodes().forEach(function(x){var _=x===a?0:Number.POSITIVE_INFINITY;f[x]={distance:_},l.add(x,_)});l.size()>0&&(p=l.removeMin(),v=f[p],v.distance!==Number.POSITIVE_INFINITY);)c(p).forEach(y);return f}return Ia}var Ta,pp;function D_(){if(pp)return Ta;pp=1;var e=gp(),t=st();Ta=r;function r(n,i,s){return t.transform(n.nodes(),function(a,o){a[o]=e(n,o,i,s)},{})}return Ta}var ka,vp;function mp(){if(vp)return ka;vp=1;var e=st();ka=t;function t(r){var n=0,i=[],s={},a=[];function o(c){var f=s[c]={onStack:!0,lowlink:n,index:n++};if(i.push(c),r.successors(c).forEach(function(v){e.has(s,v)?s[v].onStack&&(f.lowlink=Math.min(f.lowlink,s[v].index)):(o(v),f.lowlink=Math.min(f.lowlink,s[v].lowlink))}),f.lowlink===f.index){var l=[],p;do p=i.pop(),s[p].onStack=!1,l.push(p);while(c!==p);a.push(l)}}return r.nodes().forEach(function(c){e.has(s,c)||o(c)}),a}return ka}var ja,yp;function z_(){if(yp)return ja;yp=1;var e=st(),t=mp();ja=r;function r(n){return e.filter(t(n),function(i){return i.length>1||i.length===1&&n.hasEdge(i[0],i[0])})}return ja}var Ca,wp;function F_(){if(wp)return Ca;wp=1;var e=st();Ca=r;var t=e.constant(1);function r(i,s,a){return n(i,s||t,a||function(o){return i.outEdges(o)})}function n(i,s,a){var o={},c=i.nodes();return c.forEach(function(f){o[f]={},o[f][f]={distance:0},c.forEach(function(l){f!==l&&(o[f][l]={distance:Number.POSITIVE_INFINITY})}),a(f).forEach(function(l){var p=l.v===f?l.w:l.v,v=s(l);o[f][p]={distance:v,predecessor:f}})}),c.forEach(function(f){var l=o[f];c.forEach(function(p){var v=o[p];c.forEach(function(y){var x=v[f],_=l[y],b=v[y],w=x.distance+_.distance;w<b.distance&&(b.distance=w,b.predecessor=_.predecessor)})})}),o}return Ca}var Pa,bp;function _p(){if(bp)return Pa;bp=1;var e=st();Pa=t,t.CycleException=r;function t(n){var i={},s={},a=[];function o(c){if(e.has(s,c))throw new r;e.has(i,c)||(s[c]=!0,i[c]=!0,e.each(n.predecessors(c),o),delete s[c],a.push(c))}if(e.each(n.sinks(),o),e.size(i)!==n.nodeCount())throw new r;return a}function r(){}return r.prototype=new Error,Pa}var La,Ep;function B_(){if(Ep)return La;Ep=1;var e=_p();La=t;function t(r){try{e(r)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return La}var Da,xp;function Np(){if(xp)return Da;xp=1;var e=st();Da=t;function t(n,i,s){e.isArray(i)||(i=[i]);var a=(n.isDirected()?n.successors:n.neighbors).bind(n),o=[],c={};return e.each(i,function(f){if(!n.hasNode(f))throw new Error("Graph does not have node: "+f);r(n,f,s==="post",c,a,o)}),o}function r(n,i,s,a,o,c){e.has(a,i)||(a[i]=!0,s||c.push(i),e.each(o(i),function(f){r(n,f,s,a,o,c)}),s&&c.push(i))}return Da}var za,Mp;function $_(){if(Mp)return za;Mp=1;var e=Np();za=t;function t(r,n){return e(r,n,"post")}return za}var Fa,Sp;function G_(){if(Sp)return Fa;Sp=1;var e=Np();Fa=t;function t(r,n){return e(r,n,"pre")}return Fa}var Ba,qp;function U_(){if(qp)return Ba;qp=1;var e=st(),t=Ma(),r=hp();Ba=n;function n(i,s){var a=new t,o={},c=new r,f;function l(v){var y=v.v===f?v.w:v.v,x=c.priority(y);if(x!==void 0){var _=s(v);_<x&&(o[y]=f,c.decrease(y,_))}}if(i.nodeCount()===0)return a;e.each(i.nodes(),function(v){c.add(v,Number.POSITIVE_INFINITY),a.setNode(v)}),c.decrease(i.nodes()[0],0);for(var p=!1;c.size()>0;){if(f=c.removeMin(),e.has(o,f))a.setEdge(f,o[f]);else{if(p)throw new Error("Input graph is not connected: "+i);p=!0}i.nodeEdges(f).forEach(l)}return a}return Ba}var $a,Rp;function V_(){return Rp||(Rp=1,$a={components:L_(),dijkstra:gp(),dijkstraAll:D_(),findCycles:z_(),floydWarshall:F_(),isAcyclic:B_(),postorder:$_(),preorder:G_(),prim:U_(),tarjan:mp(),topsort:_p()}),$a}var Ga,Op;function W_(){if(Op)return Ga;Op=1;var e=C_();return Ga={Graph:e.Graph,json:P_(),alg:V_(),version:e.version},Ga}var Ua,Ap;function at(){if(Ap)return Ua;Ap=1;var e;if(typeof In=="function")try{e=W_()}catch{}return e||(e=window.graphlib),Ua=e,Ua}var Va,Ip;function Y_(){if(Ip)return Va;Ip=1;var e=td(),t=1,r=4;function n(i){return e(i,t|r)}return Va=n,Va}var Wa,Tp;function Ur(){if(Tp)return Wa;Tp=1;var e=Gt(),t=mt(),r=Cr(),n=it();function i(s,a,o){if(!n(o))return!1;var c=typeof a;return(c=="number"?t(o)&&r(a,o.length):c=="string"&&a in o)?e(o[a],s):!1}return Wa=i,Wa}var Ya,kp;function K_(){if(kp)return Ya;kp=1;var e=Gr(),t=Gt(),r=Ur(),n=Ct(),i=Object.prototype,s=i.hasOwnProperty,a=e(function(o,c){o=Object(o);var f=-1,l=c.length,p=l>2?c[2]:void 0;for(p&&r(c[0],c[1],p)&&(l=1);++f<l;)for(var v=c[f],y=n(v),x=-1,_=y.length;++x<_;){var b=y[x],w=o[b];(w===void 0||t(w,i[b])&&!s.call(o,b))&&(o[b]=v[b])}return o});return Ya=a,Ya}var Ka,jp;function X_(){if(jp)return Ka;jp=1;var e=yt(),t=mt(),r=qt();function n(i){return function(s,a,o){var c=Object(s);if(!t(s)){var f=e(a,3);s=r(s),a=function(p){return f(c[p],p,c)}}var l=i(s,a,o);return l>-1?c[f?s[l]:l]:void 0}}return Ka=n,Ka}var Xa,Cp;function Z_(){if(Cp)return Xa;Cp=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return Xa=t,Xa}var Za,Pp;function J_(){if(Pp)return Za;Pp=1;var e=Z_(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return Za=r,Za}var Ja,Lp;function Q_(){if(Lp)return Ja;Lp=1;var e=J_(),t=it(),r=Yt(),n=NaN,i=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,a=/^0o[0-7]+$/i,o=parseInt;function c(f){if(typeof f=="number")return f;if(r(f))return n;if(t(f)){var l=typeof f.valueOf=="function"?f.valueOf():f;f=t(l)?l+"":l}if(typeof f!="string")return f===0?f:+f;f=e(f);var p=s.test(f);return p||a.test(f)?o(f.slice(2),p?2:8):i.test(f)?n:+f}return Ja=c,Ja}var Qa,Dp;function zp(){if(Dp)return Qa;Dp=1;var e=Q_(),t=1/0,r=17976931348623157e292;function n(i){if(!i)return i===0?i:0;if(i=e(i),i===t||i===-t){var s=i<0?-1:1;return s*r}return i===i?i:0}return Qa=n,Qa}var Ha,Fp;function H_(){if(Fp)return Ha;Fp=1;var e=zp();function t(r){var n=e(r),i=n%1;return n===n?i?n-i:n:0}return Ha=t,Ha}var eu,Bp;function eE(){if(Bp)return eu;Bp=1;var e=Ug(),t=yt(),r=H_(),n=Math.max;function i(s,a,o){var c=s==null?0:s.length;if(!c)return-1;var f=o==null?0:r(o);return f<0&&(f=n(c+f,0)),e(s,t(a,3),f)}return eu=i,eu}var tu,$p;function tE(){if($p)return tu;$p=1;var e=X_(),t=eE(),r=e(t);return tu=r,tu}var ru,Gp;function Up(){if(Gp)return ru;Gp=1;var e=na();function t(r){var n=r==null?0:r.length;return n?e(r,1):[]}return ru=t,ru}var nu,Vp;function rE(){if(Vp)return nu;Vp=1;var e=$s(),t=ld(),r=Ct();function n(i,s){return i==null?i:e(i,t(s),r)}return nu=n,nu}var iu,Wp;function nE(){if(Wp)return iu;Wp=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return iu=e,iu}var su,Yp;function iE(){if(Yp)return su;Yp=1;var e=kr(),t=Us(),r=yt();function n(i,s){var a={};return s=r(s,3),t(i,function(o,c,f){e(a,c,s(o,c,f))}),a}return su=n,su}var ou,Kp;function au(){if(Kp)return ou;Kp=1;var e=Yt();function t(r,n,i){for(var s=-1,a=r.length;++s<a;){var o=r[s],c=n(o);if(c!=null&&(f===void 0?c===c&&!e(c):i(c,f)))var f=c,l=o}return l}return ou=t,ou}var uu,Xp;function sE(){if(Xp)return uu;Xp=1;function e(t,r){return t>r}return uu=e,uu}var cu,Zp;function oE(){if(Zp)return cu;Zp=1;var e=au(),t=sE(),r=Pt();function n(i){return i&&i.length?e(i,r,t):void 0}return cu=n,cu}var fu,Jp;function Qp(){if(Jp)return fu;Jp=1;var e=kr(),t=Gt();function r(n,i,s){(s!==void 0&&!t(n[i],s)||s===void 0&&!(i in n))&&e(n,i,s)}return fu=r,fu}var lu,Hp;function aE(){if(Hp)return lu;Hp=1;var e=kt(),t=Dr(),r=ft(),n="[object Object]",i=Function.prototype,s=Object.prototype,a=i.toString,o=s.hasOwnProperty,c=a.call(Object);function f(l){if(!r(l)||e(l)!=n)return!1;var p=t(l);if(p===null)return!0;var v=o.call(p,"constructor")&&p.constructor;return typeof v=="function"&&v instanceof v&&a.call(v)==c}return lu=f,lu}var hu,ev;function tv(){if(ev)return hu;ev=1;function e(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}return hu=e,hu}var du,rv;function uE(){if(rv)return du;rv=1;var e=ar(),t=Ct();function r(n){return e(n,t(n))}return du=r,du}var gu,nv;function cE(){if(nv)return gu;nv=1;var e=Qp(),t=lh(),r=Uh(),n=dh(),i=Xh(),s=ur(),a=Pe(),o=ep(),c=Vt(),f=or(),l=it(),p=aE(),v=lr(),y=tv(),x=uE();function _(b,w,E,N,S,q,A){var j=y(b,E),I=y(w,E),D=A.get(I);if(D){e(b,E,D);return}var z=q?q(j,I,E+"",b,w,A):void 0,$=z===void 0;if($){var V=a(I),Y=!V&&c(I),ee=!V&&!Y&&v(I);z=I,V||Y||ee?a(j)?z=j:o(j)?z=n(j):Y?($=!1,z=t(I,!0)):ee?($=!1,z=r(I,!0)):z=[]:p(I)||s(I)?(z=j,s(j)?z=x(j):(!l(j)||f(j))&&(z=i(I))):$=!1}$&&(A.set(I,z),S(z,I,N,q,A),A.delete(I)),e(b,E,z)}return gu=_,gu}var pu,iv;function fE(){if(iv)return pu;iv=1;var e=Tr(),t=Qp(),r=$s(),n=cE(),i=it(),s=Ct(),a=tv();function o(c,f,l,p,v){c!==f&&r(f,function(y,x){if(v||(v=new e),i(y))n(c,f,x,l,o,p,v);else{var _=p?p(a(c,x),y,x+"",c,f,v):void 0;_===void 0&&(_=y),t(c,x,_)}},s)}return pu=o,pu}var vu,sv;function lE(){if(sv)return vu;sv=1;var e=Gr(),t=Ur();function r(n){return e(function(i,s){var a=-1,o=s.length,c=o>1?s[o-1]:void 0,f=o>2?s[2]:void 0;for(c=n.length>3&&typeof c=="function"?(o--,c):void 0,f&&t(s[0],s[1],f)&&(c=o<3?void 0:c,o=1),i=Object(i);++a<o;){var l=s[a];l&&n(i,l,a,c)}return i})}return vu=r,vu}var mu,ov;function hE(){if(ov)return mu;ov=1;var e=fE(),t=lE(),r=t(function(n,i,s){e(n,i,s)});return mu=r,mu}var yu,av;function uv(){if(av)return yu;av=1;function e(t,r){return t<r}return yu=e,yu}var wu,cv;function dE(){if(cv)return wu;cv=1;var e=au(),t=uv(),r=Pt();function n(i){return i&&i.length?e(i,r,t):void 0}return wu=n,wu}var bu,fv;function gE(){if(fv)return bu;fv=1;var e=au(),t=yt(),r=uv();function n(i,s){return i&&i.length?e(i,t(s,2),r):void 0}return bu=n,bu}var _u,lv;function pE(){if(lv)return _u;lv=1;var e=ot(),t=function(){return e.Date.now()};return _u=t,_u}var Eu,hv;function vE(){if(hv)return Eu;hv=1;var e=jr(),t=Br(),r=Cr(),n=it(),i=dr();function s(a,o,c,f){if(!n(a))return a;o=t(o,a);for(var l=-1,p=o.length,v=p-1,y=a;y!=null&&++l<p;){var x=i(o[l]),_=c;if(x==="__proto__"||x==="constructor"||x==="prototype")return a;if(l!=v){var b=y[x];_=f?f(b,x,y):void 0,_===void 0&&(_=n(b)?b:r(o[l+1])?[]:{})}e(y,x,_),y=y[x]}return a}return Eu=s,Eu}var xu,dv;function mE(){if(dv)return xu;dv=1;var e=$r(),t=vE(),r=Br();function n(i,s,a){for(var o=-1,c=s.length,f={};++o<c;){var l=s[o],p=e(i,l);a(p,l)&&t(f,r(l,i),p)}return f}return xu=n,xu}var Nu,gv;function yE(){if(gv)return Nu;gv=1;var e=mE(),t=ng();function r(n,i){return e(n,i,function(s,a){return t(n,a)})}return Nu=r,Nu}var Mu,pv;function wE(){if(pv)return Mu;pv=1;var e=Up(),t=Lg(),r=Bg();function n(i){return r(t(i,void 0,e),i+"")}return Mu=n,Mu}var Su,vv;function bE(){if(vv)return Su;vv=1;var e=yE(),t=wE(),r=t(function(n,i){return n==null?{}:e(n,i)});return Su=r,Su}var qu,mv;function _E(){if(mv)return qu;mv=1;var e=Math.ceil,t=Math.max;function r(n,i,s,a){for(var o=-1,c=t(e((i-n)/(s||1)),0),f=Array(c);c--;)f[a?c:++o]=n,n+=s;return f}return qu=r,qu}var Ru,yv;function EE(){if(yv)return Ru;yv=1;var e=_E(),t=Ur(),r=zp();function n(i){return function(s,a,o){return o&&typeof o!="number"&&t(s,a,o)&&(a=o=void 0),s=r(s),a===void 0?(a=s,s=0):a=r(a),o=o===void 0?s<a?1:-1:r(o),e(s,a,o,i)}}return Ru=n,Ru}var Ou,wv;function xE(){if(wv)return Ou;wv=1;var e=EE(),t=e();return Ou=t,Ou}var Au,bv;function NE(){if(bv)return Au;bv=1;function e(t,r){var n=t.length;for(t.sort(r);n--;)t[n]=t[n].value;return t}return Au=e,Au}var Iu,_v;function ME(){if(_v)return Iu;_v=1;var e=Yt();function t(r,n){if(r!==n){var i=r!==void 0,s=r===null,a=r===r,o=e(r),c=n!==void 0,f=n===null,l=n===n,p=e(n);if(!f&&!p&&!o&&r>n||o&&c&&l&&!f&&!p||s&&c&&l||!i&&l||!a)return 1;if(!s&&!o&&!p&&r<n||p&&i&&a&&!s&&!o||f&&i&&a||!c&&a||!l)return-1}return 0}return Iu=t,Iu}var Tu,Ev;function SE(){if(Ev)return Tu;Ev=1;var e=ME();function t(r,n,i){for(var s=-1,a=r.criteria,o=n.criteria,c=a.length,f=i.length;++s<c;){var l=e(a[s],o[s]);if(l){if(s>=f)return l;var p=i[s];return l*(p=="desc"?-1:1)}}return r.index-n.index}return Tu=t,Tu}var ku,xv;function qE(){if(xv)return ku;xv=1;var e=Fr(),t=$r(),r=yt(),n=wg(),i=NE(),s=Pr(),a=SE(),o=Pt(),c=Pe();function f(l,p,v){p.length?p=e(p,function(_){return c(_)?function(b){return t(b,_.length===1?_[0]:_)}:_}):p=[o];var y=-1;p=e(p,s(r));var x=n(l,function(_,b,w){var E=e(p,function(N){return N(_)});return{criteria:E,index:++y,value:_}});return i(x,function(_,b){return a(_,b,v)})}return ku=f,ku}var ju,Nv;function RE(){if(Nv)return ju;Nv=1;var e=na(),t=qE(),r=Gr(),n=Ur(),i=r(function(s,a){if(s==null)return[];var o=a.length;return o>1&&n(s,a[0],a[1])?a=[]:o>2&&n(a[0],a[1],a[2])&&(a=[a[0]]),t(s,e(a,1),[])});return ju=i,ju}var Cu,Mv;function OE(){if(Mv)return Cu;Mv=1;var e=Kd(),t=0;function r(n){var i=++t;return e(n)+i}return Cu=r,Cu}var Pu,Sv;function AE(){if(Sv)return Pu;Sv=1;function e(t,r,n){for(var i=-1,s=t.length,a=r.length,o={};++i<s;){var c=i<a?r[i]:void 0;n(o,t[i],c)}return o}return Pu=e,Pu}var Lu,qv;function IE(){if(qv)return Lu;qv=1;var e=jr(),t=AE();function r(n,i){return t(n||[],i||[],e)}return Lu=r,Lu}var Du,Rv;function Ae(){if(Rv)return Du;Rv=1;var e;if(typeof In=="function")try{e={cloneDeep:Y_(),constant:zs(),defaults:K_(),each:pd(),filter:lg(),find:tE(),flatten:Up(),forEach:dd(),forIn:rE(),has:gg(),isUndefined:mg(),last:nE(),map:_g(),mapValues:iE(),max:oE(),merge:hE(),min:dE(),minBy:gE(),now:pE(),pick:bE(),range:xE(),reduce:Mg(),sortBy:RE(),uniqueId:OE(),values:ip(),zipObject:IE()}}catch{}return e||(e=window._),Du=e,Du}var zu,Ov;function TE(){if(Ov)return zu;Ov=1,zu=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,i=n._prev;if(i!==n)return t(i),i},e.prototype.enqueue=function(n){var i=this._sentinel;n._prev&&n._next&&t(n),n._next=i._next,i._next._prev=n,i._next=n,n._prev=i},e.prototype.toString=function(){for(var n=[],i=this._sentinel,s=i._prev;s!==i;)n.push(JSON.stringify(s,r)),s=s._prev;return"["+n.join(", ")+"]"};function t(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function r(n,i){if(n!=="_next"&&n!=="_prev")return i}return zu}var Fu,Av;function kE(){if(Av)return Fu;Av=1;var e=Ae(),t=at().Graph,r=TE();Fu=i;var n=e.constant(1);function i(f,l){if(f.nodeCount()<=1)return[];var p=o(f,l||n),v=s(p.graph,p.buckets,p.zeroIdx);return e.flatten(e.map(v,function(y){return f.outEdges(y.v,y.w)}),!0)}function s(f,l,p){for(var v=[],y=l[l.length-1],x=l[0],_;f.nodeCount();){for(;_=x.dequeue();)a(f,l,p,_);for(;_=y.dequeue();)a(f,l,p,_);if(f.nodeCount()){for(var b=l.length-2;b>0;--b)if(_=l[b].dequeue(),_){v=v.concat(a(f,l,p,_,!0));break}}}return v}function a(f,l,p,v,y){var x=y?[]:void 0;return e.forEach(f.inEdges(v.v),function(_){var b=f.edge(_),w=f.node(_.v);y&&x.push({v:_.v,w:_.w}),w.out-=b,c(l,p,w)}),e.forEach(f.outEdges(v.v),function(_){var b=f.edge(_),w=_.w,E=f.node(w);E.in-=b,c(l,p,E)}),f.removeNode(v.v),x}function o(f,l){var p=new t,v=0,y=0;e.forEach(f.nodes(),function(b){p.setNode(b,{v:b,in:0,out:0})}),e.forEach(f.edges(),function(b){var w=p.edge(b.v,b.w)||0,E=l(b),N=w+E;p.setEdge(b.v,b.w,N),y=Math.max(y,p.node(b.v).out+=E),v=Math.max(v,p.node(b.w).in+=E)});var x=e.range(y+v+3).map(function(){return new r}),_=v+1;return e.forEach(p.nodes(),function(b){c(x,_,p.node(b))}),{graph:p,buckets:x,zeroIdx:_}}function c(f,l,p){p.out?p.in?f[p.out-p.in+l].enqueue(p):f[f.length-1].enqueue(p):f[0].enqueue(p)}return Fu}var Bu,Iv;function jE(){if(Iv)return Bu;Iv=1;var e=Ae(),t=kE();Bu={run:r,undo:i};function r(s){var a=s.graph().acyclicer==="greedy"?t(s,o(s)):n(s);e.forEach(a,function(c){var f=s.edge(c);s.removeEdge(c),f.forwardName=c.name,f.reversed=!0,s.setEdge(c.w,c.v,f,e.uniqueId("rev"))});function o(c){return function(f){return c.edge(f).weight}}}function n(s){var a=[],o={},c={};function f(l){e.has(c,l)||(c[l]=!0,o[l]=!0,e.forEach(s.outEdges(l),function(p){e.has(o,p.w)?a.push(p):f(p.w)}),delete o[l])}return e.forEach(s.nodes(),f),a}function i(s){e.forEach(s.edges(),function(a){var o=s.edge(a);if(o.reversed){s.removeEdge(a);var c=o.forwardName;delete o.reversed,delete o.forwardName,s.setEdge(a.w,a.v,o,c)}})}return Bu}var $u,Tv;function He(){if(Tv)return $u;Tv=1;var e=Ae(),t=at().Graph;$u={addDummyNode:r,simplify:n,asNonCompoundGraph:i,successorWeights:s,predecessorWeights:a,intersectRect:o,buildLayerMatrix:c,normalizeRanks:f,removeEmptyRanks:l,addBorderNode:p,maxRank:v,partition:y,time:x,notime:_};function r(b,w,E,N){var S;do S=e.uniqueId(N);while(b.hasNode(S));return E.dummy=w,b.setNode(S,E),S}function n(b){var w=new t().setGraph(b.graph());return e.forEach(b.nodes(),function(E){w.setNode(E,b.node(E))}),e.forEach(b.edges(),function(E){var N=w.edge(E.v,E.w)||{weight:0,minlen:1},S=b.edge(E);w.setEdge(E.v,E.w,{weight:N.weight+S.weight,minlen:Math.max(N.minlen,S.minlen)})}),w}function i(b){var w=new t({multigraph:b.isMultigraph()}).setGraph(b.graph());return e.forEach(b.nodes(),function(E){b.children(E).length||w.setNode(E,b.node(E))}),e.forEach(b.edges(),function(E){w.setEdge(E,b.edge(E))}),w}function s(b){var w=e.map(b.nodes(),function(E){var N={};return e.forEach(b.outEdges(E),function(S){N[S.w]=(N[S.w]||0)+b.edge(S).weight}),N});return e.zipObject(b.nodes(),w)}function a(b){var w=e.map(b.nodes(),function(E){var N={};return e.forEach(b.inEdges(E),function(S){N[S.v]=(N[S.v]||0)+b.edge(S).weight}),N});return e.zipObject(b.nodes(),w)}function o(b,w){var E=b.x,N=b.y,S=w.x-E,q=w.y-N,A=b.width/2,j=b.height/2;if(!S&&!q)throw new Error("Not possible to find intersection inside of the rectangle");var I,D;return Math.abs(q)*A>Math.abs(S)*j?(q<0&&(j=-j),I=j*S/q,D=j):(S<0&&(A=-A),I=A,D=A*q/S),{x:E+I,y:N+D}}function c(b){var w=e.map(e.range(v(b)+1),function(){return[]});return e.forEach(b.nodes(),function(E){var N=b.node(E),S=N.rank;e.isUndefined(S)||(w[S][N.order]=E)}),w}function f(b){var w=e.min(e.map(b.nodes(),function(E){return b.node(E).rank}));e.forEach(b.nodes(),function(E){var N=b.node(E);e.has(N,"rank")&&(N.rank-=w)})}function l(b){var w=e.min(e.map(b.nodes(),function(q){return b.node(q).rank})),E=[];e.forEach(b.nodes(),function(q){var A=b.node(q).rank-w;E[A]||(E[A]=[]),E[A].push(q)});var N=0,S=b.graph().nodeRankFactor;e.forEach(E,function(q,A){e.isUndefined(q)&&A%S!==0?--N:N&&e.forEach(q,function(j){b.node(j).rank+=N})})}function p(b,w,E,N){var S={width:0,height:0};return arguments.length>=4&&(S.rank=E,S.order=N),r(b,"border",S,w)}function v(b){return e.max(e.map(b.nodes(),function(w){var E=b.node(w).rank;if(!e.isUndefined(E))return E}))}function y(b,w){var E={lhs:[],rhs:[]};return e.forEach(b,function(N){w(N)?E.lhs.push(N):E.rhs.push(N)}),E}function x(b,w){var E=e.now();try{return w()}finally{console.log(b+" time: "+(e.now()-E)+"ms")}}function _(b,w){return w()}return $u}var Gu,kv;function CE(){if(kv)return Gu;kv=1;var e=Ae(),t=He();Gu={run:r,undo:i};function r(s){s.graph().dummyChains=[],e.forEach(s.edges(),function(a){n(s,a)})}function n(s,a){var o=a.v,c=s.node(o).rank,f=a.w,l=s.node(f).rank,p=a.name,v=s.edge(a),y=v.labelRank;if(l!==c+1){s.removeEdge(a);var x,_,b;for(b=0,++c;c<l;++b,++c)v.points=[],_={width:0,height:0,edgeLabel:v,edgeObj:a,rank:c},x=t.addDummyNode(s,"edge",_,"_d"),c===y&&(_.width=v.width,_.height=v.height,_.dummy="edge-label",_.labelpos=v.labelpos),s.setEdge(o,x,{weight:v.weight},p),b===0&&s.graph().dummyChains.push(x),o=x;s.setEdge(o,f,{weight:v.weight},p)}}function i(s){e.forEach(s.graph().dummyChains,function(a){var o=s.node(a),c=o.edgeLabel,f;for(s.setEdge(o.edgeObj,c);o.dummy;)f=s.successors(a)[0],s.removeNode(a),c.points.push({x:o.x,y:o.y}),o.dummy==="edge-label"&&(c.x=o.x,c.y=o.y,c.width=o.width,c.height=o.height),a=f,o=s.node(a)})}return Gu}var Uu,jv;function Vr(){if(jv)return Uu;jv=1;var e=Ae();Uu={longestPath:t,slack:r};function t(n){var i={};function s(a){var o=n.node(a);if(e.has(i,a))return o.rank;i[a]=!0;var c=e.min(e.map(n.outEdges(a),function(f){return s(f.w)-n.edge(f).minlen}));return(c===Number.POSITIVE_INFINITY||c===void 0||c===null)&&(c=0),o.rank=c}e.forEach(n.sources(),s)}function r(n,i){return n.node(i.w).rank-n.node(i.v).rank-n.edge(i).minlen}return Uu}var Vu,Cv;function Pv(){if(Cv)return Vu;Cv=1;var e=Ae(),t=at().Graph,r=Vr().slack;Vu=n;function n(o){var c=new t({directed:!1}),f=o.nodes()[0],l=o.nodeCount();c.setNode(f,{});for(var p,v;i(c,o)<l;)p=s(c,o),v=c.hasNode(p.v)?r(o,p):-r(o,p),a(c,o,v);return c}function i(o,c){function f(l){e.forEach(c.nodeEdges(l),function(p){var v=p.v,y=l===v?p.w:v;!o.hasNode(y)&&!r(c,p)&&(o.setNode(y,{}),o.setEdge(l,y,{}),f(y))})}return e.forEach(o.nodes(),f),o.nodeCount()}function s(o,c){return e.minBy(c.edges(),function(f){if(o.hasNode(f.v)!==o.hasNode(f.w))return r(c,f)})}function a(o,c,f){e.forEach(o.nodes(),function(l){c.node(l).rank+=f})}return Vu}var Wu,Lv;function PE(){if(Lv)return Wu;Lv=1;var e=Ae(),t=Pv(),r=Vr().slack,n=Vr().longestPath,i=at().alg.preorder,s=at().alg.postorder,a=He().simplify;Wu=o,o.initLowLimValues=p,o.initCutValues=c,o.calcCutValue=l,o.leaveEdge=y,o.enterEdge=x,o.exchangeEdges=_;function o(N){N=a(N),n(N);var S=t(N);p(S),c(S,N);for(var q,A;q=y(S);)A=x(S,N,q),_(S,N,q,A)}function c(N,S){var q=s(N,N.nodes());q=q.slice(0,q.length-1),e.forEach(q,function(A){f(N,S,A)})}function f(N,S,q){var A=N.node(q),j=A.parent;N.edge(q,j).cutvalue=l(N,S,q)}function l(N,S,q){var A=N.node(q),j=A.parent,I=!0,D=S.edge(q,j),z=0;return D||(I=!1,D=S.edge(j,q)),z=D.weight,e.forEach(S.nodeEdges(q),function($){var V=$.v===q,Y=V?$.w:$.v;if(Y!==j){var ee=V===I,J=S.edge($).weight;if(z+=ee?J:-J,w(N,q,Y)){var ae=N.edge(q,Y).cutvalue;z+=ee?-ae:ae}}}),z}function p(N,S){arguments.length<2&&(S=N.nodes()[0]),v(N,{},1,S)}function v(N,S,q,A,j){var I=q,D=N.node(A);return S[A]=!0,e.forEach(N.neighbors(A),function(z){e.has(S,z)||(q=v(N,S,q,z,A))}),D.low=I,D.lim=q++,j?D.parent=j:delete D.parent,q}function y(N){return e.find(N.edges(),function(S){return N.edge(S).cutvalue<0})}function x(N,S,q){var A=q.v,j=q.w;S.hasEdge(A,j)||(A=q.w,j=q.v);var I=N.node(A),D=N.node(j),z=I,$=!1;I.lim>D.lim&&(z=D,$=!0);var V=e.filter(S.edges(),function(Y){return $===E(N,N.node(Y.v),z)&&$!==E(N,N.node(Y.w),z)});return e.minBy(V,function(Y){return r(S,Y)})}function _(N,S,q,A){var j=q.v,I=q.w;N.removeEdge(j,I),N.setEdge(A.v,A.w,{}),p(N),c(N,S),b(N,S)}function b(N,S){var q=e.find(N.nodes(),function(j){return!S.node(j).parent}),A=i(N,q);A=A.slice(1),e.forEach(A,function(j){var I=N.node(j).parent,D=S.edge(j,I),z=!1;D||(D=S.edge(I,j),z=!0),S.node(j).rank=S.node(I).rank+(z?D.minlen:-D.minlen)})}function w(N,S,q){return N.hasEdge(S,q)}function E(N,S,q){return q.low<=S.lim&&S.lim<=q.lim}return Wu}var Yu,Dv;function LE(){if(Dv)return Yu;Dv=1;var e=Vr(),t=e.longestPath,r=Pv(),n=PE();Yu=i;function i(c){switch(c.graph().ranker){case"network-simplex":o(c);break;case"tight-tree":a(c);break;case"longest-path":s(c);break;default:o(c)}}var s=t;function a(c){t(c),r(c)}function o(c){n(c)}return Yu}var Ku,zv;function DE(){if(zv)return Ku;zv=1;var e=Ae();Ku=t;function t(i){var s=n(i);e.forEach(i.graph().dummyChains,function(a){for(var o=i.node(a),c=o.edgeObj,f=r(i,s,c.v,c.w),l=f.path,p=f.lca,v=0,y=l[v],x=!0;a!==c.w;){if(o=i.node(a),x){for(;(y=l[v])!==p&&i.node(y).maxRank<o.rank;)v++;y===p&&(x=!1)}if(!x){for(;v<l.length-1&&i.node(y=l[v+1]).minRank<=o.rank;)v++;y=l[v]}i.setParent(a,y),a=i.successors(a)[0]}})}function r(i,s,a,o){var c=[],f=[],l=Math.min(s[a].low,s[o].low),p=Math.max(s[a].lim,s[o].lim),v,y;v=a;do v=i.parent(v),c.push(v);while(v&&(s[v].low>l||p>s[v].lim));for(y=v,v=o;(v=i.parent(v))!==y;)f.push(v);return{path:c.concat(f.reverse()),lca:y}}function n(i){var s={},a=0;function o(c){var f=a;e.forEach(i.children(c),o),s[c]={low:f,lim:a++}}return e.forEach(i.children(),o),s}return Ku}var Xu,Fv;function zE(){if(Fv)return Xu;Fv=1;var e=Ae(),t=He();Xu={run:r,cleanup:a};function r(o){var c=t.addDummyNode(o,"root",{},"_root"),f=i(o),l=e.max(e.values(f))-1,p=2*l+1;o.graph().nestingRoot=c,e.forEach(o.edges(),function(y){o.edge(y).minlen*=p});var v=s(o)+1;e.forEach(o.children(),function(y){n(o,c,p,v,l,f,y)}),o.graph().nodeRankFactor=p}function n(o,c,f,l,p,v,y){var x=o.children(y);if(!x.length){y!==c&&o.setEdge(c,y,{weight:0,minlen:f});return}var _=t.addBorderNode(o,"_bt"),b=t.addBorderNode(o,"_bb"),w=o.node(y);o.setParent(_,y),w.borderTop=_,o.setParent(b,y),w.borderBottom=b,e.forEach(x,function(E){n(o,c,f,l,p,v,E);var N=o.node(E),S=N.borderTop?N.borderTop:E,q=N.borderBottom?N.borderBottom:E,A=N.borderTop?l:2*l,j=S!==q?1:p-v[y]+1;o.setEdge(_,S,{weight:A,minlen:j,nestingEdge:!0}),o.setEdge(q,b,{weight:A,minlen:j,nestingEdge:!0})}),o.parent(y)||o.setEdge(c,_,{weight:0,minlen:p+v[y]})}function i(o){var c={};function f(l,p){var v=o.children(l);v&&v.length&&e.forEach(v,function(y){f(y,p+1)}),c[l]=p}return e.forEach(o.children(),function(l){f(l,1)}),c}function s(o){return e.reduce(o.edges(),function(c,f){return c+o.edge(f).weight},0)}function a(o){var c=o.graph();o.removeNode(c.nestingRoot),delete c.nestingRoot,e.forEach(o.edges(),function(f){var l=o.edge(f);l.nestingEdge&&o.removeEdge(f)})}return Xu}var Zu,Bv;function FE(){if(Bv)return Zu;Bv=1;var e=Ae(),t=He();Zu=r;function r(i){function s(a){var o=i.children(a),c=i.node(a);if(o.length&&e.forEach(o,s),e.has(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(var f=c.minRank,l=c.maxRank+1;f<l;++f)n(i,"borderLeft","_bl",a,c,f),n(i,"borderRight","_br",a,c,f)}}e.forEach(i.children(),s)}function n(i,s,a,o,c,f){var l={width:0,height:0,rank:f,borderType:s},p=c[s][f-1],v=t.addDummyNode(i,"border",l,a);c[s][f]=v,i.setParent(v,o),p&&i.setEdge(p,v,{weight:1})}return Zu}var Ju,$v;function BE(){if($v)return Ju;$v=1;var e=Ae();Ju={adjust:t,undo:r};function t(f){var l=f.graph().rankdir.toLowerCase();(l==="lr"||l==="rl")&&n(f)}function r(f){var l=f.graph().rankdir.toLowerCase();(l==="bt"||l==="rl")&&s(f),(l==="lr"||l==="rl")&&(o(f),n(f))}function n(f){e.forEach(f.nodes(),function(l){i(f.node(l))}),e.forEach(f.edges(),function(l){i(f.edge(l))})}function i(f){var l=f.width;f.width=f.height,f.height=l}function s(f){e.forEach(f.nodes(),function(l){a(f.node(l))}),e.forEach(f.edges(),function(l){var p=f.edge(l);e.forEach(p.points,a),e.has(p,"y")&&a(p)})}function a(f){f.y=-f.y}function o(f){e.forEach(f.nodes(),function(l){c(f.node(l))}),e.forEach(f.edges(),function(l){var p=f.edge(l);e.forEach(p.points,c),e.has(p,"x")&&c(p)})}function c(f){var l=f.x;f.x=f.y,f.y=l}return Ju}var Qu,Gv;function $E(){if(Gv)return Qu;Gv=1;var e=Ae();Qu=t;function t(r){var n={},i=e.filter(r.nodes(),function(f){return!r.children(f).length}),s=e.max(e.map(i,function(f){return r.node(f).rank})),a=e.map(e.range(s+1),function(){return[]});function o(f){if(!e.has(n,f)){n[f]=!0;var l=r.node(f);a[l.rank].push(f),e.forEach(r.successors(f),o)}}var c=e.sortBy(i,function(f){return r.node(f).rank});return e.forEach(c,o),a}return Qu}var Hu,Uv;function GE(){if(Uv)return Hu;Uv=1;var e=Ae();Hu=t;function t(n,i){for(var s=0,a=1;a<i.length;++a)s+=r(n,i[a-1],i[a]);return s}function r(n,i,s){for(var a=e.zipObject(s,e.map(s,function(v,y){return y})),o=e.flatten(e.map(i,function(v){return e.sortBy(e.map(n.outEdges(v),function(y){return{pos:a[y.w],weight:n.edge(y).weight}}),"pos")}),!0),c=1;c<s.length;)c<<=1;var f=2*c-1;c-=1;var l=e.map(new Array(f),function(){return 0}),p=0;return e.forEach(o.forEach(function(v){var y=v.pos+c;l[y]+=v.weight;for(var x=0;y>0;)y%2&&(x+=l[y+1]),y=y-1>>1,l[y]+=v.weight;p+=v.weight*x})),p}return Hu}var ec,Vv;function UE(){if(Vv)return ec;Vv=1;var e=Ae();ec=t;function t(r,n){return e.map(n,function(i){var s=r.inEdges(i);if(s.length){var a=e.reduce(s,function(o,c){var f=r.edge(c),l=r.node(c.v);return{sum:o.sum+f.weight*l.order,weight:o.weight+f.weight}},{sum:0,weight:0});return{v:i,barycenter:a.sum/a.weight,weight:a.weight}}else return{v:i}})}return ec}var tc,Wv;function VE(){if(Wv)return tc;Wv=1;var e=Ae();tc=t;function t(i,s){var a={};e.forEach(i,function(c,f){var l=a[c.v]={indegree:0,in:[],out:[],vs:[c.v],i:f};e.isUndefined(c.barycenter)||(l.barycenter=c.barycenter,l.weight=c.weight)}),e.forEach(s.edges(),function(c){var f=a[c.v],l=a[c.w];!e.isUndefined(f)&&!e.isUndefined(l)&&(l.indegree++,f.out.push(a[c.w]))});var o=e.filter(a,function(c){return!c.indegree});return r(o)}function r(i){var s=[];function a(f){return function(l){l.merged||(e.isUndefined(l.barycenter)||e.isUndefined(f.barycenter)||l.barycenter>=f.barycenter)&&n(f,l)}}function o(f){return function(l){l.in.push(f),--l.indegree===0&&i.push(l)}}for(;i.length;){var c=i.pop();s.push(c),e.forEach(c.in.reverse(),a(c)),e.forEach(c.out,o(c))}return e.map(e.filter(s,function(f){return!f.merged}),function(f){return e.pick(f,["vs","i","barycenter","weight"])})}function n(i,s){var a=0,o=0;i.weight&&(a+=i.barycenter*i.weight,o+=i.weight),s.weight&&(a+=s.barycenter*s.weight,o+=s.weight),i.vs=s.vs.concat(i.vs),i.barycenter=a/o,i.weight=o,i.i=Math.min(s.i,i.i),s.merged=!0}return tc}var rc,Yv;function WE(){if(Yv)return rc;Yv=1;var e=Ae(),t=He();rc=r;function r(s,a){var o=t.partition(s,function(_){return e.has(_,"barycenter")}),c=o.lhs,f=e.sortBy(o.rhs,function(_){return-_.i}),l=[],p=0,v=0,y=0;c.sort(i(!!a)),y=n(l,f,y),e.forEach(c,function(_){y+=_.vs.length,l.push(_.vs),p+=_.barycenter*_.weight,v+=_.weight,y=n(l,f,y)});var x={vs:e.flatten(l,!0)};return v&&(x.barycenter=p/v,x.weight=v),x}function n(s,a,o){for(var c;a.length&&(c=e.last(a)).i<=o;)a.pop(),s.push(c.vs),o++;return o}function i(s){return function(a,o){return a.barycenter<o.barycenter?-1:a.barycenter>o.barycenter?1:s?o.i-a.i:a.i-o.i}}return rc}var nc,Kv;function YE(){if(Kv)return nc;Kv=1;var e=Ae(),t=UE(),r=VE(),n=WE();nc=i;function i(o,c,f,l){var p=o.children(c),v=o.node(c),y=v?v.borderLeft:void 0,x=v?v.borderRight:void 0,_={};y&&(p=e.filter(p,function(q){return q!==y&&q!==x}));var b=t(o,p);e.forEach(b,function(q){if(o.children(q.v).length){var A=i(o,q.v,f,l);_[q.v]=A,e.has(A,"barycenter")&&a(q,A)}});var w=r(b,f);s(w,_);var E=n(w,l);if(y&&(E.vs=e.flatten([y,E.vs,x],!0),o.predecessors(y).length)){var N=o.node(o.predecessors(y)[0]),S=o.node(o.predecessors(x)[0]);e.has(E,"barycenter")||(E.barycenter=0,E.weight=0),E.barycenter=(E.barycenter*E.weight+N.order+S.order)/(E.weight+2),E.weight+=2}return E}function s(o,c){e.forEach(o,function(f){f.vs=e.flatten(f.vs.map(function(l){return c[l]?c[l].vs:l}),!0)})}function a(o,c){e.isUndefined(o.barycenter)?(o.barycenter=c.barycenter,o.weight=c.weight):(o.barycenter=(o.barycenter*o.weight+c.barycenter*c.weight)/(o.weight+c.weight),o.weight+=c.weight)}return nc}var ic,Xv;function KE(){if(Xv)return ic;Xv=1;var e=Ae(),t=at().Graph;ic=r;function r(i,s,a){var o=n(i),c=new t({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(function(f){return i.node(f)});return e.forEach(i.nodes(),function(f){var l=i.node(f),p=i.parent(f);(l.rank===s||l.minRank<=s&&s<=l.maxRank)&&(c.setNode(f),c.setParent(f,p||o),e.forEach(i[a](f),function(v){var y=v.v===f?v.w:v.v,x=c.edge(y,f),_=e.isUndefined(x)?0:x.weight;c.setEdge(y,f,{weight:i.edge(v).weight+_})}),e.has(l,"minRank")&&c.setNode(f,{borderLeft:l.borderLeft[s],borderRight:l.borderRight[s]}))}),c}function n(i){for(var s;i.hasNode(s=e.uniqueId("_root")););return s}return ic}var sc,Zv;function XE(){if(Zv)return sc;Zv=1;var e=Ae();sc=t;function t(r,n,i){var s={},a;e.forEach(i,function(o){for(var c=r.parent(o),f,l;c;){if(f=r.parent(c),f?(l=s[f],s[f]=c):(l=a,a=c),l&&l!==c){n.setEdge(l,c);return}c=f}})}return sc}var oc,Jv;function ZE(){if(Jv)return oc;Jv=1;var e=Ae(),t=$E(),r=GE(),n=YE(),i=KE(),s=XE(),a=at().Graph,o=He();oc=c;function c(v){var y=o.maxRank(v),x=f(v,e.range(1,y+1),"inEdges"),_=f(v,e.range(y-1,-1,-1),"outEdges"),b=t(v);p(v,b);for(var w=Number.POSITIVE_INFINITY,E,N=0,S=0;S<4;++N,++S){l(N%2?x:_,N%4>=2),b=o.buildLayerMatrix(v);var q=r(v,b);q<w&&(S=0,E=e.cloneDeep(b),w=q)}p(v,E)}function f(v,y,x){return e.map(y,function(_){return i(v,_,x)})}function l(v,y){var x=new a;e.forEach(v,function(_){var b=_.graph().root,w=n(_,b,x,y);e.forEach(w.vs,function(E,N){_.node(E).order=N}),s(_,x,w.vs)})}function p(v,y){e.forEach(y,function(x){e.forEach(x,function(_,b){v.node(_).order=b})})}return oc}var ac,Qv;function JE(){if(Qv)return ac;Qv=1;var e=Ae(),t=at().Graph,r=He();ac={positionX:x,findType1Conflicts:n,findType2Conflicts:i,addConflict:a,hasConflict:o,verticalAlignment:c,horizontalCompaction:f,alignCoordinates:v,findSmallestWidthAlignment:p,balance:y};function n(w,E){var N={};function S(q,A){var j=0,I=0,D=q.length,z=e.last(A);return e.forEach(A,function($,V){var Y=s(w,$),ee=Y?w.node(Y).order:D;(Y||$===z)&&(e.forEach(A.slice(I,V+1),function(J){e.forEach(w.predecessors(J),function(ae){var be=w.node(ae),Z=be.order;(Z<j||ee<Z)&&!(be.dummy&&w.node(J).dummy)&&a(N,ae,J)})}),I=V+1,j=ee)}),A}return e.reduce(E,S),N}function i(w,E){var N={};function S(A,j,I,D,z){var $;e.forEach(e.range(j,I),function(V){$=A[V],w.node($).dummy&&e.forEach(w.predecessors($),function(Y){var ee=w.node(Y);ee.dummy&&(ee.order<D||ee.order>z)&&a(N,Y,$)})})}function q(A,j){var I=-1,D,z=0;return e.forEach(j,function($,V){if(w.node($).dummy==="border"){var Y=w.predecessors($);Y.length&&(D=w.node(Y[0]).order,S(j,z,V,I,D),z=V,I=D)}S(j,z,j.length,D,A.length)}),j}return e.reduce(E,q),N}function s(w,E){if(w.node(E).dummy)return e.find(w.predecessors(E),function(N){return w.node(N).dummy})}function a(w,E,N){if(E>N){var S=E;E=N,N=S}var q=w[E];q||(w[E]=q={}),q[N]=!0}function o(w,E,N){if(E>N){var S=E;E=N,N=S}return e.has(w[E],N)}function c(w,E,N,S){var q={},A={},j={};return e.forEach(E,function(I){e.forEach(I,function(D,z){q[D]=D,A[D]=D,j[D]=z})}),e.forEach(E,function(I){var D=-1;e.forEach(I,function(z){var $=S(z);if($.length){$=e.sortBy($,function(ae){return j[ae]});for(var V=($.length-1)/2,Y=Math.floor(V),ee=Math.ceil(V);Y<=ee;++Y){var J=$[Y];A[z]===z&&D<j[J]&&!o(N,z,J)&&(A[J]=z,A[z]=q[z]=q[J],D=j[J])}}})}),{root:q,align:A}}function f(w,E,N,S,q){var A={},j=l(w,E,N,q),I=q?"borderLeft":"borderRight";function D(V,Y){for(var ee=j.nodes(),J=ee.pop(),ae={};J;)ae[J]?V(J):(ae[J]=!0,ee.push(J),ee=ee.concat(Y(J))),J=ee.pop()}function z(V){A[V]=j.inEdges(V).reduce(function(Y,ee){return Math.max(Y,A[ee.v]+j.edge(ee))},0)}function $(V){var Y=j.outEdges(V).reduce(function(J,ae){return Math.min(J,A[ae.w]-j.edge(ae))},Number.POSITIVE_INFINITY),ee=w.node(V);Y!==Number.POSITIVE_INFINITY&&ee.borderType!==I&&(A[V]=Math.max(A[V],Y))}return D(z,j.predecessors.bind(j)),D($,j.successors.bind(j)),e.forEach(S,function(V){A[V]=A[N[V]]}),A}function l(w,E,N,S){var q=new t,A=w.graph(),j=_(A.nodesep,A.edgesep,S);return e.forEach(E,function(I){var D;e.forEach(I,function(z){var $=N[z];if(q.setNode($),D){var V=N[D],Y=q.edge(V,$);q.setEdge(V,$,Math.max(j(w,z,D),Y||0))}D=z})}),q}function p(w,E){return e.minBy(e.values(E),function(N){var S=Number.NEGATIVE_INFINITY,q=Number.POSITIVE_INFINITY;return e.forIn(N,function(A,j){var I=b(w,j)/2;S=Math.max(A+I,S),q=Math.min(A-I,q)}),S-q})}function v(w,E){var N=e.values(E),S=e.min(N),q=e.max(N);e.forEach(["u","d"],function(A){e.forEach(["l","r"],function(j){var I=A+j,D=w[I],z;if(D!==E){var $=e.values(D);z=j==="l"?S-e.min($):q-e.max($),z&&(w[I]=e.mapValues(D,function(V){return V+z}))}})})}function y(w,E){return e.mapValues(w.ul,function(N,S){if(E)return w[E.toLowerCase()][S];var q=e.sortBy(e.map(w,S));return(q[1]+q[2])/2})}function x(w){var E=r.buildLayerMatrix(w),N=e.merge(n(w,E),i(w,E)),S={},q;e.forEach(["u","d"],function(j){q=j==="u"?E:e.values(E).reverse(),e.forEach(["l","r"],function(I){I==="r"&&(q=e.map(q,function(V){return e.values(V).reverse()}));var D=(j==="u"?w.predecessors:w.successors).bind(w),z=c(w,q,N,D),$=f(w,q,z.root,z.align,I==="r");I==="r"&&($=e.mapValues($,function(V){return-V})),S[j+I]=$})});var A=p(w,S);return v(S,A),y(S,w.graph().align)}function _(w,E,N){return function(S,q,A){var j=S.node(q),I=S.node(A),D=0,z;if(D+=j.width/2,e.has(j,"labelpos"))switch(j.labelpos.toLowerCase()){case"l":z=-j.width/2;break;case"r":z=j.width/2;break}if(z&&(D+=N?z:-z),z=0,D+=(j.dummy?E:w)/2,D+=(I.dummy?E:w)/2,D+=I.width/2,e.has(I,"labelpos"))switch(I.labelpos.toLowerCase()){case"l":z=I.width/2;break;case"r":z=-I.width/2;break}return z&&(D+=N?z:-z),z=0,D}}function b(w,E){return w.node(E).width}return ac}var uc,Hv;function QE(){if(Hv)return uc;Hv=1;var e=Ae(),t=He(),r=JE().positionX;uc=n;function n(s){s=t.asNonCompoundGraph(s),i(s),e.forEach(r(s),function(a,o){s.node(o).x=a})}function i(s){var a=t.buildLayerMatrix(s),o=s.graph().ranksep,c=0;e.forEach(a,function(f){var l=e.max(e.map(f,function(p){return s.node(p).height}));e.forEach(f,function(p){s.node(p).y=c+l/2}),c+=l+o})}return uc}var cc,e0;function HE(){if(e0)return cc;e0=1;var e=Ae(),t=jE(),r=CE(),n=LE(),i=He().normalizeRanks,s=DE(),a=He().removeEmptyRanks,o=zE(),c=FE(),f=BE(),l=ZE(),p=QE(),v=He(),y=at().Graph;cc=x;function x(G,P){var X=P&&P.debugTiming?v.time:v.notime;X("layout",function(){var te=X(" buildLayoutGraph",function(){return D(G)});X(" runLayout",function(){_(te,X)}),X(" updateInputGraph",function(){b(G,te)})})}function _(G,P){P(" makeSpaceForEdgeLabels",function(){z(G)}),P(" removeSelfEdges",function(){ue(G)}),P(" acyclic",function(){t.run(G)}),P(" nestingGraph.run",function(){o.run(G)}),P(" rank",function(){n(v.asNonCompoundGraph(G))}),P(" injectEdgeLabelProxies",function(){$(G)}),P(" removeEmptyRanks",function(){a(G)}),P(" nestingGraph.cleanup",function(){o.cleanup(G)}),P(" normalizeRanks",function(){i(G)}),P(" assignRankMinMax",function(){V(G)}),P(" removeEdgeLabelProxies",function(){Y(G)}),P(" normalize.run",function(){r.run(G)}),P(" parentDummyChains",function(){s(G)}),P(" addBorderSegments",function(){c(G)}),P(" order",function(){l(G)}),P(" insertSelfEdges",function(){ge(G)}),P(" adjustCoordinateSystem",function(){f.adjust(G)}),P(" position",function(){p(G)}),P(" positionSelfEdges",function(){le(G)}),P(" removeBorderNodes",function(){Z(G)}),P(" normalize.undo",function(){r.undo(G)}),P(" fixupEdgeLabelCoords",function(){ae(G)}),P(" undoCoordinateSystem",function(){f.undo(G)}),P(" translateGraph",function(){ee(G)}),P(" assignNodeIntersects",function(){J(G)}),P(" reversePoints",function(){be(G)}),P(" acyclic.undo",function(){t.undo(G)})}function b(G,P){e.forEach(G.nodes(),function(X){var te=G.node(X),fe=P.node(X);te&&(te.x=fe.x,te.y=fe.y,P.children(X).length&&(te.width=fe.width,te.height=fe.height))}),e.forEach(G.edges(),function(X){var te=G.edge(X),fe=P.edge(X);te.points=fe.points,e.has(fe,"x")&&(te.x=fe.x,te.y=fe.y)}),G.graph().width=P.graph().width,G.graph().height=P.graph().height}var w=["nodesep","edgesep","ranksep","marginx","marginy"],E={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},N=["acyclicer","ranker","rankdir","align"],S=["width","height"],q={width:0,height:0},A=["minlen","weight","width","height","labeloffset"],j={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},I=["labelpos"];function D(G){var P=new y({multigraph:!0,compound:!0}),X=_e(G.graph());return P.setGraph(e.merge({},E,ie(X,w),e.pick(X,N))),e.forEach(G.nodes(),function(te){var fe=_e(G.node(te));P.setNode(te,e.defaults(ie(fe,S),q)),P.setParent(te,G.parent(te))}),e.forEach(G.edges(),function(te){var fe=_e(G.edge(te));P.setEdge(te,e.merge({},j,ie(fe,A),e.pick(fe,I)))}),P}function z(G){var P=G.graph();P.ranksep/=2,e.forEach(G.edges(),function(X){var te=G.edge(X);te.minlen*=2,te.labelpos.toLowerCase()!=="c"&&(P.rankdir==="TB"||P.rankdir==="BT"?te.width+=te.labeloffset:te.height+=te.labeloffset)})}function $(G){e.forEach(G.edges(),function(P){var X=G.edge(P);if(X.width&&X.height){var te=G.node(P.v),fe=G.node(P.w),xe={rank:(fe.rank-te.rank)/2+te.rank,e:P};v.addDummyNode(G,"edge-proxy",xe,"_ep")}})}function V(G){var P=0;e.forEach(G.nodes(),function(X){var te=G.node(X);te.borderTop&&(te.minRank=G.node(te.borderTop).rank,te.maxRank=G.node(te.borderBottom).rank,P=e.max(P,te.maxRank))}),G.graph().maxRank=P}function Y(G){e.forEach(G.nodes(),function(P){var X=G.node(P);X.dummy==="edge-proxy"&&(G.edge(X.e).labelRank=X.rank,G.removeNode(P))})}function ee(G){var P=Number.POSITIVE_INFINITY,X=0,te=Number.POSITIVE_INFINITY,fe=0,xe=G.graph(),Ce=xe.marginx||0,Ke=xe.marginy||0;function Zt(Xe){var $e=Xe.x,Ee=Xe.y,bt=Xe.width,Me=Xe.height;P=Math.min(P,$e-bt/2),X=Math.max(X,$e+bt/2),te=Math.min(te,Ee-Me/2),fe=Math.max(fe,Ee+Me/2)}e.forEach(G.nodes(),function(Xe){Zt(G.node(Xe))}),e.forEach(G.edges(),function(Xe){var $e=G.edge(Xe);e.has($e,"x")&&Zt($e)}),P-=Ce,te-=Ke,e.forEach(G.nodes(),function(Xe){var $e=G.node(Xe);$e.x-=P,$e.y-=te}),e.forEach(G.edges(),function(Xe){var $e=G.edge(Xe);e.forEach($e.points,function(Ee){Ee.x-=P,Ee.y-=te}),e.has($e,"x")&&($e.x-=P),e.has($e,"y")&&($e.y-=te)}),xe.width=X-P+Ce,xe.height=fe-te+Ke}function J(G){e.forEach(G.edges(),function(P){var X=G.edge(P),te=G.node(P.v),fe=G.node(P.w),xe,Ce;X.points?(xe=X.points[0],Ce=X.points[X.points.length-1]):(X.points=[],xe=fe,Ce=te),X.points.unshift(v.intersectRect(te,xe)),X.points.push(v.intersectRect(fe,Ce))})}function ae(G){e.forEach(G.edges(),function(P){var X=G.edge(P);if(e.has(X,"x"))switch((X.labelpos==="l"||X.labelpos==="r")&&(X.width-=X.labeloffset),X.labelpos){case"l":X.x-=X.width/2+X.labeloffset;break;case"r":X.x+=X.width/2+X.labeloffset;break}})}function be(G){e.forEach(G.edges(),function(P){var X=G.edge(P);X.reversed&&X.points.reverse()})}function Z(G){e.forEach(G.nodes(),function(P){if(G.children(P).length){var X=G.node(P),te=G.node(X.borderTop),fe=G.node(X.borderBottom),xe=G.node(e.last(X.borderLeft)),Ce=G.node(e.last(X.borderRight));X.width=Math.abs(Ce.x-xe.x),X.height=Math.abs(fe.y-te.y),X.x=xe.x+X.width/2,X.y=te.y+X.height/2}}),e.forEach(G.nodes(),function(P){G.node(P).dummy==="border"&&G.removeNode(P)})}function ue(G){e.forEach(G.edges(),function(P){if(P.v===P.w){var X=G.node(P.v);X.selfEdges||(X.selfEdges=[]),X.selfEdges.push({e:P,label:G.edge(P)}),G.removeEdge(P)}})}function ge(G){var P=v.buildLayerMatrix(G);e.forEach(P,function(X){var te=0;e.forEach(X,function(fe,xe){var Ce=G.node(fe);Ce.order=xe+te,e.forEach(Ce.selfEdges,function(Ke){v.addDummyNode(G,"selfedge",{width:Ke.label.width,height:Ke.label.height,rank:Ce.rank,order:xe+ ++te,e:Ke.e,label:Ke.label},"_se")}),delete Ce.selfEdges})})}function le(G){e.forEach(G.nodes(),function(P){var X=G.node(P);if(X.dummy==="selfedge"){var te=G.node(X.e.v),fe=te.x+te.width/2,xe=te.y,Ce=X.x-fe,Ke=te.height/2;G.setEdge(X.e,X.label),G.removeNode(P),X.label.points=[{x:fe+2*Ce/3,y:xe-Ke},{x:fe+5*Ce/6,y:xe-Ke},{x:fe+Ce,y:xe},{x:fe+5*Ce/6,y:xe+Ke},{x:fe+2*Ce/3,y:xe+Ke}],X.label.x=X.x,X.label.y=X.y}})}function ie(G,P){return e.mapValues(e.pick(G,P),Number)}function _e(G){var P={};return e.forEach(G,function(X,te){P[te.toLowerCase()]=X}),P}return cc}var fc,t0;function ex(){if(t0)return fc;t0=1;var e=Ae(),t=He(),r=at().Graph;fc={debugOrdering:n};function n(i){var s=t.buildLayerMatrix(i),a=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(i.nodes(),function(o){a.setNode(o,{label:o}),a.setParent(o,"layer"+i.node(o).rank)}),e.forEach(i.edges(),function(o){a.setEdge(o.v,o.w,{},o.name)}),e.forEach(s,function(o,c){var f="layer"+c;a.setNode(f,{rank:"same"}),e.reduce(o,function(l,p){return a.setEdge(l,p,{style:"invis"}),p})}),a}return fc}var lc,r0;function tx(){return r0||(r0=1,lc="0.8.5"),lc}var hc,n0;function rx(){return n0||(n0=1,hc={graphlib:at(),layout:HE(),debug:ex(),util:{time:He().time,notime:He().notime},version:tx()}),hc}var i0=rx(),nx=pf(i0);class Wr{constructor(t){this.id="dagre",this.options={},Object.assign(this.options,Wr.defaultOptions,t)}execute(t,r){return ye(this,void 0,void 0,function*(){return this.genericDagreLayout(!1,t,Object.assign(Object.assign({},this.options),r))})}assign(t,r){return ye(this,void 0,void 0,function*(){yield this.genericDagreLayout(!0,t,Object.assign(Object.assign({},this.options),r))})}genericDagreLayout(t,r,n){return ye(this,void 0,void 0,function*(){const{nodeSize:i}=n,s=new i0.graphlib.Graph;s.setGraph(n),s.setDefaultEdgeLabel(()=>({}));const a=r.getAllNodes(),o=r.getAllEdges();[...a,...o].some(({id:f})=>ve(f))&&console.error("Dagre layout only support string id, it will convert number to string."),r.getAllNodes().forEach(f=>{const{id:l}=f,p=Object.assign({},f.data);if(i!==void 0){const[v,y]=er(gt(i)?i(f):i);Object.assign(p,{width:v,height:y})}s.setNode(l.toString(),p)}),r.getAllEdges().forEach(({id:f,source:l,target:p})=>{s.setEdge(l.toString(),p.toString(),{id:f})}),nx.layout(s);const c={nodes:[],edges:[]};return s.nodes().forEach(f=>{const l=s.node(f);c.nodes.push({id:f,data:l}),t&&r.mergeNodeData(f,l)}),s.edges().forEach(f=>{const l=s.edge(f),{id:p}=l,v=c0(l,["id"]),{v:y,w:x}=f;c.edges.push({id:p,source:y,target:x,data:v}),t&&r.mergeEdgeData(p,v)}),c})}}Wr.defaultOptions={};class dc{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 r=this.rx-t.rx,n=this.ry-t.ry;return Math.hypot(r,n)}setPos(t,r){this.rx=t,this.ry=r}resetForce(){this.fx=0,this.fy=0}addForce(t){const r=t.rx-this.rx,n=t.ry-this.ry;let i=Math.hypot(r,n);i=i<1e-4?1e-4:i;const s=this.g*(this.degree+1)*(t.degree+1)/i;this.fx+=s*r/i,this.fy+=s*n/i}in(t){return t.contains(this.rx,this.ry)}add(t){const r=this.mass+t.mass,n=(this.rx*this.mass+t.rx*t.mass)/r,i=(this.ry*this.mass+t.ry*t.mass)/r,s=this.degree+t.degree,a={rx:n,ry:i,mass:r,degree:s};return new dc(a)}}class Kt{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,r){const n=this.length/2;return t<=this.xmid+n&&t>=this.xmid-n&&r<=this.ymid+n&&r>=this.ymid-n}NW(){const t=this.xmid-this.length/4,r=this.ymid+this.length/4,n=this.length/2,i={xmid:t,ymid:r,length:n};return new Kt(i)}NE(){const t=this.xmid+this.length/4,r=this.ymid+this.length/4,n=this.length/2,i={xmid:t,ymid:r,length:n};return new Kt(i)}SW(){const t=this.xmid-this.length/4,r=this.ymid-this.length/4,n=this.length/2,i={xmid:t,ymid:r,length:n};return new Kt(i)}SE(){const t=this.xmid+this.length/4,r=this.ymid-this.length/4,n=this.length/2,i={xmid:t,ymid:r,length:n};return new Kt(i)}}class Xt{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 Xt(this.quad.NW()),this.NE=new Xt(this.quad.NE()),this.SW=new Xt(this.quad.SW()),this.SE=new Xt(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 r=this.quad?this.quad.getLength():0,n=this.body.distanceTo(t);r/n<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t))}}}const ix={center:[0,0],width:300,height:300,kr:5,kg:1,mode:"normal",preventOverlap:!1,dissuadeHubs:!1,maxIteration:0,ks:.1,ksmax:10,tao:.1};class sx{constructor(t={}){this.options=t,this.id="forceAtlas2",this.options=Object.assign(Object.assign({},ix),t)}execute(t,r){return ye(this,void 0,void 0,function*(){return this.genericForceAtlas2Layout(!1,t,r)})}assign(t,r){return ye(this,void 0,void 0,function*(){yield this.genericForceAtlas2Layout(!0,t,r)})}genericForceAtlas2Layout(t,r,n){return ye(this,void 0,void 0,function*(){const i=r.getAllEdges(),s=r.getAllNodes(),a=this.formatOptions(n,s.length),{width:o,height:c,prune:f,maxIteration:l,nodeSize:p,center:v}=a;if(!s?.length||s.length===1)return It(r,t,v);const y=s.map(w=>et(w,[o,c])),x=i.filter(w=>{const{source:E,target:N}=w;return E!==N}),_=new De({nodes:y,edges:x}),b=this.getSizes(_,p);if(this.run(_,r,l,b,t,a),f){for(let E=0;E<x.length;E+=1){const{source:N,target:S}=x[E],q=_.getDegree(N),A=_.getDegree(N);if(q<=1){const j=_.getNode(S);_.mergeNodeData(N,{x:j.data.x,y:j.data.y})}else if(A<=1){const j=_.getNode(N);_.mergeNodeData(S,{x:j.data.x,y:j.data.y})}}const w=Object.assign(Object.assign({},a),{prune:!1,barnesHut:!1});this.run(_,r,100,b,t,w)}return{nodes:y,edges:i}})}getSizes(t,r){const n=t.getAllNodes(),i={};for(let s=0;s<n.length;s+=1){const a=n[s];i[a.id]=mn(r,void 0)(a)}return i}formatOptions(t={},r){const n=Object.assign(Object.assign({},this.options),t),{center:i,width:s,height:a,barnesHut:o,prune:c,maxIteration:f,kr:l,kg:p}=n;return n.width=!s&&typeof window<"u"?window.innerWidth:s,n.height=!a&&typeof window<"u"?window.innerHeight:a,n.center=i||[n.width/2,n.height/2],o===void 0&&r>250&&(n.barnesHut=!0),c===void 0&&r>100&&(n.prune=!0),f===0&&!c?(n.maxIteration=250,r<=200&&r>100?n.maxIteration=1e3:r>200&&(n.maxIteration=1200)):f===0&&c&&(n.maxIteration=100,r<=200&&r>100?n.maxIteration=500:r>200&&(n.maxIteration=950)),l||(n.kr=50,r>100&&r<=500?n.kr=20:r>500&&(n.kr=1)),p||(n.kg=20,r>100&&r<=500?n.kg=10:r>500&&(n.kg=1)),n}run(t,r,n,i,s,a){const{kr:o,barnesHut:c,onTick:f}=a,l=t.getAllNodes();let p=0,v=n;const y={},x={},_={};for(let b=0;b<l.length;b+=1){const{data:w,id:E}=l[b];if(y[E]=[0,0],c){const N={id:b,rx:w.x,ry:w.y,mass:1,g:o,degree:t.getDegree(E)};_[E]=new dc(N)}}for(;v>0;)p=this.oneStep(t,{iter:v,preventOverlapIters:50,krPrime:100,sg:p,forces:y,preForces:x,bodies:_,sizes:i},a),v--,f?.({nodes:l,edges:r.getAllEdges()});return t}oneStep(t,r,n){const{iter:i,preventOverlapIters:s,krPrime:a,sg:o,preForces:c,bodies:f,sizes:l}=r;let{forces:p}=r;const{preventOverlap:v,barnesHut:y}=n,x=t.getAllNodes();for(let _=0;_<x.length;_+=1){const{id:b}=x[_];c[b]=[...p[b]],p[b]=[0,0]}return p=this.getAttrForces(t,i,s,l,p,n),y&&(v&&i>s||!v)?p=this.getOptRepGraForces(t,p,f,n):p=this.getRepGraForces(t,i,s,p,a,l,n),this.updatePos(t,p,c,o,n)}getAttrForces(t,r,n,i,s,a){const{preventOverlap:o,dissuadeHubs:c,mode:f,prune:l}=a,p=t.getAllEdges();for(let v=0;v<p.length;v+=1){const{source:y,target:x}=p[v],_=t.getNode(y),b=t.getNode(x),w=t.getDegree(y),E=t.getDegree(x);if(l&&(w<=1||E<=1))continue;const N=[b.data.x-_.data.x,b.data.y-_.data.y];let S=Math.hypot(N[0],N[1]);S=S<1e-4?1e-4:S,N[0]=N[0]/S,N[1]=N[1]/S,o&&r<n&&(S=S-i[y]-i[x]);let q=S,A=q;f==="linlog"&&(q=Math.log(1+S),A=q),c&&(q=S/w,A=S/E),o&&r<n&&S<=0?(q=0,A=0):o&&r<n&&S>0&&(q=S,A=S),s[y][0]+=q*N[0],s[x][0]-=A*N[0],s[y][1]+=q*N[1],s[x][1]-=A*N[1]}return s}getOptRepGraForces(t,r,n,i){const{kg:s,center:a,prune:o}=i,c=t.getAllNodes(),f=c.length;let l=9e10,p=-9e10,v=9e10,y=-9e10;for(let E=0;E<f;E+=1){const{id:N,data:S}=c[E];o&&t.getDegree(N)<=1||(n[N].setPos(S.x,S.y),S.x>=p&&(p=S.x),S.x<=l&&(l=S.x),S.y>=y&&(y=S.y),S.y<=v&&(v=S.y))}const x=Math.max(p-l,y-v),_={xmid:(p+l)/2,ymid:(y+v)/2,length:x,massCenter:a,mass:f},b=new Kt(_),w=new Xt(b);for(let E=0;E<f;E+=1){const{id:N}=c[E];o&&t.getDegree(N)<=1||n[N].in(b)&&w.insert(n[N])}for(let E=0;E<f;E+=1){const{id:N,data:S}=c[E],q=t.getDegree(N);if(o&&q<=1)continue;n[N].resetForce(),w.updateForce(n[N]),r[N][0]-=n[N].fx,r[N][1]-=n[N].fy;const A=[S.x-a[0],S.y-a[1]];let j=Math.hypot(A[0],A[1]);j=j<1e-4?1e-4:j,A[0]=A[0]/j,A[1]=A[1]/j;const I=s*(q+1);r[N][0]-=I*A[0],r[N][1]-=I*A[1]}return r}getRepGraForces(t,r,n,i,s,a,o){const{preventOverlap:c,kr:f,kg:l,center:p,prune:v}=o,y=t.getAllNodes(),x=y.length;for(let _=0;_<x;_+=1){const b=y[_],w=t.getDegree(b.id);for(let q=_+1;q<x;q+=1){const A=y[q],j=t.getDegree(A.id);if(v&&(w<=1||j<=1))continue;const I=[A.data.x-b.data.x,A.data.y-b.data.y];let D=Math.hypot(I[0],I[1]);D=D<1e-4?1e-4:D,I[0]=I[0]/D,I[1]=I[1]/D,c&&r<n&&(D=D-a[b.id]-a[A.id]);let z=f*(w+1)*(j+1)/D;c&&r<n&&D<0?z=s*(w+1)*(j+1):c&&r<n&&D===0?z=0:c&&r<n&&D>0&&(z=f*(w+1)*(j+1)/D),i[b.id][0]-=z*I[0],i[A.id][0]+=z*I[0],i[b.id][1]-=z*I[1],i[A.id][1]+=z*I[1]}const E=[b.data.x-p[0],b.data.y-p[1]],N=Math.hypot(E[0],E[1]);E[0]=E[0]/N,E[1]=E[1]/N;const S=l*(w+1);i[b.id][0]-=S*E[0],i[b.id][1]-=S*E[1]}return i}updatePos(t,r,n,i,s){const{ks:a,tao:o,prune:c,ksmax:f}=s,l=t.getAllNodes(),p=l.length,v=[],y=[];let x=0,_=0,b=i;for(let E=0;E<p;E+=1){const{id:N}=l[E],S=t.getDegree(N);if(c&&S<=1)continue;const q=[r[N][0]-n[N][0],r[N][1]-n[N][1]],A=Math.hypot(q[0],q[1]),j=[r[N][0]+n[N][0],r[N][1]+n[N][1]],I=Math.hypot(j[0],j[1]);v[E]=A,y[E]=I/2,x+=(S+1)*v[E],_+=(S+1)*y[E]}const w=b;b=o*_/x,w!==0&&(b=b>1.5*w?1.5*w:b);for(let E=0;E<p;E+=1){const{id:N,data:S}=l[E],q=t.getDegree(N);if(c&&q<=1||ve(S.fx)&&ve(S.fy))continue;let A=a*b/(1+b*Math.sqrt(v[E])),j=Math.hypot(r[N][0],r[N][1]);j=j<1e-4?1e-4:j;const I=f/j;A=A>I?I:A;const D=A*r[N][0],z=A*r[N][1];t.mergeNodeData(N,{x:S.x+D,y:S.y+z})}return b}}const ox={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},ax=800;class ux{constructor(t={}){this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=Object.assign(Object.assign({},ox),t)}execute(t,r){return ye(this,void 0,void 0,function*(){return this.genericFruchtermanLayout(!1,t,r)})}assign(t,r){return ye(this,void 0,void 0,function*(){yield this.genericFruchtermanLayout(!0,t,r)})}stop(){this.timeInterval&&typeof window<"u"&&window.clearInterval(this.timeInterval),this.running=!1}tick(t=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let n=0;n<t;n++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);const r={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&r.nodes.forEach(n=>this.lastGraph.mergeNodeData(n.id,{x:n.data.x,y:n.data.y,z:this.options.dimensions===3?n.data.z:void 0})),r}genericFruchtermanLayout(t,r,n){return ye(this,void 0,void 0,function*(){if(this.running)return;const i=this.formatOptions(n),{dimensions:s,width:a,height:o,center:c,clustering:f,nodeClusterBy:l,maxIteration:p,onTick:v}=i,y=r.getAllNodes(),x=r.getAllEdges();if(!y?.length){const N={nodes:[],edges:x};return this.lastResult=N,N}if(y.length===1){t&&r.mergeNodeData(y[0].id,{x:c[0],y:c[1],z:s===3?c[2]:void 0});const N={nodes:[Object.assign(Object.assign({},y[0]),{data:Object.assign(Object.assign({},y[0].data),{x:c[0],y:c[1],z:s===3?c[2]:void 0})})],edges:x};return this.lastResult=N,N}const _=y.map(N=>et(N,[a,o])),b=new De({nodes:_,edges:x}),w={};if(f&&_.forEach(N=>{const S=N.data[l];w[S]||(w[S]={name:S,cx:0,cy:0,count:0})}),this.lastLayoutNodes=_,this.lastLayoutEdges=x,this.lastAssign=t,this.lastGraph=b,this.lastOptions=i,this.lastClusterMap=w,typeof window>"u")return;let E=0;return new Promise(N=>{this.timeInterval=window.setInterval(()=>{if(!this.running){N({nodes:_,edges:x});return}this.runOneStep(b,w,i),t&&_.forEach(({id:S,data:q})=>r.mergeNodeData(S,{x:q.x,y:q.y,z:s===3?q.z:void 0})),v?.({nodes:_,edges:x}),E++,E>=p&&(window.clearInterval(this.timeInterval),N({nodes:_,edges:x}))},0),this.running=!0})})}formatOptions(t={}){const r=Object.assign(Object.assign({},this.options),t),{clustering:n,nodeClusterBy:i}=r,{center:s,width:a,height:o}=r;return r.width=!a&&typeof window<"u"?window.innerWidth:a,r.height=!o&&typeof window<"u"?window.innerHeight:o,r.center=s||[r.width/2,r.height/2],r.clustering=n&&!!i,r}runOneStep(t,r,n){const{dimensions:i,height:s,width:a,gravity:o,center:c,speed:f,clustering:l,nodeClusterBy:p,clusterGravity:v}=n,y=s*a,x=Math.sqrt(y)/10,_=t.getAllNodes(),b=y/(_.length+1),w=Math.sqrt(b),E={};if(this.applyCalculate(t,E,w,b),l){for(const S in r)r[S].cx=0,r[S].cy=0,r[S].count=0;_.forEach(S=>{const{data:q}=S,A=r[q[p]];ve(q.x)&&(A.cx+=q.x),ve(q.y)&&(A.cy+=q.y),A.count++});for(const S in r)r[S].cx/=r[S].count,r[S].cy/=r[S].count;const N=v||o;_.forEach((S,q)=>{const{id:A,data:j}=S;if(!ve(j.x)||!ve(j.y))return;const I=r[j[p]],D=Math.sqrt((j.x-I.cx)*(j.x-I.cx)+(j.y-I.cy)*(j.y-I.cy)),z=w*N;E[A].x-=z*(j.x-I.cx)/D,E[A].y-=z*(j.y-I.cy)/D})}_.forEach((N,S)=>{const{id:q,data:A}=N;if(!ve(A.x)||!ve(A.y))return;const j=.01*w*o;E[q].x-=j*(A.x-c[0]),E[q].y-=j*(A.y-c[1]),i===3&&(E[q].z-=j*(A.z-c[2]))}),_.forEach((N,S)=>{const{id:q,data:A}=N;if(ve(A.fx)&&ve(A.fy)){A.x=A.fx,A.y=A.fy,i===3&&(A.z=A.fz);return}if(!ve(A.x)||!ve(A.y))return;const j=Math.sqrt(E[q].x*E[q].x+E[q].y*E[q].y+(i===3?E[q].z*E[q].z:0));if(j>0){const I=Math.min(x*(f/ax),j);t.mergeNodeData(q,{x:A.x+E[q].x/j*I,y:A.y+E[q].y/j*I,z:i===3?A.z+E[q].z/j*I:void 0})}})}applyCalculate(t,r,n,i){this.calRepulsive(t,r,i),this.calAttractive(t,r,n)}calRepulsive(t,r,n){const i=t.getAllNodes();i.forEach(({data:s,id:a},o)=>{r[a]={x:0,y:0,z:0},i.forEach(({data:c,id:f},l)=>{if(o<=l||!ve(s.x)||!ve(c.x)||!ve(s.y)||!ve(c.y))return;let p=s.x-c.x,v=s.y-c.y,y=this.options.dimensions===3?s.z-c.z:0,x=p*p+v*v+y*y;x===0&&(x=1,p=.01,v=.01,y=.01);const _=n/x,b=p*_,w=v*_,E=y*_;r[a].x+=b,r[a].y+=w,r[f].x-=b,r[f].y-=w,this.options.dimensions===3&&(r[a].z+=E,r[f].z-=E)})})}calAttractive(t,r,n){t.getAllEdges().forEach(s=>{const{source:a,target:o}=s;if(!a||!o||a===o)return;const{data:c}=t.getNode(a),{data:f}=t.getNode(o);if(!ve(f.x)||!ve(c.x)||!ve(f.y)||!ve(c.y))return;const l=f.x-c.x,p=f.y-c.y,v=this.options.dimensions===3?f.z-c.z:0,y=Math.sqrt(l*l+p*p+v*v)/n,x=l*y,_=p*y,b=v*y;r[a].x+=x,r[a].y+=_,r[o].x-=x,r[o].y-=_,this.options.dimensions===3&&(r[a].z+=b,r[o].z-=b)})}}const cx={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 fx{constructor(t={}){this.options=t,this.id="grid",this.options=Object.assign(Object.assign({},cx),t)}execute(t,r){return ye(this,void 0,void 0,function*(){return this.genericGridLayout(!1,t,r)})}assign(t,r){return ye(this,void 0,void 0,function*(){yield this.genericGridLayout(!0,t,r)})}genericGridLayout(t,r,n){return ye(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),n),{begin:s=[0,0],condense:a,preventOverlapPadding:o,preventOverlap:c,rows:f,cols:l,nodeSpacing:p,nodeSize:v,width:y,height:x,position:_}=i;let{sortBy:b}=i;const w=r.getAllNodes(),E=r.getAllEdges(),N=w?.length;if(!N||N===1)return It(r,t,s);const S=w.map(J=>et(J));b!=="id"&&(!Qt(b)||S[0].data[b]===void 0)&&(b="degree"),b==="degree"?S.sort((J,ae)=>r.getDegree(ae.id,"both")-r.getDegree(J.id,"both")):b==="id"?S.sort((J,ae)=>ve(ae.id)&&ve(J.id)?ae.id-J.id:`${J.id}`.localeCompare(`${ae.id}`)):S.sort((J,ae)=>ae.data[b]-J.data[b]);const q=!y&&typeof window<"u"?window.innerWidth:y,A=!x&&typeof window<"u"?window.innerHeight:x,j=N,I={rows:f,cols:l};if(f!=null&&l!=null)I.rows=f,I.cols=l;else if(f!=null&&l==null)I.rows=f,I.cols=Math.ceil(j/I.rows);else if(f==null&&l!=null)I.cols=l,I.rows=Math.ceil(j/I.cols);else{const J=Math.sqrt(j*A/q);I.rows=Math.round(J),I.cols=Math.round(q/A*J)}if(I.rows=Math.max(I.rows,1),I.cols=Math.max(I.cols,1),I.cols*I.rows>j){const J=Yr(I),ae=Kr(I);(J-1)*ae>=j?Yr(I,J-1):(ae-1)*J>=j&&Kr(I,ae-1)}else for(;I.cols*I.rows<j;){const J=Yr(I),ae=Kr(I);(ae+1)*J>=j?Kr(I,ae+1):Yr(I,J+1)}let D=a?0:q/I.cols,z=a?0:A/I.rows;if(c||p){const J=At(10,p),ae=vn(30,v,!1);S.forEach(be=>{(!be.data.x||!be.data.y)&&(be.data.x=0,be.data.y=0);const Z=r.getNode(be.id),[ue,ge]=er(ae(Z)||30),le=J!==void 0?J(be):o,ie=ue+le,_e=ge+le;D=Math.max(D,ie),z=Math.max(z,_e)})}const $={},V={row:0,col:0},Y={};for(let J=0;J<S.length;J++){const ae=S[J];let be;if(_&&(be=_(r.getNode(ae.id))),be&&(be.row!==void 0||be.col!==void 0)){const Z={row:be.row,col:be.col};if(Z.col===void 0)for(Z.col=0;gc($,Z);)Z.col++;else if(Z.row===void 0)for(Z.row=0;gc($,Z);)Z.row++;Y[ae.id]=Z,s0($,Z)}lx(ae,s,D,z,Y,I,V,$)}const ee={nodes:S,edges:E};return t&&S.forEach(J=>{r.mergeNodeData(J.id,{x:J.data.x,y:J.data.y})}),ee})}}const Yr=(e,t)=>{let r;const n=e.rows||5,i=e.cols||5;return t==null?r=Math.min(n,i):Math.min(n,i)===e.rows?e.rows=t:e.cols=t,r},Kr=(e,t)=>{let r;const n=e.rows||5,i=e.cols||5;return t==null?r=Math.max(n,i):Math.max(n,i)===e.rows?e.rows=t:e.cols=t,r},gc=(e,t)=>e[`c-${t.row}-${t.col}`]||!1,s0=(e,t)=>e[`c-${t.row}-${t.col}`]=!0,o0=(e,t)=>{const r=e.cols||5;t.col++,t.col>=r&&(t.col=0,t.row++)},lx=(e,t,r,n,i,s,a,o)=>{let c,f;const l=i[e.id];if(l)c=l.col*r+r/2+t[0],f=l.row*n+n/2+t[1];else{for(;gc(o,a);)o0(s,a);c=a.col*r+r/2+t[0],f=a.row*n+n/2+t[1],s0(o,a),o0(s,a)}e.data.x=c,e.data.y=f},hx=(e,t,r)=>{try{const n=Mt.mul(Mt.pow(t,2),-.5),i=n.mean("row"),s=n.mean("column"),a=n.mean();n.add(a).subRowVector(i).subColumnVector(s);const o=new wf(n),c=Mt.sqrt(o.diagonalMatrix).diagonal();return o.leftSingularVectors.toJSON().map(f=>Mt.mul([f],[c]).toJSON()[0].splice(0,e))}catch{const i=[];for(let s=0;s<t.length;s++){const a=Math.random()*r,o=Math.random()*r;i.push([a,o])}return i}},dx=800,gx={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},px=(e,t)=>{const r=Object.assign(Object.assign({},gx),t),{positions:n,iterations:i,width:s,k:a,speed:o=100,strictRadial:c,focusIdx:f,radii:l=[],nodeSizeFunc:p}=r,v=e.getAllNodes(),y=[],x=s/10;for(let _=0;_<i;_++)n.forEach((b,w)=>{y[w]={x:0,y:0}}),vx(v,n,y,a,l,p),mx(n,y,o,c,f,x,s,l);return n},vx=(e,t,r,n,i,s)=>{t.forEach((a,o)=>{r[o]={x:0,y:0},t.forEach((c,f)=>{if(o===f||i[o]!==i[f])return;let l=a.x-c.x,p=a.y-c.y,v=Math.sqrt(l*l+p*p);if(v===0){v=1;const y=o>f?1:-1;l=.01*y,p=.01*y}if(v<s(e[o])/2+s(e[f])/2){const y=n*n/v;r[o].x+=l/v*y,r[o].y+=p/v*y}})})},mx=(e,t,r,n,i,s,a,o)=>{const c=s||a/10;return n&&t.forEach((f,l)=>{const p=e[l].x-e[i].x,v=e[l].y-e[i].y,y=Math.sqrt(p*p+v*v);let x=v/y,_=-p/y;const b=Math.sqrt(f.x*f.x+f.y*f.y);let w=Math.acos((x*f.x+_*f.y)/b);w>Math.PI/2&&(w-=Math.PI/2,x*=-1,_*=-1);const E=Math.cos(w)*b;f.x=x*E,f.y=_*E}),e.forEach((f,l)=>{if(l===i)return;const p=Math.sqrt(t[l].x*t[l].x+t[l].y*t[l].y);if(p>0&&l!==i){const v=Math.min(c*(r/dx),p);if(f.x+=t[l].x/p*v,f.y+=t[l].y/p*v,n){let y=f.x-e[i].x,x=f.y-e[i].y;const _=Math.sqrt(y*y+x*x);y=y/_*o[l],x=x/_*o[l],f.x=e[i].x+y,f.y=e[i].y+x}}}),e},yx={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10};class wx{constructor(t={}){this.options=t,this.id="radial",this.options=Object.assign(Object.assign({},yx),t)}execute(t,r){return ye(this,void 0,void 0,function*(){return this.genericRadialLayout(!1,t,r)})}assign(t,r){return ye(this,void 0,void 0,function*(){yield this.genericRadialLayout(!0,t,r)})}genericRadialLayout(t,r,n){return ye(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),n),{width:s,height:a,center:o,focusNode:c,unitRadius:f,nodeSize:l,nodeSpacing:p,strictRadial:v,preventOverlap:y,maxPreventOverlapIteration:x,sortBy:_,linkDistance:b=50,sortStrength:w=10,maxIteration:E=1e3}=i,N=r.getAllNodes(),S=r.getAllEdges(),q=!s&&typeof window<"u"?window.innerWidth:s,A=!a&&typeof window<"u"?window.innerHeight:a,j=o||[q/2,A/2];if(!N?.length||N.length===1)return It(r,t,j);let I=N[0];if(Qt(c)){for(let te=0;te<N.length;te++)if(N[te].id===c){I=N[te];break}}else I=c||N[0];const D=Ex(N,I.id),z=sf({nodes:N,edges:S}),$=nf(z),V=Nx($,D);xx($,D,V+1);const Y=$[D];let ee=q-j[0]>j[0]?j[0]:q-j[0],J=A-j[1]>j[1]?j[1]:A-j[1];ee===0&&(ee=q/2),J===0&&(J=A/2);const ae=Math.min(ee,J),be=Math.max(...Y),Z=[],ue=f||ae/be;Y.forEach((te,fe)=>{Z[fe]=te*ue});const ge=bx(N,$,b,Z,ue,_,w),le=_x(ge),ie=hx(b,ge,b);let _e=ie.map(([te,fe])=>({x:(isNaN(te)?Math.random()*b:te)-ie[D][0],y:(isNaN(fe)?Math.random()*b:fe)-ie[D][1]}));this.run(E,_e,le,ge,Z,D);let G;if(y){G=mn(l,p);const te={nodes:N,nodeSizeFunc:G,positions:_e,radii:Z,height:A,width:q,strictRadial:!!v,focusIdx:D,iterations:x||200,k:_e.length/4.5};_e=px(r,te)}const P=[];return _e.forEach((te,fe)=>{const xe=et(N[fe]);xe.data.x=te.x+j[0],xe.data.y=te.y+j[1],P.push(xe)}),t&&P.forEach(te=>r.mergeNodeData(te.id,{x:te.data.x,y:te.data.y})),{nodes:P,edges:S}})}run(t,r,n,i,s,a){for(let o=0;o<=t;o++){const c=o/t;this.oneIteration(c,r,s,i,n,a)}}oneIteration(t,r,n,i,s,a){const o=1-t;r.forEach((c,f)=>{const l=of(c,{x:0,y:0}),p=l===0?0:1/l;if(f===a)return;let v=0,y=0,x=0;r.forEach((b,w)=>{if(f===w)return;const E=of(c,b),N=E===0?0:1/E,S=i[w][f];x+=s[f][w],v+=s[f][w]*(b.x+S*(c.x-b.x)*N),y+=s[f][w]*(b.y+S*(c.y-b.y)*N)});const _=n[f]===0?0:1/n[f];x*=o,x+=t*_*_,v*=o,v+=t*_*c.x*p,c.x=v/x,y*=o,y+=t*_*c.y*p,c.y=y/x})}}const bx=(e,t,r,n,i,s,a)=>{if(!e)return[];const o=[];if(t){const c={};t.forEach((f,l)=>{const p=[];f.forEach((v,y)=>{var x,_;if(l===y)p.push(0);else if(n[l]===n[y])if(s==="data")p.push(v*(Math.abs(l-y)*a)/(n[l]/i));else if(s){let b,w;if(c[e[l].id])b=c[e[l].id];else{const E=(s==="id"?e[l].id:(x=e[l].data)===null||x===void 0?void 0:x[s])||0;Qt(E)?b=E.charCodeAt(0):b=E,c[e[l].id]=b}if(c[e[y].id])w=c[e[y].id];else{const E=(s==="id"?e[y].id:(_=e[y].data)===null||_===void 0?void 0:_[s])||0;Qt(E)?w=E.charCodeAt(0):w=E,c[e[y].id]=w}p.push(v*(Math.abs(b-w)*a)/(n[l]/i))}else p.push(v*r/(n[l]/i));else{const b=(r+i)/2;p.push(v*b)}}),o.push(p)})}return o},_x=e=>{const t=e.length,r=e[0].length,n=[];for(let i=0;i<t;i++){const s=[];for(let a=0;a<r;a++)e[i][a]!==0?s.push(1/(e[i][a]*e[i][a])):s.push(0);n.push(s)}return n},Ex=(e,t)=>{let r=-1;return e.forEach((n,i)=>{n.id===t&&(r=i)}),Math.max(r,0)},xx=(e,t,r)=>{const n=e.length;for(let i=0;i<n;i++)if(e[t][i]===1/0){e[t][i]=r,e[i][t]=r;for(let s=0;s<n;s++)e[i][s]!==1/0&&e[t][s]===1/0&&(e[t][s]=r+e[i][s],e[s][t]=r+e[i][s])}for(let i=0;i<n;i++)if(i!==t){for(let s=0;s<n;s++)if(e[i][s]===1/0){let a=Math.abs(e[t][i]-e[t][s]);a=a===0?1:a,e[i][s]=a}}},Nx=(e,t)=>{let r=0;for(let n=0;n<e[t].length;n++)e[t][n]!==1/0&&(r=e[t][n]>r?e[t][n]:r);return r},Mx={center:[0,0],width:300,height:300};class Sx{constructor(t={}){this.options=t,this.id="random",this.options=Object.assign(Object.assign({},Mx),t)}execute(t,r){return ye(this,void 0,void 0,function*(){return this.genericRandomLayout(!1,t,r)})}assign(t,r){return ye(this,void 0,void 0,function*(){yield this.genericRandomLayout(!0,t,r)})}genericRandomLayout(t,r,n){return ye(this,void 0,void 0,function*(){const i=Object.assign(Object.assign({},this.options),n),{center:s,width:a,height:o}=i,c=r.getAllNodes(),f=.9,l=!a&&typeof window<"u"?window.innerWidth:a,p=!o&&typeof window<"u"?window.innerHeight:o,v=s||[l/2,p/2],y=[];return c&&c.forEach(_=>{y.push({id:_.id,data:{x:(Math.random()-.5)*f*l+v[0],y:(Math.random()-.5)*f*p+v[1]}})}),t&&y.forEach(_=>r.mergeNodeData(_.id,{x:_.data.x,y:_.data.y})),{nodes:y,edges:r.getAllEdges()}})}}const qx={circular:Oy,concentric:yn,mds:bf,random:Sx,grid:fx,radial:wx,force:hf,d3force:Af,"d3-force-3d":B1,fruchterman:ux,forceAtlas2:sx,dagre:Wr,antvDagre:Sy,comboCombined:Lw};let wt;rn({stopLayout(){wt?.stop&&wt.stop()},calculateLayout(e,t){return ye(this,void 0,void 0,function*(){const{layout:{id:r,options:n,iterations:i},nodes:s,edges:a}=e,o=new De({nodes:s,edges:a}),c=qx[r];if(c)wt=new c(n);else throw new Error(`Unknown layout id: ${r}`);let f=yield wt.execute(o);return _f(wt)&&(wt.stop(),f=wt.tick(i)),[f,t]})}})})();