UNPKG

code-server

Version:

Run VS Code on a remote server.

5 lines (4 loc) • 36.7 kB
import{a as Ge,b as Ae,c as C,d as ie,e as Fe,f as Q,g as Ve}from"./chunk-TQ233OSW.js";import{A as U,B as ae,C as x,a as De,b as F,c as O,d as Te,e as oe,f as Me,g as X,h as u,i as S,j as W,k as y,l as je,m as Be,n as K,o as D,p as k,q as V,r as L,s as q,t as T,u as Y,v as z,w as N,x as G,y as Xe,z as P}from"./chunk-3JG36FMP.js";import{b as Pe}from"./chunk-3X4WHORZ.js";import{g as te,i as Ce,j as Re}from"./chunk-Q4UTCILM.js";import{a as Oe,c as Se,e as ne}from"./chunk-RS4OOBDL.js";import{b as Ie}from"./chunk-KWINGM6W.js";import"./chunk-XJWARXV4.js";import"./chunk-HBYVLBIR.js";import"./chunk-6XUBHLNE.js";import"./chunk-G2EWPYLQ.js";import"./chunk-OZ4ASJEX.js";import"./chunk-7RYOY7AM.js";import"./chunk-IAAAUKJX.js";import{$ as Ne}from"./chunk-YX6DBKFT.js";import{b as w}from"./chunk-TOKYXDRE.js";import{a as E}from"./chunk-TZZ523SA.js";import"./chunk-3RNHDNP5.js";var Z=class{constructor(){var r={};r._next=r._prev=r,this._sentinel=r}dequeue(){var r=this._sentinel,n=r._prev;if(n!==r)return Ye(n),n}enqueue(r){var n=this._sentinel;r._prev&&r._next&&Ye(r),r._next=n._next,n._next._prev=r,n._next=r,r._prev=n}toString(){for(var r=[],n=this._sentinel,t=n._prev;t!==n;)r.push(JSON.stringify(t,Vr)),t=t._prev;return"["+r.join(", ")+"]"}};function Ye(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Vr(e,r){if(e!=="_next"&&e!=="_prev")return r}var Yr=F(1);function ze(e,r){if(e.nodeCount()<=1)return[];var n=Ur(e,r||Yr),t=zr(n.graph,n.buckets,n.zeroIdx);return O(y(t,function(o){return e.outEdges(o.v,o.w)}))}function zr(e,r,n){for(var t=[],o=r[r.length-1],a=r[0],i;e.nodeCount();){for(;i=a.dequeue();)se(e,r,n,i);for(;i=o.dequeue();)se(e,r,n,i);if(e.nodeCount()){for(var s=r.length-2;s>0;--s)if(i=r[s].dequeue(),i){t=t.concat(se(e,r,n,i,!0));break}}}return t}function se(e,r,n,t,o){var a=o?[]:void 0;return u(e.inEdges(t.v),function(i){var s=e.edge(i),d=e.node(i.v);o&&a.push({v:i.v,w:i.w}),d.out-=s,de(r,n,d)}),u(e.outEdges(t.v),function(i){var s=e.edge(i),d=i.w,f=e.node(d);f.in-=s,de(r,n,f)}),e.removeNode(t.v),a}function Ur(e,r){var n=new x,t=0,o=0;u(e.nodes(),function(s){n.setNode(s,{v:s,in:0,out:0})}),u(e.edges(),function(s){var d=n.edge(s.v,s.w)||0,f=r(s),c=d+f;n.setEdge(s.v,s.w,c),o=Math.max(o,n.node(s.v).out+=f),t=Math.max(t,n.node(s.w).in+=f)});var a=N(o+t+3).map(function(){return new Z}),i=t+1;return u(n.nodes(),function(s){de(a,i,n.node(s))}),{graph:n,buckets:a,zeroIdx:i}}function de(e,r,n){n.out?n.in?e[n.out-n.in+r].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}function Ue(e){var r=e.graph().acyclicer==="greedy"?ze(e,n(e)):Wr(e);u(r,function(t){var o=e.edge(t);e.removeEdge(t),o.forwardName=t.name,o.reversed=!0,e.setEdge(t.w,t.v,o,U("rev"))});function n(t){return function(o){return t.edge(o).weight}}}function Wr(e){var r=[],n={},t={};function o(a){Object.prototype.hasOwnProperty.call(t,a)||(t[a]=!0,n[a]=!0,u(e.outEdges(a),function(i){Object.prototype.hasOwnProperty.call(n,i.w)?r.push(i):o(i.w)}),delete n[a])}return u(e.nodes(),o),r}function We(e){u(e.edges(),function(r){var n=e.edge(r);if(n.reversed){e.removeEdge(r);var t=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(r.w,r.v,n,t)}})}function I(e,r,n,t){var o;do o=U(t);while(e.hasNode(o));return n.dummy=r,e.setNode(o,n),o}function He(e){var r=new x().setGraph(e.graph());return u(e.nodes(),function(n){r.setNode(n,e.node(n))}),u(e.edges(),function(n){var t=r.edge(n.v,n.w)||{weight:0,minlen:1},o=e.edge(n);r.setEdge(n.v,n.w,{weight:t.weight+o.weight,minlen:Math.max(t.minlen,o.minlen)})}),r}function $(e){var r=new x({multigraph:e.isMultigraph()}).setGraph(e.graph());return u(e.nodes(),function(n){e.children(n).length||r.setNode(n,e.node(n))}),u(e.edges(),function(n){r.setEdge(n,e.edge(n))}),r}function fe(e,r){var n=e.x,t=e.y,o=r.x-n,a=r.y-t,i=e.width/2,s=e.height/2;if(!o&&!a)throw new Error("Not possible to find intersection inside of the rectangle");var d,f;return Math.abs(a)*i>Math.abs(o)*s?(a<0&&(s=-s),d=s*o/a,f=s):(o<0&&(i=-i),d=i,f=i*a/o),{x:n+d,y:t+f}}function M(e){var r=y(N(ue(e)+1),function(){return[]});return u(e.nodes(),function(n){var t=e.node(n),o=t.rank;k(o)||(r[o][t.order]=n)}),r}function Je(e){var r=T(y(e.nodes(),function(n){return e.node(n).rank}));u(e.nodes(),function(n){var t=e.node(n);K(t,"rank")&&(t.rank-=r)})}function Ke(e){var r=T(y(e.nodes(),function(a){return e.node(a).rank})),n=[];u(e.nodes(),function(a){var i=e.node(a).rank-r;n[i]||(n[i]=[]),n[i].push(a)});var t=0,o=e.graph().nodeRankFactor;u(n,function(a,i){k(a)&&i%o!==0?--t:t&&u(a,function(s){e.node(s).rank+=t})})}function ce(e,r,n,t){var o={width:0,height:0};return arguments.length>=4&&(o.rank=n,o.order=t),I(e,"border",o,r)}function ue(e){return L(y(e.nodes(),function(r){var n=e.node(r).rank;if(!k(n))return n}))}function Qe(e,r){var n={lhs:[],rhs:[]};return u(e,function(t){r(t)?n.lhs.push(t):n.rhs.push(t)}),n}function Ze(e,r){var n=oe();try{return r()}finally{console.log(e+" time: "+(oe()-n)+"ms")}}function $e(e,r){return r()}function rr(e){function r(n){var t=e.children(n),o=e.node(n);if(t.length&&u(t,r),Object.prototype.hasOwnProperty.call(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(var a=o.minRank,i=o.maxRank+1;a<i;++a)er(e,"borderLeft","_bl",n,o,a),er(e,"borderRight","_br",n,o,a)}}u(e.children(),r)}function er(e,r,n,t,o,a){var i={width:0,height:0,rank:a,borderType:r},s=o[r][a-1],d=I(e,"border",i,n);o[r][a]=d,e.setParent(d,t),s&&e.setEdge(s,d,{weight:1})}function tr(e){var r=e.graph().rankdir.toLowerCase();(r==="lr"||r==="rl")&&ar(e)}function or(e){var r=e.graph().rankdir.toLowerCase();(r==="bt"||r==="rl")&&qr(e),(r==="lr"||r==="rl")&&(Hr(e),ar(e))}function ar(e){u(e.nodes(),function(r){nr(e.node(r))}),u(e.edges(),function(r){nr(e.edge(r))})}function nr(e){var r=e.width;e.width=e.height,e.height=r}function qr(e){u(e.nodes(),function(r){le(e.node(r))}),u(e.edges(),function(r){var n=e.edge(r);u(n.points,le),Object.prototype.hasOwnProperty.call(n,"y")&&le(n)})}function le(e){e.y=-e.y}function Hr(e){u(e.nodes(),function(r){he(e.node(r))}),u(e.edges(),function(r){var n=e.edge(r);u(n.points,he),Object.prototype.hasOwnProperty.call(n,"x")&&he(n)})}function he(e){var r=e.x;e.x=e.y,e.y=r}function ir(e){e.graph().dummyChains=[],u(e.edges(),function(r){Kr(e,r)})}function Kr(e,r){var n=r.v,t=e.node(n).rank,o=r.w,a=e.node(o).rank,i=r.name,s=e.edge(r),d=s.labelRank;if(a!==t+1){e.removeEdge(r);var f=void 0,c,l;for(l=0,++t;t<a;++l,++t)s.points=[],f={width:0,height:0,edgeLabel:s,edgeObj:r,rank:t},c=I(e,"edge",f,"_d"),t===d&&(f.width=s.width,f.height=s.height,f.dummy="edge-label",f.labelpos=s.labelpos),e.setEdge(n,c,{weight:s.weight},i),l===0&&e.graph().dummyChains.push(c),n=c;e.setEdge(n,o,{weight:s.weight},i)}}function sr(e){u(e.graph().dummyChains,function(r){var n=e.node(r),t=n.edgeLabel,o;for(e.setEdge(n.edgeObj,t);n.dummy;)o=e.successors(r)[0],e.removeNode(r),t.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(t.x=n.x,t.y=n.y,t.width=n.width,t.height=n.height),r=o,n=e.node(r)})}function H(e){var r={};function n(t){var o=e.node(t);if(Object.prototype.hasOwnProperty.call(r,t))return o.rank;r[t]=!0;var a=T(y(e.outEdges(t),function(i){return n(i.w)-e.edge(i).minlen}));return(a===Number.POSITIVE_INFINITY||a===void 0||a===null)&&(a=0),o.rank=a}u(e.sources(),n)}function A(e,r){return e.node(r.w).rank-e.node(r.v).rank-e.edge(r).minlen}function ee(e){var r=new x({directed:!1}),n=e.nodes()[0],t=e.nodeCount();r.setNode(n,{});for(var o,a;Qr(r,e)<t;)o=Zr(r,e),a=r.hasNode(o.v)?A(e,o):-A(e,o),$r(r,e,a);return r}function Qr(e,r){function n(t){u(r.nodeEdges(t),function(o){var a=o.v,i=t===a?o.w:a;!e.hasNode(i)&&!A(r,o)&&(e.setNode(i,{}),e.setEdge(t,i,{}),n(i))})}return u(e.nodes(),n),e.nodeCount()}function Zr(e,r){return Y(r.edges(),function(n){if(e.hasNode(n.v)!==e.hasNode(n.w))return A(r,n)})}function $r(e,r,n){u(e.nodes(),function(t){r.node(t).rank+=n})}var Dt=F(1);var At=F(1);pe.CycleException=J;function pe(e){var r={},n={},t=[];function o(a){if(Object.prototype.hasOwnProperty.call(n,a))throw new J;Object.prototype.hasOwnProperty.call(r,a)||(n[a]=!0,r[a]=!0,u(e.predecessors(a),o),delete n[a],t.push(a))}if(u(e.sinks(),o),Xe(r)!==e.nodeCount())throw new J;return t}function J(){}J.prototype=new Error;function re(e,r,n){De(r)||(r=[r]);var t=(e.isDirected()?e.successors:e.neighbors).bind(e),o=[],a={};return u(r,function(i){if(!e.hasNode(i))throw new Error("Graph does not have node: "+i);fr(e,i,n==="post",a,t,o)}),o}function fr(e,r,n,t,o,a){Object.prototype.hasOwnProperty.call(t,r)||(t[r]=!0,n||a.push(r),u(o(r),function(i){fr(e,i,n,t,o,a)}),n&&a.push(r))}function me(e,r){return re(e,r,"post")}function ve(e,r){return re(e,r,"pre")}B.initLowLimValues=_e;B.initCutValues=ge;B.calcCutValue=ur;B.leaveEdge=hr;B.enterEdge=pr;B.exchangeEdges=mr;function B(e){e=He(e),H(e);var r=ee(e);_e(r),ge(r,e);for(var n,t;n=hr(r);)t=pr(r,e,n),mr(r,e,n,t)}function ge(e,r){var n=me(e,e.nodes());n=n.slice(0,n.length-1),u(n,function(t){on(e,r,t)})}function on(e,r,n){var t=e.node(n),o=t.parent;e.edge(n,o).cutvalue=ur(e,r,n)}function ur(e,r,n){var t=e.node(n),o=t.parent,a=!0,i=r.edge(n,o),s=0;return i||(a=!1,i=r.edge(o,n)),s=i.weight,u(r.nodeEdges(n),function(d){var f=d.v===n,c=f?d.w:d.v;if(c!==o){var l=f===a,h=r.edge(d).weight;if(s+=l?h:-h,sn(e,n,c)){var m=e.edge(n,c).cutvalue;s+=l?-m:m}}}),s}function _e(e,r){arguments.length<2&&(r=e.nodes()[0]),lr(e,{},1,r)}function lr(e,r,n,t,o){var a=n,i=e.node(t);return r[t]=!0,u(e.neighbors(t),function(s){Object.prototype.hasOwnProperty.call(r,s)||(n=lr(e,r,n,s,t))}),i.low=a,i.lim=n++,o?i.parent=o:delete i.parent,n}function hr(e){return W(e.edges(),function(r){return e.edge(r).cutvalue<0})}function pr(e,r,n){var t=n.v,o=n.w;r.hasEdge(t,o)||(t=n.w,o=n.v);var a=e.node(t),i=e.node(o),s=a,d=!1;a.lim>i.lim&&(s=i,d=!0);var f=S(r.edges(),function(c){return d===cr(e,e.node(c.v),s)&&d!==cr(e,e.node(c.w),s)});return Y(f,function(c){return A(r,c)})}function mr(e,r,n,t){var o=n.v,a=n.w;e.removeEdge(o,a),e.setEdge(t.v,t.w,{}),_e(e),ge(e,r),an(e,r)}function an(e,r){var n=W(e.nodes(),function(o){return!r.node(o).parent}),t=ve(e,n);t=t.slice(1),u(t,function(o){var a=e.node(o).parent,i=r.edge(o,a),s=!1;i||(i=r.edge(a,o),s=!0),r.node(o).rank=r.node(a).rank+(s?i.minlen:-i.minlen)})}function sn(e,r,n){return e.hasEdge(r,n)}function cr(e,r,n){return n.low<=r.lim&&r.lim<=n.lim}function we(e){switch(e.graph().ranker){case"network-simplex":vr(e);break;case"tight-tree":fn(e);break;case"longest-path":dn(e);break;default:vr(e)}}var dn=H;function fn(e){H(e),ee(e)}function vr(e){B(e)}function gr(e){var r=I(e,"root",{},"_root"),n=cn(e),t=L(D(n))-1,o=2*t+1;e.graph().nestingRoot=r,u(e.edges(),function(i){e.edge(i).minlen*=o});var a=un(e)+1;u(e.children(),function(i){_r(e,r,o,a,t,n,i)}),e.graph().nodeRankFactor=o}function _r(e,r,n,t,o,a,i){var s=e.children(i);if(!s.length){i!==r&&e.setEdge(r,i,{weight:0,minlen:n});return}var d=ce(e,"_bt"),f=ce(e,"_bb"),c=e.node(i);e.setParent(d,i),c.borderTop=d,e.setParent(f,i),c.borderBottom=f,u(s,function(l){_r(e,r,n,t,o,a,l);var h=e.node(l),m=h.borderTop?h.borderTop:l,g=h.borderBottom?h.borderBottom:l,v=h.borderTop?t:2*t,p=m!==g?1:o-a[i]+1;e.setEdge(d,m,{weight:v,minlen:p,nestingEdge:!0}),e.setEdge(g,f,{weight:v,minlen:p,nestingEdge:!0})}),e.parent(i)||e.setEdge(r,d,{weight:0,minlen:o+a[i]})}function cn(e){var r={};function n(t,o){var a=e.children(t);a&&a.length&&u(a,function(i){n(i,o+1)}),r[t]=o}return u(e.children(),function(t){n(t,1)}),r}function un(e){return G(e.edges(),function(r,n){return r+e.edge(n).weight},0)}function wr(e){var r=e.graph();e.removeNode(r.nestingRoot),delete r.nestingRoot,u(e.edges(),function(n){var t=e.edge(n);t.nestingEdge&&e.removeEdge(n)})}function yr(e,r,n){var t={},o;u(n,function(a){for(var i=e.parent(a),s,d;i;){if(s=e.parent(i),s?(d=t[s],t[s]=i):(d=o,o=i),d&&d!==i){r.setEdge(d,i);return}i=s}})}function br(e,r,n){var t=hn(e),o=new x({compound:!0}).setGraph({root:t}).setDefaultNodeLabel(function(a){return e.node(a)});return u(e.nodes(),function(a){var i=e.node(a),s=e.parent(a);(i.rank===r||i.minRank<=r&&r<=i.maxRank)&&(o.setNode(a),o.setParent(a,s||t),u(e[n](a),function(d){var f=d.v===a?d.w:d.v,c=o.edge(f,a),l=k(c)?0:c.weight;o.setEdge(f,a,{weight:e.edge(d).weight+l})}),Object.prototype.hasOwnProperty.call(i,"minRank")&&o.setNode(a,{borderLeft:i.borderLeft[r],borderRight:i.borderRight[r]}))}),o}function hn(e){for(var r;e.hasNode(r=U("_root")););return r}function Er(e,r){for(var n=0,t=1;t<r.length;++t)n+=pn(e,r[t-1],r[t]);return n}function pn(e,r,n){for(var t=ae(n,y(n,function(f,c){return c})),o=O(y(r,function(f){return P(y(e.outEdges(f),function(c){return{pos:t[c.w],weight:e.edge(c).weight}}),"pos")})),a=1;a<n.length;)a<<=1;var i=2*a-1;a-=1;var s=y(new Array(i),function(){return 0}),d=0;return u(o.forEach(function(f){var c=f.pos+a;s[c]+=f.weight;for(var l=0;c>0;)c%2&&(l+=s[c+1]),c=c-1>>1,s[c]+=f.weight;d+=f.weight*l})),d}function xr(e){var r={},n=S(e.nodes(),function(s){return!e.children(s).length}),t=L(y(n,function(s){return e.node(s).rank})),o=y(N(t+1),function(){return[]});function a(s){if(!K(r,s)){r[s]=!0;var d=e.node(s);o[d.rank].push(s),u(e.successors(s),a)}}var i=P(n,function(s){return e.node(s).rank});return u(i,a),o}function kr(e,r){return y(r,function(n){var t=e.inEdges(n);if(t.length){var o=G(t,function(a,i){var s=e.edge(i),d=e.node(i.v);return{sum:a.sum+s.weight*d.order,weight:a.weight+s.weight}},{sum:0,weight:0});return{v:n,barycenter:o.sum/o.weight,weight:o.weight}}else return{v:n}})}function Lr(e,r){var n={};u(e,function(o,a){var i=n[o.v]={indegree:0,in:[],out:[],vs:[o.v],i:a};k(o.barycenter)||(i.barycenter=o.barycenter,i.weight=o.weight)}),u(r.edges(),function(o){var a=n[o.v],i=n[o.w];!k(a)&&!k(i)&&(i.indegree++,a.out.push(n[o.w]))});var t=S(n,function(o){return!o.indegree});return mn(t)}function mn(e){var r=[];function n(a){return function(i){i.merged||(k(i.barycenter)||k(a.barycenter)||i.barycenter>=a.barycenter)&&vn(a,i)}}function t(a){return function(i){i.in.push(a),--i.indegree===0&&e.push(i)}}for(;e.length;){var o=e.pop();r.push(o),u(o.in.reverse(),n(o)),u(o.out,t(o))}return y(S(r,function(a){return!a.merged}),function(a){return z(a,["vs","i","barycenter","weight"])})}function vn(e,r){var n=0,t=0;e.weight&&(n+=e.barycenter*e.weight,t+=e.weight),r.weight&&(n+=r.barycenter*r.weight,t+=r.weight),e.vs=r.vs.concat(e.vs),e.barycenter=n/t,e.weight=t,e.i=Math.min(r.i,e.i),r.merged=!0}function Ir(e,r){var n=Qe(e,function(c){return Object.prototype.hasOwnProperty.call(c,"barycenter")}),t=n.lhs,o=P(n.rhs,function(c){return-c.i}),a=[],i=0,s=0,d=0;t.sort(gn(!!r)),d=Nr(a,o,d),u(t,function(c){d+=c.vs.length,a.push(c.vs),i+=c.barycenter*c.weight,s+=c.weight,d=Nr(a,o,d)});var f={vs:O(a)};return s&&(f.barycenter=i/s,f.weight=s),f}function Nr(e,r,n){for(var t;r.length&&(t=X(r)).i<=n;)r.pop(),e.push(t.vs),n++;return n}function gn(e){return function(r,n){return r.barycenter<n.barycenter?-1:r.barycenter>n.barycenter?1:e?n.i-r.i:r.i-n.i}}function ye(e,r,n,t){var o=e.children(r),a=e.node(r),i=a?a.borderLeft:void 0,s=a?a.borderRight:void 0,d={};i&&(o=S(o,function(g){return g!==i&&g!==s}));var f=kr(e,o);u(f,function(g){if(e.children(g.v).length){var v=ye(e,g.v,n,t);d[g.v]=v,Object.prototype.hasOwnProperty.call(v,"barycenter")&&wn(g,v)}});var c=Lr(f,n);_n(c,d);var l=Ir(c,t);if(i&&(l.vs=O([i,l.vs,s]),e.predecessors(i).length)){var h=e.node(e.predecessors(i)[0]),m=e.node(e.predecessors(s)[0]);Object.prototype.hasOwnProperty.call(l,"barycenter")||(l.barycenter=0,l.weight=0),l.barycenter=(l.barycenter*l.weight+h.order+m.order)/(l.weight+2),l.weight+=2}return l}function _n(e,r){u(e,function(n){n.vs=O(n.vs.map(function(t){return r[t]?r[t].vs:t}))})}function wn(e,r){k(e.barycenter)?(e.barycenter=r.barycenter,e.weight=r.weight):(e.barycenter=(e.barycenter*e.weight+r.barycenter*r.weight)/(e.weight+r.weight),e.weight+=r.weight)}function Pr(e){var r=ue(e),n=Or(e,N(1,r+1),"inEdges"),t=Or(e,N(r-1,-1,-1),"outEdges"),o=xr(e);Sr(e,o);for(var a=Number.POSITIVE_INFINITY,i,s=0,d=0;d<4;++s,++d){yn(s%2?n:t,s%4>=2),o=M(e);var f=Er(e,o);f<a&&(d=0,i=Te(o),a=f)}Sr(e,i)}function Or(e,r,n){return y(r,function(t){return br(e,t,n)})}function yn(e,r){var n=new x;u(e,function(t){var o=t.graph().root,a=ye(t,o,n,r);u(a.vs,function(i,s){t.node(i).order=s}),yr(t,n,a.vs)})}function Sr(e,r){u(r,function(n){u(n,function(t,o){e.node(t).order=o})})}function Cr(e){var r=En(e);u(e.graph().dummyChains,function(n){for(var t=e.node(n),o=t.edgeObj,a=bn(e,r,o.v,o.w),i=a.path,s=a.lca,d=0,f=i[d],c=!0;n!==o.w;){if(t=e.node(n),c){for(;(f=i[d])!==s&&e.node(f).maxRank<t.rank;)d++;f===s&&(c=!1)}if(!c){for(;d<i.length-1&&e.node(f=i[d+1]).minRank<=t.rank;)d++;f=i[d]}e.setParent(n,f),n=e.successors(n)[0]}})}function bn(e,r,n,t){var o=[],a=[],i=Math.min(r[n].low,r[t].low),s=Math.max(r[n].lim,r[t].lim),d,f;d=n;do d=e.parent(d),o.push(d);while(d&&(r[d].low>i||s>r[d].lim));for(f=d,d=t;(d=e.parent(d))!==f;)a.push(d);return{path:o.concat(a.reverse()),lca:f}}function En(e){var r={},n=0;function t(o){var a=n;u(e.children(o),t),r[o]={low:a,lim:n++}}return u(e.children(),t),r}function xn(e,r){var n={};function t(o,a){var i=0,s=0,d=o.length,f=X(a);return u(a,function(c,l){var h=Ln(e,c),m=h?e.node(h).order:d;(h||c===f)&&(u(a.slice(s,l+1),function(g){u(e.predecessors(g),function(v){var p=e.node(v),_=p.order;(_<i||m<_)&&!(p.dummy&&e.node(g).dummy)&&Rr(n,v,g)})}),s=l+1,i=m)}),a}return G(r,t),n}function kn(e,r){var n={};function t(a,i,s,d,f){var c;u(N(i,s),function(l){c=a[l],e.node(c).dummy&&u(e.predecessors(c),function(h){var m=e.node(h);m.dummy&&(m.order<d||m.order>f)&&Rr(n,h,c)})})}function o(a,i){var s=-1,d,f=0;return u(i,function(c,l){if(e.node(c).dummy==="border"){var h=e.predecessors(c);h.length&&(d=e.node(h[0]).order,t(i,f,l,s,d),f=l,s=d)}t(i,f,i.length,d,a.length)}),i}return G(r,o),n}function Ln(e,r){if(e.node(r).dummy)return W(e.predecessors(r),function(n){return e.node(n).dummy})}function Rr(e,r,n){if(r>n){var t=r;r=n,n=t}Object.prototype.hasOwnProperty.call(e,r)||Object.defineProperty(e,r,{enumerable:!0,configurable:!0,value:{},writable:!0});var o=e[r];Object.defineProperty(o,n,{enumerable:!0,configurable:!0,value:!0,writable:!0})}function Nn(e,r,n){if(r>n){var t=r;r=n,n=t}return!!e[r]&&Object.prototype.hasOwnProperty.call(e[r],n)}function In(e,r,n,t){var o={},a={},i={};return u(r,function(s){u(s,function(d,f){o[d]=d,a[d]=d,i[d]=f})}),u(r,function(s){var d=-1;u(s,function(f){var c=t(f);if(c.length){c=P(c,function(v){return i[v]});for(var l=(c.length-1)/2,h=Math.floor(l),m=Math.ceil(l);h<=m;++h){var g=c[h];a[f]===f&&d<i[g]&&!Nn(n,f,g)&&(a[g]=f,a[f]=o[f]=o[g],d=i[g])}}})}),{root:o,align:a}}function On(e,r,n,t,o){var a={},i=Sn(e,r,n,o),s=o?"borderLeft":"borderRight";function d(l,h){for(var m=i.nodes(),g=m.pop(),v={};g;)v[g]?l(g):(v[g]=!0,m.push(g),m=m.concat(h(g))),g=m.pop()}function f(l){a[l]=i.inEdges(l).reduce(function(h,m){return Math.max(h,a[m.v]+i.edge(m))},0)}function c(l){var h=i.outEdges(l).reduce(function(g,v){return Math.min(g,a[v.w]-i.edge(v))},Number.POSITIVE_INFINITY),m=e.node(l);h!==Number.POSITIVE_INFINITY&&m.borderType!==s&&(a[l]=Math.max(a[l],h))}return d(f,i.predecessors.bind(i)),d(c,i.successors.bind(i)),u(t,function(l){a[l]=a[n[l]]}),a}function Sn(e,r,n,t){var o=new x,a=e.graph(),i=Dn(a.nodesep,a.edgesep,t);return u(r,function(s){var d;u(s,function(f){var c=n[f];if(o.setNode(c),d){var l=n[d],h=o.edge(l,c);o.setEdge(l,c,Math.max(i(e,f,d),h||0))}d=f})}),o}function Pn(e,r){return Y(D(r),function(n){var t=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;return je(n,function(a,i){var s=Tn(e,i)/2;t=Math.max(a+s,t),o=Math.min(a-s,o)}),t-o})}function Cn(e,r){var n=D(r),t=T(n),o=L(n);u(["u","d"],function(a){u(["l","r"],function(i){var s=a+i,d=e[s],f;if(d!==r){var c=D(d);f=i==="l"?t-T(c):o-L(c),f&&(e[s]=V(d,function(l){return l+f}))}})})}function Rn(e,r){return V(e.ul,function(n,t){if(r)return e[r.toLowerCase()][t];var o=P(y(e,t));return(o[1]+o[2])/2})}function Dr(e){var r=M(e),n=q(xn(e,r),kn(e,r)),t={},o;u(["u","d"],function(i){o=i==="u"?r:D(r).reverse(),u(["l","r"],function(s){s==="r"&&(o=y(o,function(l){return D(l).reverse()}));var d=(i==="u"?e.predecessors:e.successors).bind(e),f=In(e,o,n,d),c=On(e,o,f.root,f.align,s==="r");s==="r"&&(c=V(c,function(l){return-l})),t[i+s]=c})});var a=Pn(e,t);return Cn(t,a),Rn(t,e.graph().align)}function Dn(e,r,n){return function(t,o,a){var i=t.node(o),s=t.node(a),d=0,f;if(d+=i.width/2,Object.prototype.hasOwnProperty.call(i,"labelpos"))switch(i.labelpos.toLowerCase()){case"l":f=-i.width/2;break;case"r":f=i.width/2;break}if(f&&(d+=n?f:-f),f=0,d+=(i.dummy?r:e)/2,d+=(s.dummy?r:e)/2,d+=s.width/2,Object.prototype.hasOwnProperty.call(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":f=s.width/2;break;case"r":f=-s.width/2;break}return f&&(d+=n?f:-f),f=0,d}}function Tn(e,r){return e.node(r).width}function Tr(e){e=$(e),Mn(e),Be(Dr(e),function(r,n){e.node(n).x=r})}function Mn(e){var r=M(e),n=e.graph().ranksep,t=0;u(r,function(o){var a=L(y(o,function(i){return e.node(i).height}));u(o,function(i){e.node(i).y=t+a/2}),t+=a+n})}function xe(e,r){var n=r&&r.debugTiming?Ze:$e;n("layout",()=>{var t=n(" buildLayoutGraph",()=>Wn(e));n(" runLayout",()=>jn(t,n)),n(" updateInputGraph",()=>Bn(e,t))})}function jn(e,r){r(" makeSpaceForEdgeLabels",()=>qn(e)),r(" removeSelfEdges",()=>nt(e)),r(" acyclic",()=>Ue(e)),r(" nestingGraph.run",()=>gr(e)),r(" rank",()=>we($(e))),r(" injectEdgeLabelProxies",()=>Hn(e)),r(" removeEmptyRanks",()=>Ke(e)),r(" nestingGraph.cleanup",()=>wr(e)),r(" normalizeRanks",()=>Je(e)),r(" assignRankMinMax",()=>Jn(e)),r(" removeEdgeLabelProxies",()=>Kn(e)),r(" normalize.run",()=>ir(e)),r(" parentDummyChains",()=>Cr(e)),r(" addBorderSegments",()=>rr(e)),r(" order",()=>Pr(e)),r(" insertSelfEdges",()=>tt(e)),r(" adjustCoordinateSystem",()=>tr(e)),r(" position",()=>Tr(e)),r(" positionSelfEdges",()=>ot(e)),r(" removeBorderNodes",()=>rt(e)),r(" normalize.undo",()=>sr(e)),r(" fixupEdgeLabelCoords",()=>$n(e)),r(" undoCoordinateSystem",()=>or(e)),r(" translateGraph",()=>Qn(e)),r(" assignNodeIntersects",()=>Zn(e)),r(" reversePoints",()=>et(e)),r(" acyclic.undo",()=>We(e))}function Bn(e,r){u(e.nodes(),function(n){var t=e.node(n),o=r.node(n);t&&(t.x=o.x,t.y=o.y,r.children(n).length&&(t.width=o.width,t.height=o.height))}),u(e.edges(),function(n){var t=e.edge(n),o=r.edge(n);t.points=o.points,Object.prototype.hasOwnProperty.call(o,"x")&&(t.x=o.x,t.y=o.y)}),e.graph().width=r.graph().width,e.graph().height=r.graph().height}var Xn=["nodesep","edgesep","ranksep","marginx","marginy"],Gn={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},An=["acyclicer","ranker","rankdir","align"],Fn=["width","height"],Vn={width:0,height:0},Yn=["minlen","weight","width","height","labeloffset"],zn={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Un=["labelpos"];function Wn(e){var r=new x({multigraph:!0,compound:!0}),n=Ee(e.graph());return r.setGraph(q({},Gn,be(n,Xn),z(n,An))),u(e.nodes(),function(t){var o=Ee(e.node(t));r.setNode(t,Me(be(o,Fn),Vn)),r.setParent(t,e.parent(t))}),u(e.edges(),function(t){var o=Ee(e.edge(t));r.setEdge(t,q({},zn,be(o,Yn),z(o,Un)))}),r}function qn(e){var r=e.graph();r.ranksep/=2,u(e.edges(),function(n){var t=e.edge(n);t.minlen*=2,t.labelpos.toLowerCase()!=="c"&&(r.rankdir==="TB"||r.rankdir==="BT"?t.width+=t.labeloffset:t.height+=t.labeloffset)})}function Hn(e){u(e.edges(),function(r){var n=e.edge(r);if(n.width&&n.height){var t=e.node(r.v),o=e.node(r.w),a={rank:(o.rank-t.rank)/2+t.rank,e:r};I(e,"edge-proxy",a,"_ep")}})}function Jn(e){var r=0;u(e.nodes(),function(n){var t=e.node(n);t.borderTop&&(t.minRank=e.node(t.borderTop).rank,t.maxRank=e.node(t.borderBottom).rank,r=L(r,t.maxRank))}),e.graph().maxRank=r}function Kn(e){u(e.nodes(),function(r){var n=e.node(r);n.dummy==="edge-proxy"&&(e.edge(n.e).labelRank=n.rank,e.removeNode(r))})}function Qn(e){var r=Number.POSITIVE_INFINITY,n=0,t=Number.POSITIVE_INFINITY,o=0,a=e.graph(),i=a.marginx||0,s=a.marginy||0;function d(f){var c=f.x,l=f.y,h=f.width,m=f.height;r=Math.min(r,c-h/2),n=Math.max(n,c+h/2),t=Math.min(t,l-m/2),o=Math.max(o,l+m/2)}u(e.nodes(),function(f){d(e.node(f))}),u(e.edges(),function(f){var c=e.edge(f);Object.prototype.hasOwnProperty.call(c,"x")&&d(c)}),r-=i,t-=s,u(e.nodes(),function(f){var c=e.node(f);c.x-=r,c.y-=t}),u(e.edges(),function(f){var c=e.edge(f);u(c.points,function(l){l.x-=r,l.y-=t}),Object.prototype.hasOwnProperty.call(c,"x")&&(c.x-=r),Object.prototype.hasOwnProperty.call(c,"y")&&(c.y-=t)}),a.width=n-r+i,a.height=o-t+s}function Zn(e){u(e.edges(),function(r){var n=e.edge(r),t=e.node(r.v),o=e.node(r.w),a,i;n.points?(a=n.points[0],i=n.points[n.points.length-1]):(n.points=[],a=o,i=t),n.points.unshift(fe(t,a)),n.points.push(fe(o,i))})}function $n(e){u(e.edges(),function(r){var n=e.edge(r);if(Object.prototype.hasOwnProperty.call(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function et(e){u(e.edges(),function(r){var n=e.edge(r);n.reversed&&n.points.reverse()})}function rt(e){u(e.nodes(),function(r){if(e.children(r).length){var n=e.node(r),t=e.node(n.borderTop),o=e.node(n.borderBottom),a=e.node(X(n.borderLeft)),i=e.node(X(n.borderRight));n.width=Math.abs(i.x-a.x),n.height=Math.abs(o.y-t.y),n.x=a.x+n.width/2,n.y=t.y+n.height/2}}),u(e.nodes(),function(r){e.node(r).dummy==="border"&&e.removeNode(r)})}function nt(e){u(e.edges(),function(r){if(r.v===r.w){var n=e.node(r.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:r,label:e.edge(r)}),e.removeEdge(r)}})}function tt(e){var r=M(e);u(r,function(n){var t=0;u(n,function(o,a){var i=e.node(o);i.order=a+t,u(i.selfEdges,function(s){I(e,"selfedge",{width:s.label.width,height:s.label.height,rank:i.rank,order:a+ ++t,e:s.e,label:s.label},"_se")}),delete i.selfEdges})})}function ot(e){u(e.nodes(),function(r){var n=e.node(r);if(n.dummy==="selfedge"){var t=e.node(n.e.v),o=t.x+t.width/2,a=t.y,i=n.x-o,s=t.height/2;e.setEdge(n.e,n.label),e.removeNode(r),n.label.points=[{x:o+2*i/3,y:a-s},{x:o+5*i/6,y:a-s},{x:o+i,y:a},{x:o+5*i/6,y:a+s},{x:o+2*i/3,y:a+s}],n.label.x=n.x,n.label.y=n.y}})}function be(e,r){return V(z(e,r),Number)}function Ee(e){var r={};return u(e,function(n,t){r[t.toLowerCase()]=n}),r}var Mr=E((e,r,n)=>Math.max(r,Math.min(n,e)),"clamp"),jr=E((e="TB")=>{switch(e){case"BT":return"bottom";case"LR":return"right";case"RL":return"left";default:return"top"}},"getDefaultSelfLoopSide"),at=E(e=>e==="flowchart"||e==="flowchart-v2"||e==="stateDiagram"||e==="er"||e==="classDiagram","shouldMergeSelfLoopSegments"),it=["x","y","width","height","labelBBox","intersect","calcIntersect","diff","clusterNode"],st=E((e,r,n,t,o)=>{let a=[],i=new Set;if(n.forEach(({start:c,end:l})=>{c!==t&&i.add(c),l!==t&&i.add(l)}),i.forEach(c=>{let l=e.node(c);typeof l?.x=="number"&&typeof l?.y=="number"&&a.push(l)}),a.length===0&&n.forEach(({edge:c})=>{(c.points??[]).forEach(l=>{typeof l?.x=="number"&&typeof l?.y=="number"&&a.push(l)})}),a.length===0)return jr(o);let s=a.reduce((c,l)=>({x:c.x+l.x/a.length,y:c.y+l.y/a.length}),{x:0,y:0}),d=s.x-r.x,f=s.y-r.y;return Math.abs(d)>Math.abs(f)?d>0?"right":"left":Math.abs(f)>0?f>0?"bottom":"top":jr(o)},"getSelfLoopSide"),dt=E((e,r="top",n=0,t=0)=>{let o=e.x,a=e.y-n,i=e.width/2,s=e.height/2,d=Math.max(36,Math.min(100,e.width*.8)),f=Mr(Math.max(t,e.width*.35),36,d),c=Mr(Math.min(e.width,e.height)*.45,24,48);switch(r){case"bottom":{let l=a+s;return[{x:o-f/2,y:l},{x:o-f/2,y:l+c},{x:o+f/2,y:l+c},{x:o+f/2,y:l}]}case"right":{let l=o+i;return[{x:l,y:a-f/2},{x:l+c,y:a-f/2},{x:l+c,y:a+f/2},{x:l,y:a+f/2}]}case"left":{let l=o-i;return[{x:l,y:a-f/2},{x:l-c,y:a-f/2},{x:l-c,y:a+f/2},{x:l,y:a+f/2}]}default:{let l=a-s;return[{x:o-f/2,y:l},{x:o-f/2,y:l-c},{x:o+f/2,y:l-c},{x:o+f/2,y:l}]}}},"getSelfLoopPoints"),ft=E((e,r,n="top",t=0,o={})=>{let i=e.x,s=e.y-t,d=o.width??0,f=o.height??0;switch(n){case"bottom":return{x:i,y:Math.max(...r.map(c=>c.y))+f/2+4};case"right":return{x:Math.max(...r.map(c=>c.x))+d/2+4,y:s};case"left":return{x:Math.min(...r.map(c=>c.x))-d/2-4,y:s};default:return{x:i,y:Math.min(...r.map(c=>c.y))-f/2-4}}},"getSelfLoopLabelPosition"),Xr=E((e,r=0,{mergeSelfLoops:n=!0}={})=>{let t=new Map,o=[],a=e.graph()?.rankdir;return e.edges().forEach(i=>{let s=e.edge(i);if(n&&s.selfLoop){let d=s.selfLoop.id;t.has(d)||t.set(d,[]),t.get(d).push({edge:s,start:i.v,end:i.w})}else o.push({edge:s,start:i.v,end:i.w})}),t.forEach(i=>{if(i.length!==3){i.forEach(_=>o.push(_));return}i.sort((_,R)=>_.edge.selfLoop.order-R.edge.selfLoop.order);let[s,d,f]=i,c=s.edge.originalEdge??d.edge.originalEdge??f.edge.originalEdge??d.edge,l=e.node(c.start);if(!l){i.forEach(_=>o.push(_));return}let h={width:d.edge.width,height:d.edge.height},m=st(e,l,i,c.start,a),g=dt(l,m,r,h.width??0),v=ft(l,g,m,r,h),p={...d.edge,...c,id:c.id,points:g,start:c.start,end:c.end,x:v.x,y:v.y,width:h.width,height:h.height,labelStyle:d.edge.labelStyle,fromCluster:s.edge.fromCluster??d.edge.fromCluster??f.edge.fromCluster,toCluster:s.edge.toCluster??d.edge.toCluster??f.edge.toCluster};delete p.selfLoop,delete p.originalEdge,o.push({edge:p,start:p.start,end:p.end})}),o},"getEdgesToRender"),Gr=E(async({element:e,graph:r,diagramType:n,id:t,parentCluster:o,siteConfig:a})=>{let i=r.graph().rankdir;w.trace("Dir in recursive render - dir:",i);let{clusters:s,edgePaths:d,edgeLabels:f,nodes:c,rootGroups:l}=Ge(e,{edgePathsClass:"edgePaths"});r.nodes()?w.info("Recursive render XXX",r.nodes()):w.info("No nodes found for",r),r.edges().length>0&&w.info("Recursive edges",r.edge(r.edges()[0]));let h=at(n);await Promise.all(r.nodes().map(async function(v){let p=r.node(v);if(o!==void 0){let _=JSON.parse(JSON.stringify(o.clusterData));w.trace(`Setting data for parent cluster XXX Node.id = `,v,` data=`,_.height,` Parent cluster`,o.height),r.setNode(o.id,_),r.parent(v)||(w.trace("Setting parent",v,o.id),r.setParent(v,o.id,_))}if(w.info("(Insert) Node XXX"+v+": "+JSON.stringify(r.node(v))),p?.clusterNode){w.info("Cluster identified XBX",v,p.width,r.node(v));let{ranksep:_,nodesep:R}=r.graph();p.graph.setGraph({...p.graph.graph(),ranksep:_+25,nodesep:R});let ke=await pt({element:c,graph:p.graph,diagramType:n,id:t,parentCluster:r.node(v),siteConfig:a}),Le=ke.elem;Ie(p,Le),p.diff=ke.diff||0,w.info("New compound node after recursive render XAX",v,"width",p.width,"height",p.height),Se(Le,p)}else r.children(v).length>0?(w.trace("Cluster - the non recursive path XBX",v,p.id,p,p.width,"Graph:",r),w.trace(ie(p.id,r)),C.set(p.id,{id:ie(p.id,r),node:p})):(w.trace("Node - the non recursive path XAX",v,c,r.node(v),i),await Ae(c,r.node(v),{config:a,dir:i}))})),await E(async()=>{let v=r.edges().map(async function(p){let _=r.edge(p.v,p.w,p.name);if(w.info("Edge "+p.v+" -> "+p.w+": "+JSON.stringify(p)),w.info("Edge "+p.v+" -> "+p.w+": ",p," ",JSON.stringify(r.edge(p))),w.info("Fix",C,"ids:",p.v,p.w,"Translating: ",C.get(p.v),C.get(p.w)),h&&_.selfLoop){if(_.selfLoop.order!==1)return;let R={..._.originalEdge,..._,id:_.selfLoop.id,startLabelLeft:_.originalEdge?.startLabelLeft??_.startLabelLeft,startLabelRight:_.originalEdge?.startLabelRight??_.startLabelRight,endLabelLeft:_.originalEdge?.endLabelLeft??_.endLabelLeft,endLabelRight:_.originalEdge?.endLabelRight??_.endLabelRight};await te(f,R),_.width=R.width,_.height=R.height,_.labelStyle=R.labelStyle;return}await te(f,_)});await Promise.all(v)},"processEdges")();let{subGraphTitleTotalMargin:g}=Oe(a);return{elem:l,graph:r,groups:{clusters:s,edgePaths:d,edgeLabels:f,nodes:c,rootGroups:l},diagramType:n,id:t,mergeSelfLoops:h,subGraphTitleTotalMargin:g}},"measureDagreGraph"),Ar=E(e=>{w.info("############################################# XXX"),w.info("### Layout ### XXX"),w.info("############################################# XXX"),xe(e)},"runDagreGraphLayout"),ct=E((e,r,n)=>{let t=e.node(r);if(!t)return;let o={...t};return t?.clusterNode?o.y=(t.y??0)+n:e.children(r).length>0?o.height=(t.height??0)+n:o.y=(t.y??0)+n/2,o},"normalizeDagreNode"),Br=E((e,r)=>{it.forEach(n=>{r[n]!==void 0&&(e[n]=r[n])})},"applyDagreNodeLayout"),ut=E((e,r,n,t)=>({...e,start:e.start??r,end:e.end??n,points:(e.points??[]).map(o=>({...o,y:typeof o.y=="number"?o.y+t:o.y}))}),"normalizeDagreEdge"),lt=E((e,r)=>{let{graph:n,mergeSelfLoops:t,subGraphTitleTotalMargin:o=0}=r,a=new Map(e.nodes.map(s=>[s.id,s]));Q(n).forEach(s=>{let d=ct(n,s,o);if(!d)return;Br(n.node(s),d);let f=a.get(s);f&&Br(f,d)});let i=o/2;return e.edges=Xr(n,i,{mergeSelfLoops:t}).map(({edge:s,start:d,end:f})=>ut(s,d,f,i)),e},"applyDagreLayoutResult"),ht=E(async({elem:e,graph:r,groups:{clusters:n,edgePaths:t},diagramType:o,id:a,mergeSelfLoops:i,subGraphTitleTotalMargin:s})=>{let d=0;await Promise.all(Q(r).map(async function(l){let h=r.node(l);if(w.info("Position XBX => "+l+": ("+h.x,","+h.y,") width: ",h.width," height: ",h.height),h?.clusterNode)h.y+=s,w.info("A tainted cluster node XBX1",l,h.id,h.width,h.height,h.x,h.y,r.parent(l)),C.get(h.id).node=h,ne(h);else if(r.children(l).length>0){w.info("A pure cluster node XBX1",l,h.id,h.x,h.y,h.width,h.height,r.parent(l)),h.height+=s,r.node(h.parentId);let m=h?.padding/2||0,g=h?.labelBBox?.height||0,v=g-m||0;w.debug("OffsetY",v,"labelHeight",g,"halfPadding",m),await Pe(n,h),C.get(h.id).node=h}else{let m=r.node(h.parentId);h.y+=s/2,w.info("A regular node XBX1 - using the padding",h.id,"parent",h.parentId,h.width,h.height,h.x,h.y,"offsetY",h.offsetY,"parent",m,m?.offsetY,h),ne(h)}}));let f=s/2;return Xr(r,f,{mergeSelfLoops:i}).forEach(function({edge:l,start:h,end:m}){w.info("Edge "+h+" -> "+m+": "+JSON.stringify(l),l),l.points.forEach(_=>_.y+=f);let g=r.node(h),v=r.node(m),p=Re(t,l,C,o,g,v,a);Ce(l,p)}),r.nodes().forEach(function(l){let h=r.node(l);w.info(l,h.type,h.diff),h.isGroup&&(d=h.diff)}),w.warn("Returning from recursive render XAX",e,d),{elem:e,diff:d}},"paintDagreLayoutCore"),pt=E(async e=>{let r=await Gr(e);return Ar(r.graph),await ht(r)},"renderDagreSubgraph"),Fr=E(e=>{let r=new x({multigraph:!0,compound:!0}).setGraph({rankdir:e.direction,nodesep:e.config?.nodeSpacing||e.nodeSpacing||e.config?.flowchart?.nodeSpacing,ranksep:e.config?.rankSpacing||e.rankSpacing||e.config?.flowchart?.rankSpacing,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});return e.nodes.forEach(n=>{r.setNode(n.id,{...n}),n.parentId&&r.setParent(n.id,n.parentId)}),w.debug("Edges:",e.edges),e.edges.forEach(n=>{if(n.start===n.end){let t=n.start,o=t+"---"+t+"---1",a=t+"---"+t+"---2",i=r.node(t);r.setNode(o,{domId:o,id:o,parentId:i.parentId,labelStyle:"",label:"",padding:0,shape:"labelRect",style:"",width:10,height:10}),r.setParent(o,i.parentId),r.setNode(a,{domId:a,id:a,parentId:i.parentId,labelStyle:"",padding:0,shape:"labelRect",label:"",style:"",width:10,height:10}),r.setParent(a,i.parentId);let s=structuredClone(n),d=structuredClone(n),f=structuredClone(n),c=structuredClone(n);d.originalEdge=s,d.selfLoop={id:s.id,order:0},f.originalEdge=s,f.selfLoop={id:s.id,order:1},c.originalEdge=s,c.selfLoop={id:s.id,order:2},d.label="",d.arrowTypeEnd="none",d.endLabelLeft="",d.endLabelRight="",d.startLabelLeft="",d.id=t+"-cyclic-special-1",f.startLabelRight="",f.startLabelLeft="",f.endLabelLeft="",f.endLabelRight="",f.arrowTypeStart="none",f.arrowTypeEnd="none",f.id=t+"-cyclic-special-mid",c.label="",c.startLabelRight="",c.startLabelLeft="",c.arrowTypeStart="none",i.isGroup&&(d.fromCluster=t,c.toCluster=t),c.id=t+"-cyclic-special-2",c.arrowTypeStart="none",r.setEdge(t,o,d,t+"-cyclic-special-0"),r.setEdge(o,a,f,t+"-cyclic-special-1"),r.setEdge(a,t,c,t+"-cyclic-special-2")}else r.setEdge(n.start,n.end,{...n},n.id)}),Fe(r),{graph:r}},"prepareLayoutForDagre"),mt=E(async(e,{element:r,preparedLayout:n})=>{let t=n??Fr(e),o=Ne(),a=await Gr({element:r,graph:t.graph,diagramType:e.type,id:e.diagramId,parentCluster:void 0,siteConfig:o});return t.measuredLayout=a,a},"measureDagreLayout"),vt=E((e,r)=>{let n=r.preparedLayout?.measuredLayout;if(!n)throw new Error("runDagreLayoutCore requires measureDagreLayout to run first");return Ar(n.graph),lt(e,n),n},"runDagreLayoutCore"),gt=E((e,{measure:r})=>Q(r.graph).map(n=>r.graph.node(n)).filter(Boolean),"getDagrePaintNodes"),_t=E((e,r,{measure:n})=>e?n.graph.node(e):void 0,"getDagreEdgeNode"),ya=Ve({prepareLayout:Fr,measureLayout:mt,runLayoutCore:vt,paintOptions:{clusterDb:C,getNodes:gt,getEdgeNode:_t,skipNode:E((e,{measure:r})=>!r.graph.hasNode(e.id),"skipNode"),isCluster:E((e,{measure:r})=>r.graph.hasNode(e.id)&&(r.graph.children(e.id)??[]).length>0,"isCluster")}});export{lt as applyDagreLayoutResult,Xr as getEdgesToRender,mt as measureDagreLayout,Fr as prepareLayoutForDagre,ya as render,vt as runDagreLayoutCore};