/*! third party licenses: js/vendor.LICENSE.txt */ import{G as y}from"./graph-BOKMr-rC.chunk.mjs";import{a as f,i as b,f as L,v as E,r as G}from"./_baseUniq-CE6homwJ.chunk.mjs";import{f as M,m as p,g as R,h as A,l as P,e as xn}from"./_basePickBy-0DU--7tw.chunk.mjs";import{h as m}from"./has-DJswI7NS.chunk.mjs";import{r as N,u as J,m as x,a as H,z as En,s as C,p as S,c as Nn,b as F,f as In,d as _n}from"./zipObject-D21phg5E.chunk.mjs";import{n as Rn,J as Tn,a8 as z}from"./isEmpty-nTVdZyYD.chunk.mjs";class Ln{constructor(){var e={};e._next=e._prev=e,this._sentinel=e}dequeue(){var e=this._sentinel,r=e._prev;if(r!==e)return X(r),r}enqueue(e){var r=this._sentinel;e._prev&&e._next&&X(e),e._next=r._next,r._next._prev=e,r._next=e,e._prev=r}toString(){for(var e=[],r=this._sentinel,t=r._prev;t!==r;)e.push(JSON.stringify(t,Mn)),t=t._prev;return"["+e.join(", ")+"]"}}function X(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function Mn(n,e){if(n!=="_next"&&n!=="_prev")return e}var Cn=Rn(1);function Pn(n,e){if(n.nodeCount()<=1)return[];var r=Gn(n,e||Cn),t=Sn(r.graph,r.buckets,r.zeroIdx);return M(p(t,function(o){return n.outEdges(o.v,o.w)}))}function Sn(n,e,r){for(var t=[],o=e[e.length-1],u=e[0],i;n.nodeCount();){for(;i=u.dequeue();)V(n,e,r,i);for(;i=o.dequeue();)V(n,e,r,i);if(n.nodeCount()){for(var a=e.length-2;a>0;--a)if(i=e[a].dequeue(),i){t=t.concat(V(n,e,r,i,!0));break}}}return t}function V(n,e,r,t,o){var u=o?[]:void 0;return f(n.inEdges(t.v),function(i){var a=n.edge(i),d=n.node(i.v);o&&u.push({v:i.v,w:i.w}),d.out-=a,D(e,r,d)}),f(n.outEdges(t.v),function(i){var a=n.edge(i),d=i.w,c=n.node(d);c.in-=a,D(e,r,c)}),n.removeNode(t.v),u}function Gn(n,e){var r=new y,t=0,o=0;f(n.nodes(),function(a){r.setNode(a,{v:a,in:0,out:0})}),f(n.edges(),function(a){var d=r.edge(a.v,a.w)||0,c=e(a),s=d+c;r.setEdge(a.v,a.w,s),o=Math.max(o,r.node(a.v).out+=c),t=Math.max(t,r.node(a.w).in+=c)});var u=N(o+t+3).map(function(){return new Ln}),i=t+1;return f(r.nodes(),function(a){D(u,i,r.node(a))}),{graph:r,buckets:u,zeroIdx:i}}function D(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 Fn(n){var e=n.graph().acyclicer==="greedy"?Pn(n,r(n)):On(n);f(e,function(t){var o=n.edge(t);n.removeEdge(t),o.forwardName=t.name,o.reversed=!0,n.setEdge(t.w,t.v,o,J("rev"))});function r(t){return function(o){return t.edge(o).weight}}}function On(n){var e=[],r={},t={};function o(u){m(t,u)||(t[u]=!0,r[u]=!0,f(n.outEdges(u),function(i){m(r,i.w)?e.push(i):o(i.w)}),delete r[u])}return f(n.nodes(),o),e}function Vn(n){f(n.edges(),function(e){var r=n.edge(e);if(r.reversed){n.removeEdge(e);var t=r.forwardName;delete r.reversed,delete r.forwardName,n.setEdge(e.w,e.v,r,t)}})}function I(n,e,r,t){var o;do o=J(t);while(n.hasNode(o));return r.dummy=e,n.setNode(o,r),o}function Bn(n){var e=new y().setGraph(n.graph());return f(n.nodes(),function(r){e.setNode(r,n.node(r))}),f(n.edges(),function(r){var t=e.edge(r.v,r.w)||{weight:0,minlen:1},o=n.edge(r);e.setEdge(r.v,r.w,{weight:t.weight+o.weight,minlen:Math.max(t.minlen,o.minlen)})}),e}function dn(n){var e=new y({multigraph:n.isMultigraph()}).setGraph(n.graph());return f(n.nodes(),function(r){n.children(r).length||e.setNode(r,n.node(r))}),f(n.edges(),function(r){e.setEdge(r,n.edge(r))}),e}function Z(n,e){var r=n.x,t=n.y,o=e.x-r,u=e.y-t,i=n.width/2,a=n.height/2;if(!o&&!u)throw new Error("Not possible to find intersection inside of the rectangle");var d,c;return Math.abs(u)*i>Math.abs(o)*a?(u<0&&(a=-a),d=a*o/u,c=a):(o<0&&(i=-i),d=i,c=i*u/o),{x:r+d,y:t+c}}function O(n){var e=p(N(cn(n)+1),function(){return[]});return f(n.nodes(),function(r){var t=n.node(r),o=t.rank;b(o)||(e[o][t.order]=r)}),e}function qn(n){var e=R(p(n.nodes(),function(r){return n.node(r).rank}));f(n.nodes(),function(r){var t=n.node(r);m(t,"rank")&&(t.rank-=e)})}function Yn(n){var e=R(p(n.nodes(),function(u){return n.node(u).rank})),r=[];f(n.nodes(),function(u){var i=n.node(u).rank-e;r[i]||(r[i]=[]),r[i].push(u)});var t=0,o=n.graph().nodeRankFactor;f(r,function(u,i){b(u)&&i%o!==0?--t:t&&f(u,function(a){n.node(a).rank+=t})})}function $(n,e,r,t){var o={width:0,height:0};return arguments.length>=4&&(o.rank=r,o.order=t),I(n,"border",o,e)}function cn(n){return x(p(n.nodes(),function(e){var r=n.node(e).rank;if(!b(r))return r}))}function jn(n,e){var r={lhs:[],rhs:[]};return f(n,function(t){e(t)?r.lhs.push(t):r.rhs.push(t)}),r}function zn(n,e){return e()}function Dn(n){function e(r){var t=n.children(r),o=n.node(r);if(t.length&&f(t,e),m(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(var u=o.minRank,i=o.maxRank+1;ui.lim&&(a=i,d=!0);var c=L(e.edges(),function(s){return d===rn(n,n.node(s.v),a)&&d!==rn(n,n.node(s.w),a)});return H(c,function(s){return T(e,s)})}function wn(n,e,r,t){var o=r.v,u=r.w;n.removeEdge(o,u),n.setEdge(t.v,t.w,{}),U(n),Q(n,e),oe(n,e)}function oe(n,e){var r=A(n.nodes(),function(o){return!e.node(o).parent}),t=re(n,r);t=t.slice(1),f(t,function(o){var u=n.node(o).parent,i=e.edge(o,u),a=!1;i||(i=e.edge(u,o),a=!0),e.node(o).rank=e.node(u).rank+(a?i.minlen:-i.minlen)})}function ie(n,e,r){return n.hasEdge(e,r)}function rn(n,e,r){return r.low<=e.lim&&e.lim<=r.lim}function ue(n){switch(n.graph().ranker){case"network-simplex":tn(n);break;case"tight-tree":de(n);break;case"longest-path":ae(n);break;default:tn(n)}}var ae=K;function de(n){K(n),sn(n)}function tn(n){k(n)}function ce(n){var e=I(n,"root",{},"_root"),r=fe(n),t=x(E(r))-1,o=2*t+1;n.graph().nestingRoot=e,f(n.edges(),function(i){n.edge(i).minlen*=o});var u=se(n)+1;f(n.children(),function(i){bn(n,e,o,u,t,r,i)}),n.graph().nodeRankFactor=o}function bn(n,e,r,t,o,u,i){var a=n.children(i);if(!a.length){i!==e&&n.setEdge(e,i,{weight:0,minlen:r});return}var d=$(n,"_bt"),c=$(n,"_bb"),s=n.node(i);n.setParent(d,i),s.borderTop=d,n.setParent(c,i),s.borderBottom=c,f(a,function(g){bn(n,e,r,t,o,u,g);var h=n.node(g),v=h.borderTop?h.borderTop:g,l=h.borderBottom?h.borderBottom:g,w=h.borderTop?t:2*t,_=v!==l?1:o-u[i]+1;n.setEdge(d,v,{weight:w,minlen:_,nestingEdge:!0}),n.setEdge(l,c,{weight:w,minlen:_,nestingEdge:!0})}),n.parent(i)||n.setEdge(e,d,{weight:0,minlen:o+u[i]})}function fe(n){var e={};function r(t,o){var u=n.children(t);u&&u.length&&f(u,function(i){r(i,o+1)}),e[t]=o}return f(n.children(),function(t){r(t,1)}),e}function se(n){return G(n.edges(),function(e,r){return e+n.edge(r).weight},0)}function ge(n){var e=n.graph();n.removeNode(e.nestingRoot),delete e.nestingRoot,f(n.edges(),function(r){var t=n.edge(r);t.nestingEdge&&n.removeEdge(r)})}function he(n,e,r){var t={},o;f(r,function(u){for(var i=n.parent(u),a,d;i;){if(a=n.parent(i),a?(d=t[a],t[a]=i):(d=o,o=i),d&&d!==i){e.setEdge(d,i);return}i=a}})}function ve(n,e,r){var t=le(n),o=new y({compound:!0}).setGraph({root:t}).setDefaultNodeLabel(function(u){return n.node(u)});return f(n.nodes(),function(u){var i=n.node(u),a=n.parent(u);(i.rank===e||i.minRank<=e&&e<=i.maxRank)&&(o.setNode(u),o.setParent(u,a||t),f(n[r](u),function(d){var c=d.v===u?d.w:d.v,s=o.edge(c,u),g=b(s)?0:s.weight;o.setEdge(c,u,{weight:n.edge(d).weight+g})}),m(i,"minRank")&&o.setNode(u,{borderLeft:i.borderLeft[e],borderRight:i.borderRight[e]}))}),o}function le(n){for(var e;n.hasNode(e=J("_root")););return e}function me(n,e){for(var r=0,t=1;t0;)s%2&&(g+=a[s+1]),s=s-1>>1,a[s]+=c.weight;d+=c.weight*g})),d}function we(n){var e={},r=L(n.nodes(),function(a){return!n.children(a).length}),t=x(p(r,function(a){return n.node(a).rank})),o=p(N(t+1),function(){return[]});function u(a){if(!m(e,a)){e[a]=!0;var d=n.node(a);o[d.rank].push(a),f(n.successors(a),u)}}var i=C(r,function(a){return n.node(a).rank});return f(i,u),o}function be(n,e){return p(e,function(r){var t=n.inEdges(r);if(t.length){var o=G(t,function(u,i){var a=n.edge(i),d=n.node(i.v);return{sum:u.sum+a.weight*d.order,weight:u.weight+a.weight}},{sum:0,weight:0});return{v:r,barycenter:o.sum/o.weight,weight:o.weight}}else return{v:r}})}function ye(n,e){var r={};f(n,function(o,u){var i=r[o.v]={indegree:0,in:[],out:[],vs:[o.v],i:u};b(o.barycenter)||(i.barycenter=o.barycenter,i.weight=o.weight)}),f(e.edges(),function(o){var u=r[o.v],i=r[o.w];!b(u)&&!b(i)&&(i.indegree++,u.out.push(r[o.w]))});var t=L(r,function(o){return!o.indegree});return ke(t)}function ke(n){var e=[];function r(u){return function(i){i.merged||(b(i.barycenter)||b(u.barycenter)||i.barycenter>=u.barycenter)&&xe(u,i)}}function t(u){return function(i){i.in.push(u),--i.indegree===0&&n.push(i)}}for(;n.length;){var o=n.pop();e.push(o),f(o.in.reverse(),r(o)),f(o.out,t(o))}return p(L(e,function(u){return!u.merged}),function(u){return S(u,["vs","i","barycenter","weight"])})}function xe(n,e){var r=0,t=0;n.weight&&(r+=n.barycenter*n.weight,t+=n.weight),e.weight&&(r+=e.barycenter*e.weight,t+=e.weight),n.vs=e.vs.concat(n.vs),n.barycenter=r/t,n.weight=t,n.i=Math.min(e.i,n.i),e.merged=!0}function Ee(n,e){var r=jn(n,function(s){return m(s,"barycenter")}),t=r.lhs,o=C(r.rhs,function(s){return-s.i}),u=[],i=0,a=0,d=0;t.sort(Ne(!!e)),d=on(u,o,d),f(t,function(s){d+=s.vs.length,u.push(s.vs),i+=s.barycenter*s.weight,a+=s.weight,d=on(u,o,d)});var c={vs:M(u)};return a&&(c.barycenter=i/a,c.weight=a),c}function on(n,e,r){for(var t;e.length&&(t=P(e)).i<=r;)e.pop(),n.push(t.vs),r++;return r}function Ne(n){return function(e,r){return e.barycenterr.barycenter?1:n?r.i-e.i:e.i-r.i}}function yn(n,e,r,t){var o=n.children(e),u=n.node(e),i=u?u.borderLeft:void 0,a=u?u.borderRight:void 0,d={};i&&(o=L(o,function(l){return l!==i&&l!==a}));var c=be(n,o);f(c,function(l){if(n.children(l.v).length){var w=yn(n,l.v,r,t);d[l.v]=w,m(w,"barycenter")&&_e(l,w)}});var s=ye(c,r);Ie(s,d);var g=Ee(s,t);if(i&&(g.vs=M([i,g.vs,a]),n.predecessors(i).length)){var h=n.node(n.predecessors(i)[0]),v=n.node(n.predecessors(a)[0]);m(g,"barycenter")||(g.barycenter=0,g.weight=0),g.barycenter=(g.barycenter*g.weight+h.order+v.order)/(g.weight+2),g.weight+=2}return g}function Ie(n,e){f(n,function(r){r.vs=M(r.vs.map(function(t){return e[t]?e[t].vs:t}))})}function _e(n,e){b(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 Re(n){var e=cn(n),r=un(n,N(1,e+1),"inEdges"),t=un(n,N(e-1,-1,-1),"outEdges"),o=we(n);an(n,o);for(var u=Number.POSITIVE_INFINITY,i,a=0,d=0;d<4;++a,++d){Te(a%2?r:t,a%4>=2),o=O(n);var c=me(n,o);ci||a>e[d].lim));for(c=d,d=t;(d=n.parent(d))!==c;)u.push(d);return{path:o.concat(u.reverse()),lca:c}}function Ce(n){var e={},r=0;function t(o){var u=r;f(n.children(o),t),e[o]={low:u,lim:r++}}return f(n.children(),t),e}function Pe(n,e){var r={};function t(o,u){var i=0,a=0,d=o.length,c=P(u);return f(u,function(s,g){var h=Ge(n,s),v=h?n.node(h).order:d;(h||s===c)&&(f(u.slice(a,g+1),function(l){f(n.predecessors(l),function(w){var _=n.node(w),W=_.order;(Wc)&&kn(r,h,s)})})}function o(u,i){var a=-1,d,c=0;return f(i,function(s,g){if(n.node(s).dummy==="border"){var h=n.predecessors(s);h.length&&(d=n.node(h[0]).order,t(i,c,g,a,d),c=g,a=d)}t(i,c,i.length,d,u.length)}),i}return G(e,o),r}function Ge(n,e){if(n.node(e).dummy)return A(n.predecessors(e),function(r){return n.node(r).dummy})}function kn(n,e,r){if(e>r){var t=e;e=r,r=t}var o=n[e];o||(n[e]=o={}),o[r]=!0}function Fe(n,e,r){if(e>r){var t=e;e=r,r=t}return m(n[e],r)}function Oe(n,e,r,t){var o={},u={},i={};return f(e,function(a){f(a,function(d,c){o[d]=d,u[d]=d,i[d]=c})}),f(e,function(a){var d=-1;f(a,function(c){var s=t(c);if(s.length){s=C(s,function(w){return i[w]});for(var g=(s.length-1)/2,h=Math.floor(g),v=Math.ceil(g);h<=v;++h){var l=s[h];u[c]===c&&d