livebook/static/assets/chunk-47P5NBBB.js
2024-12-05 05:49:36 +00:00

2 lines
8.7 KiB
JavaScript

import{a as vt}from"./chunk-XHGORZV2.js";import{Ea as _,Ha as A,Ia as N,Ja as R,Ka as H,La as D,Ma as O,N as w,Na as j,Oa as z,Pa as U,Qa as k,Ra as G,Sa as J,Ta as X,Ua as Y,Va as q,Wa as Z,Xa as K,Ya as Q,Za as V,h as s,ia as F,j as f,m as v,p as L,s as B,w as S}from"./chunk-KRX7QNR4.js";import{T as tt,k as M}from"./chunk-24JW6VB3.js";import{i as mt}from"./chunk-MGYUK2XN.js";var rt=mt(vt(),1);var yt="\u200B",xt={curveBasis:R,curveBasisClosed:H,curveBasisOpen:D,curveBumpX:A,curveBumpY:N,curveBundle:O,curveCardinalClosed:z,curveCardinalOpen:U,curveCardinal:j,curveCatmullRomClosed:G,curveCatmullRomOpen:J,curveCatmullRom:k,curveLinear:_,curveLinearClosed:X,curveMonotoneX:Y,curveMonotoneY:q,curveNatural:Z,curveStep:K,curveStepAfter:V,curveStepBefore:Q},pt=/\s*(?:(\w+)(?=:):|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi,$t=s(function(e,t){let n=it(e,/(?:init\b)|(?:initialize\b)/),r={};if(Array.isArray(n)){let a=n.map(l=>l.args);S(a),r=B(r,[...a])}else r=n.args;if(!r)return;let o=L(e,t),i="config";return r[i]!==void 0&&(o==="flowchart-v2"&&(o="flowchart"),r[o]=r[i],delete r[i]),r},"detectInit"),it=s(function(e,t=null){var n,r;try{let o=new RegExp(`[%]{2}(?![{]${pt.source})(?=[}][%]{2}).*
`,"ig");e=e.trim().replace(o,"").replace(/'/gm,'"'),f.debug(`Detecting diagram directive${t!==null?" type:"+t:""} based on the text:${e}`);let i,a=[];for(;(i=v.exec(e))!==null;)if(i.index===v.lastIndex&&v.lastIndex++,i&&!t||t&&((n=i[1])!=null&&n.match(t))||t&&((r=i[2])!=null&&r.match(t))){let l=i[1]?i[1]:i[2],c=i[3]?i[3].trim():i[4]?JSON.parse(i[4].trim()):null;a.push({type:l,args:c})}return a.length===0?{type:e,args:null}:a.length===1?a[0]:a}catch(o){return f.error(`ERROR: ${o.message} - Unable to parse directive type: '${t}' based on the text: '${e}'`),{type:void 0,args:null}}},"detectDirective"),Dt=s(function(e){return e.replace(v,"")},"removeDirectives"),wt=s(function(e,t){for(let[n,r]of t.entries())if(r.match(e))return n;return-1},"isSubstringInArray");function ot(e,t){var r;if(!e)return t;let n=`curve${e.charAt(0).toUpperCase()+e.slice(1)}`;return(r=xt[n])!=null?r:t}s(ot,"interpolateToCurve");function at(e,t){let n=e.trim();if(n)return t.securityLevel!=="loose"?(0,rt.sanitizeUrl)(n):n}s(at,"formatUrl");var Mt=s((e,...t)=>{let n=e.split("."),r=n.length-1,o=n[r],i=window;for(let a=0;a<r;a++)if(i=i[n[a]],!i){f.error(`Function name: ${e} not found in window`);return}i[o](...t)},"runFunc");function W(e,t){return!e||!t?0:Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}s(W,"distance");function st(e){let t,n=0;e.forEach(o=>{n+=W(o,t),t=o});let r=n/2;return T(e,r)}s(st,"traverseEdge");function ct(e){return e.length===1?e[0]:st(e)}s(ct,"calcLabelPosition");var et=s((e,t=2)=>{let n=Math.pow(10,t);return Math.round(e*n)/n},"roundNumber"),T=s((e,t)=>{let n,r=t;for(let o of e){if(n){let i=W(o,n);if(i<r)r-=i;else{let a=r/i;if(a<=0)return n;if(a>=1)return{x:o.x,y:o.y};if(a>0&&a<1)return{x:et((1-a)*n.x+a*o.x,5),y:et((1-a)*n.y+a*o.y,5)}}}n=o}throw new Error("Could not find a suitable point for the given distance")},"calculatePoint"),bt=s((e,t,n)=>{f.info(`our points ${JSON.stringify(t)}`),t[0]!==n&&(t=t.reverse());let o=T(t,25),i=e?10:5,a=Math.atan2(t[0].y-o.y,t[0].x-o.x),l={x:0,y:0};return l.x=Math.sin(a)*i+(t[0].x+o.x)/2,l.y=-Math.cos(a)*i+(t[0].y+o.y)/2,l},"calcCardinalityPosition");function lt(e,t,n){let r=structuredClone(n);f.info("our points",r),t!=="start_left"&&t!=="start_right"&&r.reverse();let o=25+e,i=T(r,o),a=10+e*.5,l=Math.atan2(r[0].y-i.y,r[0].x-i.x),c={x:0,y:0};return t==="start_left"?(c.x=Math.sin(l+Math.PI)*a+(r[0].x+i.x)/2,c.y=-Math.cos(l+Math.PI)*a+(r[0].y+i.y)/2):t==="end_right"?(c.x=Math.sin(l-Math.PI)*a+(r[0].x+i.x)/2-5,c.y=-Math.cos(l-Math.PI)*a+(r[0].y+i.y)/2-5):t==="end_left"?(c.x=Math.sin(l)*a+(r[0].x+i.x)/2-5,c.y=-Math.cos(l)*a+(r[0].y+i.y)/2-5):(c.x=Math.sin(l)*a+(r[0].x+i.x)/2,c.y=-Math.cos(l)*a+(r[0].y+i.y)/2),c}s(lt,"calcTerminalLabelPosition");function ut(e){let t="",n="";for(let r of e)r!==void 0&&(r.startsWith("color:")||r.startsWith("text-align:")?n=n+r+";":t=t+r+";");return{style:t,labelStyle:n}}s(ut,"getStylesFromArray");var nt=0,Bt=s(()=>(nt++,"id-"+Math.random().toString(36).substr(2,12)+"-"+nt),"generateId");function ht(e){let t="",n="0123456789abcdef",r=n.length;for(let o=0;o<e;o++)t+=n.charAt(Math.floor(Math.random()*r));return t}s(ht,"makeRandomHex");var Wt=s(e=>ht(e.length),"random"),Tt=s(function(){return{x:0,y:0,fill:void 0,anchor:"start",style:"#666",width:100,height:100,textMargin:0,rx:0,ry:0,valign:void 0,text:""}},"getTextObj"),Ct=s(function(e,t){let n=t.text.replace(w.lineBreakRegex," "),[,r]=P(t.fontSize),o=e.append("text");o.attr("x",t.x),o.attr("y",t.y),o.style("text-anchor",t.anchor),o.style("font-family",t.fontFamily),o.style("font-size",r),o.style("font-weight",t.fontWeight),o.attr("fill",t.fill),t.class!==void 0&&o.attr("class",t.class);let i=o.append("tspan");return i.attr("x",t.x+t.textMargin*2),i.attr("fill",t.fill),i.text(n),o},"drawSimpleText"),Pt=M((e,t,n)=>{if(!e||(n=Object.assign({fontSize:12,fontWeight:400,fontFamily:"Arial",joinWith:"<br/>"},n),w.lineBreakRegex.test(e)))return e;let r=e.split(" ").filter(Boolean),o=[],i="";return r.forEach((a,l)=>{let c=y(`${a} `,n),u=y(i,n);if(c>t){let{hyphenatedStrings:m,remainingWord:h}=Et(a,t,"-",n);o.push(i,...m),i=h}else u+c>=t?(o.push(i),i=a):i=[i,a].filter(Boolean).join(" ");l+1===r.length&&o.push(i)}),o.filter(a=>a!=="").join(n.joinWith)},(e,t,n)=>`${e}${t}${n.fontSize}${n.fontWeight}${n.fontFamily}${n.joinWith}`),Et=M((e,t,n="-",r)=>{r=Object.assign({fontSize:12,fontWeight:400,fontFamily:"Arial",margin:0},r);let o=[...e],i=[],a="";return o.forEach((l,c)=>{let u=`${a}${l}`;if(y(u,r)>=t){let p=c+1,m=o.length===p,h=`${u}${n}`;i.push(m?u:h),a=""}else a=u}),{hyphenatedStrings:i,remainingWord:a}},(e,t,n="-",r)=>`${e}${t}${n}${r.fontSize}${r.fontWeight}${r.fontFamily}`);function dt(e,t){return C(e,t).height}s(dt,"calculateTextHeight");function y(e,t){return C(e,t).width}s(y,"calculateTextWidth");var C=M((e,t)=>{let{fontSize:n=12,fontFamily:r="Arial",fontWeight:o=400}=t;if(!e)return{width:0,height:0};let[,i]=P(n),a=["sans-serif",r],l=e.split(w.lineBreakRegex),c=[],u=F("body");if(!u.remove)return{width:0,height:0,lineHeight:0};let x=u.append("svg");for(let m of a){let h=0,d={width:0,height:0,lineHeight:0};for(let gt of l){let E=Tt();E.text=gt||yt;let I=Ct(x,E).style("font-size",i).style("font-weight",o).style("font-family",m),$=(I._groups||I)[0][0].getBBox();if($.width===0&&$.height===0)throw new Error("svg element not in render tree");d.width=Math.round(Math.max(d.width,$.width)),h=Math.round($.height),d.height+=h,d.lineHeight=Math.round(Math.max(d.lineHeight,h))}c.push(d)}x.remove();let p=isNaN(c[1].height)||isNaN(c[1].width)||isNaN(c[1].lineHeight)||c[0].height>c[1].height&&c[0].width>c[1].width&&c[0].lineHeight>c[1].lineHeight?0:1;return c[p]},(e,t)=>`${e}${t.fontSize}${t.fontWeight}${t.fontFamily}`),g,It=(g=class{constructor(t=!1,n){this.count=0,this.count=n?n.length:0,this.next=t?()=>this.count++:()=>Date.now()}},s(g,"InitIDGenerator"),g),b,Lt=s(function(e){return b=b||document.createElement("div"),e=escape(e).replace(/%26/g,"&").replace(/%23/g,"#").replace(/%3B/g,";"),b.innerHTML=e,unescape(b.textContent)},"entityDecode");function St(e){return"str"in e}s(St,"isDetailedError");var Ft=s((e,t,n,r)=>{var i;if(!r)return;let o=(i=e.node())==null?void 0:i.getBBox();o&&e.append("text").text(r).attr("text-anchor","middle").attr("x",o.x+o.width/2).attr("y",-n).attr("class",t)},"insertTitle"),P=s(e=>{if(typeof e=="number")return[e,e+"px"];let t=parseInt(e!=null?e:"",10);return Number.isNaN(t)?[void 0,void 0]:e===String(t)?[t,e+"px"]:[t,e]},"parseFontSize");function ft(e,t){return tt({},e,t)}s(ft,"cleanAndMerge");var Ot={assignWithDepth:B,wrapLabel:Pt,calculateTextHeight:dt,calculateTextWidth:y,calculateTextDimensions:C,cleanAndMerge:ft,detectInit:$t,detectDirective:it,isSubstringInArray:wt,interpolateToCurve:ot,calcLabelPosition:ct,calcCardinalityPosition:bt,calcTerminalLabelPosition:lt,formatUrl:at,getStylesFromArray:ut,generateId:Bt,random:Wt,runFunc:Mt,entityDecode:Lt,insertTitle:Ft,parseFontSize:P,InitIDGenerator:It},jt=s(function(e){let t=e;return t=t.replace(/style.*:\S*#.*;/g,function(n){return n.substring(0,n.length-1)}),t=t.replace(/classDef.*:\S*#.*;/g,function(n){return n.substring(0,n.length-1)}),t=t.replace(/#\w+;/g,function(n){let r=n.substring(1,n.length-1);return/^\+?\d+$/.test(r)?"\uFB02\xB0\xB0"+r+"\xB6\xDF":"\uFB02\xB0"+r+"\xB6\xDF"}),t},"encodeEntities"),zt=s(function(e){return e.replace(/fl°°/g,"&#").replace(/fl°/g,"&").replace(/¶ß/g,";")},"decodeEntities"),Ut=s((e,t,{counter:n=0,prefix:r,suffix:o})=>`${r?`${r}_`:""}${e}_${t}_${n}${o?`_${o}`:""}`,"getEdgeId");function _t(e){return e!=null?e:null}s(_t,"handleUndefinedAttr");export{yt as a,Dt as b,ot as c,ut as d,Bt as e,Wt as f,Pt as g,dt as h,y as i,St as j,P as k,ft as l,Ot as m,jt as n,zt as o,Ut as p,_t as q};