1import{m as tt,c as et,a as nt,u as it,s as st,i as at,b as rt,p as G,d as lt,e as ot,f as F,g as R}from"./chunk-REEJFE46.BrF_TFuK.js";import{c as ct,a as M,s as dt}from"./chunk-NGC4727B.Di2OO6_-.js";import{_ as h,l as s,d as m,j as T,u as ft,Q as ut,R as $,S as H,T as W,v as ht,e as z,U as J,V as B,W as gt}from"./mermaid.core.gEBT5xeO.js";import{G as V}from"./graph.Bfn-Vfwd.js";import{l as wt}from"./layout.DPeAd9XO.js";import{w as x}from"./json.fOGw0emO.js";import"./hoisted.BLcgdF5b.js";import"./_baseUniq.DhndXXgO.js";import"./_basePickBy.CKyYS4vK.js";import"./clone.CHcse0tZ.js";var f={},p={},q={},yt=h(()=>{p={},q={},f={}},"clear"),L=h((e,t)=>(s.trace("In isDescendant",t," ",e," = ",p[t].includes(e)),!!p[t].includes(e)),"isDescendant"),bt=h((e,t)=>(s.info("Descendants of ",t," is ",p[t]),s.info("Edge is ",e),e.v===t||e.w===t?!1:p[t]?p[t].includes(e.v)||L(e.v,t)||L(e.w,t)||p[t].includes(e.w):(s.debug("Tilt, ",t,",not in descendants"),!1)),"edgeInCluster"),Q=h((e,t,n,r)=>{s.warn("Copying children of ",e,"root",r,"data",t.node(e),r);const i=t.children(e)||[];e!==r&&i.push(e),s.warn("Copying (nodes) clusterId",e,"nodes",i),i.forEach(a=>{if(t.children(a).length>0)Q(a,t,n,r);else{const c=t.node(a);s.info("cp ",a," to ",r," with parent ",e),n.setNode(a,c),r!==t.parent(a)&&(s.warn("Setting parent",a,t.parent(a)),n.setParent(a,t.parent(a))),e!==r&&a!==e?(s.debug("Setting parent",a,e),n.setParent(a,e)):(s.info("In copy ",e,"root",r,"data",t.node(e),r),s.debug("Not Setting parent for node=",a,"cluster!==rootId",e!==r,"node!==clusterId",a!==e));const u=t.edges(a);s.debug("Copying Edges",u),u.forEach(d=>{s.info("Edge",d);const g=t.edge(d.v,d.w,d.name);s.info("Edge data",g,r);try{bt(d,r)?(s.info("Copying as ",d.v,d.w,g,d.name),n.setEdge(d.v,d.w,g,d.name),s.info("newGraph edges ",n.edges(),n.edge(n.edges()[0]))):s.info("Skipping copy of edge ",d.v,"-->",d.w," rootId: ",r," clusterId:",e)}catch(y){s.error(y)}})}s.debug("Removing node",a),t.removeNode(a)})},"copy"),U=h((e,t)=>{const n=t.children(e);let r=[...n];for(const i of n)q[i]=e,r=[...r,...U(i,t)];return r},"extractDescendants"),k=h((e,t)=>{s.trace("Searching",e);const n=t.children(e);if(s.trace("Searching children of id ",e,n),n.length<1)return s.trace("This is a valid node",e),e;for(const r of n){const i=k(r,t);if(i)return s.trace("Found replacement for",e," => ",i),i}},"findNonClusterChild"),X=h(e=>!f[e]||!f[e].externalConnections?e:f[e]?f[e].id:e,"getAnchorId"),mt=h((e,t)=>{if(!e||t>10){s.debug("Opting out, no graph ");return}else s.debug("Opting in, graph ");e.nodes().forEach(function(n){e.children(n).length>0&&(s.warn("Cluster identified",n," Replacement id in edges: ",k(n,e)),p[n]=U(n,e),f[n]={id:k(n,e),clusterData:e.node(n)})}),e.nodes().forEach(function(n){const r=e.children(n),i=e.edges();r.length>0?(s.debug("Cluster identified",n,p),i.forEach(a=>{if(a.v!==n&&a.w!==n){const c=L(a.v,n),u=L(a.w,n);c^u&&(s.warn("Edge: ",a," leaves cluster ",n),s.warn("Descendants of XXX ",n,": ",p[n]),f[n].externalConnections=!0)}})):s.debug("Not a cluster ",n,p)});for(let n of Object.keys(f)){const r=f[n].id,i=e.parent(r);i!==n&&f[i]&&!f[i].externalConnections&&(f[n].id=i)}
1e.edges().forEach(function(n){const r=e.edge(n);s.warn("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(n)),s.warn("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(e.edge(n)));let i=n.v,a=n.w;if(s.warn("Fix XXX",f,"ids:",n.v,n.w,"Translating: ",f[n.v]," --- ",f[n.w]),f[n.v]&&f[n.w]&&f[n.v]===f[n.w]){s.warn("Fixing and trixing link to self - removing XXX",n.v,n.w,n.name),s.warn("Fixing and trixing - removing XXX",n.v,n.w,n.name),i=X(n.v),a=X(n.w),e.removeEdge(n.v,n.w,n.name);const c=n.w+"---"+n.v;e.setNode(c,{domId:c,id:c,labelStyle:"",labelText:r.label,padding:0,shape:"labelRect",style:""});const u=structuredClone(r),d=structuredClone(r);u.label="",u.arrowTypeEnd="none",d.label="",u.fromCluster=n.v,d.toCluster=n.v,e.setEdge(i,c,u,n.name+"-cyclic-special"),e.setEdge(c,a,d,n.name+"-cyclic-special")}else if(f[n.v]||f[n.w]){if(s.warn("Fixing and trixing - removing XXX",n.v,n.w,n.name),i=X(n.v),a=X(n.w),e.removeEdge(n.v,n.w,n.name),i!==n.v){const c=e.parent(i);f[c].externalConnections=!0,r.fromCluster=n.v}if(a!==n.w){const c=e.parent(a);f[c].externalConnections=!0,r.toCluster=n.w}s.warn("Fix Replacing with XXX",i,a,n.name),e.setEdge(i,a,r,n.name)}}),s.warn("Adjusted Graph",x(e)),j(e,0),s.trace(f)},"adjustClustersAndEdges"),j=h((e,t)=>{if(s.warn("extractor - ",t,x(e),e.children("D")),t>10){s.error("Bailing out");return}let n=e.nodes(),r=!1;for(const i of n){const a=e.children(i);r=r||a.length>0}if(!r){s.debug("Done, no node has children",e.nodes());return}s.debug("Nodes = ",n,t);for(const i of n)if(s.debug("Extracting node",i,f,f[i]&&!f[i].externalConnections,!e.parent(i),e.node(i),e.children("D")," Depth ",t),!f[i])s.debug("Not a cluster",i,t);else if(!f[i].externalConnections&&e.children(i)&&e.children(i).length>0){s.warn("Cluster without external connections, without a parent and with children",i,t);let c=e.graph().rankdir==="TB"?"LR":"TB";f[i]?.clusterData?.dir&&(c=f[i].clusterData.dir,s.warn("Fixing dir",f[i].clusterData.dir,c));const u=new V({multigraph:!0,compound:!0}).setGraph({rankdir:c,nodesep:50,ranksep:50,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});s.warn("Old graph before copy",x(e)),Q(i,e,u,i),e.setNode(i,{clusterNode:!0,id:i,clusterData:f[i].clusterData,labelText:f[i].labelText,graph:u}),s.warn("New graph after copy node: (",i,")",x(u)),s.debug("Old graph after copy",x(e))}else s.warn("Cluster ** ",i," **not meeting the criteria !externalConnections:",!f[i].externalConnections," no parent: ",!e.parent(i)," children ",e.children(i)&&e.children(i).length>0,e.children("D"),t),s.debug(f);n=e.nodes(),s.warn("New list of nodes",n);for(const i of n){const a=e.node(i);s.warn(" Now next level",i,a),a.clusterNode&&j(a.graph,t+1)}},"extractor"),K=h((e,t)=>{if(t.length===0)return[];let n=Object.assign(t);return t.forEach(r=>{const i=e.children(r),a=K(e,i);n=[...n,...a]}),n},"sorter"),vt=h(e=>K(e,e.children()),"sortNodesByHierarchy"),pt=h((e,t)=>{s.info("Creating subgraph rect for ",t.id,t);const n=m(),r=e.insert("g").attr("class","cluster"+(t.class?" "+t.class:"")).attr("id",t.id),i=r.insert("rect",":first-child"),a=B(n.flowchart.htmlLabels),c=r.insert("g").attr("class","cluster-label"),u=t.labelType==="markdown"?gt(c,t.labelText,{style:t.labelStyle,useHtmlLabels:a},n):c.node().appendChild(F(t.labelText,t.labelStyle,void 0,!0));let d=u.getBBox();if(B(n.flowchart.htmlLabels)){const l=u.children[0],o=T(u);d=l.getBoundingClientRect(),o.attr("width",d.width),o.attr("height",d.height)}const g=0*t.padding,y=g/2,w=t.width<=d.width+g?d.width+g:t.width;t.width<=d.width+g?t.diff=(d.width-t.width)/2-t.padding/2:t.diff=-t.padding/2,s.trace("Data ",t,JSON.stringify(t)),i.attr("style",t.style).attr("rx",t.rx).attr("ry",t.ry).attr("x",t.x-w/2).attr("y",t.y-t.height/2-y).attr("width",w).attr("height",t.height+g);const{subGraphTitleTopMargin:v}=J(n);a?c.attr("transform",`translate(${t.x-d.width/2}, ${t.y-t.height/2+v})`):c.attr("transform",`translate(${t.x}, ${t.y-t.height/2+v})`);const b=i.node().getBBox();return t.width=b.width,t.height=b.height,t.intersect=function(l){return R(t,l)},r},"rect"),xt=h((e,t)=>{const n=e.insert("g").attr("class","note-cluster").attr("id",t.id),r=n.insert("rect",":first-child"),i=0*t.padding,a=i/2;r.attr("rx",t.rx).attr("ry",t.ry).attr("x",t.x-t.width/2-a).attr("y",t.y-t.height/2-a).attr("width",t.width+i).attr("height",t.height+i).attr("fill","none");const c=r.node().getBBox();return t.width=c.width,t.height=c.height,t.intersect=function(u){return R(t,u)},n},"noteGroup"),St=h((e,t)=>{const n=m(),r=e.insert("g").attr("class",t.classes).attr("id",t.id),i=r.insert("rect",":first-child"),a=r.insert("g").attr("class","cluster-label"),c=r.append("rect"),u=a.node().appendChild(F(t.labelText,t.labelStyle,void 0,!0));let d=u.getBBox();
1if(B(n.flowchart.htmlLabels)){const l=u.children[0],o=T(u);d=l.getBoundingClientRect(),o.attr("width",d.width),o.attr("height",d.height)}d=u.getBBox();const g=0*t.padding,y=g/2,w=t.width<=d.width+t.padding?d.width+t.padding:t.width;t.width<=d.width+t.padding?t.diff=(d.width+t.padding*0-t.width)/2:t.diff=-t.padding/2,i.attr("class","outer").attr("x",t.x-w/2-y).attr("y",t.y-t.height/2-y).attr("width",w+g).attr("height",t.height+g),c.attr("class","inner").attr("x",t.x-w/2-y).attr("y",t.y-t.height/2-y+d.height-1).attr("width",w+g).attr("height",t.height+g-d.height-3);const{subGraphTitleTopMargin:v}=J(n);a.attr("transform",`translate(${t.x-d.width/2}, ${t.y-t.height/2-t.padding/3+(B(n.flowchart.htmlLabels)?5:3)+v})`);const b=i.node().getBBox();return t.height=b.height,t.intersect=function(l){return R(t,l)},r},"roundedWithTitle"),Nt=h((e,t)=>{const n=e.insert("g").attr("class",t.classes).attr("id",t.id),r=n.insert("rect",":first-child"),i=0*t.padding,a=i/2;r.attr("class","divider").attr("x",t.x-t.width/2-a).attr("y",t.y-t.height/2).attr("width",t.width+i).attr("height",t.height+i);const c=r.node().getBBox();return t.width=c.width,t.height=c.height,t.diff=-t.padding/2,t.intersect=function(u){return R(t,u)},n},"divider"),Et={rect:pt,roundedWithTitle:St,noteGroup:xt,divider:Nt},Y={},Ct=h((e,t)=>{s.trace("Inserting cluster");const n=t.shape||"rect";Y[t.id]=Et[n](e,t)},"insertCluster"),Tt=h(()=>{Y={}},"clear"),Z=h(async(e,t,n,r,i,a)=>{s.info("Graph in recursive render: XXX",x(t),i);const c=t.graph().rankdir;s.trace("Dir in recursive render - dir:",c);const u=e.insert("g").attr("class","root");t.nodes()?s.info("Recursive render XXX",t.nodes()):s.info("No nodes found for",t),t.edges().length>0&&s.trace("Recursive edges",t.edge(t.edges()[0]));const d=u.insert("g").attr("class","clusters"),g=u.insert("g").attr("class","edgePaths"),y=u.insert("g").attr("class","edgeLabels"),w=u.insert("g").attr("class","nodes");await Promise.all(t.nodes().map(async function(l){const o=t.node(l);if(i!==void 0){const S=JSON.parse(JSON.stringify(i.clusterData));s.info("Setting data for cluster XXX (",l,") ",S,i),t.setNode(i.id,S),t.parent(l)||(s.trace("Setting parent",l,i.id),t.setParent(l,i.id,S))}if(s.info("(Insert) Node XXX"+l+": "+JSON.stringify(t.node(l))),o?.clusterNode){s.info("Cluster identified",l,o.width,t.node(l));const{ranksep:S,nodesep:E}=t.graph();o.graph.setGraph({...o.graph.graph(),ranksep:S,nodesep:E});const D=await Z(w,o.graph,n,r,t.node(l),a),N=D.elem;it(o,N),o.diff=D.diff||0,s.info("Node bounds (abc123)",l,o,o.width,o.x,o.y),st(N,o),s.warn("Recursive render complete ",N,o)}else t.children(l).length>0?(s.info("Cluster - the non recursive path XXX",l,o.id,o,t),s.info(k(o.id,t)),f[o.id]={id:k(o.id,t),node:o}):(s.info("Node - the non recursive path",l,o.id,o),await at(w,t.node(l),{config:a,dir:c}))}
1)),t.edges().forEach(async function(l){const o=t.edge(l.v,l.w,l.name);s.info("Edge "+l.v+" -> "+l.w+": "+JSON.stringify(l)),s.info("Edge "+l.v+" -> "+l.w+": ",l," ",JSON.stringify(t.edge(l))),s.info("Fix",f,"ids:",l.v,l.w,"Translating: ",f[l.v],f[l.w]),await rt(y,o)}),t.edges().forEach(function(l){s.info("Edge "+l.v+" -> "+l.w+": "+JSON.stringify(l))}),s.info("Graph before layout:",JSON.stringify(x(t))),s.info("#############################################"),s.info("### Layout ###"),s.info("#############################################"),s.info(t),wt(t),s.info("Graph after layout:",JSON.stringify(x(t)));let v=0;const{subGraphTitleTotalMargin:b}=J(a);return vt(t).forEach(function(l){const o=t.node(l);s.info("Position "+l+": "+JSON.stringify(t.node(l))),s.info("Position "+l+": ("+o.x,","+o.y,") width: ",o.width," height: ",o.height),o?.clusterNode?(o.y+=b,G(o)):t.children(l).length>0?(o.height+=b,Ct(d,o),f[o.id].node=o):(o.y+=b/2,G(o))}),t.edges().forEach(function(l){const o=t.edge(l);s.info("Edge "+l.v+" -> "+l.w+": "+JSON.stringify(o),o),o.points.forEach(E=>E.y+=b/2);const S=lt(g,l,o,f,n,t,r);ot(o,S)}),t.nodes().forEach(function(l){const o=t.node(l);s.info(l,o.type,o.diff),o.type==="group"&&(v=o.diff)}),{elem:u,diff:v}},"recursiveRender"),kt=h(async(e,t,n,r,i)=>{tt(e,n,r,i),et(),nt(),Tt(),yt(),s.warn("Graph at first:",JSON.stringify(x(t))),mt(t),s.warn("Graph after:",JSON.stringify(x(t)));const a=m();await Z(e,t,r,i,void 0,a)},"render"),O=h(e=>z.sanitizeText(e,m()),"sanitizeText"),_={dividerMargin:10,padding:5,textHeight:10,curve:void 0},Dt=h(function(e,t,n,r){s.info("keys:",[...e.keys()]),s.info(e),e.forEach(function(i){const c={shape:"rect",id:i.id,domId:i.domId,labelText:O(i.id),labelStyle:"",style:"fill: none; stroke: black",padding:m().flowchart?.padding??m().class?.padding};t.setNode(i.id,c),I(i.classes,t,n,r,i.id),s.info("setNode",c)})},"addNamespaces"),I=h(function(e,t,n,r,i){s.info("keys:",[...e.keys()]),s.info(e),[...e.values()].filter(a=>
1a.parent===i).forEach(function(a){const c=a.cssClasses.join(" "),u=$(a.styles),d=a.label??a.id,g=0,w={labelStyle:u.labelStyle,shape:"class_box",labelText:O(d),classData:a,rx:g,ry:g,class:c,style:u.style,id:a.id,domId:a.domId,tooltip:r.db.getTooltip(a.id,i)||"",haveCallback:a.haveCallback,link:a.link,width:a.type==="group"?500:void 0,type:a.type,padding:m().flowchart?.padding??m().class?.padding};t.setNode(a.id,w),i&&t.setParent(a.id,i),s.info("setNode",w)})},"addClasses"),Xt=h(function(e,t,n,r){s.info(e),e.forEach(function(i,a){const c=i,u="",d={labelStyle:"",style:""},g=c.text,y=0,v={labelStyle:d.labelStyle,shape:"note",labelText:O(g),noteData:c,rx:y,ry:y,class:u,style:d.style,id:c.id,domId:c.id,tooltip:"",type:"note",padding:m().flowchart?.padding??m().class?.padding};if(t.setNode(c.id,v),s.info("setNode",v),!c.class||!r.has(c.class))return;const b=n+a,l={id:`edgeNote${b}`,classes:"relation",pattern:"dotted",arrowhead:"none",startLabelRight:"",endLabelLeft:"",arrowTypeStart:"none",arrowTypeEnd:"none",style:"fill:none",labelStyle:"",curve:H(_.curve,W)};t.setEdge(c.id,c.class,l,b)})},"addNotes"),Bt=h(function(e,t){const n=m().flowchart;let r=0;e.forEach(function(i){r++;const a={classes:"relation",pattern:i.relation.lineType==1?"dashed":"solid",id:ht(i.id1,i.id2,{prefix:"id",counter:r}),arrowhead:i.type==="arrow_open"?"none":"normal",startLabelRight:i.relationTitle1==="none"?"":i.relationTitle1,endLabelLeft:i.relationTitle2==="none"?"":i.relationTitle2,arrowTypeStart:A(i.relation.type1),arrowTypeEnd:A(i.relation.type2),style:"fill:none",labelStyle:"",curve:H(n?.curve,W)};if(s.info(a,i),i.style!==void 0){const c=$(i.style);a.style=c.style,a.labelStyle=c.labelStyle}i.text=i.title,i.text===void 0?i.style!==void 0&&(a.arrowheadStyle="fill: #333"):(a.arrowheadStyle="fill: #333",a.labelpos="c",m().flowchart?.htmlLabels??m().htmlLabels?(a.labelType="html",a.label='<span class="edgeLabel">'+i.text+"</span>"):(a.labelType="text",a.label=i.text.replace(z.lineBreakRegex,` 2`),i.style===void 0&&(a.style=a.style||"stroke: #333; stroke-width: 1.5px;fill:none"),a.labelStyle=a.labelStyle.replace("color:","fill:"))),t.setEdge(i.id1,i.id2,a,r)})},"addRelations"),Lt=h(function(e){_={..._,...e}},"setConf"),Rt=h(async function(e,t,n,r){s.info("Drawing class - ",t);const i=m().flowchart??m().class,a=m().securityLevel;s.info("config:",i);const c=i?.nodeSpacing??50,u=i?.rankSpacing??50,d=new V({multigraph:!0,compound:!0}).setGraph({rankdir:r.db.getDirection(),nodesep:c,ranksep:u,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}}),g=r.db.getNamespaces(),y=r.db.getClasses(),w=r.db.getRelations(),v=r.db.getNotes();s.info(w),Dt(g,d,t,r),I(y,d,t,r),Bt(w,d),Xt(v,d,w.length+1,y);let b;a==="sandbox"&&(b=T("#i"+t));const l=a==="sandbox"?T(b.nodes()[0].contentDocument.body):T("body"),o=l.select(`[id="${t}"]`),S=l.select("#"+t+" g");if(await kt(S,d,["aggregation","extension","composition","dependency","lollipop"],"classDiagram",t),ft.insertTitle(o,"classTitleText",i?.titleTopMargin??5,r.db.getDiagramTitle()),ut(d,o,i?.diagramPadding,i?.useMaxWidth),!i?.htmlLabels){const E=a==="sandbox"?b.nodes()[0].contentDocument:document,D=E.querySelectorAll('[id="'+t+'"] .edgeLabel .label');for(const N of D){const P=N.getBBox(),C=E.createElementNS("http://www.w3.org/2000/svg","rect");C.setAttribute("rx",0),C.setAttribute("ry",0),C.setAttribute("width",P.width),C.setAttribute("height",P.height),N.insertBefore(C,N.firstChild)}}},"draw");function A(e){let t;switch(e){case 0:t="aggregation";break;case 1:t="extension";break;case 2:t="composition";break;case 3:t="dependency";break;case 4:t="lollipop";break;default:t="none"}return t}h(A,"getArrowMarker");var _t={setConf:Lt,draw:Rt},zt={parser:ct,db:M,renderer:_t,styles:dt,init:h(e=>{e.class||(e.class={}),e.class.arrowMarkerAbsolute=e.arrowMarkerAbsolute,M.clear()},"init")};export{zt as diagram};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.