import{a as kt,b as St}from"./chunk-OA7IVPWH.mjs";import{a as yt,b as F,d as q,e as Q,f as L,g as J,h as k,i as K}from"./chunk-5IYKIBJY.mjs";import"./chunk-KMVYKOKI.mjs";import"./chunk-RBZFHHGM.mjs";import"./chunk-GKMXV7QN.mjs";import"./chunk-MEJ245MW.mjs";import"./chunk-AOAEVBQL.mjs";import{a as wt,b as bt}from"./chunk-LU4ULLGK.mjs";import{D as xt,h as U,j as ct,p as b,x as vt,y as gt}from"./chunk-2NUPJ2B5.mjs";import"./chunk-PUD22X6X.mjs";import{B as Y,C as X}from"./chunk-6WX52H5W.mjs";import{c as ot,e as lt}from"./chunk-GO66RM32.mjs";import"./chunk-UW4DGUNY.mjs";import{H as G,I as ft,a as l,g as B,m as v,n as ut,p as ht,ra as H,va as mt}from"./chunk-3OFI44Y5.mjs";var Z={normal:ee,vee:re,undirected:ae};function _t(r){Z=r}l(_t,"setArrows");function ee(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");L(s,t[n+"Style"]),t[n+"Class"]&&s.attr("class",t[n+"Class"])}l(ee,"normal");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 L 4 5 z").style("stroke-width",1).style("stroke-dasharray","1,0");L(s,t[n+"Style"]),t[n+"Class"]&&s.attr("class",t[n+"Class"])}l(re,"vee");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 5 L 10 5").style("stroke-width",1).style("stroke-dasharray","1,0");L(s,t[n+"Style"]),t[n+"Class"]&&s.attr("class",t[n+"Class"])}l(ae,"undirected");function Lt(r,e){var t=r;return t.node().appendChild(e.label),L(t,e.labelStyle),t}l(Lt,"addSVGLabel");function Et(r,e){for(var t=r.append("text"),n=ne(e.label).split(` `),a=0;a0}l(Dt,"sameSign");function C(r,e,t){var n=r.x,a=r.y,s=[],i=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY;e.forEach(function(m){i=Math.min(i,m.x),o=Math.min(o,m.y)});for(var d=n-r.width/2-i,p=a-r.height/2-o,c=0;c1&&s.sort(function(m,x){var f=m.x-t.x,g=m.y-t.y,E=Math.sqrt(f*f+g*g),R=x.x-t.x,N=x.y-t.y,st=Math.sqrt(R*R+N*N);return EMath.abs(a)*o?(s<0&&(o=-o),d=s===0?0:o*a/s,p=o):(a<0&&(i=-i),d=i,p=a===0?0:i*s/a),{x:t+d,y:n+p}}l(V,"intersectRect");var nt={rect:me,ellipse:ye,circle:ve,diamond:ge};function Ut(r){nt=r}l(Ut,"setShapes");function me(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 V(t,a)},n}l(me,"rect");function ye(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 at(t,n,a,i)},s}l(ye,"ellipse");function ve(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 Rt(t,n,s)},a}l(ve,"circle");function ge(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 C(t,s,o)},i}l(ge,"diamond");function pt(){var r=l(function(e,t){be(t);var n=z(e,"output"),a=z(n,"clusters"),s=z(n,"edgePaths"),i=tt(z(n,"edgeLabels"),t),o=rt(z(n,"nodes"),t,nt);bt(t),Pt(o,t),Bt(i,t),et(s,t,Z);var d=O(a,t);Mt(d,t),ke(t)},"fn");return r.createNodes=function(e){return arguments.length?(It(e),r):rt},r.createClusters=function(e){return arguments.length?(Tt(e),r):O},r.createEdgeLabels=function(e){return arguments.length?(Ct(e),r):tt},r.createEdgePaths=function(e){return arguments.length?(Nt(e),r):et},r.shapes=function(e){return arguments.length?(Ut(e),r):nt},r.arrows=function(e){return arguments.length?(_t(e),r):Z},r}l(pt,"render");var xe={paddingLeft:10,paddingRight:10,paddingTop:10,paddingBottom:10,rx:0,ry:0,shape:"rect"},we={arrowhead:"normal",curve:G};function be(r){r.nodes().forEach(function(e){var t=r.node(e);!b(t,"label")&&!r.children(e).length&&(t.label=e),b(t,"paddingX")&&U(t,{paddingLeft:t.paddingX,paddingRight:t.paddingX}),b(t,"paddingY")&&U(t,{paddingTop:t.paddingY,paddingBottom:t.paddingY}),b(t,"padding")&&U(t,{paddingLeft:t.padding,paddingRight:t.padding,paddingTop:t.padding,paddingBottom:t.padding}),U(t,xe),ct(["paddingLeft","paddingRight","paddingTop","paddingBottom"],function(n){t[n]=Number(t[n])}),b(t,"width")&&(t._prevWidth=t.width),b(t,"height")&&(t._prevHeight=t.height)}),r.edges().forEach(function(e){var t=r.edge(e);b(t,"label")||(t.label=""),U(t,we)})}l(be,"preProcessGraph");function ke(r){ct(r.nodes(),function(e){var t=r.node(e);b(t,"_prevWidth")?t.width=t._prevWidth:delete t.width,b(t,"_prevHeight")?t.height=t._prevHeight:delete t.height,delete t._prevWidth,delete t._prevHeight})}l(ke,"postProcessGraph");function z(r,e){var t=r.select("g."+e);return t.empty()&&(t=r.append("g").attr("class",e)),t}l(z,"createOrSelectGroup");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=I(r,s,s,i);return t.intersect=function(d){return C(t,i,d)},o}l(Wt,"question");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}],d=I(r,i,a,o);return t.intersect=function(p){return C(t,o,p)},d}l(Vt,"hexagon");function zt(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=I(r,n,a,s);return t.intersect=function(o){return C(t,s,o)},i}l(zt,"rect_left_inv_arrow");function $t(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=I(r,n,a,s);return t.intersect=function(o){return C(t,s,o)},i}l($t,"lean_right");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=I(r,n,a,s);return t.intersect=function(o){return C(t,s,o)},i}l(Ht,"lean_left");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=I(r,n,a,s);return t.intersect=function(o){return C(t,s,o)},i}l(Yt,"trapezoid");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=I(r,n,a,s);return t.intersect=function(o){return C(t,s,o)},i}l(Xt,"inv_trapezoid");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=I(r,n,a,s);return t.intersect=function(o){return C(t,s,o)},i}l(Ft,"rect_right_inv_arrow");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 V(t,i)},s}l(qt,"stadium");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=I(r,n,a,s);return t.intersect=function(o){return C(t,s,o)},i}l(Qt,"subroutine");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,d=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(p){let c=V(t,p),y=c.x-t.x;if(a!=0&&(Math.abs(y)t.height/2-s)){let u=s*s*(1-y*y/(a*a));u!=0&&(u=Math.sqrt(u)),u=s-u,p.y-t.y>0&&(u=-u),c.y+=u}return c},d}l(Jt,"cylinder");function Le(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=zt,r.shapes().lean_right=$t,r.shapes().lean_left=Ht,r.shapes().trapezoid=Yt,r.shapes().inv_trapezoid=Xt,r.shapes().rect_right_inv_arrow=Ft}l(Le,"addToRender");function Ee(r){r({question:Wt}),r({hexagon:Vt}),r({stadium:qt}),r({subroutine:Qt}),r({cylinder:Jt}),r({rect_left_inv_arrow:zt}),r({lean_right:$t}),r({lean_left:Ht}),r({trapezoid:Yt}),r({inv_trapezoid:Xt}),r({rect_right_inv_arrow:Ft})}l(Ee,"addToRenderV2");function I(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+")")}l(I,"insertPolygonShape");var Kt={addToRender:Le,addToRenderV2:Ee};var Zt={},Te=l(function(r){let e=Object.keys(r);for(let t of e)Zt[t]=r[t]},"setConf"),Ot=l(function(r,e,t,n,a,s){let i=n?n.select(`[id="${t}"]`):v(`[id="${t}"]`),o=a||document;Object.keys(r).forEach(function(p){let c=r[p],y="default";c.classes.length>0&&(y=c.classes.join(" "));let u=X(c.styles),h=c.text!==void 0?c.text:c.id,m;if(ot(H().flowchart.htmlLabels)){let g={label:h.replace(/fa[blrs]?:fa-[\w-]+/g,E=>``)};m=K(i,g).node(),m.parentNode.removeChild(m)}else{let g=o.createElementNS("http://www.w3.org/2000/svg","text");g.setAttribute("style",u.labelStyle.replace("color:","fill:"));let E=h.split(lt.lineBreakRegex);for(let R of E){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=R,g.appendChild(N)}m=g}let x=0,f="";switch(c.type){case"round":x=5,f="rect";break;case"square":f="rect";break;case"diamond":f="question";break;case"hexagon":f="hexagon";break;case"odd":f="rect_left_inv_arrow";break;case"lean_right":f="lean_right";break;case"lean_left":f="lean_left";break;case"trapezoid":f="trapezoid";break;case"inv_trapezoid":f="inv_trapezoid";break;case"odd_right":f="rect_left_inv_arrow";break;case"circle":f="circle";break;case"ellipse":f="ellipse";break;case"stadium":f="stadium";break;case"subroutine":f="subroutine";break;case"cylinder":f="cylinder";break;case"group":f="rect";break;default:f="rect"}B.warn("Adding node",c.id,c.domId),e.setNode(s.db.lookUpDomId(c.id),{labelType:"svg",labelStyle:u.labelStyle,shape:f,label:m,rx:x,ry:x,class:y,style:u.style,id:s.db.lookUpDomId(c.id)})})},"addVertices"),jt=l(function(r,e,t){let n=0,a,s;if(r.defaultStyle!==void 0){let i=X(r.defaultStyle);a=i.style,s=i.labelStyle}r.forEach(function(i){n++;let o="L-"+i.start+"-"+i.end,d="LS-"+i.start,p="LE-"+i.end,c={};i.type==="arrow_open"?c.arrowhead="none":c.arrowhead="normal";let y="",u="";if(i.style!==void 0){let h=X(i.style);y=h.style,u=h.labelStyle}else switch(i.stroke){case"normal":y="fill:none",a!==void 0&&(y=a),s!==void 0&&(u=s);break;case"dotted":y="fill:none;stroke-width:2px;stroke-dasharray:3;";break;case"thick":y=" stroke-width: 3.5px;fill:none";break}c.style=y,c.labelStyle=u,i.interpolate!==void 0?c.curve=Y(i.interpolate,G):r.defaultInterpolate!==void 0?c.curve=Y(r.defaultInterpolate,G):c.curve=Y(Zt.curve,G),i.text===void 0?i.style!==void 0&&(c.arrowheadStyle="fill: #333"):(c.arrowheadStyle="fill: #333",c.labelpos="c",ot(H().flowchart.htmlLabels)?(c.labelType="html",c.label=`${i.text.replace(/fa[blrs]?:fa-[\w-]+/g,h=>``)}`):(c.labelType="text",c.label=i.text.replace(lt.lineBreakRegex,` `),i.style===void 0&&(c.style=c.style||"stroke: #333; stroke-width: 1.5px;fill:none"),c.labelStyle=c.labelStyle.replace("color:","fill:"))),c.id=o,c.class=d+" "+p,c.minlen=i.length||1,e.setEdge(t.db.lookUpDomId(i.start),t.db.lookUpDomId(i.end),c,n)})},"addEdges"),Ce=l(function(r,e){B.info("Extracting classes"),e.db.clear();try{return e.parse(r),e.db.getClasses()}catch(t){return B.error(t),{}}},"getClasses"),Ne=l(function(r,e,t,n){B.info("Drawing flowchart"),n.db.clear();let{securityLevel:a,flowchart:s}=H(),i;a==="sandbox"&&(i=v("#i"+e));let o=a==="sandbox"?v(i.nodes()[0].contentDocument.body):v("body"),d=a==="sandbox"?i.nodes()[0].contentDocument:document,p=n.db.getDirection();p===void 0&&(p="TD");let c=s.nodeSpacing||50,y=s.rankSpacing||50,u=new wt({multigraph:!0,compound:!0}).setGraph({rankdir:p,nodesep:c,ranksep:y,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}}),h,m=n.db.getSubGraphs();for(let w=m.length-1;w>=0;w--)h=m[w],n.db.addVertex(h.id,h.title,"group",void 0,h.classes);let x=n.db.getVertices();B.warn("Get vertices",x);let f=n.db.getEdges(),g=0;for(g=m.length-1;g>=0;g--){h=m[g],ut("cluster").append("text");for(let w=0;w{r.flowchart||(r.flowchart={}),r.flowchart.arrowMarkerAbsolute=r.arrowMarkerAbsolute,te.setConf(r.flowchart),F.clear(),F.setGen("gen-1")}};export{ea as diagram};