import{t as e}from"./src-BHeH9bp0.js";import{a as t,i as n,n as r,o as i,r as a,t as o}from"./esm-D3bORTFC.js";import{n as s}from"./marked.esm-BR-H6018.js";import{n as c,r as l}from"./chunk-AGHRB4JF-Dk9Dm4Nw.js";import{L as u,P as d,k as f,s as p,y as m}from"./chunk-ICPOFSXX-k6RnaK7d.js";import{i as h}from"./chunk-5PVQY5BW-C7UhewbW.js";var g={body:`<g><rect width="80" height="80" style="fill: #087ebf; stroke-width: 0px;"/><text transform="translate(21.16 64.67)" style="fill: #fff; font-family: ArialMT, Arial; font-size: 67.75px;"><tspan x="0" y="0">?</tspan></text></g>`,height:80,width:80},_=new Map,v=new Map,y=c(e=>{for(let t of e){if(!t.name)throw Error(`Invalid icon loader. Must have a "name" property with non-empty string value.`);if(l.debug(`Registering icon pack:`,t.name),`loader`in t)v.set(t.name,t.loader);else if(`icons`in t)_.set(t.name,t.icons);else throw l.error(`Invalid icon loader:`,t),Error(`Invalid icon loader. Must have either "icons" or "loader" property.`)}},`registerIconPacks`),b=c(async(e,n)=>{let r=i(e,!0,n!==void 0);if(!r)throw Error(`Invalid icon name: ${e}`);let a=r.prefix||n;if(!a)throw Error(`Icon name must contain a prefix: ${e}`);let o=_.get(a);if(!o){let e=v.get(a);if(!e)throw Error(`Icon set not found: ${r.prefix}`);try{o={...await e(),prefix:a},_.set(a,o)}catch(e){throw l.error(e),Error(`Failed to load icon set: ${r.prefix}`)}}let s=t(o,r.name);if(!s)throw Error(`Icon not found: ${e}`);return s},`getRegisteredIconData`),x=c(async e=>{try{return await b(e),!0}catch{return!1}},`isIconAvailable`),S=c(async(e,t,i)=>{let o;try{o=await b(e,t?.fallbackPrefix)}catch(e){l.error(e),o=g}let s=n(o,t);return u(r(a(s.body),{...s.attributes,...i}),m())},`getIconSVG`);function C(e,{markdownAutoWrap:t}){return o(e.replace(/<br\/>/g,`
`).replace(/\n{2,}/g,`
`))}c(C,`preprocessMarkdown`);function w(e){return e.split(/\\n|\n|<br\s*\/?>/gi).map(e=>e.trim().match(/<[^>]+>|[^\s<>]+/g)?.map(e=>({content:e,type:`normal`}))??[])}c(w,`nonMarkdownToLines`);function T(e,t={}){let n=C(e,t),r=s.lexer(n),i=[[]],a=0;function o(e,t=`normal`){e.type===`text`?e.text.split(`
`).forEach((e,n)=>{n!==0&&(a++,i.push([])),e.split(` `).forEach(e=>{e=e.replace(/&#39;/g,`'`),e&&i[a].push({content:e,type:t})})}):e.type===`strong`||e.type===`em`?e.tokens.forEach(t=>{o(t,e.type)}):e.type===`html`&&i[a].push({content:e.text,type:`normal`})}return c(o,`processNode`),r.forEach(e=>{e.type===`paragraph`?e.tokens?.forEach(e=>{o(e)}):e.type===`html`?i[a].push({content:e.text,type:`normal`}):i[a].push({content:e.raw,type:`normal`})}),i}c(T,`markdownToLines`);function E(e){return e?`<p>${e.replace(/\\n|\n/g,`<br />`)}</p>`:``}c(E,`nonMarkdownToHTML`);function D(e,{markdownAutoWrap:t}={}){let n=s.lexer(e);function r(e){return e.type===`text`?t===!1?e.text.replace(/\n */g,`<br/>`).replace(/ /g,`&nbsp;`):e.text.replace(/\n */g,`<br/>`):e.type===`strong`?`<strong>${e.tokens?.map(r).join(``)}</strong>`:e.type===`em`?`<em>${e.tokens?.map(r).join(``)}</em>`:e.type===`paragraph`?`<p>${e.tokens?.map(r).join(``)}</p>`:e.type===`space`?``:e.type===`html`?`${e.text}`:e.type===`escape`?e.text:(l.warn(`Unsupported markdown: ${e.type}`),e.raw)}return c(r,`output`),n.map(r).join(``)}c(D,`markdownToHTML`);function O(e){return Intl.Segmenter?[...new Intl.Segmenter().segment(e)].map(e=>e.segment):[...e]}c(O,`splitTextToChars`);function k(e,t){return A(e,[],O(t.content),t.type)}c(k,`splitWordToFitWidth`);function A(e,t,n,r){if(n.length===0)return[{content:t.join(``),type:r},{content:``,type:r}];let[i,...a]=n,o=[...t,i];return e([{content:o.join(``),type:r}])?A(e,o,a,r):(t.length===0&&i&&(t.push(i),n.shift()),[{content:t.join(``),type:r},{content:n.join(``),type:r}])}c(A,`splitWordToFitWidthRecursion`);function j(e,t){if(e.some(({content:e})=>e.includes(`
`)))throw Error(`splitLineToFitWidth does not support newlines in the line`);return M(e,t)}c(j,`splitLineToFitWidth`);function M(e,t,n=[],r=[]){if(e.length===0)return r.length>0&&n.push(r),n.length>0?n:[];let i=``;e[0].content===` `&&(i=` `,e.shift());let a=e.shift()??{content:` `,type:`normal`},o=[...r];if(i!==``&&o.push({content:i,type:`normal`}),o.push(a),t(o))return M(e,t,n,o);if(r.length>0)n.push(r),e.unshift(a);else if(a.content){let[r,i]=k(t,a);n.push([r]),i.content&&e.unshift(i)}return M(e,t,n)}c(M,`splitLineToFitWidthRecursion`);function N(e,t){t&&e.attr(`style`,t)}c(N,`applyStyle`);var P=16384;async function F(e,t,n,r,i=!1,a=m()){let o=e.append(`foreignObject`);o.attr(`width`,`${Math.min(10*n,P)}px`),o.attr(`height`,`${Math.min(10*n,P)}px`);let s=o.append(`xhtml:div`),c=f(t.label)?await d(t.label.replace(p.lineBreakRegex,`
`),a):u(t.label,a),l=t.isNode?`nodeLabel`:`edgeLabel`,h=s.append(`span`);h.html(c),N(h,t.labelStyle),h.attr(`class`,`${l} ${r}`),N(s,t.labelStyle),s.style(`display`,`table-cell`),s.style(`white-space`,`nowrap`),s.style(`line-height`,`1.5`),n!==1/0&&(s.style(`max-width`,n+`px`),s.style(`text-align`,`center`)),s.attr(`xmlns`,`http://www.w3.org/1999/xhtml`),i&&s.attr(`class`,`labelBkg`);let g=s.node().getBoundingClientRect();return g.width===n&&(s.style(`display`,`table`),s.style(`white-space`,`break-spaces`),s.style(`width`,n+`px`),g=s.node().getBoundingClientRect()),o.node()}c(F,`addHtmlSpan`);function I(e,t,n,r=!1){let i=e.append(`tspan`).attr(`class`,`text-outer-tspan`).attr(`x`,0).attr(`y`,t*n-.1+`em`).attr(`dy`,n+`em`);return r&&i.attr(`text-anchor`,`middle`),i}c(I,`createTspan`);function L(e,t,n){let r=e.append(`text`),i=I(r,1,t);V(i,n);let a=i.node().getComputedTextLength();return r.remove(),a}c(L,`computeWidthOfText`);function R(e,t,n){let r=e.append(`text`),i=I(r,1,t);V(i,[{content:n,type:`normal`}]);let a=i.node()?.getBoundingClientRect();return a&&r.remove(),a}c(R,`computeDimensionOfText`);function z(e,t,n,r=!1,i=!1){let a=1.1,o=t.append(`g`),s=o.insert(`rect`).attr(`class`,`background`).attr(`style`,`stroke: none`),l=o.append(`text`).attr(`y`,`-10.1`);i&&l.attr(`text-anchor`,`middle`);let u=0;for(let t of n){let n=c(t=>L(o,a,t)<=e,`checkWidth`),r=n(t)?[t]:j(t,n);for(let e of r)V(I(l,u,a,i),e),u++}if(r){let e=l.node().getBBox();return s.attr(`x`,e.x-2).attr(`y`,e.y-2).attr(`width`,e.width+4).attr(`height`,e.height+4),o.node()}else return l.node()}c(z,`createFormattedText`);function B(e){return e.replace(/&(amp|lt|gt);/g,(e,t)=>{switch(t){case`amp`:return`&`;case`lt`:return`<`;case`gt`:return`>`;default:return e}})}c(B,`decodeHTMLEntities`);function V(e,t){e.text(``),t.forEach((t,n)=>{let r=e.append(`tspan`).attr(`font-style`,t.type===`em`?`italic`:`normal`).attr(`class`,`text-inner-tspan`).attr(`font-weight`,t.type===`strong`?`bold`:`normal`);n===0?r.text(B(t.content)):r.text(` `+B(t.content))})}c(V,`updateTextContentAndStyles`);async function H(e,t={}){let n=[];e.replace(/(fa[bklrs]?):fa-([\w-]+)/g,(e,r,i)=>(n.push((async()=>{let n=`${r}:${i}`;return await x(n)?await S(n,void 0,{class:`label-icon`}):`<i class='${u(e,t).replace(`:`,` `)}'></i>`})()),e));let r=await Promise.all(n);return e.replace(/(fa[bklrs]?):fa-([\w-]+)/g,()=>r.shift()??``)}c(H,`replaceIconSubstring`);var U=c(async(t,n=``,{style:r=``,isTitle:i=!1,classes:a=``,useHtmlLabels:o=!0,markdown:s=!0,isNode:c=!0,width:u=200,addSvgBackground:d=!1}={},p)=>{if(l.debug(`XYZ createText`,n,r,i,a,o,c,`addSvgBackground: `,d),o){let e=await H(h(s?D(n,p):E(n)),p),i=n.replace(/\\\\/g,`\\`);return await F(t,{isNode:c,label:f(n)?i:e,labelStyle:r.replace(`fill:`,`color:`)},u,a,d,p)}else{let a=h(n.replace(/<br\s*\/?>/g,`<br/>`)),o=z(u,t,s?T(a.replace(`<br>`,`<br/>`),p):w(a),n?d:!1,!c);if(c){/stroke:/.exec(r)&&(r=r.replace(`stroke:`,`lineColor:`));let t=r.replace(/stroke:[^;]+;?/g,``).replace(/stroke-width:[^;]+;?/g,``).replace(/fill:[^;]+;?/g,``).replace(/color:/g,`fill:`);e(o).attr(`style`,t)}else{let t=r.replace(/stroke:[^;]+;?/g,``).replace(/stroke-width:[^;]+;?/g,``).replace(/fill:[^;]+;?/g,``).replace(/background:/g,`fill:`);e(o).select(`rect`).attr(`style`,t.replace(/background:/g,`fill:`));let n=r.replace(/stroke:[^;]+;?/g,``).replace(/stroke-width:[^;]+;?/g,``).replace(/fill:[^;]+;?/g,``).replace(/color:/g,`fill:`);e(o).select(`text`).attr(`style`,n)}return i?e(o).selectAll(`tspan.text-outer-tspan`).classed(`title-row`,!0):e(o).selectAll(`tspan.text-outer-tspan`).classed(`row`,!0),o}},`createText`);export{g as a,y as i,U as n,S as r,R as t};
//# sourceMappingURL=chunk-U2HBQHQK-BTJFO3At.js.map