Ultron/static/js/plugins/D3-dag/d3-dag.0.9.0.min.js

17 lines
85 KiB
JavaScript

// d3-dag Version 0.9.0. Copyright 2021 Erik Brinkman.
var d3 = Object.assign(d3 || {}, (() => {
var d3=(()=>{var Mn=Object.create;var mt=Object.defineProperty;var Cn=Object.getOwnPropertyDescriptor;var En=Object.getOwnPropertyNames;var Bn=Object.getPrototypeOf,Sn=Object.prototype.hasOwnProperty;var Ie=t=>mt(t,"__esModule",{value:!0});var Oe=(t=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(t,{get:(e,r)=>(typeof require!="undefined"?require:e)[r]}):t)(function(t){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var P=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),_n=(t,e)=>{for(var r in e)mt(t,r,{get:e[r],enumerable:!0})},Me=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of En(e))!Sn.call(t,i)&&(r||i!=="default")&&mt(t,i,{get:()=>e[i],enumerable:!(n=Cn(e,i))||n.enumerable});return t},it=(t,e)=>Me(Ie(mt(t!=null?Mn(Bn(t)):{},"default",!e&&t&&t.__esModule?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t),jn=(t=>(e,r)=>t&&t.get(e)||(r=Me(Ie({}),e,1),t&&t.set(e,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var Qt=P((ls,Le)=>{function Fe(t,e,r,n){this.feasible=r,this.evaluation=e,this.bounded=n,this._tableau=t}Le.exports=Fe;Fe.prototype.generateSolutionSet=function(){for(var t={},e=this._tableau,r=e.varIndexByRow,n=e.variablesPerIndex,i=e.matrix,s=e.rhsColumn,o=e.height-1,a=Math.round(1/e.precision),f=1;f<=o;f+=1){var l=r[f],u=n[l];if(!(u===void 0||u.isSlack===!0)){var c=i[f][s];t[u.id]=Math.round((Number.EPSILON+c)*a)/a}}return t}});var We=P((us,Ge)=>{var Ue=Qt();function jt(t,e,r,n,i){Ue.call(this,t,e,r,n),this.iter=i}Ge.exports=jt;jt.prototype=Object.create(Ue.prototype);jt.constructor=jt});var J=P((cs,Je)=>{var Wn=Qt(),Jn=We();function H(t){this.model=null,this.matrix=null,this.width=0,this.height=0,this.costRowIndex=0,this.rhsColumn=0,this.variablesPerIndex=[],this.unrestrictedVars=null,this.feasible=!0,this.evaluation=0,this.simplexIters=0,this.varIndexByRow=null,this.varIndexByCol=null,this.rowByVarIndex=null,this.colByVarIndex=null,this.precision=t||1e-8,this.optionalObjectives=[],this.objectivesByPriority={},this.savedState=null,this.availableIndexes=[],this.lastElementIndex=0,this.variables=null,this.nVars=0,this.bounded=!0,this.unboundedVarIndex=null,this.branchAndCutIterations=0}Je.exports=H;H.prototype.solve=function(){return this.model.getNumberOfIntegerVariables()>0?this.branchAndCut():this.simplex(),this.updateVariableValues(),this.getSolution()};function te(t,e){this.priority=t,this.reducedCosts=new Array(e);for(var r=0;r<e;r+=1)this.reducedCosts[r]=0}te.prototype.copy=function(){var t=new te(this.priority,this.reducedCosts.length);return t.reducedCosts=this.reducedCosts.slice(),t};H.prototype.setOptionalObjective=function(t,e,r){var n=this.objectivesByPriority[t];if(n===void 0){var i=Math.max(this.width,e+1);n=new te(t,i),this.objectivesByPriority[t]=n,this.optionalObjectives.push(n),this.optionalObjectives.sort(function(s,o){return s.priority-o.priority})}n.reducedCosts[e]=r};H.prototype.initialize=function(t,e,r,n){this.variables=r,this.unrestrictedVars=n,this.width=t,this.height=e;for(var i=new Array(t),s=0;s<t;s++)i[s]=0;this.matrix=new Array(e);for(var o=0;o<e;o++)this.matrix[o]=i.slice();this.varIndexByRow=new Array(this.height),this.varIndexByCol=new Array(this.width),this.varIndexByRow[0]=-1,this.varIndexByCol[0]=-1,this.nVars=t+e-2,this.rowByVarIndex=new Array(this.nVars),this.colByVarIndex=new Array(this.nVars),this.lastElementIndex=this.nVars};H.prototype._resetMatrix=function(){var t=this.model.variables,e=this.model.constraints,r=t.length,n=e.length,i,s,o=this.matrix[0],a=this.model.isMinimization===!0?-1:1;for(i=0;i<r;i+=1){var f=t[i],l=f.priority,u=a*f.cost;l===0?o[i+1]=u:this.setOptionalObjective(l,i+1,u),s=t[i].index,this.rowByVarIndex[s]=-1,this.colByVarIndex[s]=i+1,this.varIndexByCol[i+1]=s}for(var c=1,d=0;d<n;d+=1){var v=e[d],g=v.index;this.rowByVarIndex[g]=c,this.colByVarIndex[g]=-1,this.varIndexByRow[c]=g;var h,O,x,m=v.terms,b=m.length,I=this.matrix[c++];if(v.isUpperBound){for(h=0;h<b;h+=1)O=m[h],x=this.colByVarIndex[O.variable.index],I[x]=O.coefficient;I[0]=v.rhs}else{for(h=0;h<b;h+=1)O=m[h],x=this.colByVarIndex[O.variable.index],I[x]=-O.coefficient;I[0]=-v.rhs}}};H.prototype.setModel=function(t){this.model=t;var e=t.nVariables+1,r=t.nConstraints+1;return this.initialize(e,r,t.variables,t.unrestrictedVariables),this._resetMatrix(),this};H.prototype.getNewElementIndex=function(){if(this.availableIndexes.length>0)return this.availableIndexes.pop();var t=this.lastElementIndex;return this.lastElementIndex+=1,t};H.prototype.density=function(){for(var t=0,e=this.matrix,r=0;r<this.height;r++)for(var n=e[r],i=0;i<this.width;i++)n[i]!==0&&(t+=1);return t/(this.height*this.width)};H.prototype.setEvaluation=function(){var t=Math.round(1/this.precision),e=this.matrix[this.costRowIndex][this.rhsColumn],r=Math.round((Number.EPSILON+e)*t)/t;this.evaluation=r,this.simplexIters===0&&(this.bestPossibleEval=r)};H.prototype.getSolution=function(){var t=this.model.isMinimization===!0?this.evaluation:-this.evaluation;return this.model.getNumberOfIntegerVariables()>0?new Jn(this,t,this.feasible,this.bounded,this.branchAndCutIterations):new Wn(this,t,this.feasible,this.bounded)}});var Ze=P(()=>{var ht=J();ht.prototype.simplex=function(){return this.bounded=!0,this.phase1(),this.feasible===!0&&this.phase2(),this};ht.prototype.phase1=function(){for(var t=this.model.checkForCycles,e=[],r=this.matrix,n=this.rhsColumn,i=this.width-1,s=this.height-1,o,a=0;;){for(var f=0,l=-this.precision,u=1;u<=s;u++){o=this.unrestrictedVars[this.varIndexByRow[u]]===!0;var c=r[u][n];c<l&&(l=c,f=u)}if(f===0)return this.feasible=!0,a;for(var d=0,v=-1/0,g=r[0],h=r[f],O=1;O<=i;O++){var x=h[O];if(o=this.unrestrictedVars[this.varIndexByCol[O]]===!0,o||x<-this.precision){var m=-g[O]/x;v<m&&(v=m,d=O)}}if(d===0)return this.feasible=!1,a;if(t){e.push([this.varIndexByRow[f],this.varIndexByCol[d]]);var b=this.checkForCycles(e);if(b.length>0)return this.model.messages.push("Cycle in phase 1"),this.model.messages.push("Start :"+b[0]),this.model.messages.push("Length :"+b[1]),this.feasible=!1,a}this.pivot(f,d),a+=1}};ht.prototype.phase2=function(){for(var t=this.model.checkForCycles,e=[],r=this.matrix,n=this.rhsColumn,i=this.width-1,s=this.height-1,o=this.precision,a=this.optionalObjectives.length,f=null,l=0,u,c;;){var d=r[this.costRowIndex];a>0&&(f=[]);for(var v=0,g=o,h=!1,O=1;O<=i;O++){if(u=d[O],c=this.unrestrictedVars[this.varIndexByCol[O]]===!0,a>0&&-o<u&&u<o){f.push(O);continue}if(c&&u<0){-u>g&&(g=-u,v=O,h=!0);continue}u>g&&(g=u,v=O,h=!1)}if(a>0)for(var x=0;v===0&&f.length>0&&x<a;){var m=[],b=this.optionalObjectives[x].reducedCosts;g=o;for(var I=0;I<f.length;I++){if(O=f[I],u=b[O],c=this.unrestrictedVars[this.varIndexByCol[O]]===!0,-o<u&&u<o){m.push(O);continue}if(c&&u<0){-u>g&&(g=-u,v=O,h=!0);continue}u>g&&(g=u,v=O,h=!1)}f=m,x+=1}if(v===0)return this.setEvaluation(),this.simplexIters+=1,l;for(var w=0,y=1/0,S=this.varIndexByRow,E=1;E<=s;E++){var B=r[E],C=B[n],j=B[v];if(!(-o<j&&j<o)){if(j>0&&o>C&&C>-o){y=0,w=E;break}var z=h?-C/j:C/j;z>o&&y>z&&(y=z,w=E)}}if(y===1/0)return this.evaluation=-1/0,this.bounded=!1,this.unboundedVarIndex=this.varIndexByCol[v],l;if(t){e.push([this.varIndexByRow[w],this.varIndexByCol[v]]);var V=this.checkForCycles(e);if(V.length>0)return this.model.messages.push("Cycle in phase 2"),this.model.messages.push("Start :"+V[0]),this.model.messages.push("Length :"+V[1]),this.feasible=!1,l}this.pivot(w,v,!0),l+=1}};var ee=[];ht.prototype.pivot=function(t,e){var r=this.matrix,n=r[t][e],i=this.height-1,s=this.width-1,o=this.varIndexByRow[t],a=this.varIndexByCol[e];this.varIndexByRow[t]=a,this.varIndexByCol[e]=o,this.rowByVarIndex[a]=t,this.rowByVarIndex[o]=-1,this.colByVarIndex[a]=-1,this.colByVarIndex[o]=e;for(var f=r[t],l=0,u=0;u<=s;u++)f[u]>=-1e-16&&f[u]<=1e-16?f[u]=0:(f[u]/=n,ee[l]=u,l+=1);f[e]=1/n;for(var c,d,v,g=this.precision,h=0;h<=i;h++)if(h!==t&&!(r[h][e]>=-1e-16&&r[h][e]<=1e-16)){var O=r[h];if(c=O[e],c>=-1e-16&&c<=1e-16)c!==0&&(O[e]=0);else{for(d=0;d<l;d++)u=ee[d],v=f[u],v>=-1e-16&&v<=1e-16?v!==0&&(f[u]=0):O[u]=O[u]-c*v;O[e]=-c/n}}var x=this.optionalObjectives.length;if(x>0)for(var m=0;m<x;m+=1){var b=this.optionalObjectives[m].reducedCosts;if(c=b[e],c!==0){for(d=0;d<l;d++)u=ee[d],v=f[u],v!==0&&(b[u]=b[u]-c*v);b[e]=-c/n}}};ht.prototype.checkForCycles=function(t){for(var e=0;e<t.length-1;e++)for(var r=e+1;r<t.length;r++){var n=t[e],i=t[r];if(n[0]===i[0]&&n[1]===i[1]){if(r-e>t.length-r)break;for(var s=!0,o=1;o<r-e;o++){var a=t[e+o],f=t[r+o];if(a[0]!==f[0]||a[1]!==f[1]){s=!1;break}}if(s)return[e,r-e]}}return[]}});var zt=P((ps,Ke)=>{function re(t,e,r,n){this.id=t,this.cost=e,this.index=r,this.value=0,this.priority=n}function Ye(t,e,r,n){re.call(this,t,e,r,n)}Ye.prototype.isInteger=!0;function ne(t,e){re.call(this,t,0,e,0)}ne.prototype.isSlack=!0;function He(t,e){this.variable=t,this.coefficient=e}function Xe(t,e,r){return r===0||r==="required"?null:(e=e||1,r=r||1,t.isMinimization===!1&&(e=-e),t.addVariable(e,"r"+t.relaxationIndex++,!1,!1,r))}function rt(t,e,r,n){this.slack=new ne("s"+r,r),this.index=r,this.model=n,this.rhs=t,this.isUpperBound=e,this.terms=[],this.termsByVarIndex={},this.relaxation=null}rt.prototype.addTerm=function(t,e){var r=e.index,n=this.termsByVarIndex[r];if(n===void 0)n=new He(e,t),this.termsByVarIndex[r]=n,this.terms.push(n),this.isUpperBound===!0&&(t=-t),this.model.updateConstraintCoefficient(this,e,t);else{var i=n.coefficient+t;this.setVariableCoefficient(i,e)}return this};rt.prototype.removeTerm=function(t){return this};rt.prototype.setRightHandSide=function(t){if(t!==this.rhs){var e=t-this.rhs;this.isUpperBound===!0&&(e=-e),this.rhs=t,this.model.updateRightHandSide(this,e)}return this};rt.prototype.setVariableCoefficient=function(t,e){var r=e.index;if(r===-1){console.warn("[Constraint.setVariableCoefficient] Trying to change coefficient of inexistant variable.");return}var n=this.termsByVarIndex[r];if(n===void 0)this.addTerm(t,e);else if(t!==n.coefficient){var i=t-n.coefficient;this.isUpperBound===!0&&(i=-i),n.coefficient=t,this.model.updateConstraintCoefficient(this,e,i)}return this};rt.prototype.relax=function(t,e){this.relaxation=Xe(this.model,t,e),this._relax(this.relaxation)};rt.prototype._relax=function(t){t!==null&&(this.isUpperBound?this.setVariableCoefficient(-1,t):this.setVariableCoefficient(1,t))};function ot(t,e){this.upperBound=t,this.lowerBound=e,this.model=t.model,this.rhs=t.rhs,this.relaxation=null}ot.prototype.isEquality=!0;ot.prototype.addTerm=function(t,e){return this.upperBound.addTerm(t,e),this.lowerBound.addTerm(t,e),this};ot.prototype.removeTerm=function(t){return this.upperBound.removeTerm(t),this.lowerBound.removeTerm(t),this};ot.prototype.setRightHandSide=function(t){this.upperBound.setRightHandSide(t),this.lowerBound.setRightHandSide(t),this.rhs=t};ot.prototype.relax=function(t,e){this.relaxation=Xe(this.model,t,e),this.upperBound.relaxation=this.relaxation,this.upperBound._relax(this.relaxation),this.lowerBound.relaxation=this.relaxation,this.lowerBound._relax(this.relaxation)};Ke.exports={Constraint:rt,Variable:re,IntegerVariable:Ye,SlackVariable:ne,Equality:ot,Term:He}});var Qe=P(()=>{var Vt=J(),ie=zt().SlackVariable;Vt.prototype.addCutConstraints=function(t){for(var e=t.length,r=this.height,n=r+e,i=r;i<n;i+=1)this.matrix[i]===void 0&&(this.matrix[i]=this.matrix[i-1].slice());this.height=n,this.nVars=this.width+this.height-2;for(var s,o=this.width-1,a=0;a<e;a+=1){var f=t[a],l=r+a,u=f.type==="min"?-1:1,c=f.varIndex,d=this.rowByVarIndex[c],v=this.matrix[l];if(d===-1){for(v[this.rhsColumn]=u*f.value,s=1;s<=o;s+=1)v[s]=0;v[this.colByVarIndex[c]]=u}else{var g=this.matrix[d],h=g[this.rhsColumn];for(v[this.rhsColumn]=u*(f.value-h),s=1;s<=o;s+=1)v[s]=-u*g[s]}var O=this.getNewElementIndex();this.varIndexByRow[l]=O,this.rowByVarIndex[O]=l,this.colByVarIndex[O]=-1,this.variablesPerIndex[O]=new ie("s"+O,O),this.nVars+=1}};Vt.prototype._addLowerBoundMIRCut=function(t){if(t===this.costRowIndex)return!1;var e=this.model,r=this.matrix,n=this.variablesPerIndex[this.varIndexByRow[t]];if(!n.isInteger)return!1;var i=r[t][this.rhsColumn],s=i-Math.floor(i);if(s<this.precision||1-this.precision<s)return!1;var o=this.height;r[o]=r[o-1].slice(),this.height+=1,this.nVars+=1;var a=this.getNewElementIndex();this.varIndexByRow[o]=a,this.rowByVarIndex[a]=o,this.colByVarIndex[a]=-1,this.variablesPerIndex[a]=new ie("s"+a,a),r[o][this.rhsColumn]=Math.floor(i);for(var f=1;f<this.varIndexByCol.length;f+=1){var l=this.variablesPerIndex[this.varIndexByCol[f]];if(!l.isInteger)r[o][f]=Math.min(0,r[t][f]/(1-s));else{var u=r[t][f],c=Math.floor(u)+Math.max(0,u-Math.floor(u)-s)/(1-s);r[o][f]=c}}for(var d=0;d<this.width;d+=1)r[o][d]-=r[t][d];return!0};Vt.prototype._addUpperBoundMIRCut=function(t){if(t===this.costRowIndex)return!1;var e=this.model,r=this.matrix,n=this.variablesPerIndex[this.varIndexByRow[t]];if(!n.isInteger)return!1;var i=r[t][this.rhsColumn],s=i-Math.floor(i);if(s<this.precision||1-this.precision<s)return!1;var o=this.height;r[o]=r[o-1].slice(),this.height+=1,this.nVars+=1;var a=this.getNewElementIndex();this.varIndexByRow[o]=a,this.rowByVarIndex[a]=o,this.colByVarIndex[a]=-1,this.variablesPerIndex[a]=new ie("s"+a,a),r[o][this.rhsColumn]=-s;for(var f=1;f<this.varIndexByCol.length;f+=1){var l=this.variablesPerIndex[this.varIndexByCol[f]],u=r[t][f],c=u-Math.floor(u);l.isInteger?c<=s?r[o][f]=-c:r[o][f]=-(1-c)*s/c:u>=0?r[o][f]=-u:r[o][f]=u*s/(1-s)}return!0};Vt.prototype.applyMIRCuts=function(){}});var tr=P(()=>{var X=J();X.prototype._putInBase=function(t){var e=this.rowByVarIndex[t];if(e===-1){for(var r=this.colByVarIndex[t],n=1;n<this.height;n+=1){var i=this.matrix[n][r];if(i<-this.precision||this.precision<i){e=n;break}}this.pivot(e,r)}return e};X.prototype._takeOutOfBase=function(t){var e=this.colByVarIndex[t];if(e===-1){for(var r=this.rowByVarIndex[t],n=this.matrix[r],i=1;i<this.height;i+=1){var s=n[i];if(s<-this.precision||this.precision<s){e=i;break}}this.pivot(r,e)}return e};X.prototype.updateVariableValues=function(){for(var t=this.variables.length,e=Math.round(1/this.precision),r=0;r<t;r+=1){var n=this.variables[r],i=n.index,s=this.rowByVarIndex[i];if(s===-1)n.value=0;else{var o=this.matrix[s][this.rhsColumn];n.value=Math.round((o+Number.EPSILON)*e)/e}}};X.prototype.updateRightHandSide=function(t,e){var r=this.height-1,n=this.rowByVarIndex[t.index];if(n===-1){for(var i=this.colByVarIndex[t.index],s=0;s<=r;s+=1){var o=this.matrix[s];o[this.rhsColumn]-=e*o[i]}var a=this.optionalObjectives.length;if(a>0)for(var f=0;f<a;f+=1){var l=this.optionalObjectives[f].reducedCosts;l[this.rhsColumn]-=e*l[i]}}else this.matrix[n][this.rhsColumn]-=e};X.prototype.updateConstraintCoefficient=function(t,e,r){if(t.index===e.index)throw new Error("[Tableau.updateConstraintCoefficient] constraint index should not be equal to variable index !");var n=this._putInBase(t.index),i=this.colByVarIndex[e.index];if(i===-1)for(var s=this.rowByVarIndex[e.index],o=0;o<this.width;o+=1)this.matrix[n][o]+=r*this.matrix[s][o];else this.matrix[n][i]-=r};X.prototype.updateCost=function(t,e){var r=t.index,n=this.width-1,i=this.colByVarIndex[r];if(i===-1){var s=this.matrix[this.rowByVarIndex[r]],o;if(t.priority===0){var a=this.matrix[0];for(o=0;o<=n;o+=1)a[o]+=e*s[o]}else{var f=this.objectivesByPriority[t.priority].reducedCosts;for(o=0;o<=n;o+=1)f[o]+=e*s[o]}}else this.matrix[0][i]-=e};X.prototype.addConstraint=function(t){var e=t.isUpperBound?1:-1,r=this.height,n=this.matrix[r];n===void 0&&(n=this.matrix[0].slice(),this.matrix[r]=n);for(var i=this.width-1,s=0;s<=i;s+=1)n[s]=0;n[this.rhsColumn]=e*t.rhs;for(var o=t.terms,a=o.length,f=0;f<a;f+=1){var l=o[f],u=l.coefficient,c=l.variable.index,d=this.rowByVarIndex[c];if(d===-1)n[this.colByVarIndex[c]]+=e*u;else{var v=this.matrix[d],g=v[this.rhsColumn];for(s=0;s<=i;s+=1)n[s]-=e*u*v[s]}}var h=t.index;this.varIndexByRow[r]=h,this.rowByVarIndex[h]=r,this.colByVarIndex[h]=-1,this.height+=1};X.prototype.removeConstraint=function(t){var e=t.index,r=this.height-1,n=this._putInBase(e),i=this.matrix[r];this.matrix[r]=this.matrix[n],this.matrix[n]=i,this.varIndexByRow[n]=this.varIndexByRow[r],this.varIndexByRow[r]=-1,this.rowByVarIndex[e]=-1,this.availableIndexes[this.availableIndexes.length]=e,t.slack.index=-1,this.height-=1};X.prototype.addVariable=function(t){var e=this.height-1,r=this.width,n=this.model.isMinimization===!0?-t.cost:t.cost,i=t.priority,s=this.optionalObjectives.length;if(s>0)for(var o=0;o<s;o+=1)this.optionalObjectives[o].reducedCosts[r]=0;i===0?this.matrix[0][r]=n:(this.setOptionalObjective(i,r,n),this.matrix[0][r]=0);for(var a=1;a<=e;a+=1)this.matrix[a][r]=0;var f=t.index;this.varIndexByCol[r]=f,this.rowByVarIndex[f]=-1,this.colByVarIndex[f]=r,this.width+=1};X.prototype.removeVariable=function(t){var e=t.index,r=this._takeOutOfBase(e),n=this.width-1;if(r!==n){for(var i=this.height-1,s=0;s<=i;s+=1){var o=this.matrix[s];o[r]=o[n]}var a=this.optionalObjectives.length;if(a>0)for(var f=0;f<a;f+=1){var l=this.optionalObjectives[f].reducedCosts;l[r]=l[n]}var u=this.varIndexByCol[n];this.varIndexByCol[r]=u,this.colByVarIndex[u]=r}this.varIndexByCol[n]=-1,this.colByVarIndex[e]=-1,this.availableIndexes[this.availableIndexes.length]=e,t.index=-1,this.width-=1}});var er=P(()=>{var Zn=J();Zn.prototype.log=function(t,e){console.log("****",t,"****"),console.log("Nb Variables",this.width-1),console.log("Nb Constraints",this.height-1),console.log("Basic Indexes",this.varIndexByRow),console.log("Non Basic Indexes",this.varIndexByCol),console.log("Rows",this.rowByVarIndex),console.log("Cols",this.colByVarIndex);var r=5,n="",i=[" "],s,o,a,f,l,u,c,d,v,g,h,O,x;for(o=1;o<this.width;o+=1)u=this.varIndexByCol[o],l=this.variablesPerIndex[u],l===void 0?c="c"+u:c=l.id,d=c.length,v=Math.abs(d-5),g=" ",h=" ",d>5?g+=" ":h+=" ",i[o]=g,n+=h+c;console.log(n);var m,b=this.matrix[this.costRowIndex],I=" ";for(s=1;s<this.width;s+=1)m=" ",I+=m,I+=i[s],I+=b[s].toFixed(r);for(m=" ",I+=m+i[0]+b[0].toFixed(r),console.log(I+" Z"),f=1;f<this.height;f+=1){for(O=this.matrix[f],x=" ",o=1;o<this.width;o+=1)m=" ",x+=m+i[o]+O[o].toFixed(r);m=" ",x+=m+i[0]+O[0].toFixed(r),u=this.varIndexByRow[f],l=this.variablesPerIndex[u],l===void 0?c="c"+u:c=l.id,console.log(x+" "+c)}console.log("");var w=this.optionalObjectives.length;if(w>0){console.log(" Optional objectives:");for(var y=0;y<w;y+=1){var S=this.optionalObjectives[y].reducedCosts,E="";for(s=1;s<this.width;s+=1)m=S[s]<0?"":" ",E+=m,E+=i[s],E+=S[s].toFixed(r);m=S[0]<0?"":" ",E+=m+i[0]+S[0].toFixed(r),console.log(E+" z"+y)}}return console.log("Feasible?",this.feasible),console.log("evaluation",this.evaluation),this}});var rr=P(()=>{var Nt=J();Nt.prototype.copy=function(){var t=new Nt(this.precision);t.width=this.width,t.height=this.height,t.nVars=this.nVars,t.model=this.model,t.variables=this.variables,t.variablesPerIndex=this.variablesPerIndex,t.unrestrictedVars=this.unrestrictedVars,t.lastElementIndex=this.lastElementIndex,t.varIndexByRow=this.varIndexByRow.slice(),t.varIndexByCol=this.varIndexByCol.slice(),t.rowByVarIndex=this.rowByVarIndex.slice(),t.colByVarIndex=this.colByVarIndex.slice(),t.availableIndexes=this.availableIndexes.slice();for(var e=[],r=0;r<this.optionalObjectives.length;r++)e[r]=this.optionalObjectives[r].copy();t.optionalObjectives=e;for(var n=this.matrix,i=new Array(this.height),s=0;s<this.height;s++)i[s]=n[s].slice();return t.matrix=i,t};Nt.prototype.save=function(){this.savedState=this.copy()};Nt.prototype.restore=function(){if(this.savedState!==null){var t=this.savedState,e=t.matrix;this.nVars=t.nVars,this.model=t.model,this.variables=t.variables,this.variablesPerIndex=t.variablesPerIndex,this.unrestrictedVars=t.unrestrictedVars,this.lastElementIndex=t.lastElementIndex,this.width=t.width,this.height=t.height;var r,n;for(r=0;r<this.height;r+=1){var i=e[r],s=this.matrix[r];for(n=0;n<this.width;n+=1)s[n]=i[n]}var o=t.varIndexByRow;for(n=0;n<this.height;n+=1)this.varIndexByRow[n]=o[n];for(;this.varIndexByRow.length>this.height;)this.varIndexByRow.pop();var a=t.varIndexByCol;for(r=0;r<this.width;r+=1)this.varIndexByCol[r]=a[r];for(;this.varIndexByCol.length>this.width;)this.varIndexByCol.pop();for(var f=t.rowByVarIndex,l=t.colByVarIndex,u=0;u<this.nVars;u+=1)this.rowByVarIndex[u]=f[u],this.colByVarIndex[u]=l[u];if(t.optionalObjectives.length>0&&this.optionalObjectives.length>0){this.optionalObjectives=[],this.optionalObjectivePerPriority={};for(var c=0;c<t.optionalObjectives.length;c++){var d=t.optionalObjectives[c].copy();this.optionalObjectives[c]=d,this.optionalObjectivePerPriority[d.priority]=d}}}}});var sr=P(()=>{var nr=J();function ir(t,e){this.index=t,this.value=e}nr.prototype.getMostFractionalVar=function(){for(var t=0,e=null,r=null,n=.5,i=this.model.integerVariables,s=i.length,o=0;o<s;o++){var a=i[o].index,f=this.rowByVarIndex[a];if(f!==-1){var l=this.matrix[f][this.rhsColumn],u=Math.abs(l-Math.round(l));t<u&&(t=u,e=a,r=l)}}return new ir(e,r)};nr.prototype.getFractionalVarWithLowestCost=function(){for(var t=1/0,e=null,r=null,n=this.model.integerVariables,i=n.length,s=0;s<i;s++){var o=n[s],a=o.index,f=this.rowByVarIndex[a];if(f!==-1){var l=this.matrix[f][this.rhsColumn];if(Math.abs(l-Math.round(l))>this.precision){var u=o.cost;t>u&&(t=u,e=a,r=l)}}}return new ir(e,r)}});var or=P(()=>{var se=J();se.prototype.countIntegerValues=function(){for(var t=0,e=1;e<this.height;e+=1)if(this.variablesPerIndex[this.varIndexByRow[e]].isInteger){var r=this.matrix[e][this.rhsColumn];r=r-Math.floor(r),r<this.precision&&-r<this.precision&&(t+=1)}return t};se.prototype.isIntegral=function(){for(var t=this.model.integerVariables,e=t.length,r=0;r<e;r++){var n=this.rowByVarIndex[t[r].index];if(n!==-1){var i=this.matrix[n][this.rhsColumn];if(Math.abs(i-Math.round(i))>this.precision)return!1}}return!0};se.prototype.computeFractionalVolume=function(t){for(var e=-1,r=1;r<this.height;r+=1)if(this.variablesPerIndex[this.varIndexByRow[r]].isInteger){var n=this.matrix[r][this.rhsColumn];n=Math.abs(n);var i=Math.min(n-Math.floor(n),Math.floor(n+1));if(i<this.precision){if(!t)return 0}else e===-1?e=n:e*=n}return e===-1?0:e}});var fr=P((Bs,ar)=>{Ze();Qe();tr();er();rr();sr();or();ar.exports=J()});var ae=P(()=>{var lr=J();function ur(t,e,r){this.type=t,this.varIndex=e,this.value=r}function oe(t,e){this.relaxedEvaluation=t,this.cuts=e}function Yn(t,e){return e.relaxedEvaluation-t.relaxedEvaluation}lr.prototype.applyCuts=function(t){if(this.restore(),this.addCutConstraints(t),this.simplex(),this.model.useMIRCuts)for(var e=!0;e;){var r=this.computeFractionalVolume(!0);this.applyMIRCuts(),this.simplex();var n=this.computeFractionalVolume(!0);n>=.9*r&&(e=!1)}};lr.prototype.branchAndCut=function(){var t=[],e=0,r=this.model.tolerance,n=!0,i=1e99;this.model.timeout&&(i=Date.now()+this.model.timeout);for(var s=1/0,o=null,a=[],f=0;f<this.optionalObjectives.length;f+=1)a.push(1/0);var l=new oe(-1/0,[]),u;for(t.push(l);t.length>0&&n===!0&&Date.now()<i;)if(this.model.isMinimization?u=this.bestPossibleEval*(1+r):u=this.bestPossibleEval*(1-r),r>0&&s<u&&(n=!1),l=t.pop(),!(l.relaxedEvaluation>s)){var c=l.cuts;if(this.applyCuts(c),e++,this.feasible!==!1){var d=this.evaluation;if(!(d>s)){if(d===s){for(var v=!0,g=0;g<this.optionalObjectives.length&&!(this.optionalObjectives[g].reducedCosts[0]>a[g]);g+=1)if(this.optionalObjectives[g].reducedCosts[0]<a[g]){v=!1;break}if(v)continue}if(this.isIntegral()===!0){if(this.__isIntegral=!0,e===1){this.branchAndCutIterations=e;return}o=l,s=d;for(var h=0;h<this.optionalObjectives.length;h+=1)a[h]=this.optionalObjectives[h].reducedCosts[0]}else{e===1&&this.save();for(var O=this.getMostFractionalVar(),x=O.index,m=[],b=[],I=c.length,w=0;w<I;w+=1){var y=c[w];y.varIndex===x?y.type==="min"?b.push(y):m.push(y):(m.push(y),b.push(y))}var S=Math.ceil(O.value),E=Math.floor(O.value),B=new ur("min",x,S);m.push(B);var C=new ur("max",x,E);b.push(C),t.push(new oe(d,m)),t.push(new oe(d,b)),t.sort(Yn)}}}}o!==null&&this.applyCuts(o.cuts),this.branchAndCutIterations=e}});var dr=P((Vs,hr)=>{var Hn=J(),js=ae(),dt=zt(),$t=dt.Constraint,cr=dt.Equality,Xn=dt.Variable,Kn=dt.IntegerVariable,zs=dt.Term;function R(t,e){this.tableau=new Hn(t),this.name=e,this.variables=[],this.integerVariables=[],this.unrestrictedVariables={},this.constraints=[],this.nConstraints=0,this.nVariables=0,this.isMinimization=!0,this.tableauInitialized=!1,this.relaxationIndex=1,this.useMIRCuts=!1,this.checkForCycles=!0,this.messages=[]}hr.exports=R;R.prototype.minimize=function(){return this.isMinimization=!0,this};R.prototype.maximize=function(){return this.isMinimization=!1,this};R.prototype._getNewElementIndex=function(){if(this.availableIndexes.length>0)return this.availableIndexes.pop();var t=this.lastElementIndex;return this.lastElementIndex+=1,t};R.prototype._addConstraint=function(t){var e=t.slack;this.tableau.variablesPerIndex[e.index]=e,this.constraints.push(t),this.nConstraints+=1,this.tableauInitialized===!0&&this.tableau.addConstraint(t)};R.prototype.smallerThan=function(t){var e=new $t(t,!0,this.tableau.getNewElementIndex(),this);return this._addConstraint(e),e};R.prototype.greaterThan=function(t){var e=new $t(t,!1,this.tableau.getNewElementIndex(),this);return this._addConstraint(e),e};R.prototype.equal=function(t){var e=new $t(t,!0,this.tableau.getNewElementIndex(),this);this._addConstraint(e);var r=new $t(t,!1,this.tableau.getNewElementIndex(),this);return this._addConstraint(r),new cr(e,r)};R.prototype.addVariable=function(t,e,r,n,i){if(typeof i=="string")switch(i){case"required":i=0;break;case"strong":i=1;break;case"medium":i=2;break;case"weak":i=3;break;default:i=0;break}var s=this.tableau.getNewElementIndex();e==null&&(e="v"+s),t==null&&(t=0),i==null&&(i=0);var o;return r?(o=new Kn(e,t,s,i),this.integerVariables.push(o)):o=new Xn(e,t,s,i),this.variables.push(o),this.tableau.variablesPerIndex[s]=o,n&&(this.unrestrictedVariables[s]=!0),this.nVariables+=1,this.tableauInitialized===!0&&this.tableau.addVariable(o),o};R.prototype._removeConstraint=function(t){var e=this.constraints.indexOf(t);if(e===-1){console.warn("[Model.removeConstraint] Constraint not present in model");return}this.constraints.splice(e,1),this.nConstraints-=1,this.tableauInitialized===!0&&this.tableau.removeConstraint(t),t.relaxation&&this.removeVariable(t.relaxation)};R.prototype.removeConstraint=function(t){return t.isEquality?(this._removeConstraint(t.upperBound),this._removeConstraint(t.lowerBound)):this._removeConstraint(t),this};R.prototype.removeVariable=function(t){var e=this.variables.indexOf(t);if(e===-1){console.warn("[Model.removeVariable] Variable not present in model");return}return this.variables.splice(e,1),this.tableauInitialized===!0&&this.tableau.removeVariable(t),this};R.prototype.updateRightHandSide=function(t,e){return this.tableauInitialized===!0&&this.tableau.updateRightHandSide(t,e),this};R.prototype.updateConstraintCoefficient=function(t,e,r){return this.tableauInitialized===!0&&this.tableau.updateConstraintCoefficient(t,e,r),this};R.prototype.setCost=function(t,e){var r=t-e.cost;return this.isMinimization===!1&&(r=-r),e.cost=t,this.tableau.updateCost(e,r),this};R.prototype.loadJson=function(t){this.isMinimization=t.opType!=="max";for(var e=t.variables,r=t.constraints,n={},i={},s=Object.keys(r),o=s.length,a=0;a<o;a+=1){var f=s[a],l=r[f],u=l.equal,c=l.weight,d=l.priority,v=c!==void 0||d!==void 0,g,h;if(u===void 0){var O=l.min;O!==void 0&&(g=this.greaterThan(O),n[f]=g,v&&g.relax(c,d));var x=l.max;x!==void 0&&(h=this.smallerThan(x),i[f]=h,v&&h.relax(c,d))}else{g=this.greaterThan(u),n[f]=g,h=this.smallerThan(u),i[f]=h;var m=new cr(g,h);v&&m.relax(c,d)}}var b=Object.keys(e),I=b.length;this.tolerance=t.tolerance||0,t.timeout&&(this.timeout=t.timeout),t.options&&(t.options.timeout&&(this.timeout=t.options.timeout),this.tolerance===0&&(this.tolerance=t.options.tolerance||0),t.options.useMIRCuts&&(this.useMIRCuts=t.options.useMIRCuts),typeof t.options.exitOnCycles=="undefined"?this.checkForCycles=!0:this.checkForCycles=t.options.exitOnCycles);for(var w=t.ints||{},y=t.binaries||{},S=t.unrestricted||{},E=t.optimize,B=0;B<I;B+=1){var C=b[B],j=e[C],z=j[E]||0,V=!!y[C],q=!!w[C]||V,A=!!S[C],N=this.addVariable(z,C,q,A);V&&this.smallerThan(1).addTerm(1,N);var U=Object.keys(j);for(a=0;a<U.length;a+=1){var L=U[a];if(L!==E){var W=j[L],D=n[L];D!==void 0&&D.addTerm(W,N);var et=i[L];et!==void 0&&et.addTerm(W,N)}}}return this};R.prototype.getNumberOfIntegerVariables=function(){return this.integerVariables.length};R.prototype.solve=function(){return this.tableauInitialized===!1&&(this.tableau.setModel(this),this.tableauInitialized=!0),this.tableau.solve()};R.prototype.isFeasible=function(){return this.tableau.feasible};R.prototype.save=function(){return this.tableau.save()};R.prototype.restore=function(){return this.tableau.restore()};R.prototype.activateMIRCuts=function(t){this.useMIRCuts=t};R.prototype.debug=function(t){this.checkForCycles=t};R.prototype.log=function(t){return this.tableau.log(t)}});var vr=P(pr=>{pr.CleanObjectiveAttributes=function(t){var e,r,n;if(typeof t.optimize=="string")if(t.constraints[t.optimize]){e=Math.random();for(r in t.variables)t.variables[r][t.optimize]&&(t.variables[r][e]=t.variables[r][t.optimize]);return t.constraints[e]=t.constraints[t.optimize],delete t.constraints[t.optimize],t}else return t;else{for(n in t.optimize)if(t.constraints[n])if(t.constraints[n]==="equal")delete t.optimize[n];else{e=Math.random();for(r in t.variables)t.variables[r][n]&&(t.variables[r][e]=t.variables[r][n]);t.constraints[e]=t.constraints[n],delete t.constraints[n]}return t}}});var qt=P(($s,gr)=>{function Qn(t){var e={is_blank:/^\W{0,}$/,is_objective:/(max|min)(imize){0,}\:/i,is_int:/^(?!\/\*)\W{0,}int/i,is_bin:/^(?!\/\*)\W{0,}bin/i,is_constraint:/(\>|\<){0,}\=/i,is_unrestricted:/^\S{0,}unrestricted/i,parse_lhs:/(\-|\+){0,1}\s{0,1}\d{0,}\.{0,}\d{0,}\s{0,}[A-Za-z]\S{0,}/gi,parse_rhs:/(\-|\+){0,1}\d{1,}\.{0,}\d{0,}\W{0,}\;{0,1}$/i,parse_dir:/(\>|\<){0,}\=/gi,parse_int:/[^\s|^\,]+/gi,parse_bin:/[^\s|^\,]+/gi,get_num:/(\-|\+){0,1}(\W|^)\d+\.{0,1}\d{0,}/g,get_word:/[A-Za-z].*/},r={opType:"",optimize:"_obj",constraints:{},variables:{}},n={">=":"min","<=":"max","=":"equal"},i="",s=0,o=null,a="",f="",l="",u=0;typeof t=="string"&&(t=t.split(`
`));for(var c=0;c<t.length;c++)if(l="__"+c,i=t[c],s=0,o=null,e.is_objective.test(i))r.opType=i.match(/(max|min)/gi)[0],o=i.match(e.parse_lhs).map(function(g){return g.replace(/\s+/,"")}).slice(1),o.forEach(function(g){a=g.match(e.get_num),a===null?g.substr(0,1)==="-"?a=-1:a=1:a=a[0],a=parseFloat(a),f=g.match(e.get_word)[0].replace(/\;$/,""),r.variables[f]=r.variables[f]||{},r.variables[f]._obj=a});else if(e.is_int.test(i))o=i.match(e.parse_int).slice(1),r.ints=r.ints||{},o.forEach(function(g){g=g.replace(";",""),r.ints[g]=1});else if(e.is_bin.test(i))o=i.match(e.parse_bin).slice(1),r.binaries=r.binaries||{},o.forEach(function(g){g=g.replace(";",""),r.binaries[g]=1});else if(e.is_constraint.test(i)){var d=i.indexOf(":"),v=d===-1?i:i.slice(d+1);o=v.match(e.parse_lhs).map(function(g){return g.replace(/\s+/,"")}),o.forEach(function(g){a=g.match(e.get_num),a===null?g.substr(0,1)==="-"?a=-1:a=1:a=a[0],a=parseFloat(a),f=g.match(e.get_word)[0],r.variables[f]=r.variables[f]||{},r.variables[f][l]=a}),u=parseFloat(i.match(e.parse_rhs)[0]),i=n[i.match(e.parse_dir)[0]],r.constraints[l]=r.constraints[l]||{},r.constraints[l][i]=u}else e.is_unrestricted.test(i)&&(o=i.match(e.parse_int).slice(1),r.unrestricted=r.unrestricted||{},o.forEach(function(g){g=g.replace(";",""),r.unrestricted[g]=1}));return r}function ti(t){if(!t)throw new Error("Solver requires a model to operate on");var e="",r=[],n=1,i={max:"<=",min:">=",equal:"="},s=new RegExp("[^A-Za-z0-9_[{}/.&#$%~'@^]","gi");if(t.opType){e+=t.opType+":";for(var o in t.variables)t.variables[o][o]=t.variables[o][o]?t.variables[o][o]:1,t.variables[o][t.optimize]&&(e+=" "+t.variables[o][t.optimize]+" "+o.replace(s,"_"))}else e+="max:";e+=`;
`;for(var a in t.constraints)for(var f in t.constraints[a])if(typeof i[f]!="undefined"){for(var l in t.variables)typeof t.variables[l][a]!="undefined"&&(e+=" "+t.variables[l][a]+" "+l.replace(s,"_"));e+=" "+i[f]+" "+t.constraints[a][f],e+=`;
`}if(t.ints){e+=`
`;for(var u in t.ints)e+="int "+u.replace(s,"_")+`;
`}if(t.unrestricted){e+=`
`;for(var c in t.unrestricted)e+="unrestricted "+c.replace(s,"_")+`;
`}return e}gr.exports=function(t){return t.length?Qn(t):ti(t)}});var xr=P(fe=>{fe.reformat=qt();function mr(t){return t=t.replace("\\r\\n",`\r
`),t=t.split(`\r
`),t=t.filter(function(e){var r;return r=new RegExp(" 0$","gi"),!(r.test(e)===!0||(r=new RegExp("\\d$","gi"),r.test(e)===!1))}).map(function(e){return e.split(/\:{0,1} +(?=\d)/)}).reduce(function(e,r,n){return e[r[0]]=r[1],e},{}),t}fe.solve=function(t){return new Promise(function(e,r){typeof window!="undefined"&&r("Function Not Available in Browser");var n=qt()(t);t.external||r("Data for this function must be contained in the 'external' attribute. Not seeing anything there."),t.external.binPath||r("No Executable | Binary path provided in arguments as 'binPath'"),t.external.args||r("No arguments array for cli | bash provided on 'args' attribute"),t.external.tempName||r("No 'tempName' given. This is necessary to produce a staging file for the solver to operate on");var i=Oe("fs");i.writeFile(t.external.tempName,n,function(s,o){if(s)r(s);else{var a=Oe("child_process").execFile;t.external.args.push(t.external.tempName),a(t.external.binPath,t.external.args,function(f,l){if(f)if(f.code===1)e(mr(l));else{var u={"-2":"Out of Memory","1":"SUBOPTIMAL","2":"INFEASIBLE","3":"UNBOUNDED","4":"DEGENERATE","5":"NUMFAILURE","6":"USER-ABORT","7":"TIMEOUT","9":"PRESOLVED","25":"ACCURACY ERROR","255":"FILE-ERROR"},c={code:f.code,meaning:u[f.code],data:l};r(c)}else e(mr(l))})}})})}});var yr=P((Ps,br)=>{br.exports={lpsolve:xr()}});var le=P((Ts,wr)=>{wr.exports=function(t,e){var r=e.optimize,n=JSON.parse(JSON.stringify(e.optimize)),i=Object.keys(e.optimize),s,o=0,a={},f="",l={},u=[],c,d,v,g,h;for(delete e.optimize,c=0;c<i.length;c++)n[i[c]]=0;for(c=0;c<i.length;c++){e.optimize=i[c],e.opType=r[i[c]],s=t.Solve(e,void 0,void 0,!0);for(g in i)if(!e.variables[i[g]]){s[i[g]]=s[i[g]]?s[i[g]]:0;for(v in e.variables)e.variables[v][i[g]]&&s[v]&&(s[i[g]]+=s[v]*e.variables[v][i[g]])}for(f="base",d=0;d<i.length;d++)s[i[d]]?f+="-"+(s[i[d]]*1e3|0)/1e3:f+="-0";if(!a[f]){for(a[f]=1,o++,d=0;d<i.length;d++)s[i[d]]&&(n[i[d]]+=s[i[d]]);delete s.feasible,delete s.result,u.push(s)}}for(c=0;c<i.length;c++)e.constraints[i[c]]={equal:n[i[c]]/o};e.optimize="cheater-"+Math.random(),e.opType="max";for(c in e.variables)e.variables[c].cheater=1;for(c in u)for(v in u[c])l[v]=l[v]||{min:1e99,max:-1e99};for(c in l)for(v in u)u[v][c]?(u[v][c]>l[c].max&&(l[c].max=u[v][c]),u[v][c]<l[c].min&&(l[c].min=u[v][c])):(u[v][c]=0,l[c].min=0);return s=t.Solve(e,void 0,void 0,!0),{midpoint:s,vertices:u,ranges:l}}});var pt=P((Rs,Or)=>{var ei=fr(),ue=dr(),ri=ae(),Pt=zt(),Ir=vr(),ni=Pt.Constraint,ii=Pt.Variable,si=Pt.Numeral,oi=Pt.Term,Tt=yr(),Rt=function(){"use strict";this.Model=ue,this.branchAndCut=ri,this.Constraint=ni,this.Variable=ii,this.Numeral=si,this.Term=oi,this.Tableau=ei,this.lastSolvedModel=null,this.External=Tt,this.Solve=function(t,e,r,n){if(n)for(var i in Ir)t=Ir[i](t);if(!t)throw new Error("Solver requires a model to operate on");if(typeof t.optimize=="object"&&Object.keys(t.optimize>1))return le()(this,t);if(t.external){var s=Object.keys(Tt);if(s=JSON.stringify(s),!t.external.solver)throw new Error("The model you provided has an 'external' object that doesn't have a solver attribute. Use one of the following:"+s);if(!Tt[t.external.solver])throw new Error("No support (yet) for "+t.external.solver+". Please use one of these instead:"+s);return Tt[t.external.solver].solve(t)}else{t instanceof ue||(t=new ue(e).loadJson(t));var o=t.solve();if(this.lastSolvedModel=t,o.solutionSet=o.generateSolutionSet(),r)return o;var a={};return a.feasible=o.feasible,a.result=o.evaluation,a.bounded=o.bounded,o._tableau.__isIntegral&&(a.isIntegral=!0),Object.keys(o.solutionSet).forEach(function(f){o.solutionSet[f]!==0&&(a[f]=o.solutionSet[f])}),a}},this.ReformatLP=qt(),this.MultiObjective=function(t){return le()(this,t)}};typeof define=="function"?define([],function(){return new Rt}):typeof window=="object"?window.solver=new Rt:typeof self=="object"&&(self.solver=new Rt);Or.exports=new Rt});var _r=P((Fs,Sr)=>{"use strict";var vt=1e-60,Er,Br;do vt+=vt,Er=1+.1*vt,Br=1+.2*vt;while(Er<=1||Br<=1);Sr.exports=vt});var zr=P((Ls,jr)=>{"use strict";function li(t,e,r){let n,i;for(let s=1;s<=r;s+=1){t[s][s]=1/t[s][s],i=-t[s][s];for(let o=1;o<s;o+=1)t[o][s]*=i;if(n=s+1,r<n)break;for(let o=n;o<=r;o+=1){i=t[s][o],t[s][o]=0;for(let a=1;a<=s;a+=1)t[a][o]+=i*t[a][s]}}}jr.exports=li});var Nr=P((Us,Vr)=>{"use strict";function ui(t,e,r,n){let i,s;for(i=1;i<=r;i+=1){s=0;for(let o=1;o<i;o+=1)s+=t[o][i]*n[o];n[i]=(n[i]-s)/t[i][i]}for(let o=1;o<=r;o+=1){i=r+1-o,n[i]/=t[i][i],s=-n[i];for(let a=1;a<i;a+=1)n[a]+=s*t[a][i]}}Vr.exports=ui});var qr=P((Gs,$r)=>{"use strict";function ci(t,e,r,n){let i,s,o;for(let a=1;a<=r;a+=1){if(n[1]=a,o=0,i=a-1,i<1){if(o=t[a][a]-o,o<=0)break;t[a][a]=Math.sqrt(o)}else{for(let f=1;f<=i;f+=1){s=t[f][a];for(let l=1;l<f;l+=1)s-=t[l][a]*t[l][f];s/=t[f][f],t[f][a]=s,o+=s*s}if(o=t[a][a]-o,o<=0)break;t[a][a]=Math.sqrt(o)}n[1]=0}}$r.exports=ci});var Tr=P((Ws,Pr)=>{"use strict";var he=_r(),hi=zr(),di=Nr(),pi=qr();function vi(t,e,r,n,i,s,o,a,f,l,u,c,d,v=0,g,h,O){let x,m,b,I,w,y,S,E,B,C,j,z,V,q,A=Math.min(n,u),N=2*n+A*(A+5)/2+2*u+1;for(let p=1;p<=n;p+=1)h[p]=e[p];for(let p=n+1;p<=N;p+=1)h[p]=0;for(let p=1;p<=u;p+=1)d[p]=0,s[p]=0;let U=[];if(O[1]===0){if(pi(t,r,n,U),U[1]!==0){O[1]=2;return}di(t,r,n,e),hi(t,r,n)}else{for(let p=1;p<=n;p+=1){i[p]=0;for(let _=1;_<=p;_+=1)i[p]+=t[_][p]*e[_]}for(let p=1;p<=n;p+=1){e[p]=0;for(let _=p;_<=n;_+=1)e[p]+=t[p][_]*i[_]}}o[1]=0;for(let p=1;p<=n;p+=1){i[p]=e[p],o[1]+=h[p]*i[p],h[p]=0;for(let _=p+1;_<=n;_+=1)t[_][p]=0}o[1]=-o[1]/2,O[1]=0;let L=n,W=L+n,D=W+A,et=D+A+1,K=et+A*(A+1)/2,Zt=K+u;for(let p=1;p<=u;p+=1){y=0;for(let _=1;_<=n;_+=1)y+=a[_][p]*a[_][p];h[Zt+p]=Math.sqrt(y)}I=v,g[1]=0,g[2]=0;function yn(){g[1]+=1,N=K;for(let p=1;p<=u;p+=1){N+=1,y=-f[p];for(let _=1;_<=n;_+=1)y+=a[_][p]*i[_];if(Math.abs(y)<he&&(y=0),p>c)h[N]=y;else if(h[N]=-Math.abs(y),y>0){for(let _=1;_<=n;_+=1)a[_][p]=-a[_][p];f[p]=-f[p]}}for(let p=1;p<=I;p+=1)h[K+d[p]]=0;b=0,w=0;for(let p=1;p<=u;p+=1)h[K+p]<w*h[Zt+p]&&(b=p,w=h[K+p]/h[Zt+p]);if(b===0){for(let p=1;p<=I;p+=1)s[d[p]]=h[D+p];return 999}return 0}function wn(){for(let p=1;p<=n;p+=1){y=0;for(let _=1;_<=n;_+=1)y+=t[_][p]*a[_][b];h[p]=y}x=L;for(let p=1;p<=n;p+=1)h[x+p]=0;for(let p=I+1;p<=n;p+=1)for(let _=1;_<=n;_+=1)h[x+_]=h[x+_]+t[_][p]*h[p];z=!0;for(let p=I;p>=1;p-=1){y=h[p],N=et+p*(p+3)/2,x=N-p;for(let _=p+1;_<=I;_+=1)y-=h[N]*h[W+_],N+=_;y/=h[x],h[W+p]=y,!(d[p]<=c)&&(y<=0||(z=!1,m=p))}if(!z){S=h[D+m]/h[W+m];for(let p=1;p<=I;p+=1)d[p]<=c||h[W+p]<=0||(w=h[D+p]/h[W+p],w<S&&(S=w,m=p))}y=0;for(let p=L+1;p<=L+n;p+=1)y+=h[p]*h[p];if(Math.abs(y)<=he){if(z)return O[1]=1,999;for(let p=1;p<=I;p+=1)h[D+p]=h[D+p]-S*h[W+p];return h[D+I+1]=h[D+I+1]+S,700}y=0;for(let p=1;p<=n;p+=1)y+=h[L+p]*a[p][b];E=-h[K+b]/y,V=!0,z||S<E&&(E=S,V=!1);for(let p=1;p<=n;p+=1)i[p]+=E*h[L+p],Math.abs(i[p])<he&&(i[p]=0);o[1]+=E*y*(E/2+h[D+I+1]);for(let p=1;p<=I;p+=1)h[D+p]=h[D+p]-E*h[W+p];if(h[D+I+1]=h[D+I+1]+E,V){I+=1,d[I]=b,N=et+(I-1)*I/2+1;for(let p=1;p<=I-1;p+=1)h[N]=h[p],N+=1;if(I===n)h[N]=h[n];else{for(let p=n;p>=I+1;p-=1)if(h[p]!==0&&(B=Math.max(Math.abs(h[p-1]),Math.abs(h[p])),C=Math.min(Math.abs(h[p-1]),Math.abs(h[p])),h[p-1]>=0?w=Math.abs(B*Math.sqrt(1+C*C/(B*B))):w=-Math.abs(B*Math.sqrt(1+C*C/(B*B))),B=h[p-1]/w,C=h[p]/w,B!==1))if(B===0){h[p-1]=C*w;for(let _=1;_<=n;_+=1)w=t[_][p-1],t[_][p-1]=t[_][p],t[_][p]=w}else{h[p-1]=w,j=C/(1+B);for(let _=1;_<=n;_+=1)w=B*t[_][p-1]+C*t[_][p],t[_][p]=j*(t[_][p-1]+w)-t[_][p],t[_][p-1]=w}h[N]=h[I]}}else{y=-f[b];for(let p=1;p<=n;p+=1)y+=i[p]*a[p][b];if(b>c)h[K+b]=y;else if(h[K+b]=-Math.abs(y),y>0){for(let p=1;p<=n;p+=1)a[p][b]=-a[p][b];f[b]=-f[b]}return 700}return 0}function In(){if(N=et+m*(m+1)/2+1,x=N+m,h[x]===0||(B=Math.max(Math.abs(h[x-1]),Math.abs(h[x])),C=Math.min(Math.abs(h[x-1]),Math.abs(h[x])),h[x-1]>=0?w=Math.abs(B*Math.sqrt(1+C*C/(B*B))):w=-Math.abs(B*Math.sqrt(1+C*C/(B*B))),B=h[x-1]/w,C=h[x]/w,B===1))return 798;if(B===0){for(let p=m+1;p<=I;p+=1)w=h[x-1],h[x-1]=h[x],h[x]=w,x+=p;for(let p=1;p<=n;p+=1)w=t[p][m],t[p][m]=t[p][m+1],t[p][m+1]=w}else{j=C/(1+B);for(let p=m+1;p<=I;p+=1)w=B*h[x-1]+C*h[x],h[x]=j*(h[x-1]+w)-h[x],h[x-1]=w,x+=p;for(let p=1;p<=n;p+=1)w=B*t[p][m]+C*t[p][m+1],t[p][m+1]=j*(t[p][m]+w)-t[p][m+1],t[p][m]=w}return 0}function On(){x=N-m;for(let p=1;p<=m;p+=1)h[x]=h[N],N+=1,x+=1;return h[D+m]=h[D+m+1],d[m]=d[m+1],m+=1,m<I?797:0}function we(){return h[D+I]=h[D+I+1],h[D+I+1]=0,d[I]=0,I-=1,g[2]+=1,0}for(q=0;;){if(q=yn(),q===999)return;for(;q=wn(),q!==0;){if(q===999)return;if(q===700)if(m===I)we();else{for(;In(),q=On(),q===797;);we()}}}}Pr.exports=vi});var Ar=P(Rr=>{"use strict";var gi=Tr();function mi(t,e,r,n=[],i=0,s=[0,0]){let o=[],a=[],f=[],l=[],u=[],c=[],d="",v=t.length-1,g=r[1].length-1;if(!n)for(let x=1;x<=g;x+=1)n[x]=0;if(v!==t[1].length-1&&(d="Dmat is not symmetric!"),v!==e.length-1&&(d="Dmat and dvec are incompatible!"),v!==r.length-1&&(d="Amat and dvec are incompatible!"),g!==n.length-1&&(d="Amat and bvec are incompatible!"),(i>g||i<0)&&(d="Value of meq is invalid!"),d!=="")return{message:d};for(let x=1;x<=g;x+=1)a[x]=0,l[x]=0;let h=0,O=Math.min(v,g);for(let x=1;x<=v;x+=1)f[x]=0;o[1]=0;for(let x=1;x<=2*v+O*(O+5)/2+2*g+1;x+=1)u[x]=0;for(let x=1;x<=2;x+=1)c[x]=0;return gi(t,e,v,v,f,l,o,r,n,v,g,i,a,h,c,u,s),s[1]===1&&(d="constraints are inconsistent, no solution!"),s[1]===2&&(d="matrix D in quadratic function is not positive definite!"),{solution:f,Lagrangian:l,value:o,unconstrained_solution:e,iterations:c,iact:a,message:d}}Rr.solveQP=mi});var kr=P((Zs,Dr)=>{"use strict";Dr.exports=Ar()});var fn=P((No,an)=>{"use strict";var Ei=function(t,e){return t<e};function k(t){if(!(this instanceof k))return new k(t);this.array=[],this.size=0,this.compare=t||Ei}k.prototype.clone=function(){var t=new k(this.compare);return t.size=this.size,t.array=this.array.slice(0,this.size),t};k.prototype.add=function(t){var e=this.size;this.array[this.size]=t,this.size+=1;for(var r,n;e>0&&(r=e-1>>1,n=this.array[r],!!this.compare(t,n));)this.array[e]=n,e=r;this.array[e]=t};k.prototype.heapify=function(t){this.array=t,this.size=t.length;var e;for(e=this.size>>1;e>=0;e--)this._percolateDown(e)};k.prototype._percolateUp=function(t,e){for(var r=this.array[t],n,i;t>0&&(n=t-1>>1,i=this.array[n],!(!e&&!this.compare(r,i)));)this.array[t]=i,t=n;this.array[t]=r};k.prototype._percolateDown=function(t){for(var e=this.size,r=this.size>>>1,n=this.array[t],i,s,o;t<r&&(i=(t<<1)+1,s=i+1,o=this.array[i],s<e&&this.compare(this.array[s],o)&&(i=s,o=this.array[s]),!!this.compare(o,n));)this.array[t]=o,t=i;this.array[t]=n};k.prototype._removeAt=function(t){if(!(t>this.size-1||t<0))return this._percolateUp(t,!0),this.poll()};k.prototype.remove=function(t){for(var e=0;e<this.size;e++)if(!this.compare(this.array[e],t)&&!this.compare(t,this.array[e]))return this._removeAt(e),!0;return!1};k.prototype.removeOne=function(t){if(typeof t=="function"){for(var e=0;e<this.size;e++)if(t(this.array[e]))return this._removeAt(e)}};k.prototype.removeMany=function(t,e){if(typeof t!="function"||this.size<1)return[];e=e?Math.min(e,this.size):this.size;for(var r=0,n=new Array(e),i=0,s=new Array(this.size);r<e&&!this.isEmpty();){var o=this.poll();t(o)?n[r++]=o:s[i++]=o}n.length=r;for(var a=0;a<i;)this.add(s[a++]);return n};k.prototype.peek=function(){if(this.size!=0)return this.array[0]};k.prototype.poll=function(){if(this.size!=0){var t=this.array[0];return this.size>1?(this.array[0]=this.array[--this.size],this._percolateDown(0)):this.size-=1,t}};k.prototype.replaceTop=function(t){if(this.size!=0){var e=this.array[0];return this.array[0]=t,this._percolateDown(0),e}};k.prototype.trim=function(){this.array=this.array.slice(0,this.size)};k.prototype.isEmpty=function(){return this.size===0};k.prototype.forEach=function(t){if(!(this.isEmpty()||typeof t!="function"))for(var e=0,r=this.clone();!r.isEmpty();)t(r.poll(),e++)};k.prototype.kSmallest=function(t){if(this.size==0)return[];t=Math.min(this.size,t);var e=new k(this.compare);let r=Math.min((t>0?Math.pow(2,t-1):0)+1,this.size);e.size=r,e.array=this.array.slice(0,r);for(var n=new Array(t),i=0;i<t;i++)n[i]=e.poll();return n};an.exports=k});var Bi={};_n(Bi,{aggMeanFactory:()=>Gr,aggMedianFactory:()=>pe,coordCenter:()=>en,coordGreedy:()=>rn,coordQuad:()=>Ut,coordTopological:()=>nn,dagConnect:()=>ze,dagHierarchy:()=>It,dagStratify:()=>Pe,decrossOpt:()=>on,decrossTwoLayer:()=>Wt,grid:()=>ke,laneGreedy:()=>St,laneOpt:()=>Cr,layeringCoffmanGraham:()=>cn,layeringLongestPath:()=>dn,layeringSimplex:()=>Jt,layeringTopological:()=>pn,sugiyama:()=>tn,twolayerAgg:()=>Gt,twolayerOpt:()=>gn,zherebko:()=>bn});function*Z(t){let e=0;for(let r of t)yield[e++,r]}function*Ce(t,e){for(let[r,n]of Z(t))yield*e(n,r)}function xt(t,e,r){let n=e,i=r;for(let[s,o]of Z(t))i=n(i,o,s);return i}function*T(t,e){for(let[r,n]of Z(t))yield e(n,r)}function Ee(t,e){for(let[r,n]of Z(t))if(!e(n,r))return!1;return!0}function*Be(t){for(let e=t.length;e!=0;)yield t[--e]}function Y(t){return xt(t,e=>e+1,0)}function M(t){if(t!==void 0)return t;throw new Error("internal error: got unexpected undefined value")}function $(t){if(!t)throw new Error("internal error: failed assert")}function Se(t,e){if(e.size!==t.size)return!1;for(let r of t)if(!e.has(r))return!1;return!0}function _e(t,e){e.size<t.size&&([e,t]=[t,e]);for(let r of t)if(e.has(r))return!0;return!1}function zn(){let t=new WeakSet;return(e,r)=>{if(typeof r=="object"&&r!==null){if(t.has(r))return"[circular]";t.add(r)}return r}}function F(t,...e){let[r,...n]=t;return[r].concat(...n.map((i,s)=>[JSON.stringify(e[s],zn()),i])).join("")}function*G(t){let[e,...r]=t;for(let n of r)yield[e,n],e=n}function*at(t,...e){let r=new Set,n;for(;n=e.pop();)r.has(n)||(yield n,r.add(n),e.push(...t(n)))}var ft=window&&window.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r},bt=class{constructor(e,r,n=[]){this.child=e,this.data=r,this.points=n}},je=class{constructor(e,r,n,i){this.source=e,this.target=r,this.data=n,this.points=i}},Q=class{constructor(e){e&&(this.proots=e)}[Symbol.iterator](){return this.idescendants()[Symbol.iterator]()}iroots(){let e=M(this.proots);return{[Symbol.iterator]:()=>e[Symbol.iterator]()}}roots(){return[...this.iroots()]}*idepth(){yield*at(r=>r.ichildren(),...this.iroots())}*ibreadth(){let e=new Set,r=this.roots(),n=[];do{n=r.reverse(),r=[];let i;for(;i=n.pop();)e.has(i)||(e.add(i),yield i,r.push(...i.ichildren()))}while(r.length)}*ibefore(){let e=new Map;for(let i of this)for(let s of i.ichildren())e.set(s,(e.get(s)||0)+1);let r=this.roots(),n;for(;n=r.pop();){yield n;for(let i of n.ichildren()){let s=M(e.get(i));s>1?e.set(i,s-1):r.push(i)}}}*iafter(){let e=this.roots(),r=new Set,n;for(;n=e.pop();)r.has(n)||(Ee(n.ichildren(),i=>r.has(i))?(r.add(n),yield n):(e.push(n),e.push(...n.ichildren())))}idescendants(e="depth"){if(e==="depth")return this.idepth();if(e==="breadth")return this.ibreadth();if(e==="before")return this.ibefore();if(e==="after")return this.iafter();throw new Error(`unknown iteration style: ${e}`)}descendants(e="depth"){return[...this.idescendants(e)]}ilinks(){return Ce(this.idescendants(),e=>e.ichildLinks())}links(){return[...this.ilinks()]}size(){return xt(this.idescendants(),e=>e+1,0)}sum(e){let r=new Map;for(let[n,i]of Z(this.idescendants("after"))){let s=e(i,n),o=new Map;o.set(i,s);for(let a of i.ichildren()){let f=M(r.get(a));for(let[l,u]of f.entries())o.set(l,u)}i.value=xt(o.values(),(a,f)=>a+f,0),r.set(i,o)}return this}count(){let e=new Map;for(let r of this.idescendants("after"))if(r.ichildren()[Symbol.iterator]().next().done)e.set(r,new Set([r])),r.value=1;else{let n=new Set;for(let i of r.ichildren()){let s=M(e.get(i));for(let o of s)n.add(o)}e.set(r,n),r.value=n.size}return this}height(){for(let e of this.idescendants("after"))e.value=Math.max(0,...T(e.ichildren(),r=>M(r.value)+1));return this}depth(){let e=new Map;for(let r of this)for(let n of r.ichildren()){let i=e.get(n);i?i.push(r):e.set(n,[r])}for(let r of this.idescendants("before"))r.value=Math.max(0,...T(e.get(r)||[],n=>M(n.value)+1));return this}*isplit(){let e=new Map;for(let i of this)for(let s of i.ichildren()){let o=e.get(s);o?o.push(i):e.set(s,[i])}function*r(i){yield*i.ichildren(),yield*e.get(i)||[]}let n=new Set(this.iroots());for(let i of this.iroots()){if(!n.delete(i))continue;let s=[i];for(let o of at(r,i))n.delete(o)&&s.push(o);yield s.length>1?new Q(s):s[0]}}split(){return[...this.isplit()]}connected(){let e=this.isplit()[Symbol.iterator](),{done:r}=e.next();return $(!r),{done:r}=e.next(),!!r}},lt=class extends Q{constructor(e){super();this.data=e,this.dataChildren=[]}iroots(){let e=[this];return{[Symbol.iterator]:()=>e[Symbol.iterator]()}}*ichildren(){for(let{child:e}of this.dataChildren)yield e}children(){return[...this.ichildren()]}*ichildLinks(){for(let{child:e,data:r,points:n}of this.dataChildren)yield new je(this,e,r,n)}childLinks(){return[...this.ichildLinks()]}isplit(){return this.iroots()}split(){return this.roots()}connected(){return!0}};function Yt(t){if(typeof t!="string")throw new Error(`id is supposed to be string but got type ${typeof t}`);return t}function Ht(t){if(!t.length)throw new Error("dag contained no roots; this often indicates a cycle");for(let s of new Q(t))if(new Set(s.ichildren()).size!==Y(s.ichildren()))throw new Error(F`node '${s.data}' contained duplicate children`);let e=new Set,r=new Set,n=null;function i(s){if(e.has(s))return[];if(r.has(s))return n=s,[s];{r.add(s);let o=[];for(let a of s.ichildren())if(o=i(a),o.length)break;return r.delete(s),e.add(s),o.length&&n!==null&&o.push(s),n===s&&(n=null),o}}for(let s of t){let o=i(s);if(o.length){let a=o.reverse().map(({data:f})=>F`'${f}'`).join(" -> ");throw new Error(`dag contained a cycle: ${a}`)}}}function yt(t){function e(s){if(!s.length)throw new Error("can't connect empty data");let o=new Map,a=new Set;for(let[l,u]of s.entries()){let c=Yt(t.sourceId(u,l)),d=o.get(c);d===void 0&&(d=new lt({id:c}),o.set(c,d));let v=Yt(t.targetId(u,l)),g=o.get(v);g===void 0&&(g=new lt({id:v}),o.set(v,g)),(c!==v||!t.single)&&(d.dataChildren.push(new bt(g,u)),a.add(v))}let f=[];for(let[l,u]of o.entries())a.has(l)||f.push(u);return Ht(f),f.length>1?new Q(f):f[0]}function r(s){if(s===void 0)return t.sourceId;{let{sourceId:o}=t,a=ft(t,["sourceId"]);return yt(Object.assign(Object.assign({},a),{sourceId:s}))}}e.sourceId=r;function n(s){if(s===void 0)return t.targetId;{let{targetId:o}=t,a=ft(t,["targetId"]);return yt(Object.assign(Object.assign({},a),{targetId:s}))}}e.targetId=n;function i(s){return s===void 0?t.single:yt(Object.assign(Object.assign({},t),{single:s}))}return e.single=i,e}function Vn(t){try{return typeof t[0]=="string"}catch(e){return!1}}function Nn(t){if(Vn(t))return t[0];throw new Error(`default source id expected datum[0] to be a string but got datum: ${t}`)}function $n(t){try{return typeof t[1]=="string"}catch(e){return!1}}function qn(t){if($n(t))return t[1];throw new Error(`default target id expected datum[1] to be a string but got datum: ${t}`)}function ze(...t){if(t.length)throw new Error(`got arguments to connect(${t}), but constructor takes no aruguments. These were probably meant as data which should be called as connect()(...)`);return yt({sourceId:Nn,targetId:qn,single:!1})}function wt(t){function e(...s){if(!s.length)throw new Error("must pass in at least one node");let o=new Map,a=[];function f(g){let h=o.get(g);return h===void 0&&(h=new lt(g),o.set(g,h),a.push(h)),h}let l=s.map(f),u,c=0;for(;u=a.pop();)u.dataChildren=(t.childrenData(u.data,c++)||[]).map(([g,h])=>new bt(f(g),h));let d=new Set(l);for(let g of o.values())for(let h of g.ichildren())if(d.delete(h)&&t.roots)throw new Error(F`node '${g.data}' pointed to a root`);let v=d.size&&d.size!==l.length?[...d]:l;return Ht(v),v.length>1?new Q(v):v[0]}function r(s){return s===void 0?t.children:wt({children:s,childrenData:Ve(s),roots:t.roots})}e.children=r;function n(s){return s===void 0?t.childrenData:wt({children:Pn(s),childrenData:s,roots:t.roots})}e.childrenData=n;function i(s){return s===void 0?t.roots:wt(Object.assign(Object.assign({},t),{roots:s}))}return e.roots=i,e}function Ve(t){function e(r,n){return(t(r,n)||[]).map(i=>[i,void 0])}return e.wrapped=t,e}function Pn(t){function e(r,n){return(t(r,n)||[]).map(([i])=>i)}return e.wrapped=t,e}function Tn(t){try{let e=t.children;return e===void 0||e instanceof Array}catch(e){return!1}}function Ne(t){if(Tn(t))return t.children;throw new Error(F`default children function expected datum to have a children field but got: ${t}`)}function It(...t){if(t.length)throw new Error(`got arguments to hierarchy(${t}), but constructor takes no aruguments. These were probably meant as data which should be called as hierarchy()(...)`);return wt({children:Ne,childrenData:Ve(Ne),roots:!0})}function Ot(t){function e(s){if(!s.length)throw new Error("can't stratify empty data");let o=new Map;for(let[f,l]of s.entries()){let u=Yt(t.id(l,f)),c=t.parentData(l,f)||[],d=new lt(l);if(o.has(u))throw new Error(`found a duplicate id: ${r}`);o.set(u,[d,c])}let a=[];for(let[f,l]of o.values()){for(let[u,c]of l){let d=o.get(u);if(!d)throw new Error(`missing id: ${u}`);let[v]=d;v.dataChildren.push(new bt(f,c))}l.length||a.push(f)}return Ht(a),a.length>1?new Q(a):a[0]}function r(s){if(s===void 0)return t.id;{let{id:o}=t,a=ft(t,["id"]);return Ot(Object.assign(Object.assign({},a),{id:s}))}}e.id=r;function n(s){if(s===void 0)return t.parentData;{let{parentIds:o,parentData:a}=t,f=ft(t,["parentIds","parentData"]);return Ot(Object.assign(Object.assign({},f),{parentIds:Rn(s),parentData:s}))}}e.parentData=n;function i(s){if(s===void 0)return t.parentIds;{let{parentIds:o,parentData:a}=t,f=ft(t,["parentIds","parentData"]);return Ot(Object.assign(Object.assign({},f),{parentIds:s,parentData:$e(s)}))}}return e.parentIds=i,e}function $e(t){function e(r,n){return(t(r,n)||[]).map(i=>[i,void 0])}return e.wrapped=t,e}function Rn(t){function e(r,n){return(t(r,n)||[]).map(([i])=>i)}return e.wrapped=t,e}function An(t){try{return typeof t.id=="string"}catch(e){return!1}}function Dn(t){if(An(t))return t.id;throw new Error(F`default id function expected datum to have an id field but got '${t}'`)}function kn(t){try{let e=t.parentIds;return e===void 0||e instanceof Array&&e.every(r=>typeof r=="string")}catch(e){return!1}}function qe(t){if(kn(t))return t.parentIds;throw new Error(`default parentIds function expected datum to have a parentIds field but got: ${t}`)}function Pe(...t){if(t.length)throw new Error(`got arguments to stratify(${t}), but constructor takes no aruguments. These were probably meant as data which should be called as stratify()(...)`);return Ot({id:Dn,parentIds:qe,parentData:$e(qe)})}function tt(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function*Te(t,e){if(e===void 0)for(let r of t)r!=null&&(r=+r)>=r&&(yield r);else{let r=-1;for(let n of t)(n=e(n,++r,t))!=null&&(n=+n)>=n&&(yield n)}}function Re(t=tt){if(t===tt)return Xt;if(typeof t!="function")throw new TypeError("compare is not a function");return(e,r)=>{let n=t(e,r);return n||n===0?n:(t(r,r)===0)-(t(e,e)===0)}}function Xt(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}function Mt(t,e){let r;if(e===void 0)for(let n of t)n!=null&&(r<n||r===void 0&&n>=n)&&(r=n);else{let n=-1;for(let i of t)(i=e(i,++n,t))!=null&&(r<i||r===void 0&&i>=i)&&(r=i)}return r}function Ct(t,e){let r;if(e===void 0)for(let n of t)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);else{let n=-1;for(let i of t)(i=e(i,++n,t))!=null&&(r>i||r===void 0&&i>=i)&&(r=i)}return r}function Et(t,e,r=0,n=t.length-1,i){for(i=i===void 0?Xt:Re(i);n>r;){if(n-r>600){let f=n-r+1,l=e-r+1,u=Math.log(f),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(f-c)/f)*(l-f/2<0?-1:1),v=Math.max(r,Math.floor(e-l*c/f+d)),g=Math.min(n,Math.floor(e+(f-l)*c/f+d));Et(t,e,v,g,i)}let s=t[e],o=r,a=n;for(ut(t,r,e),i(t[n],s)>0&&ut(t,r,n);o<a;){for(ut(t,o,a),++o,--a;i(t[o],s)<0;)++o;for(;i(t[a],s)>0;)--a}i(t[r],s)===0?ut(t,r,a):(++a,ut(t,a,n)),a<=e&&(r=a+1),e<=a&&(n=a-1)}return t}function ut(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}function Kt(t,e,r){if(t=Float64Array.from(Te(t,r)),!!(n=t.length)){if((e=+e)<=0||n<2)return Ct(t);if(e>=1)return Mt(t);var n,i=(n-1)*e,s=Math.floor(i),o=Mt(Et(t,s).subarray(0,s+1)),a=Ct(t.subarray(s+1));return o+(a-o)*(i-s)}}function st(t,e){return Kt(t,.5,e)}function ct(t,e=tt){let r,n=!1;if(e.length===1){let i;for(let s of t){let o=e(s);(n?tt(o,i)<0:tt(o,o)===0)&&(r=s,i=o,n=!0)}}else for(let i of t)(n?e(i,r)<0:e(i,i)===0)&&(r=i,n=!0);return r}var Ae=class{constructor(e){this.uncompressed=e,this.indices=[]}getIndex(e,r){var n;let i=[];for(let[a,f]of this.indices.entries())f<=e&&i.push(a);this.uncompressed&&i.push(this.indices.length);let s=r!=null?r:0,o=(n=ct(i,a=>[Math.abs(s-a),a]))!==null&&n!==void 0?n:this.indices.length;return this.setIndex(o,e),o}setIndex(e,r){this.indices[e]=r}offset(){return 0}},De=class{constructor(e){this.uncompressed=e,this.posIndices=[0],this.negIndices=[]}nextNeg(){return-this.negIndices.length-1}nextPos(){return this.posIndices.length}getIndex(e,r){var n;let i=[];for(let[f,l]of this.negIndices.entries())l<=e&&i.push(-f-1);for(let[f,l]of this.posIndices.entries())l<=e&&i.push(f);this.uncompressed&&(i.push(this.nextNeg()),i.push(this.nextPos()));let s=r!=null?r:0,o=this.negIndices.length<this.posIndices.length-1?this.nextNeg():this.nextPos(),a=(n=ct(i,f=>[Math.abs(s-f),Math.abs(f),-f]))!==null&&n!==void 0?n:o;return this.setIndex(a,e),a}setIndex(e,r){e<0?this.negIndices[-e-1]=r:this.posIndices[e]=r}offset(){return this.negIndices.length}};function Fn(t,e){return e?new De(!t):new Ae(!t)}function Ln(t,e){for(let n of t)n.x=void 0;for(let n of t){$(n.y!==void 0),n.x===void 0&&(n.x=e.getIndex(n.y));for(let[i,s]of[...T(n.ichildren(),o=>[o,M(o.y)])].sort(([,o],[,a])=>a-o))i.x===void 0&&(i.x=e.getIndex(n.y,n.x),e.setIndex(i.x,s))}let r=e.offset();for(let n of t)$(n.x!==void 0),n.x+=r}function Un(t,e){var r;let n=new Map;for(let s of t){s.x=void 0,$(s.y!==void 0);for(let o of s.ichildren()){let a=n.get(o);(a===void 0||s.y<M(a.y))&&n.set(o,s)}}for(let s of Be(t)){if(s.x===void 0){let a=st(T(s.ichildren(),f=>f.x));s.x=e.getIndex(t.length-M(s.y),a)}let o=n.get(s);o!==void 0&&((r=o.x)!==null&&r!==void 0||(o.x=s.x),e.setIndex(s.x,t.length-M(o.y)))}let i=e.offset();for(let s of t)$(s.x!=null),s.x+=i}function Bt(t,e,r){function n(a){let f=Fn(e,r);t?Ln(a,f):Un(a,f)}function i(a){return a===void 0?t:Bt(a,e,r)}n.topDown=i;function s(a){return a===void 0?e:Bt(t,a,r)}n.compressed=s;function o(a){return a===void 0?r:Bt(t,e,a)}return n.bidirectional=o,n}function St(...t){if(t.length)throw new Error(`got arguments to greedy(${t}), but constructor takes no aruguments.`);return Bt(!0,!0,!1)}function Gn(t){for(let n of t){if(n.x===void 0)throw new Error(F`coord didn't assign an x to node '${n}'`);if(n.x<0)throw new Error(`coord assgined an x (${n.x}) less than 0`)}let e=new Set(t.map(n=>n.x));if(!Se(e,new Set(T(e,(n,i)=>i)))){let n=[...e].join(", ");throw new Error(`didn't assign increasing positive integers for x coordinates: ${n}`)}let r=new Map;for(let[n,i]of t.entries()){let s=r.get(i);if(s!==void 0){for(let o of t.slice(s+1,n))if(o.x===i.x)throw new Error(F`node ${o} was assigned an overlapping lane with ${i}`)}for(let o of i.ichildren())r.has(o)||r.set(o,n)}return e.size}function _t(t,e,r,n){function i(f){let l=[...f.idescendants("before")];for(let[v,g]of l.entries())g.y=v;t(l);let u=Gn(l);for(let v of l)v.x=(M(v.x)+.5)*e,v.y=(M(v.y)+.5)*r;let c=u*e,d=l.length*r;if(n!==null){let[v,g]=n;for(let h of l)$(h.x!==void 0&&h.y!==void 0),h.x*=v/c,h.y*=g/d;c=v,d=g}for(let{source:v,target:g,points:h}of f.ilinks())h.length=0,$(v.x!==void 0&&v.y!==void 0),$(g.x!==void 0&&g.y!==void 0),v.x!=g.x&&h.push({x:v.x,y:v.y}),h.push({x:g.x,y:v.y}),h.push({x:g.x,y:g.y});return{width:c,height:d}}function s(f){return f===void 0?t:_t(f,e,r,n)}i.lane=s;function o(f){if(f===void 0)return[e,r];{let[l,u]=f;return _t(t,l,u,n)}}i.nodeSize=o;function a(f){if(f!==void 0)return _t(t,e,r,f);if(n===null)return null;{let[l,u]=n;return[l,u]}}return i.size=a,i}function ke(...t){if(t.length)throw new Error(`got arguments to grid(${t}), but constructor takes no aruguments.`);return _t(St(),1,1,null)}var Mr=it(pt());var ai=window&&window.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r};function fi(t){let e=[],r=new Set;for(let n of t){let i=M(n.y);if(!r.has(n)){let s=e.findIndex(a=>a<=i),o=s===-1?e.length:s;e[o]=i}for(let[s,o]of[...T(n.ichildren(),a=>[a,M(a.y)])].sort(([,a],[,f])=>f-a))if(!r.has(s)){let a=e.findIndex(l=>l<=i),f=a===-1?e.length:a;e[f]=o,r.add(s)}}return e.length}function ce(t,e){function r(s){var o,a,f;let l={optimize:"opt",opType:"min",constraints:{},variables:{},ints:{}},u=new Map(T(s,(O,x)=>[O,x])),c=t?fi(s):s.length-1;for(let O of s.keys())l.variables[O]={opt:0,[O]:1},l.constraints[O]={max:c-1};let d=new Map;for(let[O,x]of s.entries()){let m=d.get(x);if(m!==void 0)for(let[b,I]of s.slice(m+1,O).entries()){let w=b+m+1,y=`${O}-${w}-above`;l.variables[y]={opt:0,[y]:1},l.constraints[y]={max:1},l.ints[y]=1;let S=`${y}-span`;l.variables[O][S]=1,l.variables[w][S]=-1,l.variables[y][S]=-c,l.constraints[S]={min:1-c,max:-1};for(let E of I.ichildren()){if(E===x)continue;let B=M(u.get(E)),C=`${y}-${B}-cross`;l.variables[C]={opt:1,[C]:1},l.constraints[C]={max:1},l.ints[C]=1;let j=`${C}-left`;l.variables[O][j]=-1,l.variables[B][j]=1,l.variables[y][j]=c,l.variables[C][j]=-c,l.constraints[j]={max:c};let z=`${C}-right`;l.variables[O][z]=-1,l.variables[B][z]=1,l.variables[y][z]=c,l.variables[C][z]=c,l.constraints[z]={min:0}}}for(let b of x.ichildren())d.has(b)||d.set(b,O)}if(e){let O=s.reduce((x,m)=>x+m.children().length,0);for(let[x,m]of s.entries())for(let b of m.ichildren()){let I=M(u.get(b)),w=`${x}-${I}-dist`;l.variables[w]={opt:1/O};let y=`${w}-upper`;l.variables[x][y]=1,l.variables[I][y]=-1,l.variables[w][y]=-c,l.constraints[y]={max:0};let S=`${w}-lower`;l.variables[x][S]=1,l.variables[I][S]=-1,l.variables[w][S]=c,l.constraints[S]={min:0}}}let v=Mr.Solve.call({},l),{feasible:g}=v,h=ai(v,["feasible"]);if(!g)throw new Error("internal error: couldn't find a feasible solution");if(e||t)for(let[O,x]of s.entries())x.x=(o=h[O])!==null&&o!==void 0?o:0;else{let O=new Set;for(let m of s.keys())O.add((a=h[m])!==null&&a!==void 0?a:0);let x=new Map(T([...O].sort(),(m,b)=>[m,b]));for(let[m,b]of s.entries())b.x=M(x.get((f=h[m])!==null&&f!==void 0?f:0))}}function n(s){return s===void 0?t:ce(s,e)}r.compressed=n;function i(s){return s===void 0?e:ce(t,s)}return r.dist=i,r}function Cr(...t){if(t.length)throw new Error(`got arguments to opt(${t}), but constructor takes no aruguments.`);return ce(!1,!0)}var Fr=it(kr());function xi(t,e,r,n,i){if(!e.length)return[];let s=[[0]],o=[0],a=[[0]],f=[0];for(let c of t){let d=[0];d.push(...c),s.push(d)}o.push(...e),a.push(...e.map(()=>[0]));for(let c of r)for(let[d,v]of c.entries())a[d+1].push(-v);f.push(...n.map(c=>-c));let{solution:l,message:u}=(0,Fr.solveQP)(s,o,a,f,i);return $(!u.length),l.shift(),l}function At(t,e,r,n,i=0){e.pop(),t.pop(),t.forEach(o=>o.pop()),r.forEach(o=>o.pop());let s=xi(t,e,r,n,i);return s.push(0),s}function Lr(t){return new Map(t.flatMap(e=>e).map((e,r)=>[e,r]))}function Dt(t,e,r){let n=1+Math.max(...e.values()),i=[],s=[];for(let f of t)for(let[l,u]of G(f)){let c=M(e.get(l)),d=M(e.get(u)),v=new Array(n).fill(0);v[c]=1,v[d]=-1,i.push(v),s.push(-(r(l)+r(u))/2)}let o=new Array(n).fill(0);return[[...new Array(n)].map(()=>new Array(n).fill(0)),o,i,s]}function de(t,e,r,n){t[r][r]+=n,t[r][e]-=n,t[e][r]-=n,t[e][e]+=n}function kt(t,e,r,n,i){t[n][n]+=i,t[n][r]-=2*i,t[n][e]+=i,t[r][n]-=2*i,t[r][r]+=4*i,t[r][e]-=2*i,t[e][n]+=i,t[e][r]-=2*i,t[e][e]+=i}function Ft(t,e,r,n){let i=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(let a of t){let f=a[0],l=a[a.length-1];i=Math.min(i,n[M(r.get(f))]-e(f)/2),s=Math.max(s,n[M(r.get(l))]+e(l)/2)}let o=s-i;for(let a of t)for(let f of a)f.x=Math.min(Math.max(0,n[M(r.get(f))]-i),o);return o}function bi(t){let e=new Map;for(let s of t)for(let o of s)for(let a of o.ichildren()){let f=e.get(a);f?f.push(o):e.set(a,[o])}function*r(s){yield*s.ichildren(),yield*e.get(s)||[]}let n=0,i=new Map;for(let s of t)for(let o of s)if(!i.has(o)){for(let a of at(r,o))i.set(a,n);n++}return i}function yi(t,e){let r=[],n=[],i=new Set;for(let s of t){let o=new Set(s.map(a=>M(e.get(a))));_e(i,o)||r.push(n=[]),n.push(s),i=o}return r}function Lt(t){function e(o,a,f){let{vertNode:l,vertDummy:u,curveNode:c,curveDummy:d,comp:v}=t,g=Lr(o),[h,O,x,m]=Dt(o,g,a);for(let I of o)for(let w of I){let y=M(g.get(w)),S="node"in w.data?l:u;for(let E of w.ichildren()){let B=M(g.get(E)),C="node"in E.data?l:u,j="node"in E.data?c:d;de(h,y,B,S+C);for(let z of E.ichildren()){let V=M(g.get(z));kt(h,y,B,V,j)}}}for(let I of o)for(let[w,y]of G(I))M(f.get(w))!==M(f.get(y))&&de(h,M(g.get(w)),M(g.get(y)),v);let b=At(h,O,x,m);return Ft(o,a,g,b)}function r(o,a){let{vertNode:f,vertDummy:l,curveNode:u,curveDummy:c}=t;if(f===0&&u===0)throw new Error("node vertical weight or node curve weight needs to be positive");if(l===0&&c===0)throw new Error("dummy vertical weight or dummy curve weight needs to be positive");let d=bi(o),v=yi(o,d),g=v.map(O=>e(O,a,d)),h=Math.max(...g);if(h<=0)throw new Error("must assign nonzero width to at least one node");for(let[O,x]of v.entries()){let m=(h-g[O])/2;for(let b of x)for(let I of b)I.x=M(I.x)+m}return h}function n(o){if(o===void 0){let{vertNode:l,vertDummy:u}=t;return[l,u]}let[a,f]=o;if(a<0||f<0)throw new Error(`weights must be non-negative, but were ${a} and ${f}`);return Lt(Object.assign(Object.assign({},t),{vertNode:a,vertDummy:f}))}r.vertical=n;function i(o){if(o===void 0){let{curveNode:l,curveDummy:u}=t;return[l,u]}let[a,f]=o;if(a<0||f<0)throw new Error(`weights must be non-negative, but were ${a} and ${f}`);return Lt(Object.assign(Object.assign({},t),{curveNode:a,curveDummy:f}))}r.curve=i;function s(o){if(o===void 0)return t.comp;if(o<=0)throw new Error(`weight must be positive, but was ${o}`);return Lt(Object.assign(Object.assign({},t),{comp:o}))}return r.component=s,r}function Ut(...t){if(t.length)throw new Error(`got arguments to quad(${t}), but constructor takes no aruguments.`);return Lt({vertNode:1,vertDummy:0,curveNode:0,curveDummy:1,comp:1})}var Ur=class{constructor(){this.mean=0,this.count=0}add(e){this.mean+=(e-this.mean)/++this.count}val(){return this.count?this.mean:void 0}},Gr=()=>new Ur,Wr=class{constructor(){this.vals=[]}add(e){this.vals.push(e)}val(){return st(this.vals)}},pe=()=>new Wr;function wi(t,e){let r=t();for(let n of e)r.add(n);return r.val()}function Jr(t,e){let r=new Map;for(let u of t){let c=e.get(u);if(c===void 0)continue;let d=r.get(c);d===void 0?r.set(c,[u]):d.push(u)}let n=[...r.entries()].sort(([u],[c])=>u-c).flatMap(([,u])=>u),i=new Map(t.map((u,c)=>[u,c])),s=t.filter(u=>e.get(u)===void 0),o=new Array(s.length).fill(null);function a(u,c,d,v){if(c<=u)return;let g=Math.floor((u+c)/2),h=s[g],O=M(i.get(h)),x=0,m=[x];for(let I=d;I<v;++I)x+=M(i.get(n[I]))<O?-1:1,m.push(x);let b=d+m.indexOf(Math.min(...m));o[g]=b,a(u,g,d,b),a(g+1,c,b,v)}a(0,s.length,0,n.length),o.push(n.length+1);let f=0,l=0;for(let[u,c]of n.entries()){for(;o[l]==u;)t[f++]=s[l++];t[f++]=c}for(;o[l]==n.length;)t[f++]=s[l++]}function Zr({factory:t}){function e(n,i,s){if(s){let o=new Map(i.map(f=>[f,t()]));for(let[f,l]of n.entries())for(let u of l.ichildren())M(o.get(u)).add(f);let a=new Map([...o.entries()].map(([f,l])=>[f,l.val()]));Jr(i,a)}else{let o=new Map(i.map((f,l)=>[f,l])),a=new Map(n.map(f=>{let l=wi(t,T(f.ichildren(),u=>M(o.get(u))));return[f,l]}));Jr(n,a)}}function r(n){return n===void 0?t:Zr({factory:n})}return e.aggregator=r,e}function Gt(...t){if(t.length)throw new Error(`got arguments to agg(${t}), but constructor takes no aruguments.`);return Zr({factory:pe})}var Ii=window&&window.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r};function ve(t){function e(i){let s=i.slice().reverse(),o=!0;for(let a=0;a<t.passes&&o;++a){o=!1;for(let[f,l]of G(i)){let u=new Map(l.map((c,d)=>[c,d]));t.order(f,l,!0),l.some((c,d)=>M(u.get(c))!==d)&&(o=!0)}for(let[f,l]of G(s)){let u=new Map(l.map((c,d)=>[c,d]));t.order(l,f,!1),l.some((c,d)=>M(u.get(c))!==d)&&(o=!0)}}}function r(i){if(i===void 0)return t.order;{let{order:s}=t,o=Ii(t,["order"]);return ve(Object.assign(Object.assign({},o),{order:i}))}}e.order=r;function n(i){if(i===void 0)return t.passes;if(i<=0)throw new Error("number of passes must be positive");return ve(Object.assign(Object.assign({},t),{passes:i}))}return e.passes=n,e}function Wt(...t){if(t.length)throw new Error(`got arguments to twoLayer(${t}), but constructor takes no aruguments.`);return ve({order:Gt(),passes:1})}var Yr=it(pt());var ge=window&&window.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r};function me(t){function e(i){let s={},o={},a={},f=new Map(T(Z(i.idescendants()),([b,I])=>[I,b.toString()]));function l(b){return M(f.get(b))}function u(b){return s[l(b)]}function c(b,I,w,y=!0){let S=u(I),E=u(w),B=`${b}: ${M(l(I))} -> ${M(l(w))}`;a[B]={min:+y},S[B]=-1,E[B]=1}function d(b,I,w){c(`${b} before`,I,w,!1),c(`${b} after`,w,I,!1)}let v=[],g=new Map;for(let b of i){let I=l(b);o[I]=1,s[I]={opt:b.children.length};let w=t.rank(b);w!==void 0&&v.push([w,b]);let y=t.group(b);if(y!==void 0){let S=g.get(y);S?S.push(b):g.set(y,[b])}}for(let b of i.ilinks())c("link",b.source,b.target),++u(b.source).opt,--u(b.target).opt;let h=v.sort(([b],[I])=>b-I);for(let[[b,I],[w,y]]of G(h))b<w?c("rank",I,y):d("rank",I,y);for(let b of g.values())for(let[I,w]of G(b))d("group",I,w);let O=Yr.Solve.call({},{optimize:"opt",opType:"max",constraints:a,variables:s,ints:o}),{feasible:x}=O,m=ge(O,["feasible"]);if(!x)throw $(v.length||g.size),new Error("could not find a feasbile simplex layout, check that rank or group accessors are not ill-defined");for(let b of i)b.value=m[l(b)]||0}function r(i){if(i===void 0)return t.rank;{let{rank:s}=t,o=ge(t,["rank"]);return me(Object.assign(Object.assign({},o),{rank:i}))}}e.rank=r;function n(i){if(i===void 0)return t.group;{let{group:s}=t,o=ge(t,["group"]);return me(Object.assign(Object.assign({},o),{group:i}))}}return e.group=n,e}function Hr(){}function Jt(...t){if(t.length)throw new Error(`got arguments to simplex(${t}), but constructor takes no aruguments.`);return me({rank:Hr,group:Hr})}function Oi(t){if(t.value===void 0)throw new Error(F`node with data '${t.data}' did not get a defined value during layering`);if(t.value<0)throw new Error(F`node with data '${t.data}' got an invalid (negative) value during layering: ${t.value}`);return t.value}function Xr(t){let e=new Map(T(t.idescendants(),s=>[s,{node:s,layer:Oi(s)}]));function r(s){let o=s.layer+1,a="node"in s?s.node.children():[s.target],f="node"in s?s.node:s.source;return a.map(l=>{let u=M(e.get(l));if(u.layer<o)throw new Error(F`layering left child data '${l.data}' (${l.value}) with greater or equal layer to parent data '${f.data}' (${f.value})`);return u.layer===o?u:{source:f,target:l,layer:o}})}let n=It().children(r)(...T(t.iroots(),s=>M(e.get(s)))),i=[];for(let s of n)(i[s.data.layer]||(i[s.data.layer]=[])).push(s);if(!i[0]||!i[0].length)throw new Error("no nodes were assigned to layer 0");for(let s of i)$(s&&s.length);return i}var gt=window&&window.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r};function Kr(t){let e=t();function r(n){return"node"in n.data?t(n.data.node):e}return r.wrapped=t,r}function Mi(t){let e=new Map;function r(s){let o=e.get(s);if(o===void 0){o=t(s);let[a,f]=o;if(a<0||f<0)throw new Error(F`all node sizes must be non-negative, but got width ${a} and height ${f} for node '${s}'`);e.set(s,o)}return o}return[s=>r(s)[0],s=>r(s)[1]]}function nt(t){function e(f){t.layering(f);let l=Xr(f),[u,c]=Mi(t.sugiNodeSize),d=0;for(let g of l){let h=Math.max(...g.map(c));for(let O of g)O.y=d+h/2;d+=h}if(d<=0)throw new Error("at least one node must have positive height, but total height was zero");t.decross(l);let v=t.coord(l,u);for(let g of l)for(let h of g){if(h.x===void 0)throw new Error(F`coord didn't assign an x to node '${h}'`);if(h.x<0||h.x>v)throw new Error(`coord assgined an x (${h.x}) outside of [0, ${v}]`)}if(t.size!==null){let[g,h]=t.size;for(let O of l)for(let x of O)$(x.x!==void 0&&x.y!==void 0),x.x*=g/v,x.y*=h/d;v=g,d=h}for(let g of l)for(let h of g){if($(h.x!==void 0&&h.y!==void 0),"target"in h.data)continue;h.data.node.x=h.x,h.data.node.y=h.y;let O=new Map(T(h.data.node.ichildLinks(),({points:x,target:m})=>[m,x]));for(let x of h.ichildren()){let m=[{x:h.x,y:h.y}];for(;"target"in x.data;)$(x.x!==void 0&&x.y!==void 0),m.push({x:x.x,y:x.y}),[x]=x.ichildren();$(x.x!==void 0&&x.y!==void 0),m.push({x:x.x,y:x.y});let b=M(O.get(x.data.node));b.splice(0,b.length,...m)}}return{width:v,height:d}}function r(f){if(f===void 0)return t.layering;{let{layering:l}=t,u=gt(t,["layering"]);return nt(Object.assign(Object.assign({},u),{layering:f}))}}e.layering=r;function n(f){if(f===void 0)return t.decross;{let{decross:l}=t,u=gt(t,["decross"]);return nt(Object.assign(Object.assign({},u),{decross:f}))}}e.decross=n;function i(f){if(f===void 0)return t.coord;{let{coord:l}=t,u=gt(t,["coord"]);return nt(Object.assign(Object.assign({},u),{coord:f}))}}e.coord=i;function s(f){return f!==void 0?nt(Object.assign(Object.assign({},t),{size:f})):t.size}e.size=s;function o(f){if(f!==void 0){let{nodeSize:l,sugiNodeSize:u}=t,c=gt(t,["nodeSize","sugiNodeSize"]);return nt(Object.assign(Object.assign({},c),{nodeSize:f,sugiNodeSize:Kr(f)}))}else return t.nodeSize}e.nodeSize=o;function a(f){if(f!==void 0){let{sugiNodeSize:l,nodeSize:u}=t,c=gt(t,["sugiNodeSize","nodeSize"]);return nt(Object.assign(Object.assign({},c),{sugiNodeSize:f,nodeSize:null}))}else return t.sugiNodeSize}return e.sugiNodeSize=a,e}function Qr(t){return[+(t!==void 0),1]}function tn(...t){if(t.length)throw new Error(`got arguments to sugiyama(${t}), but constructor takes no aruguments.`);return nt({layering:Jt(),decross:Wt(),coord:Ut(),size:null,nodeSize:Qr,sugiNodeSize:Kr(Qr)})}function en(...t){if(t.length)throw new Error(`got arguments to center(${t}), but constructor takes no aruguments.`);function e(r,n){let i=r.map(o=>{let a=0;for(let f of o){let l=n(f);f.x=a+l/2,a+=l}return a}),s=Math.max(...i);if(s<=0)throw new Error("must assign nonzero width to at least one node");for(let[o,a]of r.entries()){let f=i[o],l=(s-f)/2;for(let u of a)u.x=M(u.x)+l}return s}return e}function rn(...t){if(t.length)throw new Error(`got arguments to greedy(${t}), but constructor takes no aruguments.`);function e(r,n){let i=Ci,s=new Map;for(let c of r)for(let d of c)s.set(d,Y(d.ichildren())+("node"in d.data?0:-3));for(let c of r)for(let d of c)for(let v of d.ichildren())s.set(v,M(s.get(v))+1);let[o,...a]=r,f=0,l=0;for(let c of o){let d=n(c);c.x=l+d/2,l+=d}for(let c of a){i(o,c);let d=c.map((v,g)=>[g,v]).sort(([v,g],[h,O])=>{let x=M(s.get(g)),m=M(s.get(O));return x===m?v-h:m-x});for(let[v,g]of d){let h=n(g),O=M(g.x)+h/2;for(let m of c.slice(v+1)){let b=n(m)/2;O=(m.x=Math.max(M(m.x),O+b))+b}l=Math.max(l,O);let x=M(g.x)-h/2;for(let m of c.slice(0,v).reverse()){let b=n(m)/2;x=(m.x=Math.min(M(m.x),x-b))-b}f=Math.min(f,x)}o=c}for(let c of r)for(let d of c)d.x=M(d.x)-f;let u=l-f;if(u<=0)throw new Error("must assign nonzero width to at least one node");return u}return e}function Ci(t,e){for(let n of e)n.x=0;let r=new Map;for(let n of t){$(n.x!==void 0);for(let i of n.ichildren()){$(i.x!==void 0);let s=(r.get(i)||0)+1;r.set(i,s),i.x+=(n.x-i.x)/s}}}function nn(...t){if(t.length)throw new Error(`got arguments to topological(${t}), but constructor takes no aruguments.`);function e(r,n){for(let d of r)if(d.reduce((g,h)=>g+ +("node"in h.data),0)!==1)throw new Error("topological() only works with a topological layering");let i=new Map,s=0;for(let d of r)for(let v of d)"target"in v.data&&i.set(v,s++);for(let d of r)for(let v of d)"node"in v.data&&i.set(v,s);let[o,a,f,l]=Dt(r,i,n);for(let d of r)for(let v of d){let g=M(i.get(v));for(let h of v.ichildren()){let O=M(i.get(h));if("target"in h.data)for(let x of h.ichildren()){let m=M(i.get(x));kt(o,g,O,m,1)}}}let u=At(o,a,f,l),c=Ft(r,n,i,u);if(c<=0)throw new Error("must assign nonzero width to at least one node");return c}return e}var sn=it(pt());function xe(t){function e(i){let s=i.reduce((m,b)=>m+b.length*Math.max(b.length-1,0)/2,0),o=i.reduce((m,b)=>m+b.reduce((I,w)=>I+Y(w.ichildren()),0),0);if(t.large!=="large"&&s>1200)throw new Error('size of dag to decrossOpt is too large and will likely crash instead of complete, enable "large" grahps to run anyway');if(t.large!=="large"&&t.large!=="medium"&&(s>400||o>100))throw new Error('size of dag to decrossOpt is too large and will likely not complete, enable "medium" grahps to run anyway');let a=[];for(let[m,b]of G(i)){let I=new Set(m.flatMap(C=>C.children())),w=b.filter(C=>!I.has(C)),y=m.map(C=>C.children()).filter(C=>C.length>1);a.push([w,y]);let S=m.filter(C=>!Y(C.ichildren())),E=new Map;for(let C of m)for(let j of C.ichildren()){let z=E.get(j);z?z.push(C):E.set(j,[C])}let B=[...E.values()];a.push([S,B])}let f=a.reduce((m,[b,I])=>I.reduce((w,y)=>w+y.length*y.length,0)*b.length,0)/4,l=1/(f+1),u=l/(s+1),c={optimize:"opt",opType:"min",constraints:{},variables:{},ints:{}},d=new Map;{let m=0;for(let b of i)for(let I of b)d.set(I,m++)}function v(...m){return m.map(b=>M(d.get(b))).sort((b,I)=>b-I).join(" => ")}function g(m){for(let[b,I]of m.slice(0,m.length-1).entries())for(let w of m.slice(b+1)){let y=v(I,w);c.ints[y]=1,c.constraints[y]={max:1},c.variables[y]={opt:-u,[y]:1}}for(let[b,I]of m.slice(0,m.length-1).entries())for(let[w,y]of m.slice(b+1).entries())for(let S of m.slice(b+w+2)){let E=v(I,y),B=v(I,S),C=v(y,S),j=v(I,y,S),z=j+"+";c.constraints[z]={max:1},c.variables[E][z]=1,c.variables[B][z]=-1,c.variables[C][z]=1;let V=j+"-";c.constraints[V]={min:0},c.variables[E][V]=1,c.variables[B][V]=-1,c.variables[C][V]=1}}function h(m){for(let[b,I]of m.slice(0,m.length-1).entries())for(let w of m.slice(b+1)){let y=v(I,w);for(let S of I.ichildren())for(let E of w.ichildren()){if(S===E)continue;let B=v(S,E),C=`slack (${y}) (${B})`,j=`${C} +`,z=`${C} -`;c.variables[C]={opt:1,[j]:1,[z]:1};let V=Math.sign(M(d.get(S))-M(d.get(E))),q=Math.max(V,0);c.constraints[j]={min:q},c.variables[y][j]=1,c.variables[B][j]=V,c.constraints[z]={min:-q},c.variables[y][z]=-1,c.variables[B][z]=-V}}}function O(m,b){for(let I of m)for(let w of b)for(let[y,S]of w.entries())for(let E of w.slice(y+1)){let C=`dist ${[S,I,E].map(q=>M(d.get(q))).join(" => ")}`,j=`${C} normal`,z=`${C} reversed`;c.variables[C]={opt:l,[j]:1,[z]:1};let V=0;for(let[q,A]of[[S,I],[S,E],[I,E]]){let N=v(q,A),U=Math.sign(M(d.get(q))-M(d.get(A)));V+=+(U>0),c.variables[N][j]=-U,c.variables[N][z]=U}c.constraints[j]={min:1-V},c.constraints[z]={min:V-2}}}for(let m of i)g(m);for(let m of i.slice(0,i.length-1))h(m);if(t.dist)for(let[m,b]of a)O(m,b);let x=sn.Solve.call({},c);for(let m of i)m.sort((b,I)=>x[v(b,I)]||-1)}function r(i){return i===void 0?t.large:xe(Object.assign(Object.assign({},t),{large:i}))}e.large=r;function n(i){return i===void 0?t.dist:xe(Object.assign(Object.assign({},t),{dist:i}))}return e.dist=n,e}function on(...t){if(t.length)throw new Error(`got arguments to opt(${t}), but constructor takes no aruguments.`);return xe({large:"small",dist:!1})}var ln=it(fn());function un(t){function e(n){let i=t.width||Math.floor(Math.sqrt(n.size()+.5)),s=new Map(T(n.idescendants(),d=>[d,{before:[],parents:[]}]));for(let d of n)for(let v of d.ichildren())M(s.get(v)).parents.push(d);function o(d,v){let g=M(s.get(d)).before,h=M(s.get(v)).before;for(let[O,x]of g.entries()){let m=h[O];if(m===void 0)return!1;if(x<m)return!0;if(m<x)return!1}return!0}let a=new ln.default(o);for(let d of n.iroots())a.add(d);let f=0,l=0,u=0,c;for(;c=a.poll();){u<i&&M(s.get(c)).parents.every(d=>M(d.value)<l)?(c.value=l,u++):(c.value=++l,u=1);for(let d of c.ichildren()){let{before:v,parents:g}=M(s.get(d));v.push(f),v.length===g.length&&(v.sort((h,O)=>O-h),a.add(d))}f++}}function r(n){if(n===void 0)return t.width;if(n<0)throw new Error(`width must be non-negative: ${n}`);return un(Object.assign(Object.assign({},t),{width:n}))}return e.width=r,e}function cn(...t){if(t.length)throw new Error(`got arguments to coffmanGraham(${t}), but constructor takes no aruguments.`);return un({width:0})}function hn(t){function e(n){if(t.topDown)n.depth();else{n.height();let i=Math.max(...T(n.iroots(),s=>M(s.value)));for(let s of n)s.value=i-M(s.value)}}function r(n){return n===void 0?t.topDown:hn(Object.assign(Object.assign({},t),{topDown:n}))}return e.topDown=r,e}function dn(...t){if(t.length)throw new Error(`got arguments to longestPath(${t}), but constructor takes no aruguments.`);return hn({topDown:!0})}function pn(...t){if(t.length)throw new Error(`got arguments to topological(${t}), but constructor takes no aruguments.`);function e(r){for(let[n,i]of Z(r.idescendants("before")))i.value=n}return e}var vn=it(pt());function be(t){function e(i,s,o){let a=o?s:i,f=a.length*Math.max(a.length-1,0)/2,l=i.reduce((w,y)=>w+Y(y.ichildren()),0);if(t.large!=="large"&&f>1200)throw new Error('size of dag to twolayerOpt is too large and will likely crash, enable "large" dags to run anyway');if(t.large!=="large"&&t.large!=="medium"&&(f>400||l>100))throw new Error('size of dag to twolayerOpt is too large and will likely not finish, enable "medium" dags to run anyway');let u={optimize:"opt",opType:"min",constraints:{},variables:{},ints:{}},c=new Map(a.map((w,y)=>[w,y]));function d(...w){return w.map(y=>M(c.get(y))).sort((y,S)=>y-S).join(" => ")}let v,g;if(o){let w=new Set(i.flatMap(y=>y.children()));v=s.filter(y=>!w.has(y)),g=i.map(y=>y.children()).filter(y=>y.length>1)}else{v=i.filter(y=>!Y(y.ichildren()));let w=new Map;for(let y of i)for(let S of y.ichildren()){let E=w.get(S);E?E.push(y):w.set(S,[y])}g=[...w.values()]}let O=g.reduce((w,y)=>w+y.length*y.length,0)*v.length/4,x=1/(O+1),m=x/(f+1),b=new Map(s.map((w,y)=>[w,y]));for(let[w,y]of a.slice(0,a.length-1).entries())for(let S of a.slice(w+1)){let E=d(y,S);u.ints[E]=1,u.constraints[E]={max:1},u.variables[E]={opt:-m,[E]:1}}for(let[w,y]of a.slice(0,a.length-1).entries())for(let[S,E]of a.slice(w+1).entries())for(let B of a.slice(w+S+2)){let C=d(y,E),j=d(y,B),z=d(E,B),V=d(y,E,B),q=V+"+";u.constraints[q]={max:1},u.variables[C][q]=1,u.variables[j][q]=-1,u.variables[z][q]=1;let A=V+"-";u.constraints[A]={min:0},u.variables[C][A]=1,u.variables[j][A]=-1,u.variables[z][A]=1}for(let[w,y]of i.slice(0,i.length-1).entries())for(let S of i.slice(w+1))for(let E of y.ichildren())for(let B of S.ichildren()){if(E===B)continue;let C=o?d(E,B):d(y,S);u.variables[C].opt+=Math.sign(M(b.get(E))-M(b.get(B)))}if(t.dist)for(let w of v)for(let y of g)for(let[S,E]of y.entries())for(let B of y.slice(S+1)){let j=`dist ${[E,w,B].map(A=>M(c.get(A))).join(" => ")}`,z=`${j} normal`,V=`${j} reversed`;u.variables[j]={opt:x,[z]:1,[V]:1};let q=0;for(let[A,N]of[[E,w],[E,B],[w,B]]){let U=d(A,N),L=Math.sign(M(c.get(A))-M(c.get(N)));q+=+(L>0),u.variables[U][z]=-L,u.variables[U][V]=L}u.constraints[z]={min:1-q},u.constraints[V]={min:q-2}}let I=vn.Solve.call({},u);a.sort((w,y)=>I[d(w,y)]||-1)}function r(i){return i===void 0?t.large:be(Object.assign(Object.assign({},t),{large:i}))}e.large=r;function n(i){return i===void 0?t.dist:be(Object.assign(Object.assign({},t),{dist:i}))}return e.dist=n,e}function gn(...t){if(t.length)throw new Error(`got arguments to opt(${t}), but constructor takes no aruguments.`);return be({large:"small",dist:!1})}function mn(t,e){let r=t.findIndex(n=>n<=e);return r>=0?r:t.length}function xn(t){let e=new Map(t.map((o,a)=>[o,a])),r=[];for(let[o,a]of t.entries())for(let f of a.ichildren()){let l=M(e.get(f));l>o+1&&r.push([a,o,f,l])}r.sort(([,o,,a],[,f,,l])=>a===l?f-o:a-l);let n=new Map,i=[],s=[];for(let[o,a,f,l]of r){let u=n.get(o);u===void 0&&(u=new Map,n.set(o,u));let c=mn(s,a),d=mn(i,a);c<d?(u.set(f,-c-1),s[c]=l-1):(u.set(f,d+1),i[d]=l-1)}return n}function ye(t,e,r,n){function i(a){var f,l;let u=[...a.idescendants("before")],c=xn(u),d=0,v=0;for(let{source:x,target:m}of a.ilinks()){let b=(f=c.get(x))===null||f===void 0?void 0:f.get(m);b!==void 0&&(d=Math.min(d,b),v=Math.max(v,b))}let g=-d*r+t/2;for(let[x,m]of u.entries())m.x=g,m.y=(x+.5)*e;for(let{source:x,target:m,points:b}of a.ilinks()){b.length=0,$(x.x!==void 0&&x.y!==void 0),$(m.x!==void 0&&m.y!==void 0),b.push({x:x.x,y:x.y});let I=(l=c.get(x))===null||l===void 0?void 0:l.get(m);if(I!==void 0){let w=(I-d+.5)*r+(I>0?t-r:0),y=x.y+e,S=m.y-e;S-y>e/2?b.push({x:w,y},{x:w,y:S}):b.push({x:w,y})}b.push({x:m.x,y:m.y})}let h=(v-d)*r+t,O=u.length*e;if(n===null)return{width:h,height:O};{let[x,m]=n;for(let b of u)$(b.x!==void 0&&b.y!==void 0),b.x*=x/h,b.y*=m/O;for(let{points:b}of a.ilinks()){let I=b.map(({x:w,y})=>({x:M(w)*x/h,y:M(y)*m/O}));b.splice(0,b.length,...I)}return{width:x,height:m}}}function s(a){if(a===void 0)return[t,e,r];{let[f,l,u]=a;return ye(f,l,u,n)}}i.nodeSize=s;function o(a){if(a!==void 0)return ye(t,e,r,a);if(n===null)return n;{let[f,l]=n;return[f,l]}}return i.size=o,i}function bn(...t){if(t.length)throw new Error(`got arguments to zherebko(${t}), but constructor takes no aruguments.`);return ye(1,1,1,null)}return jn(Bi);})();
return d3; })())