| 1 |
- import{G as y}from"./graph-Sdp66Lnm.js";import{g as f,f as P,v as x,r as j}from"./reduce-CD1dTGRv.js";import{s as E,u as q,q as L,p as g,n as ie,r as $,j as W,z as ke,t as R,o as M,l as xe,m as Ee,i as Oe}from"./zipObject-55ZJCf5z.js";import{d4 as _,eY as w,cd as Ne,eF as m,eg as Le,fA as C,eM as T,c1 as Ie,f4 as D}from"./admin-ZywPplgI.js";class Pe{constructor(){var n={};n._next=n._prev=n,this._sentinel=n}dequeue(){var n=this._sentinel,r=n._prev;if(r!==n)return J(r),r}enqueue(n){var r=this._sentinel;n._prev&&n._next&&J(n),n._next=r._next,r._next._prev=n,r._next=n,n._prev=r}toString(){for(var n=[],r=this._sentinel,t=r._prev;t!==r;)n.push(JSON.stringify(t,Re)),t=t._prev;return"["+n.join(", ")+"]"}}function J(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Re(e,n){if(e!=="_next"&&e!=="_prev")return n}var _e=Ne(1);function Ce(e,n){if(e.nodeCount()<=1)return[];var r=je(e,n||_e),t=Te(r.graph,r.buckets,r.zeroIdx);return _(w(t,function(a){return e.outEdges(a.v,a.w)}))}function Te(e,n,r){for(var t=[],a=n[n.length-1],i=n[0],o;e.nodeCount();){for(;o=i.dequeue();)F(e,n,r,o);for(;o=a.dequeue();)F(e,n,r,o);if(e.nodeCount()){for(var d=n.length-2;d>0;--d)if(o=n[d].dequeue(),o){t=t.concat(F(e,n,r,o,!0));break}}}return t}function F(e,n,r,t,a){var i=a?[]:void 0;return f(e.inEdges(t.v),function(o){var d=e.edge(o),u=e.node(o.v);a&&i.push({v:o.v,w:o.w}),u.out-=d,G(n,r,u)}),f(e.outEdges(t.v),function(o){var d=e.edge(o),u=o.w,s=e.node(u);s.in-=d,G(n,r,s)}),e.removeNode(t.v),i}function je(e,n){var r=new y,t=0,a=0;f(e.nodes(),function(d){r.setNode(d,{v:d,in:0,out:0})}),f(e.edges(),function(d){var u=r.edge(d.v,d.w)||0,s=n(d),c=u+s;r.setEdge(d.v,d.w,c),a=Math.max(a,r.node(d.v).out+=s),t=Math.max(t,r.node(d.w).in+=s)});var i=E(a+t+3).map(function(){return new Pe}),o=t+1;return f(r.nodes(),function(d){G(i,o,r.node(d))}),{graph:r,buckets:i,zeroIdx:o}}function G(e,n,r){r.out?r.in?e[r.out-r.in+n].enqueue(r):e[e.length-1].enqueue(r):e[0].enqueue(r)}function Me(e){var n=e.graph().acyclicer==="greedy"?Ce(e,r(e)):Se(e);f(n,function(t){var a=e.edge(t);e.removeEdge(t),a.forwardName=t.name,a.reversed=!0,e.setEdge(t.w,t.v,a,q("rev"))});function r(t){return function(a){return t.edge(a).weight}}}function Se(e){var n=[],r={},t={};function a(i){Object.prototype.hasOwnProperty.call(t,i)||(t[i]=!0,r[i]=!0,f(e.outEdges(i),function(o){Object.prototype.hasOwnProperty.call(r,o.w)?n.push(o):a(o.w)}),delete r[i])}return f(e.nodes(),a),n}function Fe(e){f(e.edges(),function(n){var r=e.edge(n);if(r.reversed){e.removeEdge(n);var t=r.forwardName;delete r.reversed,delete r.forwardName,e.setEdge(n.w,n.v,r,t)}})}function O(e,n,r,t){var a;do a=q(t);while(e.hasNode(a));return r.dummy=n,e.setNode(a,r),a}function Ve(e){var n=new y().setGraph(e.graph());return f(e.nodes(),function(r){n.setNode(r,e.node(r))}),f(e.edges(),function(r){var t=n.edge(r.v,r.w)||{weight:0,minlen:1},a=e.edge(r);n.setEdge(r.v,r.w,{weight:t.weight+a.weight,minlen:Math.max(t.minlen,a.minlen)})}),n}function de(e){var n=new y({multigraph:e.isMultigraph()}).setGraph(e.graph());return f(e.nodes(),function(r){e.children(r).length||n.setNode(r,e.node(r))}),f(e.edges(),function(r){n.setEdge(r,e.edge(r))}),n}function K(e,n){var r=e.x,t=e.y,a=n.x-r,i=n.y-t,o=e.width/2,d=e.height/2;if(!a&&!i)throw new Error("Not possible to find intersection inside of the rectangle");var u,s;return Math.abs(i)*o>Math.abs(a)*d?(i<0&&(d=-d),u=d*a/i,s=d):(a<0&&(o=-o),u=o,s=o*i/a),{x:r+u,y:t+s}}function S(e){var n=w(E(ue(e)+1),function(){return[]});return f(e.nodes(),function(r){var t=e.node(r),a=t.rank;m(a)||(n[a][t.order]=r)}),n}function Ae(e){var n=L(w(e.nodes(),function(r){return e.node(r).rank}));f(e.nodes(),function(r){var t=e.node(r);ie(t,"rank")&&(t.rank-=n)})}function Be(e){var n=L(w(e.nodes(),function(i){return e.node(i).rank})),r=[];f(e.nodes(),function(i){var o=e.node(i).rank-n;r[o]||(r[o]=[]),r[o].push(i)});var t=0,a=e.graph().nodeRankFactor;f(r,function(i,o){m(i)&&o%a!==0?--t:t&&f(i,function(d){e.node(d).rank+=t})})}function Q(e,n,r,t){var a={width:0,height:0};return arguments.length>=4&&(a.rank=r,a.order=t),O(e,"border",a,n)}function ue(e){return g(w(e.nodes(),function(n){var r=e.node(n).rank;if(!m(r))return r}))}function Ye(e,n){var r={lhs:[],rhs:[]};return f(e,function(t){n(t)?r.lhs.push(t):r.rhs.push(t)}),r}function De(e,n){return n()}function Ge(e){function n(r){var t=e.children(r),a=e.node(r);if(t.length&&f(t,n),Object.prototype.hasOwnProperty.call(a,"minRank")){a.borderLeft=[],a.borderRight=[];for(var i=a.minRank,o=a.maxRank+1;i<o;++i)Z(e,"borderLeft","_bl",r,a,i),Z(e,"borderRight","_br",r,a,i)}}f(e.children(),n)}function Z(e,n,r,t,a,i){var o={width:0,height:0,rank:i,borderType:n},d=a[n][i-1],u=O(e,"border",o,r);a[n][i]=u,e.setParent(u,t),d&&e.setEdge(d,u,{weight:1})}function qe(e){var n=e.graph().rankdir.toLowerCase();(n==="lr"||n==="rl")&&se(e)}function $e(e){var n=e.graph().rankdir.toLowerCase();(n==="bt"||n==="rl")&&We(e),(n==="lr"||n==="rl")&&(ze(e),se(e))}function se(e){f(e.nodes(),function(n){ee(e.node(n))}),f(e.edges(),function(n){ee(e.edge(n))})}function ee(e){var n=e.width;e.width=e.height,e.height=n}function We(e){f(e.nodes(),function(n){V(e.node(n))}),f(e.edges(),function(n){var r=e.edge(n);f(r.points,V),Object.prototype.hasOwnProperty.call(r,"y")&&V(r)})}function V(e){e.y=-e.y}function ze(e){f(e.nodes(),function(n){A(e.node(n))}),f(e.edges(),function(n){var r=e.edge(n);f(r.points,A),Object.prototype.hasOwnProperty.call(r,"x")&&A(r)})}function A(e){var n=e.x;e.x=e.y,e.y=n}function Xe(e){e.graph().dummyChains=[],f(e.edges(),function(n){Ue(e,n)})}function Ue(e,n){var r=n.v,t=e.node(r).rank,a=n.w,i=e.node(a).rank,o=n.name,d=e.edge(n),u=d.labelRank;if(i!==t+1){e.removeEdge(n);var s=void 0,c,l;for(l=0,++t;t<i;++l,++t)d.points=[],s={width:0,height:0,edgeLabel:d,edgeObj:n,rank:t},c=O(e,"edge",s,"_d"),t===u&&(s.width=d.width,s.height=d.height,s.dummy="edge-label",s.labelpos=d.labelpos),e.setEdge(r,c,{weight:d.weight},o),l===0&&e.graph().dummyChains.push(c),r=c;e.setEdge(r,a,{weight:d.weight},o)}}function He(e){f(e.graph().dummyChains,function(n){var r=e.node(n),t=r.edgeLabel,a;for(e.setEdge(r.edgeObj,t);r.dummy;)a=e.successors(n)[0],e.removeNode(n),t.points.push({x:r.x,y:r.y}),r.dummy==="edge-label"&&(t.x=r.x,t.y=r.y,t.width=r.width,t.height=r.height),n=a,r=e.node(n)})}function z(e){var n={};function r(t){var a=e.node(t);if(Object.prototype.hasOwnProperty.call(n,t))return a.rank;n[t]=!0;var i=L(w(e.outEdges(t),function(o){return r(o.w)-e.edge(o).minlen}));return(i===Number.POSITIVE_INFINITY||i===void 0||i===null)&&(i=0),a.rank=i}f(e.sources(),r)}function I(e,n){return e.node(n.w).rank-e.node(n.v).rank-e.edge(n).minlen}function fe(e){var n=new y({directed:!1}),r=e.nodes()[0],t=e.nodeCount();n.setNode(r,{});for(var a,i;Je(n,e)<t;)a=Ke(n,e),i=n.hasNode(a.v)?I(e,a):-I(e,a),Qe(n,e,i);return n}function Je(e,n){function r(t){f(n.nodeEdges(t),function(a){var i=a.v,o=t===i?a.w:i;!e.hasNode(o)&&!I(n,a)&&(e.setNode(o,{}),e.setEdge(t,o,{}),r(o))})}return f(e.nodes(),r),e.nodeCount()}function Ke(e,n){return $(n.edges(),function(r){if(e.hasNode(r.v)!==e.hasNode(r.w))return I(n,r)})}function Qe(e,n,r){f(e.nodes(),function(t){n.node(t).rank+=r})}function Ze(){}Ze.prototype=new Error;function ce(e,n,r){Le(n)||(n=[n]);var t=(e.isDirected()?e.successors:e.neighbors).bind(e),a=[],i={};return f(n,function(o){if(!e.hasNode(o))throw new Error("Graph does not have node: "+o);le(e,o,r==="post",i,t,a)}),a}function le(e,n,r,t,a,i){Object.prototype.hasOwnProperty.call(t,n)||(t[n]=!0,r||i.push(n),f(a(n),function(o){le(e,o,r,t,a,i)}),r&&i.push(n))}function en(e,n){return ce(e,n,"post")}function nn(e,n){return ce(e,n,"pre")}k.initLowLimValues=U;k.initCutValues=X;k.calcCutValue=he;k.leaveEdge=pe;k.enterEdge=we;k.exchangeEdges=be;function k(e){e=Ve(e),z(e);var n=fe(e);U(n),X(n,e);for(var r,t;r=pe(n);)t=we(n,e,r),be(n,e,r,t)}function X(e,n){var r=en(e,e.nodes());r=r.slice(0,r.length-1),f(r,function(t){rn(e,n,t)})}function rn(e,n,r){var t=e.node(r),a=t.parent;e.edge(r,a).cutvalue=he(e,n,r)}function he(e,n,r){var t=e.node(r),a=t.parent,i=!0,o=n.edge(r,a),d=0;return o||(i=!1,o=n.edge(a,r)),d=o.weight,f(n.nodeEdges(r),function(u){var s=u.v===r,c=s?u.w:u.v;if(c!==a){var l=s===i,h=n.edge(u).weight;if(d+=l?h:-h,an(e,r,c)){var v=e.edge(r,c).cutvalue;d+=l?-v:v}}}),d}function U(e,n){arguments.length<2&&(n=e.nodes()[0]),ve(e,{},1,n)}function ve(e,n,r,t,a){var i=r,o=e.node(t);return n[t]=!0,f(e.neighbors(t),function(d){Object.prototype.hasOwnProperty.call(n,d)||(r=ve(e,n,r,d,t))}),o.low=i,o.lim=r++,a?o.parent=a:delete o.parent,r}function pe(e){return W(e.edges(),function(n){return e.edge(n).cutvalue<0})}function we(e,n,r){var t=r.v,a=r.w;n.hasEdge(t,a)||(t=r.w,a=r.v);var i=e.node(t),o=e.node(a),d=i,u=!1;i.lim>o.lim&&(d=o,u=!0);var s=P(n.edges(),function(c){return u===ne(e,e.node(c.v),d)&&u!==ne(e,e.node(c.w),d)});return $(s,function(c){return I(n,c)})}function be(e,n,r,t){var a=r.v,i=r.w;e.removeEdge(a,i),e.setEdge(t.v,t.w,{}),U(e),X(e,n),tn(e,n)}function tn(e,n){var r=W(e.nodes(),function(a){return!n.node(a).parent}),t=nn(e,r);t=t.slice(1),f(t,function(a){var i=e.node(a).parent,o=n.edge(a,i),d=!1;o||(o=n.edge(i,a),d=!0),n.node(a).rank=n.node(i).rank+(d?o.minlen:-o.minlen)})}function an(e,n,r){return e.hasEdge(n,r)}function ne(e,n,r){return r.low<=n.lim&&n.lim<=r.lim}function on(e){switch(e.graph().ranker){case"network-simplex":re(e);break;case"tight-tree":un(e);break;case"longest-path":dn(e);break;default:re(e)}}var dn=z;function un(e){z(e),fe(e)}function re(e){k(e)}function sn(e){var n=O(e,"root",{},"_root"),r=fn(e),t=g(x(r))-1,a=2*t+1;e.graph().nestingRoot=n,f(e.edges(),function(o){e.edge(o).minlen*=a});var i=cn(e)+1;f(e.children(),function(o){me(e,n,a,i,t,r,o)}),e.graph().nodeRankFactor=a}function me(e,n,r,t,a,i,o){var d=e.children(o);if(!d.length){o!==n&&e.setEdge(n,o,{weight:0,minlen:r});return}var u=Q(e,"_bt"),s=Q(e,"_bb"),c=e.node(o);e.setParent(u,o),c.borderTop=u,e.setParent(s,o),c.borderBottom=s,f(d,function(l){me(e,n,r,t,a,i,l);var h=e.node(l),v=h.borderTop?h.borderTop:l,p=h.borderBottom?h.borderBottom:l,b=h.borderTop?t:2*t,N=v!==p?1:a-i[o]+1;e.setEdge(u,v,{weight:b,minlen:N,nestingEdge:!0}),e.setEdge(p,s,{weight:b,minlen:N,nestingEdge:!0})}),e.parent(o)||e.setEdge(n,u,{weight:0,minlen:a+i[o]})}function fn(e){var n={};function r(t,a){var i=e.children(t);i&&i.length&&f(i,function(o){r(o,a+1)}),n[t]=a}return f(e.children(),function(t){r(t,1)}),n}function cn(e){return j(e.edges(),function(n,r){return n+e.edge(r).weight},0)}function ln(e){var n=e.graph();e.removeNode(n.nestingRoot),delete n.nestingRoot,f(e.edges(),function(r){var t=e.edge(r);t.nestingEdge&&e.removeEdge(r)})}function hn(e,n,r){var t={},a;f(r,function(i){for(var o=e.parent(i),d,u;o;){if(d=e.parent(o),d?(u=t[d],t[d]=o):(u=a,a=o),u&&u!==o){n.setEdge(u,o);return}o=d}})}function vn(e,n,r){var t=pn(e),a=new y({compound:!0}).setGraph({root:t}).setDefaultNodeLabel(function(i){return e.node(i)});return f(e.nodes(),function(i){var o=e.node(i),d=e.parent(i);(o.rank===n||o.minRank<=n&&n<=o.maxRank)&&(a.setNode(i),a.setParent(i,d||t),f(e[r](i),function(u){var s=u.v===i?u.w:u.v,c=a.edge(s,i),l=m(c)?0:c.weight;a.setEdge(s,i,{weight:e.edge(u).weight+l})}),Object.prototype.hasOwnProperty.call(o,"minRank")&&a.setNode(i,{borderLeft:o.borderLeft[n],borderRight:o.borderRight[n]}))}),a}function pn(e){for(var n;e.hasNode(n=q("_root")););return n}function wn(e,n){for(var r=0,t=1;t<n.length;++t)r+=bn(e,n[t-1],n[t]);return r}function bn(e,n,r){for(var t=ke(r,w(r,function(s,c){return c})),a=_(w(n,function(s){return R(w(e.outEdges(s),function(c){return{pos:t[c.w],weight:e.edge(c).weight}}),"pos")})),i=1;i<r.length;)i<<=1;var o=2*i-1;i-=1;var d=w(new Array(o),function(){return 0}),u=0;return f(a.forEach(function(s){var c=s.pos+i;d[c]+=s.weight;for(var l=0;c>0;)c%2&&(l+=d[c+1]),c=c-1>>1,d[c]+=s.weight;u+=s.weight*l})),u}function mn(e){var n={},r=P(e.nodes(),function(d){return!e.children(d).length}),t=g(w(r,function(d){return e.node(d).rank})),a=w(E(t+1),function(){return[]});function i(d){if(!ie(n,d)){n[d]=!0;var u=e.node(d);a[u.rank].push(d),f(e.successors(d),i)}}var o=R(r,function(d){return e.node(d).rank});return f(o,i),a}function yn(e,n){return w(n,function(r){var t=e.inEdges(r);if(t.length){var a=j(t,function(i,o){var d=e.edge(o),u=e.node(o.v);return{sum:i.sum+d.weight*u.order,weight:i.weight+d.weight}},{sum:0,weight:0});return{v:r,barycenter:a.sum/a.weight,weight:a.weight}}else return{v:r}})}function gn(e,n){var r={};f(e,function(a,i){var o=r[a.v]={indegree:0,in:[],out:[],vs:[a.v],i};m(a.barycenter)||(o.barycenter=a.barycenter,o.weight=a.weight)}),f(n.edges(),function(a){var i=r[a.v],o=r[a.w];!m(i)&&!m(o)&&(o.indegree++,i.out.push(r[a.w]))});var t=P(r,function(a){return!a.indegree});return kn(t)}function kn(e){var n=[];function r(i){return function(o){o.merged||(m(o.barycenter)||m(i.barycenter)||o.barycenter>=i.barycenter)&&xn(i,o)}}function t(i){return function(o){o.in.push(i),--o.indegree===0&&e.push(o)}}for(;e.length;){var a=e.pop();n.push(a),f(a.in.reverse(),r(a)),f(a.out,t(a))}return w(P(n,function(i){return!i.merged}),function(i){return C(i,["vs","i","barycenter","weight"])})}function xn(e,n){var r=0,t=0;e.weight&&(r+=e.barycenter*e.weight,t+=e.weight),n.weight&&(r+=n.barycenter*n.weight,t+=n.weight),e.vs=n.vs.concat(e.vs),e.barycenter=r/t,e.weight=t,e.i=Math.min(n.i,e.i),n.merged=!0}function En(e,n){var r=Ye(e,function(c){return Object.prototype.hasOwnProperty.call(c,"barycenter")}),t=r.lhs,a=R(r.rhs,function(c){return-c.i}),i=[],o=0,d=0,u=0;t.sort(On(!!n)),u=te(i,a,u),f(t,function(c){u+=c.vs.length,i.push(c.vs),o+=c.barycenter*c.weight,d+=c.weight,u=te(i,a,u)});var s={vs:_(i)};return d&&(s.barycenter=o/d,s.weight=d),s}function te(e,n,r){for(var t;n.length&&(t=T(n)).i<=r;)n.pop(),e.push(t.vs),r++;return r}function On(e){return function(n,r){return n.barycenter<r.barycenter?-1:n.barycenter>r.barycenter?1:e?r.i-n.i:n.i-r.i}}function ye(e,n,r,t){var a=e.children(n),i=e.node(n),o=i?i.borderLeft:void 0,d=i?i.borderRight:void 0,u={};o&&(a=P(a,function(p){return p!==o&&p!==d}));var s=yn(e,a);f(s,function(p){if(e.children(p.v).length){var b=ye(e,p.v,r,t);u[p.v]=b,Object.prototype.hasOwnProperty.call(b,"barycenter")&&Ln(p,b)}});var c=gn(s,r);Nn(c,u);var l=En(c,t);if(o&&(l.vs=_([o,l.vs,d]),e.predecessors(o).length)){var h=e.node(e.predecessors(o)[0]),v=e.node(e.predecessors(d)[0]);Object.prototype.hasOwnProperty.call(l,"barycenter")||(l.barycenter=0,l.weight=0),l.barycenter=(l.barycenter*l.weight+h.order+v.order)/(l.weight+2),l.weight+=2}return l}function Nn(e,n){f(e,function(r){r.vs=_(r.vs.map(function(t){return n[t]?n[t].vs:t}))})}function Ln(e,n){m(e.barycenter)?(e.barycenter=n.barycenter,e.weight=n.weight):(e.barycenter=(e.barycenter*e.weight+n.barycenter*n.weight)/(e.weight+n.weight),e.weight+=n.weight)}function In(e){var n=ue(e),r=ae(e,E(1,n+1),"inEdges"),t=ae(e,E(n-1,-1,-1),"outEdges"),a=mn(e);oe(e,a);for(var i=Number.POSITIVE_INFINITY,o,d=0,u=0;u<4;++d,++u){Pn(d%2?r:t,d%4>=2),a=S(e);var s=wn(e,a);s<i&&(u=0,o=Ie(a),i=s)}oe(e,o)}function ae(e,n,r){return w(n,function(t){return vn(e,t,r)})}function Pn(e,n){var r=new y;f(e,function(t){var a=t.graph().root,i=ye(t,a,r,n);f(i.vs,function(o,d){t.node(o).order=d}),hn(t,r,i.vs)})}function oe(e,n){f(n,function(r){f(r,function(t,a){e.node(t).order=a})})}function Rn(e){var n=Cn(e);f(e.graph().dummyChains,function(r){for(var t=e.node(r),a=t.edgeObj,i=_n(e,n,a.v,a.w),o=i.path,d=i.lca,u=0,s=o[u],c=!0;r!==a.w;){if(t=e.node(r),c){for(;(s=o[u])!==d&&e.node(s).maxRank<t.rank;)u++;s===d&&(c=!1)}if(!c){for(;u<o.length-1&&e.node(s=o[u+1]).minRank<=t.rank;)u++;s=o[u]}e.setParent(r,s),r=e.successors(r)[0]}})}function _n(e,n,r,t){var a=[],i=[],o=Math.min(n[r].low,n[t].low),d=Math.max(n[r].lim,n[t].lim),u,s;u=r;do u=e.parent(u),a.push(u);while(u&&(n[u].low>o||d>n[u].lim));for(s=u,u=t;(u=e.parent(u))!==s;)i.push(u);return{path:a.concat(i.reverse()),lca:s}}function Cn(e){var n={},r=0;function t(a){var i=r;f(e.children(a),t),n[a]={low:i,lim:r++}}return f(e.children(),t),n}function Tn(e,n){var r={};function t(a,i){var o=0,d=0,u=a.length,s=T(i);return f(i,function(c,l){var h=Mn(e,c),v=h?e.node(h).order:u;(h||c===s)&&(f(i.slice(d,l+1),function(p){f(e.predecessors(p),function(b){var N=e.node(b),H=N.order;(H<o||v<H)&&!(N.dummy&&e.node(p).dummy)&&ge(r,b,p)})}),d=l+1,o=v)}),i}return j(n,t),r}function jn(e,n){var r={};function t(i,o,d,u,s){var c;f(E(o,d),function(l){c=i[l],e.node(c).dummy&&f(e.predecessors(c),function(h){var v=e.node(h);v.dummy&&(v.order<u||v.order>s)&&ge(r,h,c)})})}function a(i,o){var d=-1,u,s=0;return f(o,function(c,l){if(e.node(c).dummy==="border"){var h=e.predecessors(c);h.length&&(u=e.node(h[0]).order,t(o,s,l,d,u),s=l,d=u)}t(o,s,o.length,u,i.length)}),o}return j(n,a),r}function Mn(e,n){if(e.node(n).dummy)return W(e.predecessors(n),function(r){return e.node(r).dummy})}function ge(e,n,r){if(n>r){var t=n;n=r,r=t}Object.prototype.hasOwnProperty.call(e,n)||Object.defineProperty(e,n,{enumerable:!0,configurable:!0,value:{},writable:!0});var a=e[n];Object.defineProperty(a,r,{enumerable:!0,configurable:!0,value:!0,writable:!0})}function Sn(e,n,r){if(n>r){var t=n;n=r,r=t}return!!e[n]&&Object.prototype.hasOwnProperty.call(e[n],r)}function Fn(e,n,r,t){var a={},i={},o={};return f(n,function(d){f(d,function(u,s){a[u]=u,i[u]=u,o[u]=s})}),f(n,function(d){var u=-1;f(d,function(s){var c=t(s);if(c.length){c=R(c,function(b){return o[b]});for(var l=(c.length-1)/2,h=Math.floor(l),v=Math.ceil(l);h<=v;++h){var p=c[h];i[s]===s&&u<o[p]&&!Sn(r,s,p)&&(i[p]=s,i[s]=a[s]=a[p],u=o[p])}}})}),{root:a,align:i}}function Vn(e,n,r,t,a){var i={},o=An(e,n,r,a),d=a?"borderLeft":"borderRight";function u(l,h){for(var v=o.nodes(),p=v.pop(),b={};p;)b[p]?l(p):(b[p]=!0,v.push(p),v=v.concat(h(p))),p=v.pop()}function s(l){i[l]=o.inEdges(l).reduce(function(h,v){return Math.max(h,i[v.v]+o.edge(v))},0)}function c(l){var h=o.outEdges(l).reduce(function(p,b){return Math.min(p,i[b.w]-o.edge(b))},Number.POSITIVE_INFINITY),v=e.node(l);h!==Number.POSITIVE_INFINITY&&v.borderType!==d&&(i[l]=Math.max(i[l],h))}return u(s,o.predecessors.bind(o)),u(c,o.successors.bind(o)),f(t,function(l){i[l]=i[r[l]]}),i}function An(e,n,r,t){var a=new y,i=e.graph(),o=qn(i.nodesep,i.edgesep,t);return f(n,function(d){var u;f(d,function(s){var c=r[s];if(a.setNode(c),u){var l=r[u],h=a.edge(l,c);a.setEdge(l,c,Math.max(o(e,s,u),h||0))}u=s})}),a}function Bn(e,n){return $(x(n),function(r){var t=Number.NEGATIVE_INFINITY,a=Number.POSITIVE_INFINITY;return xe(r,function(i,o){var d=$n(e,o)/2;t=Math.max(i+d,t),a=Math.min(i-d,a)}),t-a})}function Yn(e,n){var r=x(n),t=L(r),a=g(r);f(["u","d"],function(i){f(["l","r"],function(o){var d=i+o,u=e[d],s;if(u!==n){var c=x(u);s=o==="l"?t-L(c):a-g(c),s&&(e[d]=M(u,function(l){return l+s}))}})})}function Dn(e,n){return M(e.ul,function(r,t){if(n)return e[n.toLowerCase()][t];var a=R(w(e,t));return(a[1]+a[2])/2})}function Gn(e){var n=S(e),r=D(Tn(e,n),jn(e,n)),t={},a;f(["u","d"],function(o){a=o==="u"?n:x(n).reverse(),f(["l","r"],function(d){d==="r"&&(a=w(a,function(l){return x(l).reverse()}));var u=(o==="u"?e.predecessors:e.successors).bind(e),s=Fn(e,a,r,u),c=Vn(e,a,s.root,s.align,d==="r");d==="r"&&(c=M(c,function(l){return-l})),t[o+d]=c})});var i=Bn(e,t);return Yn(t,i),Dn(t,e.graph().align)}function qn(e,n,r){return function(t,a,i){var o=t.node(a),d=t.node(i),u=0,s;if(u+=o.width/2,Object.prototype.hasOwnProperty.call(o,"labelpos"))switch(o.labelpos.toLowerCase()){case"l":s=-o.width/2;break;case"r":s=o.width/2;break}if(s&&(u+=r?s:-s),s=0,u+=(o.dummy?n:e)/2,u+=(d.dummy?n:e)/2,u+=d.width/2,Object.prototype.hasOwnProperty.call(d,"labelpos"))switch(d.labelpos.toLowerCase()){case"l":s=d.width/2;break;case"r":s=-d.width/2;break}return s&&(u+=r?s:-s),s=0,u}}function $n(e,n){return e.node(n).width}function Wn(e){e=de(e),zn(e),Ee(Gn(e),function(n,r){e.node(r).x=n})}function zn(e){var n=S(e),r=e.graph().ranksep,t=0;f(n,function(a){var i=g(w(a,function(o){return e.node(o).height}));f(a,function(o){e.node(o).y=t+i/2}),t+=i+r})}function gr(e,n){var r=De;r("layout",()=>{var t=r(" buildLayoutGraph",()=>tr(e));r(" runLayout",()=>Xn(t,r)),r(" updateInputGraph",()=>Un(e,t))})}function Xn(e,n){n(" makeSpaceForEdgeLabels",()=>ar(e)),n(" removeSelfEdges",()=>hr(e)),n(" acyclic",()=>Me(e)),n(" nestingGraph.run",()=>sn(e)),n(" rank",()=>on(de(e))),n(" injectEdgeLabelProxies",()=>or(e)),n(" removeEmptyRanks",()=>Be(e)),n(" nestingGraph.cleanup",()=>ln(e)),n(" normalizeRanks",()=>Ae(e)),n(" assignRankMinMax",()=>ir(e)),n(" removeEdgeLabelProxies",()=>dr(e)),n(" normalize.run",()=>Xe(e)),n(" parentDummyChains",()=>Rn(e)),n(" addBorderSegments",()=>Ge(e)),n(" order",()=>In(e)),n(" insertSelfEdges",()=>vr(e)),n(" adjustCoordinateSystem",()=>qe(e)),n(" position",()=>Wn(e)),n(" positionSelfEdges",()=>pr(e)),n(" removeBorderNodes",()=>lr(e)),n(" normalize.undo",()=>He(e)),n(" fixupEdgeLabelCoords",()=>fr(e)),n(" undoCoordinateSystem",()=>$e(e)),n(" translateGraph",()=>ur(e)),n(" assignNodeIntersects",()=>sr(e)),n(" reversePoints",()=>cr(e)),n(" acyclic.undo",()=>Fe(e))}function Un(e,n){f(e.nodes(),function(r){var t=e.node(r),a=n.node(r);t&&(t.x=a.x,t.y=a.y,n.children(r).length&&(t.width=a.width,t.height=a.height))}),f(e.edges(),function(r){var t=e.edge(r),a=n.edge(r);t.points=a.points,Object.prototype.hasOwnProperty.call(a,"x")&&(t.x=a.x,t.y=a.y)}),e.graph().width=n.graph().width,e.graph().height=n.graph().height}var Hn=["nodesep","edgesep","ranksep","marginx","marginy"],Jn={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},Kn=["acyclicer","ranker","rankdir","align"],Qn=["width","height"],Zn={width:0,height:0},er=["minlen","weight","width","height","labeloffset"],nr={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},rr=["labelpos"];function tr(e){var n=new y({multigraph:!0,compound:!0}),r=Y(e.graph());return n.setGraph(D({},Jn,B(r,Hn),C(r,Kn))),f(e.nodes(),function(t){var a=Y(e.node(t));n.setNode(t,Oe(B(a,Qn),Zn)),n.setParent(t,e.parent(t))}),f(e.edges(),function(t){var a=Y(e.edge(t));n.setEdge(t,D({},nr,B(a,er),C(a,rr)))}),n}function ar(e){var n=e.graph();n.ranksep/=2,f(e.edges(),function(r){var t=e.edge(r);t.minlen*=2,t.labelpos.toLowerCase()!=="c"&&(n.rankdir==="TB"||n.rankdir==="BT"?t.width+=t.labeloffset:t.height+=t.labeloffset)})}function or(e){f(e.edges(),function(n){var r=e.edge(n);if(r.width&&r.height){var t=e.node(n.v),a=e.node(n.w),i={rank:(a.rank-t.rank)/2+t.rank,e:n};O(e,"edge-proxy",i,"_ep")}})}function ir(e){var n=0;f(e.nodes(),function(r){var t=e.node(r);t.borderTop&&(t.minRank=e.node(t.borderTop).rank,t.maxRank=e.node(t.borderBottom).rank,n=g(n,t.maxRank))}),e.graph().maxRank=n}function dr(e){f(e.nodes(),function(n){var r=e.node(n);r.dummy==="edge-proxy"&&(e.edge(r.e).labelRank=r.rank,e.removeNode(n))})}function ur(e){var n=Number.POSITIVE_INFINITY,r=0,t=Number.POSITIVE_INFINITY,a=0,i=e.graph(),o=i.marginx||0,d=i.marginy||0;function u(s){var c=s.x,l=s.y,h=s.width,v=s.height;n=Math.min(n,c-h/2),r=Math.max(r,c+h/2),t=Math.min(t,l-v/2),a=Math.max(a,l+v/2)}f(e.nodes(),function(s){u(e.node(s))}),f(e.edges(),function(s){var c=e.edge(s);Object.prototype.hasOwnProperty.call(c,"x")&&u(c)}),n-=o,t-=d,f(e.nodes(),function(s){var c=e.node(s);c.x-=n,c.y-=t}),f(e.edges(),function(s){var c=e.edge(s);f(c.points,function(l){l.x-=n,l.y-=t}),Object.prototype.hasOwnProperty.call(c,"x")&&(c.x-=n),Object.prototype.hasOwnProperty.call(c,"y")&&(c.y-=t)}),i.width=r-n+o,i.height=a-t+d}function sr(e){f(e.edges(),function(n){var r=e.edge(n),t=e.node(n.v),a=e.node(n.w),i,o;r.points?(i=r.points[0],o=r.points[r.points.length-1]):(r.points=[],i=a,o=t),r.points.unshift(K(t,i)),r.points.push(K(a,o))})}function fr(e){f(e.edges(),function(n){var r=e.edge(n);if(Object.prototype.hasOwnProperty.call(r,"x"))switch((r.labelpos==="l"||r.labelpos==="r")&&(r.width-=r.labeloffset),r.labelpos){case"l":r.x-=r.width/2+r.labeloffset;break;case"r":r.x+=r.width/2+r.labeloffset;break}})}function cr(e){f(e.edges(),function(n){var r=e.edge(n);r.reversed&&r.points.reverse()})}function lr(e){f(e.nodes(),function(n){if(e.children(n).length){var r=e.node(n),t=e.node(r.borderTop),a=e.node(r.borderBottom),i=e.node(T(r.borderLeft)),o=e.node(T(r.borderRight));r.width=Math.abs(o.x-i.x),r.height=Math.abs(a.y-t.y),r.x=i.x+r.width/2,r.y=t.y+r.height/2}}),f(e.nodes(),function(n){e.node(n).dummy==="border"&&e.removeNode(n)})}function hr(e){f(e.edges(),function(n){if(n.v===n.w){var r=e.node(n.v);r.selfEdges||(r.selfEdges=[]),r.selfEdges.push({e:n,label:e.edge(n)}),e.removeEdge(n)}})}function vr(e){var n=S(e);f(n,function(r){var t=0;f(r,function(a,i){var o=e.node(a);o.order=i+t,f(o.selfEdges,function(d){O(e,"selfedge",{width:d.label.width,height:d.label.height,rank:o.rank,order:i+ ++t,e:d.e,label:d.label},"_se")}),delete o.selfEdges})})}function pr(e){f(e.nodes(),function(n){var r=e.node(n);if(r.dummy==="selfedge"){var t=e.node(r.e.v),a=t.x+t.width/2,i=t.y,o=r.x-a,d=t.height/2;e.setEdge(r.e,r.label),e.removeNode(n),r.label.points=[{x:a+2*o/3,y:i-d},{x:a+5*o/6,y:i-d},{x:a+o,y:i},{x:a+5*o/6,y:i+d},{x:a+2*o/3,y:i+d}],r.label.x=r.x,r.label.y=r.y}})}function B(e,n){return M(C(e,n),Number)}function Y(e){var n={};return f(e,function(r,t){n[t.toLowerCase()]=r}),n}export{gr as l};
|