!(function(){var cc=Object.defineProperty,fc=Object.defineProperties;var lc=Object.getOwnPropertyDescriptors;var vi=Object.getOwnPropertySymbols;var dc=Object.prototype.hasOwnProperty,hc=Object.prototype.propertyIsEnumerable;var ts=(Xe,Ie,me)=>Ie in Xe?cc(Xe,Ie,{enumerable:!0,configurable:!0,writable:!0,value:me}):Xe[Ie]=me,Gn=(Xe,Ie)=>{for(var me in Ie||(Ie={}))dc.call(Ie,me)&&ts(Xe,me,Ie[me]);if(vi)for(var me of vi(Ie))hc.call(Ie,me)&&ts(Xe,me,Ie[me]);return Xe},es=(Xe,Ie)=>fc(Xe,lc(Ie));var be=(Xe,Ie,me)=>ts(Xe,typeof Ie!="symbol"?Ie+"":Ie,me);(function(){var Xe={48202:function(w,P,a){"use strict";var l,x=Object.defineProperty,E=T=>{throw TypeError(T)},b=Math.pow,v=(T,u,c)=>u in T?x(T,u,{enumerable:!0,configurable:!0,writable:!0,value:c}):T[u]=c,N=(T,u,c)=>v(T,typeof u!="symbol"?u+"":u,c),S=(T,u,c)=>u.has(T)||E("Cannot "+c),M=(T,u,c)=>(S(T,u,"read from private field"),c?c.call(T):u.get(T)),A=(T,u,c)=>u.has(T)?E("Cannot add the same private member more than once"):u instanceof WeakSet?u.add(T):u.set(T,c),I=(T,u,c,i)=>(S(T,u,"write to private field"),i?i.call(T,c):u.set(T,c),c),j=(T,u,c)=>(S(T,u,"access private method"),c),D,$,K;l={value:!0};var ot=a(44091),nt=a(75823);const _=" ".repeat(2),et=" ".repeat(4);function tt(){return it(this)}function it(T,u={}){const{maxRows:c=15,maxColumns:i=10,maxNumSize:f=8,padMinus:m="auto"}=u;return`${T.constructor.name} { ${_}[ ${et}${at(T,c,i,f,m)} ${_}] ${_}rows: ${T.rows} ${_}columns: ${T.columns} }`}function at(T,u,c,i,f){const{rows:m,columns:k}=T,B=Math.min(m,u),G=Math.min(k,c),V=[];if(f==="auto"){f=!1;t:for(let rt=0;rt=0&&c?` ${ht(T,u-1)}`:ht(T,u)).padEnd(u)}function ht(T,u){let c=T.toString();if(c.length<=u)return c;let i=T.toFixed(u);if(i.length>u&&(i=T.toFixed(Math.max(0,u-(i.length-u)))),i.length<=u&&!i.startsWith("0.000")&&!i.startsWith("-0.000"))return i;let f=T.toExponential(u);return f.length>u&&(f=T.toExponential(Math.max(0,u-(f.length-u)))),f.slice(0)}function dt(T,u){T.prototype.add=function(i){return typeof i=="number"?this.addS(i):this.addM(i)},T.prototype.addS=function(i){for(let f=0;f>i);return this},T.prototype.signPropagatingRightShiftM=function(i){if(i=u.checkMatrix(i),this.rows!==i.rows||this.columns!==i.columns)throw new RangeError("Matrices dimensions must be equal");for(let f=0;f>i.get(f,m));return this},T.signPropagatingRightShift=function(i,f){return new u(i).signPropagatingRightShift(f)},T.prototype.rightShift=function(i){return typeof i=="number"?this.rightShiftS(i):this.rightShiftM(i)},T.prototype.rightShiftS=function(i){for(let f=0;f>>i);return this},T.prototype.rightShiftM=function(i){if(i=u.checkMatrix(i),this.rows!==i.rows||this.columns!==i.columns)throw new RangeError("Matrices dimensions must be equal");for(let f=0;f>>i.get(f,m));return this},T.rightShift=function(i,f){return new u(i).rightShift(f)},T.prototype.zeroFillRightShift=T.prototype.rightShift,T.prototype.zeroFillRightShiftS=T.prototype.rightShiftS,T.prototype.zeroFillRightShiftM=T.prototype.rightShiftM,T.zeroFillRightShift=T.rightShift,T.prototype.not=function(){for(let i=0;ii)throw new RangeError("Row index out of range")}function yt(T,u,c){let i=c?T.columns:T.columns-1;if(u<0||u>i)throw new RangeError("Column index out of range")}function Mt(T,u){if(u.to1DArray&&(u=u.to1DArray()),u.length!==T.columns)throw new RangeError("vector size must be the same as the number of columns");return u}function St(T,u){if(u.to1DArray&&(u=u.to1DArray()),u.length!==T.rows)throw new RangeError("vector size must be the same as the number of rows");return u}function kt(T,u){if(!ot.isAnyArray(u))throw new TypeError("row indices must be an array");for(let c=0;c=T.rows)throw new RangeError("row indices are out of range")}function Vt(T,u){if(!ot.isAnyArray(u))throw new TypeError("column indices must be an array");for(let c=0;c=T.columns)throw new RangeError("column indices are out of range")}function qt(T,u,c,i,f){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(ce("startRow",u),ce("endRow",c),ce("startColumn",i),ce("endColumn",f),u>c||i>f||u<0||u>=T.rows||c<0||c>=T.rows||i<0||i>=T.columns||f<0||f>=T.columns)throw new RangeError("Submatrix indices are out of range")}function te(T,u=0){let c=[];for(let i=0;i=m)throw new RangeError("min must be smaller than max");let B=m-f,G=new It(u,c);for(let V=0;Vi?(m=!0,i=c):(f=!1,m=!0);u++}return f}isReducedEchelonForm(){let u=0,c=0,i=-1,f=!0,m=!1;for(;ui?(m=!0,i=c):(f=!1,m=!0);for(let k=c+1;ku.get(f,i)&&(f=m);if(u.get(f,i)===0)i++;else{u.swapRows(c,f);let m=u.get(c,i);for(let k=i;k=0;)if(u.maxRow(f)===0)f--;else{let m=0,k=!1;for(;mc[i]&&(c[i]=this.get(i,f));return c}case"column":{const c=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let i=0;ic[f]&&(c[f]=this.get(i,f));return c}case void 0:{let c=this.get(0,0);for(let i=0;ic&&(c=this.get(i,f));return c}default:throw new Error(`invalid option: ${u}`)}}maxIndex(){ze(this);let u=this.get(0,0),c=[0,0];for(let i=0;iu&&(u=this.get(i,f),c[0]=i,c[1]=f);return c}min(u){if(this.isEmpty())return NaN;switch(u){case"row":{const c=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let i=0;ic&&(c=this.get(u,i));return c}maxRowIndex(u){xt(this,u),ze(this);let c=this.get(u,0),i=[u,0];for(let f=1;fc&&(c=this.get(u,f),i[1]=f);return i}minRow(u){if(xt(this,u),this.isEmpty())return NaN;let c=this.get(u,0);for(let i=1;ic&&(c=this.get(i,u));return c}maxColumnIndex(u){yt(this,u),ze(this);let c=this.get(0,u),i=[0,u];for(let f=1;fc&&(c=this.get(f,u),i[0]=f);return i}minColumn(u){if(yt(this,u),this.isEmpty())return NaN;let c=this.get(0,u);for(let i=1;i1;f/=2)f&1&&(c=c.mmul(i)),i=i.mmul(i);return c}strassen2x2(u){u=It.checkMatrix(u);let c=new It(2,2);const i=this.get(0,0),f=u.get(0,0),m=this.get(0,1),k=u.get(0,1),B=this.get(1,0),G=u.get(1,0),V=this.get(1,1),rt=u.get(1,1),Z=(i+V)*(f+rt),lt=(B+V)*f,At=i*(k-rt),ct=V*(G-f),pt=(i+m)*rt,Lt=(B-i)*(f+k),J=(m-V)*(G+rt),Ot=Z+ct-pt+J,Ct=At+pt,Kt=lt+ct,Zt=Z-lt+At+Lt;return c.set(0,0,Ot),c.set(0,1,Ct),c.set(1,0,Kt),c.set(1,1,Zt),c}strassen3x3(u){u=It.checkMatrix(u);let c=new It(3,3);const i=this.get(0,0),f=this.get(0,1),m=this.get(0,2),k=this.get(1,0),B=this.get(1,1),G=this.get(1,2),V=this.get(2,0),rt=this.get(2,1),Z=this.get(2,2),lt=u.get(0,0),At=u.get(0,1),ct=u.get(0,2),pt=u.get(1,0),Lt=u.get(1,1),J=u.get(1,2),Ot=u.get(2,0),Ct=u.get(2,1),Kt=u.get(2,2),Zt=(i+f+m-k-B-rt-Z)*Lt,ye=(i-k)*(-At+Lt),Ut=B*(-lt+At+pt-Lt-J-Ot+Kt),Yt=(-i+k+B)*(lt-At+Lt),ae=(k+B)*(-lt+At),H=i*lt,mt=(-i+V+rt)*(lt-ct+J),Rt=(-i+V)*(ct-J),Nt=(V+rt)*(-lt+ct),we=(i+f+m-B-G-V-rt)*J,ue=rt*(-lt+ct+pt-Lt-J-Ot+Ct),he=(-m+rt+Z)*(Lt+Ot-Ct),pe=(m-Z)*(Lt-Ct),Pe=m*Ot,Ze=(rt+Z)*(-Ot+Ct),Oe=(-m+B+G)*(J+Ot-Kt),_e=(m-G)*(J-Kt),sn=(B+G)*(-Ot+Kt),ne=f*pt,Te=G*Ct,Ge=k*ct,Be=V*At,Ae=Z*Kt,Ar=H+Pe+ne,Tr=Zt+Yt+ae+H+he+Pe+Ze,ar=H+mt+Nt+we+Pe+Oe+sn,ur=ye+Ut+Yt+H+Pe+Oe+_e,Xn=ye+Yt+ae+H+Te,jr=Pe+Oe+_e+sn+Ge,Ir=H+mt+Rt+ue+he+pe+Pe,Pr=he+pe+Pe+Ze+Be,Lr=H+mt+Rt+Nt+Ae;return c.set(0,0,Ar),c.set(0,1,Tr),c.set(0,2,ar),c.set(1,0,ur),c.set(1,1,Xn),c.set(1,2,jr),c.set(2,0,Ir),c.set(2,1,Pr),c.set(2,2,Lr),c}mmulStrassen(u){u=It.checkMatrix(u);let c=this.clone(),i=c.rows,f=c.columns,m=u.rows,k=u.columns;f!==m&&console.warn(`Multiplying ${i} x ${f} and ${m} x ${k} matrix: dimensions do not match.`);function B(Z,lt,At){let ct=Z.rows,pt=Z.columns;if(ct===lt&&pt===At)return Z;{let Lt=Wt.zeros(lt,At);return Lt=Lt.setSubMatrix(Z,0,0),Lt}}let G=Math.max(i,m),V=Math.max(f,k);c=B(c,G,V),u=B(u,G,V);function rt(Z,lt,At,ct){if(At<=512||ct<=512)return Z.mmul(lt);At%2===1&&ct%2===1?(Z=B(Z,At+1,ct+1),lt=B(lt,At+1,ct+1)):At%2===1?(Z=B(Z,At+1,ct),lt=B(lt,At+1,ct)):ct%2===1&&(Z=B(Z,At,ct+1),lt=B(lt,At,ct+1));let pt=parseInt(Z.rows/2,10),Lt=parseInt(Z.columns/2,10),J=Z.subMatrix(0,pt-1,0,Lt-1),Ot=lt.subMatrix(0,pt-1,0,Lt-1),Ct=Z.subMatrix(0,pt-1,Lt,Z.columns-1),Kt=lt.subMatrix(0,pt-1,Lt,lt.columns-1),Zt=Z.subMatrix(pt,Z.rows-1,0,Lt-1),ye=lt.subMatrix(pt,lt.rows-1,0,Lt-1),Ut=Z.subMatrix(pt,Z.rows-1,Lt,Z.columns-1),Yt=lt.subMatrix(pt,lt.rows-1,Lt,lt.columns-1),ae=rt(Wt.add(J,Ut),Wt.add(Ot,Yt),pt,Lt),H=rt(Wt.add(Zt,Ut),Ot,pt,Lt),mt=rt(J,Wt.sub(Kt,Yt),pt,Lt),Rt=rt(Ut,Wt.sub(ye,Ot),pt,Lt),Nt=rt(Wt.add(J,Ct),Yt,pt,Lt),we=rt(Wt.sub(Zt,J),Wt.add(Ot,Kt),pt,Lt),ue=rt(Wt.sub(Ct,Ut),Wt.add(ye,Yt),pt,Lt),he=Wt.add(ae,Rt);he.sub(Nt),he.add(ue);let pe=Wt.add(mt,Nt),Pe=Wt.add(H,Rt),Ze=Wt.sub(ae,H);Ze.add(mt),Ze.add(we);let Oe=Wt.zeros(2*he.rows,2*he.columns);return Oe=Oe.setSubMatrix(he,0,0),Oe=Oe.setSubMatrix(pe,he.rows,0),Oe=Oe.setSubMatrix(Pe,0,he.columns),Oe=Oe.setSubMatrix(Ze,he.rows,he.columns),Oe.subMatrix(0,At-1,0,ct-1)}return rt(c,u,G,V)}scaleRows(u={}){if(typeof u!="object")throw new TypeError("options must be an object");const{min:c=0,max:i=1}=u;if(!Number.isFinite(c))throw new TypeError("min must be a number");if(!Number.isFinite(i))throw new TypeError("max must be a number");if(c>=i)throw new RangeError("min must be smaller than max");let f=new It(this.rows,this.columns);for(let m=0;m0&&nt(k,{min:c,max:i,output:k}),f.setRow(m,k)}return f}scaleColumns(u={}){if(typeof u!="object")throw new TypeError("options must be an object");const{min:c=0,max:i=1}=u;if(!Number.isFinite(c))throw new TypeError("min must be a number");if(!Number.isFinite(i))throw new TypeError("max must be a number");if(c>=i)throw new RangeError("min must be smaller than max");let f=new It(this.rows,this.columns);for(let m=0;mi||c<0||c>=this.columns||i<0||i>=this.columns)throw new RangeError("Argument out of range");let f=new It(u.length,i-c+1);for(let m=0;m=this.rows)throw new RangeError(`Row index out of range: ${u[m]}`);f.set(m,k-c,this.get(u[m],k))}return f}subMatrixColumn(u,c,i){if(c===void 0&&(c=0),i===void 0&&(i=this.rows-1),c>i||c<0||c>=this.rows||i<0||i>=this.rows)throw new RangeError("Argument out of range");let f=new It(i-c+1,u.length);for(let m=0;m=this.columns)throw new RangeError(`Column index out of range: ${u[m]}`);f.set(k-c,m,this.get(k,u[m]))}return f}setSubMatrix(u,c,i){if(u=It.checkMatrix(u),u.isEmpty())return this;let f=c+u.rows-1,m=i+u.columns-1;qt(this,c,f,i,m);for(let k=0;ktypeof u=="number")}Wt.random=Wt.rand,Wt.randomInt=Wt.randInt,Wt.diagonal=Wt.diag,Wt.prototype.diagonal=Wt.prototype.diag,Wt.identity=Wt.eye,Wt.prototype.negate=Wt.prototype.neg,Wt.prototype.tensorProduct=Wt.prototype.kroneckerProduct;const an=class ns extends Wt{constructor(u,c){if(super(),A(this,D),N(this,"data"),ns.isMatrix(u))j(this,D,$).call(this,u.rows,u.columns),ns.copy(u,this);else if(Number.isInteger(u)&&u>=0)j(this,D,$).call(this,u,c);else if(ot.isAnyArray(u)){const i=u;if(u=i.length,c=u?i[0].length:0,typeof c!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let f=0;f=0)for(let c=0;c=0)I(this,K,new It(u,u));else if(I(this,K,new It(u)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return M(this,K).size}get rows(){return M(this,K).rows}get columns(){return M(this,K).columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(u){return It.isMatrix(u)&&u.klassType==="SymmetricMatrix"}static zeros(u){return new this(u)}static ones(u){return new this(u).fill(1)}clone(){const u=new rs(this.diagonalSize);for(const[c,i,f]of this.upperRightEntries())u.set(c,i,f);return u}toMatrix(){return new It(this)}get(u,c){return M(this,K).get(u,c)}set(u,c,i){return M(this,K).set(u,c,i),M(this,K).set(c,u,i),this}removeCross(u){return M(this,K).removeRow(u),M(this,K).removeColumn(u),this}addCross(u,c){c===void 0&&(c=u,u=this.diagonalSize);const i=c.slice();return i.splice(u,1),M(this,K).addRow(u,i),M(this,K).addColumn(u,c),this}applyMask(u){if(u.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const c=[];for(const[i,f]of u.entries())f||c.push(i);c.reverse();for(const i of c)this.removeCross(i);return this}toCompact(){const{diagonalSize:u}=this,c=new Array(u*(u+1)/2);for(let i=0,f=0,m=0;m=u&&(i=++f);return c}static fromCompact(u){const c=u.length,i=(Math.sqrt(8*c+1)-1)/2;if(!Number.isInteger(i))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(u)}`);const f=new rs(i);for(let m=0,k=0,B=0;B=i&&(m=++k);return f}*upperRightEntries(){for(let u=0,c=0;u=this.diagonalSize&&(c=++u)}}*upperRightValues(){for(let u=0,c=0;u=this.diagonalSize&&(c=++u)}};K=new WeakMap;let De=yn;De.prototype.klassType="SymmetricMatrix";class Se extends De{static isDistanceMatrix(u){return De.isSymmetricMatrix(u)&&u.klassSubType==="DistanceMatrix"}constructor(u){if(super(u),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(u,c,i){return u===c&&(i=0),super.set(u,c,i)}addCross(u,c){return c===void 0&&(c=u,u=this.diagonalSize),c=c.slice(),c[u]=0,super.addCross(u,c)}toSymmetricMatrix(){return new De(this)}clone(){const u=new Se(this.diagonalSize);for(const[c,i,f]of this.upperRightEntries())c!==i&&u.set(c,i,f);return u}toCompact(){const{diagonalSize:u}=this,c=(u-1)*u/2,i=new Array(c);for(let f=1,m=0,k=0;k=u&&(f=++m+1);return i}static fromCompact(u){const c=u.length;if(c===0)return new this(0);const i=(Math.sqrt(8*c+1)+1)/2;if(!Number.isInteger(i))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(u)}`);const f=new this(i);for(let m=1,k=0,B=0;B=i&&(m=++k+1);return f}}Se.prototype.klassSubType="DistanceMatrix";class Fe extends Wt{constructor(u,c,i){super(),this.matrix=u,this.rows=c,this.columns=i}}class wn extends Fe{constructor(u,c){yt(u,c),super(u,u.rows,1),this.column=c}set(u,c,i){return this.matrix.set(u,this.column,i),this}get(u){return this.matrix.get(u,this.column)}}class rr extends Fe{constructor(u,c){Vt(u,c),super(u,u.rows,c.length),this.columnIndices=c}set(u,c,i){return this.matrix.set(u,this.columnIndices[c],i),this}get(u,c){return this.matrix.get(u,this.columnIndices[c])}}class ln extends Fe{constructor(u){super(u,u.rows,u.columns)}set(u,c,i){return this.matrix.set(u,this.columns-c-1,i),this}get(u,c){return this.matrix.get(u,this.columns-c-1)}}class ke extends Fe{constructor(u){super(u,u.rows,u.columns)}set(u,c,i){return this.matrix.set(this.rows-u-1,c,i),this}get(u,c){return this.matrix.get(this.rows-u-1,c)}}class nn extends Fe{constructor(u,c){xt(u,c),super(u,1,u.columns),this.row=c}set(u,c,i){return this.matrix.set(this.row,c,i),this}get(u,c){return this.matrix.get(this.row,c)}}class In extends Fe{constructor(u,c){kt(u,c),super(u,c.length,u.columns),this.rowIndices=c}set(u,c,i){return this.matrix.set(this.rowIndices[u],c,i),this}get(u,c){return this.matrix.get(this.rowIndices[u],c)}}class $t extends Fe{constructor(u,c,i){kt(u,c),Vt(u,i),super(u,c.length,i.length),this.rowIndices=c,this.columnIndices=i}set(u,c,i){return this.matrix.set(this.rowIndices[u],this.columnIndices[c],i),this}get(u,c){return this.matrix.get(this.rowIndices[u],this.columnIndices[c])}}class Pn extends Fe{constructor(u,c,i,f,m){qt(u,c,i,f,m),super(u,i-c+1,m-f+1),this.startRow=c,this.startColumn=f}set(u,c,i){return this.matrix.set(this.startRow+u,this.startColumn+c,i),this}get(u,c){return this.matrix.get(this.startRow+u,this.startColumn+c)}}class Qe extends Fe{constructor(u){super(u,u.columns,u.rows)}set(u,c,i){return this.matrix.set(c,u,i),this}get(u,c){return this.matrix.get(c,u)}}class Ke extends Wt{constructor(u,c={}){const{rows:i=1}=c;if(u.length%i!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=i,this.columns=u.length/i,this.data=u}set(u,c,i){let f=this._calculateIndex(u,c);return this.data[f]=i,this}get(u,c){let i=this._calculateIndex(u,c);return this.data[i]}_calculateIndex(u,c){return u*this.columns+c}}class Ve extends Wt{constructor(u){super(),this.data=u,this.rows=u.length,this.columns=u[0].length}set(u,c,i){return this.data[u][c]=i,this}get(u,c){return this.data[u][c]}}function Er(T,u){if(ot.isAnyArray(T))return T[0]&&ot.isAnyArray(T[0])?new Ve(T):new Ke(T,u);throw new Error("the argument is not an array")}class Ln{constructor(u){u=Ve.checkMatrix(u);let c=u.clone(),i=c.rows,f=c.columns,m=new Float64Array(i),k=1,B,G,V,rt,Z,lt,At,ct,pt;for(B=0;BMath.abs(ct[rt])&&(rt=B);if(rt!==G){for(V=0;V=0;V--){for(G=0;Gk?f.set(m,k,u.get(m,k)):m===k?f.set(m,k,1):f.set(m,k,0);return f}get upperTriangularMatrix(){let u=this.LU,c=u.rows,i=u.columns,f=new It(c,i);for(let m=0;mMath.abs(u)?(c=u/T,Math.abs(T)*Math.sqrt(1+c*c)):u!==0?(c=T/u,Math.abs(u)*Math.sqrt(1+c*c)):0}class Wn{constructor(u){u=Ve.checkMatrix(u);let c=u.clone(),i=u.rows,f=u.columns,m=new Float64Array(f),k,B,G,V;for(G=0;G=0;V--){for(G=0;G=0;B--){for(m=0;m=0;H--)if(ct[H]!==0){for(let mt=H+1;mt=0;H--){if(H0;){let H,mt;for(H=Ut-2;H>=-1&&H!==-1;H--){const Rt=Number.MIN_VALUE+ae*Math.abs(ct[H]+Math.abs(ct[H+1]));if(Math.abs(J[H])<=Rt||Number.isNaN(J[H])){J[H]=0;break}}if(H===Ut-2)mt=4;else{let Rt;for(Rt=Ut-1;Rt>=H&&Rt!==H;Rt--){let Nt=(Rt!==Ut?Math.abs(J[Rt]):0)+(Rt!==H+1?Math.abs(J[Rt-1]):0);if(Math.abs(ct[Rt])<=ae*Nt){ct[Rt]=0;break}}Rt===H?mt=3:Rt===Ut-1?mt=1:(mt=2,H=Rt)}switch(H++,mt){case 1:{let Rt=J[Ut-2];J[Ut-2]=0;for(let Nt=Ut-2;Nt>=H;Nt--){let we=rn(ct[Nt],Rt),ue=ct[Nt]/we,he=Rt/we;if(ct[Nt]=we,Nt!==H&&(Rt=-he*J[Nt-1],J[Nt-1]=ue*J[Nt-1]),V)for(let pe=0;pe=ct[H+1]);){let Rt=ct[H];if(ct[H]=ct[H+1],ct[H+1]=Rt,V&&Hc&&m.set(rt,Z,u.get(rt,Z)/this.s[Z]);let k=this.U,B=k.rows,G=k.columns,V=new It(i,B);for(let rt=0;rtu&&c++;return c}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 It.diag(this.s)}}function br(T,u=!1){return T=Ve.checkMatrix(T),u?new un(T).inverse():Rn(T,It.eye(T.rows))}function Rn(T,u,c=!1){return T=Ve.checkMatrix(T),u=Ve.checkMatrix(u),c?new un(T).solve(u):T.isSquare()?new Ln(T).solve(u):new Wn(T).solve(u)}function Cn(T){if(T=It.checkMatrix(T),T.isSquare()){if(T.columns===0)return 1;let u,c,i,f;if(T.columns===2)return u=T.get(0,0),c=T.get(0,1),i=T.get(1,0),f=T.get(1,1),u*f-c*i;if(T.columns===3){let m,k,B;return m=new $t(T,[1,2],[1,2]),k=new $t(T,[1,2],[0,2]),B=new $t(T,[1,2],[0,1]),u=T.get(0,0),c=T.get(0,1),i=T.get(0,2),u*Cn(m)-c*Cn(k)+i*Cn(B)}else return new Ln(T).determinant}else throw Error("determinant can only be calculated for a square matrix")}function Nr(T,u){let c=[];for(let i=0;if)return new Array(u.rows+1).fill(0);{let m=u.addRow(c,[0]);for(let k=0;ku?m[k]=1/m[k]:m[k]=0;return f.mmul(It.diag(m).mmul(i.transpose()))}function Or(T,u=T,c={}){T=new It(T);let i=!1;if(typeof u=="object"&&!It.isMatrix(u)&&!ot.isAnyArray(u)?(c=u,u=T,i=!0):u=new It(u),T.rows!==u.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:f=!0}=c;f&&(T=T.center("column"),i||(u=u.center("column")));const m=T.transpose().mmul(u);for(let k=0;k0?f.set(m,m+1,c[m]):c[m]<0&&f.set(m,m-1,c[m])}return f}}function ss(T,u,c,i){let f,m,k,B,G,V,rt,Z;for(G=0;G0;B--){for(Z=0,k=0,V=0;V0&&(m=-m),u[B]=Z*m,k=k-f*m,c[B-1]=f-m,G=0;GV)do{for(f=c[V],Z=(c[V+1]-f)/(2*u[V]),lt=rn(Z,1),Z<0&&(lt=-lt),c[V]=u[V]/(Z+lt),c[V+1]=u[V]*(Z+lt),At=c[V+1],m=f-c[V],k=V+2;k=V;k--)for(Lt=pt,pt=ct,Ct=Ot,f=ct*u[k],m=ct*Z,lt=rn(Z,u[k]),u[k+1]=Ot*lt,Ot=u[k]/lt,ct=Z/lt,Z=ct*c[k]-Ot*f,c[k+1]=m+Ot*(ct*f+Ot*c[k]),G=0;Gye*Zt);c[V]=c[V]+Kt,u[V]=0}for(k=0;k=Z;V--)c[V]=u.get(V,Z-1)/lt,G+=c[V]*c[V];for(B=Math.sqrt(G),c[Z]>0&&(B=-B),G=G-c[Z]*B,c[Z]=c[Z]-B,rt=Z;rt=Z;V--)k+=c[V]*u.get(V,rt);for(k=k/G,V=Z;V<=m;V++)u.set(V,rt,u.get(V,rt)-k*c[V])}for(V=0;V<=m;V++){for(k=0,rt=m;rt>=Z;rt--)k+=c[rt]*u.get(V,rt);for(k=k/G,rt=Z;rt<=m;rt++)u.set(V,rt,u.get(V,rt)-k*c[rt])}c[Z]=lt*c[Z],u.set(Z,Z-1,lt*B)}}for(V=0;V=f+1;Z--)if(u.get(Z,Z-1)!==0){for(V=Z+1;V<=m;V++)c[V]=u.get(V,Z-1);for(rt=Z;rt<=m;rt++){for(B=0,V=Z;V<=m;V++)B+=c[V]*i.get(V,rt);for(B=B/c[Z]/u.get(Z,Z-1),V=Z;V<=m;V++)i.set(V,rt,i.get(V,rt)+B*c[V])}}}function Sn(T,u,c,i,f){let m=T-1,k=0,B=T-1,G=Number.EPSILON,V=0,rt=0,Z=0,lt=0,At=0,ct=0,pt=0,Lt=0,J,Ot,Ct,Kt,Zt,ye,Ut,Yt,ae,H,mt,Rt,Nt,we,ue;for(J=0;JB)&&(c[J]=f.get(J,J),u[J]=0),Ot=Math.max(J-1,0);Ot=k;){for(Kt=m;Kt>k&&(ct=Math.abs(f.get(Kt-1,Kt-1))+Math.abs(f.get(Kt,Kt)),ct===0&&(ct=rt),!(Math.abs(f.get(Kt,Kt-1))=0){for(pt=Z>=0?Z+pt:Z-pt,c[m-1]=Yt+pt,c[m]=c[m-1],pt!==0&&(c[m]=Yt-Ut/pt),u[m-1]=0,u[m]=0,Yt=f.get(m,m-1),ct=Math.abs(Yt)+Math.abs(pt),Z=Yt/ct,lt=pt/ct,At=Math.sqrt(Z*Z+lt*lt),Z=Z/At,lt=lt/At,Ot=m-1;Ot0)){for(ct=Math.sqrt(ct),ae=Kt&&(pt=f.get(Zt,Zt),At=Yt-pt,ct=ae-pt,Z=(At*ct-Ut)/f.get(Zt+1,Zt)+f.get(Zt,Zt+1),lt=f.get(Zt+1,Zt+1)-pt-At-ct,At=f.get(Zt+2,Zt+1),ct=Math.abs(Z)+Math.abs(lt)+Math.abs(At),Z=Z/ct,lt=lt/ct,At=At/ct,!(Zt===Kt||Math.abs(f.get(Zt,Zt-1))*(Math.abs(lt)+Math.abs(At))Zt+2&&f.set(J,J-3,0);for(Ct=Zt;Ct<=m-1&&(we=Ct!==m-1,Ct!==Zt&&(Z=f.get(Ct,Ct-1),lt=f.get(Ct+1,Ct-1),At=we?f.get(Ct+2,Ct-1):0,Yt=Math.abs(Z)+Math.abs(lt)+Math.abs(At),Yt!==0&&(Z=Z/Yt,lt=lt/Yt,At=At/Yt)),Yt!==0);Ct++)if(ct=Math.sqrt(Z*Z+lt*lt+At*At),Z<0&&(ct=-ct),ct!==0){for(Ct!==Zt?f.set(Ct,Ct-1,-ct*Yt):Kt!==Zt&&f.set(Ct,Ct-1,-f.get(Ct,Ct-1)),Z=Z+ct,Yt=Z/ct,ae=lt/ct,pt=At/ct,lt=lt/Z,At=At/Z,Ot=Ct;Ot=0;m--)if(Z=c[m],lt=u[m],lt===0)for(Kt=m,f.set(m,m,1),J=m-1;J>=0;J--){for(Ut=f.get(J,J)-Z,At=0,Ot=Kt;Ot<=m;Ot++)At=At+f.get(J,Ot)*f.get(Ot,m);if(u[J]<0)pt=Ut,ct=At;else if(Kt=J,u[J]===0?f.set(J,m,Ut!==0?-At/Ut:-At/(G*rt)):(Yt=f.get(J,J+1),ae=f.get(J+1,J),lt=(c[J]-Z)*(c[J]-Z)+u[J]*u[J],ye=(Yt*ct-pt*At)/lt,f.set(J,m,ye),f.set(J+1,m,Math.abs(Yt)>Math.abs(pt)?(-At-Ut*ye)/Yt:(-ct-ae*ye)/pt)),ye=Math.abs(f.get(J,m)),G*ye*ye>1)for(Ot=J;Ot<=m;Ot++)f.set(Ot,m,f.get(Ot,m)/ye)}else if(lt<0)for(Kt=m-1,Math.abs(f.get(m,m-1))>Math.abs(f.get(m-1,m))?(f.set(m-1,m-1,lt/f.get(m,m-1)),f.set(m-1,m,-(f.get(m,m)-Z)/f.get(m,m-1))):(ue=Dn(0,-f.get(m-1,m),f.get(m-1,m-1)-Z,lt),f.set(m-1,m-1,ue[0]),f.set(m-1,m,ue[1])),f.set(m,m-1,0),f.set(m,m,1),J=m-2;J>=0;J--){for(H=0,mt=0,Ot=Kt;Ot<=m;Ot++)H=H+f.get(J,Ot)*f.get(Ot,m-1),mt=mt+f.get(J,Ot)*f.get(Ot,m);if(Ut=f.get(J,J)-Z,u[J]<0)pt=Ut,At=H,ct=mt;else if(Kt=J,u[J]===0?(ue=Dn(-H,-mt,Ut,lt),f.set(J,m-1,ue[0]),f.set(J,m,ue[1])):(Yt=f.get(J,J+1),ae=f.get(J+1,J),Rt=(c[J]-Z)*(c[J]-Z)+u[J]*u[J]-lt*lt,Nt=(c[J]-Z)*2*lt,Rt===0&&Nt===0&&(Rt=G*rt*(Math.abs(Ut)+Math.abs(lt)+Math.abs(Yt)+Math.abs(ae)+Math.abs(pt))),ue=Dn(Yt*At-pt*H+lt*mt,Yt*ct-pt*mt-lt*H,Rt,Nt),f.set(J,m-1,ue[0]),f.set(J,m,ue[1]),Math.abs(Yt)>Math.abs(pt)+Math.abs(lt)?(f.set(J+1,m-1,(-H-Ut*f.get(J,m-1)+lt*f.get(J,m))/Yt),f.set(J+1,m,(-mt-Ut*f.get(J,m)-lt*f.get(J,m-1))/Yt)):(ue=Dn(-At-ae*f.get(J,m-1),-ct-ae*f.get(J,m),pt,lt),f.set(J+1,m-1,ue[0]),f.set(J+1,m,ue[1]))),ye=Math.max(Math.abs(f.get(J,m-1)),Math.abs(f.get(J,m))),G*ye*ye>1)for(Ot=J;Ot<=m;Ot++)f.set(Ot,m-1,f.get(Ot,m-1)/ye),f.set(Ot,m,f.get(Ot,m)/ye)}for(J=0;JB)for(Ot=J;Ot=k;Ot--)for(J=k;J<=B;J++){for(pt=0,Ct=k;Ct<=Math.min(Ot,B);Ct++)pt=pt+i.get(J,Ct)*f.get(Ct,Ot);i.set(J,Ot,pt)}}}function Dn(T,u,c,i){let f,m;return Math.abs(c)>Math.abs(i)?(f=i/c,m=c+f*i,[(T+f*u)/m,(u-f*T)/m]):(f=c/i,m=i+f*c,[(f*T+u)/m,(f*u-T)/m])}class or{constructor(u){if(u=Ve.checkMatrix(u),!u.isSymmetric())throw new Error("Matrix is not symmetric");let c=u,i=c.rows,f=new It(i,i),m=!0,k,B,G;for(B=0;B0),f.set(B,B,Math.sqrt(Math.max(V,0))),G=B+1;G=0;G--)for(B=0;Bk;At++)Z=u.transpose().mmul(B).div(B.transpose().mmul(B).get(0,0)),Z=Z.div(Z.norm()),V=u.mmul(Z).div(Z.transpose().mmul(Z).get(0,0)),At>0&&(G=V.clone().sub(lt).pow(2).sum()),lt=V.clone(),i?(rt=i.transpose().mmul(V).div(V.transpose().mmul(V).get(0,0)),rt=rt.div(rt.norm()),B=i.mmul(rt).div(rt.transpose().mmul(rt).get(0,0))):B=V;if(i){let At=u.transpose().mmul(V).div(V.transpose().mmul(V).get(0,0));At=At.div(At.norm());let ct=u.clone().sub(V.clone().mmul(At.transpose())),pt=B.transpose().mmul(V).div(V.transpose().mmul(V).get(0,0)),Lt=i.clone().sub(V.clone().mulS(pt.get(0,0)).mmul(rt.transpose()));this.t=V,this.p=At.transpose(),this.w=Z.transpose(),this.q=rt,this.u=B,this.s=V.transpose().mmul(V),this.xResidual=ct,this.yResidual=Lt,this.betas=pt}else this.w=Z.transpose(),this.s=V.transpose().mmul(V).sqrt(),f?this.t=V.clone().div(this.s.get(0,0)):this.t=V,this.xResidual=u.sub(V.mmul(Z.transpose()))}}P.XA=Wt,P.a_=or,P.yQ=or,P.Hs=Se,P.Ec=Yn,P.dx=Yn,P.LU=Ln,P.Rm=Ln,P.y3=It,P.qK=rr,P.pb=wn,P.j=ln,P.sO=ke,P.BZ=In,P.EK=nn,P.Db=$t,P.Fx=Pn,P.tU=Qe,P.Ym=$n,P.rs=$n,P.QR=Wn,P.TB=Wn,P.oH=un,P.Sc=un,P.BN=De,P.it=Ke,P.$r=Ve,P.QM=sr,P.AV=Or,l=It,P.GH=Cn,P.SO=br,P.uZ=Sr,P.yU=xn,P.F1=Rn,P.re=Er},70681:function(w,P,a){w.exports={graphlib:a(70574),layout:a(98123),debug:a(27570),util:{time:a(11138).time,notime:a(11138).notime},version:a(88177)}},92188:function(w,P,a){"use strict";var l=a(38436),x=a(74079);w.exports={run:E,undo:v};function E(N){var S=N.graph().acyclicer==="greedy"?x(N,M(N)):b(N);l.forEach(S,function(A){var I=N.edge(A);N.removeEdge(A),I.forwardName=A.name,I.reversed=!0,N.setEdge(A.w,A.v,I,l.uniqueId("rev"))});function M(A){return function(I){return A.edge(I).weight}}}function b(N){var S=[],M={},A={};function I(j){l.has(A,j)||(A[j]=!0,M[j]=!0,l.forEach(N.outEdges(j),function(D){l.has(M,D.w)?S.push(D):I(D.w)}),delete M[j])}return l.forEach(N.nodes(),I),S}function v(N){l.forEach(N.edges(),function(S){var M=N.edge(S);if(M.reversed){N.removeEdge(S);var A=M.forwardName;delete M.reversed,delete M.forwardName,N.setEdge(S.w,S.v,M,A)}})}},61133:function(w,P,a){var l=a(38436),x=a(11138);w.exports=E;function E(v){function N(S){var M=v.children(S),A=v.node(S);if(M.length&&l.forEach(M,N),l.has(A,"minRank")){A.borderLeft=[],A.borderRight=[];for(var I=A.minRank,j=A.maxRank+1;I0;--_)if(nt=j[_].dequeue(),nt){$=$.concat(S(I,j,D,nt,!0));break}}}return $}function S(I,j,D,$,K){var ot=K?[]:void 0;return l.forEach(I.inEdges($.v),function(nt){var _=I.edge(nt),et=I.node(nt.v);K&&ot.push({v:nt.v,w:nt.w}),et.out-=_,A(j,D,et)}),l.forEach(I.outEdges($.v),function(nt){var _=I.edge(nt),et=nt.w,tt=I.node(et);tt.in-=_,A(j,D,tt)}),I.removeNode($.v),ot}function M(I,j){var D=new x,$=0,K=0;l.forEach(I.nodes(),function(_){D.setNode(_,{v:_,in:0,out:0})}),l.forEach(I.edges(),function(_){var et=D.edge(_.v,_.w)||0,tt=j(_),it=et+tt;D.setEdge(_.v,_.w,it),K=Math.max(K,D.node(_.v).out+=tt),$=Math.max($,D.node(_.w).in+=tt)});var ot=l.range(K+$+3).map(function(){return new E}),nt=$+1;return l.forEach(D.nodes(),function(_){A(ot,nt,D.node(_))}),{graph:D,buckets:ot,zeroIdx:nt}}function A(I,j,D){D.out?D.in?I[D.out-D.in+j].enqueue(D):I[I.length-1].enqueue(D):I[0].enqueue(D)}},98123:function(w,P,a){"use strict";var l=a(38436),x=a(92188),E=a(45995),b=a(78093),v=a(11138).normalizeRanks,N=a(24219),S=a(11138).removeEmptyRanks,M=a(72981),A=a(61133),I=a(53258),j=a(53408),D=a(17873),$=a(11138),K=a(70574).Graph;w.exports=ot;function ot(gt,wt){var jt=wt&&wt.debugTiming?$.time:$.notime;jt("layout",function(){var Ft=jt(" buildLayoutGraph",function(){return yt(gt)});jt(" runLayout",function(){nt(Ft,jt)}),jt(" updateInputGraph",function(){_(gt,Ft)})})}function nt(gt,wt){wt(" makeSpaceForEdgeLabels",function(){Mt(gt)}),wt(" removeSelfEdges",function(){xe(gt)}),wt(" acyclic",function(){x.run(gt)}),wt(" nestingGraph.run",function(){M.run(gt)}),wt(" rank",function(){b($.asNonCompoundGraph(gt))}),wt(" injectEdgeLabelProxies",function(){St(gt)}),wt(" removeEmptyRanks",function(){S(gt)}),wt(" nestingGraph.cleanup",function(){M.cleanup(gt)}),wt(" normalizeRanks",function(){v(gt)}),wt(" assignRankMinMax",function(){kt(gt)}),wt(" removeEdgeLabelProxies",function(){Vt(gt)}),wt(" normalize.run",function(){E.run(gt)}),wt(" parentDummyChains",function(){N(gt)}),wt(" addBorderSegments",function(){A(gt)}),wt(" order",function(){j(gt)}),wt(" insertSelfEdges",function(){mn(gt)}),wt(" adjustCoordinateSystem",function(){I.adjust(gt)}),wt(" position",function(){D(gt)}),wt(" positionSelfEdges",function(){Mn(gt)}),wt(" removeBorderNodes",function(){tn(gt)}),wt(" normalize.undo",function(){E.undo(gt)}),wt(" fixupEdgeLabelCoords",function(){ce(gt)}),wt(" undoCoordinateSystem",function(){I.undo(gt)}),wt(" translateGraph",function(){qt(gt)}),wt(" assignNodeIntersects",function(){te(gt)}),wt(" reversePoints",function(){ze(gt)}),wt(" acyclic.undo",function(){x.undo(gt)})}function _(gt,wt){l.forEach(gt.nodes(),function(jt){var Ft=gt.node(jt),Ht=wt.node(jt);Ft&&(Ft.x=Ht.x,Ft.y=Ht.y,wt.children(jt).length&&(Ft.width=Ht.width,Ft.height=Ht.height))}),l.forEach(gt.edges(),function(jt){var Ft=gt.edge(jt),Ht=wt.edge(jt);Ft.points=Ht.points,l.has(Ht,"x")&&(Ft.x=Ht.x,Ft.y=Ht.y)}),gt.graph().width=wt.graph().width,gt.graph().height=wt.graph().height}var et=["nodesep","edgesep","ranksep","marginx","marginy"],tt={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},it=["acyclicer","ranker","rankdir","align"],at=["width","height"],ft={width:0,height:0},ht=["minlen","weight","width","height","labeloffset"],dt={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},xt=["labelpos"];function yt(gt){var wt=new K({multigraph:!0,compound:!0}),jt=en(gt.graph());return wt.setGraph(l.merge({},tt,cn(jt,et),l.pick(jt,it))),l.forEach(gt.nodes(),function(Ft){var Ht=en(gt.node(Ft));wt.setNode(Ft,l.defaults(cn(Ht,at),ft)),wt.setParent(Ft,gt.parent(Ft))}),l.forEach(gt.edges(),function(Ft){var Ht=en(gt.edge(Ft));wt.setEdge(Ft,l.merge({},dt,cn(Ht,ht),l.pick(Ht,xt)))}),wt}function Mt(gt){var wt=gt.graph();wt.ranksep/=2,l.forEach(gt.edges(),function(jt){var Ft=gt.edge(jt);Ft.minlen*=2,Ft.labelpos.toLowerCase()!=="c"&&(wt.rankdir==="TB"||wt.rankdir==="BT"?Ft.width+=Ft.labeloffset:Ft.height+=Ft.labeloffset)})}function St(gt){l.forEach(gt.edges(),function(wt){var jt=gt.edge(wt);if(jt.width&&jt.height){var Ft=gt.node(wt.v),Ht=gt.node(wt.w),de={rank:(Ht.rank-Ft.rank)/2+Ft.rank,e:wt};$.addDummyNode(gt,"edge-proxy",de,"_ep")}})}function kt(gt){var wt=0;l.forEach(gt.nodes(),function(jt){var Ft=gt.node(jt);Ft.borderTop&&(Ft.minRank=gt.node(Ft.borderTop).rank,Ft.maxRank=gt.node(Ft.borderBottom).rank,wt=l.max(wt,Ft.maxRank))}),gt.graph().maxRank=wt}function Vt(gt){l.forEach(gt.nodes(),function(wt){var jt=gt.node(wt);jt.dummy==="edge-proxy"&&(gt.edge(jt.e).labelRank=jt.rank,gt.removeNode(wt))})}function qt(gt){var wt=Number.POSITIVE_INFINITY,jt=0,Ft=Number.POSITIVE_INFINITY,Ht=0,de=gt.graph(),ge=de.marginx||0,Re=de.marginy||0;function fn(Ce){var Ne=Ce.x,se=Ce.y,Wt=Ce.width,ee=Ce.height;wt=Math.min(wt,Ne-Wt/2),jt=Math.max(jt,Ne+Wt/2),Ft=Math.min(Ft,se-ee/2),Ht=Math.max(Ht,se+ee/2)}l.forEach(gt.nodes(),function(Ce){fn(gt.node(Ce))}),l.forEach(gt.edges(),function(Ce){var Ne=gt.edge(Ce);l.has(Ne,"x")&&fn(Ne)}),wt-=ge,Ft-=Re,l.forEach(gt.nodes(),function(Ce){var Ne=gt.node(Ce);Ne.x-=wt,Ne.y-=Ft}),l.forEach(gt.edges(),function(Ce){var Ne=gt.edge(Ce);l.forEach(Ne.points,function(se){se.x-=wt,se.y-=Ft}),l.has(Ne,"x")&&(Ne.x-=wt),l.has(Ne,"y")&&(Ne.y-=Ft)}),de.width=jt-wt+ge,de.height=Ht-Ft+Re}function te(gt){l.forEach(gt.edges(),function(wt){var jt=gt.edge(wt),Ft=gt.node(wt.v),Ht=gt.node(wt.w),de,ge;jt.points?(de=jt.points[0],ge=jt.points[jt.points.length-1]):(jt.points=[],de=Ht,ge=Ft),jt.points.unshift($.intersectRect(Ft,de)),jt.points.push($.intersectRect(Ht,ge))})}function ce(gt){l.forEach(gt.edges(),function(wt){var jt=gt.edge(wt);if(l.has(jt,"x"))switch((jt.labelpos==="l"||jt.labelpos==="r")&&(jt.width-=jt.labeloffset),jt.labelpos){case"l":jt.x-=jt.width/2+jt.labeloffset;break;case"r":jt.x+=jt.width/2+jt.labeloffset;break}})}function ze(gt){l.forEach(gt.edges(),function(wt){var jt=gt.edge(wt);jt.reversed&&jt.points.reverse()})}function tn(gt){l.forEach(gt.nodes(),function(wt){if(gt.children(wt).length){var jt=gt.node(wt),Ft=gt.node(jt.borderTop),Ht=gt.node(jt.borderBottom),de=gt.node(l.last(jt.borderLeft)),ge=gt.node(l.last(jt.borderRight));jt.width=Math.abs(ge.x-de.x),jt.height=Math.abs(Ht.y-Ft.y),jt.x=de.x+jt.width/2,jt.y=Ft.y+jt.height/2}}),l.forEach(gt.nodes(),function(wt){gt.node(wt).dummy==="border"&>.removeNode(wt)})}function xe(gt){l.forEach(gt.edges(),function(wt){if(wt.v===wt.w){var jt=gt.node(wt.v);jt.selfEdges||(jt.selfEdges=[]),jt.selfEdges.push({e:wt,label:gt.edge(wt)}),gt.removeEdge(wt)}})}function mn(gt){var wt=$.buildLayerMatrix(gt);l.forEach(wt,function(jt){var Ft=0;l.forEach(jt,function(Ht,de){var ge=gt.node(Ht);ge.order=de+Ft,l.forEach(ge.selfEdges,function(Re){$.addDummyNode(gt,"selfedge",{width:Re.label.width,height:Re.label.height,rank:ge.rank,order:de+ ++Ft,e:Re.e,label:Re.label},"_se")}),delete ge.selfEdges})})}function Mn(gt){l.forEach(gt.nodes(),function(wt){var jt=gt.node(wt);if(jt.dummy==="selfedge"){var Ft=gt.node(jt.e.v),Ht=Ft.x+Ft.width/2,de=Ft.y,ge=jt.x-Ht,Re=Ft.height/2;gt.setEdge(jt.e,jt.label),gt.removeNode(wt),jt.label.points=[{x:Ht+2*ge/3,y:de-Re},{x:Ht+5*ge/6,y:de-Re},{x:Ht+ge,y:de},{x:Ht+5*ge/6,y:de+Re},{x:Ht+2*ge/3,y:de+Re}],jt.label.x=jt.x,jt.label.y=jt.y}})}function cn(gt,wt){return l.mapValues(l.pick(gt,wt),Number)}function en(gt){var wt={};return l.forEach(gt,function(jt,Ft){wt[Ft.toLowerCase()]=jt}),wt}},38436:function(w,P,a){var l;try{l={cloneDeep:a(50361),constant:a(75703),defaults:a(91747),each:a(85768),filter:a(63105),find:a(13311),flatten:a(85564),forEach:a(84486),forIn:a(62620),has:a(18721),isUndefined:a(52353),last:a(10928),map:a(35161),mapValues:a(8521),max:a(6162),merge:a(82492),min:a(53632),minBy:a(22762),now:a(7771),pick:a(78718),range:a(96026),reduce:a(54061),sortBy:a(89734),uniqueId:a(73955),values:a(52628),zipObject:a(7287)}}catch(x){}l||(l=window._),w.exports=l},72981:function(w,P,a){var l=a(38436),x=a(11138);w.exports={run:E,cleanup:S};function E(M){var A=x.addDummyNode(M,"root",{},"_root"),I=v(M),j=l.max(l.values(I))-1,D=2*j+1;M.graph().nestingRoot=A,l.forEach(M.edges(),function(K){M.edge(K).minlen*=D});var $=N(M)+1;l.forEach(M.children(),function(K){b(M,A,D,$,j,I,K)}),M.graph().nodeRankFactor=D}function b(M,A,I,j,D,$,K){var ot=M.children(K);if(!ot.length){K!==A&&M.setEdge(A,K,{weight:0,minlen:I});return}var nt=x.addBorderNode(M,"_bt"),_=x.addBorderNode(M,"_bb"),et=M.node(K);M.setParent(nt,K),et.borderTop=nt,M.setParent(_,K),et.borderBottom=_,l.forEach(ot,function(tt){b(M,A,I,j,D,$,tt);var it=M.node(tt),at=it.borderTop?it.borderTop:tt,ft=it.borderBottom?it.borderBottom:tt,ht=it.borderTop?j:2*j,dt=at!==ft?1:D-$[K]+1;M.setEdge(nt,at,{weight:ht,minlen:dt,nestingEdge:!0}),M.setEdge(ft,_,{weight:ht,minlen:dt,nestingEdge:!0})}),M.parent(K)||M.setEdge(A,nt,{weight:0,minlen:D+$[K]})}function v(M){var A={};function I(j,D){var $=M.children(j);$&&$.length&&l.forEach($,function(K){I(K,D+1)}),A[j]=D}return l.forEach(M.children(),function(j){I(j,1)}),A}function N(M){return l.reduce(M.edges(),function(A,I){return A+M.edge(I).weight},0)}function S(M){var A=M.graph();M.removeNode(A.nestingRoot),delete A.nestingRoot,l.forEach(M.edges(),function(I){var j=M.edge(I);j.nestingEdge&&M.removeEdge(I)})}},45995:function(w,P,a){"use strict";var l=a(38436),x=a(11138);w.exports={run:E,undo:v};function E(N){N.graph().dummyChains=[],l.forEach(N.edges(),function(S){b(N,S)})}function b(N,S){var M=S.v,A=N.node(M).rank,I=S.w,j=N.node(I).rank,D=S.name,$=N.edge(S),K=$.labelRank;if(j!==A+1){N.removeEdge(S);var ot,nt,_;for(_=0,++A;A0;)K%2&&(ot+=j[K+1]),K=K-1>>1,j[K]+=$.weight;D+=$.weight*ot})),D}},53408:function(w,P,a){"use strict";var l=a(38436),x=a(2588),E=a(56630),b=a(61026),v=a(23128),N=a(55093),S=a(70574).Graph,M=a(11138);w.exports=A;function A($){var K=M.maxRank($),ot=I($,l.range(1,K+1),"inEdges"),nt=I($,l.range(K-1,-1,-1),"outEdges"),_=x($);D($,_);for(var et=Number.POSITIVE_INFINITY,tt,it=0,at=0;at<4;++it,++at){j(it%2?ot:nt,it%4>=2),_=M.buildLayerMatrix($);var ft=E($,_);ft=I.barycenter)&&b(I,j)}}function M(I){return function(j){j.in.push(I),--j.indegree===0&&v.push(j)}}for(;v.length;){var A=v.pop();N.push(A),l.forEach(A.in.reverse(),S(A)),l.forEach(A.out,M(A))}return l.map(l.filter(N,function(I){return!I.merged}),function(I){return l.pick(I,["vs","i","barycenter","weight"])})}function b(v,N){var S=0,M=0;v.weight&&(S+=v.barycenter*v.weight,M+=v.weight),N.weight&&(S+=N.barycenter*N.weight,M+=N.weight),v.vs=N.vs.concat(v.vs),v.barycenter=S/M,v.weight=M,v.i=Math.min(N.i,v.i),N.merged=!0}},61026:function(w,P,a){var l=a(38436),x=a(35439),E=a(83678),b=a(87304);w.exports=v;function v(M,A,I,j){var D=M.children(A),$=M.node(A),K=$?$.borderLeft:void 0,ot=$?$.borderRight:void 0,nt={};K&&(D=l.filter(D,function(ft){return ft!==K&&ft!==ot}));var _=x(M,D);l.forEach(_,function(ft){if(M.children(ft.v).length){var ht=v(M,ft.v,I,j);nt[ft.v]=ht,l.has(ht,"barycenter")&&S(ft,ht)}});var et=E(_,I);N(et,nt);var tt=b(et,j);if(K&&(tt.vs=l.flatten([K,tt.vs,ot],!0),M.predecessors(K).length)){var it=M.node(M.predecessors(K)[0]),at=M.node(M.predecessors(ot)[0]);l.has(tt,"barycenter")||(tt.barycenter=0,tt.weight=0),tt.barycenter=(tt.barycenter*tt.weight+it.order+at.order)/(tt.weight+2),tt.weight+=2}return tt}function N(M,A){l.forEach(M,function(I){I.vs=l.flatten(I.vs.map(function(j){return A[j]?A[j].vs:j}),!0)})}function S(M,A){l.isUndefined(M.barycenter)?(M.barycenter=A.barycenter,M.weight=A.weight):(M.barycenter=(M.barycenter*M.weight+A.barycenter*A.weight)/(M.weight+A.weight),M.weight+=A.weight)}},87304:function(w,P,a){var l=a(38436),x=a(11138);w.exports=E;function E(N,S){var M=x.partition(N,function(nt){return l.has(nt,"barycenter")}),A=M.lhs,I=l.sortBy(M.rhs,function(nt){return-nt.i}),j=[],D=0,$=0,K=0;A.sort(v(!!S)),K=b(j,I,K),l.forEach(A,function(nt){K+=nt.vs.length,j.push(nt.vs),D+=nt.barycenter*nt.weight,$+=nt.weight,K=b(j,I,K)});var ot={vs:l.flatten(j,!0)};return $&&(ot.barycenter=D/$,ot.weight=$),ot}function b(N,S,M){for(var A;S.length&&(A=l.last(S)).i<=M;)S.pop(),N.push(A.vs),M++;return M}function v(N){return function(S,M){return S.barycenterM.barycenter?1:N?M.i-S.i:S.i-M.i}}},24219:function(w,P,a){var l=a(38436);w.exports=x;function x(v){var N=b(v);l.forEach(v.graph().dummyChains,function(S){for(var M=v.node(S),A=M.edgeObj,I=E(v,N,A.v,A.w),j=I.path,D=I.lca,$=0,K=j[$],ot=!0;S!==A.w;){if(M=v.node(S),ot){for(;(K=j[$])!==D&&v.node(K).maxRankj||D>N[$].lim));for(K=$,$=M;($=v.parent($))!==K;)I.push($);return{path:A.concat(I.reverse()),lca:K}}function b(v){var N={},S=0;function M(A){var I=S;l.forEach(v.children(A),M),N[A]={low:I,lim:S++}}return l.forEach(v.children(),M),N}},3573:function(w,P,a){"use strict";var l=a(38436),x=a(70574).Graph,E=a(11138);w.exports={positionX:ot,findType1Conflicts:b,findType2Conflicts:v,addConflict:S,hasConflict:M,verticalAlignment:A,horizontalCompaction:I,alignCoordinates:$,findSmallestWidthAlignment:D,balance:K};function b(et,tt){var it={};function at(ft,ht){var dt=0,xt=0,yt=ft.length,Mt=l.last(ht);return l.forEach(ht,function(St,kt){var Vt=N(et,St),qt=Vt?et.node(Vt).order:yt;(Vt||St===Mt)&&(l.forEach(ht.slice(xt,kt+1),function(te){l.forEach(et.predecessors(te),function(ce){var ze=et.node(ce),tn=ze.order;(tnMt)&&S(it,Vt,St)})})}function ft(ht,dt){var xt=-1,yt,Mt=0;return l.forEach(dt,function(St,kt){if(et.node(St).dummy==="border"){var Vt=et.predecessors(St);Vt.length&&(yt=et.node(Vt[0]).order,at(dt,Mt,kt,xt,yt),Mt=kt,xt=yt)}at(dt,Mt,dt.length,yt,ht.length)}),dt}return l.reduce(tt,ft),it}function N(et,tt){if(et.node(tt).dummy)return l.find(et.predecessors(tt),function(it){return et.node(it).dummy})}function S(et,tt,it){if(tt>it){var at=tt;tt=it,it=at}var ft=et[tt];ft||(et[tt]=ft={}),ft[it]=!0}function M(et,tt,it){if(tt>it){var at=tt;tt=it,it=at}return l.has(et[tt],it)}function A(et,tt,it,at){var ft={},ht={},dt={};return l.forEach(tt,function(xt){l.forEach(xt,function(yt,Mt){ft[yt]=yt,ht[yt]=yt,dt[yt]=Mt})}),l.forEach(tt,function(xt){var yt=-1;l.forEach(xt,function(Mt){var St=at(Mt);if(St.length){St=l.sortBy(St,function(ce){return dt[ce]});for(var kt=(St.length-1)/2,Vt=Math.floor(kt),qt=Math.ceil(kt);Vt<=qt;++Vt){var te=St[Vt];ht[Mt]===Mt&&ytyt.lim&&(Mt=yt,St=!0);var kt=l.filter(at.edges(),function(Vt){return St===tt(it,it.node(Vt.v),Mt)&&St!==tt(it,it.node(Vt.w),Mt)});return l.minBy(kt,function(Vt){return E(at,Vt)})}function nt(it,at,ft,ht){var dt=ft.v,xt=ft.w;it.removeEdge(dt,xt),it.setEdge(ht.v,ht.w,{}),D(it),A(it,at),_(it,at)}function _(it,at){var ft=l.find(it.nodes(),function(dt){return!at.node(dt).parent}),ht=v(it,ft);ht=ht.slice(1),l.forEach(ht,function(dt){var xt=it.node(dt).parent,yt=at.edge(dt,xt),Mt=!1;yt||(yt=at.edge(xt,dt),Mt=!0),at.node(dt).rank=at.node(xt).rank+(Mt?yt.minlen:-yt.minlen)})}function et(it,at,ft){return it.hasEdge(at,ft)}function tt(it,at,ft){return ft.low<=at.lim&&at.lim<=ft.lim}},76681:function(w,P,a){"use strict";var l=a(38436);w.exports={longestPath:x,slack:E};function x(b){var v={};function N(S){var M=b.node(S);if(l.has(v,S))return M.rank;v[S]=!0;var A=l.min(l.map(b.outEdges(S),function(I){return N(I.w)-b.edge(I).minlen}));return(A===Number.POSITIVE_INFINITY||A===void 0||A===null)&&(A=0),M.rank=A}l.forEach(b.sources(),N)}function E(b,v){return b.node(v.w).rank-b.node(v.v).rank-b.edge(v).minlen}},11138:function(w,P,a){"use strict";var l=a(38436),x=a(70574).Graph;w.exports={addDummyNode:E,simplify:b,asNonCompoundGraph:v,successorWeights:N,predecessorWeights:S,intersectRect:M,buildLayerMatrix:A,normalizeRanks:I,removeEmptyRanks:j,addBorderNode:D,maxRank:$,partition:K,time:ot,notime:nt};function E(_,et,tt,it){var at;do at=l.uniqueId(it);while(_.hasNode(at));return tt.dummy=et,_.setNode(at,tt),at}function b(_){var et=new x().setGraph(_.graph());return l.forEach(_.nodes(),function(tt){et.setNode(tt,_.node(tt))}),l.forEach(_.edges(),function(tt){var it=et.edge(tt.v,tt.w)||{weight:0,minlen:1},at=_.edge(tt);et.setEdge(tt.v,tt.w,{weight:it.weight+at.weight,minlen:Math.max(it.minlen,at.minlen)})}),et}function v(_){var et=new x({multigraph:_.isMultigraph()}).setGraph(_.graph());return l.forEach(_.nodes(),function(tt){_.children(tt).length||et.setNode(tt,_.node(tt))}),l.forEach(_.edges(),function(tt){et.setEdge(tt,_.edge(tt))}),et}function N(_){var et=l.map(_.nodes(),function(tt){var it={};return l.forEach(_.outEdges(tt),function(at){it[at.w]=(it[at.w]||0)+_.edge(at).weight}),it});return l.zipObject(_.nodes(),et)}function S(_){var et=l.map(_.nodes(),function(tt){var it={};return l.forEach(_.inEdges(tt),function(at){it[at.v]=(it[at.v]||0)+_.edge(at).weight}),it});return l.zipObject(_.nodes(),et)}function M(_,et){var tt=_.x,it=_.y,at=et.x-tt,ft=et.y-it,ht=_.width/2,dt=_.height/2;if(!at&&!ft)throw new Error("Not possible to find intersection inside of the rectangle");var xt,yt;return Math.abs(ft)*ht>Math.abs(at)*dt?(ft<0&&(dt=-dt),xt=dt*at/ft,yt=dt):(at<0&&(ht=-ht),xt=ht,yt=ht*ft/at),{x:tt+xt,y:it+yt}}function A(_){var et=l.map(l.range($(_)+1),function(){return[]});return l.forEach(_.nodes(),function(tt){var it=_.node(tt),at=it.rank;l.isUndefined(at)||(et[at][it.order]=tt)}),et}function I(_){var et=l.min(l.map(_.nodes(),function(tt){return _.node(tt).rank}));l.forEach(_.nodes(),function(tt){var it=_.node(tt);l.has(it,"rank")&&(it.rank-=et)})}function j(_){var et=l.min(l.map(_.nodes(),function(ft){return _.node(ft).rank})),tt=[];l.forEach(_.nodes(),function(ft){var ht=_.node(ft).rank-et;tt[ht]||(tt[ht]=[]),tt[ht].push(ft)});var it=0,at=_.graph().nodeRankFactor;l.forEach(tt,function(ft,ht){l.isUndefined(ft)&&ht%at!==0?--it:it&&l.forEach(ft,function(dt){_.node(dt).rank+=it})})}function D(_,et,tt,it){var at={width:0,height:0};return arguments.length>=4&&(at.rank=tt,at.order=it),E(_,"border",at,et)}function $(_){return l.max(l.map(_.nodes(),function(et){var tt=_.node(et).rank;if(!l.isUndefined(tt))return tt}))}function K(_,et){var tt={lhs:[],rhs:[]};return l.forEach(_,function(it){et(it)?tt.lhs.push(it):tt.rhs.push(it)}),tt}function ot(_,et){var tt=l.now();try{return et()}finally{console.log(_+" time: "+(l.now()-tt)+"ms")}}function nt(_,et){return et()}},88177:function(w){w.exports="0.8.5"},28282:function(w,P,a){var l=a(82354);w.exports={Graph:l.Graph,json:a(28974),alg:a(12440),version:l.version}},2842:function(w,P,a){var l=a(89126);w.exports=x;function x(E){var b={},v=[],N;function S(M){l.has(b,M)||(b[M]=!0,N.push(M),l.each(E.successors(M),S),l.each(E.predecessors(M),S))}return l.each(E.nodes(),function(M){N=[],S(M),N.length&&v.push(N)}),v}},53984:function(w,P,a){var l=a(89126);w.exports=x;function x(b,v,N){l.isArray(v)||(v=[v]);var S=(b.isDirected()?b.successors:b.neighbors).bind(b),M=[],A={};return l.each(v,function(I){if(!b.hasNode(I))throw new Error("Graph does not have node: "+I);E(b,I,N==="post",A,S,M)}),M}function E(b,v,N,S,M,A){l.has(S,v)||(S[v]=!0,N||A.push(v),l.each(M(v),function(I){E(b,I,N,S,M,A)}),N&&A.push(v))}},84847:function(w,P,a){var l=a(63763),x=a(89126);w.exports=E;function E(b,v,N){return x.transform(b.nodes(),function(S,M){S[M]=l(b,M,v,N)},{})}},63763:function(w,P,a){var l=a(89126),x=a(75639);w.exports=b;var E=l.constant(1);function b(N,S,M,A){return v(N,String(S),M||E,A||function(I){return N.outEdges(I)})}function v(N,S,M,A){var I={},j=new x,D,$,K=function(ot){var nt=ot.v!==D?ot.v:ot.w,_=I[nt],et=M(ot),tt=$.distance+et;if(et<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+ot+" Weight: "+et);tt<_.distance&&(_.distance=tt,_.predecessor=D,j.decrease(nt,tt))};for(N.nodes().forEach(function(ot){var nt=ot===S?0:Number.POSITIVE_INFINITY;I[ot]={distance:nt},j.add(ot,nt)});j.size()>0&&(D=j.removeMin(),$=I[D],$.distance!==Number.POSITIVE_INFINITY);)A(D).forEach(K);return I}},9096:function(w,P,a){var l=a(89126),x=a(5023);w.exports=E;function E(b){return l.filter(x(b),function(v){return v.length>1||v.length===1&&b.hasEdge(v[0],v[0])})}},38924:function(w,P,a){var l=a(89126);w.exports=E;var x=l.constant(1);function E(v,N,S){return b(v,N||x,S||function(M){return v.outEdges(M)})}function b(v,N,S){var M={},A=v.nodes();return A.forEach(function(I){M[I]={},M[I][I]={distance:0},A.forEach(function(j){I!==j&&(M[I][j]={distance:Number.POSITIVE_INFINITY})}),S(I).forEach(function(j){var D=j.v===I?j.w:j.v,$=N(j);M[I][D]={distance:$,predecessor:I}})}),A.forEach(function(I){var j=M[I];A.forEach(function(D){var $=M[D];A.forEach(function(K){var ot=$[I],nt=j[K],_=$[K],et=ot.distance+nt.distance;et<_.distance&&(_.distance=et,_.predecessor=nt.predecessor)})})}),M}},12440:function(w,P,a){w.exports={components:a(2842),dijkstra:a(63763),dijkstraAll:a(84847),findCycles:a(9096),floydWarshall:a(38924),isAcyclic:a(62707),postorder:a(58828),preorder:a(92648),prim:a(80514),tarjan:a(5023),topsort:a(2166)}},62707:function(w,P,a){var l=a(2166);w.exports=x;function x(E){try{l(E)}catch(b){if(b instanceof l.CycleException)return!1;throw b}return!0}},58828:function(w,P,a){var l=a(53984);w.exports=x;function x(E,b){return l(E,b,"post")}},92648:function(w,P,a){var l=a(53984);w.exports=x;function x(E,b){return l(E,b,"pre")}},80514:function(w,P,a){var l=a(89126),x=a(30771),E=a(75639);w.exports=b;function b(v,N){var S=new x,M={},A=new E,I;function j($){var K=$.v===I?$.w:$.v,ot=A.priority(K);if(ot!==void 0){var nt=N($);nt0;){if(I=A.removeMin(),l.has(M,I))S.setEdge(I,M[I]);else{if(D)throw new Error("Input graph is not connected: "+v);D=!0}v.nodeEdges(I).forEach(j)}return S}},5023:function(w,P,a){var l=a(89126);w.exports=x;function x(E){var b=0,v=[],N={},S=[];function M(A){var I=N[A]={onStack:!0,lowlink:b,index:b++};if(v.push(A),E.successors(A).forEach(function($){l.has(N,$)?N[$].onStack&&(I.lowlink=Math.min(I.lowlink,N[$].index)):(M($),I.lowlink=Math.min(I.lowlink,N[$].lowlink))}),I.lowlink===I.index){var j=[],D;do D=v.pop(),N[D].onStack=!1,j.push(D);while(A!==D);S.push(j)}}return E.nodes().forEach(function(A){l.has(N,A)||M(A)}),S}},2166:function(w,P,a){var l=a(89126);w.exports=x,x.CycleException=E;function x(b){var v={},N={},S=[];function M(A){if(l.has(N,A))throw new E;l.has(v,A)||(N[A]=!0,v[A]=!0,l.each(b.predecessors(A),M),delete N[A],S.push(A))}if(l.each(b.sinks(),M),l.size(v)!==b.nodeCount())throw new E;return S}function E(){}E.prototype=new Error},75639:function(w,P,a){var l=a(89126);w.exports=x;function x(){this._arr=[],this._keyIndices={}}x.prototype.size=function(){return this._arr.length},x.prototype.keys=function(){return this._arr.map(function(E){return E.key})},x.prototype.has=function(E){return l.has(this._keyIndices,E)},x.prototype.priority=function(E){var b=this._keyIndices[E];if(b!==void 0)return this._arr[b].priority},x.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},x.prototype.add=function(E,b){var v=this._keyIndices;if(E=String(E),!l.has(v,E)){var N=this._arr,S=N.length;return v[E]=S,N.push({key:E,priority:b}),this._decrease(S),!0}return!1},x.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var E=this._arr.pop();return delete this._keyIndices[E.key],this._heapify(0),E.key},x.prototype.decrease=function(E,b){var v=this._keyIndices[E];if(b>this._arr[v].priority)throw new Error("New priority is greater than current priority. Key: "+E+" Old: "+this._arr[v].priority+" New: "+b);this._arr[v].priority=b,this._decrease(v)},x.prototype._heapify=function(E){var b=this._arr,v=2*E,N=v+1,S=E;v>1,!(b[N].priority1?K.setNode(ot,D):K.setNode(ot)}),this},v.prototype.setNode=function(j,D){return l.has(this._nodes,j)?(arguments.length>1&&(this._nodes[j]=D),this):(this._nodes[j]=arguments.length>1?D:this._defaultNodeLabelFn(j),this._isCompound&&(this._parent[j]=E,this._children[j]={},this._children[E][j]=!0),this._in[j]={},this._preds[j]={},this._out[j]={},this._sucs[j]={},++this._nodeCount,this)},v.prototype.node=function(j){return this._nodes[j]},v.prototype.hasNode=function(j){return l.has(this._nodes,j)},v.prototype.removeNode=function(j){var D=this;if(l.has(this._nodes,j)){var $=function(K){D.removeEdge(D._edgeObjs[K])};delete this._nodes[j],this._isCompound&&(this._removeFromParentsChildList(j),delete this._parent[j],l.each(this.children(j),function(K){D.setParent(K)}),delete this._children[j]),l.each(l.keys(this._in[j]),$),delete this._in[j],delete this._preds[j],l.each(l.keys(this._out[j]),$),delete this._out[j],delete this._sucs[j],--this._nodeCount}return this},v.prototype.setParent=function(j,D){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(l.isUndefined(D))D=E;else{D+="";for(var $=D;!l.isUndefined($);$=this.parent($))if($===j)throw new Error("Setting "+D+" as parent of "+j+" would create a cycle");this.setNode(D)}return this.setNode(j),this._removeFromParentsChildList(j),this._parent[j]=D,this._children[D][j]=!0,this},v.prototype._removeFromParentsChildList=function(j){delete this._children[this._parent[j]][j]},v.prototype.parent=function(j){if(this._isCompound){var D=this._parent[j];if(D!==E)return D}},v.prototype.children=function(j){if(l.isUndefined(j)&&(j=E),this._isCompound){var D=this._children[j];if(D)return l.keys(D)}else{if(j===E)return this.nodes();if(this.hasNode(j))return[]}},v.prototype.predecessors=function(j){var D=this._preds[j];if(D)return l.keys(D)},v.prototype.successors=function(j){var D=this._sucs[j];if(D)return l.keys(D)},v.prototype.neighbors=function(j){var D=this.predecessors(j);if(D)return l.union(D,this.successors(j))},v.prototype.isLeaf=function(j){var D;return this.isDirected()?D=this.successors(j):D=this.neighbors(j),D.length===0},v.prototype.filterNodes=function(j){var D=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});D.setGraph(this.graph());var $=this;l.each(this._nodes,function(nt,_){j(_)&&D.setNode(_,nt)}),l.each(this._edgeObjs,function(nt){D.hasNode(nt.v)&&D.hasNode(nt.w)&&D.setEdge(nt,$.edge(nt))});var K={};function ot(nt){var _=$.parent(nt);return _===void 0||D.hasNode(_)?(K[nt]=_,_):_ in K?K[_]:ot(_)}return this._isCompound&&l.each(D.nodes(),function(nt){D.setParent(nt,ot(nt))}),D},v.prototype.setDefaultEdgeLabel=function(j){return l.isFunction(j)||(j=l.constant(j)),this._defaultEdgeLabelFn=j,this},v.prototype.edgeCount=function(){return this._edgeCount},v.prototype.edges=function(){return l.values(this._edgeObjs)},v.prototype.setPath=function(j,D){var $=this,K=arguments;return l.reduce(j,function(ot,nt){return K.length>1?$.setEdge(ot,nt,D):$.setEdge(ot,nt),nt}),this},v.prototype.setEdge=function(){var j,D,$,K,ot=!1,nt=arguments[0];typeof nt=="object"&&nt!==null&&"v"in nt?(j=nt.v,D=nt.w,$=nt.name,arguments.length===2&&(K=arguments[1],ot=!0)):(j=nt,D=arguments[1],$=arguments[3],arguments.length>2&&(K=arguments[2],ot=!0)),j=""+j,D=""+D,l.isUndefined($)||($=""+$);var _=M(this._isDirected,j,D,$);if(l.has(this._edgeLabels,_))return ot&&(this._edgeLabels[_]=K),this;if(!l.isUndefined($)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(j),this.setNode(D),this._edgeLabels[_]=ot?K:this._defaultEdgeLabelFn(j,D,$);var et=A(this._isDirected,j,D,$);return j=et.v,D=et.w,Object.freeze(et),this._edgeObjs[_]=et,N(this._preds[D],j),N(this._sucs[j],D),this._in[D][_]=et,this._out[j][_]=et,this._edgeCount++,this},v.prototype.edge=function(j,D,$){var K=arguments.length===1?I(this._isDirected,arguments[0]):M(this._isDirected,j,D,$);return this._edgeLabels[K]},v.prototype.hasEdge=function(j,D,$){var K=arguments.length===1?I(this._isDirected,arguments[0]):M(this._isDirected,j,D,$);return l.has(this._edgeLabels,K)},v.prototype.removeEdge=function(j,D,$){var K=arguments.length===1?I(this._isDirected,arguments[0]):M(this._isDirected,j,D,$),ot=this._edgeObjs[K];return ot&&(j=ot.v,D=ot.w,delete this._edgeLabels[K],delete this._edgeObjs[K],S(this._preds[D],j),S(this._sucs[j],D),delete this._in[D][K],delete this._out[j][K],this._edgeCount--),this},v.prototype.inEdges=function(j,D){var $=this._in[j];if($){var K=l.values($);return D?l.filter(K,function(ot){return ot.v===D}):K}},v.prototype.outEdges=function(j,D){var $=this._out[j];if($){var K=l.values($);return D?l.filter(K,function(ot){return ot.w===D}):K}},v.prototype.nodeEdges=function(j,D){var $=this.inEdges(j,D);if($)return $.concat(this.outEdges(j,D))};function N(j,D){j[D]?j[D]++:j[D]=1}function S(j,D){--j[D]||delete j[D]}function M(j,D,$,K){var ot=""+D,nt=""+$;if(!j&&ot>nt){var _=ot;ot=nt,nt=_}return ot+b+nt+b+(l.isUndefined(K)?x:K)}function A(j,D,$,K){var ot=""+D,nt=""+$;if(!j&&ot>nt){var _=ot;ot=nt,nt=_}var et={v:ot,w:nt};return K&&(et.name=K),et}function I(j,D){return M(j,D.v,D.w,D.name)}},82354:function(w,P,a){w.exports={Graph:a(30771),version:a(49631)}},28974:function(w,P,a){var l=a(89126),x=a(30771);w.exports={write:E,read:N};function E(S){var M={options:{directed:S.isDirected(),multigraph:S.isMultigraph(),compound:S.isCompound()},nodes:b(S),edges:v(S)};return l.isUndefined(S.graph())||(M.value=l.clone(S.graph())),M}function b(S){return l.map(S.nodes(),function(M){var A=S.node(M),I=S.parent(M),j={v:M};return l.isUndefined(A)||(j.value=A),l.isUndefined(I)||(j.parent=I),j})}function v(S){return l.map(S.edges(),function(M){var A=S.edge(M),I={v:M.v,w:M.w};return l.isUndefined(M.name)||(I.name=M.name),l.isUndefined(A)||(I.value=A),I})}function N(S){var M=new x(S.options).setGraph(S.value);return l.each(S.nodes,function(A){M.setNode(A.v,A.value),A.parent&&M.setParent(A.v,A.parent)}),l.each(S.edges,function(A){M.setEdge({v:A.v,w:A.w,name:A.name},A.value)}),M}},89126:function(w,P,a){var l;try{l={clone:a(66678),constant:a(75703),each:a(85768),filter:a(63105),has:a(18721),isArray:a(1469),isEmpty:a(58367),isFunction:a(23560),isUndefined:a(52353),keys:a(3674),map:a(35161),reduce:a(54061),size:a(84238),transform:a(68718),union:a(93386),values:a(52628)}}catch(x){}l||(l=window._),w.exports=l},49631:function(w){w.exports="2.1.8"},44091:function(w,P,a){"use strict";a.r(P),a.d(P,{isAnyArray:function(){return x}});const l=Object.prototype.toString;function x(E){const b=l.call(E);return b.endsWith("Array]")&&!b.includes("Big")}},18552:function(w,P,a){var l=a(10852),x=a(55639),E=l(x,"DataView");w.exports=E},1989:function(w,P,a){var l=a(51789),x=a(80401),E=a(57667),b=a(21327),v=a(81866);function N(S){var M=-1,A=S==null?0:S.length;for(this.clear();++M-1}w.exports=x},1196:function(w){function P(a,l,x){for(var E=-1,b=a==null?0:a.length;++E0&&N(j)?v>1?E(j,v-1,N,S,M):l(M,j):S||(M[M.length]=j)}return M}w.exports=E},28483:function(w,P,a){var l=a(25063),x=l();w.exports=x},47816:function(w,P,a){var l=a(28483),x=a(3674);function E(b,v){return b&&l(b,v,x)}w.exports=E},97786:function(w,P,a){var l=a(71811),x=a(40327);function E(b,v){v=l(v,b);for(var N=0,S=v.length;b!=null&&Nl}w.exports=P},78565:function(w){var P=Object.prototype,a=P.hasOwnProperty;function l(x,E){return x!=null&&a.call(x,E)}w.exports=l},13:function(w){function P(a,l){return a!=null&&l in Object(a)}w.exports=P},42118:function(w,P,a){var l=a(41848),x=a(62722),E=a(42351);function b(v,N,S){return N===N?E(v,N,S):l(v,x,S)}w.exports=b},9454:function(w,P,a){var l=a(44239),x=a(37005),E="[object Arguments]";function b(v){return x(v)&&l(v)==E}w.exports=b},90939:function(w,P,a){var l=a(2492),x=a(37005);function E(b,v,N,S,M){return b===v?!0:b==null||v==null||!x(b)&&!x(v)?b!==b&&v!==v:l(b,v,N,S,E,M)}w.exports=E},2492:function(w,P,a){var l=a(46384),x=a(67114),E=a(18351),b=a(16096),v=a(64160),N=a(1469),S=a(44144),M=a(36719),A=1,I="[object Arguments]",j="[object Array]",D="[object Object]",$=Object.prototype,K=$.hasOwnProperty;function ot(nt,_,et,tt,it,at){var ft=N(nt),ht=N(_),dt=ft?j:v(nt),xt=ht?j:v(_);dt=dt==I?D:dt,xt=xt==I?D:xt;var yt=dt==D,Mt=xt==D,St=dt==xt;if(St&&S(nt)){if(!S(_))return!1;ft=!0,yt=!1}if(St&&!yt)return at||(at=new l),ft||M(nt)?x(nt,_,et,tt,it,at):E(nt,_,dt,et,tt,it,at);if(!(et&A)){var kt=yt&&K.call(nt,"__wrapped__"),Vt=Mt&&K.call(_,"__wrapped__");if(kt||Vt){var qt=kt?nt.value():nt,te=Vt?_.value():_;return at||(at=new l),it(qt,te,et,tt,at)}}return St?(at||(at=new l),b(nt,_,et,tt,it,at)):!1}w.exports=ot},25588:function(w,P,a){var l=a(64160),x=a(37005),E="[object Map]";function b(v){return x(v)&&l(v)==E}w.exports=b},2958:function(w,P,a){var l=a(46384),x=a(90939),E=1,b=2;function v(N,S,M,A){var I=M.length,j=I,D=!A;if(N==null)return!j;for(N=Object(N);I--;){var $=M[I];if(D&&$[2]?$[1]!==N[$[0]]:!($[0]in N))return!1}for(;++I=S){var et=I?null:v(A);if(et)return N(et);ot=!1,$=b,_=new l}else _=I?[]:nt;t:for(;++Db||M&&A&&j&&!I&&!D||N&&A&&j||!v&&j||!S)return 1;if(!N&&!M&&!D&&E=I)return j;var D=v[N];return j*(D=="desc"?-1:1)}}return E.index-b.index}w.exports=x},278:function(w){function P(a,l){var x=-1,E=a.length;for(l||(l=Array(E));++x1?N[M-1]:void 0,I=M>2?N[2]:void 0;for(A=b.length>3&&typeof A=="function"?(M--,A):void 0,I&&x(N[0],N[1],I)&&(A=M<3?void 0:A,M=1),v=Object(v);++S-1?A[I?N[j]:j]:void 0}}w.exports=b},47445:function(w,P,a){var l=a(40098),x=a(16612),E=a(18601);function b(v){return function(N,S,M){return M&&typeof M!="number"&&x(N,S,M)&&(S=M=void 0),N=E(N),S===void 0?(S=N,N=0):S=E(S),M=M===void 0?NK))return!1;var nt=D.get(S),_=D.get(M);if(nt&&_)return nt==M&&_==S;var et=-1,tt=!0,it=A&v?new l:void 0;for(D.set(S,M),D.set(M,S);++et-1&&x%1==0&&x-1}w.exports=x},54705:function(w,P,a){var l=a(18470);function x(E,b){var v=this.__data__,N=l(v,E);return N<0?(++this.size,v.push([E,b])):v[N][1]=b,this}w.exports=x},24785:function(w,P,a){var l=a(1989),x=a(38407),E=a(57071);function b(){this.size=0,this.__data__={hash:new l,map:new(E||x),string:new l}}w.exports=b},11285:function(w,P,a){var l=a(45050);function x(E){var b=l(this,E).delete(E);return this.size-=b?1:0,b}w.exports=x},96e3:function(w,P,a){var l=a(45050);function x(E){return l(this,E).get(E)}w.exports=x},49916:function(w,P,a){var l=a(45050);function x(E){return l(this,E).has(E)}w.exports=x},95265:function(w,P,a){var l=a(45050);function x(E,b){var v=l(this,E),N=v.size;return v.set(E,b),this.size+=v.size==N?0:1,this}w.exports=x},68776:function(w){function P(a){var l=-1,x=Array(a.size);return a.forEach(function(E,b){x[++l]=[b,E]}),x}w.exports=P},42634:function(w){function P(a,l){return function(x){return x==null?!1:x[a]===l&&(l!==void 0||a in Object(x))}}w.exports=P},24523:function(w,P,a){var l=a(88306),x=500;function E(b){var v=l(b,function(S){return N.size===x&&N.clear(),S}),N=v.cache;return v}w.exports=E},94536:function(w,P,a){var l=a(10852),x=l(Object,"create");w.exports=x},86916:function(w,P,a){var l=a(5569),x=l(Object.keys,Object);w.exports=x},33498:function(w){function P(a){var l=[];if(a!=null)for(var x in Object(a))l.push(x);return l}w.exports=P},31167:function(w,P,a){w=a.nmd(w);var l=a(31957),x=P&&!P.nodeType&&P,E=x&&!0&&w&&!w.nodeType&&w,b=E&&E.exports===x,v=b&&l.process,N=function(){try{var S=E&&E.require&&E.require("util").types;return S||v&&v.binding&&v.binding("util")}catch(M){}}();w.exports=N},2333:function(w){var P=Object.prototype,a=P.toString;function l(x){return a.call(x)}w.exports=l},5569:function(w){function P(a,l){return function(x){return a(l(x))}}w.exports=P},45357:function(w,P,a){var l=a(96874),x=Math.max;function E(b,v,N){return v=x(v===void 0?b.length-1:v,0),function(){for(var S=arguments,M=-1,A=x(S.length-v,0),I=Array(A);++M0){if(++b>=P)return arguments[0]}else b=0;return E.apply(void 0,arguments)}}w.exports=x},37465:function(w,P,a){var l=a(38407);function x(){this.__data__=new l,this.size=0}w.exports=x},63779:function(w){function P(a){var l=this.__data__,x=l.delete(a);return this.size=l.size,x}w.exports=P},67599:function(w){function P(a){return this.__data__.get(a)}w.exports=P},44758:function(w){function P(a){return this.__data__.has(a)}w.exports=P},34309:function(w,P,a){var l=a(38407),x=a(57071),E=a(83369),b=200;function v(N,S){var M=this.__data__;if(M instanceof l){var A=M.__data__;if(!x||A.length2?A[2]:void 0;for(D&&E(A[0],A[1],D)&&(j=1);++I-1&&l%1==0&&l<=P}w.exports=a},56688:function(w,P,a){var l=a(25588),x=a(7518),E=a(31167),b=E&&E.isMap,v=b?x(b):l;w.exports=v},13218:function(w){function P(a){var l=typeof a;return a!=null&&(l=="object"||l=="function")}w.exports=P},37005:function(w){function P(a){return a!=null&&typeof a=="object"}w.exports=P},68630:function(w,P,a){var l=a(44239),x=a(85924),E=a(37005),b="[object Object]",v=Function.prototype,N=Object.prototype,S=v.toString,M=N.hasOwnProperty,A=S.call(Object);function I(j){if(!E(j)||l(j)!=b)return!1;var D=x(j);if(D===null)return!0;var $=M.call(D,"constructor")&&D.constructor;return typeof $=="function"&&$ instanceof $&&S.call($)==A}w.exports=I},72928:function(w,P,a){var l=a(29221),x=a(7518),E=a(31167),b=E&&E.isSet,v=b?x(b):l;w.exports=v},47037:function(w,P,a){var l=a(44239),x=a(1469),E=a(37005),b="[object String]";function v(N){return typeof N=="string"||!x(N)&&E(N)&&l(N)==b}w.exports=v},33448:function(w,P,a){var l=a(44239),x=a(37005),E="[object Symbol]";function b(v){return typeof v=="symbol"||x(v)&&l(v)==E}w.exports=b},36719:function(w,P,a){var l=a(38749),x=a(7518),E=a(31167),b=E&&E.isTypedArray,v=b?x(b):l;w.exports=v},52353:function(w){function P(a){return a===void 0}w.exports=P},3674:function(w,P,a){var l=a(14636),x=a(280),E=a(98612);function b(v){return E(v)?l(v):x(v)}w.exports=b},81704:function(w,P,a){var l=a(14636),x=a(10313),E=a(98612);function b(v){return E(v)?l(v,!0):x(v)}w.exports=b},10928:function(w){function P(a){var l=a==null?0:a.length;return l?a[l-1]:void 0}w.exports=P},35161:function(w,P,a){var l=a(29932),x=a(67206),E=a(69199),b=a(1469);function v(N,S){var M=b(N)?l:E;return M(N,x(S,3))}w.exports=v},8521:function(w,P,a){var l=a(89465),x=a(47816),E=a(67206);function b(v,N){var S={};return N=E(N,3),x(v,function(M,A,I){l(S,A,N(M,A,I))}),S}w.exports=b},6162:function(w,P,a){var l=a(56029),x=a(53325),E=a(6557);function b(v){return v&&v.length?l(v,E,x):void 0}w.exports=b},88306:function(w,P,a){var l=a(83369),x="Expected a function";function E(b,v){if(typeof b!="function"||v!=null&&typeof v!="function")throw new TypeError(x);var N=function(){var S=arguments,M=v?v.apply(this,S):S[0],A=N.cache;if(A.has(M))return A.get(M);var I=b.apply(this,S);return N.cache=A.set(M,I)||A,I};return N.cache=new(E.Cache||l),N}E.Cache=l,w.exports=E},82492:function(w,P,a){var l=a(42980),x=a(21463),E=x(function(b,v,N){l(b,v,N)});w.exports=E},53632:function(w,P,a){var l=a(56029),x=a(70433),E=a(6557);function b(v){return v&&v.length?l(v,E,x):void 0}w.exports=b},22762:function(w,P,a){var l=a(56029),x=a(67206),E=a(70433);function b(v,N){return v&&v.length?l(v,x(N,2),E):void 0}w.exports=b},50308:function(w){function P(){}w.exports=P},7771:function(w,P,a){var l=a(55639),x=function(){return l.Date.now()};w.exports=x},78718:function(w,P,a){var l=a(25970),x=a(99021),E=x(function(b,v){return b==null?{}:l(b,v)});w.exports=E},39601:function(w,P,a){var l=a(40371),x=a(79152),E=a(15403),b=a(40327);function v(N){return E(N)?l(b(N)):x(N)}w.exports=v},96026:function(w,P,a){var l=a(47445),x=l();w.exports=x},54061:function(w,P,a){var l=a(62663),x=a(89881),E=a(67206),b=a(10107),v=a(1469);function N(S,M,A){var I=v(S)?l:b,j=arguments.length<3;return I(S,E(M,4),A,j,x)}w.exports=N},84238:function(w,P,a){var l=a(280),x=a(64160),E=a(98612),b=a(47037),v=a(88016),N="[object Map]",S="[object Set]";function M(A){if(A==null)return 0;if(E(A))return b(A)?v(A):A.length;var I=x(A);return I==N||I==S?A.size:l(A).length}w.exports=M},89734:function(w,P,a){var l=a(21078),x=a(82689),E=a(18460),b=a(16612),v=E(function(N,S){if(N==null)return[];var M=S.length;return M>1&&b(N,S[0],S[1])?S=[]:M>2&&b(S[0],S[1],S[2])&&(S=[S[0]]),x(N,l(S,1),[])});w.exports=v},70479:function(w){function P(){return[]}w.exports=P},95062:function(w){function P(){return!1}w.exports=P},18601:function(w,P,a){var l=a(14841),x=1/0,E=17976931348623157e292;function b(v){if(!v)return v===0?v:0;if(v=l(v),v===x||v===-x){var N=v<0?-1:1;return N*E}return v===v?v:0}w.exports=b},40554:function(w,P,a){var l=a(18601);function x(E){var b=l(E),v=b%1;return b===b?v?b-v:b:0}w.exports=x},14841:function(w,P,a){var l=a(27561),x=a(13218),E=a(33448),b=NaN,v=/^[-+]0x[0-9a-f]+$/i,N=/^0b[01]+$/i,S=/^0o[0-7]+$/i,M=parseInt;function A(I){if(typeof I=="number")return I;if(E(I))return b;if(x(I)){var j=typeof I.valueOf=="function"?I.valueOf():I;I=x(j)?j+"":j}if(typeof I!="string")return I===0?I:+I;I=l(I);var D=N.test(I);return D||S.test(I)?M(I.slice(2),D?2:8):v.test(I)?b:+I}w.exports=A},59881:function(w,P,a){var l=a(98363),x=a(81704);function E(b){return l(b,x(b))}w.exports=E},79833:function(w,P,a){var l=a(80531);function x(E){return E==null?"":l(E)}w.exports=x},68718:function(w,P,a){var l=a(77412),x=a(3118),E=a(47816),b=a(67206),v=a(85924),N=a(1469),S=a(44144),M=a(23560),A=a(13218),I=a(36719);function j(D,$,K){var ot=N(D),nt=ot||S(D)||I(D);if($=b($,4),K==null){var _=D&&D.constructor;nt?K=ot?new _:[]:A(D)?K=M(_)?x(v(D)):{}:K={}}return(nt?l:E)(D,function(et,tt,it){return $(K,et,tt,it)}),K}w.exports=j},93386:function(w,P,a){var l=a(21078),x=a(18460),E=a(45652),b=a(29246),v=x(function(N){return E(l(N,1,b,!0))});w.exports=v},73955:function(w,P,a){var l=a(79833),x=0;function E(b){var v=++x;return l(b)+v}w.exports=E},52628:function(w,P,a){var l=a(47415),x=a(3674);function E(b){return b==null?[]:l(b,x(b))}w.exports=E},7287:function(w,P,a){var l=a(34865),x=a(1757);function E(b,v){return x(b||[],v||[],l)}w.exports=E},75823:function(w,P,a){"use strict";a.r(P),a.d(P,{default:function(){return b}});var l=a(44091);function x(v){var N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!(0,l.isAnyArray)(v))throw new TypeError("input must be an array");if(v.length===0)throw new TypeError("input must not be empty");var S=N.fromIndex,M=S===void 0?0:S,A=N.toIndex,I=A===void 0?v.length:A;if(M<0||M>=v.length||!Number.isInteger(M))throw new Error("fromIndex must be a positive integer smaller than length");if(I<=M||I>v.length||!Number.isInteger(I))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var j=v[M],D=M+1;Dj&&(j=v[D]);return j}function E(v){var N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!(0,l.isAnyArray)(v))throw new TypeError("input must be an array");if(v.length===0)throw new TypeError("input must not be empty");var S=N.fromIndex,M=S===void 0?0:S,A=N.toIndex,I=A===void 0?v.length:A;if(M<0||M>=v.length||!Number.isInteger(M))throw new Error("fromIndex must be a positive integer smaller than length");if(I<=M||I>v.length||!Number.isInteger(I))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var j=v[M],D=M+1;D1&&arguments[1]!==void 0?arguments[1]:{};if((0,l.isAnyArray)(v)){if(v.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var S;if(N.output!==void 0){if(!(0,l.isAnyArray)(N.output))throw new TypeError("output option must be an array if specified");S=N.output}else S=new Array(v.length);var M=E(v),A=x(v);if(M===A)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var I=N.min,j=I===void 0?N.autoMinMax?M:0:I,D=N.max,$=D===void 0?N.autoMinMax?A:1:D;if(j>=$)throw new RangeError("min option must be smaller than max option");for(var K=($-j)/(A-M),ot=0;ot=0;h--)(d=n[h])&&(o=(s<3?d(o):s>3?d(t,e,o):d(t,e))||o);return s>3&&o&&Object.defineProperty(t,e,o),o}function E(n,t){return function(e,r){t(e,r,n)}}function b(n,t,e,r,s,o){function d(C){if(C!==void 0&&typeof C!="function")throw new TypeError("Function expected");return C}for(var h=r.kind,p=h==="getter"?"get":h==="setter"?"set":"value",g=!t&&n?r.static?n:n.prototype:null,y=t||(g?Object.getOwnPropertyDescriptor(g,r.name):{}),O,L=!1,R=e.length-1;R>=0;R--){var U={};for(var F in r)U[F]=F==="access"?{}:r[F];for(var F in r.access)U.access[F]=r.access[F];U.addInitializer=function(C){if(L)throw new TypeError("Cannot add initializers after decoration has completed");o.push(d(C||null))};var z=(0,e[R])(h==="accessor"?{get:y.get,set:y.set}:y[p],U);if(h==="accessor"){if(z===void 0)continue;if(z===null||typeof z!="object")throw new TypeError("Object expected");(O=d(z.get))&&(y.get=O),(O=d(z.set))&&(y.set=O),(O=d(z.init))&&s.push(O)}else(O=d(z))&&(h==="field"?s.push(O):y[p]=O)}g&&Object.defineProperty(g,r.name,y),L=!0}function v(n,t,e){for(var r=arguments.length>2,s=0;s0&&o[o.length-1])&&(g[0]===6||g[0]===2)){e=0;continue}if(g[0]===3&&(!o||g[1]>o[0]&&g[1]=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function K(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),s,o=[],d;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(h){d={error:h}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(d)throw d.error}}return o}function ot(){for(var n=[],t=0;t1||h(L,R)})})}function h(L,R){try{p(r[L](R))}catch(U){O(o[0][3],U)}}function p(L){L.value instanceof et?Promise.resolve(L.value.v).then(g,y):O(o[0][2],L)}function g(L){h("next",L)}function y(L){h("throw",L)}function O(L,R){L(R),o.shift(),o.length&&h(o[0][0],o[0][1])}}function it(n){var t,e;return t={},r("next"),r("throw",function(s){throw s}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(s,o){t[s]=n[s]?function(d){return(e=!e)?{value:et(n[s](d)),done:!1}:o?o(d):d}:o}}function at(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=n[Symbol.asyncIterator],e;return t?t.call(n):(n=typeof $=="function"?$(n):n[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(o){e[o]=n[o]&&function(d){return new Promise(function(h,p){d=n[o](d),s(h,p,d.done,d.value)})}}function s(o,d,h,p){Promise.resolve(p).then(function(g){o({value:g,done:h})},d)}}function ft(n,t){return Object.defineProperty?Object.defineProperty(n,"raw",{value:t}):n.raw=t,n}var ht=Object.create?function(n,t){Object.defineProperty(n,"default",{enumerable:!0,value:t})}:function(n,t){n.default=t};function dt(n){if(n&&n.__esModule)return n;var t={};if(n!=null)for(var e in n)e!=="default"&&Object.prototype.hasOwnProperty.call(n,e)&&j(t,n,e);return ht(t,n),t}function xt(n){return n&&n.__esModule?n:{default:n}}function yt(n,t,e,r){if(e==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!r:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?r:e==="a"?r.call(n):r?r.value:t.get(n)}function Mt(n,t,e,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?n!==t||!s:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(n,e):s?s.value=e:t.set(n,e),e}function St(n,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof n=="function"?t===n:n.has(t)}var kt="*",Vt=function(){function n(){this._events={}}return n.prototype.on=function(t,e,r){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!r}),this},n.prototype.once=function(t,e){return this.on(t,e,!0)},n.prototype.emit=function(t){for(var e=this,r=[],s=1;s{t.has(d.id)||(t.add(d.id),n.push(d))})}return!1}function ce(n,t,e,r){if(e(n))return!0;t.add(n.id);for(const o of r(n.id))if(!t.has(o.id)&&ce(o,t,e,r))return!0;return!1}const ze=()=>!0;class tn{constructor(t){be(this,"graph");be(this,"nodeFilter");be(this,"edgeFilter");be(this,"cacheEnabled");be(this,"inEdgesMap",new Map);be(this,"outEdgesMap",new Map);be(this,"bothEdgesMap",new Map);be(this,"allNodesMap",new Map);be(this,"allEdgesMap",new Map);be(this,"clearCache",()=>{this.inEdgesMap.clear(),this.outEdgesMap.clear(),this.bothEdgesMap.clear(),this.allNodesMap.clear(),this.allEdgesMap.clear()});be(this,"refreshCache",()=>{this.clearCache(),this.updateCache(this.graph.getAllNodes().map(t=>t.id))});be(this,"updateCache",t=>{const e=new Set;t.forEach(r=>{const s=this.bothEdgesMap.get(r);if(s&&s.forEach(o=>e.add(o.id)),!this.hasNode(r))this.inEdgesMap.delete(r),this.outEdgesMap.delete(r),this.bothEdgesMap.delete(r),this.allNodesMap.delete(r);else{const o=this.graph.getRelatedEdges(r,"in").filter(this.edgeFilter),d=this.graph.getRelatedEdges(r,"out").filter(this.edgeFilter),h=Array.from(new Set([...o,...d]));h.forEach(p=>e.add(p.id)),this.inEdgesMap.set(r,o),this.outEdgesMap.set(r,d),this.bothEdgesMap.set(r,h),this.allNodesMap.set(r,this.graph.getNode(r))}}),e.forEach(r=>{this.hasEdge(r)?this.allEdgesMap.set(r,this.graph.getEdge(r)):this.allEdgesMap.delete(r)})});be(this,"handleGraphChanged",t=>{const e=new Set;t.changes.forEach(r=>{switch(r.type){case"NodeAdded":e.add(r.value.id);break;case"NodeDataUpdated":e.add(r.id);break;case"EdgeAdded":e.add(r.value.source),e.add(r.value.target);break;case"EdgeUpdated":(r.propertyName==="source"||r.propertyName==="target")&&(e.add(r.oldValue),e.add(r.newValue));break;case"EdgeDataUpdated":if(t.graph.hasEdge(r.id)){const s=t.graph.getEdge(r.id);e.add(s.source),e.add(s.target)}break;case"EdgeRemoved":e.add(r.value.source),e.add(r.value.target);break;case"NodeRemoved":e.add(r.value.id);break;default:break}}),this.updateCache(e)});this.graph=t.graph;const e=t.nodeFilter||ze,r=t.edgeFilter||ze;this.nodeFilter=e,this.edgeFilter=s=>{const{source:o,target:d}=this.graph.getEdgeDetail(s.id);return!e(o)||!e(d)?!1:r(s,o,d)},t.cache==="auto"?(this.cacheEnabled=!0,this.startAutoCache()):t.cache==="manual"?this.cacheEnabled=!0:this.cacheEnabled=!1}startAutoCache(){this.refreshCache(),this.graph.on("changed",this.handleGraphChanged)}stopAutoCache(){this.graph.off("changed",this.handleGraphChanged)}checkNodeExistence(t){this.getNode(t)}hasNode(t){if(!this.graph.hasNode(t))return!1;const e=this.graph.getNode(t);return this.nodeFilter(e)}areNeighbors(t,e){return this.checkNodeExistence(t),this.getNeighbors(e).some(r=>r.id===t)}getNode(t){const e=this.graph.getNode(t);if(!this.nodeFilter(e))throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){return this.checkNodeExistence(t),this.cacheEnabled?e==="in"?this.inEdgesMap.get(t):e==="out"?this.outEdgesMap.get(t):this.bothEdgesMap.get(t):this.graph.getRelatedEdges(t,e).filter(this.edgeFilter)}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const r=this.getRelatedEdges(t,"out").map(s=>this.getNode(s.target));return Array.from(new Set(r))}getPredecessors(t){const r=this.getRelatedEdges(t,"in").map(s=>this.getNode(s.source));return Array.from(new Set(r))}getNeighbors(t){const e=this.getPredecessors(t),r=this.getSuccessors(t);return Array.from(new Set([...e,...r]))}hasEdge(t){if(!this.graph.hasEdge(t))return!1;const e=this.graph.getEdge(t);return this.edgeFilter(e)}getEdge(t){const e=this.graph.getEdge(t);if(!this.edgeFilter(e))throw new Error("Edge not found for id: "+t);return e}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}hasTreeStructure(t){return this.graph.hasTreeStructure(t)}getRoots(t){return this.graph.getRoots(t).filter(this.nodeFilter)}getChildren(t,e){return this.checkNodeExistence(t),this.graph.getChildren(t,e).filter(this.nodeFilter)}getParent(t,e){this.checkNodeExistence(t);const r=this.graph.getParent(t,e);return!r||!this.nodeFilter(r)?null:r}getAllNodes(){return this.cacheEnabled?Array.from(this.allNodesMap.values()):this.graph.getAllNodes().filter(this.nodeFilter)}getAllEdges(){return this.cacheEnabled?Array.from(this.allEdgesMap.values()):this.graph.getAllEdges().filter(this.edgeFilter)}bfs(t,e,r="out"){const s={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];te([this.getNode(t)],new Set,e,s)}dfs(t,e,r="out"){const s={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];ce(this.getNode(t),new Set,e,s)}}class xe extends qt{constructor(e){super();be(this,"nodeMap",new Map);be(this,"edgeMap",new Map);be(this,"inEdgesMap",new Map);be(this,"outEdgesMap",new Map);be(this,"bothEdgesMap",new Map);be(this,"treeIndices",new Map);be(this,"changes",[]);be(this,"batchCount",0);be(this,"onChanged",()=>{});be(this,"batch",e=>{this.batchCount+=1,e(),this.batchCount-=1,this.batchCount||this.commit()});e&&(e.nodes&&this.addNodes(e.nodes),e.edges&&this.addEdges(e.edges),e.tree&&this.addTree(e.tree),e.onChanged&&(this.onChanged=e.onChanged))}commit(){const e=this.changes;this.changes=[];const r={graph:this,changes:e};this.emit("changed",r),this.onChanged(r)}reduceChanges(e){let r=[];return e.forEach(s=>{switch(s.type){case"NodeRemoved":{let o=!1;r=r.filter(d=>{if(d.type==="NodeAdded"){const h=d.value.id===s.value.id;return h&&(o=!0),!h}else{if(d.type==="NodeDataUpdated")return d.id!==s.value.id;if(d.type==="TreeStructureChanged")return d.nodeId!==s.value.id}return!0}),o||r.push(s);break}case"EdgeRemoved":{let o=!1;r=r.filter(d=>{if(d.type==="EdgeAdded"){const h=d.value.id===s.value.id;return h&&(o=!0),!h}else if(d.type==="EdgeDataUpdated"||d.type==="EdgeUpdated")return d.id!==s.value.id;return!0}),o||r.push(s);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const o=r.findIndex(h=>h.type===s.type&&h.id===s.id&&(s.propertyName===void 0||h.propertyName===s.propertyName)),d=r[o];d?s.propertyName!==void 0?d.newValue=s.newValue:(r.splice(o,1),r.push(s)):r.push(s);break}case"TreeStructureDetached":{r=r.filter(o=>o.type==="TreeStructureAttached"||o.type==="TreeStructureChanged"?o.treeKey!==s.treeKey:!0),r.push(s);break}case"TreeStructureChanged":{const o=r.find(d=>d.type==="TreeStructureChanged"&&d.treeKey===s.treeKey&&d.nodeId===s.nodeId);o?o.newParentId=s.newParentId:r.push(s);break}default:r.push(s);break}}),r}checkNodeExistence(e){this.getNode(e)}hasNode(e){return this.nodeMap.has(e)}areNeighbors(e,r){return this.getNeighbors(r).some(s=>s.id===e)}getNode(e){const r=this.nodeMap.get(e);if(!r)throw new Error("Node not found for id: "+e);return r}getRelatedEdges(e,r){if(this.checkNodeExistence(e),r==="in"){const s=this.inEdgesMap.get(e);return Array.from(s)}else if(r==="out"){const s=this.outEdgesMap.get(e);return Array.from(s)}else{const s=this.bothEdgesMap.get(e);return Array.from(s)}}getDegree(e,r){return this.getRelatedEdges(e,r).length}getSuccessors(e){const s=this.getRelatedEdges(e,"out").map(o=>this.getNode(o.target));return Array.from(new Set(s))}getPredecessors(e){const s=this.getRelatedEdges(e,"in").map(o=>this.getNode(o.source));return Array.from(new Set(s))}getNeighbors(e){const r=this.getPredecessors(e),s=this.getSuccessors(e);return Array.from(new Set([...r,...s]))}doAddNode(e){if(this.hasNode(e.id))throw new Error("Node already exists: "+e.id);this.nodeMap.set(e.id,e),this.inEdgesMap.set(e.id,new Set),this.outEdgesMap.set(e.id,new Set),this.bothEdgesMap.set(e.id,new Set),this.treeIndices.forEach(r=>{r.childrenMap.set(e.id,new Set)}),this.changes.push({type:"NodeAdded",value:e})}addNodes(e){this.batch(()=>{for(const r of e)this.doAddNode(r)})}addNode(e){this.addNodes([e])}doRemoveNode(e){const r=this.getNode(e),s=this.bothEdgesMap.get(e);s==null||s.forEach(o=>this.doRemoveEdge(o.id)),this.nodeMap.delete(e),this.treeIndices.forEach(o=>{var h,p;(h=o.childrenMap.get(e))==null||h.forEach(g=>{o.parentMap.delete(g.id)});const d=o.parentMap.get(e);d&&((p=o.childrenMap.get(d.id))==null||p.delete(r)),o.parentMap.delete(e),o.childrenMap.delete(e)}),this.bothEdgesMap.delete(e),this.inEdgesMap.delete(e),this.outEdgesMap.delete(e),this.changes.push({type:"NodeRemoved",value:r})}removeNodes(e){this.batch(()=>{e.forEach(r=>this.doRemoveNode(r))})}removeNode(e){this.removeNodes([e])}updateNodeDataProperty(e,r,s){const o=this.getNode(e);this.batch(()=>{const d=o.data[r],h=s;o.data[r]=h,this.changes.push({type:"NodeDataUpdated",id:e,propertyName:r,oldValue:d,newValue:h})})}mergeNodeData(e,r){this.batch(()=>{Object.entries(r).forEach(([s,o])=>{this.updateNodeDataProperty(e,s,o)})})}updateNodeData(...e){const r=e[0],s=this.getNode(r);if(typeof e[1]=="string"){this.updateNodeDataProperty(r,e[1],e[2]);return}let o;if(typeof e[1]=="function"){const d=e[1];o=d(s.data)}else typeof e[1]=="object"&&(o=e[1]);this.batch(()=>{const d=s.data,h=o;s.data=o,this.changes.push({type:"NodeDataUpdated",id:r,oldValue:d,newValue:h})})}checkEdgeExistence(e){if(!this.hasEdge(e))throw new Error("Edge not found for id: "+e)}hasEdge(e){return this.edgeMap.has(e)}getEdge(e){return this.checkEdgeExistence(e),this.edgeMap.get(e)}getEdgeDetail(e){const r=this.getEdge(e);return{edge:r,source:this.getNode(r.source),target:this.getNode(r.target)}}doAddEdge(e){if(this.hasEdge(e.id))throw new Error("Edge already exists: "+e.id);this.checkNodeExistence(e.source),this.checkNodeExistence(e.target),this.edgeMap.set(e.id,e);const r=this.inEdgesMap.get(e.target),s=this.outEdgesMap.get(e.source),o=this.bothEdgesMap.get(e.source),d=this.bothEdgesMap.get(e.target);r.add(e),s.add(e),o.add(e),d.add(e),this.changes.push({type:"EdgeAdded",value:e})}addEdges(e){this.batch(()=>{for(const r of e)this.doAddEdge(r)})}addEdge(e){this.addEdges([e])}doRemoveEdge(e){const r=this.getEdge(e),s=this.outEdgesMap.get(r.source),o=this.inEdgesMap.get(r.target),d=this.bothEdgesMap.get(r.source),h=this.bothEdgesMap.get(r.target);s.delete(r),o.delete(r),d.delete(r),h.delete(r),this.edgeMap.delete(e),this.changes.push({type:"EdgeRemoved",value:r})}removeEdges(e){this.batch(()=>{e.forEach(r=>this.doRemoveEdge(r))})}removeEdge(e){this.removeEdges([e])}updateEdgeSource(e,r){const s=this.getEdge(e);this.checkNodeExistence(r);const o=s.source,d=r;this.outEdgesMap.get(o).delete(s),this.bothEdgesMap.get(o).delete(s),this.outEdgesMap.get(d).add(s),this.bothEdgesMap.get(d).add(s),s.source=r,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:e,propertyName:"source",oldValue:o,newValue:d})})}updateEdgeTarget(e,r){const s=this.getEdge(e);this.checkNodeExistence(r);const o=s.target,d=r;this.inEdgesMap.get(o).delete(s),this.bothEdgesMap.get(o).delete(s),this.inEdgesMap.get(d).add(s),this.bothEdgesMap.get(d).add(s),s.target=r,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:e,propertyName:"target",oldValue:o,newValue:d})})}updateEdgeDataProperty(e,r,s){const o=this.getEdge(e);this.batch(()=>{const d=o.data[r],h=s;o.data[r]=h,this.changes.push({type:"EdgeDataUpdated",id:e,propertyName:r,oldValue:d,newValue:h})})}updateEdgeData(...e){const r=e[0],s=this.getEdge(r);if(typeof e[1]=="string"){this.updateEdgeDataProperty(r,e[1],e[2]);return}let o;if(typeof e[1]=="function"){const d=e[1];o=d(s.data)}else typeof e[1]=="object"&&(o=e[1]);this.batch(()=>{const d=s.data,h=o;s.data=o,this.changes.push({type:"EdgeDataUpdated",id:r,oldValue:d,newValue:h})})}mergeEdgeData(e,r){this.batch(()=>{Object.entries(r).forEach(([s,o])=>{this.updateEdgeDataProperty(e,s,o)})})}checkTreeExistence(e){if(!this.hasTreeStructure(e))throw new Error("Tree structure not found for treeKey: "+e)}hasTreeStructure(e){return this.treeIndices.has(e)}attachTreeStructure(e){this.treeIndices.has(e)||(this.treeIndices.set(e,{parentMap:new Map,childrenMap:new Map}),this.batch(()=>{this.changes.push({type:"TreeStructureAttached",treeKey:e})}))}detachTreeStructure(e){this.checkTreeExistence(e),this.treeIndices.delete(e),this.batch(()=>{this.changes.push({type:"TreeStructureDetached",treeKey:e})})}addTree(e,r){this.batch(()=>{this.attachTreeStructure(r);const s=[],o=Array.isArray(e)?e:[e];for(;o.length;){const d=o.shift();s.push(d),d.children&&o.push(...d.children)}this.addNodes(s),s.forEach(d=>{var h;(h=d.children)==null||h.forEach(p=>{this.setParent(p.id,d.id,r)})})})}getRoots(e){return this.checkTreeExistence(e),this.getAllNodes().filter(r=>!this.getParent(r.id,e))}getChildren(e,r){this.checkNodeExistence(e),this.checkTreeExistence(r);const o=this.treeIndices.get(r).childrenMap.get(e);return Array.from(o||[])}getParent(e,r){return this.checkNodeExistence(e),this.checkTreeExistence(r),this.treeIndices.get(r).parentMap.get(e)||null}getAncestors(e,r){const s=[];let o=this.getNode(e),d;for(;d=this.getParent(o.id,r);)s.push(d),o=d;return s}setParent(e,r,s){var y,O;this.checkTreeExistence(s);const o=this.treeIndices.get(s),d=this.getNode(e),h=o.parentMap.get(e);if((h==null?void 0:h.id)===r)return;if(r===void 0){h&&((y=o.childrenMap.get(h.id))==null||y.delete(d)),o.parentMap.delete(e);return}const p=this.getNode(r);o.parentMap.set(e,p),h&&((O=o.childrenMap.get(h.id))==null||O.delete(d));let g=o.childrenMap.get(p.id);g||(g=new Set,o.childrenMap.set(p.id,g)),g.add(d),this.batch(()=>{this.changes.push({type:"TreeStructureChanged",treeKey:s,nodeId:e,oldParentId:h==null?void 0:h.id,newParentId:p.id})})}dfsTree(e,r,s){const o=d=>this.getChildren(d,s);return ce(this.getNode(e),new Set,r,o)}bfsTree(e,r,s){const o=d=>this.getChildren(d,s);return te([this.getNode(e)],new Set,r,o)}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(e,r,s="out"){const o={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[s];return te([this.getNode(e)],new Set,r,o)}dfs(e,r,s="out"){const o={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[s];return ce(this.getNode(e),new Set,r,o)}clone(){const e=this.getAllNodes().map(o=>es(Gn({},o),{data:Gn({},o.data)})),r=this.getAllEdges().map(o=>es(Gn({},o),{data:Gn({},o.data)})),s=new xe({nodes:e,edges:r});return this.treeIndices.forEach(({parentMap:o,childrenMap:d},h)=>{const p=new Map;o.forEach((y,O)=>{p.set(O,s.getNode(y.id))});const g=new Map;d.forEach((y,O)=>{g.set(O,new Set(Array.from(y).map(L=>s.getNode(L.id))))}),s.treeIndices.set(h,{parentMap:p,childrenMap:g})}),s}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}createView(e){return new tn(Gn({graph:this},e))}}const mn=Symbol("Comlink.proxy"),Mn=Symbol("Comlink.endpoint"),cn=Symbol("Comlink.releaseProxy"),en=Symbol("Comlink.finalizer"),gt=Symbol("Comlink.thrown"),wt=n=>typeof n=="object"&&n!==null||typeof n=="function",jt={canHandle:n=>wt(n)&&n[mn],serialize(n){const{port1:t,port2:e}=new MessageChannel;return ge(n,t),[e,[e]]},deserialize(n){return n.start(),Ce(n)}},Ft={canHandle:n=>wt(n)&> in n,serialize({value:n}){let t;return n instanceof Error?t={isError:!0,value:{message:n.message,name:n.name,stack:n.stack}}:t={isError:!1,value:n},[t,[]]},deserialize(n){throw n.isError?Object.assign(new Error(n.value.message),n.value):n.value}},Ht=new Map([["proxy",jt],["throw",Ft]]);function de(n,t){for(const e of n)if(t===e||e==="*"||e instanceof RegExp&&e.test(t))return!0;return!1}function ge(n,t=globalThis,e=["*"]){t.addEventListener("message",function r(s){if(!s||!s.data)return;if(!de(e,s.origin)){console.warn(`Invalid origin '${s.origin}' for comlink proxy`);return}const{id:o,type:d,path:h}=Object.assign({path:[]},s.data),p=(s.data.argumentList||[]).map(ke);let g;try{const y=h.slice(0,-1).reduce((L,R)=>L[R],n),O=h.reduce((L,R)=>L[R],n);switch(d){case"GET":g=O;break;case"SET":y[h.slice(-1)[0]]=ke(s.data.value),g=!0;break;case"APPLY":g=O.apply(y,p);break;case"CONSTRUCT":{const L=new O(...p);g=wn(L)}break;case"ENDPOINT":{const{port1:L,port2:R}=new MessageChannel;ge(n,R),g=Fe(L,[L])}break;case"RELEASE":g=void 0;break;default:return}}catch(y){g={value:y,[gt]:0}}Promise.resolve(g).catch(y=>({value:y,[gt]:0})).then(y=>{const[O,L]=ln(y);t.postMessage(Object.assign(Object.assign({},O),{id:o}),L),d==="RELEASE"&&(t.removeEventListener("message",r),fn(t),en in n&&typeof n[en]=="function"&&n[en]())}).catch(y=>{const[O,L]=ln({value:new TypeError("Unserializable return value"),[gt]:0});t.postMessage(Object.assign(Object.assign({},O),{id:o}),L)})}),t.start&&t.start()}function Re(n){return n.constructor.name==="MessagePort"}function fn(n){Re(n)&&n.close()}function Ce(n,t){return It(n,[],t)}function Ne(n){if(n)throw new Error("Proxy has been released and is not useable")}function se(n){return nn(n,{type:"RELEASE"}).then(()=>{fn(n)})}const Wt=new WeakMap,ee="FinalizationRegistry"in globalThis&&new FinalizationRegistry(n=>{const t=(Wt.get(n)||0)-1;Wt.set(n,t),t===0&&se(n)});function on(n,t){const e=(Wt.get(t)||0)+1;Wt.set(t,e),ee&&ee.register(n,t,n)}function an(n){ee&&ee.unregister(n)}function It(n,t=[],e=function(){}){let r=!1;const s=new Proxy(e,{get(o,d){if(Ne(r),d===cn)return()=>{an(s),se(n),r=!0};if(d==="then"){if(t.length===0)return{then:()=>s};const h=nn(n,{type:"GET",path:t.map(p=>p.toString())}).then(ke);return h.then.bind(h)}return It(n,[...t,d])},set(o,d,h){Ne(r);const[p,g]=ln(h);return nn(n,{type:"SET",path:[...t,d].map(y=>y.toString()),value:p},g).then(ke)},apply(o,d,h){Ne(r);const p=t[t.length-1];if(p===Mn)return nn(n,{type:"ENDPOINT"}).then(ke);if(p==="bind")return It(n,t.slice(0,-1));const[g,y]=De(h);return nn(n,{type:"APPLY",path:t.map(O=>O.toString()),argumentList:g},y).then(ke)},construct(o,d){Ne(r);const[h,p]=De(d);return nn(n,{type:"CONSTRUCT",path:t.map(g=>g.toString()),argumentList:h},p).then(ke)}});return on(s,n),s}function yn(n){return Array.prototype.concat.apply([],n)}function De(n){const t=n.map(ln);return[t.map(e=>e[0]),yn(t.map(e=>e[1]))]}const Se=new WeakMap;function Fe(n,t){return Se.set(n,t),n}function wn(n){return Object.assign(n,{[mn]:!0})}function rr(n,t=globalThis,e="*"){return{postMessage:(r,s)=>n.postMessage(r,e,s),addEventListener:t.addEventListener.bind(t),removeEventListener:t.removeEventListener.bind(t)}}function ln(n){for(const[t,e]of Ht)if(e.canHandle(n)){const[r,s]=e.serialize(n);return[{type:"HANDLER",name:t,value:r},s]}return[{type:"RAW",value:n},Se.get(n)||[]]}function ke(n){switch(n.type){case"HANDLER":return Ht.get(n.name).deserialize(n.value);case"RAW":return n.value}}function nn(n,t,e){return new Promise(r=>{const s=In();n.addEventListener("message",function o(d){!d.data||!d.data.id||d.data.id!==s||(n.removeEventListener("message",o),r(d.data))}),n.start&&n.start(),n.postMessage(Object.assign({id:s},t),e)})}function In(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}function $t(n){return typeof n=="number"}function Pn(n){return n==null}const Qe=(n,t)=>{if(n!=="next"&&n!=="prev")return t},Ke=n=>{n.prev.next=n.next,n.next.prev=n.prev,delete n.next,delete n.prev};class Ve{constructor(){const t={};t.prev=t,t.next=t.prev,this.shortcut=t}dequeue(){const t=this.shortcut,e=t.prev;if(e&&e!==t)return Ke(e),e}enqueue(t){const e=this.shortcut;t.prev&&t.next&&Ke(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e}toString(){const t=[],e=this.shortcut;let r=e.prev;for(;r!==e;)t.push(JSON.stringify(r,Qe)),r=r==null?void 0:r.prev;return`[${t.join(", ")}]`}}class Er extends Ve{}const Ln=()=>1,rn=(n,t)=>{var e;if(n.getAllNodes().length<=1)return[];const r=br(n,t||Ln);return(e=Wn(r.graph,r.buckets,r.zeroIdx).map(o=>n.getRelatedEdges(o.v,"out").filter(({target:d})=>d===o.w)))===null||e===void 0?void 0:e.flat()},Wn=(n,t,e)=>{let r=[];const s=t[t.length-1],o=t[0];let d;for(;n.getAllNodes().length;){for(;d=o.dequeue();)un(n,t,e,d);for(;d=s.dequeue();)un(n,t,e,d);if(n.getAllNodes().length){for(let h=t.length-2;h>0;--h)if(d=t[h].dequeue(),d){r=r.concat(un(n,t,e,d,!0));break}}}return r},un=(n,t,e,r,s)=>{var o,d;const h=[];return n.hasNode(r.v)&&((o=n.getRelatedEdges(r.v,"in"))===null||o===void 0||o.forEach(p=>{const g=p.data.weight,y=n.getNode(p.source);s&&h.push({v:p.source,w:p.target,in:0,out:0}),y.data.out===void 0&&(y.data.out=0),y.data.out-=g,Rn(t,e,Object.assign({v:y.id},y.data))}),(d=n.getRelatedEdges(r.v,"out"))===null||d===void 0||d.forEach(p=>{const g=p.data.weight,y=p.target,O=n.getNode(y);O.data.in===void 0&&(O.data.in=0),O.data.in-=g,Rn(t,e,Object.assign({v:O.id},O.data))}),n.removeNode(r.v)),s?h:void 0},br=(n,t)=>{const e=new xe;let r=0,s=0;n.getAllNodes().forEach(p=>{e.addNode({id:p.id,data:{v:p.id,in:0,out:0}})}),n.getAllEdges().forEach(p=>{const g=e.getRelatedEdges(p.source,"out").find(O=>O.target===p.target),y=(t==null?void 0:t(p))||1;g?e.updateEdgeData(g==null?void 0:g.id,Object.assign(Object.assign({},g.data),{weight:g.data.weight+y})):e.addEdge({id:p.id,source:p.source,target:p.target,data:{weight:y}}),s=Math.max(s,e.getNode(p.source).data.out+=y),r=Math.max(r,e.getNode(p.target).data.in+=y)});const o=[],d=s+r+3;for(let p=0;p{Rn(o,h,Object.assign({v:p.id},e.getNode(p.id).data))}),{buckets:o,zeroIdx:h,graph:e}},Rn=(n,t,e)=>{e.out?e.in?n[e.out-e.in+t].enqueue(e):n[n.length-1].enqueue(e):n[0].enqueue(e)},Cn=(n,t)=>{const r=t==="greedy"?rn(n,(s=>o=>o.data.weight||1)(n)):Nr(n);r==null||r.forEach(s=>{const o=s.data;n.removeEdge(s.id),o.forwardName=s.data.name,o.reversed=!0,n.addEdge({id:s.id,source:s.target,target:s.source,data:Object.assign({},o)})})},Nr=n=>{const t=[],e={},r={},s=o=>{r[o]||(r[o]=!0,e[o]=!0,n.getRelatedEdges(o,"out").forEach(d=>{e[d.target]?t.push(d):s(d.target)}),delete e[o])};return n.getAllNodes().forEach(o=>s(o.id)),t},Mr=n=>{n.getAllEdges().forEach(t=>{const e=t.data;if(e.reversed){n.removeEdge(t.id);const r=e.forwardName;delete e.reversed,delete e.forwardName,n.addEdge({id:t.id,source:t.target,target:t.source,data:Object.assign(Object.assign({},e),{forwardName:r})})}})},Sr=(n,t)=>Number(n)-Number(t),xn=(n,t,e,r)=>{let s;do s=`${r}${Math.random()}`;while(n.hasNode(s));return e.dummy=t,n.addNode({id:s,data:e}),s},Or=n=>{const t=new xe;return n.getAllNodes().forEach(e=>{t.addNode(Object.assign({},e))}),n.getAllEdges().forEach(e=>{const r=t.getRelatedEdges(e.source,"out").find(s=>s.target===e.target);r?t.updateEdgeData(r==null?void 0:r.id,Object.assign(Object.assign({},r.data),{weight:r.data.weight+e.data.weight||0,minlen:Math.max(r.data.minlen,e.data.minlen||1)})):t.addEdge({id:e.id,source:e.source,target:e.target,data:{weight:e.data.weight||0,minlen:e.data.minlen||1}})}),t},sr=n=>{const t=new xe;return n.getAllNodes().forEach(e=>{n.getChildren(e.id).length||t.addNode(Object.assign({},e))}),n.getAllEdges().forEach(e=>{t.addEdge(e)}),t},Yn=(n,t)=>n==null?void 0:n.reduce((e,r,s)=>(e[r]=t[s],e),{}),ss=n=>{const t={};return n.getAllNodes().forEach(e=>{const r={};n.getRelatedEdges(e.id,"out").forEach(s=>{r[s.target]=(r[s.target]||0)+(s.data.weight||0)}),t[e.id]=r}),t},is=n=>{const t=n.getAllNodes(),e=t.map(r=>{const s={};return n.getRelatedEdges(r.id,"in").forEach(o=>{s[o.source]=(s[o.source]||0)+o.data.weight}),s});return Yn(t.map(r=>r.id),e)},ir=(n,t)=>{const e=Number(n.x),r=Number(n.y),s=Number(t.x)-e,o=Number(t.y)-r;let d=Number(n.width)/2,h=Number(n.height)/2;if(!s&&!o)return{x:0,y:0};let p,g;return Math.abs(o)*d>Math.abs(s)*h?(o<0&&(h=-h),p=h*s/o,g=h):(s<0&&(d=-d),p=d,g=d*o/s),{x:e+p,y:r+g}},Sn=n=>{const t=[],e=T(n)+1;for(let r=0;r{const s=r.data.rank;s!==void 0&&t[s]&&t[s].push(r.id)});for(let r=0;rSr(n.getNode(s).data.order,n.getNode(o).data.order));return t},Dn=n=>{const t=n.getAllNodes().filter(r=>r.data.rank!==void 0).map(r=>r.data.rank),e=Math.min(...t);n.getAllNodes().forEach(r=>{r.data.hasOwnProperty("rank")&&e!==1/0&&(r.data.rank-=e)})},or=(n,t=0)=>{const e=n.getAllNodes(),r=e.filter(h=>h.data.rank!==void 0).map(h=>h.data.rank),s=Math.min(...r),o=[];e.forEach(h=>{const p=(h.data.rank||0)-s;o[p]||(o[p]=[]),o[p].push(h.id)});let d=0;for(let h=0;h{const y=n.getNode(g);y&&(y.data.rank=y.data.rank||0,y.data.rank+=d)}))}},$n=(n,t,e,r)=>{const s={width:0,height:0};return $t(e)&&$t(r)&&(s.rank=e,s.order=r),xn(n,"border",s,t)},T=n=>{let t;return n.getAllNodes().forEach(e=>{const r=e.data.rank;r!==void 0&&(t===void 0||r>t)&&(t=r)}),t||(t=0),t},u=(n,t)=>{const e={lhs:[],rhs:[]};return n==null||n.forEach(r=>{t(r)?e.lhs.push(r):e.rhs.push(r)}),e},c=(n,t)=>n.reduce((e,r)=>{const s=t(e),o=t(r);return s>o?r:e}),i=(n,t,e,r,s,o)=>{r.includes(t.id)||(r.push(t.id),e||o.push(t.id),s(t.id).forEach(d=>i(n,d,e,r,s,o)),e&&o.push(t.id))},f=(n,t,e,r)=>{const s=Array.isArray(t)?t:[t],o=p=>r?n.getSuccessors(p):n.getNeighbors(p),d=[],h=[];return s.forEach(p=>{if(n.hasNode(p.id))i(n,p,e==="post",h,o,d);else throw new Error(`Graph does not have node: ${p}`)}),d},m=n=>{const t=e=>{const r=n.getChildren(e),s=n.getNode(e);if(r!=null&&r.length&&r.forEach(o=>t(o.id)),s.data.hasOwnProperty("minRank")){s.data.borderLeft=[],s.data.borderRight=[];for(let o=s.data.minRank,d=s.data.maxRank+1;ot(e.id))},k=(n,t,e,r,s,o)=>{const d={rank:o,borderType:t,width:0,height:0},h=s.data[t][o-1],p=xn(n,"border",d,e);s.data[t][o]=p,n.setParent(p,r),h&&n.addEdge({id:`e${Math.random()}`,source:h,target:p,data:{weight:1}})},B=(n,t)=>{const e=t.toLowerCase();(e==="lr"||e==="rl")&&V(n)},G=(n,t)=>{const e=t.toLowerCase();(e==="bt"||e==="rl")&&Z(n),(e==="lr"||e==="rl")&&(At(n),V(n))},V=n=>{n.getAllNodes().forEach(t=>{rt(t)}),n.getAllEdges().forEach(t=>{rt(t)})},rt=n=>{const t=n.data.width;n.data.width=n.data.height,n.data.height=t},Z=n=>{n.getAllNodes().forEach(t=>{lt(t.data)}),n.getAllEdges().forEach(t=>{var e;(e=t.data.points)===null||e===void 0||e.forEach(r=>lt(r)),t.data.hasOwnProperty("y")&<(t.data)})},lt=n=>{n!=null&&n.y&&(n.y=-n.y)},At=n=>{n.getAllNodes().forEach(t=>{ct(t.data)}),n.getAllEdges().forEach(t=>{var e;(e=t.data.points)===null||e===void 0||e.forEach(r=>ct(r)),t.data.hasOwnProperty("x")&&ct(t.data)})},ct=n=>{const t=n.x;n.x=n.y,n.y=t},pt=n=>{const t=xn(n,"root",{},"_root"),e=J(n);let r=Math.max(...Object.values(e));Math.abs(r)===1/0&&(r=1);const s=r-1,o=2*s+1;n.getAllEdges().forEach(h=>{h.data.minlen*=o});const d=Ot(n)+1;return n.getRoots().forEach(h=>{Lt(n,t,o,d,s,e,h.id)}),{nestingRoot:t,nodeRankFactor:o}},Lt=(n,t,e,r,s,o,d)=>{const h=n.getChildren(d);if(!(h!=null&&h.length)){d!==t&&n.addEdge({id:`e${Math.random()}`,source:t,target:d,data:{weight:0,minlen:e}});return}const p=$n(n,"_bt"),g=$n(n,"_bb"),y=n.getNode(d);n.setParent(p,d),y.data.borderTop=p,n.setParent(g,d),y.data.borderBottom=g,h==null||h.forEach(O=>{Lt(n,t,e,r,s,o,O.id);const L=O.data.borderTop?O.data.borderTop:O.id,R=O.data.borderBottom?O.data.borderBottom:O.id,U=O.data.borderTop?r:2*r,F=L!==R?1:s-o[d]+1;n.addEdge({id:`e${Math.random()}`,source:p,target:L,data:{minlen:F,weight:U,nestingEdge:!0}}),n.addEdge({id:`e${Math.random()}`,source:R,target:g,data:{minlen:F,weight:U,nestingEdge:!0}})}),n.getParent(d)||n.addEdge({id:`e${Math.random()}`,source:t,target:p,data:{weight:0,minlen:s+o[d]}})},J=n=>{const t={},e=(r,s)=>{const o=n.getChildren(r);o==null||o.forEach(d=>e(d.id,s+1)),t[r]=s};return n.getRoots().forEach(r=>e(r.id,1)),t},Ot=n=>{let t=0;return n.getAllEdges().forEach(e=>{t+=e.data.weight}),t},Ct=(n,t)=>{t&&n.removeNode(t),n.getAllEdges().forEach(e=>{e.data.nestingEdge&&n.removeEdge(e.id)})},Kt="edge",Zt="edge-label",ye=(n,t)=>{n.getAllEdges().forEach(e=>Ut(n,e,t))},Ut=(n,t,e)=>{let r=t.source,s=n.getNode(r).data.rank;const o=t.target,d=n.getNode(o).data.rank,h=t.data.labelRank;if(d===s+1)return;n.removeEdge(t.id);let p,g,y;for(y=0,++s;s{t.forEach(e=>{let r=n.getNode(e);const{data:s}=r,o=s.originalEdge;let d;o&&n.addEdge(o);let h=e;for(;r.data.dummy;)d=n.getSuccessors(h)[0],n.removeNode(h),o.data.points.push({x:r.data.x,y:r.data.y}),r.data.dummy===Zt&&(o.data.x=r.data.x,o.data.y=r.data.y,o.data.width=r.data.width,o.data.height=r.data.height),h=d.id,r=n.getNode(h)})};function ae(n){return Array.isArray(n)}var H=function(n){if(typeof n!="object"||n===null)return n;var t;if(ae(n)){t=[];for(var e=0,r=n.length;e{const r={};let s;e==null||e.forEach(o=>{let d=n.getParent(o),h,p;for(;d;){if(h=n.getParent(d.id),h?(p=r[h.id],r[h.id]=d.id):(p=s,s=d.id),p&&p!==d.id){t.hasNode(p)||t.addNode({id:p,data:{}}),t.hasNode(d.id)||t.addNode({id:d.id,data:{}}),t.hasEdge(`e${p}-${d.id}`)||t.addEdge({id:`e${p}-${d.id}`,source:p,target:d.id,data:{}});return}d=h}})},Nt=(n,t,e)=>{const r=we(n),s=new xe({tree:[{id:r,children:[],data:{}}]});return n.getAllNodes().forEach(o=>{const d=n.getParent(o.id);(o.data.rank===t||o.data.minRank<=t&&t<=o.data.maxRank)&&(s.hasNode(o.id)||s.addNode(Object.assign({},o)),d!=null&&d.id&&!s.hasNode(d==null?void 0:d.id)&&s.addNode(Object.assign({},d)),s.setParent(o.id,(d==null?void 0:d.id)||r),n.getRelatedEdges(o.id,e).forEach(h=>{const p=h.source===o.id?h.target:h.source;s.hasNode(p)||s.addNode(Object.assign({},n.getNode(p)));const g=s.getRelatedEdges(p,"out").find(({target:O})=>O===o.id),y=g!==void 0?g.data.weight:0;g?s.updateEdgeData(g.id,Object.assign(Object.assign({},g.data),{weight:h.data.weight+y})):s.addEdge({id:h.id,source:p,target:o.id,data:{weight:h.data.weight+y}})}),o.data.hasOwnProperty("minRank")&&s.updateNodeData(o.id,Object.assign(Object.assign({},o.data),{borderLeft:o.data.borderLeft[t],borderRight:o.data.borderRight[t]})))}),s},we=n=>{let t;for(;n.hasNode(t=`_root${Math.random()}`););return t},ue=(n,t,e)=>{const r=Yn(e,e.map((y,O)=>O)),o=t.map(y=>{const O=n.getRelatedEdges(y,"out").map(L=>({pos:r[L.target]||0,weight:L.data.weight}));return O==null?void 0:O.sort((L,R)=>L.pos-R.pos)}).flat().filter(y=>y!==void 0);let d=1;for(;d{if(y){let O=y.pos+d;p[O]+=y.weight;let L=0;for(;O>0;)O%2&&(L+=p[O+1]),O=O-1>>1,p[O]+=y.weight;g+=y.weight*L}}),g},he=(n,t)=>{let e=0;for(let r=1;r<(t==null?void 0:t.length);r+=1)e+=ue(n,t[r-1],t[r]);return e},pe=n=>{const t={},e=n.getAllNodes(),r=e.map(g=>{var y;return(y=g.data.rank)!==null&&y!==void 0?y:-1/0}),s=Math.max(...r),o=[];for(let g=0;gn.getNode(g.id).data.rank-n.getNode(y.id).data.rank),p=d.filter(g=>n.getNode(g.id).data.fixorder!==void 0).sort((g,y)=>n.getNode(g.id).data.fixorder-n.getNode(y.id).data.fixorder);return p==null||p.forEach(g=>{isNaN(n.getNode(g.id).data.rank)||o[n.getNode(g.id).data.rank].push(g.id),t[g.id]=!0}),d==null||d.forEach(g=>n.dfsTree(g.id,y=>{if(t.hasOwnProperty(y.id))return!0;t[y.id]=!0,isNaN(y.data.rank)||o[y.data.rank].push(y.id)})),o},Pe=(n,t)=>t.map(e=>{const r=n.getRelatedEdges(e,"in");if(!(r!=null&&r.length))return{v:e};const s={sum:0,weight:0};return r==null||r.forEach(o=>{const d=n.getNode(o.source);s.sum+=o.data.weight*d.data.order,s.weight+=o.data.weight}),{v:e,barycenter:s.sum/s.weight,weight:s.weight}}),Ze=(n,t)=>{var e,r,s;const o={};n==null||n.forEach((h,p)=>{o[h.v]={i:p,indegree:0,in:[],out:[],vs:[h.v]};const g=o[h.v];h.barycenter!==void 0&&(g.barycenter=h.barycenter,g.weight=h.weight)}),(e=t.getAllEdges())===null||e===void 0||e.forEach(h=>{const p=o[h.source],g=o[h.target];p!==void 0&&g!==void 0&&(g.indegree++,p.out.push(o[h.target]))});const d=(s=(r=Object.values(o)).filter)===null||s===void 0?void 0:s.call(r,h=>!h.indegree);return Oe(d)},Oe=n=>{var t,e;const r=[],s=p=>g=>{g.merged||(g.barycenter===void 0||p.barycenter===void 0||g.barycenter>=p.barycenter)&&_e(p,g)},o=p=>g=>{g.in.push(p),--g.indegree===0&&n.push(g)};for(;n!=null&&n.length;){const p=n.pop();r.push(p),(t=p.in.reverse())===null||t===void 0||t.forEach(g=>s(p)(g)),(e=p.out)===null||e===void 0||e.forEach(g=>o(p)(g))}const d=r.filter(p=>!p.merged),h=["vs","i","barycenter","weight"];return d.map(p=>{const g={};return h==null||h.forEach(y=>{p[y]!==void 0&&(g[y]=p[y])}),g})},_e=(n,t)=>{var e;let r=0,s=0;n.weight&&(r+=n.barycenter*n.weight,s+=n.weight),t.weight&&(r+=t.barycenter*t.weight,s+=t.weight),n.vs=(e=t.vs)===null||e===void 0?void 0:e.concat(n.vs),n.barycenter=r/s,n.weight=s,n.i=Math.min(t.i,n.i),t.merged=!0};var sn=Ze;const ne=(n,t,e,r)=>{const s=u(n,L=>{const R=L.hasOwnProperty("fixorder")&&!isNaN(L.fixorder);return r?!R&&L.hasOwnProperty("barycenter"):R||L.hasOwnProperty("barycenter")}),o=s.lhs,d=s.rhs.sort((L,R)=>-L.i- -R.i),h=[];let p=0,g=0,y=0;o==null||o.sort(Ge(!!t,!!e)),y=Te(h,d,y),o==null||o.forEach(L=>{var R;y+=(R=L.vs)===null||R===void 0?void 0:R.length,h.push(L.vs),p+=L.barycenter*L.weight,g+=L.weight,y=Te(h,d,y)});const O={vs:h.flat()};return g&&(O.barycenter=p/g,O.weight=g),O},Te=(n,t,e)=>{let r=e,s;for(;t.length&&(s=t[t.length-1]).i<=r;)t.pop(),n==null||n.push(s.vs),r++;return r},Ge=(n,t)=>(e,r)=>{if(e.fixorder!==void 0&&r.fixorder!==void 0)return e.fixorder-r.fixorder;if(e.barycenterr.barycenter)return 1;if(t&&e.order!==void 0&&r.order!==void 0){if(e.orderr.order)return 1}return n?r.i-e.i:e.i-r.i},Be=(n,t,e,r,s,o)=>{var d,h,p,g;let y=n.getChildren(t).map(W=>W.id);const O=n.getNode(t),L=O?O.data.borderLeft:void 0,R=O?O.data.borderRight:void 0,U={};L&&(y=y==null?void 0:y.filter(W=>W!==L&&W!==R));const F=Pe(n,y||[]);F==null||F.forEach(W=>{var Y;if(!((Y=n.getChildren(W.v))===null||Y===void 0)&&Y.length){const X=Be(n,W.v,e,r,o);U[W.v]=X,X.hasOwnProperty("barycenter")&&Ar(W,X)}});const z=sn(F,e);Ae(z,U),(d=z.filter(W=>W.vs.length>0))===null||d===void 0||d.forEach(W=>{const Y=n.getNode(W.vs[0]);Y&&(W.fixorder=Y.data.fixorder,W.order=Y.data.order)});const C=ne(z,r,s,o);if(L&&(C.vs=[L,C.vs,R].flat(),!((h=n.getPredecessors(L))===null||h===void 0)&&h.length)){const W=n.getNode(((p=n.getPredecessors(L))===null||p===void 0?void 0:p[0].id)||""),Y=n.getNode(((g=n.getPredecessors(R))===null||g===void 0?void 0:g[0].id)||"");C.hasOwnProperty("barycenter")||(C.barycenter=0,C.weight=0),C.barycenter=(C.barycenter*C.weight+W.data.order+Y.data.order)/(C.weight+2),C.weight+=2}return C},Ae=(n,t)=>{n==null||n.forEach(e=>{var r;const s=(r=e.vs)===null||r===void 0?void 0:r.map(o=>t[o]?t[o].vs:o);e.vs=s.flat()})},Ar=(n,t)=>{n.barycenter!==void 0?(n.barycenter=(n.barycenter*n.weight+t.barycenter*t.weight)/(n.weight+t.weight),n.weight+=t.weight):(n.barycenter=t.barycenter,n.weight=t.weight)},Tr=(n,t)=>{const e=T(n),r=[],s=[];for(let y=1;y-1;y--)s.push(y);const o=ar(n,r,"in"),d=ar(n,s,"out");let h=pe(n);Xn(n,h);let p=Number.POSITIVE_INFINITY,g;for(let y=0,O=0;O<4;++y,++O){ur(y%2?o:d,y%4>=2,!1,t),h=Sn(n);const L=he(n,h);L=2,!0,t),h=Sn(n);const L=he(n,h);Lt.map(r=>Nt(n,r,e)),ur=(n,t,e,r)=>{const s=new xe;n==null||n.forEach(o=>{var d;const h=o.getRoots()[0].id,p=Be(o,h,s,t,e,r);for(let g=0;g<((d=p.vs)===null||d===void 0?void 0:d.length);g++){const y=o.getNode(p.vs[g]);y&&(y.data.order=g)}Rt(o,s,p.vs)})},Xn=(n,t)=>{t==null||t.forEach(e=>{e==null||e.forEach((r,s)=>{n.getNode(r).data.order=s})})},jr=(n,t)=>{const r=n.getAllNodes().filter(d=>{var h;return!(!((h=n.getChildren(d.id))===null||h===void 0)&&h.length)}).map(d=>d.data.rank),s=Math.max(...r),o=[];for(let d=0;d{const h=n.getNode(d);!h||h.data.dummy||isNaN(h.data.rank)||(h.data.fixorder=o[h.data.rank].length,o[h.data.rank].push(d))})},Ir=n=>{const t={};let e=0;const r=s=>{const o=e;n.getChildren(s).forEach(d=>r(d.id)),t[s]={low:o,lim:e++}};return n.getRoots().forEach(s=>r(s.id)),t},Pr=(n,t,e,r)=>{var s,o;const d=[],h=[],p=Math.min(t[e].low,t[r].low),g=Math.max(t[e].lim,t[r].lim);let y,O;y=e;do y=(s=n.getParent(y))===null||s===void 0?void 0:s.id,d.push(y);while(y&&(t[y].low>p||g>t[y].lim));for(O=y,y=r;y&&y!==O;)h.push(y),y=(o=n.getParent(y))===null||o===void 0?void 0:o.id;return{lca:O,path:d.concat(h.reverse())}},Lr=(n,t)=>{const e=Ir(n);t.forEach(r=>{var s,o;let d=r,h=n.getNode(d);const p=h.data.originalEdge;if(!p)return;const g=Pr(n,e,p.source,p.target),y=g.path,O=g.lca;let L=0,R=y[L],U=!0;for(;d!==p.target;){if(h=n.getNode(d),U){for(;R!==O&&((s=n.getNode(R))===null||s===void 0?void 0:s.data.maxRank){const e={},r=(s,o)=>{let d=0,h=0;const p=s.length,g=o==null?void 0:o[(o==null?void 0:o.length)-1];return o==null||o.forEach((y,O)=>{var L;const R=mi(n,y),U=R?n.getNode(R.id).data.order:p;(R||y===g)&&((L=o.slice(h,O+1))===null||L===void 0||L.forEach(F=>{var z;(z=n.getPredecessors(F))===null||z===void 0||z.forEach(C=>{var W;const Y=n.getNode(C.id),X=Y.data.order;(X{const e={};function r(h,p,g,y,O){var L,R;let U;for(let F=p;F{const C=n.getNode(z.id);C.data.dummy&&(C.data.orderO)&&us(e,z.id,U)}))}function s(h){return JSON.stringify(h.slice(1))}function o(h,p){const g=s(h);p.get(g)||(r(...h),p.set(g,!0))}const d=(h,p)=>{let g=-1,y,O=0;const L=new Map;return p==null||p.forEach((R,U)=>{var F;if(((F=n.getNode(R))===null||F===void 0?void 0:F.data.dummy)==="border"){const z=n.getPredecessors(R)||[];z.length&&(y=n.getNode(z[0].id).data.order,o([p,O,U,g,y],L),O=U,g=y)}o([p,O,p.length,y,h.length],L)}),p};return t!=null&&t.length&&t.reduce(d),e},mi=(n,t)=>{var e,r;if(!((e=n.getNode(t))===null||e===void 0)&&e.data.dummy)return(r=n.getPredecessors(t))===null||r===void 0?void 0:r.find(s=>n.getNode(s.id).data.dummy)},us=(n,t,e)=>{let r=t,s=e;if(r>s){const d=r;r=s,s=d}let o=n[r];o||(n[r]=o={}),o[s]=!0},yi=(n,t,e)=>{let r=t,s=e;if(r>s){const o=t;r=s,s=o}return!!n[r]},cs=(n,t,e,r)=>{const s={},o={},d={};return t==null||t.forEach(h=>{h==null||h.forEach((p,g)=>{s[p]=p,o[p]=p,d[p]=g})}),t==null||t.forEach(h=>{let p=-1;h==null||h.forEach(g=>{let y=r(g).map(O=>O.id);if(y.length){y=y.sort((L,R)=>d[L]-d[R]);const O=(y.length-1)/2;for(let L=Math.floor(O),R=Math.ceil(O);L<=R;++L){const U=y[L];o[g]===g&&p{var h;const p={},g=wi(n,t,e,s,o,d),y=d?"borderLeft":"borderRight",O=(U,F)=>{let z=g.getAllNodes(),C=z.pop();const W={};for(;C;)W[C.id]?U(C.id):(W[C.id]=!0,z.push(C),z=z.concat(F(C.id))),C=z.pop()},L=U=>{p[U]=(g.getRelatedEdges(U,"in")||[]).reduce((F,z)=>Math.max(F,(p[z.source]||0)+z.data.weight),0)},R=U=>{const F=(g.getRelatedEdges(U,"out")||[]).reduce((C,W)=>Math.min(C,(p[W.target]||0)-W.data.weight),Number.POSITIVE_INFINITY),z=n.getNode(U);F!==Number.POSITIVE_INFINITY&&z.data.borderType!==y&&(p[U]=Math.max(p[U],F))};return O(L,g.getPredecessors.bind(g)),O(R,g.getSuccessors.bind(g)),(h=Object.values(r))===null||h===void 0||h.forEach(U=>{p[U]=p[e[U]]}),p},wi=(n,t,e,r,s,o)=>{const d=new xe,h=xi(r,s,o);return t==null||t.forEach(p=>{let g;p==null||p.forEach(y=>{const O=e[y];if(d.hasNode(O)||d.addNode({id:O,data:{}}),g){const L=e[g],R=d.getRelatedEdges(L,"out").find(U=>U.target===O);R?d.updateEdgeData(R.id,Object.assign(Object.assign({},R.data),{weight:Math.max(h(n,y,g),R.data.weight||0)})):d.addEdge({id:`e${Math.random()}`,source:L,target:O,data:{weight:Math.max(h(n,y,g),0)}})}g=y})}),d},ls=(n,t)=>c(Object.values(t),e=>{var r;let s=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;return(r=Object.keys(e))===null||r===void 0||r.forEach(d=>{const h=e[d],p=Ei(n,d)/2;s=Math.max(h+p,s),o=Math.min(h-p,o)}),s-o});function ds(n,t){const e=Object.values(t),r=Math.min(...e),s=Math.max(...e);["u","d"].forEach(o=>{["l","r"].forEach(d=>{const h=o+d,p=n[h];let g;if(p===t)return;const y=Object.values(p);g=d==="l"?r-Math.min(...y):s-Math.max(...y),g&&(n[h]={},Object.keys(p).forEach(O=>{n[h][O]=p[O]+g}))})})}const hs=(n,t)=>{const e={};return Object.keys(n.ul).forEach(r=>{if(t)e[r]=n[t.toLowerCase()][r];else{const s=Object.values(n).map(o=>o[r]);e[r]=(s[0]+s[1])/2}}),e},pc=(n,t)=>{const{align:e,nodesep:r=0,edgesep:s=0}=t||{},o=buildLayerMatrix(n),d=Object.assign(os(n,o),as(n,o)),h={};let p;["u","d"].forEach(y=>{p=y==="u"?o:Object.values(o).reverse(),["l","r"].forEach(O=>{O==="r"&&(p=p.map(F=>Object.values(F).reverse()));const L=(y==="u"?n.getPredecessors:n.getSuccessors).bind(n),R=cs(n,p,d,L),U=fs(n,p,R.root,R.align,r,s,O==="r");O==="r"&&Object.keys(U).forEach(F=>{U[F]=-U[F]}),h[y+O]=U})});const g=ls(n,h);return ds(h,g),hs(h,e)},xi=(n,t,e)=>(r,s,o)=>{const d=r.getNode(s),h=r.getNode(o);let p=0,g=0;if(p+=d.data.width/2,d.data.hasOwnProperty("labelpos"))switch((d.data.labelpos||"").toLowerCase()){case"l":g=-d.data.width/2;break;case"r":g=d.data.width/2;break}if(g&&(p+=e?g:-g),g=0,p+=(d.data.dummy?t:n)/2,p+=(h.data.dummy?t:n)/2,p+=h.data.width/2,h.data.labelpos)switch((h.data.labelpos||"").toLowerCase()){case"l":g=h.data.width/2;break;case"r":g=-h.data.width/2;break}return g&&(p+=e?g:-g),g=0,p},Ei=(n,t)=>n.getNode(t).data.width||0,bi=(n,t)=>{const{ranksep:e=0}=t||{},r=Sn(n);let s=0;r==null||r.forEach(o=>{const d=o.map(p=>n.getNode(p).data.height),h=Math.max(...d,0);o==null||o.forEach(p=>{n.getNode(p).data.y=s+h/2}),s+=h+e})},Ni=(n,t)=>{const{align:e,nodesep:r=0,edgesep:s=0}=t||{},o=Sn(n),d=Object.assign(os(n,o),as(n,o)),h={};let p=[];["u","d"].forEach(y=>{p=y==="u"?o:Object.values(o).reverse(),["l","r"].forEach(O=>{O==="r"&&(p=p.map(F=>Object.values(F).reverse()));const L=(y==="u"?n.getPredecessors:n.getSuccessors).bind(n),R=cs(n,p,d,L),U=fs(n,p,R.root,R.align,r,s,O==="r");O==="r"&&Object.keys(U).forEach(F=>U[F]=-U[F]),h[y+O]=U})});const g=ls(n,h);return g&&ds(h,g),hs(h,e)},Mi=(n,t)=>{var e;const r=sr(n);bi(r,t);const s=Ni(r,t);(e=Object.keys(s))===null||e===void 0||e.forEach(o=>{r.getNode(o).data.x=s[o]})},gs=n=>{const t={},e=r=>{var s;const o=n.getNode(r);if(!o)return 0;if(t[r])return o.data.rank;t[r]=!0;let d;return(s=n.getRelatedEdges(r,"out"))===null||s===void 0||s.forEach(h=>{const p=e(h.target),g=h.data.minlen,y=p-g;y&&(d===void 0||yn.getRelatedEdges(r.id,"in").length===0).forEach(r=>e(r.id))},Si=n=>{const t={};let e;const r=d=>{var h;const p=n.getNode(d);if(!p)return 0;if(t[d])return p.data.rank;t[d]=!0;let g;return(h=n.getRelatedEdges(d,"out"))===null||h===void 0||h.forEach(y=>{const O=r(y.target),L=y.data.minlen,R=O-L;R&&(g===void 0||Rn.getRelatedEdges(d.id,"in").length===0).forEach(d=>{d&&r(d.id)}),e===void 0&&(e=0);const s={},o=(d,h)=>{var p;const g=n.getNode(d),y=isNaN(g.data.layer)?h:g.data.layer;(g.data.rank===void 0||g.data.rank{o(O.target,y+O.data.minlen)}))};n.getAllNodes().forEach(d=>{const h=d.data;h&&(isNaN(h.layer)?h.rank-=e:o(d.id,h.layer))})},En=(n,t)=>n.getNode(t.target).data.rank-n.getNode(t.source).data.rank-t.data.minlen,Oi=n=>{const t=new xe({tree:[]}),e=n.getAllNodes()[0],r=n.getAllNodes().length;t.addNode(e);let s,o;for(;Ai(t,n){const e=r=>{t.getRelatedEdges(r,"both").forEach(s=>{const o=s.source,d=r===o?s.target:o;!n.hasNode(d)&&!En(t,s)&&(n.addNode({id:d,data:{}}),n.addEdge({id:s.id,source:r,target:d,data:{}}),e(d))})};return n.getAllNodes().forEach(r=>e(r.id)),n.getAllNodes().length},Ti=n=>{const t=new xe({tree:[]}),e=n.getAllNodes()[0],r=n.getAllNodes().length;t.addNode(e);let s,o;for(;ji(t,n){const e=r=>{var s;(s=t.getRelatedEdges(r,"both"))===null||s===void 0||s.forEach(o=>{const d=o.source,h=r===d?o.target:d;!n.hasNode(h)&&(t.getNode(h).data.layer!==void 0||!En(t,o))&&(n.addNode({id:h,data:{}}),n.addEdge({id:o.id,source:r,target:h,data:{}}),e(h))})};return n.getAllNodes().forEach(r=>e(r.id)),n.getAllNodes().length},ps=(n,t)=>c(t.getAllEdges(),e=>n.hasNode(e.source)!==n.hasNode(e.target)?En(t,e):1/0),vs=(n,t,e)=>{n.getAllNodes().forEach(r=>{const s=t.getNode(r.id);s.data.rank||(s.data.rank=0),s.data.rank+=e})},Ii=n=>{const t=Or(n);gs(t);const e=Oi(t);ys(e),ms(e,t);let r,s;for(;r=Ri(e);)s=Ci(e,t,r),Di(e,t,r,s)},ms=(n,t)=>{let e=f(n,n.getAllNodes(),"post",!1);e=e.slice(0,(e==null?void 0:e.length)-1),e.forEach(r=>{Pi(n,t,r)})},Pi=(n,t,e)=>{const s=n.getNode(e).data.parent,o=n.getRelatedEdges(e,"both").find(d=>d.target===s||d.source===s);o.data.cutvalue=Li(n,t,e)},Li=(n,t,e)=>{const s=n.getNode(e).data.parent;let o=!0,d=t.getRelatedEdges(e,"out").find(p=>p.target===s),h=0;return d||(o=!1,d=t.getRelatedEdges(s,"out").find(p=>p.target===e)),h=d.data.weight,t.getRelatedEdges(e,"both").forEach(p=>{const g=p.source===e,y=g?p.target:p.source;if(y!==s){const O=g===o,L=p.data.weight;if(h+=O?L:-L,Fi(n,e,y)){const R=n.getRelatedEdges(e,"both").find(U=>U.source===y||U.target===y).data.cutvalue;h+=O?-R:R}}}),h},ys=(n,t=n.getAllNodes()[0].id)=>{ws(n,{},1,t)},ws=(n,t,e,r,s)=>{var o;const d=e;let h=e;const p=n.getNode(r);return t[r]=!0,(o=n.getNeighbors(r))===null||o===void 0||o.forEach(g=>{t[g.id]||(h=ws(n,t,h,g.id,r))}),p.data.low=d,p.data.lim=h++,s?p.data.parent=s:delete p.data.parent,h},Ri=n=>n.getAllEdges().find(t=>t.data.cutvalue<0),Ci=(n,t,e)=>{let r=e.source,s=e.target;t.getRelatedEdges(r,"out").find(y=>y.target===s)||(r=e.target,s=e.source);const o=n.getNode(r),d=n.getNode(s);let h=o,p=!1;o.data.lim>d.data.lim&&(h=d,p=!0);const g=t.getAllEdges().filter(y=>p===xs(n.getNode(y.source),h)&&p!==xs(n.getNode(y.target),h));return c(g,y=>En(t,y))},Di=(n,t,e,r)=>{const s=n.getRelatedEdges(e.source,"both").find(o=>o.source===e.target||o.target===e.target);s&&n.removeEdge(s.id),n.addEdge({id:`e${Math.random()}`,source:r.source,target:r.target,data:{}}),ys(n),ms(n,t),zi(n,t)},zi=(n,t)=>{const e=n.getAllNodes().find(s=>!s.data.parent);let r=f(n,e,"pre",!1);r=r.slice(1),r.forEach(s=>{const o=n.getNode(s).data.parent;let d=t.getRelatedEdges(s,"out").find(p=>p.target===o),h=!1;!d&&t.hasNode(o)&&(d=t.getRelatedEdges(o,"out").find(p=>p.target===s),h=!0),t.getNode(s).data.rank=(t.hasNode(o)&&t.getNode(o).data.rank||0)+(h?d==null?void 0:d.data.minlen:-(d==null?void 0:d.data.minlen))})},Fi=(n,t,e)=>n.getRelatedEdges(t,"both").find(r=>r.source===e||r.target===e),xs=(n,t)=>t.data.low<=n.data.lim&&n.data.lim<=t.data.lim,ki=(n,t)=>{switch(t){case"network-simplex":Ui(n);break;case"tight-tree":Es(n);break;case"longest-path":Bi(n);break;default:Es(n)}},Bi=gs,Es=n=>{Si(n),Ti(n)},Ui=n=>{Ii(n)},Vi=(n,t)=>{const{edgeLabelSpace:e,keepNodeOrder:r,prevGraph:s,rankdir:o,ranksep:d}=t;!r&&s&&Wi(n,s);const h=Ji(n);e&&(t.ranksep=Qi(h,{rankdir:o,ranksep:d}));let p;try{p=Gi(h,t)}catch(g){if(g.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: `,g);return}throw g}return Yi(n,h),p},Gi=(n,t)=>{const{acyclicer:e,ranker:r,rankdir:s="tb",nodeOrder:o,keepNodeOrder:d,align:h,nodesep:p=50,edgesep:g=20,ranksep:y=50}=t;io(n),Cn(n,e);const{nestingRoot:O,nodeRankFactor:L}=pt(n);ki(sr(n),r),_i(n),or(n,L),Ct(n,O),Dn(n),Hi(n),qi(n);const R=[];ye(n,R),Lr(n,R),m(n),d&&jr(n,o),Tr(n,d),oo(n),B(n,s),Mi(n,{align:h,nodesep:p,edgesep:g,ranksep:y}),ao(n),so(n),Yt(n,R),no(n),G(n,s);const{width:U,height:F}=to(n);return eo(n),ro(n),Mr(n),{width:U,height:F}},Wi=(n,t)=>{n.getAllNodes().forEach(e=>{const r=n.getNode(e.id);if(t.hasNode(e.id)){const s=t.getNode(e.id);r.data.fixorder=s.data._order,delete s.data._order}else delete r.data.fixorder})},Yi=(n,t)=>{n.getAllNodes().forEach(e=>{var r;const s=n.getNode(e.id);if(s){const o=t.getNode(e.id);s.data.x=o.data.x,s.data.y=o.data.y,s.data._order=o.data.order,s.data._rank=o.data.rank,!((r=t.getChildren(e.id))===null||r===void 0)&&r.length&&(s.data.width=o.data.width,s.data.height=o.data.height)}}),n.getAllEdges().forEach(e=>{const r=n.getEdge(e.id),s=t.getEdge(e.id);r.data.points=s?s.data.points:[],s&&s.data.hasOwnProperty("x")&&(r.data.x=s.data.x,r.data.y=s.data.y)})},$i=["width","height","layer","fixorder"],Xi={width:0,height:0},Ki=["minlen","weight","width","height","labeloffset"],Zi={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Rr=["labelpos"],Ji=n=>{const t=new xe({tree:[]});return n.getAllNodes().forEach(e=>{const r=Ns(n.getNode(e.id).data),s=Object.assign(Object.assign({},Xi),r),o=bs(s,$i);t.hasNode(e.id)||t.addNode({id:e.id,data:Object.assign({},o)});const d=n.hasTreeStructure("combo")?n.getParent(e.id,"combo"):n.getParent(e.id);Pn(d)||(t.hasNode(d.id)||t.addNode(Object.assign({},d)),t.setParent(e.id,d.id))}),n.getAllEdges().forEach(e=>{const r=Ns(n.getEdge(e.id).data),s={};Rr==null||Rr.forEach(o=>{r[o]!==void 0&&(s[o]=r[o])}),t.addEdge({id:e.id,source:e.source,target:e.target,data:Object.assign({},Zi,bs(r,Ki),s)})}),t},Qi=(n,t)=>{const{ranksep:e=0,rankdir:r}=t;return n.getAllNodes().forEach(s=>{isNaN(s.data.layer)||s.data.layer||(s.data.layer=0)}),n.getAllEdges().forEach(s=>{var o;s.data.minlen*=2,((o=s.data.labelpos)===null||o===void 0?void 0:o.toLowerCase())!=="c"&&(r==="TB"||r==="BT"?s.data.width+=s.data.labeloffset:s.data.height+=s.data.labeloffset)}),e/2},_i=n=>{n.getAllEdges().forEach(t=>{if(t.data.width&&t.data.height){const e=n.getNode(t.source),r=n.getNode(t.target),s={e:t,rank:(r.data.rank-e.data.rank)/2+e.data.rank};xn(n,"edge-proxy",s,"_ep")}})},Hi=n=>{let t=0;return n.getAllNodes().forEach(e=>{var r,s;e.data.borderTop&&(e.data.minRank=(r=n.getNode(e.data.borderTop))===null||r===void 0?void 0:r.data.rank,e.data.maxRank=(s=n.getNode(e.data.borderBottom))===null||s===void 0?void 0:s.data.rank,t=Math.max(t,e.data.maxRank||-1/0))}),t},qi=n=>{n.getAllNodes().forEach(t=>{t.data.dummy==="edge-proxy"&&(n.getEdge(t.data.e.id).data.labelRank=t.data.rank,n.removeNode(t.id))})},to=(n,t)=>{let e,r=0,s,o=0;const{marginx:d=0,marginy:h=0}=t||{},p=g=>{if(!g.data)return;const y=g.data.x,O=g.data.y,L=g.data.width,R=g.data.height;!isNaN(y)&&!isNaN(L)&&(e===void 0&&(e=y-L/2),e=Math.min(e,y-L/2),r=Math.max(r,y+L/2)),!isNaN(O)&&!isNaN(R)&&(s===void 0&&(s=O-R/2),s=Math.min(s,O-R/2),o=Math.max(o,O+R/2))};return n.getAllNodes().forEach(g=>{p(g)}),n.getAllEdges().forEach(g=>{g!=null&&g.data.hasOwnProperty("x")&&p(g)}),e-=d,s-=h,n.getAllNodes().forEach(g=>{g.data.x-=e,g.data.y-=s}),n.getAllEdges().forEach(g=>{var y;(y=g.data.points)===null||y===void 0||y.forEach(O=>{O.x-=e,O.y-=s}),g.data.hasOwnProperty("x")&&(g.data.x-=e),g.data.hasOwnProperty("y")&&(g.data.y-=s)}),{width:r-e+d,height:o-s+h}},eo=n=>{n.getAllEdges().forEach(t=>{const e=n.getNode(t.source),r=n.getNode(t.target);let s,o;t.data.points?(s=t.data.points[0],o=t.data.points[t.data.points.length-1]):(t.data.points=[],s={x:r.data.x,y:r.data.y},o={x:e.data.x,y:e.data.y}),t.data.points.unshift(ir(e.data,s)),t.data.points.push(ir(r.data,o))})},no=n=>{n.getAllEdges().forEach(t=>{if(t.data.hasOwnProperty("x"))switch((t.data.labelpos==="l"||t.data.labelpos==="r")&&(t.data.width-=t.data.labeloffset),t.data.labelpos){case"l":t.data.x-=t.data.width/2+t.data.labeloffset;break;case"r":t.data.x+=t.data.width/2+t.data.labeloffset;break}})},ro=n=>{n.getAllEdges().forEach(t=>{var e;t.data.reversed&&((e=t.data.points)===null||e===void 0||e.reverse())})},so=n=>{n.getAllNodes().forEach(t=>{var e,r,s;if(!((e=n.getChildren(t.id))===null||e===void 0)&&e.length){const o=n.getNode(t.id),d=n.getNode(o.data.borderTop),h=n.getNode(o.data.borderBottom),p=n.getNode(o.data.borderLeft[((r=o.data.borderLeft)===null||r===void 0?void 0:r.length)-1]),g=n.getNode(o.data.borderRight[((s=o.data.borderRight)===null||s===void 0?void 0:s.length)-1]);o.data.width=Math.abs((g==null?void 0:g.data.x)-(p==null?void 0:p.data.x))||10,o.data.height=Math.abs((h==null?void 0:h.data.y)-(d==null?void 0:d.data.y))||10,o.data.x=((p==null?void 0:p.data.x)||0)+o.data.width/2,o.data.y=((d==null?void 0:d.data.y)||0)+o.data.height/2}}),n.getAllNodes().forEach(t=>{t.data.dummy==="border"&&n.removeNode(t.id)})},io=n=>{n.getAllEdges().forEach(t=>{if(t.source===t.target){const e=n.getNode(t.source);e.data.selfEdges||(e.data.selfEdges=[]),e.data.selfEdges.push(t),n.removeEdge(t.id)}})},oo=n=>{const t=Sn(n);t==null||t.forEach(e=>{let r=0;e==null||e.forEach((s,o)=>{var d;const h=n.getNode(s);h.data.order=o+r,(d=h.data.selfEdges)===null||d===void 0||d.forEach(p=>{xn(n,"selfedge",{width:p.data.width,height:p.data.height,rank:h.data.rank,order:o+ ++r,e:p},"_se")}),delete h.data.selfEdges})})},ao=n=>{n.getAllNodes().forEach(t=>{const e=n.getNode(t.id);if(e.data.dummy==="selfedge"){const r=n.getNode(e.data.e.source),s=r.data.x+r.data.width/2,o=r.data.y,d=e.data.x-s,h=r.data.height/2;n.hasEdge(e.data.e.id)?n.updateEdgeData(e.data.e.id,e.data.e.data):n.addEdge({id:e.data.e.id,source:e.data.e.source,target:e.data.e.target,data:e.data.e.data}),n.removeNode(t.id),e.data.e.data.points=[{x:s+2*d/3,y:o-h},{x:s+5*d/6,y:o-h},{y:o,x:s+d},{x:s+5*d/6,y:o+h},{x:s+2*d/3,y:o+h}],e.data.e.data.x=e.data.x,e.data.e.data.y=e.data.y}})},bs=(n,t)=>{const e={};return t==null||t.forEach(r=>{n[r]!==void 0&&(e[r]=+n[r])}),e},Ns=(n={})=>{const t={};return Object.keys(n).forEach(e=>{t[e.toLowerCase()]=n[e]}),t};function dn(n){return typeof n=="function"}var zn=function(n){var t=typeof n;return n!==null&&t==="object"||t==="function"};function Kn(n){if(!n)return[0,0,0];if($t(n))return[n,n,n];if(n.length===0)return[0,0,0];const[t,e=t,r=t]=n;return[t,e,r]}function On(n,t){let e;return dn(t)?e=t:$t(t)?e=()=>t:e=()=>n,e}function Cr(n,t,e=!0){return!t&&t!==0?r=>{const{size:s}=r.data||{};return s?Array.isArray(s)?e?Math.max(...s)||n:s:zn(s)&&s.width&&s.height?e?Math.max(s.width,s.height)||n:[s.width,s.height]:s:n}:dn(t)?t:$t(t)?()=>t:Array.isArray(t)?()=>e?Math.max(...t)||n:t:zn(t)&&t.width&&t.height?()=>e?Math.max(t.width,t.height)||n:[t.width,t.height]:()=>n}const Dr=(n,t,e=10)=>{let r;const s=typeof t=="function"?t:()=>t||0;return n?Array.isArray(n)?r=d=>n:dn(n)?r=n:r=d=>n:r=d=>{var h,p,g;if(!((h=d.data)===null||h===void 0)&&h.bboxSize)return(p=d.data)===null||p===void 0?void 0:p.bboxSize;if(!((g=d.data)===null||g===void 0)&&g.size){const y=d.data.size;return Array.isArray(y)?y:zn(y)?[y.width,y.height]:y}return e},d=>{const h=r(d),p=s(d);return Math.max(...Kn(h))+p}},zr=n=>{if(n===null)return n;if(n instanceof Date)return new Date(n.getTime());if(n instanceof Array){const t=[];return n.forEach(e=>{t.push(e)}),t.map(e=>zr(e))}if(typeof n=="object"){const t={};return Object.keys(n).forEach(e=>{t[e]=zr(n[e])}),t}return n},Je=(n,t)=>{const e=zr(n);return e.data=e.data||{},t&&($t(e.data.x)||(e.data.x=Math.random()*t[0]),$t(e.data.y)||(e.data.y=Math.random()*t[1])),e},uo={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};class co{constructor(t={}){this.options=t,this.id="antv-dagre",this.options=Object.assign(Object.assign({},uo),t)}execute(t,e){return A(this,void 0,void 0,function*(){return this.genericDagreLayout(!1,t,e)})}assign(t,e){return A(this,void 0,void 0,function*(){yield this.genericDagreLayout(!0,t,e)})}genericDagreLayout(t,e,r){return A(this,void 0,void 0,function*(){const s=Object.assign(Object.assign({},this.options),r),{nodeSize:o,align:d,rankdir:h="TB",ranksep:p,nodesep:g,ranksepFunc:y,nodesepFunc:O,edgeLabelSpace:L,ranker:R,nodeOrder:U,begin:F,controlPoints:z,radial:C,sortByCombo:W,preset:Y}=s,X=new xe({tree:[]}),q=On(p||50,y),st=On(g||50,O);let ut=st,Q=q;(h==="LR"||h==="RL")&&(ut=q,Q=st);const vt=Cr(10,o,!1),Et=e.getAllNodes(),Tt=e.getAllEdges();Et.forEach(bt=>{const Bt=Kn(vt(bt)),_t=Q(bt),Xt=ut(bt),ie=Bt[0]+2*Xt,le=Bt[1]+2*_t,Qt=bt.data.layer;$t(Qt)?X.addNode({id:bt.id,data:{width:ie,height:le,layer:Qt}}):X.addNode({id:bt.id,data:{width:ie,height:le}})}),W&&(X.attachTreeStructure("combo"),Et.forEach(bt=>{const{parentId:Bt}=bt.data;Bt!==void 0&&X.hasNode(Bt)&&X.setParent(bt.id,Bt,"combo")})),Tt.forEach(bt=>{X.addEdge({id:bt.id,source:bt.source,target:bt.target,data:{weight:bt.data.weight||1}})});let Pt;Y!=null&&Y.length&&(Pt=new xe({nodes:Y})),Vi(X,{prevGraph:Pt,edgeLabelSpace:L,keepNodeOrder:!!U,nodeOrder:U||[],acyclicer:"greedy",ranker:R,rankdir:h,nodesep:g,align:d});const Dt=[0,0];if(F){let bt=1/0,Bt=1/0;X.getAllNodes().forEach(_t=>{bt>_t.data.x&&(bt=_t.data.x),Bt>_t.data.y&&(Bt=_t.data.y)}),X.getAllEdges().forEach(_t=>{var Xt;(Xt=_t.data.points)===null||Xt===void 0||Xt.forEach(ie=>{bt>ie.x&&(bt=ie.x),Bt>ie.y&&(Bt=ie.y)})}),Dt[0]=F[0]-bt,Dt[1]=F[1]-Bt}const Gt=h==="LR"||h==="RL";if(!C){const bt=new Set,_t=h==="BT"||h==="RL"?(Qt,oe)=>oe-Qt:(Qt,oe)=>Qt-oe;X.getAllNodes().forEach(Qt=>{Qt.data.x=Qt.data.x+Dt[0],Qt.data.y=Qt.data.y+Dt[1],bt.add(Gt?Qt.data.x:Qt.data.y)});const Xt=Array.from(bt).sort(_t),ie=Gt?(Qt,oe)=>Qt.x!==oe.x:(Qt,oe)=>Qt.y!==oe.y,le=Gt?(Qt,oe,je)=>{const Ee=Math.max(oe.y,je.y),qe=Math.min(oe.y,je.y);return Qt.filter(vn=>vn.y<=Ee&&vn.y>=qe)}:(Qt,oe,je)=>{const Ee=Math.max(oe.x,je.x),qe=Math.min(oe.x,je.x);return Qt.filter(vn=>vn.x<=Ee&&vn.x>=qe)};X.getAllEdges().forEach((Qt,oe)=>{var je;L&&z&&Qt.data.type!=="loop"&&(Qt.data.controlPoints=fo((je=Qt.data.points)===null||je===void 0?void 0:je.map(({x:Ee,y:qe})=>({x:Ee+Dt[0],y:qe+Dt[1]})),X.getNode(Qt.source),X.getNode(Qt.target),Xt,Gt,ie,le))})}let zt=[];zt=X.getAllNodes().map(bt=>Je(bt));const Jt=X.getAllEdges();return t&&(zt.forEach(bt=>{e.mergeNodeData(bt.id,{x:bt.data.x,y:bt.data.y})}),Jt.forEach(bt=>{e.mergeEdgeData(bt.id,{controlPoints:bt.data.controlPoints})})),{nodes:zt,edges:Jt}})}}const fo=(n,t,e,r,s,o,d)=>{let h=(n==null?void 0:n.slice(1,n.length-1))||[];if(t&&e){let{x:p,y:g}=t.data,{x:y,y:O}=e.data;if(s&&(p=t.data.y,g=t.data.x,y=e.data.y,O=e.data.x),O!==g&&p!==y){const L=r.indexOf(g),R=r[L+1];if(R){const z=h[0],C=s?{x:(g+R)/2,y:(z==null?void 0:z.y)||y}:{x:(z==null?void 0:z.x)||y,y:(g+R)/2};(!z||o(z,C))&&h.unshift(C)}const U=r.indexOf(O),F=Math.abs(U-L);if(F===1)h=d(h,t.data,e.data),h.length||h.push(s?{x:(g+O)/2,y:p}:{x:p,y:(g+O)/2});else if(F>1){const z=r[U-1];if(z){const C=h[h.length-1],W=s?{x:(O+z)/2,y:(C==null?void 0:C.y)||y}:{x:(C==null?void 0:C.x)||p,y:(O+z)/2};(!C||o(C,W))&&h.push(W)}}}}return h},An=(n,t,e)=>{const r=n.getAllNodes(),s=n.getAllEdges();if(!(r!=null&&r.length))return{nodes:[],edges:s};if(r.length===1)return t&&n.mergeNodeData(r[0].id,{x:e[0],y:e[1]}),{nodes:[Object.assign(Object.assign({},r[0]),{data:Object.assign(Object.assign({},r[0].data),{x:e[0],y:e[1]})})],edges:s}},lo={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1};class ho{constructor(t={}){this.options=t,this.id="circular",this.options=Object.assign(Object.assign({},lo),t)}execute(t,e){return A(this,void 0,void 0,function*(){return this.genericCircularLayout(!1,t,e)})}assign(t,e){return A(this,void 0,void 0,function*(){yield this.genericCircularLayout(!0,t,e)})}genericCircularLayout(t,e,r){return A(this,void 0,void 0,function*(){const s=Object.assign(Object.assign({},this.options),r),{width:o,height:d,center:h,divisions:p,startAngle:g=0,endAngle:y=2*Math.PI,angleRatio:O,ordering:L,clockwise:R,nodeSpacing:U,nodeSize:F}=s,z=e.getAllNodes(),C=e.getAllEdges(),[W,Y,X]=po(o,d,h),q=z==null?void 0:z.length;if(!q||q===1)return An(e,t,X);const st=(y-g)/q;let{radius:ut,startRadius:Q,endRadius:vt}=s;if(U){const Gt=On(10,U),zt=Cr(10,F);let Jt=-1/0;z.forEach(bt=>{const Bt=zt(bt);Jt{Bt===0?fe+=Jt||10:fe+=(Gt(bt)||0)+(Jt||10)}),ut=fe/(2*Math.PI)}else!ut&&!Q&&!vt?ut=Math.min(Y,W)/2:!Q&&vt?Q=vt:Q&&!vt&&(vt=Q);const Et=st*O;let Tt=[];L==="topology"?Tt=Ms(e,z):L==="topology-directed"?Tt=Ms(e,z,!0):L==="degree"?Tt=go(e,z):Tt=z.map(Gt=>Je(Gt));const Pt=Math.ceil(q/p);for(let Gt=0;Gt{e.mergeNodeData(Gt.id,{x:Gt.data.x,y:Gt.data.y})}),{nodes:Tt,edges:C}})}}const Ms=(n,t,e=!1)=>{const r=[Je(t[0])],s={},o=t.length;s[t[0].id]=!0;let d=0;return t.forEach((h,p)=>{if(p!==0)if((p===o-1||n.getDegree(h.id,"both")!==n.getDegree(t[p+1].id,"both")||n.areNeighbors(r[d].id,h.id))&&!s[h.id])r.push(Je(h)),s[h.id]=!0,d++;else{const g=e?n.getSuccessors(r[d].id):n.getNeighbors(r[d].id);let y=!1;for(let L=0;L{e.push(Je(r))}),e.sort((r,s)=>n.getDegree(r.id,"both")-n.getDegree(s.id,"both")),e}const po=(n,t,e)=>{let r=n,s=t,o=e;return!r&&typeof window!="undefined"&&(r=window.innerWidth),!s&&typeof window!="undefined"&&(s=window.innerHeight),o||(o=[r/2,s/2]),[r,s,o]};function Zn(n){return typeof n=="string"}const hn=Array.isArray,vo={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:3/2*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"};class Fr{constructor(t={}){this.options=t,this.id="concentric",this.options=Object.assign(Object.assign({},vo),t)}execute(t,e){return A(this,void 0,void 0,function*(){return this.genericConcentricLayout(!1,t,e)})}assign(t,e){return A(this,void 0,void 0,function*(){yield this.genericConcentricLayout(!0,t,e)})}genericConcentricLayout(t,e,r){return A(this,void 0,void 0,function*(){const s=Object.assign(Object.assign({},this.options),r),{center:o,width:d,height:h,sortBy:p,maxLevelDiff:g,sweep:y,clockwise:O,equidistant:L,preventOverlap:R,startAngle:U=3/2*Math.PI,nodeSize:F,nodeSpacing:z}=s,C=e.getAllNodes(),W=e.getAllEdges(),Y=!d&&typeof window!="undefined"?window.innerWidth:d,X=!h&&typeof window!="undefined"?window.innerHeight:h,q=o||[Y/2,X/2];if(!(C!=null&&C.length)||C.length===1)return An(e,t,q);const st=[];let ut,Q=0;hn(F)?ut=Math.max(F[0],F[1]):dn(F)?(ut=-1/0,C.forEach(bt=>{const Bt=Math.max(...Kn(F(bt)));Bt>ut&&(ut=Bt)})):ut=F,hn(z)?Q=Math.max(z[0],z[1]):$t(z)&&(Q=z),C.forEach(bt=>{const Bt=Je(bt);st.push(Bt);let _t=ut;const{data:Xt}=Bt;hn(Xt.size)?_t=Math.max(Xt.size[0],Xt.size[1]):$t(Xt.size)?_t=Xt.size:zn(Xt.size)&&(_t=Math.max(Xt.size.width,Xt.size.height)),ut=Math.max(ut,_t),dn(z)&&(Q=Math.max(z(bt),Q))});const vt={};st.forEach((bt,Bt)=>{vt[bt.id]=Bt});let Et=p;(!Zn(Et)||st[0].data[Et]===void 0)&&(Et="degree"),Et==="degree"?st.sort((bt,Bt)=>e.getDegree(Bt.id,"both")-e.getDegree(bt.id,"both")):st.sort((bt,Bt)=>Bt.data[Et]-bt.data[Et]);const Tt=st[0],Pt=(g||(Et==="degree"?e.getDegree(Tt.id,"both"):Tt.data[Et]))/4,Dt=[{nodes:[]}];let Gt=Dt[0];st.forEach(bt=>{if(Gt.nodes.length>0){const Bt=Math.abs(Et==="degree"?e.getDegree(Gt.nodes[0].id,"both")-e.getDegree(bt.id,"both"):Gt.nodes[0].data[Et]-bt.data[Et]);Pt&&Bt>=Pt&&(Gt={nodes:[]},Dt.push(Gt))}Gt.nodes.push(bt)});let zt=ut+Q;if(!R){const bt=Dt.length>0&&Dt[0].nodes.length>1,_t=(Math.min(Y,X)/2-zt)/(Dt.length+(bt?1:0));zt=Math.min(zt,_t)}let Jt=0;if(Dt.forEach(bt=>{const Bt=y===void 0?2*Math.PI-2*Math.PI/bt.nodes.length:y;if(bt.dTheta=Bt/Math.max(1,bt.nodes.length-1),bt.nodes.length>1&&R){const _t=Math.cos(bt.dTheta)-Math.cos(0),Xt=Math.sin(bt.dTheta)-Math.sin(0),ie=Math.sqrt(zt*zt/(_t*_t+Xt*Xt));Jt=Math.max(ie,Jt)}bt.r=Jt,Jt+=zt}),L){let bt=0,Bt=0;for(let _t=0;_t{Xt===0&&(Bt=_t.r||0),_t.r=Bt,Bt+=bt})}return Dt.forEach(bt=>{const Bt=bt.dTheta||0,_t=bt.r||0;bt.nodes.forEach((Xt,ie)=>{const le=U+(O?1:-1)*Bt*ie;Xt.data.x=q[0]+_t*Math.cos(le),Xt.data.y=q[1]+_t*Math.sin(le)})}),t&&st.forEach(bt=>e.mergeNodeData(bt.id,{x:bt.data.x,y:bt.data.y})),{nodes:st,edges:W}})}}function mo(n){const t=+this._x.call(null,n),e=+this._y.call(null,n);return Ss(this.cover(t,e),t,e,n)}function Ss(n,t,e,r){if(isNaN(t)||isNaN(e))return n;var s,o=n._root,d={data:r},h=n._x0,p=n._y0,g=n._x1,y=n._y1,O,L,R,U,F,z,C,W;if(!o)return n._root=d,n;for(;o.length;)if((F=t>=(O=(h+g)/2))?h=O:g=O,(z=e>=(L=(p+y)/2))?p=L:y=L,s=o,!(o=o[C=z<<1|F]))return s[C]=d,n;if(R=+n._x.call(null,o.data),U=+n._y.call(null,o.data),t===R&&e===U)return d.next=o,s?s[C]=d:n._root=d,n;do s=s?s[C]=new Array(4):n._root=new Array(4),(F=t>=(O=(h+g)/2))?h=O:g=O,(z=e>=(L=(p+y)/2))?p=L:y=L;while((C=z<<1|F)===(W=(U>=L)<<1|R>=O));return s[W]=o,s[C]=d,n}function yo(n){var t,e,r=n.length,s,o,d=new Array(r),h=new Array(r),p=1/0,g=1/0,y=-1/0,O=-1/0;for(e=0;ey&&(y=s),oO&&(O=o));if(p>y||g>O)return this;for(this.cover(p,g).cover(y,O),e=0;en||n>=s||r>t||t>=o;)switch(g=(ty||(h=U.y0)>O||(p=U.x1)=C)<<1|n>=z)&&(U=L[L.length-1],L[L.length-1]=L[L.length-1-F],L[L.length-1-F]=U)}else{var W=n-+this._x.call(null,R.data),Y=t-+this._y.call(null,R.data),X=W*W+Y*Y;if(X=(L=(d+p)/2))?d=L:p=L,(F=O>=(R=(h+g)/2))?h=R:g=R,t=e,!(e=e[z=F<<1|U]))return this;if(!e.length)break;(t[z+1&3]||t[z+2&3]||t[z+3&3])&&(r=t,C=z)}for(;e.data!==n;)if(s=e,!(e=e.next))return this;return(o=e.next)&&delete e.next,s?(o?s.next=o:delete s.next,this):t?(o?t[z]=o:delete t[z],(e=t[0]||t[1]||t[2]||t[3])&&e===(t[3]||t[2]||t[1]||t[0])&&!e.length&&(r?r[C]=e:this._root=e),this):(this._root=o,this)}function Mo(n){for(var t=0,e=n.length;t=(U=(p+O)/2))?p=U:O=U,(q=e>=(F=(g+L)/2))?g=F:L=F,(st=r>=(z=(y+R)/2))?y=z:R=z,o=d,!(d=d[ut=st<<2|q<<1|X]))return o[ut]=h,n;if(C=+n._x.call(null,d.data),W=+n._y.call(null,d.data),Y=+n._z.call(null,d.data),t===C&&e===W&&r===Y)return h.next=d,o?o[ut]=h:n._root=h,n;do o=o?o[ut]=new Array(8):n._root=new Array(8),(X=t>=(U=(p+O)/2))?p=U:O=U,(q=e>=(F=(g+L)/2))?g=F:L=F,(st=r>=(z=(y+R)/2))?y=z:R=z;while((ut=st<<2|q<<1|X)===(Q=(Y>=z)<<2|(W>=F)<<1|C>=U));return o[Q]=d,o[ut]=h,n}function Co(n){Array.isArray(n)||(n=Array.from(n));const t=n.length,e=new Float64Array(t),r=new Float64Array(t),s=new Float64Array(t);let o=1/0,d=1/0,h=1/0,p=-1/0,g=-1/0,y=-1/0;for(let O=0,L,R,U,F;Op&&(p=R),Ug&&(g=U),Fy&&(y=F));if(o>p||d>g||h>y)return this;this.cover(o,d,h).cover(p,g,y);for(let O=0;On||n>=d||s>t||t>=h||o>e||e>=p;)switch(L=(eU||(g=Y.y0)>F||(y=Y.z0)>z||(O=Y.x1)=ut)<<2|(t>=st)<<1|n>=q)&&(Y=C[C.length-1],C[C.length-1]=C[C.length-1-X],C[C.length-1-X]=Y)}else{var Q=n-+this._x.call(null,W.data),vt=t-+this._y.call(null,W.data),Et=e-+this._z.call(null,W.data),Tt=Q*Q+vt*vt+Et*Et;if(Tt=(F=(d+g)/2))?d=F:g=F,(Y=R>=(z=(h+y)/2))?h=z:y=z,(X=U>=(C=(p+O)/2))?p=C:O=C,t=e,!(e=e[q=X<<2|Y<<1|W]))return this;if(!e.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])&&(r=t,st=q)}for(;e.data!==n;)if(s=e,!(e=e.next))return this;return(o=e.next)&&delete e.next,s?(o?s.next=o:delete s.next,this):t?(o?t[q]=o:delete t[q],(e=t[0]||t[1]||t[2]||t[3]||t[4]||t[5]||t[6]||t[7])&&e===(t[7]||t[6]||t[5]||t[4]||t[3]||t[2]||t[1]||t[0])&&!e.length&&(r?r[st]=e:this._root=e),this):(this._root=o,this)}function Uo(n){for(var t=0,e=n.length;t{const{nodeStrength:L,x:R,y:U,z:F,size:z}=y.data;return{x:R,y:U,z:F,size:z,index:O,id:y.id,vx:0,vy:0,vz:0,weight:o*L}}),p=(s===2?Fn(h,y=>y.x,y=>y.y):cr(h,y=>y.x,y=>y.y,y=>y.z)).visitAfter(qo),g=new Map;return h.forEach(y=>{g.set(y.id,y),ea(y,p,s)}),h.map((y,O)=>{const{id:L,data:R}=d[O],{mass:U=1}=R;r[L]={x:y.vx/U,y:y.vy/U,z:y.vz/U}}),r}function qo(n){let t=0,e=0,r=0,s=0,o=0;const d=n.length;if(d){for(let h=0;h{var h;if(((h=n.data)===null||h===void 0?void 0:h.id)===o.id)return;const p=[e,r,s][d-1],g=o.x-n.x||Ur,y=o.y-n.y||Ur,O=o.z-n.z||Ur,L=[g,y,O],R=p-t;let U=0;for(let C=0;Cta(r,s,o,d,h,n,e))}const na={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 js{constructor(t={}){this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=Object.assign(Object.assign({},na),t)}execute(t,e){return A(this,void 0,void 0,function*(){return this.genericForceLayout(!1,t,e)})}assign(t,e){return A(this,void 0,void 0,function*(){yield this.genericForceLayout(!0,t,e)})}stop(){this.timeInterval&&typeof window!="undefined"&&window.clearInterval(this.timeInterval),this.running=!1}tick(t=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let r=0;(this.judgingDistance>this.lastOptions.minMovement||r<1)&&rthis.lastGraph.mergeNodeData(r.id,{x:r.data.x,y:r.data.y,z:this.options.dimensions===3?r.data.z:void 0})),e}genericForceLayout(t,e,r){return A(this,void 0,void 0,function*(){const s=Object.assign(Object.assign({},this.options),r),o=e.getAllNodes(),d=e.getAllEdges(),h=this.formatOptions(s,e),{dimensions:p,width:g,height:y,nodeSize:O,getMass:L,nodeStrength:R,edgeStrength:U,linkDistance:F}=h,z=o.map((Q,vt)=>Object.assign(Object.assign({},Q),{data:Object.assign(Object.assign({},Q.data),{x:$t(Q.data.x)?Q.data.x:Math.random()*g,y:$t(Q.data.y)?Q.data.y:Math.random()*y,z:$t(Q.data.z)?Q.data.z:Math.random()*Math.sqrt(g*y),size:O(Q)||30,mass:L(Q),nodeStrength:R(Q)})})),C=d.map(Q=>Object.assign(Object.assign({},Q),{data:Object.assign(Object.assign({},Q.data),{edgeStrength:U(Q),linkDistance:F(Q,e.getNode(Q.source),e.getNode(Q.target))})}));if(!(o!=null&&o.length))return this.lastResult={nodes:[],edges:d},{nodes:[],edges:d};const W={};o.forEach((Q,vt)=>{W[Q.id]={x:0,y:0,z:0}});const Y=new xe({nodes:z,edges:C});this.formatCentripetal(h,Y);const{maxIteration:X,minMovement:q,onTick:st}=h;if(this.lastLayoutNodes=z,this.lastLayoutEdges=C,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=Y,this.lastOptions=h,this.lastVelMap=W,typeof window=="undefined")return;let ut=0;return new Promise(Q=>{this.timeInterval=window.setInterval(()=>{(!o||!this.running)&&Q({nodes:Vr(e,z),edges:d}),this.runOneStep(Y,e,ut,W,h),this.updatePosition(e,Y,W,h),t&&z.forEach(vt=>e.mergeNodeData(vt.id,{x:vt.data.x,y:vt.data.y,z:p===3?vt.data.z:void 0})),st==null||st({nodes:Vr(e,z),edges:d}),ut++,(ut>=X||this.judgingDistance{let g=1;$t(p==null?void 0:p.data.mass)&&(g=p==null?void 0:p.data.mass);const y=e.getDegree(p.id,"both");return!y||y<5?g:y*5*g}),r.nodeSize=Dr(t.nodeSize,t.nodeSpacing);const h=t.linkDistance?On(1,t.linkDistance):p=>1+r.nodeSize(e.getNode(p.source))+r.nodeSize(e.getNode(p.target));return r.linkDistance=h,r.nodeStrength=On(1,t.nodeStrength),r.edgeStrength=On(1,t.edgeStrength),r}formatCentripetal(t,e){const{dimensions:r,centripetalOptions:s,center:o,clusterNodeStrength:d,leafCluster:h,clustering:p,nodeClusterBy:g}=t,y=e.getAllNodes(),O=s||{leaf:2,single:2,others:1,center:C=>({x:o[0],y:o[1],z:r===3?o[2]:void 0})};typeof d!="function"&&(t.clusterNodeStrength=C=>d);let L,R;if(h&&g&&(L=Is(e,g),R=Array.from(new Set(y==null?void 0:y.map(C=>C.data[g])))||[],t.centripetalOptions=Object.assign(O,{single:100,leaf:C=>{const{siblingLeaves:W,sameTypeLeaves:Y}=L[C.id]||{};return(Y==null?void 0:Y.length)===(W==null?void 0:W.length)||(R==null?void 0:R.length)===1?1:t.clusterNodeStrength(C)},others:1,center:C=>{const W=e.getDegree(C.id,"both");if(!W)return{x:100,y:100,z:0};let Y;if(W===1){const{sameTypeLeaves:X=[]}=L[C.id]||{};X.length===1?Y=void 0:X.length>1&&(Y=Ps(X))}else Y=void 0;return{x:Y==null?void 0:Y.x,y:Y==null?void 0:Y.y,z:Y==null?void 0:Y.z}}})),p&&g){L||(L=Is(e,g)),R||(R=Array.from(new Set(y.map(W=>W.data[g])))),R=R.filter(W=>W!==void 0);const C={};R.forEach(W=>{const Y=y.filter(X=>X.data[g]===W).map(X=>e.getNode(X.id));C[W]=Ps(Y)}),t.centripetalOptions=Object.assign(O,{single:W=>t.clusterNodeStrength(W),leaf:W=>t.clusterNodeStrength(W),others:W=>t.clusterNodeStrength(W),center:W=>{const Y=C[W.data[g]];return{x:Y==null?void 0:Y.x,y:Y==null?void 0:Y.y,z:Y==null?void 0:Y.z}}})}const{leaf:U,single:F,others:z}=t.centripetalOptions||{};U&&typeof U!="function"&&(t.centripetalOptions.leaf=()=>U),F&&typeof F!="function"&&(t.centripetalOptions.single=()=>F),z&&typeof z!="function"&&(t.centripetalOptions.others=()=>z)}runOneStep(t,e,r,s,o){const d={},h=t.getAllNodes(),p=t.getAllEdges();if(!(h!=null&&h.length))return;const{monitor:g}=o;if(this.calRepulsive(t,d,o),p&&this.calAttractive(t,d,o),this.calGravity(t,e,d,o),this.updateVelocity(t,d,s,o),g){const y=this.calTotalEnergy(d,h);g({energy:y,nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:r})}}calTotalEnergy(t,e){if(!(e!=null&&e.length))return 0;let r=0;return e.forEach((s,o)=>{const d=t[s.id].x,h=t[s.id].y,p=this.options.dimensions===3?t[s.id].z:0,g=d*d+h*h+p*p,{mass:y=1}=s.data;r+=y*g*.5}),r}calRepulsive(t,e,r){const{dimensions:s,factor:o,coulombDisScale:d}=r;Ho(t,o,d*d,e,s)}calAttractive(t,e,r){const{dimensions:s,nodeSize:o}=r;t.getAllEdges().forEach((d,h)=>{const{source:p,target:g}=d,y=t.getNode(p),O=t.getNode(g);if(!y||!O)return;let L=O.data.x-y.data.x,R=O.data.y-y.data.y,U=s===3?O.data.z-y.data.z:0;!L&&!R&&(L=Math.random()*.01,R=Math.random()*.01,s===3&&!U&&(U=Math.random()*.01));const F=Math.sqrt(L*L+R*R+U*U);if(F{const{id:F,data:z}=U,{mass:C,x:W,y:Y,z:X}=z,q=e.getNode(F);let st=0,ut=0,Q=0,vt=L;const Et=t.getDegree(F,"in"),Tt=t.getDegree(F,"out"),Pt=t.getDegree(F,"both"),Dt=o==null?void 0:o(q,Pt);if(Dt){const[Gt,zt,Jt]=Dt;st=W-Gt,ut=Y-zt,vt=Jt}else st=W-O[0],ut=Y-O[1],Q=X-O[2];if(vt&&(r[F].x-=vt*st/C,r[F].y-=vt*ut/C,r[F].z-=vt*Q/C),R){const{leaf:Gt,single:zt,others:Jt,center:fe}=R,{x:bt,y:Bt,z:_t,centerStrength:Xt}=(fe==null?void 0:fe(q,h,p,g,y))||{x:0,y:0,z:0,centerStrength:0};if(!$t(bt)||!$t(Bt))return;const ie=(W-bt)/C,le=(Y-Bt)/C,Qt=(X-_t)/C;if(Xt&&(r[F].x-=Xt*ie,r[F].y-=Xt*le,r[F].z-=Xt*Qt),Pt===0){const je=zt(q);if(!je)return;r[F].x-=je*ie,r[F].y-=je*le,r[F].z-=je*Qt;return}if(Et===0||Tt===0){const je=Gt(q,h,p);if(!je)return;r[F].x-=je*ie,r[F].y-=je*le,r[F].z-=je*Qt;return}const oe=Jt(q);if(!oe)return;r[F].x-=oe*ie,r[F].y-=oe*le,r[F].z-=oe*Qt}})}updateVelocity(t,e,r,s){const{damping:o,maxSpeed:d,interval:h,dimensions:p}=s,g=t.getAllNodes();g!=null&&g.length&&g.forEach(y=>{const{id:O}=y;let L=(r[O].x+e[O].x*h)*o||.01,R=(r[O].y+e[O].y*h)*o||.01,U=p===3?(r[O].z+e[O].z*h)*o||.01:0;const F=Math.sqrt(L*L+R*R+U*U);if(F>d){const z=d/F;L=z*L,R=z*R,U=z*U}r[O]={x:L,y:R,z:U}})}updatePosition(t,e,r,s){const{distanceThresholdMode:o,interval:d,dimensions:h}=s,p=e.getAllNodes();if(!(p!=null&&p.length)){this.judgingDistance=0;return}let g=0;o==="max"?this.judgingDistance=-1/0:o==="min"&&(this.judgingDistance=1/0),p.forEach(y=>{const{id:O}=y,L=t.getNode(O);if($t(L.data.fx)&&$t(L.data.fy)){e.mergeNodeData(O,{x:L.data.fx,y:L.data.fy,z:h===3?L.data.fz:void 0});return}const R=r[O].x*d,U=r[O].y*d,F=h===3?r[O].z*d:0;e.mergeNodeData(O,{x:y.data.x+R,y:y.data.y+U,z:y.data.z+F});const z=Math.sqrt(R*R+U*U+F*F);switch(o){case"max":this.judgingDistancez&&(this.judgingDistance=z);break;default:g=g+z;break}}),(!o||o==="mean")&&(this.judgingDistance=g/p.length)}}const Is=(n,t)=>{const e=n.getAllNodes();if(!(e!=null&&e.length))return{};const r={};return e.forEach((s,o)=>{n.getDegree(s.id,"both")===1&&(r[s.id]=ra(n,"leaf",s,t))}),r},ra=(n,t,e,r)=>{const s=n.getDegree(e.id,"in"),o=n.getDegree(e.id,"out");let d=e,h=[];s===0?(d=n.getSuccessors(e.id)[0],h=n.getNeighbors(d.id)):o===0&&(d=n.getPredecessors(e.id)[0],h=n.getNeighbors(d.id)),h=h.filter(g=>n.getDegree(g.id,"in")===0||n.getDegree(g.id,"out")===0);const p=sa(n,t,r,e,h);return{coreNode:d,siblingLeaves:h,sameTypeLeaves:p}},sa=(n,t,e,r,s)=>{const o=r.data[e]||"";let d=(s==null?void 0:s.filter(h=>h.data[e]===o))||[];return t==="leaf"&&(d=d.filter(h=>n.getDegree(h.id,"in")===0||n.getDegree(h.id,"out")===0)),d},Ps=n=>{const t={x:0,y:0};n.forEach(r=>{const{x:s,y:o}=r.data;t.x+=s||0,t.y+=o||0});const e=n.length||1;return{x:t.x/e,y:t.y/e}},Vr=(n,t)=>t.map(e=>{const{id:r,data:s}=e,o=n.getNode(r);return Object.assign(Object.assign({},o),{data:Object.assign(Object.assign({},o.data),{x:s.x,y:s.y,z:s.z})})});var re=me(48202);const vc=re.XA,mc=re.a_,yc=re.yQ,wc=re.Hs,xc=re.Ec,Ec=re.dx,bc=re.LU,Nc=re.Rm,bn=re.y3,Mc=re.qK,Sc=re.pb,Oc=re.j,Ac=re.sO,Tc=re.BZ,jc=re.EK,Ic=re.Db,Pc=re.Fx,Lc=re.tU,Rc=re.Ym,Cc=re.rs,Dc=re.QR,zc=re.TB,Fc=re.oH,Ls=re.Sc,kc=re.BN,Bc=re.it,Uc=re.$r,Vc=re.QM,Gc=re.AV;var Wc=(re.y3,re.y3);const Yc=re.GH,$c=re.SO,Xc=re.uZ,Kc=re.yU,Zc=re.F1,Jc=re.re,Rs=n=>{const t=[],e=n.length;for(let r=0;rt[s][r]+t[r][o]&&(t[s][o]=t[s][r]+t[r][o]);return t},Cs=(n,t)=>{const{nodes:e,edges:r}=n,s=[],o={};if(!e)throw new Error("invalid nodes data!");return e&&e.forEach((d,h)=>{o[d.id]=h;const p=[];s.push(p)}),r==null||r.forEach(d=>{const{source:h,target:p}=d,g=o[h],y=o[p];g===void 0||y===void 0||(s[g][y]=1,t||(s[y][g]=1))}),s},ia=(n,t)=>{const e=[];return n.forEach(r=>{const s=[];r.forEach(o=>{s.push(o*t)}),e.push(s)}),e},oa=n=>{let t=1/0,e=1/0,r=-1/0,s=-1/0;return n.forEach(o=>{let d=o.data.size;hn(d)?d.length===1&&(d=[d[0],d[0]]):$t(d)?d=[d,d]:(d===void 0||isNaN(d))&&(d=[30,30]);const h=[d[0]/2,d[1]/2],p=o.data.x-h[0],g=o.data.x+h[0],y=o.data.y-h[1],O=o.data.y+h[1];t>p&&(t=p),e>y&&(e=y),rMath.sqrt((n.x-t.x)*(n.x-t.x)+(n.y-t.y)*(n.y-t.y)),Gr=(n,t,e,r="TB",s,o={})=>{if(!(t!=null&&t.length))return;const{stopBranchFn:d,stopAllFn:h}=o;for(let p=0;p{const C=Je(h[z]);C.data.x=F[0]+o[0],C.data.y=F[1]+o[1],R.push(C)}),t&&R.forEach(F=>e.mergeNodeData(F.id,{x:F.data.x,y:F.data.y})),{nodes:R,edges:p}})}}const ua=n=>{let t=-999999;n.forEach(e=>{e.forEach(r=>{r!==1/0&&t{e.forEach((s,o)=>{s===1/0&&(n[r][o]=t)})})},ca=n=>{const e=bn.mul(bn.pow(n,2),-.5),r=e.mean("row"),s=e.mean("column"),o=e.mean();e.add(o).subRowVector(r).subColumnVector(s);const d=new Ls(e),h=bn.sqrt(d.diagonalMatrix).diagonal();return d.leftSingularVectors.toJSON().map(p=>bn.mul([p],[h]).toJSON()[0].splice(0,2))};function Fs(n){return!!n.tick&&!!n.stop}const fa={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},la={center:[0,0],comboPadding:10,treeKey:"combo"};class da{constructor(t={}){this.options=t,this.id="comboCombined",this.options=Object.assign(Object.assign({},la),t)}execute(t,e){return A(this,void 0,void 0,function*(){return this.genericComboCombinedLayout(!1,t,e)})}assign(t,e){return A(this,void 0,void 0,function*(){yield this.genericComboCombinedLayout(!0,t,e)})}genericComboCombinedLayout(t,e,r){return A(this,void 0,void 0,function*(){const s=this.initVals(Object.assign(Object.assign({},this.options),r)),{center:o,treeKey:d,outerLayout:h}=s,p=e.getAllNodes().filter(Q=>!Q.data._isCombo),g=e.getAllNodes().filter(Q=>Q.data._isCombo),y=e.getAllEdges(),O=p==null?void 0:p.length;if(!O||O===1)return An(e,t,o);const L=[],R=new Map;p.forEach(Q=>{R.set(Q.id,Q)});const U=new Map;g.forEach(Q=>{U.set(Q.id,Q)});const F=new Map,z=this.getInnerGraphs(e,d,R,U,y,s,F);yield Promise.all(z);const C=new Map,W=[],Y=new Map;let X=!0;e.getRoots(d).forEach(Q=>{const vt=F.get(Q.id),Et=U.get(Q.id)||R.get(Q.id),Tt={id:Q.id,data:Object.assign(Object.assign({},Q.data),{x:vt.data.x||Et.data.x,y:vt.data.y||Et.data.y,fx:vt.data.fx||Et.data.fx,fy:vt.data.fy||Et.data.fy,mass:vt.data.mass||Et.data.mass,size:vt.data.size})};W.push(Tt),C.set(Q.id,!0),!isNaN(Tt.data.x)&&Tt.data.x!==0&&!isNaN(Tt.data.y)&&Tt.data.y!==0?X=!1:(Tt.data.x=Math.random()*100,Tt.data.y=Math.random()*100),Gr(e,[Q],Pt=>{Pt.id!==Q.id&&Y.set(Pt.id,Q.id)},"TB",d)});const q=[];y.forEach(Q=>{const vt=Y.get(Q.source)||Q.source,Et=Y.get(Q.target)||Q.target;vt!==Et&&C.has(vt)&&C.has(Et)&&q.push({id:Q.id,source:vt,target:Et,data:{}})});let st;if(W!=null&&W.length){if(W.length===1)W[0].data.x=o[0],W[0].data.y=o[1];else{const Q=new xe({nodes:W,edges:q}),vt=h||new js;X&&fa[vt.id]&&(yield(W.length<100?new zs:new Fr).assign(Q));const Et=Object.assign({center:o,kg:5,preventOverlap:!0,animate:!1},vt.id==="force"?{gravity:1,factor:4,linkDistance:(Tt,Pt,Dt)=>{const Gt=Math.max(...Pt.data.size)||32,zt=Math.max(...Dt.data.size)||32;return Gt/2+zt/2+200}}:{});st=yield ks(vt,Q,Et)}F.forEach(Q=>{var vt;const Et=st.nodes.find(Dt=>Dt.id===Q.id);if(Et){const{x:Dt,y:Gt}=Et.data;Q.data.visited=!0,Q.data.x=Dt,Q.data.y=Gt,L.push({id:Q.id,data:{x:Dt,y:Gt}})}const{x:Tt,y:Pt}=Q.data;(vt=Q.data.nodes)===null||vt===void 0||vt.forEach(Dt=>{L.push({id:Dt.id,data:{x:Dt.data.x+Tt,y:Dt.data.y+Pt}})})}),F.forEach(({data:Q})=>{const{x:vt,y:Et,visited:Tt,nodes:Pt}=Q;Pt==null||Pt.forEach(Dt=>{if(!Tt){const Gt=L.find(zt=>zt.id===Dt.id);Gt.data.x+=vt||0,Gt.data.y+=Et||0}})})}return t&&L.forEach(Q=>{e.mergeNodeData(Q.id,{x:Q.data.x,y:Q.data.y})}),{nodes:L,edges:y}})}initVals(t){const e=Object.assign({},t),{nodeSize:r,spacing:s,comboPadding:o}=t;let d,h;if($t(s)?h=()=>s:dn(s)?h=s:h=()=>0,e.spacing=h,!r)d=g=>{const y=h(g);return g.size?hn(g.size)?((g.size[0]>g.size[1]?g.size[0]:g.size[1])+y)/2:zn(g.size)?((g.size.width>g.size.height?g.size.width:g.size.height)+y)/2:(g.size+y)/2:32+y/2};else if(dn(r))d=g=>{const y=r(g),O=h(g);return hn(g.size)?((g.size[0]>g.size[1]?g.size[0]:g.size[1])+O)/2:((y||32)+O)/2};else if(hn(r)){const y=(r[0]>r[1]?r[0]:r[1])/2;d=O=>y+h(O)/2}else{const g=r/2;d=y=>g+h(y)/2}e.nodeSize=d;let p;return $t(o)?p=()=>o:hn(o)?p=()=>Math.max.apply(null,o):dn(o)?p=o:p=()=>0,e.comboPadding=p,e}getInnerGraphs(t,e,r,s,o,d,h){const{nodeSize:p,comboPadding:g,spacing:y,innerLayout:O}=d,L=O||new Fr({}),R={center:[0,0],preventOverlap:!0,nodeSpacing:y},U=[],F=z=>{let C=(g==null?void 0:g(z))||10;return hn(C)&&(C=Math.max(...C)),{size:C?[C*2,C*2]:[30,30],padding:C}};return t.getRoots(e).forEach(z=>{h.set(z.id,{id:z.id,data:{nodes:[],size:F(z).size}});let C=Promise.resolve();Gr(t,[z],W=>{var Y;if(!W.data._isCombo)return;const{size:X,padding:q}=F(W);if(!(!((Y=t.getChildren(W.id,e))===null||Y===void 0)&&Y.length))h.set(W.id,{id:W.id,data:Object.assign(Object.assign({},W.data),{size:X})});else{const st=h.get(W.id);h.set(W.id,{id:W.id,data:Object.assign({nodes:[]},st==null?void 0:st.data)});const ut=new Map,Q=t.getChildren(W.id,e).map(Tt=>{if(Tt.data._isCombo)return h.has(Tt.id)||h.set(Tt.id,{id:Tt.id,data:Object.assign({},Tt.data)}),ut.set(Tt.id,!0),h.get(Tt.id);const Pt=r.get(Tt.id)||s.get(Tt.id);return ut.set(Tt.id,!0),{id:Tt.id,data:Object.assign(Object.assign({},Pt.data),Tt.data)}}),vt={nodes:Q,edges:o.filter(Tt=>ut.has(Tt.source)&&ut.has(Tt.target))};let Et=1/0;Q.forEach(Tt=>{var Pt;let{size:Dt}=Tt.data;Dt||(Dt=((Pt=h.get(Tt.id))===null||Pt===void 0?void 0:Pt.data.size)||(p==null?void 0:p(Tt))||[30,30]),$t(Dt)&&(Dt=[Dt,Dt]);const[Gt,zt]=Dt;Et>Gt&&(Et=Gt),Et>zt&&(Et=zt),Tt.data.size=Dt}),C=C.then(()=>A(this,void 0,void 0,function*(){const Tt=new xe(vt);yield ks(L,Tt,R,!0);const{minX:Pt,minY:Dt,maxX:Gt,maxY:zt}=oa(Q),Jt={x:(Gt+Pt)/2,y:(zt+Dt)/2};vt.nodes.forEach(bt=>{bt.data.x-=Jt.x,bt.data.y-=Jt.y});const fe=[Math.max(Gt-Pt,Et)+q*2,Math.max(zt-Dt,Et)+q*2];h.get(W.id).data.size=fe,h.get(W.id).data.nodes=Q}))}return!0},"BT",e),U.push(C)}),U}}function ks(n,t,e,r){var s;return A(this,void 0,void 0,function*(){return Fs(n)?(n.execute(t,e),n.stop(),n.tick((s=e.iterations)!==null&&s!==void 0?s:300)):r?yield n.assign(t,e):yield n.execute(t,e)})}var ha=function(n){return typeof n=="object"&&n!==null},ga=ha,pa={}.toString,va=function(n,t){return pa.call(n)==="[object "+t+"]"},ma=va,ya=function(n){if(!ga(n)||!ma(n,"Object"))return!1;if(Object.getPrototypeOf(n)===null)return!0;for(var t=n;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(n)===t},Wr=ya,wa=5;function xa(n,t){if(Object.hasOwn)return Object.hasOwn(n,t);if(n==null)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(Object(n),t)}function Bs(n,t,e,r){e=e||0,r=r||wa;for(var s in t)if(xa(t,s)){var o=t[s];o!==null&&Wr(o)?(Wr(n[s])||(n[s]={}),e[t(q,st,d),q])),X;for(z=0,h=new Array(C);z{}};function Ws(){for(var n=0,t=arguments.length,e={},r;n=0&&(r=e.slice(s+1),e=e.slice(0,s)),e&&!t.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:r}})}fr.prototype=Ws.prototype={constructor:fr,on:function(n,t){var e=this._,r=Ta(n+"",e),s,o=-1,d=r.length;if(arguments.length<2){for(;++o0)for(var e=new Array(s),r=0,s,o;r=0&&n._call.call(void 0,t),n=n._next;--kn}function Js(){Tn=(dr=Hn.now())+hr,kn=Jn=0;try{La()}finally{kn=0,Ca(),Tn=0}}function Ra(){var n=Hn.now(),t=n-dr;t>$s&&(hr-=t,dr=n)}function Ca(){for(var n,t=lr,e,r=1/0;t;)t._call?(r>t._time&&(r=t._time),n=t,t=t._next):(e=t._next,t._next=null,t=n?n._next=e:lr=e);_n=n,$r(r)}function $r(n){if(!kn){Jn&&(Jn=clearTimeout(Jn));var t=n-Tn;t>24?(n<1/0&&(Jn=setTimeout(Js,n-Hn.now()-hr)),Qn&&(Qn=clearInterval(Qn))):(Qn||(dr=Hn.now(),Qn=setInterval(Ra,$s)),kn=1,Xs(Js))}}const Da=1664525,za=1013904223,Qs=4294967296;function Fa(){let n=1;return()=>(n=(Da*n+za)%Qs)/Qs}function ka(n){return n.x}function Ba(n){return n.y}var Ua=10,Va=Math.PI*(3-Math.sqrt(5));function Ga(n){var t,e=1,r=.001,s=1-Math.pow(r,1/300),o=0,d=.6,h=new Map,p=Zs(O),g=Ia("tick","end"),y=Fa();n==null&&(n=[]);function O(){L(),g.call("tick",t),e1?(z==null?h.delete(F):h.set(F,U(z)),t):h.get(F)},find:function(F,z,C){var W=0,Y=n.length,X,q,st,ut,Q;for(C==null?C=1/0:C*=C,W=0;W1?(g.on(F,z),t):g.on(F)}}}function Wa(){var n,t,e,r,s=Le(-30),o,d=1,h=1/0,p=.81;function g(R){var U,F=n.length,z=Fn(n,ka,Ba).visitAfter(O);for(r=R,U=0;U=h)return;(R.data!==t||R.next)&&(C===0&&(C=Nn(e),X+=C*C),W===0&&(W=Nn(e),X+=W*W),XL.index){var Tt=R-Q.x-Q.vx,Pt=U-Q.y-Q.vy,Dt=Tt*Tt+Pt*Pt;DtR+Et||stU+Et||utg.r&&(g.r=g[y].r)}function p(){if(t){var g,y=t.length,O;for(e=new Array(y),g=0;ge.id},manyBody:{},center:{x:0,y:0}},this.context={options:{},assign:!1,nodes:[],edges:[]},Us(this.options,t),this.options.forceSimulation&&(this.simulation=this.options.forceSimulation)}execute(t,e){return A(this,void 0,void 0,function*(){return this.genericLayout(!1,t,e)})}assign(t,e){return A(this,void 0,void 0,function*(){yield this.genericLayout(!0,t,e)})}stop(){this.simulation.stop()}tick(t){return this.simulation.tick(t),this.getResult()}restart(){this.simulation.restart()}setFixedPosition(t,e){const r=this.context.nodes.find(s=>s.id===t);r&&e.forEach((s,o)=>{if(typeof s=="number"||s===null){const d=["fx","fy","fz"][o];r[d]=s}})}getOptions(t){var e,r;const s=Us({},this.options,t);return s.collide&&((e=s.collide)===null||e===void 0?void 0:e.radius)===void 0&&(s.collide=s.collide||{},s.collide.radius=(r=s.nodeSize)!==null&&r!==void 0?r:10),s.iterations===void 0&&(s.link&&s.link.iterations===void 0&&(s.iterations=s.link.iterations),s.collide&&s.collide.iterations===void 0&&(s.iterations=s.collide.iterations)),this.context.options=s,s}genericLayout(t,e,r){var s;return A(this,void 0,void 0,function*(){const o=this.getOptions(r),d=e.getAllNodes().map(({id:y,data:O})=>Object.assign(Object.assign({id:y},O),Vs(O.data,this.config.inputNodeAttrs))),h=e.getAllEdges().map(y=>Object.assign({},y));Object.assign(this.context,{assign:t,nodes:d,edges:h,graph:e});const p=new Promise(y=>{this.resolver=y}),g=this.setSimulation(o);return g.nodes(d),(s=g.force("link"))===null||s===void 0||s.links(h),p})}getResult(){const{assign:t,nodes:e,edges:r,graph:s}=this.context,o=e.map(h=>({id:h.id,data:Object.assign(Object.assign({},h.data),Vs(h,this.config.outputNodeAttrs))})),d=r.map(({id:h,source:p,target:g,data:y})=>({id:h,source:typeof p=="object"?p.id:p,target:typeof g=="object"?g.id:g,data:y}));return t&&o.forEach(h=>s.mergeNodeData(h.id,h.data)),{nodes:o,edges:d}}initSimulation(){return Ga()}setSimulation(t){const e=this.simulation||this.options.forceSimulation||this.initSimulation();return this.simulation||(this.simulation=e.on("tick",()=>{var r;return(r=t.onTick)===null||r===void 0?void 0:r.call(t,this.getResult())}).on("end",()=>{var r;return(r=this.resolver)===null||r===void 0?void 0:r.call(this,this.getResult())})),Hs(e,this.config.simulationAttrs.map(r=>[r,t[r]])),Object.entries(this.forceMap).forEach(([r,s])=>{const o=r;if(t[r]){let d=e.force(o);d||(d=s(),e.force(o,d)),Hs(d,Object.entries(t[o]))}else e.force(o,null)}),e}}const Hs=(n,t)=>t.reduce((e,[r,s])=>!e[r]||s===void 0?e:e[r].call(n,s),n);function Me(n){return function(){return n}}function He(n){return(n()-.5)*1e-6}function _a(n){return n.index}function qs(n,t){var e=n.get(t);if(!e)throw new Error("node not found: "+t);return e}function Ha(n){var t=_a,e=L,r,s=Me(30),o,d,h,p,g,y,O=1;n==null&&(n=[]);function L(C){return 1/Math.min(p[C.source.index],p[C.target.index])}function R(C){for(var W=0,Y=n.length;W1&&(vt=ut.y+ut.vy-st.y-st.vy||He(y)),h>2&&(Et=ut.z+ut.vz-st.z-st.vz||He(y)),Tt=Math.sqrt(Q*Q+vt*vt+Et*Et),Tt=(Tt-o[X])/Tt*C*r[X],Q*=Tt,vt*=Tt,Et*=Tt,ut.vx-=Q*(Pt=g[X]),h>1&&(ut.vy-=vt*Pt),h>2&&(ut.vz-=Et*Pt),st.vx+=Q*(Pt=1-Pt),h>1&&(st.vy+=vt*Pt),h>2&&(st.vz+=Et*Pt)}function U(){if(d){var C,W=d.length,Y=n.length,X=new Map(d.map((st,ut)=>[t(st,ut,d),st])),q;for(C=0,p=new Array(W);Ctypeof Y=="function")||Math.random,h=W.find(Y=>[1,2,3].includes(Y))||2,U()},R.links=function(C){return arguments.length?(n=C,U(),R):n},R.id=function(C){return arguments.length?(t=C,R):t},R.iterations=function(C){return arguments.length?(O=+C,R):O},R.strength=function(C){return arguments.length?(e=typeof C=="function"?C:Me(+C),F(),R):e},R.distance=function(C){return arguments.length?(s=typeof C=="function"?C:Me(+C),z(),R):s},R}function qa(n){const t=+this._x.call(null,n);return ti(this.cover(t),t,n)}function ti(n,t,e){if(isNaN(t))return n;var r,s=n._root,o={data:e},d=n._x0,h=n._x1,p,g,y,O,L;if(!s)return n._root=o,n;for(;s.length;)if((y=t>=(p=(d+h)/2))?d=p:h=p,r=s,!(s=s[O=+y]))return r[O]=o,n;if(g=+n._x.call(null,s.data),t===g)return o.next=s,r?r[O]=o:n._root=o,n;do r=r?r[O]=new Array(2):n._root=new Array(2),(y=t>=(p=(d+h)/2))?d=p:h=p;while((O=+y)==(L=+(g>=p)));return r[L]=s,r[O]=o,n}function tu(n){Array.isArray(n)||(n=Array.from(n));const t=n.length,e=new Float64Array(t);let r=1/0,s=-1/0;for(let o=0,d;os&&(s=d));if(r>s)return this;this.cover(r).cover(s);for(let o=0;on||n>=e;)switch(d=+(nd||(o=g.x1)=O))&&(g=h[h.length-1],h[h.length-1]=h[h.length-1-y],h[h.length-1-y]=g)}else{var L=Math.abs(n-+this._x.call(null,p.data));L=(g=(d+h)/2))?d=g:h=g,t=e,!(e=e[O=+y]))return this;if(!e.length)break;t[O+1&1]&&(r=t,L=O)}for(;e.data!==n;)if(s=e,!(e=e.next))return this;return(o=e.next)&&delete e.next,s?(o?s.next=o:delete s.next,this):t?(o?t[O]=o:delete t[O],(e=t[0]||t[1])&&e===(t[1]||t[0])&&!e.length&&(r?r[L]=e:this._root=e),this):(this._root=o,this)}function ou(n){for(var t=0,e=n.length;t{}};function ni(){for(var n=0,t=arguments.length,e={},r;n=0&&(r=e.slice(s+1),e=e.slice(0,s)),e&&!t.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:r}})}gr.prototype=ni.prototype={constructor:gr,on:function(n,t){var e=this._,r=gu(n+"",e),s,o=-1,d=r.length;if(arguments.length<2){for(;++o0)for(var e=new Array(s),r=0,s,o;r=0&&n._call.call(void 0,t),n=n._next;--Bn}function ui(){jn=(vr=nr.now())+mr,Bn=qn=0;try{yu()}finally{Bn=0,xu(),jn=0}}function wu(){var n=nr.now(),t=n-vr;t>si&&(mr-=t,vr=n)}function xu(){for(var n,t=pr,e,r=1/0;t;)t._call?(r>t._time&&(r=t._time),n=t,t=t._next):(e=t._next,t._next=null,t=n?n._next=e:pr=e);er=n,Jr(r)}function Jr(n){if(!Bn){qn&&(qn=clearTimeout(qn));var t=n-jn;t>24?(n<1/0&&(qn=setTimeout(ui,n-nr.now()-mr)),tr&&(tr=clearInterval(tr))):(tr||(vr=nr.now(),tr=setInterval(wu,si)),Bn=1,ii(ui))}}const Eu=1664525,bu=1013904223,ci=4294967296;function Nu(){let n=1;return()=>(n=(Eu*n+bu)%ci)/ci}var fi=3;function Qr(n){return n.x}function li(n){return n.y}function Mu(n){return n.z}var Su=10,Ou=Math.PI*(3-Math.sqrt(5)),Au=Math.PI*20/(9+Math.sqrt(221));function Tu(n,t){t=t||2;var e=Math.min(fi,Math.max(1,Math.round(t))),r,s=1,o=.001,d=1-Math.pow(o,1/300),h=0,p=.6,g=new Map,y=ai(R),O=vu("tick","end"),L=Nu();n==null&&(n=[]);function R(){U(),O.call("tick",r),s1&&(X.fy==null?X.y+=X.vy*=p:(X.y=X.fy,X.vy=0)),e>2&&(X.fz==null?X.z+=X.vz*=p:(X.z=X.fz,X.vz=0));return r}function F(){for(var C=0,W=n.length,Y;C1&&isNaN(Y.y)||e>2&&isNaN(Y.z)){var X=Su*(e>2?Math.cbrt(.5+C):e>1?Math.sqrt(.5+C):C),q=C*Ou,st=C*Au;e===1?Y.x=X:e===2?(Y.x=X*Math.cos(q),Y.y=X*Math.sin(q)):(Y.x=X*Math.sin(q)*Math.cos(st),Y.y=X*Math.cos(q),Y.z=X*Math.sin(q)*Math.sin(st))}(isNaN(Y.vx)||e>1&&isNaN(Y.vy)||e>2&&isNaN(Y.vz))&&(Y.vx=0,e>1&&(Y.vy=0),e>2&&(Y.vz=0))}}function z(C){return C.initialize&&C.initialize(n,L,e),C}return F(),r={tick:U,restart:function(){return y.restart(R),r},stop:function(){return y.stop(),r},numDimensions:function(C){return arguments.length?(e=Math.min(fi,Math.max(1,Math.round(C))),g.forEach(z),r):e},nodes:function(C){return arguments.length?(n=C,F(),g.forEach(z),r):n},alpha:function(C){return arguments.length?(s=+C,r):s},alphaMin:function(C){return arguments.length?(o=+C,r):o},alphaDecay:function(C){return arguments.length?(d=+C,r):+d},alphaTarget:function(C){return arguments.length?(h=+C,r):h},velocityDecay:function(C){return arguments.length?(p=1-C,r):1-p},randomSource:function(C){return arguments.length?(L=C,g.forEach(z),r):L},force:function(C,W){return arguments.length>1?(W==null?g.delete(C):g.set(C,z(W)),r):g.get(C)},find:function(){var C=Array.prototype.slice.call(arguments),W=C.shift()||0,Y=(e>1?C.shift():null)||0,X=(e>2?C.shift():null)||0,q=C.shift()||1/0,st=0,ut=n.length,Q,vt,Et,Tt,Pt,Dt;for(q*=q,st=0;st1?(O.on(C,W),r):O.on(C)}}}function ju(){var n,t,e,r,s,o=Me(-30),d,h=1,p=1/0,g=.81;function y(U){var F,z=n.length,C=(t===1?Xr(n,Qr):t===2?Fn(n,Qr,li):t===3?cr(n,Qr,li,Mu):null).visitAfter(L);for(s=U,F=0;F1&&(U.y=X/W),t>2&&(U.z=q/W)}else{z=U,z.x=z.data.x,t>1&&(z.y=z.data.y),t>2&&(z.z=z.data.z);do F+=d[z.data.index];while(z=z.next)}U.value=F}function R(U,F,z,C,W){if(!U.value)return!0;var Y=[z,C,W][t-1],X=U.x-e.x,q=t>1?U.y-e.y:0,st=t>2?U.z-e.z:0,ut=Y-F,Q=X*X+q*q+st*st;if(ut*ut/g1&&q===0&&(q=He(r),Q+=q*q),t>2&&st===0&&(st=He(r),Q+=st*st),Q1&&(e.vy+=q*U.value*s/Q),t>2&&(e.vz+=st*U.value*s/Q)),!0;if(U.length||Q>=p)return;(U.data!==e||U.next)&&(X===0&&(X=He(r),Q+=X*X),t>1&&q===0&&(q=He(r),Q+=q*q),t>2&&st===0&&(st=He(r),Q+=st*st),Q1&&(e.vy+=q*ut),t>2&&(e.vz+=st*ut));while(U=U.next)}return y.initialize=function(U,...F){n=U,r=F.find(z=>typeof z=="function")||Math.random,t=F.find(z=>[1,2,3].includes(z))||2,O()},y.strength=function(U){return arguments.length?(o=typeof U=="function"?U:Me(+U),O(),y):o},y.distanceMin=function(U){return arguments.length?(h=U*U,y):Math.sqrt(h)},y.distanceMax=function(U){return arguments.length?(p=U*U,y):Math.sqrt(p)},y.theta=function(U){return arguments.length?(g=U*U,y):Math.sqrt(g)},y}function Iu(n,t,e){var r,s=1;n==null&&(n=0),t==null&&(t=0),e==null&&(e=0);function o(){var d,h=r.length,p,g=0,y=0,O=0;for(d=0;d1&&(F=R.y+R.vy),e>2&&(z=R.z+R.vz),L.visit(X);function X(q,st,ut,Q,vt,Et,Tt){var Pt=[st,ut,Q,vt,Et,Tt],Dt=Pt[0],Gt=Pt[1],zt=Pt[2],Jt=Pt[e],fe=Pt[e+1],bt=Pt[e+2],Bt=q.data,_t=q.r,Xt=C+_t;if(Bt){if(Bt.index>R.index){var ie=U-Bt.x-Bt.vx,le=e>1?F-Bt.y-Bt.vy:0,Qt=e>2?z-Bt.z-Bt.vz:0,oe=ie*ie+le*le+Qt*Qt;oe1&&le===0&&(le=He(s),oe+=le*le),e>2&&Qt===0&&(Qt=He(s),oe+=Qt*Qt),oe=(Xt-(oe=Math.sqrt(oe)))/oe*o,R.vx+=(ie*=oe)*(Xt=(_t*=_t)/(W+_t)),e>1&&(R.vy+=(le*=oe)*Xt),e>2&&(R.vz+=(Qt*=oe)*Xt),Bt.vx-=ie*(Xt=1-Xt),e>1&&(Bt.vy-=le*Xt),e>2&&(Bt.vz-=Qt*Xt))}return}return Dt>U+Xt||Jt1&&(Gt>F+Xt||fe2&&(zt>z+Xt||bty.r&&(y.r=y[O].r)}function g(){if(t){var y,O=t.length,L;for(r=new Array(O),y=0;ytypeof L=="function")||Math.random,e=O.find(L=>[1,2,3].includes(L))||2,g()},h.iterations=function(y){return arguments.length?(d=+y,h):d},h.strength=function(y){return arguments.length?(o=+y,h):o},h.radius=function(y){return arguments.length?(n=typeof y=="function"?y:Me(+y),g(),h):n},h}function Ru(n,t,e,r){var s,o,d=Me(.1),h,p;typeof n!="function"&&(n=Me(+n)),t==null&&(t=0),e==null&&(e=0),r==null&&(r=0);function g(O){for(var L=0,R=s.length;L1&&(U.vy+=z*Y),o>2&&(U.vz+=C*Y)}}function y(){if(s){var O,L=s.length;for(h=new Array(L),p=new Array(L),O=0;O[1,2,3].includes(R))||2,y()},g.strength=function(O){return arguments.length?(d=typeof O=="function"?O:Me(+O),y(),g):d},g.radius=function(O){return arguments.length?(n=typeof O=="function"?O:Me(+O),y(),g):n},g.x=function(O){return arguments.length?(t=+O,g):t},g.y=function(O){return arguments.length?(e=+O,g):e},g.z=function(O){return arguments.length?(r=+O,g):r},g}function Cu(n){var t=Me(.1),e,r,s;typeof n!="function"&&(n=Me(n==null?0:+n));function o(h){for(var p=0,g=e.length,y;pt.id},manyBody:{},center:{x:0,y:0,z:0}}}initSimulation(){return Tu()}}var hi=me(70681),ku=me.n(hi);class yr{constructor(t){this.id="dagre",this.options={},Object.assign(this.options,yr.defaultOptions,t)}execute(t,e){return A(this,void 0,void 0,function*(){return this.genericDagreLayout(!1,t,Object.assign(Object.assign({},this.options),e))})}assign(t,e){return A(this,void 0,void 0,function*(){yield this.genericDagreLayout(!0,t,Object.assign(Object.assign({},this.options),e))})}genericDagreLayout(t,e,r){return A(this,void 0,void 0,function*(){const{nodeSize:s}=r,o=new hi.graphlib.Graph;o.setGraph(r),o.setDefaultEdgeLabel(()=>({}));const d=e.getAllNodes(),h=e.getAllEdges();[...d,...h].some(({id:g})=>$t(g))&&console.error("Dagre layout only support string id, it will convert number to string."),e.getAllNodes().forEach(g=>{const{id:y}=g,O=Object.assign({},g.data);if(s!==void 0){const[L,R]=Kn(dn(s)?s(g):s);Object.assign(O,{width:L,height:R})}o.setNode(y.toString(),O)}),e.getAllEdges().forEach(({id:g,source:y,target:O})=>{o.setEdge(y.toString(),O.toString(),{id:g})}),ku().layout(o);const p={nodes:[],edges:[]};return o.nodes().forEach(g=>{const y=o.node(g);p.nodes.push({id:g,data:y}),t&&e.mergeNodeData(g,y)}),o.edges().forEach(g=>{const y=o.edge(g),{id:O}=y,L=l(y,["id"]),{v:R,w:U}=g;p.edges.push({id:O,source:R,target:U,data:L}),t&&e.mergeEdgeData(O,L)}),p})}}yr.defaultOptions={};class Hr{constructor(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}distanceTo(t){const e=this.rx-t.rx,r=this.ry-t.ry;return Math.hypot(e,r)}setPos(t,e){this.rx=t,this.ry=e}resetForce(){this.fx=0,this.fy=0}addForce(t){const e=t.rx-this.rx,r=t.ry-this.ry;let s=Math.hypot(e,r);s=s<1e-4?1e-4:s;const o=this.g*(this.degree+1)*(t.degree+1)/s;this.fx+=o*e/s,this.fy+=o*r/s}in(t){return t.contains(this.rx,this.ry)}add(t){const e=this.mass+t.mass,r=(this.rx*this.mass+t.rx*t.mass)/e,s=(this.ry*this.mass+t.ry*t.mass)/e,o=this.degree+t.degree,d={rx:r,ry:s,mass:e,degree:o};return new Hr(d)}}class Un{constructor(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}getLength(){return this.length}contains(t,e){const r=this.length/2;return t<=this.xmid+r&&t>=this.xmid-r&&e<=this.ymid+r&&e>=this.ymid-r}NW(){const t=this.xmid-this.length/4,e=this.ymid+this.length/4,r=this.length/2,s={xmid:t,ymid:e,length:r};return new Un(s)}NE(){const t=this.xmid+this.length/4,e=this.ymid+this.length/4,r=this.length/2,s={xmid:t,ymid:e,length:r};return new Un(s)}SW(){const t=this.xmid-this.length/4,e=this.ymid-this.length/4,r=this.length/2,s={xmid:t,ymid:e,length:r};return new Un(s)}SE(){const t=this.xmid+this.length/4,e=this.ymid-this.length/4,r=this.length/2,s={xmid:t,ymid:e,length:r};return new Un(s)}}class Vn{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 Vn(this.quad.NW()),this.NE=new Vn(this.quad.NE()),this.SW=new Vn(this.quad.SW()),this.SE=new Vn(this.quad.SE())),this._putBody(this.body),this._putBody(t),this.body=this.body.add(t)):(this.body=this.body.add(t),this._putBody(t))}_putBody(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))}_isExternal(){return this.NW==null&&this.NE==null&&this.SW==null&&this.SE==null}updateForce(t){if(!(this.body==null||t===this.body))if(this._isExternal())t.addForce(this.body);else{const e=this.quad?this.quad.getLength():0,r=this.body.distanceTo(t);e/rJe(C,[h,p])),U=s.filter(C=>{const{source:W,target:Y}=C;return W!==Y}),F=new xe({nodes:R,edges:U}),z=this.getSizes(F,O);if(this.run(F,e,y,z,t,d),g){for(let W=0;W250&&(r.barnesHut=!0),p===void 0&&e>100&&(r.prune=!0),g===0&&!p?(r.maxIteration=250,e<=200&&e>100?r.maxIteration=1e3:e>200&&(r.maxIteration=1200)):g===0&&p&&(r.maxIteration=100,e<=200&&e>100?r.maxIteration=500:e>200&&(r.maxIteration=950)),y||(r.kr=50,e>100&&e<=500?r.kr=20:e>500&&(r.kr=1)),O||(r.kg=20,e>100&&e<=500?r.kg=10:e>500&&(r.kg=1)),r}run(t,e,r,s,o,d){const{kr:h,barnesHut:p,onTick:g}=d,y=t.getAllNodes();let O=0,L=r;const R={},U={},F={};for(let z=0;z0;)O=this.oneStep(t,{iter:L,preventOverlapIters:50,krPrime:100,sg:O,forces:R,preForces:U,bodies:F,sizes:s},d),L--,g==null||g({nodes:y,edges:e.getAllEdges()});return t}oneStep(t,e,r){const{iter:s,preventOverlapIters:o,krPrime:d,sg:h,preForces:p,bodies:g,sizes:y}=e;let{forces:O}=e;const{preventOverlap:L,barnesHut:R}=r,U=t.getAllNodes();for(let F=0;Fo||!L)?O=this.getOptRepGraForces(t,O,g,r):O=this.getRepGraForces(t,s,o,O,d,y,r),this.updatePos(t,O,p,h,r)}getAttrForces(t,e,r,s,o,d){const{preventOverlap:h,dissuadeHubs:p,mode:g,prune:y}=d,O=t.getAllEdges();for(let L=0;L0&&(q=X,st=X),o[R][0]+=q*Y[0],o[U][0]-=st*Y[0],o[R][1]+=q*Y[1],o[U][1]-=st*Y[1]}return o}getOptRepGraForces(t,e,r,s){const{kg:o,center:d,prune:h}=s,p=t.getAllNodes(),g=p.length;let y=9e10,O=-9e10,L=9e10,R=-9e10;for(let W=0;W=O&&(O=X.x),X.x<=y&&(y=X.x),X.y>=R&&(R=X.y),X.y<=L&&(L=X.y))}const U=Math.max(O-y,R-L),F={xmid:(O+y)/2,ymid:(R+L)/2,length:U,massCenter:d,mass:g},z=new Un(F),C=new Vn(z);for(let W=0;W0&&(Et=g*(C+1)*(ut+1)/vt),s[z.id][0]-=Et*Q[0],s[st.id][0]+=Et*Q[0],s[z.id][1]-=Et*Q[1],s[st.id][1]+=Et*Q[1]}const W=[z.data.x-O[0],z.data.y-O[1]],Y=Math.hypot(W[0],W[1]);W[0]=W[0]/Y,W[1]=W[1]/Y;const X=y*(C+1);s[z.id][0]-=X*W[0],s[z.id][1]-=X*W[1]}return s}updatePos(t,e,r,s,o){const{ks:d,tao:h,prune:p,ksmax:g}=o,y=t.getAllNodes(),O=y.length,L=[],R=[];let U=0,F=0,z=s;for(let W=0;W1.5*C?1.5*C:z);for(let W=0;WQ?Q:st;const vt=st*e[Y][0],Et=st*e[Y][1];t.mergeNodeData(Y,{x:X.x+vt,y:X.y+Et})}return z}}const Vu={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},Gu=800;class Wu{constructor(t={}){this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=Object.assign(Object.assign({},Vu),t)}execute(t,e){return A(this,void 0,void 0,function*(){return this.genericFruchtermanLayout(!1,t,e)})}assign(t,e){return A(this,void 0,void 0,function*(){yield this.genericFruchtermanLayout(!0,t,e)})}stop(){this.timeInterval&&typeof window!="undefined"&&window.clearInterval(this.timeInterval),this.running=!1}tick(t=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let r=0;rthis.lastGraph.mergeNodeData(r.id,{x:r.data.x,y:r.data.y,z:this.options.dimensions===3?r.data.z:void 0})),e}genericFruchtermanLayout(t,e,r){return A(this,void 0,void 0,function*(){if(this.running)return;const s=this.formatOptions(r),{dimensions:o,width:d,height:h,center:p,clustering:g,nodeClusterBy:y,maxIteration:O,onTick:L}=s,R=e.getAllNodes(),U=e.getAllEdges();if(!(R!=null&&R.length)){const Y={nodes:[],edges:U};return this.lastResult=Y,Y}if(R.length===1){t&&e.mergeNodeData(R[0].id,{x:p[0],y:p[1],z:o===3?p[2]:void 0});const Y={nodes:[Object.assign(Object.assign({},R[0]),{data:Object.assign(Object.assign({},R[0].data),{x:p[0],y:p[1],z:o===3?p[2]:void 0})})],edges:U};return this.lastResult=Y,Y}const F=R.map(Y=>Je(Y,[d,h])),z=new xe({nodes:F,edges:U}),C={};if(g&&F.forEach(Y=>{const X=Y.data[y];C[X]||(C[X]={name:X,cx:0,cy:0,count:0})}),this.lastLayoutNodes=F,this.lastLayoutEdges=U,this.lastAssign=t,this.lastGraph=z,this.lastOptions=s,this.lastClusterMap=C,typeof window=="undefined")return;let W=0;return new Promise(Y=>{this.timeInterval=window.setInterval(()=>{if(!this.running){Y({nodes:F,edges:U});return}this.runOneStep(z,C,s),t&&F.forEach(({id:X,data:q})=>e.mergeNodeData(X,{x:q.x,y:q.y,z:o===3?q.z:void 0})),L==null||L({nodes:F,edges:U}),W++,W>=O&&(window.clearInterval(this.timeInterval),Y({nodes:F,edges:U}))},0),this.running=!0})})}formatOptions(t={}){const e=Object.assign(Object.assign({},this.options),t),{clustering:r,nodeClusterBy:s}=e,{center:o,width:d,height:h}=e;return e.width=!d&&typeof window!="undefined"?window.innerWidth:d,e.height=!h&&typeof window!="undefined"?window.innerHeight:h,e.center=o||[e.width/2,e.height/2],e.clustering=r&&!!s,e}runOneStep(t,e,r){const{dimensions:s,height:o,width:d,gravity:h,center:p,speed:g,clustering:y,nodeClusterBy:O,clusterGravity:L}=r,R=o*d,U=Math.sqrt(R)/10,F=t.getAllNodes(),z=R/(F.length+1),C=Math.sqrt(z),W={};if(this.applyCalculate(t,W,C,z),y){for(const X in e)e[X].cx=0,e[X].cy=0,e[X].count=0;F.forEach(X=>{const{data:q}=X,st=e[q[O]];$t(q.x)&&(st.cx+=q.x),$t(q.y)&&(st.cy+=q.y),st.count++});for(const X in e)e[X].cx/=e[X].count,e[X].cy/=e[X].count;const Y=L||h;F.forEach((X,q)=>{const{id:st,data:ut}=X;if(!$t(ut.x)||!$t(ut.y))return;const Q=e[ut[O]],vt=Math.sqrt((ut.x-Q.cx)*(ut.x-Q.cx)+(ut.y-Q.cy)*(ut.y-Q.cy)),Et=C*Y;W[st].x-=Et*(ut.x-Q.cx)/vt,W[st].y-=Et*(ut.y-Q.cy)/vt})}F.forEach((Y,X)=>{const{id:q,data:st}=Y;if(!$t(st.x)||!$t(st.y))return;const ut=.01*C*h;W[q].x-=ut*(st.x-p[0]),W[q].y-=ut*(st.y-p[1]),s===3&&(W[q].z-=ut*(st.z-p[2]))}),F.forEach((Y,X)=>{const{id:q,data:st}=Y;if($t(st.fx)&&$t(st.fy)){st.x=st.fx,st.y=st.fy,s===3&&(st.z=st.fz);return}if(!$t(st.x)||!$t(st.y))return;const ut=Math.sqrt(W[q].x*W[q].x+W[q].y*W[q].y+(s===3?W[q].z*W[q].z:0));if(ut>0){const Q=Math.min(U*(g/Gu),ut);t.mergeNodeData(q,{x:st.x+W[q].x/ut*Q,y:st.y+W[q].y/ut*Q,z:s===3?st.z+W[q].z/ut*Q:void 0})}})}applyCalculate(t,e,r,s){this.calRepulsive(t,e,s),this.calAttractive(t,e,r)}calRepulsive(t,e,r){const s=t.getAllNodes();s.forEach(({data:o,id:d},h)=>{e[d]={x:0,y:0,z:0},s.forEach(({data:p,id:g},y)=>{if(h<=y||!$t(o.x)||!$t(p.x)||!$t(o.y)||!$t(p.y))return;let O=o.x-p.x,L=o.y-p.y,R=this.options.dimensions===3?o.z-p.z:0,U=O*O+L*L+R*R;U===0&&(U=1,O=.01,L=.01,R=.01);const F=r/U,z=O*F,C=L*F,W=R*F;e[d].x+=z,e[d].y+=C,e[g].x-=z,e[g].y-=C,this.options.dimensions===3&&(e[d].z+=W,e[g].z-=W)})})}calAttractive(t,e,r){t.getAllEdges().forEach(o=>{const{source:d,target:h}=o;if(!d||!h||d===h)return;const{data:p}=t.getNode(d),{data:g}=t.getNode(h);if(!$t(g.x)||!$t(p.x)||!$t(g.y)||!$t(p.y))return;const y=g.x-p.x,O=g.y-p.y,L=this.options.dimensions===3?g.z-p.z:0,R=Math.sqrt(y*y+O*O+L*L)/r,U=y*R,F=O*R,z=L*R;e[d].x+=U,e[d].y+=F,e[h].x-=U,e[h].y-=F,this.options.dimensions===3&&(e[d].z+=z,e[h].z-=z)})}}const Yu={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 $u{constructor(t={}){this.options=t,this.id="grid",this.options=Object.assign(Object.assign({},Yu),t)}execute(t,e){return A(this,void 0,void 0,function*(){return this.genericGridLayout(!1,t,e)})}assign(t,e){return A(this,void 0,void 0,function*(){yield this.genericGridLayout(!0,t,e)})}genericGridLayout(t,e,r){return A(this,void 0,void 0,function*(){const s=Object.assign(Object.assign({},this.options),r),{begin:o=[0,0],condense:d,preventOverlapPadding:h,preventOverlap:p,rows:g,cols:y,nodeSpacing:O,nodeSize:L,width:R,height:U,position:F}=s;let{sortBy:z}=s;const C=e.getAllNodes(),W=e.getAllEdges(),Y=C==null?void 0:C.length;if(!Y||Y===1)return An(e,t,o);const X=C.map(zt=>Je(zt));z!=="id"&&(!Zn(z)||X[0].data[z]===void 0)&&(z="degree"),z==="degree"?X.sort((zt,Jt)=>e.getDegree(Jt.id,"both")-e.getDegree(zt.id,"both")):z==="id"?X.sort((zt,Jt)=>$t(Jt.id)&&$t(zt.id)?Jt.id-zt.id:`${zt.id}`.localeCompare(`${Jt.id}`)):X.sort((zt,Jt)=>Jt.data[z]-zt.data[z]);const q=!R&&typeof window!="undefined"?window.innerWidth:R,st=!U&&typeof window!="undefined"?window.innerHeight:U,ut=Y,Q={rows:g,cols:y};if(g!=null&&y!=null)Q.rows=g,Q.cols=y;else if(g!=null&&y==null)Q.rows=g,Q.cols=Math.ceil(ut/Q.rows);else if(g==null&&y!=null)Q.cols=y,Q.rows=Math.ceil(ut/Q.cols);else{const zt=Math.sqrt(ut*st/q);Q.rows=Math.round(zt),Q.cols=Math.round(q/st*zt)}if(Q.rows=Math.max(Q.rows,1),Q.cols=Math.max(Q.cols,1),Q.cols*Q.rows>ut){const zt=wr(Q),Jt=xr(Q);(zt-1)*Jt>=ut?wr(Q,zt-1):(Jt-1)*zt>=ut&&xr(Q,Jt-1)}else for(;Q.cols*Q.rows=ut?xr(Q,Jt+1):wr(Q,zt+1)}let vt=d?0:q/Q.cols,Et=d?0:st/Q.rows;if(p||O){const zt=On(10,O),Jt=Cr(30,L,!1);X.forEach(fe=>{(!fe.data.x||!fe.data.y)&&(fe.data.x=0,fe.data.y=0);const bt=e.getNode(fe.id),[Bt,_t]=Kn(Jt(bt)||30),Xt=zt!==void 0?zt(fe):h,ie=Bt+Xt,le=_t+Xt;vt=Math.max(vt,ie),Et=Math.max(Et,le)})}const Tt={},Pt={row:0,col:0},Dt={};for(let zt=0;zt{e.mergeNodeData(zt.id,{x:zt.data.x,y:zt.data.y})}),Gt})}}const wr=(n,t)=>{let e;const r=n.rows||5,s=n.cols||5;return t==null?e=Math.min(r,s):Math.min(r,s)===n.rows?n.rows=t:n.cols=t,e},xr=(n,t)=>{let e;const r=n.rows||5,s=n.cols||5;return t==null?e=Math.max(r,s):Math.max(r,s)===n.rows?n.rows=t:n.cols=t,e},qr=(n,t)=>n[`c-${t.row}-${t.col}`]||!1,gi=(n,t)=>n[`c-${t.row}-${t.col}`]=!0,pi=(n,t)=>{const e=n.cols||5;t.col++,t.col>=e&&(t.col=0,t.row++)},Xu=(n,t,e,r,s,o,d,h)=>{let p,g;const y=s[n.id];if(y)p=y.col*e+e/2+t[0],g=y.row*r+r/2+t[1];else{for(;qr(h,d);)pi(o,d);p=d.col*e+e/2+t[0],g=d.row*r+r/2+t[1],gi(h,d),pi(o,d)}n.data.x=p,n.data.y=g},Ku=(n,t,e)=>{try{const r=bn.mul(bn.pow(t,2),-.5),s=r.mean("row"),o=r.mean("column"),d=r.mean();r.add(d).subRowVector(s).subColumnVector(o);const h=new Ls(r),p=bn.sqrt(h.diagonalMatrix).diagonal();return h.leftSingularVectors.toJSON().map(g=>bn.mul([g],[p]).toJSON()[0].splice(0,n))}catch(r){const s=[];for(let o=0;o{const e=Object.assign(Object.assign({},Ju),t),{positions:r,iterations:s,width:o,k:d,speed:h=100,strictRadial:p,focusIdx:g,radii:y=[],nodeSizeFunc:O}=e,L=n.getAllNodes(),R=[],U=o/10;for(let F=0;F{R[C]={x:0,y:0}}),_u(L,r,R,d,y,O),Hu(r,R,h,p,g,U,o,y);return r},_u=(n,t,e,r,s,o)=>{t.forEach((d,h)=>{e[h]={x:0,y:0},t.forEach((p,g)=>{if(h===g||s[h]!==s[g])return;let y=d.x-p.x,O=d.y-p.y,L=Math.sqrt(y*y+O*O);if(L===0){L=1;const R=h>g?1:-1;y=.01*R,O=.01*R}if(L{const p=o||d/10;return r&&t.forEach((g,y)=>{const O=n[y].x-n[s].x,L=n[y].y-n[s].y,R=Math.sqrt(O*O+L*L);let U=L/R,F=-O/R;const z=Math.sqrt(g.x*g.x+g.y*g.y);let C=Math.acos((U*g.x+F*g.y)/z);C>Math.PI/2&&(C-=Math.PI/2,U*=-1,F*=-1);const W=Math.cos(C)*z;g.x=U*W,g.y=F*W}),n.forEach((g,y)=>{if(y===s)return;const O=Math.sqrt(t[y].x*t[y].x+t[y].y*t[y].y);if(O>0&&y!==s){const L=Math.min(p*(e/Zu),O);if(g.x+=t[y].x/O*L,g.y+=t[y].y/O*L,r){let R=g.x-n[s].x,U=g.y-n[s].y;const F=Math.sqrt(R*R+U*U);R=R/F*h[y],U=U/F*h[y],g.x=n[s].x+R,g.y=n[s].y+U}}}),n},qu={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10};class tc{constructor(t={}){this.options=t,this.id="radial",this.options=Object.assign(Object.assign({},qu),t)}execute(t,e){return A(this,void 0,void 0,function*(){return this.genericRadialLayout(!1,t,e)})}assign(t,e){return A(this,void 0,void 0,function*(){yield this.genericRadialLayout(!0,t,e)})}genericRadialLayout(t,e,r){return A(this,void 0,void 0,function*(){const s=Object.assign(Object.assign({},this.options),r),{width:o,height:d,center:h,focusNode:p,unitRadius:g,nodeSize:y,nodeSpacing:O,strictRadial:L,preventOverlap:R,maxPreventOverlapIteration:U,sortBy:F,linkDistance:z=50,sortStrength:C=10,maxIteration:W=1e3}=s,Y=e.getAllNodes(),X=e.getAllEdges(),q=!o&&typeof window!="undefined"?window.innerWidth:o,st=!d&&typeof window!="undefined"?window.innerHeight:d,ut=h||[q/2,st/2];if(!(Y!=null&&Y.length)||Y.length===1)return An(e,t,ut);let Q=Y[0];if(Zn(p)){for(let Ee=0;Eeut[0]?ut[0]:q-ut[0],zt=st-ut[1]>ut[1]?ut[1]:st-ut[1];Gt===0&&(Gt=q/2),zt===0&&(zt=st/2);const Jt=Math.min(Gt,zt),fe=Math.max(...Dt),bt=[],Bt=g||Jt/fe;Dt.forEach((Ee,qe)=>{bt[qe]=Ee*Bt});const _t=ec(Y,Tt,z,bt,Bt,F,C),Xt=nc(_t),ie=Ku(z,_t,z);let le=ie.map(([Ee,qe])=>({x:(isNaN(Ee)?Math.random()*z:Ee)-ie[vt][0],y:(isNaN(qe)?Math.random()*z:qe)-ie[vt][1]}));this.run(W,le,Xt,_t,bt,vt);let Qt;if(R){Qt=Dr(y,O);const Ee={nodes:Y,nodeSizeFunc:Qt,positions:le,radii:bt,height:st,width:q,strictRadial:!!L,focusIdx:vt,iterations:U||200,k:le.length/4.5};le=Qu(e,Ee)}const oe=[];return le.forEach((Ee,qe)=>{const vn=Je(Y[qe]);vn.data.x=Ee.x+ut[0],vn.data.y=Ee.y+ut[1],oe.push(vn)}),t&&oe.forEach(Ee=>e.mergeNodeData(Ee.id,{x:Ee.data.x,y:Ee.data.y})),{nodes:oe,edges:X}})}run(t,e,r,s,o,d){for(let h=0;h<=t;h++){const p=h/t;this.oneIteration(p,e,o,s,r,d)}}oneIteration(t,e,r,s,o,d){const h=1-t;e.forEach((p,g)=>{const y=Ds(p,{x:0,y:0}),O=y===0?0:1/y;if(g===d)return;let L=0,R=0,U=0;e.forEach((z,C)=>{if(g===C)return;const W=Ds(p,z),Y=W===0?0:1/W,X=s[C][g];U+=o[g][C],L+=o[g][C]*(z.x+X*(p.x-z.x)*Y),R+=o[g][C]*(z.y+X*(p.y-z.y)*Y)});const F=r[g]===0?0:1/r[g];U*=h,U+=t*F*F,L*=h,L+=t*F*p.x*O,p.x=L/U,R*=h,R+=t*F*p.y*O,p.y=R/U})}}const ec=(n,t,e,r,s,o,d)=>{if(!n)return[];const h=[];if(t){const p={};t.forEach((g,y)=>{const O=[];g.forEach((L,R)=>{var U,F;if(y===R)O.push(0);else if(r[y]===r[R])if(o==="data")O.push(L*(Math.abs(y-R)*d)/(r[y]/s));else if(o){let z,C;if(p[n[y].id])z=p[n[y].id];else{const W=(o==="id"?n[y].id:(U=n[y].data)===null||U===void 0?void 0:U[o])||0;Zn(W)?z=W.charCodeAt(0):z=W,p[n[y].id]=z}if(p[n[R].id])C=p[n[R].id];else{const W=(o==="id"?n[R].id:(F=n[R].data)===null||F===void 0?void 0:F[o])||0;Zn(W)?C=W.charCodeAt(0):C=W,p[n[R].id]=C}O.push(L*(Math.abs(z-C)*d)/(r[y]/s))}else O.push(L*e/(r[y]/s));else{const z=(e+s)/2;O.push(L*z)}}),h.push(O)})}return h},nc=n=>{const t=n.length,e=n[0].length,r=[];for(let s=0;s{let e=-1;return n.forEach((r,s)=>{r.id===t&&(e=s)}),Math.max(e,0)},sc=(n,t,e)=>{const r=n.length;for(let s=0;s{let e=0;for(let r=0;re?n[t][r]:e);return e},oc={center:[0,0],width:300,height:300};class ac{constructor(t={}){this.options=t,this.id="random",this.options=Object.assign(Object.assign({},oc),t)}execute(t,e){return A(this,void 0,void 0,function*(){return this.genericRandomLayout(!1,t,e)})}assign(t,e){return A(this,void 0,void 0,function*(){yield this.genericRandomLayout(!0,t,e)})}genericRandomLayout(t,e,r){return A(this,void 0,void 0,function*(){const s=Object.assign(Object.assign({},this.options),r),{center:o,width:d,height:h}=s,p=e.getAllNodes(),g=.9,y=!d&&typeof window!="undefined"?window.innerWidth:d,O=!h&&typeof window!="undefined"?window.innerHeight:h,L=o||[y/2,O/2],R=[];return p&&p.forEach(F=>{R.push({id:F.id,data:{x:(Math.random()-.5)*g*y+L[0],y:(Math.random()-.5)*g*O+L[1]}})}),t&&R.forEach(F=>e.mergeNodeData(F.id,{x:F.data.x,y:F.data.y})),{nodes:R,edges:e.getAllEdges()}})}}const uc={circular:ho,concentric:Fr,mds:zs,random:ac,grid:$u,radial:tc,force:js,d3force:_s,"d3-force-3d":Fu,fruchterman:Wu,forceAtlas2:Uu,dagre:yr,antvDagre:co,comboCombined:da};let pn;ge({stopLayout(){pn!=null&&pn.stop&&pn.stop()},calculateLayout(n,t){return A(this,void 0,void 0,function*(){const{layout:{id:e,options:r,iterations:s},nodes:o,edges:d}=n,h=new xe({nodes:o,edges:d}),p=uc[e];if(p)pn=new p(r);else throw new Error(`Unknown layout id: ${e}`);let g=yield pn.execute(h);return Fs(pn)&&(pn.stop(),g=pn.tick(s)),[g,t]})}})})()})(); }());