1
0
ultimatedocs/docs/.vitepress/dist/assets/chunks/flowDiagram-b222e15a.u5AVV-hs.js

5 lines
21 KiB
JavaScript
Raw Permalink Normal View History

2024-07-27 13:25:59 +02:00
import{p as Lt,f as V}from"./flowDb-c1833063.DvoUJcPW.js";import{h as S,f as tt,G as _t}from"./graph.kiq1lfdl.js";import{h as x,o as U,p as Y,q as et,c as G,r as rt,j as at,l as R,t as z,u as Et}from"../app.CV7ObeM5.js";import{u as Tt,r as Nt,p as At,l as Ct,d as M}from"./layout.CGyoqY46.js";import{a as N,b as nt,i as st,c as E,e as it,d as ot,f as It,g as Bt,s as Mt}from"./styles-483fbfea.B1aiHS7-.js";import{l as Dt}from"./line.DlbMY8Uz.js";import"./framework.DuA-ZlS8.js";import"./theme.B-IrzYt-.js";import"./index-01f381cb.C7DEWKJL.js";import"./clone.DbtYtBgG.js";import"./edges-066a5561.ShgFzVAi.js";import"./createText-ca0c5216.CfRbav5E.js";import"./channel.hie1L93G.js";import"./array.BKyUJesY.js";import"./path.CbwjOpE9.js";function Rt(r){if(!r.ok)throw new Error(r.status+" "+r.statusText);return r.text()}function Gt(r,e){return fetch(r,e).then(Rt)}function Pt(r){return(e,t)=>Gt(e,t).then(n=>new DOMParser().parseFromString(n,r))}var Ut=Pt("image/svg+xml"),H={normal:Wt,vee:Vt,undirected:zt};function $t(r){H=r}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 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 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 zt(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 Yt(r,e){var t=r;return t.node().appendChild(e.label),N(t,e.labelStyle),t}function Ht(r,e){for(var t=r.append("text"),n=Xt(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 Xt(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 J(r,e,t){var n=e.label,a=r.append("g");e.labelType==="svg"?Yt(a,e):typeof n!="string"||e.labelType==="html"?nt(a,e):Ht(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 X=function(r,e){var t=e.nodes().filter(function(s){return st(e,s)}),n=r.selectAll("g.cluster").data(t,function(s){return s});E(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=x(this);x(this).append("rect");var c=o.append("g").attr("class","label");J(c,i,i.clusterLabelPos)});return n=n.merge(a),n=E(n,e).style("opacity",1),n.selectAll("rect").each(function(s){var i=e.node(s),o=x(this);N(o,i.style)}),n};function Ft(r){X=r}let F=function(r,e){var t=r.selectAll("g.edgeLabel").data(e.edges(),function(a){return it(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=x(this);s.select(".label").remove();var i=e.edge(a),o=J(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),E(n,e).style("opacity",0).remove(),t};function qt(r){F=r}function O(r,e){return r.intersect(e)}var q=function(r,e,t){var n=r.selectAll("g.edgePath").data(e.edges(),function(i){return it(i)}).classed("update",!0),a=Ot(n,e);jt(n,e);var s=n.merge!==void 0?n.merge(a):n;return E(s,e).style("opacity",1),s.each(function(i){var o=x(this),c=e.edge(i);c.elem=this,c.id&&o.attr("id",c.id),ot(o,c.class,(o.classed("update")?"update ":"")+"edgePath")}),s.selectAll("path.path").each(function(i){var o=e.edge(i);o.arrowheadId=Tt("arrowhead");var c=x(this).attr("marker-end",function(){return"url("+Kt(location.href,o.arrowheadId)+")"}).style("fill","none");E(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(x(this),o.arrowheadId,o,"arrowhead")}),s};function Qt(r){q=r}function Kt(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])),lt(t,s)}function lt(r,e){var t=(Dt||Ut.line)().x(function(n){return n.x}).y(function(n){return n.y});return(t.curve||t.interpolate)(r.curve),t(e)}function Zt(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 Ot(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=Nt(a.points.length).map(function(){return Zt(s)});return lt(a,i)}),t.append("defs"),t}function jt(r,e){var t=r.exit();E(t,e).style("opacity",0).remove()}var Q=function(r,e,t){var n=e.nodes().filter(function(i){return!st(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=x(this);ot(c,o.class,(c.classed("update")?"update ":"")+"node"),c.select("g.label").remove();var d=c.append("g").attr("class","label"),l=J(d,o),v=t[o.shape],h=At(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=x(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()},be=async function(r,e,t,n){R.info("Drawing flowchart");const{securityLevel:a,flowchart:s}=G();let i;a==="sandbox"&&(i=x("#i"+e));const o=a==="sandbox"?x(i.nodes()[0].contentDocument.body):x("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 _t({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 y=n.db.getVertices();R.warn("Get vertices",y);const f=n.db.getEdges();let g=0;for(g=p.length-1;g>=0;g--){u=p[g],Mt("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))}await kt(y,h,e,o,c,n),await St(f,h,n);const k=new he;we.addToRender(k),k.arrows().none=function(b,L,m,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,m[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}"]`),_=o.select("#"+e+" g");for(k(_,h),_.selectAll("g.node").attr("title",function(){return n.db.getTooltip(this.id)}),n.db.indexNodes("subGraph"+g),g=0;g<p.length;g++)if(u=p[g],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,m=w[0].y.baseVal.value,B=w[0].width.baseVal.value,C=x(b[0]).select(".label");C.attr("transform",`translate(${L+B/2}, ${m+14})`),C.attr("id",e+"Text");for(let W=0;W<u.classes.length;W++)b[0].classList.add(u.classes[W])}if(!s.htmlLabels){const w=c.querySelectorAll('[id="'+e+'"] .edgeLabel .label');for(const b of w){const L=b.getBBox(),m=c.createElementNS("http://www.w3.org/2000/svg","rect");m.setAttribute("rx",0),m.setAttribute("ry",0),m.setAttribute("width",L.width),m.setAttribute("height",L.height),b.insertBefore(m,b.firstChild)}}Et(h,I,s.diagramPadding,s.useMaxWidth),Object.keys(y).forEach(function(w){const b=y[w];if(b.link){const L=o.select("#"+e+' [id="'+n.db.lookUpDomId(w)+'"]');if(L){const m=c.createElementNS("http://www.w3.org/2000/svg","a");m.setAttributeNS("http://www.w3.org/2000/svg","class",b.classes.join(" ")),m.setAttributeNS("http://www.w3.org/2000/svg","href",b.link),m.setAttributeNS("http://www.w3.org/2000/svg","rel","noopener"),a==="sandbox"?m.setAttributeNS("http://www.w3.org/2000/svg","target","_top"):b.linkTarget&&m.setAttributeNS("http://www.w3.org/2000/svg","target",b.linkTarget);const B=L.insert(function(){return m},":first-child"),P=L.select(".label-container");P&&B.append(function(){return P.node()});const C=L.select(".label");C&&B.append(function(){return C.node()})}}})},ke={setConf:me,addVertices:kt,addEdges:St,getClasses:xe,draw:be},Ue={parser:Lt,db:V,renderer:It,styles:Bt,init:r=>{r.flowchart||(r.flowchart={}),r.flowchart.arrowMarkerAbsolute=r.arrowMarkerAbsolute,ke.setConf(r.flowchart),V.clear(),V.setGen("gen-1")}};export{Ue as diagram};