"use strict";(self["webpackChunk_flowforge_node_red_dashboard"]=self["webpackChunk_flowforge_node_red_dashboard"]||[]).push([[655],{24655:function(e,t,s){s.d(t,{diagram:function(){return Q}});s(57658);var o=s(4861),r=s(66666),i=s(68510),n=s(40370),a=s(16910);s(55743),s(84747),s(3617),s(39339),s(51294);const d="rect",c="rectWithTitle",l="start",p="end",b="divider",g="roundedWithTitle",h="note",u="noteGroup",y="statediagram",f="state",$=`${y}-${f}`,w="transition",x="note",m="note-edge",T=`${w} ${m}`,k=`${y}-${x}`,S="cluster",D=`${y}-${S}`,A="cluster-alt",v=`${y}-${A}`,B="parent",_="note",C="state",E="----",R=`${E}${_}`,V=`${E}${B}`,N="fill:none",L="fill: #333",M="c",z="text",I="normal";let P={},W=0;const Y=function(e){const t=Object.keys(e);for(const s of t)e[s]},j=function(e,t){return t.db.extract(t.db.getRootDocV2()),t.db.getClasses()};function G(e){return void 0===e||null===e?"":e.classes?e.classes.join(" "):""}function O(e="",t=0,s="",o=E){const r=null!==s&&s.length>0?`${o}${s}`:"";return`${C}-${e}${r}-${t}`}const q=(e,t,s,r,i,a)=>{const y=s.id,f=G(r[y]);if("root"!==y){let t=d;!0===s.start&&(t=l),!1===s.start&&(t=p),s.type!==o.D&&(t=s.type),P[y]||(P[y]={id:y,shape:t,description:n.e.sanitizeText(y,(0,n.c)()),classes:`${f} ${$}`});const r=P[y];s.description&&(Array.isArray(r.description)?(r.shape=c,r.description.push(s.description)):r.description.length>0?(r.shape=c,r.description===y?r.description=[s.description]:r.description=[r.description,s.description]):(r.shape=d,r.description=s.description),r.description=n.e.sanitizeTextOrArray(r.description,(0,n.c)())),1===r.description.length&&r.shape===c&&(r.shape=d),!r.type&&s.doc&&(n.l.info("Setting cluster for ",y,H(s)),r.type="group",r.dir=H(s),r.shape=s.type===o.a?b:g,r.classes=r.classes+" "+D+" "+(a?v:""));const i={labelStyle:"",shape:r.shape,labelText:r.description,classes:r.classes,style:"",id:y,dir:r.dir,domId:O(y,W),type:r.type,padding:15,centerLabel:!0};if(s.note){const t={labelStyle:"",shape:h,labelText:s.note.text,classes:k,style:"",id:y+R+"-"+W,domId:O(y,W,_),type:r.type,padding:15},o={labelStyle:"",shape:u,labelText:s.note.text,classes:r.classes,style:"",id:y+V,domId:O(y,W,B),type:"group",padding:0};W++;const n=y+V;e.setNode(n,o),e.setNode(t.id,t),e.setNode(y,i),e.setParent(y,n),e.setParent(t.id,n);let a=y,d=t.id;"left of"===s.note.position&&(a=t.id,d=y),e.setEdge(a,d,{arrowhead:"none",arrowType:"",style:N,labelStyle:"",classes:T,arrowheadStyle:L,labelpos:M,labelType:z,thickness:I})}else e.setNode(y,i)}t&&"root"!==t.id&&(n.l.trace("Setting node ",y," to be child of its parent ",t.id),e.setParent(y,t.id)),s.doc&&(n.l.trace("Adding nodes children "),F(e,s,s.doc,r,i,!a))},F=(e,t,s,r,i,a)=>{n.l.trace("items",s),s.forEach((s=>{switch(s.stmt){case o.b:q(e,t,s,r,i,a);break;case o.D:q(e,t,s,r,i,a);break;case o.S:{q(e,t,s.state1,r,i,a),q(e,t,s.state2,r,i,a);const o={id:"edge"+W,arrowhead:"normal",arrowTypeEnd:"arrow_barb",style:N,labelStyle:"",label:n.e.sanitizeText(s.description,(0,n.c)()),arrowheadStyle:L,labelpos:M,labelType:z,thickness:I,classes:w};e.setEdge(s.state1.id,s.state2.id,o,W),W++}break}}))},H=(e,t=o.c)=>{let s=t;if(e.doc)for(let o=0;o<e.doc.length;o++){const t=e.doc[o];"dir"===t.stmt&&(s=t.value)}return s},J=async function(e,t,s,o){n.l.info("Drawing state diagram (v2)",t),P={},o.db.getDirection();const{securityLevel:c,state:l}=(0,n.c)(),p=l.nodeSpacing||50,b=l.rankSpacing||50;n.l.info(o.db.getRootDocV2()),o.db.extract(o.db.getRootDocV2()),n.l.info(o.db.getRootDocV2());const g=o.db.getStates(),h=new r.k({multigraph:!0,compound:!0}).setGraph({rankdir:H(o.db.getRootDocV2()),nodesep:p,ranksep:b,marginx:8,marginy:8}).setDefaultEdgeLabel((function(){return{}}));let u;q(h,void 0,o.db.getRootDocV2(),g,o.db,!0),"sandbox"===c&&(u=(0,i.Ys)("#i"+t));const f="sandbox"===c?(0,i.Ys)(u.nodes()[0].contentDocument.body):(0,i.Ys)("body"),$=f.select(`[id="${t}"]`),w=f.select("#"+t+" g");await(0,a.r)(w,h,["barb"],y,t);const x=8;n.u.insertTitle($,"statediagramTitleText",l.titleTopMargin,o.db.getDiagramTitle());const m=$.node().getBBox(),T=m.width+2*x,k=m.height+2*x;$.attr("class",y);const S=$.node().getBBox();(0,n.i)($,k,T,l.useMaxWidth);const D=`${S.x-x} ${S.y-x} ${T} ${k}`;n.l.debug(`viewBox ${D}`),$.attr("viewBox",D);const A=document.querySelectorAll('[id="'+t+'"] .edgeLabel .label');for(const r of A){const e=r.getBBox(),t=document.createElementNS("http://www.w3.org/2000/svg",d);t.setAttribute("rx",0),t.setAttribute("ry",0),t.setAttribute("width",e.width),t.setAttribute("height",e.height),r.insertBefore(t,r.firstChild)}},K={setConf:Y,getClasses:j,draw:J},Q={parser:o.p,db:o.d,renderer:K,styles:o.s,init:e=>{e.state||(e.state={}),e.state.arrowMarkerAbsolute=e.arrowMarkerAbsolute,o.d.clear()}}}}]);
//# sourceMappingURL=655.a53e5df9.js.map