f7cloud_client/apps/whiteboard/js/layout-_kSBx-Bz.chunk.mjs
root 8b6a0139db f7cloud_client
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-17 22:59:26 +00:00

4 lines
24 KiB
JavaScript

/*! 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;u<i;++u)nn(n,"borderLeft","_bl",r,o,u),nn(n,"borderRight","_br",r,o,u)}}f(n.children(),e)}function nn(n,e,r,t,o,u){var i={width:0,height:0,rank:u,borderType:e},a=o[e][u-1],d=I(n,"border",i,r);o[e][u]=d,n.setParent(d,t),a&&n.setEdge(a,d,{weight:1})}function An(n){var e=n.graph().rankdir.toLowerCase();(e==="lr"||e==="rl")&&fn(n)}function Jn(n){var e=n.graph().rankdir.toLowerCase();(e==="bt"||e==="rl")&&Hn(n),(e==="lr"||e==="rl")&&(Kn(n),fn(n))}function fn(n){f(n.nodes(),function(e){en(n.node(e))}),f(n.edges(),function(e){en(n.edge(e))})}function en(n){var e=n.width;n.width=n.height,n.height=e}function Hn(n){f(n.nodes(),function(e){B(n.node(e))}),f(n.edges(),function(e){var r=n.edge(e);f(r.points,B),m(r,"y")&&B(r)})}function B(n){n.y=-n.y}function Kn(n){f(n.nodes(),function(e){q(n.node(e))}),f(n.edges(),function(e){var r=n.edge(e);f(r.points,q),m(r,"x")&&q(r)})}function q(n){var e=n.x;n.x=n.y,n.y=e}function Qn(n){n.graph().dummyChains=[],f(n.edges(),function(e){Un(n,e)})}function Un(n,e){var r=e.v,t=n.node(r).rank,o=e.w,u=n.node(o).rank,i=e.name,a=n.edge(e),d=a.labelRank;if(u!==t+1){n.removeEdge(e);var c,s,g;for(g=0,++t;t<u;++g,++t)a.points=[],s={width:0,height:0,edgeLabel:a,edgeObj:e,rank:t},c=I(n,"edge",s,"_d"),t===d&&(s.width=a.width,s.height=a.height,s.dummy="edge-label",s.labelpos=a.labelpos),n.setEdge(r,c,{weight:a.weight},i),g===0&&n.graph().dummyChains.push(c),r=c;n.setEdge(r,o,{weight:a.weight},i)}}function Wn(n){f(n.graph().dummyChains,function(e){var r=n.node(e),t=r.edgeLabel,o;for(n.setEdge(r.edgeObj,t);r.dummy;)o=n.successors(e)[0],n.removeNode(e),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),e=o,r=n.node(e)})}function K(n){var e={};function r(t){var o=n.node(t);if(m(e,t))return o.rank;e[t]=!0;var u=R(p(n.outEdges(t),function(i){return r(i.w)-n.edge(i).minlen}));return(u===Number.POSITIVE_INFINITY||u===void 0||u===null)&&(u=0),o.rank=u}f(n.sources(),r)}function T(n,e){return n.node(e.w).rank-n.node(e.v).rank-n.edge(e).minlen}function sn(n){var e=new y({directed:!1}),r=n.nodes()[0],t=n.nodeCount();e.setNode(r,{});for(var o,u;Xn(e,n)<t;)o=Zn(e,n),u=e.hasNode(o.v)?T(n,o):-T(n,o),$n(e,n,u);return e}function Xn(n,e){function r(t){f(e.nodeEdges(t),function(o){var u=o.v,i=t===u?o.w:u;!n.hasNode(i)&&!T(e,o)&&(n.setNode(i,{}),n.setEdge(t,i,{}),r(i))})}return f(n.nodes(),r),n.nodeCount()}function Zn(n,e){return H(e.edges(),function(r){if(n.hasNode(r.v)!==n.hasNode(r.w))return T(e,r)})}function $n(n,e,r){f(n.nodes(),function(t){e.node(t).rank+=r})}function ne(){}ne.prototype=new Error;function gn(n,e,r){Tn(e)||(e=[e]);var t=(n.isDirected()?n.successors:n.neighbors).bind(n),o=[],u={};return f(e,function(i){if(!n.hasNode(i))throw new Error("Graph does not have node: "+i);hn(n,i,r==="post",u,t,o)}),o}function hn(n,e,r,t,o,u){m(t,e)||(t[e]=!0,r||u.push(e),f(o(e),function(i){hn(n,i,r,t,o,u)}),r&&u.push(e))}function ee(n,e){return gn(n,e,"post")}function re(n,e){return gn(n,e,"pre")}k.initLowLimValues=U,k.initCutValues=Q,k.calcCutValue=vn,k.leaveEdge=mn,k.enterEdge=pn,k.exchangeEdges=wn;function k(n){n=Bn(n),K(n);var e=sn(n);U(e),Q(e,n);for(var r,t;r=mn(e);)t=pn(e,n,r),wn(e,n,r,t)}function Q(n,e){var r=ee(n,n.nodes());r=r.slice(0,r.length-1),f(r,function(t){te(n,e,t)})}function te(n,e,r){var t=n.node(r),o=t.parent;n.edge(r,o).cutvalue=vn(n,e,r)}function vn(n,e,r){var t=n.node(r),o=t.parent,u=!0,i=e.edge(r,o),a=0;return i||(u=!1,i=e.edge(o,r)),a=i.weight,f(e.nodeEdges(r),function(d){var c=d.v===r,s=c?d.w:d.v;if(s!==o){var g=c===u,h=e.edge(d).weight;if(a+=g?h:-h,ie(n,r,s)){var v=n.edge(r,s).cutvalue;a+=g?-v:v}}}),a}function U(n,e){arguments.length<2&&(e=n.nodes()[0]),ln(n,{},1,e)}function ln(n,e,r,t,o){var u=r,i=n.node(t);return e[t]=!0,f(n.neighbors(t),function(a){m(e,a)||(r=ln(n,e,r,a,t))}),i.low=u,i.lim=r++,o?i.parent=o:delete i.parent,r}function mn(n){return A(n.edges(),function(e){return n.edge(e).cutvalue<0})}function pn(n,e,r){var t=r.v,o=r.w;e.hasEdge(t,o)||(t=r.w,o=r.v);var u=n.node(t),i=n.node(o),a=u,d=!1;u.lim>i.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;t<e.length;++t)r+=pe(n,e[t-1],e[t]);return r}function pe(n,e,r){for(var t=En(r,p(r,function(c,s){return s})),o=M(p(e,function(c){return C(p(n.outEdges(c),function(s){return{pos:t[s.w],weight:n.edge(s).weight}}),"pos")})),u=1;u<r.length;)u<<=1;var i=2*u-1;u-=1;var a=p(new Array(i),function(){return 0}),d=0;return f(o.forEach(function(c){var s=c.pos+u;a[s]+=c.weight;for(var g=0;s>0;)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.barycenter<r.barycenter?-1:e.barycenter>r.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);c<u&&(d=0,i=Nn(o),u=c)}an(n,i)}function un(n,e,r){return p(e,function(t){return ve(n,t,r)})}function Te(n,e){var r=new y;f(n,function(t){var o=t.graph().root,u=yn(t,o,r,e);f(u.vs,function(i,a){t.node(i).order=a}),he(t,r,u.vs)})}function an(n,e){f(e,function(r){f(r,function(t,o){n.node(t).order=o})})}function Le(n){var e=Ce(n);f(n.graph().dummyChains,function(r){for(var t=n.node(r),o=t.edgeObj,u=Me(n,e,o.v,o.w),i=u.path,a=u.lca,d=0,c=i[d],s=!0;r!==o.w;){if(t=n.node(r),s){for(;(c=i[d])!==a&&n.node(c).maxRank<t.rank;)d++;c===a&&(s=!1)}if(!s){for(;d<i.length-1&&n.node(c=i[d+1]).minRank<=t.rank;)d++;c=i[d]}n.setParent(r,c),r=n.successors(r)[0]}})}function Me(n,e,r,t){var o=[],u=[],i=Math.min(e[r].low,e[t].low),a=Math.max(e[r].lim,e[t].lim),d,c;d=r;do d=n.parent(d),o.push(d);while(d&&(e[d].low>i||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;(W<i||v<W)&&!(_.dummy&&n.node(l).dummy)&&kn(r,w,l)})}),a=g+1,i=v)}),u}return G(e,t),r}function Se(n,e){var r={};function t(u,i,a,d,c){var s;f(N(i,a),function(g){s=u[g],n.node(s).dummy&&f(n.predecessors(s),function(h){var v=n.node(h);v.dummy&&(v.order<d||v.order>c)&&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<i[l]&&!Fe(r,c,l)&&(u[l]=c,u[c]=o[c]=o[l],d=i[l])}}})}),{root:o,align:u}}function Ve(n,e,r,t,o){var u={},i=Be(n,e,r,o),a=o?"borderLeft":"borderRight";function d(g,h){for(var v=i.nodes(),l=v.pop(),w={};l;)w[l]?g(l):(w[l]=!0,v.push(l),v=v.concat(h(l))),l=v.pop()}function c(g){u[g]=i.inEdges(g).reduce(function(h,v){return Math.max(h,u[v.v]+i.edge(v))},0)}function s(g){var h=i.outEdges(g).reduce(function(l,w){return Math.min(l,u[w.w]-i.edge(w))},Number.POSITIVE_INFINITY),v=n.node(g);h!==Number.POSITIVE_INFINITY&&v.borderType!==a&&(u[g]=Math.max(u[g],h))}return d(c,i.predecessors.bind(i)),d(s,i.successors.bind(i)),f(t,function(g){u[g]=u[r[g]]}),u}function Be(n,e,r,t){var o=new y,u=n.graph(),i=De(u.nodesep,u.edgesep,t);return f(e,function(a){var d;f(a,function(c){var s=r[c];if(o.setNode(s),d){var g=r[d],h=o.edge(g,s);o.setEdge(g,s,Math.max(i(n,c,d),h||0))}d=c})}),o}function qe(n,e){return H(E(e),function(r){var t=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;return In(r,function(u,i){var a=Ae(n,i)/2;t=Math.max(u+a,t),o=Math.min(u-a,o)}),t-o})}function Ye(n,e){var r=E(e),t=R(r),o=x(r);f(["u","d"],function(u){f(["l","r"],function(i){var a=u+i,d=n[a],c;if(d!==e){var s=E(d);c=i==="l"?t-R(s):o-x(s),c&&(n[a]=F(d,function(g){return g+c}))}})})}function je(n,e){return F(n.ul,function(r,t){if(e)return n[e.toLowerCase()][t];var o=C(p(n,t));return(o[1]+o[2])/2})}function ze(n){var e=O(n),r=z(Pe(n,e),Se(n,e)),t={},o;f(["u","d"],function(i){o=i==="u"?e:E(e).reverse(),f(["l","r"],function(a){a==="r"&&(o=p(o,function(g){return E(g).reverse()}));var d=(i==="u"?n.predecessors:n.successors).bind(n),c=Oe(n,o,r,d),s=Ve(n,o,c.root,c.align,a==="r");a==="r"&&(s=F(s,function(g){return-g})),t[i+a]=s})});var u=qe(n,t);return Ye(t,u),je(t,n.graph().align)}function De(n,e,r){return function(t,o,u){var i=t.node(o),a=t.node(u),d=0,c;if(d+=i.width/2,m(i,"labelpos"))switch(i.labelpos.toLowerCase()){case"l":c=-i.width/2;break;case"r":c=i.width/2;break}if(c&&(d+=r?c:-c),c=0,d+=(i.dummy?e:n)/2,d+=(a.dummy?e:n)/2,d+=a.width/2,m(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":c=a.width/2;break;case"r":c=-a.width/2;break}return c&&(d+=r?c:-c),c=0,d}}function Ae(n,e){return n.node(e).width}function Je(n){n=dn(n),He(n),_n(ze(n),function(e,r){n.node(r).x=e})}function He(n){var e=O(n),r=n.graph().ranksep,t=0;f(e,function(o){var u=x(p(o,function(i){return n.node(i).height}));f(o,function(i){n.node(i).y=t+u/2}),t+=u+r})}function xr(n,e){var r=zn;r("layout",function(){var t=r(" buildLayoutGraph",function(){return tr(n)});r(" runLayout",function(){Ke(t,r)}),r(" updateInputGraph",function(){Qe(n,t)})})}function Ke(n,e){e(" makeSpaceForEdgeLabels",function(){or(n)}),e(" removeSelfEdges",function(){hr(n)}),e(" acyclic",function(){Fn(n)}),e(" nestingGraph.run",function(){ce(n)}),e(" rank",function(){ue(dn(n))}),e(" injectEdgeLabelProxies",function(){ir(n)}),e(" removeEmptyRanks",function(){Yn(n)}),e(" nestingGraph.cleanup",function(){ge(n)}),e(" normalizeRanks",function(){qn(n)}),e(" assignRankMinMax",function(){ur(n)}),e(" removeEdgeLabelProxies",function(){ar(n)}),e(" normalize.run",function(){Qn(n)}),e(" parentDummyChains",function(){Le(n)}),e(" addBorderSegments",function(){Dn(n)}),e(" order",function(){Re(n)}),e(" insertSelfEdges",function(){vr(n)}),e(" adjustCoordinateSystem",function(){An(n)}),e(" position",function(){Je(n)}),e(" positionSelfEdges",function(){lr(n)}),e(" removeBorderNodes",function(){gr(n)}),e(" normalize.undo",function(){Wn(n)}),e(" fixupEdgeLabelCoords",function(){fr(n)}),e(" undoCoordinateSystem",function(){Jn(n)}),e(" translateGraph",function(){dr(n)}),e(" assignNodeIntersects",function(){cr(n)}),e(" reversePoints",function(){sr(n)}),e(" acyclic.undo",function(){Vn(n)})}function Qe(n,e){f(n.nodes(),function(r){var t=n.node(r),o=e.node(r);t&&(t.x=o.x,t.y=o.y,e.children(r).length&&(t.width=o.width,t.height=o.height))}),f(n.edges(),function(r){var t=n.edge(r),o=e.edge(r);t.points=o.points,m(o,"x")&&(t.x=o.x,t.y=o.y)}),n.graph().width=e.graph().width,n.graph().height=e.graph().height}var Ue=["nodesep","edgesep","ranksep","marginx","marginy"],We={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},Xe=["acyclicer","ranker","rankdir","align"],Ze=["width","height"],$e={width:0,height:0},nr=["minlen","weight","width","height","labeloffset"],er={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},rr=["labelpos"];function tr(n){var e=new y({multigraph:!0,compound:!0}),r=j(n.graph());return e.setGraph(z({},We,Y(r,Ue),S(r,Xe))),f(n.nodes(),function(t){var o=j(n.node(t));e.setNode(t,xn(Y(o,Ze),$e)),e.setParent(t,n.parent(t))}),f(n.edges(),function(t){var o=j(n.edge(t));e.setEdge(t,z({},er,Y(o,nr),S(o,rr)))}),e}function or(n){var e=n.graph();e.ranksep/=2,f(n.edges(),function(r){var t=n.edge(r);t.minlen*=2,t.labelpos.toLowerCase()!=="c"&&(e.rankdir==="TB"||e.rankdir==="BT"?t.width+=t.labeloffset:t.height+=t.labeloffset)})}function ir(n){f(n.edges(),function(e){var r=n.edge(e);if(r.width&&r.height){var t=n.node(e.v),o=n.node(e.w),u={rank:(o.rank-t.rank)/2+t.rank,e};I(n,"edge-proxy",u,"_ep")}})}function ur(n){var e=0;f(n.nodes(),function(r){var t=n.node(r);t.borderTop&&(t.minRank=n.node(t.borderTop).rank,t.maxRank=n.node(t.borderBottom).rank,e=x(e,t.maxRank))}),n.graph().maxRank=e}function ar(n){f(n.nodes(),function(e){var r=n.node(e);r.dummy==="edge-proxy"&&(n.edge(r.e).labelRank=r.rank,n.removeNode(e))})}function dr(n){var e=Number.POSITIVE_INFINITY,r=0,t=Number.POSITIVE_INFINITY,o=0,u=n.graph(),i=u.marginx||0,a=u.marginy||0;function d(c){var s=c.x,g=c.y,h=c.width,v=c.height;e=Math.min(e,s-h/2),r=Math.max(r,s+h/2),t=Math.min(t,g-v/2),o=Math.max(o,g+v/2)}f(n.nodes(),function(c){d(n.node(c))}),f(n.edges(),function(c){var s=n.edge(c);m(s,"x")&&d(s)}),e-=i,t-=a,f(n.nodes(),function(c){var s=n.node(c);s.x-=e,s.y-=t}),f(n.edges(),function(c){var s=n.edge(c);f(s.points,function(g){g.x-=e,g.y-=t}),m(s,"x")&&(s.x-=e),m(s,"y")&&(s.y-=t)}),u.width=r-e+i,u.height=o-t+a}function cr(n){f(n.edges(),function(e){var r=n.edge(e),t=n.node(e.v),o=n.node(e.w),u,i;r.points?(u=r.points[0],i=r.points[r.points.length-1]):(r.points=[],u=o,i=t),r.points.unshift(Z(t,u)),r.points.push(Z(o,i))})}function fr(n){f(n.edges(),function(e){var r=n.edge(e);if(m(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 sr(n){f(n.edges(),function(e){var r=n.edge(e);r.reversed&&r.points.reverse()})}function gr(n){f(n.nodes(),function(e){if(n.children(e).length){var r=n.node(e),t=n.node(r.borderTop),o=n.node(r.borderBottom),u=n.node(P(r.borderLeft)),i=n.node(P(r.borderRight));r.width=Math.abs(i.x-u.x),r.height=Math.abs(o.y-t.y),r.x=u.x+r.width/2,r.y=t.y+r.height/2}}),f(n.nodes(),function(e){n.node(e).dummy==="border"&&n.removeNode(e)})}function hr(n){f(n.edges(),function(e){if(e.v===e.w){var r=n.node(e.v);r.selfEdges||(r.selfEdges=[]),r.selfEdges.push({e,label:n.edge(e)}),n.removeEdge(e)}})}function vr(n){var e=O(n);f(e,function(r){var t=0;f(r,function(o,u){var i=n.node(o);i.order=u+t,f(i.selfEdges,function(a){I(n,"selfedge",{width:a.label.width,height:a.label.height,rank:i.rank,order:u+ ++t,e:a.e,label:a.label},"_se")}),delete i.selfEdges})})}function lr(n){f(n.nodes(),function(e){var r=n.node(e);if(r.dummy==="selfedge"){var t=n.node(r.e.v),o=t.x+t.width/2,u=t.y,i=r.x-o,a=t.height/2;n.setEdge(r.e,r.label),n.removeNode(e),r.label.points=[{x:o+2*i/3,y:u-a},{x:o+5*i/6,y:u-a},{x:o+i,y:u},{x:o+5*i/6,y:u+a},{x:o+2*i/3,y:u+a}],r.label.x=r.x,r.label.y=r.y}})}function Y(n,e){return F(S(n,e),Number)}function j(n){var e={};return f(n,function(r,t){e[t.toLowerCase()]=r}),e}export{xr as l};
//# sourceMappingURL=layout-_kSBx-Bz.chunk.mjs.map