nodered_cfg/node_modules/@flowfuse/node-red-dashboard/dist/assets/flowDiagram-d6f8fe3a-7u7sIj1R.js

5 lines
21 KiB
JavaScript
Raw Normal View History

2024-08-24 20:48:14 +02:00
import{p as St,f as W}from"./flowDb-ff651a22-BhvlhwYW.js";import{h as S,u as Lt,r as Et,p as _t,l as Tt,d as M,f as tt,G as Nt}from"./layout-DtdJliGi.js";import{h as m,o as P,p as z,q as et,c as J,j as rt,l as R,r as V,t as At}from"./index-BPCszWWQ.js";import{a as N,b as at,i as nt,c as _,e as st,d as it,f as Ct,g as It,s as Bt}from"./styles-1b0c237a-DEBp4bhg.js";import{l as Mt}from"./line-DZ-Aqgz-.js";import"./index-f58d48f9-CLIR902B.js";import"./edges-0005682e-uu5Q-DT8.js";import"./createText-3b1f58a4-B660LV3z.js";import"./svgDraw-70101091-Dh3U16Ho.js";import"./array-BKyUJesY.js";function Dt(r){if(!r.ok)throw new Error(r.status+" "+r.statusText);return r.text()}function Rt(r,e){return fetch(r,e).then(Dt)}function Gt(r){return(e,t)=>Rt(e,t).then(n=>new DOMParser().parseFromString(n,r))}var Pt=Gt("image/svg+xml"),Y={normal:$t,vee:Wt,undirected:Vt};function Ut(r){Y=r}function $t(r,e,t,n){var a=r.append("marker").attr("id",e).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerUnits","strokeWidth").attr("markerWidth",8).attr("markerHeight",6).attr("orient","auto"),s=a.append("path").attr("d","M 0 0 L 10 5 L 0 10 z").style("stroke-width",1).style("stroke-dasharray","1,0");N(s,t[n+"Style"]),t[n+"Class"]&&s.attr("class",t[n+"Class"])}function Wt(r,e,t,n){var a=r.append("marker").attr("id",e).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerUnits","strokeWidth").attr("markerWidth",8).attr("markerHeight",6).attr("orient","auto"),s=a.append("path").attr("d","M 0 0 L 10 5 L 0 10 L 4 5 z").style("stroke-width",1).style("stroke-dasharray","1,0");N(s,t[n+"Style"]),t[n+"Class"]&&s.attr("class",t[n+"Class"])}function Vt(r,e,t,n){var a=r.append("marker").attr("id",e).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerUnits","strokeWidth").attr("markerWidth",8).attr("markerHeight",6).attr("orient","auto"),s=a.append("path").attr("d","M 0 5 L 10 5").style("stroke-width",1).style("stroke-dasharray","1,0");N(s,t[n+"Style"]),t[n+"Class"]&&s.attr("class",t[n+"Class"])}function zt(r,e){var t=r;return t.node().appendChild(e.label),N(t,e.labelStyle),t}function Yt(r,e){for(var t=r.append("text"),n=Ht(e.label).split(`
`),a=0;a<n.length;a++)t.append("tspan").attr("xml:space","preserve").attr("dy","1em").attr("x","1").text(n[a]);return N(t,e.labelStyle),t}function Ht(r){for(var e="",t=!1,n,a=0;a<r.length;++a)if(n=r[a],t){switch(n){case"n":e+=`
`;break;default:e+=n}t=!1}else n==="\\"?t=!0:e+=n;return e}function K(r,e,t){var n=e.label,a=r.append("g");e.labelType==="svg"?zt(a,e):typeof n!="string"||e.labelType==="html"?at(a,e):Yt(a,e);var s=a.node().getBBox(),i;switch(t){case"top":i=-e.height/2;break;case"bottom":i=e.height/2-s.height;break;default:i=-s.height/2}return a.attr("transform","translate("+-s.width/2+","+i+")"),a}var H=function(r,e){var t=e.nodes().filter(function(s){return nt(e,s)}),n=r.selectAll("g.cluster").data(t,function(s){return s});_(n.exit(),e).style("opacity",0).remove();var a=n.enter().append("g").attr("class","cluster").attr("id",function(s){var i=e.node(s);return i.id}).style("opacity",0).each(function(s){var i=e.node(s),o=m(this);m(this).append("rect");var c=o.append("g").attr("class","label");K(c,i,i.clusterLabelPos)});return n=n.merge(a),n=_(n,e).style("opacity",1),n.selectAll("rect").each(function(s){var i=e.node(s),o=m(this);N(o,i.style)}),n};function Xt(r){H=r}let X=function(r,e){var t=r.selectAll("g.edgeLabel").data(e.edges(),function(a){return st(a)}).classed("update",!0);t.exit().remove(),t.enter().append("g").classed("edgeLabel",!0).style("opacity",0),t=r.selectAll("g.edgeLabel"),t.each(function(a){var s=m(this);s.select(".label").remove();var i=e.edge(a),o=K(s,e.edge(a),0).classed("label",!0),c=o.node().getBBox();i.labelId&&o.attr("id",i.labelId),S(i,"width")||(i.width=c.width),S(i,"height")||(i.height=c.height)});var n;return t.exit?n=t.exit():n=t.selectAll(null),_(n,e).style("opacity",0).remove(),t};function Ft(r){X=r}function O(r,e){return r.intersect(e)}var F=function(r,e,t){var n=r.selectAll("g.edgePath").data(e.edges(),function(i){return st(i)}).classed("update",!0),a=Zt(n,e);Ot(n,e);var s=n.merge!==void 0?n.merge(a):n;return _(s,e).style("opacity",1),s.each(function(i){var o=m(this),c=e.edge(i);c.elem=this,c.id&&o.attr("id",c.id),it(o,c.class,(o.classed("update")?"update ":"")+"edgePath")}),s.selectAll("path.path").each(function(i){var o=e.edge(i);o.arrowheadId=Lt("arrowhead");var c=m(this).attr("marker-end",function(){return"url("+Qt(location.href,o.arrowheadId)+")"}).style("fill","none");_(c,e).attr("d",function(d){return Jt(e,d)}),N(c,o.style)}),s.selectAll("defs *").remove(),s.selectAll("defs").each(function(i){var o=e.edge(i),c=t[o.arrowhead];c(m(this),o.arrowheadId,o,"arrowhead")}),s};function qt(r){F=r}function Qt(r,e){var t=r.split("#")[0];return t+"#"+e}function Jt(r,e){var t=r.edge(e),n=r.node(e.v),a=r.node(e.w),s=t.points.slice(1,t.points.length-1);return s.unshift(O(n,s[0])),s.push(O(a,s[s.length-1])),ot(t,s)}function ot(r,e){var t=(Mt||Pt.line)().x(function(n){return n.x}).y(function(n){return n.y});return(t.curve||t.interpolate)(r.curve),t(e)}function Kt(r){var e=r.getBBox(),t=r.ownerSVGElement.getScreenCTM().inverse().multiply(r.getScreenCTM()).translate(e.width/2,e.height/2);return{x:t.e,y:t.f}}function Zt(r,e){var t=r.enter().append("g").attr("class","edgePath").style("opacity",0);return t.append("path").attr("class","path").attr("d",function(n){var a=e.edge(n),s=e.node(n.v).elem,i=Et(a.points.length).map(function(){return Kt(s)});return ot(a,i)}),t.append("defs"),t}function Ot(r,e){var t=r.exit();_(t,e).style("opacity",0).remove()}var q=function(r,e,t){var n=e.nodes().filter(function(i){return!nt(e,i)}),a=r.selectAll("g.node").data(n,function(i){return i}).classed("update",!0);a.exit().remove(),a.enter().append("g").attr("class","node").style("opacity",0),a=r.selectAll("g.node"),a.each(function(i){var o=e.node(i),c=m(this);it(c,o.class,(c.classed("update")?"update ":"")+"node"),c.select("g.label").remove();var d=c.append("g").attr("class","label"),l=K(d,o),v=t[o.shape],h=_t(l.node().getBBox(),"width","height");o.elem=this,o.id&&c.attr("id",o.id),o.labelId&&d.attr("id",o.labelId),S(o,"width")&&(h.width=o.width),S(o,"height")&&(h.height=o.height),h.width+=o.paddingLeft+o.paddingRight,h.height+=o.paddingTop+o.paddingBottom,d.attr("transform","translate("+(o.paddingLeft-o.paddingRight)/2+","+(o.paddingTop-o.paddingBottom)/2+")");var u=m(this);u.select(".label-container").remove();var p=v(u,h,o).classed("lab
`),i.style===void 0&&(l.style=l.style||"stroke: #333; stroke-width: 1.5px;fill:none"),l.labelStyle=l.labelStyle.replace("color:","fill:"))),l.id=o,l.class=c+" "+d,l.minlen=i.length||1,e.setEdge(t.db.lookUpDomId(i.start),t.db.lookUpDomId(i.end),l,n)})},xe=function(r,e){return R.info("Extracting classes"),e.db.getClasses()},me=function(r,e,t,n){R.info("Drawing flowchart");const{securityLevel:a,flowchart:s}=J();let i;a==="sandbox"&&(i=m("#i"+e));const o=a==="sandbox"?m(i.nodes()[0].contentDocument.body):m("body"),c=a==="sandbox"?i.nodes()[0].contentDocument:document;let d=n.db.getDirection();d===void 0&&(d="TD");const l=s.nodeSpacing||50,v=s.rankSpacing||50,h=new Nt({multigraph:!0,compound:!0}).setGraph({rankdir:d,nodesep:l,ranksep:v,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});let u;const p=n.db.getSubGraphs();for(let w=p.length-1;w>=0;w--)u=p[w],n.db.addVertex(u.id,u.title,"group",void 0,u.classes);const g=n.db.getVertices();R.warn("Get vertices",g);const f=n.db.getEdges();let y=0;for(y=p.length-1;y>=0;y--){u=p[y],Bt("cluster").append("text");for(let w=0;w<u.nodes.length;w++)R.warn("Setting subgraph",u.nodes[w],n.db.lookUpDomId(u.nodes[w]),n.db.lookUpDomId(u.id)),h.setParent(n.db.lookUpDomId(u.nodes[w]),n.db.lookUpDomId(u.id))}bt(g,h,e,o,c,n),kt(f,h,n);const k=new de;ge.addToRender(k),k.arrows().none=function(b,L,x,B){const C=b.append("marker").attr("id",L).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerUnits","strokeWidth").attr("markerWidth",8).attr("markerHeight",6).attr("orient","auto").append("path").attr("d","M 0 0 L 0 0 L 0 0 z");N(C,x[B+"Style"])},k.arrows().normal=function(b,L){b.append("marker").attr("id",L).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerUnits","strokeWidth").attr("markerWidth",8).attr("markerHeight",6).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("class","arrowheadPath").style("stroke-width",1).style("stroke-dasharray","1,0")};const I=o.select(`[id="${e}"]`),E=o.select("#"+e+" g");for(k(E,h),E.selectAll("g.node").attr("title",function(){return n.db.getTooltip(this.id)}),n.db.indexNodes("subGraph"+y),y=0;y<p.length;y++)if(u=p[y],u.title!=="undefined"){const w=c.querySelectorAll("#"+e+' [id="'+n.db.lookUpDomId(u.id)+'"] rect'),b=c.querySelectorAll("#"+e+' [id="'+n.db.lookUpDomId(u.id)+'"]'),L=w[0].x.baseVal.value,x=w[0].y.baseVal.value,B=w[0].width.baseVal.value,C=m(b[0]).select(".label");C.attr("transform",`translate(${L+B/2}, ${x+14})`),C.attr("id",e+"Text");for(let $=0;$<u.classes.length;$++)b[0].classList.add(u.classes[$])}if(!s.htmlLabels){const w=c.querySelectorAll('[id="'+e+'"] .edgeLabel .label');for(const b of w){const L=b.getBBox(),x=c.createElementNS("http://www.w3.org/2000/svg","rect");x.setAttribute("rx",0),x.setAttribute("ry",0),x.setAttribute("width",L.width),x.setAttribute("height",L.height),b.insertBefore(x,b.firstChild)}}At(h,I,s.diagramPadding,s.useMaxWidth),Object.keys(g).forEach(function(w){const b=g[w];if(b.link){const L=o.select("#"+e+' [id="'+n.db.lookUpDomId(w)+'"]');if(L){const x=c.createElementNS("http://www.w3.org/2000/svg","a");x.setAttributeNS("http://www.w3.org/2000/svg","class",b.classes.join(" ")),x.setAttributeNS("http://www.w3.org/2000/svg","href",b.link),x.setAttributeNS("http://www.w3.org/2000/svg","rel","noopener"),a==="sandbox"?x.setAttributeNS("http://www.w3.org/2000/svg","target","_top"):b.linkTarget&&x.setAttributeNS("http://www.w3.org/2000/svg","target",b.linkTarget);const B=L.insert(function(){return x},":first-child"),G=L.select(".label-container");G&&B.append(function(){return G.node()});const C=L.select(".label");C&&B.append(function(){return C.node()})}}})},be={setConf:we,addVertices:bt,addEdges:kt,getClasses:xe,draw:me},Be={parser:St,db:W,renderer:Ct,styles:It,init:r=>{r.flowchart||(r.flowchart={}),r.flowchart.arrowMarkerAbsolute=r.arrowMarkerAbsolute,be.setConf(r.flowchart),W.clear(),W.setGen("gen-1")}};export{Be as diagram};