Files
Awperative/_site/public/stateDiagram-FKZM4ZOC-XLDSNUEM.min.js
2026-02-09 16:52:39 -05:00

3 lines
10 KiB
JavaScript
Executable File

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