You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
11 KiB
1 line
11 KiB
"use strict";(self.webpackChunkjupyter_web=self.webpackChunkjupyter_web||[]).push([[1553],{21553:(rt,O,f)=>{f.r(O),f.d(O,{diagram:()=>it});var _,m=f(47989),I=(f(23242),f(76794),f(79487),f(11930),f(9681),f(25333),f(77437),f(50027),f(62477)),t=f(3685),S=f(31083),A=f(20222),C=f(75788),P={},R=(0,t.eW)((e,a)=>{P[e]=a},"set"),U=(0,t.eW)(e=>P[e],"get"),D=(0,t.eW)(()=>Object.keys(P),"keys"),H=(0,t.eW)(()=>D().length,"size"),z={get:U,set:R,keys:D,size:H},K=(0,t.eW)(e=>e.append("circle").attr("class","start-state").attr("r",(0,t.nV)().state.sizeUnit).attr("cx",(0,t.nV)().state.padding+(0,t.nV)().state.sizeUnit).attr("cy",(0,t.nV)().state.padding+(0,t.nV)().state.sizeUnit),"drawStartState"),j=(0,t.eW)(e=>e.append("line").style("stroke","grey").style("stroke-dasharray","3").attr("x1",(0,t.nV)().state.textHeight).attr("class","divider").attr("x2",2*(0,t.nV)().state.textHeight).attr("y1",0).attr("y2",0),"drawDivider"),Y=(0,t.eW)((e,a)=>{const d=e.append("text").attr("x",2*(0,t.nV)().state.padding).attr("y",(0,t.nV)().state.textHeight+2*(0,t.nV)().state.padding).attr("font-size",(0,t.nV)().state.fontSize).attr("class","state-title").text(a.id),o=d.node().getBBox();return e.insert("rect",":first-child").attr("x",(0,t.nV)().state.padding).attr("y",(0,t.nV)().state.padding).attr("width",o.width+2*(0,t.nV)().state.padding).attr("height",o.height+2*(0,t.nV)().state.padding).attr("rx",(0,t.nV)().state.radius),d},"drawSimpleState"),G=(0,t.eW)((e,a)=>{const d=(0,t.eW)(function(g,E,y){const M=g.append("tspan").attr("x",2*(0,t.nV)().state.padding).text(E);y||M.attr("dy",(0,t.nV)().state.textHeight)},"addTspan"),r=e.append("text").attr("x",2*(0,t.nV)().state.padding).attr("y",(0,t.nV)().state.textHeight+1.3*(0,t.nV)().state.padding).attr("font-size",(0,t.nV)().state.fontSize).attr("class","state-title").text(a.descriptions[0]).node().getBBox(),l=r.height,x=e.append("text").attr("x",(0,t.nV)().state.padding).attr("y",l+.4*(0,t.nV)().state.padding+(0,t.nV)().state.dividerMargin+(0,t.nV)().state.textHeight).attr("class","state-description");let n=!0,s=!0;a.descriptions.forEach(function(g){n||(d(x,g,s),s=!1),n=!1});const V=e.append("line").attr("x1",(0,t.nV)().state.padding).attr("y1",(0,t.nV)().state.padding+l+(0,t.nV)().state.dividerMargin/2).attr("y2",(0,t.nV)().state.padding+l+(0,t.nV)().state.dividerMargin/2).attr("class","descr-divider"),p=x.node().getBBox(),c=Math.max(p.width,r.width);return V.attr("x2",c+3*(0,t.nV)().state.padding),e.insert("rect",":first-child").attr("x",(0,t.nV)().state.padding).attr("y",(0,t.nV)().state.padding).attr("width",c+2*(0,t.nV)().state.padding).attr("height",p.height+l+2*(0,t.nV)().state.padding).attr("rx",(0,t.nV)().state.radius),e},"drawDescrState"),J=(0,t.eW)((e,a,d)=>{const o=(0,t.nV)().state.padding,r=2*(0,t.nV)().state.padding,l=e.node().getBBox(),x=l.width,n=l.x,s=e.append("text").attr("x",0).attr("y",(0,t.nV)().state.titleShift).attr("font-size",(0,t.nV)().state.fontSize).attr("class","state-title").text(a.id),p=s.node().getBBox().width+r;let g,c=Math.max(p,x);c===x&&(c+=r);const E=e.node().getBBox();a.doc,g=n-o,p>x&&(g=(x-c)/2+o),Math.abs(n-E.x)<o&&p>x&&(g=n-(p-x)/2);const y=1-(0,t.nV)().state.textHeight;return e.insert("rect",":first-child").attr("x",g).attr("y",y).attr("class",d?"alt-composit":"composit").attr("width",c).attr("height",E.height+(0,t.nV)().state.textHeight+(0,t.nV)().state.titleShift+1).attr("rx","0"),s.attr("x",g+o),p<=x&&s.attr("x",n+(c-r)/2-p/2+o),e.insert("rect",":first-child").attr("x",g).attr("y",(0,t.nV)().state.titleShift-(0,t.nV)().state.textHeight-(0,t.nV)().state.padding).attr("width",c).attr("height",3*(0,t.nV)().state.textHeight).attr("rx",(0,t.nV)().state.radius),e.insert("rect",":first-child").attr("x",g).attr("y",(0,t.nV)().state.titleShift-(0,t.nV)().state.textHeight-(0,t.nV)().state.padding).attr("width",c).attr("height",E.height+3+2*(0,t.nV)().state.textHeight).attr("rx",(0,t.nV)().state.radius),e},"addTitleAndBox"),F=(0,t.eW)(e=>(e.append("circle").attr("class","end-state-outer").attr("r",(0,t.nV)().state.sizeUnit+(0,t.nV)().state.miniPadding).attr("cx",(0,t.nV)().state.padding+(0,t.nV)().state.sizeUnit+(0,t.nV)().state.miniPadding).attr("cy",(0,t.nV)().state.padding+(0,t.nV)().state.sizeUnit+(0,t.nV)().state.miniPadding),e.append("circle").attr("class","end-state-inner").attr("r",(0,t.nV)().state.sizeUnit).attr("cx",(0,t.nV)().state.padding+(0,t.nV)().state.sizeUnit+2).attr("cy",(0,t.nV)().state.padding+(0,t.nV)().state.sizeUnit+2)),"drawEndState"),X=(0,t.eW)((e,a)=>{let d=(0,t.nV)().state.forkWidth,o=(0,t.nV)().state.forkHeight;if(a.parentId){let r=d;d=o,o=r}return e.append("rect").style("stroke","black").style("fill","black").attr("width",d).attr("height",o).attr("x",(0,t.nV)().state.padding).attr("y",(0,t.nV)().state.padding)},"drawForkJoinState"),Z=(0,t.eW)((e,a,d,o)=>{let r=0;const l=o.append("text");l.style("text-anchor","start"),l.attr("class","noteText");let x=e.replace(/\r\n/g,"<br/>");x=x.replace(/\n/g,"<br/>");const n=x.split(t.SY.lineBreakRegex);let s=1.25*(0,t.nV)().state.noteMargin;for(const V of n){const p=V.trim();if(p.length>0){const c=l.append("tspan");c.text(p),0===s&&(s+=c.node().getBBox().height),r+=s,c.attr("x",a+(0,t.nV)().state.noteMargin),c.attr("y",d+r+1.25*(0,t.nV)().state.noteMargin)}}return{textWidth:l.node().getBBox().width,textHeight:r}},"_drawLongText"),$=(0,t.eW)((e,a)=>{a.attr("class","state-note");const d=a.append("rect").attr("x",0).attr("y",(0,t.nV)().state.padding),o=a.append("g"),{textWidth:r,textHeight:l}=Z(e,0,0,o);return d.attr("height",l+2*(0,t.nV)().state.noteMargin),d.attr("width",r+2*(0,t.nV)().state.noteMargin),d},"drawNote"),k=(0,t.eW)(function(e,a){const d=a.id,o={id:d,label:a.id,width:0,height:0},r=e.append("g").attr("id",d).attr("class","stateGroup");"start"===a.type&&K(r),"end"===a.type&&F(r),("fork"===a.type||"join"===a.type)&&X(r,a),"note"===a.type&&$(a.note.text,r),"divider"===a.type&&j(r),"default"===a.type&&0===a.descriptions.length&&Y(r,a),"default"===a.type&&a.descriptions.length>0&&G(r,a);const l=r.node().getBBox();return o.width=l.width+2*(0,t.nV)().state.padding,o.height=l.height+2*(0,t.nV)().state.padding,z.set(d,o),o},"drawState"),N=0,Q=(0,t.eW)(function(e,a,d){const o=(0,t.eW)(function(s){switch(s){case m.oI.relationType.AGGREGATION:return"aggregation";case m.oI.relationType.EXTENSION:return"extension";case m.oI.relationType.COMPOSITION:return"composition";case m.oI.relationType.DEPENDENCY:return"dependency"}},"getRelationType");a.points=a.points.filter(s=>!Number.isNaN(s.y));const r=a.points,l=(0,S.jvg)().x(function(s){return s.x}).y(function(s){return s.y}).curve(S.$0Z),x=e.append("path").attr("d",l(r)).attr("id","edge"+N).attr("class","transition");let n="";if((0,t.nV)().state.arrowMarkerAbsolute&&(n=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,n=n.replace(/\(/g,"\\("),n=n.replace(/\)/g,"\\)")),x.attr("marker-end","url("+n+"#"+o(m.oI.relationType.DEPENDENCY)+"End)"),void 0!==d.title){const s=e.append("g").attr("class","stateLabel"),{x:V,y:p}=I.w8.calcLabelPosition(a.points),c=t.SY.getRows(d.title);let g=0;const E=[];let y=0,M=0;for(let i=0;i<=c.length;i++){const u=s.append("text").attr("text-anchor","middle").text(c[i]).attr("x",V).attr("y",p+g),h=u.node().getBBox();y=Math.max(y,h.width),M=Math.min(M,h.x),t.cM.info(h.x,V,p+g),0===g&&(g=u.node().getBBox().height,t.cM.info("Title height",g,p)),E.push(u)}let v=g*c.length;if(c.length>1){const i=(c.length-1)*g*.5;E.forEach((u,h)=>u.attr("y",p+h*g-i)),v=g*c.length}const W=s.node().getBBox();s.insert("rect",":first-child").attr("class","box").attr("x",V-y/2-(0,t.nV)().state.padding/2).attr("y",p-v/2-(0,t.nV)().state.padding/2-3.5).attr("width",y+(0,t.nV)().state.padding).attr("height",v+(0,t.nV)().state.padding),t.cM.info(W)}N++},"drawEdge"),T={},q=(0,t.eW)(function(){},"setConf"),tt=(0,t.eW)(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"),et=(0,t.eW)(function(e,a,d,o){_=(0,t.nV)().state;const r=(0,t.nV)().securityLevel;let l;"sandbox"===r&&(l=(0,S.Ys)("#i"+a));const x="sandbox"===r?(0,S.Ys)(l.nodes()[0].contentDocument.body):(0,S.Ys)("body"),n="sandbox"===r?l.nodes()[0].contentDocument:document;t.cM.debug("Rendering diagram "+e);const s=x.select(`[id='${a}']`);tt(s);const V=o.db.getRootDoc();L(V,s,void 0,!1,x,n,o);const p=_.padding,c=s.node().getBBox(),g=c.width+2*p,E=c.height+2*p,y=1.75*g;(0,t.v2)(s,E,y,_.useMaxWidth),s.attr("viewBox",`${c.x-_.padding} ${c.y-_.padding} `+g+" "+E)},"draw"),nt=(0,t.eW)(e=>e?e.length*_.fontSizeFactor:1,"getLabelWidth"),L=(0,t.eW)((e,a,d,o,r,l,x)=>{const n=new C.k({compound:!0,multigraph:!0});let s,V=!0;for(s=0;s<e.length;s++)if("relation"===e[s].stmt){V=!1;break}d?n.setGraph({rankdir:"LR",multigraph:!0,compound:!0,ranker:"tight-tree",ranksep:V?1:_.edgeLengthFactor,nodeSep:V?1:50,isMultiGraph:!0}):n.setGraph({rankdir:"TB",multigraph:!0,compound:!0,ranksep:V?1:_.edgeLengthFactor,nodeSep:V?1:50,ranker:"tight-tree",isMultiGraph:!0}),n.setDefaultEdgeLabel(function(){return{}});const p=x.db.getStates(),c=x.db.getRelations(),g=Object.keys(p);for(const i of g){const u=p[i];let h;if(d&&(u.parentId=d),u.doc){let B=a.append("g").attr("id",u.id).attr("class","stateGroup");h=L(u.doc,B,u.id,!o,r,l,x);{B=J(B,u,o);let w=B.node().getBBox();h.width=w.width,h.height=w.height+_.padding/2,T[u.id]={y:_.compositTitleSize}}}else h=k(a,u,n);if(u.note){const B={descriptions:[],id:u.id+"-note",note:u.note,type:"note"},w=k(a,B,n);"left of"===u.note.position?(n.setNode(h.id+"-note",w),n.setNode(h.id,h)):(n.setNode(h.id,h),n.setNode(h.id+"-note",w)),n.setParent(h.id,h.id+"-group"),n.setParent(h.id+"-note",h.id+"-group")}else n.setNode(h.id,h)}t.cM.debug("Count=",n.nodeCount(),n);let y=0;c.forEach(function(i){y++,t.cM.debug("Setting edge",i),n.setEdge(i.id1,i.id2,{relation:i,width:nt(i.title),height:_.labelHeight*t.SY.getRows(i.title).length,labelpos:"c"},"id"+y)}),(0,A.bK)(n),t.cM.debug("Graph after layout",n.nodes());const M=a.node();n.nodes().forEach(function(i){void 0!==i&&void 0!==n.node(i)?(t.cM.warn("Node "+i+": "+JSON.stringify(n.node(i))),r.select("#"+M.id+" #"+i).attr("transform","translate("+(n.node(i).x-n.node(i).width/2)+","+(n.node(i).y+(T[i]?T[i].y:0)-n.node(i).height/2)+" )"),r.select("#"+M.id+" #"+i).attr("data-x-shift",n.node(i).x-n.node(i).width/2),l.querySelectorAll("#"+M.id+" #"+i+" .divider").forEach(h=>{const B=h.parentElement;let w=0,b=0;B&&(B.parentElement&&(w=B.parentElement.getBBox().width),b=parseInt(B.getAttribute("data-x-shift"),10),Number.isNaN(b)&&(b=0)),h.setAttribute("x1",0-b+8),h.setAttribute("x2",w-b-8)})):t.cM.debug("No Node "+i+": "+JSON.stringify(n.node(i)))});let v=M.getBBox();n.edges().forEach(function(i){void 0!==i&&void 0!==n.edge(i)&&(t.cM.debug("Edge "+i.v+" -> "+i.w+": "+JSON.stringify(n.edge(i))),Q(a,n.edge(i),n.edge(i).relation))}),v=M.getBBox();const W={id:d||"root",label:d||"root",width:0,height:0};return W.width=v.width+2*_.padding,W.height=v.height+2*_.padding,t.cM.debug("Doc rendered",W,n),W},"renderDoc"),at={setConf:q,draw:et},it={parser:m.J8,get db(){return new m.oI(1)},renderer:at,styles:m.Ee,init:(0,t.eW)(e=>{e.state||(e.state={}),e.state.arrowMarkerAbsolute=e.arrowMarkerAbsolute},"init")}}}]); |