f7cloud_client/apps/text/js/stateDiagram-FKZM4ZOC-CbhoquXf.chunk.mjs
root 8b6a0139db f7cloud_client
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-17 22:59:26 +00:00

3 lines
10 KiB
JavaScript

import{s as G,a as A,S as M}from"./chunk-DI55MBZ5-CbAnZHZo.chunk.mjs";import{_ as y,c as t,d as v,l as S,e as O,k as H,a9 as P,aa as R,a6 as U,u as C}from"./mermaid.core-BxtrgwOm.chunk.mjs";import{G as I}from"./graph-BOcm7ic5.chunk.mjs";import{l as W}from"./layout-9-Reifww.chunk.mjs";import"./chunk-55IACEB6-Bmn8dk9H.chunk.mjs";import"./chunk-QN33PNHL-BzMeKeZN.chunk.mjs";import"./index-CYtgifWR.chunk.mjs";import"./emoji-picker-B23JpFV7.chunk.mjs";import"./NcLoadingIcon-zQCGdPwE.chunk.mjs";import"./vue.runtime.esm-fahCO3eG.chunk.mjs";import"./index-DxwFe63_.chunk.mjs";import"./_baseUniq-08qBA_if.chunk.mjs";import"./_basePickBy-D4Ve5JSk.chunk.mjs";var F=y(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"),J=y(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"),Y=y((e,n)=>{const g=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(n.id),s=g.node().getBBox();return e.insert("rect",":first-child").attr("x",t().state.padding).attr("y",t().state.padding).attr("width",s.width+2*t().state.padding).attr("height",s.height+2*t().state.padding).attr("rx",t().state.radius),g},"drawSimpleState"),$=y((e,n)=>{const g=y(function(o,u,b){const w=o.append("tspan").attr("x",2*t().state.padding).text(u);b||w.attr("dy",t().state.textHeight)},"addTspan"),s=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(n.descriptions[0]).node().getBBox(),d=s.height,c=e.append("text").attr("x",t().state.padding).attr("y",d+t().state.padding*.4+t().state.dividerMargin+t().state.textHeight).attr("class","state-description");let l=!0,a=!0;n.descriptions.forEach(function(o){l||(g(c,o,a),a=!1),l=!1});const r=e.append("line").attr("x1",t().state.padding).attr("y1",t().state.padding+d+t().state.dividerMargin/2).attr("y2",t().state.padding+d+t().state.dividerMargin/2).attr("class","descr-divider"),x=c.node().getBBox(),h=Math.max(x.width,s.width);return r.attr("x2",h+3*t().state.padding),e.insert("rect",":first-child").attr("x",t().state.padding).attr("y",t().state.padding).attr("width",h+2*t().state.padding).attr("height",x.height+d+2*t().state.padding).attr("rx",t().state.radius),e},"drawDescrState"),j=y((e,n,g)=>{const s=t().state.padding,d=2*t().state.padding,c=e.node().getBBox(),l=c.width,a=c.x,r=e.append("text").attr("x",0).attr("y",t().state.titleShift).attr("font-size",t().state.fontSize).attr("class","state-title").text(n.id),x=r.node().getBBox().width+d;let h=Math.max(x,l);h===l&&(h=h+d);let o;const u=e.node().getBBox();n.doc,o=a-s,x>l&&(o=(l-h)/2+s),Math.abs(a-u.x)<s&&x>l&&(o=a-(x-l)/2);const b=1-t().state.textHeight;return e.insert("rect",":first-child").attr("x",o).attr("y",b).attr("class",g?"alt-composit":"composit").attr("width",h).attr("height",u.height+t().state.textHeight+t().state.titleShift+1).attr("rx","0"),r.attr("x",o+s),x<=l&&r.attr("x",a+(h-d)/2-x/2+s),e.insert("rect",":first-child").attr("x",o).attr("y",t().state.titleShift-t().state.textHeight-t().state.padding).attr("width",h).attr("height",t().state.textHeight*3).attr("rx",t().state.radius),e.insert("rect",":first-child").attr("x",o).attr("y",t().state.titleShift-t().state.textHeight-t().state.padding).attr("width",h).attr("height",u.height+3+2*t().state.textHeight).attr("rx",t().state.radius),e},"addTitleAndBox"),X=y(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"),_=y((e,n)=>{let g=t().state.forkWidth,s=t().state.forkHeight;if(n.parentId){let d=g;g=s,s=d}return e.append("rect").style("stroke","black").style("fill","black").attr("width",g).attr("height",s).attr("x",t().state.padding).attr("y",t().state.padding)},"drawForkJoinState"),q=y((e,n,g,s)=>{let d=0;const c=s.append("text");c.style("text-anchor","start"),c.attr("class","noteText");let l=e.replace(/\r\n/g,"<br/>");l=l.replace(/\n/g,"<br/>");const a=l.split(H.lineBreakRegex);let r=1.25*t().state.noteMargin;for(const x of a){const h=x.trim();if(h.length>0){const o=c.append("tspan");if(o.text(h),r===0){const u=o.node().getBBox();r+=u.height}d+=r,o.attr("x",n+t().state.noteMargin),o.attr("y",g+d+1.25*t().state.noteMargin)}}return{textWidth:c.node().getBBox().width,textHeight:d}},"_drawLongText"),Z=y((e,n)=>{n.attr("class","state-note");const g=n.append("rect").attr("x",0).attr("y",t().state.padding),s=n.append("g"),{textWidth:d,textHeight:c}=q(e,0,0,s);return g.attr("height",c+2*t().state.noteMargin),g.attr("width",d+t().state.noteMargin*2),g},"drawNote"),T=y(function(e,n){const g=n.id,s={id:g,label:n.id,width:0,height:0},d=e.append("g").attr("id",g).attr("class","stateGroup");n.type==="start"&&F(d),n.type==="end"&&X(d),(n.type==="fork"||n.type==="join")&&_(d,n),n.type==="note"&&Z(n.note.text,d),n.type==="divider"&&J(d),n.type==="default"&&n.descriptions.length===0&&Y(d,n),n.type==="default"&&n.descriptions.length>0&&$(d,n);const c=d.node().getBBox();return s.width=c.width+2*t().state.padding,s.height=c.height+2*t().state.padding,s},"drawState"),D=0,K=y(function(e,n,g){const s=y(function(r){switch(r){case M.relationType.AGGREGATION:return"aggregation";case M.relationType.EXTENSION:return"extension";case M.relationType.COMPOSITION:return"composition";case M.relationType.DEPENDENCY:return"dependency"}},"getRelationType");n.points=n.points.filter(r=>!Number.isNaN(r.y));const d=n.points,c=P().x(function(r){return r.x}).y(function(r){return r.y}).curve(R),l=e.append("path").attr("d",c(d)).attr("id","edge"+D).attr("class","transition");let a="";if(t().state.arrowMarkerAbsolute&&(a=U(!0)),l.attr("marker-end","url("+a+"#"+s(M.relationType.DEPENDENCY)+"End)"),g.title!==void 0){const r=e.append("g").attr("class","stateLabel"),{x,y:h}=C.calcLabelPosition(n.points),o=H.getRows(g.title);let u=0;const b=[];let w=0,N=0;for(let f=0;f<=o.length;f++){const p=r.append("text").attr("text-anchor","middle").text(o[f]).attr("x",x).attr("y",h+u),m=p.node().getBBox();w=Math.max(w,m.width),N=Math.min(N,m.x),S.info(m.x,x,h+u),u===0&&(u=p.node().getBBox().height,S.info("Title height",u,h)),b.push(p)}let E=u*o.length;if(o.length>1){const f=(o.length-1)*u*.5;b.forEach((p,m)=>p.attr("y",h+m*u-f)),E=u*o.length}const i=r.node().getBBox();r.insert("rect",":first-child").attr("class","box").attr("x",x-w/2-t().state.padding/2).attr("y",h-E/2-t().state.padding/2-3.5).attr("width",w+t().state.padding).attr("height",E+t().state.padding),S.info(i)}D++},"drawEdge"),B,z={},Q=y(function(){},"setConf"),V=y(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"),tt=y(function(e,n,g,s){B=t().state;const d=t().securityLevel;let c;d==="sandbox"&&(c=v("#i"+n));const l=d==="sandbox"?v(c.nodes()[0].contentDocument.body):v("body"),a=d==="sandbox"?c.nodes()[0].contentDocument:document;S.debug("Rendering diagram "+e);const r=l.select(`[id='${n}']`);V(r);const x=s.db.getRootDoc();L(x,r,void 0,!1,l,a,s);const h=B.padding,o=r.node().getBBox(),u=o.width+h*2,b=o.height+h*2,w=u*1.75;O(r,b,w,B.useMaxWidth),r.attr("viewBox",`${o.x-B.padding} ${o.y-B.padding} `+u+" "+b)},"draw"),et=y(e=>e?e.length*B.fontSizeFactor:1,"getLabelWidth"),L=y((e,n,g,s,d,c,l)=>{const a=new I({compound:!0,multigraph:!0});let r,x=!0;for(r=0;r<e.length;r++)if(e[r].stmt==="relation"){x=!1;break}g?a.setGraph({rankdir:"LR",multigraph:!0,compound:!0,ranker:"tight-tree",ranksep:x?1:B.edgeLengthFactor,nodeSep:x?1:50,isMultiGraph:!0}):a.setGraph({rankdir:"TB",multigraph:!0,compound:!0,ranksep:x?1:B.edgeLengthFactor,nodeSep:x?1:50,ranker:"tight-tree",isMultiGraph:!0}),a.setDefaultEdgeLabel(function(){return{}});const h=l.db.getStates(),o=l.db.getRelations(),u=Object.keys(h);for(const i of u){const f=h[i];g&&(f.parentId=g);let p;if(f.doc){let m=n.append("g").attr("id",f.id).attr("class","stateGroup");p=L(f.doc,m,f.id,!s,d,c,l);{m=j(m,f,s);let k=m.node().getBBox();p.width=k.width,p.height=k.height+B.padding/2,z[f.id]={y:B.compositTitleSize}}}else p=T(n,f,a);if(f.note){const m={descriptions:[],id:f.id+"-note",note:f.note,type:"note"},k=T(n,m,a);f.note.position==="left of"?(a.setNode(p.id+"-note",k),a.setNode(p.id,p)):(a.setNode(p.id,p),a.setNode(p.id+"-note",k)),a.setParent(p.id,p.id+"-group"),a.setParent(p.id+"-note",p.id+"-group")}else a.setNode(p.id,p)}S.debug("Count=",a.nodeCount(),a);let b=0;o.forEach(function(i){b++,S.debug("Setting edge",i),a.setEdge(i.id1,i.id2,{relation:i,width:et(i.title),height:B.labelHeight*H.getRows(i.title).length,labelpos:"c"},"id"+b)}),W(a),S.debug("Graph after layout",a.nodes());const w=n.node();a.nodes().forEach(function(i){i!==void 0&&a.node(i)!==void 0?(S.warn("Node "+i+": "+JSON.stringify(a.node(i))),d.select("#"+w.id+" #"+i).attr("transform","translate("+(a.node(i).x-a.node(i).width/2)+","+(a.node(i).y+(z[i]?z[i].y:0)-a.node(i).height/2)+" )"),d.select("#"+w.id+" #"+i).attr("data-x-shift",a.node(i).x-a.node(i).width/2),c.querySelectorAll("#"+w.id+" #"+i+" .divider").forEach(f=>{const p=f.parentElement;let m=0,k=0;p&&(p.parentElement&&(m=p.parentElement.getBBox().width),k=parseInt(p.getAttribute("data-x-shift"),10),Number.isNaN(k)&&(k=0)),f.setAttribute("x1",0-k+8),f.setAttribute("x2",m-k-8)})):S.debug("No Node "+i+": "+JSON.stringify(a.node(i)))});let N=w.getBBox();a.edges().forEach(function(i){i!==void 0&&a.edge(i)!==void 0&&(S.debug("Edge "+i.v+" -> "+i.w+": "+JSON.stringify(a.edge(i))),K(n,a.edge(i),a.edge(i).relation))}),N=w.getBBox();const E={id:g||"root",label:g||"root",width:0,height:0};return E.width=N.width+2*B.padding,E.height=N.height+2*B.padding,S.debug("Doc rendered",E,a),E},"renderDoc"),at={setConf:Q,draw:tt},ft={parser:A,get db(){return new M(1)},renderer:at,styles:G,init:y(e=>{e.state||(e.state={}),e.state.arrowMarkerAbsolute=e.arrowMarkerAbsolute},"init")};export{ft as diagram};
//# sourceMappingURL=stateDiagram-FKZM4ZOC-CbhoquXf.chunk.mjs.map