import{a as H,b as Y,c as _,d as X,e as b,f as F,g as bt,h as kt}from"./chunk-WLRI2CE5.js";import{a as mt,b as z}from"./chunk-AJUNCWM5.js";import"./chunk-JOINRAHF.js";import"./chunk-LSZKUOXR.js";import"./chunk-SF6FGZXC.js";import{b as R,c as ot,e as w,g as yt,h as vt,i as gt,j as xt,k as wt}from"./chunk-4VIGWTJT.js";import{$a as J,E as P,F as ft,Fa as G,I as ee,Ia as lt,Ka as ct,Pa as q,Qa as Q,b as jt,c as te,cb as St,h as y,i as ut,k as ht}from"./chunk-AZTSVESG.js";import"./chunk-BZUL2CAN.js";import{h as it}from"./chunk-EP6THQJ3.js";var K={normal:re,vee:ae,undirected:ne};function _t(r){K=r}function re(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");_(s,t[n+"Style"]),t[n+"Class"]&&s.attr("class",t[n+"Class"])}function ae(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");_(s,t[n+"Style"]),t[n+"Class"]&&s.attr("class",t[n+"Class"])}function ne(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");_(s,t[n+"Style"]),t[n+"Class"]&&s.attr("class",t[n+"Class"])}function Lt(r,e){var t=r;return t.node().appendChild(e.label),_(t,e.labelStyle),t}function Et(r,e){for(var t=r.append("text"),n=se(e.label).split(` `),a=0;a0}function T(r,e,t){var n=r.x,a=r.y,s=[],i=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY;e.forEach(function(f){i=Math.min(i,f.x),o=Math.min(o,f.y)});for(var c=n-r.width/2-i,d=a-r.height/2-o,l=0;l1&&s.sort(function(f,g){var h=f.x-t.x,v=f.y-t.y,L=Math.sqrt(h*h+v*v),M=g.x-t.x,N=g.y-t.y,nt=Math.sqrt(M*M+N*N);return LMath.abs(a)*o?(s<0&&(o=-o),c=s===0?0:o*a/s,d=o):(a<0&&(i=-i),c=i,d=a===0?0:i*s/a),{x:t+c,y:n+d}}var at={rect:ye,ellipse:ve,circle:ge,diamond:xe};function Ut(r){at=r}function ye(r,e,t){var n=r.insert("rect",":first-child").attr("rx",t.rx).attr("ry",t.ry).attr("x",-e.width/2).attr("y",-e.height/2).attr("width",e.width).attr("height",e.height);return t.intersect=function(a){return W(t,a)},n}function ve(r,e,t){var n=e.width/2,a=e.height/2,s=r.insert("ellipse",":first-child").attr("x",-e.width/2).attr("y",-e.height/2).attr("rx",n).attr("ry",a);return t.intersect=function(i){return rt(t,n,a,i)},s}function ge(r,e,t){var n=Math.max(e.width,e.height)/2,a=r.insert("circle",":first-child").attr("x",-e.width/2).attr("y",-e.height/2).attr("r",n);return t.intersect=function(s){return Pt(t,n,s)},a}function xe(r,e,t){var n=e.width*Math.SQRT2/2,a=e.height*Math.SQRT2/2,s=[{x:0,y:-a},{x:-n,y:0},{x:0,y:a},{x:n,y:0}],i=r.insert("polygon",":first-child").attr("points",s.map(function(o){return o.x+","+o.y}).join(" "));return t.intersect=function(o){return T(t,s,o)},i}function pt(){var r=function(e,t){ke(t);var n=V(e,"output"),a=V(n,"clusters"),s=V(n,"edgePaths"),i=j(V(n,"edgeLabels"),t),o=et(V(n,"nodes"),t,at);wt(t),Dt(o,t),Mt(i,t),tt(s,t,K);var c=Z(a,t);Bt(c,t),Se(t)};return r.createNodes=function(e){return arguments.length?(It(e),r):et},r.createClusters=function(e){return arguments.length?(Tt(e),r):Z},r.createEdgeLabels=function(e){return arguments.length?(Nt(e),r):j},r.createEdgePaths=function(e){return arguments.length?(Ct(e),r):tt},r.shapes=function(e){return arguments.length?(Ut(e),r):at},r.arrows=function(e){return arguments.length?(_t(e),r):K},r}var we={paddingLeft:10,paddingRight:10,paddingTop:10,paddingBottom:10,rx:0,ry:0,shape:"rect"},be={arrowhead:"normal",curve:P};function ke(r){r.nodes().forEach(function(e){var t=r.node(e);!w(t,"label")&&!r.children(e).length&&(t.label=e),w(t,"paddingX")&&R(t,{paddingLeft:t.paddingX,paddingRight:t.paddingX}),w(t,"paddingY")&&R(t,{paddingTop:t.paddingY,paddingBottom:t.paddingY}),w(t,"padding")&&R(t,{paddingLeft:t.padding,paddingRight:t.padding,paddingTop:t.padding,paddingBottom:t.padding}),R(t,we),ot(["paddingLeft","paddingRight","paddingTop","paddingBottom"],function(n){t[n]=Number(t[n])}),w(t,"width")&&(t._prevWidth=t.width),w(t,"height")&&(t._prevHeight=t.height)}),r.edges().forEach(function(e){var t=r.edge(e);w(t,"label")||(t.label=""),R(t,be)})}function Se(r){ot(r.nodes(),function(e){var t=r.node(e);w(t,"_prevWidth")?t.width=t._prevWidth:delete t.width,w(t,"_prevHeight")?t.height=t._prevHeight:delete t.height,delete t._prevWidth,delete t._prevHeight})}function V(r,e){var t=r.select("g."+e);return t.empty()&&(t=r.append("g").attr("class",e)),t}var Nr=it(jt(),1),Cr=it(te(),1),Ar=it(ee(),1);function Wt(r,e,t){let n=e.width,a=e.height,s=(n+a)*.9,i=[{x:s/2,y:0},{x:s,y:-s/2},{x:s/2,y:-s},{x:0,y:-s/2}],o=A(r,s,s,i);return t.intersect=function(c){return T(t,i,c)},o}function Vt(r,e,t){let a=e.height,s=a/4,i=e.width+2*s,o=[{x:s,y:0},{x:i-s,y:0},{x:i,y:-a/2},{x:i-s,y:-a},{x:s,y:-a},{x:0,y:-a/2}],c=A(r,i,a,o);return t.intersect=function(d){return T(t,o,d)},c}function $t(r,e,t){let n=e.width,a=e.height,s=[{x:-a/2,y:0},{x:n,y:0},{x:n,y:-a},{x:-a/2,y:-a},{x:0,y:-a/2}],i=A(r,n,a,s);return t.intersect=function(o){return T(t,s,o)},i}function zt(r,e,t){let n=e.width,a=e.height,s=[{x:-2*a/6,y:0},{x:n-a/6,y:0},{x:n+2*a/6,y:-a},{x:a/6,y:-a}],i=A(r,n,a,s);return t.intersect=function(o){return T(t,s,o)},i}function Ht(r,e,t){let n=e.width,a=e.height,s=[{x:2*a/6,y:0},{x:n+a/6,y:0},{x:n-2*a/6,y:-a},{x:-a/6,y:-a}],i=A(r,n,a,s);return t.intersect=function(o){return T(t,s,o)},i}function Yt(r,e,t){let n=e.width,a=e.height,s=[{x:-2*a/6,y:0},{x:n+2*a/6,y:0},{x:n-a/6,y:-a},{x:a/6,y:-a}],i=A(r,n,a,s);return t.intersect=function(o){return T(t,s,o)},i}function Xt(r,e,t){let n=e.width,a=e.height,s=[{x:a/6,y:0},{x:n-a/6,y:0},{x:n+2*a/6,y:-a},{x:-2*a/6,y:-a}],i=A(r,n,a,s);return t.intersect=function(o){return T(t,s,o)},i}function Ft(r,e,t){let n=e.width,a=e.height,s=[{x:0,y:0},{x:n+a/2,y:0},{x:n,y:-a/2},{x:n+a/2,y:-a},{x:0,y:-a}],i=A(r,n,a,s);return t.intersect=function(o){return T(t,s,o)},i}function qt(r,e,t){let n=e.height,a=e.width+n/4,s=r.insert("rect",":first-child").attr("rx",n/2).attr("ry",n/2).attr("x",-a/2).attr("y",-n/2).attr("width",a).attr("height",n);return t.intersect=function(i){return W(t,i)},s}function Qt(r,e,t){let n=e.width,a=e.height,s=[{x:0,y:0},{x:n,y:0},{x:n,y:-a},{x:0,y:-a},{x:0,y:0},{x:-8,y:0},{x:n+8,y:0},{x:n+8,y:-a},{x:-8,y:-a},{x:-8,y:0}],i=A(r,n,a,s);return t.intersect=function(o){return T(t,s,o)},i}function Jt(r,e,t){let n=e.width,a=n/2,s=a/(2.5+n/50),i=e.height+s,o="M 0,"+s+" a "+a+","+s+" 0,0,0 "+n+" 0 a "+a+","+s+" 0,0,0 "+-n+" 0 l 0,"+i+" a "+a+","+s+" 0,0,0 "+n+" 0 l 0,"+-i,c=r.attr("label-offset-y",s).insert("path",":first-child").attr("d",o).attr("transform","translate("+-n/2+","+-(i/2+s)+")");return t.intersect=function(d){let l=W(t,d),m=l.x-t.x;if(a!=0&&(Math.abs(m)t.height/2-s)){let p=s*s*(1-m*m/(a*a));p!=0&&(p=Math.sqrt(p)),p=s-p,d.y-t.y>0&&(p=-p),l.y+=p}return l},c}function Ee(r){r.shapes().question=Wt,r.shapes().hexagon=Vt,r.shapes().stadium=qt,r.shapes().subroutine=Qt,r.shapes().cylinder=Jt,r.shapes().rect_left_inv_arrow=$t,r.shapes().lean_right=zt,r.shapes().lean_left=Ht,r.shapes().trapezoid=Yt,r.shapes().inv_trapezoid=Xt,r.shapes().rect_right_inv_arrow=Ft}function Te(r){r({question:Wt}),r({hexagon:Vt}),r({stadium:qt}),r({subroutine:Qt}),r({cylinder:Jt}),r({rect_left_inv_arrow:$t}),r({lean_right:zt}),r({lean_left:Ht}),r({trapezoid:Yt}),r({inv_trapezoid:Xt}),r({rect_right_inv_arrow:Ft})}function A(r,e,t,n){return r.insert("polygon",":first-child").attr("points",n.map(function(a){return a.x+","+a.y}).join(" ")).attr("transform","translate("+-e/2+","+t/2+")")}var Ne={addToRender:Ee,addToRenderV2:Te},Kt={},Ce=function(r){let e=Object.keys(r);for(let t of e)Kt[t]=r[t]},Zt=function(r,e,t,n,a,s){let i=n?n.select(`[id="${t}"]`):y(`[id="${t}"]`),o=a||document;Object.keys(r).forEach(function(d){let l=r[d],m="default";l.classes.length>0&&(m=l.classes.join(" "));let p=Q(l.styles),u=l.text!==void 0?l.text:l.id,f;if(lt(J().flowchart.htmlLabels)){let v={label:u.replace(/fa[blrs]?:fa-[\w-]+/g,L=>``)};f=F(i,v).node(),f.parentNode.removeChild(f)}else{let v=o.createElementNS("http://www.w3.org/2000/svg","text");v.setAttribute("style",p.labelStyle.replace("color:","fill:"));let L=u.split(ct.lineBreakRegex);for(let M of L){let N=o.createElementNS("http://www.w3.org/2000/svg","tspan");N.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),N.setAttribute("dy","1em"),N.setAttribute("x","1"),N.textContent=M,v.appendChild(N)}f=v}let g=0,h="";switch(l.type){case"round":g=5,h="rect";break;case"square":h="rect";break;case"diamond":h="question";break;case"hexagon":h="hexagon";break;case"odd":h="rect_left_inv_arrow";break;case"lean_right":h="lean_right";break;case"lean_left":h="lean_left";break;case"trapezoid":h="trapezoid";break;case"inv_trapezoid":h="inv_trapezoid";break;case"odd_right":h="rect_left_inv_arrow";break;case"circle":h="circle";break;case"ellipse":h="ellipse";break;case"stadium":h="stadium";break;case"subroutine":h="subroutine";break;case"cylinder":h="cylinder";break;case"group":h="rect";break;default:h="rect"}G.warn("Adding node",l.id,l.domId),e.setNode(s.db.lookUpDomId(l.id),{labelType:"svg",labelStyle:p.labelStyle,shape:h,label:f,rx:g,ry:g,class:m,style:p.style,id:s.db.lookUpDomId(l.id)})})},Ot=function(r,e,t){let n=0,a,s;if(r.defaultStyle!==void 0){let i=Q(r.defaultStyle);a=i.style,s=i.labelStyle}r.forEach(function(i){n++;let o="L-"+i.start+"-"+i.end,c="LS-"+i.start,d="LE-"+i.end,l={};i.type==="arrow_open"?l.arrowhead="none":l.arrowhead="normal";let m="",p="";if(i.style!==void 0){let u=Q(i.style);m=u.style,p=u.labelStyle}else switch(i.stroke){case"normal":m="fill:none",a!==void 0&&(m=a),s!==void 0&&(p=s);break;case"dotted":m="fill:none;stroke-width:2px;stroke-dasharray:3;";break;case"thick":m=" stroke-width: 3.5px;fill:none";break}l.style=m,l.labelStyle=p,i.interpolate!==void 0?l.curve=q(i.interpolate,P):r.defaultInterpolate!==void 0?l.curve=q(r.defaultInterpolate,P):l.curve=q(Kt.curve,P),i.text===void 0?i.style!==void 0&&(l.arrowheadStyle="fill: #333"):(l.arrowheadStyle="fill: #333",l.labelpos="c",lt(J().flowchart.htmlLabels)?(l.labelType="html",l.label=`${i.text.replace(/fa[blrs]?:fa-[\w-]+/g,u=>``)}`):(l.labelType="text",l.label=i.text.replace(ct.lineBreakRegex,` `),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)})},Ae=function(r,e){return G.info("Extracting classes"),e.db.getClasses()},Ie=function(r,e,t,n){G.info("Drawing flowchart");let{securityLevel:a,flowchart:s}=J(),i;a==="sandbox"&&(i=y("#i"+e));let o=a==="sandbox"?y(i.nodes()[0].contentDocument.body):y("body"),c=a==="sandbox"?i.nodes()[0].contentDocument:document,d=n.db.getDirection();d===void 0&&(d="TD");let l=s.nodeSpacing||50,m=s.rankSpacing||50,p=new xt({multigraph:!0,compound:!0}).setGraph({rankdir:d,nodesep:l,ranksep:m,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}}),u,f=n.db.getSubGraphs();for(let x=f.length-1;x>=0;x--)u=f[x],n.db.addVertex(u.id,u.title,"group",void 0,u.classes);let g=n.db.getVertices();G.warn("Get vertices",g);let h=n.db.getEdges(),v=0;for(v=f.length-1;v>=0;v--){u=f[v],ut("cluster").append("text");for(let x=0;x{r.flowchart||(r.flowchart={}),r.flowchart.arrowMarkerAbsolute=r.arrowMarkerAbsolute,Be.setConf(r.flowchart),z.clear(),z.setGen("gen-1")}};export{Mr as diagram};