livebook/static/assets/chunk-2VAHKEM3.js
2023-05-27 07:05:48 +00:00

5 lines
2.7 KiB
JavaScript

import{Pa as x,a as y,ha as m}from"./chunk-CRHZHETQ.js";import{s as d}from"./chunk-HA3AQNT4.js";function w(a){let e=a.replace(/\n{2,}/g,`
`);return y(e)}function T(a){let e=w(a),{children:n}=d(e),r=[[]],c=0;function s(t,o="normal"){t.type==="text"?t.value.split(`
`).forEach((l,i)=>{i!==0&&(c++,r.push([])),l.split(" ").forEach(h=>{h&&r[c].push({content:h,type:o})})}):(t.type==="strong"||t.type==="emphasis")&&t.children.forEach(p=>{s(p,t.type)})}return n.forEach(t=>{t.type==="paragraph"&&t.children.forEach(o=>{s(o)})}),r}function E(a){let{children:e}=d(a);function n(r){return r.type==="text"?r.value.replace(/\n/g,"<br/>"):r.type==="strong"?`<strong>${r.children.map(n).join("")}</strong>`:r.type==="emphasis"?`<em>${r.children.map(n).join("")}</em>`:r.type==="paragraph"?`<p>${r.children.map(n).join("")}</p>`:`Unsupported markdown: ${r.type}`}return e.map(n).join("")}function L(a,e){e&&a.attr("style",e)}function k(a,e,n,r,c=!1){let s=a.append("foreignObject"),t=s.append("xhtml:div"),o=e.label,p=e.isNode?"nodeLabel":"edgeLabel";t.html(`
<span class="${p} ${r}" `+(e.labelStyle?'style="'+e.labelStyle+'"':"")+">"+o+"</span>"),L(t,e.labelStyle),t.style("display","table-cell"),t.style("white-space","nowrap"),t.style("max-width",n+"px"),t.attr("xmlns","http://www.w3.org/1999/xhtml"),c&&t.attr("class","labelBkg");let l=t.node().getBoundingClientRect();return l.width===n&&(t.style("display","table"),t.style("white-space","break-spaces"),t.style("width",n+"px"),l=t.node().getBoundingClientRect()),s.style("width",l.width),s.style("height",l.height),s.node()}function g(a,e,n){return a.append("tspan").attr("class","text-outer-tspan").attr("x",0).attr("y",e*n-.1+"em").attr("dy",n+"em")}function v(a,e,n,r=!1){let s=e.append("g"),t=s.insert("rect").attr("class","background"),o=s.append("text").attr("y","-10.1"),p=-1;if(n.forEach(l=>{p++;let i=g(o,p,1.1),h=[...l].reverse(),f,u=[];for(;h.length;)f=h.pop(),u.push(f),b(i,u),i.node().getComputedTextLength()>a&&(u.pop(),h.push(f),b(i,u),u=[],p++,i=g(o,p,1.1))}),r){let l=o.node().getBBox(),i=2;return t.attr("x",-i).attr("y",-i).attr("width",l.width+2*i).attr("height",l.height+2*i),s.node()}else return o.node()}function b(a,e){a.text(""),e.forEach((n,r)=>{let c=a.append("tspan").attr("font-style",n.type==="em"?"italic":"normal").attr("class","text-inner-tspan").attr("font-weight",n.type==="strong"?"bold":"normal");r===0?c.text(n.content):c.text(" "+n.content)})}var C=(a,e="",{style:n="",isTitle:r=!1,classes:c="",useHtmlLabels:s=!0,isNode:t=!0,width:o,addSvgBackground:p=!1}={})=>{if(m.info("createText",e,n,r,c,s,t,p),s){let l=E(e),i={isNode:t,label:x(l).replace(/fa[blrs]?:fa-[\w-]+/g,f=>`<i class='${f.replace(":"," ")}'></i>`),labelStyle:n.replace("fill:","color:")};return k(a,i,o,c,p)}else{let l=T(e);return v(o,a,l,p)}};export{C as a};