import{f as $,p as kt}from"./flowDb-c6c81e3f-Xo4IlFVb.js";import{d as x,a1 as G,l as M,g as D,_ as St,$ as z,a0 as W,v as Z,W as tt,k as et}from"./intro-yEGgrrvb.js";import{G as Lt}from"./graph-dRcR-yLk.js";import{u as _t,r as Et,p as Tt,l as Nt,d as I}from"./layout-B3-ufvKb.js";import{b as T,c as rt,i as at,d as _,e as nt,g as st,f as At,a as Pt,s as Ct}from"./styles-d45a18b0-KIbkKEsH.js";import{l as It}from"./line-B-avEjkP.js";import"./dayjs.min-CfWDS3UC.js";import"./index-bIIEL2MP.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./iframe-CzjIX-qr.js";import"./index-CO-0pc0F.js";import"./index-Z-6k0Xrj.js";import"./index-aQYXhgXp.js";import"./index-DrFu-skq.js";import"./docsPage-CT2vyZOj.js";import"./Table-F-lkejrq.js";import"./parseCss-DFN8Q8fx.js";import"./index-D7HDsfES.js";import"./_color-UiaLB_4F.js";import"./index-5325376f-DOibkmr3.js";import"./clone-BQyYyzoF.js";import"./edges-96097737-bcIN93B1.js";import"./createText-1719965b-BPRaF8Mh.js";import"./channel-D_sSfY1t.js";import"./array-BKyUJesY.js";import"./path-CbwjOpE9.js";function Bt(r){if(!r.ok)throw new Error(r.status+" "+r.statusText);return r.text()}function Mt(r,e){return fetch(r,e).then(Bt)}function Dt(r){return(e,t)=>Mt(e,t).then(n=>new DOMParser().parseFromString(n,r))}var Rt=Dt("image/svg+xml"),V={normal:Ot,vee:Ut,undirected:$t};function Gt(r){V=r}function Ot(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");T(s,t[n+"Style"]),t[n+"Class"]&&s.attr("class",t[n+"Class"])}function Ut(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");T(s,t[n+"Style"]),t[n+"Class"]&&s.attr("class",t[n+"Class"])}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 5 L 10 5").style("stroke-width",1).style("stroke-dasharray","1,0");T(s,t[n+"Style"]),t[n+"Class"]&&s.attr("class",t[n+"Class"])}function Wt(r,e){var t=r;return t.node().appendChild(e.label),T(t,e.labelStyle),t}function zt(r,e){for(var t=r.append("text"),n=Vt(e.label).split(` `),a=0;a0}function E(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 p=f.x-t.x,v=f.y-t.y,k=Math.sqrt(p*p+v*v),P=g.x-t.x,L=g.y-t.y,O=Math.sqrt(P*P+L*L);return kMath.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 j={rect:se,ellipse:ie,circle:oe,diamond:le};function ne(r){j=r}function se(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 Q(t,a)},n}function ie(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 ot(t,n,a,i)},s}function oe(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 re(t,n,s)},a}function le(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 E(t,s,o)},i}function ce(){var r=function(e,t){ue(t);var n=B(e,"output"),a=B(n,"clusters"),s=B(n,"edgePaths"),i=H(B(n,"edgeLabels"),t),o=F(B(n,"nodes"),t,j);Nt(t),ee(o,t),te(i,t),X(s,t,V);var c=Y(a,t);Zt(c,t),pe(t)};return r.createNodes=function(e){return arguments.length?(Jt(e),r):F},r.createClusters=function(e){return arguments.length?(Yt(e),r):Y},r.createEdgeLabels=function(e){return arguments.length?(Ht(e),r):H},r.createEdgePaths=function(e){return arguments.length?(Xt(e),r):X},r.shapes=function(e){return arguments.length?(ne(e),r):j},r.arrows=function(e){return arguments.length?(Gt(e),r):V},r}var de={paddingLeft:10,paddingRight:10,paddingTop:10,paddingBottom:10,rx:0,ry:0,shape:"rect"},he={arrowhead:"normal",curve:G};function ue(r){r.nodes().forEach(e=>{const t=r.node(e);!Object.prototype.hasOwnProperty.call(t,"label")&&!r.children(e).length&&(t.label=e),Object.prototype.hasOwnProperty.call(t,"paddingX")&&I(t,{paddingLeft:t.paddingX,paddingRight:t.paddingX}),Object.prototype.hasOwnProperty.call(t,"paddingY")&&I(t,{paddingTop:t.paddingY,paddingBottom:t.paddingY}),Object.prototype.hasOwnProperty.call(t,"padding")&&I(t,{paddingLeft:t.padding,paddingRight:t.padding,paddingTop:t.padding,paddingBottom:t.padding}),I(t,de),["paddingLeft","paddingRight","paddingTop","paddingBottom"].forEach(n=>{t[n]=Number(t[n])}),Object.prototype.hasOwnProperty.call(t,"width")&&(t._prevWidth=t.width),Object.prototype.hasOwnProperty.call(t,"height")&&(t._prevHeight=t.height)}),r.edges().forEach(function(e){var t=r.edge(e);Object.prototype.hasOwnProperty.call(t,"label")||(t.label=""),I(t,he)})}function pe(r){r.nodes().forEach(e=>{var t=r.node(e);Object.prototype.hasOwnProperty.call(t,"_prevWidth")?t.width=t._prevWidth:delete t.width,Object.prototype.hasOwnProperty.call(t,"_prevHeight")?t.height=t._prevHeight:delete t.height,delete t._prevWidth,delete t._prevHeight})}function B(r,e){var t=r.select("g."+e);return t.empty()&&(t=r.append("g").attr("class",e)),t}function lt(r,e,t){const 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=N(r,s,s,i);return t.intersect=function(c){return E(t,i,c)},o}function ct(r,e,t){const 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=N(r,i,a,o);return t.intersect=function(d){return E(t,o,d)},c}function dt(r,e,t){const 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=N(r,n,a,s);return t.intersect=function(o){return E(t,s,o)},i}function ht(r,e,t){const 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=N(r,n,a,s);return t.intersect=function(o){return E(t,s,o)},i}function ut(r,e,t){const 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=N(r,n,a,s);return t.intersect=function(o){return E(t,s,o)},i}function pt(r,e,t){const 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=N(r,n,a,s);return t.intersect=function(o){return E(t,s,o)},i}function ft(r,e,t){const 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=N(r,n,a,s);return t.intersect=function(o){return E(t,s,o)},i}function yt(r,e,t){const 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=N(r,n,a,s);return t.intersect=function(o){return E(t,s,o)},i}function vt(r,e,t){const 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 Q(t,i)},s}function gt(r,e,t){const 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=N(r,n,a,s);return t.intersect=function(o){return E(t,s,o)},i}function wt(r,e,t){const 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){const l=Q(t,d),y=l.x-t.x;if(a!=0&&(Math.abs(y)t.height/2-s)){let h=s*s*(1-y*y/(a*a));h!=0&&(h=Math.sqrt(h)),h=s-h,d.y-t.y>0&&(h=-h),l.y+=h}return l},c}function fe(r){r.shapes().question=lt,r.shapes().hexagon=ct,r.shapes().stadium=vt,r.shapes().subroutine=gt,r.shapes().cylinder=wt,r.shapes().rect_left_inv_arrow=dt,r.shapes().lean_right=ht,r.shapes().lean_left=ut,r.shapes().trapezoid=pt,r.shapes().inv_trapezoid=ft,r.shapes().rect_right_inv_arrow=yt}function ye(r){r({question:lt}),r({hexagon:ct}),r({stadium:vt}),r({subroutine:gt}),r({cylinder:wt}),r({rect_left_inv_arrow:dt}),r({lean_right:ht}),r({lean_left:ut}),r({trapezoid:pt}),r({inv_trapezoid:ft}),r({rect_right_inv_arrow:yt})}function N(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+")")}const ve={addToRender:fe,addToRenderV2:ye},mt={},ge=function(r){const e=Object.keys(r);for(const t of e)mt[t]=r[t]},xt=async function(r,e,t,n,a,s){const i=n?n.select(`[id="${t}"]`):x(`[id="${t}"]`),o=a||document,c=Object.keys(r);for(const d of c){const l=r[d];let y="default";l.classes.length>0&&(y=l.classes.join(" "));const h=z(l.styles);let u=l.text!==void 0?l.text:l.id,f;if(Z(D().flowchart.htmlLabels)){const v={label:await tt(u.replace(/fa[blrs]?:fa-[\w-]+/g,k=>``),D())};f=rt(i,v).node(),f.parentNode.removeChild(f)}else{const v=o.createElementNS("http://www.w3.org/2000/svg","text");v.setAttribute("style",h.labelStyle.replace("color:","fill:"));const k=u.split(et.lineBreakRegex);for(const P of k){const L=o.createElementNS("http://www.w3.org/2000/svg","tspan");L.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),L.setAttribute("dy","1em"),L.setAttribute("x","1"),L.textContent=P,v.appendChild(L)}f=v}let g=0,p="";switch(l.type){case"round":g=5,p="rect";break;case"square":p="rect";break;case"diamond":p="question";break;case"hexagon":p="hexagon";break;case"odd":p="rect_left_inv_arrow";break;case"lean_right":p="lean_right";break;case"lean_left":p="lean_left";break;case"trapezoid":p="trapezoid";break;case"inv_trapezoid":p="inv_trapezoid";break;case"odd_right":p="rect_left_inv_arrow";break;case"circle":p="circle";break;case"ellipse":p="ellipse";break;case"stadium":p="stadium";break;case"subroutine":p="subroutine";break;case"cylinder":p="cylinder";break;case"group":p="rect";break;default:p="rect"}M.warn("Adding node",l.id,l.domId),e.setNode(s.db.lookUpDomId(l.id),{labelType:"svg",labelStyle:h.labelStyle,shape:p,label:f,rx:g,ry:g,class:y,style:h.style,id:s.db.lookUpDomId(l.id)})}},bt=async function(r,e,t){let n=0,a,s;if(r.defaultStyle!==void 0){const i=z(r.defaultStyle);a=i.style,s=i.labelStyle}for(const i of r){n++;const 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 y="",h="";if(i.style!==void 0){const u=z(i.style);y=u.style,h=u.labelStyle}else switch(i.stroke){case"normal":y="fill:none",a!==void 0&&(y=a),s!==void 0&&(h=s);break;case"dotted":y="fill:none;stroke-width:2px;stroke-dasharray:3;";break;case"thick":y=" stroke-width: 3.5px;fill:none";break}l.style=y,l.labelStyle=h,i.interpolate!==void 0?l.curve=W(i.interpolate,G):r.defaultInterpolate!==void 0?l.curve=W(r.defaultInterpolate,G):l.curve=W(mt.curve,G),i.text===void 0?i.style!==void 0&&(l.arrowheadStyle="fill: #333"):(l.arrowheadStyle="fill: #333",l.labelpos="c",Z(D().flowchart.htmlLabels)?(l.labelType="html",l.label=`${await tt(i.text.replace(/fa[blrs]?:fa-[\w-]+/g,u=>``),D())}`):(l.labelType="text",l.label=i.text.replace(et.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)}},we=function(r,e){return M.info("Extracting classes"),e.db.getClasses()},me=async function(r,e,t,n){M.info("Drawing flowchart");const{securityLevel:a,flowchart:s}=D();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,y=s.rankSpacing||50,h=new Lt({multigraph:!0,compound:!0}).setGraph({rankdir:d,nodesep:l,ranksep:y,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});let u;const f=n.db.getSubGraphs();for(let w=f.length-1;w>=0;w--)u=f[w],n.db.addVertex(u.id,u.title,"group",void 0,u.classes);const g=n.db.getVertices();M.warn("Get vertices",g);const p=n.db.getEdges();let v=0;for(v=f.length-1;v>=0;v--){u=f[v],Ct("cluster").append("text");for(let w=0;w{r.flowchart||(r.flowchart={}),r.flowchart.arrowMarkerAbsolute=r.arrowMarkerAbsolute,xe.setConf(r.flowchart),$.clear(),$.setGen("gen-1")}};export{Fe as diagram};