import{G as k}from"./graph-RRZFWUB3.js";import{a_ as Pn,aR as Sn,aU as z,bj as Fn,aZ as ln,aY as en,aX as A,aW as vn,bk as On,bl as Vn,aQ as W,aB as An,aC as Bn,bm as Yn,bn as Gn,bo as T,aE as Dn,aA as g,bp as P,bq as jn,br as $}from"./index-rTfho1Gk.js";import{d as pn,e as mn,a as s,h as m,f as I,v as y,r as F}from"./_baseUniq-DbOZ-2NY.js";import{b as wn,a as qn,c as Wn,t as B,m as w,d as _,f as U,l as S,e as $n}from"./min-CsCIFSS6.js";function Xn(n,e){return n==null?n:Pn(n,pn(e),Sn)}function zn(n,e){return n&&mn(n,pn(e))}function Un(n,e){return n>e}function O(n,e){var r={};return e=z(e),mn(n,function(i,t,a){Fn(r,t,e(i,t,a))}),r}function x(n){return n&&n.length?wn(n,ln,Un):void 0}function H(n,e){return n&&n.length?wn(n,z(e),qn):void 0}function Hn(n,e){var r=n.length;for(n.sort(e);r--;)n[r]=n[r].value;return n}function Zn(n,e){if(n!==e){var r=n!==void 0,i=n===null,t=n===n,a=en(n),o=e!==void 0,u=e===null,d=e===e,f=en(e);if(!u&&!f&&!a&&n>e||a&&o&&d&&!u&&!f||i&&o&&d||!r&&d||!t)return 1;if(!i&&!a&&!f&&n=u)return d;var f=r[i];return d*(f=="desc"?-1:1)}}return n.index-e.index}function Qn(n,e,r){e.length?e=A(e,function(a){return vn(a)?function(o){return On(o,a.length===1?a[0]:a)}:a}):e=[ln];var i=-1;e=A(e,Vn(z));var t=Wn(n,function(a,o,u){var d=A(e,function(f){return f(a)});return{criteria:d,index:++i,value:a}});return Hn(t,function(a,o){return Jn(a,o,r)})}var Kn=Math.ceil,ne=Math.max;function ee(n,e,r,i){for(var t=-1,a=ne(Kn((e-n)/(r||1)),0),o=Array(a);a--;)o[++t]=n,n+=r;return o}function re(n){return function(e,r,i){return i&&typeof i!="number"&&W(e,r,i)&&(r=i=void 0),e=B(e),r===void 0?(r=e,e=0):r=B(r),i=i===void 0?e1&&W(n,e[0],e[1])?e=[]:r>2&&W(e[0],e[1],e[2])&&(e=[e[0]]),Qn(n,Bn(e),[])}),ie=0;function Z(n){var e=++ie;return Yn(n)+e}function te(n,e,r){for(var i=-1,t=n.length,a=e.length,o={};++i0;--u)if(o=e[u].dequeue(),o){i=i.concat(Y(n,e,r,o,!0));break}}}return i}function Y(n,e,r,i,t){var a=t?[]:void 0;return s(n.inEdges(i.v),function(o){var u=n.edge(o),d=n.node(o.v);t&&a.push({v:o.v,w:o.w}),d.out-=u,X(e,r,d)}),s(n.outEdges(i.v),function(o){var u=n.edge(o),d=o.w,f=n.node(d);f.in-=u,X(e,r,f)}),n.removeNode(i.v),a}function ce(n,e){var r=new k,i=0,t=0;s(n.nodes(),function(u){r.setNode(u,{v:u,in:0,out:0})}),s(n.edges(),function(u){var d=r.edge(u.v,u.w)||0,f=e(u),c=d+f;r.setEdge(u.v,u.w,c),t=Math.max(t,r.node(u.v).out+=f),i=Math.max(i,r.node(u.w).in+=f)});var a=N(t+i+3).map(function(){return new oe}),o=i+1;return s(r.nodes(),function(u){X(a,o,r.node(u))}),{graph:r,buckets:a,zeroIdx:o}}function X(n,e,r){r.out?r.in?n[r.out-r.in+e].enqueue(r):n[n.length-1].enqueue(r):n[0].enqueue(r)}function he(n){var e=n.graph().acyclicer==="greedy"?fe(n,r(n)):le(n);s(e,function(i){var t=n.edge(i);n.removeEdge(i),t.forwardName=i.name,t.reversed=!0,n.setEdge(i.w,i.v,t,Z("rev"))});function r(i){return function(t){return i.edge(t).weight}}}function le(n){var e=[],r={},i={};function t(a){m(i,a)||(i[a]=!0,r[a]=!0,s(n.outEdges(a),function(o){m(r,o.w)?e.push(o):t(o.w)}),delete r[a])}return s(n.nodes(),t),e}function ve(n){s(n.edges(),function(e){var r=n.edge(e);if(r.reversed){n.removeEdge(e);var i=r.forwardName;delete r.reversed,delete r.forwardName,n.setEdge(e.w,e.v,r,i)}})}function L(n,e,r,i){var t;do t=Z(i);while(n.hasNode(t));return r.dummy=e,n.setNode(t,r),t}function pe(n){var e=new k().setGraph(n.graph());return s(n.nodes(),function(r){e.setNode(r,n.node(r))}),s(n.edges(),function(r){var i=e.edge(r.v,r.w)||{weight:0,minlen:1},t=n.edge(r);e.setEdge(r.v,r.w,{weight:i.weight+t.weight,minlen:Math.max(i.minlen,t.minlen)})}),e}function bn(n){var e=new k({multigraph:n.isMultigraph()}).setGraph(n.graph());return s(n.nodes(),function(r){n.children(r).length||e.setNode(r,n.node(r))}),s(n.edges(),function(r){e.setEdge(r,n.edge(r))}),e}function tn(n,e){var r=n.x,i=n.y,t=e.x-r,a=e.y-i,o=n.width/2,u=n.height/2;if(!t&&!a)throw new Error("Not possible to find intersection inside of the rectangle");var d,f;return Math.abs(a)*o>Math.abs(t)*u?(a<0&&(u=-u),d=u*t/a,f=u):(t<0&&(o=-o),d=o,f=o*a/t),{x:r+d,y:i+f}}function V(n){var e=w(N(gn(n)+1),function(){return[]});return s(n.nodes(),function(r){var i=n.node(r),t=i.rank;g(t)||(e[t][i.order]=r)}),e}function me(n){var e=_(w(n.nodes(),function(r){return n.node(r).rank}));s(n.nodes(),function(r){var i=n.node(r);m(i,"rank")&&(i.rank-=e)})}function we(n){var e=_(w(n.nodes(),function(a){return n.node(a).rank})),r=[];s(n.nodes(),function(a){var o=n.node(a).rank-e;r[o]||(r[o]=[]),r[o].push(a)});var i=0,t=n.graph().nodeRankFactor;s(r,function(a,o){g(a)&&o%t!==0?--i:i&&s(a,function(u){n.node(u).rank+=i})})}function an(n,e,r,i){var t={width:0,height:0};return arguments.length>=4&&(t.rank=r,t.order=i),L(n,"border",t,e)}function gn(n){return x(w(n.nodes(),function(e){var r=n.node(e).rank;if(!g(r))return r}))}function be(n,e){var r={lhs:[],rhs:[]};return s(n,function(i){e(i)?r.lhs.push(i):r.rhs.push(i)}),r}function ge(n,e){return e()}function ke(n){function e(r){var i=n.children(r),t=n.node(r);if(i.length&&s(i,e),m(t,"minRank")){t.borderLeft=[],t.borderRight=[];for(var a=t.minRank,o=t.maxRank+1;ao.lim&&(u=o,d=!0);var f=I(e.edges(),function(c){return d===dn(n,n.node(c.v),u)&&d!==dn(n,n.node(c.w),u)});return H(f,function(c){return R(e,c)})}function Rn(n,e,r,i){var t=r.v,a=r.w;n.removeEdge(t,a),n.setEdge(i.v,i.w,{}),K(n),Q(n,e),Oe(n,e)}function Oe(n,e){var r=U(n.nodes(),function(t){return!e.node(t).parent}),i=Se(n,r);i=i.slice(1),s(i,function(t){var a=n.node(t).parent,o=e.edge(t,a),u=!1;o||(o=e.edge(a,t),u=!0),e.node(t).rank=e.node(a).rank+(u?o.minlen:-o.minlen)})}function Ve(n,e,r){return n.hasEdge(e,r)}function dn(n,e,r){return r.low<=e.lim&&e.lim<=r.lim}function Ae(n){switch(n.graph().ranker){case"network-simplex":fn(n);break;case"tight-tree":Ye(n);break;case"longest-path":Be(n);break;default:fn(n)}}var Be=J;function Ye(n){J(n),xn(n)}function fn(n){E(n)}function Ge(n){var e=L(n,"root",{},"_root"),r=De(n),i=x(y(r))-1,t=2*i+1;n.graph().nestingRoot=e,s(n.edges(),function(o){n.edge(o).minlen*=t});var a=je(n)+1;s(n.children(),function(o){Tn(n,e,t,a,i,r,o)}),n.graph().nodeRankFactor=t}function Tn(n,e,r,i,t,a,o){var u=n.children(o);if(!u.length){o!==e&&n.setEdge(e,o,{weight:0,minlen:r});return}var d=an(n,"_bt"),f=an(n,"_bb"),c=n.node(o);n.setParent(d,o),c.borderTop=d,n.setParent(f,o),c.borderBottom=f,s(u,function(h){Tn(n,e,r,i,t,a,h);var l=n.node(h),v=l.borderTop?l.borderTop:h,p=l.borderBottom?l.borderBottom:h,b=l.borderTop?i:2*i,C=v!==p?1:t-a[o]+1;n.setEdge(d,v,{weight:b,minlen:C,nestingEdge:!0}),n.setEdge(p,f,{weight:b,minlen:C,nestingEdge:!0})}),n.parent(o)||n.setEdge(e,d,{weight:0,minlen:t+a[o]})}function De(n){var e={};function r(i,t){var a=n.children(i);a&&a.length&&s(a,function(o){r(o,t+1)}),e[i]=t}return s(n.children(),function(i){r(i,1)}),e}function je(n){return F(n.edges(),function(e,r){return e+n.edge(r).weight},0)}function qe(n){var e=n.graph();n.removeNode(e.nestingRoot),delete e.nestingRoot,s(n.edges(),function(r){var i=n.edge(r);i.nestingEdge&&n.removeEdge(r)})}function We(n,e,r){var i={},t;s(r,function(a){for(var o=n.parent(a),u,d;o;){if(u=n.parent(o),u?(d=i[u],i[u]=o):(d=t,t=o),d&&d!==o){e.setEdge(d,o);return}o=u}})}function $e(n,e,r){var i=Xe(n),t=new k({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(function(a){return n.node(a)});return s(n.nodes(),function(a){var o=n.node(a),u=n.parent(a);(o.rank===e||o.minRank<=e&&e<=o.maxRank)&&(t.setNode(a),t.setParent(a,u||i),s(n[r](a),function(d){var f=d.v===a?d.w:d.v,c=t.edge(f,a),h=g(c)?0:c.weight;t.setEdge(f,a,{weight:n.edge(d).weight+h})}),m(o,"minRank")&&t.setNode(a,{borderLeft:o.borderLeft[e],borderRight:o.borderRight[e]}))}),t}function Xe(n){for(var e;n.hasNode(e=Z("_root")););return e}function ze(n,e){for(var r=0,i=1;i0;)c%2&&(h+=u[c+1]),c=c-1>>1,u[c]+=f.weight;d+=f.weight*h})),d}function He(n){var e={},r=I(n.nodes(),function(u){return!n.children(u).length}),i=x(w(r,function(u){return n.node(u).rank})),t=w(N(i+1),function(){return[]});function a(u){if(!m(e,u)){e[u]=!0;var d=n.node(u);t[d.rank].push(u),s(n.successors(u),a)}}var o=M(r,function(u){return n.node(u).rank});return s(o,a),t}function Ze(n,e){return w(e,function(r){var i=n.inEdges(r);if(i.length){var t=F(i,function(a,o){var u=n.edge(o),d=n.node(o.v);return{sum:a.sum+u.weight*d.order,weight:a.weight+u.weight}},{sum:0,weight:0});return{v:r,barycenter:t.sum/t.weight,weight:t.weight}}else return{v:r}})}function Je(n,e){var r={};s(n,function(t,a){var o=r[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:a};g(t.barycenter)||(o.barycenter=t.barycenter,o.weight=t.weight)}),s(e.edges(),function(t){var a=r[t.v],o=r[t.w];!g(a)&&!g(o)&&(o.indegree++,a.out.push(r[t.w]))});var i=I(r,function(t){return!t.indegree});return Qe(i)}function Qe(n){var e=[];function r(a){return function(o){o.merged||(g(o.barycenter)||g(a.barycenter)||o.barycenter>=a.barycenter)&&Ke(a,o)}}function i(a){return function(o){o.in.push(a),--o.indegree===0&&n.push(o)}}for(;n.length;){var t=n.pop();e.push(t),s(t.in.reverse(),r(t)),s(t.out,i(t))}return w(I(e,function(a){return!a.merged}),function(a){return P(a,["vs","i","barycenter","weight"])})}function Ke(n,e){var r=0,i=0;n.weight&&(r+=n.barycenter*n.weight,i+=n.weight),e.weight&&(r+=e.barycenter*e.weight,i+=e.weight),n.vs=e.vs.concat(n.vs),n.barycenter=r/i,n.weight=i,n.i=Math.min(e.i,n.i),e.merged=!0}function nr(n,e){var r=be(n,function(c){return m(c,"barycenter")}),i=r.lhs,t=M(r.rhs,function(c){return-c.i}),a=[],o=0,u=0,d=0;i.sort(er(!!e)),d=sn(a,t,d),s(i,function(c){d+=c.vs.length,a.push(c.vs),o+=c.barycenter*c.weight,u+=c.weight,d=sn(a,t,d)});var f={vs:T(a)};return u&&(f.barycenter=o/u,f.weight=u),f}function sn(n,e,r){for(var i;e.length&&(i=S(e)).i<=r;)e.pop(),n.push(i.vs),r++;return r}function er(n){return function(e,r){return e.barycenterr.barycenter?1:n?r.i-e.i:e.i-r.i}}function In(n,e,r,i){var t=n.children(e),a=n.node(e),o=a?a.borderLeft:void 0,u=a?a.borderRight:void 0,d={};o&&(t=I(t,function(p){return p!==o&&p!==u}));var f=Ze(n,t);s(f,function(p){if(n.children(p.v).length){var b=In(n,p.v,r,i);d[p.v]=b,m(b,"barycenter")&&ir(p,b)}});var c=Je(f,r);rr(c,d);var h=nr(c,i);if(o&&(h.vs=T([o,h.vs,u]),n.predecessors(o).length)){var l=n.node(n.predecessors(o)[0]),v=n.node(n.predecessors(u)[0]);m(h,"barycenter")||(h.barycenter=0,h.weight=0),h.barycenter=(h.barycenter*h.weight+l.order+v.order)/(h.weight+2),h.weight+=2}return h}function rr(n,e){s(n,function(r){r.vs=T(r.vs.map(function(i){return e[i]?e[i].vs:i}))})}function ir(n,e){g(n.barycenter)?(n.barycenter=e.barycenter,n.weight=e.weight):(n.barycenter=(n.barycenter*n.weight+e.barycenter*e.weight)/(n.weight+e.weight),n.weight+=e.weight)}function tr(n){var e=gn(n),r=cn(n,N(1,e+1),"inEdges"),i=cn(n,N(e-1,-1,-1),"outEdges"),t=He(n);hn(n,t);for(var a=Number.POSITIVE_INFINITY,o,u=0,d=0;d<4;++u,++d){ar(u%2?r:i,u%4>=2),t=V(n);var f=ze(n,t);fo||u>e[d].lim));for(f=d,d=i;(d=n.parent(d))!==f;)a.push(d);return{path:t.concat(a.reverse()),lca:f}}function dr(n){var e={},r=0;function i(t){var a=r;s(n.children(t),i),e[t]={low:a,lim:r++}}return s(n.children(),i),e}function fr(n,e){var r={};function i(t,a){var o=0,u=0,d=t.length,f=S(a);return s(a,function(c,h){var l=cr(n,c),v=l?n.node(l).order:d;(l||c===f)&&(s(a.slice(u,h+1),function(p){s(n.predecessors(p),function(b){var C=n.node(b),nn=C.order;(nnf)&&Mn(r,l,c)})})}function t(a,o){var u=-1,d,f=0;return s(o,function(c,h){if(n.node(c).dummy==="border"){var l=n.predecessors(c);l.length&&(d=n.node(l[0]).order,i(o,f,h,u,d),f=h,u=d)}i(o,f,o.length,d,a.length)}),o}return F(e,t),r}function cr(n,e){if(n.node(e).dummy)return U(n.predecessors(e),function(r){return n.node(r).dummy})}function Mn(n,e,r){if(e>r){var i=e;e=r,r=i}var t=n[e];t||(n[e]=t={}),t[r]=!0}function hr(n,e,r){if(e>r){var i=e;e=r,r=i}return m(n[e],r)}function lr(n,e,r,i){var t={},a={},o={};return s(e,function(u){s(u,function(d,f){t[d]=d,a[d]=d,o[d]=f})}),s(e,function(u){var d=-1;s(u,function(f){var c=i(f);if(c.length){c=M(c,function(b){return o[b]});for(var h=(c.length-1)/2,l=Math.floor(h),v=Math.ceil(h);l<=v;++l){var p=c[l];a[f]===f&&d