Spaces:
Running
Running
import{s as t,a as e,b as a}from"./chunk-7U56Z5CX-pnTfnjQ7.js";import{_ as i,c as r,l as n,d,j as s,u as o}from"./mermaid-D0MGOvVE.js";import{s as g}from"./transform-CdY8z5kT.js";import{G as p}from"./graph-XoNMemoA.js";import{l as c}from"./layout-D3QmwxRU.js";import{l as h,k as l}from"./step-xJWGRC3d.js";import"./chunk-5HRBRIJM-QR2D2yWQ.js";import"./index-BiV-b1K2.js";import"./_baseUniq-DUj_-ybn.js";import"./_baseEach-DDZLUgL5.js";import"./min-FhCtSWQU.js";import"./_baseMap-CoUfqKnE.js";import"./sortBy-CHDem8Sy.js";var x,f={},u=i(((t,e)=>{f[t]=e}),"set"),y=i((t=>f[t]),"get"),m=i((()=>Object.keys(f)),"keys"),w=i((()=>m().length),"size"),b={get:y,set:u,keys:m,size:w},B=i((t=>t.append("circle").attr("class","start-state").attr("r",r().state.sizeUnit).attr("cx",r().state.padding+r().state.sizeUnit).attr("cy",r().state.padding+r().state.sizeUnit)),"drawStartState"),k=i((t=>t.append("line").style("stroke","grey").style("stroke-dasharray","3").attr("x1",r().state.textHeight).attr("class","divider").attr("x2",2*r().state.textHeight).attr("y1",0).attr("y2",0)),"drawDivider"),S=i(((t,e)=>{const a=t.append("text").attr("x",2*r().state.padding).attr("y",r().state.textHeight+2*r().state.padding).attr("font-size",r().state.fontSize).attr("class","state-title").text(e.id),i=a.node().getBBox();return t.insert("rect",":first-child").attr("x",r().state.padding).attr("y",r().state.padding).attr("width",i.width+2*r().state.padding).attr("height",i.height+2*r().state.padding).attr("rx",r().state.radius),a}),"drawSimpleState"),E=i(((t,e)=>{const a=i((function(t,e,a){const i=t.append("tspan").attr("x",2*r().state.padding).text(e);a||i.attr("dy",r().state.textHeight)}),"addTspan"),n=t.append("text").attr("x",2*r().state.padding).attr("y",r().state.textHeight+1.3*r().state.padding).attr("font-size",r().state.fontSize).attr("class","state-title").text(e.descriptions[0]).node().getBBox(),d=n.height,s=t.append("text").attr("x",r().state.padding).attr("y",d+.4*r().state.padding+r().state.dividerMargin+r().state.textHeight).attr("class","state-description");let o=!0,g=!0;e.descriptions.forEach((function(t){o||(a(s,t,g),g=!1),o=!1}));const p=t.append("line").attr("x1",r().state.padding).attr("y1",r().state.padding+d+r().state.dividerMargin/2).attr("y2",r().state.padding+d+r().state.dividerMargin/2).attr("class","descr-divider"),c=s.node().getBBox(),h=Math.max(c.width,n.width);return p.attr("x2",h+3*r().state.padding),t.insert("rect",":first-child").attr("x",r().state.padding).attr("y",r().state.padding).attr("width",h+2*r().state.padding).attr("height",c.height+d+2*r().state.padding).attr("rx",r().state.radius),t}),"drawDescrState"),N=i(((t,e,a)=>{const i=r().state.padding,n=2*r().state.padding,d=t.node().getBBox(),s=d.width,o=d.x,g=t.append("text").attr("x",0).attr("y",r().state.titleShift).attr("font-size",r().state.fontSize).attr("class","state-title").text(e.id),p=g.node().getBBox().width+n;let c,h=Math.max(p,s);h===s&&(h+=n);const l=t.node().getBBox();e.doc,c=o-i,p>s&&(c=(s-h)/2+i),Math.abs(o-l.x)<i&&p>s&&(c=o-(p-s)/2);const x=1-r().state.textHeight;return t.insert("rect",":first-child").attr("x",c).attr("y",x).attr("class",a?"alt-composit":"composit").attr("width",h).attr("height",l.height+r().state.textHeight+r().state.titleShift+1).attr("rx","0"),g.attr("x",c+i),p<=s&&g.attr("x",o+(h-n)/2-p/2+i),t.insert("rect",":first-child").attr("x",c).attr("y",r().state.titleShift-r().state.textHeight-r().state.padding).attr("width",h).attr("height",3*r().state.textHeight).attr("rx",r().state.radius),t.insert("rect",":first-child").attr("x",c).attr("y",r().state.titleShift-r().state.textHeight-r().state.padding).attr("width",h).attr("height",l.height+3+2*r().state.textHeight).attr("rx",r().state.radius),t}),"addTitleAndBox"),M=i((t=>(t.append("circle").attr("class","end-state-outer").attr("r",r().state.sizeUnit+r().state.miniPadding).attr("cx",r().state.padding+r().state.sizeUnit+r().state.miniPadding).attr("cy",r().state.padding+r().state.sizeUnit+r().state.miniPadding),t.append("circle").attr("class","end-state-inner").attr("r",r().state.sizeUnit).attr("cx",r().state.padding+r().state.sizeUnit+2).attr("cy",r().state.padding+r().state.sizeUnit+2))),"drawEndState"),v=i(((t,e)=>{let a=r().state.forkWidth,i=r().state.forkHeight;if(e.parentId){let t=a;a=i,i=t}return t.append("rect").style("stroke","black").style("fill","black").attr("width",a).attr("height",i).attr("x",r().state.padding).attr("y",r().state.padding)}),"drawForkJoinState"),z=i(((t,e,a,i)=>{let n=0;const d=i.append("text");d.style("text-anchor","start"),d.attr("class","noteText");let o=t.replace(/\r\n/g,"<br/>");o=o.replace(/\n/g,"<br/>");const g=o.split(s.lineBreakRegex);let p=1.25*r().state.noteMargin;for(const s of g){const t=s.trim();if(t.length>0){const i=d.append("tspan");if(i.text(t),0===p){p+=i.node().getBBox().height}n+=p,i.attr("x",e+r().state.noteMargin),i.attr("y",a+n+1.25*r().state.noteMargin)}}return{textWidth:d.node().getBBox().width,textHeight:n}}),"_drawLongText"),j=i(((t,e)=>{e.attr("class","state-note");const a=e.append("rect").attr("x",0).attr("y",r().state.padding),i=e.append("g"),{textWidth:n,textHeight:d}=z(t,0,0,i);return a.attr("height",d+2*r().state.noteMargin),a.attr("width",n+2*r().state.noteMargin),a}),"drawNote"),H=i((function(t,e){const a=e.id,i={id:a,label:e.id,width:0,height:0},n=t.append("g").attr("id",a).attr("class","stateGroup");"start"===e.type&&B(n),"end"===e.type&&M(n),"fork"!==e.type&&"join"!==e.type||v(n,e),"note"===e.type&&j(e.note.text,n),"divider"===e.type&&k(n),"default"===e.type&&0===e.descriptions.length&&S(n,e),"default"===e.type&&e.descriptions.length>0&&E(n,e);const d=n.node().getBBox();return i.width=d.width+2*r().state.padding,i.height=d.height+2*r().state.padding,b.set(a,i),i}),"drawState"),T=0,D=i((function(t,a,d){const g=i((function(t){switch(t){case e.relationType.AGGREGATION:return"aggregation";case e.relationType.EXTENSION:return"extension";case e.relationType.COMPOSITION:return"composition";case e.relationType.DEPENDENCY:return"dependency"}}),"getRelationType");a.points=a.points.filter((t=>!Number.isNaN(t.y)));const p=a.points,c=h().x((function(t){return t.x})).y((function(t){return t.y})).curve(l),x=t.append("path").attr("d",c(p)).attr("id","edge"+T).attr("class","transition");let f="";if(r().state.arrowMarkerAbsolute&&(f=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,f=f.replace(/\(/g,"\\("),f=f.replace(/\)/g,"\\)")),x.attr("marker-end","url("+f+"#"+g(e.relationType.DEPENDENCY)+"End)"),void 0!==d.title){const e=t.append("g").attr("class","stateLabel"),{x:i,y:g}=o.calcLabelPosition(a.points),p=s.getRows(d.title);let c=0;const h=[];let l=0,x=0;for(let t=0;t<=p.length;t++){const a=e.append("text").attr("text-anchor","middle").text(p[t]).attr("x",i).attr("y",g+c),r=a.node().getBBox();if(l=Math.max(l,r.width),x=Math.min(x,r.x),n.info(r.x,i,g+c),0===c){const t=a.node().getBBox();c=t.height,n.info("Title height",c,g)}h.push(a)}let f=c*p.length;if(p.length>1){const t=(p.length-1)*c*.5;h.forEach(((e,a)=>e.attr("y",g+a*c-t))),f=c*p.length}const u=e.node().getBBox();e.insert("rect",":first-child").attr("class","box").attr("x",i-l/2-r().state.padding/2).attr("y",g-f/2-r().state.padding/2-3.5).attr("width",l+r().state.padding).attr("height",f+r().state.padding),n.info(u)}T++}),"drawEdge"),L={},G=i((function(){}),"setConf"),R=i((function(t){t.append("defs").append("marker").attr("id","dependencyEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 19,7 L9,13 L14,7 L9,1 Z")}),"insertMarkers"),U=i((function(t,e,a,i){x=r().state;const s=r().securityLevel;let o;"sandbox"===s&&(o=g("#i"+e));const p=g("sandbox"===s?o.nodes()[0].contentDocument.body:"body"),c="sandbox"===s?o.nodes()[0].contentDocument:document;n.debug("Rendering diagram "+t);const h=p.select(`[id='${e}']`);R(h);const l=i.db.getRootDoc();O(l,h,void 0,!1,p,c,i);const f=x.padding,u=h.node().getBBox(),y=u.width+2*f,m=u.height+2*f;d(h,m,1.75*y,x.useMaxWidth),h.attr("viewBox",`${u.x-x.padding} ${u.y-x.padding} `+y+" "+m)}),"draw"),A=i((t=>t?t.length*x.fontSizeFactor:1),"getLabelWidth"),O=i(((t,e,a,i,r,d,o)=>{const g=new p({compound:!0,multigraph:!0});let h,l=!0;for(h=0;h<t.length;h++)if("relation"===t[h].stmt){l=!1;break}a?g.setGraph({rankdir:"LR",multigraph:!0,compound:!0,ranker:"tight-tree",ranksep:l?1:x.edgeLengthFactor,nodeSep:l?1:50,isMultiGraph:!0}):g.setGraph({rankdir:"TB",multigraph:!0,compound:!0,ranksep:l?1:x.edgeLengthFactor,nodeSep:l?1:50,ranker:"tight-tree",isMultiGraph:!0}),g.setDefaultEdgeLabel((function(){return{}})),o.db.extract(t);const f=o.db.getStates(),u=o.db.getRelations(),y=Object.keys(f);for(const n of y){const t=f[n];let s;if(a&&(t.parentId=a),t.doc){let a=e.append("g").attr("id",t.id).attr("class","stateGroup");s=O(t.doc,a,t.id,!i,r,d,o);{a=N(a,t,i);let e=a.node().getBBox();s.width=e.width,s.height=e.height+x.padding/2,L[t.id]={y:x.compositTitleSize}}}else s=H(e,t,g);if(t.note){const a={descriptions:[],id:t.id+"-note",note:t.note,type:"note"},i=H(e,a,g);"left of"===t.note.position?(g.setNode(s.id+"-note",i),g.setNode(s.id,s)):(g.setNode(s.id,s),g.setNode(s.id+"-note",i)),g.setParent(s.id,s.id+"-group"),g.setParent(s.id+"-note",s.id+"-group")}else g.setNode(s.id,s)}n.debug("Count=",g.nodeCount(),g);let m=0;u.forEach((function(t){m++,n.debug("Setting edge",t),g.setEdge(t.id1,t.id2,{relation:t,width:A(t.title),height:x.labelHeight*s.getRows(t.title).length,labelpos:"c"},"id"+m)})),c(g),n.debug("Graph after layout",g.nodes());const w=e.node();g.nodes().forEach((function(t){if(void 0!==t&&void 0!==g.node(t)){n.warn("Node "+t+": "+JSON.stringify(g.node(t))),r.select("#"+w.id+" #"+t).attr("transform","translate("+(g.node(t).x-g.node(t).width/2)+","+(g.node(t).y+(L[t]?L[t].y:0)-g.node(t).height/2)+" )"),r.select("#"+w.id+" #"+t).attr("data-x-shift",g.node(t).x-g.node(t).width/2);d.querySelectorAll("#"+w.id+" #"+t+" .divider").forEach((t=>{const e=t.parentElement;let a=0,i=0;e&&(e.parentElement&&(a=e.parentElement.getBBox().width),i=parseInt(e.getAttribute("data-x-shift"),10),Number.isNaN(i)&&(i=0)),t.setAttribute("x1",0-i+8),t.setAttribute("x2",a-i-8)}))}else n.debug("No Node "+t+": "+JSON.stringify(g.node(t)))}));let b=w.getBBox();g.edges().forEach((function(t){void 0!==t&&void 0!==g.edge(t)&&(n.debug("Edge "+t.v+" -> "+t.w+": "+JSON.stringify(g.edge(t))),D(e,g.edge(t),g.edge(t).relation))})),b=w.getBBox();const B={id:a||"root",label:a||"root",width:0,height:0};return B.width=b.width+2*x.padding,B.height=b.height+2*x.padding,n.debug("Doc rendered",B,g),B}),"renderDoc"),P={parser:a,db:e,renderer:{setConf:G,draw:U},styles:t,init:i((t=>{t.state||(t.state={}),t.state.arrowMarkerAbsolute=t.arrowMarkerAbsolute,e.clear()}),"init")};export{P as diagram}; | |