livebook/static/assets/chunk-BOD4ZWPQ.js
2024-11-21 10:56:42 +00:00

4 lines
14 KiB
JavaScript

import{a as U,d as w}from"./chunk-24CS6DUF.js";import{a as O}from"./chunk-YJYNUSAM.js";import{a as H}from"./chunk-5JJWRCP3.js";import{d as Y}from"./chunk-MCENFELV.js";import{m as u}from"./chunk-HFFTYNMA.js";import{Fa as R,I as W,Ja as X,Z as y,h as d,ia as T,j as f}from"./chunk-3QLLRM5L.js";var G=d((r,t,a,i,o)=>{t.arrowTypeStart&&A(r,"start",t.arrowTypeStart,a,i,o),t.arrowTypeEnd&&A(r,"end",t.arrowTypeEnd,a,i,o)},"addEdgeMarkers"),P={arrow_cross:"cross",arrow_point:"point",arrow_barb:"barb",arrow_circle:"circle",aggregation:"aggregation",extension:"extension",composition:"composition",dependency:"dependency",lollipop:"lollipop"},A=d((r,t,a,i,o,l)=>{let s=P[a];if(!s){f.warn(`Unknown arrow type: ${a}`);return}let n=t==="start"?"Start":"End";r.attr(`marker-${t}`,`url(${i}#${o}_${l}-${s}${n})`)},"addEdgeMarker"),_=new Map,k=new Map,gt=d(()=>{_.clear(),k.clear()},"clear"),M=d(r=>r?r.reduce((a,i)=>a+";"+i,""):"","getLabelStyles"),ut=d(async(r,t)=>{let a=W(y().flowchart.htmlLabels),i=await Y(r,t.label,{style:M(t.labelStyle),useHtmlLabels:a,addSvgBackground:!0,isNode:!1});f.info("abc82",t,t.labelType);let o=r.insert("g").attr("class","edgeLabel"),l=o.insert("g").attr("class","label");l.node().appendChild(i);let s=i.getBBox();if(a){let e=i.children[0],h=T(i);s=e.getBoundingClientRect(),h.attr("width",s.width),h.attr("height",s.height)}l.attr("transform","translate("+-s.width/2+", "+-s.height/2+")"),_.set(t.id,o),t.width=s.width,t.height=s.height;let n;if(t.startLabelLeft){let e=await w(t.startLabelLeft,M(t.labelStyle)),h=r.insert("g").attr("class","edgeTerminals"),p=h.insert("g").attr("class","inner");n=p.node().appendChild(e);let c=e.getBBox();p.attr("transform","translate("+-c.width/2+", "+-c.height/2+")"),k.get(t.id)||k.set(t.id,{}),k.get(t.id).startLeft=h,v(n,t.startLabelLeft)}if(t.startLabelRight){let e=await w(t.startLabelRight,M(t.labelStyle)),h=r.insert("g").attr("class","edgeTerminals"),p=h.insert("g").attr("class","inner");n=h.node().appendChild(e),p.node().appendChild(e);let c=e.getBBox();p.attr("transform","translate("+-c.width/2+", "+-c.height/2+")"),k.get(t.id)||k.set(t.id,{}),k.get(t.id).startRight=h,v(n,t.startLabelRight)}if(t.endLabelLeft){let e=await w(t.endLabelLeft,M(t.labelStyle)),h=r.insert("g").attr("class","edgeTerminals"),p=h.insert("g").attr("class","inner");n=p.node().appendChild(e);let c=e.getBBox();p.attr("transform","translate("+-c.width/2+", "+-c.height/2+")"),h.node().appendChild(e),k.get(t.id)||k.set(t.id,{}),k.get(t.id).endLeft=h,v(n,t.endLabelLeft)}if(t.endLabelRight){let e=await w(t.endLabelRight,M(t.labelStyle)),h=r.insert("g").attr("class","edgeTerminals"),p=h.insert("g").attr("class","inner");n=p.node().appendChild(e);let c=e.getBBox();p.attr("transform","translate("+-c.width/2+", "+-c.height/2+")"),h.node().appendChild(e),k.get(t.id)||k.set(t.id,{}),k.get(t.id).endRight=h,v(n,t.endLabelRight)}return i},"insertEdgeLabel");function v(r,t){y().flowchart.htmlLabels&&r&&(r.style.width=t.length*9+"px",r.style.height="12px")}d(v,"setTerminalWidth");var Lt=d((r,t)=>{f.debug("Moving label abc88 ",r.id,r.label,_.get(r.id),t);let a=t.updatedPath?t.updatedPath:t.originalPath,i=y(),{subGraphTitleTotalMargin:o}=H(i);if(r.label){let l=_.get(r.id),s=r.x,n=r.y;if(a){let e=u.calcLabelPosition(a);f.debug("Moving label "+r.label+" from (",s,",",n,") to (",e.x,",",e.y,") abc88"),t.updatedPath&&(s=e.x,n=e.y)}l.attr("transform",`translate(${s}, ${n+o/2})`)}if(r.startLabelLeft){let l=k.get(r.id).startLeft,s=r.x,n=r.y;if(a){let e=u.calcTerminalLabelPosition(r.arrowTypeStart?10:0,"start_left",a);s=e.x,n=e.y}l.attr("transform",`translate(${s}, ${n})`)}if(r.startLabelRight){let l=k.get(r.id).startRight,s=r.x,n=r.y;if(a){let e=u.calcTerminalLabelPosition(r.arrowTypeStart?10:0,"start_right",a);s=e.x,n=e.y}l.attr("transform",`translate(${s}, ${n})`)}if(r.endLabelLeft){let l=k.get(r.id).endLeft,s=r.x,n=r.y;if(a){let e=u.calcTerminalLabelPosition(r.arrowTypeEnd?10:0,"end_left",a);s=e.x,n=e.y}l.attr("transform",`translate(${s}, ${n})`)}if(r.endLabelRight){let l=k.get(r.id).endRight,s=r.x,n=r.y;if(a){let e=u.calcTerminalLabelPosition(r.arrowTypeEnd?10:0,"end_right",a);s=e.x,n=e.y}l.attr("transform",`translate(${s}, ${n})`)}},"positionEdgeLabel"),V=d((r,t)=>{let a=r.x,i=r.y,o=Math.abs(t.x-a),l=Math.abs(t.y-i),s=r.width/2,n=r.height/2;return o>=s||l>=n},"outsideNode"),D=d((r,t,a)=>{f.debug(`intersection calc abc89:
outsidePoint: ${JSON.stringify(t)}
insidePoint : ${JSON.stringify(a)}
node : x:${r.x} y:${r.y} w:${r.width} h:${r.height}`);let i=r.x,o=r.y,l=Math.abs(i-a.x),s=r.width/2,n=a.x<t.x?s-l:s+l,e=r.height/2,h=Math.abs(t.y-a.y),p=Math.abs(t.x-a.x);if(Math.abs(o-t.y)*s>Math.abs(i-t.x)*e){let c=a.y<t.y?t.y-e-o:o-e-t.y;n=p*c/h;let x={x:a.x<t.x?a.x+n:a.x-p+n,y:a.y<t.y?a.y+h-c:a.y-h+c};return n===0&&(x.x=t.x,x.y=t.y),p===0&&(x.x=t.x),h===0&&(x.y=t.y),f.debug(`abc89 top/bottom calc, Q ${h}, q ${c}, R ${p}, r ${n}`,x),x}else{a.x<t.x?n=t.x-s-i:n=i-s-t.x;let c=h*n/p,x=a.x<t.x?a.x+p-n:a.x-p+n,m=a.y<t.y?a.y+c:a.y-c;return f.debug(`sides calc abc89, Q ${h}, q ${c}, R ${p}, r ${n}`,{_x:x,_y:m}),n===0&&(x=t.x,m=t.y),p===0&&(x=t.x),h===0&&(m=t.y),{x,y:m}}},"intersection"),Z=d((r,t)=>{f.warn("abc88 cutPathAtIntersect",r,t);let a=[],i=r[0],o=!1;return r.forEach(l=>{if(f.info("abc88 checking point",l,t),!V(t,l)&&!o){let s=D(t,i,l);f.debug("abc88 inside",l,i,s),f.debug("abc88 intersection",s,t);let n=!1;a.forEach(e=>{n=n||e.x===s.x&&e.y===s.y}),a.some(e=>e.x===s.x&&e.y===s.y)?f.warn("abc88 no intersect",s,a):a.push(s),o=!0}else f.warn("abc88 outside",l,i),i=l,o||a.push(l)}),f.debug("returning points",a),a},"cutPathAtIntersect");function q(r){let t=[],a=[];for(let i=1;i<r.length-1;i++){let o=r[i-1],l=r[i],s=r[i+1];(o.x===l.x&&l.y===s.y&&Math.abs(l.x-s.x)>5&&Math.abs(l.y-o.y)>5||o.y===l.y&&l.x===s.x&&Math.abs(l.x-o.x)>5&&Math.abs(l.y-s.y)>5)&&(t.push(l),a.push(i))}return{cornerPoints:t,cornerPointPositions:a}}d(q,"extractCornerPoints");var N=d(function(r,t,a){let i=t.x-r.x,o=t.y-r.y,l=Math.sqrt(i*i+o*o),s=a/l;return{x:t.x-s*i,y:t.y-s*o}},"findAdjacentPoint"),K=d(function(r){let{cornerPointPositions:t}=q(r),a=[];for(let i=0;i<r.length;i++)if(t.includes(i)){let o=r[i-1],l=r[i+1],s=r[i],n=N(o,s,5),e=N(l,s,5),h=e.x-n.x,p=e.y-n.y;a.push(n);let c=Math.sqrt(2)*2,x={x:s.x,y:s.y};if(Math.abs(l.x-o.x)>10&&Math.abs(l.y-o.y)>=10){f.debug("Corner point fixing",Math.abs(l.x-o.x),Math.abs(l.y-o.y));let m=5;s.x===n.x?x={x:h<0?n.x-m+c:n.x+m-c,y:p<0?n.y-c:n.y+c}:x={x:h<0?n.x-c:n.x+c,y:p<0?n.y-m+c:n.y+m-c}}else f.debug("Corner point skipping fixing",Math.abs(l.x-o.x),Math.abs(l.y-o.y));a.push(x,e)}else a.push(r[i]);return a},"fixCorners"),wt=d(function(r,t,a,i,o,l,s){let{handDrawnSeed:n}=y(),e=t.points,h=!1,p=o;var c=l;c.intersect&&p.intersect&&(e=e.slice(1,t.points.length-1),e.unshift(p.intersect(e[0])),f.debug("Last point APA12",t.start,"-->",t.end,e[e.length-1],c,c.intersect(e[e.length-1])),e.push(c.intersect(e[e.length-1]))),t.toCluster&&(f.info("to cluster abc88",a.get(t.toCluster)),e=Z(t.points,a.get(t.toCluster).node),h=!0),t.fromCluster&&(f.debug("from cluster abc88",a.get(t.fromCluster),JSON.stringify(e,null,2)),e=Z(e.reverse(),a.get(t.fromCluster).node).reverse(),h=!0);let x=e.filter(L=>!Number.isNaN(L.y));x=K(x);let m=X;t.curve&&(m=t.curve);let{x:I,y:j}=O(t),J=R().x(I).y(j).curve(m),b;switch(t.thickness){case"normal":b="edge-thickness-normal";break;case"thick":b="edge-thickness-thick";break;case"invisible":b="edge-thickness-invisible";break;default:b="edge-thickness-normal"}switch(t.pattern){case"solid":b+=" edge-pattern-solid";break;case"dotted":b+=" edge-pattern-dotted";break;case"dashed":b+=" edge-pattern-dashed";break;default:b+=" edge-pattern-solid"}let g,B=J(x),E=Array.isArray(t.style)?t.style:[t.style];if(t.look==="handDrawn"){let L=U.svg(r);Object.assign([],x);let C=L.path(B,{roughness:.3,seed:n});b+=" transition",g=T(C).select("path").attr("id",t.id).attr("class"," "+b+(t.classes?" "+t.classes:"")).attr("style",E?E.reduce((z,F)=>z+";"+F,""):"");let Q=g.attr("d");g.attr("d",Q),r.node().appendChild(g.node())}else g=r.append("path").attr("d",B).attr("id",t.id).attr("class"," "+b+(t.classes?" "+t.classes:"")).attr("style",E?E.reduce((L,C)=>L+";"+C,""):"");let S="";(y().flowchart.arrowMarkerAbsolute||y().state.arrowMarkerAbsolute)&&(S=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,S=S.replace(/\(/g,"\\(").replace(/\)/g,"\\)")),f.info("arrowTypeStart",t.arrowTypeStart),f.info("arrowTypeEnd",t.arrowTypeEnd),G(g,t,S,s,i);let $={};return h&&($.updatedPath=e),$.originalPath=t.points,$},"insertEdge"),tt=d((r,t,a,i)=>{t.forEach(o=>{ht[o](r,a,i)})},"insertMarkers"),rt=d((r,t,a)=>{f.trace("Making markers for ",a),r.append("defs").append("marker").attr("id",a+"_"+t+"-extensionStart").attr("class","marker extension "+t).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 1,7 L18,13 V 1 Z"),r.append("defs").append("marker").attr("id",a+"_"+t+"-extensionEnd").attr("class","marker extension "+t).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 1,1 V 13 L18,7 Z")},"extension"),at=d((r,t,a)=>{r.append("defs").append("marker").attr("id",a+"_"+t+"-compositionStart").attr("class","marker composition "+t).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),r.append("defs").append("marker").attr("id",a+"_"+t+"-compositionEnd").attr("class","marker composition "+t).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z")},"composition"),et=d((r,t,a)=>{r.append("defs").append("marker").attr("id",a+"_"+t+"-aggregationStart").attr("class","marker aggregation "+t).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),r.append("defs").append("marker").attr("id",a+"_"+t+"-aggregationEnd").attr("class","marker aggregation "+t).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z")},"aggregation"),st=d((r,t,a)=>{r.append("defs").append("marker").attr("id",a+"_"+t+"-dependencyStart").attr("class","marker dependency "+t).attr("refX",6).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 5,7 L9,13 L1,7 L9,1 Z"),r.append("defs").append("marker").attr("id",a+"_"+t+"-dependencyEnd").attr("class","marker dependency "+t).attr("refX",13).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L14,7 L9,1 Z")},"dependency"),nt=d((r,t,a)=>{r.append("defs").append("marker").attr("id",a+"_"+t+"-lollipopStart").attr("class","marker lollipop "+t).attr("refX",13).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("circle").attr("stroke","black").attr("fill","transparent").attr("cx",7).attr("cy",7).attr("r",6),r.append("defs").append("marker").attr("id",a+"_"+t+"-lollipopEnd").attr("class","marker lollipop "+t).attr("refX",1).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("circle").attr("stroke","black").attr("fill","transparent").attr("cx",7).attr("cy",7).attr("r",6)},"lollipop"),it=d((r,t,a)=>{r.append("marker").attr("id",a+"_"+t+"-pointEnd").attr("class","marker "+t).attr("viewBox","0 0 10 10").attr("refX",5).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",8).attr("markerHeight",8).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0"),r.append("marker").attr("id",a+"_"+t+"-pointStart").attr("class","marker "+t).attr("viewBox","0 0 10 10").attr("refX",4.5).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",8).attr("markerHeight",8).attr("orient","auto").append("path").attr("d","M 0 5 L 10 10 L 10 0 z").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0")},"point"),lt=d((r,t,a)=>{r.append("marker").attr("id",a+"_"+t+"-circleEnd").attr("class","marker "+t).attr("viewBox","0 0 10 10").attr("refX",11).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("circle").attr("cx","5").attr("cy","5").attr("r","5").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0"),r.append("marker").attr("id",a+"_"+t+"-circleStart").attr("class","marker "+t).attr("viewBox","0 0 10 10").attr("refX",-1).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("circle").attr("cx","5").attr("cy","5").attr("r","5").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0")},"circle"),ot=d((r,t,a)=>{r.append("marker").attr("id",a+"_"+t+"-crossEnd").attr("class","marker cross "+t).attr("viewBox","0 0 11 11").attr("refX",12).attr("refY",5.2).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("path").attr("d","M 1,1 l 9,9 M 10,1 l -9,9").attr("class","arrowMarkerPath").style("stroke-width",2).style("stroke-dasharray","1,0"),r.append("marker").attr("id",a+"_"+t+"-crossStart").attr("class","marker cross "+t).attr("viewBox","0 0 11 11").attr("refX",-1).attr("refY",5.2).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("path").attr("d","M 1,1 l 9,9 M 10,1 l -9,9").attr("class","arrowMarkerPath").style("stroke-width",2).style("stroke-dasharray","1,0")},"cross"),ct=d((r,t,a)=>{r.append("defs").append("marker").attr("id",a+"_"+t+"-barbEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",14).attr("markerUnits","userSpaceOnUse").attr("orient","auto").append("path").attr("d","M 19,7 L9,13 L14,7 L9,1 Z")},"barb"),ht={extension:rt,composition:at,aggregation:et,dependency:st,lollipop:nt,point:it,circle:lt,cross:ot,barb:ct},Mt=tt;export{gt as a,ut as b,Lt as c,wt as d,Mt as e};