docs.waku.org/assets/js/8142.b86f4ff8.js
2025-10-03 11:14:33 +00:00

1 line
11 KiB
JavaScript

"use strict";(self.webpackChunkwaku_guide=self.webpackChunkwaku_guide||[]).push([[8142],{88142:(t,e,a)=>{a.d(e,{diagram:()=>R});var i,n=a(54616),r=(a(89625),a(21152),a(10045),a(5164),a(28698),a(5894),a(63245),a(32387),a(30092),a(13226)),d=a(67633),s=a(40797),o=a(70451),g=a(62334),p=a(697),h=(0,s.K2)(t=>t.append("circle").attr("class","start-state").attr("r",(0,d.D7)().state.sizeUnit).attr("cx",(0,d.D7)().state.padding+(0,d.D7)().state.sizeUnit).attr("cy",(0,d.D7)().state.padding+(0,d.D7)().state.sizeUnit),"drawStartState"),c=(0,s.K2)(t=>t.append("line").style("stroke","grey").style("stroke-dasharray","3").attr("x1",(0,d.D7)().state.textHeight).attr("class","divider").attr("x2",2*(0,d.D7)().state.textHeight).attr("y1",0).attr("y2",0),"drawDivider"),l=(0,s.K2)((t,e)=>{const a=t.append("text").attr("x",2*(0,d.D7)().state.padding).attr("y",(0,d.D7)().state.textHeight+2*(0,d.D7)().state.padding).attr("font-size",(0,d.D7)().state.fontSize).attr("class","state-title").text(e.id),i=a.node().getBBox();return t.insert("rect",":first-child").attr("x",(0,d.D7)().state.padding).attr("y",(0,d.D7)().state.padding).attr("width",i.width+2*(0,d.D7)().state.padding).attr("height",i.height+2*(0,d.D7)().state.padding).attr("rx",(0,d.D7)().state.radius),a},"drawSimpleState"),x=(0,s.K2)((t,e)=>{const a=(0,s.K2)(function(t,e,a){const i=t.append("tspan").attr("x",2*(0,d.D7)().state.padding).text(e);a||i.attr("dy",(0,d.D7)().state.textHeight)},"addTspan"),i=t.append("text").attr("x",2*(0,d.D7)().state.padding).attr("y",(0,d.D7)().state.textHeight+1.3*(0,d.D7)().state.padding).attr("font-size",(0,d.D7)().state.fontSize).attr("class","state-title").text(e.descriptions[0]).node().getBBox(),n=i.height,r=t.append("text").attr("x",(0,d.D7)().state.padding).attr("y",n+.4*(0,d.D7)().state.padding+(0,d.D7)().state.dividerMargin+(0,d.D7)().state.textHeight).attr("class","state-description");let o=!0,g=!0;e.descriptions.forEach(function(t){o||(a(r,t,g),g=!1),o=!1});const p=t.append("line").attr("x1",(0,d.D7)().state.padding).attr("y1",(0,d.D7)().state.padding+n+(0,d.D7)().state.dividerMargin/2).attr("y2",(0,d.D7)().state.padding+n+(0,d.D7)().state.dividerMargin/2).attr("class","descr-divider"),h=r.node().getBBox(),c=Math.max(h.width,i.width);return p.attr("x2",c+3*(0,d.D7)().state.padding),t.insert("rect",":first-child").attr("x",(0,d.D7)().state.padding).attr("y",(0,d.D7)().state.padding).attr("width",c+2*(0,d.D7)().state.padding).attr("height",h.height+n+2*(0,d.D7)().state.padding).attr("rx",(0,d.D7)().state.radius),t},"drawDescrState"),D=(0,s.K2)((t,e,a)=>{const i=(0,d.D7)().state.padding,n=2*(0,d.D7)().state.padding,r=t.node().getBBox(),s=r.width,o=r.x,g=t.append("text").attr("x",0).attr("y",(0,d.D7)().state.titleShift).attr("font-size",(0,d.D7)().state.fontSize).attr("class","state-title").text(e.id),p=g.node().getBBox().width+n;let h,c=Math.max(p,s);c===s&&(c+=n);const l=t.node().getBBox();e.doc,h=o-i,p>s&&(h=(s-c)/2+i),Math.abs(o-l.x)<i&&p>s&&(h=o-(p-s)/2);const x=1-(0,d.D7)().state.textHeight;return t.insert("rect",":first-child").attr("x",h).attr("y",x).attr("class",a?"alt-composit":"composit").attr("width",c).attr("height",l.height+(0,d.D7)().state.textHeight+(0,d.D7)().state.titleShift+1).attr("rx","0"),g.attr("x",h+i),p<=s&&g.attr("x",o+(c-n)/2-p/2+i),t.insert("rect",":first-child").attr("x",h).attr("y",(0,d.D7)().state.titleShift-(0,d.D7)().state.textHeight-(0,d.D7)().state.padding).attr("width",c).attr("height",3*(0,d.D7)().state.textHeight).attr("rx",(0,d.D7)().state.radius),t.insert("rect",":first-child").attr("x",h).attr("y",(0,d.D7)().state.titleShift-(0,d.D7)().state.textHeight-(0,d.D7)().state.padding).attr("width",c).attr("height",l.height+3+2*(0,d.D7)().state.textHeight).attr("rx",(0,d.D7)().state.radius),t},"addTitleAndBox"),u=(0,s.K2)(t=>(t.append("circle").attr("class","end-state-outer").attr("r",(0,d.D7)().state.sizeUnit+(0,d.D7)().state.miniPadding).attr("cx",(0,d.D7)().state.padding+(0,d.D7)().state.sizeUnit+(0,d.D7)().state.miniPadding).attr("cy",(0,d.D7)().state.padding+(0,d.D7)().state.sizeUnit+(0,d.D7)().state.miniPadding),t.append("circle").attr("class","end-state-inner").attr("r",(0,d.D7)().state.sizeUnit).attr("cx",(0,d.D7)().state.padding+(0,d.D7)().state.sizeUnit+2).attr("cy",(0,d.D7)().state.padding+(0,d.D7)().state.sizeUnit+2)),"drawEndState"),f=(0,s.K2)((t,e)=>{let a=(0,d.D7)().state.forkWidth,i=(0,d.D7)().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",(0,d.D7)().state.padding).attr("y",(0,d.D7)().state.padding)},"drawForkJoinState"),y=(0,s.K2)((t,e,a,i)=>{let n=0;const r=i.append("text");r.style("text-anchor","start"),r.attr("class","noteText");let s=t.replace(/\r\n/g,"<br/>");s=s.replace(/\n/g,"<br/>");const o=s.split(d.Y2.lineBreakRegex);let g=1.25*(0,d.D7)().state.noteMargin;for(const p of o){const t=p.trim();if(t.length>0){const i=r.append("tspan");if(i.text(t),0===g){g+=i.node().getBBox().height}n+=g,i.attr("x",e+(0,d.D7)().state.noteMargin),i.attr("y",a+n+1.25*(0,d.D7)().state.noteMargin)}}return{textWidth:r.node().getBBox().width,textHeight:n}},"_drawLongText"),w=(0,s.K2)((t,e)=>{e.attr("class","state-note");const a=e.append("rect").attr("x",0).attr("y",(0,d.D7)().state.padding),i=e.append("g"),{textWidth:n,textHeight:r}=y(t,0,0,i);return a.attr("height",r+2*(0,d.D7)().state.noteMargin),a.attr("width",n+2*(0,d.D7)().state.noteMargin),a},"drawNote"),m=(0,s.K2)(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&&h(n),"end"===e.type&&u(n),"fork"!==e.type&&"join"!==e.type||f(n,e),"note"===e.type&&w(e.note.text,n),"divider"===e.type&&c(n),"default"===e.type&&0===e.descriptions.length&&l(n,e),"default"===e.type&&e.descriptions.length>0&&x(n,e);const r=n.node().getBBox();return i.width=r.width+2*(0,d.D7)().state.padding,i.height=r.height+2*(0,d.D7)().state.padding,i},"drawState"),b=0,B=(0,s.K2)(function(t,e,a){const i=(0,s.K2)(function(t){switch(t){case n.u4.relationType.AGGREGATION:return"aggregation";case n.u4.relationType.EXTENSION:return"extension";case n.u4.relationType.COMPOSITION:return"composition";case n.u4.relationType.DEPENDENCY:return"dependency"}},"getRelationType");e.points=e.points.filter(t=>!Number.isNaN(t.y));const g=e.points,p=(0,o.n8j)().x(function(t){return t.x}).y(function(t){return t.y}).curve(o.qrM),h=t.append("path").attr("d",p(g)).attr("id","edge"+b).attr("class","transition");let c="";if((0,d.D7)().state.arrowMarkerAbsolute&&(c=(0,d.ID)(!0)),h.attr("marker-end","url("+c+"#"+i(n.u4.relationType.DEPENDENCY)+"End)"),void 0!==a.title){const i=t.append("g").attr("class","stateLabel"),{x:n,y:o}=r._K.calcLabelPosition(e.points),g=d.Y2.getRows(a.title);let p=0;const h=[];let c=0,l=0;for(let t=0;t<=g.length;t++){const e=i.append("text").attr("text-anchor","middle").text(g[t]).attr("x",n).attr("y",o+p),a=e.node().getBBox();if(c=Math.max(c,a.width),l=Math.min(l,a.x),s.Rm.info(a.x,n,o+p),0===p){const t=e.node().getBBox();p=t.height,s.Rm.info("Title height",p,o)}h.push(e)}let x=p*g.length;if(g.length>1){const t=(g.length-1)*p*.5;h.forEach((e,a)=>e.attr("y",o+a*p-t)),x=p*g.length}const D=i.node().getBBox();i.insert("rect",":first-child").attr("class","box").attr("x",n-c/2-(0,d.D7)().state.padding/2).attr("y",o-x/2-(0,d.D7)().state.padding/2-3.5).attr("width",c+(0,d.D7)().state.padding).attr("height",x+(0,d.D7)().state.padding),s.Rm.info(D)}b++},"drawEdge"),k={},S=(0,s.K2)(function(){},"setConf"),N=(0,s.K2)(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"),E=(0,s.K2)(function(t,e,a,n){i=(0,d.D7)().state;const r=(0,d.D7)().securityLevel;let g;"sandbox"===r&&(g=(0,o.Ltv)("#i"+e));const p="sandbox"===r?(0,o.Ltv)(g.nodes()[0].contentDocument.body):(0,o.Ltv)("body"),h="sandbox"===r?g.nodes()[0].contentDocument:document;s.Rm.debug("Rendering diagram "+t);const c=p.select(`[id='${e}']`);N(c);const l=n.db.getRootDoc();v(l,c,void 0,!1,p,h,n);const x=i.padding,D=c.node().getBBox(),u=D.width+2*x,f=D.height+2*x,y=1.75*u;(0,d.a$)(c,f,y,i.useMaxWidth),c.attr("viewBox",`${D.x-i.padding} ${D.y-i.padding} `+u+" "+f)},"draw"),M=(0,s.K2)(t=>t?t.length*i.fontSizeFactor:1,"getLabelWidth"),v=(0,s.K2)((t,e,a,n,r,o,h)=>{const c=new p.T({compound:!0,multigraph:!0});let l,x=!0;for(l=0;l<t.length;l++)if("relation"===t[l].stmt){x=!1;break}a?c.setGraph({rankdir:"LR",multigraph:!0,compound:!0,ranker:"tight-tree",ranksep:x?1:i.edgeLengthFactor,nodeSep:x?1:50,isMultiGraph:!0}):c.setGraph({rankdir:"TB",multigraph:!0,compound:!0,ranksep:x?1:i.edgeLengthFactor,nodeSep:x?1:50,ranker:"tight-tree",isMultiGraph:!0}),c.setDefaultEdgeLabel(function(){return{}});const u=h.db.getStates(),f=h.db.getRelations(),y=Object.keys(u);for(const d of y){const t=u[d];let s;if(a&&(t.parentId=a),t.doc){let a=e.append("g").attr("id",t.id).attr("class","stateGroup");s=v(t.doc,a,t.id,!n,r,o,h);{a=D(a,t,n);let e=a.node().getBBox();s.width=e.width,s.height=e.height+i.padding/2,k[t.id]={y:i.compositTitleSize}}}else s=m(e,t,c);if(t.note){const a={descriptions:[],id:t.id+"-note",note:t.note,type:"note"},i=m(e,a,c);"left of"===t.note.position?(c.setNode(s.id+"-note",i),c.setNode(s.id,s)):(c.setNode(s.id,s),c.setNode(s.id+"-note",i)),c.setParent(s.id,s.id+"-group"),c.setParent(s.id+"-note",s.id+"-group")}else c.setNode(s.id,s)}s.Rm.debug("Count=",c.nodeCount(),c);let w=0;f.forEach(function(t){w++,s.Rm.debug("Setting edge",t),c.setEdge(t.id1,t.id2,{relation:t,width:M(t.title),height:i.labelHeight*d.Y2.getRows(t.title).length,labelpos:"c"},"id"+w)}),(0,g.Zp)(c),s.Rm.debug("Graph after layout",c.nodes());const b=e.node();c.nodes().forEach(function(t){if(void 0!==t&&void 0!==c.node(t)){s.Rm.warn("Node "+t+": "+JSON.stringify(c.node(t))),r.select("#"+b.id+" #"+t).attr("transform","translate("+(c.node(t).x-c.node(t).width/2)+","+(c.node(t).y+(k[t]?k[t].y:0)-c.node(t).height/2)+" )"),r.select("#"+b.id+" #"+t).attr("data-x-shift",c.node(t).x-c.node(t).width/2);o.querySelectorAll("#"+b.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 s.Rm.debug("No Node "+t+": "+JSON.stringify(c.node(t)))});let S=b.getBBox();c.edges().forEach(function(t){void 0!==t&&void 0!==c.edge(t)&&(s.Rm.debug("Edge "+t.v+" -> "+t.w+": "+JSON.stringify(c.edge(t))),B(e,c.edge(t),c.edge(t).relation))}),S=b.getBBox();const N={id:a||"root",label:a||"root",width:0,height:0};return N.width=S.width+2*i.padding,N.height=S.height+2*i.padding,s.Rm.debug("Doc rendered",N,c),N},"renderDoc"),K={setConf:S,draw:E},R={parser:n.Zk,get db(){return new n.u4(1)},renderer:K,styles:n.tM,init:(0,s.K2)(t=>{t.state||(t.state={}),t.state.arrowMarkerAbsolute=t.arrowMarkerAbsolute},"init")}}}]);