HomeDashboard/.venv/lib/python3.12/site-packages/nicegui/elements/mermaid/dist/stateDiagram-ZFDIVMDF-UXJc7GMs.js
2026-01-03 14:54:18 +01:00

3 lines
10 KiB
JavaScript

import{g as t,B as e,_ as a}from"./chunk-AI4T2ZLM-DI9Pzep9.js";import{f as i}from"./chunk-CCU7O4O5-DDF7LoPN.js";import{m as r}from"./chunk-EYG76IYJ-BW_kWavW.js";import"./chunk-6EQESGSB-CMpZRKNo.js";import"./chunk-T244DUNM-DsHGI3jp.js";import{m as d,a as n,i as s,p as o,W as g,h as p,af as h,am as l,aj as c,d as x}from"./index-BDq3hoFe.js";import"./chunk-OMTJKCYW-D0VGaEv2.js";var u,f=d(t=>t.append("circle").attr("class","start-state").attr("r",n().state.sizeUnit).attr("cx",n().state.padding+n().state.sizeUnit).attr("cy",n().state.padding+n().state.sizeUnit),"drawStartState"),y=d(t=>t.append("line").style("stroke","grey").style("stroke-dasharray","3").attr("x1",n().state.textHeight).attr("class","divider").attr("x2",2*n().state.textHeight).attr("y1",0).attr("y2",0),"drawDivider"),w=d((t,e)=>{let a=t.append("text").attr("x",2*n().state.padding).attr("y",n().state.textHeight+2*n().state.padding).attr("font-size",n().state.fontSize).attr("class","state-title").text(e.id),i=a.node().getBBox();return t.insert("rect",":first-child").attr("x",n().state.padding).attr("y",n().state.padding).attr("width",i.width+2*n().state.padding).attr("height",i.height+2*n().state.padding).attr("rx",n().state.radius),a},"drawSimpleState"),m=d((t,e)=>{let a=d(function(t,e,a){let i=t.append("tspan").attr("x",2*n().state.padding).text(e);a||i.attr("dy",n().state.textHeight)},"addTspan"),i=t.append("text").attr("x",2*n().state.padding).attr("y",n().state.textHeight+1.3*n().state.padding).attr("font-size",n().state.fontSize).attr("class","state-title").text(e.descriptions[0]).node().getBBox(),r=i.height,s=t.append("text").attr("x",n().state.padding).attr("y",r+.4*n().state.padding+n().state.dividerMargin+n().state.textHeight).attr("class","state-description"),o=!0,g=!0;e.descriptions.forEach(function(t){o||(a(s,t,g),g=!1),o=!1});let p=t.append("line").attr("x1",n().state.padding).attr("y1",n().state.padding+r+n().state.dividerMargin/2).attr("y2",n().state.padding+r+n().state.dividerMargin/2).attr("class","descr-divider"),h=s.node().getBBox(),l=Math.max(h.width,i.width);return p.attr("x2",l+3*n().state.padding),t.insert("rect",":first-child").attr("x",n().state.padding).attr("y",n().state.padding).attr("width",l+2*n().state.padding).attr("height",h.height+r+2*n().state.padding).attr("rx",n().state.radius),t},"drawDescrState"),b=d((t,e,a)=>{let i=n().state.padding,r=2*n().state.padding,d=t.node().getBBox(),s=d.width,o=d.x,g=t.append("text").attr("x",0).attr("y",n().state.titleShift).attr("font-size",n().state.fontSize).attr("class","state-title").text(e.id),p=g.node().getBBox().width+r,h=Math.max(p,s);h===s&&(h+=r);let l,c=t.node().getBBox();e.doc,l=o-i,p>s&&(l=(s-h)/2+i),Math.abs(o-c.x)<i&&p>s&&(l=o-(p-s)/2);let x=1-n().state.textHeight;return t.insert("rect",":first-child").attr("x",l).attr("y",x).attr("class",a?"alt-composit":"composit").attr("width",h).attr("height",c.height+n().state.textHeight+n().state.titleShift+1).attr("rx","0"),g.attr("x",l+i),p<=s&&g.attr("x",o+(h-r)/2-p/2+i),t.insert("rect",":first-child").attr("x",l).attr("y",n().state.titleShift-n().state.textHeight-n().state.padding).attr("width",h).attr("height",3*n().state.textHeight).attr("rx",n().state.radius),t.insert("rect",":first-child").attr("x",l).attr("y",n().state.titleShift-n().state.textHeight-n().state.padding).attr("width",h).attr("height",c.height+3+2*n().state.textHeight).attr("rx",n().state.radius),t},"addTitleAndBox"),B=d(t=>(t.append("circle").attr("class","end-state-outer").attr("r",n().state.sizeUnit+n().state.miniPadding).attr("cx",n().state.padding+n().state.sizeUnit+n().state.miniPadding).attr("cy",n().state.padding+n().state.sizeUnit+n().state.miniPadding),t.append("circle").attr("class","end-state-inner").attr("r",n().state.sizeUnit).attr("cx",n().state.padding+n().state.sizeUnit+2).attr("cy",n().state.padding+n().state.sizeUnit+2)),"drawEndState"),k=d((t,e)=>{let a=n().state.forkWidth,i=n().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",n().state.padding).attr("y",n().state.padding)},"drawForkJoinState"),S=d((t,e,a,i)=>{let r=0,d=i.append("text");d.style("text-anchor","start"),d.attr("class","noteText");let s=t.replace(/\r\n/g,"<br/>");s=s.replace(/\n/g,"<br/>");let o=s.split(p.lineBreakRegex),g=1.25*n().state.noteMargin;for(let t of o){let i=t.trim();if(i.length>0){let t=d.append("tspan");if(t.text(i),0===g){g+=t.node().getBBox().height}r+=g,t.attr("x",e+n().state.noteMargin),t.attr("y",a+r+1.25*n().state.noteMargin)}}return{textWidth:d.node().getBBox().width,textHeight:r}},"_drawLongText"),E=d((t,e)=>{e.attr("class","state-note");let a=e.append("rect").attr("x",0).attr("y",n().state.padding),i=e.append("g"),{textWidth:r,textHeight:d}=S(t,0,0,i);return a.attr("height",d+2*n().state.noteMargin),a.attr("width",r+2*n().state.noteMargin),a},"drawNote"),N=d(function(t,e){let a=e.id,i={id:a,label:e.id,width:0,height:0},r=t.append("g").attr("id",a).attr("class","stateGroup");"start"===e.type&&f(r),"end"===e.type&&B(r),("fork"===e.type||"join"===e.type)&&k(r,e),"note"===e.type&&E(e.note.text,r),"divider"===e.type&&y(r),"default"===e.type&&0===e.descriptions.length&&w(r,e),"default"===e.type&&e.descriptions.length>0&&m(r,e);let d=r.node().getBBox();return i.width=d.width+2*n().state.padding,i.height=d.height+2*n().state.padding,i},"drawState"),M=0,v=d(function(t,e,i){let r=d(function(t){switch(t){case a.relationType.AGGREGATION:return"aggregation";case a.relationType.EXTENSION:return"extension";case a.relationType.COMPOSITION:return"composition";case a.relationType.DEPENDENCY:return"dependency"}},"getRelationType");e.points=e.points.filter(t=>!Number.isNaN(t.y));let s=e.points,g=h().x(function(t){return t.x}).y(function(t){return t.y}).curve(l),u=t.append("path").attr("d",g(s)).attr("id","edge"+M).attr("class","transition"),f="";if(n().state.arrowMarkerAbsolute&&(f=c(!0)),u.attr("marker-end","url("+f+"#"+r(a.relationType.DEPENDENCY)+"End)"),void 0!==i.title){let a=t.append("g").attr("class","stateLabel"),{x:r,y:d}=x.calcLabelPosition(e.points),s=p.getRows(i.title),g=0,h=[],l=0,c=0;for(let t=0;t<=s.length;t++){let e=a.append("text").attr("text-anchor","middle").text(s[t]).attr("x",r).attr("y",d+g),i=e.node().getBBox();l=Math.max(l,i.width),c=Math.min(c,i.x),o.info(i.x,r,d+g),0===g&&(g=e.node().getBBox().height,o.info("Title height",g,d)),h.push(e)}let u=g*s.length;if(s.length>1){let t=(s.length-1)*g*.5;h.forEach((e,a)=>e.attr("y",d+a*g-t)),u=g*s.length}let f=a.node().getBBox();a.insert("rect",":first-child").attr("class","box").attr("x",r-l/2-n().state.padding/2).attr("y",d-u/2-n().state.padding/2-3.5).attr("width",l+n().state.padding).attr("height",u+n().state.padding),o.info(f)}M++},"drawEdge"),T={},z=d(function(){},"setConf"),H=d(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"),D=d(function(t,e,a,i){u=n().state;let r,d=n().securityLevel;"sandbox"===d&&(r=s("#i"+e));let p=s("sandbox"===d?r.nodes()[0].contentDocument.body:"body"),h="sandbox"===d?r.nodes()[0].contentDocument:document;o.debug("Rendering diagram "+t);let l=p.select(`[id='${e}']`);H(l);let c=i.db.getRootDoc();G(c,l,void 0,!1,p,h,i);let x=u.padding,f=l.node().getBBox(),y=f.width+2*x,w=f.height+2*x;g(l,w,1.75*y,u.useMaxWidth),l.attr("viewBox",`${f.x-u.padding} ${f.y-u.padding} `+y+" "+w)},"draw"),L=d(t=>t?t.length*u.fontSizeFactor:1,"getLabelWidth"),G=d((t,e,a,d,n,s,g)=>{let h,l=new r({compound:!0,multigraph:!0}),c=!0;for(h=0;h<t.length;h++)if("relation"===t[h].stmt){c=!1;break}a?l.setGraph({rankdir:"LR",multigraph:!0,compound:!0,ranker:"tight-tree",ranksep:c?1:u.edgeLengthFactor,nodeSep:c?1:50,isMultiGraph:!0}):l.setGraph({rankdir:"TB",multigraph:!0,compound:!0,ranksep:c?1:u.edgeLengthFactor,nodeSep:c?1:50,ranker:"tight-tree",isMultiGraph:!0}),l.setDefaultEdgeLabel(function(){return{}});let x=g.db.getStates(),f=g.db.getRelations(),y=Object.keys(x);for(let t of y){let i,r=x[t];if(a&&(r.parentId=a),r.doc){let t=e.append("g").attr("id",r.id).attr("class","stateGroup");i=G(r.doc,t,r.id,!d,n,s,g);{t=b(t,r,d);let e=t.node().getBBox();i.width=e.width,i.height=e.height+u.padding/2,T[r.id]={y:u.compositTitleSize}}}else i=N(e,r,l);if(r.note){let t={descriptions:[],id:r.id+"-note",note:r.note,type:"note"},a=N(e,t,l);"left of"===r.note.position?(l.setNode(i.id+"-note",a),l.setNode(i.id,i)):(l.setNode(i.id,i),l.setNode(i.id+"-note",a)),l.setParent(i.id,i.id+"-group"),l.setParent(i.id+"-note",i.id+"-group")}else l.setNode(i.id,i)}o.debug("Count=",l.nodeCount(),l);let w=0;f.forEach(function(t){w++,o.debug("Setting edge",t),l.setEdge(t.id1,t.id2,{relation:t,width:L(t.title),height:u.labelHeight*p.getRows(t.title).length,labelpos:"c"},"id"+w)}),i(l),o.debug("Graph after layout",l.nodes());let m=e.node();l.nodes().forEach(function(t){void 0!==t&&void 0!==l.node(t)?(o.warn("Node "+t+": "+JSON.stringify(l.node(t))),n.select("#"+m.id+" #"+t).attr("transform","translate("+(l.node(t).x-l.node(t).width/2)+","+(l.node(t).y+(T[t]?T[t].y:0)-l.node(t).height/2)+" )"),n.select("#"+m.id+" #"+t).attr("data-x-shift",l.node(t).x-l.node(t).width/2),s.querySelectorAll("#"+m.id+" #"+t+" .divider").forEach(t=>{let e=t.parentElement,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)})):o.debug("No Node "+t+": "+JSON.stringify(l.node(t)))});let B=m.getBBox();l.edges().forEach(function(t){void 0!==t&&void 0!==l.edge(t)&&(o.debug("Edge "+t.v+" -> "+t.w+": "+JSON.stringify(l.edge(t))),v(e,l.edge(t),l.edge(t).relation))}),B=m.getBBox();let k={id:a||"root",label:a||"root",width:0,height:0};return k.width=B.width+2*u.padding,k.height=B.height+2*u.padding,o.debug("Doc rendered",k,l),k},"renderDoc"),O={setConf:z,draw:D},A={parser:e,get db(){return new a(1)},renderer:O,styles:t,init:d(t=>{t.state||(t.state={}),t.state.arrowMarkerAbsolute=t.arrowMarkerAbsolute},"init")};export{A as diagram};
//# sourceMappingURL=stateDiagram-ZFDIVMDF-UXJc7GMs.js.map