!(function(){var $u=Object.defineProperty,Xu=Object.defineProperties;var _u=Object.getOwnPropertyDescriptors;var ei=Object.getOwnPropertySymbols;var Ku=Object.prototype.hasOwnProperty,Zu=Object.prototype.propertyIsEnumerable;var cr=Math.pow,_r=(Xe,je,me)=>je in Xe?$u(Xe,je,{enumerable:!0,configurable:!0,writable:!0,value:me}):Xe[je]=me,kn=(Xe,je)=>{for(var me in je||(je={}))Ku.call(je,me)&&_r(Xe,me,je[me]);if(ei)for(var me of ei(je))Zu.call(je,me)&&_r(Xe,me,je[me]);return Xe},Kr=(Xe,je)=>Xu(Xe,_u(je));var be=(Xe,je,me)=>_r(Xe,typeof je!="symbol"?je+"":je,me);(function(){var Xe={18086:function(w,P,a){"use strict";var f,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,Y,_;f={value:!0};var ot=a(34634),nt=a(34402);const Q=" ".repeat(2),et=" ".repeat(4);function H(){return it(this)}function it(T,u={}){const{maxRows:c=15,maxColumns:i=10,maxNumSize:l=8,padMinus:m="auto"}=u;return`${T.constructor.name} { ${Q}[ ${et}${at(T,c,i,l,m)} ${Q}] ${Q}rows: ${T.rows} ${Q}columns: ${T.columns} }`}function at(T,u,c,i,l){const{rows:m,columns:B}=T,U=Math.min(m,u),V=Math.min(B,c),G=[];if(l==="auto"){l=!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 l=T.toExponential(u);return l.length>u&&(l=T.toExponential(Math.max(0,u-(l.length-u)))),l.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 l=0;l>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 l=0;l>i.get(l,m));return this},T.signPropagatingRightShift=function(i,l){return new u(i).signPropagatingRightShift(l)},T.prototype.rightShift=function(i){return typeof i=="number"?this.rightShiftS(i):this.rightShiftM(i)},T.prototype.rightShiftS=function(i){for(let l=0;l>>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 l=0;l>>i.get(l,m));return this},T.rightShift=function(i,l){return new u(i).rightShift(l)},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 Nt(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 Ot(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 Ht(T,u,c,i,l){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(ye("startRow",u),ye("endRow",c),ye("startColumn",i),ye("endColumn",l),u>c||i>l||u<0||u>=T.rows||c<0||c>=T.rows||i<0||i>=T.columns||l<0||l>=T.columns)throw new RangeError("Submatrix indices are out of range")}function ee(T,u=0){let c=[];for(let i=0;i=m)throw new RangeError("min must be smaller than max");let U=m-l,V=new It(u,c);for(let G=0;Gi?(m=!0,i=c):(l=!1,m=!0);u++}return l}isReducedEchelonForm(){let u=0,c=0,i=-1,l=!0,m=!1;for(;ui?(m=!0,i=c):(l=!1,m=!0);for(let B=c+1;Bu.get(l,i)&&(l=m);if(u.get(l,i)===0)i++;else{u.swapRows(c,l);let m=u.get(c,i);for(let B=i;B=0;)if(u.maxRow(l)===0)l--;else{let m=0,B=!1;for(;mc[i]&&(c[i]=this.get(i,l));return c}case"column":{const c=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let i=0;ic[l]&&(c[l]=this.get(i,l));return c}case void 0:{let c=this.get(0,0);for(let i=0;ic&&(c=this.get(i,l));return c}default:throw new Error(`invalid option: ${u}`)}}maxIndex(){Ye(this);let u=this.get(0,0),c=[0,0];for(let i=0;iu&&(u=this.get(i,l),c[0]=i,c[1]=l);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),Ye(this);let c=this.get(u,0),i=[u,0];for(let l=1;lc&&(c=this.get(u,l),i[1]=l);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),Ye(this);let c=this.get(0,u),i=[0,u];for(let l=1;lc&&(c=this.get(l,u),i[0]=l);return i}minColumn(u){if(yt(this,u),this.isEmpty())return NaN;let c=this.get(0,u);for(let i=1;i=1;l/=2)l&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),l=u.get(0,0),m=this.get(0,1),B=u.get(0,1),U=this.get(1,0),V=u.get(1,0),G=this.get(1,1),rt=u.get(1,1),K=(i+G)*(l+rt),lt=(U+G)*l,Tt=i*(B-rt),ct=G*(V-l),pt=(i+m)*rt,Rt=(U-i)*(l+B),Z=(m-G)*(V+rt),St=K+ct-pt+Z,Ct=Tt+pt,Xt=lt+ct,Zt=K-lt+Tt+Rt;return c.set(0,0,St),c.set(0,1,Ct),c.set(1,0,Xt),c.set(1,1,Zt),c}strassen3x3(u){u=It.checkMatrix(u);let c=new It(3,3);const i=this.get(0,0),l=this.get(0,1),m=this.get(0,2),B=this.get(1,0),U=this.get(1,1),V=this.get(1,2),G=this.get(2,0),rt=this.get(2,1),K=this.get(2,2),lt=u.get(0,0),Tt=u.get(0,1),ct=u.get(0,2),pt=u.get(1,0),Rt=u.get(1,1),Z=u.get(1,2),St=u.get(2,0),Ct=u.get(2,1),Xt=u.get(2,2),Zt=(i+l+m-B-U-rt-K)*Rt,ge=(i-B)*(-Tt+Rt),Ut=U*(-lt+Tt+pt-Rt-Z-St+Xt),Yt=(-i+B+U)*(lt-Tt+Rt),ce=(B+U)*(-lt+Tt),tt=i*lt,wt=(-i+G+rt)*(lt-ct+Z),Lt=(-i+G)*(ct-Z),Mt=(G+rt)*(-lt+ct),we=(i+l+m-U-V-G-rt)*Z,ae=rt*(-lt+ct+pt-Rt-Z-St+Ct),fe=(-m+rt+K)*(Rt+St-Ct),pe=(m-K)*(Rt-Ct),Re=m*St,_e=(rt+K)*(-St+Ct),Se=(-m+U+V)*(Z+St-Xt),Je=(m-V)*(Z-Xt),Qe=(U+V)*(-St+Xt),te=l*pt,Le=V*Ct,Ue=B*ct,Ve=G*Tt,Oe=K*Xt,xr=tt+Re+te,Er=Zt+Yt+ce+tt+fe+Re+_e,Hn=tt+wt+Mt+we+Re+Se+Qe,br=ge+Ut+Yt+tt+Re+Se+Je,qn=ge+Yt+ce+tt+Le,Nr=Re+Se+Je+Qe+Ue,Mr=tt+wt+Lt+ae+fe+pe+Re,Sr=fe+pe+Re+_e+Ve,tr=tt+wt+Lt+Mt+Oe;return c.set(0,0,xr),c.set(0,1,Er),c.set(0,2,Hn),c.set(1,0,br),c.set(1,1,qn),c.set(1,2,Nr),c.set(2,0,Mr),c.set(2,1,Sr),c.set(2,2,tr),c}mmulStrassen(u){u=It.checkMatrix(u);let c=this.clone(),i=c.rows,l=c.columns,m=u.rows,B=u.columns;l!==m&&console.warn(`Multiplying ${i} x ${l} and ${m} x ${B} matrix: dimensions do not match.`);function U(K,lt,Tt){let ct=K.rows,pt=K.columns;if(ct===lt&&pt===Tt)return K;{let Rt=Wt.zeros(lt,Tt);return Rt=Rt.setSubMatrix(K,0,0),Rt}}let V=Math.max(i,m),G=Math.max(l,B);c=U(c,V,G),u=U(u,V,G);function rt(K,lt,Tt,ct){if(Tt<=512||ct<=512)return K.mmul(lt);Tt%2===1&&ct%2===1?(K=U(K,Tt+1,ct+1),lt=U(lt,Tt+1,ct+1)):Tt%2===1?(K=U(K,Tt+1,ct),lt=U(lt,Tt+1,ct)):ct%2===1&&(K=U(K,Tt,ct+1),lt=U(lt,Tt,ct+1));let pt=parseInt(K.rows/2,10),Rt=parseInt(K.columns/2,10),Z=K.subMatrix(0,pt-1,0,Rt-1),St=lt.subMatrix(0,pt-1,0,Rt-1),Ct=K.subMatrix(0,pt-1,Rt,K.columns-1),Xt=lt.subMatrix(0,pt-1,Rt,lt.columns-1),Zt=K.subMatrix(pt,K.rows-1,0,Rt-1),ge=lt.subMatrix(pt,lt.rows-1,0,Rt-1),Ut=K.subMatrix(pt,K.rows-1,Rt,K.columns-1),Yt=lt.subMatrix(pt,lt.rows-1,Rt,lt.columns-1),ce=rt(Wt.add(Z,Ut),Wt.add(St,Yt),pt,Rt),tt=rt(Wt.add(Zt,Ut),St,pt,Rt),wt=rt(Z,Wt.sub(Xt,Yt),pt,Rt),Lt=rt(Ut,Wt.sub(ge,St),pt,Rt),Mt=rt(Wt.add(Z,Ct),Yt,pt,Rt),we=rt(Wt.sub(Zt,Z),Wt.add(St,Xt),pt,Rt),ae=rt(Wt.sub(Ct,Ut),Wt.add(ge,Yt),pt,Rt),fe=Wt.add(ce,Lt);fe.sub(Mt),fe.add(ae);let pe=Wt.add(wt,Mt),Re=Wt.add(tt,Lt),_e=Wt.sub(ce,tt);_e.add(wt),_e.add(we);let Se=Wt.zeros(2*fe.rows,2*fe.columns);return Se=Se.setSubMatrix(fe,0,0),Se=Se.setSubMatrix(pe,fe.rows,0),Se=Se.setSubMatrix(Re,0,fe.columns),Se=Se.setSubMatrix(_e,fe.rows,fe.columns),Se.subMatrix(0,Tt-1,0,ct-1)}return rt(c,u,V,G)}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 l=new It(this.rows,this.columns);for(let m=0;m0&&nt(B,{min:c,max:i,output:B}),l.setRow(m,B)}return l}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 l=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 l=new It(u.length,i-c+1);for(let m=0;m=this.rows)throw new RangeError(`Row index out of range: ${u[m]}`);l.set(m,B-c,this.get(u[m],B))}return l}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 l=new It(i-c+1,u.length);for(let m=0;m=this.columns)throw new RangeError(`Column index out of range: ${u[m]}`);l.set(B-c,m,this.get(B,u[m]))}return l}setSubMatrix(u,c,i){if(u=It.checkMatrix(u),u.isEmpty())return this;let l=c+u.rows-1,m=i+u.columns-1;Ht(this,c,l,i,m);for(let B=0;Btypeof 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 on=class Zr extends Wt{constructor(u,c){if(super(),A(this,D),N(this,"data"),Zr.isMatrix(u))j(this,D,Y).call(this,u.rows,u.columns),Zr.copy(u,this);else if(Number.isInteger(u)&&u>=0)j(this,D,Y).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 l=0;l=0)for(let c=0;c=0)I(this,_,new It(u,u));else if(I(this,_,new It(u)),!this.isSymmetric())throw new TypeError("not symmetric data")}get size(){return M(this,_).size}get rows(){return M(this,_).rows}get columns(){return M(this,_).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 Jr(this.diagonalSize);for(const[c,i,l]of this.upperRightEntries())u.set(c,i,l);return u}toMatrix(){return new It(this)}get(u,c){return M(this,_).get(u,c)}set(u,c,i){return M(this,_).set(u,c,i),M(this,_).set(c,u,i),this}removeCross(u){return M(this,_).removeRow(u),M(this,_).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,_).addRow(u,i),M(this,_).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,l]of u.entries())l||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,l=0,m=0;m=u&&(i=++l);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 l=new Jr(i);for(let m=0,B=0,U=0;U=i&&(m=++B);return l}*upperRightEntries(){for(let u=0,c=0;u=this.diagonalSize&&(c=++u)}}*upperRightValues(){for(let u=0,c=0;u=this.diagonalSize&&(c=++u)}};_=new WeakMap;let Pe=un;Pe.prototype.klassType="SymmetricMatrix";class xe extends Pe{static isDistanceMatrix(u){return Pe.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 Pe(this)}clone(){const u=new xe(this.diagonalSize);for(const[c,i,l]of this.upperRightEntries())c!==i&&u.set(c,i,l);return u}toCompact(){const{diagonalSize:u}=this,c=(u-1)*u/2,i=new Array(c);for(let l=1,m=0,B=0;B=u&&(l=++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 l=new this(i);for(let m=1,B=0,U=0;U=i&&(m=++B+1);return l}}xe.prototype.klassSubType="DistanceMatrix";class ke extends Wt{constructor(u,c,i){super(),this.matrix=u,this.rows=c,this.columns=i}}class vn extends ke{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 Mn extends ke{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 In extends ke{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 nn extends ke{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 Sn extends ke{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 Pn extends ke{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 mn extends ke{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 Bn extends ke{constructor(u,c,i,l,m){Ht(u,c,i,l,m),super(u,i-c+1,m-l+1),this.startRow=c,this.startColumn=l}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 Be extends ke{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 ze 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 l=this._calculateIndex(u,c);return this.data[l]=i,this}get(u,c){let i=this._calculateIndex(u,c);return this.data[i]}_calculateIndex(u,c){return u*this.columns+c}}class Ae 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 fr(T,u){if(ot.isAnyArray(T))return T[0]&&ot.isAnyArray(T[0])?new Ae(T):new ze(T,u);throw new Error("the argument is not an array")}class _t{constructor(u){u=Ae.checkMatrix(u);let c=u.clone(),i=c.rows,l=c.columns,m=new Float64Array(i),B=1,U,V,G,rt,K,lt,Tt,ct,pt;for(U=0;UMath.abs(ct[rt])&&(rt=U);if(rt!==V){for(G=0;G=0;G--){for(V=0;VB?l.set(m,B,u.get(m,B)):m===B?l.set(m,B,1):l.set(m,B,0);return l}get upperTriangularMatrix(){let u=this.LU,c=u.rows,i=u.columns,l=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 Un{constructor(u){u=Ae.checkMatrix(u);let c=u.clone(),i=u.rows,l=u.columns,m=new Float64Array(l),B,U,V,G;for(V=0;V=0;G--){for(V=0;V=0;U--){for(m=0;m=0;tt--)if(ct[tt]!==0){for(let wt=tt+1;wt=0;tt--){if(tt0;){let tt,wt;for(tt=Ut-2;tt>=-1&&tt!==-1;tt--){const Lt=Number.MIN_VALUE+ce*Math.abs(ct[tt]+Math.abs(ct[tt+1]));if(Math.abs(Z[tt])<=Lt||Number.isNaN(Z[tt])){Z[tt]=0;break}}if(tt===Ut-2)wt=4;else{let Lt;for(Lt=Ut-1;Lt>=tt&&Lt!==tt;Lt--){let Mt=(Lt!==Ut?Math.abs(Z[Lt]):0)+(Lt!==tt+1?Math.abs(Z[Lt-1]):0);if(Math.abs(ct[Lt])<=ce*Mt){ct[Lt]=0;break}}Lt===tt?wt=3:Lt===Ut-1?wt=1:(wt=2,tt=Lt)}switch(tt++,wt){case 1:{let Lt=Z[Ut-2];Z[Ut-2]=0;for(let Mt=Ut-2;Mt>=tt;Mt--){let we=rn(ct[Mt],Lt),ae=ct[Mt]/we,fe=Lt/we;if(ct[Mt]=we,Mt!==tt&&(Lt=-fe*Z[Mt-1],Z[Mt-1]=ae*Z[Mt-1]),G)for(let pe=0;pe=ct[tt+1]);){let Lt=ct[tt];if(ct[tt]=ct[tt+1],ct[tt+1]=Lt,G&&ttc&&m.set(rt,K,u.get(rt,K)/this.s[K]);let B=this.U,U=B.rows,V=B.columns,G=new It(i,U);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 lr(T,u=!1){return T=Ae.checkMatrix(T),u?new cn(T).inverse():Jn(T,It.eye(T.rows))}function Jn(T,u,c=!1){return T=Ae.checkMatrix(T),u=Ae.checkMatrix(u),c?new cn(T).solve(u):T.isSquare()?new _t(T).solve(u):new Un(T).solve(u)}function Rn(T){if(T=It.checkMatrix(T),T.isSquare()){if(T.columns===0)return 1;let u,c,i,l;if(T.columns===2)return u=T.get(0,0),c=T.get(0,1),i=T.get(1,0),l=T.get(1,1),u*l-c*i;if(T.columns===3){let m,B,U;return m=new mn(T,[1,2],[1,2]),B=new mn(T,[1,2],[0,2]),U=new mn(T,[1,2],[0,1]),u=T.get(0,0),c=T.get(0,1),i=T.get(0,2),u*Rn(m)-c*Rn(B)+i*Rn(U)}else return new _t(T).determinant}else throw Error("determinant can only be calculated for a square matrix")}function dr(T,u){let c=[];for(let i=0;il)return new Array(u.rows+1).fill(0);{let m=u.addRow(c,[0]);for(let B=0;Bu?m[B]=1/m[B]:m[B]=0;return l.mmul(It.diag(m).mmul(i.transpose()))}function Gn(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:l=!0}=c;l&&(T=T.center("column"),i||(u=u.center("column")));const m=T.transpose().mmul(u);for(let B=0;B0?l.set(m,m+1,c[m]):c[m]<0&&l.set(m,m-1,c[m])}return l}}function vr(T,u,c,i){let l,m,B,U,V,G,rt,K;for(V=0;V0;U--){for(K=0,B=0,G=0;G0&&(m=-m),u[U]=K*m,B=B-l*m,c[U-1]=l-m,V=0;VG)do{for(l=c[G],K=(c[G+1]-l)/(2*u[G]),lt=rn(K,1),K<0&&(lt=-lt),c[G]=u[G]/(K+lt),c[G+1]=u[G]*(K+lt),Tt=c[G+1],m=l-c[G],B=G+2;B=G;B--)for(Rt=pt,pt=ct,Ct=St,l=ct*u[B],m=ct*K,lt=rn(K,u[B]),u[B+1]=St*lt,St=u[B]/lt,ct=K/lt,K=ct*c[B]-St*l,c[B+1]=m+St*(ct*l+St*c[B]),V=0;Vge*Zt);c[G]=c[G]+Xt,u[G]=0}for(B=0;B=K;G--)c[G]=u.get(G,K-1)/lt,V+=c[G]*c[G];for(U=Math.sqrt(V),c[K]>0&&(U=-U),V=V-c[K]*U,c[K]=c[K]-U,rt=K;rt=K;G--)B+=c[G]*u.get(G,rt);for(B=B/V,G=K;G<=m;G++)u.set(G,rt,u.get(G,rt)-B*c[G])}for(G=0;G<=m;G++){for(B=0,rt=m;rt>=K;rt--)B+=c[rt]*u.get(G,rt);for(B=B/V,rt=K;rt<=m;rt++)u.set(G,rt,u.get(G,rt)-B*c[rt])}c[K]=lt*c[K],u.set(K,K-1,lt*U)}}for(G=0;G=l+1;K--)if(u.get(K,K-1)!==0){for(G=K+1;G<=m;G++)c[G]=u.get(G,K-1);for(rt=K;rt<=m;rt++){for(U=0,G=K;G<=m;G++)U+=c[G]*i.get(G,rt);for(U=U/c[K]/u.get(K,K-1),G=K;G<=m;G++)i.set(G,rt,i.get(G,rt)+U*c[G])}}}function yr(T,u,c,i,l){let m=T-1,B=0,U=T-1,V=Number.EPSILON,G=0,rt=0,K=0,lt=0,Tt=0,ct=0,pt=0,Rt=0,Z,St,Ct,Xt,Zt,ge,Ut,Yt,ce,tt,wt,Lt,Mt,we,ae;for(Z=0;ZU)&&(c[Z]=l.get(Z,Z),u[Z]=0),St=Math.max(Z-1,0);St=B;){for(Xt=m;Xt>B&&(ct=Math.abs(l.get(Xt-1,Xt-1))+Math.abs(l.get(Xt,Xt)),ct===0&&(ct=rt),!(Math.abs(l.get(Xt,Xt-1))=0){for(pt=K>=0?K+pt:K-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=l.get(m,m-1),ct=Math.abs(Yt)+Math.abs(pt),K=Yt/ct,lt=pt/ct,Tt=Math.sqrt(K*K+lt*lt),K=K/Tt,lt=lt/Tt,St=m-1;St0)){for(ct=Math.sqrt(ct),ce=Xt&&(pt=l.get(Zt,Zt),Tt=Yt-pt,ct=ce-pt,K=(Tt*ct-Ut)/l.get(Zt+1,Zt)+l.get(Zt,Zt+1),lt=l.get(Zt+1,Zt+1)-pt-Tt-ct,Tt=l.get(Zt+2,Zt+1),ct=Math.abs(K)+Math.abs(lt)+Math.abs(Tt),K=K/ct,lt=lt/ct,Tt=Tt/ct,!(Zt===Xt||Math.abs(l.get(Zt,Zt-1))*(Math.abs(lt)+Math.abs(Tt))Zt+2&&l.set(Z,Z-3,0);for(Ct=Zt;Ct<=m-1&&(we=Ct!==m-1,Ct!==Zt&&(K=l.get(Ct,Ct-1),lt=l.get(Ct+1,Ct-1),Tt=we?l.get(Ct+2,Ct-1):0,Yt=Math.abs(K)+Math.abs(lt)+Math.abs(Tt),Yt!==0&&(K=K/Yt,lt=lt/Yt,Tt=Tt/Yt)),Yt!==0);Ct++)if(ct=Math.sqrt(K*K+lt*lt+Tt*Tt),K<0&&(ct=-ct),ct!==0){for(Ct!==Zt?l.set(Ct,Ct-1,-ct*Yt):Xt!==Zt&&l.set(Ct,Ct-1,-l.get(Ct,Ct-1)),K=K+ct,Yt=K/ct,ce=lt/ct,pt=Tt/ct,lt=lt/K,Tt=Tt/K,St=Ct;St=0;m--)if(K=c[m],lt=u[m],lt===0)for(Xt=m,l.set(m,m,1),Z=m-1;Z>=0;Z--){for(Ut=l.get(Z,Z)-K,Tt=0,St=Xt;St<=m;St++)Tt=Tt+l.get(Z,St)*l.get(St,m);if(u[Z]<0)pt=Ut,ct=Tt;else if(Xt=Z,u[Z]===0?l.set(Z,m,Ut!==0?-Tt/Ut:-Tt/(V*rt)):(Yt=l.get(Z,Z+1),ce=l.get(Z+1,Z),lt=(c[Z]-K)*(c[Z]-K)+u[Z]*u[Z],ge=(Yt*ct-pt*Tt)/lt,l.set(Z,m,ge),l.set(Z+1,m,Math.abs(Yt)>Math.abs(pt)?(-Tt-Ut*ge)/Yt:(-ct-ce*ge)/pt)),ge=Math.abs(l.get(Z,m)),V*ge*ge>1)for(St=Z;St<=m;St++)l.set(St,m,l.get(St,m)/ge)}else if(lt<0)for(Xt=m-1,Math.abs(l.get(m,m-1))>Math.abs(l.get(m-1,m))?(l.set(m-1,m-1,lt/l.get(m,m-1)),l.set(m-1,m,-(l.get(m,m)-K)/l.get(m,m-1))):(ae=On(0,-l.get(m-1,m),l.get(m-1,m-1)-K,lt),l.set(m-1,m-1,ae[0]),l.set(m-1,m,ae[1])),l.set(m,m-1,0),l.set(m,m,1),Z=m-2;Z>=0;Z--){for(tt=0,wt=0,St=Xt;St<=m;St++)tt=tt+l.get(Z,St)*l.get(St,m-1),wt=wt+l.get(Z,St)*l.get(St,m);if(Ut=l.get(Z,Z)-K,u[Z]<0)pt=Ut,Tt=tt,ct=wt;else if(Xt=Z,u[Z]===0?(ae=On(-tt,-wt,Ut,lt),l.set(Z,m-1,ae[0]),l.set(Z,m,ae[1])):(Yt=l.get(Z,Z+1),ce=l.get(Z+1,Z),Lt=(c[Z]-K)*(c[Z]-K)+u[Z]*u[Z]-lt*lt,Mt=(c[Z]-K)*2*lt,Lt===0&&Mt===0&&(Lt=V*rt*(Math.abs(Ut)+Math.abs(lt)+Math.abs(Yt)+Math.abs(ce)+Math.abs(pt))),ae=On(Yt*Tt-pt*tt+lt*wt,Yt*ct-pt*wt-lt*tt,Lt,Mt),l.set(Z,m-1,ae[0]),l.set(Z,m,ae[1]),Math.abs(Yt)>Math.abs(pt)+Math.abs(lt)?(l.set(Z+1,m-1,(-tt-Ut*l.get(Z,m-1)+lt*l.get(Z,m))/Yt),l.set(Z+1,m,(-wt-Ut*l.get(Z,m)-lt*l.get(Z,m-1))/Yt)):(ae=On(-Tt-ce*l.get(Z,m-1),-ct-ce*l.get(Z,m),pt,lt),l.set(Z+1,m-1,ae[0]),l.set(Z+1,m,ae[1]))),ge=Math.max(Math.abs(l.get(Z,m-1)),Math.abs(l.get(Z,m))),V*ge*ge>1)for(St=Z;St<=m;St++)l.set(St,m-1,l.get(St,m-1)/ge),l.set(St,m,l.get(St,m)/ge)}for(Z=0;ZU)for(St=Z;St=B;St--)for(Z=B;Z<=U;Z++){for(pt=0,Ct=B;Ct<=Math.min(St,U);Ct++)pt=pt+i.get(Z,Ct)*l.get(Ct,St);i.set(Z,St,pt)}}}function On(T,u,c,i){let l,m;return Math.abs(c)>Math.abs(i)?(l=i/c,m=c+l*i,[(T+l*u)/m,(u-l*T)/m]):(l=c/i,m=i+l*c,[(l*T+u)/m,(l*u-T)/m])}class Wn{constructor(u){if(u=Ae.checkMatrix(u),!u.isSymmetric())throw new Error("Matrix is not symmetric");let c=u,i=c.rows,l=new It(i,i),m=!0,B,U,V;for(U=0;U0),l.set(U,U,Math.sqrt(Math.max(G,0))),V=U+1;V=0;V--)for(U=0;UB;Tt++)K=u.transpose().mmul(U).div(U.transpose().mmul(U).get(0,0)),K=K.div(K.norm()),G=u.mmul(K).div(K.transpose().mmul(K).get(0,0)),Tt>0&&(V=G.clone().sub(lt).pow(2).sum()),lt=G.clone(),i?(rt=i.transpose().mmul(G).div(G.transpose().mmul(G).get(0,0)),rt=rt.div(rt.norm()),U=i.mmul(rt).div(rt.transpose().mmul(rt).get(0,0))):U=G;if(i){let Tt=u.transpose().mmul(G).div(G.transpose().mmul(G).get(0,0));Tt=Tt.div(Tt.norm());let ct=u.clone().sub(G.clone().mmul(Tt.transpose())),pt=U.transpose().mmul(G).div(G.transpose().mmul(G).get(0,0)),Rt=i.clone().sub(G.clone().mulS(pt.get(0,0)).mmul(rt.transpose()));this.t=G,this.p=Tt.transpose(),this.w=K.transpose(),this.q=rt,this.u=U,this.s=G.transpose().mmul(G),this.xResidual=ct,this.yResidual=Rt,this.betas=pt}else this.w=K.transpose(),this.s=G.transpose().mmul(G).sqrt(),l?this.t=G.clone().div(this.s.get(0,0)):this.t=G,this.xResidual=u.sub(G.mmul(K.transpose()))}}P.XA=Wt,P.a_=Wn,P.yQ=Wn,P.Hs=xe,P.Ec=Qn,P.dx=Qn,P.LU=_t,P.Rm=_t,P.y3=It,P.qK=Mn,P.pb=vn,P.j=In,P.sO=nn,P.BZ=Pn,P.EK=Sn,P.Db=mn,P.Fx=Bn,P.tU=Be,P.Ym=wr,P.rs=wr,P.QR=Un,P.TB=Un,P.oH=cn,P.Sc=cn,P.BN=Pe,P.it=ze,P.$r=Ae,P.QM=pr,P.AV=Gn,f=It,P.GH=Rn,P.SO=lr,P.uZ=Vn,P.yU=gr,P.F1=Jn,P.re=fr},92546:function(w,P,a){w.exports={graphlib:a(76626),layout:a(47194),debug:a(11303),util:{time:a(53063).time,notime:a(53063).notime},version:a(11897)}},81255:function(w,P,a){"use strict";var f=a(72361),x=a(39240);w.exports={run:E,undo:v};function E(N){var S=N.graph().acyclicer==="greedy"?x(N,M(N)):b(N);f.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,f.uniqueId("rev"))});function M(A){return function(I){return A.edge(I).weight}}}function b(N){var S=[],M={},A={};function I(j){f.has(A,j)||(A[j]=!0,M[j]=!0,f.forEach(N.outEdges(j),function(D){f.has(M,D.w)?S.push(D):I(D.w)}),delete M[j])}return f.forEach(N.nodes(),I),S}function v(N){f.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)}})}},60765:function(w,P,a){var f=a(72361),x=a(53063);w.exports=E;function E(v){function N(S){var M=v.children(S),A=v.node(S);if(M.length&&f.forEach(M,N),f.has(A,"minRank")){A.borderLeft=[],A.borderRight=[];for(var I=A.minRank,j=A.maxRank+1;I0;--Q)if(nt=j[Q].dequeue(),nt){Y=Y.concat(S(I,j,D,nt,!0));break}}}return Y}function S(I,j,D,Y,_){var ot=_?[]:void 0;return f.forEach(I.inEdges(Y.v),function(nt){var Q=I.edge(nt),et=I.node(nt.v);_&&ot.push({v:nt.v,w:nt.w}),et.out-=Q,A(j,D,et)}),f.forEach(I.outEdges(Y.v),function(nt){var Q=I.edge(nt),et=nt.w,H=I.node(et);H.in-=Q,A(j,D,H)}),I.removeNode(Y.v),ot}function M(I,j){var D=new x,Y=0,_=0;f.forEach(I.nodes(),function(Q){D.setNode(Q,{v:Q,in:0,out:0})}),f.forEach(I.edges(),function(Q){var et=D.edge(Q.v,Q.w)||0,H=j(Q),it=et+H;D.setEdge(Q.v,Q.w,it),_=Math.max(_,D.node(Q.v).out+=H),Y=Math.max(Y,D.node(Q.w).in+=H)});var ot=f.range(_+Y+3).map(function(){return new E}),nt=Y+1;return f.forEach(D.nodes(),function(Q){A(ot,nt,D.node(Q))}),{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)}},47194:function(w,P,a){"use strict";var f=a(72361),x=a(81255),E=a(27163),b=a(64505),v=a(53063).normalizeRanks,N=a(71970),S=a(53063).removeEmptyRanks,M=a(31733),A=a(60765),I=a(13257),j=a(62852),D=a(93021),Y=a(53063),_=a(76626).Graph;w.exports=ot;function ot(gt,vt){var At=vt&&vt.debugTiming?Y.time:Y.notime;At("layout",function(){var Ft=At(" buildLayoutGraph",function(){return yt(gt)});At(" runLayout",function(){nt(Ft,At)}),At(" updateInputGraph",function(){Q(gt,Ft)})})}function nt(gt,vt){vt(" makeSpaceForEdgeLabels",function(){Nt(gt)}),vt(" removeSelfEdges",function(){bn(gt)}),vt(" acyclic",function(){x.run(gt)}),vt(" nestingGraph.run",function(){M.run(gt)}),vt(" rank",function(){b(Y.asNonCompoundGraph(gt))}),vt(" injectEdgeLabelProxies",function(){Ot(gt)}),vt(" removeEmptyRanks",function(){S(gt)}),vt(" nestingGraph.cleanup",function(){M.cleanup(gt)}),vt(" normalizeRanks",function(){v(gt)}),vt(" assignRankMinMax",function(){kt(gt)}),vt(" removeEdgeLabelProxies",function(){Vt(gt)}),vt(" normalize.run",function(){E.run(gt)}),vt(" parentDummyChains",function(){N(gt)}),vt(" addBorderSegments",function(){A(gt)}),vt(" order",function(){j(gt)}),vt(" insertSelfEdges",function(){Nn(gt)}),vt(" adjustCoordinateSystem",function(){I.adjust(gt)}),vt(" position",function(){D(gt)}),vt(" positionSelfEdges",function(){an(gt)}),vt(" removeBorderNodes",function(){tn(gt)}),vt(" normalize.undo",function(){E.undo(gt)}),vt(" fixupEdgeLabelCoords",function(){ye(gt)}),vt(" undoCoordinateSystem",function(){I.undo(gt)}),vt(" translateGraph",function(){Ht(gt)}),vt(" assignNodeIntersects",function(){ee(gt)}),vt(" reversePoints",function(){Ye(gt)}),vt(" acyclic.undo",function(){x.undo(gt)})}function Q(gt,vt){f.forEach(gt.nodes(),function(At){var Ft=gt.node(At),qt=vt.node(At);Ft&&(Ft.x=qt.x,Ft.y=qt.y,vt.children(At).length&&(Ft.width=qt.width,Ft.height=qt.height))}),f.forEach(gt.edges(),function(At){var Ft=gt.edge(At),qt=vt.edge(At);Ft.points=qt.points,f.has(qt,"x")&&(Ft.x=qt.x,Ft.y=qt.y)}),gt.graph().width=vt.graph().width,gt.graph().height=vt.graph().height}var et=["nodesep","edgesep","ranksep","marginx","marginy"],H={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 vt=new _({multigraph:!0,compound:!0}),At=sn(gt.graph());return vt.setGraph(f.merge({},H,Ze(At,et),f.pick(At,it))),f.forEach(gt.nodes(),function(Ft){var qt=sn(gt.node(Ft));vt.setNode(Ft,f.defaults(Ze(qt,at),ft)),vt.setParent(Ft,gt.parent(Ft))}),f.forEach(gt.edges(),function(Ft){var qt=sn(gt.edge(Ft));vt.setEdge(Ft,f.merge({},dt,Ze(qt,ht),f.pick(qt,xt)))}),vt}function Nt(gt){var vt=gt.graph();vt.ranksep/=2,f.forEach(gt.edges(),function(At){var Ft=gt.edge(At);Ft.minlen*=2,Ft.labelpos.toLowerCase()!=="c"&&(vt.rankdir==="TB"||vt.rankdir==="BT"?Ft.width+=Ft.labeloffset:Ft.height+=Ft.labeloffset)})}function Ot(gt){f.forEach(gt.edges(),function(vt){var At=gt.edge(vt);if(At.width&&At.height){var Ft=gt.node(vt.v),qt=gt.node(vt.w),ue={rank:(qt.rank-Ft.rank)/2+Ft.rank,e:vt};Y.addDummyNode(gt,"edge-proxy",ue,"_ep")}})}function kt(gt){var vt=0;f.forEach(gt.nodes(),function(At){var Ft=gt.node(At);Ft.borderTop&&(Ft.minRank=gt.node(Ft.borderTop).rank,Ft.maxRank=gt.node(Ft.borderBottom).rank,vt=f.max(vt,Ft.maxRank))}),gt.graph().maxRank=vt}function Vt(gt){f.forEach(gt.nodes(),function(vt){var At=gt.node(vt);At.dummy==="edge-proxy"&&(gt.edge(At.e).labelRank=At.rank,gt.removeNode(vt))})}function Ht(gt){var vt=Number.POSITIVE_INFINITY,At=0,Ft=Number.POSITIVE_INFINITY,qt=0,ue=gt.graph(),he=ue.marginx||0,Ie=ue.marginy||0;function pn(De){var Me=De.x,se=De.y,Wt=De.width,re=De.height;vt=Math.min(vt,Me-Wt/2),At=Math.max(At,Me+Wt/2),Ft=Math.min(Ft,se-re/2),qt=Math.max(qt,se+re/2)}f.forEach(gt.nodes(),function(De){pn(gt.node(De))}),f.forEach(gt.edges(),function(De){var Me=gt.edge(De);f.has(Me,"x")&&pn(Me)}),vt-=he,Ft-=Ie,f.forEach(gt.nodes(),function(De){var Me=gt.node(De);Me.x-=vt,Me.y-=Ft}),f.forEach(gt.edges(),function(De){var Me=gt.edge(De);f.forEach(Me.points,function(se){se.x-=vt,se.y-=Ft}),f.has(Me,"x")&&(Me.x-=vt),f.has(Me,"y")&&(Me.y-=Ft)}),ue.width=At-vt+he,ue.height=qt-Ft+Ie}function ee(gt){f.forEach(gt.edges(),function(vt){var At=gt.edge(vt),Ft=gt.node(vt.v),qt=gt.node(vt.w),ue,he;At.points?(ue=At.points[0],he=At.points[At.points.length-1]):(At.points=[],ue=qt,he=Ft),At.points.unshift(Y.intersectRect(Ft,ue)),At.points.push(Y.intersectRect(qt,he))})}function ye(gt){f.forEach(gt.edges(),function(vt){var At=gt.edge(vt);if(f.has(At,"x"))switch((At.labelpos==="l"||At.labelpos==="r")&&(At.width-=At.labeloffset),At.labelpos){case"l":At.x-=At.width/2+At.labeloffset;break;case"r":At.x+=At.width/2+At.labeloffset;break}})}function Ye(gt){f.forEach(gt.edges(),function(vt){var At=gt.edge(vt);At.reversed&&At.points.reverse()})}function tn(gt){f.forEach(gt.nodes(),function(vt){if(gt.children(vt).length){var At=gt.node(vt),Ft=gt.node(At.borderTop),qt=gt.node(At.borderBottom),ue=gt.node(f.last(At.borderLeft)),he=gt.node(f.last(At.borderRight));At.width=Math.abs(he.x-ue.x),At.height=Math.abs(qt.y-Ft.y),At.x=ue.x+At.width/2,At.y=Ft.y+At.height/2}}),f.forEach(gt.nodes(),function(vt){gt.node(vt).dummy==="border"&>.removeNode(vt)})}function bn(gt){f.forEach(gt.edges(),function(vt){if(vt.v===vt.w){var At=gt.node(vt.v);At.selfEdges||(At.selfEdges=[]),At.selfEdges.push({e:vt,label:gt.edge(vt)}),gt.removeEdge(vt)}})}function Nn(gt){var vt=Y.buildLayerMatrix(gt);f.forEach(vt,function(At){var Ft=0;f.forEach(At,function(qt,ue){var he=gt.node(qt);he.order=ue+Ft,f.forEach(he.selfEdges,function(Ie){Y.addDummyNode(gt,"selfedge",{width:Ie.label.width,height:Ie.label.height,rank:he.rank,order:ue+ ++Ft,e:Ie.e,label:Ie.label},"_se")}),delete he.selfEdges})})}function an(gt){f.forEach(gt.nodes(),function(vt){var At=gt.node(vt);if(At.dummy==="selfedge"){var Ft=gt.node(At.e.v),qt=Ft.x+Ft.width/2,ue=Ft.y,he=At.x-qt,Ie=Ft.height/2;gt.setEdge(At.e,At.label),gt.removeNode(vt),At.label.points=[{x:qt+2*he/3,y:ue-Ie},{x:qt+5*he/6,y:ue-Ie},{x:qt+he,y:ue},{x:qt+5*he/6,y:ue+Ie},{x:qt+2*he/3,y:ue+Ie}],At.label.x=At.x,At.label.y=At.y}})}function Ze(gt,vt){return f.mapValues(f.pick(gt,vt),Number)}function sn(gt){var vt={};return f.forEach(gt,function(At,Ft){vt[Ft.toLowerCase()]=At}),vt}},72361:function(w,P,a){var f;try{f={cloneDeep:a(44187),constant:a(46221),defaults:a(34981),each:a(61475),filter:a(3130),find:a(48835),flatten:a(1332),forEach:a(47177),forIn:a(59946),has:a(64760),isUndefined:a(68408),last:a(47522),map:a(81426),mapValues:a(60032),max:a(18038),merge:a(55056),min:a(60169),minBy:a(13604),now:a(76308),pick:a(72333),range:a(69235),reduce:a(9695),sortBy:a(35020),uniqueId:a(69624),values:a(72834),zipObject:a(79261)}}catch(x){}f||(f=window._),w.exports=f},31733:function(w,P,a){var f=a(72361),x=a(53063);w.exports={run:E,cleanup:S};function E(M){var A=x.addDummyNode(M,"root",{},"_root"),I=v(M),j=f.max(f.values(I))-1,D=2*j+1;M.graph().nestingRoot=A,f.forEach(M.edges(),function(_){M.edge(_).minlen*=D});var Y=N(M)+1;f.forEach(M.children(),function(_){b(M,A,D,Y,j,I,_)}),M.graph().nodeRankFactor=D}function b(M,A,I,j,D,Y,_){var ot=M.children(_);if(!ot.length){_!==A&&M.setEdge(A,_,{weight:0,minlen:I});return}var nt=x.addBorderNode(M,"_bt"),Q=x.addBorderNode(M,"_bb"),et=M.node(_);M.setParent(nt,_),et.borderTop=nt,M.setParent(Q,_),et.borderBottom=Q,f.forEach(ot,function(H){b(M,A,I,j,D,Y,H);var it=M.node(H),at=it.borderTop?it.borderTop:H,ft=it.borderBottom?it.borderBottom:H,ht=it.borderTop?j:2*j,dt=at!==ft?1:D-Y[_]+1;M.setEdge(nt,at,{weight:ht,minlen:dt,nestingEdge:!0}),M.setEdge(ft,Q,{weight:ht,minlen:dt,nestingEdge:!0})}),M.parent(_)||M.setEdge(A,nt,{weight:0,minlen:D+Y[_]})}function v(M){var A={};function I(j,D){var Y=M.children(j);Y&&Y.length&&f.forEach(Y,function(_){I(_,D+1)}),A[j]=D}return f.forEach(M.children(),function(j){I(j,1)}),A}function N(M){return f.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,f.forEach(M.edges(),function(I){var j=M.edge(I);j.nestingEdge&&M.removeEdge(I)})}},27163:function(w,P,a){"use strict";var f=a(72361),x=a(53063);w.exports={run:E,undo:v};function E(N){N.graph().dummyChains=[],f.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,Y=N.edge(S),_=Y.labelRank;if(j!==A+1){N.removeEdge(S);var ot,nt,Q;for(Q=0,++A;A0;)_%2&&(ot+=j[_+1]),_=_-1>>1,j[_]+=Y.weight;D+=Y.weight*ot})),D}},62852:function(w,P,a){"use strict";var f=a(72361),x=a(18043),E=a(45456),b=a(86490),v=a(59105),N=a(52205),S=a(76626).Graph,M=a(53063);w.exports=A;function A(Y){var _=M.maxRank(Y),ot=I(Y,f.range(1,_+1),"inEdges"),nt=I(Y,f.range(_-1,-1,-1),"outEdges"),Q=x(Y);D(Y,Q);for(var et=Number.POSITIVE_INFINITY,H,it=0,at=0;at<4;++it,++at){j(it%2?ot:nt,it%4>=2),Q=M.buildLayerMatrix(Y);var ft=E(Y,Q);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),f.forEach(A.in.reverse(),S(A)),f.forEach(A.out,M(A))}return f.map(f.filter(N,function(I){return!I.merged}),function(I){return f.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}},86490:function(w,P,a){var f=a(72361),x=a(99506),E=a(45926),b=a(1349);w.exports=v;function v(M,A,I,j){var D=M.children(A),Y=M.node(A),_=Y?Y.borderLeft:void 0,ot=Y?Y.borderRight:void 0,nt={};_&&(D=f.filter(D,function(ft){return ft!==_&&ft!==ot}));var Q=x(M,D);f.forEach(Q,function(ft){if(M.children(ft.v).length){var ht=v(M,ft.v,I,j);nt[ft.v]=ht,f.has(ht,"barycenter")&&S(ft,ht)}});var et=E(Q,I);N(et,nt);var H=b(et,j);if(_&&(H.vs=f.flatten([_,H.vs,ot],!0),M.predecessors(_).length)){var it=M.node(M.predecessors(_)[0]),at=M.node(M.predecessors(ot)[0]);f.has(H,"barycenter")||(H.barycenter=0,H.weight=0),H.barycenter=(H.barycenter*H.weight+it.order+at.order)/(H.weight+2),H.weight+=2}return H}function N(M,A){f.forEach(M,function(I){I.vs=f.flatten(I.vs.map(function(j){return A[j]?A[j].vs:j}),!0)})}function S(M,A){f.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)}},1349:function(w,P,a){var f=a(72361),x=a(53063);w.exports=E;function E(N,S){var M=x.partition(N,function(nt){return f.has(nt,"barycenter")}),A=M.lhs,I=f.sortBy(M.rhs,function(nt){return-nt.i}),j=[],D=0,Y=0,_=0;A.sort(v(!!S)),_=b(j,I,_),f.forEach(A,function(nt){_+=nt.vs.length,j.push(nt.vs),D+=nt.barycenter*nt.weight,Y+=nt.weight,_=b(j,I,_)});var ot={vs:f.flatten(j,!0)};return Y&&(ot.barycenter=D/Y,ot.weight=Y),ot}function b(N,S,M){for(var A;S.length&&(A=f.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}}},71970:function(w,P,a){var f=a(72361);w.exports=x;function x(v){var N=b(v);f.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,Y=0,_=j[Y],ot=!0;S!==A.w;){if(M=v.node(S),ot){for(;(_=j[Y])!==D&&v.node(_).maxRankj||D>N[Y].lim));for(_=Y,Y=M;(Y=v.parent(Y))!==_;)I.push(Y);return{path:A.concat(I.reverse()),lca:_}}function b(v){var N={},S=0;function M(A){var I=S;f.forEach(v.children(A),M),N[A]={low:I,lim:S++}}return f.forEach(v.children(),M),N}},92080:function(w,P,a){"use strict";var f=a(72361),x=a(76626).Graph,E=a(53063);w.exports={positionX:ot,findType1Conflicts:b,findType2Conflicts:v,addConflict:S,hasConflict:M,verticalAlignment:A,horizontalCompaction:I,alignCoordinates:Y,findSmallestWidthAlignment:D,balance:_};function b(et,H){var it={};function at(ft,ht){var dt=0,xt=0,yt=ft.length,Nt=f.last(ht);return f.forEach(ht,function(Ot,kt){var Vt=N(et,Ot),Ht=Vt?et.node(Vt).order:yt;(Vt||Ot===Nt)&&(f.forEach(ht.slice(xt,kt+1),function(ee){f.forEach(et.predecessors(ee),function(ye){var Ye=et.node(ye),tn=Ye.order;(tnNt)&&S(it,Vt,Ot)})})}function ft(ht,dt){var xt=-1,yt,Nt=0;return f.forEach(dt,function(Ot,kt){if(et.node(Ot).dummy==="border"){var Vt=et.predecessors(Ot);Vt.length&&(yt=et.node(Vt[0]).order,at(dt,Nt,kt,xt,yt),Nt=kt,xt=yt)}at(dt,Nt,dt.length,yt,ht.length)}),dt}return f.reduce(H,ft),it}function N(et,H){if(et.node(H).dummy)return f.find(et.predecessors(H),function(it){return et.node(it).dummy})}function S(et,H,it){if(H>it){var at=H;H=it,it=at}var ft=et[H];ft||(et[H]=ft={}),ft[it]=!0}function M(et,H,it){if(H>it){var at=H;H=it,it=at}return f.has(et[H],it)}function A(et,H,it,at){var ft={},ht={},dt={};return f.forEach(H,function(xt){f.forEach(xt,function(yt,Nt){ft[yt]=yt,ht[yt]=yt,dt[yt]=Nt})}),f.forEach(H,function(xt){var yt=-1;f.forEach(xt,function(Nt){var Ot=at(Nt);if(Ot.length){Ot=f.sortBy(Ot,function(ye){return dt[ye]});for(var kt=(Ot.length-1)/2,Vt=Math.floor(kt),Ht=Math.ceil(kt);Vt<=Ht;++Vt){var ee=Ot[Vt];ht[Nt]===Nt&&ytyt.lim&&(Nt=yt,Ot=!0);var kt=f.filter(at.edges(),function(Vt){return Ot===H(it,it.node(Vt.v),Nt)&&Ot!==H(it,it.node(Vt.w),Nt)});return f.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),Q(it,at)}function Q(it,at){var ft=f.find(it.nodes(),function(dt){return!at.node(dt).parent}),ht=v(it,ft);ht=ht.slice(1),f.forEach(ht,function(dt){var xt=it.node(dt).parent,yt=at.edge(dt,xt),Nt=!1;yt||(yt=at.edge(xt,dt),Nt=!0),at.node(dt).rank=at.node(xt).rank+(Nt?yt.minlen:-yt.minlen)})}function et(it,at,ft){return it.hasEdge(at,ft)}function H(it,at,ft){return ft.low<=at.lim&&at.lim<=ft.lim}},2416:function(w,P,a){"use strict";var f=a(72361);w.exports={longestPath:x,slack:E};function x(b){var v={};function N(S){var M=b.node(S);if(f.has(v,S))return M.rank;v[S]=!0;var A=f.min(f.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}f.forEach(b.sources(),N)}function E(b,v){return b.node(v.w).rank-b.node(v.v).rank-b.edge(v).minlen}},53063:function(w,P,a){"use strict";var f=a(72361),x=a(76626).Graph;w.exports={addDummyNode:E,simplify:b,asNonCompoundGraph:v,successorWeights:N,predecessorWeights:S,intersectRect:M,buildLayerMatrix:A,normalizeRanks:I,removeEmptyRanks:j,addBorderNode:D,maxRank:Y,partition:_,time:ot,notime:nt};function E(Q,et,H,it){var at;do at=f.uniqueId(it);while(Q.hasNode(at));return H.dummy=et,Q.setNode(at,H),at}function b(Q){var et=new x().setGraph(Q.graph());return f.forEach(Q.nodes(),function(H){et.setNode(H,Q.node(H))}),f.forEach(Q.edges(),function(H){var it=et.edge(H.v,H.w)||{weight:0,minlen:1},at=Q.edge(H);et.setEdge(H.v,H.w,{weight:it.weight+at.weight,minlen:Math.max(it.minlen,at.minlen)})}),et}function v(Q){var et=new x({multigraph:Q.isMultigraph()}).setGraph(Q.graph());return f.forEach(Q.nodes(),function(H){Q.children(H).length||et.setNode(H,Q.node(H))}),f.forEach(Q.edges(),function(H){et.setEdge(H,Q.edge(H))}),et}function N(Q){var et=f.map(Q.nodes(),function(H){var it={};return f.forEach(Q.outEdges(H),function(at){it[at.w]=(it[at.w]||0)+Q.edge(at).weight}),it});return f.zipObject(Q.nodes(),et)}function S(Q){var et=f.map(Q.nodes(),function(H){var it={};return f.forEach(Q.inEdges(H),function(at){it[at.v]=(it[at.v]||0)+Q.edge(at).weight}),it});return f.zipObject(Q.nodes(),et)}function M(Q,et){var H=Q.x,it=Q.y,at=et.x-H,ft=et.y-it,ht=Q.width/2,dt=Q.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:H+xt,y:it+yt}}function A(Q){var et=f.map(f.range(Y(Q)+1),function(){return[]});return f.forEach(Q.nodes(),function(H){var it=Q.node(H),at=it.rank;f.isUndefined(at)||(et[at][it.order]=H)}),et}function I(Q){var et=f.min(f.map(Q.nodes(),function(H){return Q.node(H).rank}));f.forEach(Q.nodes(),function(H){var it=Q.node(H);f.has(it,"rank")&&(it.rank-=et)})}function j(Q){var et=f.min(f.map(Q.nodes(),function(ft){return Q.node(ft).rank})),H=[];f.forEach(Q.nodes(),function(ft){var ht=Q.node(ft).rank-et;H[ht]||(H[ht]=[]),H[ht].push(ft)});var it=0,at=Q.graph().nodeRankFactor;f.forEach(H,function(ft,ht){f.isUndefined(ft)&&ht%at!==0?--it:it&&f.forEach(ft,function(dt){Q.node(dt).rank+=it})})}function D(Q,et,H,it){var at={width:0,height:0};return arguments.length>=4&&(at.rank=H,at.order=it),E(Q,"border",at,et)}function Y(Q){return f.max(f.map(Q.nodes(),function(et){var H=Q.node(et).rank;if(!f.isUndefined(H))return H}))}function _(Q,et){var H={lhs:[],rhs:[]};return f.forEach(Q,function(it){et(it)?H.lhs.push(it):H.rhs.push(it)}),H}function ot(Q,et){var H=f.now();try{return et()}finally{console.log(Q+" time: "+(f.now()-H)+"ms")}}function nt(Q,et){return et()}},11897:function(w){w.exports="0.8.5"},75172:function(w,P,a){var f=a(89224);w.exports={Graph:f.Graph,json:a(17401),alg:a(54613),version:f.version}},91606:function(w,P,a){var f=a(95329);w.exports=x;function x(E){var b={},v=[],N;function S(M){f.has(b,M)||(b[M]=!0,N.push(M),f.each(E.successors(M),S),f.each(E.predecessors(M),S))}return f.each(E.nodes(),function(M){N=[],S(M),N.length&&v.push(N)}),v}},21482:function(w,P,a){var f=a(95329);w.exports=x;function x(b,v,N){f.isArray(v)||(v=[v]);var S=(b.isDirected()?b.successors:b.neighbors).bind(b),M=[],A={};return f.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){f.has(S,v)||(S[v]=!0,N||A.push(v),f.each(M(v),function(I){E(b,I,N,S,M,A)}),N&&A.push(v))}},40845:function(w,P,a){var f=a(13746),x=a(95329);w.exports=E;function E(b,v,N){return x.transform(b.nodes(),function(S,M){S[M]=f(b,M,v,N)},{})}},13746:function(w,P,a){var f=a(95329),x=a(36614);w.exports=b;var E=f.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,Y,_=function(ot){var nt=ot.v!==D?ot.v:ot.w,Q=I[nt],et=M(ot),H=Y.distance+et;if(et<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+ot+" Weight: "+et);H0&&(D=j.removeMin(),Y=I[D],Y.distance!==Number.POSITIVE_INFINITY);)A(D).forEach(_);return I}},59324:function(w,P,a){var f=a(95329),x=a(94558);w.exports=E;function E(b){return f.filter(x(b),function(v){return v.length>1||v.length===1&&b.hasEdge(v[0],v[0])})}},22893:function(w,P,a){var f=a(95329);w.exports=E;var x=f.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,Y=N(j);M[I][D]={distance:Y,predecessor:I}})}),A.forEach(function(I){var j=M[I];A.forEach(function(D){var Y=M[D];A.forEach(function(_){var ot=Y[I],nt=j[_],Q=Y[_],et=ot.distance+nt.distance;et0;){if(I=A.removeMin(),f.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}},94558:function(w,P,a){var f=a(95329);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(Y){f.has(N,Y)?N[Y].onStack&&(I.lowlink=Math.min(I.lowlink,N[Y].index)):(M(Y),I.lowlink=Math.min(I.lowlink,N[Y].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){f.has(N,A)||M(A)}),S}},7793:function(w,P,a){var f=a(95329);w.exports=x,x.CycleException=E;function x(b){var v={},N={},S=[];function M(A){if(f.has(N,A))throw new E;f.has(v,A)||(N[A]=!0,v[A]=!0,f.each(b.predecessors(A),M),delete N[A],S.push(A))}if(f.each(b.sinks(),M),f.size(v)!==b.nodeCount())throw new E;return S}function E(){}E.prototype=new Error},36614:function(w,P,a){var f=a(95329);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 f.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),!f.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?_.setNode(ot,D):_.setNode(ot)}),this},v.prototype.setNode=function(j,D){return f.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 f.has(this._nodes,j)},v.prototype.removeNode=function(j){var D=this;if(f.has(this._nodes,j)){var Y=function(_){D.removeEdge(D._edgeObjs[_])};delete this._nodes[j],this._isCompound&&(this._removeFromParentsChildList(j),delete this._parent[j],f.each(this.children(j),function(_){D.setParent(_)}),delete this._children[j]),f.each(f.keys(this._in[j]),Y),delete this._in[j],delete this._preds[j],f.each(f.keys(this._out[j]),Y),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(f.isUndefined(D))D=E;else{D+="";for(var Y=D;!f.isUndefined(Y);Y=this.parent(Y))if(Y===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(f.isUndefined(j)&&(j=E),this._isCompound){var D=this._children[j];if(D)return f.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 f.keys(D)},v.prototype.successors=function(j){var D=this._sucs[j];if(D)return f.keys(D)},v.prototype.neighbors=function(j){var D=this.predecessors(j);if(D)return f.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 Y=this;f.each(this._nodes,function(nt,Q){j(Q)&&D.setNode(Q,nt)}),f.each(this._edgeObjs,function(nt){D.hasNode(nt.v)&&D.hasNode(nt.w)&&D.setEdge(nt,Y.edge(nt))});var _={};function ot(nt){var Q=Y.parent(nt);return Q===void 0||D.hasNode(Q)?(_[nt]=Q,Q):Q in _?_[Q]:ot(Q)}return this._isCompound&&f.each(D.nodes(),function(nt){D.setParent(nt,ot(nt))}),D},v.prototype.setDefaultEdgeLabel=function(j){return f.isFunction(j)||(j=f.constant(j)),this._defaultEdgeLabelFn=j,this},v.prototype.edgeCount=function(){return this._edgeCount},v.prototype.edges=function(){return f.values(this._edgeObjs)},v.prototype.setPath=function(j,D){var Y=this,_=arguments;return f.reduce(j,function(ot,nt){return _.length>1?Y.setEdge(ot,nt,D):Y.setEdge(ot,nt),nt}),this},v.prototype.setEdge=function(){var j,D,Y,_,ot=!1,nt=arguments[0];typeof nt=="object"&&nt!==null&&"v"in nt?(j=nt.v,D=nt.w,Y=nt.name,arguments.length===2&&(_=arguments[1],ot=!0)):(j=nt,D=arguments[1],Y=arguments[3],arguments.length>2&&(_=arguments[2],ot=!0)),j=""+j,D=""+D,f.isUndefined(Y)||(Y=""+Y);var Q=M(this._isDirected,j,D,Y);if(f.has(this._edgeLabels,Q))return ot&&(this._edgeLabels[Q]=_),this;if(!f.isUndefined(Y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(j),this.setNode(D),this._edgeLabels[Q]=ot?_:this._defaultEdgeLabelFn(j,D,Y);var et=A(this._isDirected,j,D,Y);return j=et.v,D=et.w,Object.freeze(et),this._edgeObjs[Q]=et,N(this._preds[D],j),N(this._sucs[j],D),this._in[D][Q]=et,this._out[j][Q]=et,this._edgeCount++,this},v.prototype.edge=function(j,D,Y){var _=arguments.length===1?I(this._isDirected,arguments[0]):M(this._isDirected,j,D,Y);return this._edgeLabels[_]},v.prototype.hasEdge=function(j,D,Y){var _=arguments.length===1?I(this._isDirected,arguments[0]):M(this._isDirected,j,D,Y);return f.has(this._edgeLabels,_)},v.prototype.removeEdge=function(j,D,Y){var _=arguments.length===1?I(this._isDirected,arguments[0]):M(this._isDirected,j,D,Y),ot=this._edgeObjs[_];return ot&&(j=ot.v,D=ot.w,delete this._edgeLabels[_],delete this._edgeObjs[_],S(this._preds[D],j),S(this._sucs[j],D),delete this._in[D][_],delete this._out[j][_],this._edgeCount--),this},v.prototype.inEdges=function(j,D){var Y=this._in[j];if(Y){var _=f.values(Y);return D?f.filter(_,function(ot){return ot.v===D}):_}},v.prototype.outEdges=function(j,D){var Y=this._out[j];if(Y){var _=f.values(Y);return D?f.filter(_,function(ot){return ot.w===D}):_}},v.prototype.nodeEdges=function(j,D){var Y=this.inEdges(j,D);if(Y)return Y.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,Y,_){var ot=""+D,nt=""+Y;if(!j&&ot>nt){var Q=ot;ot=nt,nt=Q}return ot+b+nt+b+(f.isUndefined(_)?x:_)}function A(j,D,Y,_){var ot=""+D,nt=""+Y;if(!j&&ot>nt){var Q=ot;ot=nt,nt=Q}var et={v:ot,w:nt};return _&&(et.name=_),et}function I(j,D){return M(j,D.v,D.w,D.name)}},89224:function(w,P,a){w.exports={Graph:a(6349),version:a(16544)}},17401:function(w,P,a){var f=a(95329),x=a(6349);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 f.isUndefined(S.graph())||(M.value=f.clone(S.graph())),M}function b(S){return f.map(S.nodes(),function(M){var A=S.node(M),I=S.parent(M),j={v:M};return f.isUndefined(A)||(j.value=A),f.isUndefined(I)||(j.parent=I),j})}function v(S){return f.map(S.edges(),function(M){var A=S.edge(M),I={v:M.v,w:M.w};return f.isUndefined(M.name)||(I.name=M.name),f.isUndefined(A)||(I.value=A),I})}function N(S){var M=new x(S.options).setGraph(S.value);return f.each(S.nodes,function(A){M.setNode(A.v,A.value),A.parent&&M.setParent(A.v,A.parent)}),f.each(S.edges,function(A){M.setEdge({v:A.v,w:A.w,name:A.name},A.value)}),M}},95329:function(w,P,a){var f;try{f={clone:a(40633),constant:a(46221),each:a(61475),filter:a(3130),has:a(64760),isArray:a(41594),isEmpty:a(74336),isFunction:a(92581),isUndefined:a(68408),keys:a(66357),map:a(81426),reduce:a(9695),size:a(24727),transform:a(61477),union:a(99477),values:a(72834)}}catch(x){}f||(f=window._),w.exports=f},16544:function(w){w.exports="2.1.8"},34634:function(w,P,a){"use strict";a.r(P),a.d(P,{isAnyArray:function(){return x}});const f=Object.prototype.toString;function x(E){const b=f.call(E);return b.endsWith("Array]")&&!b.includes("Big")}},23346:function(w,P,a){var f=a(93454),x=a(40911),E=f(x,"DataView");w.exports=E},79955:function(w,P,a){var f=a(65812),x=a(87e3),E=a(66198),b=a(64800),v=a(8602);function N(S){var M=-1,A=S==null?0:S.length;for(this.clear();++M-1}w.exports=x},90746:function(w){function P(a,f,x){for(var E=-1,b=a==null?0:a.length;++E0&&N(j)?v>1?E(j,v-1,N,S,M):f(M,j):S||(M[M.length]=j)}return M}w.exports=E},43294:function(w,P,a){var f=a(78323),x=f();w.exports=x},23543:function(w,P,a){var f=a(43294),x=a(66357);function E(b,v){return b&&f(b,v,x)}w.exports=E},96980:function(w,P,a){var f=a(89382),x=a(90370);function E(b,v){v=f(v,b);for(var N=0,S=v.length;b!=null&&Nf}w.exports=P},11874:function(w){var P=Object.prototype,a=P.hasOwnProperty;function f(x,E){return x!=null&&a.call(x,E)}w.exports=f},4769:function(w){function P(a,f){return a!=null&&f in Object(a)}w.exports=P},17713:function(w,P,a){var f=a(33405),x=a(17406),E=a(68048);function b(v,N,S){return N===N?E(v,N,S):f(v,x,S)}w.exports=b},3841:function(w,P,a){var f=a(17325),x=a(71161),E="[object Arguments]";function b(v){return x(v)&&f(v)==E}w.exports=b},30433:function(w,P,a){var f=a(98317),x=a(71161);function E(b,v,N,S,M){return b===v?!0:b==null||v==null||!x(b)&&!x(v)?b!==b&&v!==v:f(b,v,N,S,E,M)}w.exports=E},98317:function(w,P,a){var f=a(26163),x=a(70670),E=a(23499),b=a(83544),v=a(29148),N=a(41594),S=a(33636),M=a(53745),A=1,I="[object Arguments]",j="[object Array]",D="[object Object]",Y=Object.prototype,_=Y.hasOwnProperty;function ot(nt,Q,et,H,it,at){var ft=N(nt),ht=N(Q),dt=ft?j:v(nt),xt=ht?j:v(Q);dt=dt==I?D:dt,xt=xt==I?D:xt;var yt=dt==D,Nt=xt==D,Ot=dt==xt;if(Ot&&S(nt)){if(!S(Q))return!1;ft=!0,yt=!1}if(Ot&&!yt)return at||(at=new f),ft||M(nt)?x(nt,Q,et,H,it,at):E(nt,Q,dt,et,H,it,at);if(!(et&A)){var kt=yt&&_.call(nt,"__wrapped__"),Vt=Nt&&_.call(Q,"__wrapped__");if(kt||Vt){var Ht=kt?nt.value():nt,ee=Vt?Q.value():Q;return at||(at=new f),it(Ht,ee,et,H,at)}}return Ot?(at||(at=new f),b(nt,Q,et,H,it,at)):!1}w.exports=ot},9961:function(w,P,a){var f=a(29148),x=a(71161),E="[object Map]";function b(v){return x(v)&&f(v)==E}w.exports=b},44626:function(w,P,a){var f=a(26163),x=a(30433),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 Y=M[I];if(D&&Y[2]?Y[1]!==N[Y[0]]:!(Y[0]in N))return!1}for(;++I=S){var et=I?null:v(A);if(et)return N(et);ot=!1,Y=b,Q=new f}else Q=I?[]:nt;t:for(;++D<_;){var H=A[D],it=I?I(H):H;if(H=j||H!==0?H:0,ot&&it===it){for(var at=Q.length;at--;)if(Q[at]===it)continue t;I&&Q.push(it),nt.push(H)}else Y(Q,it,j)||(Q!==nt&&Q.push(it),nt.push(H))}return nt}w.exports=M},98030:function(w,P,a){var f=a(43453);function x(E,b){return f(b,function(v){return E[v]})}w.exports=x},30232:function(w){function P(a,f,x){for(var E=-1,b=a.length,v=f.length,N={};++Eb||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},63272:function(w){function P(a,f){var x=-1,E=a.length;for(f||(f=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},6651:function(w,P,a){var f=a(91018),x=a(20688),E=a(925);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?N_))return!1;var nt=D.get(S),Q=D.get(M);if(nt&&Q)return nt==M&&Q==S;var et=-1,H=!0,it=A&v?new f:void 0;for(D.set(S,M),D.set(M,S);++et<_;){var at=S[et],ft=M[et];if(I)var ht=Y?I(ft,at,et,M,S,D):I(at,ft,et,S,M,D);if(ht!==void 0){if(ht)continue;H=!1;break}if(it){if(!x(M,function(dt,xt){if(!E(it,xt)&&(at===dt||j(at,dt,A,I,D)))return it.push(xt)})){H=!1;break}}else if(!(at===ft||j(at,ft,A,I,D))){H=!1;break}}return D.delete(S),D.delete(M),H}w.exports=N},23499:function(w,P,a){var f=a(33140),x=a(85015),E=a(83914),b=a(70670),v=a(85120),N=a(25008),S=1,M=2,A="[object Boolean]",I="[object Date]",j="[object Error]",D="[object Map]",Y="[object Number]",_="[object RegExp]",ot="[object Set]",nt="[object String]",Q="[object Symbol]",et="[object ArrayBuffer]",H="[object DataView]",it=f?f.prototype:void 0,at=it?it.valueOf:void 0;function ft(ht,dt,xt,yt,Nt,Ot,kt){switch(xt){case H:if(ht.byteLength!=dt.byteLength||ht.byteOffset!=dt.byteOffset)return!1;ht=ht.buffer,dt=dt.buffer;case et:return!(ht.byteLength!=dt.byteLength||!Ot(new x(ht),new x(dt)));case A:case I:case Y:return E(+ht,+dt);case j:return ht.name==dt.name&&ht.message==dt.message;case _:case nt:return ht==dt+"";case D:var Vt=v;case ot:var Ht=yt&S;if(Vt||(Vt=N),ht.size!=dt.size&&!Ht)return!1;var ee=kt.get(ht);if(ee)return ee==dt;yt|=M,kt.set(ht,dt);var ye=b(Vt(ht),Vt(dt),yt,Nt,Ot,kt);return kt.delete(ht),ye;case Q:if(at)return at.call(ht)==at.call(dt)}return!1}w.exports=ft},83544:function(w,P,a){var f=a(29921),x=1,E=Object.prototype,b=E.hasOwnProperty;function v(N,S,M,A,I,j){var D=M&x,Y=f(N),_=Y.length,ot=f(S),nt=ot.length;if(_!=nt&&!D)return!1;for(var Q=_;Q--;){var et=Y[Q];if(!(D?et in S:b.call(S,et)))return!1}var H=j.get(N),it=j.get(S);if(H&&it)return H==S&&it==N;var at=!0;j.set(N,S),j.set(S,N);for(var ft=D;++Q<_;){et=Y[Q];var ht=N[et],dt=S[et];if(A)var xt=D?A(dt,ht,et,S,N,j):A(ht,dt,et,N,S,j);if(!(xt===void 0?ht===dt||I(ht,dt,M,A,j):xt)){at=!1;break}ft||(ft=et=="constructor")}if(at&&!ft){var yt=N.constructor,Nt=S.constructor;yt!=Nt&&"constructor"in N&&"constructor"in S&&!(typeof yt=="function"&&yt instanceof yt&&typeof Nt=="function"&&Nt instanceof Nt)&&(at=!1)}return j.delete(N),j.delete(S),at}w.exports=v},33944:function(w,P,a){var f=a(1332),x=a(9291),E=a(48815);function b(v){return E(x(v,void 0,f),v+"")}w.exports=b},89413:function(w,P,a){var f=typeof a.g=="object"&&a.g&&a.g.Object===Object&&a.g;w.exports=f},29921:function(w,P,a){var f=a(76674),x=a(69601),E=a(66357);function b(v){return f(v,E,x)}w.exports=b},53904:function(w,P,a){var f=a(76674),x=a(72426),E=a(331);function b(v){return f(v,E,x)}w.exports=b},27856:function(w,P,a){var f=a(99595);function x(E,b){var v=E.__data__;return f(b)?v[typeof b=="string"?"string":"hash"]:v.map}w.exports=x},86162:function(w,P,a){var f=a(63286),x=a(66357);function E(b){for(var v=x(b),N=v.length;N--;){var S=v[N],M=b[S];v[N]=[S,M,f(M)]}return v}w.exports=E},93454:function(w,P,a){var f=a(64023),x=a(31094);function E(b,v){var N=x(b,v);return f(N)?N:void 0}w.exports=E},13530:function(w,P,a){var f=a(1276),x=f(Object.getPrototypeOf,Object);w.exports=x},84723:function(w,P,a){var f=a(33140),x=Object.prototype,E=x.hasOwnProperty,b=x.toString,v=f?f.toStringTag:void 0;function N(S){var M=E.call(S,v),A=S[v];try{S[v]=void 0;var I=!0}catch(D){}var j=b.call(S);return I&&(M?S[v]=A:delete S[v]),j}w.exports=N},69601:function(w,P,a){var f=a(72280),x=a(57004),E=Object.prototype,b=E.propertyIsEnumerable,v=Object.getOwnPropertySymbols,N=v?function(S){return S==null?[]:(S=Object(S),f(v(S),function(M){return b.call(S,M)}))}:x;w.exports=N},72426:function(w,P,a){var f=a(10451),x=a(13530),E=a(69601),b=a(57004),v=Object.getOwnPropertySymbols,N=v?function(S){for(var M=[];S;)f(M,E(S)),S=x(S);return M}:b;w.exports=N},29148:function(w,P,a){var f=a(23346),x=a(25281),E=a(22477),b=a(73230),v=a(89516),N=a(17325),S=a(89614),M="[object Map]",A="[object Object]",I="[object Promise]",j="[object Set]",D="[object WeakMap]",Y="[object DataView]",_=S(f),ot=S(x),nt=S(E),Q=S(b),et=S(v),H=N;(f&&H(new f(new ArrayBuffer(1)))!=Y||x&&H(new x)!=M||E&&H(E.resolve())!=I||b&&H(new b)!=j||v&&H(new v)!=D)&&(H=function(it){var at=N(it),ft=at==A?it.constructor:void 0,ht=ft?S(ft):"";if(ht)switch(ht){case _:return Y;case ot:return M;case nt:return I;case Q:return j;case et:return D}return at}),w.exports=H},31094:function(w){function P(a,f){return a==null?void 0:a[f]}w.exports=P},37073:function(w,P,a){var f=a(89382),x=a(30516),E=a(41594),b=a(65068),v=a(41199),N=a(90370);function S(M,A,I){A=f(A,M);for(var j=-1,D=A.length,Y=!1;++j-1&&x%1==0&&x-1}w.exports=x},43475:function(w,P,a){var f=a(82249);function x(E,b){var v=this.__data__,N=f(v,E);return N<0?(++this.size,v.push([E,b])):v[N][1]=b,this}w.exports=x},91642:function(w,P,a){var f=a(79955),x=a(53110),E=a(25281);function b(){this.size=0,this.__data__={hash:new f,map:new(E||x),string:new f}}w.exports=b},71646:function(w,P,a){var f=a(27856);function x(E){var b=f(this,E).delete(E);return this.size-=b?1:0,b}w.exports=x},70200:function(w,P,a){var f=a(27856);function x(E){return f(this,E).get(E)}w.exports=x},85304:function(w,P,a){var f=a(27856);function x(E){return f(this,E).has(E)}w.exports=x},57862:function(w,P,a){var f=a(27856);function x(E,b){var v=f(this,E),N=v.size;return v.set(E,b),this.size+=v.size==N?0:1,this}w.exports=x},85120:function(w){function P(a){var f=-1,x=Array(a.size);return a.forEach(function(E,b){x[++f]=[b,E]}),x}w.exports=P},47366:function(w){function P(a,f){return function(x){return x==null?!1:x[a]===f&&(f!==void 0||a in Object(x))}}w.exports=P},72902:function(w,P,a){var f=a(88530),x=500;function E(b){var v=f(b,function(S){return N.size===x&&N.clear(),S}),N=v.cache;return v}w.exports=E},60865:function(w,P,a){var f=a(93454),x=f(Object,"create");w.exports=x},90535:function(w,P,a){var f=a(1276),x=f(Object.keys,Object);w.exports=x},54229:function(w){function P(a){var f=[];if(a!=null)for(var x in Object(a))f.push(x);return f}w.exports=P},37340:function(w,P,a){w=a.nmd(w);var f=a(89413),x=P&&!P.nodeType&&P,E=x&&!0&&w&&!w.nodeType&&w,b=E&&E.exports===x,v=b&&f.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},92631:function(w){var P=Object.prototype,a=P.toString;function f(x){return a.call(x)}w.exports=f},1276:function(w){function P(a,f){return function(x){return a(f(x))}}w.exports=P},9291:function(w,P,a){var f=a(33546),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},83214:function(w,P,a){var f=a(53110);function x(){this.__data__=new f,this.size=0}w.exports=x},52806:function(w){function P(a){var f=this.__data__,x=f.delete(a);return this.size=f.size,x}w.exports=P},52032:function(w){function P(a){return this.__data__.get(a)}w.exports=P},51118:function(w){function P(a){return this.__data__.has(a)}w.exports=P},36321:function(w,P,a){var f=a(53110),x=a(25281),E=a(97800),b=200;function v(N,S){var M=this.__data__;if(M instanceof f){var A=M.__data__;if(!x||A.length2?A[2]:void 0;for(D&&E(A[0],A[1],D)&&(j=1);++I-1&&f%1==0&&f<=P}w.exports=a},32455:function(w,P,a){var f=a(9961),x=a(82230),E=a(37340),b=E&&E.isMap,v=b?x(b):f;w.exports=v},71721:function(w){function P(a){var f=typeof a;return a!=null&&(f=="object"||f=="function")}w.exports=P},71161:function(w){function P(a){return a!=null&&typeof a=="object"}w.exports=P},29538:function(w,P,a){var f=a(17325),x=a(13530),E=a(71161),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)||f(j)!=b)return!1;var D=x(j);if(D===null)return!0;var Y=M.call(D,"constructor")&&D.constructor;return typeof Y=="function"&&Y instanceof Y&&S.call(Y)==A}w.exports=I},60437:function(w,P,a){var f=a(65562),x=a(82230),E=a(37340),b=E&&E.isSet,v=b?x(b):f;w.exports=v},13720:function(w,P,a){var f=a(17325),x=a(41594),E=a(71161),b="[object String]";function v(N){return typeof N=="string"||!x(N)&&E(N)&&f(N)==b}w.exports=v},66459:function(w,P,a){var f=a(17325),x=a(71161),E="[object Symbol]";function b(v){return typeof v=="symbol"||x(v)&&f(v)==E}w.exports=b},53745:function(w,P,a){var f=a(61651),x=a(82230),E=a(37340),b=E&&E.isTypedArray,v=b?x(b):f;w.exports=v},68408:function(w){function P(a){return a===void 0}w.exports=P},66357:function(w,P,a){var f=a(91762),x=a(63427),E=a(9015);function b(v){return E(v)?f(v):x(v)}w.exports=b},331:function(w,P,a){var f=a(91762),x=a(54193),E=a(9015);function b(v){return E(v)?f(v,!0):x(v)}w.exports=b},47522:function(w){function P(a){var f=a==null?0:a.length;return f?a[f-1]:void 0}w.exports=P},81426:function(w,P,a){var f=a(43453),x=a(71499),E=a(27592),b=a(41594);function v(N,S){var M=b(N)?f:E;return M(N,x(S,3))}w.exports=v},60032:function(w,P,a){var f=a(67109),x=a(23543),E=a(71499);function b(v,N){var S={};return N=E(N,3),x(v,function(M,A,I){f(S,A,N(M,A,I))}),S}w.exports=b},18038:function(w,P,a){var f=a(87542),x=a(52538),E=a(44525);function b(v){return v&&v.length?f(v,E,x):void 0}w.exports=b},88530:function(w,P,a){var f=a(97800),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||f),N}E.Cache=f,w.exports=E},55056:function(w,P,a){var f=a(37111),x=a(94792),E=x(function(b,v,N){f(b,v,N)});w.exports=E},60169:function(w,P,a){var f=a(87542),x=a(85679),E=a(44525);function b(v){return v&&v.length?f(v,E,x):void 0}w.exports=b},13604:function(w,P,a){var f=a(87542),x=a(71499),E=a(85679);function b(v,N){return v&&v.length?f(v,x(N,2),E):void 0}w.exports=b},65075:function(w){function P(){}w.exports=P},76308:function(w,P,a){var f=a(40911),x=function(){return f.Date.now()};w.exports=x},72333:function(w,P,a){var f=a(80073),x=a(33944),E=x(function(b,v){return b==null?{}:f(b,v)});w.exports=E},59932:function(w,P,a){var f=a(11372),x=a(91315),E=a(10866),b=a(90370);function v(N){return E(N)?f(b(N)):x(N)}w.exports=v},69235:function(w,P,a){var f=a(6651),x=f();w.exports=x},9695:function(w,P,a){var f=a(85665),x=a(89264),E=a(71499),b=a(88120),v=a(41594);function N(S,M,A){var I=v(S)?f:b,j=arguments.length<3;return I(S,E(M,4),A,j,x)}w.exports=N},24727:function(w,P,a){var f=a(63427),x=a(29148),E=a(9015),b=a(13720),v=a(62961),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:f(A).length}w.exports=M},35020:function(w,P,a){var f=a(27417),x=a(50447),E=a(2440),b=a(20688),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,f(S,1),[])});w.exports=v},57004:function(w){function P(){return[]}w.exports=P},75374:function(w){function P(){return!1}w.exports=P},925:function(w,P,a){var f=a(13933),x=1/0,E=17976931348623157e292;function b(v){if(!v)return v===0?v:0;if(v=f(v),v===x||v===-x){var N=v<0?-1:1;return N*E}return v===v?v:0}w.exports=b},46588:function(w,P,a){var f=a(925);function x(E){var b=f(E),v=b%1;return b===b?v?b-v:b:0}w.exports=x},13933:function(w,P,a){var f=a(8944),x=a(71721),E=a(66459),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=f(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},8416:function(w,P,a){var f=a(39408),x=a(331);function E(b){return f(b,x(b))}w.exports=E},14135:function(w,P,a){var f=a(12580);function x(E){return E==null?"":f(E)}w.exports=x},61477:function(w,P,a){var f=a(22899),x=a(93511),E=a(23543),b=a(71499),v=a(13530),N=a(41594),S=a(33636),M=a(92581),A=a(71721),I=a(53745);function j(D,Y,_){var ot=N(D),nt=ot||S(D)||I(D);if(Y=b(Y,4),_==null){var Q=D&&D.constructor;nt?_=ot?new Q:[]:A(D)?_=M(Q)?x(v(D)):{}:_={}}return(nt?f:E)(D,function(et,H,it){return Y(_,et,H,it)}),_}w.exports=j},99477:function(w,P,a){var f=a(27417),x=a(2440),E=a(75996),b=a(20577),v=x(function(N){return E(f(N,1,b,!0))});w.exports=v},69624:function(w,P,a){var f=a(14135),x=0;function E(b){var v=++x;return f(b)+v}w.exports=E},72834:function(w,P,a){var f=a(98030),x=a(66357);function E(b){return b==null?[]:f(b,x(b))}w.exports=E},79261:function(w,P,a){var f=a(78436),x=a(30232);function E(b,v){return x(b||[],v||[],f)}w.exports=E},34402:function(w,P,a){"use strict";a.r(P),a.d(P,{default:function(){return b}});var f=a(34634);function x(v){var N=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!(0,f.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,f.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,f.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,f.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,Y=D===void 0?N.autoMinMax?A:1:D;if(j>=Y)throw new RangeError("min option must be smaller than max option");for(var _=(Y-j)/(A-M),ot=0;ot=0;h--)(d=n[h])&&(o=(s<3?d(o):s>3?d(e,t,o):d(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o}function E(n,e){return function(t,r){e(t,r,n)}}function b(n,e,t,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=!e&&n?r.static?n:n.prototype:null,y=e||(g?Object.getOwnPropertyDescriptor(g,r.name):{}),O,L=!1,R=t.length-1;R>=0;R--){var k={};for(var F in r)k[F]=F==="access"?{}:r[F];for(var F in r.access)k.access[F]=r.access[F];k.addInitializer=function(C){if(L)throw new TypeError("Cannot add initializers after decoration has completed");o.push(d(C||null))};var z=(0,t[R])(h==="accessor"?{get:y.get,set:y.set}:y[p],k);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.unshift(O)}else(O=d(z))&&(h==="field"?s.unshift(O):y[p]=O)}g&&Object.defineProperty(g,r.name,y),L=!0}function v(n,e,t){for(var r=arguments.length>2,s=0;s0&&o[o.length-1])&&(g[0]===6||g[0]===2)){t=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(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function _(n,e){var t=typeof Symbol=="function"&&n[Symbol.iterator];if(!t)return n;var r=t.call(n),s,o=[],d;try{for(;(e===void 0||e-- >0)&&!(s=r.next()).done;)o.push(s.value)}catch(h){d={error:h}}finally{try{s&&!s.done&&(t=r.return)&&t.call(r)}finally{if(d)throw d.error}}return o}function ot(){for(var n=[],e=0;e1||p(R,F)})},k&&(s[R]=k(s[R])))}function p(R,k){try{g(r[R](k))}catch(F){L(o[0][3],F)}}function g(R){R.value instanceof et?Promise.resolve(R.value.v).then(y,O):L(o[0][2],R)}function y(R){p("next",R)}function O(R){p("throw",R)}function L(R,k){R(k),o.shift(),o.length&&p(o[0][0],o[0][1])}}function it(n){var e,t;return e={},r("next"),r("throw",function(s){throw s}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(s,o){e[s]=n[s]?function(d){return(t=!t)?{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 e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof Y=="function"?Y(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(o){t[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,e){return Object.defineProperty?Object.defineProperty(n,"raw",{value:e}):n.raw=e,n}var ht=Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e},dt=function(n){return dt=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},dt(n)};function xt(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t=dt(n),r=0;r{e.has(d.id)||(e.add(d.id),n.push(d))})}return!1}function Ze(n,e,t,r){if(t(n))return!0;e.add(n.id);for(const o of r(n.id))if(!e.has(o.id)&&Ze(o,e,t,r))return!0;return!1}const sn=()=>!0;class gt{constructor(e){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(e=>e.id))});be(this,"updateCache",e=>{const t=new Set;e.forEach(r=>{const s=this.bothEdgesMap.get(r);if(s&&s.forEach(o=>t.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=>t.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))}}),t.forEach(r=>{this.hasEdge(r)?this.allEdgesMap.set(r,this.graph.getEdge(r)):this.allEdgesMap.delete(r)})});be(this,"handleGraphChanged",e=>{const t=new Set;e.changes.forEach(r=>{switch(r.type){case"NodeAdded":t.add(r.value.id);break;case"NodeDataUpdated":t.add(r.id);break;case"EdgeAdded":t.add(r.value.source),t.add(r.value.target);break;case"EdgeUpdated":(r.propertyName==="source"||r.propertyName==="target")&&(t.add(r.oldValue),t.add(r.newValue));break;case"EdgeDataUpdated":if(e.graph.hasEdge(r.id)){const s=e.graph.getEdge(r.id);t.add(s.source),t.add(s.target)}break;case"EdgeRemoved":t.add(r.value.source),t.add(r.value.target);break;case"NodeRemoved":t.add(r.value.id);break;default:break}}),this.updateCache(t)});this.graph=e.graph;const t=e.nodeFilter||sn,r=e.edgeFilter||sn;this.nodeFilter=t,this.edgeFilter=s=>{const{source:o,target:d}=this.graph.getEdgeDetail(s.id);return!t(o)||!t(d)?!1:r(s,o,d)},e.cache==="auto"?(this.cacheEnabled=!0,this.startAutoCache()):e.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(e){this.getNode(e)}hasNode(e){if(!this.graph.hasNode(e))return!1;const t=this.graph.getNode(e);return this.nodeFilter(t)}areNeighbors(e,t){return this.checkNodeExistence(e),this.getNeighbors(t).some(r=>r.id===e)}getNode(e){const t=this.graph.getNode(e);if(!this.nodeFilter(t))throw new Error("Node not found for id: "+e);return t}getRelatedEdges(e,t){return this.checkNodeExistence(e),this.cacheEnabled?t==="in"?this.inEdgesMap.get(e):t==="out"?this.outEdgesMap.get(e):this.bothEdgesMap.get(e):this.graph.getRelatedEdges(e,t).filter(this.edgeFilter)}getDegree(e,t){return this.getRelatedEdges(e,t).length}getSuccessors(e){const r=this.getRelatedEdges(e,"out").map(s=>this.getNode(s.target));return Array.from(new Set(r))}getPredecessors(e){const r=this.getRelatedEdges(e,"in").map(s=>this.getNode(s.source));return Array.from(new Set(r))}getNeighbors(e){const t=this.getPredecessors(e),r=this.getSuccessors(e);return Array.from(new Set([...t,...r]))}hasEdge(e){if(!this.graph.hasEdge(e))return!1;const t=this.graph.getEdge(e);return this.edgeFilter(t)}getEdge(e){const t=this.graph.getEdge(e);if(!this.edgeFilter(t))throw new Error("Edge not found for id: "+e);return t}getEdgeDetail(e){const t=this.getEdge(e);return{edge:t,source:this.getNode(t.source),target:this.getNode(t.target)}}hasTreeStructure(e){return this.graph.hasTreeStructure(e)}getRoots(e){return this.graph.getRoots(e).filter(this.nodeFilter)}getChildren(e,t){return this.checkNodeExistence(e),this.graph.getChildren(e,t).filter(this.nodeFilter)}getParent(e,t){this.checkNodeExistence(e);const r=this.graph.getParent(e,t);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(e,t,r="out"){const s={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];an([this.getNode(e)],new Set,t,s)}dfs(e,t,r="out"){const s={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];Ze(this.getNode(e),new Set,t,s)}}class vt extends Nn{constructor(t){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",t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()});t&&(t.nodes&&this.addNodes(t.nodes),t.edges&&this.addEdges(t.edges),t.tree&&this.addTree(t.tree),t.onChanged&&(this.onChanged=t.onChanged))}commit(){const t=this.changes;this.changes=[];const r={graph:this,changes:t};this.emit("changed",r),this.onChanged(r)}reduceChanges(t){let r=[];return t.forEach(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(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,r){return this.getNeighbors(r).some(s=>s.id===t)}getNode(t){const r=this.nodeMap.get(t);if(!r)throw new Error("Node not found for id: "+t);return r}getRelatedEdges(t,r){if(this.checkNodeExistence(t),r==="in"){const s=this.inEdgesMap.get(t);return Array.from(s)}else if(r==="out"){const s=this.outEdgesMap.get(t);return Array.from(s)}else{const s=this.bothEdgesMap.get(t);return Array.from(s)}}getDegree(t,r){return this.getRelatedEdges(t,r).length}getSuccessors(t){const s=this.getRelatedEdges(t,"out").map(o=>this.getNode(o.target));return Array.from(new Set(s))}getPredecessors(t){const s=this.getRelatedEdges(t,"in").map(o=>this.getNode(o.source));return Array.from(new Set(s))}getNeighbors(t){const r=this.getPredecessors(t),s=this.getSuccessors(t);return Array.from(new Set([...r,...s]))}doAddNode(t){if(this.hasNode(t.id))throw new Error("Node already exists: "+t.id);this.nodeMap.set(t.id,t),this.inEdgesMap.set(t.id,new Set),this.outEdgesMap.set(t.id,new Set),this.bothEdgesMap.set(t.id,new Set),this.treeIndices.forEach(r=>{r.childrenMap.set(t.id,new Set)}),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch(()=>{for(const r of t)this.doAddNode(r)})}addNode(t){this.addNodes([t])}doRemoveNode(t){const r=this.getNode(t),s=this.bothEdgesMap.get(t);s==null||s.forEach(o=>this.doRemoveEdge(o.id)),this.nodeMap.delete(t),this.treeIndices.forEach(o=>{var h,p;(h=o.childrenMap.get(t))==null||h.forEach(g=>{o.parentMap.delete(g.id)});const d=o.parentMap.get(t);d&&((p=o.childrenMap.get(d.id))==null||p.delete(r)),o.parentMap.delete(t),o.childrenMap.delete(t)}),this.bothEdgesMap.delete(t),this.inEdgesMap.delete(t),this.outEdgesMap.delete(t),this.changes.push({type:"NodeRemoved",value:r})}removeNodes(t){this.batch(()=>{t.forEach(r=>this.doRemoveNode(r))})}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,r,s){const o=this.getNode(t);this.batch(()=>{const d=o.data[r],h=s;o.data[r]=h,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:r,oldValue:d,newValue:h})})}mergeNodeData(t,r){this.batch(()=>{Object.entries(r).forEach(([s,o])=>{this.updateNodeDataProperty(t,s,o)})})}updateNodeData(...t){const r=t[0],s=this.getNode(r);if(typeof t[1]=="string"){this.updateNodeDataProperty(r,t[1],t[2]);return}let o;if(typeof t[1]=="function"){const d=t[1];o=d(s.data)}else typeof t[1]=="object"&&(o=t[1]);this.batch(()=>{const d=s.data,h=o;s.data=o,this.changes.push({type:"NodeDataUpdated",id:r,oldValue:d,newValue:h})})}checkEdgeExistence(t){if(!this.hasEdge(t))throw new Error("Edge not found for id: "+t)}hasEdge(t){return this.edgeMap.has(t)}getEdge(t){return this.checkEdgeExistence(t),this.edgeMap.get(t)}getEdgeDetail(t){const r=this.getEdge(t);return{edge:r,source:this.getNode(r.source),target:this.getNode(r.target)}}doAddEdge(t){if(this.hasEdge(t.id))throw new Error("Edge already exists: "+t.id);this.checkNodeExistence(t.source),this.checkNodeExistence(t.target),this.edgeMap.set(t.id,t);const r=this.inEdgesMap.get(t.target),s=this.outEdgesMap.get(t.source),o=this.bothEdgesMap.get(t.source),d=this.bothEdgesMap.get(t.target);r.add(t),s.add(t),o.add(t),d.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch(()=>{for(const r of t)this.doAddEdge(r)})}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const r=this.getEdge(t),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(t),this.changes.push({type:"EdgeRemoved",value:r})}removeEdges(t){this.batch(()=>{t.forEach(r=>this.doRemoveEdge(r))})}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,r){const s=this.getEdge(t);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:t,propertyName:"source",oldValue:o,newValue:d})})}updateEdgeTarget(t,r){const s=this.getEdge(t);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:t,propertyName:"target",oldValue:o,newValue:d})})}updateEdgeDataProperty(t,r,s){const o=this.getEdge(t);this.batch(()=>{const d=o.data[r],h=s;o.data[r]=h,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:r,oldValue:d,newValue:h})})}updateEdgeData(...t){const r=t[0],s=this.getEdge(r);if(typeof t[1]=="string"){this.updateEdgeDataProperty(r,t[1],t[2]);return}let o;if(typeof t[1]=="function"){const d=t[1];o=d(s.data)}else typeof t[1]=="object"&&(o=t[1]);this.batch(()=>{const d=s.data,h=o;s.data=o,this.changes.push({type:"EdgeDataUpdated",id:r,oldValue:d,newValue:h})})}mergeEdgeData(t,r){this.batch(()=>{Object.entries(r).forEach(([s,o])=>{this.updateEdgeDataProperty(t,s,o)})})}checkTreeExistence(t){if(!this.hasTreeStructure(t))throw new Error("Tree structure not found for treeKey: "+t)}hasTreeStructure(t){return this.treeIndices.has(t)}attachTreeStructure(t){this.treeIndices.has(t)||(this.treeIndices.set(t,{parentMap:new Map,childrenMap:new Map}),this.batch(()=>{this.changes.push({type:"TreeStructureAttached",treeKey:t})}))}detachTreeStructure(t){this.checkTreeExistence(t),this.treeIndices.delete(t),this.batch(()=>{this.changes.push({type:"TreeStructureDetached",treeKey:t})})}addTree(t,r){this.batch(()=>{this.attachTreeStructure(r);const s=[],o=Array.isArray(t)?t:[t];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(t){return this.checkTreeExistence(t),this.getAllNodes().filter(r=>!this.getParent(r.id,t))}getChildren(t,r){this.checkNodeExistence(t),this.checkTreeExistence(r);const o=this.treeIndices.get(r).childrenMap.get(t);return Array.from(o||[])}getParent(t,r){return this.checkNodeExistence(t),this.checkTreeExistence(r),this.treeIndices.get(r).parentMap.get(t)||null}getAncestors(t,r){const s=[];let o=this.getNode(t),d;for(;d=this.getParent(o.id,r);)s.push(d),o=d;return s}setParent(t,r,s){var y,O;this.checkTreeExistence(s);const o=this.treeIndices.get(s);if(!o)return;const d=this.getNode(t),h=o.parentMap.get(t);if((h==null?void 0:h.id)===r)return;if(r==null){h&&((y=o.childrenMap.get(h.id))==null||y.delete(d)),o.parentMap.delete(t);return}const p=this.getNode(r);o.parentMap.set(t,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:t,oldParentId:h==null?void 0:h.id,newParentId:p.id})})}dfsTree(t,r,s){const o=d=>this.getChildren(d,s);return Ze(this.getNode(t),new Set,r,o)}bfsTree(t,r,s){const o=d=>this.getChildren(d,s);return an([this.getNode(t)],new Set,r,o)}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,r,s="out"){const o={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[s];return an([this.getNode(t)],new Set,r,o)}dfs(t,r,s="out"){const o={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[s];return Ze(this.getNode(t),new Set,r,o)}clone(){const t=this.getAllNodes().map(o=>Kr(kn({},o),{data:kn({},o.data)})),r=this.getAllEdges().map(o=>Kr(kn({},o),{data:kn({},o.data)})),s=new vt({nodes:t,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(t){return new gt(kn({graph:this},t))}}const At=Symbol("Comlink.proxy"),Ft=Symbol("Comlink.endpoint"),qt=Symbol("Comlink.releaseProxy"),ue=Symbol("Comlink.finalizer"),he=Symbol("Comlink.thrown"),Ie=n=>typeof n=="object"&&n!==null||typeof n=="function",pn={canHandle:n=>Ie(n)&&n[At],serialize(n){const{port1:e,port2:t}=new MessageChannel;return Wt(n,e),[t,[t]]},deserialize(n){return n.start(),on(n)}},De={canHandle:n=>Ie(n)&&he in n,serialize({value:n}){let e;return n instanceof Error?e={isError:!0,value:{message:n.message,name:n.name,stack:n.stack}}:e={isError:!1,value:n},[e,[]]},deserialize(n){throw n.isError?Object.assign(new Error(n.value.message),n.value):n.value}},Me=new Map([["proxy",pn],["throw",De]]);function se(n,e){for(const t of n)if(e===t||t==="*"||t instanceof RegExp&&t.test(e))return!0;return!1}function Wt(n,e=globalThis,t=["*"]){e.addEventListener("message",function r(s){if(!s||!s.data)return;if(!se(t,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(ze);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]]=ze(s.data.value),g=!0;break;case"APPLY":g=O.apply(y,p);break;case"CONSTRUCT":{const L=new O(...p);g=mn(L)}break;case"ENDPOINT":{const{port1:L,port2:R}=new MessageChannel;Wt(n,R),g=Pn(L,[L])}break;case"RELEASE":g=void 0;break;default:return}}catch(y){g={value:y,[he]:0}}Promise.resolve(g).catch(y=>({value:y,[he]:0})).then(y=>{const[O,L]=Be(y);e.postMessage(Object.assign(Object.assign({},O),{id:o}),L),d==="RELEASE"&&(e.removeEventListener("message",r),en(e),ue in n&&typeof n[ue]=="function"&&n[ue]())}).catch(y=>{const[O,L]=Be({value:new TypeError("Unserializable return value"),[he]:0});e.postMessage(Object.assign(Object.assign({},O),{id:o}),L)})}),e.start&&e.start()}function re(n){return n.constructor.name==="MessagePort"}function en(n){re(n)&&n.close()}function on(n,e){const t=new Map;return n.addEventListener("message",function(s){const{data:o}=s;if(!o||!o.id)return;const d=t.get(o.id);if(d)try{d(o)}finally{t.delete(o.id)}}),Mn(n,t,[],e)}function It(n){if(n)throw new Error("Proxy has been released and is not useable")}function un(n){return Ae(n,new Map,{type:"RELEASE"}).then(()=>{en(n)})}const Pe=new WeakMap,xe="FinalizationRegistry"in globalThis&&new FinalizationRegistry(n=>{const e=(Pe.get(n)||0)-1;Pe.set(n,e),e===0&&un(n)});function ke(n,e){const t=(Pe.get(e)||0)+1;Pe.set(e,t),xe&&xe.register(n,e,n)}function vn(n){xe&&xe.unregister(n)}function Mn(n,e,t=[],r=function(){}){let s=!1;const o=new Proxy(r,{get(d,h){if(It(s),h===qt)return()=>{vn(o),un(n),e.clear(),s=!0};if(h==="then"){if(t.length===0)return{then:()=>o};const p=Ae(n,e,{type:"GET",path:t.map(g=>g.toString())}).then(ze);return p.then.bind(p)}return Mn(n,e,[...t,h])},set(d,h,p){It(s);const[g,y]=Be(p);return Ae(n,e,{type:"SET",path:[...t,h].map(O=>O.toString()),value:g},y).then(ze)},apply(d,h,p){It(s);const g=t[t.length-1];if(g===Ft)return Ae(n,e,{type:"ENDPOINT"}).then(ze);if(g==="bind")return Mn(n,e,t.slice(0,-1));const[y,O]=nn(p);return Ae(n,e,{type:"APPLY",path:t.map(L=>L.toString()),argumentList:y},O).then(ze)},construct(d,h){It(s);const[p,g]=nn(h);return Ae(n,e,{type:"CONSTRUCT",path:t.map(y=>y.toString()),argumentList:p},g).then(ze)}});return ke(o,n),o}function In(n){return Array.prototype.concat.apply([],n)}function nn(n){const e=n.map(Be);return[e.map(t=>t[0]),In(e.map(t=>t[1]))]}const Sn=new WeakMap;function Pn(n,e){return Sn.set(n,e),n}function mn(n){return Object.assign(n,{[At]:!0})}function Bn(n,e=globalThis,t="*"){return{postMessage:(r,s)=>n.postMessage(r,t,s),addEventListener:e.addEventListener.bind(e),removeEventListener:e.removeEventListener.bind(e)}}function Be(n){for(const[e,t]of Me)if(t.canHandle(n)){const[r,s]=t.serialize(n);return[{type:"HANDLER",name:e,value:r},s]}return[{type:"RAW",value:n},Sn.get(n)||[]]}function ze(n){switch(n.type){case"HANDLER":return Me.get(n.name).deserialize(n.value);case"RAW":return n.value}}function Ae(n,e,t,r){return new Promise(s=>{const o=fr();e.set(o,s),n.start&&n.start(),n.postMessage(Object.assign({id:o},t),r)})}function fr(){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 rn(n){return n==null}const Un=(n,e)=>{if(n!=="next"&&n!=="prev")return e},cn=n=>{n.prev.next=n.next,n.next.prev=n.prev,delete n.next,delete n.prev};class lr{constructor(){const e={};e.prev=e,e.next=e.prev,this.shortcut=e}dequeue(){const e=this.shortcut,t=e.prev;if(t&&t!==e)return cn(t),t}enqueue(e){const t=this.shortcut;e.prev&&e.next&&cn(e),e.next=t.next,t.next.prev=e,t.next=e,e.prev=t}toString(){const e=[],t=this.shortcut;let r=t.prev;for(;r!==t;)e.push(JSON.stringify(r,Un)),r=r==null?void 0:r.prev;return`[${e.join(", ")}]`}}class Jn extends lr{}const Rn=()=>1,dr=(n,e)=>{var t;if(n.getAllNodes().length<=1)return[];const r=gr(n,e||Rn);return(t=hr(r.graph,r.buckets,r.zeroIdx).map(o=>n.getRelatedEdges(o.v,"out").filter(({target:d})=>d===o.w)))===null||t===void 0?void 0:t.flat()},hr=(n,e,t)=>{let r=[];const s=e[e.length-1],o=e[0];let d;for(;n.getAllNodes().length;){for(;d=o.dequeue();)Vn(n,e,t,d);for(;d=s.dequeue();)Vn(n,e,t,d);if(n.getAllNodes().length){for(let h=e.length-2;h>0;--h)if(d=e[h].dequeue(),d){r=r.concat(Vn(n,e,t,d,!0));break}}}return r},Vn=(n,e,t,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,Gn(e,t,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,Gn(e,t,Object.assign({v:O.id},O.data))}),n.removeNode(r.v)),s?h:void 0},gr=(n,e)=>{const t=new vt;let r=0,s=0;n.getAllNodes().forEach(p=>{t.addNode({id:p.id,data:{v:p.id,in:0,out:0}})}),n.getAllEdges().forEach(p=>{const g=t.getRelatedEdges(p.source,"out").find(O=>O.target===p.target),y=(e==null?void 0:e(p))||1;g?t.updateEdgeData(g==null?void 0:g.id,Object.assign(Object.assign({},g.data),{weight:g.data.weight+y})):t.addEdge({id:p.id,source:p.source,target:p.target,data:{weight:y}}),s=Math.max(s,t.getNode(p.source).data.out+=y),r=Math.max(r,t.getNode(p.target).data.in+=y)});const o=[],d=s+r+3;for(let p=0;p{Gn(o,h,Object.assign({v:p.id},t.getNode(p.id).data))}),{buckets:o,zeroIdx:h,graph:t}},Gn=(n,e,t)=>{t.out?t.in?n[t.out-t.in+e].enqueue(t):n[n.length-1].enqueue(t):n[0].enqueue(t)},pr=(n,e)=>{const r=e==="greedy"?dr(n,(s=>o=>o.data.weight||1)(n)):Qn(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)})})},Qn=n=>{const e=[],t={},r={},s=o=>{r[o]||(r[o]=!0,t[o]=!0,n.getRelatedEdges(o,"out").forEach(d=>{t[d.target]?e.push(d):s(d.target)}),delete t[o])};return n.getAllNodes().forEach(o=>s(o.id)),e},vr=n=>{n.getAllEdges().forEach(e=>{const t=e.data;if(t.reversed){n.removeEdge(e.id);const r=t.forwardName;delete t.reversed,delete t.forwardName,n.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign(Object.assign({},t),{forwardName:r})})}})},mr=(n,e)=>Number(n)-Number(e),yn=(n,e,t,r)=>{let s;do s=`${r}${Math.random()}`;while(n.hasNode(s));return t.dummy=e,n.addNode({id:s,data:t}),s},yr=n=>{const e=new vt;return n.getAllNodes().forEach(t=>{e.addNode(Object.assign({},t))}),n.getAllEdges().forEach(t=>{const r=e.getRelatedEdges(t.source,"out").find(s=>s.target===t.target);r?e.updateEdgeData(r==null?void 0:r.id,Object.assign(Object.assign({},r.data),{weight:r.data.weight+t.data.weight||0,minlen:Math.max(r.data.minlen,t.data.minlen||1)})):e.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||0,minlen:t.data.minlen||1}})}),e},On=n=>{const e=new vt;return n.getAllNodes().forEach(t=>{n.getChildren(t.id).length||e.addNode(Object.assign({},t))}),n.getAllEdges().forEach(t=>{e.addEdge(t)}),e},Wn=(n,e)=>n==null?void 0:n.reduce((t,r,s)=>(t[r]=e[s],t),{}),wr=n=>{const e={};return n.getAllNodes().forEach(t=>{const r={};n.getRelatedEdges(t.id,"out").forEach(s=>{r[s.target]=(r[s.target]||0)+(s.data.weight||0)}),e[t.id]=r}),e},T=n=>{const e=n.getAllNodes(),t=e.map(r=>{const s={};return n.getRelatedEdges(r.id,"in").forEach(o=>{s[o.source]=(s[o.source]||0)+o.data.weight}),s});return Wn(e.map(r=>r.id),t)},u=(n,e)=>{const t=Number(n.x),r=Number(n.y),s=Number(e.x)-t,o=Number(e.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:t+p,y:r+g}},c=n=>{const e=[],t=B(n)+1;for(let r=0;r{const s=r.data.rank;s!==void 0&&e[s]&&e[s].push(r.id)});for(let r=0;rmr(n.getNode(s).data.order,n.getNode(o).data.order));return e},i=n=>{const e=n.getAllNodes().filter(r=>r.data.rank!==void 0).map(r=>r.data.rank),t=Math.min(...e);n.getAllNodes().forEach(r=>{r.data.hasOwnProperty("rank")&&t!==1/0&&(r.data.rank-=t)})},l=(n,e=0)=>{const t=n.getAllNodes(),r=t.filter(h=>h.data.rank!==void 0).map(h=>h.data.rank),s=Math.min(...r),o=[];t.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)}))}},m=(n,e,t,r)=>{const s={width:0,height:0};return _t(t)&&_t(r)&&(s.rank=t,s.order=r),yn(n,"border",s,e)},B=n=>{let e;return n.getAllNodes().forEach(t=>{const r=t.data.rank;r!==void 0&&(e===void 0||r>e)&&(e=r)}),e||(e=0),e},U=(n,e)=>{const t={lhs:[],rhs:[]};return n==null||n.forEach(r=>{e(r)?t.lhs.push(r):t.rhs.push(r)}),t},V=(n,e)=>n.reduce((t,r)=>{const s=e(t),o=e(r);return s>o?r:t}),G=(n,e,t,r,s,o)=>{r.includes(e.id)||(r.push(e.id),t||o.push(e.id),s(e.id).forEach(d=>G(n,d,t,r,s,o)),t&&o.push(e.id))},rt=(n,e,t,r)=>{const s=Array.isArray(e)?e:[e],o=p=>r?n.getSuccessors(p):n.getNeighbors(p),d=[],h=[];return s.forEach(p=>{if(n.hasNode(p.id))G(n,p,t==="post",h,o,d);else throw new Error(`Graph does not have node: ${p}`)}),d},K=n=>{const e=t=>{const r=n.getChildren(t),s=n.getNode(t);if(r!=null&&r.length&&r.forEach(o=>e(o.id)),s.data.hasOwnProperty("minRank")){s.data.borderLeft=[],s.data.borderRight=[];for(let o=s.data.minRank,d=s.data.maxRank+1;oe(t.id))},lt=(n,e,t,r,s,o)=>{const d={rank:o,borderType:e,width:0,height:0},h=s.data[e][o-1],p=yn(n,"border",d,t);s.data[e][o]=p,n.setParent(p,r),h&&n.addEdge({id:`e${Math.random()}`,source:h,target:p,data:{weight:1}})},Tt=(n,e)=>{const t=e.toLowerCase();(t==="lr"||t==="rl")&&pt(n)},ct=(n,e)=>{const t=e.toLowerCase();(t==="bt"||t==="rl")&&Z(n),(t==="lr"||t==="rl")&&(Ct(n),pt(n))},pt=n=>{n.getAllNodes().forEach(e=>{Rt(e)}),n.getAllEdges().forEach(e=>{Rt(e)})},Rt=n=>{const e=n.data.width;n.data.width=n.data.height,n.data.height=e},Z=n=>{n.getAllNodes().forEach(e=>{St(e.data)}),n.getAllEdges().forEach(e=>{var t;(t=e.data.points)===null||t===void 0||t.forEach(r=>St(r)),e.data.hasOwnProperty("y")&&St(e.data)})},St=n=>{n!=null&&n.y&&(n.y=-n.y)},Ct=n=>{n.getAllNodes().forEach(e=>{Xt(e.data)}),n.getAllEdges().forEach(e=>{var t;(t=e.data.points)===null||t===void 0||t.forEach(r=>Xt(r)),e.data.hasOwnProperty("x")&&Xt(e.data)})},Xt=n=>{const e=n.x;n.x=n.y,n.y=e},Zt=n=>{const e=yn(n,"root",{},"_root"),t=Ut(n);let r=Math.max(...Object.values(t));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=Yt(n)+1;return n.getRoots().forEach(h=>{ge(n,e,o,d,s,t,h.id)}),{nestingRoot:e,nodeRankFactor:o}},ge=(n,e,t,r,s,o,d)=>{const h=n.getChildren(d);if(!(h!=null&&h.length)){d!==e&&n.addEdge({id:`e${Math.random()}`,source:e,target:d,data:{weight:0,minlen:t}});return}const p=m(n,"_bt"),g=m(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=>{ge(n,e,t,r,s,o,O.id);const L=O.data.borderTop?O.data.borderTop:O.id,R=O.data.borderBottom?O.data.borderBottom:O.id,k=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:k,nestingEdge:!0}}),n.addEdge({id:`e${Math.random()}`,source:R,target:g,data:{minlen:F,weight:k,nestingEdge:!0}})}),n.getParent(d)||n.addEdge({id:`e${Math.random()}`,source:e,target:p,data:{weight:0,minlen:s+o[d]}})},Ut=n=>{const e={},t=(r,s)=>{const o=n.getChildren(r);o==null||o.forEach(d=>t(d.id,s+1)),e[r]=s};return n.getRoots().forEach(r=>t(r.id,1)),e},Yt=n=>{let e=0;return n.getAllEdges().forEach(t=>{e+=t.data.weight}),e},ce=(n,e)=>{e&&n.removeNode(e),n.getAllEdges().forEach(t=>{t.data.nestingEdge&&n.removeEdge(t.id)})},tt="edge",wt="edge-label",Lt=(n,e)=>{n.getAllEdges().forEach(t=>Mt(n,t,e))},Mt=(n,e,t)=>{let r=e.source,s=n.getNode(r).data.rank;const o=e.target,d=n.getNode(o).data.rank,h=e.data.labelRank;if(d===s+1)return;n.removeEdge(e.id);let p,g,y;for(y=0,++s;s{e.forEach(t=>{let r=n.getNode(t);const{data:s}=r,o=s.originalEdge;let d;o&&n.addEdge(o);let h=t;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===wt&&(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 fe=function(n){if(typeof n!="object"||n===null)return n;var e;if(ae(n)){e=[];for(var t=0,r=n.length;t{const r={};let s;t==null||t.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){e.hasNode(p)||e.addNode({id:p,data:{}}),e.hasNode(d.id)||e.addNode({id:d.id,data:{}}),e.hasEdge(`e${p}-${d.id}`)||e.addEdge({id:`e${p}-${d.id}`,source:p,target:d.id,data:{}});return}d=h}})},_e=(n,e,t)=>{const r=Se(n),s=new vt({tree:[{id:r,children:[],data:{}}]});return n.getAllNodes().forEach(o=>{const d=n.getParent(o.id);(o.data.rank===e||o.data.minRank<=e&&e<=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,t).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[e],borderRight:o.data.borderRight[e]})))}),s},Se=n=>{let e;for(;n.hasNode(e=`_root${Math.random()}`););return e},Je=(n,e,t)=>{const r=Wn(t,t.map((y,O)=>O)),o=e.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},Qe=(n,e)=>{let t=0;for(let r=1;r<(e==null?void 0:e.length);r+=1)t+=Je(n,e[r-1],e[r]);return t},te=n=>{const e={},t=n.getAllNodes(),r=t.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),e[g.id]=!0}),d==null||d.forEach(g=>n.dfsTree(g.id,y=>{if(e.hasOwnProperty(y.id))return!0;e[y.id]=!0,isNaN(y.data.rank)||o[y.data.rank].push(y.id)})),o},Le=(n,e)=>e.map(t=>{const r=n.getRelatedEdges(t,"in");if(!(r!=null&&r.length))return{v:t};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:t,barycenter:s.sum/s.weight,weight:s.weight}}),Ue=(n,e)=>{var t,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)}),(t=e.getAllEdges())===null||t===void 0||t.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 Ve(d)},Ve=n=>{var e,t;const r=[],s=p=>g=>{g.merged||(g.barycenter===void 0||p.barycenter===void 0||g.barycenter>=p.barycenter)&&Oe(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),(e=p.in.reverse())===null||e===void 0||e.forEach(g=>s(p)(g)),(t=p.out)===null||t===void 0||t.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})},Oe=(n,e)=>{var t;let r=0,s=0;n.weight&&(r+=n.barycenter*n.weight,s+=n.weight),e.weight&&(r+=e.barycenter*e.weight,s+=e.weight),n.vs=(t=e.vs)===null||t===void 0?void 0:t.concat(n.vs),n.barycenter=r/s,n.weight=s,n.i=Math.min(e.i,n.i),e.merged=!0};var xr=Ue;const Er=(n,e,t,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(br(!!e,!!t)),y=Hn(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=Hn(h,d,y)});const O={vs:h.flat()};return g&&(O.barycenter=p/g,O.weight=g),O},Hn=(n,e,t)=>{let r=t,s;for(;e.length&&(s=e[e.length-1]).i<=r;)e.pop(),n==null||n.push(s.vs),r++;return r},br=(n,e)=>(t,r)=>{if(t.fixorder!==void 0&&r.fixorder!==void 0)return t.fixorder-r.fixorder;if(t.barycenterr.barycenter)return 1;if(e&&t.order!==void 0&&r.order!==void 0){if(t.orderr.order)return 1}return n?r.i-t.i:t.i-r.i},qn=(n,e,t,r,s,o)=>{var d,h,p,g;let y=n.getChildren(e).map(W=>W.id);const O=n.getNode(e),L=O?O.data.borderLeft:void 0,R=O?O.data.borderRight:void 0,k={};L&&(y=y==null?void 0:y.filter(W=>W!==L&&W!==R));const F=Le(n,y||[]);F==null||F.forEach(W=>{var $;if(!(($=n.getChildren(W.v))===null||$===void 0)&&$.length){const X=qn(n,W.v,t,r,o);k[W.v]=X,X.hasOwnProperty("barycenter")&&Mr(W,X)}});const z=xr(F,t);Nr(z,k),(d=z.filter(W=>W.vs.length>0))===null||d===void 0||d.forEach(W=>{const $=n.getNode(W.vs[0]);$&&(W.fixorder=$.data.fixorder,W.order=$.data.order)});const C=Er(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)||""),$=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+$.data.order)/(C.weight+2),C.weight+=2}return C},Nr=(n,e)=>{n==null||n.forEach(t=>{var r;const s=(r=t.vs)===null||r===void 0?void 0:r.map(o=>e[o]?e[o].vs:o);t.vs=s.flat()})},Mr=(n,e)=>{n.barycenter!==void 0?(n.barycenter=(n.barycenter*n.weight+e.barycenter*e.weight)/(n.weight+e.weight),n.weight+=e.weight):(n.barycenter=e.barycenter,n.weight=e.weight)},Sr=(n,e)=>{const t=B(n),r=[],s=[];for(let y=1;y-1;y--)s.push(y);const o=tr(n,r,"in"),d=tr(n,s,"out");let h=te(n);Or(n,h);let p=Number.POSITIVE_INFINITY,g;for(let y=0,O=0;O<4;++y,++O){Qr(y%2?o:d,y%4>=2,!1,e),h=c(n);const L=Qe(n,h);L=2,!0,e),h=c(n);const L=Qe(n,h);Le.map(r=>_e(n,r,t)),Qr=(n,e,t,r)=>{const s=new vt;n==null||n.forEach(o=>{var d;const h=o.getRoots()[0].id,p=qn(o,h,s,e,t,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)}Re(o,s,p.vs)})},Or=(n,e)=>{e==null||e.forEach(t=>{t==null||t.forEach((r,s)=>{n.getNode(r).data.order=s})})},ni=(n,e)=>{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))})},ri=n=>{const e={};let t=0;const r=s=>{const o=t;n.getChildren(s).forEach(d=>r(d.id)),e[s]={low:o,lim:t++}};return n.getRoots().forEach(s=>r(s.id)),e},si=(n,e,t,r)=>{var s,o;const d=[],h=[],p=Math.min(e[t].low,e[r].low),g=Math.max(e[t].lim,e[r].lim);let y,O;y=t;do y=(s=n.getParent(y))===null||s===void 0?void 0:s.id,d.push(y);while(y&&(e[y].low>p||g>e[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())}},ii=(n,e)=>{const t=ri(n);e.forEach(r=>{var s,o;let d=r,h=n.getNode(d);const p=h.data.originalEdge;if(!p)return;const g=si(n,t,p.source,p.target),y=g.path,O=g.lca;let L=0,R=y[L],k=!0;for(;d!==p.target;){if(h=n.getNode(d),k){for(;R!==O&&((s=n.getNode(R))===null||s===void 0?void 0:s.data.maxRank){const t={},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=oi(n,y),k=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 $=n.getNode(C.id),X=$.data.order;(X{const t={};function r(h,p,g,y,O){var L,R;let k;for(let F=p;F{const C=n.getNode(z.id);C.data.dummy&&(C.data.orderO)&&ts(t,z.id,k)}))}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,k)=>{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,k,g,y],L),O=k,g=y)}o([p,O,p.length,y,h.length],L)}),p};return e!=null&&e.length&&e.reduce(d),t},oi=(n,e)=>{var t,r;if(!((t=n.getNode(e))===null||t===void 0)&&t.data.dummy)return(r=n.getPredecessors(e))===null||r===void 0?void 0:r.find(s=>n.getNode(s.id).data.dummy)},ts=(n,e,t)=>{let r=e,s=t;if(r>s){const d=r;r=s,s=d}let o=n[r];o||(n[r]=o={}),o[s]=!0},ai=(n,e,t)=>{let r=e,s=t;if(r>s){const o=e;r=s,s=o}return!!n[r]},es=(n,e,t,r)=>{const s={},o={},d={};return e==null||e.forEach(h=>{h==null||h.forEach((p,g)=>{s[p]=p,o[p]=p,d[p]=g})}),e==null||e.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 k=y[L];o[g]===g&&p{var h;const p={},g=ui(n,e,t,s,o,d),y=d?"borderLeft":"borderRight",O=(k,F)=>{let z=g.getAllNodes(),C=z.pop();const W={};for(;C;)W[C.id]?k(C.id):(W[C.id]=!0,z.push(C),z=z.concat(F(C.id))),C=z.pop()},L=k=>{p[k]=(g.getRelatedEdges(k,"in")||[]).reduce((F,z)=>Math.max(F,(p[z.source]||0)+z.data.weight),0)},R=k=>{const F=(g.getRelatedEdges(k,"out")||[]).reduce((C,W)=>Math.min(C,(p[W.target]||0)-W.data.weight),Number.POSITIVE_INFINITY),z=n.getNode(k);F!==Number.POSITIVE_INFINITY&&z.data.borderType!==y&&(p[k]=Math.max(p[k],F))};return O(L,g.getPredecessors.bind(g)),O(R,g.getSuccessors.bind(g)),(h=Object.values(r))===null||h===void 0||h.forEach(k=>{p[k]=p[t[k]]}),p},ui=(n,e,t,r,s,o)=>{const d=new vt,h=ci(r,s,o);return e==null||e.forEach(p=>{let g;p==null||p.forEach(y=>{const O=t[y];if(d.hasNode(O)||d.addNode({id:O,data:{}}),g){const L=t[g],R=d.getRelatedEdges(L,"out").find(k=>k.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},rs=(n,e)=>V(Object.values(e),t=>{var r;let s=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;return(r=Object.keys(t))===null||r===void 0||r.forEach(d=>{const h=t[d],p=fi(n,d)/2;s=Math.max(h+p,s),o=Math.min(h-p,o)}),s-o});function ss(n,e){const t=Object.values(e),r=Math.min(...t),s=Math.max(...t);["u","d"].forEach(o=>{["l","r"].forEach(d=>{const h=o+d,p=n[h];let g;if(p===e)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 is=(n,e)=>{const t={};return Object.keys(n.ul).forEach(r=>{if(e)t[r]=n[e.toLowerCase()][r];else{const s=Object.values(n).map(o=>o[r]);t[r]=(s[0]+s[1])/2}}),t},Qu=(n,e)=>{const{align:t,nodesep:r=0,edgesep:s=0}=e||{},o=buildLayerMatrix(n),d=Object.assign(Hr(n,o),qr(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=es(n,p,d,L),k=ns(n,p,R.root,R.align,r,s,O==="r");O==="r"&&Object.keys(k).forEach(F=>{k[F]=-k[F]}),h[y+O]=k})});const g=rs(n,h);return ss(h,g),is(h,t)},ci=(n,e,t)=>(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+=t?g:-g),g=0,p+=(d.data.dummy?e:n)/2,p+=(h.data.dummy?e: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+=t?g:-g),g=0,p},fi=(n,e)=>n.getNode(e).data.width||0,li=(n,e)=>{const{ranksep:t=0}=e||{},r=c(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+t})},di=(n,e)=>{const{align:t,nodesep:r=0,edgesep:s=0}=e||{},o=c(n),d=Object.assign(Hr(n,o),qr(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=es(n,p,d,L),k=ns(n,p,R.root,R.align,r,s,O==="r");O==="r"&&Object.keys(k).forEach(F=>k[F]=-k[F]),h[y+O]=k})});const g=rs(n,h);return g&&ss(h,g),is(h,t)},hi=(n,e)=>{var t;const r=On(n);li(r,e);const s=di(r,e);(t=Object.keys(s))===null||t===void 0||t.forEach(o=>{r.getNode(o).data.x=s[o]})},os=n=>{const e={},t=r=>{var s;const o=n.getNode(r);if(!o)return 0;if(e[r])return o.data.rank;e[r]=!0;let d;return(s=n.getRelatedEdges(r,"out"))===null||s===void 0||s.forEach(h=>{const p=t(h.target),g=h.data.minlen,y=p-g;y&&(d===void 0||yn.getRelatedEdges(r.id,"in").length===0).forEach(r=>t(r.id))},gi=n=>{const e={};let t;const r=d=>{var h;const p=n.getNode(d);if(!p)return 0;if(e[d])return p.data.rank;e[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)}),t===void 0&&(t=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-=t:o(d.id,h.layer))})},wn=(n,e)=>n.getNode(e.target).data.rank-n.getNode(e.source).data.rank-e.data.minlen,pi=n=>{const e=new vt({tree:[]}),t=n.getAllNodes()[0],r=n.getAllNodes().length;e.addNode(t);let s,o;for(;vi(e,n){const t=r=>{e.getRelatedEdges(r,"both").forEach(s=>{const o=s.source,d=r===o?s.target:o;!n.hasNode(d)&&!wn(e,s)&&(n.addNode({id:d,data:{}}),n.addEdge({id:s.id,source:r,target:d,data:{}}),t(d))})};return n.getAllNodes().forEach(r=>t(r.id)),n.getAllNodes().length},mi=n=>{const e=new vt({tree:[]}),t=n.getAllNodes()[0],r=n.getAllNodes().length;e.addNode(t);let s,o;for(;yi(e,n){const t=r=>{var s;(s=e.getRelatedEdges(r,"both"))===null||s===void 0||s.forEach(o=>{const d=o.source,h=r===d?o.target:d;!n.hasNode(h)&&(e.getNode(h).data.layer!==void 0||!wn(e,o))&&(n.addNode({id:h,data:{}}),n.addEdge({id:o.id,source:r,target:h,data:{}}),t(h))})};return n.getAllNodes().forEach(r=>t(r.id)),n.getAllNodes().length},as=(n,e)=>V(e.getAllEdges(),t=>n.hasNode(t.source)!==n.hasNode(t.target)?wn(e,t):1/0),us=(n,e,t)=>{n.getAllNodes().forEach(r=>{const s=e.getNode(r.id);s.data.rank||(s.data.rank=0),s.data.rank+=t})},wi=n=>{const e=yr(n);os(e);const t=pi(e);fs(t),cs(t,e);let r,s;for(;r=bi(t);)s=Ni(t,e,r),Mi(t,e,r,s)},cs=(n,e)=>{let t=rt(n,n.getAllNodes(),"post",!1);t=t.slice(0,(t==null?void 0:t.length)-1),t.forEach(r=>{xi(n,e,r)})},xi=(n,e,t)=>{const s=n.getNode(t).data.parent,o=n.getRelatedEdges(t,"both").find(d=>d.target===s||d.source===s);o.data.cutvalue=Ei(n,e,t)},Ei=(n,e,t)=>{const s=n.getNode(t).data.parent;let o=!0,d=e.getRelatedEdges(t,"out").find(p=>p.target===s),h=0;return d||(o=!1,d=e.getRelatedEdges(s,"out").find(p=>p.target===t)),h=d.data.weight,e.getRelatedEdges(t,"both").forEach(p=>{const g=p.source===t,y=g?p.target:p.source;if(y!==s){const O=g===o,L=p.data.weight;if(h+=O?L:-L,Oi(n,t,y)){const R=n.getRelatedEdges(t,"both").find(k=>k.source===y||k.target===y).data.cutvalue;h+=O?-R:R}}}),h},fs=(n,e=n.getAllNodes()[0].id)=>{ls(n,{},1,e)},ls=(n,e,t,r,s)=>{var o;const d=t;let h=t;const p=n.getNode(r);return e[r]=!0,(o=n.getNeighbors(r))===null||o===void 0||o.forEach(g=>{e[g.id]||(h=ls(n,e,h,g.id,r))}),p.data.low=d,p.data.lim=h++,s?p.data.parent=s:delete p.data.parent,h},bi=n=>n.getAllEdges().find(e=>e.data.cutvalue<0),Ni=(n,e,t)=>{let r=t.source,s=t.target;e.getRelatedEdges(r,"out").find(y=>y.target===s)||(r=t.target,s=t.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=e.getAllEdges().filter(y=>p===ds(n.getNode(y.source),h)&&p!==ds(n.getNode(y.target),h));return V(g,y=>wn(e,y))},Mi=(n,e,t,r)=>{const s=n.getRelatedEdges(t.source,"both").find(o=>o.source===t.target||o.target===t.target);s&&n.removeEdge(s.id),n.addEdge({id:`e${Math.random()}`,source:r.source,target:r.target,data:{}}),fs(n),cs(n,e),Si(n,e)},Si=(n,e)=>{const t=n.getAllNodes().find(s=>!s.data.parent);let r=rt(n,t,"pre",!1);r=r.slice(1),r.forEach(s=>{const o=n.getNode(s).data.parent;let d=e.getRelatedEdges(s,"out").find(p=>p.target===o),h=!1;!d&&e.hasNode(o)&&(d=e.getRelatedEdges(o,"out").find(p=>p.target===s),h=!0),e.getNode(s).data.rank=(e.hasNode(o)&&e.getNode(o).data.rank||0)+(h?d==null?void 0:d.data.minlen:-(d==null?void 0:d.data.minlen))})},Oi=(n,e,t)=>n.getRelatedEdges(e,"both").find(r=>r.source===t||r.target===t),ds=(n,e)=>e.data.low<=n.data.lim&&n.data.lim<=e.data.lim,Ai=(n,e)=>{switch(e){case"network-simplex":ji(n);break;case"tight-tree":hs(n);break;case"longest-path":Ti(n);break;default:hs(n)}},Ti=os,hs=n=>{gi(n),mi(n)},ji=n=>{wi(n)},Ii=(n,e)=>{const{edgeLabelSpace:t,keepNodeOrder:r,prevGraph:s,rankdir:o,ranksep:d}=e;!r&&s&&Ri(n,s);const h=ki(n);t&&(e.ranksep=Bi(h,{rankdir:o,ranksep:d}));let p;try{p=Pi(h,e)}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 Li(n,h),p},Pi=(n,e)=>{const{acyclicer:t,ranker:r,rankdir:s="tb",nodeOrder:o,keepNodeOrder:d,align:h,nodesep:p=50,edgesep:g=20,ranksep:y=50}=e;Ki(n),pr(n,t);const{nestingRoot:O,nodeRankFactor:L}=Zt(n);Ai(On(n),r),Ui(n),l(n,L),ce(n,O),i(n),Vi(n),Gi(n);const R=[];Lt(n,R),ii(n,R),K(n),d&&ni(n,o),Sr(n,d),Zi(n),Tt(n,s),hi(n,{align:h,nodesep:p,edgesep:g,ranksep:y}),Ji(n),_i(n),we(n,R),$i(n),ct(n,s);const{width:k,height:F}=Wi(n);return Yi(n),Xi(n),vr(n),{width:k,height:F}},Ri=(n,e)=>{n.getAllNodes().forEach(t=>{const r=n.getNode(t.id);if(e.hasNode(t.id)){const s=e.getNode(t.id);r.data.fixorder=s.data._order,delete s.data._order}else delete r.data.fixorder})},Li=(n,e)=>{n.getAllNodes().forEach(t=>{var r;const s=n.getNode(t.id);if(s){const o=e.getNode(t.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=e.getChildren(t.id))===null||r===void 0)&&r.length&&(s.data.width=o.data.width,s.data.height=o.data.height)}}),n.getAllEdges().forEach(t=>{const r=n.getEdge(t.id),s=e.getEdge(t.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)})},Ci=["width","height","layer","fixorder"],Di={width:0,height:0},zi=["minlen","weight","width","height","labeloffset"],Fi={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Ar=["labelpos"],ki=n=>{const e=new vt({tree:[]});return n.getAllNodes().forEach(t=>{const r=ps(n.getNode(t.id).data),s=Object.assign(Object.assign({},Di),r),o=gs(s,Ci);e.hasNode(t.id)||e.addNode({id:t.id,data:Object.assign({},o)});const d=n.hasTreeStructure("combo")?n.getParent(t.id,"combo"):n.getParent(t.id);rn(d)||(e.hasNode(d.id)||e.addNode(Object.assign({},d)),e.setParent(t.id,d.id))}),n.getAllEdges().forEach(t=>{const r=ps(n.getEdge(t.id).data),s={};Ar==null||Ar.forEach(o=>{r[o]!==void 0&&(s[o]=r[o])}),e.addEdge({id:t.id,source:t.source,target:t.target,data:Object.assign({},Fi,gs(r,zi),s)})}),e},Bi=(n,e)=>{const{ranksep:t=0,rankdir:r}=e;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)}),t/2},Ui=n=>{n.getAllEdges().forEach(e=>{if(e.data.width&&e.data.height){const t=n.getNode(e.source),r=n.getNode(e.target),s={e,rank:(r.data.rank-t.data.rank)/2+t.data.rank};yn(n,"edge-proxy",s,"_ep")}})},Vi=n=>{let e=0;return n.getAllNodes().forEach(t=>{var r,s;t.data.borderTop&&(t.data.minRank=(r=n.getNode(t.data.borderTop))===null||r===void 0?void 0:r.data.rank,t.data.maxRank=(s=n.getNode(t.data.borderBottom))===null||s===void 0?void 0:s.data.rank,e=Math.max(e,t.data.maxRank||-1/0))}),e},Gi=n=>{n.getAllNodes().forEach(e=>{e.data.dummy==="edge-proxy"&&(n.getEdge(e.data.e.id).data.labelRank=e.data.rank,n.removeNode(e.id))})},Wi=(n,e)=>{let t,r=0,s,o=0;const{marginx:d=0,marginy:h=0}=e||{},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)&&(t===void 0&&(t=y-L/2),t=Math.min(t,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)}),t-=d,s-=h,n.getAllNodes().forEach(g=>{g.data.x-=t,g.data.y-=s}),n.getAllEdges().forEach(g=>{var y;(y=g.data.points)===null||y===void 0||y.forEach(O=>{O.x-=t,O.y-=s}),g.data.hasOwnProperty("x")&&(g.data.x-=t),g.data.hasOwnProperty("y")&&(g.data.y-=s)}),{width:r-t+d,height:o-s+h}},Yi=n=>{n.getAllEdges().forEach(e=>{const t=n.getNode(e.source),r=n.getNode(e.target);let s,o;e.data.points?(s=e.data.points[0],o=e.data.points[e.data.points.length-1]):(e.data.points=[],s={x:r.data.x,y:r.data.y},o={x:t.data.x,y:t.data.y}),e.data.points.unshift(u(t.data,s)),e.data.points.push(u(r.data,o))})},$i=n=>{n.getAllEdges().forEach(e=>{if(e.data.hasOwnProperty("x"))switch((e.data.labelpos==="l"||e.data.labelpos==="r")&&(e.data.width-=e.data.labeloffset),e.data.labelpos){case"l":e.data.x-=e.data.width/2+e.data.labeloffset;break;case"r":e.data.x+=e.data.width/2+e.data.labeloffset;break}})},Xi=n=>{n.getAllEdges().forEach(e=>{var t;e.data.reversed&&((t=e.data.points)===null||t===void 0||t.reverse())})},_i=n=>{n.getAllNodes().forEach(e=>{var t,r,s;if(!((t=n.getChildren(e.id))===null||t===void 0)&&t.length){const o=n.getNode(e.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(e=>{e.data.dummy==="border"&&n.removeNode(e.id)})},Ki=n=>{n.getAllEdges().forEach(e=>{if(e.source===e.target){const t=n.getNode(e.source);t.data.selfEdges||(t.data.selfEdges=[]),t.data.selfEdges.push(e),n.removeEdge(e.id)}})},Zi=n=>{const e=c(n);e==null||e.forEach(t=>{let r=0;t==null||t.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=>{yn(n,"selfedge",{width:p.data.width,height:p.data.height,rank:h.data.rank,order:o+ ++r,e:p},"_se")}),delete h.data.selfEdges})})},Ji=n=>{n.getAllNodes().forEach(e=>{const t=n.getNode(e.id);if(t.data.dummy==="selfedge"){const r=n.getNode(t.data.e.source),s=r.data.x+r.data.width/2,o=r.data.y,d=t.data.x-s,h=r.data.height/2;n.hasEdge(t.data.e.id)?n.updateEdgeData(t.data.e.id,t.data.e.data):n.addEdge({id:t.data.e.id,source:t.data.e.source,target:t.data.e.target,data:t.data.e.data}),n.removeNode(e.id),t.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}],t.data.e.data.x=t.data.x,t.data.e.data.y=t.data.y}})},gs=(n,e)=>{const t={};return e==null||e.forEach(r=>{n[r]!==void 0&&(t[r]=+n[r])}),t},ps=(n={})=>{const e={};return Object.keys(n).forEach(t=>{e[t.toLowerCase()]=n[t]}),e};function fn(n){return typeof n=="function"}var Ln=function(n){var e=typeof n;return n!==null&&e==="object"||e==="function"};function Yn(n){if(!n)return[0,0,0];if(_t(n))return[n,n,n];if(n.length===0)return[0,0,0];const[e,t=e,r=e]=n;return[e,t,r]}function An(n,e){let t;return fn(e)?t=e:_t(e)?t=()=>e:t=()=>n,t}function Tr(n,e,t=!0){return!e&&e!==0?r=>{const{size:s}=r.data||{};return s?Array.isArray(s)?t?Math.max(...s)||n:s:Ln(s)&&s.width&&s.height?t?Math.max(s.width,s.height)||n:[s.width,s.height]:s:n}:fn(e)?e:_t(e)?()=>e:Array.isArray(e)?()=>t?Math.max(...e)||n:e:Ln(e)&&e.width&&e.height?()=>t?Math.max(e.width,e.height)||n:[e.width,e.height]:()=>n}const jr=(n,e,t=10)=>{let r;const s=typeof e=="function"?e:()=>e||0;return n?Array.isArray(n)?r=d=>n:fn(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:Ln(y)?[y.width,y.height]:y}return t},d=>{const h=r(d),p=s(d);return Math.max(...Yn(h))+p}},Ir=n=>{if(n===null)return n;if(n instanceof Date)return new Date(n.getTime());if(n instanceof Array){const e=[];return n.forEach(t=>{e.push(t)}),e.map(t=>Ir(t))}if(typeof n=="object"){const e={};return Object.keys(n).forEach(t=>{e[t]=Ir(n[t])}),e}return n},Ke=(n,e)=>{const t=Ir(n);return t.data=t.data||{},e&&(_t(t.data.x)||(t.data.x=Math.random()*e[0]),_t(t.data.y)||(t.data.y=Math.random()*e[1])),t},Qi={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};class Hi{constructor(e={}){this.options=e,this.id="antv-dagre",this.options=Object.assign(Object.assign({},Qi),e)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericDagreLayout(!1,e,t)})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericDagreLayout(!0,e,t)})}genericDagreLayout(e,t,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:k,begin:F,controlPoints:z,radial:C,sortByCombo:W,preset:$}=s,X=new vt({tree:[]}),q=An(p||50,y),st=An(g||50,O);let ut=st,J=q;(h==="LR"||h==="RL")&&(ut=q,J=st);const mt=Tr(10,o,!1),Et=t.getAllNodes(),jt=t.getAllEdges();Et.forEach(bt=>{const Bt=Yn(mt(bt)),Qt=J(bt),$t=ut(bt),ie=Bt[0]+2*$t,de=Bt[1]+2*Qt,Jt=bt.data.layer;_t(Jt)?X.addNode({id:bt.id,data:{width:ie,height:de,layer:Jt}}):X.addNode({id:bt.id,data:{width:ie,height:de}})}),W&&(X.attachTreeStructure("combo"),Et.forEach(bt=>{const{parentId:Bt}=bt.data;Bt!==void 0&&X.hasNode(Bt)&&X.setParent(bt.id,Bt,"combo")})),jt.forEach(bt=>{X.addEdge({id:bt.id,source:bt.source,target:bt.target,data:{weight:bt.data.weight||1}})});let Pt;$!=null&&$.length&&(Pt=new vt({nodes:$})),Ii(X,{prevGraph:Pt,edgeLabelSpace:L,keepNodeOrder:!!k,nodeOrder:k||[],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(Qt=>{bt>Qt.data.x&&(bt=Qt.data.x),Bt>Qt.data.y&&(Bt=Qt.data.y)}),X.getAllEdges().forEach(Qt=>{var $t;($t=Qt.data.points)===null||$t===void 0||$t.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,Qt=h==="BT"||h==="RL"?(Jt,oe)=>oe-Jt:(Jt,oe)=>Jt-oe;X.getAllNodes().forEach(Jt=>{Jt.data.x=Jt.data.x+Dt[0],Jt.data.y=Jt.data.y+Dt[1],bt.add(Gt?Jt.data.x:Jt.data.y)});const $t=Array.from(bt).sort(Qt),ie=Gt?(Jt,oe)=>Jt.x!==oe.x:(Jt,oe)=>Jt.y!==oe.y,de=Gt?(Jt,oe,Te)=>{const Ee=Math.max(oe.y,Te.y),qe=Math.min(oe.y,Te.y);return Jt.filter(gn=>gn.y<=Ee&&gn.y>=qe)}:(Jt,oe,Te)=>{const Ee=Math.max(oe.x,Te.x),qe=Math.min(oe.x,Te.x);return Jt.filter(gn=>gn.x<=Ee&&gn.x>=qe)};X.getAllEdges().forEach((Jt,oe)=>{var Te;L&&z&&Jt.data.type!=="loop"&&(Jt.data.controlPoints=qi((Te=Jt.data.points)===null||Te===void 0?void 0:Te.map(({x:Ee,y:qe})=>({x:Ee+Dt[0],y:qe+Dt[1]})),X.getNode(Jt.source),X.getNode(Jt.target),$t,Gt,ie,de))})}let zt=[];zt=X.getAllNodes().map(bt=>Ke(bt));const Kt=X.getAllEdges();return e&&(zt.forEach(bt=>{t.mergeNodeData(bt.id,{x:bt.data.x,y:bt.data.y})}),Kt.forEach(bt=>{t.mergeEdgeData(bt.id,{controlPoints:bt.data.controlPoints})})),{nodes:zt,edges:Kt}})}}const qi=(n,e,t,r,s,o,d)=>{let h=(n==null?void 0:n.slice(1,n.length-1))||[];if(e&&t){let{x:p,y:g}=e.data,{x:y,y:O}=t.data;if(s&&(p=e.data.y,g=e.data.x,y=t.data.y,O=t.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 k=r.indexOf(O),F=Math.abs(k-L);if(F===1)h=d(h,e.data,t.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[k-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},Tn=(n,e,t)=>{const r=n.getAllNodes(),s=n.getAllEdges();if(!(r!=null&&r.length))return{nodes:[],edges:s};if(r.length===1)return e&&n.mergeNodeData(r[0].id,{x:t[0],y:t[1]}),{nodes:[Object.assign(Object.assign({},r[0]),{data:Object.assign(Object.assign({},r[0].data),{x:t[0],y:t[1]})})],edges:s}},to={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1};class eo{constructor(e={}){this.options=e,this.id="circular",this.options=Object.assign(Object.assign({},to),e)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericCircularLayout(!1,e,t)})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericCircularLayout(!0,e,t)})}genericCircularLayout(e,t,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:k,nodeSize:F}=s,z=t.getAllNodes(),C=t.getAllEdges(),[W,$,X]=ro(o,d,h),q=z==null?void 0:z.length;if(!q||q===1)return Tn(t,e,X);const st=(y-g)/q;let{radius:ut,startRadius:J,endRadius:mt}=s;if(k){const Gt=An(10,k),zt=Tr(10,F);let Kt=-1/0;z.forEach(bt=>{const Bt=zt(bt);Kt{Bt===0?le+=Kt||10:le+=(Gt(bt)||0)+(Kt||10)}),ut=le/(2*Math.PI)}else!ut&&!J&&!mt?ut=Math.min($,W)/2:!J&&mt?J=mt:J&&!mt&&(mt=J);const Et=st*O;let jt=[];L==="topology"?jt=vs(t,z):L==="topology-directed"?jt=vs(t,z,!0):L==="degree"?jt=no(t,z):jt=z.map(Gt=>Ke(Gt));const Pt=Math.ceil(q/p);for(let Gt=0;Gt{t.mergeNodeData(Gt.id,{x:Gt.data.x,y:Gt.data.y})}),{nodes:jt,edges:C}})}}const vs=(n,e,t=!1)=>{const r=[Ke(e[0])],s={},o=e.length;s[e[0].id]=!0;let d=0;return e.forEach((h,p)=>{if(p!==0)if((p===o-1||n.getDegree(h.id,"both")!==n.getDegree(e[p+1].id,"both")||n.areNeighbors(r[d].id,h.id))&&!s[h.id])r.push(Ke(h)),s[h.id]=!0,d++;else{const g=t?n.getSuccessors(r[d].id):n.getNeighbors(r[d].id);let y=!1;for(let L=0;L{t.push(Ke(r))}),t.sort((r,s)=>n.getDegree(r.id,"both")-n.getDegree(s.id,"both")),t}const ro=(n,e,t)=>{let r=n,s=e,o=t;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 $n(n){return typeof n=="string"}const ln=Array.isArray,so={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:3/2*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"};class Pr{constructor(e={}){this.options=e,this.id="concentric",this.options=Object.assign(Object.assign({},so),e)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericConcentricLayout(!1,e,t)})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericConcentricLayout(!0,e,t)})}genericConcentricLayout(e,t,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:k=3/2*Math.PI,nodeSize:F,nodeSpacing:z}=s,C=t.getAllNodes(),W=t.getAllEdges(),$=!d&&typeof window!="undefined"?window.innerWidth:d,X=!h&&typeof window!="undefined"?window.innerHeight:h,q=o||[$/2,X/2];if(!(C!=null&&C.length)||C.length===1)return Tn(t,e,q);const st=[];let ut,J=0;ln(F)?ut=Math.max(F[0],F[1]):fn(F)?(ut=-1/0,C.forEach(bt=>{const Bt=Math.max(...Yn(F(bt)));Bt>ut&&(ut=Bt)})):ut=F,ln(z)?J=Math.max(z[0],z[1]):_t(z)&&(J=z),C.forEach(bt=>{const Bt=Ke(bt);st.push(Bt);let Qt=ut;const{data:$t}=Bt;ln($t.size)?Qt=Math.max($t.size[0],$t.size[1]):_t($t.size)?Qt=$t.size:Ln($t.size)&&(Qt=Math.max($t.size.width,$t.size.height)),ut=Math.max(ut,Qt),fn(z)&&(J=Math.max(z(bt),J))});const mt={};st.forEach((bt,Bt)=>{mt[bt.id]=Bt});let Et=p;(!$n(Et)||st[0].data[Et]===void 0)&&(Et="degree"),Et==="degree"?st.sort((bt,Bt)=>t.getDegree(Bt.id,"both")-t.getDegree(bt.id,"both")):st.sort((bt,Bt)=>Bt.data[Et]-bt.data[Et]);const jt=st[0],Pt=(g||(Et==="degree"?t.getDegree(jt.id,"both"):jt.data[Et]))/4,Dt=[{nodes:[]}];let Gt=Dt[0];st.forEach(bt=>{if(Gt.nodes.length>0){const Bt=Math.abs(Et==="degree"?t.getDegree(Gt.nodes[0].id,"both")-t.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+J;if(!R){const bt=Dt.length>0&&Dt[0].nodes.length>1,Qt=(Math.min($,X)/2-zt)/(Dt.length+(bt?1:0));zt=Math.min(zt,Qt)}let Kt=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 Qt=Math.cos(bt.dTheta)-Math.cos(0),$t=Math.sin(bt.dTheta)-Math.sin(0),ie=Math.sqrt(zt*zt/(Qt*Qt+$t*$t));Kt=Math.max(ie,Kt)}bt.r=Kt,Kt+=zt}),L){let bt=0,Bt=0;for(let Qt=0;Qt{$t===0&&(Bt=Qt.r||0),Qt.r=Bt,Bt+=bt})}return Dt.forEach(bt=>{const Bt=bt.dTheta||0,Qt=bt.r||0;bt.nodes.forEach(($t,ie)=>{const de=k+(O?1:-1)*Bt*ie;$t.data.x=q[0]+Qt*Math.cos(de),$t.data.y=q[1]+Qt*Math.sin(de)})}),e&&st.forEach(bt=>t.mergeNodeData(bt.id,{x:bt.data.x,y:bt.data.y})),{nodes:st,edges:W}})}}function io(n){const e=+this._x.call(null,n),t=+this._y.call(null,n);return ms(this.cover(e,t),e,t,n)}function ms(n,e,t,r){if(isNaN(e)||isNaN(t))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,k,F,z,C,W;if(!o)return n._root=d,n;for(;o.length;)if((F=e>=(O=(h+g)/2))?h=O:g=O,(z=t>=(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),k=+n._y.call(null,o.data),e===R&&t===k)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=e>=(O=(h+g)/2))?h=O:g=O,(z=t>=(L=(p+y)/2))?p=L:y=L;while((C=z<<1|F)===(W=(k>=L)<<1|R>=O));return s[W]=o,s[C]=d,n}function oo(n){var e,t,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(t=0;ty&&(y=s),oO&&(O=o));if(p>y||g>O)return this;for(this.cover(p,g).cover(y,O),t=0;tn||n>=s||r>e||e>=o;)switch(g=(ey||(h=k.y0)>O||(p=k.x1)=C)<<1|n>=z)&&(k=L[L.length-1],L[L.length-1]=L[L.length-1-F],L[L.length-1-F]=k)}else{var W=n-+this._x.call(null,R.data),$=e-+this._y.call(null,R.data),X=W*W+$*$;if(X=(L=(d+p)/2))?d=L:p=L,(F=O>=(R=(h+g)/2))?h=R:g=R,e=t,!(t=t[z=F<<1|k]))return this;if(!t.length)break;(e[z+1&3]||e[z+2&3]||e[z+3&3])&&(r=e,C=z)}for(;t.data!==n;)if(s=t,!(t=t.next))return this;return(o=t.next)&&delete t.next,s?(o?s.next=o:delete s.next,this):e?(o?e[z]=o:delete e[z],(t=e[0]||e[1]||e[2]||e[3])&&t===(e[3]||e[2]||e[1]||e[0])&&!t.length&&(r?r[C]=t:this._root=t),this):(this._root=o,this)}function ho(n){for(var e=0,t=n.length;e=(k=(p+O)/2))?p=k:O=k,(q=t>=(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),$=+n._z.call(null,d.data),e===C&&t===W&&r===$)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=e>=(k=(p+O)/2))?p=k:O=k,(q=t>=(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)===(J=($>=z)<<2|(W>=F)<<1|C>=k));return o[J]=d,o[ut]=h,n}function No(n){Array.isArray(n)||(n=Array.from(n));const e=n.length,t=new Float64Array(e),r=new Float64Array(e),s=new Float64Array(e);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,k,F;Op&&(p=R),kg&&(g=k),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>e||e>=h||o>t||t>=p;)switch(L=(tk||(g=$.y0)>F||(y=$.z0)>z||(O=$.x1)=ut)<<2|(e>=st)<<1|n>=q)&&($=C[C.length-1],C[C.length-1]=C[C.length-1-X],C[C.length-1-X]=$)}else{var J=n-+this._x.call(null,W.data),mt=e-+this._y.call(null,W.data),Et=t-+this._z.call(null,W.data),jt=J*J+mt*mt+Et*Et;if(jtMath.sqrt(cr(n-r,2)+cr(e-s,2)+cr(t-o,2));function jo(n,e,t,r){const s=[],o=n-r,d=e-r,h=t-r,p=n+r,g=e+r,y=t+r;return this.visit((O,L,R,k,F,z,C)=>{if(!O.length)do{const W=O.data;To(n,e,t,this._x(W),this._y(W),this._z(W))<=r&&s.push(W)}while(O=O.next);return L>p||R>g||k>y||F=(F=(d+g)/2))?d=F:g=F,($=R>=(z=(h+y)/2))?h=z:y=z,(X=k>=(C=(p+O)/2))?p=C:O=C,e=t,!(t=t[q=X<<2|$<<1|W]))return this;if(!t.length)break;(e[q+1&7]||e[q+2&7]||e[q+3&7]||e[q+4&7]||e[q+5&7]||e[q+6&7]||e[q+7&7])&&(r=e,st=q)}for(;t.data!==n;)if(s=t,!(t=t.next))return this;return(o=t.next)&&delete t.next,s?(o?s.next=o:delete s.next,this):e?(o?e[q]=o:delete e[q],(t=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&t===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!t.length&&(r?r[st]=t:this._root=t),this):(this._root=o,this)}function Po(n){for(var e=0,t=n.length;e{const{nodeStrength:L,x:R,y:k,z:F,size:z}=y.data;return{x:R,y:k,z:F,size:z,index:O,id:y.id,vx:0,vy:0,vz:0,weight:o*L}}),p=(s===2?Cn(h,y=>y.x,y=>y.y):er(h,y=>y.x,y=>y.y,y=>y.z)).visitAfter(Yo),g=new Map;return h.forEach(y=>{g.set(y.id,y),Xo(y,p,s)}),h.map((y,O)=>{const{id:L,data:R}=d[O],{mass:k=1}=R;r[L]={x:y.vx/k,y:y.vy/k,z:y.vz/k}}),r}function Yo(n){let e=0,t=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=[t,r,s][d-1],g=o.x-n.x||Cr,y=o.y-n.y||Cr,O=o.z-n.z||Cr,L=[g,y,O],R=p-e;let k=0;for(let C=0;C$o(r,s,o,d,h,n,t))}const _o={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 Es{constructor(e={}){this.options=e,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=Object.assign(Object.assign({},_o),e)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericForceLayout(!1,e,t)})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericForceLayout(!0,e,t)})}stop(){this.timeInterval&&typeof window!="undefined"&&window.clearInterval(this.timeInterval),this.running=!1}tick(e=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})),t}genericForceLayout(e,t,r){return A(this,void 0,void 0,function*(){const s=Object.assign(Object.assign({},this.options),r),o=t.getAllNodes(),d=t.getAllEdges(),h=this.formatOptions(s,t),{dimensions:p,width:g,height:y,nodeSize:O,getMass:L,nodeStrength:R,edgeStrength:k,linkDistance:F}=h,z=o.map((J,mt)=>Object.assign(Object.assign({},J),{data:Object.assign(Object.assign({},J.data),{x:_t(J.data.x)?J.data.x:Math.random()*g,y:_t(J.data.y)?J.data.y:Math.random()*y,z:_t(J.data.z)?J.data.z:Math.random()*Math.sqrt(g*y),size:O(J)||30,mass:L(J),nodeStrength:R(J)})})),C=d.map(J=>Object.assign(Object.assign({},J),{data:Object.assign(Object.assign({},J.data),{edgeStrength:k(J),linkDistance:F(J,t.getNode(J.source),t.getNode(J.target))})}));if(!(o!=null&&o.length))return this.lastResult={nodes:[],edges:d},{nodes:[],edges:d};const W={};o.forEach((J,mt)=>{W[J.id]={x:0,y:0,z:0}});const $=new vt({nodes:z,edges:C});this.formatCentripetal(h,$);const{maxIteration:X,minMovement:q,onTick:st}=h;if(this.lastLayoutNodes=z,this.lastLayoutEdges=C,this.lastAssign=e,this.lastGraph=t,this.lastCalcGraph=$,this.lastOptions=h,this.lastVelMap=W,typeof window=="undefined")return;let ut=0;return new Promise(J=>{this.timeInterval=window.setInterval(()=>{(!o||!this.running)&&J({nodes:Dr(t,z),edges:d}),this.runOneStep($,t,ut,W,h),this.updatePosition(t,$,W,h),e&&z.forEach(mt=>t.mergeNodeData(mt.id,{x:mt.data.x,y:mt.data.y,z:p===3?mt.data.z:void 0})),st==null||st({nodes:Dr(t,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=t.getDegree(p.id,"both");return!y||y<5?g:y*5*g}),r.nodeSize=jr(e.nodeSize,e.nodeSpacing);const h=e.linkDistance?An(1,e.linkDistance):p=>1+r.nodeSize(t.getNode(p.source))+r.nodeSize(t.getNode(p.target));return r.linkDistance=h,r.nodeStrength=An(1,e.nodeStrength),r.edgeStrength=An(1,e.edgeStrength),r}formatCentripetal(e,t){const{dimensions:r,centripetalOptions:s,center:o,clusterNodeStrength:d,leafCluster:h,clustering:p,nodeClusterBy:g}=e,y=t.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"&&(e.clusterNodeStrength=C=>d);let L,R;if(h&&g&&(L=bs(t,g),R=Array.from(new Set(y==null?void 0:y.map(C=>C.data[g])))||[],e.centripetalOptions=Object.assign(O,{single:100,leaf:C=>{const{siblingLeaves:W,sameTypeLeaves:$}=L[C.id]||{};return($==null?void 0:$.length)===(W==null?void 0:W.length)||(R==null?void 0:R.length)===1?1:e.clusterNodeStrength(C)},others:1,center:C=>{const W=t.getDegree(C.id,"both");if(!W)return{x:100,y:100,z:0};let $;if(W===1){const{sameTypeLeaves:X=[]}=L[C.id]||{};X.length===1?$=void 0:X.length>1&&($=Ns(X))}else $=void 0;return{x:$==null?void 0:$.x,y:$==null?void 0:$.y,z:$==null?void 0:$.z}}})),p&&g){L||(L=bs(t,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.filter(X=>X.data[g]===W).map(X=>t.getNode(X.id));C[W]=Ns($)}),e.centripetalOptions=Object.assign(O,{single:W=>e.clusterNodeStrength(W),leaf:W=>e.clusterNodeStrength(W),others:W=>e.clusterNodeStrength(W),center:W=>{const $=C[W.data[g]];return{x:$==null?void 0:$.x,y:$==null?void 0:$.y,z:$==null?void 0:$.z}}})}const{leaf:k,single:F,others:z}=e.centripetalOptions||{};k&&typeof k!="function"&&(e.centripetalOptions.leaf=()=>k),F&&typeof F!="function"&&(e.centripetalOptions.single=()=>F),z&&typeof z!="function"&&(e.centripetalOptions.others=()=>z)}runOneStep(e,t,r,s,o){const d={},h=e.getAllNodes(),p=e.getAllEdges();if(!(h!=null&&h.length))return;const{monitor:g}=o;if(this.calRepulsive(e,d,o),p&&this.calAttractive(e,d,o),this.calGravity(e,t,d,o),this.updateVelocity(e,d,s,o),g){const y=this.calTotalEnergy(d,h);g({energy:y,nodes:t.getAllNodes(),edges:t.getAllEdges(),iterations:r})}}calTotalEnergy(e,t){if(!(t!=null&&t.length))return 0;let r=0;return t.forEach((s,o)=>{const d=e[s.id].x,h=e[s.id].y,p=this.options.dimensions===3?e[s.id].z:0,g=d*d+h*h+p*p,{mass:y=1}=s.data;r+=y*g*.5}),r}calRepulsive(e,t,r){const{dimensions:s,factor:o,coulombDisScale:d}=r;Wo(e,o,d*d,t,s)}calAttractive(e,t,r){const{dimensions:s,nodeSize:o}=r;e.getAllEdges().forEach((d,h)=>{const{source:p,target:g}=d,y=e.getNode(p),O=e.getNode(g);if(!y||!O)return;let L=O.data.x-y.data.x,R=O.data.y-y.data.y,k=s===3?O.data.z-y.data.z:0;!L&&!R&&(L=Math.random()*.01,R=Math.random()*.01,s===3&&!k&&(k=Math.random()*.01));const F=Math.sqrt(L*L+R*R+k*k);if(F{const{id:F,data:z}=k,{mass:C,x:W,y:$,z:X}=z,q=t.getNode(F);let st=0,ut=0,J=0,mt=L;const Et=e.getDegree(F,"in"),jt=e.getDegree(F,"out"),Pt=e.getDegree(F,"both"),Dt=o==null?void 0:o(q,Pt);if(Dt){const[Gt,zt,Kt]=Dt;st=W-Gt,ut=$-zt,mt=Kt}else st=W-O[0],ut=$-O[1],J=X-O[2];if(mt&&(r[F].x-=mt*st/C,r[F].y-=mt*ut/C,r[F].z-=mt*J/C),R){const{leaf:Gt,single:zt,others:Kt,center:le}=R,{x:bt,y:Bt,z:Qt,centerStrength:$t}=(le==null?void 0:le(q,h,p,g,y))||{x:0,y:0,z:0,centerStrength:0};if(!_t(bt)||!_t(Bt))return;const ie=(W-bt)/C,de=($-Bt)/C,Jt=(X-Qt)/C;if($t&&(r[F].x-=$t*ie,r[F].y-=$t*de,r[F].z-=$t*Jt),Pt===0){const Te=zt(q);if(!Te)return;r[F].x-=Te*ie,r[F].y-=Te*de,r[F].z-=Te*Jt;return}if(Et===0||jt===0){const Te=Gt(q,h,p);if(!Te)return;r[F].x-=Te*ie,r[F].y-=Te*de,r[F].z-=Te*Jt;return}const oe=Kt(q);if(!oe)return;r[F].x-=oe*ie,r[F].y-=oe*de,r[F].z-=oe*Jt}})}updateVelocity(e,t,r,s){const{damping:o,maxSpeed:d,interval:h,dimensions:p}=s,g=e.getAllNodes();g!=null&&g.length&&g.forEach(y=>{const{id:O}=y;let L=(r[O].x+t[O].x*h)*o||.01,R=(r[O].y+t[O].y*h)*o||.01,k=p===3?(r[O].z+t[O].z*h)*o||.01:0;const F=Math.sqrt(L*L+R*R+k*k);if(F>d){const z=d/F;L=z*L,R=z*R,k=z*k}r[O]={x:L,y:R,z:k}})}updatePosition(e,t,r,s){const{distanceThresholdMode:o,interval:d,dimensions:h}=s,p=t.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=e.getNode(O);if(_t(L.data.fx)&&_t(L.data.fy)){t.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,k=r[O].y*d,F=h===3?r[O].z*d:0;t.mergeNodeData(O,{x:y.data.x+R,y:y.data.y+k,z:y.data.z+F});const z=Math.sqrt(R*R+k*k+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 bs=(n,e)=>{const t=n.getAllNodes();if(!(t!=null&&t.length))return{};const r={};return t.forEach((s,o)=>{n.getDegree(s.id,"both")===1&&(r[s.id]=Ko(n,"leaf",s,e))}),r},Ko=(n,e,t,r)=>{const s=n.getDegree(t.id,"in"),o=n.getDegree(t.id,"out");let d=t,h=[];s===0?(d=n.getSuccessors(t.id)[0],h=n.getNeighbors(d.id)):o===0&&(d=n.getPredecessors(t.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=Zo(n,e,r,t,h);return{coreNode:d,siblingLeaves:h,sameTypeLeaves:p}},Zo=(n,e,t,r,s)=>{const o=r.data[t]||"";let d=(s==null?void 0:s.filter(h=>h.data[t]===o))||[];return e==="leaf"&&(d=d.filter(h=>n.getDegree(h.id,"in")===0||n.getDegree(h.id,"out")===0)),d},Ns=n=>{const e={x:0,y:0};n.forEach(r=>{const{x:s,y:o}=r.data;e.x+=s||0,e.y+=o||0});const t=n.length||1;return{x:e.x/t,y:e.y/t}},Dr=(n,e)=>e.map(t=>{const{id:r,data:s}=t,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 ne=me(18086);const Hu=ne.XA,qu=ne.a_,tc=ne.yQ,ec=ne.Hs,nc=ne.Ec,rc=ne.dx,sc=ne.LU,ic=ne.Rm,xn=ne.y3,oc=ne.qK,ac=ne.pb,uc=ne.j,cc=ne.sO,fc=ne.BZ,lc=ne.EK,dc=ne.Db,hc=ne.Fx,gc=ne.tU,pc=ne.Ym,vc=ne.rs,mc=ne.QR,yc=ne.TB,wc=ne.oH,Ms=ne.Sc,xc=ne.BN,Ec=ne.it,bc=ne.$r,Nc=ne.QM,Mc=ne.AV;var Sc=(ne.y3,ne.y3);const Oc=ne.GH,Ac=ne.SO,Tc=ne.uZ,jc=ne.yU,Ic=ne.F1,Pc=ne.re,Ss=n=>{const e=[],t=n.length;for(let r=0;re[s][r]+e[r][o]&&(e[s][o]=e[s][r]+e[r][o]);return e},Os=(n,e)=>{const{nodes:t,edges:r}=n,s=[],o={};if(!t)throw new Error("invalid nodes data!");return t&&t.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,e||(s[y][g]=1))}),s},Jo=(n,e)=>{const t=[];return n.forEach(r=>{const s=[];r.forEach(o=>{s.push(o*e)}),t.push(s)}),t},Qo=n=>{let e=1/0,t=1/0,r=-1/0,s=-1/0;return n.forEach(o=>{let d=o.data.size;ln(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];e>p&&(e=p),t>y&&(t=y),rMath.sqrt((n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y)),zr=(n,e,t,r="TB",s,o={})=>{if(!(e!=null&&e.length))return;const{stopBranchFn:d,stopAllFn:h}=o;for(let p=0;p{const C=Ke(h[z]);C.data.x=F[0]+o[0],C.data.y=F[1]+o[1],R.push(C)}),e&&R.forEach(F=>t.mergeNodeData(F.id,{x:F.data.x,y:F.data.y})),{nodes:R,edges:p}})}}const qo=n=>{let e=-999999;n.forEach(t=>{t.forEach(r=>{r!==1/0&&e{t.forEach((s,o)=>{s===1/0&&(n[r][o]=e)})})},ta=n=>{const t=xn.mul(xn.pow(n,2),-.5),r=t.mean("row"),s=t.mean("column"),o=t.mean();t.add(o).subRowVector(r).subColumnVector(s);const d=new Ms(t),h=xn.sqrt(d.diagonalMatrix).diagonal();return d.leftSingularVectors.toJSON().map(p=>xn.mul([p],[h]).toJSON()[0].splice(0,2))};function js(n){return!!n.tick&&!!n.stop}const ea={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},na={center:[0,0],comboPadding:10,treeKey:"combo"};class ra{constructor(e={}){this.options=e,this.id="comboCombined",this.options=Object.assign(Object.assign({},na),e)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericComboCombinedLayout(!1,e,t)})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericComboCombinedLayout(!0,e,t)})}genericComboCombinedLayout(e,t,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=t.getAllNodes().filter(J=>!J.data._isCombo),g=t.getAllNodes().filter(J=>J.data._isCombo),y=t.getAllEdges(),O=p==null?void 0:p.length;if(!O||O===1)return Tn(t,e,o);const L=[],R=new Map;p.forEach(J=>{R.set(J.id,J)});const k=new Map;g.forEach(J=>{k.set(J.id,J)});const F=new Map,z=this.getInnerGraphs(t,d,R,k,y,s,F);yield Promise.all(z);const C=new Map,W=[],$=new Map;let X=!0;t.getRoots(d).forEach(J=>{const mt=F.get(J.id),Et=k.get(J.id)||R.get(J.id),jt={id:J.id,data:Object.assign(Object.assign({},J.data),{x:mt.data.x||Et.data.x,y:mt.data.y||Et.data.y,fx:mt.data.fx||Et.data.fx,fy:mt.data.fy||Et.data.fy,mass:mt.data.mass||Et.data.mass,size:mt.data.size})};W.push(jt),C.set(J.id,!0),!isNaN(jt.data.x)&&jt.data.x!==0&&!isNaN(jt.data.y)&&jt.data.y!==0?X=!1:(jt.data.x=Math.random()*100,jt.data.y=Math.random()*100),zr(t,[J],Pt=>{Pt.id!==J.id&&$.set(Pt.id,J.id)},"TB",d)});const q=[];y.forEach(J=>{const mt=$.get(J.source)||J.source,Et=$.get(J.target)||J.target;mt!==Et&&C.has(mt)&&C.has(Et)&&q.push({id:J.id,source:mt,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 J=new vt({nodes:W,edges:q}),mt=h||new Es;X&&ea[mt.id]&&(yield(W.length<100?new Ts:new Pr).assign(J));const Et=Object.assign({center:o,kg:5,preventOverlap:!0,animate:!1},mt.id==="force"?{gravity:1,factor:4,linkDistance:(jt,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 Is(mt,J,Et)}F.forEach(J=>{var mt;const Et=st.nodes.find(Dt=>Dt.id===J.id);if(Et){const{x:Dt,y:Gt}=Et.data;J.data.visited=!0,J.data.x=Dt,J.data.y=Gt,L.push({id:J.id,data:{x:Dt,y:Gt}})}const{x:jt,y:Pt}=J.data;(mt=J.data.nodes)===null||mt===void 0||mt.forEach(Dt=>{L.push({id:Dt.id,data:{x:Dt.data.x+jt,y:Dt.data.y+Pt}})})}),F.forEach(({data:J})=>{const{x:mt,y:Et,visited:jt,nodes:Pt}=J;Pt==null||Pt.forEach(Dt=>{if(!jt){const Gt=L.find(zt=>zt.id===Dt.id);Gt.data.x+=mt||0,Gt.data.y+=Et||0}})})}return e&&L.forEach(J=>{t.mergeNodeData(J.id,{x:J.data.x,y:J.data.y})}),{nodes:L,edges:y}})}initVals(e){const t=Object.assign({},e),{nodeSize:r,spacing:s,comboPadding:o}=e;let d,h;if(_t(s)?h=()=>s:fn(s)?h=s:h=()=>0,t.spacing=h,!r)d=g=>{const y=h(g);return g.size?ln(g.size)?((g.size[0]>g.size[1]?g.size[0]:g.size[1])+y)/2:Ln(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(fn(r))d=g=>{const y=r(g),O=h(g);return ln(g.size)?((g.size[0]>g.size[1]?g.size[0]:g.size[1])+O)/2:((y||32)+O)/2};else if(ln(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}t.nodeSize=d;let p;return _t(o)?p=()=>o:ln(o)?p=()=>Math.max.apply(null,o):fn(o)?p=o:p=()=>0,t.comboPadding=p,t}getInnerGraphs(e,t,r,s,o,d,h){const{nodeSize:p,comboPadding:g,spacing:y,innerLayout:O}=d,L=O||new Pr({}),R={center:[0,0],preventOverlap:!0,nodeSpacing:y},k=[],F=z=>{let C=(g==null?void 0:g(z))||10;return ln(C)&&(C=Math.max(...C)),{size:C?[C*2,C*2]:[30,30],padding:C}};return e.getRoots(t).forEach(z=>{h.set(z.id,{id:z.id,data:{nodes:[],size:F(z).size}});let C=Promise.resolve();zr(e,[z],W=>{var $;if(!W.data._isCombo)return;const{size:X,padding:q}=F(W);if(!(!(($=e.getChildren(W.id,t))===null||$===void 0)&&$.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,J=e.getChildren(W.id,t).map(jt=>{if(jt.data._isCombo)return h.has(jt.id)||h.set(jt.id,{id:jt.id,data:Object.assign({},jt.data)}),ut.set(jt.id,!0),h.get(jt.id);const Pt=r.get(jt.id)||s.get(jt.id);return ut.set(jt.id,!0),{id:jt.id,data:Object.assign(Object.assign({},Pt.data),jt.data)}}),mt={nodes:J,edges:o.filter(jt=>ut.has(jt.source)&&ut.has(jt.target))};let Et=1/0;J.forEach(jt=>{var Pt;let{size:Dt}=jt.data;Dt||(Dt=((Pt=h.get(jt.id))===null||Pt===void 0?void 0:Pt.data.size)||(p==null?void 0:p(jt))||[30,30]),_t(Dt)&&(Dt=[Dt,Dt]);const[Gt,zt]=Dt;Et>Gt&&(Et=Gt),Et>zt&&(Et=zt),jt.data.size=Dt}),C=C.then(()=>A(this,void 0,void 0,function*(){const jt=new vt(mt);yield Is(L,jt,R,!0);const{minX:Pt,minY:Dt,maxX:Gt,maxY:zt}=Qo(J),Kt={x:(Gt+Pt)/2,y:(zt+Dt)/2};mt.nodes.forEach(bt=>{bt.data.x-=Kt.x,bt.data.y-=Kt.y});const le=[Math.max(Gt-Pt,Et)+q*2,Math.max(zt-Dt,Et)+q*2];h.get(W.id).data.size=le,h.get(W.id).data.nodes=J}))}return!0},"BT",t),k.push(C)}),k}}function Is(n,e,t,r){var s;return A(this,void 0,void 0,function*(){return js(n)?(n.execute(e,t),n.stop(),n.tick((s=t.iterations)!==null&&s!==void 0?s:300)):r?yield n.assign(e,t):yield n.execute(e,t)})}var sa=function(n){return typeof n=="object"&&n!==null},ia=sa,oa={}.toString,aa=function(n,e){return oa.call(n)==="[object "+e+"]"},ua=aa,ca=function(n){if(!ia(n)||!ua(n,"Object"))return!1;if(Object.getPrototypeOf(n)===null)return!0;for(var e=n;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(n)===e},Fr=ca,fa=5;function la(n,e){if(Object.hasOwn)return Object.hasOwn(n,e);if(n==null)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(Object(n),e)}function Ps(n,e,t,r){t=t||0,r=r||fa;for(var s in e)if(la(e,s)){var o=e[s];o!==null&&Fr(o)?(Fr(n[s])||(n[s]={}),t[e(q,st,d),q])),X;for(z=0,h=new Array(C);z{}};function Ds(){for(var n=0,e=arguments.length,t={},r;n=0&&(r=t.slice(s+1),t=t.slice(0,s)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:r}})}nr.prototype=Ds.prototype={constructor:nr,on:function(n,e){var t=this._,r=wa(n+"",t),s,o=-1,d=r.length;if(arguments.length<2){for(;++o0)for(var t=new Array(s),r=0,s,o;r=0&&n._call.call(void 0,e),n=n._next;--Dn}function Vs(){jn=(sr=Zn.now())+ir,Dn=Xn=0;try{ba()}finally{Dn=0,Ma(),jn=0}}function Na(){var n=Zn.now(),e=n-sr;e>ks&&(ir-=e,sr=n)}function Ma(){for(var n,e=rr,t,r=1/0;e;)e._call?(r>e._time&&(r=e._time),n=e,e=e._next):(t=e._next,e._next=null,e=n?n._next=t:rr=t);Kn=n,Ur(r)}function Ur(n){if(!Dn){Xn&&(Xn=clearTimeout(Xn));var e=n-jn;e>24?(n<1/0&&(Xn=setTimeout(Vs,n-Zn.now()-ir)),_n&&(_n=clearInterval(_n))):(_n||(sr=Zn.now(),_n=setInterval(Na,ks)),Dn=1,Bs(Vs))}}const Sa=1664525,Oa=1013904223,Gs=4294967296;function Aa(){let n=1;return()=>(n=(Sa*n+Oa)%Gs)/Gs}function Ta(n){return n.x}function ja(n){return n.y}var Ia=10,Pa=Math.PI*(3-Math.sqrt(5));function Ra(n){var e,t=1,r=.001,s=1-Math.pow(r,1/300),o=0,d=.6,h=new Map,p=Br(O),g=Fs("tick","end"),y=Aa();n==null&&(n=[]);function O(){L(),g.call("tick",e),t1?(z==null?h.delete(F):h.set(F,k(z)),e):h.get(F)},find:function(F,z,C){var W=0,$=n.length,X,q,st,ut,J;for(C==null?C=1/0:C*=C,W=0;W<$;++W)ut=n[W],X=F-ut.x,q=z-ut.y,st=X*X+q*q,st1?(g.on(F,z),e):g.on(F)}}}function La(){var n,e,t,r,s=Ce(-30),o,d=1,h=1/0,p=.81;function g(R){var k,F=n.length,z=Cn(n,Ta,ja).visitAfter(O);for(r=R,k=0;k=h)return;(R.data!==e||R.next)&&(C===0&&(C=En(t),X+=C*C),W===0&&(W=En(t),X+=W*W),XL.index){var jt=R-J.x-J.vx,Pt=k-J.y-J.vy,Dt=jt*jt+Pt*Pt;DtR+Et||stk+Et||utg.r&&(g.r=g[y].r)}function p(){if(e){var g,y=e.length,O;for(t=new Array(y),g=0;gt.id},manyBody:{},center:{x:0,y:0}},this.context={options:{},assign:!1,nodes:[],edges:[]},Rs(this.options,e),this.options.forceSimulation&&(this.simulation=this.options.forceSimulation)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericLayout(!1,e,t)})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericLayout(!0,e,t)})}stop(){this.simulation.stop()}tick(e){return this.simulation.tick(e),this.getResult()}restart(){this.simulation.restart()}setFixedPosition(e,t){const r=this.context.nodes.find(s=>s.id===e);r&&t.forEach((s,o)=>{if(typeof s=="number"||s===null){const d=["fx","fy","fz"][o];r[d]=s}})}getOptions(e){var t,r;const s=Rs({},this.options,e);return s.collide&&((t=s.collide)===null||t===void 0?void 0:t.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(e,t,r){var s;return A(this,void 0,void 0,function*(){const o=this.getOptions(r),d=t.getAllNodes().map(({id:y,data:O})=>Object.assign(Object.assign({id:y},O),Ls(O.data,this.config.inputNodeAttrs))),h=t.getAllEdges().map(y=>Object.assign({},y));Object.assign(this.context,{assign:e,nodes:d,edges:h,graph:t});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:e,nodes:t,edges:r,graph:s}=this.context,o=t.map(h=>({id:h.id,data:Object.assign(Object.assign({},h.data),Ls(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 e&&o.forEach(h=>s.mergeNodeData(h.id,h.data)),{nodes:o,edges:d}}initSimulation(){return Ra()}setSimulation(e){const t=this.simulation||this.options.forceSimulation||this.initSimulation();return this.simulation||(this.simulation=t.on("tick",()=>{var r;return(r=e.onTick)===null||r===void 0?void 0:r.call(e,this.getResult())}).on("end",()=>{var r;return(r=this.resolver)===null||r===void 0?void 0:r.call(this,this.getResult())})),Ys(t,this.config.simulationAttrs.map(r=>[r,e[r]])),Object.entries(this.forceMap).forEach(([r,s])=>{const o=r;if(e[r]){let d=t.force(o);d||(d=s(),t.force(o,d)),Ys(d,Object.entries(e[o]))}else t.force(o,null)}),t}}const Ys=(n,e)=>e.reduce((t,[r,s])=>!t[r]||s===void 0?t:t[r].call(n,s),n);function Ne(n){return function(){return n}}function He(n){return(n()-.5)*1e-6}function Va(n){return n.index}function $s(n,e){var t=n.get(e);if(!t)throw new Error("node not found: "+e);return t}function Ga(n){var e=Va,t=L,r,s=Ne(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,$=n.length;W1&&(mt=ut.y+ut.vy-st.y-st.vy||He(y)),h>2&&(Et=ut.z+ut.vz-st.z-st.vz||He(y)),jt=Math.sqrt(J*J+mt*mt+Et*Et),jt=(jt-o[X])/jt*C*r[X],J*=jt,mt*=jt,Et*=jt,ut.vx-=J*(Pt=g[X]),h>1&&(ut.vy-=mt*Pt),h>2&&(ut.vz-=Et*Pt),st.vx+=J*(Pt=1-Pt),h>1&&(st.vy+=mt*Pt),h>2&&(st.vz+=Et*Pt)}function k(){if(d){var C,W=d.length,$=n.length,X=new Map(d.map((st,ut)=>[e(st,ut,d),st])),q;for(C=0,p=new Array(W);C<$;++C)q=n[C],q.index=C,typeof q.source!="object"&&(q.source=$s(X,q.source)),typeof q.target!="object"&&(q.target=$s(X,q.target)),p[q.source.index]=(p[q.source.index]||0)+1,p[q.target.index]=(p[q.target.index]||0)+1;for(C=0,g=new Array($);C<$;++C)q=n[C],g[C]=p[q.source.index]/(p[q.source.index]+p[q.target.index]);r=new Array($),F(),o=new Array($),z()}}function F(){if(d)for(var C=0,W=n.length;Ctypeof $=="function")||Math.random,h=W.find($=>[1,2,3].includes($))||2,k()},R.links=function(C){return arguments.length?(n=C,k(),R):n},R.id=function(C){return arguments.length?(e=C,R):e},R.iterations=function(C){return arguments.length?(O=+C,R):O},R.strength=function(C){return arguments.length?(t=typeof C=="function"?C:Ne(+C),F(),R):t},R.distance=function(C){return arguments.length?(s=typeof C=="function"?C:Ne(+C),z(),R):s},R}function Wa(n){const e=+this._x.call(null,n);return Xs(this.cover(e),e,n)}function Xs(n,e,t){if(isNaN(e))return n;var r,s=n._root,o={data:t},d=n._x0,h=n._x1,p,g,y,O,L;if(!s)return n._root=o,n;for(;s.length;)if((y=e>=(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),e===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=e>=(p=(d+h)/2))?d=p:h=p;while((O=+y)==(L=+(g>=p)));return r[L]=s,r[O]=o,n}function Ya(n){Array.isArray(n)||(n=Array.from(n));const e=n.length,t=new Float64Array(e);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>=t;)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,e=t,!(t=t[O=+y]))return this;if(!t.length)break;e[O+1&1]&&(r=e,L=O)}for(;t.data!==n;)if(s=t,!(t=t.next))return this;return(o=t.next)&&delete t.next,s?(o?s.next=o:delete s.next,this):e?(o?e[O]=o:delete e[O],(t=e[0]||e[1])&&t===(e[1]||e[0])&&!t.length&&(r?r[L]=t:this._root=t),this):(this._root=o,this)}function Ja(n){for(var e=0,t=n.length;e(n=(ru*n+su)%Ks)/Ks}var Zs=3;function Wr(n){return n.x}function Js(n){return n.y}function ou(n){return n.z}var au=10,uu=Math.PI*(3-Math.sqrt(5)),cu=Math.PI*20/(9+Math.sqrt(221));function fu(n,e){e=e||2;var t=Math.min(Zs,Math.max(1,Math.round(e))),r,s=1,o=.001,d=1-Math.pow(o,1/300),h=0,p=.6,g=new Map,y=Br(R),O=Fs("tick","end"),L=iu();n==null&&(n=[]);function R(){k(),O.call("tick",r),s1&&(X.fy==null?X.y+=X.vy*=p:(X.y=X.fy,X.vy=0)),t>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,$;C1&&isNaN($.y)||t>2&&isNaN($.z)){var X=au*(t>2?Math.cbrt(.5+C):t>1?Math.sqrt(.5+C):C),q=C*uu,st=C*cu;t===1?$.x=X:t===2?($.x=X*Math.cos(q),$.y=X*Math.sin(q)):($.x=X*Math.sin(q)*Math.cos(st),$.y=X*Math.cos(q),$.z=X*Math.sin(q)*Math.sin(st))}(isNaN($.vx)||t>1&&isNaN($.vy)||t>2&&isNaN($.vz))&&($.vx=0,t>1&&($.vy=0),t>2&&($.vz=0))}}function z(C){return C.initialize&&C.initialize(n,L,t),C}return F(),r={tick:k,restart:function(){return y.restart(R),r},stop:function(){return y.stop(),r},numDimensions:function(C){return arguments.length?(t=Math.min(Zs,Math.max(1,Math.round(C))),g.forEach(z),r):t},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,$=(t>1?C.shift():null)||0,X=(t>2?C.shift():null)||0,q=C.shift()||1/0,st=0,ut=n.length,J,mt,Et,jt,Pt,Dt;for(q*=q,st=0;st1?(O.on(C,W),r):O.on(C)}}}function lu(){var n,e,t,r,s,o=Ne(-30),d,h=1,p=1/0,g=.81;function y(k){var F,z=n.length,C=(e===1?Vr(n,Wr):e===2?Cn(n,Wr,Js):e===3?er(n,Wr,Js,ou):null).visitAfter(L);for(s=k,F=0;F1&&(k.y=X/W),e>2&&(k.z=q/W)}else{z=k,z.x=z.data.x,e>1&&(z.y=z.data.y),e>2&&(z.z=z.data.z);do F+=d[z.data.index];while(z=z.next)}k.value=F}function R(k,F,z,C,W){if(!k.value)return!0;var $=[z,C,W][e-1],X=k.x-t.x,q=e>1?k.y-t.y:0,st=e>2?k.z-t.z:0,ut=$-F,J=X*X+q*q+st*st;if(ut*ut/g1&&q===0&&(q=He(r),J+=q*q),e>2&&st===0&&(st=He(r),J+=st*st),J1&&(t.vy+=q*k.value*s/J),e>2&&(t.vz+=st*k.value*s/J)),!0;if(k.length||J>=p)return;(k.data!==t||k.next)&&(X===0&&(X=He(r),J+=X*X),e>1&&q===0&&(q=He(r),J+=q*q),e>2&&st===0&&(st=He(r),J+=st*st),J1&&(t.vy+=q*ut),e>2&&(t.vz+=st*ut));while(k=k.next)}return y.initialize=function(k,...F){n=k,r=F.find(z=>typeof z=="function")||Math.random,e=F.find(z=>[1,2,3].includes(z))||2,O()},y.strength=function(k){return arguments.length?(o=typeof k=="function"?k:Ne(+k),O(),y):o},y.distanceMin=function(k){return arguments.length?(h=k*k,y):Math.sqrt(h)},y.distanceMax=function(k){return arguments.length?(p=k*k,y):Math.sqrt(p)},y.theta=function(k){return arguments.length?(g=k*k,y):Math.sqrt(g)},y}function du(n,e,t){var r,s=1;n==null&&(n=0),e==null&&(e=0),t==null&&(t=0);function o(){var d,h=r.length,p,g=0,y=0,O=0;for(d=0;d1&&(F=R.y+R.vy),t>2&&(z=R.z+R.vz),L.visit(X);function X(q,st,ut,J,mt,Et,jt){var Pt=[st,ut,J,mt,Et,jt],Dt=Pt[0],Gt=Pt[1],zt=Pt[2],Kt=Pt[t],le=Pt[t+1],bt=Pt[t+2],Bt=q.data,Qt=q.r,$t=C+Qt;if(Bt){if(Bt.index>R.index){var ie=k-Bt.x-Bt.vx,de=t>1?F-Bt.y-Bt.vy:0,Jt=t>2?z-Bt.z-Bt.vz:0,oe=ie*ie+de*de+Jt*Jt;oe<$t*$t&&(ie===0&&(ie=He(s),oe+=ie*ie),t>1&&de===0&&(de=He(s),oe+=de*de),t>2&&Jt===0&&(Jt=He(s),oe+=Jt*Jt),oe=($t-(oe=Math.sqrt(oe)))/oe*o,R.vx+=(ie*=oe)*($t=(Qt*=Qt)/(W+Qt)),t>1&&(R.vy+=(de*=oe)*$t),t>2&&(R.vz+=(Jt*=oe)*$t),Bt.vx-=ie*($t=1-$t),t>1&&(Bt.vy-=de*$t),t>2&&(Bt.vz-=Jt*$t))}return}return Dt>k+$t||Kt1&&(Gt>F+$t||le2&&(zt>z+$t||bty.r&&(y.r=y[O].r)}function g(){if(e){var y,O=e.length,L;for(r=new Array(O),y=0;ytypeof L=="function")||Math.random,t=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:Ne(+y),g(),h):n},h}function pu(n,e,t,r){var s,o,d=Ne(.1),h,p;typeof n!="function"&&(n=Ne(+n)),e==null&&(e=0),t==null&&(t=0),r==null&&(r=0);function g(O){for(var L=0,R=s.length;L1&&(k.vy+=z*$),o>2&&(k.vz+=C*$)}}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:Ne(+O),y(),g):d},g.radius=function(O){return arguments.length?(n=typeof O=="function"?O:Ne(+O),y(),g):n},g.x=function(O){return arguments.length?(e=+O,g):e},g.y=function(O){return arguments.length?(t=+O,g):t},g.z=function(O){return arguments.length?(r=+O,g):r},g}function vu(n){var e=Ne(.1),t,r,s;typeof n!="function"&&(n=Ne(n==null?0:+n));function o(h){for(var p=0,g=t.length,y;pe.id},manyBody:{},center:{x:0,y:0,z:0}}}initSimulation(){return fu()}}var Hs=me(92546),xu=me.n(Hs);class or{constructor(e){this.id="dagre",this.options={},Object.assign(this.options,or.defaultOptions,e)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericDagreLayout(!1,e,Object.assign(Object.assign({},this.options),t))})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericDagreLayout(!0,e,Object.assign(Object.assign({},this.options),t))})}genericDagreLayout(e,t,r){return A(this,void 0,void 0,function*(){const{nodeSize:s}=r,o=new Hs.graphlib.Graph;o.setGraph(r),o.setDefaultEdgeLabel(()=>({}));const d=t.getAllNodes(),h=t.getAllEdges();[...d,...h].some(({id:g})=>_t(g))&&console.error("Dagre layout only support string id, it will convert number to string."),t.getAllNodes().forEach(g=>{const{id:y}=g,O=Object.assign({},g.data);if(s!==void 0){const[L,R]=Yn(fn(s)?s(g):s);Object.assign(O,{width:L,height:R})}o.setNode(y.toString(),O)}),t.getAllEdges().forEach(({id:g,source:y,target:O})=>{o.setEdge(y.toString(),O.toString(),{id:g})}),xu().layout(o);const p={nodes:[],edges:[]};return o.nodes().forEach(g=>{const y=o.node(g);p.nodes.push({id:g,data:y}),e&&t.mergeNodeData(g,y)}),o.edges().forEach(g=>{const y=o.edge(g),{id:O}=y,L=f(y,["id"]),{v:R,w:k}=g;p.edges.push({id:O,source:R,target:k,data:L}),e&&t.mergeEdgeData(O,L)}),p})}}or.defaultOptions={};class $r{constructor(e){this.id=e.id||0,this.rx=e.rx,this.ry=e.ry,this.fx=0,this.fy=0,this.mass=e.mass,this.degree=e.degree,this.g=e.g||0}distanceTo(e){const t=this.rx-e.rx,r=this.ry-e.ry;return Math.hypot(t,r)}setPos(e,t){this.rx=e,this.ry=t}resetForce(){this.fx=0,this.fy=0}addForce(e){const t=e.rx-this.rx,r=e.ry-this.ry;let s=Math.hypot(t,r);s=s<1e-4?1e-4:s;const o=this.g*(this.degree+1)*(e.degree+1)/s;this.fx+=o*t/s,this.fy+=o*r/s}in(e){return e.contains(this.rx,this.ry)}add(e){const t=this.mass+e.mass,r=(this.rx*this.mass+e.rx*e.mass)/t,s=(this.ry*this.mass+e.ry*e.mass)/t,o=this.degree+e.degree,d={rx:r,ry:s,mass:t,degree:o};return new $r(d)}}class zn{constructor(e){this.xmid=e.xmid,this.ymid=e.ymid,this.length=e.length,this.massCenter=e.massCenter||[0,0],this.mass=e.mass||1}getLength(){return this.length}contains(e,t){const r=this.length/2;return e<=this.xmid+r&&e>=this.xmid-r&&t<=this.ymid+r&&t>=this.ymid-r}NW(){const e=this.xmid-this.length/4,t=this.ymid+this.length/4,r=this.length/2,s={xmid:e,ymid:t,length:r};return new zn(s)}NE(){const e=this.xmid+this.length/4,t=this.ymid+this.length/4,r=this.length/2,s={xmid:e,ymid:t,length:r};return new zn(s)}SW(){const e=this.xmid-this.length/4,t=this.ymid-this.length/4,r=this.length/2,s={xmid:e,ymid:t,length:r};return new zn(s)}SE(){const e=this.xmid+this.length/4,t=this.ymid-this.length/4,r=this.length/2,s={xmid:e,ymid:t,length:r};return new zn(s)}}class Fn{constructor(e){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,e!=null&&(this.quad=e)}insert(e){if(this.body==null){this.body=e;return}this._isExternal()?(this.quad&&(this.NW=new Fn(this.quad.NW()),this.NE=new Fn(this.quad.NE()),this.SW=new Fn(this.quad.SW()),this.SE=new Fn(this.quad.SE())),this._putBody(this.body),this._putBody(e),this.body=this.body.add(e)):(this.body=this.body.add(e),this._putBody(e))}_putBody(e){this.quad&&(e.in(this.quad.NW())&&this.NW?this.NW.insert(e):e.in(this.quad.NE())&&this.NE?this.NE.insert(e):e.in(this.quad.SW())&&this.SW?this.SW.insert(e):e.in(this.quad.SE())&&this.SE&&this.SE.insert(e))}_isExternal(){return this.NW==null&&this.NE==null&&this.SW==null&&this.SE==null}updateForce(e){if(!(this.body==null||e===this.body))if(this._isExternal())e.addForce(this.body);else{const t=this.quad?this.quad.getLength():0,r=this.body.distanceTo(e);t/rKe(C,[h,p])),k=s.filter(C=>{const{source:W,target:$}=C;return W!==$}),F=new vt({nodes:R,edges:k}),z=this.getSizes(F,O);if(this.run(F,t,y,z,e,d),g){for(let W=0;W250&&(r.barnesHut=!0),p===void 0&&t>100&&(r.prune=!0),g===0&&!p?(r.maxIteration=250,t<=200&&t>100?r.maxIteration=1e3:t>200&&(r.maxIteration=1200)):g===0&&p&&(r.maxIteration=100,t<=200&&t>100?r.maxIteration=500:t>200&&(r.maxIteration=950)),y||(r.kr=50,t>100&&t<=500?r.kr=20:t>500&&(r.kr=1)),O||(r.kg=20,t>100&&t<=500?r.kg=10:t>500&&(r.kg=1)),r}run(e,t,r,s,o,d){const{kr:h,barnesHut:p,onTick:g}=d,y=e.getAllNodes();let O=0,L=r;const R={},k={},F={};for(let z=0;z0;)O=this.oneStep(e,{iter:L,preventOverlapIters:50,krPrime:100,sg:O,forces:R,preForces:k,bodies:F,sizes:s},d),L--,g==null||g({nodes:y,edges:t.getAllEdges()});return e}oneStep(e,t,r){const{iter:s,preventOverlapIters:o,krPrime:d,sg:h,preForces:p,bodies:g,sizes:y}=t;let{forces:O}=t;const{preventOverlap:L,barnesHut:R}=r,k=e.getAllNodes();for(let F=0;Fo||!L)?O=this.getOptRepGraForces(e,O,g,r):O=this.getRepGraForces(e,s,o,O,d,y,r),this.updatePos(e,O,p,h,r)}getAttrForces(e,t,r,s,o,d){const{preventOverlap:h,dissuadeHubs:p,mode:g,prune:y}=d,O=e.getAllEdges();for(let L=0;L0&&(q=X,st=X),o[R][0]+=q*$[0],o[k][0]-=st*$[0],o[R][1]+=q*$[1],o[k][1]-=st*$[1]}return o}getOptRepGraForces(e,t,r,s){const{kg:o,center:d,prune:h}=s,p=e.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 k=Math.max(O-y,R-L),F={xmid:(O+y)/2,ymid:(R+L)/2,length:k,massCenter:d,mass:g},z=new zn(F),C=new Fn(z);for(let W=0;W0&&(Et=g*(C+1)*(ut+1)/mt),s[z.id][0]-=Et*J[0],s[st.id][0]+=Et*J[0],s[z.id][1]-=Et*J[1],s[st.id][1]+=Et*J[1]}const W=[z.data.x-O[0],z.data.y-O[1]],$=Math.hypot(W[0],W[1]);W[0]=W[0]/$,W[1]=W[1]/$;const X=y*(C+1);s[z.id][0]-=X*W[0],s[z.id][1]-=X*W[1]}return s}updatePos(e,t,r,s,o){const{ks:d,tao:h,prune:p,ksmax:g}=o,y=e.getAllNodes(),O=y.length,L=[],R=[];let k=0,F=0,z=s;for(let W=0;W1.5*C?1.5*C:z);for(let W=0;WJ?J:st;const mt=st*t[$][0],Et=st*t[$][1];e.mergeNodeData($,{x:X.x+mt,y:X.y+Et})}return z}}const Nu={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},Mu=800;class Su{constructor(e={}){this.options=e,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=Object.assign(Object.assign({},Nu),e)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericFruchtermanLayout(!1,e,t)})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericFruchtermanLayout(!0,e,t)})}stop(){this.timeInterval&&typeof window!="undefined"&&window.clearInterval(this.timeInterval),this.running=!1}tick(e=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})),t}genericFruchtermanLayout(e,t,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=t.getAllNodes(),k=t.getAllEdges();if(!(R!=null&&R.length)){const $={nodes:[],edges:k};return this.lastResult=$,$}if(R.length===1){e&&t.mergeNodeData(R[0].id,{x:p[0],y:p[1],z:o===3?p[2]:void 0});const $={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:k};return this.lastResult=$,$}const F=R.map($=>Ke($,[d,h])),z=new vt({nodes:F,edges:k}),C={};if(g&&F.forEach($=>{const X=$.data[y];C[X]||(C[X]={name:X,cx:0,cy:0,count:0})}),this.lastLayoutNodes=F,this.lastLayoutEdges=k,this.lastAssign=e,this.lastGraph=z,this.lastOptions=s,this.lastClusterMap=C,typeof window=="undefined")return;let W=0;return new Promise($=>{this.timeInterval=window.setInterval(()=>{if(!this.running){$({nodes:F,edges:k});return}this.runOneStep(z,C,s),e&&F.forEach(({id:X,data:q})=>t.mergeNodeData(X,{x:q.x,y:q.y,z:o===3?q.z:void 0})),L==null||L({nodes:F,edges:k}),W++,W>=O&&(window.clearInterval(this.timeInterval),$({nodes:F,edges:k}))},0),this.running=!0})})}formatOptions(e={}){const t=Object.assign(Object.assign({},this.options),e),{clustering:r,nodeClusterBy:s}=t,{center:o,width:d,height:h}=t;return t.width=!d&&typeof window!="undefined"?window.innerWidth:d,t.height=!h&&typeof window!="undefined"?window.innerHeight:h,t.center=o||[t.width/2,t.height/2],t.clustering=r&&!!s,t}runOneStep(e,t,r){const{dimensions:s,height:o,width:d,gravity:h,center:p,speed:g,clustering:y,nodeClusterBy:O,clusterGravity:L}=r,R=o*d,k=Math.sqrt(R)/10,F=e.getAllNodes(),z=R/(F.length+1),C=Math.sqrt(z),W={};if(this.applyCalculate(e,W,C,z),y){for(const X in t)t[X].cx=0,t[X].cy=0,t[X].count=0;F.forEach(X=>{const{data:q}=X,st=t[q[O]];_t(q.x)&&(st.cx+=q.x),_t(q.y)&&(st.cy+=q.y),st.count++});for(const X in t)t[X].cx/=t[X].count,t[X].cy/=t[X].count;const $=L||h;F.forEach((X,q)=>{const{id:st,data:ut}=X;if(!_t(ut.x)||!_t(ut.y))return;const J=t[ut[O]],mt=Math.sqrt((ut.x-J.cx)*(ut.x-J.cx)+(ut.y-J.cy)*(ut.y-J.cy)),Et=C*$;W[st].x-=Et*(ut.x-J.cx)/mt,W[st].y-=Et*(ut.y-J.cy)/mt})}F.forEach(($,X)=>{const{id:q,data:st}=$;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(($,X)=>{const{id:q,data:st}=$;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 J=Math.min(k*(g/Mu),ut);e.mergeNodeData(q,{x:st.x+W[q].x/ut*J,y:st.y+W[q].y/ut*J,z:s===3?st.z+W[q].z/ut*J:void 0})}})}applyCalculate(e,t,r,s){this.calRepulsive(e,t,s),this.calAttractive(e,t,r)}calRepulsive(e,t,r){const s=e.getAllNodes();s.forEach(({data:o,id:d},h)=>{t[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,k=O*O+L*L+R*R;k===0&&(k=1,O=.01,L=.01,R=.01);const F=r/k,z=O*F,C=L*F,W=R*F;t[d].x+=z,t[d].y+=C,t[g].x-=z,t[g].y-=C,this.options.dimensions===3&&(t[d].z+=W,t[g].z-=W)})})}calAttractive(e,t,r){e.getAllEdges().forEach(o=>{const{source:d,target:h}=o;if(!d||!h||d===h)return;const{data:p}=e.getNode(d),{data:g}=e.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,k=y*R,F=O*R,z=L*R;t[d].x+=k,t[d].y+=F,t[h].x-=k,t[h].y-=F,this.options.dimensions===3&&(t[d].z+=z,t[h].z-=z)})}}const Ou={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 Au{constructor(e={}){this.options=e,this.id="grid",this.options=Object.assign(Object.assign({},Ou),e)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericGridLayout(!1,e,t)})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericGridLayout(!0,e,t)})}genericGridLayout(e,t,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:k,position:F}=s;let{sortBy:z}=s;const C=t.getAllNodes(),W=t.getAllEdges(),$=C==null?void 0:C.length;if(!$||$===1)return Tn(t,e,o);const X=C.map(zt=>Ke(zt));z!=="id"&&(!$n(z)||X[0].data[z]===void 0)&&(z="degree"),z==="degree"?X.sort((zt,Kt)=>t.getDegree(Kt.id,"both")-t.getDegree(zt.id,"both")):z==="id"?X.sort((zt,Kt)=>_t(Kt.id)&&_t(zt.id)?Kt.id-zt.id:`${zt.id}`.localeCompare(`${Kt.id}`)):X.sort((zt,Kt)=>Kt.data[z]-zt.data[z]);const q=!R&&typeof window!="undefined"?window.innerWidth:R,st=!k&&typeof window!="undefined"?window.innerHeight:k,ut=$,J={rows:g,cols:y};if(g!=null&&y!=null)J.rows=g,J.cols=y;else if(g!=null&&y==null)J.rows=g,J.cols=Math.ceil(ut/J.rows);else if(g==null&&y!=null)J.cols=y,J.rows=Math.ceil(ut/J.cols);else{const zt=Math.sqrt(ut*st/q);J.rows=Math.round(zt),J.cols=Math.round(q/st*zt)}if(J.rows=Math.max(J.rows,1),J.cols=Math.max(J.cols,1),J.cols*J.rows>ut){const zt=ar(J),Kt=ur(J);(zt-1)*Kt>=ut?ar(J,zt-1):(Kt-1)*zt>=ut&&ur(J,Kt-1)}else for(;J.cols*J.rows=ut?ur(J,Kt+1):ar(J,zt+1)}let mt=d?0:q/J.cols,Et=d?0:st/J.rows;if(p||O){const zt=An(10,O),Kt=Tr(30,L,!1);X.forEach(le=>{(!le.data.x||!le.data.y)&&(le.data.x=0,le.data.y=0);const bt=t.getNode(le.id),[Bt,Qt]=Yn(Kt(bt)||30),$t=zt!==void 0?zt(le):h,ie=Bt+$t,de=Qt+$t;mt=Math.max(mt,ie),Et=Math.max(Et,de)})}const jt={},Pt={row:0,col:0},Dt={};for(let zt=0;zt{t.mergeNodeData(zt.id,{x:zt.data.x,y:zt.data.y})}),Gt})}}const ar=(n,e)=>{let t;const r=n.rows||5,s=n.cols||5;return e==null?t=Math.min(r,s):Math.min(r,s)===n.rows?n.rows=e:n.cols=e,t},ur=(n,e)=>{let t;const r=n.rows||5,s=n.cols||5;return e==null?t=Math.max(r,s):Math.max(r,s)===n.rows?n.rows=e:n.cols=e,t},Xr=(n,e)=>n[`c-${e.row}-${e.col}`]||!1,qs=(n,e)=>n[`c-${e.row}-${e.col}`]=!0,ti=(n,e)=>{const t=n.cols||5;e.col++,e.col>=t&&(e.col=0,e.row++)},Tu=(n,e,t,r,s,o,d,h)=>{let p,g;const y=s[n.id];if(y)p=y.col*t+t/2+e[0],g=y.row*r+r/2+e[1];else{for(;Xr(h,d);)ti(o,d);p=d.col*t+t/2+e[0],g=d.row*r+r/2+e[1],qs(h,d),ti(o,d)}n.data.x=p,n.data.y=g},ju=(n,e,t)=>{try{const r=xn.mul(xn.pow(e,2),-.5),s=r.mean("row"),o=r.mean("column"),d=r.mean();r.add(d).subRowVector(s).subColumnVector(o);const h=new Ms(r),p=xn.sqrt(h.diagonalMatrix).diagonal();return h.leftSingularVectors.toJSON().map(g=>xn.mul([g],[p]).toJSON()[0].splice(0,n))}catch(r){const s=[];for(let o=0;o{const t=Object.assign(Object.assign({},Pu),e),{positions:r,iterations:s,width:o,k:d,speed:h=100,strictRadial:p,focusIdx:g,radii:y=[],nodeSizeFunc:O}=t,L=n.getAllNodes(),R=[],k=o/10;for(let F=0;F{R[C]={x:0,y:0}}),Lu(L,r,R,d,y,O),Cu(r,R,h,p,g,k,o,y);return r},Lu=(n,e,t,r,s,o)=>{e.forEach((d,h)=>{t[h]={x:0,y:0},e.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&&e.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 k=L/R,F=-O/R;const z=Math.sqrt(g.x*g.x+g.y*g.y);let C=Math.acos((k*g.x+F*g.y)/z);C>Math.PI/2&&(C-=Math.PI/2,k*=-1,F*=-1);const W=Math.cos(C)*z;g.x=k*W,g.y=F*W}),n.forEach((g,y)=>{if(y===s)return;const O=Math.sqrt(e[y].x*e[y].x+e[y].y*e[y].y);if(O>0&&y!==s){const L=Math.min(p*(t/Iu),O);if(g.x+=e[y].x/O*L,g.y+=e[y].y/O*L,r){let R=g.x-n[s].x,k=g.y-n[s].y;const F=Math.sqrt(R*R+k*k);R=R/F*h[y],k=k/F*h[y],g.x=n[s].x+R,g.y=n[s].y+k}}}),n},Du={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10};class zu{constructor(e={}){this.options=e,this.id="radial",this.options=Object.assign(Object.assign({},Du),e)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericRadialLayout(!1,e,t)})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericRadialLayout(!0,e,t)})}genericRadialLayout(e,t,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:k,sortBy:F,linkDistance:z=50,sortStrength:C=10,maxIteration:W=1e3}=s,$=t.getAllNodes(),X=t.getAllEdges(),q=!o&&typeof window!="undefined"?window.innerWidth:o,st=!d&&typeof window!="undefined"?window.innerHeight:d,ut=h||[q/2,st/2];if(!($!=null&&$.length)||$.length===1)return Tn(t,e,ut);let J=$[0];if($n(p)){for(let Ee=0;Ee<$.length;Ee++)if($[Ee].id===p){J=$[Ee];break}}else J=p||$[0];const mt=Bu($,J.id),Et=Os({nodes:$,edges:X},!1),jt=Ss(Et),Pt=Vu(jt,mt);Uu(jt,mt,Pt+1);const Dt=jt[mt];let Gt=q-ut[0]>ut[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 Kt=Math.min(Gt,zt),le=Math.max(...Dt),bt=[],Bt=g||Kt/le;Dt.forEach((Ee,qe)=>{bt[qe]=Ee*Bt});const Qt=Fu($,jt,z,bt,Bt,F,C),$t=ku(Qt),ie=ju(z,Qt,z);let de=ie.map(([Ee,qe])=>({x:(isNaN(Ee)?Math.random()*z:Ee)-ie[mt][0],y:(isNaN(qe)?Math.random()*z:qe)-ie[mt][1]}));this.run(W,de,$t,Qt,bt,mt);let Jt;if(R){Jt=jr(y,O);const Ee={nodes:$,nodeSizeFunc:Jt,positions:de,radii:bt,height:st,width:q,strictRadial:!!L,focusIdx:mt,iterations:k||200,k:de.length/4.5};de=Ru(t,Ee)}const oe=[];return de.forEach((Ee,qe)=>{const gn=Ke($[qe]);gn.data.x=Ee.x+ut[0],gn.data.y=Ee.y+ut[1],oe.push(gn)}),e&&oe.forEach(Ee=>t.mergeNodeData(Ee.id,{x:Ee.data.x,y:Ee.data.y})),{nodes:oe,edges:X}})}run(e,t,r,s,o,d){for(let h=0;h<=e;h++){const p=h/e;this.oneIteration(p,t,o,s,r,d)}}oneIteration(e,t,r,s,o,d){const h=1-e;t.forEach((p,g)=>{const y=As(p,{x:0,y:0}),O=y===0?0:1/y;if(g===d)return;let L=0,R=0,k=0;t.forEach((z,C)=>{if(g===C)return;const W=As(p,z),$=W===0?0:1/W,X=s[C][g];k+=o[g][C],L+=o[g][C]*(z.x+X*(p.x-z.x)*$),R+=o[g][C]*(z.y+X*(p.y-z.y)*$)});const F=r[g]===0?0:1/r[g];k*=h,k+=e*F*F,L*=h,L+=e*F*p.x*O,p.x=L/k,R*=h,R+=e*F*p.y*O,p.y=R/k})}}const Fu=(n,e,t,r,s,o,d)=>{if(!n)return[];const h=[];if(e){const p={};e.forEach((g,y)=>{const O=[];g.forEach((L,R)=>{var k,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:(k=n[y].data)===null||k===void 0?void 0:k[o])||0;$n(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;$n(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*t/(r[y]/s));else{const z=(t+s)/2;O.push(L*z)}}),h.push(O)})}return h},ku=n=>{const e=n.length,t=n[0].length,r=[];for(let s=0;s{let t=-1;return n.forEach((r,s)=>{r.id===e&&(t=s)}),Math.max(t,0)},Uu=(n,e,t)=>{const r=n.length;for(let s=0;s{let t=0;for(let r=0;rt?n[e][r]:t);return t},Gu={center:[0,0],width:300,height:300};class Wu{constructor(e={}){this.options=e,this.id="random",this.options=Object.assign(Object.assign({},Gu),e)}execute(e,t){return A(this,void 0,void 0,function*(){return this.genericRandomLayout(!1,e,t)})}assign(e,t){return A(this,void 0,void 0,function*(){yield this.genericRandomLayout(!0,e,t)})}genericRandomLayout(e,t,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=t.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]}})}),e&&R.forEach(F=>t.mergeNodeData(F.id,{x:F.data.x,y:F.data.y})),{nodes:R,edges:t.getAllEdges()}})}}const Yu={circular:eo,concentric:Pr,mds:Ts,random:Wu,grid:Au,radial:zu,force:Es,d3force:Ws,"d3-force-3d":wu,fruchterman:Su,forceAtlas2:bu,dagre:or,antvDagre:Hi,comboCombined:ra};let hn;Wt({stopLayout(){hn!=null&&hn.stop&&hn.stop()},calculateLayout(n,e){return A(this,void 0,void 0,function*(){const{layout:{id:t,options:r,iterations:s},nodes:o,edges:d}=n,h=new vt({nodes:o,edges:d}),p=Yu[t];if(p)hn=new p(r);else throw new Error(`Unknown layout id: ${t}`);let g=yield hn.execute(h);return js(hn)&&(hn.stop(),g=hn.tick(s)),[g,e]})}})})()})(); }());