chalk-talk 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,182 @@
1
+ /*! chalk-talk Mermaid (engine v0.247.0) — MIT; mermaid-to-excalidraw and Mermaid (MIT) */
2
+ var gk=Object.create;var to=Object.defineProperty;var mk=Object.getOwnPropertyDescriptor;var yk=Object.getOwnPropertyNames;var xk=Object.getPrototypeOf,wk=Object.prototype.hasOwnProperty;var bk=(e,t,r)=>t in e?to(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Xe=(e,t)=>()=>(e&&(t=e(e=0)),t);var $k=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),_t=(e,t)=>{for(var r in t)to(e,r,{get:t[r],enumerable:!0})},kk=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of yk(t))!wk.call(e,i)&&i!==r&&to(e,i,{get:()=>t[i],enumerable:!(a=mk(t,i))||a.enumerable});return e};var Mk=(e,t,r)=>(r=e!=null?gk(xk(e)):{},kk(t||!e||!e.__esModule?to(r,"default",{value:e,enumerable:!0}):r,e));var he=(e,t,r)=>bk(e,typeof t!="symbol"?t+"":t,r);var vu=$k(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.removeMarkdown=void 0;var Ak=function(e,t){t===void 0&&(t={listUnicodeChar:""}),t=t||{},t.listUnicodeChar=t.hasOwnProperty("listUnicodeChar")?t.listUnicodeChar:!1,t.stripListLeaders=t.hasOwnProperty("stripListLeaders")?t.stripListLeaders:!0,t.gfm=t.hasOwnProperty("gfm")?t.gfm:!0,t.useImgAltText=t.hasOwnProperty("useImgAltText")?t.useImgAltText:!0,t.preserveLinks=t.hasOwnProperty("preserveLinks")?t.preserveLinks:!1;var r=e||"";r=r.replace(/^(-\s*?|\*\s*?|_\s*?){3,}\s*$/gm,"");try{t.stripListLeaders&&(t.listUnicodeChar?r=r.replace(/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm,t.listUnicodeChar+" $1"):r=r.replace(/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm,"$1")),t.gfm&&(r=r.replace(/\n={2,}/g,`
3
+ `).replace(/~{3}.*\n/g,"").replace(/~~/g,"").replace(/`{3}.*\n/g,"")),t.preserveLinks&&(r=r.replace(/\[(.*?)\][\[\(](.*?)[\]\)]/g,"$1 ($2)")),r=r.replace(/<[^>]*>/g,"").replace(/^[=\-]{2,}\s*$/g,"").replace(/\[\^.+?\](\: .*?$)?/g,"").replace(/\s{0,2}\[.*?\]: .*?$/g,"").replace(/\!\[(.*?)\][\[\(].*?[\]\)]/g,t.useImgAltText?"$1":"").replace(/\[(.*?)\][\[\(].*?[\]\)]/g,"$1").replace(/^\s{0,3}>\s?/g,"").replace(/(^|\n)\s{0,3}>\s?/g,`
4
+
5
+ `).replace(/^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$/g,"").replace(/^(\n)?\s{0,}#{1,6}\s+| {0,}(\n)?\s{0,}#{0,} {0,}(\n)?\s{0,}$/gm,"$1$2$3").replace(/([\*_]{1,3})(\S.*?\S{0,1})\1/g,"$2").replace(/([\*_]{1,3})(\S.*?\S{0,1})\1/g,"$2").replace(/(`{3,})(.*?)\1/gm,"$2").replace(/`(.+?)`/g,"$1").replace(/\n{2,}/g,`
6
+
7
+ `)}catch(a){return console.error(a),e}return r};ao.removeMarkdown=Ak});function so(e,t,r){t==="__proto__"?Object.defineProperty(e,t,{value:r,enumerable:!0,writable:!0,configurable:!0}):e[t]=r}function Ps(e){return e===" "||e===" "||e===`
8
+ `||e==="\r"}function ld(e){let t=e[0],r,a;if(t==='"'||t==="'"){let n=1;for(;;){if(n>=e.length)return null;let l=e[n];if(t==='"'&&l==="\\")n+=2;else if(l===t){if(t==='"'||e[n+1]!=="'")break;n+=2}else n++}for(r=n+1,a=r;Ps(e[a]);)a++;if(e[a]!==":")return null}else{if(t===void 0||pM.test(t)||t==="-"&&(e.length<2||Ps(e[1])||e[1]===":"||e[1]==="#"))return null;for(a=1;a<e.length&&e[a]!==":"&&e[a]!=="#";)a++;if(e[a]!==":")return null;for(r=a;Ps(e[r-1]);)r--}let i=a+1;if(i<e.length&&!Ps(e[i]))return null;for(;Ps(e[i]);)i++;return{key:e.slice(0,r),length:i}}function cd(e){let t=e.trim();if(t===""||t==="~"||t==="null"||t==="Null"||t==="NULL")return null;if(t==="true"||t==="True"||t==="TRUE")return!0;if(t==="false"||t==="False"||t==="FALSE")return!1;let r=t[0];if(r!=="-"&&r!=="+"&&r!=="."&&(r<"0"||r>"9"))return t;if(oM.test(t)||fM.test(t))return Number(t);if(cM.test(t)||hM.test(t)||dM.test(t)){let a=t[0]==="-",i=Number(a||t[0]==="+"?t.slice(1):t);return a?-i:i}return/^[-+]?\.(?:inf|Inf|INF)$/.test(t)?t[0]==="-"?-1/0:1/0:/^\.(?:nan|NaN|NAN)$/.test(t)?NaN:t}function zs(e){if(!e.includes(`
9
+ `))return e;let t=e.split(`
10
+ `),r=t.length-1;for(let a=0;a<=r;a++){let i=t[a],n=0,l=i.length;if(a>0)for(;n<l&&(i.charCodeAt(n)===32||i.charCodeAt(n)===9);)n++;if(a<r)for(;l>n&&(i.charCodeAt(l-1)===32||i.charCodeAt(l-1)===9);)l--;t[a]=i.slice(n,l)}return t.join(`
11
+ `).replace(/\n+/g,a=>a.length===1?" ":`
12
+ `.repeat(a.length-1))}function uM(e){if(!e.includes("\\"))return zs(e);let t="",r=zs(e.replace(/\\\n[ \t]*/g,""));for(let a=0;a<r.length;a++){let i=r[a];if(i!=="\\"){t+=i;continue}let n=r[++a];if(n==="x"||n==="u"||n==="U"){let l=n==="x"?2:n==="u"?4:8;t+=String.fromCodePoint(parseInt(r.slice(a+1,a+1+l),16)),a+=l}else if(n in i0)t+=i0[n];else throw new Error("YAML: unknown escape sequence")}return t}function Xi(e,t,r){for(;t<e.length;){let a=e[t];if(a===" "||a===`
13
+ `||a===" "||a==="\r"||r&&a===",")t++;else if(a==="#"&&(t===0||/\s/.test(e[t-1]))){let i=e.indexOf(`
14
+ `,t);t=i===-1?e.length:i}else break}return t}function n0(e,t){if(!t)throw new Error("YAML: missed comma between flow collection entries");if(e===",")throw new Error("YAML: expected the node content, but found ','")}function Ln(e,t,r,a=0){if(a>s0)throw new Error("YAML: nesting is too deep");t=Xi(e,t,!1);let i=e[t];if(i==="{"){let l={};t++;let s=!0;for(;;){if(t=Xi(e,t,!1),t>=e.length)throw new Rn("YAML: unexpected end of the stream within a flow collection");if(e[t]==="}")return[l,t+1];n0(e[t],s);let o;[o,t]=Ln(e,t,":,}",a+1),t=Xi(e,t,!1);let c=null;e[t]===":"&&([c,t]=Ln(e,t+1,",}",a+1)),so(l,String(o),c),t=Xi(e,t,!1),s=e[t]===",",s&&t++}}if(i==="["){let l=[];t++;let s=!0;for(;;){if(t=Xi(e,t,!1),t>=e.length)throw new Rn("YAML: unexpected end of the stream within a flow collection");if(e[t]==="]")return[l,t+1];n0(e[t],s);let o;[o,t]=Ln(e,t,",]",a+1),l.push(o),t=Xi(e,t,!1),s=e[t]===",",s&&t++}}if(i==='"'){let l=t+1;for(;l<e.length&&e[l]!=='"';)l+=e[l]==="\\"?2:1;if(l>=e.length)throw new Rn("YAML: unexpected end of the stream within a double quoted scalar");return[uM(e.slice(t+1,l)),l+1]}if(i==="'"){let l=t+1;for(;l<e.length;){if(e[l]==="'"){if(e[l+1]!=="'")break;l++}l++}if(l>=e.length)throw new Rn("YAML: unexpected end of the stream within a single quoted scalar");return[zs(e.slice(t+1,l)).replace(/''/g,"'"),l+1]}let n=t;for(;n<e.length;){let l=e[n];if(r.includes(l)&&(l!==":"||n+1>=e.length||/[\s,[\]{}]/.test(e[n+1])))break;if(l==="#"&&n>t&&/\s/.test(e[n-1])){let s=e.indexOf(`
15
+ `,n);return[cd(zs(e.slice(t,n).trim())),s===-1?e.length:s]}n++}return[cd(zs(e.slice(t,n).trim())),n]}function Fs(e){let t="";for(let r=0;r<e.length;r++){let a=e[r];if(t)a==="\\"&&t==='"'?r++:a===t&&(t="");else if(a==='"'||a==="'")t=a;else if(a==="#"&&(r===0||e[r-1]===" "||e[r-1]===" "))return e.slice(0,r)}return e}function gM(e,t,r){let a=t[0]===">",i=t.includes("-")?"-":t.includes("+")?"+":"",n=/[1-9]/.exec(t),l=n?r+Number(n[0]):-1,s=[];for(;e.i<e.lines.length;){let f=e.lines[e.i];if(f.trim()===""){s.push(""),e.i++;continue}let p=f.length-f.trimStart().length;if(l===-1){if(p<=r)break;l=p}if(p<l)break;s.push(f.slice(l)),e.i++}let o=0;for(;s.length>0&&s[s.length-1]==="";)s.pop(),o++;let c;if(a){c="";for(let f=0;f<s.length;f++){let p=s[f];if(f>0){let h=s[f-1];p===""?c+=`
16
+ `:h!==""&&(c+=/^[ \t]/.test(h)||/^[ \t]/.test(p)?`
17
+ `:" ")}c+=p}}else c=s.join(`
18
+ `);return s.length===0?i==="+"?`
19
+ `.repeat(o):"":i==="-"?c:i==="+"?c+`
20
+ `.repeat(o+1):c+`
21
+ `}function od(e,t,r){let a=t[0];if((a==="|"||a===">")&&/^[|>][-+0-9]*\s*(?:#.*)?$/.test(t))return gM(e,t,r);if(a==="{"||a==="["||a==='"'||a==="'"){let n=e.i,l=t,s=0,o=1;for(;;)try{let[c,f]=Ln(l,0,""),p=0;for(let g=l.indexOf(`
22
+ `);g!==-1&&g<f;g=l.indexOf(`
23
+ `,g+1))p++;let h=l.indexOf(`
24
+ `,f);if(Fs(l.slice(f,h===-1?l.length:h)).trim()!=="")throw new Error("YAML: unexpected content after a value");return e.i=n+p,c}catch(c){if(!(c instanceof Rn))throw c;if(n+s>=e.lines.length)throw new Error(c.message);let f=e.lines.slice(n+s,n+s+o);l+=`
25
+ `+f.join(`
26
+ `),s+=f.length,o*=2}}let i=Fs(t).trim();for(;e.i<e.lines.length;){let n=e.lines[e.i];if(n.trim()===""){let s=e.i;for(;s<e.lines.length&&e.lines[s].trim()==="";)s++;if(s>=e.lines.length||e.lines[s].length-e.lines[s].trimStart().length<=r)break;i+=`
27
+ `.repeat(s-e.i),e.i=s;continue}if(n.length-n.trimStart().length<=r)break;let l=Fs(n).trim();i+=(i.endsWith(`
28
+ `)?"":" ")+l,e.i++}return cd(i)}function lo(e,t,r=0){if(r>s0)throw new Error("YAML: nesting is too deep");if(e.skipBlank(),e.i>=e.lines.length)return null;let a=e.indent();if(a<t)return null;let i=e.lines[e.i].slice(a);if(i==="-"||i.startsWith("- ")){let l=[];for(;e.i<e.lines.length&&(e.skipBlank(),!(e.i>=e.lines.length||e.indent()!==a));){let s=e.lines[e.i].slice(a);if(s!=="-"&&!s.startsWith("- "))break;let o=s.slice(1),c=o.length-o.trimStart().length+1,f=Fs(o).trim();f===""?(e.i++,l.push(lo(e,a+1,r+1))):ld(f)!==null?(e.lines[e.i]=" ".repeat(a+c)+o.trimStart(),l.push(lo(e,a+c,r+1))):(e.i++,l.push(od(e,o.trim(),a)))}return l}if(ld(i)===null)return e.i++,od(e,i.trim(),a-1);let n={};for(;e.i<e.lines.length&&(e.skipBlank(),!(e.i>=e.lines.length));){let l=e.indent();if(l<a)break;if(l>a)throw new Error("YAML: bad indentation of a mapping entry");let s=e.lines[e.i].slice(a),o=ld(s);if(!o)throw new Error("YAML: can not read a block mapping entry");let c=String(Ln(o.key,0,"")[0]),f=s.slice(o.length);if(e.i++,Fs(f).trim()==="")if(e.skipBlank(),e.i<e.lines.length){let p=e.indent(),h=e.lines[e.i].slice(p),g=h==="-"||h.startsWith("- ");so(n,c,p>a||g&&p===a?lo(e,g?a:a+1,r+1):null)}else so(n,c,null);else so(n,c,od(e,f.trim(),a))}return n}function Ma(e){let t=e.trim();if(t[0]==="{"||t[0]==="[")try{let[i,n]=Ln(t,0,"");if(Xi(t,n,!1)===t.length)return i}catch(i){throw i instanceof Rn?new Error(i.message):i}let r=new lM(e),a=lo(r,0);if(r.skipBlank(),r.i<r.lines.length&&r.lines[r.i].trim()!=="...")throw new Error("YAML: end of the stream or a document separator is expected");return a}var Rn,s0,lM,oM,cM,hM,dM,fM,pM,i0,Dn=Xe(()=>{Rn=class{constructor(e){he(this,"message");this.message=e}},s0=64;lM=class{constructor(e){he(this,"lines");he(this,"i",0);this.lines=(e.includes("\r")?e.replace(/\r\n?/g,`
29
+ `):e).split(`
30
+ `)}skipBlank(){for(;this.i<this.lines.length;){let e=this.lines[this.i].trim();if(e!==""&&e[0]!=="#"&&e!=="---")break;this.i++}}indent(){let e=this.lines[this.i],t=0;for(;t<e.length&&e[t]===" ";)t++;if(e[t]===" ")throw new Error("YAML: tabs are not allowed for indentation");return t}},oM=/^[-+]?(?:0|[1-9][0-9]*)$/,cM=/^[-+]?0x[0-9a-fA-F]+$/,hM=/^[-+]?0o[0-7]+$/,dM=/^[-+]?0b[01]+$/,fM=/^[-+]?(?:[0-9][0-9]*(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][-+]?[0-9]+)?$/,pM=/[\s#:,[\]{}&*!|>'"%@`]/;i0={0:"\0",a:"\x07",b:"\b",t:" ",n:`
31
+ `,v:"\v",f:"\f",r:"\r",e:"\x1B"," ":" ",'"':'"',"/":"/","\\":"\\",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"}});function Ue(e){return e<128?e===32||e>=9&&e<=13:e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288||e===65279}function pa(e){return e===32||e===9}function Vi(e){return e===10||e===13||e===8232||e===8233}function pt(e){return e>=48&&e<=57}function si(e){return e>=65&&e<=90||e>=97&&e<=122}function oo(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function Qe(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95}var tr=Xe(()=>{});function Ys(e,t){let r=1,a=0;for(let s=e.indexOf(`
32
+ `);s!==-1&&s<t;s=e.indexOf(`
33
+ `,s+1))r++,a=s+1;let i=e.indexOf(`
34
+ `,t);i===-1&&(i=e.length);let n=t-a+1,l=e.slice(a,i);return{line:r,column:n,snippet:l+`
35
+ `+"-".repeat(n-1)+"^"}}function it(e,t,r,a,i=!1){let n=Ys(t,r),l=i?`Lexical error on line ${n.line}. Unrecognized text.`:`Parse error on line ${n.line}:`,s=i?`${l}
36
+ ${n.snippet}`:`${l}
37
+ ${n.snippet}
38
+ ${a}`;return new je(s,"syntax",{type:e,...n})}function yM(e){if(!co){co=new Map;for(let t of mM.split(",")){let r=t.indexOf(":");co.set(t.slice(0,r),String.fromCodePoint(Number(t.slice(r+1))))}}return co.get(e)}function l0(e,t){return e>0&&e<=1114111&&(e<55296||e>57343)?String.fromCodePoint(e):t}function bM(e){let t="",r=0,a=e.indexOf(o0);for(;a!==-1;){let i=e.indexOf("\xB6",a+2);if(i===-1)break;if(e[i+1]==="\xDF"){let n=e[a+2]==="\xB0";t+=e.slice(r,a)+(n?"&#":"&")+e.slice(a+(n?3:2),i)+";",r=i+2}a=e.indexOf(o0,i+1)}return r===0?e:t+e.slice(r)}function At(e){return e.includes(wM)&&(e=bM(e)),e.includes("&")&&(e=e.replace(xM,(t,r,a,i)=>r?l0(Number(r),t):a?l0(parseInt(a,16),t):yM(i)??t)),e}function p0(e,t){let r=Ws,a=Bs;Ws=e,Bs=new Map;try{return t()}finally{Ws=r,Bs=a}}function Pn(e){if(Ws===void 0)return"";let t=Bs.get(e);return t===void 0&&(t=Ws(e)??"",Bs.set(e,t)),t}function u0(e,t){let r=Ba,a=On;Ba=e,On=new Map;try{return t()}finally{Ba=r,On=a}}function g0(){return Ba!==void 0}function c0(e){return Number.isFinite(e)&&e>0}function m0(e,t){if(Ba===void 0)return;let r=t+`
39
+ `+e;if(On.has(r))return On.get(r);let a=Ba(e,t)??void 0,i=a&&c0(a.width)&&c0(a.height)&&typeof("svg"in a?a.svg:a.html)=="string"?a:void 0;return On.set(r,i),i}function y0(e){if(Ba===void 0)return e();let t=Ba;Ba=void 0;try{return e()}finally{Ba=t}}function h0(e){let t=new Uint16Array(95);for(let r=0;r<95;r++)t[r]=parseInt(e.substr(r*2,2),36);return t}function vM(e){return e>=4352&&e<=4447||e>=11904&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65280&&e<=65376||e>=65504&&e<=65510||e>=55296&&e<=56319}function EM(e){return e>=768&&e<=879||e>=8203&&e<=8207||e>=56320&&e<=57343||e>=65024&&e<=65039||e===65279}function TM(){let e=globalThis;try{if(e.OffscreenCanvas)return new e.OffscreenCanvas(1,1).getContext("2d");if(e.document)return e.document.createElement("canvas").getContext("2d")}catch{return null}return null}function d0(){let e=globalThis;return e.document?.fonts??e.fonts}function _M(e,t,r){try{return e?.check(t,r)??!0}catch{return!0}}function IM(e,t="monospace"){let r=TM();if(!r)return null;let a=new Map,i="",n=d0()?.size;return{width(l,s,o){let c=d0();c?.size!==n&&(n=c?.size,a.clear());let f=(o&2?"italic ":"")+(o&1?"bold ":"")+s+"px "+(o&4?t:e),p=a.get(f);p||a.set(f,p=new Map);let h=p.get(l);return h===void 0&&(f!==i&&(r.font=i=f),h=r.measureText(l).width,_M(c,f,l)&&(p.size>=CM&&p.clear(),p.set(l,h))),h}}}function et(e="sans-serif",t="monospace"){let r=e+`
40
+ `+t,a=f0.get(r);return a||(a=IM(e,t)??SM,f0.set(r,a)),a}var je,mM,co,xM,o0,wM,Ws,Bs,Ba,On,$M,kM,MM,AM,SM,CM,f0,wt=Xe(()=>{je=class extends Error{constructor(t,r="syntax",a={}){super(t);he(this,"code");he(this,"type");he(this,"mermaidType");he(this,"line");he(this,"column");he(this,"snippet");this.name="PeleError",this.code=r,this.type=a.type??null,this.mermaidType=a.mermaidType??null,this.line=a.line??0,this.column=a.column??0,this.snippet=a.snippet??""}};mM="amp:38,lt:60,gt:62,quot:34,apos:39,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,sect:167,copy:169,laquo:171,not:172,reg:174,deg:176,plusmn:177,sup2:178,sup3:179,micro:181,para:182,middot:183,sup1:185,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,euro:8364,trade:8482,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,radic:8730,infin:8734,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830,check:10003,cross:10007,AMP:38,LT:60,GT:62,QUOT:34,lsqb:91,rsqb:93,lcub:123,rcub:125,verbar:124,VerticalLine:124,midast:42,DiacriticalGrave:96,Hat:94,UnderBar:95,equals:61,colon:58,semi:59,num:35,percnt:37,lpar:40,rpar:41,lbrack:91,rbrack:93,lbrace:123,rbrace:125,vert:124,sol:47,bsol:92,quest:63,excl:33,ast:42,plus:43,comma:44,period:46,dollar:36,commat:64,grave:96,hat:94,lowbar:95,tilde:126,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969";xM=/&(?:#(\d+)|#[xX]([0-9a-fA-F]+)|(\w+));/g,o0="\uFB02\xB0",wM="\xB6\xDF";Bs=new Map;On=new Map;$M="7q7q9vfgfgopij5b9999atg87q997q7qfgfgfgfgfgfgfgfgfgfg7q7qg8g8g8fgs7ijijk2k2ijgzlmk27qdwijfgn5k2lmijlmk2ijgzk2ijq8ijijgz7q7q7qd1fg99fgfgdwfgfg7qfgfg6666dw66n5fgfgfgfg99dw7qfgdwk2dwdwdw9a789ag8",kM="7q99d6fgfgopk26m9999atg87q997q7qfgfgfgfgfgfgfgfgfgfg9999g8g8g8gzr3k2k2k2k2ijgzlmk27qfgk2gzn5k2lmijlmk2ijgzk2ijq8ijijgz997q99g8fg99fggzfggzfg99gzgz7q7qfg7qopgzgzgzgzatfg99gzfglmfgfgdwat7satg8";SM={width(e,t,r){let a=(r&4)!==0,i=r&1?AM??(AM=h0(kM)):MM??(MM=h0($M)),n=0;for(let l=0;l<e.length;l++){let s=e.charCodeAt(l);if(!(s<32))if(s<127)n+=a?600:i[s-32];else{if(EM(s))continue;vM(s)?n+=a?1200:1e3:n+=a?600:580}}return n*t/1e3}};CM=2e4;f0=new Map});function uo(e){return po.has(e)}function go(e){return e===void 0?"rect":KM.get(e)??po.get(e)??"rect"}var XM,VM,KM,po,gd=Xe(()=>{XM=[["rect","proc","process","rectangle","squareRect"],["rounded","event","roundedRect"],["stadium","terminal","pill"],["fr-rect","subprocess","subproc","framed-rectangle","subroutine"],["cyl","db","database","cylinder"],["datastore","data-store"],["folder","directory"],["bucket"],["console"],["browser"],["person"],["circle","circ"],["bang"],["cloud"],["diam","decision","diamond","question"],["hex","hexagon","prepare"],["lean-r","lean-right","in-out","lean_right"],["lean-l","lean-left","out-in","lean_left"],["trap-b","priority","trapezoid-bottom","trapezoid"],["trap-t","manual","trapezoid-top","inv-trapezoid","inv_trapezoid"],["dbl-circ","double-circle","doublecircle"],["text"],["notch-rect","card","notched-rectangle"],["lin-rect","lined-rectangle","lined-process","lin-proc","shaded-process"],["sm-circ","start","small-circle","stateStart"],["fr-circ","stop","framed-circle","stateEnd"],["fork","join","forkJoin"],["hourglass","collate"],["brace","comment","brace-l"],["brace-r"],["braces"],["bolt","com-link","lightning-bolt"],["doc","document"],["delay","half-rounded-rectangle"],["h-cyl","das","horizontal-cylinder"],["lin-cyl","disk","lined-cylinder"],["curv-trap","curved-trapezoid","display"],["div-rect","div-proc","divided-rectangle","divided-process"],["tri","extract","triangle"],["win-pane","internal-storage","window-pane"],["f-circ","junction","filled-circle"],["notch-pent","loop-limit","notched-pentagon"],["flip-tri","manual-file","flipped-triangle"],["sl-rect","manual-input","sloped-rectangle"],["docs","documents","st-doc","stacked-document"],["st-rect","procs","processes","stacked-rectangle"],["bow-rect","stored-data","bow-tie-rectangle"],["cross-circ","summary","crossed-circle"],["tag-doc","tagged-document"],["tag-rect","tagged-rectangle","tag-proc","tagged-process"],["flag","paper-tape"],["odd","rect_left_inv_arrow"],["lin-doc","lined-document"]],VM=["state","choice","note","composite","rectWithTitle","labelRect","block_arrow","collapsedGroup","iconSquare","iconCircle","icon","iconRounded","imageSquare","anchor","kanbanItem","mindmapCircle","defaultMindmapNode","classBox","erBox","requirementBox","usecaseActor","usecaseActorHollow","usecaseActorAwesome","usecaseActorIcon","usecaseBusiness","usecaseEllipse","usecaseJsonTable"],KM=new Map([["square","rect"],["round","rounded"],["ellipse","ellipse"],["hexagon","hex"],["diamond","diam"]]),po=new Map;for(let e of XM)for(let t of e)po.set(t,e[0]);for(let e of VM)po.set(e,e)});function JM(){let e=ZM.split(" "),t=new Uint16Array(e.length),r=0;for(let a=0;a<e.length;a+=2){let i=r+parseInt(e[a],36);r=i+parseInt(e[a+1],36),t[a]=i,t[a+1]=r}return t}function Fn(e){if(e<170||e>65500)return!1;let t=QM??(QM=JM()),r=0,a=(t.length>>1)-1;for(;r<=a;){let i=r+a>>1;if(e<t[i*2])a=i-1;else if(e>t[i*2+1])r=i+1;else return!0}return!1}var ZM,QM,mo=Xe(()=>{ZM="4q 0 b 0 5 0 6 m 2 u 2 cp 5 b f 4 8 0 2 0 3m 4 2 1 3 3 9 0 2 2 2 0 2 j 2 2a 2 3u 9 4d a 11 3 0 8 12 21 q 6 2 1a 16 10 1 2 2q 2 0 g 1 8 1 b 2 3 0 h 0 2 t u 2g c 0 p w a 1 5 0 6 l 5 0 a 0 4 0 o o 20 0 2 a 2g 1h 4 0 j 0 8 9 g 6 2 6 6 7 3 1 3 l 2 6 2 0 4 3 4 0 h 0 e 1 2 2 f 1 k 5 5 1 3 l 2 6 2 1 2 1 2 1 w 3 2 0 k 2 h 8 2 2 2 l 2 6 2 1 2 4 4 0 j 0 g 1 10 7 3 1 3 l 2 6 2 1 2 4 4 0 v 1 2 2 g 0 i 0 2 5 4 2 2 3 4 1 2 0 2 1 4 1 4 2 4 b n 0 1h 7 2 2 2 m 2 9 2 4 4 0 r 1 7 1 10 7 2 2 2 m 2 9 2 4 4 0 x 0 2 1 g 1 j 7 2 2 2 14 3 0 h 0 i 1 p 5 6 h 4 n 2 8 2 0 3 6 1n 1b 2 1 d 6 1n 1 2 0 3 1 2 0 3 0 7 3 2 6 2 2 2 0 2 0 3 1 2 3 2 1 a 0 3 4 2 0 m 3 x 0 1s 7 2 z s 4 38 16 l 0 h 5 5 3 4 0 4 1 8 2 5 c d 0 i 11 2 0 6 0 3 16 2 98 2 3 3 6 2 0 2 3 3 14 2 3 3 w 2 3 3 6 2 0 2 3 3 e 2 1k 2 3 3 1u 12 f h 2c d h7 3 g 2 p 6 22 m c 2 3 f h f h f c 2 2 g 1f 10 0 5 0 1w 2f 9 14 2 0 6 1x b s 1g t 3 4 c 17 m 6 1l m a 1g 2b 0 2m 1a i 6 1k t e 1 b 17 r z 16 2 b z 30 3 2 3 4 1 a 5b 1t 7p 3 5 3 11 3 5 3 7 2 0 2 0 2 0 2 u 3 1g 2 6 2 0 4 2 2 6 4 3 3 5 5 c 6 2 2 6 39 0 e 0 h c 2u 0 5 0 3 9 2 0 4 4 7 0 2 0 2 0 2 3 2 a 3 3 6 4 5 0 1h 1 22k 1a 2 1a 2 3o 7 3 4 1 d 11 2 0 6 0 3 1j 8 0 h m a 6 2 6 2 6 2 6 2 6 2 6 2 6 2 6 29 0 d2 1 17 4 6 1 5 2d 7 2 2 2h 2 3 6 14 4 2l i q 1i f e9 52t 23 g5o 1g wc 1w 19 3 7g 4 f b 1 l 1a h o 9 1x 1e 8 3 2u 3 3 2 3 d a 26 9 2 2 2 3 2 m u 1f f 1d 1r 5 4 0 f r b m q s 8 1a t 0 1d 14 o 2 2 7 l m 4 0 6 1b 2 0 4 1 3 4 3 0 2 0 p 2 3 a 8 2 d 5 3 5 3 5 a 6 2 6 42 y u 8mb d m 5 1c 6it a5 3 2x 13 6 d 4 6 0 2 9 2 c 2 4 2 0 2 1 2 1 2 2z y a2 j 1r 3 1h 15 b 39 4 2 3q 11 p 7 p c 2g 4 5 3 5 3 5 3 2"});function Ve(e){return eA.test(e)?e.replace(tA,t=>rA[t]??""):e}function Oe(e){return Ve(At(e))}function d(e){let t=Math.round(e*100);if(t===0)return"0";if(t>0){if(t<1e11){let r=Math.floor(t/100);return r+xd[t-r*100]}}else if(t>-1e11){let r=-t,a=Math.floor(r/100);return"-"+a+xd[r-a*100]}return String(t/100)}function Re(e,t,r,a,i){let n=e.lines;if(n.length===0)return"";let l=e.lineHeight,s=e.heights,o=e.size*.35,c=r-e.height/2,f=n.length===1&&n[0].length===1?n[0][0]:void 0;if(f&&f.icon===void 0&&f.math===void 0&&f.style===0)return`<text${a} x="${d(t)}" y="${d(c+l/2+o)}" text-anchor="middle">${Ve(f.text)}</text>`;let p=li(e),h=a,g;a=Aa(a,p);let u="",m="";for(let b=0;b<n.length;b++){let w=n[b],v=s?s[b]:l,k=c+v/2,O=k+o,R=!1;for(let L of w)(L.icon!==void 0||L.math)&&(R=!0);if(R){let L=t-e.widths[b]/2;for(let P of w){if(P.math){let B=`x="${d(L)}" y="${d(k-P.math.height/2)}" width="${d(P.math.width)}" height="${d(P.math.height)}"`;g??(g=oA(h)),m+=g.halo===void 0?cA(P.math,B,e.size,g.attrs):`<rect ${B} rx="2" fill="${g.halo}"/>`}else if(P.icon!==void 0){let B=e.size*1.1,G=i?.(P.icon)??"";m+=`<svg class="pele-icon" data-icon="${Oe(P.icon)}" x="${d(L)}" y="${d(k-B/2)}" width="${d(B)}" height="${d(B)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${G}</svg>`}else P.text!==""&&(u+=`<tspan x="${d(L)}" y="${d(O)}" text-anchor="start"${Ya(P.style&~p)}>${Ve(P.text)}</tspan>`);L+=P.width}}else{for(let L=0;L<w.length;L++){let P=w[L],B=L===0?` x="${d(t)}" y="${d(O)}"`:"";u+=`<tspan${B}${Ya(P.style&~p)}>${Ve(P.text)}</tspan>`}w.length===0&&(u+=`<tspan x="${d(t)}" y="${d(O)}"> </tspan>`)}c+=v}return`<text${a} text-anchor="middle" xml:space="preserve">${u}</text>${m}`}function oA(e){let t=nA.exec(e)?.[1]??"",r=(sA.exec(t)?.[1]??aA.exec(e)?.[1]??"").trim();if(r==="none")return{attrs:"",halo:iA.exec(e)?.[1]??"none"};let a=lA.exec(t)?.[1].trim();return{attrs:(r===""?"":` color="${r}"`)+(a?` opacity="${a}"`:"")}}function cA(e,t,r,a){return"svg"in e?`<svg class="pele-math" ${t} overflow="visible"${a}>${e.svg}</svg>`:`<foreignObject class="pele-math" ${t} overflow="visible"${a}><div xmlns="http://www.w3.org/1999/xhtml" style="display:flex;align-items:center;justify-content:center;width:100%;height:100%;font-size:${d(r)}px;line-height:normal;white-space:nowrap">${e.html}</div></foreignObject>`}function Ya(e){return(e&1?L0:"")+(e&2?D0:"")}function li(e){let t=3,r=!1;for(let a of e.lines)for(let i of a)i.icon!==void 0||i.text===""||(t&=i.style,r=!0);return r?t:0}function Aa(e,t){return e+(t&1&&!e.includes(' font-weight="')?L0:"")+(t&2&&!e.includes(' font-style="')?D0:"")}function bA(e){let t=e.split(`
41
+ `),r=1/0;for(let a of t){if(a.trim()==="")continue;let i=a.length-a.trimStart().length;i<r&&(r=i)}return r===1/0||r===0?e:t.map(a=>a.slice(Math.min(r,a.length-a.trimStart().length))).join(`
42
+ `)}function yo(e){return e!==void 0&&e.icon===void 0&&e.math===void 0}function md(e,t,r){if(t!==""){if(Hs!==void 0&&P0.test(t)){let a=Hs,i=t.split(xA);for(let n=0;n<i.length;n++){if(n%2===0){i[n]!==""&&yd(e,i[n],r);continue}let l=i[n].charCodeAt(0)-O0,s=a.math[l];s?e.push({text:"",style:r,math:s,width:s.width}):yd(e,`$$${a.tex[l]}$$`,r)}return}yd(e,t,r)}}function yd(e,t,r){let a=At(t),i=e[e.length-1];yo(i)&&i.style===r?i.text+=a:e.push({text:a,style:r,width:0})}function $A(e,t,r){if(!t.includes(":fa-")){md(e,t,r);return}let a=0;T0.lastIndex=0;let i;for(;(i=T0.exec(t))!==null;){let n=`${i[1]}:fa-${i[2]}`;if(md(e,t.slice(a,i.index),r),a=i.index+i[0].length,Pn(n)!=="")e.push({text:"",style:r,icon:n,width:0});else if(t[a]===" ")a++;else if(a===t.length){let l=e[e.length-1];yo(l)&&(l.text=l.text.trimEnd())}}md(e,t.slice(a),r)}function kA(e,t,r,a,i){let n=i,l=0,s="",o=0,c=t.length,f=()=>{$A(e,s,n),s=""};for(;o<c;){let p=t[o];if(p==="<"){S0.lastIndex=o;let h=S0.exec(t);if(h&&h.index===o){let g=h[1].toLowerCase(),u=t[o+1]==="/",m=g==="b"||g==="strong"?1:g==="i"||g==="em"?2:0;m&&(f(),i=u?i&~m|a&m:i|m,n=u?n&~m|a&m:n|m),o+=h[0].length;continue}}else if(r&&(p==="*"||p==="_")){let h=t[o+1]===p,g=h?1:2,u=h?2:1,m=(l&g)===0,b=o>0?t[o-1]:" ",w=o+u<c?t[o+u]:" ",v=m&&w.trim()!==""&&t.indexOf(h?p+p:p,o+u)!==-1,k=!m&&b.trim()!=="",O=p==="_"&&/\w/.test(b)&&/\w/.test(w);if((v||k)&&!O){f(),l=v?l|g:l&~g,n=v?n|g:n&~g|a&g,o+=u;continue}}s+=p,o++}return f(),i}function MA(e,t,r){let a=0;for(let i of e)i.width=i.icon!==void 0?r*1.25:i.math?i.math.width:t.width(i.text,r,i.style),a+=i.width;return a}function z0(e,t,r,a,i,n){let l=[],s=0,o=()=>{let c=l[l.length-1];if(yo(c)){let f=c.text.trimEnd();if(f!==c.text){c.text=f;let p=t.width(f,r,c.style);s+=p-c.width,c.width=p}}i.push(l),n.push(s),l=[],s=0};for(let c of e){if(c.icon!==void 0||c.math){let f=c.math?c.math.width:r*1.25;s>0&&s+f>a&&o(),l.push({...c,width:f}),s+=f;continue}for(let f of c.text.match(gA)??[]){let p=f;s>0&&s+t.width(p.trimEnd(),r,c.style)>a&&(o(),p=p.trimStart());let h=l[l.length-1];if(yo(h)&&h.style===c.style){h.text+=p,h.width=t.width(h.text,r,h.style),s=0;for(let g of l)s+=g.width}else{let g=t.width(p,r,c.style);l.push({text:p,style:c.style,width:g}),s+=g}}}(l.length>0||i.length===0)&&o()}function ze(e,t,r,a,i,n=0){if(e===void 0||e==="")return wA;let l=Math.round(a*hA);if(g0()&&e.includes("$$")&&!P0.test(e)){let s={tex:[],math:[]},o=e.replace(yA,(c,f)=>s.tex.length===mA?c:(s.tex.push(f),String.fromCharCode(O0+s.tex.length-1)));if(s.tex.length>0){for(let c of s.tex)s.math.push(m0(At(c),a));return _0(o,t,r,a,i,n,l,s)}}if(!fA.test(e)&&!e.includes("&")&&!e.includes("\uFB02")){let s=e.trim(),o=r.width(s,a,n);if(o<=i||!(s.includes(" ")||uA.test(s)))return{lines:[[{text:s,style:n,width:o}]],widths:[o],width:o,height:l,size:a,lineHeight:l};let c=[],f=[];z0([{text:s,style:n,width:o}],r,a,i,c,f);let p=0;for(let h of f)h>p&&(p=h);return{lines:c,widths:f,width:p,height:c.length*l,size:a,lineHeight:l}}return _0(e,t,r,a,i,n,l)}function _0(e,t,r,a,i,n,l,s){let o=Hs;Hs=s;try{let c=AA(e,t,r,a,i,n,l);return s?Us(c):c}finally{Hs=o}}function AA(e,t,r,a,i,n,l){let s=t?bA(e.replace(/\r\n?/g,`
43
+ `)).trim():e.trim(),o=[],c=[],f=0,p=n;for(let h of s.split(dA)){let g=[];p=kA(g,h.trim(),t,n,p);let u=MA(g,r,a);u>i?z0(g,r,a,i,o,c):(o.push(g),c.push(u))}for(let h of c)h>f&&(f=h);return{lines:o,widths:c,width:f,height:o.length*l,size:a,lineHeight:l}}function Us(e){let t;for(let a=0;a<e.lines.length;a++){let i=e.lineHeight;for(let n of e.lines[a])n.math&&(i=Math.max(i,Math.ceil(n.math.height+e.size/4)));i!==e.lineHeight&&t===void 0&&(t=e.lines.map(()=>e.lineHeight)),t&&(t[a]=i)}if(t===void 0)return e.heights===void 0?e:{...e,heights:void 0,height:e.lines.length*e.lineHeight};let r=0;for(let a of t)r+=a;return{...e,heights:t,height:r}}function Wn(e){for(let t of e)if(t.math)return!0;return!1}function Ha(e,t){let r=e.heights;if(!r)return(t+.5)*e.lineHeight;let a=0;for(let i=0;i<t;i++)a+=r[i];return a+r[t]/2}function Ua(e,t){let r=e.widths[t],a=e.heights?e.heights[t]:e.lineHeight,i={lines:[e.lines[t]],widths:[r],width:r,height:a,size:e.size,lineHeight:e.lineHeight};return a!==e.lineHeight&&(i.heights=[a]),i}function ft(e){let t=e.indexOf(' style="');return t<0?e+nt:`${e.slice(0,t+8)}rx:var(--_r);${e.slice(t+8)}`}function N0(e,t){return e&&SA.test(e)?e:t}function TA(e,t,r){return`;--_fm:var(--pele-font-mono,${N0(r,"monospace")});font:${e}px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,${N0(t,"sans-serif")})`}function vt(e){if(e.length===0)return R0;let t=new Map,r=new Map;for(let c of e){let f=c.indexOf(":");if(f<=0)continue;let p=c.slice(0,f).trim().toLowerCase(),h=c.slice(f+1).replace(/!important/gi,"").trim();h===""||IA.test(h)||(CA.has(p)&&t.set(p,h),_A.has(p)&&r.set(p==="color"?"fill":p,h))}if(t.size===0&&r.size===0)return R0;let a="",i="";for(let[c,f]of t)a+=`${c}:${f};`,c!=="fill"&&c!=="fill-opacity"&&(i+=`${c}:${f};`);let n="";for(let[c,f]of r)n+=`${c}:${f};`;let l=r.get("font-weight"),s=r.get("font-size"),o=s&&/^[\d.]+(px)?$/.test(s)?parseFloat(s):void 0;return{shape:a?` style="${Ve(a)}"`:"",line:i?` style="${Ve(i)}"`:"",text:n?` style="${Ve(n)}"`:"",stroke:t.get("stroke"),bold:l==="bold"||l==="bolder"||Number(l)>=600,italic:r.get("font-style")==="italic",fontSize:o!==void 0&&o>0&&o<=200?o:void 0}}function It(e){let t=e.replace(NA," ").trim();return t===""?"":" "+t}function dt(e){let t=(e%8+8)%8;return`var(--pele-series-${t+1},${RA[t]})`}function Je(e,t,r,a,i,n,l){let s=Ve(i.idPrefix??"pele"),o="",c="";n.accTitle&&(o+=`<title id="${s}-title">${Oe(n.accTitle)}</title>`,c+=` aria-labelledby="${s}-title"`),n.accDescr&&(o+=`<desc id="${s}-desc">${Oe(n.accDescr)}</desc>`,c+=` aria-describedby="${s}-desc"`);let f=i.responsive===!1?"":"max-width:100%;height:auto;",p=new Set;for(let[,g]of l.matchAll(DA))if(p.add(g),p.size===4)break;let h=p.has("r")?`;--_r:${EA}`:"";for(let[g,u]of LA)p.has(g)&&(h+=`;--_${g}:var(--pele-${u}-weight,bold)`);return`<svg xmlns="http://www.w3.org/2000/svg" class="pele pele-${e}" viewBox="0 0 ${t} ${r}" width="${t}" height="${r}" style="${f}${vA}${h}${Ve(TA(a,i.fontFamily,i.fontFamilyMono))}" fill="var(--_fg)" role="graphics-document document" aria-roledescription="${e}"${c}>`+o+l+"</svg>"}var eA,tA,rA,xd,aA,iA,nA,sA,lA,L0,D0,hA,dA,S0,T0,fA,wd,C0,pA,uA,gA,O0,mA,yA,P0,xA,Hs,wA,vA,qs,EA,nt,Gs,I0,SA,CA,_A,IA,R0,NA,RA,LA,DA,ut=Xe(()=>{wt();eA=/[&<>"\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/,tA=/[&<>"]|[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]+/g,rA={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};xd=[];for(let e=0;e<100;e++)xd.push(e===0?"":e%10===0?"."+e/10:"."+(e<10?"0"+e:e));aA=/ fill="([^"]*)"/,iA=/ stroke="([^"]*)"/,nA=/ style="([^"]*)"/,sA=/(?:^|;)\s*fill:([^;]*)/,lA=/(?:^|;)\s*opacity:([^;]*)/;L0=' font-weight="var(--_w)"',D0=' font-style="italic"';hA=1.5,dA=/<br\s*\/?>|\\n|\n/gi,S0=/<\/?([a-zA-Z][\w-]*)(?:\s[^<>]*)?\/?>/y,T0=/(fa[bklrs]?):fa-([\w-]+)/g,fA=/[<\\\n*_]|fa[bklrs]?:fa-/,wd="\\u2e80-\\u9fff\\uf900-\\ufaff\\uff00-\\uff60",C0="\u3001\u3002\uFF0C\uFF0E\uFF1A\uFF1B\uFF01\uFF1F\uFF09\uFF3D\uFF5D\u300D\u300F\u3011\u3015\u3009\u300B\u3019\u3017\u30FC\u2026\u2025\u30FB\u309D\u309E\u3041\u3043\u3045\u3047\u3049\u3063\u3083\u3085\u3087\u308E\u30A1\u30A3\u30A5\u30A7\u30A9\u30C3\u30E3\u30E5\u30E7\u30EE,.:;!?)\\]}",pA="\uFF08\uFF3B\uFF5B\u300C\u300E\u3010\u3014\u3008\u300A\u3018\u3016([{",uA=new RegExp(`[${wd}]`),gA=new RegExp(`\\s*(?:[${pA}]*[${wd}][${C0}]*|[^\\s${wd}]+[${C0}]*)\\s*|\\s+`,"g"),O0=57344,mA=6400,yA=/\$\$(.+?)\$\$/g,P0=/[\ue000-\uf8ff]/,xA=/([\ue000-\uf8ff])/,wA={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};vA="--_bg:var(--pele-bg,#fff);--_fg:var(--pele-fg,#1f1f1f);--_m:var(--pele-muted,#6e6e6e);--_l:var(--pele-line,#1f1f1f);--_s:var(--pele-surface,#f3f3f3);--_a:var(--pele-surface-alt,#e6e6e6);--_b:var(--pele-border,#8a8a8a);--_c:var(--pele-accent,#5b7bd5);color:var(--_fg)",qs="var(--_fm)",EA="var(--pele-radius,4px)",nt=' style="rx:var(--_r)"';Gs="var(--pele-critical,#e45756)",I0=String.raw`(?:"[^"'\\\n<>{}();:@]*"|'[^"'\\\n<>{}();:@]*'|[\p{L}\p{N}_-][\p{L}\p{N}_ .-]*)`,SA=new RegExp(String.raw`^\s*${I0}(?:\s*,\s*${I0})*\s*$`,"u");CA=new Set(["fill","fill-opacity","stroke","stroke-width","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-opacity","opacity","rx","ry"]),_A=new Set(["color","font-size","font-family","font-weight","font-style","text-decoration","letter-spacing","word-spacing","opacity"]),IA=/url\s*\(|expression\s*\(|javascript:|[<>{};\\]|@import|image-set|\/\*/i,R0={shape:"",line:"",text:"",stroke:void 0,bold:!1,italic:!1,fontSize:void 0};NA=/[^\w-]+/g;RA=["#4c78a8","#f58518","#54a24b","#e45756","#72b7b2","#eeca3b","#b279a2","#9d755d"];LA=[["tw","title"],["hw","heading"],["w","bold"]],DA=/var\(--_(r|tw|hw|w)\)/g});function va(e,t){for(let r=0;r<t.length;r+=3){let a=Math.round(t[r+1]),i=e.get(a);i?i.push(t[r]):e.set(a,[t[r]])}}function Ai(e,t,r,a){if(t===0)return e.x;let i=e.y-e.h/2,n=e.x-e.w/2,l=t/2,s=[n+a-6+l,e.x,n+e.w-a+6-l],o=r.get(Math.round(i));if(o===void 0)return s[0];let c=s[0],f=-1;for(let p of s){let h=1/0;for(let g of o)g>n&&g<n+e.w&&(h=Math.min(h,Math.abs(g-p)-l));if(h>=6)return p;h>f+.5&&(f=h,c=p)}return c}function xo(e,t,r,a){let i=t>0?a.get(Math.round(e.y-e.h/2)):void 0;if(i===void 0)return!1;let n=e.x-e.w/2;for(let l of i)if(l>n&&l<n+e.w&&Math.abs(l-r)<t/2+4)return!0;return!1}function wo(e,t,r,a,i,n,l,s){let o=1;for(let f=n[l].parent;f>=0&&o<8;f=n[f].parent)o++;let c=`color-mix(in srgb,var(--_a) ${d(100*(1-.5**o))}%,var(--_bg))`;return`<g class="pele-cluster-title" data-id="${i}">`+Re(e,t,r,` fill="none" stroke="${c}" stroke-width="5" stroke-linejoin="round"`,s)+Re(e,t,r,a,s)+"</g>"}var Bn=Xe(()=>{ut()});function Zi(e,t,r=0){return{w:e,h:t,kind:r,pin:0,hint:NaN,key:NaN,span:0,x:0,y:0,rank:0}}function Qi(e,t,r=1,a=0,i=0){return{tail:e,head:t,minlen:r,labelW:a,labelH:i,tailDx:0,headDx:0,tailFixed:!1,headFixed:!1,reversed:!1,points:[],labelX:0,labelY:0}}function Hn(e){return e===1||e===2}function G0(e,t,r,a){for(let i=t+1;i<r;i++){let n=e[i],l=a[n],s=i-1;for(;s>=t&&(a[e[s]]>l||a[e[s]]===l&&e[s]>n);)e[s+1]=e[s],s--;e[s+1]=n}}function jA(e,t,r,a,i,n){let l=(c,f)=>r[c]<r[f]||r[c]===r[f]&&(i?a[c]>a[f]:a[c]<a[f]);for(let c=0;c<t;c+=8)for(let f=c+1,p=Math.min(t,c+8);f<p;f++){let h=e[f],g=f-1;for(;g>=c&&l(h,e[g]);)e[g+1]=e[g],g--;e[g+1]=h}let s=e,o=n;for(let c=8;c<t;c*=2){for(let p=0;p<t;p+=2*c){let h=Math.min(t,p+c),g=Math.min(t,p+2*c),u=p,m=h,b=p;for(;u<h&&m<g;)o[b++]=l(s[m],s[u])?s[m++]:s[u++];for(;u<h;)o[b++]=s[u++];for(;m<g;)o[b++]=s[m++]}let f=s;s=o,o=f}if(s!==e)for(let c=0;c<t;c++)e[c]=s[c]}function ko(e,t,r){let a=e.length;if(a===0)return{width:0,height:0};let i=t.length;if(a===1&&i===0&&e[0].kind===0){let de=e[0];return de.rank=0,de.x=de.w/2,de.y=de.h/2,{width:de.w,height:de.h}}let n=1;if(i>0){let de=new Set;for(let ke of t){let Ce=Math.min(ke.tail,ke.head),be=Math.max(ke.tail,ke.head),Me=Ce*a+be;if(ke.labelW>0||de.has(Me)){n=2;break}de.add(Me)}}Xs(e,t),Vs(e,t,n);let l=new Int32Array(i),s=0;for(let de=0;de<i;de++){let ke=t[de];l[de]=Math.abs(e[ke.head].rank-e[ke.tail].rank),l[de]>1&&(s+=l[de]-1)}let o=new Uint8Array(i);if(s>F0){let de=[];for(let ke=0;ke<i;ke++)l[ke]>1&&de.push(ke);de.sort((ke,Ce)=>l[Ce]-l[ke]||ke-Ce);for(let ke of de){if(s<=F0)break;o[ke]=1,s-=l[ke]-1}}let c=a+s,f=new Float64Array(c),p=new Float64Array(c),h=new Uint8Array(c),g=new Int32Array(c),u=0;for(let de=0;de<a;de++){let ke=e[de];f[de]=ke.w,p[de]=ke.h,h[de]=ke.kind,g[de]=ke.rank,ke.rank>u&&(u=ke.rank)}let m=0;for(let de=0;de<i;de++)o[de]||(m+=l[de]);let b=new Int32Array(m),w=new Int32Array(m),v=new Float64Array(m),k=new Float64Array(m),O=new Int32Array(i).fill(-1),R=new Uint8Array(u+1),L=new Int32Array(i).fill(-1),P=!1;for(let de=0;de<a;de++)e[de].span>0&&e[de].kind===0&&(P=!0);let B=P?new Uint8Array(m):void 0,G=P?new Uint8Array(m):void 0,C=new Int32Array(i).fill(-1),Z=new Int32Array(i).fill(-1),ee=new Float64Array(c).fill(NaN);for(let de=0;de<a;de++)ee[de]=e[de].key;let H=!1;{let de=a,ke=0;for(let Ce=0;Ce<i;Ce++){if(o[Ce])continue;let be=t[Ce],Me=be.reversed?be.head:be.tail,Ne=be.reversed?be.tail:be.head,Be=be.reversed?be.headDx:be.tailDx,Pe=be.reversed?be.tailDx:be.headDx;(Be!==0||Pe!==0)&&(H=!0);let V=g[Me],me=g[Ne],ie=-1;be.labelW>0&&(ie=V+(me-V>>1),n===2&&me-V>=4?(ie&1)===1&&(ie+=be.reversed?1:-1):n===2&&!(ie&1)&&(ie+=be.reversed?1:-1));let $e=Me;me-V>1&&(O[Ce]=de),C[Ce]=ke,B&&!(be.reversed?be.headFixed:be.tailFixed)&&(B[ke]=be.reversed?2:1);for(let ve=V+1;ve<me;ve++){let Te=de++;g[Te]=ve,ee[Te]=ee[Me]+(ee[Ne]-ee[Me])*(ve-V)/(me-V),ve===ie?(f[Te]=be.labelW,p[Te]=be.labelH,h[Te]=2,L[Ce]=Te,R[ve]|=be.reversed?2:1):h[Te]=1,b[ke]=$e,w[ke]=Te,v[ke]=$e===Me?Be:0,ke++,$e=Te}b[ke]=$e,w[ke]=Ne,v[ke]=$e===Me?Be:0,k[ke]=Pe,G&&!(be.reversed?be.tailFixed:be.headFixed)&&(G[ke]=be.reversed?1:2),Z[Ce]=ke,ke++}}let Y;if(r.groups){let{of:de,parent:ke}=r.groups;Y=new Int32Array(c);for(let Me=0;Me<a;Me++)Y[Me]=de[Me];let Ce=Me=>{let Ne=0;for(;Me>=0;Me=ke[Me])Ne++;return Ne},be=(Me,Ne)=>{let Be=Ce(Me),Pe=Ce(Ne);for(;Be>Pe;Be--)Me=ke[Me];for(;Pe>Be;Pe--)Ne=ke[Ne];for(;Me!==Ne;)Me=ke[Me],Ne=ke[Ne];return Me};for(let Me=0;Me<i;Me++){if(O[Me]<0)continue;let Ne=t[Me],Be=be(de[Ne.tail],de[Ne.head]);for(let Pe=O[Me],V=Pe+l[Me]-1;Pe<V;Pe++)Y[Pe]=Be}}let _=new Int32Array(c+1),S=new Int32Array(c+1);for(let de=0;de<m;de++)_[b[de]+1]++,S[w[de]+1]++;for(let de=0;de<c;de++)_[de+1]+=_[de],S[de+1]+=S[de];let $=new Int32Array(m),y=new Int32Array(m);{let de=_.slice(0,c),ke=S.slice(0,c);for(let Ce=0;Ce<m;Ce++)$[de[b[Ce]]++]=Ce,y[ke[w[Ce]]++]=Ce}let E=new Int32Array(u+2);for(let de=0;de<c;de++)E[g[de]+1]++;for(let de=0;de<=u;de++)E[de+1]+=E[de];let x=new Int32Array(c),T=new Int32Array(c);{let de=new Int32Array(c),ke=E.slice(0,u+1);for(let Me=0;Me<c;Me++)de[ke[g[Me]]++]=Me;for(let Me=0;Me<=u;Me++)ke[Me]=E[Me];let Ce=new Uint8Array(c),be=[];for(let Me=0;Me<c;Me++)if(!Ce[de[Me]])for(be.push(de[Me]);be.length>0;){let Ne=be.pop();if(!Ce[Ne]){Ce[Ne]=1,x[ke[g[Ne]]++]=Ne;for(let Be=_[Ne+1]-1;Be>=_[Ne];Be--){let Pe=w[$[Be]];Ce[Pe]||be.push(Pe)}}}}let A=(de,ke)=>{let Ce=E[de],be=E[de+1];if(be-Ce<2)return!1;for(let Be=Ce;Be<be;Be++)if(Number.isNaN(ke(x[Be])))return!1;let Me=Array.from(x.subarray(Ce,be)),Ne=new Map;return Me.forEach((Be,Pe)=>Ne.set(Be,Pe)),Me.sort((Be,Pe)=>ke(Be)-ke(Pe)||Ne.get(Be)-Ne.get(Pe)),x.set(Me,Ce),!0};for(let de=0;de<=u;de++)A(de,ke=>ee[ke]);let M=!1;for(let de=0;de<a;de++)e[de].pin!==0&&(M=!0);if(M)for(let de=0;de<=u;de++){let ke=Array.from(x.subarray(E[de],E[de+1])),Ce=new Map;ke.forEach((Me,Ne)=>Ce.set(Me,Ne));let be=Me=>Me<a?e[Me].pin:0;ke.sort((Me,Ne)=>be(Me)-be(Ne)||Ce.get(Me)-Ce.get(Ne)),x.set(ke,E[de])}let N=new Uint8Array(u+1),F=de=>de<a&&(e[de].kind===3||e[de].kind===4)?e[de].hint:NaN;for(let de of[0,u])A(de,F)&&(N[de]=1);let U=()=>{for(let de=0;de<=u;de++){let ke=E[de];for(let Ce=ke,be=E[de+1];Ce<be;Ce++)T[x[Ce]]=Ce-ke}};U();let D={n:c,real:a,maxRank:u,W:f,KIND:h,RANK:g,EF:b,ET:w,EFD:v,ETD:k,succStart:_,succE:$,predStart:S,predE:y,layerStart:E,order:x,pos:T,offsets:H,fixed:N,GRP:Y,groupParent:r.groups?.parent},I=0,z=0;if(m>0&&u>0&&([I,z]=av(D,e),U()),r.orderOnly){let de=j0(D,r);for(let ke=0;ke<a;ke++)e[ke].x=de[ke];for(let ke=0;ke<i;ke++){let Ce=t[ke],be=Ce.reversed?Ce.head:Ce.tail,Me=Ce.reversed?Ce.tail:Ce.head,Ne=[g[be],de[be]];if(!o[ke]&&O[ke]>=0)for(let Be=O[ke],Pe=Be+l[ke]-1;Be<Pe;Be++)Ne.push(g[Be],de[Be]);Ne.push(g[Me],de[Me]),Ce.points=Ne}return{width:0,height:0,crossings:I,declared:z}}B&&G&&XA(D,e,B,G);let q=j0(D,r),j=JA(D);if(B&&G){let de=VA(D,B,G);KA(D,e,q,de,r,j),ZA(D,e,q,B,G,de,j),QA(D,q,j,r);for(let ke=0;ke<i;ke++){if(o[ke])continue;let Ce=t[ke],be=v[C[ke]],Me=k[Z[ke]];Ce.tailDx=Ce.reversed?Me:be,Ce.headDx=Ce.reversed?be:Me}}let Q=new Uint8Array(c);j&&!r.tracks&&tv(D,q,j,O,l,r.apart?0:r.edgeSep,Q),r.tracks||rv(D,q,O,l,r.edgeSep,Q);let K=new Int32Array(i+1),W=r.tracks||B&&!r.straight?{from:[],to:[],rank:[],lower:[],track:[],levels:[],wide:[]}:void 0,X=new Int32Array(u+1);if(W){for(let de=0;de<i;de++){if(K[de]=W.from.length,o[de])continue;let ke=O[de],Ce=!1;for(let Ne=ke,Be=ke<0?ke:ke+l[de]-1;Ne<Be;Ne++){let Pe=j!==void 0&&j[g[Ne]]===1;!r.tracks&&Pe!==(Q[Ne]===1)&&(Ce=!0)}if(Ce)continue;let be=q[b[C[de]]]+v[C[de]],Me=g[b[C[de]]];for(let Ne=ke,Be=ke<0?ke:ke+l[de]-1;Ne<Be;Ne++)j&&j[g[Ne]]||(W.from.push(be),W.to.push(q[Ne]),W.rank.push(Me),W.lower.push(Ne),be=q[Ne],Me=g[Ne]);W.from.push(be),W.to.push(q[w[Z[de]]]+k[Z[de]]),W.rank.push(Me),W.lower.push(-1)}K[i]=W.from.length}let te=(de,ke)=>{let Ce=!1;for(let be=E[de];be<E[de+1];be++){let Me=h[x[be]];if(Me===ke)Ce=!0;else if(Me!==1)return!1}return Ce},se=te(0,3)?n:0,oe=te(u,4)?n:0,ae=new Float64Array(u+1);for(let de=0;de<m;de++){let ke=Math.abs(q[b[de]]+v[de]-q[w[de]]-k[de]);ke>ae[g[b[de]]]&&(ae[g[b[de]]]=ke)}let ne=new Float64Array(u+1),J=new Float64Array(u+1),re=de=>(de<se||de>=u-oe?r.portSep:r.rankSep)/n,fe=new Float64Array(u+1);for(let de=0;de<u;de++)fe[de]=W?re(de):Math.max(re(de),Math.min(B0*r.rankSep/n,ae[de]*PA));let ye=new Uint8Array(u+1).fill(1);for(let de=0;de<a;de++)ye[g[de]]=0;for(let de=1;de<u;de++){if(r.tracks||!ye[de]||R[de]!==1&&R[de]!==2)continue;let ke=Math.min((r.headRoom??0)/2,fe[R[de]===1?de-1:de]/2);fe[de-1]+=R[de]===1?-ke:ke,fe[de]+=R[de]===1?ke:-ke}let le=de=>h[de]===1&&ye[g[de]]&&!r.tracks?(J[g[de]]-ne[g[de]])/4:0,we=r.tracks?zA:YA,pe=r.tracks?FA:Y0,ge=r.tracks?WA:Y0,Ae=new Int32Array(u+1);if(W){let de=new Float64Array(u+1);for(let Ce=0;Ce<u;Ce++){if(j&&j[Ce])continue;let be=Ce+1;for(de[Ce]=fe[Ce];be<u&&j&&j[be];)de[Ce]+=fe[be++];Ae[Ce]=be}for(let Ce=0;Ce<W.from.length;Ce++)W.wide.push(Math.abs(W.from[Ce]-W.to[Ce])>BA*de[W.rank[Ce]]?1:0);let ke=new Float64Array(u+1);ev(W,X,!r.tracks,de,ke);for(let Ce=0;Ce<u;Ce++)X[Ce]>0?fe[Ce]+=Math.max(0,2*we+(X[Ce]-1)*pe-de[Ce]):ke[Ce]>0&&(fe[Ce]+=Math.max(0,Math.min(B0*r.rankSep,ke[Ce])-de[Ce]))}let Se=0;for(let de=0;de<=u;de++){let ke=0;for(let Ce=E[de];Ce<E[de+1];Ce++)p[x[Ce]]>ke&&(ke=p[x[Ce]]);ne[de]=Se,J[de]=Se+ke,Se+=ke+fe[de]}let ce=Se,ue=(de,ke=W.track[de])=>{let Ce=W.rank[de],be=J[Ce],Me=ne[Ae[Ce]],Ne=r.tracks?X[Ce]:W.levels[de],Be=Ne>1?Math.min(ge,(Me-be-2*we)/(Ne-1)):0;return(be+Me)/2+(ke-(Ne-1)/2)*Be},xe=1/0,Ie=-1/0;for(let de=0;de<c;de++){let ke=f[de]/2;q[de]-ke<xe&&(xe=q[de]-ke),q[de]+ke>Ie&&(Ie=q[de]+ke)}let Le=new Uint8Array(u+1),We=new Uint8Array(u+1);for(let de=0;de<a;de++)h[de]!==0||!B||(S[de+1]>S[de]&&(Le[g[de]]=1),_[de+1]>_[de]&&(We[g[de]]=1));for(let de=0;de<a;de++){let ke=e[de],Ce=ke.rank;ke.x=q[de]-xe,h[de]===0&&We[Ce]&&!Le[Ce]?ke.y=J[Ce]-ke.h/2:h[de]===0&&Le[Ce]&&!We[Ce]?ke.y=ne[Ce]+ke.h/2:ke.y=(ne[Ce]+J[Ce])/2}for(let de=0;de<i;de++){let ke=t[de],Ce=e[ke.reversed?ke.head:ke.tail],be=e[ke.reversed?ke.tail:ke.head],Me=[Ce.x+(ke.reversed?ke.headDx:ke.tailDx),Ce.y+Ce.h/2],Ne=O[de];if(W&&K[de+1]>K[de])for(let Pe=K[de];Pe<K[de+1];Pe++){if(W.track[Pe]>=0&&(r.tracks||W.wide[Pe]===1)){let me=ue(Pe);Me.push(W.from[Pe]-xe,me,W.to[Pe]-xe,me)}else W.track[Pe]>0&&Me.push(W.from[Pe]-xe,ue(Pe,W.track[Pe]-1));let V=W.lower[Pe];V<0||(Me.push(q[V]-xe,ne[g[V]]+le(V)),J[g[V]]>ne[g[V]]&&Me.push(q[V]-xe,J[g[V]]-le(V)))}else if(Ne>=0)for(let Pe=Ne,V=Ne+l[de]-1;Pe<V;Pe++){if(Q[Pe])continue;let me=q[Pe]-xe,ie=ne[g[Pe]],$e=J[g[Pe]];Me.push(me,ie+le(Pe)),$e>ie&&Me.push(me,$e-le(Pe))}if(Me.push(be.x+(ke.reversed?ke.tailDx:ke.headDx),be.y-be.h/2),ke.reversed)for(let Pe=0,V=Me.length-2;Pe<V;Pe+=2,V-=2){let me=Me[Pe],ie=Me[Pe+1];Me[Pe]=Me[V],Me[Pe+1]=Me[V+1],Me[V]=me,Me[V+1]=ie}ke.points=Me;let Be=L[de];Be>=0?(ke.labelX=q[Be]-xe,ke.labelY=(ne[g[Be]]+J[g[Be]])/2):ke.labelW>0&&(ke.labelX=(Me[0]+Me[Me.length-2])/2,ke.labelY=(Me[1]+Me[Me.length-1])/2)}return{width:Ie-xe,height:ce}}function Xs(e,t){let r=e.length,a=t.length,i=new Int32Array(r+1);for(let c=0;c<a;c++){let f=t[c];f.reversed=e[f.head].kind===3||e[f.tail].kind===4,f.reversed||i[f.tail+1]++}for(let c=0;c<r;c++)i[c+1]+=i[c];let n=new Int32Array(i[r]);{let c=i.slice(0,r);for(let f=0;f<a;f++)t[f].reversed||(n[c[t[f].tail]++]=f)}let l=new Uint8Array(r),s=i.slice(0,r),o=[];for(let c=0;c<r;c++)if(l[c]===0)for(o.push(c),l[c]=1;o.length>0;){let f=o[o.length-1];if(s[f]<i[f+1]){let p=t[n[s[f]++]],h=p.head;l[h]===1?p.reversed=!0:l[h]===0&&(l[h]=1,o.push(h))}else l[f]=2,o.pop()}}function Vs(e,t,r){let a=e.length,i=t.length,n=new Int32Array(i),l=new Int32Array(i),s=new Int32Array(i),o=new Int32Array(a+1),c=new Int32Array(a+1);for(let k=0;k<i;k++){let O=t[k],R=O.reversed?O.head:O.tail,L=O.reversed?O.tail:O.head;n[k]=R,l[k]=L,s[k]=Math.max(1,O.minlen)*r,o[R+1]++,c[L+1]++}for(let k=0;k<a;k++)o[k+1]+=o[k],c[k+1]+=c[k];let f=new Int32Array(i),p=new Int32Array(i);{let k=o.slice(0,a),O=c.slice(0,a);for(let R=0;R<i;R++)f[k[n[R]]++]=R,p[O[l[R]]++]=R}let h=new Int32Array(a),g=new Int32Array(a);for(let k=0;k<a;k++)g[k]=c[k+1]-c[k];let u=new Int32Array(a),m=0;for(let k=0;k<a;k++)g[k]===0&&(u[m++]=k);for(let k=0;k<m;k++){let O=u[k];for(let R=o[O];R<o[O+1];R++){let L=f[R],P=l[L];h[O]+s[L]>h[P]&&(h[P]=h[O]+s[L]),--g[P]===0&&(u[m++]=P)}}for(let k=0;k<8;k++){let O=!1;for(let R=m-1;R>=0;R--){let L=u[R],P=c[L+1]-c[L],B=o[L+1]-o[L];if(P===0&&B===0)continue;let G=-1/0,C=1/0;for(let ee=c[L];ee<c[L+1];ee++){let H=p[ee];G=Math.max(G,h[n[H]]+s[H])}for(let ee=o[L];ee<o[L+1];ee++){let H=f[ee];C=Math.min(C,h[l[H]]-s[H])}let Z=h[L];B>P&&C!==1/0?Z=C:P>B&&G!==-1/0&&(Z=G),Z!==h[L]&&(h[L]=Z,O=!0)}if(!O)break}let b=1/0,w=-1/0,v=!1;for(let k=0;k<a;k++){let O=e[k].kind;O===3&&(v=!0),!(O===3||O===4)&&(h[k]<b&&(b=h[k]),h[k]>w&&(w=h[k]))}b===1/0&&(b=0,w=0);for(let k=0;k<a;k++)e[k].kind===3?h[k]=b-r:e[k].kind===4&&(h[k]=w+r);v&&(b-=r);for(let k=0;k<a;k++)e[k].rank=h[k]-b}function X0(e,t,r,a,i,n,l){let s=r===0?e.predStart:e.succStart,o=r===0?e.predE:e.succE,c=r===0?e.EF:e.ET,f=e.pos;for(let u=s[t];u<s[t+1];u++)i[o[u]]!==0&&n.push(o[u]);if(n.length<2)return 0;n.sort((u,m)=>f[c[u]]-f[c[m]]||u-m);let p=u=>{let m=0;l[0]=0;for(let b=1;b<n.length;b++){let w=i[n[b]]===i[n[b-1]];l[b]=u(w&&i[n[b]]===1,w),m+=l[b]}return m},h=p(()=>1);if(a/h<W0&&(h=p(u=>u?.5:1)),a/h<W0&&(h=p((u,m)=>m?0:1)),h===0)return 0;let g=Math.min(kd,a/h);for(let u=1;u<n.length;u++)l[u]*=g;return h*g}function XA(e,t,r,a){let{real:i,W:n,EFD:l,ETD:s}=e;for(let o=0;o<i;o++){let c=Math.min(t[o].span,n[o]);if(!(c<=0||t[o].kind!==0))for(let f=0;f<2;f++){let p=[],h=[],g=X0(e,o,f,c,f===0?a:r,p,h);if(g===0)continue;let u=f===0?s:l,m=-g/2;for(let b=0;b<p.length;b++)m+=h[b],u[p[b]]=m}}}function $o(e,t,r,a){if(!t)return r;let{KIND:i,RANK:n,EF:l,ET:s,succStart:o,succE:c,predStart:f,predE:p}=e;for(let h=0;h<1e5;h++){let g=a===0?l[r]:s[r];if(i[g]!==1||!t[n[g]])break;r=a===0?p[f[g]]:c[o[g]]}return r}function VA(e,t,r){let a=[new Int32Array(e.n),new Int32Array(e.n)];for(let i=0;i<e.EF.length;i++)r[i]!==0&&a[0][e.ET[i]]++,t[i]!==0&&a[1][e.EF[i]]++;return a}function Ks(e,t){return Math.max(.25,Math.min(.5,4*Math.abs(t)/(Math.abs(e)||1)))}function KA(e,t,r,a,i,n){let l=i.edgeSep,{n:s,real:o,maxRank:c,KIND:f,RANK:p,W:h,EF:g,ET:u,EFD:m,ETD:b,succStart:w,succE:v,predStart:k,predE:O,layerStart:R,order:L,pos:P}=e,B=Y=>f[Y]===2||f[Y]===1&&!(n!==void 0&&n[p[Y]]===1),G=(Y,_)=>{let S=_===0?g[Y]:u[Y];return[_===0?r[S]+m[Y]:r[S]+b[Y],S<o&&t[S].kind===0?a[1-_][S]:0]},C=Y=>{let _=R[p[Y]],S=_+P[Y],$=y=>h[y]/2+h[Y]/2+(f[y]===0?i.nodeSep/2+l/2:f[y]===f[Y]?l:l/2);return[S>_?r[L[S-1]]+$(L[S-1]):-1/0,S+1<R[p[Y]+1]?r[L[S+1]]-$(L[S+1]):1/0]},Z=(Y,_,S,$,y)=>{let E=(_[1]!==S[1]?_[1]<S[1]:Math.abs(_[0]-Y)<=Math.abs(S[0]-Y))?[_[0],S[0]]:[S[0],_[0]];return E.find(x=>x>=$&&x<=y)??Math.max($,Math.min(y,E[0]))},ee=new Uint8Array(s),H=[];for(let Y=1;Y<c;Y++)for(let _=R[Y];_<R[Y+1];_++){if(!B(L[_])||ee[L[_]])continue;let S=L[_];for(;Hn(f[g[O[k[S]]]]);)S=g[O[k[S]]];let $=S,y=-1/0,E=1/0;H.length=0;for(let x=S;Hn(f[x]);x=u[v[w[x]]]){if($=x,!B(x))continue;ee[x]=1,H.push(x);let[T,A]=C(x);T>y&&(y=T),A<E&&(E=A)}if(y<=E){let x=Z(r[H[0]],G(O[k[S]],0),G(v[w[$]],1),y,E);for(let T of H)r[T]=x;continue}for(let x of H){let[T,A]=C(x);T>A||(r[x]=Z(r[x],G($o(e,n,O[k[x]],0),0),G($o(e,n,v[w[x]],1),1),T,A))}}}function ZA(e,t,r,a,i,n,l){let{real:s,W:o,EF:c,ET:f,EFD:p,ETD:h,succStart:g,succE:u,predStart:m,predE:b,pos:w}=e,v=(O,R,L,P,B)=>{if(n[R][L]<2)return 0;O=$o(e,l,O,R);let G=R===0?c[O]:f[O],C=R===0?r[G]+p[O]:r[G]+h[O];if(B&&Math.abs(C-r[L])<=P/2+qa)return Math.max(-P/2,Math.min(P/2,C-r[L]));let Z=C,ee=0;G<s&&t[G].kind===0&&(R===0?a:i)[O]!==0&&n[1-R][G]>=2&&(ee=Math.max(0,Math.min(t[G].span,o[G])),ee>0&&(Z=r[G]));let H=Math.max(r[L]-P/2,Z-ee/2),Y=Math.min(r[L]+P/2,Z+ee/2);if(H>Y+qa){let S=Math.max(0,P/2-GA);return Math.max(-S,Math.min(S,C-r[L]))}let _=(r[L]*ee+Z*P)/(ee+P);return Math.max(H,Math.min(Y,_))-r[L]},k=[];for(let O=0;O<s;O++){let R=Math.min(t[O].span,o[O]);if(!(R<=0||t[O].kind!==0))for(let L=0;L<2;L++){let P=L===0?c:f,B=L===0?m:g,G=L===0?b:u,C=[],Z=[];if(X0(e,O,L,R,L===0?i:a,C,Z),C.length===0)continue;C.length===1&&(Z[0]=0);let ee=[];for(let H=B[O];H<B[O+1];H++)ee.push(G[H]);ee.sort((H,Y)=>w[P[H]]-w[P[Y]]||H-Y),k.push({v:O,side:L,span:R,ids:C,room:Z,all:ee})}}for(let O=0,R=!0;R&&O<6;O++){R=!1;for(let{v:L,side:P,span:B,ids:G,room:C,all:Z}of k){let ee=P===0?i:a,H=P===0?h:p,Y=0,_=-B/2;for(let S=0;S<=Z.length;S++){let $=S<Z.length&&ee[Z[S]]===0;if(S<Z.length&&!$)continue;let y=0;for(let x=S-1;x>=0&&ee[Z[x]]!==0;x--)y++;let E=$?H[Z[S]]-kd:B/2;if(y>0){let x=[],T=[],A=0;for(let F=0;F<y;F++){F>0&&(A+=C[Y+F]),x.push(v(G[Y+F],P,L,B,O>0)-A),T.push(1);let U=F>0&&C[Y+F]===0;for(;x.length>1&&(U||x[x.length-2]/T[T.length-2]>x[x.length-1]/T[T.length-1]);){U=!1;let D=x.pop(),I=T.pop();x[x.length-1]+=D,T[T.length-1]+=I}}let M=A,N=0;A=0;for(let F=0;F<x.length;F++){let U=E-M<_?(_+E-M)/2:Math.max(_,Math.min(E-M,x[F]/T[F]));for(let D=0;D<T[F];D++,N++)N>0&&(A+=C[Y+N]),Math.abs(H[G[Y+N]]-U-A)>.01&&(R=!0),H[G[Y+N]]=U+A}Y+=y}$&&(_=H[Z[S]]+kd)}}}}function QA(e,t,r,a){let{n:i,KIND:n,RANK:l,EF:s,ET:o,EFD:c,ETD:f,layerStart:p,order:h,pos:g}=e,u=C=>r!==void 0&&n[C]===1&&r[l[C]]===1,m=[],b=[],w=[],v=[];for(let C=0;C<s.length;C++){if(u(s[C]))continue;let Z=$o(e,r,C,1);m.push(s[C]),b.push(o[Z]),w.push(c[C]),v.push(f[Z])}let k=C=>t[b[C]]+v[C]-t[m[C]]-w[C],O=new Int32Array(i),R=[];for(let C=0;C<i;C++)O[C]=C,R.push([C]);let L=(C,Z)=>{let ee=O[C],H=O[Z];if(ee!==H){R[ee].length<R[H].length&&([ee,H]=[H,ee]);for(let Y of R[H])O[Y]=ee,R[ee].push(Y);R[H]=[]}},P=[];for(let C=0;C<m.length;C++){let Z=Math.abs(k(C));Z<.01?L(m[C],b[C]):Z<=U0&&P.push(C)}if(P.length===0)return;P.sort((C,Z)=>Math.abs(k(C))-Math.abs(k(Z))||C-Z);let B=C=>V0(e,a,C),G=(C,Z)=>{for(let ee of R[C]){let H=p[l[ee]],Y=p[l[ee]+1],_=H+g[ee];if(_>H&&O[h[_-1]]!==C&&t[ee]+Z-t[h[_-1]]<B(ee)+B(h[_-1])-.01||_+1<Y&&O[h[_+1]]!==C&&t[h[_+1]]-t[ee]-Z<B(ee)+B(h[_+1])-.01)return!1}return!0};for(let C of P){let Z=k(C);if(Math.abs(Z)<.01){L(m[C],b[C]);continue}if(Math.abs(Z)>U0||O[m[C]]===O[b[C]])continue;let ee=O[m[C]],H=O[b[C]],Y=R[ee].length<=R[H].length?ee:H;for(let _ of[Y,Y===ee?H:ee]){let S=_===ee?Z:-Z;if(G(_,S)){for(let $ of R[_])t[$]+=S;L(m[C],b[C]);break}}}}function JA(e){let{maxRank:t,KIND:r,layerStart:a,order:i}=e,n=new Uint8Array(t+1),l=!1;for(let s=1;s<t;s++){let o=a[s+1]>a[s];for(let c=a[s];o&&c<a[s+1];c++)r[i[c]]!==1&&(o=!1);o&&(n[s]=1,l=!0)}return l?n:void 0}function ev(e,t,r,a,i){let{from:n,to:l,rank:s,track:o,levels:c,wide:f}=e,p=n.length,h=new Map;for(let C=0;C<p;C++){if(o.push(-1),c.push(0),Math.abs(n[C]-l[C])<qa)continue;let Z=h.get(s[C]);Z?Z.push(C):h.set(s[C],[C])}if(h.size===0)return;let g=new Float64Array(p),u=new Float64Array(p);for(let C=0;C<p;C++)g[C]=Math.min(n[C],l[C]),u[C]=Math.max(n[C],l[C]);let m=(C,Z)=>C>=g[Z]-qa&&C<=u[Z]+qa?1:0,b=(C,Z)=>Math.abs(n[C]-n[Z])<qa||Math.abs(l[C]-l[Z])<qa,w=(C,Z)=>g[C]<u[Z]-qa&&g[Z]<u[C]-qa,v=(C,Z)=>w(C,Z)&&!b(C,Z),k=(C,Z)=>w(C,Z)||m(l[C],Z)+m(n[Z],C)+m(l[Z],C)+m(n[C],Z)>0,O=(C,Z)=>m(l[C],Z)+m(n[Z],C),R=C=>{let Z=C.map((H,Y)=>Y).sort((H,Y)=>g[C[H]]-g[C[Y]]),ee=[];for(let H=0;H<Z.length;H++){let Y=Z[H],_=u[C[Y]]+4*qa;for(let S=H+1;S<Z.length&&g[C[Z[S]]]<=_;S++){let $=Z[S];ee.push(Math.min(Y,$),Math.max(Y,$))}}return ee},L=C=>{C.sort((N,F)=>u[F]-g[F]-(u[N]-g[N])||g[N]-g[F]||N-F);let Z=C.length,ee=[],H=C.map((N,F)=>F),Y=N=>{for(;H[N]!==N;)N=H[N]=H[H[N]];return N},_=Z<=q0,S=_?R(C):[],$=_?C.map(()=>[]):[];for(let N=0;N<S.length;N+=2){let F=S[N],U=S[N+1];v(C[F],C[U])&&($[F].push(U),$[U].push(F))}let y=C.map((N,F)=>F);if(_){let N=new Int32Array(Z),F=[];for(let D=0;D<Z;D++)ee.push([]),F.push([]);for(let D=0;D<S.length;D+=2){let I=S[D],z=S[D+1],q=C[I],j=C[z];if(!k(q,j))continue;H[Y(I)]=Y(z);let Q=O(q,j),K=O(j,q);if(Q===K)continue;let W=Q<K?I:z,X=Q<K?z:I;ee[X].push(W),F[W].push(X),N[X]++}let U=new Uint8Array(Z);y=[];for(let D=0;D<Z;D++){let I=-1;for(let z=0;z<Z&&!(!U[z]&&((I<0||N[z]<N[I])&&(I=z),N[z]===0));z++);U[I]=1,y.push(I);for(let z of F[I])N[z]--}}let E=new Set,x=[],T=0;for(let N of y){let F=C[N],U=0;for(let D of ee[N]??[])o[C[D]]>=U&&(U=o[C[D]]+1);if(_){E.clear();for(let D of $[N])E.add(o[C[D]]);for(;E.has(U);)U++}else{for(;x[U]?.some(D=>v(F,D));)U++;(x[U]??(x[U]=[])).push(F)}o[F]=U,U>=T&&(T=U+1)}let A=new Int32Array(Z).fill(T),M=new Int32Array(Z).fill(-1);for(let N=0;N<Z;N++){let F=Y(N);A[F]=Math.min(A[F],o[C[N]]),M[F]=Math.max(M[F],o[C[N]])}for(let N=0;N<Z;N++){let F=Y(N);c[C[N]]=M[F]-A[F]+1,r&&(o[C[N]]-=A[F])}return T},P=(C,Z,ee)=>{let H=Ks(l[C]-n[C],Z);for(let Y=0;Y<=Yn;Y++){let _=Y/Yn,S=1-_;ee[2*Y]=n[C]+(l[C]-n[C])*_*_*(3-2*_),ee[2*Y+1]=Z*(3*H*_*S*S+3*(1-H)*_*_*S+_*_*_)}},B=(C,Z,ee)=>{let H=ee*ee*1.000000001;for(let Y=0;Y<=Yn;Y++){let _=C[2*Y],S=C[2*Y+1];for(let $=0;$<Yn;$++){let y=Z[2*$+2]-Z[2*$],E=Z[2*$+3]-Z[2*$+1],x=Math.max(0,Math.min(1,((_-Z[2*$])*y+(S-Z[2*$+1])*E)/(y*y+E*E||1))),T=_-Z[2*$]-x*y,A=S-Z[2*$+1]-x*E;if(T*T+A*A<H&&Math.hypot(T,A)<ee)return!0}}return!1},G=(C,Z,ee,H)=>{let Y=Math.max(ee/2,ee-2*HA);return P(C,Y,bd),P(Z,Y,$d),B(bd,$d,H)||B($d,bd,H)};for(let[C,Z]of h){if(!r){t[C]=L(Z);continue}if(Z.length>q0)continue;let ee=Z.filter(x=>f[x]===1);L(ee);let H=new Set(ee.filter(x=>c[x]>1)),Y=R(Z);for(let x=0;x<Y.length;x+=2){let T=Z[Y[x]],A=Z[Y[x+1]];H.has(T)&&H.has(A)||!v(T,A)||n[T]<l[T]!=n[A]<l[A]||G(T,A,a[C],f[T]===1||f[A]===1?UA:qA)&&H.add(T).add(A)}for(let x of ee)o[x]=-1,c[x]=0;if(H.size===0)continue;let _=0,S=0,$=new Set;for(let x=0;x<Y.length;x+=2){let T=Z[Y[x]],A=Z[Y[x+1]];if(H.has(T)&&H.has(A)){if(!w(T,A))continue;n[T]<l[T]!=n[A]<l[A]?_++:b(T,A)||S++}else(H.has(T)||H.has(A))&&k(T,A)&&$.add(T).add(A)}if(_>S){for(let x of Z)(u[x]-g[x])*H0>i[C]&&(i[C]=(u[x]-g[x])*H0);continue}let y=Z.filter(x=>H.has(x)||f[x]!==1&&$.has(x));L(y);let E=0;for(let x of y)c[x]>E&&(E=c[x]);t[C]=E}}function tv(e,t,r,a,i,n,l){let{maxRank:s,EF:o,ET:c,EFD:f,ETD:p,succStart:h,succE:g,predStart:u,predE:m,layerStart:b,order:w}=e,v=new Float64Array(t.length),k=new Float64Array(t.length),O=new Float64Array(t.length);for(let L=0;L<a.length;L++){let P=a[L];if(P<0)continue;let B=P+i[L]-1,G=e.RANK[P];for(let C=P;C<B;C++){if(!r[G+C-P])continue;let Z=C;for(;Z+1<B&&r[G+Z+1-P];)Z++;let ee=m[u[C]],H=g[h[Z]],Y=t[o[ee]]+f[ee],_=t[c[H]]+p[H],S=Z-C+2;for(let $=C;$<=Z;$++)v[$]=Y+(_-Y)*($-C+1)/S,k[$]=Y,O[$]=_;C=Z}}let R=[];for(let L=1;L<s;L++){if(!r[L])continue;let P=b[L],B=b[L+1],G=Array.from(w.subarray(P,B)).sort((C,Z)=>k[C]-k[Z]||O[C]-O[Z]||C-Z);for(let C=0;C<G.length;){R.length=0;let Z=C;for(;Z<G.length&&Math.abs(k[G[Z]]-k[G[C]])<1&&Math.abs(O[G[Z]]-O[G[C]])<1;Z++)R.push(G[Z]);R.sort((ee,H)=>e.pos[ee]-e.pos[H]);for(let ee=0;ee<R.length;ee++){let H=R[ee];t[H]=v[H]+(ee-(R.length-1)/2)*n,(R.length===1||n===0)&&(l[H]=1)}C=Z}}}function rv(e,t,r,a,i,n){let{maxRank:l,W:s,KIND:o,RANK:c,EF:f,ET:p,EFD:h,ETD:g,succStart:u,succE:m,predStart:b,predE:w,layerStart:v,order:k}=e,O=new Uint8Array(l+1),R=!1;for(let L=1;L<l;L++){let P=!1,B=!1;for(let G=v[L];G<v[L+1];G++){let C=o[k[G]];C===2?P=!0:C!==1&&(B=!0)}P&&!B&&(O[L]=1,R=!0)}if(R)for(let L=0;L<r.length;L++){let P=r[L];if(!(P<0))for(let B=P,G=P+a[L]-1;B<G;B++){if(o[B]!==1||!O[c[B]])continue;let C=B,Z=B;for(;C>P&&n[C-1];)C--;for(;Z+1<G&&n[Z+1];)Z++;let ee=w[b[C]],H=m[u[Z]],Y=t[f[ee]]+h[ee],_=t[p[H]]+g[H],S=Math.min(Y,_)-i,$=Math.max(Y,_)+i,y=!0,E=c[B];for(let T=v[E];y&&T<v[E+1];T++){let A=k[T];o[A]===2&&t[A]+s[A]/2>S&&t[A]-s[A]/2<$&&(y=!1)}if(!y)continue;n[B]=1;let x=Z-C+2;for(let T=C;T<=Z;T++)t[T]=Y+(_-Y)*(T-C+1)/x}}}function av(e,t){let{n:r,real:a,maxRank:i,W:n,EF:l,ET:s,EFD:o,ETD:c,succStart:f,succE:p,predStart:h,predE:g,layerStart:u,order:m,pos:b,offsets:w,fixed:v,GRP:k,groupParent:O}=e,R=0;for(let ae=0;ae<=i;ae++)R=Math.max(R,u[ae+1]-u[ae]);if(R<2)return[0,0];let L=w?new Int32Array(l.length):void 0,P=new Int32Array(L?l.length:0),B=new Int32Array(L?r:0),G=L?p.slice():p,C=new Uint8Array(L?r:0);if(L){let ae=g.slice(),ne=(J,re,fe,ye)=>{for(let le=re+1;le<fe;le++)if(ye[J[le]]!==ye[J[re]])return J.subarray(re,fe).sort((we,pe)=>ye[we]-ye[pe]),!0;return!1};for(let J=0;J<r;J++){if(B[J]=1,ne(ae,h[J],h[J+1],c))for(let re=h[J]+1;re<h[J+1];re++)c[ae[re]]!==c[ae[re-1]]&&B[J]++,P[ae[re]]=B[J]-1;ne(G,f[J],f[J+1],o)&&(C[J]=1)}}let Z=1;for(;Z<(L?R+l.length:R);)Z<<=1;let ee=new Int32Array(2*Z),H=new Int32Array(l.length),Y=()=>{let ae=0;for(let ne=0;ne<i;ne++){let J=u[ne+2]-u[ne+1];if(L){let ye=0;for(let le=u[ne+1];le<u[ne+2];le++){let we=m[le];for(let pe=h[we];pe<h[we+1];pe++)L[g[pe]]=ye+P[g[pe]];ye+=B[we]}J=ye}if(J<2)continue;let re=0;for(let ye=u[ne];ye<u[ne+1];ye++){let le=m[ye],we=f[le],pe=f[le+1],ge=re;for(let Se=we;Se<pe;Se++)H[re++]=L?L[G[Se]]:b[s[p[Se]]];let Ae=re-ge;if(!(Ae<2))if(L&&C[le])for(let Se=ge+1;Se<re;Se++){let ce=H[Se],ue=o[G[we+Se-ge]],xe=Se-1;for(;xe>=ge&&o[G[we+xe-ge]]===ue&&H[xe]>ce;)H[xe+1]=H[xe],xe--;H[xe+1]=ce}else if(Ae<=12)for(let Se=ge+1;Se<re;Se++){let ce=H[Se],ue=Se-1;for(;ue>=ge&&H[ue]>ce;)H[ue+1]=H[ue],ue--;H[ue+1]=ce}else H.subarray(ge,re).sort()}if(re<2)continue;let fe=1;for(;fe<J;)fe<<=1;ee.fill(0,0,2*fe);for(let ye=0;ye<re;ye++){let le=H[ye]+fe;for(ee[le]++;le>1;)!(le&1)&&(ae+=ee[le+1]),le>>=1,ee[le]++}}return ae},_=Y(),S=new Float64Array(r),$=new Int32Array(R),y=new Int32Array(R),E=O?O.length:0,x=new Int32Array(E);for(let ae=0;ae<E;ae++)for(let ne=ae;ne>=0;ne=O[ne])x[ae]++;let T=new Float64Array(E),A=new Int32Array(E),M=new Int32Array(E),N=(ae,ne)=>{let J=u[ae],re=u[ae+1];for(let pe=J;pe<re;pe++)for(let ge=k[m[pe]];ge>=0;ge=O[ge])T[ge]=0,A[ge]=0;for(let pe=J;pe<re;pe++){let ge=m[pe];for(let Ae=k[ge];Ae>=0;Ae=O[Ae])A[Ae]===0&&(M[Ae]=pe),T[Ae]+=ne[ge],A[Ae]++}let fe=pe=>pe>=r?T[pe-r]/A[pe-r]:ne[pe],ye=pe=>pe>=r?M[pe-r]:J+b[pe],le=(pe,ge)=>{let Ae=pe,Se=ge,ce=k[pe],ue=k[ge],xe=ce<0?0:x[ce],Ie=ue<0?0:x[ue];for(;xe>Ie;xe--)Ae=r+ce,ce=O[ce];for(;Ie>xe;Ie--)Se=r+ue,ue=O[ue];for(;ce!==ue;)Ae=r+ce,ce=O[ce],Se=r+ue,ue=O[ue];return fe(Ae)-fe(Se)||ye(Ae)-ye(Se)},we=Array.from(m.subarray(J,re)).sort(le);m.set(we,J);for(let pe=J;pe<re;pe++)b[m[pe]]=pe-J};if(k){let ae=new Float64Array(r);for(let ne=0;ne<=i;ne++){for(let J=u[ne];J<u[ne+1];J++)ae[m[J]]=J-u[ne];N(ne,ae)}}let F=k?Y():_;if(F===0)return[0,_];let U=m.slice(),D=Math.min(F,_),I=(ae,ne)=>{let J=ae?h:f,re=ae?g:p,fe=ae?l:s,ye=ae?o:c;for(let le=1;le<=i;le++){let we=ae?le:i-le;if(v[we])continue;let pe=u[we],ge=u[we+1],Ae=0;for(let ce=pe;ce<ge;ce++){let ue=m[ce],xe=ue<a?t[ue].pin:0;if(xe!==0){S[ue]=xe*1e9,$[Ae++]=ue;continue}let Ie=J[ue],Le=J[ue+1];if(Ie===Le){if(k){let de=ae?u[we]-u[we-1]:u[we+2]-u[we+1];S[ue]=(ce-pe)*de/(ge-pe);continue}S[ue]=-1;continue}let We=0;for(let de=Ie;de<Le;de++){let ke=fe[re[de]];We+=b[ke],w&&n[ke]>0&&(We+=ye[re[de]]/n[ke])}S[ue]=We/(Le-Ie),$[Ae++]=ue}if(k){N(we,S);continue}if(Ae<2)continue;jA($,Ae,S,b,ne,y);let Se=0;for(let ce=pe;ce<ge;ce++)S[m[ce]]!==-1&&(m[ce]=$[Se++]);for(let ce=pe;ce<ge;ce++)b[m[ce]]=ce-pe}},z=()=>{let ae=0;for(let ne=0;ne<=i;ne++)for(let J=u[ne];J<u[ne+1];J++)if(!(m[J]>=a))for(let re=J+1;re<u[ne+1];re++)m[re]<m[J]&&ae++;return ae},q=()=>{for(let ae=0;ae<=i;ae++)for(let ne=u[ae];ne<u[ae+1];ne++)b[m[ne]]=ne-u[ae]},j=ae=>ae<a?t[ae].pin:0,Q=(ae,ne)=>{let J=ne?l[ae]:s[ae];return w&&n[J]>0?b[J]+(ne?o[ae]:c[ae])/n[J]:b[J]},K=(ae,ne)=>{let J=0;for(let re=h[ae];re<h[ae+1];re++){let fe=Q(g[re],!0);for(let ye=h[ne];ye<h[ne+1];ye++)fe>Q(g[ye],!0)&&J++}for(let re=f[ae];re<f[ae+1];re++){let fe=Q(p[re],!1);for(let ye=f[ne];ye<f[ne+1];ye++)fe>Q(p[ye],!1)&&J++}return J},W=()=>{for(let ae=0;ae<8;ae++){let ne=!1;for(let J=0;J<=i;J++){if(v[J])continue;let re=u[J];for(let fe=re;fe+1<u[J+1];fe++){let ye=m[fe],le=m[fe+1];j(ye)!==j(le)||k&&k[ye]!==k[le]||K(le,ye)>=K(ye,le)||(m[fe]=le,m[fe+1]=ye,b[le]=fe-re,b[ye]=fe+1-re,ne=!0)}}if(!ne)break}},X=m.slice(),te=r<=600,se=U,oe=1/0;for(let ae=0;ae<(te?2:1);ae++){ae>0&&(m.set(X),q());let ne=D,J=X.slice();for(let fe=0,ye=0;ye<4&&fe<OA;fe++,ye++){I((fe+ae)%2===0,fe%4>=2);let le=Y();if(le<ne&&(ne=le,J.set(m),ye=0,le===0))break}if(m.set(J),te&&ne>0){q(),W();let fe=Y();fe<ne&&(ne=fe,J.set(m))}let re=te?z():0;(ae===0||ne<F||ne===F&&re<oe)&&(F=ne,se=J,oe=re)}if(m.set(se),q(),U.set(se),k&&(F=Y()),!te)return[F,_];for(let ae=0;ae<a;ae++)if(t[ae].pin!==0)return[F,_];if(oe===0||v[0]||v[i])return[F,_];for(let ae=0;ae<=i;ae++)m.subarray(u[ae],u[ae+1]).reverse();return q(),(Y()>F||z()>=oe)&&m.set(U),[F,_]}function V0(e,t,r){return e.W[r]/2+(e.KIND[r]===0?t.nodeSep:t.edgeSep)/2}function j0(e,t){let{n:r,maxRank:a,W:i,KIND:n,EF:l,ET:s,EFD:o,ETD:c,succStart:f,succE:p,predStart:h,predE:g,layerStart:u,order:m,pos:b}=e,w=l.length,v=new Float64Array(r);for(let M=0;M<r;M++)v[M]=V0(e,t,M);let k=new Int32Array(w);for(let M=0;M<w;M++)k[M]=b[s[M]];for(let M=0;M<r;M++)f[M+1]-f[M]>1&&G0(p,f[M],f[M+1],k);for(let M=0;M<w;M++)k[M]=b[l[M]];for(let M=0;M<r;M++)h[M+1]-h[M]>1&&G0(g,h[M],h[M+1],k);let O=new Uint8Array(w);for(let M=1;M<=a;M++){let N=u[M]-u[M-1],F=u[M],U=u[M+1],D=0,I=F;for(let z=F;z<U;z++){let q=m[z],j=-1;if(Hn(n[q])){let K=l[g[h[q]]];Hn(n[K])&&(j=K)}let Q=j>=0?b[j]:N;if(j>=0||z===U-1){for(let K=I;K<=z;K++){let W=m[K],X=Hn(n[W]);for(let te=h[W];te<h[W+1];te++){let se=g[te],oe=b[l[se]];(oe<D||Q<oe)&&!(X&&Hn(n[l[se]]))&&(O[se]=1)}}I=z+1,D=Q}}}let R=[],L=new Int32Array(r),P=new Int32Array(r),B=new Float64Array(r),G=new Int32Array(r),C=new Int32Array(r),Z=new Float64Array(r),ee=new Int32Array(r),H=new Int32Array(r+1),Y=new Int32Array(r),_=new Int32Array(r),S=new Int32Array(r),$=new Float64Array(r);for(let M=0;M<4;M++){let N=M<2,F=(M&1)===1,U=N?h:f,D=N?g:p,I=N?l:s,z=N?c:o,q=N?o:c;for(let W=0;W<r;W++)L[W]=W,P[W]=W,B[W]=0,ee[W]=0,H[W+1]=0,$[W]=0;for(let W=0;W<=a;W++){let X=N?W:a-W,te=u[X],se=u[X+1],oe=N?X-1:X+1,ae=oe>=0&&oe<=a?u[oe+1]-u[oe]-1:0,ne=-1;for(let J=F?se-1:te;F?J>=te:J<se;F?J--:J++){let re=m[J],fe=U[re],ye=U[re+1]-fe;if(ye===0)continue;let le=fe+(ye-1>>1),we=fe+(ye>>1);for(let pe=0;pe<2&&!(pe===1&&le===we);pe++){let ge=D[pe===0!==F?le:we],Ae=I[ge],Se=F?ae-b[Ae]:b[Ae];P[re]===re&&ne<Se&&O[ge]===0&&(P[Ae]=re,P[re]=L[re]=L[Ae],B[re]=B[Ae]+q[ge]-z[ge],ne=Se)}}}let j=0;for(let W=0;W<=a;W++){let X=u[W],te=u[W+1];for(let se=X+1;se<te;se++){let oe=F?m[se]:m[se-1],ae=F?m[se-1]:m[se],ne=v[oe]+v[ae];G[j]=L[oe],C[j]=L[ae],Z[j]=F?ne-B[oe]+B[ae]:ne+B[oe]-B[ae],ee[L[ae]]++,H[L[oe]+1]++,j++}}for(let W=0;W<r;W++)H[W+1]+=H[W];for(let W=0;W<r;W++)_[W]=H[W];for(let W=0;W<j;W++)Y[_[G[W]]++]=W;let Q=0;for(let W=0;W<r;W++)L[W]===W&&ee[W]===0&&(S[Q++]=W);for(let W=0;W<Q;W++){let X=S[W];for(let te=H[X];te<H[X+1];te++){let se=Y[te],oe=C[se];$[X]+Z[se]>$[oe]&&($[oe]=$[X]+Z[se]),--ee[oe]===0&&(S[Q++]=oe)}}for(let W=Q-1;W>=0;W--){let X=S[W],te=1/0;for(let se=H[X];se<H[X+1];se++){let oe=Y[se],ae=$[C[oe]]-Z[oe];ae<te&&(te=ae)}te!==1/0&&te>$[X]&&($[X]=te)}let K=new Float64Array(r);for(let W=0;W<r;W++)K[W]=(F?-$[L[W]]:$[L[W]])+B[W];R.push(K)}let y=0,E=1/0,x=[],T=[];for(let M=0;M<4;M++){let N=1/0,F=-1/0,U=R[M];for(let D=0;D<r;D++){let I=i[D]/2;U[D]-I<N&&(N=U[D]-I),U[D]+I>F&&(F=U[D]+I)}x.push(N),T.push(F),F-N<E&&(E=F-N,y=M)}for(let M=0;M<4;M++){let N=M&1?T[y]-T[M]:x[y]-x[M];if(N!==0){let F=R[M];for(let U=0;U<r;U++)F[U]+=N}}let A=new Float64Array(r);for(let M=0;M<r;M++){let N=R[0][M],F=R[1][M],U=R[2][M],D=R[3][M],I;N>F&&(I=N,N=F,F=I),U>D&&(I=U,U=D,D=I),N>U&&(I=N,N=U,U=I),F>D&&(I=F,F=D,D=I),F>U&&(I=F,F=U,U=I),A[M]=(F+U)/2}return A}function Mo(){let e=new Map;return{add(t,r,a){let i=gt(a);r>=0&&i>0&&i+js>(e.get(t*4+r)??0)&&e.set(t*4+r,i+js)},of:(t,r)=>r>=0?e.get(t*4+r)??0:0}}function zr(e,t,r,a,i=r>0?r+js:0,n=a>0?a+js:0){let l=t==="linear",s=t==="step"||t==="stepBefore"||t==="stepAfter",o=[],c=[],f=[],p=(y,E,x,T)=>Math.abs(y-x)<.01&&Math.abs(E-T)<.01;for(let y=0;y<e.length;y+=3){let E=e[y],x=e[y+1],T=e[y+2],A=o.length-1;if(s&&A>=0&&Math.abs(E-o[A])>=.01&&Math.abs(x-c[A])>=.01){let M=o[A],N=c[A],F=t==="stepBefore"?N:t==="stepAfter"?x:(N+x)/2,U=t==="stepBefore"?M:t==="stepAfter"?E:(M+E)/2,D=T===0?[M,F,E,F]:[U,N,U,x];for(let I=0;I<4;I+=2)p(D[I],D[I+1],M,N)||p(D[I],D[I+1],E,x)||(o.push(D[I]),c.push(D[I+1]),f.push(T))}o.push(E),c.push(x),f.push(T)}let h=o.length-1,g=y=>Math.abs(o[y]-o[y-1])<.01||Math.abs(c[y]-c[y-1])<.01,u=y=>l||g(y),m=(y,E,x)=>{if(!u(Math.max(y,E)))return x===0?[0,Math.sign(c[E]-c[y])||1]:[Math.sign(o[E]-o[y])||1,0];let T=o[E]-o[y],A=c[E]-c[y],M=Math.hypot(T,A)||1;return[T/M,A/M]},[b,w]=m(0,1,f[1]),[v,k]=m(h-1,h,f[h]),O=o[0],R=c[0],L=o[h],P=c[h];o[0]+=b*r,c[0]+=w*r,o[h]-=v*a,c[h]-=k*a;let B=y=>Math.abs(o[y]-o[y-1])+Math.abs(c[y]-c[y-1]),G=y=>!l&&y>0&&y<h&&g(y)&&g(y+1)&&B(y)>=.01&&B(y+1)>=.01&&Math.abs(o[y]-o[y-1])<.01!=Math.abs(o[y+1]-o[y])<.01,C=(y,E,x)=>Math.abs(o[y]-o[y-1])*Math.abs(E)+Math.abs(c[y]-c[y-1])*Math.abs(x),Z=(y,E,x)=>{let T=Math.min(Math.max(0,y-js-E),x/4);return T+Math.min(y-E-T,(x-T)/4)},ee=n>a&&(!u(h)||G(h-1))?Z(n,a,C(h,v,k)):0,H=i>r&&(!u(1)||G(1))?Z(i,r,C(1,b,w)):0;ee>=1&&(o.splice(h,0,o[h]-v*ee),c.splice(h,0,c[h]-k*ee),f.splice(h,0,f[h]),h++),H>=1&&(o.splice(1,0,o[0]+b*H),c.splice(1,0,c[0]+w*H),f.splice(1,0,f[1]),h++);let Y=`M${d(o[0])},${d(c[0])}`,_=o[0],S=c[0],$=(y,E)=>{p(y,E,_,S)||(Y+=`L${d(y)},${d(E)}`,_=y,S=E)};for(let y=1;y<=h;y++){let E=o[y],x=c[y];if(!u(y)){let D=f[y]===0,I=D?x-S:E-_,z=Math.abs(I)*Ks(D?E-_:x-S,I),q=D?0:Math.sign(I)*z,j=D?Math.sign(I)*z:0;Y+=`C${d(_+q)},${d(S+j)} ${d(E-q)},${d(x-j)} ${d(E)},${d(x)}`,_=E,S=x;continue}if(!G(y)){if(y<h&&g(y)&&g(y+1)&&(E-o[y-1])*(o[y+1]-E)+(x-c[y-1])*(c[y+1]-x)>0)continue;$(E,x);continue}let T=G(y-1)?B(y)/2:B(y),A=G(y+1)?B(y+1)/2:B(y+1);s&&(T=A=Math.min(iv,T,A));let[M,N]=m(y-1,y,f[y]),[F,U]=m(y,y+1,f[y+1]);$(E-M*T,x-N*T),_=E+F*A,S=x+U*A,s?Y+=`Q${d(E)},${d(x)} ${d(_)},${d(S)}`:Y+=`C${d(E-M*T*(1-bo))},${d(x-N*T*(1-bo))} ${d(E+F*A*(1-bo))},${d(x+U*A*(1-bo))} ${d(_)},${d(S)}`}return{d:Y,sx:O,sy:R,sdx:-b,sdy:-w,ex:L,ey:P,edx:v,edy:k}}function gt(e){return e==="arrow_point"?Yt-1:e==="arrow_circle"?Yt:e==="arrow_cross"?4:0}function bt(e,t,r,a,i,n){let l=-i,s=a;if(e==="arrow_point"){let o=t-a*Yt,c=r-i*Yt,f=Yt*.42;return`<path class="pele-marker" d="M${d(t)},${d(r)}L${d(o+l*f)},${d(c+s*f)}L${d(o-l*f)},${d(c-s*f)}Z" fill="${n}" stroke="none"/>`}if(e==="arrow_circle")return`<circle class="pele-marker" cx="${d(t-a*4)}" cy="${d(r-i*4)}" r="3.5" fill="${n}" stroke="none"/>`;if(e==="arrow_cross"){let o=t-a*4,c=r-i*4,f=3.5,p=(a+l)*f,h=(i+s)*f,g=(a-l)*f,u=(i-s)*f;return`<path class="pele-marker" d="M${d(o-p)},${d(c-h)}L${d(o+p)},${d(c+h)}M${d(o-g)},${d(c-u)}L${d(o+g)},${d(c+u)}"/>`}return""}function wr(e,t,r,a,i,n){let l=t.width+8,s=t.height;return`<g class="pele-edge-label" data-id="${Oe(e)}"><rect x="${d(r-l/2)}" y="${d(a-s/2)}" width="${d(l)}" height="${d(s)}" rx="3" fill="var(--_bg)"/>`+Re(t,r,a,i,n)+"</g>"}function Ao(e,t,r,a,i,n,l,s){let o=(i?t:r)/2,c=Math.min(o-4,8+a*6),f=n+a*8,p=Math.hypot(f,c)||1,h=(m,b)=>i?`${d(e.x+b)},${d(e.y+r/2+m)}`:`${d(e.x+t/2+m)},${d(e.y+b)}`,g=f/p*l,u=c/p*l;return i?(s.labelX=e.x,s.labelY=e.y+r/2+f+4+s.labelH/2):(s.labelX=e.x+t/2+f+4+s.labelW/2,s.labelY=e.y),{d:`M${h(0,-c)}C${h(f,-c*2)} ${h(f,c*2)} ${h(g,c+u)}`,sx:i?e.x-c:e.x+t/2,sy:i?e.y+r/2:e.y-c,sdx:i?0:-1,sdy:i?-1:0,ex:i?e.x+c:e.x+t/2,ey:i?e.y+r/2:e.y+c,edx:i?-c/p:-f/p,edy:i?-f/p:-c/p}}var OA,F0,kd,W0,PA,B0,zA,FA,WA,BA,YA,Y0,HA,UA,qA,H0,qa,U0,GA,q0,Yn,bd,$d,Yt,iv,bo,js,pr=Xe(()=>{ut();OA=24,F0=2e4,kd=16,W0=8,PA=.125,B0=3,zA=18,FA=10,WA=14,BA=2,YA=28,Y0=12,HA=12,UA=8,qA=4,H0=.5,qa=.5,U0=12,GA=40,q0=400,Yn=16,bd=new Float64Array(2*Yn+2),$d=new Float64Array(2*Yn+2);Yt=8,iv=12,bo=.62,js=6});function br(e){return e==="BT"||e==="LR"||e==="RL"?e:"TB"}function K0(e,t,r,a){let i=[];for(let s of e)i.push(s.x,s.y,s.w,s.h);let n=[];for(let s of t)n.push(s.labelX,s.labelY);let l=[];for(let s of r){l.push(s.x,s.y);for(let o of s.ports)l.push(o.px,o.py)}return{nodes:i,routes:t.map(s=>s.route),labels:n,levels:l,total:a}}function Z0(e,t,r,a){t.forEach((n,l)=>{n.x=e.nodes[4*l],n.y=e.nodes[4*l+1],n.w=e.nodes[4*l+2],n.h=e.nodes[4*l+3]}),r.forEach((n,l)=>{n.route=e.routes[l],n.labelX=e.labels[2*l],n.labelY=e.labels[2*l+1]});let i=0;for(let n of a){n.x=e.levels[i++],n.y=e.levels[i++];for(let l of n.ports)l.px=e.levels[i++],l.py=e.levels[i++]}return e.total}function fv(e){return e.tracks?1:e.straight?2:0}function Eo(e,t,r=0){let a=0;for(let _ of t)_.src!==_.dst&&_.route.length>3&&(a+=(_.route.length/3-1)*hv);let i=new Float64Array(a),n=new Float64Array(a),l=new Float64Array(a),s=new Float64Array(a),o=new Float64Array(a),c=new Float64Array(a),f=new Int32Array(a),p=new Uint8Array(a),h=0,g=1/0,u=-1/0,m=NaN,b=NaN,w=NaN,v=NaN,k=(_,S,$,y,E,x)=>{let T=h-1;$===w&&y===v&&(x===y&&b===y||E===$&&m===$)&&f[T]===_&&p[T]===S&&($-m)*(E-$)+(y-b)*(x-y)>0&&(h--,$=m,y=b),m=$,b=y,w=E,v=x,p[h]=S,i[h]=Math.min($,E),l[h]=Math.max($,E),n[h]=$<=E?y:x,s[h]=$<=E?x:y,o[h]=Math.min(y,x),c[h]=Math.max(y,x),o[h]<g&&(g=o[h]),c[h]>u&&(u=c[h]),f[h++]=_};for(let _=0;_<t.length;_++){let S=t[_];if(S.src===S.dst)continue;let $=S.route,y=M=>Math.abs($[M]-$[M-3])<.01||Math.abs($[M+1]-$[M-2])<.01,E=M=>Math.abs($[M]-$[M-3])+Math.abs($[M+1]-$[M-2]),x=M=>r===0&&M>0&&M<$.length-3&&y(M)&&y(M+3)&&E(M)>=.01&&E(M+3)>=.01&&Math.abs($[M]-$[M-3])<.01!=Math.abs($[M+3]-$[M])<.01,T=$[0],A=$[1];for(let M=3;M<$.length;M+=3){let N=(M===3?1:0)|(M===$.length-3?2:0),F=T,U=A,D=$[M],I=$[M+1];if(T=D,A=I,y(M)||r===2){if(!x(M)){k(_,N,F,U,D,I);continue}let K=x(M-3)?E(M)/2:E(M),W=x(M+3)?E(M+3)/2:E(M+3),X=(D-$[M-3])/E(M),te=(I-$[M-2])/E(M),se=($[M+3]-D)/E(M+3),oe=($[M+4]-I)/E(M+3),ae=D-X*K,ne=I-te*K;k(_,N,F,U,ae,ne);let J=D-X*K*(1-vo),re=I-te*K*(1-vo),fe=D+se*W*(1-vo),ye=I+oe*W*(1-vo);T=D+se*W,A=I+oe*W;let le=N|(M+3===$.length-3?2:0),we=ae,pe=ne;for(let ge=1;ge<=Ad;ge++){let Ae=ge/Ad,Se=1-Ae,ce=Se*Se*Se*ae+3*Se*Se*Ae*J+3*Se*Ae*Ae*fe+Ae*Ae*Ae*T,ue=Se*Se*Se*ne+3*Se*Se*Ae*re+3*Se*Ae*Ae*ye+Ae*Ae*Ae*A;k(_,le,we,pe,ce,ue),we=ce,pe=ue}continue}if(r===1){let K=$[M+2]===0,W=K?F:(F+D)/2,X=K?(U+I)/2:U;k(_,N,F,U,W,X),k(_,N,W,X,K?D:W,K?X:I),k(_,N,K?D:W,K?X:I,D,I);continue}let z=$[M+2]===0,q=z?Ks(D-F,I-U):Ks(I-U,D-F),j=F,Q=U;for(let K=1;K<=Md;K++){let W=K/Md,X=1-W,te=W*W*(3-2*W),se=3*q*W*X*X+3*(1-q)*W*W*X+W*W*W,oe=F+(D-F)*(z?te:se),ae=U+(I-U)*(z?se:te);k(_,N,j,Q,oe,ae),j=oe,Q=ae}}}let O=u>g?Math.round(Math.sqrt(h)):1,R=u>g?O/(u-g):0,L=_=>Math.min(O-1,Math.floor((_-g)*R)),P=new Int32Array(h),B=new Int32Array(O+1);for(let _=0;_<h;_++){P[_]=L(o[_]);for(let S=P[_],$=L(c[_]);S<=$;S++)B[S+1]++}for(let _=0;_<O;_++)B[_+1]+=B[_];let G=B.slice(0,O),C=new Int32Array(B[O]);for(let _=0;_<h;_++)for(let S=P[_],$=L(c[_]);S<=$;S++)C[G[S]++]=_;let Z=new Float64Array(t.length*8),ee=(_,S,$,y)=>Math.abs(_[S]-_[$])<Un&&Math.abs(_[S]-_[y])<Un||Math.abs(_[S+1]-_[$+1])<Un&&Math.abs(_[S+1]-_[y+1])<Un;for(let _=0;_<t.length;_++){let S=t[_].route;if(S.length<6)continue;let $=3;for(;$+3<S.length&&ee(S,0,$,$+3);)$+=3;let y=S.length-3,E=y-3;for(;E>=3&&ee(S,y,E,E-3);)E-=3;Z.set([S[0],S[1],S[$],S[$+1],S[E],S[E+1],S[y],S[y+1]],_*8)}let H=(_,S,$,y)=>{let E=_*8+(S===1?0:4),x=Z[E],T=Z[E+1],A=Z[E+2]-x,M=Z[E+3]-T,N=A*A+M*M,F=N>0?Math.max(0,Math.min(1,(($-x)*A+(y-T)*M)/N)):0;return Math.hypot($-x-F*A,y-T-F*M)<Un},Y=0;for(let _=0;_<O;_++){let S=B[_+1];if(S-B[_]>dv)C.subarray(B[_],S).sort(($,y)=>i[$]-i[y]||$-y);else for(let $=B[_]+1;$<S;$++){let y=C[$],E=$;for(;E>B[_]&&i[C[E-1]]>i[y];E--)C[E]=C[E-1];C[E]=y}for(let $=B[_];$<S;$++){let y=C[$],E=l[y]-i[y],x=s[y]-n[y],T=P[y]===_;for(let A=$+1;A<S;A++){let M=C[A];if(i[M]>l[y])break;if(c[M]<o[y]||o[M]>c[y]||f[y]===f[M]||!T&&P[M]!==_)continue;let N=E*(n[M]-n[y])-x*(i[M]-i[y]),F=E*(s[M]-n[y])-x*(l[M]-i[y]);if(N>0==F>0)continue;let U=l[M]-i[M],D=s[M]-n[M],I=U*(n[y]-n[M])-D*(i[y]-i[M]),z=U*(s[y]-n[M])-D*(l[y]-i[M]);if(I>0==z>0)continue;let q=t[f[y]],j=t[f[M]],Q=I/(I-z),K=i[y]+Q*E,W=n[y]+Q*x,X=(te,se,oe)=>(p[y]&se)!==0&&(p[M]&oe)!==0||Math.abs(K-e[te].x)<e[te].w/2+Q0&&Math.abs(W-e[te].y)<e[te].h/2+Q0||H(f[y],se,K,W)&&H(f[M],oe,K,W);q.src===j.src&&X(q.src,1,1)||q.src===j.dst&&X(q.src,1,2)||q.dst===j.src&&X(q.dst,2,1)||q.dst===j.dst&&X(q.dst,2,2)||Y++}}}return Y}function vi(e,t,r,a){for(let i of e)i.x+=r,i.y+=a;for(let i of t){for(let n=0;n<i.route.length;n+=3)i.route[n]+=r,i.route[n+1]+=a;i.labelX+=r,i.labelY+=a}}function Ut(e,t,r=-1){return{w:e,h:t,parent:r,isGroup:!1,dir:void 0,padX:0,padTop:0,padBottom:0,minW:0,seq:0,span:0,x:0,y:0}}function So(e){return e==="TB"?0:e==="BT"?2:e==="LR"?3:1}function Zs(e){return e+2&3}function Gr(e,t,r,a){let i=e.length,n=new Map,l=[],s=(S,$)=>{let y={id:S,dir:$,items:[],edges:[],ports:[],portOf:new Map,routes:new Map,x:0,y:0};return n.set(S,y),y},o=s(-1,r),c=[];for(let S=0;S<i;S++)c.push([]);let f=[];for(let S=0;S<i;S++){let $=e[S].parent;$>=0&&$<i&&$!==S&&e[$].isGroup?c[$].push(S):(e[S].parent=-1,f.push(S))}o.items=f,l.push(o);let p=new Int32Array(i),h=new Uint8Array(i),g=S=>{for(let $=S;$<l.length;$++){let y=l[$];for(let E of y.items)if(h[E]=1,p[E]=y.id<0?0:p[y.id]+1,e[E].isGroup){let x=s(E,e[E].dir??y.dir);x.items=c[E],l.push(x)}}};g(0);for(let S=0;S<i;S++){if(h[S])continue;let $=e[S].parent;if(c[$]=c[$].filter(y=>y!==S),e[S].parent=-1,o.items.push(S),h[S]=1,p[S]=0,e[S].isGroup){let y=l.length,E=s(S,e[S].dir??r);E.items=c[S],l.push(E),g(y)}}for(let S=l.length-1;S>0;S--){let $=l[S],y=1/0;for(let E of $.items)e[E].seq<y&&(y=e[E].seq);y!==1/0&&(e[$.id].seq=y)}for(let S of l)S.items.sort(($,y)=>e[$].seq-e[y].seq||$-y);let u=0;for(let S of t){let $=S.src,y=S.dst,E=0;for(;p[$]>p[y];E++)$=e[$].parent;for(;p[y]>p[$];E++)y=e[y].parent;for(;$!==y&&e[$].parent!==e[y].parent;E+=2)$=e[$].parent,y=e[y].parent;$!==y&&(u+E>nv?(S.src=$,S.dst=y):u+=E)}let m=[],b=[];for(let S=0;S<t.length;S++){let $=t[S];if($.route=[],$.src===$.dst){m.push(S);continue}let y=$.src,E=$.dst,x=[],T=[];for(;p[y]>p[E];)x.push(y),y=e[y].parent;for(;p[E]>p[y];)T.push(E),E=e[E].parent;if(y===E){b.push(S);continue}for(;e[y].parent!==e[E].parent;)x.push(y),T.push(E),y=e[y].parent,E=e[E].parent;n.get(e[y].parent).edges.push({e:S,a:y,b:E});for(let[A,M]of[[x,!0],[T,!1]])for(let N of A){let F=n.get(e[N].parent),U={e:S,inner:N,out:M,side:0,hint:NaN,px:0,py:0,route:[]};F.ports.push(U),F.portOf.set(S*2+(M?0:1),U)}}let w=new Int32Array(i),v=(S,$,y)=>(y?$.src:$.dst)!==S,k=(S,$)=>{let y=S.dir==="TB"||S.dir==="BT",E=So(S.dir),x=[],T=[];S.items.forEach((F,U)=>{w[F]=U;let D=e[F],I=$?Zi(y?D.w:D.h,y?D.h:D.w):Zi(0,0);I.span=D.isGroup?Math.min(D.span,I.w-2*D.padX):D.span,I.key=L?R[F]:NaN,x.push(I)});let A=(F,U,D)=>e[F].isGroup&&v(F,t[U],D),M=(F,U,D)=>{if(!$||!e[F].isGroup||!v(F,t[U],D))return 0;let I=n.get(F).portOf.get(U*2+(D?0:1));return y?I.px-e[F].w/2:I.py-e[F].h/2};for(let F of S.edges){let U=t[F.e],D=Qi(w[F.a],w[F.b],U.minlen);$&&(D.labelW=y?U.labelW:U.labelH,D.labelH=y?U.labelH:U.labelW,D.tailDx=M(F.a,F.e,!0),D.headDx=M(F.b,F.e,!1),D.tailFixed=A(F.a,F.e,!0),D.headFixed=A(F.b,F.e,!1)),T.push(D)}let N=new Int32Array(S.ports.length).fill(-1);return S.ports.forEach((F,U)=>{if(F.side===E||F.side===Zs(E)){let D=x.length,I=Zi(0,0,F.side===E?3:4);I.key=L?R[F.out?t[F.e].dst:t[F.e].src]:NaN,I.hint=Number.isNaN(F.hint)&&L&&B?B(S,F):F.hint,x.push(I),N[U]=D;let z=F.out?Qi(w[F.inner],D):Qi(D,w[F.inner]);F.out?(z.tailDx=M(F.inner,F.e,!0),z.tailFixed=A(F.inner,F.e,!0)):(z.headDx=M(F.inner,F.e,!1),z.headFixed=A(F.inner,F.e,!1)),T.push(z)}else x[w[F.inner]].pin=F.side===0||F.side===3?-1:1}),{lnodes:x,ledges:T,dummies:N}},O=u>1&&u<=sv&&t.length<=lv,R=new Float64Array(i).fill(NaN),L=!1,P=0,B,G=l.length>1&&O;for(let S of l)S.dir!==r&&(G=!1);if(G){let S=r==="TB"||r==="BT",$=new Int32Array(i).fill(-1),y=new Int32Array(i).fill(-1),E=[],x=[],T=[];for(let I=0;I<i;I++)e[I].isGroup&&(y[I]=T.length,T.push(-1));for(let I=0;I<i;I++){let z=e[I].parent;e[I].isGroup?T[y[I]]=z>=0?y[z]:-1:($[I]=E.length,E.push(Zi(S?e[I].w:e[I].h,S?e[I].h:e[I].w)),x.push(z>=0?y[z]:-1))}let A=[],M=new Int32Array(t.length).fill(-1);t.forEach((I,z)=>{I.src===I.dst||$[I.src]<0||$[I.dst]<0||(M[z]=A.length,A.push(Qi($[I.src],$[I.dst],I.minlen,S?I.labelW:I.labelH,S?I.labelH:I.labelW)))});let N=ko(E,A,{...a,groups:{of:Int32Array.from(x),parent:Int32Array.from(T)},orderOnly:!0});P=Math.min(N.crossings??0,N.declared??0);let F=new Float64Array(i),U=new Int32Array(i),D=new Int32Array(i).fill(-1);for(let I=0;I<i;I++)if(!($[I]<0)){R[I]=E[$[I]].x;for(let z=e[I].parent;z>=0;z=e[z].parent)F[z]+=R[I],U[z]++,D[z]=Math.max(D[z],E[$[I]].rank)}for(let I=0;I<i;I++)U[I]>0&&(R[I]=F[I]/U[I]);B=(I,z)=>{let q=M[z.e];if(q<0||I.id<0||!z.out||z.side!==Zs(So(I.dir)))return NaN;let j=A[q].points,Q=R[t[z.e].src],K=0;for(let W=0;W<j.length;W+=2)j[W]===D[I.id]&&(Q=j[W+1]),j[W]===D[I.id]+1&&(K=j[W+1]);return Q+K*1e-6}}let C=new Map,Z=(S,$,y)=>{if(!O)return{lnodes:$,ledges:y,size:ko($,y,a)};let E=[];for(let A of $)E.push(A.w,A.h,A.kind,A.pin,A.hint,A.key,A.span);for(let A of y)E.push(A.tail,A.head,A.minlen,A.labelW,A.labelH,A.tailDx,A.headDx,+A.tailFixed,+A.headFixed);let x=C.get(S.id);x||C.set(S.id,x=[]);for(let A of x){let M=A.given.length===E.length;for(let N=0;M&&N<E.length;N++)M=Object.is(A.given[N],E[N]);if(M)return A}let T={given:E,lnodes:$,ledges:y,size:ko($,y,a)};return x.push(T),T},ee={width:0,height:0},H=()=>{for(let $ of l){for(let A of $.ports)e[A.inner].isGroup&&v(A.inner,t[A.e],A.out)&&(n.get(A.inner).portOf.get(A.e*2+(A.out?0:1)).side=A.side);if($.edges.length===0)continue;let y=!1;for(let A of $.edges){let M=t[A.e];(e[A.a].isGroup&&M.src!==A.a||e[A.b].isGroup&&M.dst!==A.b)&&(y=!0)}if(!y)continue;let{lnodes:E,ledges:x}=k($,!1);Xs(E,x),Vs(E,x,1);let T=So($.dir);$.edges.forEach((A,M)=>{let N=t[A.e],F=!x[M].reversed;e[A.a].isGroup&&N.src!==A.a&&(n.get(A.a).portOf.get(A.e*2).side=F?Zs(T):T),e[A.b].isGroup&&N.dst!==A.b&&(n.get(A.b).portOf.get(A.e*2+1).side=F?T:Zs(T))})}for(let $=l.length-1;$>=0;$--){let y=l[$],E=y.id>=0?e[y.id]:void 0,x=y.dir==="TB"||y.dir==="BT",T=y.dir==="BT"||y.dir==="RL",A=k(y,!0),{lnodes:M,ledges:N,size:F}=Z(y,A.lnodes,A.ledges),U=A.dummies,D=x?F.width:F.height,I=x?F.height:F.width,z=E?E.padX:0,q=E?E.padTop:0,j=Math.max(D+2*z,E?E.minW:0),Q=I+q+(E?E.padBottom:0),K=(j-D)/2,W=q,X=(ne,J)=>K+(x?ne:T?F.height-J:J),te=(ne,J)=>W+(x?T?F.height-J:J:ne),se=x?0:1,oe=ne=>{let J=[];for(let re=0;re<ne.length;re+=2)J.push(X(ne[re],ne[re+1]),te(ne[re],ne[re+1]),se);return J};y.items.forEach((ne,J)=>{e[ne].x=X(M[J].x,M[J].y),e[ne].y=te(M[J].x,M[J].y)}),y.edges.forEach((ne,J)=>{let re=N[J];y.routes.set(ne.e,oe(re.points));let fe=t[ne.e];fe.labelW>0&&(fe.labelX=X(re.labelX,re.labelY),fe.labelY=te(re.labelX,re.labelY))});let ae=y.edges.length;y.ports.forEach((ne,J)=>{let re=e[ne.inner];if(U[J]>=0){let ge=oe(N[ae++].points),Ae=ne.out?ge.length-3:0,Se=ge[Ae],ce=ge[Ae+1];ne.side===0?ce=0:ne.side===2?ce=Q:ne.side===3?Se=0:Se=j,ne.out?ge.push(Se,ce,se):ge.unshift(Se,ce,se),ne.px=Se,ne.py=ce,ne.route=ge;return}let fe=re.x,ye=re.y;if(re.isGroup&&v(ne.inner,t[ne.e],ne.out)){let ge=n.get(ne.inner).portOf.get(ne.e*2+(ne.out?0:1));fe+=ge.px-re.w/2,ye+=ge.py-re.h/2}else ne.side===0?ye-=re.h/2:ne.side===2?ye+=re.h/2:ne.side===3?fe-=re.w/2:fe+=re.w/2;let le=fe,we=ye;ne.side===0?we=0:ne.side===2?we=Q:ne.side===3?le=0:le=j;let pe=ne.side===0||ne.side===2?0:1;ne.px=le,ne.py=we,ne.route=ne.out?[fe,ye,pe,le,we,pe]:[le,we,pe,fe,ye,pe]}),E?(E.w=j,E.h=Q):ee={width:j,height:Q}}for(let $ of l){let y=$.x,E=$.y;for(let x of $.items){let T=e[x];if(T.x+=y,T.y+=E,T.isGroup){let A=n.get(x);A.x=T.x-T.w/2,A.y=T.y-T.h/2}}}let S=($,y,E,x)=>{for(let T=0;T<y.length;T+=3){let A=y[T]+E,M=y[T+1]+x,N=$.length;N>=3&&Math.abs($[N-3]-A)<.01&&Math.abs($[N-2]-M)<.01||$.push(A,M,y[T+2])}};for(let $ of l)for(let y of $.edges){let E=t[y.e],x=[],T=[];for(let M=E.src;e[M].parent!==$.id;M=e[M].parent)T.push(n.get(e[M].parent));for(let M of T)S(x,M.portOf.get(y.e*2).route,M.x,M.y);S(x,$.routes.get(y.e),$.x,$.y);let A=[];for(let M=E.dst;e[M].parent!==$.id;M=e[M].parent)A.push(n.get(e[M].parent));for(let M=A.length-1;M>=0;M--)S(x,A[M].portOf.get(y.e*2+1).route,A[M].x,A[M].y);E.route=x,E.labelW>0&&(E.labelX+=$.x,E.labelY+=$.y)}},Y=fv(a);L=G,H();let _=-1;if(G&&(_=Eo(e,t,Y),_>P*ov+cv)){let S=K0(e,t,l,ee);L=!1,H();let $=Eo(e,t,Y);$>=_?(L=!0,ee=Z0(S,e,t,l)):_=$}if(L===G&&O){let S=!1;for(let $ of l){if($.id<0)continue;let y=e[$.id],E=$.dir==="TB"||$.dir==="BT",x=Zs(So($.dir)),T=[];for(let A of $.ports){if(A.side!==x)continue;let M=t[A.e].route,N=$.x+A.px,F=$.y+A.py,U=-1;for(let z=0;z<M.length&&(U<0||A.out);z+=3)Math.abs(M[z]-N)<.01&&Math.abs(M[z+1]-F)<.01&&(U=z);if(U<0)continue;let D=E?0:1,I=A.out?U+3:U-3;for(;I>=0&&I<M.length&&Math.abs(M[I+D]-M[U+D])<Un;)I+=A.out?3:-3;I<0||I>=M.length||(A.hint=M[I+D]-(E?y.x-y.w/2:y.y-y.h/2),T.push([E?A.px:A.py,A.hint]))}T.sort((A,M)=>A[0]-M[0]);for(let A=1;A<T.length;A++)T[A-1][1]>T[A][1]&&(S=!0)}if(S){let $=_>=0?_:Eo(e,t,Y),y=$>0?K0(e,t,l,ee):void 0;y&&(H(),Eo(e,t,Y)>=$&&(ee=Z0(y,e,t,l)))}}for(let S of b){let $=t[S],y=e[$.src],E=e[$.dst];$.route=[y.x,y.y,0,E.x,E.y,0],$.labelX=(y.x+E.x)/2,$.labelY=(y.y+E.y)/2}for(let S of m){let $=t[S],y=e[$.src];$.labelX=y.x+y.w/2+28+$.labelW/2,$.labelY=y.y}return ee}var nv,sv,lv,ov,cv,Q0,Un,Md,Ad,hv,vo,dv,Ei=Xe(()=>{pr();nv=4e4,sv=400,lv=500,ov=1.5,cv=4;Q0=24,Un=.5,Md=3,Ad=2,hv=Math.max(3,Md,Ad+1),vo=.62,dv=128});function Cr(e,t,r,a){return y0(()=>ze(e,!1,t,r,a,1))}function To(e,t,r,a,i,n,l){let s=Cr(e,t,r,4e3);if(s.height===0)return{width:i,height:n,content:l};let o=s.height+12,c=Math.max(i,Math.ceil(s.width+2*a));return{width:c,height:Math.ceil(n+o),content:Re(s,c/2,a+s.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${d((c-i)/2)},${d(o)})">${l}</g>`}}var Ea=Xe(()=>{ut();wt()});function r1(e){try{return decodeURIComponent(e)}catch{return e}}function Sa(e){if(!e)return Qs;let t=r1(e.trim()),r,a=0;do{if(++a>32)return Qs;t=t.replace(vd,"").replace(J0,(o,c)=>String.fromCharCode(c)).replace(e1,"").replace(vd,"").replace(t1,"").trim(),t=r1(t),r=t.match(vd)||t.match(J0)||t.match(e1)||t.match(t1)}while(r&&r.length>0);if(!t)return Qs;if(t[0]==="."||t[0]==="/")return t;let i=t.trimStart(),n=i.match(uv);if(!n)return t;let l=n[0].toLowerCase().trim();if(pv.test(l))return Qs;let s=i.replace(/\\/g,"/");if(l==="mailto:"||l.includes("://"))return s;if(l==="http:"||l==="https:"){let o;try{o=new URL(s)}catch{return Qs}return o.protocol=o.protocol.toLowerCase(),o.hostname=o.hostname.toLowerCase(),o.toString()}return s}function Ta(e){return Sa(At(e))}function a1(e,t){if(xv.test(e))return;let r=yv.exec(e);return!r||t.includes(r[1].toLowerCase())?e:void 0}function oi(e,t){return t.links===!1?void 0:a1(e,t.linkSchemes??gv)}function i1(e,t){return t.images===!1?void 0:a1(e,t.imageSchemes??mv)}function ua(e,t,r,a,i,n=""){let l=oi(t,i);return l===void 0?e:(a.push({id:r,href:l,internal:!1}),`<a href="${Ve(l)}"${n}${ci(i)}>${e}</a>`)}function ci(e){let t=e.linkRel??"noopener";return t?` rel="${Ve(t)}"`:""}var Qs,pv,J0,e1,vd,uv,t1,gv,mv,yv,xv,hi=Xe(()=>{ut();wt();Qs="about:blank",pv=/^([^\w]*)(javascript|data|vbscript)/im,J0=/&#(\w+)(^\w|;)?/g,e1=/&(newline|tab);/gi,vd=/[\u0000-\u001F\u007F-\u009F -‍]/gim,uv=/^.+(:|&colon;)/gim,t1=/(\\|%5[cC])((%(6[eE]|72|74))|[nrt])/g;gv=["http","https","mailto","tel"],mv=["http","https"],yv=/^([a-z][a-z0-9+.-]*):/i,xv=/^[\\/]{2}/});function No(e,t,r){let a=Math.min(1,Math.abs(e)/t);return r*(1-Math.sqrt(1-a*a))}function s1(e,t,r){let a=Math.max(1.6*e+40,80),i=(t+10)/(1-(e+8)/a),n=i/2-10-t/2;return{w:a,h:i,dy:r?-n:n}}function qn(e,t){return`<path d="${e}"${t}/>`}function Fr(e,t){let r="";for(let a=0;a<e.length;a+=2)r+=(a?" ":"")+d(e[a])+","+d(e[a+1]);return`<polygon points="${r}"${t}/>`}function Ir(e,t,r,a=""){return`<rect x="${d(-e/2)}" y="${d(-t/2)}" width="${d(e)}" height="${d(t)}"${a}${r}/>`}function _o(e,t,r,a){let i=t/2,n=6*r;return`<path d="M${d(e)},${d(-i)}q${d(n)},0 ${d(n)},6V-6q0,6 ${d(n)},6q${d(-n)},0 ${d(-n)},6V${d(i-6)}q0,6 ${d(-n)},6" fill="none"${a}/>`}function Io(e,t,r){let a=e/2,i=-t/2,n=t/2-10,l=e/4;return`<path d="M${d(-a)},${d(i)}H${d(a)}V${d(n)}q${d(-l)},-12 ${d(-2*l)},0t${d(-2*l)},0Z"${r}/>`}function Si(e,t,r){return(tl.get(e)??o1).size(t,r)}function Ca(e,t,r,a,i){return(tl.get(e)??o1).draw(t,r,a,i)}function di(e,t,r,a,i=0){return tl.get(e)?.inset?.(t,r,a,i)??0}function c1(e,t,r,a){return Math.max(0,tl.get(e)?.span?.(t,r,a)??0)}function h1(e){return tl.get(e)?.noLabel!==!0}function ga(e,t,r){let a=e[t]-r.x,i=e[t+1]-r.y;return Math.abs(Math.abs(i)-r.h/2)<.5?i<0?0:2:Math.abs(Math.abs(a)-r.w/2)<.5?a<0?3:1:-1}function rn(e,t,r,a){if(a.isGroup)return;let i=ga(e,t,a);if(i===0||i===2){let n=di(r.shape,r.w,r.h,i,e[t]-a.x)+(a.h-r.h)/2;e[t+1]+=i===0?n:-n}else if(i>=0){let n=di(r.shape,r.w,r.h,i,e[t+1]-a.y)+(a.w-r.w)/2;e[t]+=i===3?n:-n}}var mt,$t,Gn,na,Js,Ji,en,n1,tn,Co,el,l1,o1,tl,Ti=Xe(()=>{ut();mt=18,$t=12,Gn=12,na=(e,t,r)=>(r?t:e)-2*Gn,Js=e=>(t,r,a)=>a?0:t-2*e(r)-2*Gn;Ji=(e,t,r,a)=>r&1?No(a,t/2,e/2):No(a,e/2,t/2),en=(e,t,r)=>(r?t:e)*.6,n1=(e,t,r,a)=>r&1?0:No(a,e/2,Math.min(12,Math.max(6,e/14))),tn=(e,t)=>()=>({w:e,h:t,dy:0});Co=(e,t,r)=>r&1?t/8:0,el=(e,t)=>({w:Math.max(e+2*mt,2*mt+12),h:t+2*$t,dy:0});l1={rect:{size:el,span:na,draw:(e,t,r)=>Ir(e,t,ft(r))},rounded:{size:el,span:na,draw:(e,t,r)=>Ir(e,t,r,` rx="${d(Math.min(12,t/2))}"`)},stadium:{inset:(e,t,r,a)=>r&1?No(a,t/2,t/2):0,span:(e,t,r)=>r?t*.6:e-t,size:(e,t)=>{let r=t+2*$t;return{w:e+r*.5+2*mt-8,h:r,dy:0}},draw:(e,t,r)=>Ir(e,t,r,` rx="${d(t/2)}"`)},"fr-rect":{span:na,size:(e,t)=>({w:e+2*mt+16,h:t+2*$t,dy:0}),draw:(e,t,r,a)=>{let i=e/2-8;return Ir(e,t,ft(r))+`<path d="M${d(-i)},${d(-t/2)}V${d(t/2)}M${d(i)},${d(-t/2)}V${d(t/2)}" fill="none"${a}/>`}},cyl:{inset:n1,span:(e,t,r)=>r?t-2*Gn-12:e*.6,size:(e,t)=>{let r=Math.max(e+2*mt,56),a=Math.min(12,Math.max(6,r/14));return{w:r,h:t+2*$t+2*a,dy:a/2}},draw:(e,t,r,a)=>{let i=e/2,n=Math.min(12,Math.max(6,e/14)),l=-t/2+n,s=t/2-n;return`<path d="M${d(-i)},${d(l)}A${d(i)},${d(n)} 0 0 1 ${d(i)},${d(l)}V${d(s)}A${d(i)},${d(n)} 0 0 1 ${d(-i)},${d(s)}Z"${r}/><path d="M${d(-i)},${d(l)}A${d(i)},${d(n)} 0 0 0 ${d(i)},${d(l)}" fill="none"${a}/>`}},circle:{inset:Ji,span:en,size:(e,t)=>{let r=Math.max(Math.sqrt(e*e+t*t)+16,44);return{w:r,h:r,dy:0}},draw:(e,t,r)=>`<circle r="${d(e/2)}"${r}/>`},"dbl-circ":{inset:Ji,span:en,size:(e,t)=>{let r=Math.max(Math.sqrt(e*e+t*t)+26,54);return{w:r,h:r,dy:0}},draw:(e,t,r,a)=>`<circle r="${d(e/2)}"${r}/><circle r="${d(e/2-5)}" fill="none"${a}/>`},ellipse:{inset:Ji,span:en,size:(e,t)=>({w:e*1.3+2*mt,h:t*1.2+2*$t,dy:0}),draw:(e,t,r)=>`<ellipse rx="${d(e/2)}" ry="${d(t/2)}"${r}/>`},diam:{inset:(e,t,r,a)=>r&1?Math.abs(a)*e/t:Math.abs(a)*t/e,span:(e,t,r)=>(r?t:e)*.6,size:(e,t)=>{let r=e+16,a=t+8;return{w:r+1.6*a,h:r/1.6+a,dy:0}},draw:(e,t,r)=>Fr([0,-t/2,e/2,0,0,t/2,-e/2,0],r)},hex:{inset:(e,t,r,a)=>r&1?Math.abs(a)/2:0,span:(e,t,r)=>r?t*.5:e-t/2-Gn,size:(e,t)=>{let r=t+2*$t;return{w:e+2*mt+r/2,h:r,dy:0}},draw:(e,t,r)=>{let a=t/4;return Fr([-e/2+a,-t/2,e/2-a,-t/2,e/2,0,e/2-a,t/2,-e/2+a,t/2,-e/2,0],r)}},odd:{inset:(e,t,r)=>r===3?t/4:0,span:Js(()=>0),size:(e,t)=>{let r=t+2*$t;return{w:e+2*mt+r/4,h:r,dy:0}},draw:(e,t,r)=>{let a=t/4;return Fr([-e/2,-t/2,e/2,-t/2,e/2,t/2,-e/2,t/2,-e/2+a,0],r)}},"lean-r":{inset:Co,span:Js(e=>e/4),size:(e,t)=>{let r=t+2*$t;return{w:e+2*mt+r/2,h:r,dy:0}},draw:(e,t,r)=>{let a=t/4;return Fr([-e/2+a,-t/2,e/2,-t/2,e/2-a,t/2,-e/2,t/2],r)}},"lean-l":{inset:Co,span:Js(e=>e/4),size:(e,t)=>{let r=t+2*$t;return{w:e+2*mt+r/2,h:r,dy:0}},draw:(e,t,r)=>{let a=t/4;return Fr([-e/2,-t/2,e/2-a,-t/2,e/2,t/2,-e/2+a,t/2],r)}},"trap-b":{inset:Co,span:Js(e=>e/4),size:(e,t)=>{let r=t+2*$t;return{w:e+2*mt+r/2,h:r,dy:0}},draw:(e,t,r)=>{let a=t/4;return Fr([-e/2+a,-t/2,e/2-a,-t/2,e/2,t/2,-e/2,t/2],r)}},"trap-t":{inset:Co,span:Js(e=>e/4),size:(e,t)=>{let r=t+2*$t;return{w:e+2*mt+r/2,h:r,dy:0}},draw:(e,t,r)=>{let a=t/4;return Fr([-e/2,-t/2,e/2,-t/2,e/2-a,t/2,-e/2+a,t/2],r)}},text:{span:na,size:(e,t)=>({w:e+8,h:t+8,dy:0}),draw:(e,t)=>Ir(e,t,' fill="none" stroke="none"')},"sm-circ":{noLabel:!0,inset:Ji,span:en,size:tn(14,14),draw:(e,t,r)=>`<circle r="${d(e/2)}"${r}/>`},"f-circ":{noLabel:!0,inset:Ji,span:en,size:tn(14,14),draw:(e,t,r,a)=>`<circle r="${d(e/2)}" fill="var(--_l)"${a}/>`},"fr-circ":{noLabel:!0,inset:Ji,span:en,size:tn(18,18),draw:(e,t,r,a)=>`<circle r="${d(e/2)}"${r}/><circle r="${d(e/2-4)}" fill="var(--_l)"${a}/>`},fork:{noLabel:!0,span:(e,t,r)=>(r?t:e)-8,size:tn(72,8),draw:(e,t,r,a)=>Ir(e,t,` fill="var(--_l)"${a}`,' rx="2"')},"notch-rect":{size:el,span:na,draw:(e,t,r)=>Fr([-e/2+10,-t/2,e/2,-t/2,e/2,t/2,-e/2,t/2,-e/2,-t/2+10],r)},"lin-rect":{span:na,size:(e,t)=>({w:e+2*mt+8,h:t+2*$t,dy:0}),draw:(e,t,r,a)=>Ir(e,t,ft(r))+`<path d="M${d(-e/2+8)},${d(-t/2)}V${d(t/2)}" fill="none"${a}/>`},"div-rect":{span:na,size:(e,t)=>({w:e+2*mt,h:t+2*$t+8,dy:4}),draw:(e,t,r,a)=>Ir(e,t,ft(r))+`<path d="M${d(-e/2)},${d(-t/2+8)}H${d(e/2)}" fill="none"${a}/>`},"win-pane":{span:na,size:(e,t)=>({w:e+2*mt+8,h:t+2*$t+8,dy:4}),draw:(e,t,r,a)=>Ir(e,t,ft(r))+`<path d="M${d(-e/2+8)},${d(-t/2)}V${d(t/2)}M${d(-e/2)},${d(-t/2+8)}H${d(e/2)}" fill="none"${a}/>`},tri:{inset:(e,t,r)=>r&1?e/4:0,size:(e,t)=>s1(e,t,!1),draw:(e,t,r)=>Fr([0,-t/2,e/2,t/2,-e/2,t/2],r)},"flip-tri":{inset:(e,t,r)=>r&1?e/4:0,size:(e,t)=>s1(e,t,!0),draw:(e,t,r)=>Fr([-e/2,-t/2,e/2,-t/2,0,t/2],r)},"sl-rect":{inset:(e,t,r)=>r===0?5:0,size:(e,t)=>({w:e+2*mt,h:t+2*$t+10,dy:5}),draw:(e,t,r)=>Fr([-e/2,-t/2+10,e/2,-t/2,e/2,t/2,-e/2,t/2],r)},"notch-pent":{span:na,size:(e,t)=>({w:e+2*mt,h:t+2*$t,dy:0}),draw:(e,t,r)=>Fr([-e/2+10,-t/2,e/2-10,-t/2,e/2,-t/2+10,e/2,t/2,-e/2,t/2,-e/2,-t/2+10],r)},hourglass:{noLabel:!0,inset:(e,t,r)=>r&1?e/2:0,size:tn(32,40),draw:(e,t,r)=>Fr([-e/2,-t/2,e/2,-t/2,-e/2,t/2,e/2,t/2],r)},delay:{size:(e,t)=>{let r=t+2*$t;return{w:e+2*mt+r/4,h:r,dy:0}},draw:(e,t,r)=>{let a=t/2;return`<path d="M${d(-e/2)},${d(-a)}H${d(e/2-a)}A${d(a)},${d(a)} 0 0 1 ${d(e/2-a)},${d(a)}H${d(-e/2)}Z"${r}/>`}},"h-cyl":{size:(e,t)=>{let r=t+2*$t,a=Math.min(12,r/4);return{w:e+2*mt+2*a,h:r,dy:0}},draw:(e,t,r,a)=>{let i=t/2,n=Math.min(12,t/4),l=-e/2+n,s=e/2-n;return`<path d="M${d(l)},${d(-i)}H${d(s)}A${d(n)},${d(i)} 0 0 1 ${d(s)},${d(i)}H${d(l)}A${d(n)},${d(i)} 0 0 1 ${d(l)},${d(-i)}Z"${r}/><path d="M${d(s)},${d(-i)}A${d(n)},${d(i)} 0 0 0 ${d(s)},${d(i)}" fill="none"${a}/>`}},"cross-circ":{noLabel:!0,inset:Ji,span:en,size:tn(44,44),draw:(e,t,r,a)=>{let i=e/2,n=i*Math.SQRT1_2;return`<circle r="${d(i)}"${r}/><path d="M${d(-n)},${d(-n)}L${d(n)},${d(n)}M${d(n)},${d(-n)}L${d(-n)},${d(n)}" fill="none"${a}/>`}},"st-rect":{span:(e,t,r)=>(r?t:e)-2*Gn-8,size:(e,t)=>({w:e+2*mt+8,h:t+2*$t+8,dy:4}),draw:(e,t,r)=>{let a=e-8,i=t-8,n="";for(let l=0;l<3;l++){let s=-e/2+(2-l)*4,o=-t/2+l*4;n+=`<rect x="${d(s)}" y="${d(o)}" width="${d(a)}" height="${d(i)}"${ft(r)}/>`}return n}},doc:{inset:(e,t,r)=>r===2?10:0,size:(e,t)=>({w:e+2*mt,h:t+2*$t+10,dy:-5}),draw:(e,t,r)=>Io(e,t,r)},flag:{inset:(e,t,r)=>r&1?0:8,size:(e,t)=>({w:e+2*mt,h:t+2*$t+16,dy:0}),draw:(e,t,r)=>{let a=e/2,i=t/2-8,n=e/4;return`<path d="M${d(-a)},${d(-i)}q${d(n)},-10 ${d(2*n)},0t${d(2*n)},0V${d(i)}q${d(-n)},10 ${d(-2*n)},0t${d(-2*n)},0Z"${r}/>`}},datastore:{size:el,span:na,draw:(e,t,r,a)=>Ir(e,t,r.replace('stroke="var(--_b)"','stroke="none"'))+`<path d="M${d(-e/2)},${d(-t/2)}H${d(e/2)}M${d(-e/2)},${d(t/2)}H${d(e/2)}" fill="none"${a}/>`},folder:{size:(e,t)=>({w:Math.max(e+2*mt,64),h:t+2*$t+8,dy:4}),draw:(e,t,r)=>{let a=e/2,i=t/2,n=Math.min(e*.4,48);return qn(`M${d(-a)},${d(-i)}H${d(-a+n)}L${d(-a+n+8)},${d(-i+8)}H${d(a)}V${d(i)}H${d(-a)}Z`,r)}},bucket:{size:(e,t)=>({w:e+2*mt+20,h:t+2*$t+10,dy:3}),inset:(e,t,r)=>r&1?t/12:0,draw:(e,t,r,a)=>{let i=e/2,n=t/2,l=5,s=t/6;return qn(`M${d(-i)},${d(-n+l)}A${d(i)},${d(l)} 0 0 1 ${d(i)},${d(-n+l)}L${d(i-s)},${d(n-l)}A${d(i-s)},${d(l)} 0 0 1 ${d(-i+s)},${d(n-l)}Z`,r)+`<path d="M${d(-i)},${d(-n+l)}A${d(i)},${d(l)} 0 0 0 ${d(i)},${d(-n+l)}" fill="none"${a}/>`}},console:{span:na,size:(e,t)=>({w:Math.max(e+2*mt,72),h:t+2*$t+12,dy:6}),draw:(e,t,r,a)=>Ir(e,t,ft(r))+`<path d="M${d(-e/2)},${d(-t/2+12)}H${d(e/2)}M${d(-e/2+7)},${d(-t/2+4)}l3,2.5l-3,2.5M${d(-e/2+13)},${d(-t/2+9)}h4" fill="none"${a}/>`},browser:{span:na,size:(e,t)=>({w:Math.max(e+2*mt,72),h:t+2*$t+12,dy:6}),draw:(e,t,r,a)=>{let i="";for(let n=0;n<3;n++)i+=`<circle cx="${d(-e/2+8+n*7)}" cy="${d(-t/2+6)}" r="1.5" fill="none"${a}/>`;return Ir(e,t,ft(r))+`<path d="M${d(-e/2)},${d(-t/2+12)}H${d(e/2)}" fill="none"${a}/>`+i}},person:{size:(e,t)=>({w:Math.max(e+2*mt,56),h:t+2*$t+26,dy:13}),draw:(e,t,r)=>{let a=-t/2;return`<rect x="${d(-e/2)}" y="${d(a+26)}" width="${d(e)}" height="${d(t-26)}" rx="12"${r}/><circle cy="${d(a+14)}" r="13"${r}/>`}},bang:{size:(e,t)=>({w:e+2*mt+28,h:t+2*$t+24,dy:0}),inset:()=>3,draw:(e,t,r)=>{let a=[];for(let i=0;i<28;i++){let n=Math.PI*i/14-Math.PI/2,l=i%2===0?1:.82;a.push(Math.cos(n)*(e/2)*l,Math.sin(n)*(t/2)*l)}return Fr(a,r)}},cloud:{size:(e,t)=>({w:e+2*mt+32,h:t+2*$t+24,dy:0}),inset:(e,t,r)=>r&1?2:1,draw:(e,t,r)=>{let a=e/2,i=t/2,n=i*.55;return qn(`M${d(-a+n)},${d(i)}A${d(n)},${d(n)} 0 0 1 ${d(-a+n*.6)},${d(-i*.1)}A${d(a*.42)},${d(i*.7)} 0 0 1 ${d(-a*.1)},${d(-i*.72)}A${d(a*.4)},${d(i*.62)} 0 0 1 ${d(a*.62)},${d(-i*.42)}A${d(n*1.05)},${d(n*1.05)} 0 0 1 ${d(a-n)},${d(i)}Z`,r)}},brace:{size:(e,t)=>({w:e+2*mt+12,h:t+2*$t,dy:0}),draw:(e,t,r,a)=>Ir(e,t,' fill="none" stroke="none"')+_o(-e/2+12,t,-1,a)},"brace-r":{size:(e,t)=>({w:e+2*mt+12,h:t+2*$t,dy:0}),draw:(e,t,r,a)=>Ir(e,t,' fill="none" stroke="none"')+_o(e/2-12,t,1,a)},braces:{size:(e,t)=>({w:e+2*mt+24,h:t+2*$t,dy:0}),draw:(e,t,r,a)=>Ir(e,t,' fill="none" stroke="none"')+_o(-e/2+12,t,-1,a)+_o(e/2-12,t,1,a)},bolt:{noLabel:!0,size:tn(36,56),inset:(e,t,r)=>r&1?e/4:0,draw:(e,t,r)=>Fr([e*.15,-t/2,-e/2,t*.08,-e*.05,t*.08,-e*.15,t/2,e/2,-t*.08,e*.05,-t*.08],r)},"lin-cyl":{inset:n1,span:(e,t,r)=>r?t-2*Gn-20:e*.6,size:(e,t)=>{let r=Math.max(e+2*mt,56),a=Math.min(12,Math.max(6,r/14));return{w:r,h:t+2*$t+2*a+8,dy:a/2+4}},draw:(e,t,r,a)=>{let i=e/2,n=Math.min(12,Math.max(6,e/14)),l=-t/2+n,s=t/2-n,o=c=>`M${d(-i)},${d(c)}A${d(i)},${d(n)} 0 0 0 ${d(i)},${d(c)}`;return qn(`M${d(-i)},${d(l)}A${d(i)},${d(n)} 0 0 1 ${d(i)},${d(l)}V${d(s)}A${d(i)},${d(n)} 0 0 1 ${d(-i)},${d(s)}Z`,r)+`<path d="${o(l)}${o(l+8)}" fill="none"${a}/>`}},"curv-trap":{size:(e,t)=>{let r=t+2*$t;return{w:e+2*mt+r*.6,h:r,dy:0}},draw:(e,t,r)=>{let a=e/2,i=t/2,n=t*.3;return qn(`M${d(-a+n)},${d(-i)}H${d(a-n)}A${d(n)},${d(i)} 0 0 1 ${d(a-n)},${d(i)}H${d(-a+n)}L${d(-a)},0Z`,r)}},docs:{size:(e,t)=>({w:e+2*mt+8,h:t+2*$t+18,dy:-1}),inset:(e,t,r)=>r===2?10:0,draw:(e,t,r)=>{let a="";for(let i=0;i<3;i++)a+=`<g transform="translate(${(1-i)*4},${(i-1)*4})">${Io(e-8,t-8,r)}</g>`;return a}},"bow-rect":{size:(e,t)=>{let r=t+2*$t;return{w:e+2*mt+r*.4,h:r,dy:0}},inset:(e,t,r)=>r===1?t*.2:0,draw:(e,t,r)=>{let a=e/2,i=t/2,n=t*.2;return qn(`M${d(-a+n)},${d(-i)}H${d(a)}A${d(n)},${d(i)} 0 0 0 ${d(a)},${d(i)}H${d(-a+n)}A${d(n)},${d(i)} 0 0 1 ${d(-a+n)},${d(-i)}Z`,r)}},"tag-rect":{size:el,span:na,draw:(e,t,r,a)=>Ir(e,t,ft(r))+`<path d="M${d(e/2-12)},${d(t/2)}L${d(e/2)},${d(t/2-12)}" fill="none"${a}/>`},"tag-doc":{size:(e,t)=>({w:e+2*mt,h:t+2*$t+10,dy:-5}),inset:(e,t,r)=>r===2?10:0,draw:(e,t,r,a)=>Io(e,t,r)+`<path d="M${d(e/2-12)},${d(t/2-14)}L${d(e/2)},${d(t/2-26)}" fill="none"${a}/>`},"lin-doc":{size:(e,t)=>({w:e+2*mt+8,h:t+2*$t+10,dy:-5}),inset:(e,t,r)=>r===2?10:0,draw:(e,t,r,a)=>Io(e,t,r)+`<path d="M${d(-e/2+8)},${d(-t/2)}V${d(t/2-6)}" fill="none"${a}/>`},collapsedGroup:{size:(e,t)=>({w:e+2*mt+8,h:t+2*$t+8,dy:-2}),draw:(e,t,r)=>`<rect x="${d(-e/2+6)}" y="${d(-t/2+8)}" width="${d(e-12)}" height="${d(t-8)}"${ft(r)}/><rect x="${d(-e/2)}" y="${d(-t/2)}" width="${d(e)}" height="${d(t-4)}"${ft(r)}/>`}};o1=l1.rect,tl=new Map(Object.entries(l1))});function Ci(e,t,r,a){let i=a(t,!1),n=e.maxWidth;if(n===void 0||!(n>0)||i.width<=n)return i;let l=Math.min(r,t),s=t;i=a(s,!0);for(let o=0;o<3&&i.width>n&&s>l;o++)s=Math.max(l,s-(i.width-n)),i=a(s,!0);return i}function Nt(e){let t=e.maxWidth;return t!==void 0&&t>0?Math.max(80,t-2*(e.padding??8)):4e3}function _i(e,t,r,a=0){let i=e.maxWidth;return i===void 0||!(i>0)?t:Math.max(Math.min(r,t),Math.min(t,i-a))}function Bt(e,t){let r=t(!1),a=e.maxWidth;if(e.autoDirection===!1||a===void 0||!(a>0)||r.width<=a)return r;let i=e.directionBreakpoint;if(a>=(i!==void 0&&i>0?i:wv))return r;let n=t(!0);return n.width<r.width?n:r}function jr(e){return e==="LR"||e==="RL"}function Nr(e,t){let r=t(!1),a=e.maxWidth;if(a===void 0||!(a>0)||r.width<=a)return r;let i=t(!0);return i.width<r.width?i:r}var wv,zt=Xe(()=>{wv=640});function Ed(e){return e==="markdown"||e==="string"||e==="text"?e:"markdown"}function d1(e){return e.startsWith('"')&&e.endsWith('"')?e.substring(1,e.length-1):e}function bv(e,t){let r=0;for(let a=0;a<t.length;a++)t[a]===e&&r++;return r}function $v(e){let t=e.trim(),r="arrow_open";switch(t[0]){case"<":r="arrow_point",t=t.slice(1);break;case"x":r="arrow_cross",t=t.slice(1);break;case"o":r="arrow_circle",t=t.slice(1);break}let a="normal";return t.includes("=")&&(a="thick"),t.includes(".")&&(a="dotted"),{type:r,stroke:a}}function kv(e){let t=e.trim(),r=t.slice(0,-1),a="arrow_open";switch(t.slice(-1)){case"x":a="arrow_cross",t.startsWith("x")&&(a="double_"+a,r=r.slice(1));break;case">":a="arrow_point",t.startsWith("<")&&(a="double_"+a,r=r.slice(1));break;case"o":a="arrow_circle",t.startsWith("o")&&(a="double_"+a,r=r.slice(1));break}let i="normal",n=r.length-1;r.startsWith("=")&&(i="thick"),r.startsWith("~")&&(i="invisible");let l=bv(".",r);return l&&(i="dotted",n=l),{type:a,stroke:i,length:n}}function Bv(e){let t=e.length,r=[],a=[],i=[],n=[],l=0,s=0,o=!0,c=e.indexOf("direction"),f=e.indexOf("@"),p=-1,h=0,g=0,u=-1,m=-1,b=-1,w=(S,$,y)=>{r.push(S),a.push(e.slice($,y)),i.push($),s=y},v=S=>{n.push(l),l=S},k=()=>{n.length>0&&(l=n.pop())},O=(S,$)=>(S.lastIndex=$,S.test(e)?S.lastIndex:-1),R=S=>e.startsWith(S,s)&&!Qe(e.charCodeAt(s+S.length)),L=S=>{let $=S;if(S>=m&&S<=b)$=b;else if(Ue(e.charCodeAt(S))){for(;$<t&&Ue(e.charCodeAt($));)$++;m=S,b=$}let y=e.charCodeAt($);return y===120||y===111||y===60?e.charCodeAt($+1):y},P=S=>{let $=S;if(S>=m&&S<=b)$=b;else if(Ue(e.charCodeAt(S))){for(;$<t&&Ue(e.charCodeAt($));)$++;m=S,b=$}return e.charCodeAt($)===126},B=()=>{e.charCodeAt(s+1)===96?(v(2),s+=2):(v(1),s++)},G=()=>{if(!P(s))return!1;let S=O(g1,s);return S<0?!1:(w(40,s,S),!0)},C=S=>{let $=e.charCodeAt(s+1);return S===40?($===45?(v(8),w(45,s,s+2)):$===91?(v(7),w(47,s,s+2)):$===40&&e.charCodeAt(s+2)===40?(v(7),w(55,s,s+3)):(v(7),w(69,s,s+1)),!0):S===91?($===91?(v(7),w(49,s,s+2)):$===40?(v(7),w(53,s,s+2)):$===47?(v(9),w(58,s,s+2)):$===92?(v(9),w(59,s,s+2)):(v(7),w(71,s,s+1)),!0):S===124?(v(7),w(67,s,s+1),!0):S===123?(v(7),w(73,s,s+1),!0):!1},Z=S=>{o&&(o=!1,v(6)),w(20,s,s+S)},ee=()=>{let S=s;for(;S<t;){let $=e.charCodeAt(S);if($<128&&w1[$]===1)S++;else if($===45&&S+1<t){let y=e.charCodeAt(S+1);if(y===62||y===45||y===46)break;S++}else break}return S===s?!1:(w(64,s,S),!0)},H=S=>{let $=L(s),y;if($===45){if((y=O(p1,s))>=0)return w(40,s,y),!0;if((y=O(Lv,s))>=0)return v(10),w(41,s,y),!0;if((y=O(Td,s))>=0)return w(40,s,y),!0;if((y=O(Ov,s))>=0)return v(12),w(41,s,y),!0}else if($===61){if((y=O(u1,s))>=0)return w(40,s,y),!0;if((y=O(Dv,s))>=0)return v(11),w(41,s,y),!0}else if($===46&&(y=O(Td,s))>=0)return w(40,s,y),!0;return S!==45&&S!==61&&S!==46&&G()},Y=S=>{let $;switch(S){case 97:if(e.startsWith("acc",s)){if(($=O(Av,s))>=0)return v(3),w(2,s,$),!0;if(($=O(vv,s))>=0)return v(4),w(4,s,$),!0;if(($=O(Ev,s))>=0)return v(5),s=$,!0}break;case 64:if(e.charCodeAt(s+1)===123)return v(16),r.push(7),a.push(""),i.push(s),s+=2,!0;break;case 99:if(($=O(Sv,s))>=0)return v(14),s=$,!0;if(R("classDef"))return w(16,s,s+8),!0;if(R("class"))return w(17,s,s+5),!0;if(($=O(Tv,s))>=0)return v(13),s=$,!0;break;case 34:return B(),!0;case 115:if(R("style"))return w(12,s,s+5),!0;if(R("swimlane-beta"))return Z(13),!0;if(R("subgraph"))return w(21,s,s+8),!0;break;case 100:if(R("default"))return w(13,s,s+7),!0;break;case 108:if(R("linkStyle"))return w(14,s,s+9),!0;break;case 105:if(R("interpolate"))return w(15,s,s+11),!0;break;case 104:if(e.startsWith("href",s)&&Ue(e.charCodeAt(s+4)))return w(18,s,s+5),!0;break;case 102:if(R("flowchart-elk"))return Z(13),!0;if(R("flowchart"))return Z(9),!0;break;case 103:if(R("graph"))return Z(5),!0;break;case 101:if(R("end")){for($=s+3;$<t&&Ue(e.charCodeAt($));)$++;return w(22,s,$),!0}break;case 95:if(R("_self"))return w(23,s,s+5),!0;if(R("_blank"))return w(23,s,s+6),!0;if(R("_parent"))return w(23,s,s+7),!0;if(R("_top"))return w(23,s,s+4),!0;break}if(c!==-1&&s>=h&&(c<s&&(c=e.indexOf("direction",s)),c!==-1&&(p<s&&(Sd.lastIndex=s,p=Sd.test(e)?Sd.lastIndex-1:t),c<p))){for(let y=0;y<5;y++)if(($=O(Rv[y],s))>=0)return w(26+y,s,$),!0;h=p}if(f!==-1&&S!==34&&!Ue(S)){if(s>=g){f<s&&(f=e.indexOf("@",s));let y=s;for(;y<t;){let E=e.charCodeAt(y);if(E===34||Ue(E))break;y++}if(g=y,u=-1,f!==-1&&f<y)for(let E=Math.min(y,t-1)-1;E>=f;E--){if(e.charCodeAt(E)!==64)continue;let x=e.charCodeAt(E+1);if(x!==123&&x!==34){u=E;break}}}if(u>s)return w(31,s,u+1),!0}if(S>=48&&S<=57){let y=s+1;for(;y<t;){let E=e.charCodeAt(y);if(E<48||E>57)break;y++}return w(32,s,y),!0}switch(S){case 35:return w(33,s,s+1),!0;case 58:return e.charCodeAt(s+1)===58&&e.charCodeAt(s+2)===58?w(34,s,s+3):w(35,s,s+1),!0;case 38:return w(36,s,s+1),!0;case 59:return w(37,s,s+1),!0;case 44:return w(38,s,s+1),!0;case 42:return w(39,s,s+1),!0;case 120:case 111:return H(S)||ee();case 60:return H(S)||w(60,s,s+1),!0;case 45:return H(S)||ee()||w(65,s,s+1),!0;case 61:return H(S);case 46:return H(S)||ee();case 126:return G();case 40:return C(S);case 91:return e.charCodeAt(s+1)===124?(w(50,s,s+2),!0):C(S);case 124:case 123:return C(S);case 62:return v(7),w(51,s,s+1),!0;case 94:return w(61,s,s+1),!0;case 92:return e.charCodeAt(s+1)===124?(w(62,s,s+2),!0):ee();case 118:return Qe(e.charCodeAt(s+1))?ee():(w(63,s,s+1),!0)}return Ue(S)?H(S)?!0:($=O(Pv,s))>=0?(w(74,s,$),!0):($=O(zv,s))>=0?(w(75,s,$),!0):!1:S<128?ee():Fn(S)?(w(66,s,s+1),!0):!1},_=(S,$,y,E)=>{if(S===34)return B(),!0;let x=L(s);if(x===y||x===E){let A=O($,s);if(A>=0)return k(),w(40,s,A),!0}if(S===y&&(y!==45||e.charCodeAt(s+1)===45))return!1;let T=s+1;for(;T<t;){let A=e.charCodeAt(T);if(A===34)break;if(A===y){if(y!==45||e.charCodeAt(T+1)===45)break}else if(A===120||A===111||A===60||A===E||Ue(A)){let M=L(T);if((M===y||M===E)&&O($,T)>=0)break}T++}return w(42,s,T),!0};e:for(;;){if(s>=t){let y=-1;switch(l){case 0:y=76;break;case 3:y=3;break;case 4:y=5;break;case 5:y=6;break;case 13:y=19;break;case 14:y=8;break;case 15:y=9;break}y!==-1&&w(y,t,t);break}let S=e.charCodeAt(s),$=!0;switch(l){case 0:$=Y(S);break;case 1:if(S===34)e.charCodeAt(s+1)===96?(v(2),s+=2):(k(),s++);else{let y=e.indexOf('"',s);w(11,s,y===-1?t:y)}break;case 2:if(S===96)e.charCodeAt(s+1)===34?(k(),s+=2):$=!1;else if(S===34)B();else{let y=s+1;for(;y<t;){let E=e.charCodeAt(y);if(E===96||E===34)break;y++}w(10,s,y)}break;case 3:case 4:{let y=e.indexOf(`
44
+ `,s);y===-1&&(y=t);let E=l===3?3:5;k(),w(E,s,y);break}case 5:if(S===125)k(),s++;else{let y=e.indexOf("}",s);y===-1&&(y=t),w(6,s,y)}break;case 6:{let y;S===34?B():(y=O(Cv,s))>=0?(k(),w(24,s,y)):(y=O(_v,s))>=0||(y=O(Iv,s))>=0||(y=O(Nv,s))>=0?(k(),w(25,s,y)):$=G()||C(S);break}case 7:{let y=e.charCodeAt(s+1);switch(S){case 34:B();break;case 40:case 91:case 123:C(S);break;case 93:k(),y===41?w(46,s,s+2):y===93?w(48,s,s+2):w(70,s,s+1);break;case 41:k(),y===93?w(52,s,s+2):y===41&&e.charCodeAt(s+2)===41?w(54,s,s+3):w(68,s,s+1);break;case 124:k(),w(67,s,s+1);break;case 125:k(),w(72,s,s+1);break;default:{if((S===126||Ue(S))&&G())break;let E=s+1;for(;E<t;){let x=e.charCodeAt(E);if(x===91||x===93||x===40||x===41||x===123||x===125||x===124||x===34)break;E++}w(44,s,E)}}break}case 8:{let y=e.charCodeAt(s+1);if(S===34)B();else{if((S===126||Ue(S))&&G())break;if((S===45||S===47||S===41)&&y===41)k(),w(43,s,s+2);else if(S===40||S===91||S===123)C(S);else if(S===41||S===93||S===125)$=!1;else{let E=s+1;for(;E<t;){let x=e.charCodeAt(E);if(x===34||x===40||x===41||x===91||x===93||x===123||x===125||(x===45||x===47)&&e.charCodeAt(E+1)===41||(x===126||Ue(x))&&P(E)&&O(g1,E)>=0)break;E++}w(44,s,E)}}break}case 9:{let y=e.charCodeAt(s+1);if(S===34){B();break}if((S===126||Ue(S))&&G())break;switch(S){case 40:y===45||y===91||y===40&&e.charCodeAt(s+2)===40?C(S):y===93?(k(),w(56,s,s+2)):C(S);break;case 91:case 123:C(S);break;case 92:y===93?(k(),w(56,s,s+2)):w(44,s,s+1);break;case 47:y===93?(k(),w(57,s,s+2)):w(44,s,s+1);break;case 93:case 41:y===93?(k(),w(56,s,s+2)):$=!1;break;case 125:$=!1;break;default:{if((S===63||S===61)&&y===93){k(),w(56,s,s+2);break}let E=s+1;for(;E<t;){let x=e.charCodeAt(E);if(x===92||x===91||x===93||x===40||x===41||x===123||x===125||x===47)break;E++}w(44,s,E)}}break}case 10:$=_(S,p1,45,-1);break;case 11:$=_(S,u1,61,-1);break;case 12:$=_(S,Td,46,45);break;case 13:if(S===34)B();else if(Ue(S))k(),s++;else{let y=s+1;for(;y<t&&!Ue(e.charCodeAt(y));)y++;w(19,s,y)}break;case 14:if(S===40){let y=O(Fv,s);k(),y>=0?s=y:(v(15),s++)}else{let y=e.indexOf("(",s);y===-1&&(y=t),w(8,s,y)}break;case 15:if(S===41)k(),s++;else{let y=e.indexOf(")",s);y===-1&&(y=t),w(9,s,y)}break;case 16:if(S===34)v(17),w(7,s,s+1);else if(S===125)k(),s++;else if(S===94)$=!1;else{let y=s+1;for(;y<t;){let E=e.charCodeAt(y);if(E===125||E===94||E===34)break;y++}w(7,s,y)}break;case 17:if(S===34)k(),w(7,s,s+1);else{let y=e.indexOf('"',s);y===-1&&(y=t),r.push(7),a.push(e.slice(s,y).replace(Wv,"<br/>")),i.push(s),s=y}break}if(!$)return r.push(1),a.push(""),i.push(s),{types:r,texts:a,starts:i};continue e}return r.push(0),a.push(""),i.push(t),{types:r,texts:a,starts:i}}function Hv(e,t){let r=e.includes("}")?e.replace(Yv,`}
45
+ `):e,{types:a,texts:i,starts:n}=Bv(r),l=0,s,o=_=>{let S=a[l];throw S===1?it("flowchart",r,n[l],"",!0):it("flowchart",r,n[l],`Expecting ${_}, got '${f1[S]}'`)},c=(_,S="")=>(a[l]!==_&&o(`'${f1[_]}'${S?", "+S:""}`),i[l++]),f=()=>{let _=a[l];_!==74&&_!==37&&_!==76&&o("'SEMI', 'NEWLINE', 'EOF'"),l++},p=()=>{Ro[a[l]]===0&&o("'NODE_STRING'");let _=i[l++];for(;Ro[a[l]]===1;)_+=i[l++];return _},h=()=>{Nd[a[l]]===0&&o("'NODE_STRING'");let _=i[l++];for(;Nd[a[l]]===1;)_+=i[l++];return _},g=()=>{let _=a[l],S;if(_===11)S="string";else if(_===10)S="markdown";else if(_===44||_===60||_===51||_===66)S="text";else return o(`${m1}, 'TAGEND', 'STR', 'MD_STR'`);let $=i[l++];for(;;){let y=a[l];if(y!==44&&y!==60&&y!==51&&y!==66)break;$+=i[l++]}return{text:$,type:S}},u=_=>{c(_,m1)},m=()=>{let _=a[l],S;if(_===11)S="string";else if(_===10)S="markdown";else if(_===42||_===66)S="text";else return o("'EDGE_TEXT', 'STR', 'MD_STR'");let $=i[l++];for(;a[l]===42||a[l]===66;)$+=i[l++];return{text:$,type:S}},b=()=>{let _=a[l],S;if(_===11)S="text";else if(_===10)S="markdown";else if(Rd[_]===1)S="text";else return o("'NODE_STRING', 'STR', 'MD_STR'");let $=i[l++];for(;Rd[a[l]]===1;)$+=i[l++];return{text:$,type:S}},w=()=>{let _=i[l++];for(;a[l]===7;)_+=i[l++];return _},v=()=>{let _=p(),S;switch(a[l]){case 71:l++,S=g(),u(70),t.addVertex(_,S,"square");break;case 55:l++,S=g(),u(54),t.addVertex(_,S,"doublecircle");break;case 69:l++,a[l]===69?(l++,S=g(),u(68),c(68),t.addVertex(_,S,"circle")):(S=g(),u(68),t.addVertex(_,S,"round"));break;case 45:l++,S=g(),u(43),t.addVertex(_,S,"ellipse");break;case 47:l++,S=g(),u(46),t.addVertex(_,S,"stadium");break;case 49:l++,S=g(),u(48),t.addVertex(_,S,"subroutine");break;case 50:{l++;let $=c(64);c(35);let y=c(64);c(67),S=g(),u(70),t.addVertex(_,S,"rect",void 0,void 0,void 0,{[$]:y});break}case 53:l++,S=g(),u(52),t.addVertex(_,S,"cylinder");break;case 73:l++,a[l]===73?(l++,S=g(),u(72),c(72),t.addVertex(_,S,"hexagon")):(S=g(),u(72),t.addVertex(_,S,"diamond"));break;case 51:l++,S=g(),u(70),t.addVertex(_,S,"odd");break;case 58:l++,S=g(),a[l]===57?(l++,t.addVertex(_,S,"lean_right")):(u(56),t.addVertex(_,S,"trapezoid"));break;case 59:l++,S=g(),a[l]===56?(l++,t.addVertex(_,S,"lean_left")):(u(57),t.addVertex(_,S,"inv_trapezoid"));break;default:t.addVertex(_)}return _},k=()=>{let _=v();return a[l]===34&&(l++,t.setClass(_,p())),_},O=()=>{let _=[k()];for(s=void 0;;){let S=a[l]===7?w():void 0;if(a[l]!==75)return s=S,_;do l++;while(a[l]===75);if(a[l]!==36)return S!==void 0&&o("'AMP'"),_;l++,a[l]!==75&&o("'SPACE'");do l++;while(a[l]===75);let $=k();S!==void 0&&t.addVertex(_[_.length-1],void 0,void 0,void 0,void 0,void 0,void 0,S),_.push($)}},R=()=>{let _;if(a[l]===31&&(_=i[l++]),a[l]===40){let S=t.destructLink(i[l++]);return _!==void 0&&(S.id=_),a[l]===67&&(l++,S.text=g(),u(67),a[l]===75&&l++),S}if(a[l]===41){let S=i[l++],$=m(),y=c(40,"'EDGE_TEXT'"),E=t.destructLink(y,S);return E.text=$,_!==void 0&&(E.id=_),E}return o("'LINK', 'START_LINK'")},L=_=>{let S=O();s!==void 0&&t.addVertex(S[S.length-1],void 0,void 0,void 0,void 0,void 0,void 0,s);let $=S;for(;;){let y=a[l];if(y!==40&&y!==41&&y!==31)return $;let E=R(),x=O();s!==void 0&&t.addVertex(x[x.length-1],void 0,void 0,void 0,void 0,void 0,void 0,s),t.addLink(S,x,E),_&&($=x.concat($)),S=x}},P=()=>{Ld[a[l]]===0&&o("'NODE_STRING', 'NUM', 'COLON', 'BRKT'");let _=i[l++];for(;Ld[a[l]]===1;)_+=i[l++];return _},B=()=>{let _=[P()];for(;a[l]===38;)l++,_.push(P());return _},G=()=>{l++,c(75);let _;if(a[l]===13)_=[i[l++]];else for(_=[c(32,"'DEFAULT'")];a[l]===38;)l++,_.push(c(32));if(c(75),a[l]!==15){t.updateLink(_,B());return}l++,c(75);let S=h();if(a[l]===75){l++;let $=B();t.updateLinkInterpolate(_,S),t.updateLink(_,$)}else t.updateLinkInterpolate(_,S)},C=(_,S)=>{if(a[l]!==75){t.setLink(_,S);return}if(l++,a[l]===23){t.setLink(_,S,i[l++]);return}let $=c(11,"'LINK_TARGET'");a[l]===75?(l++,t.setLink(_,S,c(23))):t.setLink(_,S),t.setTooltip(_,$)},Z=()=>{let _=i[l++];switch(a[l]){case 8:{let S=i[l++],$=a[l]===9,y=$?i[l++]:void 0,E;a[l]===75&&(l++,E=c(11)),$?t.setClickEvent(_,S,y):t.setClickEvent(_,S),E!==void 0&&t.setTooltip(_,E);return}case 18:l++,C(_,c(11));return;case 11:C(_,i[l++]);return;default:{let S=h();if(a[l]===75){l++;let $=c(11);t.setClickEvent(_,S),t.setTooltip(_,$)}else t.setClickEvent(_,S)}}},ee=()=>{l++;let _=a[l];if(_===74||_===37||_===76)return l++,{id:void 0,title:void 0,list:[],collect:!1};c(75,"'SEMI', 'NEWLINE', 'EOF'");let S=b(),$=S;return a[l]===71&&(l++,$=g(),u(70)),_=a[l],_!==74&&_!==37&&_!==76&&o("'SEMI', 'NEWLINE', 'EOF', 'SQS'"),l++,{id:S,title:$,list:[],collect:!1}},H=_=>{let S=a[l];switch(S){case 12:{l++,c(75);let $=p();return c(75),t.addVertex($,void 0,void 0,B()),f(),rl}case 14:return G(),f(),rl;case 16:{l++,c(75);let $=p();return c(75),t.addClass($,B()),f(),rl}case 17:{l++,c(75);let $=p();return c(75),t.setClass($,p()),f(),rl}case 19:return Z(),f(),rl;case 26:case 27:case 28:case 29:case 30:return l++,{stmt:"dir",value:Uv[S-26]};case 2:{l++;let $=c(3).trim();return t.setAccTitle($),$}case 4:{l++;let $=c(5).trim();return t.setAccDescription($),$}case 6:{let $=i[l++].trim();return t.setAccDescription($),$}default:{Ro[S]===0&&o(y1);let $=L(_);return f(),$}}},Y=()=>{let _=[],S=[],$=!1;for(;;){let y=a[l];if(y===0)break;if(y===22){let E=_.pop();if(E===void 0)break;l++;let x=t.addSubGraph(E.id,S,E.title);S=E.list,$=E.collect,$&&S.push(x)}else if(y===37||y===74||y===75||y===76)$&&S.push(i[l]),l++;else if(y===21){let E=ee();E.list=S,E.collect=$,_.push(E),S=[],$=!0}else{let E=H($);$&&(!Array.isArray(E)||E.length>0)&&S.push(E)}}_.length>0&&o("'end'")};for(;a[l]===75||a[l]===74;)l++;if(c(20,"'SPACE', 'NEWLINE'"),a[l]===24)l++,t.setDirection("TB");else{let _=c(25,"'NODIR'"),S=a[l];if(S===75){do l++;while(a[l]===75);S=a[l],S!==74&&o("'NEWLINE', 'SPACE'")}else S!==37&&S!==74&&o("'SEMI', 'NEWLINE', 'SPACE'");l++,t.setDirection(_)}Y(),a[l]!==0&&o(y1)}function qv(e){if(e.img)return"imageSquare";if(e.icon)return e.form==="circle"?"iconCircle":e.form==="square"?"iconSquare":e.form==="rounded"?"iconRounded":"icon";switch(e.type){case"square":case void 0:return"squareRect";case"round":return"roundedRect";default:return e.type}}function Gv(e){switch(e){case"arrow_point":case"arrow_circle":case"arrow_cross":return["none",e];case"double_arrow_point":case"double_arrow_circle":case"double_arrow_cross":{let t=e.replace("double_","");return[t,t]}}return["none","arrow_point"]}function jv(e,t){let r=[],a=[],i=e.subgraphs,n=k=>{let O=[];for(let R of k){let L=e.classes.get(R);if(L!==void 0){for(let P of L.styles)O.push(P.trim());for(let P of L.textStyles)O.push(P.trim())}}return O},l=new Map;for(let k of i)for(let O of k.nodes)e.subgraph(O)&&l.set(O,k.id);let s=new Map,o=new Map;for(let k of i){let O=l.get(k.id);if(O===void 0)continue;let R=o.get(O);R?R.push(k.id):o.set(O,[k.id])}let c=0;for(let k of i){if(l.has(k.id))continue;let O=[k.id];for(;O.length>0;){let R=O.pop();if(s.has(R))continue;s.set(R,c++);let L=o.get(R);if(L)for(let P=L.length-1;P>=0;P--)O.push(L[P])}}let f=k=>e.subgraph(k)?.metadata?.view==="collapsed",p=!1;for(let k of i)k.metadata?.view==="collapsed"&&(p=!0);let h=new Map,g=k=>{let O=[],R=new Set,L=k;for(;L!==void 0&&!h.has(L)&&!R.has(L);)R.add(L),O.push(L),L=l.get(L);let P=L!==void 0?h.get(L):void 0;for(let B=O.length-1;B>=0;B--)P===void 0&&f(O[B])&&(P=O[B]),h.set(O[B],P);return P},u=new Set,m=new Map;for(let k of p?i:[]){let O=g(k.id);if(O!==void 0){k.id!==O&&(u.add(k.id),m.set(k.id,O));for(let R of k.nodes)R!==O&&(u.add(R),m.set(R,O))}}let b=new Map,w=new Set;for(let k=i.length-1;k>=0;k--){let O=i[k];if(!u.has(O.id)){O.nodes.length>0&&w.add(O.id);for(let R of O.nodes)b.set(R,O.id)}}let v=new Map;for(let k=i.length-1;k>=0;k--){let O=i[k];if(u.has(O.id))continue;let R=O.metadata?.view==="collapsed",L={id:O.id,label:O.title,labelType:O.labelType,parentId:b.get(O.id),cssStyles:[],cssCompiledStyles:n(O.classes),cssClasses:O.classes.join(" "),shape:R?"collapsedGroup":"rect",dir:O.dir,isGroup:!R,colorIndex:s.get(O.id)};R||(L.metadata=O.metadata),r.push(L),v.set(O.id,L)}for(let k of e.nodes.values()){if(u.has(k.id))continue;let O=v.get(k.id);if(O){O.cssStyles=k.styles,O.cssCompiledStyles=n(k.classes),O.cssClasses=k.classes.join(" ");continue}let R=w.has(k.id),L={id:k.id,label:k.text,labelType:k.labelType,parentId:b.get(k.id),cssStyles:k.styles,cssCompiledStyles:n(["default","node",...k.classes]),cssClasses:"default "+k.classes.join(" "),dir:k.dir,link:k.link,linkTarget:k.linkTarget,tooltip:e.tooltips.get(k.id),icon:k.icon,pos:k.pos,img:k.img,assetWidth:k.assetWidth,assetHeight:k.assetHeight,constraint:k.constraint,isGroup:R,shape:R?"rect":qv(k)};r.push(L)}return e.edges.forEach((k,O)=>{let R=m.get(k.start)??k.start,L=m.get(k.end)??k.end;if(R===L&&(m.has(k.start)||m.has(k.end)))return;let[P,B]=Gv(k.type),G=[...e.defaultEdgeStyle??[]];k.style&&G.push(...k.style);let C=k.stroke==="invisible"||k.type==="arrow_open";a.push({id:k.id||`L_${R}_${L}_${O}`,isUserDefinedId:k.isUserDefinedId,start:R,end:L,type:k.type??"normal",label:k.text,labelType:k.labelType,thickness:k.stroke,pattern:k.stroke,minlen:k.length,classes:k.stroke==="invisible"?"":"edge-thickness-normal edge-pattern-solid flowchart-link",arrowTypeStart:C?"none":P,arrowTypeEnd:C?"none":B,cssCompiledStyles:n(k.classes),style:G,animate:k.animate,animation:k.animation,curve:k.interpolate||e.defaultInterpolate||t})}),{nodes:r,edges:a}}function Id(e,t,r){let a=e[t];return typeof a=="number"&&a>0?Math.min(a,2e3):r}function al(e,t){return e!==void 0&&e>0&&e<=4e3?e:t}function Dd(e,t,r,a){let i=n=>Nr(r,l=>Qv(e,t,r,a,n,l));return jr(e.direction)?Bt(r,i):i(!1)}function Qv(e,t,r,a,i,n){let l=n?12:x1,s=a?t[a.type]:void 0,o=typeof s=="object"&&s!==null&&!Array.isArray(s)?s:t.flowchart??{},c=jv(e,typeof o.curve=="string"?o.curve:void 0);a?.prepare(c);let f=r.fontSize??16,p=Math.round(f*.875),h=r.measurer??et(r.fontFamily),g=Math.min(Id(o,"wrappingWidth",200),a&&n?100:1/0),u=r.padding??8,m=r.icons,b=new Map,w=[],v=[];c.nodes.forEach((D,I)=>b.set(D.id,I));for(let D of c.nodes){let I=vt(D.cssStyles.length>0?D.cssCompiledStyles.concat(D.cssStyles):D.cssCompiledStyles),z=(I.bold?1:0)|(I.italic?2:0),q=D.labelType==="markdown",j=I.fontSize??f,Q,K;if(D.isGroup){let W=ze(D.label,q,h,j,a&&n?Math.max(80,Nt(r)/2):4e3,z);Q={node:D,style:I,label:W,shape:"group",w:0,h:0,dy:0,loops:0},K=Ut(0,0),K.isGroup=!0,K.dir=D.dir?br(D.dir):void 0,K.padX=l,K.padTop=W.height>0?W.height+16:x1,K.padBottom=l,K.minW=W.width+2*l-12}else{let W=go(D.shape),X=D.img||D.icon||h1(W)?D.label:void 0,te=ze(X,q,h,j,g,z),se,oe,ae=0;if(D.img||D.icon){let ne=D.img?80:48,J=al(D.assetWidth,ne),re=al(D.assetHeight,ne);se=Math.max(J,te.width+8),oe=re+(te.height>0?te.height+6:0),ae=D.pos==="t"?-re/2:re/2,te.height===0&&(ae=0)}else{let ne=Si(W,te.width,te.height);se=ne.w,oe=ne.h,ae=ne.dy}Q={node:D,style:I,label:te,shape:W,w:se,h:oe,dy:ae,loops:0},K=Ut(se,oe)}K.seq=w.length,w.push(Q),v.push(K)}c.nodes.forEach((D,I)=>{v[I].parent=D.parentId!==void 0?b.get(D.parentId)??-1:-1});let k=i?"TB":br(e.direction),O=D=>{let I;for(let z=v[D].parent,q=0;z>=0&&I===void 0&&q<1e4;z=v[z].parent,q++)I=v[z].dir;return I??(I=k),I==="LR"||I==="RL"};w.forEach((D,I)=>{D.node.isGroup?v[I].span=1/0:!D.node.img&&!D.node.icon&&(v[I].span=c1(D.shape,D.w,D.h,O(I)))});let R=[],L=[],P=[];for(let D of c.edges){let I=b.get(D.start),z=b.get(D.end);if(I===void 0||z===void 0)continue;let q=ze(D.label,D.labelType==="markdown",h,p,g);I===z&&(w[I].loops++,O(I)?v[I].h+=2*(Cd+(q.height>0?q.height+8:0)):v[I].w+=2*(Cd+(q.width>0?q.width+12:0))),P.push(D),L.push(q),R.push({src:I,dst:z,minlen:D.minlen??1,labelW:q.width>0?q.width+12:0,labelH:q.height>0?q.height+4:0,route:[],labelX:0,labelY:0})}let B={nodeSep:Id(o,"nodeSpacing",Xv)*(n?.5:1),edgeSep:Vv,rankSep:Id(o,"rankSpacing",Kv)*(n?.75:1),portSep:20,tracks:typeof o.curve=="string"&&/^step/.test(o.curve),straight:o.curve==="linear",headRoom:gt("arrow_point")},G=a?a.layout(v,R,k,B,n):Gr(v,R,k,B),C=Cr(e.title,h,f,n?Nt(r):4e3),Z=C.height>0?C.height+12:0,ee=Math.max(G.width,C.width),H=u+(ee-G.width)/2,Y=u+Z;vi(v,R,H,Y);let _=Math.ceil(ee+2*u),S=Math.ceil(G.height+Z+2*u),$=[],y=new Map,E=!1;for(let D of v)D.isGroup&&(E=!0);if(E)for(let D of R)va(y,D.route);let x="",T="",A="";for(let D=0;D<w.length;D++){let I=w[D],z=v[D],q=I.node,j=z.x,Q=z.y,K=It(q.cssClasses.replace(/^default\s?/,"")),W=Oe(q.id);if(z.isGroup&&a?.drawGroup&&z.parent<0){x+=a.drawGroup(z,I.label,I.style,K,W,k,m);continue}if(z.isGroup){let ne=Ai(z,I.label.width,y,l),J=Q-z.h/2+8+I.label.height/2,re=` class="pele-cluster-label" fill="var(--_m)"${I.style.text}`,fe=xo(z,I.label.width,ne,y);fe&&(T+=wo(I.label,ne,J,re,W,v,D,m)),x+=`<g class="pele-cluster${K}" data-id="${W}"><rect x="${d(j-z.w/2)}" y="${d(Q-z.h/2)}" width="${d(z.w)}" height="${d(z.h)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${ft(I.style.shape)}/>`+(fe?"":Re(I.label,ne,J,re,m))+"</g>";continue}let X=I.w,te=I.h,se;if(q.img){let ne=al(q.assetWidth,80),J=al(q.assetHeight,80),re=I.label.height>0?q.pos==="t"?te/2-J:-te/2:-J/2,fe=i1(Ta(q.img),r);se=fe===void 0?"":`<image href="${Ve(fe)}" x="${d(-ne/2)}" y="${d(re)}" width="${d(ne)}" height="${d(J)}" preserveAspectRatio="${q.constraint==="on"?"xMidYMid meet":"none"}"/>`}else if(q.icon){let ne=al(q.assetHeight,48),J=I.label.height>0?q.pos==="t"?te/2-ne:-te/2:-ne/2,re=q.shape==="icon"?"":q.shape==="iconCircle"?`<circle cy="${d(J+ne/2)}" r="${d(ne/2)}"${_d}${I.style.shape}/>`:`<rect x="${d(-ne/2)}" y="${d(J)}" width="${d(ne)}" height="${d(ne)}" rx="${q.shape==="iconRounded"?8:0}"${_d}${I.style.shape}/>`,fe=ne*.6;se=re+`<svg class="pele-icon" data-icon="${Oe(q.icon)}" x="${d(-fe/2)}" y="${d(J+(ne-fe)/2)}" width="${d(fe)}" height="${d(fe)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${m?.(q.icon)??""}</svg>`}else se=Ca(I.shape,X,te,_d+I.style.shape,Zv+I.style.line);let oe=Re(I.label,0,I.dy,` class="pele-label"${I.style.text}`,m);if(/ internal-link(?: |$)/.test(K+" ")&&q.label&&r.links!==!1){let ne=At(q.label),J=oi(Sa(ne),r)!==void 0,re=Ve(ne);oe=`<a class="internal-link"${J?` href="${re}"${ci(r)}`:""} data-href="${re}">${oe}</a>`,$.push({id:q.id,href:ne,internal:!0})}let ae=se+oe;q.tooltip&&(ae=`<title>${Oe(q.tooltip)}</title>`+ae),q.link&&(ae=ua(ae,q.link,q.id,$,r,q.linkTarget?` target="${Ve(q.linkTarget)}"`:"")),A+=`<g class="pele-node pele-shape-${I.shape}${K}" data-id="${W}" transform="translate(${d(j)},${d(Q)})">${ae}</g>`}let M=Mo();for(let D=0;D<R.length;D++){let I=R[D];I.src===I.dst||P[D].thickness==="invisible"||I.route.length<6||(M.add(I.src,ga(I.route,0,v[I.src]),P[D].arrowTypeStart),M.add(I.dst,ga(I.route,I.route.length-3,v[I.dst]),P[D].arrowTypeEnd))}let N="",F="",U=new Map;for(let D=0;D<R.length;D++){let I=R[D],z=P[D],q=L[D],j=z.style.length>0||z.cssCompiledStyles.length>0?vt(z.cssCompiledStyles.concat(z.style)):void 0;if(z.thickness!=="invisible"){let Q=z.arrowTypeStart,K=z.arrowTypeEnd,W;if(I.src===I.dst){let oe=w[I.src],ae=U.get(I.src)??0;U.set(I.src,ae+1),W=Ao(v[I.src],oe.w,oe.h,ae,O(I.src),Cd,gt(K),I)}else{let oe=I.route.slice(),ae=M.of(I.src,ga(oe,0,v[I.src])),ne=M.of(I.dst,ga(oe,oe.length-3,v[I.dst]));rn(oe,0,w[I.src],v[I.src]),rn(oe,oe.length-3,w[I.dst],v[I.dst]),W=zr(oe,z.curve,gt(Q),gt(K),ae,ne)}let X=j?.stroke&&z.thickness!=="invisible"?Ve(j.stroke):"var(--_l)",te="";z.thickness==="thick"?te+=' stroke-width="2.5"':z.thickness==="dotted"&&(te+=' stroke-dasharray="3 4"');let se=It(z.classes.replace(/edge-thickness-normal|edge-pattern-solid|flowchart-link/g,""));N+=`<g class="pele-edge${se}" data-id="${Oe(z.id)}"${j?.line??""}><path d="${W.d}"${te}/>`+bt(Q,W.sx,W.sy,W.sdx,W.sdy,X)+bt(K,W.ex,W.ey,W.edx,W.edy,X)+"</g>"}if(q.width>0){let Q=I.labelX,K=I.labelY;F+=wr(z.id,q,Q,K,j?.text??"",m)}}return{svg:Je(a?.type??"flowchart",_,S,f,r,e,Re(C,_/2,u+C.height/2,' class="pele-title" font-weight="var(--_tw)"')+(x?`<g class="pele-clusters">${x}</g>`:"")+(N?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${N}</g>`:"")+(T?`<g class="pele-cluster-titles">${T}</g>`:"")+(F?`<g class="pele-edge-labels" font-size="${p}">${F}</g>`:"")+`<g class="pele-nodes">${A}</g>`),width:_,height:S,links:$}}var Mv,f1,w1,Av,vv,Ev,Sv,Tv,Cv,_v,Iv,Nv,Rv,Sd,p1,Lv,u1,Dv,Td,Ov,g1,Pv,zv,Fv,Wv,Ro,Nd,Rd,Ld,m1,rl,Yv,Uv,y1,Xv,Vv,Kv,x1,Cd,_d,Zv,Lo,Od=Xe(()=>{gd();Dn();mo();Bn();Ei();Ea();hi();Ti();tr();zt();pr();ut();wt();Mv=class{constructor(e={}){he(this,"type","flowchart");he(this,"direction");he(this,"nodes",new Map);he(this,"edges",[]);he(this,"subgraphs",[]);he(this,"classes",new Map);he(this,"tooltips",new Map);he(this,"defaultEdgeStyle");he(this,"defaultInterpolate");he(this,"title");he(this,"accTitle");he(this,"accDescr");he(this,"subgraphLookup",new Map);he(this,"members",new Set);he(this,"edgeById",new Map);he(this,"pairCount",new Map);he(this,"subCount",0);he(this,"options");this.options=e}addVertex(e,t,r,a,i,n,l,s){if(!e||e.trim().length===0)return;let o;if(s!==void 0){let g=s.includes(`
46
+ `)?s+`
47
+ `:`{
48
+ `+s+`
49
+ }`,u;try{u=Ma(g)}catch(m){throw new je(`Metadata of "${e}" is not valid YAML. ${m.message}`,"syntax",{type:"flowchart"})}o=u!==null&&typeof u=="object"&&!Array.isArray(u)?u:void 0}let c=this.subgraphLookup.get(e);if(c&&o){c.metadata={...c.metadata,...o};return}let f=this.edgeById.get(e);if(f){o?.animate!==void 0&&(f.animate=o.animate),o?.animation!==void 0&&(f.animation=o.animation),o?.curve!==void 0&&(f.interpolate=o.curve);return}let p=this.nodes.get(e);if(p===void 0&&(t===void 0&&r===void 0&&a!==void 0&&a!==null&&this.options.warn?.(`Style applied to unknown node "${e}". This may indicate a typo. The node will be created automatically.`),p={id:e,labelType:"text",styles:[],classes:[]},this.nodes.set(e,p)),t!==void 0?(p.labelType=t.type,p.text=d1(t.text.trim())):p.text===void 0&&(p.text=e),r!==void 0&&(p.type=r),a!=null)for(let g of a)p.styles.push(g);if(i!=null)for(let g of i)p.classes.push(g);if(n!==void 0&&(p.dir=n),p.props===void 0?p.props=l??{}:l!==void 0&&Object.assign(p.props,l),o===void 0)return;if(o.shape){let g=String(o.shape);if(g!==g.toLowerCase()||g.includes("_"))throw new je(`No such shape: ${g}. Shape names should be lowercase.`,"semantic",{type:"flowchart"});if(!uo(g))throw new je(`No such shape: ${g}.`,"semantic",{type:"flowchart"});p.type=g}let h=typeof o.label=="string"?o.label:void 0;o.label&&(p.text=String(o.label),p.labelType=Ed(o.labelType)),o.icon&&(p.icon=String(o.icon),!h?.trim()&&p.text===e&&(p.text="")),o.form&&(p.form=String(o.form)),o.pos&&(p.pos=String(o.pos)),o.img&&(p.img=String(o.img),!h?.trim()&&p.text===e&&(p.text="")),o.constraint&&(p.constraint=String(o.constraint)),o.w&&(p.assetWidth=Number(o.w)),o.h&&(p.assetHeight=Number(o.h))}addSingleLink(e,t,r,a){let i={start:e,end:t,type:void 0,text:"",labelType:"text",classes:[],isUserDefinedId:!1,interpolate:this.defaultInterpolate},n=r?.text;n!==void 0&&(i.text=d1(n.text.trim()),i.labelType=Ed(n.type)),r!==void 0&&(i.type=r.type,i.stroke=r.stroke,i.length=r.length>10?10:r.length);let l=e+"\0"+t,s=this.pairCount.get(l)??0;a&&!this.edgeById.has(a)?(i.id=a,i.isUserDefinedId=!0):i.id=`L_${e}_${t}_${s===0?0:s+1}`;let o=this.options.maxEdges;if(o!==void 0&&this.edges.length>=o)throw new je(`Edge limit exceeded. ${this.edges.length} edges found, but the limit is ${o}.`,"limit",{type:"flowchart"});this.edges.push(i),this.pairCount.set(l,s+1),this.edgeById.has(i.id)||this.edgeById.set(i.id,i)}addLink(e,t,r){let a=typeof r?.id=="string"?r.id.replace("@",""):void 0,i=e[e.length-1],n=t[0];for(let l of e)for(let s of t)this.addSingleLink(l,s,r,l===i&&s===n?a:void 0)}updateLinkInterpolate(e,t){for(let r of e)r==="default"?this.defaultInterpolate=t:this.edgeAt(r).interpolate=t}updateLink(e,t){for(let r of e){if(r==="default"){this.defaultEdgeStyle=t;continue}let a=this.edgeAt(r);a.style=t,t.length>0&&!t.some(i=>i?.startsWith("fill"))&&t.push("fill:none")}}edgeAt(e){let t=this.edges[Number(e)];if(t===void 0)throw new je(`The index ${e} for linkStyle is out of bounds. Valid indices for linkStyle are between 0 and ${this.edges.length-1}. (Help: Ensure that the index is within the range of existing edges.)`,"semantic",{type:"flowchart"});return t}addClass(e,t){let r=t.join().replace(/\\,/g,"\xA7\xA7\xA7").replace(/,/g,";").replace(/§§§/g,",").split(";");for(let a of e.split(",")){let i=this.classes.get(a);i===void 0&&(i={id:a,styles:[],textStyles:[]},this.classes.set(a,i));for(let n of r)n.includes("color")&&i.textStyles.push(n.replace("fill","bgFill")),i.styles.push(n)}}setDirection(e){let t=e.trim();t.includes("<")&&(t="RL"),t.includes("^")&&(t="BT"),t.includes(">")&&(t="LR"),t.includes("v")&&(t="TB"),t==="TD"&&(t="TB"),this.direction=t}setClass(e,t){for(let r of e.split(","))this.nodes.get(r)?.classes.push(t),this.edgeById.get(r)?.classes.push(t),this.subgraphLookup.get(r)?.classes.push(t)}setTooltip(e,t){if(t!==void 0)for(let r of e.split(","))this.tooltips.set(r,t)}setLink(e,t,r){let a=t.trim();for(let i of e.split(",")){let n=this.nodes.get(i);n!==void 0&&(n.link=a?Ta(a):void 0,n.linkTarget=r)}this.setClass(e,"clickable")}setClickEvent(e,t,r){this.setClass(e,"clickable")}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
50
+ `)}addSubGraph(e,t,r){let a=e?.text.trim(),i=r?.text??"";e!==void 0&&e===r&&/\s/.test(i)&&(a=void 0);let n=new Set,l=[],s;for(let p of t)if(typeof p=="string")p.trim()!==""&&!n.has(p)&&(n.add(p),l.push(p));else if(Array.isArray(p))for(let h of p)h.trim()!==""&&!n.has(h)&&(n.add(h),l.push(h));else s=p.value;s??(s=this.options.inheritDir?this.direction??this.options.direction:void 0),a??(a="subGraph"+this.subCount),i=i||"",this.subCount++;let o={id:a,nodes:l,title:i.trim(),classes:[],dir:s,labelType:Ed(r?.type)},c=this.members;o.nodes=l.filter(p=>!c.has(p)&&p!==a);for(let p of o.nodes)c.add(p);let f=this.subgraphLookup.get(a);if(f)for(let p of o.nodes)f.nodes.push(p);else this.subgraphs.push(o);return this.subgraphLookup.set(a,f??o),a}exists(e,t){for(let r of e)if(r.nodes.includes(t))return!0;return!1}makeUniq(e,t){let r=new Set;for(let a of t)for(let i of a.nodes)r.add(i);return{nodes:e.nodes.filter(a=>!r.has(a))}}destructLink(e,t){let r=kv(e);if(!t)return r;let a=$v(t);if(a.stroke!==r.stroke)return{type:"INVALID",stroke:"INVALID"};if(a.type==="arrow_open")a.type=r.type;else{if(a.type!==r.type)return{type:"INVALID",stroke:"INVALID"};a.type="double_"+a.type}return a.type==="double_arrow"&&(a.type="double_arrow_point"),a.length=r.length,a}subgraph(e){return this.subgraphLookup.get(e)}},f1=["$end","INVALID","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","SHAPE_DATA","CALLBACKNAME","CALLBACKARGS","MD_STR","STR","STYLE","DEFAULT","LINKSTYLE","INTERPOLATE","CLASSDEF","CLASS","HREF","CLICK","GRAPH","subgraph","end","LINK_TARGET","NODIR","DIR","direction_tb","direction_bt","direction_rl","direction_lr","direction_td","LINK_ID","NUM","BRKT","STYLE_SEPARATOR","COLON","AMP","SEMI","COMMA","MULT","LINK","START_LINK","EDGE_TEXT","-)","TEXT","(-","STADIUMEND","STADIUMSTART","SUBROUTINEEND","SUBROUTINESTART","VERTEX_WITH_PROPS_START","TAGEND","CYLINDEREND","CYLINDERSTART","DOUBLECIRCLEEND","DOUBLECIRCLESTART","TRAPEND","INVTRAPEND","TRAPSTART","INVTRAPSTART","TAGSTART","UP","SEP","DOWN","NODE_STRING","MINUS","UNICODE_TEXT","PIPE","PE","PS","SQE","SQS","DIAMOND_STOP","DIAMOND_START","NEWLINE","SPACE","EOF"],w1=new Uint8Array(128);for(let e of"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'*+.`?\\_/")w1[e.charCodeAt(0)]=1;Av=/accTitle\s*:\s*/y,vv=/accDescr\s*:\s*/y,Ev=/accDescr\s*\{\s*/y,Sv=/call\s+/y,Tv=/click\s+/y,Cv=/(?:\r?\n)*\s*\n/y,_v=/\s*(?:LR|RL|TB|BT|TD|BR)\b/y,Iv=/\s*[<>^]/y,Nv=/\s*v\b/y,Rv=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y,/.*direction\s+TD[^\n]*/y],Sd=/[\n\r\u2028\u2029]/g,p1=/\s*[xo<]?--+[-xo>]\s*/y,Lv=/\s*[xo<]?--\s*/y,u1=/\s*[xo<]?==+[=xo>]\s*/y,Dv=/\s*[xo<]?==\s*/y,Td=/\s*[xo<]?-?\.+-[xo>]?\s*/y,Ov=/\s*[xo<]?-\.\s*/y,g1=/\s*~~~+\s*/y,Pv=/(?:\r?\n)+/y,zv=/[^\S\n\r]+/y,Fv=/\(\s*\)/y,Wv=/\n\s*/g;Ro=new Uint8Array(77);for(let e of[32,64,63,65,13,38,35,36,33,39,66])Ro[e]=1;Nd=new Uint8Array(77);for(let e of[32,66,64,25,63,65,38,35,36,33,39])Nd[e]=1;Rd=new Uint8Array(77);for(let e of[32,64,75,65,36,66,35,39,33,12,14,16,17,19,20,25,21,22,63,61,41])Rd[e]=1;Ld=new Uint8Array(77);for(let e of[32,64,35,75,33,12])Ld[e]=1;m1="'UNICODE_TEXT', 'TEXT', 'TAGSTART'",rl=[],Yv=/}\s*\n/g;Uv=["TB","BT","RL","LR","TD"],y1="'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'subgraph', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'NODE_STRING'";Xv=40,Vv=16,Kv=48,x1=20,Cd=26,_d=' fill="var(--_s)" stroke="var(--_b)"',Zv=' stroke="var(--_b)"';Lo={type:"flowchart",math:!0,parse(e,t,r,a,i){let n=t.flowchart??{},l=new Mv({inheritDir:n.inheritDir===!0,maxEdges:i.maxEdges});return r&&(l.title=r),Hv(e,l),l},render:Dd}});var b1={};_t(b1,{flowchart:()=>Lo});var $1=Xe(()=>{Od()});function Jv(e){let t=e.map((i,n)=>n),r=[];for(let i=0;i<128;i++){let n=String.fromCharCode(i);r.push(t.filter(l=>{let{pattern:s,first:o}=e[l];return typeof s=="string"?s[0]===n:o===void 0||o.includes(n)}))}let a={starting:r,every:t,longer:e.map(i=>i.longer?.map(n=>e.indexOf(n)))};return k1.set(e,a),a}function Gt(e,t,r){let a=[],i=[],n=[],l=new Uint8Array(t.length),{starting:s,every:o,longer:c}=k1.get(t)??Jv(t),f=[],p=e.length,h=(u,m)=>{if(l[u])return-1;let b=t[u];if(b.match!==void 0)return b.match(e,m);if(b.scanner!==void 0)return(f[u]??(f[u]=b.scanner()))(e,m);let w=b.pattern;return typeof w=="string"?e.startsWith(w,m)?m+w.length:-1:(w.lastIndex=m,w.test(e)?w.lastIndex:(b.opener!==void 0&&(b.opener.lastIndex=m,b.opener.test(e)&&(l[u]=1)),-1))},g=0;e:for(;g<p;){let u=e.charCodeAt(g);for(let m of u<128?s[u]:o){let b=h(m,g);if(b<=g)continue;let w=m,v=c[m];if(v!==void 0)for(let k of v){let O=h(k,g);if(O>b){w=k,b=O;break}}t[w].hidden||(a.push(w),i.push(g),n.push(b)),g=b;continue e}throw it(r,e,g,"",!0)}return a.push(-1),i.push(p),n.push(p),{kinds:a,starts:i,ends:n,src:e}}function or(e){return{name:e,pattern:new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"(?:(?=%%)|(?!\\S))","y"),first:e[0]}}function Pd(e){return e.trim().replace(/[\t ]{2,}/gm," ")}function Xt(e){return Pd(rE.exec(e)[1])}function Vt(e){return Pd(tE.exec(e)[1])}function Kt(e){let t=eE.exec(e);return t[1]!==void 0?Pd(t[1]):t[2].replace(/^\s*/gm,"").replace(/\s+$/gm,"").replace(/[\t ]{2,}/gm," ").replace(/[\n\r]{2,}/gm,`
51
+ `)}function $r(e){if(!e.includes("\\"))return e.slice(1,-1);let t="";for(let r=1;r<e.length-1;r++){let a=e[r];if(a==="\\"){let i=e[++r];t+=aE.get(i)??i}else t+=a}return t}var k1,ur,rr,ar,Xr,Rr,Lr,jt,sr,lr,eE,tE,rE,aE,Zt,Vr=Xe(()=>{wt();k1=new WeakMap;ur={name:"ACC_DESCR",pattern:/[\t ]*accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\s*{([^}]*)})/y,first:" a"},rr={name:"ACC_TITLE",pattern:/[\t ]*accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/y,first:" a"},ar={name:"TITLE",pattern:/[\t ]*title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|)/y,first:" t"},Xr={name:"STRING",pattern:/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'/y,first:`"'`},Rr={name:"NEWLINE",pattern:/\r?\n/y,first:`\r
52
+ `},Lr={name:"WHITESPACE",pattern:/[\t ]+/y,hidden:!0,first:" "},jt={name:"YAML",pattern:/---[\t ]*\r?\n(?:[\S\s]*?\r?\n)?---(?:\r?\n|(?!\S))/y,hidden:!0,opener:/---[\t ]*\r?\n/y,first:"-"},sr={name:"DIRECTIVE",pattern:/[\t ]*%%{[\S\s]*?}%%(?:\r?\n|(?!\S))/y,hidden:!0,opener:/[\t ]*%%{/y,first:" %"},lr={name:"SINGLE_LINE_COMMENT",pattern:/[\t ]*%%[^\n\r]*/y,first:" %",hidden:!0};eE=/accDescr(?:[\t ]*:([^\n\r]*)|\s*{([^}]*)})/,tE=/accTitle[\t ]*:([^\n\r]*)/,rE=/title([\t ][^\n\r]*|)/;aE=new Map([["b","\b"],["f","\f"],["n",`
53
+ `],["r","\r"],["t"," "],["v","\v"],["0","\0"]]);Zt=class{constructor(e,t,r){he(this,"tokens");he(this,"types");he(this,"diagram");he(this,"i",0);he(this,"kinds");this.tokens=e,this.types=t,this.diagram=r,this.kinds=e.kinds}get kind(){return this.kinds[this.i]}text(e=this.i){return this.tokens.src.slice(this.tokens.starts[e],this.tokens.ends[e])}take(){return this.text(this.i++)}accept(e){return this.kinds[this.i]!==e?!1:(this.i++,!0)}expect(e){return this.kinds[this.i]!==e&&this.fail(`token of type '${this.types[e].name}'`),this.take()}fail(e){let t=this.kind===-1?"end of input":`\`${this.text()}\``;throw it(this.diagram,this.tokens.src,this.tokens.starts[this.i],`Expecting ${e} but found ${t}.`)}}});function iE(e,t){let r=new Map;for(let{label:a,value:i}of e.sections){if(i<0)throw new je(`"${a}" has invalid value: ${i}. Negative values are not allowed in pie charts. All slice values must be >= 0.`,"semantic",{type:"pie"});r.has(a)||r.set(a,i)}return{type:"pie",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
54
+ `):void 0,showData:e.showData,sections:r}}function M1(e,t){let r=t;for(let a=e.charCodeAt(r);a>=48&&a<=57;a=e.charCodeAt(r))r++;return r}function nE(){let e=0,t=0,r=-1;return(a,i)=>{let n=a.charCodeAt(i)===45?i+1:i;if((n<e||n>=t)&&(e=n,t=M1(a,n),r=-1,t>n&&a.charCodeAt(t)===46)){let l=M1(a,t+1),s=l-t-1;s>0&&a.charCodeAt(l)!==46?r=l:s>1&&(r=l-1)}return t===n?-1:r>=0?r:a.charCodeAt(n)===48?a.charCodeAt(n+1)===46?-1:n+1:a.charCodeAt(t)!==46?t:t-1>n?t-1:-1}}function sE(e){let t=new Zt(Gt(e,A1,"pie"),A1,"pie"),r={$type:"Pie",showData:!1,sections:[]},a=()=>{if(t.kind!==-1)for(t.kind!==8&&t.fail("a line break or the end of input");t.kind===8;)t.i++};for(;t.kind===8;)t.i++;for(t.expect(1),r.showData=t.accept(0);t.kind!==-1;)switch(t.kind){case 8:t.i++;break;case 4:r.accDescr=Kt(t.take()),a();break;case 5:r.accTitle=Vt(t.take()),a();break;case 6:r.title=Xt(t.take()),a();break;case 7:{let i=$r(t.take());t.expect(2);let n=Number(t.expect(3));r.sections.push({$type:"PieSection",label:i,value:n}),a();break}default:t.fail("a section, a title, or a line break")}return r}function Wd(e,t){return e.pie?.[t]}function jn(e,t){return`${d(Math.sin(e)*t)},${d(-Math.cos(e)*t)}`}function oE(e,t,r,a){if(t-e>=Math.PI*2-1e-9){let n=(l,s)=>`M0,${d(-l)}A${d(l)},${d(l)} 0 1 ${s} 0,${d(l)}A${d(l)},${d(l)} 0 1 ${s} 0,${d(-l)}Z`;return n(r,1)+(a>0?n(a,0):"")}let i=t-e>Math.PI?1:0;return a<=0?`M0,0L${jn(e,r)}A${d(r)},${d(r)} 0 ${i} 1 ${jn(t,r)}Z`:`M${jn(e,r)}A${d(r)},${d(r)} 0 ${i} 1 ${jn(t,r)}L${jn(t,a)}A${d(a)},${d(a)} 0 ${i} 0 ${jn(e,a)}Z`}function cE(e,t,r){return Ci(r,lE*2,140,(a,i)=>hE(e,t,r,a/2,i))}function hE(e,t,r,a,i){let n=r.fontSize??16,l=Math.round(n*.875),s=r.measurer??et(r.fontFamily),o=r.padding??8,c=Wd(t,"textPosition"),f=typeof c=="number"&&c>=0&&c<=1?c:.75,p=Wd(t,"donutHole"),h=typeof p=="number"&&p>0&&p<=.9?p*a:0,g=String(Wd(t,"legendPosition")??"right"),u=i&&(g==="left"||g==="right")?"bottom":g,m=[...e.sections],b=0;for(let[,q]of m)b+=q;let w=m.map(([q,j])=>ze(e.showData?`${q} [${j}]`:q,!1,s,l,4e3)),v=0;for(let q of w)v=Math.max(v,q.width);v+=w.length>0?il+8:0;let k=w.length*zd,O=ze(e.title,!1,s,n,Nt(r),1),R=O.height>0?O.height+16:0,L=m.map(([,q])=>{let j=b>0?q/b:0;return j*100>=1&&(j*100).toFixed(0)!=="0"?j:0}),P=L.map(q=>q===0||q>=.5?!1:2*a*f*Math.sin(q*Math.PI)<s.width((q*100).toFixed(0)+"%",l,0)+6),B=P.includes(!0)?v1:0,G=u==="left"||u==="right"||u==="center"?u:"",C=u==="top"||u==="bottom",Z=(a+B)*2,ee=Z,H=Z;G==="left"||G==="right"?(ee+=v>0?Fd+v:0,H=Math.max(H,k)):C&&(ee=Math.max(ee,v),H+=k>0?20+k:0),ee=Math.max(ee,O.width);let Y=o+(G==="left"?v+Fd+Z/2:G==="right"?Z/2:ee/2),_=o+R,S=_+(u==="top"?k+20+Z/2:C?Z/2:H/2),$="",y="",E="",x=0,T=a+v1/2,A=[],M=(q,j,Q)=>A.every(K=>Math.abs(q-K.x)>=(Q+K.width)/2+2||Math.abs(j-K.y)>=l+2);m.forEach(([q],j)=>{let Q=L[j];if(Q===0)return;let K=x+Q*Math.PI*2;$+=`<path class="pele-slice" data-id="${Oe(q)}" d="${oE(x,K,a,h)}" fill="${dt(j)}"/>`;let W=(x+K)/2,X=(Q*100).toFixed(0)+"%";if(P[j]){let te=s.width(X,l,0),se=W;for(let ne=0;ne<360&&!M(Math.sin(se)*T,-Math.cos(se)*T,te);ne++)se+=2/T;let oe=Math.sin(se)*T,ae=-Math.cos(se)*T;A.push({x:oe,y:ae,width:te}),E+=`<text x="${d(oe)}" y="${d(ae+l*.35)}">${X}</text>`}else{let te=a*f;y+=`<text x="${d(Math.sin(W)*te)}" y="${d(-Math.cos(W)*te+l*.35)}">${X}</text>`}x=K}),$===""&&($=`<circle class="pele-slice" r="${a}" fill="none" stroke="var(--_b)"/>`);let N="",F,U;G==="right"?(F=Y+Z/2+Fd,U=_+(H-k)/2):G==="left"?(F=o,U=_+(H-k)/2):G==="center"?(F=Y-v/2,U=S-k/2):(F=o+(ee-v)/2,U=u==="top"?_:_+Z+20),w.forEach((q,j)=>{let Q=U+j*zd+zd/2;N+=`<g class="pele-legend-item" data-id="${Oe(m[j][0])}"><rect x="${d(F)}" y="${d(Q-il/2)}" width="${il}" height="${il}" rx="2" fill="${dt(j)}"/>`+Re(q,F+il+8+q.width/2,Q,"")+"</g>"});let D=Math.ceil(ee+2*o),I=Math.ceil(H+R+2*o),z=Re(O,D/2,o+O.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-slices" transform="translate(${d(Y)},${d(S)})" stroke="var(--_bg)" stroke-width="1" stroke-linejoin="round">${$}</g>`+(y?`<g class="pele-slice-labels" transform="translate(${d(Y)},${d(S)})" font-size="${l}" text-anchor="middle" fill="var(--_bg)">${y}</g>`:"")+(E?`<g class="pele-slice-labels" transform="translate(${d(Y)},${d(S)})" font-size="${l}" text-anchor="middle">${E}</g>`:"")+(N?`<g class="pele-legend" font-size="${l}">${N}</g>`:"");return{svg:Je("pie",D,I,n,r,e,z),width:D,height:I,links:[]}}var A1,lE,il,zd,Fd,v1,E1,S1=Xe(()=>{zt();Vr();ut();wt();A1=[or("showData"),or("pie"),{name:":",pattern:":"},{name:"NUMBER_PIE",pattern:/(?:-?[0-9]+\.[0-9]+(?!\.))|(?:-?(0|[1-9][0-9]*)(?!\.))/y,scanner:nE,first:"-0123456789"},ur,rr,ar,Xr,Rr,Lr,jt,sr,lr];lE=120,il=12,zd=26,Fd=32,v1=28;E1={type:"pie",parse:(e,t,r)=>iE(sE(e),r),render:cE}});var T1={};_t(T1,{pie:()=>E1});var C1=Xe(()=>{S1()});function Bd(e){let t=0;for(let r=e.indexOf("~");r!==-1;r=e.indexOf("~",r+1))t++;return t}function dE(e){let t=Bd(e);if(t<=1)return e;let r=t%2!==0&&e.startsWith("~"),a=e.split(""),i=[];for(let n=r?1:0;n<a.length;n++)a[n]==="~"&&i.push(n);for(let n=0,l=i.length-1;n<l;n++,l--)a[i[n]]="<",a[i[l]]=">";return a.join("")}function an(e){if(!e.includes("~"))return e;let t=e.split(/(,)/),r=[];for(let a=0;a<t.length;a++){let i=t[a];i===","&&a>0&&a+1<t.length&&Bd(t[a-1])===1&&Bd(t[a+1])===1&&(i=t[a-1]+","+t[a+1],a++,r.pop()),r.push(dE(i))}return r.join("")}var Yd=Xe(()=>{});function fE(e){return e==="markdown"||e==="string"||e==="text"?e:"markdown"}function I1(e,t){return e<128?(_a[e]&t)!==0:e>=192||e===181}function xE(e){let t=e.length,r=[],a=[],i=[],n=0,l=0,s=-2,o=0,c=-1,f=-2,p=-1,h=-1,g=-1,u=(H,Y,_)=>{r.push(H),a.push(e.slice(Y,_)),i.push(Y),l=_},m=(H,Y)=>(H.lastIndex=Y,H.test(e)?H.lastIndex:-1),b=H=>{for(let Y=0;Y<H.length;Y++){let _=H.charCodeAt(Y),S=e.charCodeAt(l+Y);if(S!==_&&(_<97||_>122||(S|32)!==_))return!1}return!0},w=H=>b(H)&&!Qe(e.charCodeAt(l+H.length)),v=H=>{let Y=e.charCodeAt(H);return Y>=65&&Y<=90?Y+32:Y},k=H=>(Ud.lastIndex=H,Ud.test(e)?Ud.lastIndex-1:t),O=H=>{for(;pt(e.charCodeAt(H));)H++;return H},R=()=>{if(s===-1||s<l&&(Hd.lastIndex=l,s=Hd.test(e)?Hd.lastIndex-9:-1,s===-1)||l<o||(c<l&&(c=k(l)),s>=c))return!1;for(let H=0;H<4;H++){let Y=m(yE[H],l);if(Y>=0)return u(18+H,l,Y),!0}return o=c,!1},L=()=>{let H=e.indexOf('"',l+1);if(H===-1){u(45,l,l+1);return}let Y=H>l+1;for(let _=l+1;Y&&_<H;_++){let S=e.charCodeAt(_);(S===37||S===92||S===13||S===10||S===11||S===8)&&(Y=!1)}u(Y?31:44,l,H+1)},P=H=>{let Y=e.charCodeAt(l+1);if(Y===43&&(H===49||H===48)){u(H===49?39:38,l,l+2);return}let _=O(l+1);if(e.charCodeAt(_)===46&&pt(e.charCodeAt(_+1))){u(32,l,O(_+2));return}if(H===49){if(Ue(Y)){let S=l+2;for(;Ue(e.charCodeAt(S));)S++;let $=e.charCodeAt(S);if(Qe($)||$===34||$===39){u(40,l,l+1);return}}else if(Y===45||Y===46){let S=e.charCodeAt(l+2);if(S===45||S===46){u(40,l,l+1);return}}if(!Qe(Y)){u(33,l,l+1);return}}u(29,l,_)},B=H=>{let Y=e.charCodeAt(l+1);switch(H){case 101:if(w("erdiagram"))u(2,l,l+9);else if(w("end")){let _=l+3;for(;Ue(e.charCodeAt(_));)_++;u(16,l,_)}else return!1;return!0;case 115:if(w("style"))n=6,u(27,l,l+5);else if(w("subgraph"))u(17,l,l+8);else return!1;return!0;case 99:if(w("classdef"))n=6,u(22,l,l+8);else if(w("class"))u(26,l,l+5);else return!1;return!0;case 111:if(w("one or zero"))u(37,l,l+11);else if(w("one or more")||w("one or many"))u(39,l,l+11);else if(w("one"))u(40,l,l+3);else if(w("only one"))u(40,l,l+8);else if(Y===124)u(37,l,l+2);else if(Y===123)u(38,l,l+2);else if(w("optionally to"))u(42,l,l+13);else return!1;return!0;case 122:if(w("zero or one"))u(37,l,l+11);else if(w("zero or more")||w("zero or many"))u(38,l,l+12);else return!1;return!0;case 109:if(b("many(0)"))u(38,l,l+7);else if(b("many(1)"))u(39,l,l+7);else if(w("many"))u(38,l,l+4);else return!1;return!0;case 116:return w("to")?(u(43,l,l+2),!0):!1;case 117:return Y!==46&&Y!==45&&Y!==124?!1:(u(41,l,l+1),!0);case 124:if(v(l+1)===111&&!Qe(e.charCodeAt(l+2)))u(37,l,l+2);else if(Y===124)u(40,l,l+2);else if(Y===123)u(39,l,l+2);else return!1;return!0;case 125:if(v(l+1)===111&&!Qe(e.charCodeAt(l+2)))u(38,l,l+2);else if(Y===124)u(39,l,l+2);else return!1;return!0;case 46:return Y!==46&&Y!==45?!1:(u(42,l,l+2),!0);case 45:if(Y===45)u(43,l,l+2);else if(Y===46)u(42,l,l+2);else return!1;return!0}return!1},G=H=>{let Y;if((H===97||H===65)&&b("acc")){if((Y=m(uE,l))>=0){n=3,u(11,l,Y);return}if((Y=m(gE,l))>=0){n=4,u(13,l,Y);return}if((Y=m(mE,l))>=0){n=5,l=Y;return}}if(!R()){switch(H){case 32:case 9:case 13:Y=l+1;for(let _=e.charCodeAt(Y);_===32||_===9||_===13;_=e.charCodeAt(Y))Y++;l=Y;return;case 10:for(Y=l+1;e.charCodeAt(Y)===10;)Y++;u(4,l,Y);return;case 34:L();return;case 123:n=1,u(7,l,l+1);return;case 35:u(30,l,l+1);return;case 44:u(25,l,l+1);return;case 58:e.charCodeAt(l+1)===58&&e.charCodeAt(l+2)===58?u(6,l,l+3):u(5,l,l+1);return;case 91:u(9,l,l+1);return;case 93:u(10,l,l+1);return}if(pt(H)){P(H);return}if(!B(H>=65&&H<=90?H+32:H)){if(H>=128||_a[H]&ll){Y=l+1;for(let _=e.charCodeAt(Y);_>=128||_a[_]&ll;_=e.charCodeAt(Y))Y++;u(23,l,Y);return}u(45,l,l+1)}}},C=()=>{if(f===-1||f<l&&(f=e.indexOf("~",l),f===-1))return!1;if(g<l){let Y=l;for(;Y<t&&!Ue(e.charCodeAt(Y));)Y++;g=Y}if(f>=g||(p<l&&(p=k(l),h=e.lastIndexOf("~",p-1)),h<=f))return!1;let H=h+1;for(;H<t&&!Ue(e.charCodeAt(H));)H++;return u(34,l,H),!0},Z=H=>{if(Ue(H)){for(l++;Ue(e.charCodeAt(l));)l++;return}let Y=H|32;if((Y===112||Y===102||Y===117)&&(e.charCodeAt(l+1)|32)===107&&!Qe(e.charCodeAt(l+2))){u(35,l,l+2);return}if(!C()){if(I1(H,Zd)){let _=l+1;for(;_<t&&I1(e.charCodeAt(_),ol);)_++;u(34,l,_);return}if(H===96){n=2,l++;return}if(H===34){let _=e.indexOf('"',l+1);if(_!==-1){u(36,l,_+1);return}}else if(H===125){n=0,u(8,l,l+1);return}u(45,l,l+1)}};for(;l<t;){let H=e.charCodeAt(l),Y;switch(n){case 0:G(H);break;case 1:Z(H);break;case 2:H===96?(n=1,l++):(Y=e.indexOf("`",l),u(34,l,Y===-1?t:Y));break;case 3:case 4:Y=e.indexOf(`
55
+ `,l),u(n===3?12:14,l,Y===-1?t:Y),n=0;break;case 5:H===125?(n=0,l++):(Y=e.indexOf("}",l),u(15,l,Y===-1?t:Y));break;case 6:if(H===10){for(Y=l+1;e.charCodeAt(Y)===10;)Y++;n=0,u(4,l,Y)}else if(Ue(H))for(l++;Ue(e.charCodeAt(l));)l++;else if(H===58)u(5,l,l+1);else if(H===44)u(25,l,l+1);else if(H===35)u(30,l,l+1);else if(H===59)u(28,l,l+1);else if(H>=128||_a[H]&Po){Y=l+1;for(let _=e.charCodeAt(Y);_>=128||_a[_]&Po;_=e.charCodeAt(Y))Y++;u(24,l,Y)}else return r.push(1),a.push(""),i.push(l),{types:r,texts:a,starts:i};break}}let ee=n===0?3:n===3?12:n===4?14:n===5?15:-1;return ee!==-1&&(r.push(ee),a.push(""),i.push(t)),r.push(0),a.push(""),i.push(t),{types:r,texts:a,starts:i}}function $E(e,t){let{types:r,texts:a,starts:i}=xE(e),n=0,l=P=>{let B=r[n];throw B===1?it("er",e,i[n],"",!0):it("er",e,i[n],`Expecting ${P}, got '${B===45?a[n]:_1[B]}'`)},s=P=>(r[n]!==P&&l(`'${_1[P]}'`),a[n++]),o=()=>{let P=r[n];P!==4&&P!==28&&P!==3&&l("'EOF', 'NEWLINE', 'SEMI'"),n++},c=P=>P===23||P===31||P===29||P===32||P===33,f=()=>{let P=r[n];c(P)||l(Y1);let B=a[n++];return P===31?B.slice(1,-1):B},p=()=>{let P=[];for(;;){let B=r[n];if(B!==23&&B!==24&&l("'UNICODE_TEXT', 'STYLE_TEXT'"),P.push(a[n++]),r[n]!==25)return P;n++}},h=P=>P===24||P===29||P===5||P===30,g=()=>{let P=[];for(;;){h(r[n])||l("'STYLE_TEXT', 'COLON', 'NUM', 'BRKT'");let B=a[n++];for(;h(r[n]);)B+=a[n++];if(P.push(B),r[n]!==25)return P;n++}},u=()=>{let P=qd.get(r[n++]),B=r[n];B!==43&&B!==42&&l("'NON_IDENTIFYING', 'IDENTIFYING'");let G=B===43?"IDENTIFYING":"NON_IDENTIFYING";n++;let C=qd.get(r[n]);return C===void 0?l(bE):(n++,{cardA:C,relType:G,cardB:P})},m=()=>{let P=r[n];P!==44&&P!==31&&P!==23&&l("'UNICODE_TEXT', 'ENTITY_NAME', 'WORD'");let B=a[n++];return P===23?B:B.slice(1,-1)},b=P=>r[n]===45&&a[n]===P,w=()=>{let P=[];do{let B=s(34);b("?")&&(B+=a[n++]),r[n]!==34&&l(B.endsWith("?")?"'ATTRIBUTE_WORD'":"'ATTRIBUTE_WORD', '?'");let G={type:B,name:a[n++]};if(r[n]===35){let C=[a[n++]];for(;b(",");)n++,C.push(s(35));G.keys=C}r[n]===36&&(G.comment=a[n++].slice(1,-1)),P.push(G)}while(r[n]!==8);return P.reverse()},v=()=>{if(r[n]!==7)return;if(n++,r[n]===8){n++;return}let P=w();return n++,P},k=()=>{let P=f(),B=r[n];if(B===9){n++;let Z=f();s(10);let ee;r[n]===6&&(n++,ee=p());let H=v();return t.addEntity(P,Z),H&&t.addAttributes(P,H),ee&&t.setClass([P],ee),[P]}let G;if(B===6&&(n++,G=p(),B=r[n]),qd.has(B)){let Z=u(),ee=f(),H;r[n]===6&&(n++,H=p()),s(5);let Y=m();return t.addEntity(P),t.addEntity(ee),t.addRelationship(P,Y,ee,Z),G&&t.setClass([P],G),H&&t.setClass([ee],H),[P,ee]}let C=v();return t.addEntity(P),C&&t.addAttributes(P,C),G&&t.setClass([P],G),[P]};s(2);let O=[{id:"",title:"",list:[]}],R=O[0],L=!1;for(;;){let P=r[n];switch(P){case 4:n++;break;case 3:n++,L&&l(`'END', ${Do}`);return;case 16:{L||l(Do),n++;let B=t.addSubGraph({text:R.id},R.list,{text:R.title});O.pop(),R=O[O.length-1],L=O.length>1,L&&R.list.push(B);break}case 17:{n++;let B=f(),G=B;if(r[n]===9){for(n++,G=f();c(r[n]);)G+=" "+f();s(10)}o(),R={id:B,title:G,list:[]},O.push(R),L=!0;break}case 11:{n++;let B=s(12).trim();t.setAccTitle(B),L&&R.list.push(B);break}case 13:{n++;let B=s(14).trim();t.setAccDescription(B),L&&R.list.push(B);break}case 15:{let B=a[n++].trim();t.setAccDescription(B),L&&R.list.push(B);break}case 18:case 19:case 20:case 21:{n++;let B=wE[P-18];L?R.list.push({stmt:"dir",value:B}):t.setDirection(B);break}case 22:{let B=a[n++],G=p(),C=g();o(),t.addClass(G,C),L&&R.list.push(B);break}case 26:{let B=a[n++],G=p();t.setClass(G,p()),L&&R.list.push(B);break}case 27:{let B=a[n++],G=p(),C=g();o(),t.addCssStyles(G,C),L&&R.list.push(B);break}default:{c(P)||l(L?`'END', ${Do}`:Do);let B=k();if(L)for(let G of B)R.list.push(G)}}}}function ME(e){let t=[],r=[],a=e.subgraphs,i=o=>{let c=[];for(let f of o){let p=e.classes.get(f);if(p!==void 0){for(let h of p.styles)c.push(h.trim());for(let h of p.textStyles)c.push(h.trim())}}return c},n=new Map,l=new Set;for(let o=a.length-1;o>=0;o--){let c=a[o];l.add(c.id);for(let f of c.nodes)n.set(f,c.id)}for(let o=a.length-1;o>=0;o--){let c=a[o];t.push({id:c.id,label:c.title,alias:"",attributes:kE,isGroup:!0,parentId:n.get(c.id),cssStyles:c.cssStyles,cssCompiledStyles:i(c.classes),cssClasses:c.classes.join(" "),dir:c.dir,labelType:c.labelType})}let s=new Map;for(let[o,c]of e.entities){if(l.has(o)){s.set(c.id,o);continue}t.push({id:c.id,label:c.label,alias:c.alias,attributes:c.attributes,isGroup:!1,parentId:n.get(o),cssStyles:c.cssStyles,cssCompiledStyles:i(c.cssClasses.split(" ")),cssClasses:c.cssClasses,dir:void 0,labelType:"markdown"})}return e.relationships.forEach((o,c)=>{r.push({id:`id_${o.entityA}_${o.entityB}_${c}`,start:s.get(o.entityA)??o.entityA,end:s.get(o.entityB)??o.entityB,label:o.roleA,arrowTypeStart:o.relSpec.cardB.toLowerCase(),arrowTypeEnd:o.relSpec.cardA.toLowerCase(),pattern:o.relSpec.relType==="IDENTIFYING"?"solid":"dashed"})}),{nodes:t,edges:r}}function Xn(e,t,r,a,i){let n=(f,p)=>d(t-a*f-i*p)+","+d(r-i*f+a*p),l=f=>`M${n(f,-N1)}L${n(f,N1)}`,s=`M${n(0,-R1)}L${n(Gd,0)}L${n(0,R1)}`,o=f=>`<circle class="pele-marker" cx="${d(t-a*f)}" cy="${d(r-i*f)}" r="${L1}" fill="var(--_bg)"/>`,c=f=>`<path class="pele-marker" d="${f}"/>`;switch(e){case"only_one":return c(l(6)+l(10));case"zero_or_one":return c(l(6))+o(13.5);case"one_or_more":return c(s+l(Gd+3.5));case"zero_or_more":return c(s)+o(Gd+L1+.5);case"md_parent":return`<path class="pele-marker" d="M${n(0,0)}L${n(6,4)}L${n(12,0)}L${n(6,-4)}Z" fill="var(--_bg)"/>`}return""}function F1(e,t,r){let a=e.er?.[t];return typeof a=="number"&&a>0?Math.min(a,2e3):r}function Oo(e,t,r,a,i){let n=e.lines;if(n.length===0)return"";let l=n.length===1&&n[0].length===1?n[0][0]:void 0;if(l&&l.icon===void 0&&l.math===void 0&&l.style===0)return`<text${a} x="${d(t)}" y="${d(r)}">${Ve(l.text)}</text>`;let s=li(e),o=e.size*.35,c=r-o-e.lineHeight/2,f="",p="";for(let h=0;h<n.length;h++){let g=n[h],u=c+Ha(e,h);if(Wn(g)){p+=Re(Ua(e,h),t+e.widths[h]/2,u,a,i);continue}r=u+o;let m=!1;for(let v of g)v.icon!==void 0&&(m=!0);let b=t,w=!1;for(let v of g){if(v.icon!==void 0){let k=e.size*1.1;p+=`<svg class="pele-icon" data-icon="${Oe(v.icon)}" x="${d(b)}" y="${d(r-e.size*.35-k/2)}" width="${d(k)}" height="${d(k)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i?.(v.icon)??""}</svg>`}else if(v.text!==""){let k=m||!w?` x="${d(b)}" y="${d(r)}"`:"";f+=`<tspan${k}${Ya(v.style&~s)}>${Ve(v.text)}</tspan>`,w=!0}b+=v.width}}return`<text${Aa(a,s)} xml:space="preserve">${f}</text>${p}`}function Kd(e){let t=an(e);return t===e?e:t.replace(/</g,"&lt;").replace(/>/g,"&gt;")}function LE(e,t,r){return jr(e.direction)?Bt(r,a=>W1(e,t,r,a)):W1(e,t,r,!1)}function W1(e,t,r,a){let i=ME(e),n=r.fontSize??16,l=Math.round(n*.875),s=r.measurer??et(r.fontFamily),o=r.padding??8,c=r.icons,f=new Map,p=[],h=[];i.nodes.forEach((E,x)=>f.set(E.id,x));let g=[],u=[],m=[],b=new Map,w=[];for(let E of i.edges){let x=f.get(E.start),T=f.get(E.end);if(x===void 0||T===void 0)continue;let A=ze(E.label,!0,s,l,200),M;if(x===T){M={label:A,band:0,at:0};let N=b.get(x);N?N.push(M):b.set(x,[M])}w.push(M),m.push(E),u.push(A),g.push({src:x,dst:T,minlen:1,labelW:A.width>0?A.width+12:0,labelH:A.height>0?A.height+4:0,route:[],labelX:0,labelY:0})}let v=E=>{let x=E;for(let T=0;T<i.nodes.length;T++){let A=i.nodes[x].parentId,M=A===void 0?void 0:f.get(A);if(M===void 0)break;let N=i.nodes[M].dir;if(N)return N==="LR"||N==="RL";x=M}return e.direction==="LR"||e.direction==="RL"};for(let E=0;E<i.nodes.length;E++){let x=i.nodes[E],T=vt(x.cssStyles.length>0?x.cssCompiledStyles.concat(x.cssStyles):x.cssCompiledStyles),A=(T.bold?1:0)|(T.italic?2:0),M=T.fontSize??n,N=T.fontSize??l,F=T.fontSize??Math.round(n*.75),U=x.isGroup?ze(x.label,!0,s,M,4e3,A):ze(x.alias||x.label,!0,s,M,240,A),D=b.get(E)??IE,I=D.length>0&&!x.isGroup&&v(E),z={node:x,style:T,label:U,w:0,h:0,headH:0,rows:[],cols:[],rowSize:N,keySize:F,below:I},q=0,j=0;for(let W of D)W.band=Math.max(SE,I?W.label.width+12:W.label.height+6),j+=W.band,q=Math.max(q,I?W.label.height:W.label.width);let Q=Math.max(D1,I?j+8:0),K;if(x.isGroup)K=Ut(0,0),K.isGroup=!0,K.dir=x.dir?br(x.dir):void 0,K.padX=nl,K.padTop=z.label.height>0?z.label.height+16:nl,K.padBottom=nl,K.minW=Math.max(z.label.width+2*nl-12,D1);else{let W=Math.max(U.height,Math.round(M*1.5));if(x.attributes.length===0)z.w=Math.max(U.width+2*O1,Q),z.h=Math.max(W+2*TE,I?0:j+8);else{let te=Math.round(N*1.5),se=[0,0,0,0];for(let re of x.attributes){let fe=[ze(Kd(re.type),!0,s,N,Vd,A),ze(Kd(re.name),!0,s,N,Vd,A),ze(re.keys.join(", "),!1,s,F,Vd,A),ze(Kd(re.comment),!0,s,N,_E,A)],ye=te;for(let le=0;le<4;le++)fe[le].width>se[le]&&(se[le]=fe[le].width),fe[le].height>ye&&(ye=fe[le].height);z.rows.push({cells:fe,h:ye+Xd}),z.h+=ye+Xd}let oe=0,ae=0;for(let re of se)re!==0&&(ae+=re+(oe>0?P1:0),oe++);z.w=Math.max(ae+2*jd,U.width+2*O1,Q);let ne=oe>0?(z.w-ae-2*jd)/oe:0,J=jd;for(let re of se)z.cols.push(J),re>0&&(J+=re+ne+P1);z.headH=W+2*CE,z.h+=z.headH}let X=D.length>0?2*(fi+sl*.75+10+q):0;K=I?Ut(z.w,z.h+X):Ut(z.w+X,z.h)}K.seq=p.length,p.push(z),h.push(K)}i.nodes.forEach((E,x)=>{h[x].parent=E.parentId!==void 0?f.get(E.parentId)??-1:-1});let k=Gr(h,g,a?"TB":br(e.direction),{nodeSep:F1(t,"nodeSpacing",AE),edgeSep:vE,rankSep:F1(t,"rankSpacing",EE),portSep:24});OE(g,h,p);let O=k.width;for(let[E,x]of b){let T=h[E];if(!T.isGroup)continue;let A=0;for(let M of x)A=Math.max(A,M.label.width);O=Math.max(O,T.x+T.w/2+fi+sl*.75+10+A)}let R=Cr(e.title,s,n,4e3),L=R.height>0?R.height+12:0,P=Math.max(O,R.width),B=o+(P-O)/2,G=o+L;vi(h,g,B,G);let C=Math.ceil(P+2*o),Z=Math.ceil(k.height+L+2*o),ee=[],H=new Map,Y=!1;for(let E of h)E.isGroup&&(Y=!0);if(Y)for(let E of g)va(H,E.route);let _="",S="";for(let E=0;E<p.length;E++){let x=p[E],T=h[E],A=x.node,M=It(A.cssClasses.replace(/^default\s?/,""));if(T.isGroup){x.w=T.w,x.h=T.h;let K=T.x-T.w/2,W=T.y-T.h/2,X=Ai(T,x.label.width,H,nl);_+=`<g class="pele-cluster${M}" data-id="${Oe(A.id)}"><rect x="${d(K)}" y="${d(W)}" width="${d(T.w)}" height="${d(T.h)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${ft(x.style.shape)}/>`+Re(x.label,X,W+8+x.label.height/2,` class="pele-cluster-label" fill="var(--_m)"${x.style.text}`,c)+"</g>";continue}let N=x.w,F=x.h,U=-N/2,D=-F/2,I=x.style.text,z=`x="${d(U)}" y="${d(D)}" width="${d(N)}" height="${d(F)}"`,q=Re(x.label,0,x.rows.length>0?D+x.headH/2:0,` class="pele-label"${I}`,c),j=At(A.alias||A.label);if(/ internal-link(?: |$)/.test(M+" ")&&q!==""&&r.links!==!1){let K=oi(Sa(j),r)!==void 0,W=Ve(j);q=`<a class="internal-link"${K?` href="${W}"${ci(r)}`:""} data-href="${W}">${q}</a>`,ee.push({id:A.label,href:j,internal:!0})}let Q;if(x.rows.length===0)Q=`<rect ${z}${ft(z1+x.style.shape)}/>`+q;else{let K=Math.round(x.rowSize*1.5),W=x.style.stroke?Ve(x.style.stroke):"var(--_b)",X="",te="",se=D+x.headH;for(let ae=0;ae<x.rows.length;ae++){let ne=x.rows[ae];if(ae%2===0){let we=`x="${d(U)}" width="${d(N)}"`;ae===x.rows.length-1?X+=`<rect ${we} y="${d(se)}" height="${d(ne.h)}"${nt}/><rect ${we} y="${d(se)}" height="${d(ne.h/2)}"/>`:X+=`<rect ${we} y="${d(se)}" height="${d(ne.h)}"/>`}let J=se+Xd/2+K/2+x.rowSize*.35,[re,fe,ye,le]=ne.cells;te+=Oo(re,U+x.cols[0],J,` class="pele-er-type" fill="var(--_m)"${I}`,c)+Oo(fe,U+x.cols[1],J,` class="pele-er-name"${I}`,c)+Oo(ye,U+x.cols[2],J,` class="pele-er-keys" font-size="${x.keySize}" fill="var(--_m)"${I}`,c)+Oo(le,U+x.cols[3],J,` class="pele-er-comment" fill="var(--_m)"${I}`,c),se+=ne.h}let oe=d(D+x.headH);Q=`<rect ${z}${ft(z1+x.style.shape)}/><g class="pele-er-stripes" fill="var(--_bg)"${x.style.shape.includes("fill:")?' opacity="0.6"':""}>${X}</g><path class="pele-er-divider" d="M${d(U)},${oe}H${d(U+N)}" stroke="${W}"/><rect ${z} fill="none" stroke="var(--_b)"${ft(x.style.line)}/>`+q+`<g class="pele-er-attributes" font-size="${x.rowSize}">${te}</g>`}S+=`<g class="pele-node pele-entity${M}" data-id="${Oe(A.label)}" transform="translate(${d(T.x)},${d(T.y)})">${Q}</g>`}for(let[E,x]of b){let T=p[E],A=0;for(let F of x)A+=F.band;let M=Math.min(1,Math.max((T.below?T.w:T.h)-8,0)/A),N=-A*M/2;for(let F of x)F.band*=M,F.at=N+F.band/2,N+=F.band}let $="",y="";for(let E=0;E<g.length;E++){let x=g[E],T=m[E],A=u[E],M,N,F,U=w[E];if(U){let I=h[x.src],z=p[x.src],q=Math.max(Math.min(U.band/2-6,13),1),j=fi+sl*.75+6;if(z.below){let Q=I.x+U.at,K=I.y+z.h/2,W=d(K+fi),X=d(K+fi+sl);M=`M${d(Q-q)},${d(K)}V${W}C${d(Q-q)},${X} ${d(Q+q)},${X} ${d(Q+q)},${W}V${d(K)}`,N=Xn(T.arrowTypeStart,Q-q,K,0,-1),F=Xn(T.arrowTypeEnd,Q+q,K,0,-1),x.labelX=Q,x.labelY=K+j+A.height/2}else{let Q=I.x+z.w/2,K=I.y+U.at,W=d(Q+fi),X=d(Q+fi+sl);M=`M${d(Q)},${d(K-q)}H${W}C${X},${d(K-q)} ${X},${d(K+q)} ${W},${d(K+q)}H${d(Q)}`,N=Xn(T.arrowTypeStart,Q,K-q,-1,0),F=Xn(T.arrowTypeEnd,Q,K+q,-1,0),x.labelX=Q+j+A.width/2,x.labelY=K}}else{let I=DE(x.route);if(I.length<6)continue;B1(I,0,p[x.src],h[x.src]),B1(I,I.length-3,p[x.dst],h[x.dst]);let z=Math.abs(I[I.length-3]-I[0]),q=Math.abs(I[I.length-2]-I[1]),j=I.length===6&&(z<.01||q<.01||Math.hypot(z,q)<=3*fi)?0:fi,Q=zr(I,void 0,j,j);M=j>0?`M${d(Q.sx)},${d(Q.sy)}L${Q.d.slice(1)}L${d(Q.ex)},${d(Q.ey)}`:Q.d,N=Xn(T.arrowTypeStart,Q.sx,Q.sy,Q.sdx,Q.sdy),F=Xn(T.arrowTypeEnd,Q.ex,Q.ey,Q.edx,Q.edy)}let D=T.pattern==="dashed";if($+=`<g class="pele-edge pele-er-${D?"non-identifying":"identifying"}" data-id="${Oe(T.id)}"><path d="${M}"${D?' stroke-dasharray="4 3"':""}/>`+N+F+"</g>",A.width>0){let I=x.labelX,z=x.labelY;y+=wr(T.id,A,I,z,"",c)}}return{svg:Je("er",C,Z,n,r,e,Re(R,C/2,o+R.height/2,' class="pele-title" font-weight="var(--_tw)"')+(_?`<g class="pele-clusters">${_}</g>`:"")+($?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${$}</g>`:"")+(y?`<g class="pele-edge-labels" font-size="${l}">${y}</g>`:"")+`<g class="pele-nodes">${S}</g>`),width:C,height:Z,links:ee}}function DE(e){let t=e.slice(0,3);for(let r=3;r<e.length;r+=3){let a=t.length-3,i=n=>Math.abs(t[a+n]-e[r+n])<.01&&Math.abs(e[r+n]-e[r+3+n])<.01;r+3<e.length&&(i(0)||i(1))||t.push(e[r],e[r+1],e[r+2])}return t}function OE(e,t,r){let a=new Map,i=(n,l,s,o)=>{let c=t[n],f=l[s]-c.x,p=l[s+1]-c.y,h;if(Math.abs(Math.abs(p)-c.h/2)<.5)h=p<0?0:2;else if(Math.abs(Math.abs(f)-c.w/2)<.5)h=f<0?3:1;else return;let g=n*4+h,u={route:l,at:s,toward:l[o+(h&1?1:0)]},m=a.get(g);m?m.push(u):a.set(g,[u])};for(let n of e){let l=n.route.length-3;n.src===n.dst||l<3||(i(n.src,n.route,0,3),i(n.dst,n.route,l,l-3))}for(let[n,l]of a){if(l.length<2)continue;let s=n>>2,o=(n&1)===1,c=t[s].isGroup?t[s]:r[s],f=o?c.h:c.w,p=Math.max(Math.min(NE,(f-2*RE)/(l.length-1)),0),h=o?t[s].y:t[s].x;l.sort((g,u)=>g.toward-u.toward);for(let g=0;g<l.length;g++)l[g].route[l[g].at+(o?1:0)]=h+(g-(l.length-1)/2)*p}}function B1(e,t,r,a){if(a.isGroup)return;let i=e[t]-a.x,n=e[t+1]-a.y;a.w!==r.w&&Math.abs(Math.abs(i)-a.w/2)<.5&&(e[t]-=Math.sign(i)*(a.w-r.w)/2),a.h!==r.h&&Math.abs(Math.abs(n)-a.h/2)<.5&&(e[t+1]-=Math.sign(n)*(a.h-r.h)/2)}var pE,_1,ll,Po,Zd,ol,_a,uE,gE,mE,yE,Hd,Ud,qd,wE,Y1,bE,Do,kE,fi,N1,R1,Gd,L1,AE,vE,EE,nl,sl,SE,D1,O1,TE,CE,jd,P1,Xd,_E,Vd,IE,NE,RE,z1,H1,U1=Xe(()=>{Yd();Bn();Ei();Ea();hi();tr();zt();pr();ut();wt();pE=class{constructor(){he(this,"type","er");he(this,"direction","TB");he(this,"entities",new Map);he(this,"relationships",[]);he(this,"classes",new Map);he(this,"subgraphs",[]);he(this,"title");he(this,"accTitle");he(this,"accDescr");he(this,"subgraphLookup",new Map);he(this,"claimed",new Set)}addEntity(e,t=""){let r=this.entities.get(e);return r===void 0?(r={id:`entity-${e}-${this.entities.size}`,label:e,alias:t,attributes:[],cssClasses:"default",cssStyles:[]},this.entities.set(e,r)):!r.alias&&t&&(r.alias=t),r}addAttributes(e,t){let r=this.addEntity(e);for(let a=t.length-1;a>=0;a--){let i=t[a];i.keys??(i.keys=[]),i.comment??(i.comment=""),r.attributes.push(i)}}addRelationship(e,t,r,a){let i=this.subgraphLookup.has(e)?e:this.addEntity(e).id,n=this.subgraphLookup.has(r)?r:this.addEntity(r).id;this.relationships.push({entityA:i,roleA:t,entityB:n,relSpec:a})}setDirection(e){this.direction=e}addCssStyles(e,t){if(t)for(let r of e){let a=this.entities.get(r);if(a)for(let n of t)a.cssStyles.push(n);let i=this.subgraphLookup.get(r);if(i)for(let n of t)i.cssStyles.push(n)}}addClass(e,t){for(let r of e){let a=this.classes.get(r);if(a===void 0&&(a={id:r,styles:[],textStyles:[]},this.classes.set(r,a)),!!t)for(let i of t)i.includes("color")&&a.textStyles.push(i.replace("fill","bgFill")),a.styles.push(i)}}setClass(e,t){for(let r of e){let a=this.entities.get(r);if(a)for(let n of t)a.cssClasses+=" "+n;let i=this.subgraphLookup.get(r);if(i)for(let n of t)i.classes.push(n)}}addSubGraph(e,t,r){let a=e.text.trim(),i=new Set,n=[],l;for(let o of t.flat()){if(typeof o!="string"){o?.stmt==="dir"&&(l=o.value);continue}let c=o.trim();c===""||i.has(c)||(i.add(c),this.claimed.has(o)||n.push(o))}for(let o of n)this.claimed.add(o);let s={id:a,nodes:n,title:(r.text||"").trim(),classes:[],cssStyles:[],dir:l,labelType:fE(r.type)};return this.subgraphs.push(s),this.subgraphLookup.set(a,s),a}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
56
+ `)}},_1=["$end","INVALID","ER_DIAGRAM","EOF","NEWLINE","COLON","STYLE_SEPARATOR","BLOCK_START","BLOCK_STOP","SQS","SQE","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","END","SUBGRAPH","direction_tb","direction_bt","direction_rl","direction_lr","CLASSDEF","UNICODE_TEXT","STYLE_TEXT","COMMA","CLASS","STYLE","SEMI","NUM","BRKT","ENTITY_NAME","DECIMAL_NUM","ENTITY_ONE","ATTRIBUTE_WORD","ATTRIBUTE_KEY","COMMENT","ZERO_OR_ONE","ZERO_OR_MORE","ONE_OR_MORE","ONLY_ONE","MD_PARENT","NON_IDENTIFYING","IDENTIFYING","WORD","CHAR"],ll=1,Po=2,Zd=4,ol=8,_a=new Uint8Array(128);for(let e=0;e<128;e++){let t=e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95,r=t&&(e<48||e>57);t&&(_a[e]|=ll|Po|ol),r&&(_a[e]|=Zd)}for(let e of"-*")_a[e.charCodeAt(0)]|=ll|Po|ol;_a[46]|=ll|ol;_a[42]|=Zd;for(let e of"[](),")_a[e.charCodeAt(0)]|=ol;uE=/accTitle\s*:\s*/iy,gE=/accDescr\s*:\s*/iy,mE=/accDescr\s*\{\s*/iy,yE=[/.*direction\s+TB[^\n]*/iy,/.*direction\s+BT[^\n]*/iy,/.*direction\s+RL[^\n]*/iy,/.*direction\s+LR[^\n]*/iy],Hd=/direction/gi,Ud=/[\n\r\u2028\u2029]/g;qd=new Map([[37,"ZERO_OR_ONE"],[38,"ZERO_OR_MORE"],[39,"ONE_OR_MORE"],[40,"ONLY_ONE"],[41,"MD_PARENT"]]),wE=["TB","BT","RL","LR"],Y1="'UNICODE_TEXT', 'NUM', 'ENTITY_NAME', 'DECIMAL_NUM', 'ENTITY_ONE'",bE="'ZERO_OR_ONE', 'ZERO_OR_MORE', 'ONE_OR_MORE', 'ONLY_ONE', 'MD_PARENT'",Do="'EOF', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'SUBGRAPH', 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'CLASSDEF', 'CLASS', 'STYLE', "+Y1;kE=[];fi=18,N1=5,R1=6,Gd=10,L1=3.5;AE=48,vE=20,EE=64,nl=20,sl=28,SE=38,D1=96,O1=18,TE=12,CE=9,jd=12,P1=16,Xd=9,_E=260,Vd=1e6,IE=[],NE=18,RE=14,z1=' fill="var(--_s)" stroke="var(--_b)"';H1={type:"er",math:!0,parse(e,t,r){let a=new pE;return r&&(a.title=r),$E(e,a),a},render:LE}});var q1={};_t(q1,{er:()=>H1});var G1=Xe(()=>{U1()});function j1(e,t){return e===5?t?"KANBAN":"MINDMAP":PE[e]}function zo(e,t){switch(e){case"[":return Ii.RECT;case"(":return t===")"?Ii.ROUNDED_RECT:Ii.CLOUD;case"((":return Ii.CIRCLE;case")":return Ii.CLOUD;case"))":return Ii.BANG;case"{{":return Ii.HEXAGON;default:return Ii.DEFAULT}}function X1(e,t,r){for(let a=0;a<r.length;a++)if((e.charCodeAt(t+a)|32)!==r.charCodeAt(a))return!1;return!0}function qE(e,t){let r=e.length,a=[],i=[],n=[],l=t?"kanban":"mindmap",s=t?WE:FE,o=0,c=0,f=-1,p=(m,b,w)=>{a.push(m),i.push(b),n.push(c),c=w},h=(m,b,w)=>{p(m,e.slice(c,b),b),o=w},g=(m,b)=>(m.lastIndex=b,m.test(e)?m.lastIndex:-1),u=m=>{let b=e.indexOf(m,c);return b===-1?r:b};for(;c<r;){let m=e.charCodeAt(c),b=e.charCodeAt(c+1),w;if(o===0){let v=m<=32||m>=160?Math.max(g(zE,c),c):c;if(t&&m===64&&b===123)p(13,"",c+2),o=6;else if(e.charCodeAt(v)===37&&e.charCodeAt(v+1)===37)h(2,g(Qd,v),0);else if(v>c)f<c&&(f=u(`
57
+ `)),f>=v?h(6,v,0):(w=e.lastIndexOf(`
58
+ `,v-1))>c?h(2,w+1,0):h(3,c+1,0);else if(X1(e,c,l)&&!Qe(e.charCodeAt(c+l.length)))h(5,c+l.length,0);else if(m===58&&b===58&&e.charCodeAt(c+2)===58)c+=3,o=1;else if(m===58&&b===58&&X1(e,c+2,"icon")&&e.charCodeAt(c+6)===40)c+=7,o=2;else if(m===45&&b===41||m===40&&(b===45||b===40)||(m===41||m===123)&&b===m)h(9,c+2,3);else if(m===41||m===40||m===91)h(9,c+1,3);else if((w=g(s,c))!==-1)h(10,w,0);else break}else if(o===3)m===34?(o=b===96?5:4,c+=b===96?2:1):m===41||m===40?h(12,b===m||m===40&&b===45?c+2:c+1,0):m===93?h(12,c+1,0):m===125&&b===125||m===45&&b===41?h(12,c+2,0):h(11,g(m===125?Qd:BE,c),3);else if(o===4)m===34?(c++,o=3):h(11,u('"'),4);else if(o===5)if(m===96&&b===34)c+=2,o=3;else if((w=g(YE,c))!==-1)h(11,w,5);else break;else if(o===1)if((w=g(Qd,c))!==-1)h(8,w,0);else if(m===10)c++,o=0;else break;else if(o===2)m===41?(c++,o=0):h(7,u(")"),2);else if(o===6)if(m===34)h(13,c+1,7);else if(m===125)c++,o=0;else if((w=g(HE,c))!==-1)h(13,w,6);else break;else m===34?h(13,c+1,6):(w=u('"'),p(13,e.slice(c,w).replace(UE,"<br/>"),w))}return c<r?p(1,"",c):(o===0&&p(4,"",r),p(0,"",r)),{types:a,texts:i,starts:n}}function Vn(e){return e===2||e===3||e===4}function Fo(e,t,r){let a=r?"kanban":"mindmap",{types:i,texts:n,starts:l}=qE(e,r),s=r?", 'SHAPE_DATA'":"",o=0,c=h=>{let g=i[o];throw g===1?it(a,e,l[o],"",!0):it(a,e,l[o],`Expecting ${h}, got '${j1(g,r)}'`)},f=`'${j1(5,r)}'`;if(i[o]===2){for(o++;i[o]===2||i[o]===3;)o++;i[o]!==5&&c(`'SPACELINE', 'NL', ${f}`)}else i[o]!==5&&c(`'SPACELINE', ${f}`);o++;let p="'SPACELINE', 'NL', 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'";for(i[o]===3&&(o++,p="'SPACELINE', 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'");;){let h=i[o],g=0,u=h===6;if(u&&(g=n[o++].length,h=i[o]),h===10||h===9){let m,b,w=0;if(h===10&&(m=n[o++]),i[o]===9){let v=n[o++];i[o]!==11&&c("'NODE_DESCR'"),b=n[o++],i[o]!==12&&c("'NODE_DEND'");let k=n[o++];!Vn(i[o])&&i[o]!==13&&c(nn+s),w=t.getType(v,k)}else!Vn(i[o])&&i[o]!==13&&c(nn+", 'NODE_DSTART'"+s),b=m;if(i[o]===13){let v=n[o++];for(;i[o]===13;)v+=n[o++];Vn(i[o])||c(nn+s),t.addNode(g,m??b,b,w,v)}else t.addNode(g,m??b,b,w)}else if(h===7||h===8){let m=n[o++];Vn(i[o])||c(nn),t.decorateNode(h===7?{icon:m}:{class:m})}else u?Vn(h)||c(nn+", 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'"):h===2?Vn(i[++o])||c(nn):c(p);for(o++;i[o]===3||i[o]===4;)o++;if(i[o]===0)return;V1[i[o]]===0&&c(nn+", 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'")}}function cl(e,t,r,a,i){return`<svg class="pele-icon" data-icon="${Oe(e)}" x="${d(t)}" y="${d(r)}" width="${d(a)}" height="${d(a)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i?.(e)??""}</svg>`}var PE,Ii,zE,Qd,FE,WE,BE,YE,HE,UE,nn,V1,Jd=Xe(()=>{tr();ut();wt();PE=["1","INVALID","SPACELINE","NL","EOF","","SPACELIST","ICON","CLASS","NODE_DSTART","NODE_ID","NODE_DESCR","NODE_DEND","SHAPE_DATA"];Ii={DEFAULT:0,NO_BORDER:0,ROUNDED_RECT:1,RECT:2,CIRCLE:3,CLOUD:4,BANG:5,HEXAGON:6};zE=/\s+/y,Qd=/.+/y,FE=/[^([\n){}]+/y,WE=/[^([\n){}@]+/y,BE=/[^)\](}]+/y,YE=/[^`"]+/y,HE=/[^}^"]+/y,UE=/\n\s*/g;nn="'SPACELINE', 'NL', 'EOF'",V1=new Uint8Array(14);for(let e of[2,6,7,8,9,10])V1[e]=1});function XE(e,t){Fo(e,t,!1)}function r3(e,t,r,a){if(e.lines.length<2)return Re(e,t+e.width/2,r,' class="pele-label"',a);let i="",n=r-e.height/2;for(let l=0;l<e.lines.length;l++)i+=Re(Ua(e,l),t+e.widths[l]/2,n+Ha(e,l),' class="pele-label"',a);return i}function a3(e,t,r){return Bt(r,a=>i3(e,t,r,a))}function i3(e,t,r,a){let i=r.fontSize??16,n=r.measurer??et(r.fontFamily),l=r.padding??8,s=r.icons,o=t.mindmap?.maxNodeWidth,c=typeof o=="number"&&o>0?Math.min(o,2e3):200,f=i*1.25,p=e.nodes,h=p.length,g=new Int32Array(h),u=new Int32Array(h);for(let K=0;K<h;K++)for(let W of p[K].children)g[W.id]=K,u[W.id]=u[K]+1;let m=a&&r.maxWidth!==void 0&&r.maxWidth>0?r.maxWidth-2*l:1/0,b=new Array(h),w=new Array(h),v=new Float64Array(h),k=new Float64Array(h),O=new Float64Array(h),R=new Float64Array(h),L=new Uint8Array(h);for(let K=0;K<h;K++){let W=p[K];L[K]=W.icon!==void 0&&Pn(W.icon)!==""?1:0;let X=Math.min(c,Math.max(72,m-u[K]*tf-2*Q1-(L[K]?f+ef:0))),te=b[K]=ze(W.descr,!0,n,i,X),se=te.width+(L[K]?f+(te.width>0?ef:0):0),oe=Math.max(te.height,Math.round(i*1.5)),ae=VE[W.type]||(K===0?K1:"");if(a&&K===0&&ae!=="rect"&&ae!=="rounded"&&(ae=K1),w[K]=ae,ae===""){let ne=W.children.length>0;v[K]=se+2*(ne?e3:Q1),k[K]=oe+(ne?6:0),R[K]=k[K]/2}else{let ne=Si(ae,se,oe);v[K]=ne.w,k[K]=ne.h,O[K]=ne.dy,R[K]=ne.h/2}}let P=new Float64Array(h),B=new Float64Array(h),G=new Float64Array(h),C=new Float64Array(h),Z=0,ee=(K,W,X,te)=>{let se=0,oe=0;for(let J=W;J<X;J++){let re=K[J].id;B[re]=se,oe=K[J].children.length>0||J+1<X&&K[J+1].children.length>0?Math.max(te,QE):te,se+=P[re]+oe}Z=se-oe;let ae=K[W].id,ne=K[X-1].id;return(B[ae]+G[ae]+R[ae]+B[ne]+G[ne]+R[ne])/2};for(let K=h-1;K>0;K--){let W=p[K].children;if(W.length===0){P[K]=k[K];continue}let X=ee(W,0,W.length,ZE)-R[K],te=Math.min(0,X);P[K]=Math.max(Z,X+k[K])-te,G[K]=X-te,C[K]=-te}let H=new Float64Array(h),Y=new Float64Array(h),_=new Float64Array(h),S=new Int8Array(h),$=new Float64Array(h);if(a){let K=0;for(let W=0;W<h;W++)W>0&&g[W]===0&&(K+=tg),H[W]=u[W]*tf+v[W]/2,Y[W]=K,K+=k[W]+tg}else if(h>0){let K=p[0].children,W=K.length,X=0;for(let ae of K)X+=P[ae.id];let te=W,se=1/0,oe=0;for(let ae=1;ae<W;ae++){oe+=P[K[ae-1].id];let ne=Math.abs(2*oe-X+(2*ae-W)*Z1);ne<se&&(se=ne,te=ae)}for(let ae=0,ne=te,J=1;ae<W;ae=ne,ne=W,J=-1){let re=ee(K,ae,ne,Z1);for(let fe=ae;fe<ne;fe++){let ye=K[fe].id;_[ye]=B[ye]-re,S[ye]=J}}Y[0]=-k[0]/2;for(let ae=0;ae<h;ae++){ae>0&&(Y[ae]=_[ae]+G[ae]);for(let ne of p[ae].children){let J=ne.id;ae>0&&(S[J]=S[ae],_[J]=_[ae]+C[ae]+B[J]),H[J]=H[ae]+S[J]*(v[ae]/2+(ae>0?KE:JE)+v[J]/2)}}}let y=0,E=0,x=0,T=0,A="",M="",N="",F="",U=K=>{N!==""&&(A+=`<g class="pele-branch pele-section-${K??0}"><g class="pele-edges" fill="none" stroke="${F}" stroke-width="1.5">${M}</g>${N}</g>`,M=N="")};for(let K=1;K<=h;K++){let W=K%h,X=p[W],te=w[W],se=b[W],oe=H[W],ae=Y[W];if(y=Math.min(y,oe-v[W]/2),E=Math.max(E,oe+v[W]/2),x=Math.min(x,ae),T=Math.max(T,ae+k[W]),(W===0||g[W]===0)&&U(p[K-1].section),W>0&&a){g[W]===0&&(F=dt(X.section??0));let le=g[W],we=le===0?Math.min(Math.max(J1,k[0]/2),tf-eg):J1,pe=H[le]-v[le]/2+Math.min(we,v[le]/2),ge=$[le]||Y[le]+k[le],Ae=oe-v[W]/2+(te?di(te,v[W],k[W],3):0),Se=ae+R[W],ce=Math.max(0,Math.min(eg,Ae-pe,Se-ge));$[le]=Se-ce,M+=`<path class="pele-edge" d="M${d(pe)},${d(ge)}V${d(Se-ce)}Q${d(pe)},${d(Se)} ${d(pe+ce)},${d(Se)}H${d(Ae)}"/>`}else if(W>0){g[W]===0&&(F=dt(X.section??0));let le=g[W],we=S[W],pe=we>0?1:3,ge=H[le]+we*(v[le]/2-(w[le]?di(w[le],v[le],k[le],pe):0)),Ae=Y[le]+R[le],Se=oe-we*v[W]/2+(te?we*di(te,v[W],k[W],4-pe):0),ce=ae+R[W],ue=d((ge+Se)/2);M+=`<path class="pele-edge" d="M${d(ge)},${d(Ae)}C${ue},${d(Ae)} ${ue},${d(ce)} ${d(Se)},${d(ce)}"/>`}let ne=!te&&X.children.length>0,J=` fill="${F}" fill-opacity="${t3}" stroke="${F}"`,re="";te?re=W>0?Ca(te,v[W],k[W],J,` stroke="${F}"`):Ca(te,v[W],k[W],' fill="var(--_s)" stroke="var(--_b)"',' stroke="var(--_b)"'):ne&&(re=`<rect x="${d(-v[W]/2)}" y="${d(-k[W]/2)}" width="${d(v[W])}" height="${d(k[W])}" rx="${d(k[W]/2)}"${J}/>`);let fe=0;X.icon&&L[W]&&(fe=(f+(se.width>0?ef:0))/2,re+=cl(X.icon,-fe-se.width/2,O[W]-f/2,f,s));let ye=`<g class="pele-node pele-shape-${te||(ne?"branch":"text")}${W>0?"":" pele-root"}${It(X.class??"")}" data-id="${Oe(X.nodeId)}" transform="translate(${d(oe)},${d(ae+k[W]/2)})">`+re+(a&&!te?r3(se,fe-se.width/2,O[W],s):Re(se,fe,O[W],' class="pele-label"',s))+"</g>";W>0?N+=ye:A+=ye}let D=Cr(e.title,n,i,Nt(r)),I=D.height>0?D.height+16:0,z=Math.max(E-y,D.width),q=Math.ceil(z+2*l),j=Math.ceil(T-x+I+2*l),Q=Re(D,q/2,l+D.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${d(l-y+(z-E+y)/2)},${d(l+I-x)})">${A}</g>`;return{svg:Je("mindmap",q,j,i,r,{},Q),width:q,height:j,links:[]}}var GE,jE,VE,K1,KE,ZE,QE,JE,Z1,Q1,e3,t3,ef,tf,J1,eg,tg,rg,ag=Xe(()=>{Jd();Ea();Ti();zt();ut();wt();GE=11,jE=class{constructor(){he(this,"type","mindmap");he(this,"title");he(this,"nodes",[]);he(this,"getType",zo);he(this,"baseLevel",0);he(this,"open",[])}addNode(e,t,r,a){let i=this.nodes.length===0;i&&(this.baseLevel=e),e-=this.baseLevel;let n=this.open,l=n.length;for(;l>0&&n[l-1].level>=e;)l--;let s=n[l-1];if(!s&&!i)throw new je(`There can be only one root. No parent could be found for ("${r}")`,"semantic",{type:"mindmap"});let o={id:this.nodes.length,nodeId:t,level:e,descr:r,type:a,children:[],isRoot:i};s&&(o.section=s.isRoot?s.children.length%GE:s.section,s.children.push(o)),n.length=l,n.push(o),this.nodes.push(o)}decorateNode(e){let t=this.nodes[this.nodes.length-1];!e||!t||(e.icon&&(t.icon=e.icon),e.class&&(t.class=e.class))}};VE=["","rounded","rect","circle","cloud","bang","hex"],K1="stadium",KE=36,ZE=8,QE=18,JE=52,Z1=28,Q1=6,e3=12,t3=.22,ef=6,tf=28,J1=12,eg=8,tg=10;rg={type:"mindmap",math:!0,parse(e,t,r){let a=new jE;return a.title=r,XE(e,a),a},render:a3}});var ig={};_t(ig,{mindmap:()=>rg});var ng=Xe(()=>{ag()});function s3(e,t){Fo(e,t,!0)}function Wo(e,t,r,a,i,n=0){let l=ze(e,t,r,a,i,n);if(l.width<=i)return l;let s=[],o=[],c=0,f=[],p=0,h=()=>{s.push(f),o.push(p),c=Math.max(c,p),f=[],p=0};for(let u=0;u<l.lines.length;u++){if(l.widths[u]<=i){f=l.lines[u],p=l.widths[u],h();continue}for(let m of l.lines[u]){if(m.icon!==void 0||m.math){p>0&&p+m.width>i&&h(),f.push(m),p+=m.width;continue}let b="",w=p;for(let v of m.text){let k=r.width(v,a,m.style);p>0&&p+k>i&&(b&&f.push({text:b,style:m.style,width:p-w}),h(),b="",w=0),b+=v,p+=k}b&&f.push({text:b,style:m.style,width:p-w})}h()}let g={...l,lines:s,widths:o,width:c,height:s.length*l.lineHeight};return l.heights?Us(g):g}function dl(e,t,r,a,i,n=!1){let l="";for(let s=0;s<e.lines.length;s++){let o=e.lines[s],c=r+Ha(e,s);if(o.length===1&&o[0].icon===void 0&&o[0].math===void 0)l+=`<text${Aa(a,o[0].style)} x="${d(t)}" y="${d(c+e.size*.35)}"${n?' text-anchor="end"':""}>${Ve(o[0].text)}</text>`;else{let f=e.widths[s];l+=Re(Ua(e,s),t+(n?-f:f)/2,c,a,i)}}return l}function c3(e,t,r){let a=r.fontSize??16,i=Math.round(a*.875),n=Math.round(a*1.5),l=Math.round(i*1.5),s=r.measurer??et(r.fontFamily),o=r.padding??8,c=r.icons,f=t.kanban??{},p=f.sectionWidth,h=i*1.25,g=0,u=(I,z,q)=>{if(!(!I||!I.includes("$$")))for(let j of ze(I,!0,s,z,1/0).lines)for(let Q of j)Q.math&&(g=Math.max(g,Q.math.width+q))};for(let I of e.sections){let z=s.width(String(I.items.length),i,0);u(I.label,a,2*ja+8+z+12+(Kn(I.icon)?h+hl:0));for(let q of I.items){let j=2*(ja+Ia);u(q.label,i,j+(Kn(q.icon)?h+hl:0)),u(q.ticket,i,j),u(q.assigned,i,j)}}let m=Math.max(typeof p=="number"&&p>0?Math.min(Math.max(p,80),2e3):200,Math.ceil(g)),b=r.maxWidth!==void 0&&r.maxWidth>0?r.maxWidth-2*o:1/0,w=e.sections.length,v=w*(m+Ga)-Ga<=b,k=v?Math.max(w,1):Math.max(1,Math.floor((b+Ga)/(m+Ga))),O=v?m:Math.max(Math.min(m,b),Math.min(Math.floor((b+Ga)/k)-Ga,m*2),Math.ceil(g)),R=typeof f.ticketBaseUrl=="string"?f.ticketBaseUrl:"",L=O-2*ja,P=L-2*Ia,B=[],G=e.sections,C=[],Z=[],ee=[],H=n,Y=[];for(let I of G){let z=s.width(String(I.items.length),i,0),q=z+12+(Kn(I.icon)?h+hl:0),j=Wo(I.label,!0,s,a,L-8-q,1);H=Math.max(H,j.height),Z.push(z),C.push(j);let Q=[],K=0;for(let W of I.items){let X=Wo(W.label,!0,s,i,P-(Kn(W.icon)?h+hl:0)),te=Wo(W.ticket,!1,s,i,P),se=Wo(W.assigned,!1,s,i,P),oe=te.width+se.width+8>P?te.height+se.height:Math.max(te.height,se.height),ae=2*Ia+Math.max(X.height,l)+(oe?l3+oe:0);Q.push({item:W,label:X,ticket:te,assigned:se,meta:oe,height:ae}),K+=ae+rf}ee.push(Q),Y.push(K)}H+=2*ja;let _=[],S=[];for(let I=0,z=0;I<G.length;I+=k){let q=rf;for(let j=I;j<Math.min(I+k,G.length);j++)q=Math.max(q,Y[j]);S.push(z),_.push(H+q),z+=H+q+Ga}let $=_.length>0?S[S.length-1]+_[_.length-1]:0,y=Cr(e.title,s,a,Nt(r)),E=y.height>0?y.height+16:0,x=Math.max(Math.min(G.length,k)*(O+Ga)-Ga,0),T=Math.max(x,y.width),A=o+(T-x)/2,M=O-ja-4,N="";for(let I=0;I<G.length;I++){let z=G[I],q=Math.floor(I/k),j=`<rect width="${O}" height="${d(_[q])}" fill="var(--_s)"${nt}/>`+dl(C[I],ja+4,ja,' class="pele-cluster-label" font-weight="var(--_hw)"',c)+`<text class="pele-count" x="${M}" y="${d(ja+n/2+i*.35)}" text-anchor="end" font-size="${i}" fill="var(--_m)">${z.items.length}</text>`;Kn(z.icon)&&(j+=cl(z.icon,M-Z[I]-hl-h,ja+(n-h)/2,h,c));let Q=H;for(let K of ee[I]){let W=K.item,X=(W.priority??"").trim().toLowerCase(),te=o3.get(X),se=`<rect width="${L}" height="${d(K.height)}" fill="var(--_bg)" stroke="var(--_b)"${nt}/>`;te!==void 0&&(se+=`<path class="pele-priority" d="M2.5,5V${d(K.height-5)}" fill="none" ${te} stroke-width="3" stroke-linecap="round"/>`),se+=dl(K.label,Ia,Ia,' class="pele-label"',c),Kn(W.icon)&&(se+=cl(W.icon,L-Ia-h,Ia+(l-h)/2,h,c));let oe=K.height-Ia;if(W.ticket){let ae=oe-K.meta,ne=R?oi(Ta(R.replace("#TICKET#",()=>W.ticket)),r):void 0;ne===void 0?se+=dl(K.ticket,Ia,ae,' class="pele-ticket" fill="var(--_m)"',c):(se+=`<a href="${Ve(ne)}" target="_blank"${ci(r)}>`+dl(K.ticket,Ia,ae,' class="pele-ticket" fill="var(--_c)"',c)+"</a>",B.push({id:W.id,href:ne,internal:!1}))}W.assigned&&(se+=dl(K.assigned,L-Ia,oe-K.assigned.height,' class="pele-assigned" fill="var(--_m)"',c,!0)),j+=`<g class="pele-node pele-card${te===void 0?"":" pele-priority-"+X.replace(" ","-")}${It(W.cssClasses??"")}" data-id="${Oe(W.id)}" transform="translate(${ja},${d(Q)})" font-size="${i}">${se}</g>`,Q+=K.height+rf}N+=`<g class="pele-cluster pele-column${It(z.cssClasses??"")}" data-id="${Oe(z.id)}" transform="translate(${d(A+I%k*(O+Ga))},${d(o+E+S[q])})">${j}</g>`}let F=Math.ceil(T+2*o),U=Math.ceil($+E+2*o),D=Re(y,F/2,o+y.height/2,' class="pele-title" font-weight="var(--_tw)"')+N;return{svg:Je("kanban",F,U,a,r,{},D),width:F,height:U,links:B}}var n3,Ga,ja,Ia,rf,l3,hl,o3,Kn,sg,lg=Xe(()=>{Jd();Dn();Ea();hi();zt();ut();wt();n3=class{constructor(){he(this,"type","kanban");he(this,"title");he(this,"sections",[]);he(this,"getType",zo);he(this,"last");he(this,"sectionLevel",0);he(this,"misplaced")}addNode(e,t,r,a,i){let n={id:t,level:e,label:r};if(i!==void 0){let s=i.includes(`
59
+ `)?i+`
60
+ `:`{
61
+ `+i+`
62
+ }`,o;try{o=Ma(s)}catch(c){throw new je(`Metadata of "${n.id}" is not valid YAML. ${c.message}`,"syntax",{type:"kanban"})}if(o!==null&&typeof o=="object"&&!Array.isArray(o)){let c=o.shape?String(o.shape):"";if(c!==c.toLowerCase()||c.includes("_"))throw new je(`No such shape: ${c}. Shape names should be lowercase.`,"semantic",{type:"kanban"});o.label&&(n.label=String(o.label)),o.icon&&(n.icon=String(o.icon)),o.assigned&&(n.assigned=String(o.assigned)),o.ticket&&(n.ticket=String(o.ticket)),o.priority&&(n.priority=String(o.priority))}}if(this.misplaced)throw new je(`Items without section detected, found section ("${this.misplaced.label}")`,"semantic",{type:"kanban"});let l=this.sections;if(l.length===0&&(this.sectionLevel=e),this.last=n,e===this.sectionLevel){let s=n;s.items=[],l.push(s)}else l[l.length-1].items.push(n),e<this.sectionLevel&&(this.misplaced=n)}decorateNode(e){let t=this.last;!e||!t||(e.icon&&(t.icon=e.icon),e.class&&(t.cssClasses=e.class))}};Ga=12,ja=8,Ia=10,rf=8,l3=4,hl=6,o3=new Map([["very high",`stroke="${Gs}"`],["high",`stroke="${Gs}" opacity="0.5"`],["low",'stroke="var(--_m)" opacity="0.5"'],["very low",'stroke="var(--_m)"']]);Kn=e=>!!e&&Pn(e)!=="";sg={type:"kanban",math:!0,parse(e,t,r){let a=new n3;return a.title=r,s3(e,a),a},render:c3}});var og={};_t(og,{kanban:()=>sg});var cg=Xe(()=>{lg()});function Zn(e,t){let r=e.indexOf(`
63
+ `,t);return r===-1?e.length:r}function ma(e,t,r){for(let a=0;a<r.length;a++)if((e.charCodeAt(t+a)|32)!==r.charCodeAt(a))return!1;return!0}function Bo(e,t){let r=e.length,a=t;for(;a<r;){let i=e.charCodeAt(a);if(i===37&&e.charCodeAt(a+1)!==123)a=Zn(e,a);else if(i!==125&&e.charCodeAt(a+1)===37&&e.charCodeAt(a+2)===37)a=Zn(e,a+3);else{if(i===10)return a;if(Ue(i))do a++;while(a<r&&Ue(e.charCodeAt(a)));else if(i===35)a=Zn(e,a);else return a}}return a}function af(e,t){let r=t;for(;Ue(e.charCodeAt(r));)r++;return r}function Yo(e,t,r,a){let i=ma(e,t,"accdescr");if(!i&&!ma(e,t,"acctitle"))return t;let n=e.length,l=af(e,t+8),s=e.charCodeAt(l),o=(c,f,p)=>{r.types.push(c),r.texts.push(e.slice(f,p)),r.starts.push(f)};if(s===58){l=af(e,l+1);let c=Zn(e,l);return o(i?a+2:a,t,l),o(i?a+3:a+1,l,c),c}if(!i||s!==123)return t;for(l=af(e,l+1);e.charCodeAt(l)!==125;){let c=e.indexOf("}",l);if(c===-1&&(c=n),o(a+4,l,c),l===n)return n;l=c}return l+1}var nf=Xe(()=>{tr()});function Na(e,t,r,a,i=0){let n=e;return n!==void 0&&(n.includes("<")&&(n=n.replace(h3,"&lt;")),n.includes(":fa-")&&(n=n.replace(d3,"&colon;fa-"))),ze(n,!1,t,r,a,i)}function Kr(e,t,r,a,i=0){let n=Na(e,t,r,a,i);if(e===void 0||n.width<=a)return n;let l="",s=0;for(let o of e.match(f3)??[]){if(o.trim()===""||o.length>2&&o[0]==="<")s=0;else{let c=t.width(o.length>2?"x":o,r,i);s>0&&s+c>a&&(l+=`
64
+ `,s=0),s+=c}l+=o}return Na(l,t,r,a,i)}var h3,d3,f3,Ho=Xe(()=>{ut();h3=/<(?!br\s*\/?>)/gi,d3=/:fa-/g,f3=/<br\s*\/?>|fl°°?\w+¶ß|&#?\w+;|[\ud800-\udbff][\udc00-\udfff]|[\s\S]/gi});function g3(e){let t=e.length,r=[],a=[],i=[],n={types:r,texts:a,starts:i},l=0,s=(o,c)=>{r.push(o),a.push(e.slice(l,c)),i.push(l),l=c};for(;l=Bo(e,l),!(l>=t);){let o=e.charCodeAt(l),c=l+1;if(o===10){for(;e.charCodeAt(c)===10;)c++;s(3,c);continue}if(ma(e,l,"timeline")){for(c=l+8;e.charCodeAt(c)===32||e.charCodeAt(c)===9;)c++;let f=ma(e,c,"lr");if(c>l+8&&(f||ma(e,c,"td"))&&!Qe(e.charCodeAt(c+2))){s(f?5:6,c+2);continue}if(!Qe(e.charCodeAt(l+8))){s(4,l+8);continue}}if(ma(e,l,"title")&&Ue(e.charCodeAt(l+5))&&l+6<t&&e.charCodeAt(l+6)!==10){s(7,Zn(e,l+6));continue}if(c=Yo(e,l,n,8),c!==l){l=c;continue}if(ma(e,l,"section")&&Ue(e.charCodeAt(l+7))){for(c=l+8;c<t&&e.charCodeAt(c)!==58&&e.charCodeAt(c)!==10;)c++;if(c>l+8){s(13,c);continue}}if(o!==58){c=l+1;for(let f=e.charCodeAt(c);c<t&&f!==35&&f!==58&&f!==10;f=e.charCodeAt(++c));s(14,c);continue}if(Ue(e.charCodeAt(l+1))){for(c=l+2;c<t;c++){let f=e.charCodeAt(c);if(f===10||f===58&&Ue(e.charCodeAt(c+1)))break}if(c>l+2){s(15,c);continue}}s(2,l+1)}return(i.length===0||i[i.length-1]<t)&&s(1,t),s(0,t),n}function y3(e,t){let{types:r,texts:a,starts:i}=g3(e),n=(s,o)=>{let c=r[s]===0?"1":u3[r[s]];throw it("timeline",e,i[s],`Expecting ${o}, got '${c}'`)},l=r[0];l!==4&&l!==5&&l!==6&&n(0,"'timeline', 'timeline_lr', 'timeline_td'"),l!==4&&t.setDirection(l===5?"LR":"TD");for(let s=1;;s++){let o=a[s];switch(r[s]){case 3:break;case 7:t.getCommonDb().setDiagramTitle(o.substring(6));break;case 8:t.getCommonDb().setAccTitle(a[++s].trim());break;case 10:t.getCommonDb().setAccDescription(a[++s].trim());break;case 12:t.getCommonDb().setAccDescription(o.trim());break;case 13:t.addSection(o.substring(8));break;case 14:t.addTask(o,0,"");break;case 15:t.addEvent(o.substring(2));break;case 1:return;default:n(s,m3)}}}function lf(e,t,r,a,i){return`<rect x="${d(e)}" y="${d(t)}" width="${d(r)}" height="${d(a)}"${ft(i)}/>`}function $3(e,t,r){return e.direction==="TD"?pg(e,t,r,!0):Bt(r,a=>pg(e,t,r,a))}function pg(e,t,r,a){let i=r.fontSize??16,n=Math.round(i*.875),l=r.measurer??et(r.fontFamily),s=r.padding??8,o=t.timeline?.disableMulticolor!==!0,c=e.periods,f=e.sections.length>0,p=e.sections.map((X,te)=>({section:te,periods:[]})),h={section:-1,periods:[]};c.forEach((X,te)=>(p[X.sectionIndex]??h).periods.push(te)),h.periods.length>0&&p.unshift(h);let g=a&&r.maxWidth!==void 0&&r.maxWidth>0?r.maxWidth-2*s:1/0,u=Qn+qo*2+4*Uo,m=Math.min(x3,Math.max(80,Math.round((g-u)*.38))),b=Math.min(b3,Math.max(110,g-u-m)),w=m,v=()=>a?b:w,k=c.map(X=>Na(X.text,l,i,w)),O=c.map(X=>X.events.map(te=>Na(te,l,n,v()))),R=0;for(let X of k)R=Math.max(R,X.width);if(!a)for(let X of O)for(let te of X)R=Math.max(R,te.width);let L=R>w;if(a)for(let X of O)for(let te of X)L||(L=te.width>b);L&&(w=Math.min(Math.max(Math.ceil(R),m),g===1/0?w3:m),k=c.map(X=>Kr(X.text,l,i,w)),O=c.map(X=>X.events.map(te=>Kr(te,l,n,v()))));let P=Math.round(i*1.5),B=w+2*Uo,G=v()+2*Uo,C=X=>Math.max(X.height,P)+2*hg,Z=X=>Math.max(X.height,Math.round(n*1.5))+2*hg,ee=(X,te)=>X.section>=0?dt(X.section):f?"var(--_m)":dt(o?te:0),H=!1;for(let X of O)X.length>0&&(H=!0);let Y=0;for(let X of p)Y+=Math.max(X.periods.length,1);let _=B+sn,S=c.length>0,$=a?B+(H?Qn+qo*2+G:S?Qn+Go:0):Y>0?Y*_-sn+(S?Go+Yt:0):0,y=Kr(e.title,l,i,Math.max($,320),1),E=y.height>0?y.height+16:0,x=Math.max($,y.width),T=s+(x-$)/2,A=s+E,M=(X,te)=>Kr(e.sections[X.section],l,i,te-2*Uo,1),N=(X,te,se,oe,ae,ne)=>lf(se,oe,ae,ne,` fill="${dt(X.section)}"`)+Re(te,se+ae/2,oe+ne/2,' font-weight="var(--_hw)"'+dg),F=(X,te,se,oe,ae)=>lf(se,oe,B,ae,` fill="${te}"`)+Re(k[X],se+B/2,oe+ae/2,dg),U=(X,te,se,oe,ae)=>'<g class="pele-node pele-event">'+lf(se,oe,G,ae,` fill="${te}" fill-opacity="0.16"`)+Re(X,se+G/2,oe+ae/2,` font-size="${n}"`)+"</g>",D=(X,te,se)=>`<circle class="pele-dot" cx="${d(X)}" cy="${d(te)}" r="4" fill="${se}" stroke="var(--_bg)" stroke-width="2"/>`,I=X=>X.section>=0?`<g class="pele-cluster pele-section" data-id="${Oe(e.sections[X.section].trim())}">`:"",z=X=>`<g class="pele-node pele-period" data-id="${Oe(c[X].text.trim())}">`,q="",j;if(a){let X=T+B+Qn,te=X+qo,se=te+qo,oe=A;for(let ae of p){if(q+=I(ae),ae.section>=0){let ne=M(ae,$),J=C(ne);q+=N(ae,ne,T,oe,$,J),oe+=J+sf+4}for(let ne of ae.periods){let J=ee(ae,ne),re=C(k[ne]),fe=O[ne].length>0?Z(O[ne][0]):re,ye=oe+Math.max(re,fe)/2,le=`M${d(T+B)},${d(ye)}H${d(X)}`,we="",pe=ye-fe/2,ge=ye;for(let Ae of O[ne]){let Se=Z(Ae);ge=pe+Se/2,le+=`M${d(te)},${d(ge)}H${d(se)}`,we+=U(Ae,J,se,pe,Se),pe+=Se+fl}we&&(le+=`M${d(X)},${d(ye)}H${d(te)}V${d(ge)}`),q+=z(ne)+F(ne,J,T,ye-re/2,re)+`<path class="pele-edge" d="${le}"${fg}/>`+D(X,ye,J)+we+"</g>",oe=Math.max(ye+re/2,pe-fl)+sn}ae.periods.length===0&&(oe+=sn-sf-4),ae.section>=0&&(q+="</g>")}if(p.length>0&&(oe-=sn),S){let ae=oe+Go+Yt;q=`<path class="pele-axis" d="M${d(X)},${d(A)}V${d(ae-Yt+1)}" fill="none" stroke="var(--_l)"/>`+bt("arrow_point",X,ae,0,1,"var(--_l)")+q,oe=ae}j=oe+s}else{let X=0,te=p.map(fe=>{if(fe.section<0)return;let ye=M(fe,Math.max(fe.periods.length,1)*_-sn);return X=Math.max(X,C(ye)),ye}),se=0;for(let fe of k)se=Math.max(se,C(fe));let oe=A+(f?X+sf:0),ae=oe+se+(se>0?Qn:0),ne=ae+Qn,J=S?ae+Go:A+X,re=0;if(p.forEach((fe,ye)=>{let le=Math.max(fe.periods.length,1),we=T+re*_;q+=I(fe);let pe=te[ye];pe&&(q+=N(fe,pe,we,A,le*_-sn,X)),fe.periods.forEach((ge,Ae)=>{let Se=ee(fe,ge),ce=we+Ae*_,ue=ce+B/2,xe=`M${d(ue)},${d(oe+se)}V${d(O[ge].length>0?ne:ae)}`,Ie="",Le=ne;for(let We of O[ge]){let de=Z(We);Le>ne&&(xe+=`M${d(ue)},${d(Le-fl)}V${d(Le)}`),Ie+=U(We,Se,ce,Le,de),Le+=de+fl}J=Math.max(J,Le-fl),q+=z(ge)+F(ge,Se,ce,oe,se)+`<path class="pele-edge" d="${xe}"${fg}/>`+D(ue,ae,Se)+Ie+"</g>"}),fe.section>=0&&(q+="</g>"),re+=le}),S){let fe=T+$;q=`<path class="pele-axis" d="M${d(T)},${d(ae)}H${d(fe-Yt+1)}" fill="none" stroke="var(--_l)"/>`+bt("arrow_point",fe,ae,1,0,"var(--_l)")+q}j=J+s}let Q=Math.ceil(x+2*s),K=Math.ceil(Math.max(j,s*2)),W=Re(y,Q/2,s+y.height/2,' class="pele-title" font-weight="var(--_tw)"')+q;return{svg:Je("timeline",Q,K,i,r,e,W),width:Q,height:K,links:[]}}var p3,u3,m3,Uo,hg,x3,w3,b3,sn,Qn,qo,fl,sf,Go,dg,fg,ug,gg=Xe(()=>{nf();Ho();tr();zt();pr();ut();wt();p3=class{constructor(){he(this,"type","timeline");he(this,"title");he(this,"accTitle");he(this,"accDescr");he(this,"direction","LR");he(this,"sections",[]);he(this,"periods",[]);he(this,"currentSection","")}getCommonDb(){return this}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
65
+ `)}setDirection(e){this.direction=e}addSection(e){this.currentSection=e,this.sections.push(e)}addTask(e,t,r){this.periods.push({text:e,events:r?[r]:[],section:this.currentSection,sectionIndex:this.sections.length-1})}addEvent(e){let t=this.periods[this.periods.length-1];if(!t)throw new je("An event needs a time period before it.","semantic",{type:"timeline"});t.events.push(e)}},u3=["$end","EOF","INVALID","NEWLINE","timeline","timeline_lr","timeline_td","title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","section","period","event"];m3="'EOF', 'SPACE', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'period', 'event'";Uo=12,hg=8,x3=152,w3=216,b3=264,sn=20,Qn=20,qo=14,fl=8,sf=8,Go=12,dg=' fill="var(--_bg)"',fg=' fill="none" stroke="var(--_b)"';ug={type:"timeline",parse(e,t,r){let a=new p3;return a.title=r,y3(e,a),a},render:$3}});var mg={};_t(mg,{timeline:()=>ug});var yg=Xe(()=>{gg()});function hf(e){let t=new Set;for(let r of e)for(let a of r.people)t.add(a);return[...t].sort()}function jo(e,t,r){let a=e.length,i=t;for(;i<a;i++){let n=e.charCodeAt(i);if(n===35||n===10||n===59||r&&n===58)break}return i}function A3(e){let t=e.length,r=[],a=[],i=[],n={types:r,texts:a,starts:i},l=0,s=(o,c)=>{r.push(o),a.push(e.slice(l,c)),i.push(l),l=c};for(;l=Bo(e,l),!(l>=t);){let o=e.charCodeAt(l),c=l+1;if(o===10){for(;e.charCodeAt(c)===10;)c++;s(3,c);continue}if(ma(e,l,"journey")&&!Qe(e.charCodeAt(l+7))){s(4,l+7);continue}if(ma(e,l,"title")&&Ue(e.charCodeAt(l+5))&&(c=jo(e,l+6,!1),c>l+6)){s(5,c);continue}if(c=Yo(e,l,n,6),c!==l){l=c;continue}if(ma(e,l,"section")&&Ue(e.charCodeAt(l+7))&&(c=jo(e,l+8,!0),c>l+8)){s(11,c);continue}o===58?(c=jo(e,l+1,!1),s(c>l+1?13:14,c>l+1?c:l+1)):o===59?s(2,l+1):s(12,jo(e,l+1,!0))}return(i.length===0||i[i.length-1]<t)&&s(1,t),s(0,t),n}function E3(e,t){let{types:r,texts:a,starts:i}=A3(e),n=(l,s)=>{let o=r[l]===0?"1":M3[r[l]];throw it("journey",e,i[l],`Expecting ${s}, got '${o}'`)};r[0]!==4&&n(0,"'journey'");for(let l=1;;l++){let s=a[l];switch(r[l]){case 3:break;case 5:t.setDiagramTitle(s.substring(6));break;case 6:t.setAccTitle(a[++l].trim());break;case 8:t.setAccDescription(a[++l].trim());break;case 10:t.setAccDescription(s.trim());break;case 11:t.addSection(s.substring(8));break;case 12:r[++l]!==13&&n(l,"'taskData'"),t.addTask(s,a[l]);break;case 1:return;default:n(l,v3)}}}function wg(e,t,r){return`<g class="pele-face pele-face-${r}" transform="translate(${d(e)},${d(t)})"><circle r="${Jn}" fill="var(--_bg)" stroke="var(--_l)"/><g fill="var(--_l)">${I3}</g><path d="${N3[r]}" fill="none" stroke="var(--_l)" stroke-linecap="round"/></g>`}function R3(e,t,r){return Bt(r,a=>L3(e,t,r,a))}function L3(e,t,r,a){let i=r.fontSize??16,n=Math.round(i*.875),l=Math.round(i*.75),s=r.measurer??et(r.fontFamily),o=r.padding??8;if(a)return D3(e,r);let c=e.tasks,f=c.length,p=hf(c).filter(z=>z!==""),h=new Map;p.forEach((z,q)=>h.set(z,q));let g=S3,u=c.map(z=>Na(z.task,s,n,g)),m=0;for(let z of u)m=Math.max(m,z.width);m>g&&(g=Math.min(Math.ceil(m),T3),u=c.map(z=>Kr(z.task,s,n,g)));let b=g+2*Vo,w=b+Xo,v=f>0?f*w-Xo:0,k=Math.round(n*1.5),O=Math.max(v,240),R=[],L=0,P=0,B=0;for(let z of p){let q=Kr(z,s,n,O-2*Xa-6),j=2*Xa+6+q.width;B>0&&B+j>O&&(B=0,P+=4);let Q=B>0?R[R.length-1].y:P,K=Math.max(q.height,k);R.push({name:z,label:q,x:B,y:Q,h:K}),B+=j,L=Math.max(L,B),P=Math.max(P,Q+K),B+=_3}let G=f>0?of+v:0,C=Kr(e.title,s,i,Math.max(G,320),1),Z=C.height>0?C.height+16:0,ee=Math.max(G,C.width,f>0?of+L:0),H=o+(ee-G)/2+of,Y=o+Z,_=[],S=0;for(let z=0;z<f;){let q=z+1;for(;q<f&&c[q].section===c[z].section;)q++;let j;c[z].section!==""&&(j=Kr(c[z].section,s,n,(q-z)*w-Xo-2*Vo,1),S=Math.max(S,Math.max(j.height,k)+2*xg)),_.push({start:z,count:q-z,label:j}),z=q}let $=k;for(let z of u)$=Math.max($,z.height);let y=p.length>0?2*Xa+6:0,E=$+y+2*Ni,x=Y+(S>0?S+xg:0),T=x+E+Jn+16,A=T+4*cf,M=H+v,N="",F=Y;if(f>0){let z="",q="";for(let X=5;X>=1;X--){let te=T+(5-X)*cf;z+=`M${d(H-6)},${d(te)}H${d(M)}`,q+=`<text x="${d(H-12)}" y="${d(te+l*.35)}">${X}</text>`}N+=`<path class="pele-grid" d="${z}" fill="none" stroke="var(--_a)"/><g class="pele-scale" font-size="${l}" text-anchor="end" fill="var(--_m)">${q}</g>`;let j="",Q="",K="",W=[];c.forEach((X,te)=>{let se=H+te*w,oe=se+b/2,ae=X.score,ne=Number.isNaN(ae)?3:Math.min(5,Math.max(1,ae)),J=T+(5-ne)*cf;j+=`${te===0?"M":"L"}${d(oe)},${d(J)}`,Q+=`M${d(oe)},${d(x+E)}V${d(J-Jn)}`,K+=wg(oe,J,ae>3?"happy":ae<3?"sad":"neutral");let re="",fe=X.people.filter(le=>le!==""),ye=Math.min(C3,(b-2*Vo-2*Xa)/Math.max(fe.length-1,1));fe.forEach((le,we)=>{re+=`<circle class="pele-actor" cx="${d(oe+(we-(fe.length-1)/2)*ye)}" cy="${d(x+E-Ni-Xa)}" r="${Xa}" fill="${dt(h.get(le)??0)}" stroke="var(--_s)"><title>${Oe(le)}</title></circle>`}),W.push(`<g class="pele-node pele-task" data-id="${Oe(X.task.trim())}"><rect x="${d(se)}" y="${d(x)}" width="${d(b)}" height="${d(E)}" fill="var(--_s)" stroke="var(--_b)"${nt}/>`+Re(u[te],oe,x+Ni+$/2,` font-size="${n}"`)+re+"</g>")}),N+=`<path class="pele-stems" d="${Q}" fill="none" stroke="var(--_b)" stroke-dasharray="2 3"/>`+(f>1?`<path class="pele-edge" d="${j}" fill="none" stroke="var(--_l)" stroke-linejoin="round"/>`:"")+K;for(let X of _){let te=W.slice(X.start,X.start+X.count).join("");if(!X.label){N+=te;continue}let se=H+X.start*w,oe=X.count*w-Xo;N+=`<g class="pele-cluster pele-section" data-id="${Oe(c[X.start].section.trim())}"><rect x="${d(se)}" y="${d(Y)}" width="${d(oe)}" height="${d(S)}" fill="var(--_a)"${nt}/>`+Re(X.label,se+oe/2,Y+S/2,` font-size="${n}" font-weight="var(--_hw)"`)+te+"</g>"}if(F=A+Jn,R.length>0){let X=H+(v-L)/2,te=F+16,se="";for(let oe of R){let ae=te+oe.y+oe.h/2;se+=`<g class="pele-legend-item" data-id="${Oe(oe.name)}"><circle cx="${d(X+oe.x+Xa)}" cy="${d(ae)}" r="${Xa}" fill="${dt(h.get(oe.name)??0)}"/>`+Re(oe.label,X+oe.x+2*Xa+6+oe.label.width/2,ae,"")+"</g>"}N+=`<g class="pele-legend" font-size="${n}">${se}</g>`,F=te+P}}let U=Math.ceil(ee+2*o),D=Math.ceil(Math.max(F,o)+o),I=Re(C,o+ee/2,o+C.height/2,' class="pele-title" font-weight="var(--_tw)"')+N;return{svg:Je("journey",U,D,i,r,e,I),width:U,height:D,links:[]}}function D3(e,t){let r=t.fontSize??16,a=Math.round(r*.875),i=t.measurer??et(t.fontFamily),n=t.padding??8,l=Math.max(140,(t.maxWidth??320)-2*n),s=Kr(e.title,i,r,l,1),o=hf(e.tasks).filter(w=>w!==""),c=new Map(o.map((w,v)=>[w,v])),f=n+(s.height?s.height+16:0),p,h="",g=s.width;e.tasks.forEach((w,v)=>{if(w.section!==p){p=w.section;let C=Kr(p,i,r,l-16,1);C.height&&(h+=Re(C,n+8+C.width/2,f+C.height/2,' class="pele-cluster-label" font-weight="var(--_hw)"'),g=Math.max(g,C.width+16),f+=C.height+8)}let k=Kr(w.task,i,a,l-72),O=w.people.filter(C=>C!=="").map(C=>({name:C,label:Kr(C,i,a,l-44)})),R=Math.max(k.height,42),L=2*Ni+R;for(let C of O)L+=Math.max(16,C.label.height)+4;let P=Math.max(l,k.width+72);h+=`<g class="pele-node pele-journey-step" data-id="${v}"><rect x="${d(n)}" y="${d(f)}" width="${d(P)}" height="${d(L)}" fill="var(--_s)" stroke="var(--_b)"${nt}/>`,h+=Re(k,n+Vo+k.width/2,f+Ni+k.height/2,' class="pele-label"');let B=n+P-28;h+=wg(B,f+Ni+Jn,w.score>3?"happy":w.score<3?"sad":"neutral"),Number.isNaN(w.score)||(h+=`<text class="pele-journey-score" x="${d(B)}" y="${d(f+Ni+2*Jn+a)}" font-size="${a}" text-anchor="middle">${d(Math.min(5,Math.max(1,w.score)))}</text>`);let G=f+Ni+R+4;for(let C of O){let Z=Math.max(16,C.label.height);h+=`<circle class="pele-actor" cx="${d(n+16)}" cy="${d(G+Z/2)}" r="${Xa}" fill="${dt(c.get(C.name))}"/>`+Re(C.label,n+28+C.label.width/2,G+Z/2,` class="pele-journey-actor" font-size="${a}"`),G+=Z+4}h+="</g>",f+=L,v+1<e.tasks.length&&(h+=`<path class="pele-edge" d="M${d(n+P/2)},${d(f)}v16" fill="none" stroke="var(--_l)"/>`),f+=16,g=Math.max(g,P)});let u=Math.ceil(g+2*n),m=Math.ceil(Math.max(n+s.height,f-(e.tasks.length?16:0))+n),b=Re(s,u/2,n+s.height/2,' class="pele-title" font-weight="var(--_tw)"')+h;return{svg:Je("journey",u,m,r,t,e,b),width:u,height:m,links:[]}}var k3,M3,v3,Vo,Ni,S3,T3,Xo,xg,of,cf,Jn,Xa,C3,_3,I3,N3,bg,$g=Xe(()=>{nf();Ho();tr();zt();ut();wt();k3=class{constructor(){he(this,"type","journey");he(this,"title");he(this,"accTitle");he(this,"accDescr");he(this,"sections",[]);he(this,"tasks",[]);he(this,"currentSection","")}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
66
+ `)}addSection(e){this.currentSection=e,this.sections.push(e)}addTask(e,t){let r=t.substring(1).split(":"),a=r.length===1?[]:r[1].split(",").map(i=>i.trim());this.tasks.push({task:e,score:Number(r[0]),people:a,section:this.currentSection})}getActors(){return hf(this.tasks)}},M3=["$end","EOF","INVALID","NEWLINE","journey","title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","section","taskName","taskData",":"];v3="'EOF', 'SPACE', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'taskName'";Vo=10,Ni=8,S3=124,T3=200,Xo=12,xg=6,of=24,cf=26,Jn=11,Xa=5,C3=13,_3=20,I3='<circle cx="-3.6" cy="-2.8" r="1.3"/><circle cx="3.6" cy="-2.8" r="1.3"/>',N3={happy:"M-5,2A6,6 0 0 0 5,2",neutral:"M-4.5,4.5H4.5",sad:"M-5,6.5A6,6 0 0 1 5,6.5"};bg={type:"journey",parse(e,t,r){let a=new k3;return a.title=r,E3(e,a),a},render:R3}});var kg={};_t(kg,{journey:()=>bg});var Mg=Xe(()=>{$g()});function Ag(e){return e==="#"||e==="+"||e==="~"||e==="-"}function Ri(e){let t=e.indexOf("~");if(t<=0)return{className:e,type:""};let r=e.indexOf("~",t+1);return{className:e.slice(0,t),type:e.slice(t+1,r===-1?e.length:r)}}function Eg(e){let t=e.charCodeAt(0);return Ri(t>=48&&t<=57?P3+e:e).className}function B3(e){let t=e.length,r=[],a=[],i=[],n=[],l=0,s=0,o=e.indexOf("direction"),c=-1,f=0,p=(L,P,B)=>(r.push(L),a.push(e.slice(P,B)),i.push(P),s=B,!0),h=L=>{n.push(l),l=L},g=()=>{n.length>0&&(l=n.pop())},u=L=>e.startsWith(L,s)&&!Qe(e.charCodeAt(s+L.length)),m=L=>{for(;L<t&&Ue(e.charCodeAt(L));)L++;return L},b=L=>{let P=e.indexOf(L,s);return P===-1?t:P},w=L=>{let P=s,B=-1;for(let G=e.charCodeAt(P);P<t&&Ue(G);G=e.charCodeAt(++P))G===10&&(B=P);if(B<0){s=P;return}L&&g(),p(3,s,B+1)},v=L=>{switch(L){case 99:if(u("cssClass"))return p(48,s,s+8);if(u("callback"))return p(40,s,s+8);if(u("click"))return p(43,s,s+5);break;case 108:if(u("link"))return p(41,s,s+4);break;case 110:if(u("note for"))return p(24,s,s+8);if(u("note"))return p(25,s,s+4);break;case 60:if(e.charCodeAt(s+1)===60)return p(20,s,s+2);break;case 62:if(e.charCodeAt(s+1)===62)return p(21,s,s+2);break;case 104:if(u("href"))return p(46,s,s+4);break}return!1},k=L=>{if(v(L))return!0;let P=e.charCodeAt(s+1);switch(L){case 34:return h(1),s++,!0;case 126:return h(3),s++,!0;case 96:return h(2),s++,!0;case 95:if(u("_self"))return p(42,s,s+5);if(u("_blank"))return p(42,s,s+6);if(u("_parent"))return p(42,s,s+7);if(u("_top"))return p(42,s,s+4);break;case 60:return P===124?p(34,s,s+2):p(36,s,s+1);case 124:return P===62&&p(34,s,s+2);case 62:return p(36,s,s+1);case 42:return p(35,s,s+1);case 111:if(!Qe(P))return p(33,s,s+1);break;case 40:return P===41&&p(37,s,s+2);case 45:return P===45?p(38,s,s+2):p(52,s,s+1);case 46:return P===46?p(39,s,s+2):p(8,s,s+1);case 58:{let B=s+1;for(;B<t;){let G=e.charCodeAt(B);if(G===58||G===10||G===59)break;B++}return B>s+1?p(10,s,B):P===58&&e.charCodeAt(s+2)===58&&p(19,s,s+3)}case 43:return p(58,s,s+1);case 37:return p(51,s,s+1);case 61:return p(59,s,s+1);case 91:return p(5,s,s+1);case 93:return p(7,s,s+1);case 33:case 35:case 36:case 38:case 39:case 44:case 63:case 92:case 47:return p(60,s,s+1)}if(Qe(L)){let B=s+1;for(;Qe(e.charCodeAt(B));)B++;return p(27,s,B)}return Fn(L)&&p(53,s,s+1)},O=()=>{if(o===-1||s<f||(o<s&&(o=e.indexOf("direction",s)),o===-1)||(c<s&&(df.lastIndex=s,c=df.test(e)?df.lastIndex-1:t),o>=c))return!1;for(let L=0;L<4;L++){let P=W3[L];if(P.lastIndex=s,P.test(e))return p(29+L,s,P.lastIndex)}return f=c,!1},R=L=>{if(O())return!0;if(Ue(L))return w(!1),!0;switch(L){case 37:if(e.charCodeAt(s+1)===37){let P=b(`
67
+ `);for(;P<t&&(e.charCodeAt(P)===10||e.charCodeAt(P)===13);)P++;return s=P,!0}break;case 97:{let P=e.startsWith("accTitle",s);if(!P&&!e.startsWith("accDescr",s))break;let B=m(s+8),G=e.charCodeAt(B);if(G===58)return p(P?11:13,s,m(B+1)),h(P?6:7),!0;if(G===123&&!P)return s=m(B+1),h(8),!0;break}case 99:if(u("classDiagram-v2"))return p(2,s,s+15);if(u("classDiagram"))return p(2,s,s+12);if(e.startsWith("call",s)&&Ue(e.charCodeAt(s+4)))return s=m(s+4),h(4),!0;if(u("classDef"))return p(26,s,s+8);if(u("class"))return h(9),p(22,s,s+5);break;case 91:if(e.startsWith("*]",s+1))return p(55,s,s+3);break;case 115:if(u("style"))return p(47,s,s+5);break;case 110:if(u("namespace"))return h(11),p(18,s,s+9);break;case 44:return p(28,s,s+1);case 35:return p(50,s,s+1)}return k(L)||L===58&&p(49,s,s+1)};for(;;){if(s>=t){r.push(F3[l]),a.push(""),i.push(t);break}let L=e.charCodeAt(s),P=!0;switch(l){case 0:P=R(L);break;case 9:Ue(L)?w(!0):L===125?(g(),g(),p(17,s,s+1)):L===123?(h(10),p(16,s,s+1)):P=k(L);break;case 10:if(L===34)h(1),s++;else if(L===125)g(),p(17,s,s+1);else if(L===91&&e.startsWith("*]",s+1))p(55,s,s+3);else if(L===123)p(57,s,s+1);else if(L===10)s++;else{let B=s+1;for(;B<t;){let G=e.charCodeAt(B);if(G===123||G===125||G===10)break;B++}p(23,s,B)}break;case 11:Ue(L)?w(!0):L===123?(h(12),p(16,s,s+1)):L===125?g():L===110&&u("namespace")?(h(11),p(18,s,s+9)):P=k(L);break;case 12:Ue(L)?w(!1):L===125?(g(),p(17,s,s+1)):L===110&&u("namespace")?(h(11),p(18,s,s+9)):L===91&&e.startsWith("*]",s+1)?p(55,s,s+3):L===99&&u("class")?(h(9),p(22,s,s+5)):P=k(L);break;case 1:L===34?(g(),s++):p(6,s,b('"'));break;case 3:if(L===34)h(1),s++;else{if(v(L))break;L===126?(g(),s++):p(9,s,b("~"))}break;case 2:if(L===34)h(1),s++;else{if(v(L))break;L===126?(h(3),s++):L===96?(g(),s++):p(54,s,b("`"))}break;case 4:if(L===40){let B=m(s+1);g(),e.charCodeAt(B)===41?s=B+1:(h(5),s++)}else p(44,s,b("("));break;case 5:L===41?(g(),s++):p(45,s,b(")"));break;case 6:case 7:p(l===6?12:14,s,b(`
68
+ `)),g();break;case 8:L===125?(g(),s++):p(15,s,b("}"));break}if(!P)return r.push(1),a.push(""),i.push(s),{types:r,texts:a,starts:i}}return r.push(0),a.push(""),i.push(t),{types:r,texts:a,starts:i}}function H3(e,t){let{types:r,texts:a,starts:i}=B3(e),n=0,l=L=>{let P=r[n];throw P===1?it("class",e,i[n],"",!0):it("class",e,i[n],`Expecting ${L}, got '${Sg[P]}'`)},s=L=>(r[n]!==L&&l(`'${Sg[L]}'`),a[n++]),o=()=>(ec[r[n]]===0&&l("'UNICODE_TEXT', 'NUM', 'ALPHA', 'MINUS'"),a[n++]),c=L=>{let P="";for(;;){if(r[n]===54){P+=a[n++];break}ec[r[n]]===0&&l(Y3),P+=a[n++];let B=r[n];if(B===8)P+=".",n++;else if(ec[B]===0&&B!==54)break}return L&&r[n]===9&&(P+="~"+a[n++]+"~"),P},f=()=>{n++;let L=s(6);return s(7),L},p=()=>{r[n]!==23&&l("'STRUCT_STOP', 'MEMBER'");let L=[];for(;r[n]===23;)L.push(a[n++]);return s(17),L.reverse()},h=()=>{n++;let L=c(!0);switch(t.addClass(L),r[n]===5&&t.setClassLabel(L,f()),r[n]){case 19:{n++;let P=o();t.setCssClass(L,P),r[n]===16&&(n++,t.addMembers(L,p()));break}case 16:n++,r[n]===17?n++:t.addMembers(L,p());break;case 20:{n++;let P=o();s(21),t.addAnnotation(L,P),r[n]===16&&(n++,r[n]===17?n++:t.addMembers(L,p()));break}}return L},g=()=>{if(r[n++]===25)return t.addNote(s(6));let L=c(!0);return t.addNote(s(6),L)},u=()=>{let L=[];for(;;){n++;let P=c(!1),B=r[n]===5?t.addNamespace(P,f()):t.addNamespace(P);s(16),r[n]===3&&n++,L.push({id:B,classes:[],notes:[]});let G=!0;for(;G;){let C=L[L.length-1],Z=r[n];if(Z===18)break;for(Z===22?C.classes.push(h()):Z===25||Z===24?C.notes.push(g()):l("'NAMESPACE', 'CLASS', 'NOTE_FOR', 'NOTE'");;){if(r[n]===3){let H=r[n+1];if(H===18||H===22||H===25||H===24){n++;break}n++}s(17);let ee=L.pop();if(t.addClassesToNamespace(ee.id,ee.classes,ee.notes),t.popNamespace(),L.length===0){G=!1;break}}}if(L.length===0)return}},m=()=>{let L=on[r[n]];return L===0?"none":(n++,L-1)},b=()=>{let L=c(!0),P=r[n];if(P===10){t.addMember(L,t.cleanupLabel(a[n++]));return}let B="none";if(P===6)B=a[n++],P=r[n];else if(on[P]===0&&P!==38&&P!==39)return;let G=m();P=r[n],P!==38&&P!==39&&l("'AGGREGATION', 'EXTENSION', 'COMPOSITION', 'DEPENDENCY', 'LOLLIPOP', 'LINE', 'DOTTED_LINE'"),n++;let C=m(),Z=r[n]===6?a[n++]:"none",ee=c(!0),H={id1:L,id2:ee,relation:{type1:G,type2:C,lineType:P===38?0:1},relationTitle1:B,relationTitle2:Z};r[n]===10&&(H.title=t.cleanupLabel(a[n++])),t.addRelation(H)},w=()=>{let L=[];for(;;){uf[r[n]]===0&&l("'ALPHA', 'NUM', 'COLON', 'UNIT', 'SPACE', 'BRKT', 'STYLE', 'PCT', 'LABEL'");let P=a[n++];for(;uf[r[n]]===1;)P+=a[n++];if(L.push(P),r[n]!==28)return L;n++}},v=L=>{r[n]===6&&t.setTooltip(L,a[n++])},k=L=>{let P=s(6),B=r[n]===6?a[n++]:void 0;r[n]===42?t.setLink(L,P,a[n++]):t.setLink(L,P),B!==void 0&&t.setTooltip(L,B)},O=()=>{let L=r[n];switch(L){case 53:case 27:case 52:case 54:b();return;case 18:u();return;case 22:h();return;case 23:n++;return;case 20:{n++;let P=o();s(21),t.addAnnotation(c(!0),P);return}case 40:{n++;let P=c(!0);t.setClickEvent(P,s(6)),v(P);return}case 41:n++,k(c(!0));return;case 43:{n++;let P=c(!0);if(r[n]===46){n++,k(P);return}let B=s(44);r[n]===45?t.setClickEvent(P,B,a[n++]):t.setClickEvent(P,B),v(P);return}case 47:{n++;let P=s(27);t.setCssStyle(P,w());return}case 48:{n++;let P=s(6);t.setCssClass(P,s(27));return}case 25:case 24:g();return;case 26:{n++;let P=[s(27)];for(;r[n]===28;)n++,P.push(s(27));t.defineClass(P,w());return}case 29:case 30:case 31:case 32:n++,t.setDirection(L===29?"TB":L===30?"BT":L===31?"RL":"LR");return;case 11:n++,t.setAccTitle(s(12).trim());return;case 13:n++,t.setAccDescription(s(14).trim());return;case 15:t.setAccDescription(a[n++].trim());return}l("'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'NAMESPACE', 'ANNOTATION_START', 'CLASS', 'MEMBER', 'NOTE_FOR', 'NOTE', 'CLASSDEF', 'direction_tb', 'CALLBACK', 'LINK', 'CLICK', 'STYLE', 'CSSCLASS', 'ALPHA', 'MINUS', 'BQUOTE_STR'")},R=r[n]===2;for(R&&(n++,s(3));O(),!(r[n]!==3||(n++,r[n]===4||r[n]===0)););R&&s(4),s(0)}function Tg(e){return typeof e=="number"&&U3[e]||"none"}function q3(e,t=!0){let r=[],a=[],i=new Map,n=new Map,l=new Map,s=new Map,o=h=>{if(t||h===void 0)return h;let g=[],u=h,m;for(;u;){if(s.has(u)){m=s.get(u);break}let b=e.namespaces.get(u);if(b===void 0)break;if(b.explicit){m=u;break}g.push(u),u=b.parent}for(let b of g)s.set(b,m);return m},c=h=>h===void 0?-1:i.get(h)??-1;for(let h of e.namespaces.values())!t&&!h.explicit||(i.set(h.id,r.length),r.push({id:h.id,label:t?h.label:h.id,isGroup:!0,shape:"rect",parentId:t?h.parent:void 0,parent:-1}));for(let h of r)h.parent=c(h.parentId);let f=0;for(let h of e.classes.values()){let g=o(h.parent);n.set(h.id,r.length),r.push({id:h.id,label:h.label,isGroup:!1,shape:"classBox",parentId:g,parent:c(g),classNode:h,colorIndex:f++})}for(let h of e.notes.values()){let g=o(h.parent),u=h.class===void 0?void 0:n.get(h.class);u!==void 0&&a.push({id:`edgeNote${h.index}`,start:h.id,end:r[u].id,source:r.length,target:u,label:void 0,arrowTypeStart:"none",arrowTypeEnd:"none",startLabelRight:"",endLabelLeft:"",pattern:"dotted",classes:"relation"}),r.push({id:h.id,label:h.text,isGroup:!1,shape:"note",parentId:g,parent:c(g)})}for(let h of e.interfaces){let g=n.get(h.classId);l.set(h.id,r.length),r.push({id:h.id,label:h.label,isGroup:!1,shape:"interface",parentId:void 0,parent:g===void 0?-1:r[g].parent})}let p=0;for(let h of e.relations){p++;let{type1:g,type2:u}=h.relation,m=g===gl.LOLLIPOP&&u==="none"?l:n,b=m===n&&u===gl.LOLLIPOP&&g==="none"?l:n;a.push({id:`id_${h.id1}_${h.id2}_${p}`,start:h.id1,end:h.id2,source:m.get(h.id1)??-1,target:b.get(h.id2)??-1,label:h.title,arrowTypeStart:Tg(g),arrowTypeEnd:Tg(u),startLabelRight:h.relationTitle1==="none"?"":h.relationTitle1,endLabelLeft:h.relationTitle2==="none"?"":h.relationTitle2,pattern:h.relation.lineType===1?"dashed":"solid",classes:"relation"})}return{nodes:r,edges:a}}function Cg(e){switch(e){case"extension":return gf;case"composition":case"aggregation":return ul;case"lollipop":return 2*tc;case"dependency":return gt("arrow_point")}return 0}function _g(e,t,r,a,i,n){let l=-i,s=a;switch(e){case"extension":{let o=t-a*gf,c=r-i*gf;return`<path class="pele-marker" d="M${d(t)},${d(r)}L${d(o+l*pl)},${d(c+s*pl)}L${d(o-l*pl)},${d(c-s*pl)}Z" stroke-linejoin="round"/>`}case"composition":case"aggregation":{let o=t-a*ul/2,c=r-i*ul/2,f=pl-1;return`<path class="pele-marker" d="M${d(t)},${d(r)}L${d(o+l*f)},${d(c+s*f)}L${d(t-a*ul)},${d(r-i*ul)}L${d(o-l*f)},${d(c-s*f)}Z" stroke-linejoin="round"${e==="composition"?` fill="${n}"`:""}/>`}case"lollipop":return`<circle class="pele-marker" cx="${d(t-a*tc)}" cy="${d(r-i*tc)}" r="${tc}"/>`;case"dependency":return bt("arrow_point",t,r,a,i,n)}return""}function Lg(e,t,r){let a=e[t];return typeof a=="number"&&a>0?Math.min(a,2e3):r}function Dg(e,t,r){let a=At(e.getDisplayDetails().displayText).trim();return{text:a,width:t.width(a,r,e.classifier==="*"?2:0),classifier:e.classifier}}function Z3(e,t,r){let a=i=>Nr(r,n=>Q3(e,t,r,i,n));return jr(e.direction)?Bt(r,a):a(!1)}function Q3(e,t,r,a,i){let n=t.class??{},l=q3(e,n.hierarchicalNamespaces!==!1),s=n.hideEmptyMembersBox===!0,o=r.fontSize??16,c=Math.round(o*.875),f=Math.round(o*.8),p=Math.round(f*1.4),h=r.measurer??et(r.fontFamily),g=r.padding??8,u=(ce,ue)=>{if(!ce.includes("$$"))return;let xe=ze(ce,!1,h,ue,4e3);return xe.lines.some(Wn)?xe:void 0},m=ce=>ce?u(ce,f)?.width??h.width(At(ce),f,0):0,b=a?"TB":br(e.direction),w=new Map,v=new Map,k=new Map,O=ce=>{let ue=w.get(ce);if(ue===void 0){let xe=vt([ce]);ue=xe.shape===""&&xe.text===""?"":ce.slice(0,ce.indexOf(":")).trim().toLowerCase(),w.set(ce,ue)}ue!==""&&k.set(ue,ce)},R=ce=>{k.clear();let ue=v.get(ce.cssClasses);if(ue===void 0){for(let xe of ce.cssClasses.split(" ")){let Ie=e.styleClasses.get(xe);if(Ie)for(let Le of Ie.styles)for(let We of Le.split(","))O(We)}ue=[...k],v.set(ce.cssClasses,ue)}else for(let[xe,Ie]of ue)k.set(xe,Ie);for(let xe of ce.styles)O(xe);return vt(k.size===0?Jo:[...k.values()])},L=new Int32Array(l.nodes.length);for(let ce of l.nodes)ce.parent>=0&&L[ce.parent]++;let P=new Uint8Array(l.nodes.length);for(let ce of l.edges){if(ce.source<0||ce.target<0)continue;let ue=l.nodes[ce.source].parent,xe=l.nodes[ce.target].parent;if(ue!==xe){for(let Ie=ue;Ie>=0&&P[Ie]===0;Ie=l.nodes[Ie].parent)P[Ie]=1;for(let Ie=xe;Ie>=0&&P[Ie]===0;Ie=l.nodes[Ie].parent)P[Ie]=1}}let B=[],G=[];l.nodes.forEach((ce,ue)=>{let xe,Ie;if(ce.isGroup){let Le=ze(ce.label,!1,h,o,4e3);xe=C(ce,Le,0,0,o),L[ue]>0?(Ie=Ut(0,0),Ie.isGroup=!0,Ie.padX=ln,Ie.padTop=Le.height>0?Le.height+16:ln,Ie.padBottom=ln,Ie.minW=Le.width+2*ln-12+(P[ue]===1&&!i?Math.min(Le.width+24,240):0)):(xe.w=Math.max(Le.width+2*ln,80),xe.h=Le.height+2*ln,Ie=Ut(xe.w,xe.h))}else if(ce.classNode)xe=Z(ce,ce.classNode),Ie=Ut(xe.w,xe.h);else if(ce.shape==="note"){let Le=ze(ce.label,!0,h,c,260);xe=C(ce,Le,Math.max(Le.width+2*ff,40),Le.height+2*Ko,c),Ie=Ut(xe.w,xe.h)}else{let Le=ze(ce.label,!1,h,c,200);xe=C(ce,Le,Math.max(Le.width,12)+4,Math.max(Le.height,12),c),Ie=Ut(xe.w,xe.h)}Ie.parent=ce.parent,Ie.seq=ue,B.push(xe),G.push(Ie)});function C(ce,ue,xe,Ie,Le){return{node:ce,style:vt(Jo),label:ue,w:xe,h:Ie,loops:0,annotations:Jo,attributes:Qo,methods:Qo,titleH:0,attributesH:0,fontSize:Le}}function Z(ce,ue){let xe=R(ue),Ie=xe.fontSize??o,Le=Math.round(Ie*.875),We=Math.round(Le*1.5),de=ue.type?"&lt;"+an(ue.type).replace(/</g,"&lt;").replace(/>/g,"&gt;")+"&gt;":"",ke=ze(ue.label+de,!1,h,Ie,4e3,1|(xe.italic?2:0)),Ce=ue.annotations.length>0?ue.annotations.map($e=>u(`\xAB${$e.trim()}\xBB`,f)??`\xAB${At($e).trim()}\xBB`):Jo,be=ue.members.length>0?ue.members.map($e=>Dg($e,h,Le)):Qo,Me=ue.methods.length>0?ue.methods.map($e=>Dg($e,h,Le)):Qo,Ne=ke.width,Be=0;for(let $e of Ce)Ne=Math.max(Ne,typeof $e=="string"?h.width($e,f,0):$e.width),Be+=typeof $e=="string"?p:Math.max(p,$e.height);for(let $e of be)Ne=Math.max(Ne,$e.width);for(let $e of Me)Ne=Math.max(Ne,$e.width);let Pe=!(s&&be.length===0&&Me.length===0),V=$e=>Pe?$e>0?2*Rg+$e*We:X3:0,me=2*Ko+Be+Math.max(ke.height,Math.round(Ie*1.5)),ie=V(be.length);return{node:ce,style:xe,label:ke,w:Math.max(Ne+2*ff,V3),h:me+ie+V(Me.length),loops:0,annotations:Ce,attributes:be,methods:Me,titleH:me,attributesH:ie,fontSize:Ie}}let ee=[],H=[],Y=[],_=[],S=[],$=new Float64Array(B.length*4),y=(ce,ue,xe)=>{$[ce*4+ue]++,xe>$[ce*4+ue+1]&&($[ce*4+ue+1]=xe)};for(let ce of l.edges){if(ce.source<0||ce.target<0)continue;let ue=ze(ce.label,!0,h,c,200),xe=m(ce.startLabelRight),Ie=m(ce.endLabelLeft);ce.source===ce.target?(B[ce.source].loops++,G[ce.source].w+=2*(Ng+(ue.width>0?ue.width+12:0))):(y(ce.source,0,xe),y(ce.target,2,Ie)),_.push(xe),S.push(Ie),H.push(ce),Y.push(ue),ee.push({src:ce.source,dst:ce.target,minlen:1,labelW:ue.width>0?ue.width+12:0,labelH:ue.height>0?ue.height+4:0,route:[],labelX:0,labelY:0})}if(b==="TB"||b==="BT")for(let ce=0;ce<B.length;ce++){if(!B[ce].node.classNode)continue;let ue=0;for(let xe=0;xe<4;xe+=2){let Ie=$[ce*4+xe],Le=$[ce*4+xe+1];Ie>1&&(ue=Math.max(ue,(Ie-1)*(Le>0?Le+24:14)+24))}ue=Math.min(ue,480),ue>B[ce].w&&(G[ce].w+=ue-B[ce].w,B[ce].w=ue)}let E=!1;for(let ce=0;ce<H.length&&!E;ce++)E=_[ce]>0||S[ce]>0;let x=0;if(b==="TB"||b==="BT"){let ce=ue=>ue?Math.max(p,u(ue,f)?.height??0):0;for(let ue of H)x=Math.max(x,ce(ue.startLabelRight)+ce(ue.endLabelLeft)-2*p)}let T=Gr(G,ee,b,{nodeSep:Lg(n,"nodeSpacing",G3),edgeSep:j3,rankSep:Lg(n,"rankSpacing",E?Ig+16:Ig)+x,portSep:20,apart:!0}),A=new Map,M=[],N=(ce,ue,xe,Ie,Le)=>{let We=ce.route,de=G[xe],ke=ga(We,ue,de);if(ke<0)return;let Ce=(de.w-B[xe].w)/2;ke===1?We[ue]-=Ce:ke===3&&(We[ue]+=Ce);let be=ke&1,Me=We[(ue===0?3:ue-3)+be],Ne=Me-We[ue+be],Be={route:We,at:ue,toward:Me,order:Le,room:Ie,side:ke,after:be?Ne>0:Ne>=0},Pe=xe*4+ke,V=A.get(Pe);return V?V.push(Be):A.set(Pe,[Be]),Be},F=[],U=[];for(let ce=0;ce<ee.length;ce++){let ue=ee[ce],xe=ue.src!==ue.dst&&ue.route.length>=6;F.push(xe?N(ue,0,ue.src,_[ce],ce):void 0),U.push(xe?N(ue,ue.route.length-3,ue.dst,S[ce],ce):void 0)}let D=(ce,ue,xe)=>{for(let Ie=G[ce].parent,Le=0;Ie>=0&&Le<1e4;Ie=G[Ie].parent,Le++){let We=G[Ie],de=Math.abs(ue-We.x),ke=Math.abs(xe-We.y);if(Math.abs(ke-We.h/2)<.5&&de<=We.w/2+.5||Math.abs(de-We.w/2)<.5&&ke<=We.h/2+.5)return!0}return!1},I=[];for(let[ce,ue]of A){if(ue.length<2)continue;let xe=ce>>2,Ie=ce&1,Le=Ie?B[xe].h:B[xe].w;ue.sort((Ce,be)=>Ce.toward-be.toward||Ce.order-be.order);let We=0;for(let Ce=0;Ce+1<ue.length;Ce++){let be=ue[Ce],Me=ue[Ce+1],Ne=Ie?20:24;be.room>0&&be.after&&(Ne+=Ie?p+6:be.room),Me.room>0&&!Me.after&&(Ne+=Ie?p+6:Me.room),I[Ce]=Ne,We+=Ne}let de=Math.min(1,(Le-24)/We);if(de<=0)continue;let ke=(Ie?G[xe].y:G[xe].x)-We*de/2;for(let Ce=0;Ce<ue.length;Ce++){let{route:be,at:Me}=ue[Ce],Ne=Me===0?3:-3,Be=Me+Ne,Pe=-1;for(let V=Be;V>=0&&V<be.length&&Math.abs(be[V+Ie]-be[Be+Ie])<.5;V+=Ne)if(D(xe,be[V],be[V+1])){Pe=V;break}if(Pe>=0&&Math.abs(be[Be+Ie]-ke)<=24)for(let V=Be;V!==Pe+Ne;V+=Ne)be[V+Ie]=ke;be[Me+Ie]=ke,ke+=I[Ce]*de}}let z=(ce,ue,xe,Ie)=>{if(ue===void 0||xe<=0)return;let Le=ue.side&1,We=Ie?0:ce.length-3,de=We+1-Le,ke=Math.abs(ce[(Ie?3:We-3)+1-Le]-ce[de]),Ce=Math.min(Le?xe+10:p+6,ke*.35);if(Ce<4)return;let be=[ce[We],ce[We+1],ce[We+2]];be[1-Le]+=(ue.side===0||ue.side===3?-1:1)*Ce,ce.splice(Ie?3:We,0,be[0],be[1],be[2])};for(let ce=0;ce<ee.length;ce++)z(ee[ce].route,F[ce],_[ce],!0),z(ee[ce].route,U[ce],S[ce],!1);let q=0,j=0,Q=T.width,K=T.height,W=(ce,ue,xe,Ie,Le,We)=>{if(!ce)return;let de=u(ce,f),ke=de?Math.max(p,de.height):p,Ce=xe,be=Ie;Le&1?(Ce+=(Le===3?-1:1)*(5+ue/2),be+=(We?1:-1)*(7+ke/2)):(Ce+=(We?1:-1)*(9+ue/2),be+=(Le===0?-1:1)*(3+ke/2)),M.push({text:At(ce),math:de,x:Ce,y:be}),q=Math.min(q,Ce-ue/2),Q=Math.max(Q,Ce+ue/2),j=Math.min(j,be-ke/2),K=Math.max(K,be+ke/2)},X=new Map,te=new Int32Array(ee.length);for(let ce=0;ce<ee.length;ce++){let ue=ee[ce],xe=H[ce],Ie=ue.route;if(ue.src===ue.dst){let Le=X.get(ue.src)??0;X.set(ue.src,Le+1),te[ce]=Le;let We=G[ue.src],de=B[ue.src],ke=We.x+de.w/2,Ce=Math.min(de.h/2-4,8+Le*6);W(xe.startLabelRight,_[ce],ke,We.y-Ce,1,!1),W(xe.endLabelLeft,S[ce],ke,We.y+Ce,1,!0)}else if(Ie.length>=6){let Le=Ie.length-3,We=F[ce],de=U[ce];W(xe.startLabelRight,_[ce],Ie[0],Ie[1],We?We.side:2,We?We.after:!0),W(xe.endLabelLeft,S[ce],Ie[Le],Ie[Le+1],de?de.side:0,de?de.after:!0)}}let se=g-q,oe=g-j,ae=Math.ceil(Q-q+2*g),ne=Math.ceil(K-j+2*g),J=[],re=new Map;if(l.nodes.length>0&&l.nodes[0].isGroup)for(let ce of ee)va(re,ce.route);let fe="",ye="",le="";for(let ce=0;ce<B.length;ce++){let ue=B[ce],xe=G[ce],Ie=ue.node,Le=xe.x+se,We=xe.y+oe,de=Oe(Ie.id),ke=xe.isGroup?xe.w:ue.w,Ce=xe.isGroup?xe.h:ue.h;if(Ie.isGroup){let Me=xe.isGroup?Ai(xe,ue.label.width,re,ln):xe.x,Ne=We-Ce/2+8+ue.label.height/2,Be=' class="pele-cluster-label" fill="var(--_m)"',Pe=xe.isGroup&&xo(xe,ue.label.width,Me,re);Pe&&(ye+=wo(ue.label,Me+se,Ne,Be,de,l.nodes,ce)),fe+=`<g class="pele-cluster pele-namespace" data-id="${de}"><rect x="${d(Le-ke/2)}" y="${d(We-Ce/2)}" width="${d(ke)}" height="${d(Ce)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${nt}/>`+(Pe?"":Re(ue.label,Me+se,Ne,Be))+"</g>";continue}let be=` transform="translate(${d(Le)},${d(We)})"`;if(Ie.classNode)le+=we(ue,Ie.classNode,de,be);else if(Ie.shape==="note"){let Me=ke/2,Ne=-Ce/2;le+=`<g class="pele-node pele-note" data-id="${de}"${be}><path d="M${d(-Me)},${d(Ne)}H${d(Me-Zo)}L${d(Me)},${d(Ne+Zo)}V${d(-Ne)}H${d(-Me)}Z" fill="var(--_a)" stroke="var(--_b)" stroke-linejoin="round"/><path d="M${d(Me-Zo)},${d(Ne)}V${d(Ne+Zo)}H${d(Me)}" fill="none" stroke="var(--_b)" stroke-linejoin="round"/>`+Re(ue.label,0,0,` class="pele-label" font-size="${c}"`,r.icons)+"</g>"}else le+=`<g class="pele-node pele-interface" data-id="${de}"${be}>`+Re(ue.label,0,0,` class="pele-label" font-size="${c}"`,r.icons)+"</g>"}function we(ce,ue,xe,Ie){let{w:Le,h:We,style:de}=ce,ke=-Le/2,Ce=-We/2,be=Math.round(ce.fontSize*.875),Me=Math.round(be*1.5),Ne=`<rect x="${d(ke)}" y="${d(Ce)}" width="${d(Le)}" height="${d(We)}" fill="var(--_s)" stroke="var(--_b)"${ft(de.shape)}/>`,Be=Ce+ce.titleH,Pe=Be+ce.attributesH;if(We>ce.titleH){let $e=de.stroke?` style="stroke:${Ve(de.stroke)}"`:"";Ne+=`<path class="pele-divider" d="M${d(ke)},${d(Be)}H${d(-ke)}M${d(ke)},${d(Pe)}H${d(-ke)}" fill="none" stroke="var(--_b)"${$e}/>`}let V=Ce+Ko;for(let $e of ce.annotations)if(typeof $e=="string")Ne+=`<text class="pele-annotation" x="0" y="${d(V+p/2+f*.35)}" text-anchor="middle" font-size="${f}" fill="var(--_m)">${Ve($e)}</text>`,V+=p;else{let ve=Math.max(p,$e.height);Ne+=Re($e,0,V+ve/2,` class="pele-annotation" font-size="${f}" fill="var(--_m)"`,r.icons),V+=ve}let me=ce.fontSize===o?"":` font-size="${d(ce.fontSize)}"`;Ne+=Re(ce.label,0,(V+Be-Ko)/2,` class="pele-label"${me} font-weight="var(--_hw)"${de.text}`,r.icons);let ie=($e,ve,Te)=>{let De="",_e=Te+Rg+Me/2+be*.35;for(let Ye of $e){let Ee=Ye.classifier==="$"?` pele-static"${de.text?de.text.slice(0,-1)+'text-decoration:underline"':' style="text-decoration:underline"'}`:Ye.classifier==="*"?` pele-abstract" font-style="italic"${de.text}`:`"${de.text}`;De+=`<text class="pele-member pele-${ve}${Ee} x="${d(ke+ff)}" y="${d(_e)}">${Ve(Ye.text)}</text>`,_e+=Me}return De};return(ce.attributes.length>0||ce.methods.length>0)&&(Ne+=`<g class="pele-members" font-size="${be}">${ie(ce.attributes,"attribute",Be)}${ie(ce.methods,"method",Pe)}</g>`),ue.tooltip&&(Ne=`<title>${Oe(ue.tooltip)}</title>`+Ne),ue.link&&(Ne=ua(Ne,ue.link,ue.id,J,r,ue.linkTarget&&K3.has(ue.linkTarget)?` target="${ue.linkTarget}"`:"")),`<g class="pele-node pele-class${It(ue.cssClasses.replace(/^default\s?/,""))}" data-id="${xe}"${Ie}>${Ne}</g>`}let pe="",ge="";for(let ce=0;ce<ee.length;ce++){let ue=ee[ce],xe=H[ce],Ie=Y[ce],Le=xe.arrowTypeStart,We=xe.arrowTypeEnd,de=Cg(Le),ke=Cg(We),Ce;if(ue.src===ue.dst){let Me=G[ue.src],Ne=B[ue.src],Be=te[ce],Pe=Me.x+se+Ne.w/2,V=Me.y+oe,me=Math.min(Ne.h/2-4,8+Be*6),ie=Ng+Be*8;Ce={d:`M${d(Pe+de)},${d(V-me)}C${d(Pe+ie+de)},${d(V-me)} ${d(Pe+ie+ke)},${d(V+me)} ${d(Pe+ke)},${d(V+me)}`,sx:Pe,sy:V-me,sdx:-1,sdy:0,ex:Pe,ey:V+me,edx:-1,edy:0},ue.labelX=Me.x+Ne.w/2+ie+4+ue.labelW/2,ue.labelY=Me.y}else{let Me=ue.route;for(let Ne=0;Ne<Me.length;Ne+=3)Me[Ne]+=se,Me[Ne+1]+=oe;Ce=zr(Me,void 0,de,ke)}let be=xe.pattern==="dashed"?' stroke-dasharray="6 4"':xe.pattern==="dotted"?' stroke-dasharray="2 4"':"";if(pe+=`<g class="pele-edge${xe.pattern==="dotted"?" pele-note-edge":" pele-relation"}" data-id="${Oe(xe.id)}"><path d="${Ce.d}"${be}/>`+_g(Le,Ce.sx,Ce.sy,Ce.sdx,Ce.sdy,pf)+_g(We,Ce.ex,Ce.ey,Ce.edx,Ce.edy,pf)+"</g>",Ie.width>0){let Me=ue.labelX+se,Ne=ue.labelY+oe;ge+=wr(xe.id,Ie,Me,Ne,"",r.icons)}}let Ae="";for(let ce of M)Ae+=ce.math?Re(ce.math,ce.x+se,ce.y+oe,' class="pele-cardinality"',r.icons):`<text class="pele-cardinality" x="${d(ce.x+se)}" y="${d(ce.y+oe+f*.35)}" text-anchor="middle">${Ve(ce.text)}</text>`;let Se=To(e.title,h,o,g,ae,ne,(fe?`<g class="pele-clusters">${fe}</g>`:"")+(pe?`<g class="pele-edges" fill="none" stroke="${pf}" stroke-linecap="round">${pe}</g>`:"")+(ye?`<g class="pele-cluster-titles">${ye}</g>`:"")+(ge?`<g class="pele-edge-labels" font-size="${c}">${ge}</g>`:"")+(Ae?`<g class="pele-cardinalities" font-size="${f}" fill="var(--_m)">${Ae}</g>`:"")+`<g class="pele-nodes">${le}</g>`);return{svg:Je("class",Se.width,Se.height,o,r,e,Se.content),width:Se.width,height:Se.height,links:J}}var vg,O3,gl,P3,z3,Sg,F3,W3,df,mf,ec,uf,on,Y3,U3,gf,ul,pl,tc,G3,j3,Ig,ln,Ng,ff,Ko,Rg,X3,V3,Zo,pf,K3,Qo,Jo,Og,Pg=Xe(()=>{Yd();mo();Bn();Ei();Ea();hi();Ti();tr();zt();pr();ut();wt();vg=class{constructor(e,t){he(this,"id","");he(this,"memberType");he(this,"visibility","");he(this,"classifier","");he(this,"parameters","");he(this,"returnType","");this.memberType=t,(t!=="method"||!this.parseMethod(e))&&this.parseAttribute(e),this.id=this.id.startsWith(" ")?" "+this.id.trim():this.id.trim()}parseMethod(e){let t=e.length;for(let r=0;r<t;){let a=r;for(;a<t&&!Vi(e.charCodeAt(a));)a++;let i=a-1;for(;i>r&&e.charCodeAt(i)!==41;)i--;let n=i-1;for(;n>r&&e.charCodeAt(n)!==40;)n--;if(n>r){let l=e[r],s=Ag(l)&&n>r+1;s&&(this.visibility=l),this.id=e.slice(s?r+1:r,n),this.parameters=e.slice(n+1,i).trim();let o=i+1,c="";if(o<t){let p=e[o];(p==="$"||p==="*"||p.trim()==="")&&(c=p.trim(),o++)}let f=o;for(;f<t&&!Vi(e.charCodeAt(f));)f++;if(this.returnType=e.slice(o,f).trim(),c===""){let p=this.returnType.slice(-1);(p==="$"||p==="*")&&(c=p,this.returnType=this.returnType.slice(0,-1))}return this.classifier=c,!0}r=a+1}return this.memberType="attribute",!1}parseAttribute(e){let t=e.slice(0,1),r=e.slice(-1);Ag(t)&&(this.visibility=t),(r==="$"||r==="*")&&(this.classifier=r),this.id=e.substring(this.visibility===""?0:1,this.classifier===""?e.length:e.length-1)}getDisplayDetails(){let e=this.visibility+an(this.id);return this.memberType==="method"&&(e+=`(${an(this.parameters.trim())})`,this.returnType&&(e+=" : "+an(this.returnType))),{displayText:e.trim(),cssStyle:this.parseClassifier()}}parseClassifier(){return this.classifier==="*"?"font-style:italic;":this.classifier==="$"?"text-decoration:underline;":""}},O3={LINE:0,DOTTED_LINE:1},gl={AGGREGATION:0,EXTENSION:1,COMPOSITION:2,DEPENDENCY:3,LOLLIPOP:4},P3="classId-";z3=class{constructor(){he(this,"type","class");he(this,"lineType",O3);he(this,"relationType",gl);he(this,"direction","TB");he(this,"classes",new Map);he(this,"relations",[]);he(this,"notes",new Map);he(this,"namespaces",new Map);he(this,"interfaces",[]);he(this,"styleClasses",new Map);he(this,"title");he(this,"accTitle");he(this,"accDescr");he(this,"namespaceStack",[]);he(this,"withCssClass",new Map)}addClass(e){let{className:t,type:r}=Ri(e);if(this.classes.has(t))return;let a={id:t,type:r,label:t,cssClasses:"default",methods:[],members:[],annotations:[],styles:[]};this.classes.set(t,a),this.tag(a,"default")}tag(e,t){let r=this.withCssClass.get(t);r?r.add(e):this.withCssClass.set(t,new Set([e]))}ensure(e){return this.addClass(e),this.classes.get(Ri(e).className)}setClassLabel(e,t){this.ensure(e).label=t}addRelation(e){let{type1:t,type2:r}=e.relation;t===gl.LOLLIPOP&&r==="none"?(this.addClass(e.id2),e.id1=this.addInterface(e.id1,e.id2)):r===gl.LOLLIPOP&&t==="none"?(this.addClass(e.id1),e.id2=this.addInterface(e.id2,e.id1)):(this.addClass(e.id1),this.addClass(e.id2)),e.id1=Ri(e.id1).className,e.id2=Ri(e.id2).className,e.relationTitle1=e.relationTitle1.trim(),e.relationTitle2=e.relationTitle2.trim(),this.relations.push(e)}addInterface(e,t){let r=`interface${this.interfaces.length}`;return this.interfaces.push({id:r,label:e,classId:t}),r}addAnnotation(e,t){this.ensure(e).annotations.push(t)}addMember(e,t){let r=this.ensure(e);if(typeof t!="string")return;let a=t.trim();if(a.startsWith("<<")&&a.endsWith(">>"))r.annotations.push(a.substring(2,a.length-2));else if(a.indexOf(")")>0){let i=new vg(a,"method");(i.memberType==="method"?r.methods:r.members).push(i)}else a&&r.members.push(new vg(a,"attribute"))}addMembers(e,t){if(Array.isArray(t)){t.reverse();for(let r of t)this.addMember(e,r)}}addNote(e,t){let r=this.notes.size,a=`note${r}`;return this.notes.set(a,{id:a,class:t,text:e,index:r}),a}cleanupLabel(e){return(e.startsWith(":")?e.substring(1):e).trim()}setCssClass(e,t){for(let r of e.split(",")){let a=this.classes.get(Eg(r));if(a!==void 0){a.cssClasses+=" "+t;for(let i of t.split(" "))this.tag(a,i)}}}defineClass(e,t){for(let r of e){let a=this.styleClasses.get(r);if(a===void 0&&(a={id:r,styles:[],textStyles:[]},this.styleClasses.set(r,a)),!t)continue;for(let l of t)l.includes("color")&&a.textStyles.push(l.replace("fill","bgFill")),a.styles.push(l);let i=this.withCssClass.get(r);if(i===void 0)continue;let n=t.flatMap(l=>l.split(","));for(let l of i)for(let s of n)l.styles.push(s)}}setTooltip(e,t){if(t!==void 0)for(let r of e.split(",")){let a=this.classes.get(Ri(r).className);a&&(a.tooltip=t)}}setLink(e,t,r){let a=At(t).trim();for(let i of e.split(",")){let n=this.classes.get(Eg(i));n&&(n.link=a?Sa(a):void 0,n.linkTarget=typeof r=="string"?r:"_blank")}this.setCssClass(e,"clickable")}setClickEvent(e,t,r){for(let a of e.split(",")){let i=this.classes.get(Ri(a).className);i&&(i.haveCallback=!0)}this.setCssClass(e,"clickable")}setDirection(e){this.direction=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
69
+ `)}addNamespace(e,t){let r=this.namespaceStack[this.namespaceStack.length-1],a=r?`${r}.${e}`:e;this.namespaceStack.push(a);let i=this.namespaces.get(a);if(i)return i.explicit=!0,t&&(i.label=t),a;let n=r||void 0,l=r?r.length+1:0;for(;;){let s=a.indexOf(".",l),o=s===-1,c=o?a:a.slice(0,s),f=this.namespaces.get(c);if(f===void 0){let h=a.slice(l,o?a.length:s);f={id:c,label:o&&t?t:h,classes:new Map,notes:new Map,children:new Map,parent:n,explicit:o},this.namespaces.set(c,f)}else o&&(f.explicit=!0);let p=n?this.namespaces.get(n):void 0;if(p&&(p.children.has(c)||p.children.set(c,f),f.parent??(f.parent=n)),o)return a;n=c,l=s+1}}popNamespace(){this.namespaceStack.pop()}addClassesToNamespace(e,t,r){let a=this.namespaces.get(e);if(a!==void 0){for(let i of t){let{className:n}=Ri(i),l=this.classes.get(n);l!==void 0&&(l.parent=e,a.classes.set(n,l))}for(let i of r){let n=this.notes.get(i);n!==void 0&&(n.parent=e,a.notes.set(i,n))}}}setCssStyle(e,t){let r=this.classes.get(e);if(!(!t||!r))for(let a of t)for(let i of a.split(","))r.styles.push(i)}},Sg=["$end","INVALID","CLASS_DIAGRAM","NEWLINE","EOF","SQS","STR","SQE","DOT","GENERICTYPE","LABEL","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","STRUCT_START","STRUCT_STOP","NAMESPACE","STYLE_SEPARATOR","ANNOTATION_START","ANNOTATION_END","CLASS","MEMBER","NOTE_FOR","NOTE","CLASSDEF","ALPHA","COMMA","direction_tb","direction_bt","direction_rl","direction_lr","AGGREGATION","EXTENSION","COMPOSITION","DEPENDENCY","LOLLIPOP","LINE","DOTTED_LINE","CALLBACK","LINK","LINK_TARGET","CLICK","CALLBACK_NAME","CALLBACK_ARGS","HREF","STYLE","CSSCLASS","COLON","BRKT","PCT","MINUS","UNICODE_TEXT","BQUOTE_STR","EDGE_STATE","EOF_IN_STRUCT","OPEN_IN_STRUCT","PLUS","EQUALS","PUNCTUATION"],F3=[4,6,4,9,44,45,12,14,15,4,56,4,56],W3=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y],df=/[\n\r\u2028\u2029]/g;mf=61,ec=new Uint8Array(mf);for(let e of[53,27,52])ec[e]=1;uf=new Uint8Array(mf);for(let e of[27,49,50,47,51,10])uf[e]=1;on=new Uint8Array(mf);on[33]=1;on[34]=2;on[35]=3;on[36]=4;on[37]=5;Y3="'UNICODE_TEXT', 'NUM', 'ALPHA', 'MINUS', 'BQUOTE_STR'";U3=["aggregation","extension","composition","dependency","lollipop"];gf=12,ul=16,pl=6,tc=5;G3=40,j3=16,Ig=56,ln=20,Ng=26,ff=12,Ko=8,Rg=6,X3=10,V3=64,Zo=8,pf="var(--_l)",K3=new Set(["_self","_blank","_parent","_top"]);Qo=[],Jo=[];Og={type:"class",math:!0,parse(e,t,r){let a=new z3;return r&&(a.title=r),H3(e,a),a},render:Z3}});var zg={};_t(zg,{classDiagram:()=>Og});var Fg=Xe(()=>{Pg()});function kr(e,t,r){for(let a=0;a<r.length;a++){let i=e.charCodeAt(t+a),n=r.charCodeAt(a);if(i!==n&&!(n>=97&&n<=122&&i===n-32))return!1}return!0}var yf=Xe(()=>{});function rc(e,t,r){return new je(`value for ${e} ${t} is invalid, please use a valid ${r}`,"semantic",{type:"quadrantChart"})}function t4(e){let t=e.trim(),r=t.indexOf(":");if(r===-1)return[t,"undefined"];let a=t.slice(r+1).trimStart(),i=a.indexOf(":");return[t.slice(0,r).trimEnd(),i===-1?a:a.slice(0,i).trimEnd()]}function Bg(e){let t={};for(let r of e){let[a,i]=t4(r);if(a==="radius"){if(!J3.test(i))throw rc(a,i,"number");t.radius=parseInt(i)}else if(a==="color"){if(!Wg.test(i))throw rc(a,i,"hex code");t.color=i}else if(a==="stroke-color"){if(!Wg.test(i))throw rc(a,i,"hex code");t.strokeColor=i}else if(a==="stroke-width"){if(!e4.test(i))throw rc(a,i,"number of pixels (eg. 10px)");t.strokeWidth=i}else throw new je(`style named ${a} is not supported.`,"semantic",{type:"quadrantChart"})}return t}function pi(e){return{text:e.text.trim(),type:e.type}}function a4(e){let t=e.length,r=[],a=[],i=[],n=[],l=0,s=0,o=0,c=0,f=0,p=0,h=0,g=0,u=0,m=0,b=(P,B,G)=>{r.push(P),a.push(e.slice(B,G)),i.push(B),s=G},w=P=>{n.push(l),l=P},v=()=>{n.length>0&&(l=n.pop())},k=P=>{let B=e.indexOf(`
70
+ `,P);return B===-1?t:B},O=P=>{for(;e.charCodeAt(P)===32;)P++;return P},R=P=>{for(;P<t&&Ue(e.charCodeAt(P));)P++;return P},L=P=>{let B=e.charCodeAt(P);if(B===49)return P+1;if(B!==48)return-1;let G=P+1;if(G<t&&!Vi(e.charCodeAt(G))&&pt(e.charCodeAt(G+1)))for(G+=2;pt(e.charCodeAt(G));)G++;return G};e:for(;s<t;){let P=e.charCodeAt(s),B=e.charCodeAt(s+1);switch(l){case 0:break;case 1:case 2:case 3:b(xf[l],s,k(s)),v();continue;case 4:if(P===125)s++,v();else{let _=e.indexOf("}",s);b(9,s,_===-1?t:_)}continue;case 5:if(P===34)s++,v();else{let _=e.indexOf('"',s);b(19,s,_===-1?t:_)}continue;case 6:if(P===96&&B===34){s+=2,v();continue}if(P!==96&&P!==34){let _=s+1;for(let S=e.charCodeAt(_);_<t&&S!==96&&S!==34;S=e.charCodeAt(++_));b(18,s,_);continue}break e;case 7:if(Qe(P)){let _=s+1;for(;Qe(e.charCodeAt(_));)_++;b(20,s,_),v();continue}break e;case 8:{let _=L(s);if(_!==-1){b(22,s,_),w(9);continue}let S=R(s);if(e.charCodeAt(S)===93){s=O(S+1),v();continue}break e}case 9:{let _=R(s);if(e.charCodeAt(_)===44){s=R(_+1),l=10;continue}break e}case 10:{let _=L(s);if(_!==-1){b(23,s,_),v();continue}break e}}if(P===37&&B===37){s=k(s+2);continue}if(P!==125&&B===37&&e.charCodeAt(s+2)===37){s=k(s+3);continue}if(P===10||P===13){let _=s+1;for(let S=e.charCodeAt(_);S===10||S===13;S=e.charCodeAt(++_));b(2,s,_);continue}let G=P|32;if(G===116&&kr(e,s,"title")&&!Qe(e.charCodeAt(s+5))){b(3,s,s+5),w(1);continue}if(G===97&&kr(e,s,"acc")){let _=kr(e,s+3,"descr");if(_||kr(e,s+3,"title")){let S=R(s+8),$=e.charCodeAt(S);if($===58){b(_?7:5,s,R(S+1)),w(_?3:2);continue}if($===123&&_){s=R(S+1),w(4);continue}}}let C=s;P===32&&((s<o||s>=c)&&(o=s,c=O(s)),C=c);let Z=e.charCodeAt(C),ee=Z|32,H=0,Y=0;if(ee===120&&kr(e,C,"x-axis"))H=10,Y=C+6;else if(ee===121&&kr(e,C,"y-axis"))H=11,Y=C+6;else if(Z===45){if(C<f||C>=p)for(f=C,p=C;e.charCodeAt(p)===45;)p++;p-C>=2&&e.charCodeAt(p)===62&&(H=12,Y=p+1)}else if(ee===113&&kr(e,C,"quadrant")){let _=e.charCodeAt(C+9);e.charCodeAt(C+8)===45&&_>=49&&_<=52?(H=13+_-49,Y=C+10):kr(e,C+8,"chart")&&(H=24,Y=C+13)}if(H!==0){b(H,s,O(Y));continue}if(G===99&&kr(e,s,"classdef")&&!Qe(e.charCodeAt(s+8))){b(17,s,s+8);continue}if(P===34){B===96?(s+=2,w(6)):(s++,w(5));continue}if(P===58&&B===58&&e.charCodeAt(s+2)===58){s+=3,w(7);continue}if(P===58||Ue(P)){let _=s;if(P!==58&&((s<h||s>=g)&&(h=s,g=R(s)),_=g),e.charCodeAt(_)===58&&((_+1<u||_+1>=m)&&(u=_+1,m=R(_+1)),e.charCodeAt(m)===91)){b(21,s,R(m+1)),w(8);continue}}if(si(P)){let _=s+1;for(;si(e.charCodeAt(_));)_++;b(25,s,_);continue}if(P>=128){let _=s+1;for(;e.charCodeAt(_)>=128;)_++;b(26,s,_);continue}if(pt(P)){let _=s+1;for(;pt(e.charCodeAt(_));)_++;b(37,s,_);continue}if(bf[P]!==0){b(bf[P],s,s+1);continue}break}return s<t?(r.push(1),a.push(""),i.push(s),{types:r,texts:a,starts:i}):(l<xf.length&&(r.push(xf[l]),a.push(""),i.push(t)),r.push(0),a.push(""),i.push(t),{types:r,texts:a,starts:i})}function ac(...e){let t=new Uint8Array(42);for(let r of e)t[r]=1;return t}function s4(e,t){let{types:r,texts:a,starts:i}=a4(e),n=0,l=p=>{let h=r[n];throw h===1?it("quadrantChart",e,i[n],"",!0):it("quadrantChart",e,i[n],`Expecting ${p}, got '${Yg[h]}'`)},s=p=>(r[n]!==p&&l(`'${Yg[p]}'`),a[n++]),o=p=>p===19||p===18||Hg[p]===1,c=()=>{let p=r[n];o(p)||l(n4);let h=a[n++];for(;Hg[r[n]]===1||r[n]===38||r[n]===36;)h+=a[n++];return{text:h,type:p===18?"markdown":"text"}},f=()=>{let p=[];for(;;){wf[r[n]]===0&&l("'ALPHA', 'NUM', 'COLON', 'SPACE', 'BRKT', 'MINUS'");let h=a[n++];for(;wf[r[n]]===1;)h+=a[n++];if(p.push(h.trim()),r[n]!==29)return p;n++}};for(;qg[r[n]]===1||r[n]===38;)n++;for(s(24);r[n]!==0;){for(;r[n]===38;)n++;let p=r[n];switch(p){case 17:{n++,s(38),Ug[r[n]]===0&&l("'ALPHA', 'NUM', 'UNICODE_TEXT'");let h=a[n++];for(;Ug[r[n]]===1;)h+=a[n++];s(38),t.addClass(h,f());break}case 10:case 11:{n++;let h=c(),g;r[n]===12&&(n++,o(r[n])?g=c():h.text+=" \u27F6 "),p===10?(t.setXAxisLeftText(h),g&&t.setXAxisRightText(g)):(t.setYAxisBottomText(h),g&&t.setYAxisTopText(g));break}case 13:case 14:case 15:case 16:n++,t[i4[p-13]](c());break;case 3:n++,t.setDiagramTitle(s(4).trim());break;case 5:n++,t.setAccTitle(s(6).trim());break;case 7:n++,t.setAccDescription(s(8).trim());break;case 9:t.setAccDescription(a[n++].trim());break;default:if(o(p)){let h=c(),g=r[n]===20?a[n++]:"";s(21);let u=s(22),m=s(23);t.addPoint(h,g,u,m,wf[r[n]]===1?f():[])}}qg[r[n]]===0&&l("'NEWLINE', 'SEMI', 'EOF'"),n++}}function $f(e,t){return e.quadrantChart?.[t]}function ui(e,t,r,a){let i=$f(e,t);return typeof i=="number"&&i>=0?Math.min(i,a):r}function jg(e){return e.startsWith("#")?e:"#"+e}function o4(e,t,r){let a=r.fontSize??16,i=Math.round(a*.875),n=Math.round(a*.75),l=r.measurer??et(r.fontFamily),s=Math.round(Math.max(100,ui(t,"chartWidth",500,4e3))),o=Math.round(_i(r,s,280)),c=Math.round(Math.max(100,ui(t,"chartHeight",500,4e3))*o/s),f=ui(t,"quadrantPadding",r.padding??8,200),p=ui(t,"xAxisLabelPadding",5,200),h=ui(t,"yAxisLabelPadding",5,200),g=e.points.length>0,u=(X,te,se)=>ze(X?.text,X?.type==="markdown",l,te,Math.max(se,40)),m=ze(e.title,!1,l,a,Math.max(o-2*f,40),1),b=ui(t,"titlePadding",10,200),w=m.height>0?m.height+b:0,v=!!(e.xAxisLeft?.text||e.xAxisRight?.text),k=!!(e.yAxisBottom?.text||e.yAxisTop?.text),O=g||$f(t,"xAxisPosition")==="bottom",R=$f(t,"yAxisPosition")==="right",L=o-2*f,P=u(e.xAxisLeft,i,e.xAxisRight?L/2-16:L),B=u(e.xAxisRight,i,L/2-16),G=Math.max(P.height,B.height),C=v?G+p:0,Z=c-2*f-w-C,ee=u(e.yAxisBottom,i,e.yAxisTop?Z/2-16:Z),H=u(e.yAxisTop,i,Z/2-16),Y=Math.max(ee.height,H.height),_=k?Y+h:0,S=f+(R?0:_),$=f+w+(O?0:C),y=Math.max(0,L-_),E=Math.max(0,Z),x=Math.max(0,(y-Gg)/2),T=Math.max(0,(E-Gg)/2),A=[S+x,$,S+y-x,$+E,S,$+T,S+y,$+E-T],M=(X,te,se,oe,ae)=>{for(let ne=X;ne<A.length;ne+=4)if(te<A[ne+2]&&oe>A[ne]&&se<A[ne+3]&&ae>A[ne+1])return!1;return!0},N=ui(t,"quadrantTextTopPadding",5,200),F="";for(let X=0;X<4;X++){let te=X===0||X===3?S+y-x:S,se=X<2?$:$+E-T,oe=u(e.quadrants[X],a,x-16),ae=te+x/2,ne=g?se+N+oe.height/2:se+T/2;A.push(ae-oe.width/2,ne-oe.height/2,ae+oe.width/2,ne+oe.height/2),F+=`<g class="pele-quadrant" data-id="${X+1}"><rect x="${d(te)}" y="${d(se)}" width="${d(x)}" height="${d(T)}"${nt}/>`+Re(oe,ae,ne,' class="pele-label" fill="var(--_fg)" stroke="none"')+"</g>"}let U="";if(v){let X=O?$+E+p+G/2:$-p-G/2;U+=Re(P,B.height>0?S+y/4:S+P.width/2,X,"")+Re(B,S+y*3/4,X,"")}if(k){let X=R?S+y+h+Y/2:S-h-Y/2,te=(se,oe)=>se.height>0?`<g transform="translate(${d(X)},${d(oe)}) rotate(-90)">${Re(se,0,0,"")}</g>`:"";U+=te(ee,H.height>0?$+E*3/4:$+E-ee.width/2)+te(H,$+E/4)}let D=ui(t,"pointRadius",5,200),I=ui(t,"pointTextPadding",5,200),z=dt(0),q=[],j=[];for(let X of e.points){if(!(X.x>=0&&X.x<=1&&X.y>=0&&X.y<=1))continue;let te=e.classes.get(X.className),se=Math.min(X.radius??te?.radius??D,2e3),oe=X.color??te?.color,ae=X.strokeColor??te?.strokeColor,ne=X.strokeWidth??te?.strokeWidth,J=[];oe&&J.push("fill:"+jg(oe)),ne&&(ae&&J.push("stroke:"+jg(ae)),J.push("stroke-width:"+ne));let re=S+X.x*y,fe=$+(1-X.y)*E;q.push({cx:re,cy:fe,reach:se+(ne?Math.min(parseInt(ne),400)/2:0),text:u(X.text,n,200)}),j.push(`<circle class="pele-point${It(X.className)}" data-id="${Oe(X.text.text)}" cx="${d(re)}" cy="${d(fe)}" r="${d(se)}"${ne&&!ae?` stroke="${z}"`:""}${vt(J).shape}/>`)}let Q=q.length<=l4;if(Q)for(let{cx:X,cy:te,reach:se}of q)A.push(X-se,te-se,X+se,te+se);let K="";for(let{cx:X,cy:te,reach:se,text:oe}of q){let ae=oe.width/2,ne=oe.size*.6+(oe.height-oe.lineHeight)/2,J=se+I,re=[X,te+J+ne,X,te-J-ne,X+J+ae,te,X-J-ae,te],fe=X,ye=re[1],le=!1;for(let we=0;we<16;we+=2){let pe=we%8,ge=pe<4&&oe.width<y?Math.min(Math.max(re[pe],S+ae),S+y-ae):re[pe],Ae=re[pe+1];if(ge-ae<S||ge+ae>S+y||Ae-ne<$||Ae+ne>$+E)continue;let Se=!Q||M(we<8?0:8,ge-ae,Ae-ne,ge+ae,Ae+ne);if((!le||Se)&&(fe=ge,ye=Ae,le=!0),Se)break}Q&&A.push(fe-ae,ye-ne,fe+ae,ye+ne),K+=Re(oe,fe,ye,' class="pele-label"')}let W=Re(m,o/2,b/2+m.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-quadrants" fill="var(--_s)" stroke="var(--_b)">${F}</g>`+(U?`<g class="pele-axis-labels" font-size="${i}" fill="var(--_m)">${U}</g>`:"")+(q.length>0?`<g class="pele-points" fill="${z}">${j.reverse().join("")}</g><g class="pele-point-labels" font-size="${n}">${K}</g>`:"");return{svg:Je("quadrantChart",o,c,a,r,e,W),width:o,height:c,links:[]}}var J3,Wg,e4,r4,Yg,xf,bf,Hg,Ug,wf,qg,i4,n4,Gg,l4,Xg,Vg=Xe(()=>{yf();tr();zt();ut();wt();J3=/^\d+$/,Wg=/^#?([\dA-Fa-f]{6}|[\dA-Fa-f]{3})$/,e4=/^\d+px$/;r4=class{constructor(){he(this,"type","quadrantChart");he(this,"title");he(this,"accTitle");he(this,"accDescr");he(this,"quadrants",[void 0,void 0,void 0,void 0]);he(this,"xAxisLeft");he(this,"xAxisRight");he(this,"yAxisBottom");he(this,"yAxisTop");he(this,"points",[]);he(this,"classes",new Map)}setQuadrant1Text(e){this.quadrants[0]=pi(e)}setQuadrant2Text(e){this.quadrants[1]=pi(e)}setQuadrant3Text(e){this.quadrants[2]=pi(e)}setQuadrant4Text(e){this.quadrants[3]=pi(e)}setXAxisLeftText(e){this.xAxisLeft=pi(e)}setXAxisRightText(e){this.xAxisRight=pi(e)}setYAxisBottomText(e){this.yAxisBottom=pi(e)}setYAxisTopText(e){this.yAxisTop=pi(e)}addPoint(e,t,r,a,i){this.points.push({x:Number(r),y:Number(a),text:pi(e),className:t,...Bg(i)})}addClass(e,t){this.classes.set(e,Bg(t))}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
71
+ `)}},Yg=["$end","INVALID","NEWLINE","title","title_value","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","X-AXIS","Y-AXIS","AXIS-TEXT-DELIMITER","QUADRANT_1","QUADRANT_2","QUADRANT_3","QUADRANT_4","CLASSDEF","MD_STR","STR","class_name","point_start","point_x","point_y","QUADRANT","ALPHA","UNICODE_TEXT","COLON","PLUS","COMMA","EQUALS","MULT","BRKT","UNDERSCORE","DOT","AMP","MINUS","NUM","SPACE","SEMI","PUNCTUATION","EOF"],xf=[41,4,6,8,9,19],bf=new Uint8Array(128);for(let[e,t]of[[":",27],["+",28],[",",29],["=",30],["*",31],["#",32],["_",33],[".",34],["&",35],["-",36],[" \v\f",38],[";",39],["!$%'`?\\/",40]])for(let r=0;r<e.length;r++)bf[e.charCodeAt(r)]=t;Hg=ac(40,35,37,25,29,28,30,31,34,32,33,26),Ug=ac(25,37,36,29,27,35,32,31,26),wf=ac(25,37,27,38,32,36),qg=ac(2,39,41),i4=["setQuadrant1Text","setQuadrant2Text","setQuadrant3Text","setQuadrant4Text"],n4="'STR', 'MD_STR', 'ALPHA', 'NUM', 'UNICODE_TEXT', 'PUNCTUATION'";Gg=4,l4=300;Xg={type:"quadrantChart",parse(e,t,r){let a=new r4;return a.title=r,s4(e,a),a},render:o4}});var Kg={};_t(Kg,{quadrantChart:()=>Xg});var Zg=Xe(()=>{Vg()});function h4(e){let t=e.length,r=[],a=[],i=[],n=[],l=0,s=0,o=(m,b,w)=>{r.push(m),a.push(e.slice(b,w)),i.push(b),s=w},c=m=>{n.push(l),l=m},f=()=>{n.length>0&&(l=n.pop())},p=m=>{let b=e.indexOf(`
72
+ `,m);return b===-1?t:b},h=m=>{for(;m<t&&Ue(e.charCodeAt(m));)m++;return m},g=m=>{for(;pt(e.charCodeAt(m));)m++;return m},u=m=>kr(e,s,m)&&!Qe(e.charCodeAt(s+m.length));for(;s<t;){let m=e.charCodeAt(s);if(l===5){if(m===34)s++,f();else{let w=e.indexOf('"',s);o(19,s,w===-1?t:w)}continue}if(l===6||l===7){o(Jg[l],s,p(s)),f();continue}if(l===8){if(m===125)s++,f();else{let w=e.indexOf("}",s);o(8,s,w===-1?t:w)}continue}let b=e.charCodeAt(s+1);if(m===37&&b===37){s=p(s+2);continue}if(m!==125&&b===37&&e.charCodeAt(s+2)===37){s=p(s+3);continue}if(m===10||m===13){if((l===1||l===3)&&(m===10||b===10)){o(2,s,m===10?s+1:s+2),f();continue}let w=s+1;for(let v=e.charCodeAt(w);v===10||v===13;v=e.charCodeAt(++w));o(2,s,w);continue}switch(m|32){case 116:if(u("title")){o(3,s,s+5);continue}break;case 97:if(kr(e,s,"acc")){let w=kr(e,s+3,"descr");if(w||kr(e,s+3,"title")){let v=h(s+8),k=e.charCodeAt(v);if(k===58){o(w?6:4,s,h(v+1)),c(w?7:6);continue}if(k===123&&w){s=h(v+1),c(8);continue}}}break;case 120:if(u("xychart-beta")){o(9,s,s+12);continue}if(u("xychart")){o(9,s,s+7);continue}if(u("x-axis")){o(11,s,s+6),c(1);continue}break;case 121:if(u("y-axis")){o(12,s,s+6),c(1);continue}break;case 118:if(kr(e,s,"vertical")){o(10,s,s+8);continue}break;case 104:if(kr(e,s,"horizontal")){o(10,s,s+10);continue}break;case 108:if(u("line")){o(14,s,s+4),c(3);continue}break;case 98:if(u("bar")){o(15,s,s+3),c(3);continue}break}if(m===91){l===1?c(2):l===3&&c(4),o(17,s,s+1);continue}if(m===93){(l===4||l===2)&&f(),o(18,s,s+1);continue}if(l===1&&m===45&&b===45&&e.charCodeAt(s+2)===62){o(13,s,s+3);continue}if(l===1||l===4){let w=m===43||m===45?s+1:s,v=e.charCodeAt(w),k=-1;if(pt(v)?(k=g(w+1),e.charCodeAt(k)===46&&pt(e.charCodeAt(k+1))&&(k=g(k+2))):v===46&&pt(e.charCodeAt(w+1))&&(k=g(w+2)),k!==-1){o(16,s,k);continue}}if(m===96&&kr(e,s,em)){s+=em.length,f();continue}if(m===34){s++,c(5);continue}if(si(m)){let w=s+1;for(;si(e.charCodeAt(w));)w++;o(20,s,w);continue}if(pt(m)){o(31,s,g(s+1));continue}if(Ue(m)){s=h(s+1);continue}if(m<128&&Mf[m]!==0){o(Mf[m],s,s+1);continue}break}return s<t?(r.push(1),a.push(""),i.push(s),{types:r,texts:a,starts:i}):(r.push(Jg[l]),a.push(""),i.push(t),r.push(0),a.push(""),i.push(t),{types:r,texts:a,starts:i})}function hm(...e){let t=new Uint8Array(34);for(let r of e)t[r]=1;return t}function d4(e,t){let{types:r,texts:a,starts:i}=h4(e),n=0,l=h=>{let g=r[n];throw g===1?it("xychart",e,i[n],"",!0):it("xychart",e,i[n],`Expecting ${h}, got '${Qg[g]}'`)},s=h=>(r[n]!==h&&l(`'${Qg[h]}'`),a[n++]),o=h=>h===19||tm[h]===1,c=()=>{o(r[n])||l("'STR', 'ALPHA', 'NUM'");let h=a[n++];if(r[n-1]!==19)for(;tm[r[n]]===1;)h+=a[n++];return{text:h,type:"text"}},f=()=>{let h=Number(s(16));return s(13),[h,Number(s(16))]},p=()=>{let h=[];for(s(17);;){let g=Number(s(16));if(h.push({value:g,label:r[n]===19?a[n++]:""}),r[n]!==23)break;n++}return s(18),h};for(;;)if(rm[r[n]]===1)n++;else{if(r[n]!==9)break;r[++n]===10&&t.setOrientation(a[n++])}for(;r[n]!==0;){let h=r[n++];switch(h){case 3:t.setDiagramTitle(c().text.trim());break;case 11:case 12:{let g=o(r[n])?c():void 0;if(h===11&&r[n]===17){let u=[];do n++,u.push(c());while(r[n]===23);s(18),t.setXAxisBand(u)}else if(r[n]===16||g===void 0){let[u,m]=f();h===11?t.setXAxisRangeData(u,m):t.setYAxisRangeData(u,m)}h===11?t.setXAxisTitle(g??{type:"text",text:""}):t.setYAxisTitle(g??{type:"text",text:""});break}case 14:case 15:{let g=r[n]===17?{text:"",type:"text"}:c(),u=p();h===14?t.setLineData(g,u):t.setBarData(g,u);break}case 4:t.setAccTitle(s(5).trim());break;case 6:t.setAccDescription(s(7).trim());break;case 8:t.setAccDescription(a[n-1].trim());break;default:n--,l("'title', 'X_AXIS', 'Y_AXIS', 'LINE', 'BAR', 'acc_title', 'acc_descr', 'acc_descr_multiline_value'")}for(;rm[r[n]]===1;)n++}}function am(e,t){let r=e/Math.max(t,1),a=Math.floor(Math.log10(r)),i=r/10**a,n=i>=7.07?10:i>=3.16?5:i>=1.41?2:1;return a<0?-(10**-a)/n:n*10**a}function nc(e,t){return e>0?t/e:t*-e}function ml(e,t){return e>0?t*e:t/-e}function im(e,t,r){let a=Math.round(nc(r,e));ml(r,a)<e&&a++;let i=Math.round(nc(r,t));ml(r,i)>t&&i--;let n=[];for(let l=a;l<=i&&n.length<100;l++)n.push(ml(r,l));return n}function kf(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{}}function ya(e,t,r=!0){let a=e[t];return typeof a=="boolean"?a:r}function cm(e,t){return typeof e=="number"&&e>0?Math.round(Math.min(Math.max(e,100),4e3)):t}function Li(e){return typeof e=="number"&&isFinite(e)?Math.min(Math.max(e,-om),om):void 0}function f4(e){let t=0;for(let r of e)t=Math.max(t,r.label.width);return t}function ic(e,t,r,a){let i=e.lines.length===1?e.lines[0]:void 0;return i&&i.length===1&&i[0].icon===void 0&&i[0].style===0?`<text x="${d(t)}" y="${d(r+e.size*.35)}" text-anchor="${a}">${Ve(i[0].text)}</text>`:Re(e,t+(a==="start"?e.width/2:a==="end"?-e.width/2:0),r,"")}function p4(e,t,r){if(e.plots.length===0)throw new je("No Plot to render, please provide a plot with some data","semantic",{type:"xychart"});let a=kf(t.xyChart),i=r.fontSize??16,n=Math.round(i*.875),l=Math.round(i*.75),s=r.measurer??et(r.fontFamily),o=r.padding??8,c=cm(a.width,700),f=_i(r,c,240),p=Math.round(cm(a.height,500)*Math.max(.6,f/c)),h=(e.orientation??a.chartOrientation)==="horizontal",g=ya(a,"showDataLabel",!1),u=e.xAxis,m=e.plots,b=(Ee,qe,Ge)=>ze(Ee,!1,s,qe,Ge),w=b("0",n,4e3).height,v=b("0",l,4e3).height,k=ze(ya(a,"showTitle")?e.title:void 0,!1,s,i,f-2*o,1),O=k.height>0?k.height+12:0,R=[],L=0;ya(a,"showLegend")&&m.forEach((Ee,qe)=>{if(Ee.title==="")return;let Ge=b(Ee.title,n,f*.3);R.push({index:qe,label:Ge}),L=Math.max(L,Ge.width+es+8)});let P=R.length>0?L+lm:0,B=m.filter(Ee=>Ee.type==="bar").length,G=e.yAxis.min,C=e.yAxis.max,Z=e.hasSetYAxis&&isFinite(G)&&isFinite(C)&&G!==C;if(Z)G=Li(G),C=Li(C);else{G=1/0,C=-1/0;for(let Ee of m)for(let[,qe]of Ee.data){let Ge=Li(qe);Ge!==void 0&&(Ge<G&&(G=Ge),Ge>C&&(C=Ge))}G>C&&(G=C=0),B>0&&(G=Math.min(G,0),C=Math.max(C,0)),G===C&&(G===0?C=1:(G-=Math.abs(G)/2,C+=Math.abs(C)/2))}let ee=(Ee,qe)=>{let Ge=am(Math.abs(C-G),Math.max(2,Math.min(10,Math.floor(Ee/qe))));return Z||(G=ml(Ge,Math.floor(nc(Ge,G)+1e-9)),C=ml(Ge,Math.ceil(nc(Ge,C)-1e-9))),im(Math.min(G,C),Math.max(G,C),Ge).map(rt=>({at:(rt-G)/(C-G),label:b(String(rt),n,4e3)}))},H=1;if(u.type==="band")H=Math.max(u.categories.length,1);else for(let Ee of m)H=Math.max(H,Ee.data.length);let Y=1/H,_=u.type==="band"||B>0?Y/2:0,S=Li(u.type==="linear"?u.min:void 0),$=Li(u.type==="linear"?u.max:void 0),y=S!==void 0&&$!==void 0&&S!==$,E=(Ee,qe)=>u.type==="band"?(Ee+.5)*Y:_+(qe>1?Ee/(qe-1):y?0:.5)*(1-2*_),x=kf(a.xAxis),T=kf(a.yAxis),A=h?x:T,M=h?T:x,N=b(ya(A,"showTitle")?h?u.title:e.yAxis.title:void 0,n,p*.8),F=b(ya(M,"showTitle")?h?e.yAxis.title:u.title:void 0,n,f*.8),U=ya(A,"showTick")?nm:0,D=ya(M,"showTick")?nm:0,I=ya(A,"showLabel"),z=ya(M,"showLabel"),q=h?f*.3:Math.max(48,(f-2*o-64-P)*Y-8),j=u.type==="band"&&ya(x,"showLabel")?u.categories.map(Ee=>b(Ee,n,q)):[],Q=0,K=0;for(let Ee of j)Q=Math.max(Q,Ee.width),K=Math.max(K,Ee.height);let W=Ee=>{let qe=[];if(u.type==="band"){let Ge=j.length===0?8:h?K:Q+12,rt=Math.max(1,Math.ceil(Ge/(Ee*Y)));for(let ct=0;ct<u.categories.length;ct+=rt)qe.push({at:(ct+.5)*Y,label:j[ct]??b(void 0,n,0)})}else if(y){let Ge=am(Math.abs($-S),Math.max(2,Math.min(10,Math.floor(Ee/(h?32:80)))));for(let rt of im(Math.min(S,$),Math.max(S,$),Ge))qe.push({at:_+(rt-S)/($-S)*(1-2*_),label:b(String(rt),n,4e3)})}else S!==void 0&&qe.push({at:.5,label:b(String(S),n,4e3)});return qe},X=0,te=0;for(let Ee of m){for(let qe of Ee.pointLabels??[])X=Math.max(X,s.width(qe,l,0));if(g&&h&&Ee.type==="bar")for(let[,qe]of Ee.data)te=Math.max(te,s.width(String(Li(qe)??""),l,0))}let se=z?h||u.type!=="band"?w:K:0,oe=D+(se>0?se+4:0)+(F.height>0?F.height+4:0),ae=h?0:X>0||g?v+4:I?w/2:0,ne=o+O+ae,J=Math.max(1,p-o-oe-ne),re=ne+J,fe=h?W(J):ee(J,56),ye=I?f4(fe):0,le=o+(N.height>0?N.height+6:0)+(ye>0?ye+6:0)+U,we=Math.max(X>0?X+12:0,te>0?te+8:0),pe=h?Math.min(f*.25,we):0,ge=Math.max(1,f-o-le-P-pe),Ae=h?ee(ge,80):W(ge);if(z&&P+pe===0){let Ee=0;for(let qe of Ae)Ee=Math.max(Ee,qe.at*ge+qe.label.width/2-ge);ge=Math.max(1,ge-Ee)}let Se=le+ge,ce=(Ee,qe)=>h?le+qe*ge:le+Ee*ge,ue=(Ee,qe)=>h?ne+Ee*J:re-qe*J,xe=Ee=>(Ee-G)/(C-G),Ie=Ee=>Math.min(Math.max(Ee,0),1),Le=Ee=>h?`M${d(ce(0,Ee))},${d(ne)}V${d(re)}`:`M${d(le)},${d(ue(0,Ee))}H${d(Se)}`,We="";for(let Ee of h?Ae:fe)We+=Le(Ee.at);let de="",ke="";ya(A,"showAxisLine")&&(de+=`M${d(le)},${d(ne)}V${d(re)}`),ya(M,"showAxisLine")&&(de+=`M${d(le)},${d(re)}H${d(Se)}`);for(let Ee of fe){let qe=h?ne+Ee.at*J:re-Ee.at*J;U&&(de+=`M${d(le)},${d(qe)}h${-U}`),I&&(ke+=ic(Ee.label,le-U-6,qe,"end"))}for(let Ee of Ae){let qe=le+Ee.at*ge;D&&(de+=`M${d(qe)},${d(re)}v${D}`),z&&(ke+=ic(Ee.label,qe,re+D+4+Ee.label.height/2,"middle"))}let Ce=(h?J:ge)*Y,be=Ce*.7/Math.max(B,1),Me=B>1?Math.min(2,be*.2):0,Ne=Ie(xe(0));B>0&&Ne>0&&Ne<1&&(de+=Le(Ne));let Be="",Pe="",V="",me="",ie=0;m.forEach((Ee,qe)=>{let Ge=dt(qe),rt=Ee.title?` data-id="${Oe(Ee.title)}"`:"",ct=u.type==="band"?Math.min(Ee.data.length,H):Ee.data.length;if(Ee.type==="bar"){let kt=(ie++-(B-1)/2)*be-(be-Me)/2,Ft="";for(let He=0;He<ct;He++){let ht=Li(Ee.data[He][1]);if(ht===void 0)continue;let yt=E(He,ct),ot=Ie(xe(ht)),er=Math.min(Ne,ot),St=Math.max(Ne,ot),Ze=h?ce(yt,er):ce(yt,0)+kt,xt=h?ue(yt,0)+kt:ue(yt,St),Dt=h?(St-er)*ge:be-Me,Rt=h?be-Me:(St-er)*J;if(Ft+=`<rect x="${d(Ze)}" y="${d(xt)}" width="${d(Dt)}" height="${d(Rt)}"/>`,!g)continue;let ir=String(ht),ia=s.width(ir,l,0),ka=ot>=Ne?1:-1,Cs=Ze+Dt/2,_s=xt+Rt/2,Is="middle";if(h){if(Rt<l)continue;Cs=(ka>0?Ze+Dt:Ze)+ka*6,Is=ka>0?"start":"end"}else{if(ia+2>Ce/B)continue;_s=(ka>0?xt:xt+Rt)-ka*(v/2+2)}V+=`<text x="${d(Cs)}" y="${d(_s+l*.35)}" text-anchor="${Is}">${ir}</text>`}Be+=`<g class="pele-series pele-bars"${rt} fill="${Ge}">${Ft}</g>`;return}let tt="",lt="",st=!1,Wt=0,Ct=NaN;for(let kt=0;kt<ct;kt++){let Ft=Li(Ee.data[kt][1]);if(Ft===void 0){Ct=NaN;continue}let He=E(kt,ct),ht=xe(Ft),yt=ht>=0&&ht<=1;if(Ct!==Ct)yt&&(tt+=`M${d(ce(He,ht))},${d(ue(He,ht))}`),st=yt;else{let Ze=ht-Ct,xt=0,Dt=1;if(Ze!==0){let Rt=-Ct/Ze,ir=(1-Ct)/Ze;xt=Math.max(xt,Math.min(Rt,ir)),Dt=Math.min(Dt,Math.max(Rt,ir))}else yt||(xt=2);if(xt<=Dt){let Rt=Wt+(He-Wt)*xt,ir=Ct+Ze*xt,ia=Wt+(He-Wt)*Dt,ka=Ct+Ze*Dt;(!st||xt>0)&&(tt+=`M${d(ce(Rt,ir))},${d(ue(Rt,ir))}`),tt+=`L${d(ce(ia,ka))},${d(ue(ia,ka))}`}st=yt}if(Wt=He,Ct=ht,!yt)continue;let ot=ce(He,ht),er=ue(He,ht);Ce>=12&&(lt+=`<circle cx="${d(ot)}" cy="${d(er)}" r="3"/>`);let St=b(Ee.pointLabels?.[kt],l,4e3);if(St.height>0){let Ze=St.width/2;me+=h?ic(St,ot+10,er,"start"):ic(St,Math.max(Math.min(ot,Se-Ze),le+Ze),er-6-St.height/2,"middle")}}Pe+=`<g class="pele-series pele-line"${rt} fill="${Ge}">`+(tt?`<path d="${tt}" fill="none" stroke="${Ge}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>`:"")+lt+"</g>"});let $e="";N.height>0&&($e+=`<g transform="translate(${d(o+N.height/2)},${d(ne+J/2)}) rotate(-90)">${Re(N,0,0,"")}</g>`),$e+=Re(F,le+ge/2,p-o-F.height/2,"");let ve="",Te=0;for(let Ee of R)Te+=Math.max(sm,Ee.label.height+6);let De=ne+Math.max(0,(J-Te)/2),_e=Se+pe+lm;for(let{index:Ee,label:qe}of R){let Ge=Math.max(sm,qe.height+6);if(De+Ge>p)break;let rt=De+Ge/2,ct=dt(Ee);ve+=`<g class="pele-legend-item" data-id="${Oe(m[Ee].title)}">`+(m[Ee].type==="bar"?`<rect x="${d(_e)}" y="${d(rt-es/2)}" width="${es}" height="${es}" rx="2" fill="${ct}"/>`:`<path d="M${d(_e)},${d(rt)}h${es}" stroke="${ct}" stroke-width="2" stroke-linecap="round"/>`)+Re(qe,_e+es+8+qe.width/2,rt,"")+"</g>",De+=Ge}let Ye=Re(k,f/2,o+k.height/2,' class="pele-title" font-weight="var(--_tw)"')+(We?`<path class="pele-grid" d="${We}" stroke="var(--_a)"/>`:"")+`<g class="pele-plot">${Be}${Pe}</g>`+(de?`<path class="pele-axis" d="${de}" fill="none" stroke="var(--_b)"/>`:"")+(ke?`<g class="pele-axis-labels" font-size="${n}" fill="var(--_m)">${ke}</g>`:"")+($e?`<g class="pele-axis-titles" font-size="${n}">${$e}</g>`:"")+(V?`<g class="pele-data-labels" font-size="${l}">${V}</g>`:"")+(me?`<g class="pele-point-labels" font-size="${l}">${me}</g>`:"")+(ve?`<g class="pele-legend" font-size="${n}">${ve}</g>`:"");return{svg:Je("xychart",f,p,i,r,e,Ye),width:f,height:p,links:[]}}var c4,Qg,Jg,em,Mf,tm,rm,nm,es,sm,lm,om,dm,fm=Xe(()=>{yf();tr();zt();ut();wt();c4=class{constructor(){he(this,"type","xychart");he(this,"title");he(this,"accTitle");he(this,"accDescr");he(this,"orientation");he(this,"xAxis",{type:"band",title:"",categories:[]});he(this,"yAxis",{type:"linear",title:"",min:1/0,max:-1/0});he(this,"hasSetXAxis",!1);he(this,"hasSetYAxis",!1);he(this,"plots",[])}setOrientation(e){this.orientation=e==="horizontal"?"horizontal":"vertical"}setXAxisTitle(e){this.xAxis.title=e.text.trim()}setXAxisRangeData(e,t){this.xAxis={type:"linear",title:this.xAxis.title,min:e,max:t},this.hasSetXAxis=!0}setXAxisBand(e){this.xAxis={type:"band",title:this.xAxis.title,categories:e.map(t=>t.text.trim())},this.hasSetXAxis=!0}setYAxisTitle(e){this.yAxis.title=e.text.trim()}setYAxisRangeData(e,t){this.yAxis={type:"linear",title:this.yAxis.title,min:e,max:t},this.hasSetYAxis=!0}plotData(e){if(e.length===0)return[];this.hasSetXAxis||this.setXAxisRangeData(1,e.length);let t=this.xAxis;if(t.type==="band"&&e.length>t.categories.length&&(e=e.slice(0,t.categories.length)),!this.hasSetYAxis){let{min:a,max:i}=this.yAxis;for(let n of e)n<a&&(a=n),n>i&&(i=n);this.yAxis={type:"linear",title:this.yAxis.title,min:a,max:i}}if(t.type==="band")return t.categories.map((a,i)=>[a,e[i]]);if(e.length===1)return[[`${t.min}`,e[0]]];let r=(t.max-t.min)/(e.length-1);return e.map((a,i)=>[`${t.min+i*r}`,a])}addPlot(e,t,r){let a={type:e,title:t.text.trim(),data:this.plotData(r.map(i=>i.value))};e==="line"&&r.some(i=>i.label.trim()!=="")&&(a.pointLabels=r.map(i=>i.label.trim())),this.plots.push(a)}setLineData(e,t){this.addPlot("line",e,t)}setBarData(e,t){this.addPlot("bar",e,t)}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
73
+ `)}},Qg=["$end","INVALID","NEWLINE","title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","XYCHART","CHART_ORIENTATION","X_AXIS","Y_AXIS","ARROW_DELIMITER","LINE","BAR","NUMBER_WITH_DECIMAL","SQUARE_BRACES_START","SQUARE_BRACES_END","STR","ALPHA","COLON","PLUS","COMMA","EQUALS","MULT","BRKT","UNDERSCORE","DOT","AMP","MINUS","NUM","SEMI","EOF"],Jg=[33,33,33,33,33,19,5,7,8],em="`)"+" ".repeat(36)+'{ this.pushstate(md_string); }\n<md_string>(?:(?!`").)+'+" ".repeat(18)+"{ return md_str; }\n<md_string>(?:`",Mf=new Uint8Array(128);for(let[e,t]of[[":",21],["+",22],[",",23],["=",24],["*",25],["#",26],["_",27],[".",28],["&",29],["-",30],[";",32]])Mf[e.charCodeAt(0)]=t;tm=hm(29,31,20,22,24,25,28,26,30,27),rm=hm(2,32,33);nm=4,es=12,sm=26,lm=24,om=1e300;dm={type:"xychart",section:"xyChart",parse(e,t,r){let a=new c4;return a.title=r,d4(e,a),a},render:p4}});var pm={};_t(pm,{xychart:()=>dm});var um=Xe(()=>{fm()});function u4(e){let t="TB";for(let r of e)typeof r!="string"&&r.stmt==="dir"&&(t=r.value);return t}function g4(e,t,r){let a=[],i=[],n=new Map,l=new Map,s=new Map,o=0,c=0,f=g=>{if(!g.id||g.id==="</join></fork>"||g.id==="</choice>")return;if(g.cssClasses){let m;for(let b of g.cssClasses.split(" ")){let w=r.get(b);if(w){m??(m=g.cssCompiledStyles.slice());for(let v of w.styles)m.push(v)}}m&&(g.cssCompiledStyles=m)}let u=n.get(g.id);if(u){let m=g.parentId??u.parentId;Object.assign(u,g),m!==void 0&&(u.parentId=m)}else n.set(g.id,g),a.push(g)},p=(g,u,m)=>{let b=u.id;if(b==="root")return;let w=t.get(b),v=w?.classes?.join(" ")??"",k=w?.styles??[],O=l.get(b);if(!O){let H="rect";u.start===!0?H="stateStart":u.start===!1&&(H="stateEnd"),u.type!=="default"&&(H=u.type),O={shape:H,description:b,cssClasses:`${v} statediagram-state`,cssStyles:k,type:void 0,dir:void 0,colorIndex:void 0},l.set(b,O)}if(u.description&&(Array.isArray(O.description)?(O.shape="rectWithTitle",O.description=O.description.concat(u.description)):O.description.length>0?(O.shape="rectWithTitle",O.description=O.description===b?[u.description].flat():[O.description,u.description].flat()):(O.shape="rect",O.description=Array.isArray(u.description)?u.description.slice():u.description)),O.description.length===1&&O.shape==="rectWithTitle"&&(O.shape=O.type==="group"?"roundedWithTitle":"rect"),!O.type&&u.doc){if(O.type="group",O.dir=u4(u.doc),O.shape=u.type==="divider"?"divider":"roundedWithTitle",O.shape==="divider"&&g?.id!==void 0&&s.has(g.id))O.colorIndex=s.get(g.id);else{let H=c++;O.colorIndex=v.trim()!==""||k.length>0?void 0:H}s.set(b,O.colorIndex),O.cssClasses=`${O.cssClasses} statediagram-cluster ${m?"statediagram-cluster-alt":""}`}let R=O.description,L={id:b,shape:O.shape,label:Array.isArray(R)?R[0]:R,description:Array.isArray(R)?R.slice(1):[],cssClasses:O.cssClasses,cssCompiledStyles:[],cssStyles:O.cssStyles,type:O.type,isGroup:O.type==="group",dir:O.dir,colorIndex:O.colorIndex};L.shape==="divider"&&(L.label=""),g&&g.id!=="root"&&(L.parentId=g.id);let P=u.note;if(!P){f(L);return}let B=(H,Y,_,S)=>({id:H,shape:Y,label:P.text,description:[],cssClasses:_,cssCompiledStyles:[],cssStyles:[],type:S?"group":"node",isGroup:S,dir:void 0,position:P.position}),G=B(`${b}----note-${o++}`,"note","statediagram-note",!1);G.parentId=`${b}----parent`,G.noteFor=b,f(B(G.parentId,"noteGroup",O.cssClasses,!0)),f(G),f(L);let C=P.position==="left of",Z=C?G.id:b,ee=C?b:G.id;i.push({id:`${Z}-${ee}`,start:Z,end:ee,label:"",classes:"transition note-edge",pattern:"dashed"})},h=[{item:void 0,doc:e,at:0,alt:!0}];for(;h.length>0;){let g=h[h.length-1];if(g.at>=g.doc.length){h.pop();continue}let u=g.doc[g.at++];typeof u!="string"&&(u.stmt==="state"?(p(g.item,u,g.alt),u.doc&&h.push({item:u,doc:u.doc,at:0,alt:!g.alt})):u.stmt==="relation"&&(p(g.item,u.state1,g.alt),p(g.item,u.state2,g.alt),i.push({id:`edge${o++}`,start:u.state1.id,end:u.state2.id,label:u.description??"",classes:"transition"})))}for(let g of a)if(g.isGroup&&g.description.length>0)throw new je(`Group nodes can only have label. Remove the additional description for node [${g.id}]`,"semantic",{type:"state"});return{nodes:a,edges:i}}function yl(e,t){let r=0,a=-2;return i=>{if(a===-2||i<r||a!==-1&&i>a){e.lastIndex=i;let n=e.exec(t);a=n?n.index:-1,r=i}return a}}function k4(e){let t=e.length,r=[],a=[],i=[],n=[],l=0,s=0,o,c=yl(y4,e),f=yl(x4,e),p=yl(w4,e),h=yl(b4,e),g=yl($4,e),u=-1,m=-1,b=[-1,-1,-1,-1],w=[0,0,0,0],v=-1,k=-1,O=[-1,-1,-1,-1,-1,-1],R=(y,E,x)=>{r.push(y),a.push(e.slice(E,x)),i.push(E),s=x},L=(y,E,x,T)=>{r.push(y),a.push(E),i.push(x),s=T},P=y=>{n.push(l),l=y},B=()=>{n.length>0&&(l=n.pop())},G=(y,E)=>{for(let x=0;x<y.length;x++){let T=y.charCodeAt(x),A=e.charCodeAt(E+x);if(A!==T&&!(T>=97&&T<=122&&A===T-32))return!1}return!0},C=y=>{let E=y;for(;E<t&&Ue(e.charCodeAt(E));)E++;return E},Z=y=>{let E=y;for(;E<t&&Qe(e.charCodeAt(E));)E++;return E},ee=y=>{let E=e.indexOf(`
74
+ `,y);return E===-1?t:E},H=y=>{let E=p(y);return E===-1?t:E},Y=y=>{if(y<u||y>m){let E=c(y),x=E===-1?t:H(y);u=y,m=x,b[0]=b[1]=b[2]=b[3]=-1;for(let T=E;T!==-1&&T<x;T=c(T+1)){let A=C(T+9);if(A===T+9)continue;let M=G("tb",A)?0:G("bt",A)?1:G("rl",A)?2:G("lr",A)?3:-1;M!==-1&&(b[M]=T,w[M]=A+2)}}for(let E=0;E<4;E++)if(b[E]>=y)return E;return-1},_=y=>{if(y<v||y>k){let E=f(y),x=E===-1?t:H(y);v=y,k=x,O.fill(-1);for(let T=E;T!==-1&&T<x;T=f(T+1)){let A=e.charCodeAt(T+2)|32;O[(e.charCodeAt(T)===60?0:3)+(A===102?0:A===106?1:2)]=T}}for(let E=0;E<6;E++)if(O[E]>=y)return E;return-1},S=(y,E)=>{let x=h(y);return x===-1||x+2>E?(R(14,y,E),!0):x===y?(s=E,!1):(R(14,y,x),!0)},$=y=>(r.push(y),a.push(""),i.push(s),{types:r,texts:a,starts:i,error:o});for(;;){if(s>=t){switch(l){case 0:R(2,t,t);break;case 6:R(22,t,t);break;case 7:R(24,t,t);break;case 8:R(25,t,t);break;case 10:R(32,t,t);break;case 12:R(39,t,t);break;case 14:R(36,t,t);break;case 3:R(12,t,t);break;case 18:R(20,t,t);break;case 4:case 19:R(14,t,t);break}return $(0)}let y=e.charCodeAt(s);switch(l){case 0:case 1:{let E=l===0,x=y|32;if(E){if(x===99&&G("click",s)&&!Qe(e.charCodeAt(s+5))){R(26,s,s+5);continue}if(x===104&&G("href",s)&&!Qe(e.charCodeAt(s+4))){R(28,s,s+4);continue}if(y===34){let M=e.indexOf('"',s+1);if(M!==-1){R(27,s,M+1);continue}}if(x===100&&G("default",s)&&!Qe(e.charCodeAt(s+7))){R(33,s,s+7);continue}let A=Y(s);if(A!==-1){R(40+A,s,ee(w[A]));continue}if(y===10){let M=s+1;for(;e.charCodeAt(M)===10;)M++;R(2,s,M);continue}if(Ue(y)){s=C(s);continue}}else if(y!==10&&Ue(y)){let A=s+1;for(;A<t&&e.charCodeAt(A)!==10&&Ue(e.charCodeAt(A));)A++;s=A;continue}if(y===35||y===37&&e.charCodeAt(s+1)===37&&e.charCodeAt(s+2)!==123){s=ee(s);continue}if(x===115){if(E&&G("scale",s)){let A=C(s+5);if(A>s+5){R(7,s,A),P(5);continue}}if(G("style",s)){let A=C(s+5);if(A>s+5){R(34,s,A),P(13);continue}}if(G("state",s)){let A=C(s+5);if(A>s+5){s=A,P(2);continue}if(E&&G("diagram",s+5)){let M=G("-v2",s+12)?s+15:s+12;if(A=C(M),A>M){R(3,s,A);continue}}}}else if(x===99){if(G("class",s)){let A=G("def",s+5),M=A?s+8:s+5,N=C(M);if(N>M){R(A?29:37,s,N),P(A?9:11);continue}}}else if(x===97&&E&&(G("acctitle",s)||G("accdescr",s))){let A=(e.charCodeAt(s+3)|32)===116,M=C(s+8),N=e.charCodeAt(M);if(N===58){R(A?21:23,s,C(M+1)),P(A?6:7);continue}if(N===123&&!A){s=C(M+1),P(8);continue}}if(E){if(y===123){R(10,s,s+1),P(1);continue}}else{let A=Y(s);if(A!==-1){R(40+A,s,ee(w[A]));continue}if(y===125){R(11,s,s+1),B();continue}if(y===10){s++;continue}}if(x===110&&G("note",s)){let A=C(s+4);if(A>s+4){R(19,s,A),P(15);continue}}if(E&&x===104&&G("hide empty description",s)&&!Qe(e.charCodeAt(s+22))){R(6,s,s+22);continue}if(y===91&&e.charCodeAt(s+1)===42&&e.charCodeAt(s+2)===93){R(44,s,s+3);continue}let T=s;for(;T<t;){let A=e.charCodeAt(T);if(A===58||A===45||A===123||Ue(A))break;T++}if(T>s){S(s,T);continue}if(y===58){for(T=s+1;T<t;){let A=e.charCodeAt(T);if(A===10||A===59)break;if(A===58){let M=e.charCodeAt(T+1);if(T+1>=t||M===58||M===10||M===59)break;T++}T++}if(T>s+1){L(4,e.slice(s,T).trim(),s,T);continue}if(e.charCodeAt(s+1)===58&&e.charCodeAt(s+2)===58){R(45,s,s+3);continue}}else if(y===45&&e.charCodeAt(s+1)===45){if(e.charCodeAt(s+2)===62){R(5,s,s+3);continue}if(!E){R(18,s,s+2);continue}}if(!E)return $(1);R(48,s,s+1);continue}case 2:{if(y!==10&&Ue(y)){let A=s+1;for(;A<t&&e.charCodeAt(A)!==10&&Ue(e.charCodeAt(A));)A++;s=A;continue}if(y===35||y===37&&e.charCodeAt(s+1)===37&&e.charCodeAt(s+2)!==123){s=ee(s);continue}let E=_(s);if(E!==-1){let A=O[E],M=E===2||E===5;L(M?17:E%3===0?15:16,e.slice(s,A).trim(),s,A+(M?10:8)),B();continue}if(y===34){s++,P(3);continue}let x=y===10?C(s):s;if(G("as",x)){let A=C(x+2);if(A>x+2){R(13,s,A),P(4);continue}}if(y===10){s++,B();continue}if(y===123){R(10,s,s+1),B(),P(1);continue}if(Qe(y)){let A=Z(s),M=C(A);if(M>A&&Qe(e.charCodeAt(M))){let N=g(M+1);if(N!==-1&&N<H(M))return o=`Error: State name must be a single word. Found: "${e.slice(s,N+1).trim()}"`,$(1)}}let T=s+1;for(;T<t;){let A=e.charCodeAt(T);if(A===123||Ue(A))break;T++}R(9,s,T);continue}case 3:{if(y===34){s++,B();continue}let E=e.indexOf('"',s);R(12,s,E===-1?t:E);continue}case 4:{let E=s;for(;E<t;){let x=e.charCodeAt(E);if(x===10||x===123)break;E++}S(s,E)&&B();continue}case 5:{if(y>=48&&y<=57){let x=s+1;for(;x<t&&e.charCodeAt(x)>=48&&e.charCodeAt(x)<=57;)x++;R(8,s,x);continue}let E=C(s);if(E>s&&G("width",E)&&!Qe(e.charCodeAt(E+5))){s=E+5,B();continue}return $(1)}case 6:R(22,s,ee(s)),B();continue;case 7:R(24,s,ee(s)),B();continue;case 8:{if(y===125){s++,B();continue}let E=e.indexOf("}",s);R(25,s,E===-1?t:E);continue}case 9:{let E=G("default",s)&&C(s+7)>s+7,x=E?s+7:Z(s),T=C(x);if(x===s||T===x)return $(1);R(E?31:30,s,T),B(),P(10);continue}case 10:R(32,s,ee(s)),B();continue;case 11:{let E=Z(s);if(E===s)return $(1);for(;e.charCodeAt(E)===44;){let x=C(E+1),T=Z(x);if(T===x)break;E=T}R(38,s,E),B(),P(12);continue}case 12:R(39,s,ee(s)),B();continue;case 13:{let E=s;for(;E<t&&(Qe(e.charCodeAt(E))||e.charCodeAt(E)===44);)E++;let x=C(E);if(E===s||x===E)return $(1);R(35,s,x),B(),P(14);continue}case 14:R(36,s,ee(s)),B();continue;case 15:{if(G("left of",s)&&!Qe(e.charCodeAt(s+7))){R(46,s,s+7),B(),P(16);continue}if(G("right of",s)&&!Qe(e.charCodeAt(s+8))){R(47,s,s+8),B(),P(16);continue}if(y===34){s++,B(),P(18);continue}return $(1)}case 16:{let E=C(s),x=E;for(;x<t;){let T=e.charCodeAt(x);if(T===58||T===45||Ue(T))break;x++}if(x===E)return $(1);S(s,x)&&(B(),P(17));continue}case 17:{let E=C(s);if(e.charCodeAt(E)===58){let A=E+1;for(;A<t;){let M=e.charCodeAt(A);if(M===58||M===10||M===59)break;A++}if(A>E+1){L(20,e.slice(s+2,A).trim(),s,A),B();continue}}let x=e.indexOf(`
75
+ `,s),T=-1;for(;x!==-1&&(T=C(x),!(G("end note",T)&&!Qe(e.charCodeAt(T+8))));)x=e.indexOf(`
76
+ `,T);if(x===-1)return $(1);L(20,e.slice(s,T).trim(),s,T+8),B();continue}case 18:{let E=C(s);if(G("as",E)){R(13,s,C(E+2)),B(),P(19);continue}if(y===34){s++;continue}let x=e.indexOf('"',s);R(20,s,x===-1?t:x);continue}case 19:S(s,ee(s))&&B();continue}}}function A4(e,t){let{types:r,texts:a,starts:i,error:n}=k4(e),l=0,s=u=>{let m=r[l];throw m===1?n!==void 0?new je(n,"syntax",{type:"state",...Ys(e,i[l])}):it("state",e,i[l],"",!0):it("state",e,i[l],`Expecting ${u}, got '${gm[m]}'`)},o=u=>(r[l]!==u&&s(`'${gm[u]}'`),a[l++]),c=()=>{let u=r[l];u!==14&&u!==44&&s("'ID', 'EDGE_STATE'");let m=a[l++].trim();return r[l]!==45?{stmt:"state",id:m,type:"default",description:""}:(l++,{stmt:"state",id:m,classes:[o(14).trim()],type:"default",description:""})};for(;r[l]===2;)l++;r[l]!==3&&s("'NL', 'SD'"),l++;let f=[],p=[],h=u=>{u!=="nl"&&f.push(u)},g=(u,m)=>{l++;let b=[];f.push({stmt:"state",id:u,type:"default",description:m,doc:b}),p.push(f),f=b};for(;;){let u=r[l];switch(u){case 2:l++;break;case 14:case 44:{let m=c();if(r[l]===4)m.description=t.trimColon(a[l++]),h(m);else if(r[l]===5){l++;let b=c();r[l]===4?h({stmt:"relation",state1:m,state2:b,description:t.trimColon(a[l++])}):h({stmt:"relation",state1:m,state2:b})}else h(m);break}case 6:h(a[l++]);break;case 7:l++,o(8),h(a[l-2]);break;case 9:r[l+1]===10?g(a[l++],""):h(a[l++]);break;case 12:{let m=a[l++];o(13);let b=o(14);if(r[l]===10)g(b,m);else if(b.includes(":")){let w=b.split(":");h({stmt:"state",id:w[0],type:"default",description:[m.trim(),w[1]]})}else h({stmt:"state",id:b,type:"default",description:m.trim()});break}case 15:h({stmt:"state",id:a[l++],type:"fork"});break;case 16:h({stmt:"state",id:a[l++],type:"join"});break;case 17:h({stmt:"state",id:a[l++],type:"choice"});break;case 18:l++,h({stmt:"state",id:t.getDividerId(),type:"divider"});break;case 19:{let m=a[l++];if(r[l]===46||r[l]===47){let b=a[l++].trim(),w=o(14).trim();h({stmt:"state",id:w,note:{position:b,text:o(20).trim()}})}else r[l]!==20&&s("'NOTE_TEXT', 'left_of', 'right_of'"),l++,o(13),o(14),h(m);break}case 40:case 41:case 42:case 43:{let m=M4[u-40];l++,t.setDirection(m),h({stmt:"dir",value:m});break}case 21:{l++;let m=o(22).trim();t.setAccTitle(m),h(m);break}case 23:{l++;let m=o(24).trim();t.setAccDescription(m),h(m);break}case 25:{let m=a[l++].trim();t.setAccDescription(m),h(m);break}case 26:{l++;let m=c(),b,w="";r[l]===28?(l++,b=o(27)):(r[l]!==27&&s("'STRING', 'HREF'"),b=a[l++],w=o(27)),o(2),h({stmt:"click",id:m,url:b,tooltip:w});break}case 29:{l++;let m=o(30).trim();h({stmt:"classDef",id:m,classes:o(32).trim()});break}case 34:{l++;let m=o(35).trim();h({stmt:"style",id:m,styleClass:o(36).trim()});break}case 37:{l++;let m=o(38).trim();h({stmt:"applyClass",id:m,styleClass:o(39).trim()});break}case 11:p.length===0&&s(`'$end', ${sc}`),l++,f=p.pop();break;case 0:return p.length>0&&s(`'STRUCT_STOP', ${sc}`),t.setRootDoc(f),f;default:s(p.length>0?`'STRUCT_STOP', ${sc}`:`'$end', ${sc}`)}}}function bm(e){return e==="TB"||e==="BT"}function Sf(e,t,r){let a=e.state?.[t];return typeof a=="number"&&a>0?Math.min(a,2e3):r}function $m(e){let t=0,r=e.length;for(;t<r&&e.charCodeAt(t)===34;)t++;for(;r>t&&e.charCodeAt(r-1)===34;)r--;return e.slice(t,r)}function km(e,t,r){return e<t?t:e>r?r:e}function oc(e,t,r,a,i){return`<rect x="${d(e)}" y="${d(t)}" width="${d(r)}" height="${d(a)}"${i}/>`}function cc(e,t,r,a){let i=Ut(0,0);return i.isGroup=!0,i.dir=e,i.padX=t,i.padTop=r,i.padBottom=a,i}function R4(e,t,r){return jr(e.direction)?Bt(r,a=>Mm(e,t,r,a)):Mm(e,t,r,!1)}function Mm(e,t,r,a){let i=e.graph,n=r.fontSize??16,l=Math.round(n*.875),s=r.measurer??et(r.fontFamily),o=Sf(t,"wrappingWidth",200),c=r.padding??8,f=r.icons,p=a?"TB":br(e.direction),h=ze(void 0,!1,s,n,0),g=(J,re,fe,ye=0)=>ze(J,!0,s,re,fe,ye),u=new Map,m=[],b=[],w=(J,re,fe)=>(m.push({node:J,kind:re,style:void 0,label:h,lines:[],w:0,h:0,titleH:0}),fe&&b.push(fe),m.length-1);for(let J of i.nodes){if(J.shape==="noteGroup")continue;let re=J.isGroup?J.shape==="divider"?9:8:I4.get(J.shape)??0;u.set(J.id,w(J,re,void 0))}let v=m.length,k=[];for(let J=0;J<v;J++){let re=m[J].node.parentId,fe=re===void 0?void 0:u.get(re);k.push(fe!==void 0&&fe!==J&&m[fe].node.isGroup?fe:-1)}{let J=[];for(let pe=0;pe<v;pe++)J.push([]);let re=[],fe=new Uint8Array(v);for(let pe=0;pe<v;pe++)k[pe]===-1?(fe[pe]=1,re.push(pe)):J[k[pe]].push(pe);let ye=0,le=()=>{for(;ye<re.length;ye++)for(let pe of J[re[ye]])fe[pe]||(fe[pe]=1,re.push(pe))};le();let we=new Int32Array(v).fill(-1);for(let pe=0;pe<v;pe++){if(fe[pe])continue;let ge=pe;for(;we[ge]!==pe;)we[ge]=pe,ge=k[ge];k[ge]=-1,fe[ge]=1,re.push(ge),le()}}let O=new Int32Array(v).fill(-1);for(let J=0;J<v;J++){let re=m[J].node.noteFor,fe=re===void 0?void 0:u.get(re);fe!==void 0&&(O[J]=fe,k[J]=k[fe])}let R=J=>br(m[J].node.dir),L=J=>bm(k[J]===-1?p:R(k[J])),P=new Int32Array(v),B=new Uint8Array(v),G=new Array(v).fill(1/0),C=0,Z=new Int32Array(2*v);for(let J of i.edges){let re=u.get(J.start),fe=u.get(J.end);if(!(re===void 0||fe===void 0)){if(J.pattern==="dashed"){B[m[re].kind===7?fe:re]=1;continue}P[re]=Math.max(P[re],++Z[2*re]),P[fe]=Math.max(P[fe],++Z[2*fe+1]),G[re]===1/0&&(G[re]=C++),G[fe]===1/0&&(G[fe]=C++)}}for(let J=0;J<v;J++){let re=m[J],fe=re.node,ye=vt(fe.cssStyles.length>0?fe.cssCompiledStyles.concat(fe.cssStyles):fe.cssCompiledStyles),le=(ye.bold?1:0)|(ye.italic?2:0),we=ye.fontSize??n;re.style=ye;let pe;switch(re.kind){case 8:re.label=g(fe.label,we,4e3,le),re.titleH=re.label.height>0?re.label.height+12:0,pe=cc(R(J),ts,re.titleH+ts,ts),pe.minW=re.label.width+2*ts;break;case 9:pe=cc(R(J),Af,Af,Af);break;case 2:re.w=re.h=14;break;case 3:re.w=re.h=18;break;case 4:re.w=re.h=30;break;case 5:case 6:{let ge=km(40*P[J]+16,72,320);re.w=L(J)?ge:xm,re.h=L(J)?xm:ge;break}case 10:break;case 7:re.label=g(fe.label,l,Math.max(o,C4)),re.w=re.label.width+24,re.h=re.label.height+16;break;default:{re.label=g(fe.label,we,o,le);let ge=re.label.width,Ae=re.label.height+2*mm;if(re.kind===1){Ae+=14;for(let Se of fe.description){let ce=g(Se===""?" ":Se,l,o,le);re.lines.push(ce),ce.width>ge&&(ge=ce.width),Ae+=ce.height}}re.w=Math.max(ge+2*T4,56),re.h=Ae}}pe??(pe=Ut(re.w,re.h)),(re.kind===0||re.kind===1)&&(pe.span=(L(J)?re.w:re.h)-24),b.push(pe)}let ee=[],H=[],Y=[],_=new Int32Array(v),S=new Float64Array(v),$=new Float64Array(v),y=new Map,E=(J,re)=>{if(!b[J].isGroup)return!1;for(let fe=k[re];fe!==-1;fe=k[fe])if(fe===J)return!0;return!1},x=(J,re)=>(y.set(ee.length,J),G.push(re?-1:1/0),w(void 0,10,Ut(0,0,J)));for(let J of i.edges){let re=u.get(J.start),fe=u.get(J.end);if(re===void 0||fe===void 0)continue;let ye=g(J.label,l,o),le=ye.width>0?ye.width+12:0;re===fe?(_[re]++,S[re]=Math.max(S[re],le),$[re]+=ye.height):E(re,fe)?re=x(re,!0):E(fe,re)&&(fe=x(fe,!1)),Y.push(J),H.push(ye),ee.push({src:re,dst:fe,minlen:1,labelW:le,labelH:ye.height>0?ye.height+4:0,route:[],labelX:0,labelY:0})}for(let J=0;J<v;J++){if(O[J]!==-1)continue;let re=b[J],fe=0;if(_[J]>0){let le=vf+(_[J]-1)*8;fe=L(J)?le+S[J]:le*.75+4+$[J],re.isGroup||(L(J)?(re.w+=2*fe,re.h=Math.max(re.h,$[J])):(re.h+=2*fe,re.w=Math.max(re.w,S[J])),fe=0)}if(!B[J]&&fe===0){re.parent=k[J];continue}let ye=L(J)?cc("LR",fe,0,0):cc("TB",0,fe,fe);ye.parent=k[J],G.push(G[J]),b[J].parent=w(void 0,10,ye)}for(let J=0;J<v;J++)O[J]!==-1&&(b[J].parent=b[O[J]].parent);{let J=[];for(let pe=0;pe<b.length;pe++)J.push([]);let re=[];for(let pe=0;pe<b.length;pe++){let ge=b[pe].parent;ge>=0?J[ge].push(pe):re.push(pe)}let fe=pe=>m[pe].kind===2?0:1,ye=(pe,ge)=>fe(pe)-fe(ge)||(G[pe]===G[ge]?0:G[pe]<G[ge]?-1:1)||pe-ge,le=0,we=re.sort(ye).reverse();for(;we.length>0;){let pe=we.pop();b[pe].seq=le++;let ge=J[pe].sort(ye);for(let Ae=ge.length-1;Ae>=0;Ae--)we.push(ge[Ae])}}let T=Gr(b,ee,p,{nodeSep:Sf(t,"nodeSpacing",v4),edgeSep:E4,rankSep:Sf(t,"rankSpacing",S4),portSep:20,headRoom:gt("arrow_point")}),A=Math.ceil(T.width+2*c),M=Math.ceil(T.height+2*c),N=[],F=new Map;for(let J of ee){let re=J.route;for(let fe=3;fe<re.length-3;fe+=3){let ye=Math.round(re[fe+1]),le=F.get(ye);le?le.push(re[fe]):F.set(ye,[re[fe]])}}let U=[];for(let J=0;J<b.length;J++)U.push([]);let D=[];for(let J=0;J<b.length;J++){let re=b[J].parent;re>=0?U[re].push(J):D.push(J)}let I=D.slice();for(let J=0;J<D.length;J++)for(let re of U[D[J]])D.push(re);let z="",q="",j="",Q="",K=(J,re,fe,ye,le)=>{let we=J.filter(Ae=>m[Ae].kind===9);if(we.length<2)return;let pe=(Ae,Se)=>Se?b[Ae].x-b[Ae].w/2:b[Ae].y-b[Ae].h/2,ge=(Ae,Se)=>Se?b[Ae].x+b[Ae].w/2:b[Ae].y+b[Ae].h/2;for(let Ae of[!0,!1]){let Se=we.slice().sort((ue,xe)=>pe(ue,Ae)-pe(xe,Ae)||ue-xe),ce=!0;for(let ue=1;ue<Se.length;ue++)ge(Se[ue-1],Ae)>pe(Se[ue],Ae)+.5&&(ce=!1);if(ce){for(let ue=1;ue<Se.length;ue++){let xe=d((ge(Se[ue-1],Ae)+pe(Se[ue],Ae))/2+c);q+=`<path class="pele-divider" d="M${Ae?`${xe},${d(fe)}V${d(le)}`:`${d(re)},${xe}H${d(ye)}`}"/>`}return}}for(let Ae of we){let Se=b[Ae];q+=oc(Se.x-Se.w/2+c,Se.y-Se.h/2+c,Se.w,Se.h,` class="pele-divider" rx="${Ef}"`)}};K(I,c/2,c/2,A-c/2,M-c/2);for(let J of D){let re=m[J],fe=re.node,ye=re.style;if(fe===void 0||ye===void 0||re.kind>=9)continue;let le=b[J],we=le.x+c,pe=le.y+c,ge=re.w,Ae=re.h,Se=` class="pele-label"${ye.text}`,ce;switch(re.kind){case 8:{let Ie=we-le.w/2,Le=pe-le.h/2;ce=oc(Ie,Le,le.w,le.h,` rx="${Ef}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${ye.shape}`),re.titleH>0&&(ce+=`<path d="M${d(Ie)},${d(Le+re.titleH)}H${d(Ie+le.w)}"${lc}${ye.line}/>`+Re(re.label,L4(le,re.label.width,F)+c,Le+re.titleH/2,` class="pele-cluster-label"${ye.text}`,f)),K(U[J],Ie,Le+re.titleH,Ie+le.w,Le+le.h);break}case 2:ce=`<circle r="7" fill="var(--_l)"${ye.shape}/>`;break;case 3:ce=`<circle r="8.5" fill="var(--_bg)" stroke="var(--_l)"${ye.line}/><circle r="5" fill="var(--_l)"${ye.shape}/>`;break;case 4:ce=`<polygon points="0,${d(-Ae/2)} ${d(ge/2)},0 0,${d(Ae/2)} ${d(-ge/2)},0"${wm}${ye.shape}/>`;break;case 5:case 6:ce=oc(-ge/2,-Ae/2,ge,Ae,` rx="2" fill="var(--_l)"${ye.shape}`);break;case 7:{let Ie=d(ge/2),Le=d(Ae/2),We=d(ge/2-ym),de=d(ym-Ae/2);ce=`<path d="M-${Ie},-${Le}H${We}L${Ie},${de}V${Le}H-${Ie}Z" fill="var(--_bg)" stroke="var(--_b)"/><path d="M${We},-${Le}V${de}H${Ie}"${lc}/>`+Re(re.label,0,0,` class="pele-label" font-size="${l}" fill="var(--_m)"`,f);break}default:{if(ce=oc(-ge/2,-Ae/2,ge,Ae,` rx="${d(Math.min(Ef,Ae/2))}"${wm}${ye.shape}`),re.kind===0){ce+=Re(re.label,0,0,Se,f);break}let Ie=mm-Ae/2+re.label.height;ce+=`<path d="M${d(-ge/2)},${d(Ie+6)}H${d(ge/2)}"${lc}${ye.line}/>`+Re(re.label,0,Ie-re.label.height/2,Se,f),Ie+=14;for(let Le of re.lines)ce+=Re(Le,0,Ie+Le.height/2,` class="pele-state-description" font-size="${l}"${ye.text}`,f),Ie+=Le.height}}let ue=e.links.get(fe.id);if(ue){let Ie=At($m(ue.tooltip));Ie&&(ce=`<title>${Ve(Ie)}</title>`+ce),ce=ua(ce,Ta($m(ue.url)),fe.id,N,r,' target="_blank"')}let xe=`<g class="${N4[re.kind]}${It(fe.cssClasses.replace(_4,""))}" data-id="${Oe(fe.id)}"`;re.kind===8?z+=`${xe}>${ce}</g>`:re.kind===7?Q+=`${xe} transform="translate(${d(we)},${d(pe)})">${ce}</g>`:j+=`${xe} transform="translate(${d(we)},${d(pe)})">${ce}</g>`}let W=(J,re,fe)=>{let ye=b[fe];if(ye.isGroup)return;let le=m[fe],we=le.kind===5||le.kind===6,pe=re===0?3:re-3;for(let ge of[1,0]){let Ae=ge?ye.h:ye.w,Se=ge?le.h:le.w,ce=ge?le.w:le.h,ue=(ge?ye.y:ye.x)+c,xe=(ge?ye.x:ye.y)+c,Ie=J[re+ge]-ue;if(!(Math.abs(Math.abs(Ie)-Ae/2)>=.5)){J[re+ge]-=Math.sign(Ie)*(Ae-Se)/2,we&&ce>Se&&(J[re+1-ge]=km(J[pe+1-ge],xe-ce/2+6,xe+ce/2-6));return}}},X=Mo();for(let J=0;J<ee.length;J++){let re=ee[J];re.src===re.dst||re.route.length<6||Y[J].pattern==="dashed"||X.add(re.dst,ga(re.route,re.route.length-3,b[re.dst]),"arrow_point")}let te="",se="",oe=new Int32Array(v),ae=new Float64Array(v);for(let J=0;J<ee.length;J++){let re=ee[J],fe=Y[J],ye=H[J],le=fe.pattern==="dashed",we=le?"none":"arrow_point",pe;if(re.src===re.dst){let ge=b[re.src],Ae=m[re.src],Se=oe[re.src]++,ce=L(re.src),ue=ge.isGroup?ge.w:Ae.w,xe=ge.isGroup?ge.h:Ae.h,Ie=(ce?ue:xe)/2,Le=Math.max(Math.min((ce?xe:ue)/2-4,8+Se*6),2),We=vf+Se*8,de=gt(we)/(Math.hypot(We,Le)||1),ke=(Pe,V)=>ge.x+c+(ce?Ie+Pe:-V),Ce=(Pe,V)=>ge.y+c+(ce?V:Ie+Pe),be=(Pe,V)=>`${d(ke(Pe,V))},${d(Ce(Pe,V))}`;pe={d:`M${be(0,-Le)}C${be(We,-2*Le)} ${be(We,2*Le)} ${be(We*de,Le+Le*de)}`,sx:0,sy:0,sdx:0,sdy:0,ex:ke(0,Le),ey:Ce(0,Le),edx:ke(-We,-Le)-ke(0,0),edy:Ce(-We,-Le)-Ce(0,0)};let Me=Math.hypot(pe.edx,pe.edy)||1;pe.edx/=Me,pe.edy/=Me;let Ne=vf+(_[re.src]-1)*8,Be=ae[re.src]+ye.height/2;ae[re.src]+=ye.height,re.labelX=ce?ge.x+Ie+Ne+4+re.labelW/2:ge.x,re.labelY=ce?ge.y-$[re.src]/2+Be:ge.y+Ie+Ne*.75+4+Be}else{let ge=re.route.slice(),Ae=X.of(re.src,ga(ge,0,b[re.src])),Se=X.of(re.dst,ga(ge,ge.length-3,b[re.dst]));for(let ue=0;ue<ge.length;ue+=3)ge[ue]+=c,ge[ue+1]+=c;W(ge,0,re.src),W(ge,ge.length-3,re.dst);let ce=y.get(J);if(ce!==void 0&&ge.length>=6){let ue=b[ce],xe=m[re.src].kind===10,Ie=xe?0:ge.length-3,Le=(ue.dir==="TB"||ue.dir==="LR")===xe,We=bm(ue.dir)?[ge[Ie],ue.y+c+(Le?m[ce].titleH-ue.h/2:ue.h/2),0]:[ue.x+c+(Le?-ue.w/2:ue.w/2),ge[Ie+1],1];ge=xe?We.concat(ge):ge.concat(We)}pe=zr(ge,void 0,0,gt(we),Ae,Se)}if(te+=`<g class="pele-edge ${le?'pele-note-edge" stroke="var(--_b)" stroke-dasharray="3 4':"pele-transition"}" data-id="${Oe(fe.id)}"><path d="${pe.d}"/>`+bt(we,pe.ex,pe.ey,pe.edx,pe.edy,"var(--_l)")+"</g>",ye.width>0){let ge=re.labelX+c,Ae=re.labelY+c;se+=wr(fe.id,ye,ge,Ae,"",f)}}let ne=To(e.title,s,n,c,A,M,(z?`<g class="pele-clusters">${z}</g>`:"")+(q?`<g class="pele-dividers" stroke-dasharray="4 4"${lc}>${q}</g>`:"")+(te?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${te}</g>`:"")+(se?`<g class="pele-edge-labels" font-size="${l}">${se}</g>`:"")+`<g class="pele-nodes">${j}${Q}</g>`);return{svg:Je("state",ne.width,ne.height,n,r,e,ne.content),width:ne.width,height:ne.height,links:N}}function L4(e,t,r){let a=r.get(Math.round(e.y-e.h/2));if(a===void 0||t===0)return e.x;let i=e.x-e.w/2,n=t/2,l=e.x,s=-1;for(let o of[e.x,i+ts+n,i+e.w-ts-n]){let c=1/0;for(let f of a)f>i&&f<i+e.w&&(c=Math.min(c,Math.abs(f-o)-n));if(c>=6)return o;c>s+.5&&(s=c,l=o)}return l}var m4,gm,y4,x4,w4,b4,$4,M4,sc,v4,E4,S4,ts,Af,T4,mm,vf,ym,C4,Ef,xm,wm,lc,_4,I4,N4,Am,vm=Xe(()=>{Ei();Ea();hi();Ti();tr();zt();pr();ut();wt();m4=class{constructor(){he(this,"type","state");he(this,"rootDoc",[]);he(this,"states",new Map);he(this,"relations",[]);he(this,"classes",new Map);he(this,"links",new Map);he(this,"graph",{nodes:[],edges:[]});he(this,"title");he(this,"accTitle");he(this,"accDescr");he(this,"dividerCount",0)}get direction(){let e="TB";for(let t of this.rootDoc)typeof t!="string"&&t.stmt==="dir"&&(e=t.value);return e}setRootDoc(e){this.rootDoc=e,this.translate(),this.extract(e)}extract(e){this.states=new Map,this.relations=[],this.classes=new Map;let t=Array.isArray(e)?e:e.doc;for(let r of t)if(typeof r!="string")switch(r.stmt){case"state":this.addState(r.id.trim(),r.type,r.doc,r.description,r.note);break;case"relation":this.addRelation(r.state1,r.state2,r.description);break;case"classDef":this.addStyleClass(r.id.trim(),r.classes);break;case"style":{let a=r.styleClass.split(",").map(i=>i.replace(/;/g,"").trim());for(let i of this.named(r.id.trim()))i.styles=a.slice();break}case"applyClass":this.setCssClass(r.id.trim(),r.styleClass);break;case"click":this.addLink(typeof r.id=="string"?r.id:r.id.id,r.url,r.tooltip);break}this.graph=g4(t,this.states,this.classes)}translate(){let e=[["root",{stmt:"root",id:"root",doc:this.rootDoc},!0]];for(;e.length>0;){let[t,r,a]=e.pop();if(typeof r=="string")continue;if(r.stmt==="relation"){e.push([t,r.state2,!1],[t,r.state1,!0]);continue}if(r.stmt==="state")r.id==="[*]"?(r.id=t+(a?"_start":"_end"),r.start=a):r.id=r.id.trim();else if(r.stmt!=="root")continue;if(!r.doc)continue;let i=[],n=[];for(let l of r.doc)typeof l!="string"&&l.stmt==="state"&&l.type==="divider"&&!l.doc?(i.push({...l,doc:n}),n=[]):n.push(l);i.length>0&&(n.length>0&&i.push({stmt:"state",id:this.getDividerId(),type:"divider",doc:n}),r.doc=i);for(let l=r.doc.length-1;l>=0;l--)e.push([r.id,r.doc[l],!0])}}addState(e,t="default",r,a,i,n){let l=e.trim(),s=this.states.get(l);if(s?(s.doc||(s.doc=r),s.type||(s.type=t)):(s={stmt:"state",id:l,descriptions:[],type:t,doc:r,note:i,classes:[],styles:[],textStyles:[]},this.states.set(l,s)),a)for(let o of Array.isArray(a)?a:[a])this.addDescription(l,o.trim());if(i&&(s.note=i),n)for(let o of n)this.setCssClass(l,o.trim())}getState(e){return this.states.get(e)}addLink(e,t,r){this.links.set(e,{url:t,tooltip:r})}addRelation(e,t,r=""){for(let a of[e,t])this.addState(a.id,a.type,a.doc,a.description,a.note,a.classes);this.relations.push({id1:e.id.trim(),id2:t.id.trim(),relationTitle:r})}addDescription(e,t){this.states.get(e)?.descriptions?.push(t.startsWith(":")?t.replace(":","").trim():t)}getDividerId(){return`divider-id-${++this.dividerCount}`}addStyleClass(e,t=""){let r=this.classes.get(e);if(r||(r={id:e,styles:[],textStyles:[]},this.classes.set(e,r)),!!t)for(let a of t.split(",")){let i=a.replace(";","").trim();a.includes("color")&&r.textStyles.push(i.replace("fill","bgFill").replace("color","fill")),r.styles.push(i)}}setCssClass(e,t){for(let r of this.named(e))r.classes?.push(t)}getDirection(){for(let e of this.rootDoc)if(typeof e!="string"&&e.stmt==="dir")return e.value;return"TB"}setDirection(e){for(let t of this.rootDoc)if(typeof t!="string"&&t.stmt==="dir"){t.value=e;return}this.rootDoc.unshift({stmt:"dir",value:e})}trimColon(e){return e.startsWith(":")?e.slice(1).trim():e.trim()}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
77
+ `)}named(e){let t=[];for(let r of e.split(",")){let a=this.states.get(r);a||(this.addState(r),a=this.states.get(r.trim())),a&&t.push(a)}return t}},gm=["$end","INVALID","NL","SD","DESCR","-->","HIDE_EMPTY","scale","WIDTH","COMPOSIT_STATE","STRUCT_START","STRUCT_STOP","STATE_DESCR","AS","ID","FORK","JOIN","CHOICE","CONCURRENT","note","NOTE_TEXT","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","CLICK","STRING","HREF","classDef","CLASSDEF_ID","DEFAULT_CLASSDEF_ID","CLASSDEF_STYLEOPTS","DEFAULT","style","STYLE_IDS","STYLEDEF_STYLEOPTS","class","CLASSENTITY_IDS","STYLECLASS","direction_tb","direction_bt","direction_rl","direction_lr","EDGE_STATE","STYLE_SEPARATOR","left_of","right_of","INVALID"],y4=/direction/gi,x4=/<<(?:fork|join|choice)>>|\[\[(?:fork|join|choice)\]\]/gi,w4=/[\n\r\u2028\u2029]/g,b4=/%%/g,$4=/\{/g;M4=["TB","BT","RL","LR"],sc="'NL', 'ID', 'HIDE_EMPTY', 'scale', 'COMPOSIT_STATE', 'STATE_DESCR', 'FORK', 'JOIN', 'CHOICE', 'CONCURRENT', 'note', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'CLICK', 'classDef', 'style', 'class', 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'EDGE_STATE'";v4=40,E4=16,S4=44,ts=16,Af=10,T4=16,mm=10,vf=26,ym=8,C4=320,Ef=10,xm=8,wm=' fill="var(--_s)" stroke="var(--_b)"',lc=' fill="none" stroke="var(--_b)"',_4=/(?:^| )statediagram-(?:state|cluster-alt|cluster|note)(?= |$)/g,I4=new Map([["rectWithTitle",1],["stateStart",2],["stateEnd",3],["choice",4],["fork",5],["join",6],["note",7],["divider",10]]),N4=["pele-node pele-state","pele-node pele-state","pele-node pele-state-start","pele-node pele-state-end","pele-node pele-state-choice","pele-node pele-state-fork","pele-node pele-state-join","pele-note","pele-cluster pele-state-composite"];Am={type:"state",math:!0,parse(e,t,r){let a=new m4;return r&&(a.title=r),A4(e,a),a},render:R4}});var Em={};_t(Em,{state:()=>Am});var Sm=Xe(()=>{vm()});function bl(e){return!Number.isNaN(e.getTime())}function sa(e,t){let r=String(e);return r.length>=t?r:"0".repeat(t-r.length)+r}function Bm(e){let t=["th","st","nd","rd"],r=e%100;return e+(t[(r-20)%10]||t[r]||t[0])}function Nf(e){let t=-Math.round(e.getTimezoneOffset()/15)*15;return t===0?0:t}function Tm(e){let t=Nf(e),r=Math.abs(t);return(t>=0?"+":"-")+sa(Math.floor(r/60),2)+":"+sa(r%60,2)}function Ym(e){return e.getDay()||7}function Oi(e,t){let r=new Date(e);return r.setDate(r.getDate()+t),r}function D4(e){let t=new Date(e.getFullYear(),e.getMonth()+1,0);return t.setHours(23,59,59,999),t.getDate()}function Cm(e,t){let r=new Date(e);return r.setDate(1),t(r),r.setDate(Math.min(e.getDate(),D4(r))),r}function Hm(e,t,r){switch(r){case"M":return Cm(e,a=>a.setMonth(e.getMonth()+t));case"y":return Cm(e,a=>a.setFullYear(e.getFullYear()+t));case"d":return Oi(e,Math.round(t));case"w":return Oi(e,Math.round(7*t));case"h":return new Date(e.getTime()+t*36e5);case"m":return new Date(e.getTime()+t*6e4);case"s":return new Date(e.getTime()+t*1e3);default:return new Date(e.getTime()+t)}}function Um(e){return Oi(e,4-Ym(e))}function _m(e){let t=Um(e),r=new Date(t.getFullYear(),0,1),a=Ym(r),i=Oi(r,4-a+(a>4?7:0)),n=(Nf(i)-Nf(t))*6e4,l=(t.getTime()-i.getTime()-n)/6048e5;return(l<0?Math.ceil(l)||0:Math.floor(l))+1}function qm(e,t){if(!bl(e))return"Invalid Date";let r=t||z4;if(r==="YYYY-MM-DD")return Gm(e);let a=!1,i=r.replace(O4,l=>{switch(l){case"Q":return String(Math.ceil((e.getMonth()+1)/3));case"Do":return"["+Bm(e.getDate())+"]";case"GGGG":return String(Um(e).getFullYear());case"W":return String(_m(e));case"WW":return sa(_m(e),2);case"k":return String(e.getHours()||24);case"kk":return sa(e.getHours()||24,2);case"X":return String(Math.floor(e.getTime()/1e3));case"x":return String(e.getTime());case"gggg":case"wo":case"w":case"ww":case"z":case"zzz":return a=!0,l;default:return l}});if(a)return;let n=e.getHours();return i.replace(P4,(l,s)=>{if(s)return s;switch(l){case"YY":return String(e.getFullYear()).slice(-2);case"YYYY":return sa(e.getFullYear(),4);case"M":return String(e.getMonth()+1);case"MM":return sa(e.getMonth()+1,2);case"MMM":return is[e.getMonth()].slice(0,3);case"MMMM":return is[e.getMonth()];case"D":return String(e.getDate());case"DD":return sa(e.getDate(),2);case"d":return String(e.getDay());case"dd":return hn[e.getDay()].slice(0,2);case"ddd":return hn[e.getDay()].slice(0,3);case"dddd":return hn[e.getDay()];case"H":return String(n);case"HH":return sa(n,2);case"h":return String(n%12||12);case"hh":return sa(n%12||12,2);case"a":return n<12?"am":"pm";case"A":return n<12?"AM":"PM";case"m":return String(e.getMinutes());case"mm":return sa(e.getMinutes(),2);case"s":return String(e.getSeconds());case"ss":return sa(e.getSeconds(),2);case"SSS":return sa(e.getMilliseconds(),3);case"Z":return Tm(e);default:return Tm(e).replace(":","")}})}function Gm(e){let t=e.getFullYear(),r=e.getMonth()+1,a=e.getDate();return(t>=1e3&&t<=9999?t:sa(t,4))+(r<10?"-0":"-")+r+(a<10?"-0":"-")+a}function Dr(e){return(t,r)=>(t[e]=+r,!0)}function Lm(e){return(t,r)=>{let a=e.indexOf(r)+1;return a<1?!1:(t.month=a%12||a,!0)}}function q4(e){if(e===Dm)return hc;if(Dm=e,hc=null,/[Ll]/.test(e.replace(W4,"")))return null;let t=e.match(F4);return t?(hc=t.map(r=>U4.get(r)??r.replace(/^\[|\]$/g,"")),hc):null}function G4(e,t,r){if(t==="x"||t==="X")return new Date((t==="X"?1e3:1)*Number(e));let a=q4(t);if(!a)return;let i={},n=e,l=0;for(let u of a){if(typeof u=="string"){l+=u.length;continue}let m=u.re.exec(n.slice(l));if(!m||!u.read(i,m[0]))return;n=n.replace(m[0],"")}i.afternoon!==void 0&&i.hours!==void 0&&(i.afternoon?i.hours<12&&(i.hours+=12):i.hours===12&&(i.hours=0));let s=i.dayGiven||i.day?i.day:!i.year&&!i.month?r.getDate():1,o=i.year||r.getFullYear(),c=0;i.year&&!i.month||(c=i.month>0?i.month-1:r.getMonth());let f=i.hours||0,p=i.minutes||0,h=i.seconds||0,g=i.milliseconds||0;if(i.offset!==void 0)return new Date(Date.UTC(o,c,s,f,p,h,g+i.offset*6e4));if(!i.week)return new Date(o,c,s,f,p,h,g)}function j4(e,t,r){let a=G4(e,t,r);return a&&bl(a)&&qm(a,t)===e?a:void 0}function jm(e){let t=e===void 0?NaN:+e;return Number.isFinite(t)?t:Date.now()}function sS(e){let t=Q4.exec(e.trim());return t?[Number.parseFloat(t[1]),t[2]]:[NaN,"ms"]}function Om(e,t){let r=new Set(e);for(let a of t.toLowerCase().split(J4))a!==""&&r.add(a);return[...r]}function wS(e){let t=e.length,r=[],a=[],i=[],n=0,l=0,s=(p,h,g)=>{r.push(p),a.push(e.slice(h,g)),i.push(h),l=g},o=p=>(p.lastIndex=l,p.test(e)?p.lastIndex:-1),c=(p,h)=>{let g=e.indexOf(p,h);return g===-1?t:g},f=p=>{let h;switch(p|32){case 97:if((h=o(cS))>=0)return n=1,s(3,l,h),!0;if((h=o(hS))>=0)return n=2,s(5,l,h),!0;if((h=o(dS))>=0)return n=3,l=h,!0;break;case 104:if((h=o(fS))>=0)return n=4,l=h,!0;break;case 99:if((h=o(pS))>=0)return n=5,l=h,!0;if((h=o(uS))>=0)return n=7,l=h,!0;break;case 119:{Tf.lastIndex=l;let u=Tf.exec(e);if(u)return s(22+mS.indexOf(u[1].toLowerCase()),l,Tf.lastIndex),!0;if(Cf.lastIndex=l,u=Cf.exec(e),u)return s(u[1]!==void 0?29:30,l,Cf.lastIndex),!0;break}}let g=xS.get(p|32);if(g){for(let[u,m]of g)if((h=o(u))>=0)return s(m,l,h),!0}return!1};for(;;){if(l>=t){let h=38;switch(n){case 1:h=4;break;case 2:h=6;break;case 3:h=7;break;case 4:h=9;break;case 5:h=10;break;case 6:h=11;break;case 7:h=12;break}s(h,t,t);break}let p=e.charCodeAt(l);switch(n){case 0:{let h=e.charCodeAt(l+1);if(p===37)if(h!==37){let g=c(`
78
+ `,l+1);for(;e.charCodeAt(g)===10;)g++;l=g}else{if(e.charCodeAt(l+2)===123)return s(2,l,l+3),s(1,l,l),{types:r,texts:a,starts:i};l=c(`
79
+ `,l+2)}else if(p!==125&&h===37)l=c(`
80
+ `,l+2);else if(p===10){let g=l+1;for(;e.charCodeAt(g)===10;)g++;s(8,l,g)}else if(Ue(p))for(l++;l<t&&Ue(e.charCodeAt(l));)l++;else{if(f(p))break;if(p>=48&&p<=57&&o(yS)>=0)s(31,l,l+10);else if(p!==58){let g=l+1;for(;g<t;){let u=e.charCodeAt(g);if(u===58||u===10)break;g++}s(35,l,g)}else{let g=l+1;for(;g<t;){let u=e.charCodeAt(g);if(u===35||u===10||u===59)break;g++}s(g>l+1?36:37,l,g)}}break}case 1:case 2:{let h=n===1?4:6;n=0,s(h,l,c(`
81
+ `,l));break}case 3:p===125?(n=0,l++):s(7,l,c("}",l));break;case 4:p===34?(n=0,l++):s(9,l,c('"',l));break;case 5:if(p===40){let h=o(gS);h>=0?(n=0,l=h):(n=6,l++)}else s(10,l,c("(",l));break;case 6:p===41?(n=0,l++):s(11,l,c(")",l));break;case 7:if(Ue(p))n=0,l++;else{let h=l+1;for(;h<t&&!Ue(e.charCodeAt(h));)h++;s(12,l,h)}break}}return r.push(0),a.push(""),i.push(t),{types:r,texts:a,starts:i}}function $S(e,t){let{types:r,texts:a,starts:i}=wS(e),n=0,l=o=>{let c=r[n];throw it("gantt",e,i[n],`Expecting ${o}, got '${c===0?"1":oS[c]}'`)},s=(o="")=>{gc[r[n]]!==1&&l(Pm+o)};for(r[n]!==13&&l("'gantt'"),n++;;){let o=r[n],c=a[n];switch(gc[o]!==1&&l(Pm),n++,o){case 38:if(r[n]===0)return;s();break;case 8:break;case 14:s(),t.setDateFormat(c.slice(11));break;case 15:s(),t.enableInclusiveEndDates();break;case 16:s(),t.TopAxis();break;case 17:s(),t.setAxisFormat(c.slice(11));break;case 18:s(),t.setTickInterval(c.slice(13));break;case 20:s(),t.setExcludes(c.slice(9));break;case 19:s(),t.setIncludes(c.slice(9));break;case 21:s(),t.setTodayMarker(c.slice(12));break;case 29:s(),t.setWeekend("friday");break;case 30:s(),t.setWeekend("saturday");break;case 32:s(),t.setDiagramTitle(c.slice(6));break;case 3:{r[n]!==4&&l("'acc_title_value'");let f=a[n++];s(),t.setAccTitle(f.trim());break}case 5:{r[n]!==6&&l("'acc_descr_value'");let f=a[n++];s(),t.setAccDescription(f.trim());break}case 7:s(),t.setAccDescription(c.trim());break;case 34:s(),t.addSection(c.slice(8));break;case 35:{r[n]!==36&&l("'taskData'");let f=a[n++];s(),t.addTask(c,f);break}case 12:{let f,p=null,h;r[n]===10?(f=a[n++],r[n]===11&&(p=a[n++]),r[n]===9?(h=a[n++],s()):s(p===null?", 'callbackargs', 'href'":", 'href'")):r[n]===9?(h=a[n++],r[n]===10?(f=a[n++],r[n]===11?(p=a[n++],s()):s(", 'callbackargs'")):s(", 'callbackname'")):l("'callbackname', 'href'"),f!==void 0&&t.setClickEvent(c,f,p),h!==void 0&&t.setLink(c,h);break}default:s(),t.setWeekday(bS[o-22])}}}function dc(e){e.setHours(0,0,0,0)}function xc(e){return{floor(t){t.setDate(t.getDate()-(t.getDay()+7-e)%7),dc(t)},offset:(t,r)=>t.setDate(t.getDate()+r*7),cycle:1/0,ms:kl}}function yc(e,t,r){return Math.floor((+t-+e-(t.getTimezoneOffset()-e.getTimezoneOffset())*mi)/r)}function kS(e,t){return(e%t+t)%t}function fc(e,t,r){let a=e==="week"?xc(r):$l[e];if(t<=1)return a;if(e==="millisecond")return{...a,floor:l=>l.setTime(Math.floor(+l/t)*t),offset:(l,s)=>l.setTime(+l+s*t)};if(e==="year")return{...a,floor(l){l.setFullYear(Math.floor(l.getFullYear()/t)*t),a.floor(l)},offset:(l,s)=>l.setFullYear(l.getFullYear()+s*t)};if(e==="week"){let l=new Date(0);return a.floor(l),{...a,floor(s){a.floor(s),a.offset(s,-kS(yc(l,s,kl),t))},offset:(s,o)=>a.offset(s,o*t)}}let i=a.field,n=l=>i(l)%t===0;return{...a,floor(l){for(a.floor(l);Number.isFinite(+l)&&!n(l);a.floor(l))l.setTime(+l-1)},offset(l,s){for(let o=0;o<s&&Number.isFinite(+l);o++)do a.offset(l,1);while(Number.isFinite(+l)&&!n(l))}}}function Xm(e,t,r,a){let i=new Date(t-1);e.floor(i),e.offset(i,1),e.floor(i);let n=[],l=-1/0;for(;+i<=r&&+i>l;){if(n.length>=a)return;l=+i,n.push(l),e.offset(i,1),e.floor(i)}return n}function zm(e,t,r){let a=(t-e)/Math.max(0,r),i=Math.floor(Math.log10(a)),n=a/Math.pow(10,i),l=n>=Math.sqrt(50)?10:n>=Math.sqrt(10)?5:n>=Math.SQRT2?2:1;return Math.pow(10,i)*l}function MS(e,t,r){let a=(t-e)/r,i=0;for(;i<rs.length&&rs[i][2]<=a;)i++;let n;if(i===rs.length)n=fc("year",Math.max(1,zm(e/mc,t/mc,r)),0);else if(i===0)n=fc("millisecond",Math.max(zm(e,t,r),1),0);else{let[l,s]=rs[a/rs[i-1][2]<rs[i][2]/a?i-1:i];n=fc(l,s,0)}return Xm(n,e,t,4*r+8)??[]}function ES(e,t,r,a,i){let n=AS.exec(e);if(!n)return;let l=parseInt(n[1],10),s=n[2],o=fc(s,l,Math.max(0,vS.indexOf(t)));if(!((a-r)/(Math.min(l,o.cycle)*o.ms)>i))return Xm(o,r,a,i)}function Mr(e,t,r){let a=e<0?"-":"",i=String(a?-e:e);return a+(i.length<r?t.repeat(r-i.length)+i:i)}function Di(e,t){let r=new Date(+e);return t.floor(r),r}function Fm(e,t){let r=xc(t),a=Di(e,$l.year);return yc(Di(new Date(+a-1),r),Di(e,r),kl)}function _f(e){let t=xc(4),r=e.getDay(),a=Di(r>=4||r===0?e:new Date(+e-1),t);return r>=4||r===0||(t.offset(a,1),t.floor(a)),a}function pc(e,t){let r="",a=0,i=e.length;for(let n=0;n<i;n++){if(e.charCodeAt(n)!==37)continue;r+=e.slice(a,n);let l=e.charAt(++n),s=SS.get(l);s!==void 0?l=e.charAt(++n):s=l==="e"?" ":"0",r+=TS(l,t,s),a=n+1}return r+e.slice(a)}function TS(e,t,r){switch(e){case"a":return hn[t.getDay()].slice(0,3);case"A":return hn[t.getDay()];case"b":return is[t.getMonth()].slice(0,3);case"B":return is[t.getMonth()];case"c":return pc("%x, %X",t);case"d":case"e":return Mr(t.getDate(),r,2);case"f":return Mr(t.getMilliseconds(),r,3)+"000";case"g":return Mr(_f(t).getFullYear()%100,r,2);case"G":return Mr(_f(t).getFullYear()%1e4,r,4);case"H":return Mr(t.getHours(),r,2);case"I":return Mr(t.getHours()%12||12,r,2);case"j":return Mr(1+yc(Di(t,$l.year),Di(t,$l.day),dn),r,3);case"L":return Mr(t.getMilliseconds(),r,3);case"m":return Mr(t.getMonth()+1,r,2);case"M":return Mr(t.getMinutes(),r,2);case"p":return t.getHours()>=12?"PM":"AM";case"q":return String(1+Math.floor(t.getMonth()/3));case"Q":return String(+t);case"s":return String(Math.floor(+t/1e3));case"S":return Mr(t.getSeconds(),r,2);case"u":return String(t.getDay()||7);case"U":return Mr(Fm(t,0),r,2);case"V":{let a=_f(t),i=Di(a,$l.year),n=Di(i,xc(4));return Mr(yc(n,a,kl)+(i.getDay()===4?1:0),r,2)}case"w":return String(t.getDay());case"W":return Mr(Fm(t,1),r,2);case"x":return pc("%-m/%-d/%Y",t);case"X":return pc("%-I:%M:%S %p",t);case"y":return Mr(t.getFullYear()%100,r,2);case"Y":return Mr(t.getFullYear()%1e4,r,4);case"Z":{let a=t.getTimezoneOffset(),i=Math.abs(a);return(a>0?"-":"+")+Mr(Math.floor(i/60),"0",2)+Mr(i%60,"0",2)}case"%":return"%";default:return e}}function Va(e,t,r,a){let i=e.gantt?.[t];return typeof i=="number"&&Number.isFinite(i)?Math.min(a,Math.max(r,i)):void 0}function If(e,t){let r=e.gantt?.[t];return typeof r=="string"?r:void 0}function NS(e,t){return e.gantt?.[t]===!0}function Wm(e,t,r){let a=ze(e.replace(IS," "),!1,t,r,4e3);return a.lines.length<=1?a:{...a,lines:[a.lines[0]],widths:[a.widths[0]],width:a.widths[0],height:a.lineHeight}}function uc(e){return Number.isFinite(+e.startTime)&&Number.isFinite(+e.endTime)}function RS(e,t,r){let a=e.filter(uc).sort((l,s)=>+l.startTime-+s.startTime||l.order-s.order),i=[];for(let l of a){let s=+l.startTime,o=0;for(;o<i.length&&s<i[o];)o++;i[o]=+l.endTime,r.set(l,t+o)}let n=i.length;for(let l of e)r.has(l)||r.set(l,t+n++);return Math.max(n,1)}function LS(e,t,r){let a=r.fontSize??16,i=r.measurer??et(r.fontFamily),n=r.padding??8,l=jm(r.now),s=Va(t,"fontSize",4,72)??Math.round(a*.8125),o=Va(t,"sectionFontSize",4,72)??s,c=Math.round(a*.75),f=Va(t,"barHeight",4,400)??Math.round(s*1.85),p=Va(t,"barGap",0,400)??Math.round(f/4),h=f+p,g=Math.round(Va(t,"numberSectionStyles",1,1e3)??4),u=e.displayMode==="compact",m=e.topAxis||NS(t,"topAxis"),b=e.getTasks(l),w=b.filter(be=>!be.vert),v=b.filter(be=>be.vert&&uc(be)),k=new Map;for(let be of w)k.has(be.section)||k.set(be.section,k.size);let O=new Map,R=[];if(u){let be=new Map;for(let Me of w){let Ne=be.get(Me.section);Ne?Ne.push(Me):be.set(Me.section,[Me])}for(let[Me,Ne]of be){let Be=RS(Ne,R.length,O);for(let Pe=0;Pe<Be;Pe++)R.push(Me)}}else for(let be of w)O.set(be,R.length),R.push(be.section);let L=R.length,P=1/0,B=-1/0;for(let be of b)uc(be)&&(P=Math.min(P,+be.startTime),B=Math.max(B,+be.endTime));let G=P<=B,C=ze(e.title,!1,i,a,4e3,1),Z=C.height>0?C.height+16:0;if(!G){let be=Math.ceil(Math.max(C.width,1)+2*n),Me=Math.ceil(Math.max(C.height,1)+2*n),Ne=Re(C,be/2,n+C.height/2,' class="pele-title" font-weight="var(--_tw)"');return{svg:Je("gantt",be,Me,a,r,e,Ne),width:be,height:Me,links:[]}}let ee=new Map,H=0;for(let be of k.keys()){let Me=ze(be,!1,i,o,180);ee.set(be,Me),H=Math.max(H,Me.width)}let Y=e.axisFormat||(e.dateFormat==="D"?"%d":If(t,"axisFormat")??"%Y-%m-%d"),_=be=>pc(Y,new Date(be)),S=Math.max(i.width(_(P),c,0),i.width(_(B),c,0)),$=n+(Va(t,"leftPadding",0,2e3)??Math.max(H>0?H+24:0,S/2)),y=Va(t,"rightPadding",0,2e3)??Math.max(16,S/2),E=_i(r,Va(t,"useWidth",100,2e4)??CS,280),x=Math.max(_S,E-$-y-n),T=$+x,A=B>P?x/(B-P):0,M=be=>A===0?$+x/2:$+(be-P)*A,N=Math.round(c*1.75),F=Va(t,"topPadding",0,2e3),U=Va(t,"gridLineStartPadding",0,2e3),D=n+Z+(m?N:0),I=Math.max(D,F??0),z=F!==void 0&&U!==void 0?Math.max(0,Math.min(F-U,I-D)):0,q=Math.max(L,1)*h,j=I+q,Q=[],K=T+y;for(let be of w){let Me=Wm(be.task,i,s),Ne=O.get(be);if(!uc(be)){let ie=$+as+Me.width/2;K=Math.max(K,ie+Me.width/2),Q.push({task:be,label:Me,row:Ne,x0:NaN,x1:NaN,labelX:ie,inside:!1});continue}let Be=M(+be.startTime),Pe=Math.max(M(+(be.renderEndTime??be.endTime)),Be+(be.milestone?0:2));if(be.milestone){let ie=Be+(M(+be.endTime)-Be)/2;Be=ie-f/2,Pe=ie+f/2}let V=!be.milestone&&Me.width+2*as<=Pe-Be,me=(Be+Pe)/2;if(!V){let ie=Pe+as+Me.width<=T+y,$e=Be-as-Me.width>=$;me=ie||!$e?Pe+as+Me.width/2:Be-as-Me.width/2,K=Math.max(K,me+Me.width/2)}Q.push({task:be,label:Me,row:Ne,x0:Be,x1:Pe,labelX:me,inside:V})}let W=e.tickInterval||If(t,"tickInterval")||"",X=e.weekday??If(t,"weekday")??"sunday",te=Math.max(2,Math.min(10,Math.floor(x/(S+24)))),se=ES(W,X,P,B,Math.ceil(x/3))??MS(P,B,te),oe="",ae="",ne="",J=-1/0,re="",fe=j+N/2+2,ye=I-z-N/2-2;for(let be of se){let Me=M(be);oe+=`M${d(Me)},${d(I-z)}V${d(j)}`;let Ne=_(be),Be=i.width(Ne,c,0);if(Me-Be/2<J+8||Ne===re)continue;J=Me+Be/2,re=Ne,K=Math.max(K,J);let Pe=`text-anchor="middle">${Ve(Ne)}</text>`;ae+=`<text x="${d(Me)}" y="${d(fe+c*.35)}" ${Pe}`,m&&(ne+=`<text x="${d(Me)}" y="${d(ye+c*.35)}" ${Pe}`)}let le="",we="",pe=[],ge=j+N+4,Ae=Math.round(s*1.5);for(let be of[...v].sort((Me,Ne)=>+Me.startTime-+Ne.startTime)){let Me=M(+be.startTime),Ne=Wm(be.task,i,s),Be=Math.max(n+Ne.width/2,Me),Pe=0;for(;Pe<pe.length&&Be-Ne.width/2<pe[Pe]+8;)Pe++;pe[Pe]=Be+Ne.width/2,K=Math.max(K,pe[Pe]),le+=`<path class="pele-vert" data-id="${Oe(be.id)}" d="M${d(Me)},${d(I-z)}V${d(j)}"/>`,we+=Re(Ne,Be,ge+Pe*Ae+Ae/2,` class="pele-vert-label" data-id="${Oe(be.id)}"`)}let Se=Math.ceil(Math.max(K,n+C.width)+n),ce=Math.ceil(j+N+(pe.length>0?4+pe.length*Ae:0)+n),ue="",xe="";for(let be=0;be<L;){let Me=R[be],Ne=be+1;for(;Ne<L&&R[Ne]===Me;)Ne++;let Be=k.get(Me)%g,Pe=I+be*h,V=(Ne-be)*h;(k.size>1||Me!=="")&&(ue+=`<rect class="pele-section pele-section-${Be}" x="0" y="${d(Pe)}" width="${Se}" height="${d(V)}" fill="${Be%2===0?"var(--_s)":"none"}"/>`);let me=ee.get(Me);xe+=Re(me,n+8+me.width/2,Pe+V/2,` class="pele-section-label" data-id="${Oe(Me)}"`,r.icons),be=Ne}let Ie="";if((e.excludes.length>0||e.includes.length>0)&&+Hm(new Date(P),6,"y")>B){let be,Me,Ne=()=>{if(!be||!Me)return;let Be=new Date(be);Be.setHours(0,0,0,0);let Pe=new Date(Me);Pe.setHours(23,59,59,999);let V=Math.max($,M(+Be)),me=Math.min(T,M(+Pe));me>V&&(Ie+=`<rect x="${d(V)}" y="${d(I)}" width="${d(me-V)}" height="${d(q)}"/>`),be=Me=void 0};for(let Be=new Date(P);+Be<=B;Be=Oi(Be,1))e.isInvalidDate(Be)?(be??(be=Be),Me=Be):Ne();Ne()}let Le=[],We="";for(let be of Q){let Me=be.task,Ne=I+be.row*h+h/2,Be=Me.active?"active":Me.done?"done":"",Pe="pele-task";Be&&(Pe+=" pele-"+Be),Me.crit&&(Pe+=" pele-crit"),Me.milestone&&(Pe+=" pele-milestone"),Me.classes.includes("clickable")&&(Pe+=" pele-clickable");let V="",me="";if(Number.isNaN(be.x0))Pe+=" pele-unscheduled",me=' fill="var(--_m)"';else{let ve=Me.crit?Gs:"var(--_c)",Te=Be==="done"?'fill="var(--_a)"':Be==="active"?`fill="${ve}" fill-opacity="0.25"`:`fill="${ve}"`,De=`stroke="${Be==="done"&&!Me.crit?"var(--_b)":ve}"`;if(Me.milestone){let _e=(be.x0+be.x1)/2,Ye=f/2;V=`<path d="M${d(_e)},${d(Ne-Ye)}L${d(_e+Ye)},${d(Ne)}L${d(_e)},${d(Ne+Ye)}L${d(_e-Ye)},${d(Ne)}Z" ${Te} ${De} stroke-linejoin="round"/>`}else V=`<rect x="${d(be.x0)}" y="${d(Ne-f/2)}" width="${d(be.x1-be.x0)}" height="${d(f)}" ${Te} ${De}${nt}/>`;be.inside?me=Be===""?' fill="var(--_bg)"':"":Be==="done"&&(me=' fill="var(--_m)"')}let ie=V+Re(be.label,be.labelX,Ne,` class="pele-label"${me}`),$e=e.links.get(Me.id);$e!==void 0&&(ie=ua(ie,$e,Me.id,Le,r)),We+=`<g class="${Pe}" data-id="${Oe(Me.id)}">${ie}</g>`}let de="";if(e.todayMarker!=="off"&&l>=P&&l<=B&&B>P){let be=M(l),Me=I-z,Ne=e.todayMarker?vt(e.todayMarker.split(",")).line:"";de=`<g class="pele-today"><path d="M${d(be)},${d(Me)}V${d(j)}" fill="none" stroke="var(--_c)" stroke-width="2"${Ne}/>`+(Ne?"":`<path d="M${d(be-4)},${d(Me-5)}H${d(be+4)}L${d(be)},${d(Me+1)}Z" fill="var(--_c)"/>`)+"</g>"}let ke=`M${d($)},${d(j)}H${d(T)}`+(m?`M${d($)},${d(I-z)}H${d(T)}`:""),Ce=Re(C,Se/2,n+C.height/2,' class="pele-title" font-weight="var(--_tw)"')+(ue?`<g class="pele-sections">${ue}</g>`:"")+(Ie?`<g class="pele-excluded" fill="var(--_a)">${Ie}</g>`:"")+`<g class="pele-grid" fill="none"><path d="${oe}" stroke="var(--_b)" stroke-dasharray="1 3"/><path d="${ke}" stroke="var(--_b)"/></g>`+(le?`<g class="pele-verts" fill="none" stroke="var(--_l)" stroke-width="1.5" stroke-dasharray="4 3">${le}</g>`:"")+de+`<g class="pele-tasks" font-size="${d(s)}">${We}</g><g class="pele-section-labels" font-size="${d(o)}">${xe}</g><g class="pele-axis" font-size="${c}" fill="var(--_m)">${ae}${ne}</g>`+(we?`<g class="pele-vert-labels" font-size="${d(s)}">${we}</g>`:"");return{svg:Je("gantt",Se,ce,a,r,e,Ce),width:Se,height:ce,links:Le}}var is,hn,O4,P4,z4,F4,W4,Im,xl,B4,Y4,Ra,H4,Nm,wl,Rm,U4,Dm,hc,X4,V4,K4,Z4,Q4,J4,eS,tS,rS,aS,iS,nS,lS,oS,cS,hS,dS,fS,pS,uS,gS,Tf,mS,Cf,yS,xS,bS,Pm,gc,gi,mi,cn,dn,kl,Rf,mc,$l,rs,AS,vS,SS,CS,_S,as,IS,Vm,Km=Xe(()=>{hi();tr();zt();ut();wt();is=["January","February","March","April","May","June","July","August","September","October","November","December"],hn=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];O4=/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,P4=/\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,z4="YYYY-MM-DDTHH:mm:ssZ";F4=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,W4=/\[[^\]]+]/g,Im=/\d/,xl=/\d\d/,B4=/\d{3}/,Y4=/\d{4}/,Ra=/\d\d?/,H4=/[+-]?\d+/,Nm=/[+-]\d\d:?(\d\d)?|Z/,wl=/\d*[^-_:/,()\s\d]+/;Rm=(e,t)=>{if(t==="Z")return e.offset=0,!0;let r=t.match(/([+-]|\d\d)/g),a=+r[1]*60+(+r[2]||0);return e.offset=a===0?0:r[0]==="+"?-a:a,!0};U4=new Map([["A",{re:wl,read:(e,t)=>(e.afternoon=t==="PM",!0)}],["a",{re:wl,read:(e,t)=>(e.afternoon=t==="pm",!0)}],["Q",{re:Im,read:(e,t)=>(e.month=(+t-1)*3+1,!0)}],["S",{re:Im,read:(e,t)=>(e.milliseconds=+t*100,!0)}],["SS",{re:xl,read:(e,t)=>(e.milliseconds=+t*10,!0)}],["SSS",{re:B4,read:(e,t)=>(e.milliseconds=+t,!0)}],["s",{re:Ra,read:Dr("seconds")}],["ss",{re:Ra,read:Dr("seconds")}],["m",{re:Ra,read:Dr("minutes")}],["mm",{re:Ra,read:Dr("minutes")}],["H",{re:Ra,read:Dr("hours")}],["h",{re:Ra,read:Dr("hours")}],["HH",{re:Ra,read:Dr("hours")}],["hh",{re:Ra,read:Dr("hours")}],["D",{re:Ra,read:Dr("day")}],["DD",{re:xl,read:Dr("day")}],["Do",{re:wl,read:(e,t)=>{let r=t.match(/\d+/);if(!r)return!1;e.day=+r[0],e.dayGiven=!0;for(let a=1;a<=31;a++)Bm(a)===t&&(e.day=a);return!0}}],["w",{re:Ra,read:Dr("week")}],["ww",{re:xl,read:Dr("week")}],["M",{re:Ra,read:Dr("month")}],["MM",{re:xl,read:Dr("month")}],["MMM",{re:wl,read:Lm(is.map(e=>e.slice(0,3)))}],["MMMM",{re:wl,read:Lm(is)}],["Y",{re:H4,read:Dr("year")}],["YY",{re:xl,read:(e,t)=>(e.year=+t+(+t>68?1900:2e3),!0)}],["YYYY",{re:Y4,read:Dr("year")}],["Z",{re:Nm,read:Rm}],["ZZ",{re:Nm,read:Rm}]]),hc=null;X4=/^[YMDHhmsSZXx\-/.:, T]*$/,V4=/^\s*(active|done|crit|milestone|vert)\s*$/,K4=/^after\s+([\d\w- ]+)/,Z4=/^until\s+([\d\w- ]+)/,Q4=/^(\d+(?:\.\d+)?)([Mdhmswy]|ms)$/,J4=/[\s,]+/,eS=/^\d+$/,tS=new Set(hn.map(e=>e.toLowerCase())),rS=4e8,aS=400,iS=200,nS=400;lS=class{constructor(e={}){he(this,"type","gantt");he(this,"title");he(this,"accTitle");he(this,"accDescr");he(this,"dateFormat","");he(this,"axisFormat","");he(this,"tickInterval");he(this,"todayMarker","");he(this,"includes",[]);he(this,"excludes",[]);he(this,"inclusiveEndDates",!1);he(this,"topAxis",!1);he(this,"displayMode","");he(this,"weekday");he(this,"weekend","saturday");he(this,"sections",[]);he(this,"links",new Map);he(this,"tasks",[]);he(this,"byId",new Map);he(this,"currentSection","");he(this,"taskCount",0);he(this,"lastOrder",0);he(this,"lastTaskId");he(this,"options");he(this,"now",0);he(this,"work",0);he(this,"includeSet",new Set);he(this,"excludeSet",new Set);he(this,"excludedDays",[]);he(this,"datedTokens",!1);this.options=e}setDateFormat(e){this.dateFormat=e}enableInclusiveEndDates(){this.inclusiveEndDates=!0}TopAxis(){this.topAxis=!0}setAxisFormat(e){this.axisFormat=e}setTickInterval(e){this.tickInterval=e}setTodayMarker(e){this.todayMarker=e}setIncludes(e){this.includes=Om(this.includes,e)}setExcludes(e){this.excludes=Om(this.excludes,e)}setWeekday(e){this.weekday=e}setWeekend(e){this.weekend=e}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
82
+ `)}addSection(e){this.currentSection=e,this.sections.push(e)}addTask(e,t){let r=(t.startsWith(":")?t.slice(1):t).split(","),a={id:"",task:e,section:this.currentSection,startTime:void 0,endTime:void 0,renderEndTime:null,manualEndTime:!1,processed:!1,active:!1,done:!1,crit:!1,milestone:!1,vert:!1,order:-1,classes:[],prevTaskId:this.lastTaskId,raw:{data:t,start:void 0,end:""}},i;for(;r.length>0&&(i=V4.exec(r[0]))!==null;)a[i[1]]=!0,r.shift();if(r.length===0)throw new je(`Task "${e.trim()}" needs a duration or an end date.`,"semantic",{type:"gantt"});if(r.length>3)throw new je(`Task "${e.trim()}" has too many fields. A task takes an id, a start, and an end or duration.`,"semantic",{type:"gantt"});for(let n=0;n<r.length;n++)r[n]=r[n].trim();r.length===3?a.id=r[0]:(this.taskCount++,a.id="task"+this.taskCount),r.length>1&&(a.raw.start=r[r.length-2]),a.raw.end=r[r.length-1],a.vert||(a.order=this.lastOrder++),this.tasks.push(a),this.lastTaskId=a.id,this.byId.set(a.id,a)}setLink(e,t){let r=Ta(t);for(let a of e.split(","))this.byId.has(a)&&this.links.set(a,r);this.setClass(e,"clickable")}setClickEvent(e,t,r){this.setClass(e,"clickable")}setClass(e,t){for(let r of e.split(","))this.byId.get(r)?.classes.push(t)}getTasks(e){this.now=jm(e),this.work=0,this.includeSet=new Set(this.includes),this.excludeSet=new Set(this.excludes);let t=this.weekend==="friday"?5:this.weekend==="saturday"?6:NaN,r=this.excludeSet.has("weekends");this.excludedDays=hn.map((i,n)=>{let l=n||7;return r&&(l===t||l===t+1)||this.excludeSet.has(i.toLowerCase())}),this.datedTokens=this.includes.length>0||!X4.test(this.dateFormat.trim());for(let i of this.excludes)i!=="weekends"&&!tS.has(i)&&(this.datedTokens=!0);for(let i of this.tasks)i.startTime=i.endTime=void 0,i.renderEndTime=null,i.processed=i.manualEndTime=!1;let a=this.compileTasks();for(let i=0;!a&&i<10;i++)a=this.compileTasks();return this.tasks}isInvalidDate(e){let t=this.excludedDays[e.getDay()];if(!this.datedTokens)return t;let r=this.dateFormat.trim(),a=Gm(e),i=a;this.spend(iS),r!=="YYYY-MM-DD"&&(this.spend(nS+r.length*8),i=qm(e,r));let n=l=>l.has(a)||i!==void 0&&l.has(i);return n(this.includeSet)?!1:t||n(this.excludeSet)}spend(e){if(this.work+=e,this.work>rS)throw new je("The gantt chart takes too much work to schedule.","limit",{type:"gantt"})}parse(e,t){return this.spend((t.length+1)*(e.length+1)),j4(e,t,new Date(this.now))}today(){let e=new Date(this.now);return e.setHours(0,0,0,0),e}warn(e){this.options.warn&&this.options.warn(e())}compileTasks(){let e=!0;for(let t of this.tasks)this.compileTask(t),e=e&&t.processed;return e}compileTask(e){let t=e.raw.start;if(t===void 0){let r=e.prevTaskId===void 0?void 0:this.byId.get(e.prevTaskId);e.startTime=r?r.endTime:this.today()}else{let r=this.getStartDate(t);r&&(e.startTime=r)}e.startTime&&(e.endTime=this.getEndDate(e.startTime,e.raw.end),e.endTime&&(e.processed=!0,e.manualEndTime=this.parse(e.raw.end,"YYYY-MM-DD")!==void 0,this.checkTaskDates(e)))}references(e,t){let r=[],a;for(let i of t.split(" ")){if(i==="")continue;let n=this.byId.get(i);n?r.push(n):(a??(a=[])).push(i)}if(a){let i=a;this.warn(()=>`Gantt: "${e}" refers to task ids that do not exist: ${i.join(", ")}.`)}return r}getStartDate(e){let t=e.trim(),r=this.dateFormat.trim();if((r==="x"||r==="X")&&eS.test(t))return this.checked(new Date(Number(t)),t);let a=K4.exec(t);if(a!==null){let l=this.references("after",a[1]),s;for(let o of l)(!s||o.endTime>s.endTime)&&(s=o);return s?s.endTime:this.today()}let i=this.parse(t,r);if(i)return i;let n=new Date(t);if(!bl(n)||n.getFullYear()<-1e4||n.getFullYear()>1e4)throw new je("Invalid date:"+t,"semantic",{type:"gantt"});return n}checked(e,t){if(!bl(e))throw new je("Invalid date:"+t,"semantic",{type:"gantt"});return e}getEndDate(e,t){let r=t.trim(),a=Z4.exec(r);if(a!==null){let c=this.references("until",a[1]),f;for(let p of c)(!f||p.startTime<f.startTime)&&(f=p);return f?f.startTime:this.today()}let i=this.dateFormat.trim(),n=this.parse(r,i);if(n)return this.inclusiveEndDates?Oi(n,1):n;let[l,s]=sS(r);if(Number.isNaN(l))return this.warn(()=>`Gantt: "${r}" is neither a date in the "${i}" format nor a duration such as "3d", so the task gets no duration.`),new Date(e);let o=Hm(e,l,s);return bl(o)?o:new Date(e)}checkTaskDates(e){if(this.excludes.length===0||e.manualEndTime)return;let t=Oi(e.startTime,1),r=new Date(e.endTime),a=+Oi(r,1e4),i=!1,n=null;for(;+t<=+r;){if(this.spend(aS),i||(n=+r),i=this.isInvalidDate(t),i&&(r.setDate(r.getDate()+1),+r>a))throw new je("Failed to find a valid date that was not excluded by `excludes` after 10,000 iterations.","semantic",{type:"gantt"});t.setDate(t.getDate()+1)}e.endTime=r,e.renderEndTime=n===null?null:new Date(n)}},oS=["$end","INVALID","open_directive","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","NL","href","callbackname","callbackargs","click","gantt","dateFormat","inclusiveEndDates","topAxis","axisFormat","tickInterval","includes","excludes","todayMarker","weekday_monday","weekday_tuesday","weekday_wednesday","weekday_thursday","weekday_friday","weekday_saturday","weekday_sunday","weekend_friday","weekend_saturday","date","title","accDescription","section","taskTxt","taskData",":","EOF"],cS=/accTitle\s*:\s*/iy,hS=/accDescr\s*:\s*/iy,dS=/accDescr\s*\{\s*/iy,fS=/href\s+"/iy,pS=/call\s+/iy,uS=/click\s+/iy,gS=/\(\s*\)/y,Tf=/weekday\s+(monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/iy,mS=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Cf=/weekend\s+(?:(friday)|saturday)\b/iy,yS=/\d\d\d\d-\d\d-\d\d\b/y,xS=new Map([[97,[[/axisFormat\s[^#\n;]+/iy,17],[/accDescription\s[^#\n;]+/iy,33]]],[103,[[/gantt\b/iy,13]]],[100,[[/dateFormat\s[^#\n;]+/iy,14]]],[105,[[/inclusiveEndDates\b/iy,15],[/includes\s[^#\n;]+/iy,19]]],[116,[[/topAxis\b/iy,16],[/tickInterval\s[^#\n;]+/iy,18],[/todayMarker\s[^\n;]+/iy,21],[/title\s[^\n]+/iy,32]]],[101,[[/excludes\s[^#\n;]+/iy,20]]],[115,[[/section\s[^\n]+/iy,34]]]]);bS=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],Pm="'EOF', 'SPACE', 'NL', 'weekday_monday', 'weekday_tuesday', 'weekday_wednesday', 'weekday_thursday', 'weekday_friday', 'weekday_saturday', 'weekday_sunday', 'weekend_friday', 'weekend_saturday', 'dateFormat', 'inclusiveEndDates', 'topAxis', 'axisFormat', 'tickInterval', 'excludes', 'includes', 'todayMarker', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'taskTxt', 'click'",gc=new Uint8Array(39);for(let e=22;e<=30;e++)gc[e]=1;for(let e of[38,8,14,15,16,17,18,20,19,21,32,3,5,7,34,35,12])gc[e]=1;gi=1e3,mi=60*gi,cn=60*mi,dn=24*cn,kl=7*dn,Rf=30*dn,mc=365*dn;$l={millisecond:{floor:()=>{},offset:(e,t)=>e.setTime(+e+t),cycle:1/0,ms:1},second:{floor:e=>e.setTime(+e-e.getMilliseconds()),offset:(e,t)=>e.setTime(+e+t*gi),field:e=>e.getUTCSeconds(),cycle:60,ms:gi},minute:{floor:e=>e.setTime(+e-e.getMilliseconds()-e.getSeconds()*gi),offset:(e,t)=>e.setTime(+e+t*mi),field:e=>e.getMinutes(),cycle:60,ms:mi},hour:{floor:e=>e.setTime(+e-e.getMilliseconds()-e.getSeconds()*gi-e.getMinutes()*mi),offset:(e,t)=>e.setTime(+e+t*cn),field:e=>e.getHours(),cycle:24,ms:cn},day:{floor:dc,offset:(e,t)=>e.setDate(e.getDate()+t),field:e=>e.getDate()-1,cycle:31,ms:dn},month:{floor(e){e.setDate(1),dc(e)},offset:(e,t)=>e.setMonth(e.getMonth()+t),field:e=>e.getMonth(),cycle:12,ms:Rf},year:{floor(e){e.setMonth(0,1),dc(e)},offset:(e,t)=>e.setFullYear(e.getFullYear()+t),cycle:1/0,ms:mc}};rs=[["second",1,gi],["second",5,5*gi],["second",15,15*gi],["second",30,30*gi],["minute",1,mi],["minute",5,5*mi],["minute",15,15*mi],["minute",30,30*mi],["hour",1,cn],["hour",3,3*cn],["hour",6,6*cn],["hour",12,12*cn],["day",1,dn],["day",2,2*dn],["week",1,kl],["month",1,Rf],["month",3,3*Rf],["year",1,mc]];AS=/^([1-9]\d*)(millisecond|second|minute|hour|day|week|month)$/,vS=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];SS=new Map([["-",""],["_"," "],["0","0"]]);CS=800,_S=240,as=8,IS=/<br\s*\/?>/gi;Vm={type:"gantt",parse(e,t,r){let a=new lS;r&&(a.title=r);let i=t.gantt?.displayMode;return typeof i=="string"&&(a.displayMode=i),$S(e,a),a},render:LS}});var Zm={};_t(Zm,{gantt:()=>Vm});var Qm=Xe(()=>{Km()});function Ka(e){throw new je(e,"semantic",{type:"architecture"})}function OS(e,t){e.accDescr&&(t.accDescr=e.accDescr.replace(/\n\s+/g,`
83
+ `)),e.accTitle&&(t.accTitle=e.accTitle.replace(/^\s+/g,"")),e.title&&(t.title=e.title);for(let r of e.groups)t.addGroup(r);for(let r of e.services)t.addService(r);for(let r of e.junctions)t.addJunction(r);for(let r of e.edges)t.addEdge(r);for(let r of e.alignments)t.addLayoutHint({direction:r.direction,members:[...r.members]})}function Pi(e){return{name:e,pattern:e,longer:[s2]}}function Lf(e){let t=e.slice(1,-1).trim();return(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1,-1).replace(/\\"/g,'"').replace(/\\'/g,"'")),t.trim()}function PS(e){let t=new Zt(Gt(e,Jm,"architecture"),Jm,"architecture"),r={$type:"Architecture",groups:[],services:[],junctions:[],edges:[],alignments:[]},a=n=>t.kinds[t.i]===n,i=()=>{if(t.kind!==-1)for(t.kind!==19&&t.fail("a line break or the end of input");t.kind===19;)t.i++};for(;t.kind===19;)t.i++;for(t.expect(0);t.kind!==-1;){switch(t.kind){case 19:t.i++;continue;case 14:r.accDescr=Kt(t.take());break;case 15:r.accTitle=Vt(t.take());break;case 16:r.title=Xt(t.take());break;case 4:{t.i++;let n={$type:"Group",id:t.expect(18)};a(24)&&(n.icon=t.take().slice(1,-1)),a(25)&&(n.title=Lf(t.take())),t.accept(8)&&(n.in=t.expect(18)),r.groups.push(n);break}case 2:{t.i++;let n={$type:"Service",id:t.expect(18)};a(17)?n.iconText=$r(t.take()):a(24)&&(n.icon=t.take().slice(1,-1)),a(25)&&(n.title=Lf(t.take())),t.accept(8)&&(n.in=t.expect(18)),r.services.push(n);break}case 1:{t.i++;let n={$type:"Junction",id:t.expect(18)};t.accept(8)&&(n.in=t.expect(18)),r.junctions.push(n);break}case 18:{let n=t.take(),l=t.accept(12);t.expect(9);let s=t.expect(11),o=t.accept(13),c;t.accept(7)||(a(10)||t.fail("'--' or '-'"),t.i++,c=Lf(t.expect(25)),t.expect(10));let f=t.accept(13),p=t.expect(11);t.expect(9);let h=t.expect(18),g=t.accept(12);r.edges.push({$type:"Edge",lhsId:n,lhsGroup:l,lhsDir:s,lhsInto:o,title:c,rhsInto:f,rhsDir:p,rhsId:h,rhsGroup:g});break}case 5:{t.i++,!a(6)&&!a(3)&&t.fail("'row' or 'column'");let n=t.take(),l=[t.expect(18),t.expect(18)];for(;a(18);)l.push(t.take());r.alignments.push({$type:"Alignment",direction:n,members:l});break}default:t.fail("a group, a service, a junction, an edge, an alignment, a title, or a line break")}i()}return r}function FS(e){let t=zS.get(e);return t===void 0?"":`<path d="${t}" stroke="var(--_fg)" stroke-width="1.5"/>`}function $c(e){return e==="L"?0:e==="R"?1:e==="T"?2:3}function WS(e,t,r,a){let i=e.length,n=t.length,l=n,s=new Map,o=new Map,c=new Int32Array(i+n).fill(l),f=new Int32Array(n+1),p=[];for(let j=0;j<=n;j++)p.push([]);t.forEach((j,Q)=>{o.set(j.id,Q);let K=j.in===void 0?void 0:o.get(j.in);K!==void 0&&K!==Q?(c[i+Q]=K,f[Q]=f[K]+1):f[Q]=1}),e.forEach((j,Q)=>{s.set(j.id,Q);let K=j.in===void 0?void 0:o.get(j.in);K!==void 0&&(c[Q]=K),p[c[Q]].push(Q)});for(let j=0;j<n;j++)p[c[i+j]].push(i+j);let h=[],g=[],u=[],m=[],b=[],w=[],v=new Array(i+n),k=new Array(i+n),O=(j,Q,K,W,X)=>{if(j===Q)return;let te=j,se=Q,oe=c[j],ae=c[Q];for(;oe!==ae;)f[oe]>=f[ae]?(te=i+oe,oe=c[te]):(se=i+ae,ae=c[se]);let ne=h.length;h.push(j),g.push(Q),u.push(K),m.push(W),b.push(te),w.push(se),(X[te]??(X[te]=[])).push(ne),(X[se]??(X[se]=[])).push(ne)};for(let j of a){let Q=j.direction==="row";for(let K=1;K<j.members.length;K++){let W=s.get(j.members[K-1]),X=s.get(j.members[K]);W!==void 0&&X!==void 0&&O(W,X,Q?1:3,Q?0:2,v)}}for(let j of[!1,!0])for(let Q of r){if(Q.lhsDir===Q.rhsDir!==j)continue;let K=s.get(Q.lhsId),W=s.get(Q.rhsId);K!==void 0&&W!==void 0&&O(K,W,$c(Q.lhsDir),$c(Q.rhsDir),k)}let R=new Int32Array(i+n),L=new Int32Array(i+n),P=new Int32Array(i+n).fill(1),B=new Int32Array(i+n).fill(1),G=new Uint8Array(i+n),C=[],Z=new Map,ee=[],H=new Map,Y=0,_=0,S=0,$=(j,Q)=>{_=0,S=0;for(let K=j;K!==Q;K=i+c[K])_+=R[K],S+=L[K]},y=(j,Q,K)=>{if(R[j]=Q,L[j]=K,G[j]=1,C.push(j),P[j]*B[j]>e2){ee.push(j);return}for(let W=K;W<K+B[j];W++)for(let X=Q;X<Q+P[j];X++)Z.set((X+bc)*t2+W+bc,j)},E=(j,Q,K,W,X)=>R[j]<Q+W&&Q<R[j]+P[j]&&L[j]<K+X&&K<L[j]+B[j],x=(j,Q,K,W)=>{if(K*W>e2){for(let X=Y;X<C.length;X++)if(E(C[X],j,Q,K,W))return C[X];return-1}for(let X=Q;X<Q+W;X++)for(let te=j;te<j+K;te++){let se=Z.get((te+bc)*t2+X+bc);if(se!==void 0)return se}for(let X of ee)if(E(X,j,Q,K,W))return X;return-1},T=(j,Q,K,W,X,te)=>{let se=`${j},${Q},${K},${W},${X},${te}`,oe=H.get(se)??0;for(;;){let ae=x(j+oe*X,Q+oe*te,K,W);if(ae<0)break;oe=X>0?R[ae]+P[ae]-j:X<0?j+K-R[ae]:te>0?L[ae]+B[ae]-Q:Q+W-L[ae]}return H.set(se,oe),oe},A=(j,Q)=>{let K=b[Q]===j,W=K?w[Q]:b[Q];if(G[W])return;let X=K?u[Q]:m[Q],te=K?m[Q]:u[Q];$(K?h[Q]:g[Q],j);let se=_,oe=S;$(K?g[Q]:h[Q],W);let ae=Ml[X],ne=wc[X],J=0,re=0,fe=Ml[X]+Ml[te]===0&&wc[X]+wc[te]===0;X===te?(ae=Ml[X]===0?1:0,ne=1-ae):fe||(J=-Ml[te],re=-wc[te]);let ye,le;if(ae!==0?(ye=ae>0?R[j]+P[j]:R[j]-P[W],le=L[j]+oe+re-S):(le=ne>0?L[j]+B[j]:L[j]-B[W],ye=R[j]+se+J-_),fe){let we=k[W];if(we!==void 0&&we.length>1){let ue=[];for(let xe of we){let Ie=w[xe]===W,Le=Ie?b[xe]:w[xe];if(!G[Le]||(Ie?u[xe]:m[xe])!==X||(Ie?m[xe]:u[xe])!==te)continue;$(Ie?h[xe]:g[xe],Le);let We=ae!==0?L[Le]+S:R[Le]+_;$(Ie?g[xe]:h[xe],W),ue.push(We-(ae!==0?S:_))}ue.length>1&&(ue.sort((xe,Ie)=>xe-Ie),ae!==0?le=ue[ue.length-1>>1]:ye=ue[ue.length-1>>1])}let pe=ae===0?1:0,ge=1-pe,Ae=T(ye,le,P[W],B[W],pe,ge),Se=Ae===0?0:T(ye,le,P[W],B[W],-pe,-ge),ce=Ae<=Se?Ae:-Se;ye+=pe*ce,le+=ge*ce}else{let we=T(ye,le,P[W],B[W],ae,ne);ye+=ae*we,le+=ne*we}y(W,ye,le)},M=j=>{let Q=p[j];if(Q.length===0)return;C.length=0;let K=[];for(let we of Q){if(G[we])continue;Y=C.length,K.push(Y),Z.clear(),ee.length=0,H.clear(),y(we,0,0);let pe=Y,ge=Y,Ae=0;for(;;){if(pe<C.length){let ce=C[pe++],ue=v[ce];if(ue!==void 0)for(let xe of ue)A(ce,xe);continue}if(ge>=C.length)break;let Se=k[C[ge]];if(Se===void 0||Ae>=Se.length){ge++,Ae=0;continue}A(C[ge],Se[Ae++])}}K.push(C.length);let W=K.length-1,X=new Array(W),te=new Array(W),se=new Array(W),oe=new Array(W),ae=0,ne=0;for(let we=0;we<W;we++){let pe=1/0,ge=1/0,Ae=-1/0,Se=-1/0;for(let ce=K[we];ce<K[we+1];ce++){let ue=C[ce];pe=Math.min(pe,R[ue]),ge=Math.min(ge,L[ue]),Ae=Math.max(Ae,R[ue]+P[ue]),Se=Math.max(Se,L[ue]+B[ue])}X[we]=pe,te[we]=ge,se[we]=Ae-pe,oe[we]=Se-ge,ae+=se[we]*oe[we],ne=Math.max(ne,se[we])}let J=Math.max(ne,Math.ceil(Math.sqrt(ae*2))),re=0,fe=0,ye=0,le=0;for(let we=0;we<W;we++){re>0&&re+se[we]>J&&(fe+=ye,re=0,ye=0);for(let pe=K[we];pe<K[we+1];pe++)R[C[pe]]+=re-X[we],L[C[pe]]+=fe-te[we];re+=se[we],ye=Math.max(ye,oe[we]),le=Math.max(le,re)}j<n&&(P[i+j]=le,B[i+j]=fe+ye)};for(let j=n-1;j>=0;j--)M(j);M(l);let N=new Int32Array(n),F=new Int32Array(n),U=new Int32Array(n),D=new Uint8Array(n);for(let j=0;j<n;j++){let Q=c[i+j];U[j]=Q===l?-1:Q,N[j]=R[i+j]+(Q===l?0:N[Q]),F[j]=L[i+j]+(Q===l?0:F[Q]),p[j].length===0&&(D[j]=1)}let I=new Int32Array(i),z=new Int32Array(i),q=new Int32Array(i);for(let j=0;j<i;j++){let Q=c[j];q[j]=Q===l?-1:Q,I[j]=R[j]+(Q===l?0:N[Q]),z[j]=L[j]+(Q===l?0:F[Q])}return{col:I,row:z,groupCol:N,groupRow:F,groupCols:P.slice(i),groupRows:B.slice(i),groupParent:U,groupEmpty:D,nodeParent:q}}function Df(e,t,r,a,i){let n=e.architecture,l=n!==null&&typeof n=="object"&&!Array.isArray(n)?n[t]:void 0;return typeof l=="number"&&Number.isFinite(l)?Math.min(i,Math.max(a,l)):r}function i2(e){let t=new Map;for(let r of e.sort((a,i)=>a-i))t.has(r)||t.set(r,t.size);return t}function n2(e,t,r,a,i){return`<svg class="pele-icon" data-icon="${Oe(e)}" x="${d(t)}" y="${d(r)}" width="${d(a)}" height="${d(a)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i?.(e)??FS(e)}</svg>`}function US(e,t,r,a){let i=e.lines.length>r;if(!i&&e.width<=t)return e;let n=a.width("\u2026",e.size,0),l=[],s=[],o=0;for(let c=0;c<Math.min(r,e.lines.length);c++){let f=e.lines[c].map(h=>({...h})),p=e.widths[c];if(p>t||i&&c===r-1)for(;;){let h=f[f.length-1];if(h===void 0){f.push({text:"\u2026",style:0,width:n}),p=n;break}let g=p-h.width;if(h.icon===void 0&&g+n<t){let u=0,m=h.text.length;for(;u<m;){let w=u+m+1>>1;g+a.width(h.text.slice(0,w),e.size,h.style)+n<=t?u=w:m=w-1}let b=u>0?h.text.charCodeAt(u-1):0;b>=55296&&b<=56319&&u--,h.text=h.text.slice(0,u).trimEnd()+"\u2026",h.width=a.width(h.text,e.size,h.style),p=g+h.width;break}f.pop(),p=g}l.push(f),s.push(p),o=Math.max(o,p)}return{...e,lines:l,widths:s,width:o,height:l.length*e.lineHeight}}function qS(e,t){let{x:r,y:a,dx:i,dy:n}=e,{x:l,y:s,dx:o,dy:c}=t,f=r+i*Wr,p=a+n*Wr,h=l+o*Wr,g=s+c*Wr;if(i*o+n*c===0){let w=i!==0?l:r,v=i!==0?a:s;return(w-r)*i+(v-a)*n>0&&(w-l)*o+(v-s)*c>0?[r,a,w,v,l,s]:i!==0?[r,a,f,p,f,g,h,g,l,s]:[r,a,f,p,h,p,h,g,l,s]}let u=i!==0,m=u?s-a:l-r;if(i===-o&&n===-c){if((l-r)*i+(s-a)*n>0){if(Math.abs(m)<.5)return[r,a,l,s];if(u){let O=i>0?e.x1:t.x1,R=i>0?t.x0:e.x0,L=O<R?(O+R)/2:(r+l)/2;return[r,a,L,a,L,s,l,s]}let w=n>0?e.y1:t.y1,v=n>0?t.y0:e.y0,k=w<v?(w+v)/2:(a+s)/2;return[r,a,r,k,l,k,l,s]}}else if(Math.abs(m)>=1){if(u){let v=i>0?Math.max(r,l)+Wr:Math.min(r,l)-Wr;return[r,a,v,a,v,s,l,s]}let w=n>0?Math.max(a,s)+Wr:Math.min(a,s)-Wr;return[r,a,r,w,l,w,l,s]}if(u){let w=e.y1+Wr<=t.y0?(e.y1+t.y0)/2:t.y1+Wr<=e.y0?(t.y1+e.y0)/2:Math.max(e.y1,t.y1)+Wr;return[r,a,f,a,f,w,h,w,h,s,l,s]}let b=e.x1+Wr<=t.x0?(e.x1+t.x0)/2:t.x1+Wr<=e.x0?(t.x1+e.x0)/2:Math.max(e.x1,t.x1)+Wr;return[r,a,r,p,b,p,b,g,l,g,l,s]}function GS(e){let t=[e[0],e[1]];for(let r=2;r<e.length;r+=2){let a=e[r],i=e[r+1],n=t.length,l=Math.abs(a-t[n-2])<.01,s=Math.abs(i-t[n-1])<.01;l&&s||(n>=4&&(l&&Math.abs(t[n-4]-t[n-2])<.01||s&&Math.abs(t[n-3]-t[n-1])<.01)?(t[n-2]=a,t[n-1]=i):t.push(a,i))}return t}function jS(e,t,r){let a=e.length/2,i=new Array(a),n=new Array(a);for(let o=0;o<a;o++)i[o]=e[o*2],n[o]=e[o*2+1];let l=(o,c,f)=>{let p=Math.hypot(i[c]-i[o],n[c]-n[o]),h=Math.min(f,Math.max(0,p-1));p>0&&h>0&&(i[o]+=(i[c]-i[o])/p*h,n[o]+=(n[c]-n[o])/p*h)};l(0,1,t),l(a-1,a-2,r);let s=`M${d(i[0])},${d(n[0])}`;for(let o=1;o<a-1;o++){let c=Math.hypot(i[o]-i[o-1],n[o]-n[o-1]),f=Math.hypot(i[o+1]-i[o],n[o+1]-n[o]),p=Math.min(BS,c/2,f/2);if(p<.5){s+=`L${d(i[o])},${d(n[o])}`;continue}let h=i[o]-(i[o]-i[o-1])/c*p,g=n[o]-(n[o]-n[o-1])/c*p,u=i[o]+(i[o+1]-i[o])/f*p,m=n[o]+(n[o+1]-n[o])/f*p;s+=`L${d(h)},${d(g)}Q${d(i[o])},${d(n[o])} ${d(u)},${d(m)}`}return s+`L${d(i[a-1])},${d(n[a-1])}`}function XS(e,t,r){return Nr(r,a=>VS(e,t,r,a))}function VS(e,t,r,a){let i=Df(t,"iconSize",48,8,512),n=Df(t,"fontSize",r.fontSize??16,4,128),l=Math.min(Df(t,"padding",20,0,256),a?12:1/0),s=Math.round(n*.875),o=r.measurer??et(r.fontFamily),c=r.padding??8,f=r.icons,p=i/2,h=[...e.nodes.values()],g=[...e.groups.values()],u=h.length,m=g.length,b=WS(h,g,e.edges,e.layoutHints),w=new Map;h.forEach((ie,$e)=>w.set(ie.id,$e));let v=new Array(u),k=new Float64Array(u),O=new Float64Array(u),R=a?Math.max(i,64):Math.max(i*2.25,96);for(let ie=0;ie<u;ie++){let $e=h[ie],ve=ze($e.type==="service"?$e.title:void 0,!0,o,n,R);v[ie]=ve,k[ie]=Math.max(i,2*Math.ceil(ve.width/2)),O[ie]=i+(ve.height>0?r2+ve.height:0)}let L=[],P=[];for(let ie=0;ie<u;ie++)L.push(b.col[ie]),P.push(b.row[ie]);for(let ie=0;ie<m;ie++)b.groupEmpty[ie]&&(L.push(b.groupCol[ie]),P.push(b.groupRow[ie]));let B=i2(L),G=i2(P),C=B.size,Z=G.size,ee=new Float64Array(C),H=new Float64Array(Z),Y=a?Math.max(24,2*Wr):Math.max(40,Math.round(i*.75)),_=new Float64Array(C).fill(Y),S=new Float64Array(Z).fill(Y),$=new Int32Array(u),y=new Int32Array(u);for(let ie=0;ie<u;ie++){let $e=$[ie]=B.get(b.col[ie]),ve=y[ie]=G.get(b.row[ie]);ee[$e]=Math.max(ee[$e],k[ie]),H[ve]=Math.max(H[ve],O[ie])}for(let ie=0;ie<m;ie++){if(!b.groupEmpty[ie])continue;let $e=B.get(b.groupCol[ie]),ve=G.get(b.groupRow[ie]);ee[$e]=Math.max(ee[$e],i),H[ve]=Math.max(H[ve],p)}let E=e.edges.length,x=new Array(E),T=new Int32Array(E*2);for(let ie=0;ie<E;ie++){let $e=e.edges[ie],ve=T[ie*2]=w.get($e.lhsId)??-1,Te=T[ie*2+1]=w.get($e.rhsId)??-1,De=ze($e.title,!0,o,s,160);if(x[ie]=De,!(De.width===0||ve<0||Te<0)){if($[ve]!==$[Te]){let _e=Math.min($[ve],$[Te]);_[_e]=Math.max(_[_e],Math.ceil(De.width)+28)}else if(ee[$[ve]]=Math.max(ee[$[ve]],2*Math.ceil(De.width/2)+8),y[ve]!==y[Te]){let _e=Math.min(y[ve],y[Te]);S[_e]=Math.max(S[_e],Math.ceil(De.height)+24)}}}let A=new Array(m),M=new Int32Array(m),N=new Int32Array(m),F=new Int32Array(m),U=new Int32Array(m),D=new Float64Array(m),I=new Float64Array(m),z=new Float64Array(m),q=new Float64Array(m),j=new Float64Array(m),Q=new Float64Array(m),K=new Float64Array(C),W=new Float64Array(C),X=new Float64Array(Z),te=new Float64Array(Z),se=Math.round(n*1.25);for(let ie=0;ie<m;ie++){M[ie]=B.get(b.groupCol[ie]),N[ie]=B.get(b.groupCol[ie]+b.groupCols[ie]-1),F[ie]=G.get(b.groupRow[ie]),U[ie]=G.get(b.groupRow[ie]+b.groupRows[ie]-1);let $e=ze(g[ie].title,!0,o,n,a?Math.max(80,Nt(r)/2):320);A[ie]=$e;let ve=g[ie].icon?se:0;j[ie]=$e.width+ve+($e.width>0&&ve>0?6:0),Q[ie]=Math.max($e.height,ve)}for(let ie=m-1;ie>=0;ie--){let $e=l+D[ie],ve=l+I[ie],Te=(Q[ie]>0?Math.max(l,Q[ie]+12):l)+z[ie],De=l+q[ie];if(j[ie]>0){let Ye=$e+ve;for(let Ee=M[ie];Ee<=N[ie];Ee++)Ye+=ee[Ee]+(Ee<N[ie]?W[Ee]+_[Ee]+K[Ee+1]:0);j[ie]+20>Ye&&(ve+=Math.ceil(j[ie]+20-Ye))}D[ie]=$e,I[ie]=ve,z[ie]=Te,q[ie]=De,K[M[ie]]=Math.max(K[M[ie]],$e),W[N[ie]]=Math.max(W[N[ie]],ve),X[F[ie]]=Math.max(X[F[ie]],Te),te[U[ie]]=Math.max(te[U[ie]],De);let _e=b.groupParent[ie];_e<0||(M[_e]===M[ie]&&(D[_e]=Math.max(D[_e],$e)),N[_e]===N[ie]&&(I[_e]=Math.max(I[_e],ve)),F[_e]===F[ie]&&(z[_e]=Math.max(z[_e],Te)),U[_e]===U[ie]&&(q[_e]=Math.max(q[_e],De)))}let oe=new Float64Array(C),ae=new Float64Array(Z),ne=0;for(let ie=0;ie<C;ie++)oe[ie]=ne+K[ie],ne=oe[ie]+ee[ie]+W[ie]+(ie<C-1?_[ie]:0);let J=0;for(let ie=0;ie<Z;ie++)ae[ie]=J+X[ie],J=ae[ie]+H[ie]+te[ie]+(ie<Z-1?S[ie]:0);let re=0,fe=0,ye=ne,le=J,we=ie=>oe[M[ie]]-D[ie],pe=ie=>oe[N[ie]]+ee[N[ie]]+I[ie],ge=ie=>ae[F[ie]]-z[ie],Ae=ie=>ae[U[ie]]+H[U[ie]]+q[ie],Se=ie=>oe[$[ie]]+ee[$[ie]]/2,ce=(ie,$e,ve)=>{let Te=YS[$e],De=HS[$e],_e=Se(ie),Ye=ae[y[ie]],Ee={x:_e,y:Ye+p,dx:Te,dy:De,x0:_e-k[ie]/2,y0:Ye,x1:_e+k[ie]/2,y1:Ye+O[ie],gap:0,wire:!1};h[ie].type==="junction"?(Ee.x0=Ee.x1=_e,Ee.y0=Ee.y1=Ee.y,Ee.gap=a2):Te!==0?Ee.x=_e+Te*p:Ee.y=De<0?Ye:Ye+O[ie]+(v[ie].height>0?2:0);let qe=ve?b.nodeParent[ie]:-1;return qe>=0&&(Ee.x0=we(qe),Ee.x1=pe(qe),Ee.y0=ge(qe),Ee.y1=Ae(qe),Ee.gap=0,Ee.wire=h[ie].type==="junction",Te!==0?Ee.x=Te<0?Ee.x0:Ee.x1:Ee.y=De<0?Ee.y0:Ee.y1),Ee},ue="",xe="",Ie=[],Le=gt("arrow_point");for(let ie=0;ie<E;ie++){let $e=e.edges[ie],ve=T[ie*2],Te=T[ie*2+1];if(ve<0||Te<0)continue;let De=ce(ve,$c($e.lhsDir),$e.lhsGroup),_e=ce(Te,$c($e.rhsDir),$e.rhsGroup);De.x===_e.x&&De.y===_e.y&&De.dx===_e.dx&&(De.x-=8*Math.abs(De.dy),De.y-=8*Math.abs(De.dx),_e.x+=8*Math.abs(De.dy),_e.y+=8*Math.abs(De.dx));let Ye=qS(De,_e);De.wire&&Ye.unshift(Se(ve),ae[y[ve]]+p),_e.wire&&Ye.push(Se(Te),ae[y[Te]]+p);let Ee=GS(Ye);if(Ee.length<4)continue;let qe=Oe(`${$e.lhsId}-${$e.rhsId}`);ue+=`<g class="pele-edge" data-id="${qe}"><path d="${jS(Ee,$e.lhsInto&&!De.wire?Le+De.gap:0,$e.rhsInto&&!_e.wire?Le+_e.gap:0)}"/>`+($e.lhsInto?bt("arrow_point",De.x+De.dx*De.gap,De.y+De.dy*De.gap,-De.dx,-De.dy,"var(--_l)"):"")+($e.rhsInto?bt("arrow_point",_e.x+_e.dx*_e.gap,_e.y+_e.dy*_e.gap,-_e.dx,-_e.dy,"var(--_l)"):"")+"</g>";let Ge=-1,rt=-1,ct=-1,tt=-1,lt=x[ie];for(let st=0;st<Ee.length;st+=2)re=Math.min(re,Ee[st]-4),ye=Math.max(ye,Ee[st]+4),fe=Math.min(fe,Ee[st+1]-4),le=Math.max(le,Ee[st+1]+4);for(let st=0;st+3<Ee.length;st+=2){let Wt=Math.abs(Ee[st+1]-Ee[st+3])<.01,Ct=Math.abs(Ee[st]-Ee[st+2])+Math.abs(Ee[st+1]-Ee[st+3]);Wt||Ie.push(Ee[st],Math.min(Ee[st+1],Ee[st+3]),Math.max(Ee[st+1],Ee[st+3])),Ct>rt&&(Ge=st,rt=Ct),Wt&&Ct>tt&&(ct=st,tt=Ct)}if(lt.width>0){let st=tt>=lt.width+8?ct:Ge,Wt=(Ee[st]+Ee[st+2])/2,Ct=(Ee[st+1]+Ee[st+3])/2,kt=lt.width+8,Ft=Math.abs(Ee[st]-Ee[st+2])<.01;for(let He of[De,_e])Wt+kt/2<=He.x0||Wt-kt/2>=He.x1||Ct+lt.height/2<=He.y0||Ct-lt.height/2>=He.y1||(Ft?Wt=Wt>=(He.x0+He.x1)/2?He.x1+kt/2+4:He.x0-kt/2-4:Ct=Ct>=(He.y0+He.y1)/2?He.y1+lt.height/2+4:He.y0-lt.height/2-4);re=Math.min(re,Wt-kt/2),ye=Math.max(ye,Wt+kt/2),fe=Math.min(fe,Ct-lt.height/2),le=Math.max(le,Ct+lt.height/2),xe+=wr(`${$e.lhsId}-${$e.rhsId}`,lt,Wt,Ct,"",f)}}let We="";for(let ie=0;ie<m;ie++){let $e=g[ie],ve=we(ie),Te=ge(ie),De=pe(ie)-ve,_e=A[ie],Ye="";if(j[ie]>0){let Ee=Te+Q[ie]+12,qe=[];for(let tt=0;tt<Ie.length;tt+=3)Ie[tt+1]<Ee&&Ie[tt+2]>Te&&Ie[tt]>ve&&Ie[tt]<ve+De&&qe.push(Ie[tt]);qe.sort((tt,lt)=>tt-lt),qe.push(ve+De-4);let Ge=ve+10;for(let tt of qe){if(tt-6-Ge>=j[ie])break;Ge=Math.max(Ge,tt+6)}Ge+j[ie]>ve+De-4&&(Ge=ve+10);let rt=Te+6+Q[ie]/2,ct=Ge;$e.icon&&(Ye+=n2($e.icon,Ge,rt-se/2,se,f),ct+=se+6),Ye+=Re(_e,ct+_e.width/2,rt,' class="pele-cluster-label" fill="var(--_m)"',f)}We+=`<g class="pele-cluster" data-id="${Oe($e.id)}"><rect x="${d(ve)}" y="${d(Te)}" width="${d(De)}" height="${d(Ae(ie)-Te)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${nt}/>`+Ye+"</g>"}let de="",ke=i*.5,Ce=Math.max(6,Math.round(n*.75));for(let ie=0;ie<u;ie++){let $e=h[ie],ve=`data-id="${Oe($e.id)}" transform="translate(${d(Se(ie))},${d(ae[y[ie]])})"`;if($e.type==="junction"){de+=`<g class="pele-node pele-junction" ${ve}><circle cy="${d(p)}" r="${a2}" fill="var(--_l)"/></g>`;continue}let Te="";if($e.icon)Te=n2($e.icon,-ke/2,(i-ke)/2,ke,f);else if($e.iconText){let De=ze($e.iconText,!1,o,Ce,i-8),_e=Math.max(1,Math.floor((i-4)/(De.lineHeight||1)));Te=Re(US(De,i-8,_e,o),0,p,` class="pele-icon-text" font-size="${Ce}"`,f)}de+=`<g class="pele-node pele-service" ${ve}><rect x="${d(-p)}" width="${d(i)}" height="${d(i)}" fill="var(--_s)" stroke="var(--_b)"${nt}/>`+Te+Re(v[ie],0,i+r2+v[ie].height/2,' class="pele-label"',f)+"</g>"}let be=ze(e.title,!1,o,n,a?Nt(r):4e3,1),Me=be.height>0?be.height+12:0,Ne=Math.ceil(Math.max(ye-re,be.width)+2*c),Be=Math.ceil(le-fe+Me+2*c),Pe=Math.round((Ne-(ye-re))/2-re),V=Math.round(c+Me-fe),me=(We?`<g class="pele-clusters">${We}</g>`:"")+(ue?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round" stroke-linejoin="round">${ue}</g>`:"")+(xe?`<g class="pele-edge-labels" font-size="${s}">${xe}</g>`:"")+(de?`<g class="pele-nodes">${de}</g>`:"");return{svg:Je("architecture",Ne,Be,n,r,e,Re(be,Ne/2,c+be.height/2,' class="pele-title" font-weight="var(--_tw)"')+(me?`<g transform="translate(${Pe},${V})">${me}</g>`:"")),width:Ne,height:Be,links:[]}}var DS,s2,Jm,zS,Ml,wc,e2,bc,t2,Wr,BS,r2,a2,YS,HS,l2,o2=Xe(()=>{zt();Vr();pr();ut();wt();DS=class{constructor(){he(this,"type","architecture");he(this,"title");he(this,"accTitle");he(this,"accDescr");he(this,"nodes",new Map);he(this,"groups",new Map);he(this,"edges",[]);he(this,"layoutHints",[]);he(this,"registered",new Map)}register(e,t,r){this.registered.has(t)&&Ka(`The ${e} id [${t}] is already in use by another ${this.registered.get(t)}`),r!==void 0&&(t===r&&Ka(`The ${e} [${t}] cannot be placed within itself`),this.registered.has(r)||Ka(`The ${e} [${t}]'s parent does not exist. Please make sure the parent is created before this ${e}`),this.registered.get(r)==="node"&&Ka(`The ${e} [${t}]'s parent is not a group`)),this.registered.set(t,e==="group"?"group":"node")}addService({id:e,icon:t,iconText:r,title:a,in:i}){this.register("service",e,i),this.nodes.set(e,{id:e,type:"service",icon:t,iconText:r,title:a,in:i})}addJunction({id:e,in:t}){this.register("junction",e,t),this.nodes.set(e,{id:e,type:"junction",in:t})}addGroup({id:e,icon:t,title:r,in:a}){this.register("group",e,a),this.groups.set(e,{id:e,icon:t,title:r,in:a})}addEdge({lhsId:e,rhsId:t,lhsDir:r,rhsDir:a,lhsInto:i,rhsInto:n,lhsGroup:l,rhsGroup:s,title:o}){let c=[["left",e,l],["right",t,s]];for(let[p,h]of c)this.registered.has(h)||Ka(`The ${p}-hand id [${h}] does not yet exist. Please create the service/group before declaring an edge to it.`);for(let[p,h]of c)this.nodes.has(h)||Ka(`The ${p}-hand id [${h}] is a group. Add {group} to a service inside it instead.`);let f=this.nodes.get(e).in;if(f!==void 0&&f===this.nodes.get(t).in)for(let[p,h,g]of c)g&&Ka(`The ${p}-hand id [${h}] is modified to traverse the group boundary, but the edge does not pass through two groups.`);this.edges.push({lhsId:e,lhsDir:r,lhsInto:i,lhsGroup:l,rhsId:t,rhsDir:a,rhsInto:n,rhsGroup:s,title:o})}addLayoutHint(e){e.members.length<2&&Ka(`An align directive requires at least two members; got ${e.members.length}`);let t=new Set;for(let r of e.members)this.registered.get(r)!=="node"&&Ka(`align ${e.direction} references [${r}], which is not a service or junction`),t.has(r)&&Ka(`align ${e.direction} lists [${r}] more than once`),t.add(r);this.layoutHints.push(e)}};s2={name:"ID",pattern:/[\w]([-\w]*\w)?/y};Jm=[Pi("architecture-beta"),Pi("junction"),Pi("service"),Pi("column"),Pi("group"),Pi("align"),Pi("row"),{name:"--",pattern:"--",longer:[jt]},Pi("in"),{name:":",pattern:":"},{name:"-",pattern:"-",longer:[jt]},{name:"ARROW_DIRECTION",pattern:/L|R|T|B/y},{name:"ARROW_GROUP",pattern:/\{group\}/y},{name:"ARROW_INTO",pattern:/<|>/y},ur,rr,ar,Xr,s2,Rr,Lr,jt,sr,lr,{name:"ARCH_ICON",pattern:/\([\w-:]+\)/y},{name:"ARCH_TITLE",pattern:/\[(?:"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|[^\[\]\r\n]+)\]/y}];zS=new Map([["database","M4 6a8 3 0 1 0 16 0a8 3 0 1 0-16 0M4 6v12a8 3 0 0 0 16 0V6M4 12a8 3 0 0 0 16 0"],["server","M3 4h18v7H3zM3 13h18v7H3zM7 7.5h.01M7 16.5h.01M11 7.5h6M11 16.5h6"],["disk","M5 3h14v18H5zM12 6.5a4 4 0 1 0 0 8a4 4 0 1 0 0-8M12 10.5h.01M8 18h3"],["internet","M3 12a9 9 0 1 0 18 0a9 9 0 1 0-18 0M3 12h18M12 3a13 13 0 0 0 0 18M12 3a13 13 0 0 1 0 18"],["cloud","M7 18a4 4 0 0 1-.5-7.97A6 6 0 0 1 18 9.5a4.25 4.25 0 0 1-.5 8.5z"]]);Ml=[-1,1,0,0],wc=[0,0,-1,1];e2=64,bc=2**25,t2=2**26;Wr=12,BS=6,r2=4,a2=3,YS=[-1,1,0,0],HS=[0,0,-1,1];l2={type:"architecture",parse(e,t,r){let a=new DS;return r&&(a.title=r),OS(PS(e),a),a},render:XS}});var c2={};_t(c2,{architecture:()=>l2});var h2=Xe(()=>{o2()});function aT(e){let t=e.length,r=[],a=[],i=[],n=[],l=0,s=0,o=[[],[],[],[]],c=[[],[],[],[]],f=[0,0,0,0],p=!1,h=-1;Mc.lastIndex=0;for(let L=Mc.exec(e);L!==null;L=Mc.exec(e)){let P=L[1]!==void 0?0:L[2]!==void 0?1:L[3]!==void 0?2:3;o[P].push(L.index),c[P].push(Mc.lastIndex),p=!0}let g=(L,P,B)=>{r.push(L),a.push(e.slice(P,B)),i.push(P),s=B},u=L=>{n.push(l),l=L},m=()=>{n.length>0&&(l=n.pop())},b=(L,P)=>(L.lastIndex=P,L.test(e)?L.lastIndex:-1),w=L=>{let P=e.indexOf(`
84
+ `,L);return P===-1?t:P},v=()=>{if(h<s){Pf.lastIndex=s,h=Pf.test(e)?Pf.lastIndex-1:t;for(let L=0;L<4;L++){let P=o[L],B=f[L];for(;B<P.length&&P[B]<=h;)B++;f[L]=B}}for(let L=0;L<4;L++){let P=f[L]-1;if(P>=0&&o[L][P]>=s)return g(8+L,s,w(c[L][P])),!0}return!1},k=L=>{let P=L|32;if(P===116&&e.slice(s+1,s+5).toLowerCase()==="itle"&&Ue(e.charCodeAt(s+5))){let B=s+6;for(;B<t;){let G=e.charCodeAt(B);if(G===35||G===10||G===59)break;B++}if(B>s+6)return g(2,s,B),!0}if(P===97&&(e.charCodeAt(s+1)|32)===99&&(e.charCodeAt(s+2)|32)===99){let B;if((B=b(JS,s))>=0)return u(3),g(3,s,B),!0;if((B=b(eT,s))>=0)return u(4),g(5,s,B),!0;if((B=b(tT,s))>=0)return u(5),s=B,!0}if(p&&!Vi(L)&&v())return!0;if(L===10||L===13&&e.charCodeAt(s+1)===10){let B=s;for(;B<t;){let G=e.charCodeAt(B);if(G===10)B++;else if(G===13&&e.charCodeAt(B+1)===10)B+=2;else break}return g(12,s,B),!0}if(Ue(L)){for(s++;s<t&&Ue(e.charCodeAt(s));)s++;return!0}if(L===35||L===37)return s=w(s),!0;if(Qe(L)){let B=s+1;for(;B<t&&Qe(e.charCodeAt(B));)B++;if(B-s<=rT){let G=QS.get(e.slice(s,B).toLowerCase());if(G!==void 0)return(G===46||G===47||G===48)&&u(2),g(G,s,B),!0}for(;B<t;){let G=e.charCodeAt(B);if(G<128&&y2[G]===1)break;B++}return r.push(59),a.push(e.slice(s,B).trim()),i.push(s),s=B,!0}switch(L){case 123:return g(15,s,s+1),!0;case 125:return g(16,s,s+1),!0;case 58:return e.charCodeAt(s+1)===58&&e.charCodeAt(s+2)===58?g(17,s,s+3):g(18,s,s+1),!0;case 60:return e.charCodeAt(s+1)!==45?!1:(g(55,s,s+2),!0);case 45:return e.charCodeAt(s+1)===62?g(56,s,s+2):g(57,s,s+1),!0;case 34:return u(1),s++,!0;case 44:return g(60,s,s+1),!0}return!1},O=L=>{if(Qe(L)){let P=s+1;for(;P<t&&Qe(e.charCodeAt(P));)P++;return g(49,s,P),!0}switch(L){case 58:return g(50,s,s+1),!0;case 59:return g(51,s,s+1),!0;case 37:return g(52,s,s+1),!0;case 45:return g(53,s,s+1),!0;case 35:return g(54,s,s+1),!0;case 32:return s++,!0;case 34:return u(1),s++,!0;case 10:return m(),s++,!0;case 44:return g(60,s,s+1),!0}return!1};for(;s<t;){let L=e.charCodeAt(s),P=!0;switch(l){case 0:P=k(L);break;case 2:P=O(L);break;case 1:if(L===34)m(),s++;else{let B=e.indexOf('"',s);g(58,s,B===-1?t:B)}break;case 3:m(),g(4,s,w(s));break;case 4:m(),g(6,s,w(s));break;case 5:if(L===125)m(),s++;else{let B=e.indexOf("}",s);g(7,s,B===-1?t:B)}break}if(!P)return r.push(1),a.push(""),i.push(s),{types:r,texts:a,starts:i}}let R=l===0?13:l===1?58:l===3?4:l===4?6:l===5?7:-1;return R!==-1&&g(R,t,t),g(0,t,t),{types:r,texts:a,starts:i}}function f2(e){return e===49||e===50||e===54||e===53||e===51}function nT(e,t){let{types:r,texts:a,starts:i}=aT(e),n=0,l=[],s=[],o=(w,v=w,...k)=>{let O=r[n];if(O===1)throw it("requirement",e,i[n],"",!0);for(let L=v;L>=w;L--)k.unshift(L);let R=k.map(L=>`'${d2[L]}'`).join(", ");throw it("requirement",e,i[n],`Expecting ${R}, got '${d2[O]}'`)},c=w=>(r[n]!==w&&o(w),a[n++]),f=(w,v)=>{let k=r[n];return(k<w||k>v)&&o(w,v),n++,iT[k-23]},p=()=>{let w=r[n];return w!==59&&w!==58&&o(58,59),a[n++]},h=()=>{let w=r[n];if(w===3)n++,t.setAccTitle(c(4).trim());else if(w===5)n++,t.setAccDescription(c(6).trim());else if(w===7)t.setAccDescription(a[n++].trim());else return!1;return!0},g=()=>{let w=[];for(;;){let v=r[n];if(v!==49&&v!==59&&v!==58&&o(58,59,49),w.push(a[n++]),r[n]!==60)return w;n++}},u=()=>{let w=[];for(;;){f2(r[n])||o(49,51,53,54);let v=a[n++];for(;f2(r[n]);)v+=a[n++];if(w.push(v),r[n]!==60)return w;n++}},m=()=>{let w;return r[n]===17?(n++,w=g(),c(15)):r[n]===15?n++:o(15,15,17),c(12),w},b=w=>{for(l.length=0,s.length=0;;){let v=r[n];if(v===16){n++;break}if(v===12){n++;continue}(w?v<19||v>22:v!==44&&v!==45)&&(w&&o(19,22,12,16),o(44,45,12,16)),n++,c(18),s.push(v===21?f(29,31):v===22?f(32,35):p()),l.push(v),c(12)}for(let v=l.length-1;v>=0;v--){let k=s[v];switch(l[v]){case 19:t.setNewReqId(k);break;case 20:t.setNewReqText(k);break;case 21:t.setNewReqRisk(k);break;case 22:t.setNewReqVerifyMethod(k);break;case 44:t.setNewElementType(k);break;default:t.setNewElementDocRef(k)}}};for(;h();)r[n]===12&&n++;for(r[n]!==14&&o(14,14,3,5,7),n++,c(12);;){let w=r[n];if(w===13)return;if(w===12)n++;else{if(h())continue;if(w>=8&&w<=11)n++,t.setDirection(w===8?"TB":w===9?"BT":w===10?"RL":"LR");else if(w>=23&&w<=28){let v=f(23,28),k=p(),O=m();b(!0),t.addRequirement(k,v),O&&t.setClass([k],O)}else if(w===36){n++;let v=p(),k=m();b(!1),t.addElement(v),k&&t.setClass([v],k)}else if(w===46){n++;let v=g();t.setCssStyle(v,u())}else if(w===47){n++;let v=g();t.defineClass(v,u())}else if(w===48){n++;let v=g();t.setClass(v,g())}else if(w===59||w===58){let v=a[n++],k=r[n];if(k===17)n++,t.setClass([v],g());else if(k===55||k===57){n++;let O=f(37,43);c(k===57?56:57);let R=p();k===57?t.addRelationship(O,v,R):t.addRelationship(O,R,v)}else o(17,17,55,57)}else o(12,13,3,5,7,8,9,10,11,23,24,25,26,27,28,36,47,48,46,59,58)}}}function sT(e){let t=[];for(let i of e.requirements.values())t.push({id:i.name,requirement:i,element:void 0,cssStyles:i.cssStyles,cssClasses:i.classes.join(" ")});for(let i of e.elements.values())t.push({id:i.name,requirement:void 0,element:i,cssStyles:i.cssStyles,cssClasses:i.classes.join(" ")});let r=i=>e.requirements.has(i)||e.elements.has(i)?i:void 0,a=e.relations.map((i,n)=>({id:`${i.src}-${i.dst}-${n}`,start:r(i.src),end:r(i.dst),type:i.type,contains:i.type===zi.CONTAINS}));return{nodes:t,edges:a,direction:e.direction}}function Ec(e,t,r){if(t===0||e.lines.length===0)return e;let a=0,i=[],n=e.lines.map(l=>{let s=0,o=l.map(c=>{let f=c.style|t,p=c.icon!==void 0||c.math?c.width:r.width(c.text,e.size,f);return s+=p,{...c,style:f,width:p}});return i.push(s),s>a&&(a=s),o});return{...e,lines:n,widths:i,width:a}}function g2(e,t,r,a){let i=li(e),n="",l="";for(let s=0;s<e.lines.length;s++){let o=e.lines[s],c=r+Ha(e,s);if(Wn(o)){l+=Re(Ua(e,s),t+e.widths[s]/2,c,a);continue}let f=c+e.size*.35,p=!0;for(let h of o)h.icon!==void 0||h.text===""||(n+=`<tspan${p?` x="${d(t)}" y="${d(f)}"`:""}${Ya(h.style&~i)}>${Ve(h.text)}</tspan>`,p=!1)}return(n===""?"":`<text${Aa(a,i)} text-anchor="start" xml:space="preserve">${n}</text>`)+l}function gT(e,t,r,a){let i=x2,n=e-r*i,l=t-a*i;return`<circle class="pele-marker" cx="${d(n)}" cy="${d(l)}" r="${i}"/><path class="pele-marker" d="M${d(n-r*i)},${d(l-a*i)}L${d(n+r*i)},${d(l+a*i)}M${d(n+a*i)},${d(l-r*i)}L${d(n-a*i)},${d(l+r*i)}"/>`}function mT(e,t,r,a){let i=e-r*u2,n=t-a*u2;return`<path class="pele-marker" d="M${d(i-a*vc)},${d(n+r*vc)}L${d(e)},${d(t)}L${d(i+a*vc)},${d(n-r*vc)}" stroke-linejoin="round"/>`}function yT(e,t,r){let a=new Map;for(let i of t){let n=i.route;if(!(i.src===i.dst||n.length<6))for(let l of[0,n.length-3]){let s=l===0?i.src:i.dst,o=e[s],c=n[l]-o.x,f=n[l+1]-o.y,p=l===0?3:l-3,h;if(Math.abs(Math.abs(f)-o.h/2)<.5)h=f<0?0:2;else if(Math.abs(Math.abs(c)-o.w/2)<.5)h=c<0?3:1;else continue;let g=s*4+h,u={route:n,at:l,toward:n[h%2===0?p:p+1]},m=a.get(g);m?m.push(u):a.set(g,[u])}}for(let[i,n]of a){if(n.length<2)continue;let l=i>>2,s=i%2===1,o=(s?r[l].h:r[l].w)-2*uT,c=Math.max(0,Math.min(pT,o/(n.length-1)));n.sort((f,p)=>f.toward-p.toward);for(let f=0;f<n.length;f++){let p=(f-(n.length-1)/2)*c;s?n[f].route[n[f].at+1]=e[l].y+p:n[f].route[n[f].at]=e[l].x+p}}}function xT(e,t,r){return jr(e.direction)?Bt(r,a=>m2(e,t,r,a)):m2(e,t,r,!1)}function m2(e,t,r,a){let i=sT(e),n=r.fontSize??16,l=Math.round(n*.875),s=r.measurer??et(r.fontFamily),o=r.padding??8,c=new Map,f=[],p=[];for(let H of i.nodes){let Y=vt(H.cssStyles),_=(Y.bold?1:0)|(Y.italic?2:0),S=Y.fontSize??n,$=Y.fontSize??l,y=H.requirement,E=H.element,x=Ec(ze(`\xAB${y?y.type:"Element"}\xBB`,!1,s,$,4e3),_,s),T=Ec(ze(H.id,!0,s,S,dT),_|1,s),A=y?[["ID",y.requirementId],["Text",y.text],["Risk",y.risk],["Verification",y.verifyMethod]]:[["Type",E.type],["Doc Ref",E.docRef]],M=[],N=0,F=0,U=0;for(let[q,j]of A){if(!j)continue;let Q=Ec(ze(q,!1,s,$,4e3),_,s),K=Ec(ze(j,!0,s,$,fT),_,s),W=Math.max(Q.height,K.height);M.push({key:Q,value:K,height:W}),N=Math.max(N,Q.width),F=Math.max(F,K.width),U+=W+zf}M.length>0&&(U+=2*Al-zf);let D=2*Al+x.height+T.height,I=Math.max(hT,Math.max(x.width,T.width)+2*Ac,M.length>0?N+p2+F+2*Ac:0);c.has(H.id)||c.set(H.id,f.length);let z=Ut(I,D+U);z.seq=f.length,f.push({node:H,style:Y,kind:x,name:T,rows:M,keyWidth:N,headHeight:D,w:I,h:D+U}),p.push(z)}let h=a?"TB":br(i.direction),g=h==="LR"||h==="RL",u=[],m=[],b=[];for(let H of i.edges){let Y=H.start===void 0?void 0:c.get(H.start),_=H.end===void 0?void 0:c.get(H.end);if(Y===void 0||_===void 0)continue;let S=ze(`\xAB${H.type}\xBB`,!1,s,l,4e3);Y===_&&(g?p[Y].h+=2*(Ff+S.height+8):p[Y].w+=2*(Ff+S.width+12)),b.push(H),m.push(S),u.push({src:Y,dst:_,minlen:1,labelW:S.width+12,labelH:S.height+4,route:[],labelX:0,labelY:0})}let w=Gr(p,u,h,{nodeSep:lT,edgeSep:oT,rankSep:cT,portSep:20});yT(p,u,f);let v=Cr(e.title,s,n,4e3),k=v.height>0?v.height+12:0,O=Math.max(w.width,v.width),R=o+(O-w.width)/2,L=o+k,P=Math.ceil(O+2*o),B=Math.ceil(w.height+k+2*o),G="";for(let H=0;H<f.length;H++){let Y=f[H],{w:_,h:S,style:$}=Y,y=-_/2,E=-S/2,x=`<rect x="${d(y)}" y="${d(E)}" width="${d(_)}" height="${d(S)}" fill="var(--_s)" stroke="var(--_b)"${ft($.shape)}/>`+Re(Y.kind,0,E+Al+Y.kind.height/2,` class="pele-stereotype" font-size="${Y.kind.size}" fill="var(--_m)"${$.text}`)+Re(Y.name,0,E+Al+Y.kind.height+Y.name.height/2,` class="pele-label" font-size="${Y.name.size}" font-weight="var(--_hw)"${$.text}`);if(Y.rows.length>0){let T=E+Y.headHeight;x+=`<path class="pele-divider" d="M${d(y)},${d(T)}H${d(-y)}" stroke="var(--_b)"${$.line}/>`;let A=T+Al,M="";for(let N of Y.rows)M+=g2(N.key,y+Ac,A,` class="pele-field" fill="var(--_m)"${$.text}`)+g2(N.value,y+Ac+Y.keyWidth+p2,A,` class="pele-value"${$.text}`),A+=N.height+zf;x+=`<g class="pele-fields" font-size="${Y.rows[0].key.size}">${M}</g>`}G+=`<g class="pele-node ${Y.node.requirement?"pele-requirement":"pele-element"}${It(Y.node.cssClasses.replace(/^default\s?/,""))}" data-id="${Oe(Y.node.id)}" transform="translate(${d(p[H].x+R)},${d(p[H].y+L)})">${x}</g>`}let C="",Z="",ee=new Map;for(let H=0;H<u.length;H++){let Y=u[H],_=b[H],S=m[H],$=_.contains?2*x2:0,y,E=Y.labelX+R,x=Y.labelY+L;if(Y.src===Y.dst){let T=f[Y.src],A=p[Y.src].x+R,M=p[Y.src].y+L,N=ee.get(Y.src)??0;ee.set(Y.src,N+1);let F=(g?T.w:T.h)/2,U=Math.min(F-4,12+N*6),D=Ff+N*8,I=(q,j)=>g?`${d(A+j)},${d(M+T.h/2+q)}`:`${d(A+T.w/2+q)},${d(M+j)}`,z=D/.75;y={d:`M${I($,-U)}C${I(z,-U)} ${I(z,U)} ${I(0,U)}`,sx:g?A-U:A+T.w/2,sy:g?M+T.h/2:M-U,sdx:g?0:-1,sdy:g?-1:0,ex:g?A+U:A+T.w/2,ey:g?M+T.h/2:M+U,edx:g?0:-1,edy:g?-1:0},g?(E=A,x=M+T.h/2+D+4+Y.labelH/2):(E=A+T.w/2+D+4+Y.labelW/2,x=M)}else{let T=Y.route.slice();for(let A=0;A<T.length;A+=3)T[A]+=R,T[A+1]+=L;y=zr(T,void 0,$,0)}C+=`<g class="pele-edge pele-relationship-${_.contains?"contains":"arrow"}" data-id="${Oe(_.id)}"><path d="${y.d}"${_.contains?"":' stroke-dasharray="5 4"'}/>`+(_.contains?gT(y.sx,y.sy,y.sdx,y.sdy):mT(y.ex,y.ey,y.edx,y.edy))+"</g>",Z+=wr(_.id,S,E,x,"")}return{svg:Je("requirement",P,B,n,r,e,Re(v,P/2,o+v.height/2,' class="pele-title" font-weight="var(--_tw)"')+(C?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${C}</g>`:"")+(Z?`<g class="pele-edge-labels" font-size="${l}" fill="var(--_m)">${Z}</g>`:"")+`<g class="pele-nodes">${G}</g>`),width:P,height:B,links:[]}}var ns,Of,kc,zi,KS,ZS,d2,QS,JS,eT,tT,Mc,Pf,rT,y2,iT,lT,oT,cT,Ac,Al,zf,p2,hT,dT,fT,Ff,x2,u2,vc,pT,uT,w2,b2=Xe(()=>{Ei();Ea();tr();zt();pr();ut();wt();ns={REQUIREMENT:"Requirement",FUNCTIONAL_REQUIREMENT:"Functional Requirement",INTERFACE_REQUIREMENT:"Interface Requirement",PERFORMANCE_REQUIREMENT:"Performance Requirement",PHYSICAL_REQUIREMENT:"Physical Requirement",DESIGN_CONSTRAINT:"Design Constraint"},Of={LOW_RISK:"Low",MED_RISK:"Medium",HIGH_RISK:"High"},kc={VERIFY_ANALYSIS:"Analysis",VERIFY_DEMONSTRATION:"Demonstration",VERIFY_INSPECTION:"Inspection",VERIFY_TEST:"Test"},zi={CONTAINS:"contains",COPIES:"copies",DERIVES:"derives",SATISFIES:"satisfies",VERIFIES:"verifies",REFINES:"refines",TRACES:"traces"},KS=1e6,ZS=class{constructor(){he(this,"type","requirement");he(this,"direction","TB");he(this,"requirements",new Map);he(this,"elements",new Map);he(this,"relations",[]);he(this,"classes",new Map);he(this,"title");he(this,"accTitle");he(this,"accDescr");he(this,"newId","");he(this,"newText","");he(this,"newRisk","");he(this,"newVerifyMethod","");he(this,"newElementType","");he(this,"newDocRef","");he(this,"styleCopies",0)}copy(e,t){if(this.styleCopies+=t.length,this.styleCopies>KS)throw new je("Requirement diagram applies too many style declarations.","limit",{type:"requirement"});for(let r of t)e.push(r)}setDirection(e){this.direction=e}addRequirement(e,t){let r=this.requirements.get(e);return r===void 0&&(r={name:e,type:t,requirementId:this.newId,text:this.newText,risk:this.newRisk,verifyMethod:this.newVerifyMethod,cssStyles:[],classes:["default"]},this.requirements.set(e,r)),this.newId=this.newText=this.newRisk=this.newVerifyMethod="",r}setNewReqId(e){this.newId=e}setNewReqText(e){this.newText=e}setNewReqRisk(e){this.newRisk=e}setNewReqVerifyMethod(e){this.newVerifyMethod=e}addElement(e){let t=this.elements.get(e);return t===void 0&&(t={name:e,type:this.newElementType,docRef:this.newDocRef,cssStyles:[],classes:["default"]},this.elements.set(e,t)),this.newElementType=this.newDocRef="",t}setNewElementType(e){this.newElementType=e}setNewElementDocRef(e){this.newDocRef=e}addRelationship(e,t,r){this.relations.push({type:e,src:t,dst:r})}node(e){return this.requirements.get(e)??this.elements.get(e)}setCssStyle(e,t){for(let r of e){let a=this.node(r);if(!t||!a)return;for(let i of t)this.copy(a.cssStyles,i.includes(",")?i.split(","):[i])}}setClass(e,t){for(let r of e){let a=this.node(r);if(a)for(let i of t){a.classes.push(i);let n=this.classes.get(i)?.styles;n&&this.copy(a.cssStyles,n)}}}defineClass(e,t){for(let r of e){let a=this.classes.get(r);a===void 0&&(a={id:r,styles:[],textStyles:[]},this.classes.set(r,a));for(let n of t)n.includes("color")&&a.textStyles.push(n.replace("fill","bgFill")),a.styles.push(n);let i=t.flatMap(n=>n.split(","));for(let n of this.requirements.values())n.classes.includes(r)&&this.copy(n.cssStyles,i);for(let n of this.elements.values())n.classes.includes(r)&&this.copy(n.cssStyles,i)}}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
85
+ `)}},d2=["$end","INVALID","title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","direction_tb","direction_bt","direction_rl","direction_lr","NEWLINE","EOF","RD","STRUCT_START","STRUCT_STOP","STYLE_SEPARATOR","COLONSEP","ID","TEXT","RISK","VERIFYMTHD","REQUIREMENT","FUNCTIONAL_REQUIREMENT","INTERFACE_REQUIREMENT","PERFORMANCE_REQUIREMENT","PHYSICAL_REQUIREMENT","DESIGN_CONSTRAINT","LOW_RISK","MED_RISK","HIGH_RISK","VERIFY_ANALYSIS","VERIFY_DEMONSTRATION","VERIFY_INSPECTION","VERIFY_TEST","ELEMENT","CONTAINS","COPIES","DERIVES","SATISFIES","VERIFIES","REFINES","TRACES","TYPE","DOCREF","STYLE","CLASSDEF","CLASS","ALPHA","COLON","SEMICOLON","PERCENT","MINUS","BRKT","END_ARROW_L","END_ARROW_R","LINE","qString","unqString","COMMA"],QS=new Map([["requirementdiagram",14],["id",19],["text",20],["risk",21],["verifymethod",22],["requirement",23],["functionalrequirement",24],["interfacerequirement",25],["performancerequirement",26],["physicalrequirement",27],["designconstraint",28],["low",29],["medium",30],["high",31],["analysis",32],["demonstration",33],["inspection",34],["test",35],["element",36],["contains",37],["copies",38],["derives",39],["satisfies",40],["verifies",41],["refines",42],["traces",43],["type",44],["docref",45],["style",46],["classdef",47],["class",48]]),JS=/accTitle\s*:\s*/iy,eT=/accDescr\s*:\s*/iy,tT=/accDescr\s*\{\s*/iy,Mc=/direction\s+(?:(TB)|(BT)|(RL)|LR)/gi,Pf=/[\n\r\u2028\u2029]/g,rT=22,y2=new Uint8Array(128);for(let e of`:,\r
86
+ {<>-=`)y2[e.charCodeAt(0)]=1;iT=[ns.REQUIREMENT,ns.FUNCTIONAL_REQUIREMENT,ns.INTERFACE_REQUIREMENT,ns.PERFORMANCE_REQUIREMENT,ns.PHYSICAL_REQUIREMENT,ns.DESIGN_CONSTRAINT,Of.LOW_RISK,Of.MED_RISK,Of.HIGH_RISK,kc.VERIFY_ANALYSIS,kc.VERIFY_DEMONSTRATION,kc.VERIFY_INSPECTION,kc.VERIFY_TEST,"",zi.CONTAINS,zi.COPIES,zi.DERIVES,zi.SATISFIES,zi.VERIFIES,zi.REFINES,zi.TRACES];lT=40,oT=16,cT=56,Ac=14,Al=10,zf=2,p2=12,hT=120,dT=280,fT=240,Ff=26,x2=6,u2=9,vc=4.5,pT=28,uT=14;w2={type:"requirement",math:!0,parse(e,t,r){let a=new ZS;return r&&(a.title=r),nT(e,a),a},render:xT}});var $2={};_t($2,{requirement:()=>w2});var k2=Xe(()=>{b2()});function M2(e){return e>=32&&e<=126&&e!==34&&e!==44}function bT(e){let t=e.length,r=[],a=[],i=[],n=[],l=0,s=0,o=(f,p,h)=>{r.push(f),a.push(e.slice(p,h)),i.push(p),s=h},c=f=>e.slice(s,s+f.length).toLowerCase()===f&&!Qe(e.charCodeAt(s+f.length));for(;s<t;){let f=e.charCodeAt(s),p=s,h=s;if(l===2){if(f===34&&e.charCodeAt(s+1)!==34){n.length>0&&(l=n.pop()),o(5,s,s+1);continue}for(;h<t;){let g=e.charCodeAt(h);if(M2(g)||g===44||g===13||g===10)h++;else if(g===34&&e.charCodeAt(h+1)===34)h+=2;else break}o(7,s,h)}else{if(l===0&&(f|32)===115){let g=c("sankey-beta")?11:c("sankey")?6:0;if(g>0){n.push(l),l=1,o(2,s,s+g);continue}}if(f===10||f===13&&e.charCodeAt(s+1)===10){o(3,s,f===10?s+1:s+2);continue}if(f===44){o(4,s,s+1);continue}if(f===34){n.push(l),l=2,o(5,s,s+1);continue}for(;h<t&&M2(e.charCodeAt(h));)h++;o(6,s,h)}if(h===p)return o(1,s,s),{types:r,texts:a,starts:i}}return o(l===2?7:8,t,t),o(0,t,t),{types:r,texts:a,starts:i}}function A2(e){return e===10||e===13?!1:e<128?e===32||e===9||e===11||e===12:e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288||e===65279}function kT(e){let t=0,r=e.length;for(;t<r&&A2(e.charCodeAt(t));)t++;for(;r>t&&A2(e.charCodeAt(r-1));)r--;return e.slice(t,r).replace($T,`
87
+ `).trim()}function MT(e,t){let{types:r,texts:a,starts:i}=bT(e),n=0,l=f=>{let p=r[n],h=p===1?Wf[r[n-1]]:Wf[p];throw it("sankey",e,i[n],`Expecting ${f}, got '${h}'`)},s=(f,p="")=>{r[n]!==f&&l(`'${Wf[f]}'${p}`),n++},o=()=>{if(r[n]===6)return a[n++];r[n]!==5&&l("'DQUOTE', 'NON_ESCAPED_TEXT'"),n++,r[n]!==7&&l("'ESCAPED_TEXT'");let f=a[n++];return s(5),f},c=()=>o().trim().replaceAll('""','"');for(s(2),s(3);;){let f=c();s(4,", 'NEWLINE', 'EOF'");let p=c();s(4,", 'NEWLINE', 'EOF'");let h=o(),g=t.findOrCreateNode(f),u=t.findOrCreateNode(p);if(t.addLink(g,u,parseFloat(h.trim())),r[n]!==3)break;n++}r[n]===8&&n++,r[n]!==0&&l("'NEWLINE', 'EOF'")}function Bf(e,t){if(e.length>8){e.sort(t);return}for(let r=1;r<e.length;r++){let a=e[r],i=r-1;for(;i>=0&&t(e[i],a)>0;)e[i+1]=e[i],i--;e[i+1]=a}}function vT(e,t){let r=e.nodes.length,a=e.links.map($=>({source:$.source.index,target:$.target.index,value:Number.isFinite($.value)&&$.value>0?$.value:0,thickness:0,sourceY:0,targetY:0})),i=[],n=[];for(let $=0;$<r;$++)i.push([]),n.push([]);a.forEach(($,y)=>{i[$.source].push(y),n[$.target].push(y)});let l=new Int32Array(r),s=new Int32Array(r),o=[];for(let $=0;$<r;$++)s[$]=n[$].length,s[$]===0&&o.push($);for(let $=0;$<o.length;$++){let y=o[$];for(let E of i[y]){let x=a[E].target;l[x]<l[y]+1&&(l[x]=l[y]+1),--s[x]===0&&o.push(x)}}if(o.length<r){let $=0;for(;s[$]===0;)$++;let y=new Uint8Array(r);for(;y[$]===0;){y[$]=1;for(let E of n[$])if(s[a[E].source]>0){$=a[E].source;break}}throw new je(`Sankey diagrams cannot have circular links, and "${e.nodes[$].id}" is part of one.`,"semantic",{type:"sankey"})}let c=1;for(let $=0;$<r;$++)l[$]+1>c&&(c=l[$]+1);let f=new Int32Array(r);for(let $=r-1;$>=0;$--){let y=o[$];for(let E of i[y])f[y]<f[a[E].target]+1&&(f[y]=f[a[E].target]+1)}let p=0;for(let $ of a)$.value>p&&(p=$.value);let h=p>0?1/p:0,g=[],u=new Float64Array(r),m=[];for(let $=0;$<c;$++)m.push([]);let b=c>1?(t.width-t.nodeWidth)/(c-1):0;for(let $=0;$<r;$++){let y;if(t.alignment==="left")y=l[$];else if(t.alignment==="right")y=c-1-f[$];else if(t.alignment==="center"){if(y=l[$],n[$].length===0&&i[$].length>0){y=c;for(let M of i[$])l[a[M].target]-1<y&&(y=l[a[M].target]-1)}}else y=i[$].length>0?l[$]:c-1;let E=0,x=0,T=0,A=0;for(let M of n[$])E+=a[M].value*h,T+=a[M].value;for(let M of i[$])x+=a[M].value*h,A+=a[M].value;u[$]=Math.max(E,x),g.push({layer:y,value:Math.max(T,A),x:y*b,y:0,height:0}),m[y].push($)}let w=1;for(let $ of m)$.length>w&&(w=$.length);let v=w>1?Math.min(t.nodePadding,t.height/(w-1)):t.nodePadding,k=1/0;for(let $ of m){let y=0;for(let E of $)y+=u[E];y>0&&(k=Math.min(k,(t.height-($.length-1)*v)/y))}(!Number.isFinite(k)||k<0)&&(k=0);let O=Math.max(0,t.labelHeight-v),R=$=>{for(let y of m){let E=(y.length-1)*v;for(let x of y)E+=Math.max(u[x]*$,O);if(E>t.height+1e-6)return!1}return!0};if(O>0&&!R(k))if(R(0)){let $=0;for(let y=0;y<40;y++){let E=($+k)/2;R(E)?$=E:k=E}k=$}else O=0;let L=new Float64Array(r);for(let $ of a)$.thickness=$.value*h*k;for(let $ of m){let y=0;for(let x of $)g[x].height=u[x]*k,L[x]=Math.max(0,O-g[x].height)/2,g[x].y=y+L[x],y+=g[x].height+2*L[x]+v;let E=(t.height-y+v)/($.length+1);$.forEach((x,T)=>g[x].y+=E*(T+1))}let P=$=>g[$].y+g[$].height/2,B=new Float64Array(a.length),G=new Float64Array(a.length),C=($,y)=>P(a[$].target)-P(a[y].target)||$-y,Z=($,y)=>P(a[$].source)-P(a[y].source)||$-y,ee=($,y)=>P($)-P(y)||$-y,H=$=>{let y=0;Bf(i[$],C);for(let E of i[$])B[E]=y+a[E].thickness/2,y+=a[E].thickness},Y=$=>{let y=0;Bf(n[$],Z);for(let E of n[$])G[E]=y+a[E].thickness/2,y+=a[E].thickness},_=()=>{for(let $=0;$<r;$++)H($),Y($)},S=($,y,E)=>{for(let T of $){let A=E?n[T]:i[T];if(A.length===0)continue;E?Y(T):H(T);let M=0,N=0,F=0;for(let D of A){let I=E?g[a[D].source].y+B[D]-G[D]:g[a[D].target].y+G[D]-B[D];M+=I*a[D].thickness,N+=a[D].thickness,F+=P(E?a[D].source:a[D].target)-g[T].height/2}let U=N>0?M/N:F/A.length;g[T].y+=(U-g[T].y)*y}Bf($,ee);let x=0;for(let T of $)g[T].y-L[T]<x&&(g[T].y=x+L[T]),x=g[T].y+g[T].height+L[T]+v;x=t.height;for(let T=$.length-1;T>=0;T--){let A=$[T];g[A].y+g[A].height+L[A]>x&&(g[A].y=x-g[A].height-L[A]),x=g[A].y-L[A]-v}};_();for(let $=0;$<AT;$++){let y=Math.pow(.99,$);for(let E=c-2;E>=0;E--)S(m[E],y,!1);_();for(let E=1;E<c;E++)S(m[E],y,!0);_()}for(let $=0;$<a.length;$++)a[$].sourceY=g[a[$].source].y+B[$],a[$].targetY=g[a[$].target].y+G[$];return{nodes:g,links:a}}function C2(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Sc(e,t,r,a,i){let n=e[t];return typeof n=="number"&&n>=a?Math.min(n,i):r}function E2(e,t){let r=e[t];return typeof r=="string"||typeof r=="number"&&Number.isFinite(r)?String(r):""}function S2(e){return Math.abs(e)<1e15?Math.round(e*100)/100:e}function T2(e){return typeof e=="string"?vt([`fill:${e}`]).shape:""}function ST(e,t,r){let a=C2(t.sankey)?t.sankey:{};return Ci(r,Sc(a,"width",600,1,1e4),160,i=>TT(e,a,r,i))}function TT(e,t,r,a){let i=r.fontSize??16,n=Math.round(i*.875),l=r.measurer??et(r.fontFamily),s=r.padding??8,o=Sc(t,"height",400,1,1e4),c=Math.min(Sc(t,"nodeWidth",10,1,200),a),f=t.showValues!==!1,p=E2(t,"prefix"),h=E2(t,"suffix"),g=t.labelStyle==="outlined",u=t.nodeAlignment==="left"||t.nodeAlignment==="right"||t.nodeAlignment==="center"?t.nodeAlignment:"justify",m=typeof t.linkColor=="string"?t.linkColor:"gradient",{nodes:b,links:w}=vT(e,{width:a,height:o,nodeWidth:c,nodePadding:Sc(t,"nodePadding",12,0,200)+(f?ET:0),labelHeight:n*1.15,alignment:u}),v=new Map;if(C2(t.nodeColors))for(let[T,A]of Object.entries(t.nodeColors)){let M=T2(A);M&&v.set(T,M)}let k=T=>v.get(e.nodes[T].id)??"",O=0,R=0;b.forEach(T=>{T.value>R&&(R=T.value,O=T.layer)});let L=0,P=a,B=0,G=o,C="",Z="";b.forEach((T,A)=>{let M=e.nodes[A].id,N=Math.max(T.height,1);Z+=`<rect class="pele-sankey-node" data-id="${Oe(M)}" x="${d(T.x)}" y="${d(T.y)}" width="${d(c)}" height="${d(N)}" rx="${d(Math.min(2,N/2))}" fill="${dt(A)}"${k(A)}/>`;let F=f?`${p}${S2(T.value)}${h}`:"",U=g?T.layer>=O:T.x<a/2,D=l.width(F?`${M} ${F}`:M,n,0),I=U?T.x+c+v2:T.x-v2,z=T.y+T.height/2;L=Math.min(L,U?I:I-D),P=Math.max(P,U?I+D:I),B=Math.min(B,z-n*.75),G=Math.max(G,z+n*.75);let q=` x="${d(I)}" y="${d(z+n*.35)}" text-anchor="${U?"start":"end"}"`,j=Ve(M)+(F?` <tspan class="pele-sankey-value" fill="var(--_m)">${Ve(F)}</tspan>`:"");C+=`<g class="pele-label" data-id="${Oe(M)}">`+(g?`<text${q} fill="none" stroke="var(--_bg)" stroke-width="3" stroke-linejoin="round">${Ve(M)}${F?" "+Ve(F):""}</text>`:"")+`<text${q}>${j}</text></g>`});let ee=m==="gradient"||m==="source"||m==="target"?"":T2(m),H="";for(let T of w){let A=m==="target"?T.target:T.source,M=Math.max(T.thickness,1)/2,N=b[T.source].x+c,F=b[T.target].x,U=d((N+F)/2),D=Oe(e.nodes[T.source].id),I=Oe(e.nodes[T.target].id);H+=`<path class="pele-sankey-link" data-id="${D}-&gt;${I}" d="M${d(N)},${d(T.sourceY-M)}C${U},${d(T.sourceY-M)} ${U},${d(T.targetY-M)} ${d(F)},${d(T.targetY-M)}L${d(F)},${d(T.targetY+M)}C${U},${d(T.targetY+M)} ${U},${d(T.sourceY+M)} ${d(N)},${d(T.sourceY+M)}Z" fill="${dt(A)}"${ee||k(A)}><title>${D} \u2192 ${I}: ${Oe(p)}${S2(T.value)}${Oe(h)}</title></path>`}let Y=ze(e.title,!1,l,i,Nt(r),1),_=Y.height>0?Y.height+12:0,S=Math.max(P-L,Y.width),$=s-L+(S-(P-L))/2,y=s+_-B,E=Math.ceil(S+2*s),x=Math.ceil(G-B+_+2*s);return{svg:Je("sankey",E,x,i,r,e,Re(Y,E/2,s+Y.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${d($)},${d(y)})"><g class="pele-sankey-links" fill-opacity="0.4">${H}</g><g class="pele-sankey-nodes">${Z}</g><g class="pele-labels" font-size="${n}">${C}</g></g>`),width:E,height:x,links:[]}}var wT,Wf,$T,AT,v2,ET,_2,I2=Xe(()=>{tr();zt();ut();wt();wT=class{constructor(){he(this,"type","sankey");he(this,"nodes",[]);he(this,"links",[]);he(this,"title");he(this,"accTitle");he(this,"accDescr");he(this,"lookup",new Map)}findOrCreateNode(e){let t=this.lookup.get(e);return t===void 0&&(t={id:e,index:this.nodes.length},this.lookup.set(e,t),this.nodes.push(t)),t}addLink(e,t,r){this.links.push({source:e,target:t,value:r})}},Wf=["$end","STUCK","SANKEY","NEWLINE","COMMA","DQUOTE","NON_ESCAPED_TEXT","ESCAPED_TEXT","EOF"];$T=/[\n\r]+/g;AT=6;v2=6,ET=15;_2={type:"sankey",parse(e,t,r){let a=new wT;return r&&(a.title=r),MT(kT(e),a),a},render:ST}});var N2={};_t(N2,{sankey:()=>_2});var R2=Xe(()=>{I2()});function vl(e,t,r,a,i,n=0){if(e===""||t<=0)return;let l=i.width(e,r,n);if(l<=t)return{text:e,size:r,width:l};let s=Math.max(a,Math.floor(r*t/l));for(;s>=a;){if(l=i.width(e,s,n),l<=t)return{text:e,size:s,width:l};s--}let o=Array.from(e),c=0,f=o.length-1;for(;c<f;){let h=c+f+1>>1;i.width(o.slice(0,h).join("").trimEnd()+"\u2026",a,n)<=t?c=h:f=h-1}if(c===0)return;let p=o.slice(0,c).join("").trimEnd()+"\u2026";return l=i.width(p,a,n),l<=t?{text:p,size:a,width:l}:void 0}var Yf=Xe(()=>{});function fn(e,t,r,a,i=0){let n=[];for(let c of e.split(`
88
+ `)){let f=Array.from(c);f.length===0&&n.push("");let p=0;for(;p<f.length;){let h=v=>t.width(f.slice(p,p+v).join(""),r,i)<=a,g=1;for(;g<f.length-p&&h(g);)g=Math.min(f.length-p,g*2);let u=1;for(;u<g;){let v=Math.ceil((u+g)/2);h(v)?u=v:g=v-1}let m=u,b=p+m<f.length;if(b&&!Hf.test(f[p+m])){for(let v=m-1;v>0;v--)if(Hf.test(f[p+v])){m=v+1;break}}let w=f.slice(p,p+m).join("");for(n.push(b&&w.trimEnd()||w),p+=m;b&&p<f.length&&Hf.test(f[p]);)p++}}e===""&&(n.length=0);let l=n.map(c=>t.width(c,r,i)),s=0;for(let c of l)s=Math.max(s,c);let o=Math.round(r*1.5);return{lines:n.map((c,f)=>[{text:c,style:i,width:l[f]}]),widths:l,width:s,height:n.length*o,size:r,lineHeight:o}}function pn(e,t,r){if(e.width<=r)return e;let a=[],i=[];for(let s=0;s<e.lines.length;s++){if(e.widths[s]<=r){a.push(e.lines[s]),i.push(e.widths[s]);continue}let o=[],c=0,f=()=>{a.push(o),i.push(c),o=[],c=0};for(let p of e.lines[s]){if(p.icon!==void 0||p.math){o.length&&c+p.width>r&&f(),o.push(p),c+=p.width;continue}for(let h of Array.from(p.text)){let g=o[o.length-1],u=g&&g.icon===void 0&&g.math===void 0&&g.style===p.style,m=t.width(u?g.text+h:h,e.size,p.style)-(u?g.width:0);o.length&&c+m>r&&(f(),g=void 0,m=t.width(h,e.size,p.style)),g&&g.icon===void 0&&g.math===void 0&&g.style===p.style?(g.text+=h,g.width+=m):o.push({text:h,style:p.style,width:m}),c+=m}}(o.length||!e.lines[s].length)&&f()}let n=0;for(let s of i)n=Math.max(n,s);let l={...e,lines:a,widths:i,width:n,height:a.length*e.lineHeight};return e.heights?Us(l):l}function yi(e,t,r,a){let i=li(e),n="<text"+Aa(a,i),l="";for(let s=0;s<e.lines.length;s++){let o=e.lines[s],c=r+(s+.5)*e.lineHeight;if(o.some(p=>p.icon!==void 0)){let p=e.widths[s];l+=Re({...e,lines:[o],widths:[p],width:p,height:e.lineHeight},t+p/2,c,a);continue}let f="";for(let p of o){let h=Ya(p.style&~i);f+=h?`<tspan${h}>${Ve(p.text)}</tspan>`:Ve(p.text)}f!==""&&(l+=`${n} x="${d(t)}" y="${d(c+e.size*.35)}" text-anchor="start" xml:space="preserve">${f}</text>`)}return l}var Hf,un=Xe(()=>{ut();Hf=/\s/});function El(e,t,r,a,i){let n=e.packet?.[t];return typeof n=="number"&&n>=a?Math.min(n,i):r}function Uf(e){return new je(e,"semantic",{type:"packet"})}function _T(e,t,r){let a=Math.floor(El(t,"bitsPerRow",32,1,4096)),i=[],n=-1,l=[],s=1;for(let o of e.blocks){let{start:c,end:f,bits:p}=o;if(c!==void 0&&f!==void 0&&f<c)throw Uf(`Packet block ${c} - ${f} is invalid. End must be greater than start.`);if(c??(c=n+1),c!==n+1)throw Uf(`Packet block ${c} - ${f??c} is not contiguous. It should start from ${n+1}.`);if(p===0)throw Uf(`Packet block ${c} is invalid. Cannot have a zero bit field.`);for(f??(f=c+(p??1)-1),p??(p=f-c+1),n=f;l.length<=a+1&&i.length<CT;){let h=s*a-1;if(f<=h){l.push({start:c,end:f,bits:p,label:o.label}),f===h&&(i.push(l),l=[],s++);break}l.push({start:c,end:h,bits:h-c,label:o.label}),i.push(l),l=[],s++,c=h+1,p=f-c}}return l.length>0&&i.push(l),{type:"packet",title:e.title||r,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
89
+ `):void 0,bitsPerRow:a,rows:i}}function IT(e){let t=new Zt(Gt(e,L2,"packet"),L2,"packet"),r={$type:"Packet",blocks:[]},a=()=>{if(t.kind!==-1)for(t.kind!==10&&t.fail("a line break or the end of input");t.kind===10;)t.i++};for(;t.kind===10;)t.i++;for(t.accept(0)||t.expect(1);t.kind!==-1;)switch(t.kind){case 10:t.i++;break;case 5:r.accDescr=Kt(t.take()),a();break;case 6:r.accTitle=Vt(t.take()),a();break;case 7:r.title=Xt(t.take()),a();break;case 8:case 3:{let i={$type:"PacketBlock",label:""};t.accept(3)?i.bits=Number(t.expect(8)):(i.start=Number(t.take()),t.accept(2)&&(i.end=Number(t.expect(8)))),t.expect(4),i.label=$r(t.expect(9)),r.blocks.push(i),a();break}default:t.fail("a field, a title, or a line break")}return r}function NT(e,t,r){return Bt(r,a=>RT(e,t,r,a))}function RT(e,t,r,a){let i=r.fontSize??16,n=Math.round(i*.875),l=Math.round(i*.625),s=r.measurer??et(r.fontFamily),o=r.padding??8,c=t.packet??{},f=El(t,"rowHeight",32,1,400),p=El(t,"bitWidth",32,1,400),h=El(t,"paddingX",5,0,400),g=El(t,"paddingY",5,0,400),u=c.showBits!==!1,m=c.bitOrder==="descending",b=e.bitsPerRow,w=e.rows;if(a){let E=Math.max(1,Math.floor(((r.maxWidth??320)-2*o)/Math.min(p,18)));b=Math.min(b,Math.max(8,2**Math.floor(Math.log2(E))));let x=e.rows[e.rows.length-1],T=x?.[x.length-1]?.end??0;Math.ceil((T+1)/b)>1e4&&(b=e.bitsPerRow),p=Math.min(p,Math.max(18,((r.maxWidth??320)-2*o)/b));let A=N=>N.bits===N.end-N.start,M=[];for(let N of e.rows)for(let F of N){let U=M[M.length-1];U&&A(U)&&A(F)&&U.label===F.label&&F.start===U.end+1&&F.start%e.bitsPerRow===0?(U.end=F.end,U.bits=U.end-U.start):M.push({...F})}w=[];for(let N of M)for(let F=N.start;F<=N.end;){let U=Math.min(N.end,(Math.floor(F/b)+1)*b-1),D=Math.floor(F/b);(w[D]??(w[D]=[])).push({...N,start:F,end:U}),F=U+1}}let v=new Map;if(a)for(let E of w)for(let x of E){let T=Math.max(1,(x.end-x.start+1)*p-Math.min(h,p-1)-6),A=fn(At(x.label).trim(),s,n,T);v.set(x,A)}let k=u?l+4:0,O=w.map(E=>{let x=f;if(a)for(let T of E)x=Math.max(x,v.get(T).height+10);return x}),R=[],L=0;for(let E of O)R.push(L),L+=k+E+g;w.length&&(L-=g);let P=Math.min(h,p-1),B=w.length>0?b*p-P:0,G=ze(e.title,!1,s,i,a?Nt(r):4e3,1),C=G.height>0?G.height+(L>0?12:0):0,Z=new Map,ee=(E,x)=>{let T=Z.get(E);return T||Z.set(E,T=new Map),T.has(x)||T.set(x,vl(At(E).trim(),x,n,Math.round(i*.5),s)),T.get(x)},H=o+Math.max(0,(G.width-B)/2),Y="",_="";w.forEach((E,x)=>{let T=o+R[x]+k,A=O[x];for(let M of E){let N=M.end-M.start+1,F=M.start%b,U=H+(m?b-F-N:F)*p,D=N*p-P,I=a?void 0:ee(M.label,D-6);if(Y+=`<g class="pele-node" data-id="${M.start}-${M.end}"><rect x="${d(U)}" y="${d(T)}" width="${d(D)}" height="${d(A)}" fill="var(--_s)" stroke="var(--_b)"${nt}/>`+(a?Re(v.get(M),U+D/2,T+A/2,""):I&&I.size<=A?`<text x="${d(U+D/2)}" y="${d(T+A/2+I.size*.35)}"${I.size===n?"":` font-size="${d(I.size)}"`}>${Ve(I.text)}</text>`:"")+"</g>",!u)continue;let z=m?M.end:M.start,q=m?M.start:M.end;N===1?_+=`<text x="${d(U+D/2)}" y="${d(T-4)}" text-anchor="middle">${z}</text>`:_+=`<text x="${d(U)}" y="${d(T-4)}">${z}</text><text x="${d(U+D)}" y="${d(T-4)}" text-anchor="end">${q}</text>`}});let S=Math.ceil(Math.max(B,G.width)+2*o),$=Math.ceil(L+C+2*o),y=(Y?`<g class="pele-packet-fields" font-size="${n}" text-anchor="middle">${Y}</g>`:"")+(_?`<g class="pele-packet-bits" font-size="${l}" fill="var(--_m)">${_}</g>`:"")+Re(G,S/2,$-o-G.height/2,' class="pele-title" font-weight="var(--_tw)"');return{svg:Je("packet",S,$,i,r,e,y),width:S,height:$,links:[]}}var CT,L2,D2,O2=Xe(()=>{Yf();un();zt();Vr();ut();wt();CT=1e4;L2=[{name:"packet-beta",pattern:"packet-beta"},or("packet"),{name:"-",pattern:"-",longer:[jt]},{name:"+",pattern:"+"},{name:":",pattern:":"},ur,rr,ar,{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y},Xr,Rr,Lr,jt,sr,lr];D2={type:"packet",parse:(e,t,r)=>_T(IT(e),t,r),render:NT}});var P2={};_t(P2,{packet:()=>D2});var z2=Xe(()=>{O2()});function W2(e){return new je(e,"semantic",{type:"radar"})}function LT(e,t){let r=e.axes.map(n=>({name:n.name,label:n.label??n.name})),a=e.curves.map(n=>{let l;if(n.entries[0].axis===void 0)l=n.entries.map(s=>s.value);else{if(r.length===0)throw W2("Axes must be populated before curves for reference entries");let s=new Map;for(let o of n.entries)o.axis!==void 0&&!s.has(o.axis.$refText)&&s.set(o.axis.$refText,o.value);l=r.map(o=>{let c=s.get(o.name);if(c===void 0)throw W2("Missing entry for axis "+o.label);return c})}return{name:n.name,label:n.label??n.name,entries:l}}),i={showLegend:!0,ticks:5,max:null,min:0,graticule:"circle"};for(let n of e.options)n.name==="showLegend"?i.showLegend=n.value:n.name==="graticule"?i.graticule=n.value:i[n.name]=n.value;return i.ticks>F2&&(i.ticks=F2),{type:"radar",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
90
+ `):void 0,axes:r,curves:a,options:i}}function B2(e,t){let r=t;for(let a=e.charCodeAt(r);a>=48&&a<=57;a=e.charCodeAt(r))r++;return r}function DT(e,t){(t<Xf||t>=Tc)&&(Xf=t,Tc=B2(e,t));let r=Tc;if(r===t)return-1;let a=e.charCodeAt(r)===46;if(a){let i=B2(e,r+1),n=i-r-1;if(n>0&&e.charCodeAt(i)!==46)return i;if(n>1)return i-1}return e.charCodeAt(t)===48?t+1:a?r-1>t?r-1:-1:r}function OT(e,t){return Gf.lastIndex=t,Gf.test(e)&&(Cc===-2&&(Cc=e.lastIndexOf("}")),Gf.lastIndex>Cc)?-1:(qf.lastIndex=t,qf.test(e)?qf.lastIndex:-1)}function PT(e){return Xf=Tc=0,Cc=-2,Gt(e,U2,"radar")}function zT(e){let t=new Zt(PT(e),U2,"radar"),r={$type:"Radar",axes:[],curves:[],options:[]},a=()=>{for(;t.kind===23;)t.i++},i=()=>{t.kind!==-1&&(t.kind!==23&&t.fail("a line break or the end of input"),a())},n=()=>{if(!t.accept(11))return;let p=$r(t.expect(21));return t.expect(12),p},l=p=>{if(!p)return{$type:"Entry",value:Number(t.expect(20))};let h={$refText:t.expect(22)};return t.accept(9),{$type:"Entry",axis:h,value:Number(t.expect(20))}},s=()=>{let p=t.expect(22),h=n(),g={$type:"Curve",name:p,entries:[]};h!==void 0&&(g.label=h),t.expect(13),a(),t.kind!==20&&t.kind!==22&&t.fail("a number or an axis name");let u=t.kind===22;for(g.entries.push(l(u));t.accept(10);)a(),g.entries.push(l(u));return a(),t.expect(14),g},o=()=>{let p={$type:"Axis",name:t.expect(22)},h=n();return h!==void 0&&(p.label=h),p},c=()=>{let p=t.kind,h=t.take(),g;return p===2?g=t.expect(16)==="true":p===3?g=t.expect(15):g=Number(t.expect(20)),{$type:"Option",name:h,value:g}},f=()=>t.kind===2||t.kind===5||t.kind===7||t.kind===8||t.kind===3;for(a(),t.accept(0)||(t.expect(1),t.accept(9)),a();t.kind!==-1;)switch(t.kind){case 23:t.i++;break;case 17:r.accDescr=Kt(t.take()),i();break;case 18:r.accTitle=Vt(t.take()),i();break;case 19:r.title=Xt(t.take()),i();break;case 6:t.i++;do r.axes.push(o());while(t.accept(10));break;case 4:t.i++;do r.curves.push(s());while(t.accept(10));break;default:for(f()||t.fail("an axis, a curve, an option, a title, or a line break"),r.options.push(c());t.accept(10);)f()||t.fail("an option"),r.options.push(c())}return r}function xi(e,t,r,a,i){let n=e.radar?.[t];return typeof n=="number"&&n>=a?Math.min(n,i):r}function FT(e,t,r,a){let i=Math.min(Math.max(e,t),r);return a*(i-t)/(r-t)}function WT(e,t){let r=e.length,a=`M${d(e[0].x)},${d(e[0].y)}`;for(let i=0;i<r;i++){let n=e[(i-1+r)%r],l=e[i],s=e[(i+1)%r],o=e[(i+2)%r];a+=` C${d(l.x+(s.x-n.x)*t)},${d(l.y+(s.y-n.y)*t)} ${d(s.x-(o.x-l.x)*t)},${d(s.y-(o.y-l.y)*t)} ${d(s.x)},${d(s.y)}`}return a+" Z"}function H2(e){let t="";for(let r of e)t+=(t?" ":"")+d(r.x)+","+d(r.y);return t}function BT(e,t,r){let a=xi(t,"width",320,1,4e3);return Ci(r,a,160,(i,n)=>YT(e,t,r,i,xi(t,"height",320,1,4e3)*i/a,n))}function YT(e,t,r,a,i,n){let l=r.fontSize??16,s=Math.round(l*.875),o=r.measurer??et(r.fontFamily),c=r.padding??8,f=xi(t,"axisScaleFactor",1,0,10),p=xi(t,"axisLabelFactor",1.05,0,10),h=xi(t,"curveTension",.17,0,1),g=Math.min(a,i)/2,{axes:u,curves:m}=e,{ticks:b,graticule:w,min:v}=e.options,k=u.length,O=u.map((D,I)=>{let z=2*Math.PI*I/k-Math.PI/2;return{x:Math.cos(z),y:Math.sin(z)}}),R=e.options.max;if(R===null){R=-1/0;for(let D of m)for(let I of D.entries)I>R&&(R=I)}let L=-a/2-xi(t,"marginLeft",16,0,2e3),P=a/2+xi(t,"marginRight",16,0,2e3),B=-i/2-xi(t,"marginTop",16,0,2e3),G=i/2+xi(t,"marginBottom",16,0,2e3),C="";for(let D=0;D<b;D++){let I=Math.min(g,g*(D+1)/b);w==="circle"?C+=`<circle r="${d(I)}"/>`:C+=`<polygon points="${H2(O.map(z=>({x:z.x*I,y:z.y*I})))}"/>`}let Z="",ee="";O.forEach((D,I)=>{let z=g*f;Z+=`M0,0L${d(D.x*z)},${d(D.y*z)}`;let q=ze(u[I].label,!1,o,s,4e3),j=g*p+6,Q=D.x*j+(D.x>.01?q.width/2:D.x<-.01?-q.width/2:0),K=D.y*j+(D.y>.01?q.height/2:D.y<-.01?-q.height/2:0);ee+=`<g class="pele-axis-label" data-id="${Oe(u[I].name)}">${Re(q,Q,K,"")}</g>`,L=Math.min(L,Q-q.width/2),P=Math.max(P,Q+q.width/2),B=Math.min(B,K-q.height/2),G=Math.max(G,K+q.height/2)});let H="";m.forEach((D,I)=>{if(D.entries.length!==k)return;let z=D.entries.map((Q,K)=>{let W=FT(Q,v,R,g),X=Number.isFinite(W)?W:0;return{x:O[K].x*X,y:O[K].y*X}}),q=dt(I),j=` class="pele-curve" data-id="${Oe(D.name)}" fill="${q}" stroke="${q}"`;H+=w==="circle"?`<path${j} d="${WT(z,h)}"/>`:`<polygon${j} points="${H2(z)}"/>`});let Y=e.options.showLegend?m.map(D=>ze(D.label,!1,o,s,4e3)):[],_=0;for(let D of Y)_=Math.max(_,D.width);let S=Y.length*jf,$=n?-(ss+8+_)/2:P+Y2,y=n?G+Y2/2:-S/2;Y.length>0&&n?(L=Math.min(L,$),P=Math.max(P,-$),G=y+S):Y.length>0&&(P=$+ss+8+_,B=Math.min(B,-S/2),G=Math.max(G,S/2));let E="";Y.forEach((D,I)=>{let z=y+I*jf+jf/2,q=dt(I);E+=`<g class="pele-legend-item" data-id="${Oe(m[I].name)}"><rect x="${d($)}" y="${d(z-ss/2)}" width="${ss}" height="${ss}" rx="2" fill="${q}" fill-opacity="0.4" stroke="${q}"/>`+Re(D,$+ss+8+D.width/2,z,"")+"</g>"});let x=ze(e.title,!1,o,l,Nt(r),1),T=x.height>0?x.height+8:0,A=Math.max(P-L,x.width),M=Math.ceil(A+2*c),N=Math.ceil(G-B+T+2*c),F=`translate(${d(c+(A-(P-L))/2-L)},${d(c+T-B)})`,U=Re(x,M/2,c+x.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="${F}">`+(C?`<g class="pele-graticule" fill="none" stroke="var(--_a)">${C}</g>`:"")+(Z?`<path class="pele-axes" d="${Z}" fill="none" stroke="var(--_b)"/>`:"")+(H?`<g class="pele-curves" fill-opacity="0.2" stroke-width="1.5" stroke-linejoin="round">${H}</g>`:"")+(ee?`<g class="pele-axis-labels" font-size="${s}">${ee}</g>`:"")+(E?`<g class="pele-legend" font-size="${s}">${E}</g>`:"")+"</g>";return{svg:Je("radar",M,N,l,r,e,U),width:M,height:N,links:[]}}var F2,Xf,Tc,qf,Gf,Cc,Vf,gn,mn,U2,ss,jf,Y2,q2,G2=Xe(()=>{zt();Vr();ut();wt();F2=32;Xf=0,Tc=0;qf=ur.pattern,Gf=/[\t ]*accDescr\s*{/y,Cc=-2;Vf={name:"ID",pattern:/[\w]([-\w]*\w)?/y},gn=e=>({name:e,pattern:e,longer:[Vf]}),mn=e=>({name:e,pattern:e}),U2=[mn("radar-beta:"),{...or("radar-beta"),longer:[Vf]},gn("showLegend"),gn("graticule"),gn("curve"),gn("ticks"),gn("axis"),gn("max"),gn("min"),mn(":"),mn(","),mn("["),mn("]"),mn("{"),mn("}"),{name:"GRATICULE",pattern:/circle|polygon/y},{name:"BOOLEAN",pattern:/true|false/y},{...ur,match:OT},rr,ar,{name:"NUMBER",pattern:/(?:[0-9]+\.[0-9]+(?!\.))|(?:0|[1-9][0-9]*(?!\.))/y,match:DT},Xr,Vf,Rr,Lr,jt,sr,lr];ss=12,jf=26,Y2=24;q2={type:"radar",parse:(e,t,r)=>LT(zT(e),r),render:BT}});var j2={};_t(j2,{radar:()=>q2});var X2=Xe(()=>{G2()});function HT(e){let t=[],r=[];for(let a of e){let i=a.type==="Leaf",n={name:a.name,children:i?void 0:[]};for(n.classSelector=a.classSelector,a.cssCompiledStyles&&(n.cssCompiledStyles=a.cssCompiledStyles),i&&a.value!==void 0&&(n.value=a.value);r.length>0&&r[r.length-1].level>=a.level;)r.pop();r.length===0?t.push(n):r[r.length-1].node.children.push(n),i||r.push({node:n,level:a.level})}return t}function UT(e,t){let r=new Map;for(let i of e.TreemapRows){if(i.$type!=="ClassDefStatement")continue;let n=r.get(i.className);n||r.set(i.className,n=[]);let l=(i.styleText??"").replace(/\\,/g,"\xA7\xA7\xA7").replace(/,/g,";").replace(/§§§/g,",");for(let s of l.split(";"))n.push(s)}let a=[];for(let i of e.TreemapRows){if(i.$type!=="TreemapRow")continue;let n=i.item,l=n.classSelector?r.get(n.classSelector):void 0;a.push({level:i.indent??0,name:n.name,type:n.$type,value:n.$type==="Leaf"?n.value:void 0,classSelector:n.classSelector,cssCompiledStyles:l&&l.length>0?l:void 0})}return{type:"treemap",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
91
+ `):void 0,roots:HT(a),classes:r}}function GT(e){let t=new Zt(Gt(e,V2,"treemap"),V2,"treemap"),r=t.kinds,a={$type:"Treemap",TreemapRows:[]},i=()=>t.accept(5)?t.expect(12):void 0;for(t.expect(3);t.kind!==-1;){let n=t.kind;if(n===0){a.accDescr=Kt(t.take());continue}if(n===1){a.accTitle=Vt(t.take());continue}if(n===2){a.title=Xt(t.take());continue}n!==8&&n!==14&&n!==4&&t.fail("a node, a class definition, or a title");let l=n===8?t.take().length:void 0;if(t.kind===4){let h=qT.exec(t.take()),g={$type:"ClassDefStatement",className:h[1]};h[2]&&(g.styleText=h[2]),l!==void 0&&(g.indent=l),a.TreemapRows.push(g);continue}let s=t.expect(14).slice(1,-1),o=r[t.i]===8?t.i+1:t.i,c;r[o]===6||r[o]===7?(t.i=o+1,t.accept(8),c={$type:"Leaf",name:s,value:parseFloat(t.expect(13).replace(/,/g,""))}):c={$type:"Section",name:s};let f=i();f!==void 0&&(c.classSelector=f);let p={$type:"TreemapRow",item:c};l!==void 0&&(p.indent=l),a.TreemapRows.push(p)}return a}function Z2(e){let t="";for(let r=e.length;r>0;r-=3)t=e.slice(Math.max(0,r-3),r)+(t?","+t:"");return t}function jT(e){let t=K2.exec(e==="$0,0"?"$,":e)??K2.exec(","),r=t[1]==="+",a=t[3]!==void 0,i=t[4]===void 0?void 0:Math.min(Number(t[4]),20),n=t[6]??"";return l=>{let s=Math.abs(l),o,c="";if(n==="f"?o=s.toFixed(i??6):n==="%"?(o=(s*100).toFixed(i??6),c="%"):n==="d"?o=Math.round(s).toFixed(0):n==="e"?o=s.toExponential(i??6):o=String(Number(s.toPrecision(Math.max(1,i??12)))),t[5]&&o.includes(".")&&!o.includes("e")&&(o=o.replace(/\.?0+$/,"")),a&&!o.includes("e")){let f=o.indexOf(".");o=f===-1?Z2(o):Z2(o.slice(0,f))+o.slice(f)}return(l<0?"-":r?"+":"")+(t[2]??"")+o+c}}function Q2(e,t,r){let a=e.children===void 0&&Number.isFinite(e.value)&&e.value>0?e.value:0;return{node:e,parent:t,series:r,value:a,children:[],x:0,y:0,w:0,h:0}}function XT(e,t,r,a,i,n,l){let s=t,o=0;for(;o<e.length;){let c=i*n/s,f=Math.min(i,n),p=e[o].value*c,h=p,g=Math.max(f*f*h/(p*p),p*p/(f*f*h)),u=o+1;for(;u<e.length;){let w=e[u].value*c,v=p+w,k=Math.max(f*f*h/(v*v),v*v/(f*f*w));if(k>g)break;g=k,p=v,u++}let m=p/f,b=0;for(let w=o;w<u;w++){let v=e[w],k=w===u-1?f-b:v.value*c/m,O=i>=n?r:r+b,R=i>=n?a+b:a,L=Math.round(O+l/2),P=Math.round(R+l/2);v.x=L,v.y=P,v.w=Math.round(O+(i>=n?m:k)-l/2)-L,v.h=Math.round(R+(i>=n?k:m)-l/2)-P,b+=k,s-=v.value}i>=n?(r+=m,i-=m):(a+=m,n-=m),o=u}}function VT(e,t,r,a){let i=e.map((p,h)=>Q2(p,void 0,h)),n=i.slice();for(let p=0;p<n.length;p++){let h=n[p];for(let g of h.node.children??[]){let u=Q2(g,h,h.series);h.children.push(u),n.push(u)}}for(let p=n.length-1;p>=0;p--){let h=n[p];h.parent&&(h.parent.value+=h.value)}let{gap:l,header:s,side:o}=a,c=[],f=(p,h,g,u,m)=>{if(u<=0||m<=0)return;let b=p.filter(v=>v.value>0).sort((v,k)=>k.value-v.value),w=0;for(let v of b)w+=v.value;if(!(b.length===0||!Number.isFinite(w))){XT(b,w,h-l/2,g-l/2,u+l,m+l,l);for(let v of b)v.w>0&&v.h>0&&c.push(v)}};f(i,0,0,t,r);for(let p=0;p<c.length;p++){let h=c[p];h.children.length>0&&f(h.children,h.x+o,h.y+s,h.w-2*o,h.h-s-o)}return c}function Nc(e,t,r,a,i){let n=e.treemap?.[t];return typeof n=="number"&&n>=a?Math.min(n,i):r}function KT(e,t,r){let a=r.fontSize??16,i=Math.round(a*.875),n=Math.round(a*.75),l=Math.round(a*.5625),s=r.measurer??et(r.fontFamily),o=t.treemap??{},c=r.padding??Nc(t,"diagramPadding",8,0,2e3),f=Math.round(_i(r,Nc(t,"nodeWidth",64,1,400)*10,200,2*c)),p=Math.round(Nc(t,"nodeHeight",40,1,400)*10),h=o.showValues!==!1,g=jT(typeof o.valueFormat=="string"?o.valueFormat:","),u=VT(e.roots,f,p,{gap:Nc(t,"padding",4,0,200),header:Kf,side:_c}),m=ze(e.title,!1,s,a,Nt(r),1),b=m.height>0?m.height+8:0,w=c+Math.max(0,(m.width-f)/2),v=c+b,k="",O="";for(let B of u){let G=B.node,C=vt(G.cssCompiledStyles??[]),Z=dt(B.series),ee=w+B.x,H=v+B.y,Y=At(G.name).trim(),_=h?g(B.value):"",S=`data-id="${Oe(G.name)}">`,$=`<rect x="${d(ee)}" y="${d(H)}" width="${d(B.w)}" height="${d(B.h)}" fill="${Z}"`;if(G.children!==void 0){let A="";if(B.h>=Kf){let N=B.w-2*_c-4,F=_?s.width(_,n,0):0,U=F>0&&N-F-12>=3*i,D=vl(Y,U?N-F-12:N,i,i,s,1),I=H+Kf/2+1;D&&(A+=`<text x="${d(ee+_c+2)}" y="${d(I+i*.35)}" font-weight="var(--_hw)"${C.text}>${Ve(D.text)}</text>`),U&&(A+=`<text class="pele-value" x="${d(ee+B.w-_c-2)}" y="${d(I+n*.35)}" font-size="${n}" text-anchor="end" fill="var(--_m)"${C.text}>${Ve(_)}</text>`)}let M=/[";]fill:/.test(C.shape)?"":' fill-opacity="0.12"';k+=`<g class="pele-node pele-section${It(G.classSelector??"")}" ${S}${$}${ft(`${M} stroke="${Z}"${C.shape}`)}/>${A}</g>`;continue}let y="",E=B.w-8,x=Math.min(a,Math.floor((B.h-4)/Ic)),T=x>=l?vl(Y,E,x,l,s):void 0;if(T){let A=d(ee+B.w/2),M=H+B.h/2,N=Math.max(l,Math.round(T.size*.8)),F=(T.size+N)*Ic;if(_&&F<=B.h-4&&s.width(_,N,0)<=E){let U=M-F/2+T.size*Ic/2,D=M+F/2-N*Ic/2;y=`<text x="${A}" y="${d(U+T.size*.35)}" font-size="${d(T.size)}"${C.text}>${Ve(T.text)}</text><text class="pele-value" x="${A}" y="${d(D+N*.35)}" font-size="${d(N)}"${C.text}>${Ve(_)}</text>`}else y=`<text x="${A}" y="${d(M+T.size*.35)}" font-size="${d(T.size)}"${C.text}>${Ve(T.text)}</text>`}O+=`<g class="pele-node pele-leaf${It(G.classSelector??"")}" ${S}${$}${ft(C.shape)}/>${y}</g>`}let R=Math.ceil(Math.max(f,m.width)+2*c),L=Math.ceil(p+b+2*c),P=Re(m,R/2,c+m.height/2,' class="pele-title" font-weight="var(--_tw)"')+(k?`<g class="pele-sections" font-size="${i}">${k}</g>`:"")+(O?`<g class="pele-leaves" text-anchor="middle" fill="var(--_bg)">${O}</g>`:"");return{svg:Je("treemap",R,L,a,r,e,P),width:R,height:L,links:[]}}var V2,qT,K2,Kf,_c,Ic,J2,ey=Xe(()=>{Yf();zt();Vr();ut();wt();V2=[ur,rr,ar,{name:"TREEMAP_KEYWORD",pattern:/treemap-beta|treemap/y},{name:"CLASS_DEF",pattern:/classDef\s+([a-zA-Z_][a-zA-Z0-9_]+)(?:\s+([^;\r\n]*))?(?:;)?/y},{name:"STYLE_SEPARATOR",pattern:/:::/y},{name:"SEPARATOR",pattern:/:/y},{name:"COMMA",pattern:/,/y},{name:"INDENTATION",pattern:/[ \t]{1,}/y},{name:"WS",pattern:/[ \t]+/y,hidden:!0},{name:"ML_COMMENT",pattern:/\%\%[^\n]*/y,hidden:!0},{name:"NL",pattern:/\r?\n/y,hidden:!0},{name:"ID2",pattern:/[a-zA-Z_][a-zA-Z0-9_]*/y},{name:"NUMBER2",pattern:/[0-9_\.\,]+/y},{name:"STRING2",pattern:/"[^"]*"|'[^']*'/y}],qT=/classDef\s+([A-Z_a-z]\w+)(?:\s+([^\n\r;]*))?;?/;K2=/^(?:.?[<>=^])?([-+( ])?(\$)?0?\d*(,)?(?:\.(\d+))?(~)?([a-zA-Z%])?$/;Kf=28,_c=6,Ic=1.25;J2={type:"treemap",parse:(e,t,r)=>UT(GT(e),r),render:KT}});var ty={};_t(ty,{treemap:()=>J2});var ry=Xe(()=>{ey()});function ZT(e,t){return{type:"info",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
92
+ `):void 0}}function QT(e){let t=new Zt(Gt(e,ay,"info"),ay,"info"),r={$type:"Info"};for(;t.kind===5;)t.i++;for(t.expect(1);t.kind===5;)t.i++;if(t.accept(0))for(;t.kind===5;)t.i++;for(;t.kind!==-1;){let a=t.kind;if(a===2?r.accDescr=Kt(t.take()):a===3?r.accTitle=Vt(t.take()):a===4?r.title=Xt(t.take()):t.fail("a title or the end of input"),t.kind===-1)break;for(t.kind!==5&&t.fail("a line break or the end of input");t.kind===5;)t.i++}return r}function eC(e,t,r){let a=r.fontSize??16,i=r.measurer??et(r.fontFamily),n=r.padding??8,l=ze(e.title,!1,i,a,4e3,1),s=l.height>0?l.height+8:0,o=ze(`Pele v${JT}`,!1,i,a,4e3),c=Math.ceil(Math.max(l.width,o.width)+2*n),f=Math.ceil(s+o.height+2*n),p=Re(l,c/2,n+l.height/2,' class="pele-title" font-weight="var(--_tw)"')+Re(o,c/2,n+s+o.height/2,' class="pele-version" fill="var(--_m)"');return{svg:Je("info",c,f,a,r,e,p),width:c,height:f,links:[]}}var ay,JT,iy,ny=Xe(()=>{Vr();ut();wt();ay=[or("showInfo"),or("info"),ur,rr,ar,Rr,Lr,jt,sr,lr];JT="1.8.0";iy={type:"info",parse:(e,t,r)=>ZT(QT(e),r),render:eC}});var sy={};_t(sy,{info:()=>iy});var ly=Xe(()=>{ny()});function wy(e){if(e.toLowerCase()==="none")return 4;let t=rC.exec(e);return t?t[1]===void 0?1:t[1]==="%"?2:3:0}function aC(e,t){let r=wy(e);return r===1||r===2||t&&r===4}function iC(e){let t=e.startsWith("hsl"),r=e.indexOf("("),a=e.slice(0,r);if(a!=="rgb"&&a!=="rgba"&&a!=="hsl"&&a!=="hsla"||e.length>120||e.indexOf(")")!==e.length-1)return!1;let i=e.slice(r+1,-1).trim(),n,l,s=i.includes(",");if(s)n=i.split(",").map(c=>c.trim()),n.length===4&&(l=n.pop());else{let c=i.split("/");if(c.length>2)return!1;n=c[0].trim().split(/\s+/),c.length===2&&(l=c[1].trim())}if(n.length!==3||l!==void 0&&!aC(l,!s))return!1;let o=n.map(wy);if(s)return t?(o[0]===1||o[0]===3)&&o[1]===2&&o[2]===2:(o[0]===1||o[0]===2)&&o[1]===o[0]&&o[2]===o[0];for(let c=0;c<3;c++){let f=o[c];if(!(f===1||f===4||(t&&c===0?f===3:f===2)))return!1}return!0}function nC(e){return e.includes("(")?iC(e):(oy??(oy=new Set(tC.split(" "))),oy.has(e.toLowerCase()))}function Sl(e){throw new je(e,"semantic",{type:"sequence"})}function hy(e){let t=e.trim(),r=sC.test(t)?!0:lC.test(t)?!1:void 0;return{text:(r===void 0?t:t.replace(oC,"")).trim(),wrap:r}}function dC(e){let t=cC.exec(e);if(t){let a=e.lastIndexOf(")");if(a>=t[0].length)return cy.test(e.slice(t[0].length))?void 0:[e.slice(0,a+1),e.slice(a+1)]}if(cy.test(e))return;let r=hC.exec(e)[0];return[r,e.slice(r.length)]}function dy(e){return typeof e=="string"?[...e].map((t,r)=>[String(r),t]):e!==null&&typeof e=="object"?Object.entries(e):[]}function pC(e){let t=e.length,r=[],a=[],i=[],n=[],l=0,s=0,o=-1,c=(y,E,x)=>{r.push(y),a.push(e.slice(E,x)),i.push(E),s=x},f=(y,E,x,T)=>{r.push(y),a.push(T),i.push(E),s=x},p=y=>{n.push(l),l=y},h=()=>{n.length>0&&(l=n.pop())},g=y=>(o<y&&(o=e.indexOf(`
93
+ `,y),o===-1&&(o=t)),o),u=(y,E)=>{let x=e.charCodeAt(y);return x<128?(by[x]&E)!==0:E===4||E===32?!Ue(x):!0},m=(y,E)=>{for(let x=0;x<E.length;x++){let T=E.charCodeAt(x),A=e.charCodeAt(y+x);if(T>=97&&T<=122?(A|32)!==T:A!==T)return!1}return!0},b=y=>m(s,y)&&!Qe(e.charCodeAt(s+y.length)),w=y=>{for(;y<t&&Ue(e.charCodeAt(y));)y++;return y},v=()=>{let y=s;for(;y<t;){let E=e.charCodeAt(y);if(E===10||!Ue(E))break;y++}return y===s?!1:(s=y,!0)},k=y=>{for(;y<t&&u(y,16);)y++;return y},O=(y,E,x)=>{c(y,s,s+E),p(x)},R=(y,E,x=-1)=>b(y)?(c(E,s,s+y.length),x>=0&&p(x),!0):!1,L=(y,E)=>{if(!m(s,y))return!1;let x=s+y.length,T=e.charCodeAt(x);if(T!==32&&T!==9)return!1;for(;T===32||T===9;)T=e.charCodeAt(++x);return x>=t||!u(x,32)?!1:(c(E,s,s+y.length),!0)},P=y=>{let E=e.charCodeAt(y),x=e.charCodeAt(y+1);if(E===45){if(x===120||x===88||x===41||x===92||x===47||x===45)return!0;let T=e.charCodeAt(y+2);return x===124&&(T===92||T===47)}return E===47||E===92?(x===124||x===E)&&e.charCodeAt(y+2)===45:E===40&&x===41},B=()=>{let y=s+1;for(;y<t&&u(y,1);)y++;for(;y<t&&!P(y);){let E=y;for(;e.charCodeAt(E)===45;)E++;if(E>=t||!u(E,2))break;for(E++;E<t&&u(E,2);)E++;y=E}f(48,s,y,e.slice(s,y).trim())},G=()=>{let y=s;for(;pt(e.charCodeAt(y));)y++;let E=y>s;if(e.charCodeAt(y)===46&&pt(e.charCodeAt(y+1))){let T=pt(e.charCodeAt(y+2))?y+3:y+2,A=e.charCodeAt(T);if(A===32||A===10)return c(10,s,T),!0}let x=e.charCodeAt(y);return E&&(x===32||x===10)?(c(10,s,y),!0):!1},C=()=>{let y=e.charCodeAt(s+1),E=e.charCodeAt(s+2);if(y===62)c(E===62?55:53,s,s+(E===62?3:2));else if(y===120||y===88)c(59,s,s+2);else if(y===41)c(61,s,s+2);else if(y===124&&E===92)c(63,s,s+3);else if(y===124&&E===47)c(64,s,s+3);else if(y===92&&E===92)c(65,s,s+3);else if(y===47&&E===47)c(66,s,s+3);else if(y===45){let x=e.charCodeAt(s+3);E===62?c(x===62?57:54,s,s+(x===62?4:3)):E===120||E===88?c(60,s,s+3):E===41?c(62,s,s+3):E===124&&x===92?c(67,s,s+4):E===124&&x===47?c(68,s,s+4):E===92&&x===92?c(69,s,s+4):E===47&&x===47?c(70,s,s+4):c(46,s,s+1)}else c(46,s,s+1)},Z=y=>{let E=e.charCodeAt(s+1);if(E!==124&&E!==y||e.charCodeAt(s+2)!==45)return!1;let x=e.charCodeAt(s+3)===45,T=y===47,A;return E===124?x?A=T?75:76:A=T?71:72:x?A=T?77:78:A=T?73:74,c(A,s,s+(x?4:3)),!0},ee=()=>{if(!m(s,"title"))return!1;let y=s+5,E=e.charCodeAt(y)===58;return E&&y++,!Ue(e.charCodeAt(y))||y+1>=t||!u(y+1,16)?!1:(c(E?15:14,s,k(y+1)),!0)},H=()=>{let y=m(s,"accdescr");if(!y&&!m(s,"acctitle"))return!1;let E=w(s+8),x=e.charCodeAt(E);return x===58?(c(y?18:16,s,w(E+1)),p(y?6:5),!0):y&&x===123?(s=w(E+1),p(7),!0):!1},Y=y=>{switch(y|32){case 97:return R("actor",34,1)||R("alt",24,3)||R("and",30,3)||R("activate",12,1)||H()||R("autonumber",9);case 98:return R("box",6,3)||R("break",28,3);case 99:return R("create",5)||R("critical",27,3);case 100:return R("destroy",35,1)||L("details",41)||R("deactivate",13,1);case 101:return R("else",31,3)||R("end",8);case 108:return R("loop",21,3)||R("left of",43)||L("links",38)||L("link",39);case 110:return R("note",36);case 111:return R("opt",23,3)||R("option",29,3)||R("over",37)||R("off",11);case 112:return R("participant",32,1)||R("par",25,3)||R("par_over",26,3)||L("properties",40);case 114:return R("rect",22,3)||R("right of",44);case 115:return R("sequencediagram",4);case 116:return ee();default:return!1}},_=()=>{let y=e.charCodeAt(s);if(y===10){let E=s+1;for(;e.charCodeAt(E)===10;)E++;c(3,s,E);return}if(Ue(y)){s=w(s+1);return}if(y===35||y===37&&e.charCodeAt(s+1)!==123){s=g(s);return}if(y!==125&&e.charCodeAt(s+1)===37&&e.charCodeAt(s+2)===37){s=g(s);return}if(!((pt(y)||y===46)&&G())&&!(y<128&&(y|32)>=97&&(y|32)<=122&&Y(y)))if(y===44)c(42,s,s+1);else if(y===59)c(3,s,s+1);else if(u(s,1))B();else if(y===45)C();else if(y===60&&e.startsWith("<<->>",s))c(56,s,s+5);else if(y===60&&e.startsWith("<<-->>",s))c(58,s,s+6);else{if((y===47||y===92)&&Z(y))return;y===58?c(52,s,k(s+1)):y===43?c(45,s,s+1):y===40&&e.charCodeAt(s+1)===41?c(47,s,s+2):c(2,s,s+1)}},S=()=>{if(v())return!0;let y=e.charCodeAt(s);if(y===35)return s=g(s),!0;if(y===64&&e.charCodeAt(s+1)===123)return O(49,2,4),!0;let E=s;for(;E<t&&u(E,4);)E++;if(E>s){let T=w(E);if(e.charCodeAt(T)===64&&e.charCodeAt(T+1)===123)return c(48,s,E),!0;if(T>E&&m(T,"as")&&Ue(e.charCodeAt(T+2)))return c(48,s,E),p(2),!0}let x=E;for(;x<t&&u(x,8);)x++;if(x>s){let T=e.charCodeAt(x),A=x;if(x<t&&T!==10&&T!==59)for(A--;A>s&&e.charCodeAt(A)!==35;)A--;if(A>s)return f(48,s,A,e.slice(s,A).trim()),h(),!0}if(e.charCodeAt(x)===60)return c(2,s,g(s)),h(),!0;if(y!==10){let T=g(s);return f(2,s,T,e.slice(s,T).trim()),h(),!0}return!1},$=()=>{switch(l){case 0:return _(),!0;case 1:return S();case 2:return v()?!0:e.charCodeAt(s)===35?(s=g(s),!0):(h(),h(),b("as")?O(33,2,3):c(3,s,s),!0);case 3:return v()?!0:e.charCodeAt(s)===35?(s=g(s),!0):(c(7,s,k(s)),h(),!0);case 4:if(e.charCodeAt(s)!==125){let y=e.indexOf("}",s);return y===-1&&(y=t),c(50,s,y),!0}else{let y=w(s+1),E=y>s+1&&m(y,"as")&&Ue(e.charCodeAt(y+2));return c(51,s,s+1),h(),E?p(2):h(),!0}case 5:case 6:return c(l===5?17:19,s,g(s)),h(),!0;default:if(e.charCodeAt(s)===125)s++,h();else{let y=e.indexOf("}",s);y===-1&&(y=t),c(20,s,y)}return!0}};for(;s<t;)if(!$())return r.push(1),a.push(""),i.push(s),{types:r,texts:a,starts:i};return l===0||l===2?c(3,t,t):l===3?c(7,t,t):l===5?c(17,t,t):l===6?c(19,t,t):l===7&&c(20,t,t),r.push(0),a.push(""),i.push(t),{types:r,texts:a,starts:i}}function gC(e,t){let{types:r,texts:a,starts:i}=pC(e),n=0,l=k=>{let O=r[n];throw O===1?it("sequence",e,i[n],"",!0):it("sequence",e,i[n],`Expecting ${k}, got '${fy[O]}'`)},s=k=>(r[n]!==k&&l(`'${fy[k]}'`),a[n++]),o=()=>{let k=r[n];return k!==48&&k!==39&&l("'ACTOR'"),{type:"addParticipant",actor:a[n++]}},c=()=>t.parseMessage(s(52).trim().substring(1)),f=()=>{let k=r[n++];if(k===35){let R=o();return s(3),R.type="destroyParticipant",R}let O=o();if(r[n]===49&&r[n-1]===48){n++;let R=s(50);s(51),O.config=R.trim()}if(O.draw=k===32?"participant":"actor",r[n]===33){n++;let R=s(7);s(3),O.description=t.parseMessage(R)}else r[n]===3?n++:l("'AS', 'NEWLINE'");return O},p=k=>{let O=!1;r[n]===47&&(O=!0,n++);let R=Ht[r[n]];R<0&&l(uC),n++;let L=r[n];(L===47||!O&&(L===45||L===46))&&n++;let P=o(),B=c(),G={type:"addMessage",from:k.actor,to:P.actor,signalType:R,msg:B},C=[k,P,G];if(O){let Z=L===47;G.activate=Z,G.centralConnection=Z?61:60,Z&&C.push({type:"centralConnection",signalType:59,actor:P.actor}),C.push({type:"centralConnectionReverse",signalType:60,actor:k.actor})}else L===45?(G.activate=!0,C.push({type:"activeStart",signalType:17,actor:P.actor})):L===46?C.push({type:"activeEnd",signalType:18,actor:k.actor}):L===47&&(G.activate=!0,G.centralConnection=59,C.push({type:"centralConnection",signalType:59,actor:P.actor}));return C},h=k=>{n++;let O=o();return[O,{type:k,actor:O.actor,text:c()}]},g=()=>{n++;let k=r[n];if(k===37){n++;let L=o(),P=L,B=[L.actor,L.actor];if(r[n]===42){n++;let G=o();P=[L,G],B=[L.actor,G.actor]}return[P,{type:"addNote",placement:2,actor:B,text:c()}]}k!==43&&k!==44&&l("'over', 'left_of', 'right_of'"),n++;let O=o();return[O,{type:"addNote",placement:k===43?0:1,actor:O.actor,text:c()}]},u=()=>{n++;let k={type:"sequenceIndex",sequenceVisible:!0,signalType:26};return r[n]===10?(k.sequenceIndex=Number(a[n++]),k.sequenceIndexStep=r[n]===10?Number(a[n++]):1):r[n]===11&&(n++,k.sequenceVisible=!1),r[n]!==3&&l("'NEWLINE', 'NUM', 'off'"),n++,k},m=(k,O,R,L)=>{let P=k.list,B=k.sections;if(B)for(let G=B.length-2;G>=0;G-=2){let C={type:O,signalType:L};C[R]=t.parseMessage(B[G+1]),P=B[G].concat([C,P])}return P},b=k=>{let O=k.text,R=k.list;switch(k.kind){case 1:R[0]={type:"boxStart",boxData:t.parseBoxData(O)},R.push({type:"boxEnd",boxText:O});break;case 2:R[0]={type:"loopStart",loopText:t.parseMessage(O),signalType:10},R.push({type:"loopEnd",loopText:O,signalType:11});break;case 3:R[0]={type:"rectStart",color:t.parseMessage(O),signalType:22},R.push({type:"rectEnd",color:t.parseMessage(O),signalType:23});break;case 4:R[0]={type:"optStart",optText:t.parseMessage(O),signalType:15},R.push({type:"optEnd",optText:t.parseMessage(O),signalType:16});break;case 5:R[0]={type:"breakStart",breakText:t.parseMessage(O),signalType:30},R.push({type:"breakEnd",optText:t.parseMessage(O),signalType:31});break;case 6:R=m(k,"else","altText",13),R[0]={type:"altStart",altText:t.parseMessage(O),signalType:12},R.push({type:"altEnd",signalType:14});break;case 7:R=m(k,"and","parText",20),R[0]={type:"parStart",parText:t.parseMessage(O),signalType:k.startType},R.push({type:"parEnd",signalType:21});break;default:R=m(k,"option","optionText",28),R[0]={type:"criticalStart",criticalText:t.parseMessage(O),signalType:27},R.push({type:"criticalEnd",signalType:29})}return R};for(;r[n]===3;)n++;s(4);let w=[],v={kind:0,text:"",startType:0,list:[],sections:void 0};for(;;){let k=r[n],O=v.list;if(v.kind===1){if(k===32||k===34||k===35)O.push(f());else if(k===3)O.push([]),n++;else if(k===8){n++;let R=b(v);v=w.pop(),v.list.push(R)}else l("'end', 'NEWLINE', 'participant', 'participant_actor', 'destroy'");continue}switch(k){case 3:case 2:O.push([]),n++;break;case 32:case 34:case 35:O.push(f());break;case 5:{n++;let R=r[n];R!==32&&R!==34&&R!==35&&l("'participant', 'participant_actor', 'destroy'");let L=f();L.type="createParticipant",O.push(L);break}case 48:O.push(p(o())),s(3);break;case 39:{let R=r[n+1];O.push(R===48||R===39?h("addALink"):p(o())),s(3);break}case 38:O.push(h("addLinks")),s(3);break;case 40:O.push(h("addProperties")),s(3);break;case 41:O.push(h("addDetails")),s(3);break;case 36:O.push(g()),s(3);break;case 9:O.push(u());break;case 12:case 13:{n++;let R=o();s(3),O.push(k===12?{type:"activeStart",signalType:17,actor:R.actor}:{type:"activeEnd",signalType:18,actor:R.actor});break}case 14:case 15:{let R=a[n++].substring(k===14?6:7);t.setDiagramTitle(R),O.push(R);break}case 16:{n++;let R=s(17).trim();t.setAccTitle(R),O.push(R);break}case 18:{n++;let R=s(19).trim();t.setAccDescription(R),O.push(R);break}case 20:{let R=a[n++].trim();t.setAccDescription(R),O.push(R);break}case 21:case 22:case 23:case 28:case 24:case 25:case 26:case 27:case 6:{n++;let R=s(7);w.push(v),v={kind:Za[k],text:R,startType:k===26?32:19,list:[[]],sections:void 0};break}case 31:case 30:case 29:{v.kind!==(k===31?6:k===30?7:8)&&l("'end'"),n++;let R=s(7);(v.sections??(v.sections=[])).push(O,R),v.list=[];break}case 8:{v.kind===0&&l("'NEWLINE', 'EOF'"),n++;let R=b(v);v=w.pop(),v.list.push(R);break}case 0:v.kind!==0&&l("'end'"),t.apply(O);return;default:l("'NEWLINE', 'ACTOR', 'participant', 'note', 'end'")}}}function bC(e){return xC.has(e)?e:"participant"}function Jf(e){return wC.has(e)}function $C(e,t,r,a,i=mC){if(Jf(e))return{w:Math.max(40,t.width+8),h:$y+(t.height>0?ky+t.height:0)};let n=e==="collections"?wn:e==="queue"?2*xn:0;return{w:Math.max(r,t.width+2*i)+n,h:Math.max(a,t.height+2*yC)+(e==="collections"?wn:0)}}function kC(e,t,r){let a=d(t),i=n=>d(r+n);switch(e){case"actor":return`<circle cx="${a}" cy="${i(7)}" r="6"${wi}/><path d="M${a},${i(13)}V${i(24)}M${d(t-10)},${i(17)}H${d(t+10)}M${d(t-8)},${i(34)}L${a},${i(24)}L${d(t+8)},${i(34)}"${cs}/>`;case"boundary":return`<path d="M${d(t-19)},${i(6)}V${i(28)}M${d(t-19)},${i(17)}H${d(t-8)}"${cs}/><circle cx="${d(t+3)}" cy="${i(17)}" r="11"${wi}/>`;case"control":return`<circle cx="${a}" cy="${i(21)}" r="11"${wi}/><path d="M${d(t+5)},${i(5)}L${d(t-1)},${i(10)}L${d(t+5)},${i(15)}"${cs}/>`;case"entity":return`<circle cx="${a}" cy="${i(15)}" r="11"${wi}/><path d="M${d(t-11)},${i(30)}H${d(t+11)}"${cs}/>`;default:{let n=d(t-14),l=d(t+14);return`<path d="M${n},${i(7)}V${i(27)}A14,5 0 0 0 ${l},${i(27)}V${i(7)}A14,5 0 0 0 ${n},${i(7)}Z"${wi}/><path d="M${n},${i(7)}A14,5 0 0 0 ${l},${i(7)}"${cs}/>`}}}function MC(e,t,r,a,i,n){let{w:l,h:s}=a,o=' class="pele-label"';if(Jf(e))return kC(e,t,r)+Re(i,t,r+$y+ky+i.height/2,o,n);let c=t-l/2;if(e==="collections"){let f=l-wn,p=s-wn,h=`<rect x="${d(c+wn)}" y="${d(r)}" width="${d(f)}" height="${d(p)}"${wi}${nt}/>`,g=`<rect x="${d(c)}" y="${d(r+wn)}" width="${d(f)}" height="${d(p)}"${wi}${nt}/>`;return h+g+Re(i,c+f/2,r+wn+p/2,o,n)}if(e==="queue"){let f=d(c+xn),p=d(c+l-xn),h=d(r+s),g=d(s/2);return`<path d="M${f},${d(r)}H${p}A${xn},${g} 0 0 1 ${p},${h}H${f}A${xn},${g} 0 0 1 ${f},${d(r)}Z"${wi}/><path d="M${p},${d(r)}A${xn},${g} 0 0 0 ${p},${h}"${cs}/>`+Re(i,t-xn/2,r+s/2,o,n)}return`<rect x="${d(c)}" y="${d(r)}" width="${d(l)}" height="${d(s)}"${wi}${nt}/>`+Re(i,t,r+s/2,o,n)}function Ar(e,t,r,a=1,i=!1){ep[e]={dotted:t,head:r,atStart:a!==1,atEnd:a!==0,bottom:i}}function Qf(e){return e!==void 0&&ep[e]!==void 0}function _C(e,t){let r=new Array(e.length),a=new Array(e.length),i=1,n=1,l=!1;for(let s=0;s<e.length;s++){let o=e[s];if(r[s]=NaN,a[s]=!1,o.type===26){let c=o.message;i=c.start||i,n=c.step||n,l=c.visible}else Qf(o.type)&&(r[s]=i,a[s]=l||t,i=Math.round((i+n)*100)/100)}return{index:r,shown:a,visible:l}}function yn(e,t,r){let a=e[t];return typeof a=="number"&&a>=0&&a<=2e3?a:r}function xy(e,t,r,a,i){let n=d(e-r*Yt);return i?`<path class="pele-marker" d="M${d(e)},${d(t)}L${n},${d(t+a*5)}"/>`:`<path class="pele-marker" d="M${d(e)},${d(t)}L${n},${d(t+a*4.5)}V${d(t)}Z" fill="var(--_l)" stroke="none"/>`}function Dc(e,t,r,a,i){switch(e){case 1:return bt("arrow_point",t,r,a,0,"var(--_l)");case 2:return bt("arrow_cross",t,r,a,0,"var(--_l)");case 3:return`<path class="pele-marker" d="M${d(t-a*Yt)},${d(r-4.5)}L${d(t)},${d(r)}L${d(t-a*Yt)},${d(r+4.5)}" stroke-linejoin="round"/>`;case 4:return xy(t,r,a,i,!1);case 5:return xy(t,r,a,i,!0);default:return""}}function IC(e){return e===1?Yt-1:e===2?4:0}function NC(e,t,r){return Nr(r,a=>RC(e,t,r,a))}function RC(e,t,r,a){let i=t.sequence??{},n=r.fontSize??16,l=Math.round(n*.875),s=Math.round(n*.75),o=r.measurer??et(r.fontFamily),c=r.icons,f=r.padding??8,p=i.mirrorActors!==!1,h=i.rightAngles===!0,g=Math.min(yn(i,"actorMargin",40),a?8:1/0),u=Math.min(yn(i,"width",64),a?48:1/0),m=yn(i,"height",Math.round(n*1.5)+20),b=Math.min(yn(i,"width",160),a?Math.max(32,((r.maxWidth??320)-2*f)/Math.max(1,e.actors.size)-g-24):1/0),w=Math.max(4,14+yn(i,"messageMargin",35)-35),v=Math.min(yn(i,"noteMargin",10),a?6:1/0),k=Math.min(yn(i,"boxMargin",10),a?6:1/0),O=i.messageAlign==="left"?-1:i.messageAlign==="right"?1:0,R=a?6:vC,L=a?8:SC,P=a?12:TC,B=a?6:CC,G=e.messages,C=G.length,Z=_C(G,i.showSequenceNumbers===!0),ee=(V,me,ie,$e=b,ve=0)=>{let Te=ze(V,!1,o,me,a||ie?$e:1/0,ve);return a?pn(Te,o,Math.max(120,$e)):Te},H;if(i.hideUnusedParticipants===!0){H=new Set;for(let V of G)H.add(V.from).add(V.to)}let Y=new Int32Array(C+1);Y[C]=-1;for(let V=C-1;V>=0;V--)Y[V]=Qf(G[V].type)?V:Y[V+1];let _=[],S=new Map;for(let[V,me]of e.actors){if(H&&!H.has(V))continue;let ie=bC(me.type),$e=ee(me.description,n,me.wrap),ve=e.createdActors.get(V),Te=e.destroyedActors.get(V),De=ve===void 0?-1:Y[Math.min(ve,C)];De>=0&&G[De].to!==V&&(De=-1);let _e=Te===void 0?-1:Y[Math.min(Te,C)];_e>=0&&G[_e].to!==V&&G[_e].from!==V&&(_e=-1),S.set(V,_.length),_.push({id:V,actor:me,kind:ie,label:$e,size:$C(ie,$e,u,m,a?8:void 0),x:0,createAt:De,destroyAt:_e,top:0,lifeStart:0,lifeEnd:-1,activations:[]})}let $=_.length-1,y=new Map,E=(V,me,ie)=>{if(V<0||me>$)return;let $e=V*_.length+me;(y.get($e)??0)<ie&&y.set($e,ie)},x=V=>Z.shown[V]?Math.max(Lc,o.width(String(Z.index[V]),s,0)+8):0,T=new Array(C);for(let V=0;V<C;V++){let me=G[V],ie=me.from===void 0?void 0:S.get(me.from),$e=me.to===void 0?void 0:S.get(me.to);if(!(ie===void 0||$e===void 0||typeof me.message!="string")){if(me.type===2){let ve=ee(me.message,l,me.wrap),Te=ve.width+2*v;me.placement===0?E(ie-1,ie,Te+2*ls+La):me.placement===1?E(ie,ie+1,Te+2*ls+La):ie===$e?(E(ie-1,ie,Te/2+ls),E(ie,ie+1,Te/2+ls)):E(Math.min(ie,$e),Math.max(ie,$e),Te-2*L),T[V]={kind:2,a:ie,b:$e,label:ve,x:0,w:Te}}else if(Qf(me.type)){let ve=ee(me.message,l,me.wrap),Te=x(V);if(ie===$e)E(ie,ie+1,Zf+8+ve.width+16+La+Te),T[V]={kind:1,a:ie,b:$e,label:ve,x:0,w:0};else{let De=_[$e].createAt===V?_[$e].size.w/2:0,_e=me.centralConnection?4*os:0;E(Math.min(ie,$e),Math.max(ie,$e),(a?Math.min(ve.width,Math.max(16,b-16)):ve.width)+2*R+La+Te+De+_e),T[V]={kind:0,a:ie,b:$e,label:ve,x:0,w:0}}}}}let A=[];for(let V=0;V<=$;V++){let me=_[V].actor.box,ie=A[A.length-1];me&&ie&&ie.box===me&&ie.last===V-1?ie.last=V:me&&A.push({box:me,first:V,last:V,title:ee(me.name,l,me.wrap),grow:0})}let M=new Array(Math.max($,0));for(let V=0;V<$;V++){let me=_[V],ie=_[V+1],$e=me.actor.box!==ie.actor.box?(me.actor.box?k:0)+(ie.actor.box?k:0):0;M[V]=Math.max(me.size.w/2+ie.size.w/2+g+$e,y.get(V*_.length+V+1)??0)}let N=[];for(let[V,me]of y){let ie=Math.floor(V/_.length),$e=V%_.length;$e-ie>1&&N.push([ie,$e,me])}N.sort((V,me)=>V[1]-V[0]-(me[1]-me[0])||V[0]-me[0]);for(let[V,me,ie]of N){let $e=0;for(let Te=V;Te<me;Te++)$e+=M[Te];if($e>=ie)continue;let ve=(ie-$e)/(me-V);for(let Te=V;Te<me;Te++)M[Te]+=ve}let F=()=>{for(let V=1;V<=$;V++)_[V].x=_[V-1].x+M[V-1]};F();for(let V of A){let me=_[V.last].x+_[V.last].size.w/2-(_[V.first].x-_[V.first].size.w/2);V.grow=Math.max(0,(V.title.width-me)/2),V.grow!==0&&(V.first>0&&(M[V.first-1]+=V.grow),V.last<$&&(M[V.last]+=V.grow))}F();let U=1/0,D=-1/0,I=(V,me)=>{V<U&&(U=V),me>D&&(D=me)};for(let V of _)I(V.x-V.size.w/2,V.x+V.size.w/2);for(let V of A)I(_[V.first].x-_[V.first].size.w/2-k-V.grow,_[V.last].x+_[V.last].size.w/2+k+V.grow);let z=new Array(C),q=[],j=()=>$<0?[0,120]:[_[0].x-P,_[$].x+P];for(let V=0;V<C;V++){let me=G[V],ie=me.type,$e=ie===void 0?void 0:AC.get(ie),ve=T[V];if($e!==void 0){let Te={kind:$e,x0:1/0,x1:-1/0,top:0,title:yy,tabW:0,fill:$e==="rect"&&typeof me.message=="string"?me.message:"",dividers:[V],dividerY:[],dividerLabels:[]};z[V]=Te,q.push(Te)}else if(ie===13||ie===20||ie===28)q[q.length-1]?.dividers.push(V);else if(ie===11||ie===14||ie===16||ie===21||ie===29||ie===31||ie===23){let Te=q.pop();if(!Te)continue;if(z[V]=Te,Te.x0>Te.x1&&([Te.x0,Te.x1]=j()),Te.kind!=="rect"){Te.tabW=o.width(Te.kind,s,1)+14;for(let _e=0;_e<Te.dividers.length;_e++){let Ye=G[Te.dividers[_e]].message,Ee=_e===0?Te.tabW+8:0,qe=Te.x1-Te.x0-16-Ee,Ge=Ye?ee(`[${Ye}]`,l,!0,Math.max(qe,a?Math.min(gy,b):gy)):yy;Ge.width>qe&&(Te.x1+=Ge.width-qe),_e===0?Te.title=Ge:Te.dividerLabels.push(Ge)}}I(Te.x0,Te.x1);let De=q[q.length-1];De&&(De.x0=Math.min(De.x0,Te.x0-B),De.x1=Math.max(De.x1,Te.x1+B))}else if(ve){let Te=_[ve.a],De=_[ve.b],_e,Ye;if(ve.kind===2){if(me.placement===0)ve.x=Te.x-ls-ve.w;else if(me.placement===1)ve.x=Te.x+ls;else if(ve.a===ve.b)ve.x=Te.x-ve.w/2;else{let qe=Math.min(Te.x,De.x)-L,Ge=Math.max(Te.x,De.x)+L;(a||me.wrap)&&(ve.label=ee(me.message,l,!0,Math.max(b,Ge-qe-2*v))),ve.w=Math.max(Ge-qe,ve.label.width+2*v),ve.x=(qe+Ge-ve.w)/2}_e=ve.x,Ye=ve.x+ve.w}else ve.kind===1?(_e=Te.x,Ye=Te.x+La+Zf+8+ve.label.width+x(V)):(_e=Math.min(Te.x,De.x),Ye=Math.max(Te.x,De.x),(a||me.wrap)&&(ve.label=ee(me.message,l,!0,Math.max(b,Ye-_e-2*R-La))),De.createAt===V&&(De.x>Te.x?Ye+=De.size.w/2:_e-=De.size.w/2));I(_e,Ye);let Ee=q[q.length-1];Ee&&(Ee.x0=Math.min(Ee.x0,_e-P),Ee.x1=Math.max(Ee.x1,Ye+P))}}let Q=0;for(let V of A)Q=Math.max(Q,V.title.height);let K=A.length>0?k+(Q>0?Q+4:0):0,W=0;for(let V of _)V.createAt<0&&(W=Math.max(W,V.size.h));let X=K+W;for(let V of _)V.top=X-V.size.h,V.lifeStart=X;let te=_.map(V=>V.x),se=(V,me)=>{let ie=0,$e=te.length;for(;ie<$e;){let ve=ie+$e>>1;te[ve]<=V?ie=ve+1:$e=ve}return ie<te.length&&te[ie]<me},oe=(V,me,ie,$e)=>{if(V.width===0)return"";let ve=me-V.width/2;return(se(ve,ve+V.width)?`<rect x="${d(ve-3)}" y="${d(ie-V.height/2+2)}" width="${d(V.width+6)}" height="${d(V.height-4)}" rx="3" fill="var(--_bg)" stroke="none"/>`:"")+Re(V,me,ie,$e,c)},ae=(V,me=0)=>V.activations.length+me>0?V.x-La/2:V.x,ne=(V,me=0)=>{let ie=V.activations.length+me;return ie>0?V.x+La/2+(ie-1)*uy:V.x},J=[],re=[],fe="",ye="",le="",we="",pe="",ge="",Ae=(V,me)=>{let ie=V.activations.pop(),$e=Math.max(me,ie+EC),ve=V.x-La/2+V.activations.length*uy;return I(ve,ve+La),re.push(`<rect class="pele-activation" data-id="${Oe(V.id)}" x="${d(ve)}" y="${d(ie)}" width="${La}" height="${d($e-ie)}" rx="2"/>`),$e},Se=(V,me)=>{let ie=V.x,$e=me+16;return V.lifeEnd=$e,ge+=`<path class="pele-destroy" data-id="${Oe(V.id)}" d="M${d(ie-6)},${d($e-6)}L${d(ie+6)},${d($e+6)}M${d(ie+6)},${d($e-6)}L${d(ie-6)},${d($e+6)}"/>`,$e+6},ce=(V,me,ie)=>{let $e=V.actor.properties.get("class");return`<g class="pele-node pele-actor pele-actor-${V.kind}${ie?" pele-actor-footer":""}${typeof $e=="string"?It($e):""}" data-id="${Oe(V.id)}">`+MC(V.kind,V.x,me,V.size,V.label,c)+"</g>"},ue=(V,me,ie,$e)=>`<g class="pele-sequence-number"><rect x="${d(me-$e/2)}" y="${d(ie-Lc/2)}" width="${d($e)}" height="${Lc}" rx="${Lc/2}" fill="var(--_l)" stroke="none"/><text x="${d(me)}" y="${d(ie+s*.35)}" text-anchor="middle" font-size="${s}" fill="var(--_bg)" stroke="none">${Ve(String(Z.index[V]))}</text></g>`,xe=X+6,Ie=[];for(let V=0;V<C;V++){let me=G[V],ie=me.type,$e=T[V],ve=z[V];if(ie===17){let Te=me.from===void 0?void 0:S.get(me.from);Te!==void 0&&_[Te].activations.push(xe)}else if(ie===18){let Te=me.from===void 0?void 0:S.get(me.from);Te!==void 0&&_[Te].activations.length>0&&(xe=Math.max(xe,Ae(_[Te],xe)))}else if(ve&&ve.dividers[0]===V)Ie.push(ve),ve.kind==="rect"?(ve.top=xe+8,xe=ve.top):(ve.top=xe+12,xe=ve.top+Math.max(Rc,ve.title.height+2));else if(ve){Ie.pop();let Te=xe+12,De=d(ve.x0),_e=d(ve.x1-ve.x0);if(ve.kind==="rect"){let Ye=ve.fill?vt([`fill:${ve.fill}`]).shape:"";J.push(`<rect class="pele-rect" x="${De}" y="${d(ve.top)}" width="${_e}" height="${d(Te-ve.top)}"${ft((Ye?"":' fill-opacity="0.5"')+Ye)}/>`)}else{let Ye=`<rect x="${De}" y="${d(ve.top)}" width="${_e}" height="${d(Te-ve.top)}" fill="none"${nt}/>`;for(let Ee=0;Ee<ve.dividerY.length;Ee++){let qe=ve.dividerY[Ee],Ge=ve.dividerLabels[Ee];Ye+=`<path d="M${De},${d(qe)}H${d(ve.x1)}"${my}/>`+oe(Ge,ve.x0+8+Ge.width/2,qe+2+Ge.height/2,' class="pele-frame-label" fill="var(--_m)" stroke="none"')}Ye+=`<rect x="${De}" y="${d(ve.top)}" width="${d(ve.tabW)}" height="${Rc}" fill="var(--_s)"${nt}/><text class="pele-frame-kind" x="${d(ve.x0+ve.tabW/2)}" y="${d(ve.top+Rc/2+s*.35)}" text-anchor="middle" font-size="${s}" font-weight="var(--_hw)" fill="var(--_m)" stroke="none">${ve.kind}</text>`+oe(ve.title,ve.x0+ve.tabW+8+ve.title.width/2,ve.top+Math.max(Rc,ve.title.height)/2,' class="pele-frame-label" fill="var(--_m)" stroke="none"'),fe+=`<g class="pele-frame pele-frame-${ve.kind}">${Ye}</g>`}xe=Te}else if(ie===13||ie===20||ie===28){let Te=Ie[Ie.length-1];if(Te){let De=Te.dividerLabels[Te.dividerY.length];Te.dividerY.push(xe+12),xe+=12+(De.height>0?De.height:0)}}else if($e&&$e.kind===2){let Te=_[$e.a],De=$e.label.height+2*Math.max(4,v-4),_e=xe+10,Ye=$e.x;me.placement===1?Ye+=ne(Te)-Te.x:me.placement===0&&(Ye+=ae(Te)-Te.x),I(Ye,Ye+$e.w),we+=`<g class="pele-note" data-id="i${Oe(me.id)}"><rect x="${d(Ye)}" y="${d(_e)}" width="${d($e.w)}" height="${d(De)}"${nt}/>`+Re($e.label,Ye+$e.w/2,_e+De/2,' class="pele-label" stroke="none" fill="var(--_fg)"',c)+"</g>",xe=_e+De}else if($e){let Te=ep[ie],De=_[$e.a],_e=_[$e.b],Ye=$e.label,Ee=x(V),qe=0;for(let He=V+1;He<C;He++){let ht=G[He].type;if(ht===17)G[He].from===me.to&&qe++;else if(ht!==18&&ht!==59&&ht!==60)break}let Ge=Te.bottom?1:-1,rt=Te.dotted?my:"",ct=me.centralConnection,tt=ct===59||ct===61,lt=ct===60||ct===61,st=(He,ht)=>`<circle class="pele-central" cx="${d(He)}" cy="${d(ht)}" r="${os}" fill="var(--_l)" stroke="none"/>`,Wt=Te.atStart&&!Te.atEnd,Ct=IC(Te.head),kt="",Ft;if($e.kind===1){let He=xe+w+Math.max(0,(Ye.height-py)/2),ht=He+py,yt=lt?De.x+os:ne(De),ot=tt?De.x+os:ne(De,qe),er=Math.max(yt,ot)+Zf+Ee/2;lt&&(kt+=st(De.x,He)),tt&&(kt+=st(De.x,ht)),Ee>0&&(kt+=ue(V,Wt?ot:yt,Wt?ht:He,Ee),Wt?ot+=Ee/2:yt+=Ee/2);let St=(Te.atStart?Dc(Te.head,yt,He,-1,Ge):"")+(Te.atEnd?Dc(Te.head,ot,ht,-1,-Ge):""),Ze=d(yt+(Te.atStart?Ct:0)),xt=d(ot+(Te.atEnd?Ct:0));kt=`<path d="${h?`M${Ze},${d(He)}H${d(er)}V${d(ht)}H${xt}`:`M${Ze},${d(He)}H${d(er-6)}A6,6 0 0 1 ${d(er)},${d(He+6)}V${d(ht-6)}A6,6 0 0 1 ${d(er-6)},${d(ht)}H${xt}`}"${rt}/>`+St+kt,I(De.x,er+8+Ye.width),Ye.width>0&&(le+=`<g class="pele-edge-label" data-id="i${Oe(me.id)}">${Re(Ye,er+8+Ye.width/2,(He+ht)/2,"",c)}</g>`),Ft=Math.max(ht,(He+ht)/2+Ye.height/2)}else{let He=_e.x>De.x?1:-1,ht=_e.createAt===V;Ft=xe+w+Math.max(Ye.height>0?Ye.height+2:6,ht?_e.size.h/2-w+6:0);let yt=He>0?ne(De):ae(De),ot=He>0?ae(_e,qe):ne(_e,qe);if(ht&&(_e.top=Ft-_e.size.h/2,_e.lifeStart=_e.top+_e.size.h,ot=_e.x-He*(Jf(_e.kind)?18:_e.size.w/2+1)),lt&&(kt+=st(De.x,Ft),yt=De.x+He*os),tt&&(kt+=st(_e.x,Ft),ot=_e.x-He*os),Ee>0)if(Wt){let xt=tt?ot-He*(Ee/2+2):ot;kt+=ue(V,xt,Ft,Ee),ot=xt-He*Ee/2}else{let xt=lt?yt+He*(Ee/2+2):yt;kt+=ue(V,xt,Ft,Ee),yt=xt+He*Ee/2}let er=(Te.atStart?Dc(Te.head,yt,Ft,-He,Ge*He):"")+(Te.atEnd?Dc(Te.head,ot,Ft,He,Ge*He):""),St=yt+(Te.atStart?He*Ct:0),Ze=ot-(Te.atEnd?He*Ct:0);if(kt=`<path d="M${d(St)},${d(Ft)}H${d(Ze)}"${rt}/>`+er+kt,Ye.width>0){let xt=Math.min(yt,ot),Dt=Math.max(yt,ot),Rt=O<0?xt+R+Ye.width/2:O>0?Dt-R-Ye.width/2:(xt+Dt)/2;I(Rt-Ye.width/2,Rt+Ye.width/2),le+=`<g class="pele-edge-label" data-id="i${Oe(me.id)}">${oe(Ye,Rt,Ft-4-Ye.height/2,"")}</g>`}ht&&(xe=Ft+_e.size.h/2-6)}ye+=`<g class="pele-edge pele-message" data-id="i${Oe(me.id)}">${kt}</g>`,xe=Math.max(xe,Ft),De.destroyAt===V&&(xe=Math.max(xe,Se(De,Ft))),_e.destroyAt===V&&_e!==De&&(xe=Math.max(xe,Se(_e,Ft)))}}xe+=20;for(let V of _)for(;V.activations.length>0;)Ae(V,xe);let Le=xe;if(p){let V=0;for(let me of _)me.lifeEnd>=0||(V=Math.max(V,me.size.h),pe+=ce(me,xe,!0));Le=xe+V}let We="";for(let V of _){pe+=ce(V,V.top,!1);let me=V.lifeEnd>=0?V.lifeEnd:xe;me>V.lifeStart&&(We+=`<path class="pele-lifeline" data-id="${Oe(V.id)}" d="M${d(V.x)},${d(V.lifeStart)}V${d(me)}"/>`)}let de="";for(let V of A){let me=_[V.first].x-_[V.first].size.w/2-k-V.grow,ie=_[V.last].x+_[V.last].size.w/2+k+V.grow,$e=V.box.fill==="transparent"?"":vt([`fill:${V.box.fill}`]).shape;de+=`<g class="pele-cluster pele-box"${V.box.name?` data-id="${Oe(V.box.name)}"`:""}><rect x="${d(me)}" y="0" width="${d(ie-me)}" height="${d(Le+k)}" fill="var(--_a)" stroke="var(--_b)"${ft(($e?"":' fill-opacity="0.5"')+$e)}/>`+Re(V.title,(me+ie)/2,k/2+2+V.title.height/2,' class="pele-cluster-label" fill="var(--_m)"',c)+"</g>"}A.length>0&&(Le+=k);let ke=0,Ce="",be=Nt(r),Me=Cr(e.title,o,n,a?be:1/0),Ne=a?pn(Me,o,Math.max(120,be)):Me;if(U>D&&I(0,Math.max(Ne.width,40)),Ne.width>0){let V=(U+D)/2;I(V-Ne.width/2,V+Ne.width/2),ke=-Ne.height-12,Ce=Re(Ne,V,ke+Ne.height/2,' class="pele-title" font-weight="var(--_tw)"',c)}let Be=Math.ceil(D-U+2*f),Pe=Math.ceil(Le-ke+2*f);return{svg:Je("sequence",Be,Pe,n,r,e,`<g transform="translate(${d(f-U)},${d(f-ke)})">`+Ce+(de?`<g class="pele-boxes" font-size="${l}">${de}</g>`:"")+(J.length>0?`<g class="pele-rects" fill="var(--_a)">${J.reverse().join("")}</g>`:"")+(We?`<g class="pele-lifelines" fill="none" stroke="var(--_b)">${We}</g>`:"")+(re.length>0?`<g class="pele-activations" fill="var(--_s)" stroke="var(--_b)">${re.reverse().join("")}</g>`:"")+(fe?`<g class="pele-frames" font-size="${l}" stroke="var(--_b)">${fe}</g>`:"")+(ye?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${ye}</g>`:"")+(ge?`<g class="pele-destroys" fill="none" stroke="var(--_l)" stroke-width="1.5" stroke-linecap="round">${ge}</g>`:"")+(le?`<g class="pele-edge-labels" font-size="${l}">${le}</g>`:"")+(we?`<g class="pele-notes" font-size="${l}" fill="var(--_a)" stroke="var(--_b)">${we}</g>`:"")+(pe?`<g class="pele-nodes">${pe}</g>`:"")+"</g>"),width:Be,height:Pe,links:[]}}var tC,oy,rC,sC,lC,oC,cC,cy,hC,fC,fy,by,Ht,Za,uC,mC,yC,$y,ky,wn,xn,wi,cs,xC,wC,ep,AC,vC,Zf,py,La,uy,EC,ls,SC,TC,CC,Rc,gy,Lc,os,my,yy,My,Ay=Xe(()=>{Dn();un();Ea();tr();zt();pr();ut();wt();tC="aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen transparent currentcolor inherit initial unset revert accentcolor accentcolortext activetext buttonborder buttonface buttontext canvas canvastext field fieldtext graytext highlight highlighttext linktext mark marktext selecteditem selecteditemtext visitedtext activeborder activecaption appworkspace background buttonhighlight buttonshadow captiontext inactiveborder inactivecaption inactivecaptiontext infobackground infotext menu menutext scrollbar threeddarkshadow threedface threedhighlight threedlightshadow threedshadow window windowframe windowtext",rC=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?(%|deg|grad|rad|turn)?$/i;sC=/^:?wrap:/,lC=/^:?nowrap:/,oC=/^:?(?:no)?wrap:/,cC=/^(?:rgba?|hsla?)\s*\(/,cy=/[\r\u2028\u2029]/,hC=/^\w*/;fC=class{constructor(e={}){he(this,"type","sequence");he(this,"actors",new Map);he(this,"createdActors",new Map);he(this,"destroyedActors",new Map);he(this,"boxes",[]);he(this,"messages",[]);he(this,"notes",[]);he(this,"title");he(this,"accTitle");he(this,"accDescr");he(this,"prevActor");he(this,"currentBox");he(this,"lastCreated");he(this,"lastDestroyed");he(this,"wrapEnabled");he(this,"sequenceWrap");he(this,"active",new Map);this.wrapEnabled=e.wrap,this.sequenceWrap=e.sequenceWrap??!1}autoWrap(){return this.wrapEnabled??this.sequenceWrap}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
94
+ `)}setDiagramTitle(e){this.title=e}parseMessage(e){return hy(e)}parseBoxData(e){let t=dC(e),r=t?.[0]?t[0].trim():"transparent",a=t?.[1]?t[1].trim():void 0;if(nC(r)||(r="transparent",a=e.trim()),a===void 0)return{text:void 0,color:r,wrap:void 0};let{text:i,wrap:n}=hy(a);return{text:i||void 0,color:r,wrap:n}}addBox(e){this.currentBox={name:e.text,wrap:e.wrap??this.autoWrap(),fill:e.color,actorKeys:[]},this.boxes.push(this.currentBox)}addActor(e,t,r,a,i){let n=this.currentBox,l;if(i!==void 0){let f;try{f=Ma(i.includes(`
95
+ `)?i+`
96
+ `:`{
97
+ `+i+`
98
+ }`)}catch(p){throw new je(`Config of participant "${e}" is not valid YAML. ${p.message}`,"syntax",{type:"sequence"})}f!==null&&typeof f=="object"&&!Array.isArray(f)&&(l=f)}let s=l&&Object.prototype.hasOwnProperty.call(l,"type")?l.type:void 0,o=l&&Object.prototype.hasOwnProperty.call(l,"alias")?l.alias:void 0;s!=null&&(a=String(s)),o&&(!r||r.text===t)&&(r={text:String(o),wrap:r?.wrap,type:a});let c=this.actors.get(e);if(!(c&&(this.currentBox&&c.box&&this.currentBox!==c.box&&Sl(`A same participant should only be defined in one Box: ${c.name} can't be in '${c.box.name}' and in '${this.currentBox.name}' at the same time.`),n=c.box?c.box:this.currentBox,c.box=n,t===c.name&&r==null))){if((r?.text==null||a==null)&&(r={text:t,type:a}),this.actors.set(e,{box:n,name:t,description:r.text,wrap:r.wrap??this.autoWrap(),prevActor:this.prevActor,links:new Map,properties:new Map,type:a??"participant"}),this.prevActor){let f=this.actors.get(this.prevActor);f&&(f.nextActor=e)}this.currentBox&&this.currentBox.actorKeys.push(e),this.prevActor=e}}addMessage(e,t,r,a){this.messages.push({id:String(this.messages.length),from:e,to:t,message:r.text,wrap:r.wrap??this.autoWrap(),answer:a})}addSignal(e,t,r,a,i=!1,n){if(a===18){let l=e?this.active.get(e)??0:0;l<1&&Sl(`Trying to inactivate an inactive participant (${e})`),this.active.set(e,l-1)}else a===17&&e&&this.active.set(e,(this.active.get(e)??0)+1);return this.messages.push({id:String(this.messages.length),from:e,to:t,message:r?.text??"",wrap:r?.wrap??this.autoWrap(),type:a,activate:i,centralConnection:n??0}),!0}addNote(e,t,r){let a=r.wrap??this.autoWrap(),i={actor:e,placement:t,message:r.text,wrap:a},n=typeof e=="string"?[e,e]:e;this.notes.push(i),this.messages.push({id:String(this.messages.length),from:n[0],to:n[1],message:r.text,wrap:a,type:2,placement:t})}addLinks(e,t){let r=this.actors.get(e);if(r)try{let a=JSON.parse(t.text);for(let[i,n]of dy(a))r.links.set(i,n)}catch{return}}addALink(e,t){let r=this.actors.get(e);if(!r)return;let a=t.text.indexOf("@");r.links.set(t.text.slice(0,a-1).trim(),t.text.slice(a+1).trim())}addProperties(e,t){let r=this.actors.get(e);if(r)try{let a=JSON.parse(t.text);for(let[i,n]of dy(a))r.properties.set(i,n)}catch{return}}addDetails(e,t){let r=this.actors.get(e);r&&(r.details=t.text)}apply(e){let t=[],r=[],a=e;for(;;){a!==void 0&&(Array.isArray(a)?(t.push(a),r.push(0)):typeof a!="string"&&this.applyOne(a));let i=t.length-1;if(i<0)return;let n=t[i];r[i]<n.length?a=n[r[i]++]:(t.pop(),r.pop(),a=void 0)}}applyOne(e){let t=e.actor;switch(e.type){case"sequenceIndex":this.messages.push({id:String(this.messages.length),from:void 0,to:void 0,message:{start:e.sequenceIndex,step:e.sequenceIndexStep,visible:e.sequenceVisible===!0},wrap:!1,type:e.signalType});break;case"addParticipant":this.addActor(t,t,e.description,e.draw,e.config);break;case"createParticipant":this.actors.has(t)&&Sl("It is not possible to have actors with the same id, even if one is destroyed before the next is created. Use 'AS' aliases to simulate the behavior"),this.lastCreated=t,this.addActor(t,t,e.description,e.draw,e.config),this.createdActors.set(t,this.messages.length);break;case"destroyParticipant":this.lastDestroyed=t,this.destroyedActors.set(t,this.messages.length);break;case"activeStart":case"activeEnd":case"centralConnection":case"centralConnectionReverse":this.addSignal(t,void 0,void 0,e.signalType);break;case"addNote":this.addNote(e.actor,e.placement,e.text);break;case"addLinks":this.addLinks(t,e.text);break;case"addALink":this.addALink(t,e.text);break;case"addProperties":this.addProperties(t,e.text);break;case"addDetails":this.addDetails(t,e.text);break;case"addMessage":this.lastCreated?(e.to!==this.lastCreated&&Sl(`The created participant ${this.lastCreated} does not have an associated creating message after its declaration. Please check the sequence diagram.`),this.lastCreated=void 0):this.lastDestroyed&&(e.to!==this.lastDestroyed&&e.from!==this.lastDestroyed&&Sl(`The destroyed participant ${this.lastDestroyed} does not have an associated destroying message after its declaration. Please check the sequence diagram.`),this.lastDestroyed=void 0),this.addSignal(e.from,e.to,e.msg,e.signalType,e.activate,e.centralConnection);break;case"boxStart":this.addBox(e.boxData);break;case"boxEnd":this.currentBox=void 0;break;case"loopStart":this.addSignal(void 0,void 0,e.loopText,e.signalType);break;case"rectStart":this.addSignal(void 0,void 0,e.color,e.signalType);break;case"optStart":this.addSignal(void 0,void 0,e.optText,e.signalType);break;case"altStart":case"else":this.addSignal(void 0,void 0,e.altText,e.signalType);break;case"parStart":case"and":this.addSignal(void 0,void 0,e.parText,e.signalType);break;case"criticalStart":this.addSignal(void 0,void 0,e.criticalText,e.signalType);break;case"option":this.addSignal(void 0,void 0,e.optionText,e.signalType);break;case"breakStart":this.addSignal(void 0,void 0,e.breakText,e.signalType);break;case"loopEnd":case"rectEnd":case"optEnd":case"altEnd":case"parEnd":case"criticalEnd":case"breakEnd":this.addSignal(void 0,void 0,void 0,e.signalType);break}}},fy=["$end","INVALID","INVALID","NEWLINE","SD","create","box","restOfLine","end","autonumber","NUM","off","activate","deactivate","title","legacy_title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","loop","rect","opt","alt","par","par_over","critical","break","option","and","else","participant","AS","participant_actor","destroy","note","over","links","link","properties","details",",","left_of","right_of","+","-","()","ACTOR","CONFIG_START","CONFIG_CONTENT","CONFIG_END","TXT","SOLID_OPEN_ARROW","DOTTED_OPEN_ARROW","SOLID_ARROW","BIDIRECTIONAL_SOLID_ARROW","DOTTED_ARROW","BIDIRECTIONAL_DOTTED_ARROW","SOLID_CROSS","DOTTED_CROSS","SOLID_POINT","DOTTED_POINT","SOLID_ARROW_TOP","SOLID_ARROW_BOTTOM","STICK_ARROW_TOP","STICK_ARROW_BOTTOM","SOLID_ARROW_TOP_DOTTED","SOLID_ARROW_BOTTOM_DOTTED","STICK_ARROW_TOP_DOTTED","STICK_ARROW_BOTTOM_DOTTED","SOLID_ARROW_TOP_REVERSE","SOLID_ARROW_BOTTOM_REVERSE","STICK_ARROW_TOP_REVERSE","STICK_ARROW_BOTTOM_REVERSE","SOLID_ARROW_TOP_REVERSE_DOTTED","SOLID_ARROW_BOTTOM_REVERSE_DOTTED","STICK_ARROW_TOP_REVERSE_DOTTED","STICK_ARROW_BOTTOM_REVERSE_DOTTED"],by=new Uint8Array(128);for(let e=0;e<128;e++){let t=String.fromCharCode(e),r=e===32||e>=9&&e<=13,a=0;`/\\+()<->:
99
+ ,;`.includes(t)||(a|=1),`+<->:
100
+ ,;`.includes(t)||(a|=2),`<>:
101
+ ,;@`.includes(t)||(a|=8|(r?0:4)),`#
102
+ ;`.includes(t)||(a|=16),!`/\\+()<>:
103
+ ,;-`.includes(t)&&!r&&(a|=32),by[e]=a}Ht=new Int8Array(79).fill(-1);Ht[53]=5;Ht[54]=6;Ht[55]=0;Ht[57]=1;Ht[56]=33;Ht[58]=34;Ht[59]=3;Ht[60]=4;Ht[61]=24;Ht[62]=25;Ht[63]=41;Ht[64]=42;Ht[65]=43;Ht[66]=44;Ht[67]=51;Ht[68]=52;Ht[69]=53;Ht[70]=54;Ht[71]=45;Ht[72]=46;Ht[73]=47;Ht[74]=48;Ht[75]=55;Ht[76]=56;Ht[77]=57;Ht[78]=58;Za=new Int8Array(79).fill(-1);Za[21]=2;Za[22]=3;Za[23]=4;Za[28]=5;Za[24]=6;Za[25]=7;Za[26]=7;Za[27]=8;Za[6]=1;uC="'SOLID_OPEN_ARROW', 'DOTTED_OPEN_ARROW', 'SOLID_ARROW', 'DOTTED_ARROW', 'SOLID_CROSS', 'DOTTED_CROSS', 'SOLID_POINT', 'DOTTED_POINT'";mC=16,yC=10,$y=34,ky=4,wn=5,xn=6,wi=' fill="var(--_s)" stroke="var(--_b)"',cs=' fill="none" stroke="var(--_b)"',xC=new Set(["participant","actor","boundary","control","entity","database","collections","queue"]),wC=new Set(["actor","boundary","control","entity","database"]);ep=[];Ar(0,!1,1);Ar(1,!0,1);Ar(3,!1,2);Ar(4,!0,2);Ar(5,!1,0);Ar(6,!0,0);Ar(24,!1,3);Ar(25,!0,3);Ar(33,!1,1,2);Ar(34,!0,1,2);for(let e of[!1,!0]){let t=e?10:0;Ar(41+t,e,4),Ar(42+t,e,4,1,!0),Ar(43+t,e,5),Ar(44+t,e,5,1,!0),Ar(45+t,e,4,0),Ar(46+t,e,4,0,!0),Ar(47+t,e,5,0),Ar(48+t,e,5,0,!0)}AC=new Map([[10,"loop"],[12,"alt"],[15,"opt"],[19,"par"],[32,"par"],[27,"critical"],[30,"break"],[22,"rect"]]),vC=12,Zf=28,py=22,La=10,uy=4,EC=14,ls=10,SC=16,TC=20,CC=10,Rc=20,gy=240,Lc=16,os=4,my=' stroke-dasharray="4 4"';yy={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};My={type:"sequence",math:!0,parse(e,t,r){let a=t.sequence??{},i=new fC({wrap:typeof t.wrap=="boolean"?t.wrap:void 0,sequenceWrap:a.wrap===!0});return r&&i.setDiagramTitle(r),gC(e,i),i},render:NC}});var vy={};_t(vy,{sequence:()=>My});var Ey=Xe(()=>{Ay()});function Zr(e){throw new je(e,"semantic",{type:"gitGraph"})}function Sy(e){return e==="REVERSE"?gr.REVERSE:e==="HIGHLIGHT"?gr.HIGHLIGHT:gr.NORMAL}function LC(e,t){e.dir&&t.setDirection(e.dir);for(let r of e.statements)DC(r,t)}function DC(e,t){switch(e.$type){case"Commit":t.commit({id:e.id,msg:e.message??"",type:e.type!==void 0?Sy(e.type):gr.NORMAL,tags:e.tags??void 0});break;case"Branch":t.branch({name:e.name,order:e.order??0});break;case"Merge":t.merge({branch:e.branch,id:e.id??"",type:e.type!==void 0?Sy(e.type):void 0,tags:e.tags??void 0});break;case"Checkout":t.checkout(e.branch);break;case"CherryPicking":t.cherryPick({id:e.id,targetId:"",tags:e.tags?.length===0?void 0:e.tags,parent:e.parent});break}}function OC(e,t,r){let a=t.gitGraph,i=typeof a?.mainBranchName=="string"?a.mainBranchName:"main",n=typeof a?.mainBranchOrder=="number"?a.mainBranchOrder:0,l=new Map,s=new Map([[i,null]]),o=new Map([[i,n]]),c=[],f=null,p=i,h="LR",g=0,u=()=>{for(let v=g+1;;v+=2654435761){let k=`${g}-${(Math.imul(v,2654435761)>>>0).toString(16).padStart(8,"0").slice(0,7)}`;if(!l.has(k))return k}},m=v=>{f=v,l.set(v.id,v),s.set(p,v.id)},b=v=>{s.has(v)||Zr(`Trying to checkout branch which is not yet created. (Help try using "branch ${v}")`),p=v;let k=s.get(v);f=k?l.get(k)??null:null};LC(e,{setDirection(v){h=v},commit({msg:v,id:k,type:O,tags:R}){let L={id:k||u(),message:v,seq:g++,type:O??gr.NORMAL,tags:R?[...R]:[],parents:f===null?[]:[f.id],branch:p};l.has(L.id)&&c.push(`Commit ID ${L.id} already exists`),m(L)},branch({name:v,order:k}){s.has(v)&&Zr(`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${v}")`),s.set(v,f!==null?f.id:null),o.set(v,k),b(v)},merge({branch:v,id:k,type:O,tags:R}){let L=s.get(p),P=s.get(v),B=L?l.get(L):void 0,G=P?l.get(P):void 0;B&&G&&B.branch===v&&Zr(`Cannot merge branch '${v}' into itself.`),p===v&&Zr('Incorrect usage of "merge". Cannot merge a branch to itself'),B===void 0&&Zr(`Incorrect usage of "merge". Current branch (${p})has no commits`),s.has(v)||Zr(`Incorrect usage of "merge". Branch to be merged (${v}) does not exist`),G===void 0&&Zr(`Incorrect usage of "merge". Branch to be merged (${v}) has no commits`),B===G&&Zr('Incorrect usage of "merge". Both branches have same head'),k&&l.has(k)&&Zr(`Incorrect usage of "merge". Commit with id:${k} already exists, use different custom id`),m({id:k||u(),message:`merged branch ${v} into ${p}`,seq:g++,parents:f===null?[]:[f.id,P||""],branch:p,type:gr.MERGE,customType:O,customId:!!k,tags:R?[...R]:[]})},cherryPick({id:v,targetId:k,tags:O,parent:R}){let L=v?l.get(v):void 0;if(L===void 0&&Zr('Incorrect usage of "cherryPick". Source commit id should exist and provided'),R&&!L.parents.includes(R)&&Zr("Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit."),L.type===gr.MERGE&&!R&&Zr("Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified."),k&&l.has(k))return;L.branch===p&&Zr('Incorrect usage of "cherryPick". Source commit is already on current branch');let P=s.get(p);(!P||!l.has(P))&&Zr(`Incorrect usage of "cherry-pick". Current branch (${p})has no commits`),m({id:u(),message:`cherry-picked ${L.message} into ${p}`,seq:g++,parents:f===null?[]:[f.id,L.id],branch:p,type:gr.CHERRY_PICK,tags:O?O.filter(Boolean):[`cherry-pick:${L.id}${L.type===gr.MERGE?`|parent:${R}`:""}`]})},checkout:b});let w=[...o].map(([v,k],O)=>({name:v,order:k??parseFloat(`0.${O}`)})).sort((v,k)=>v.order-k.order).map(v=>v.name);return{type:"gitGraph",title:e.title||r,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
104
+ `):void 0,direction:h,commits:l,branches:s,lanes:w,currentBranch:p,head:f,warnings:c}}function xa(e){return{name:e,pattern:e,longer:Ly}}function PC(e){let t=new Zt(Gt(e,Ty,"gitGraph"),Ty,"gitGraph"),r={$type:"GitGraph",statements:[]},a=()=>{if(t.kind!==-1)for(t.kind!==26&&t.fail("a line break or the end of input");t.kind===26;)t.i++},i=()=>t.kind===31?t.take():t.kind===25?$r(t.take()):t.fail("a branch name"),n=()=>$r(t.expect(25)),l=()=>(t.kind!==8&&t.kind!==5&&t.kind!==2&&t.fail("NORMAL, REVERSE, or HIGHLIGHT"),t.take());for(;t.kind===26;)t.i++;if(!t.accept(1)){t.expect(3);let s=t.kinds[t.i+1];(t.kind===17||t.kind===18||t.kind===19)&&s===20?(r.$type="Direction",r.dir=t.take(),t.i++):t.accept(20)}for(;t.kind!==-1;)switch(t.kind){case 26:t.i++;break;case 21:r.accDescr=Kt(t.take()),a();break;case 22:r.accTitle=Vt(t.take()),a();break;case 23:r.title=Xt(t.take()),a();break;case 7:{t.i++;let s={$type:"Commit",tags:[]};for(;;)if(t.accept(16))s.id=n();else if(t.accept(15))s.tags.push(n());else if(t.accept(12))s.type=l();else if(t.accept(14)||t.kinds[t.i]===25)s.message=n();else break;a(),r.statements.push(s);break}case 9:{t.i++;let s={$type:"Branch",name:i()};t.accept(10)&&(s.order=parseInt(t.expect(24))),a(),r.statements.push(s);break}case 13:{t.i++;let s={$type:"Merge",branch:i(),tags:[]};for(;;)if(t.accept(16))s.id=n();else if(t.accept(15))s.tags.push(n());else if(t.accept(12))s.type=l();else break;a(),r.statements.push(s);break}case 4:case 11:{t.i++;let s={$type:"Checkout",branch:i()};a(),r.statements.push(s);break}case 0:{t.i++;let s={$type:"CherryPicking",tags:[]};for(;;)if(t.accept(16))s.id=n();else if(t.accept(15))s.tags.push(n());else if(t.accept(6))s.parent=n();else break;a(),r.statements.push(s);break}default:t.fail("a statement, a title, or a line break")}return r}function zc(e,t,r){let a=e.gitGraph?.[t];return typeof a=="boolean"?a:r}function Iy(e){return Cl+4+e.width+6}function WC(e,t,r,a){let i=`cx="${d(t)}" cy="${d(r)}"`;if(e===gr.HIGHLIGHT)return`<rect x="${d(t-cr-1)}" y="${d(r-cr-1)}" width="${2*cr+2}" height="${2*cr+2}" rx="2" fill="${a}"/>`;if(e===gr.MERGE)return`<circle ${i} r="${cr-1}" fill="var(--_bg)" stroke="${a}" stroke-width="2"/><circle ${i} r="2.5" fill="${a}"/>`;let n=`<circle ${i} r="${cr}" fill="${a}"/>`;return e===gr.REVERSE?n+`<path d="M${d(t-3)},${d(r-3)}l6,6M${d(t-3)},${d(r+3)}l6,-6" fill="none" stroke="var(--_bg)" stroke-width="1.5" stroke-linecap="round"/>`:e===gr.CHERRY_PICK?n+`<path d="M${d(t-2.6)},${d(r+1)}L${d(t+.8)},${d(r-4.2)}L${d(t+2.6)},${d(r+1)}" fill="none" stroke="var(--_bg)" stroke-linejoin="round"/><circle cx="${d(t-2.6)}" cy="${d(r+2.2)}" r="1.8" fill="var(--_bg)"/><circle cx="${d(t+2.6)}" cy="${d(r+2.2)}" r="1.8" fill="var(--_bg)"/>`:n}function BC(e,t,r){return e.direction!=="LR"?Ny(e,t,r,e.direction):Bt(r,a=>Ny(e,t,r,a?"TB":"LR"))}function Ny(e,t,r,a){let i=r.fontSize??16,n=Math.round(i*.75),l=r.measurer??et(r.fontFamily),s=r.padding??8,o=zc(t,"showBranches",!0),c=zc(t,"showCommitLabel",!0),f=zc(t,"rotateCommitLabel",!0),p=zc(t,"parallelCommits",!1),h=a!=="LR",g=a==="BT",u=new Map;e.lanes.forEach((W,X)=>u.set(W,X));let m=e.lanes.length,b=Math.round(i*.875),w=e.lanes.map(W=>Na(o?W:"",l,b,4e3)),v=[],k=new Map;for(let W of[...e.commits.values()].sort((X,te)=>X.seq-te.seq)){let X=c&&W.type!==gr.CHERRY_PICK&&(W.type!==gr.MERGE||W.customId===!0),te=[];for(let oe of W.tags){let ae=Na(oe,l,n,4e3);ae.lines.length>0&&te.push(ae)}let se={commit:W,index:v.length,lane:u.get(W.branch)??0,m:0,label:X?Na(W.id,l,n,4e3):void 0,tags:te};v.push(se),k.set(W.id,se)}let O=new Float64Array(v.length),R=new Float64Array(v.length),L=new Float64Array(m).fill(cr),P=new Float64Array(m).fill(cr);v.forEach((W,X)=>{let{label:te,tags:se}=W,oe=0,ae=0;for(let le of se){let we=Iy(le);h?(oe=Math.max(oe,le.height),ae+=we+4):(oe=Math.max(oe,we),ae+=le.height+3)}let ne=0,J=0;te!==void 0&&te.lines.length>0&&(f?J=3+tp*(te.width+te.height):(ne=h?te.height:te.width,J=6+(h?te.width:te.height))),O[X]=Math.max(cr,oe/2,ne/2),R[X]=oe/2;let re=cr+(se.length>0?Cy+ae:0),fe=cr+J,ye=W.lane;L[ye]=Math.max(L[ye],h?fe:re),P[ye]=Math.max(P[ye],h?re:fe)});let B=new Float64Array(v.length);h||v.forEach((W,X)=>{if(R[X]!==0)for(let te of W.commit.parents){let se=k.get(te);se!==void 0&&se.lane<W.lane&&(B[X]=R[X]+4)}});let G=(W,X)=>Math.max(zC,O[W]+O[X]+Pc,B[X]>0?O[W]+Oc+B[X]:0);v.forEach((W,X)=>{if(!p){W.m=X===0?0:v[X-1].m+G(X-1,X);return}let te=0;for(let se of W.commit.parents){let oe=k.get(se);oe===void 0||oe.index>=X||(te=Math.max(te,oe.m+G(oe.index,X)))}W.m=te});let C=0;for(let W of v)C=Math.max(C,W.m);let Z=new Float64Array(m);for(let W=0;W<m;W++){let X=w[W],te=X.lines.length===0?0:h?X.width/2+8:X.height/2+2;L[W]=Math.max(L[W],te),P[W]=Math.max(P[W],te),W>0&&(Z[W]=Z[W-1]+Math.max(FC,P[W-1]+L[W]+Pc))}let ee=(W,X)=>h?X:W,H=(W,X)=>h?g?-W:W:X,Y=(W,X)=>`${d(ee(W,X))},${d(H(W,X))}`,_=1/0,S=1/0,$=-1/0,y=-1/0,E=(W,X,te,se)=>{W<_&&(_=W),X<S&&(S=X),te>$&&($=te),se>y&&(y=se)},x="";if(o)for(let W=0;W<m;W++){let X=w[W],te=dt(W),se=Z[W],oe=X.width+16,ae=X.height+4,ne=X.lines.length===0?-bn:-bn-(h?ae:oe),J=ee(ne+(h?ae:oe)/2,se),re=H(ne+(h?ae:oe)/2,se);E(ee(-bn,se),H(-bn,se),ee(-bn,se),H(-bn,se)),E(ee(C+Tl,se),H(C+Tl,se),ee(C+Tl,se),H(C+Tl,se)),x+=`<g class="pele-branch" data-id="${Oe(e.lanes[W])}"><path class="pele-lane" d="M${Y(-bn,se)}L${Y(C+Tl,se)}" stroke="${te}" stroke-dasharray="2 4"/>`,X.lines.length>0&&(E(J-oe/2,re-ae/2,J+oe/2,re+ae/2),x+=`<rect x="${d(J-oe/2)}" y="${d(re-ae/2)}" width="${d(oe)}" height="${d(ae)}" fill="${te}"${nt}/>`+Re(X,J,re,' class="pele-label" fill="var(--_bg)"')),x+="</g>"}let T=Array.from({length:m},()=>[]);for(let W of v)T[W.lane].push(W.m);if(p)for(let W of T)W.sort((X,te)=>X-te);let A=(W,X,te)=>{let se=T[W],oe=0,ae=se.length;for(;oe<ae;){let ne=oe+ae>>1;se[ne]<=X?oe=ne+1:ae=ne}return oe<se.length&&se[oe]<te},M="",N="";for(let W of v){let{commit:X}=W,te=Z[W.lane],se=W.m;for(let oe=0;oe<X.parents.length;oe++){let ae=k.get(X.parents[oe]);if(ae===void 0||ae===W)continue;let ne=Z[ae.lane],J=ae.m;if(ae.lane===W.lane){N+=`<path class="pele-edge" d="M${Y(J,ne)}L${Y(se,te)}" stroke="${dt(W.lane)}"/>`;continue}let re=oe>0&&X.type===gr.MERGE,fe=oe>0&&!re,ye=`M${Y(J,ne)}`;if(se<=J){let le=(J+se)/2;ye+=`C${Y(le,ne)} ${Y(le,te)} ${Y(se,te)}`}else if(!re&&!A(W.lane,J,se)){let le=Math.min(Oc,se-J);ye+=`C${Y(J+le/2,ne)} ${Y(J+le/2,te)} ${Y(J+le,te)}L${Y(se,te)}`}else{let le=ae.lane<W.lane&&se-B[W.index]>J?se-B[W.index]:se,we=Math.min(Oc,le-J),pe=ne;(!re||A(ae.lane,J,se))&&(pe=ne>te?te+P[W.lane]+Pc/2:te-L[W.lane]-Pc/2,we=Math.min(Oc,(le-J)/2),ye+=`C${Y(J+we/2,ne)} ${Y(J+we/2,pe)} ${Y(J+we,pe)}`),ye+=`L${Y(le-we,pe)}C${Y(le-we/2,pe)} ${Y(le-we/2,te)} ${Y(le,te)}`,le<se&&(ye+=`L${Y(se,te)}`)}M+=`<path class="pele-edge${re?" pele-edge-merge":fe?" pele-edge-cherry-pick":""}" d="${ye}" stroke="${dt(re?ae.lane:W.lane)}"${fe?' stroke-dasharray="4 3"':""}/>`}}let F="";for(let W of v){let{commit:X,label:te,tags:se}=W,oe=ee(W.m,Z[W.lane]),ae=H(W.m,Z[W.lane]),ne=X.customType??X.type;E(oe-cr-1,ae-cr-1,oe+cr+1,ae+cr+1);let J=X.type<gr.MERGE&&X.message!==""?`<title>${Oe(X.message)}</title>`:"";if(J+=WC(ne,oe,ae,dt(W.lane)),te!==void 0&&te.lines.length>0){let ye=te.width,le=te.height,we=(pe,ge)=>`<rect x="${d(pe-ye/2-2)}" y="${d(ge-le/2+2)}" width="${d(ye+4)}" height="${d(le-4)}" rx="3" fill="var(--_bg)"/>`;if(f){let pe=tp*le/2,ge=h?oe-cr-3-pe:oe+3,Ae=h?ae:ae+cr+3+pe,Se=tp*ye+pe;E(ge-Se,g?Ae-Se:Ae-pe,ge+pe,g?Ae+pe:Ae+Se),J+=`<g class="pele-commit-label" transform="rotate(${g?45:-45} ${d(ge)} ${d(Ae)})">`+we(ge-ye/2,Ae)+Re(te,ge-ye/2,Ae,"")+"</g>"}else{let pe=h?oe-cr-6-ye/2:oe,ge=h?ae:ae+cr+6+le/2;E(pe-ye/2,ge-le/2,pe+ye/2,ge+le/2),J+=`<g class="pele-commit-label">${we(pe,ge)}${Re(te,pe,ge,"")}</g>`}}let re=cr+Cy;for(let ye=h?0:se.length-1;ye>=0&&ye<se.length;ye+=h?1:-1){let le=se[ye],we=Iy(le),pe=le.height,ge=h?oe+re:oe-we/2,Ae=h?ae:ae-re-pe/2;re+=h?we+4:pe+3,E(ge,Ae-pe/2,ge+we,Ae+pe/2),J+=`<g class="pele-tag"><path d="M${d(ge)},${d(Ae)}L${d(ge+Cl)},${d(Ae-pe/2)}H${d(ge+we)}V${d(Ae+pe/2)}H${d(ge+Cl)}Z" fill="var(--_s)" stroke="var(--_b)" stroke-linejoin="round"/><circle cx="${d(ge+Cl)}" cy="${d(Ae)}" r="1.5" fill="var(--_b)"/>`+Re(le,ge+Cl+4+le.width/2,Ae,' fill="var(--_fg)"')+"</g>"}let fe=X.type===gr.MERGE&&ne!==gr.MERGE?" pele-commit-merge":"";F+=`<g class="pele-commit pele-commit-${_y[ne]??_y[0]}${fe}" data-id="${Oe(X.id)}">${J}</g>`}_>$&&E(0,0,0,0);let U=ze(e.title,!1,l,i,4e3,1),D=U.height>0?U.height+16:0,I=Math.max($-_,U.width),z=Math.ceil(I+2*s),q=Math.ceil(y-S+D+2*s),j=s-_+(I-($-_))/2,Q=s+D-S,K=Re(U,z/2,s+U.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${d(j)},${d(Q)})">`+(x?`<g class="pele-branches" fill="none" font-size="${b}">${x}</g>`:"")+(M||N?`<g class="pele-edges" fill="none" stroke-width="2" stroke-linecap="round">${M}${N}</g>`:"")+(F?`<g class="pele-commits" font-size="${n}" fill="var(--_m)">${F}</g>`:"")+"</g>";return{svg:Je("gitGraph",z,q,i,r,e,K),width:z,height:q,links:[]}}var gr,Ry,Ly,Ty,cr,zC,FC,Oc,Pc,bn,Tl,Cl,Cy,tp,_y,Dy,Oy=Xe(()=>{Ho();zt();Vr();ut();wt();gr={NORMAL:0,REVERSE:1,HIGHLIGHT:2,MERGE:3,CHERRY_PICK:4};Ry={name:"REFERENCE",pattern:/\w([-\./\w]*[-\w])?/y},Ly=[Ry];Ty=[xa("cherry-pick"),{name:"gitGraph:",pattern:"gitGraph:"},xa("HIGHLIGHT"),{...or("gitGraph"),longer:Ly},xa("checkout"),xa("REVERSE"),{name:"parent:",pattern:"parent:"},xa("commit"),xa("NORMAL"),xa("branch"),{name:"order:",pattern:"order:"},xa("switch"),{name:"type:",pattern:"type:"},xa("merge"),{name:"msg:",pattern:"msg:"},{name:"tag:",pattern:"tag:"},{name:"id:",pattern:"id:"},xa("LR"),xa("TB"),xa("BT"),{name:":",pattern:":"},{...ur,opener:/[\t ]*accDescr\s*{/y},rr,ar,{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y},Xr,Rr,Lr,jt,sr,lr,Ry];cr=7,zC=44,FC=44,Oc=36,Pc=8,bn=20,Tl=20,Cl=7,Cy=6,tp=Math.SQRT1_2,_y=["normal","reverse","highlight","merge","cherry-pick"];Dy={type:"gitGraph",parse:(e,t,r)=>OC(PC(e),t,r),render:BC}});var Py={};_t(Py,{gitGraph:()=>Dy});var zy=Xe(()=>{Oy()});function Il(e,t){let{key:r,value:a}=t;"from"in e&&(r==="offsetX"||r==="offsetY")?e[r]=parseInt(a):("from"in e?HC:YC).has(r)?e[r]=a:(e.extra??(e.extra=new Map)).set(r,a)}function Qt(e,t,r){r!==void 0&&(typeof r=="string"?e[t]=r:Il(e,r))}function hs(e,t,r){r===void 0?e[t]??(e[t]=""):Qt(e,t,r)}function Fy(e,t){e.labelAttr=void 0,typeof t=="object"?(e.label="",e.labelAttr=t,Il(e,t)):e.label=t??""}function GC(e){let t=e.length,r=[],a=[],i=[],n=0,l=9,s=0,o=!1,c=-2,f=-1,p=0,h=(b,w,v)=>{r.push(b),a.push(w),i.push(v),s=v},g=b=>{for(;b<t&&Ue(e.charCodeAt(b));)b++;return b},u=(b,w)=>{let v=e.indexOf(b,w);return v===-1?t:v},m=(b,w)=>{let v=s+b.length;if(!e.startsWith(b,s)||!Ue(e.charCodeAt(v)))return!1;let k=++v;for(;v<t;){let O=e.charCodeAt(v);if(O===35||O===10||O===59)break;v++}return v===k?!1:(h(w,s,v),!0)};for(;;){if(o){h(0,t,t);break}s>=t&&(o=!0);let b=e.charCodeAt(s);if(n===0){if(s>=t){h(64,t,t);continue}if(c!==-1&&s>=p&&(c<s&&(c=e.indexOf("direction",s)),c!==-1&&(f<s&&(ap.lastIndex=s,f=ap.test(e)?ap.lastIndex-1:t),c<f))){let w=!1;for(let v=0;v<4&&!w;v++)rp[v].lastIndex=s,rp[v].test(e)&&(h(2+v,s,rp[v].lastIndex),w=!0);if(w)continue;p=f}if(b===116&&m("title",6))continue;if(b===97){if(m("accDescription",7))continue;let w=e.startsWith("accTitle",s);if(w||e.startsWith("accDescr",s)){let v=g(s+8),k=e.charCodeAt(v);if(k===58){h(w?8:10,s,g(v+1)),l=w?9:11,n=7;continue}if(k===123&&!w){s=g(v+1),n=8;continue}}}if(b===37&&e.charCodeAt(s+1)===37){let w=u(`
105
+ `,s+2);for(;w<t&&(e.charCodeAt(w)===10||e.charCodeAt(w)===13);)w++;s=w;continue}if(Ue(b)){let w=s,v=-1;for(;w<t;){let k=e.charCodeAt(w);if(!Ue(k))break;k===10&&(v=w),w++}v!==-1?h(13,s,v+1):s=w;continue}if(b===123){h(62,s,s+1);continue}if(b===125){h(63,s,s+1);continue}if(Qe(b)){let w=s+1;for(;w<t&&Qe(e.charCodeAt(w));)w++;let v=w-s<=19?qC.get(e.slice(s,w)):void 0;if(v!==void 0){v>18&&(n=1),h(v,s,w);continue}}h(1,s,s);break}if(n===1){if(s>=t)h(57,t,t);else if(b===40){let w=s+1;for(;e.charCodeAt(w)===32;)w++;e.charCodeAt(w)===44?h(58,s,w+1):s++,n=2}else if(b===41)s++,n=0;else{h(1,s,s);break}continue}if(n===2){if(s>=t)continue;if(b===41)s++,n=0;else if(b===44)e.charCodeAt(s+1)===44?h(58,s,s+2):s++;else{let w=s;for(;e.charCodeAt(w)===32;)w++;let v=e.charCodeAt(w);v===34?e.charCodeAt(w+1)===34?h(58,s,w+2):(s=w+1,n=3):v===36?(s=w+1,n=4):h(59,s,u(",",s))}continue}if(n===3){b===34?(s++,n=2):h(59,s,u('"',s));continue}if(n===4){h(60,s,u("=",s)),n=5;continue}if(n===5){if(s>=t)continue;let w=s+1;if(b===61)for(;e.charCodeAt(w)===32;)w++;if(b!==61||e.charCodeAt(w)!==34){h(1,s,s);break}s=w+1,n=6;continue}if(n===6){if(s>=t)continue;b===34?(s++,n=2):h(61,s,u('"',s));continue}if(n===7){h(l,s,u(`
106
+ `,s)),n=0;continue}b===125?(s++,n=0):h(12,s,u("}",s))}return{types:r,starts:a,ends:i}}function ZC(e){return e===6||e===7||e===8||e===10||e===12}function By(e){return e>=19&&e<=56}function QC(e,t){let{types:r,starts:a,ends:i}=GC(e),n=0,l=m=>e.slice(a[m],i[m]),s=m=>{let b=r[n];throw b===1?it("c4",e,a[n],"",!0):it("c4",e,a[n],`Expecting ${m}, got '${Wy[b]}'`)},o=m=>{r[n]!==m&&s(`'${Wy[m]}'`),n++},c=()=>{let m=[];for(;;){let b=r[n];if(b===59)m.push(l(n++).trim());else if(b===58)m.push(""),n++;else if(b===60)n++,r[n]!==61&&s("'STR_VALUE'"),m.push({key:l(n-1).trim(),value:l(n).trim()}),n++;else break}return m.length===0&&s(KC),m},f=m=>{m===6?t.setTitle(l(n++).substring(6)):m===7?t.setAccDescription(l(n++).substring(15)):m===12?t.setAccDescription(l(n++).trim()):(n++,m===8?(r[n]!==9&&s("'acc_title_value'"),t.setTitle(l(n++).trim())):(r[n]!==11&&s("'acc_descr_value'"),t.setAccDescription(l(n++).trim())))},p=m=>{n++;let b=c();if(m<=26)t.addPersonOrSystem(ip[m-19],b);else if(m<=32)t.addContainer(ip[m-19],b);else if(m<=38)t.addComponent(ip[m-19],b);else{if(m<=45)return m===39?b.splice(2,0,"ENTERPRISE"):m===40?b.splice(2,0,"SYSTEM"):m===42&&b.splice(2,0,"CONTAINER"),m>=43?t.addDeploymentNode(XC[m-43],b):m===42?t.addContainerBoundary(b):t.addPersonOrSystemBoundary(b),r[n]===62?(n++,o(13)):r[n]===13?(n++,o(62),r[n]===13&&n++):s("'NEWLINE', 'LBRACE'"),!0;m<=53?(m===53&&b.splice(0,1),t.addRel(jC[m-46],b)):m===54?t.updateElStyle("update_el_style",b):m===55?t.updateRelStyle("update_rel_style",b):t.updateLayoutConfig("update_layout_config",b)}return!1},h=r[n];(h<14||h>18)&&s(VC),n++,o(13);let g=0,u=0;for(;;){let m=r[n];if(u===3||u===4){if(m===13){n++,u=2;continue}if(u===3&&By(m)){u=1;continue}}else if(By(m)){p(m)?(g++,u=1):u=4;continue}else if(ZC(m)&&u!==1){f(m),u=3;continue}else u!==2&&s("'title', 'accDescription', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'PERSON', 'REL'");if(g>0)m!==63&&s("'NEWLINE', 'RBRACE'"),n++,t.popBoundaryParseStack(),g--,u=4;else{m!==64&&s("'NEWLINE', 'EOF'"),n++,o(0),t.setC4Type(l(0));return}}}function $n(e,t,r,a,i,n,l,s){let o=0,c=1;if(l===0){if(i<e||i>r)return 1/0}else{let f=(e-i)/l,p=(r-i)/l;o=Math.max(o,Math.min(f,p)),c=Math.min(c,Math.max(f,p))}if(s===0){if(n<t||n>a)return 1/0}else{let f=(t-n)/s,p=(a-n)/s;o=Math.max(o,Math.min(f,p)),c=Math.min(c,Math.max(f,p))}return o<=c?o:1/0}function _l(e,t,r,a,i,n,l,s){let o=l/r,c=s/a,f=(i-e)/r,p=(n-t)/a,h=o*o+c*c,g=2*(o*f+c*p),u=f*f+p*p-1,m=g*g-4*h*u;if(h===0||m<0)return 1/0;let b=(-g-Math.sqrt(m))/(2*h);return b>=0&&b<=1?b:u<=0?0:1/0}function la(e,t,r,a,i){let{x:n,y:l,w:s,h:o}=e,c=a-t,f=i-r;if(e.form==="person")return Math.min($n(n,l+pp,n+s,l+o,t,r,c,f),_l(n+s/2,l+14,13,13,t,r,c,f));if(e.form==="cyl"){let p=Vy(s);return Math.min($n(n,l+p,n+s,l+o-p,t,r,c,f),_l(n+s/2,l+p,s/2,p,t,r,c,f),_l(n+s/2,l+o-p,s/2,p,t,r,c,f))}if(e.form==="h-cyl"){let p=Ky(o);return Math.min($n(n+p,l,n+s-p,l+o,t,r,c,f),_l(n+p,l+o/2,p,o/2,t,r,c,f),_l(n+s-p,l+o/2,p,o/2,t,r,c,f))}return $n(n,l,n+s,l+o,t,r,c,f)}function Zy(e,t,r,a,i){for(let n=2;n<e.length;n+=2){let l=e[n-2],s=e[n-1];if($n(t,r,a,i,l,s,e[n]-l,e[n+1]-s)<=1)return!0}return!1}function Uc(e,t){return e.x<=t.x&&e.y<=t.y&&e.x+e.w>=t.x+t.w&&e.y+e.h>=t.y+t.h}function t_(e,t,r){let a=e.x+e.w/2,i=e.y+e.h/2,n=t.x+t.w/2,l=t.y+t.h/2,s=Uc(e,t);if(s||Uc(t,e)){let R=s?e:t,L=s?t:e,P=L.x+L.w/2,B=L.y+L.h/2,G=L.x-R.x,C=R.x+R.w-L.x-L.w,Z=L.y-R.y,ee=R.y+R.h-L.y-L.h,H=Math.min(G,C,Z,ee),Y=H===G?R.x:H===C?R.x+R.w:P,_=H===G||H===C?B:H===ee?R.y+R.h:R.y,S=Math.min(la(L,Y,_,P,B),1),$=Y+(P-Y)*S,y=_+(B-_)*S;return s?[Y,_,$,y]:[$,y,Y,_]}let o=a,c=i,f=n,p=l,h=Math.max(e.x,t.x),g=Math.min(e.x+e.w,t.x+t.w),u=Math.max(e.y,t.y),m=Math.min(e.y+e.h,t.y+t.h);h<g?o=f=(h+g)/2:u<m&&(c=p=(u+m)/2);let b=Math.hypot(f-o,p-c)||1,w=-(p-c)/b*r,v=(f-o)/b*r,k=la(e,f+w,p+v,o+w,c+v),O=la(t,o+w,c+v,f+w,p+v);return k<=1&&O<=1?(o+=w,c+=v,f+=w,p+=v):(o=a,c=i,f=n,p=l,k=Math.min(la(e,f,p,o,c),1),O=Math.min(la(t,o,c,f,p),1)),[f+(o-f)*k,p+(c-p)*k,o+(f-o)*O,c+(p-c)*O]}function i_(e,t,r){let a=e.length,i=Math.sign(e[2]-e[0]),n=Math.sign(e[3]-e[1]),l=`M${d(e[0]+i*t)},${d(e[1]+n*t)}`;for(let c=2;c<a-2;c+=2){let f=e[c],p=e[c+1],h=Math.sign(f-e[c-2]),g=Math.sign(p-e[c-1]),u=Math.sign(e[c+2]-f),m=Math.sign(e[c+3]-p),b=Math.min(JC,Math.abs(f-e[c-2]+p-e[c-1])/2,Math.abs(e[c+2]-f+e[c+3]-p)/2);l+=`${h?"H"+d(f-h*b):"V"+d(p-g*b)}Q${d(f)},${d(p)} ${d(f+u*b)},${d(p+m*b)}`}let s=Math.sign(e[a-2]-e[a-4]),o=Math.sign(e[a-1]-e[a-3]);return l+(s?"H"+d(e[a-2]-s*r):"V"+d(e[a-1]-o*r))}function Qy(e,t,r,a){for(let i of t)if(i!==r&&i!==a&&Zy(e,i.x,i.y,i.x+i.w,i.y+i.h))return!1;return!0}function Jy(e,t,r,a,i){let n=e.length;return{d:i_(e,r,a),sx:e[0],sy:e[1],sdx:-Math.sign(e[2]-e[0]),sdy:-Math.sign(e[3]-e[1]),ex:e[n-2],ey:e[n-1],edx:Math.sign(e[n-2]-e[n-4]),edy:Math.sign(e[n-1]-e[n-3]),x0:e[t],y0:e[t+1],x1:e[t+2],y1:e[t+3],nx:0,ny:0,lean:0,room:Hc,...i,points:e}}function Hy(e,t){let r=[],a=(e+t)/2,i=Math.max(Xy,(t-e)/4);for(let n=0;n<9;n++){let l=a+(n&1?1:-1)*Math.ceil(n/2)*i;l>=e+hp&&l<=t-hp&&r.push(l)}return r}function n_(e,t,r,a,i,n){let l=e.x+e.w/2,s=e.y+e.h/2,o=t.x+t.w/2,c=t.y+t.h/2,f,p=(m,b,w)=>{if(!Qy(m,r,e,t))return;for(let k=2;k<m.length;k+=2){let O=m[k]===m[k-2];if(!a.free(O,O?m[k]:m[k+1],O?m[k-1]:m[k-2],O?m[k+1]:m[k]))return}let v=a.crossings(m)*1e6;for(let k=2;k<m.length;k+=2)v+=Math.abs(m[k]-m[k-2])+Math.abs(m[k+1]-m[k-1]);(!f||v<f.cost)&&(f={points:m,cost:v,upright:b,sides:w})};if(e.x+e.w<=t.x||t.x+t.w<=e.x){let m=o>l,b=Math.sign(c-s),w=m?[1,0]:[0,1],v=Hy(m?e.x+e.w:t.x+t.w,m?t.x:e.x);e:for(let k of a.ports(e,w[0],s+b*e.h/4,e.y+8,e.y+e.h-8))for(let O of a.ports(t,w[1],c-b*t.h/4,t.y+8,t.y+t.h-8))for(let R of v){let L=R+(l-R)*Math.min(la(e,R,k,l,k),1),P=R+(o-R)*Math.min(la(t,R,O,o,O),1),B=f;if(p([L,k,R,k,R,O,P,O],!0,w),f!==B)break e}}if(e.y+e.h<=t.y||t.y+t.h<=e.y){let m=c>s,b=Math.sign(o-l),w=m?[3,2]:[2,3],v=Hy(m?e.y+e.h:t.y+t.h,m?t.y:e.y);e:for(let k of a.ports(e,w[0],l+b*e.w/4,e.x+8,e.x+e.w-8))for(let O of a.ports(t,w[1],o-b*t.w/4,t.x+8,t.x+t.w-8))for(let R of v){let L=R+(s-R)*Math.min(la(e,k,R,k,s),1),P=R+(c-R)*Math.min(la(t,O,R,O,c),1),B=f;if(p([k,L,k,R,O,R,O,P],!1,w),f!==B)break e}}if(!f)return;let{points:h,upright:g,sides:u}=f;return a.take(h),a.claim(e,u[0],g?h[1]:h[0]),a.claim(t,u[1],g?h[7]:h[6]),Jy(h,2,i,n,{room:g?cp:Hc})}function s_(e,t,r,a,i,n,l){if(e===t){let b=Math.min(e.h/2-4,10),w=Math.hypot(ds,b),v=e.x+e.w,k=e.y+e.h/2,O=ds/w,R=b/w;return{d:`M${d(v+O*n)},${d(k-b-R*n)}C${d(v+ds)},${d(k-b*2)} ${d(v+ds)},${d(k+b*2)} ${d(v+O*l)},${d(k+b+R*l)}`,sx:v,sy:k-b,sdx:-O,sdy:R,ex:v,ey:k+b,edx:-O,edy:-R,x0:v+ds+4,y0:k,x1:v+ds+4,y1:k,nx:1,ny:0,lean:0,room:64,points:[]}}let[s,o,c,f]=t_(e,t,r),p=s===c,h=!1;if(a&&!Uc(e,t)&&!Uc(t,e))for(let b of a)b!==e&&b!==t&&$n(b.x,b.y,b.x+b.w,b.y+b.h,s,o,c-s,f-o)<=1&&(h=!0);if(a&&h&&!p&&o!==f){let b=n_(e,t,a,i,n,l);if(b)return b;i.squeezed++}if(a&&h&&(p||o===f)){let b=M=>{let N=M?-1/0:1/0,F=U=>{let D=p?U.x:U.y;N=M?Math.max(N,D+(p?U.w:U.h)):Math.min(N,D)};F(e),F(t);for(let U of a)U!==e&&U!==t&&$n(U.x,U.y,U.x+U.w,U.y+U.h,s,o,c-s,f-o)<=1&&F(U);return N},w=p?Math.min(e.y,t.y):Math.min(e.x,t.x),v=p?Math.max(e.y+e.h,t.y+t.h):Math.max(e.x+e.w,t.x+t.w),k=(M,N)=>{for(let F of a){if(F===e||F===t)continue;let U=p?F.y<v&&F.y+F.h>w:F.x<v&&F.x+F.w>w,D=p?F.x:F.y,I=D+(p?F.w:F.h);if(U&&(M?I>N:D<N))return!1}return!0},O=e.x+e.w/2,R=e.y+e.h/2,L=t.x+t.w/2,P=t.y+t.h/2,B=Math.sign(p?P-R:L-O),G=M=>{let N=b(M),F=M?1:-1,U=p?M?1:0:M?3:2,D=p?i.ports(e,U,R+B*e.h/4,e.y+8,e.y+e.h-8)[0]:i.ports(e,U,O+B*e.w/4,e.x+8,e.x+e.w-8)[0],I=p?i.ports(t,U,P-B*t.h/4,t.y+8,t.y+t.h-8)[0]:i.ports(t,U,L-B*t.w/4,t.x+8,t.x+t.w-8)[0],z=j=>{if(p){let W=j+(O-j)*Math.min(la(e,j,D,O,D),1),X=j+(L-j)*Math.min(la(t,j,I,L,I),1);return[W,D,j,D,j,I,X,I]}let Q=j+(R-j)*Math.min(la(e,D,j,D,R),1),K=j+(P-j)*Math.min(la(t,I,j,I,P),1);return[D,Q,D,j,I,j,I,K]},q=z(N+F*Rl);for(let j=0;j<=4;j++){let Q=N+F*(Rl+j*Xy),K=z(Q);if(Qy(K,a,e,t)&&(q=K,i.free(p,Q,D,I)))return{points:q,side:U,p0:D,p1:I,step:j}}return{points:q,side:U,p0:D,p1:I,step:5}},C=p?f>o:c<s,Z=k(C,b(C)),ee=k(!C,b(!C)),H=G(C),Y=Z===ee?G(!C):void 0,_=M=>i.crossings(M.points)*8+M.step,S=ee&&!Z||Y&&_(Y)<_(H)?!C:C,{points:$,side:y,p0:E,p1:x,step:T}=S===C?H:Y??G(!C),A=S?1:-1;return T>4&&i.squeezed++,i.take($),i.claim(e,y,E),i.claim(t,y,x),Jy($,2,n,l,p?{nx:A,lean:e_,room:cp}:{room:Hc})}let g=Math.hypot(c-s,f-o)||1,u=(c-s)/g,m=(f-o)/g;return(p||o===f)&&i.take([s,o,c,f]),{d:`M${d(s+u*n)},${d(o+m*n)}L${d(c-u*l)},${d(f-m*l)}`,sx:s,sy:o,sdx:-u,sdy:-m,ex:c,ey:f,edx:u,edy:m,x0:s,y0:o,x1:c,y1:f,nx:r?-m:0,ny:r?u:0,lean:0,room:Math.abs(u)>Math.abs(m)?cp:Hc,points:[s,o,c,f]}}function d_(e){let t=np.get((e.shape??"").toLowerCase())??np.get((e.sprite??"").toLowerCase());if(t)return t;if(e.tags)for(let a of e.tags.split(",")){let i=np.get(a.trim().toLowerCase());if(i)return i}let r=e.kind;return r.endsWith("person")?"person":r.endsWith("_db")?"cyl":r.endsWith("_queue")?"h-cyl":"rect"}function f_(e,t,r,a,i=dp){let n=d_(e),l=n==="h-cyl"?36:0,s=n==="person"?pp:n==="cyl"?24:0,o=i-2*Uy-l,c=[ze("\xAB"+e.kind.replace(/_/g," ")+"\xBB",!1,t,a-1,o),ze(e.label,!1,t,r,o,1),ze(e.techn?`[${e.techn}]`:void 0,!1,t,a,o),ze(e.descr,!1,t,a,o)],f=0,p=c[3].height>0?4:0;for(let h of c)f=Math.max(f,h.width),p+=h.height;return{shape:e,form:n,labels:c,textH:p,x:0,y:0,w:Math.max(i,f+2*Uy+l),h:Math.max(l_,p+2*o_+s)}}function Gy(e,t,r,a,i){let n=0,l=0;for(let s=0;s<e.length;s+=t){let o=Math.min(e.length,s+t),c=0,f=0;for(let p=s;p<o;p++)f=Math.max(f,e[p].h);for(let p=s;p<o;p++){let h=e[p];h.x=c,h.y=l,i&&(h.h=f),c+=h.w+r}n=Math.max(n,c-r),l+=f+a}return[n,e.length>0?l-a:0]}function p_(e,t,r,a,i,n){let l=i===void 0?qy:12,s=new Map;for(let m of e.boundaries){let b=i===void 0?4e3:Math.max(80,i-2*Nl-2*qy*2),w=m.parent?[ze(m.label,!1,t,r,b,1),ze(m.type?`[${m.type}]`:void 0,!1,t,a,b),ze(m.descr,!1,t,a,b)]:[],v=0,k=0;for(let O of w)v+=O.height,k=Math.max(k,O.width);s.set(m,{boundary:m,kids:[],nodes:[],labels:w,head:v>0?v+fp+6+Rl:l,headW:k,headX:Nl,x:0,y:0,w:0,h:0,form:"rect"})}let o=s.get(e.boundaries[0]);for(let m of s.values()){let b=m.boundary.parent;b&&s.get(b)?.kids.push(m)}let c=[o],f=new Map([[o.boundary,0]]);for(let m=0;m<c.length;m++)for(let b of c[m].kids)f.set(b.boundary,f.get(c[m].boundary)+1),c.push(b);for(let m of e.shapes)if(m.parent){let b=f.get(m.parent)??0,w=i===void 0?dp:Math.max(100,Math.min(dp,i-2*b*l-32));s.get(m.parent)?.nodes.push(f_(m,t,r,a,w))}let p=Math.max(1,e.shapeInRow),h=Math.max(1,e.boundaryInRow),g=new Map;for(let m=c.length-1;m>=0;m--){let b=c[m],w=i===void 0?c_:n,v=(G,C,Z)=>{if(i===void 0)return C;let ee=1;for(let H of G)ee=Math.max(ee,H.w);return Math.max(1,Math.min(C,Math.floor((i+Z-2*l)/(ee+Z))))},[k,O]=Gy(b.nodes,v(b.nodes,p,w),w,h_,!0),[R,L]=Gy(b.kids,v(b.kids,h,Fc),Fc,Fc,!1),P=O>0&&L>0?Fc:0,B=b===o?0:l;g.set(b,O+P),b.w=Math.max(k,R,b.headW+2*Nl-2*B)+2*B,b.h=(B&&b.head)+O+P+L+B}let u=new Map;for(let m of c){let b=m.x+(m===o?0:l),w=m.y+(m===o?0:m.head);for(let v of m.nodes)v.x+=b,v.y+=w,u.set(v.shape,v);for(let v of m.kids)v.x+=b,v.y+=w+g.get(m);m!==o&&u.set(m.boundary,m)}return{order:c,boxes:u}}function Bc(e,t,r){let a=[];return e&&a.push("fill:"+e),t&&a.push("stroke:"+t),r&&a.push("color:"+r),vt(a)}function lp(e,t,r,a,i){return t?ua(e,Sa(t.includes("\xB6\xDF")?t.replace(/\ufb02\u00b0\u00b0?/g,"#").replace(/\u00b6\u00df/g,";"):t),r,a,i):e}function y_(e,t,r){return Nr(r,a=>{if(!a)return op(e,t,r,!1)[0];let[i,n]=op(e,t,r,!0,Yc);for(let l=Yc+sp;n>0&&l<=Yc+3*sp;l+=sp){let[s,o]=op(e,t,r,!0,l);o<n&&([i,n]=[s,o])}return i})}function op(e,t,r,a,i=Yc){let n=r.fontSize??16,l=Math.round(n*.8125),s=r.measurer??et(r.fontFamily),o=r.padding??8,c=[],{order:f,boxes:p}=p_(e,s,n,l,a?Math.max(80,(r.maxWidth??320)-2*o):void 0,i),h=f[0],g=0,u=0,m=h.w,b=h.h,w=(M,N,F,U)=>{g=Math.min(g,M),u=Math.min(u,N),m=Math.max(m,F),b=Math.max(b,U)},v=[],k=new Map;for(let M of e.rels){let N=M.fromAttr?void 0:e.getC4Shape(M.from),F=M.toAttr?void 0:e.getC4Shape(M.to),U=N&&p.get(N),D=F&&p.get(F);if(!U||!D)throw new je(`C4 rel "${M.from}" -> "${M.to}" references an unknown shape or boundary`,"semantic",{type:"c4"});v.push(U,D);let I=k.get(U);I||k.set(U,I=new Set),I.add(D)}let O=[],R=[];for(let M of f)for(let N of M.nodes)O.push(N),R.push(N.x+Wc,N.y+Wc,N.x+N.w-Wc,N.y+N.h-Wc);let L=e.rels.length*(O.length+f.length+3*e.rels.length)<=m_,P=(M,N,F,U)=>{let D=0;for(let I=0;I<R.length;I+=4){let z=Math.min(F,R[I+2])-Math.max(M,R[I]);if(z<=0)continue;let q=Math.min(U,R[I+3])-Math.max(N,R[I+1]);q>0&&(D+=z*q)}return D},B=M=>M?Math.max(-jy,Math.min(jy,M)):0,G="",C=gt("arrow_point"),Z=new a_;for(let M of f)M!==h&&Z.frame(M);let ee=e.rels.map((M,N)=>{let F=v[N*2],U=v[N*2+1],D=Bc(void 0,M.lineColor,void 0),I=D.stroke?Ve(D.stroke):"var(--_l)",z=M.type==="birel"||M.type==="rel_b",q=M.type!=="rel_b",j=F!==U&&k.get(U)?.has(F)===!0,Q=s_(F,U,j?u_:0,L?O:void 0,Z,z?C:0,q?C:0);return w(Math.min(Q.x0,Q.x1),Math.min(Q.y0,Q.y1),Math.max(Q.x0,Q.x1),Math.max(Q.y0,Q.y1)),z&&L&&R.push(Q.sx-Yt,Q.sy-Yt,Q.sx+Yt,Q.sy+Yt),q&&L&&R.push(Q.ex-Yt,Q.ey-Yt,Q.ex+Yt,Q.ey+Yt),G+=`<g class="pele-edge" data-id="${Oe(M.from+"-"+M.to)}"${D.line}><path d="${Q.d}"/>`+(z?bt("arrow_point",Q.sx,Q.sy,Q.sdx,Q.sdy,I):"")+(q?bt("arrow_point",Q.ex,Q.ey,Q.edx,Q.edy,I):"")+"</g>",Q});for(let M of f){if(!L||M.headW===0)continue;let N=M.y+fp,F=M.y+M.head-Rl,U=1/0;for(let D of[Nl,(M.w-M.headW)/2,M.w-Nl-M.headW]){let I=0;for(let z of ee)Zy(z.points,M.x+D-4,N,M.x+D+M.headW+4,F)&&I++;if(I<U&&(U=I,M.headX=D),I===0)break}R.push(M.x+M.headX-4,N,M.x+M.headX+M.headW+4,F)}let H="";e.rels.forEach((M,N)=>{let F=ee[N],U=M.from+"-"+M.to,D=Bc(void 0,void 0,M.textColor),I=(e.c4Type==="C4Dynamic"?N+1+": ":"")+M.label,z=ze(I,!1,s,l,F.room),q=ze(M.techn?`[${M.techn}]`:void 0,!1,s,l,F.room,2),j=Math.max(z.width,q.width)+8,Q=z.height+q.height;if(Q===0)return;let K=Math.abs(F.nx)*(j/2)+Math.abs(F.ny)*(Q/2)+2,W=F.lean?Math.max(0,Math.min(F.lean,K-14)):K,X=F.nx*W+(a?0:B(M.offsetX)),te=F.ny*W+(a?0:B(M.offsetY)),se=.5;if(L){let ne=1/0,J=X!==F.nx*W||te!==F.ny*W;for(let re=0;re<(J?2:1)&&ne>0;re++){let fe=re?F.nx*W:X,ye=re?F.ny*W:te;for(let le of g_){let we=F.x0+(F.x1-F.x0)*le+fe,pe=F.y0+(F.y1-F.y0)*le+ye,ge=P(we-j/2,pe-Q/2,we+j/2,pe+Q/2);if(ge<ne&&(ne=ge,se=le,X=fe,te=ye),ge===0)break}}}let oe=F.x0+(F.x1-F.x0)*se+X,ae=F.y0+(F.y1-F.y0)*se+te-Q/2;L&&R.push(oe-j/2,ae,oe+j/2,ae+Q),w(oe-j/2,ae,oe+j/2,ae+Q),H+=`<g class="pele-edge-label" data-id="${Oe(U)}">`+(M.descr?`<title>${Oe(M.descr)}</title>`:"")+`<rect x="${d(oe-j/2)}" y="${d(ae)}" width="${d(j)}" height="${d(Q)}" rx="3" fill="var(--_bg)"/>`+lp(Re(z,oe,ae+z.height/2,D.text)+Re(q,oe,ae+z.height+q.height/2,` class="pele-c4-techn" fill="var(--_m)"${D.text}`),M.link,U,c,r)+"</g>"});let Y="",_="";for(let M of f){if(M!==h){let N=M.boundary,F=Bc(N.bgColor,N.borderColor,N.fontColor),U=M.x+M.headX,D=M.y+fp,I=yi(M.labels[0],U,D,` class="pele-cluster-label" font-weight="var(--_hw)"${F.text}`);D+=M.labels[0].height,I+=yi(M.labels[1],U,D,` class="pele-c4-type" font-size="${l}" fill="var(--_m)"${F.text}`),D+=M.labels[1].height,I+=yi(M.labels[2],U,D,` class="pele-c4-descr" font-size="${l}" fill="var(--_m)"${F.text}`),Y+=`<g class="pele-cluster pele-c4-${N.nodeType?"node":"boundary"}" data-id="${Oe(N.alias)}"><rect x="${d(M.x)}" y="${d(M.y)}" width="${d(M.w)}" height="${d(M.h)}" fill="none" stroke="var(--_b)"${N.nodeType?"":' stroke-dasharray="6 4"'}${ft(F.shape)}/>`+lp(I,N.link,N.alias,c,r)+"</g>"}for(let N of M.nodes){let F=N.shape,U=F.kind.startsWith("external"),D=Bc(F.bgColor,F.borderColor,F.fontColor),I=' stroke="var(--_b)"'+(U?' stroke-dasharray="4 3"':""),{w:z,h:q,form:j,labels:Q}=N,K=j==="h-cyl"?-Ky(q)/2:0,W=j==="person"?pp/2:j==="cyl"?Vy(z)/2:0,X=` fill="var(--_m)"${D.text}`,te=W-N.textH/2,se=Re(Q[0],K,te+Q[0].height/2,` class="pele-c4-type" font-size="${l-1}"${X}`);te+=Q[0].height,se+=Re(Q[1],K,te+Q[1].height/2,` class="pele-label" font-weight="var(--_hw)"${D.text}`),te+=Q[1].height,se+=Re(Q[2],K,te+Q[2].height/2,` class="pele-c4-techn" font-size="${l}"${X}`),te+=Q[2].height+4,se+=Re(Q[3],K,te+Q[3].height/2,` class="pele-c4-descr" font-size="${l}"${D.text}`),_+=`<g class="pele-node pele-shape-${j} pele-c4-${F.kind}${U?" pele-c4-external":""}" data-id="${Oe(F.alias)}" transform="translate(${d(N.x+z/2)},${d(N.y+q/2)})">`+lp(Ca(j,z,q,` fill="var(${U?"--_bg":"--_s"})"${I}${D.shape}`,I+D.line)+se,F.link,F.alias,c,r)+"</g>"}}let S=ze(e.title,!1,s,n,a?Nt(r):4e3,1),$=S.height>0?S.height+12:0,y=Math.max(m-g,S.width),E=Math.ceil(y+2*o),x=Math.ceil(b-u+$+2*o),T=o-g+(y-(m-g))/2,A=o+$-u;return[{svg:Je("c4",E,x,n,r,e,Re(S,E/2,o+S.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${d(T)},${d(A)})">`+(Y?`<g class="pele-clusters">${Y}</g>`:"")+(G?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${G}</g>`:"")+(_?`<g class="pele-nodes">${_}</g>`:"")+(H?`<g class="pele-edge-labels" font-size="${l}">${H}</g>`:"")+"</g>"),width:E,height:x,links:c},Z.squeezed]}var YC,HC,UC,Wy,qC,rp,ap,ip,jC,XC,VC,KC,ds,Rl,Xy,JC,e_,cp,Hc,pp,Vy,Ky,hp,r_,Yy,a_,dp,l_,Uy,o_,c_,h_,qy,Fc,Nl,fp,np,u_,Yc,sp,jy,Wc,g_,m_,ex,tx=Xe(()=>{un();hi();Ti();tr();zt();pr();ut();wt();YC=new Set(["label","type","descr","techn","sprite","tags","link","bgColor","fontColor","borderColor","shadowing","shape","legendText","legendSprite"]),HC=new Set(["label","descr","techn","sprite","tags","link","textColor","lineColor"]);UC=class{constructor(){he(this,"type","c4");he(this,"c4Type");he(this,"title");he(this,"accTitle");he(this,"accDescr");he(this,"shapes",[]);he(this,"boundaries",[{alias:"global",label:"global",type:"global",parent:void 0}]);he(this,"rels",[]);he(this,"shapeInRow",4);he(this,"boundaryInRow",2);he(this,"shapeIndex",new Map);he(this,"boundaryIndex",new Map);he(this,"relIndex",new Map);he(this,"current",this.boundaries[0]);he(this,"stack",[])}setC4Type(e){this.c4Type=e}setTitle(e){this.title=e}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
107
+ `)}element(e,t,r,a){let i=typeof r=="string"?t.get(r):void 0;return i===void 0&&(i={alias:"",label:"",parent:void 0},e.push(i),typeof r=="string"?(i.alias=r,t.set(r,i)):(i.aliasAttr=r,Il(i,r))),Fy(i,a),i}addPersonOrSystem(e,t){let r=this.element(this.shapes,this.shapeIndex,t[0],t[1]);hs(r,"descr",t[2]),this.finishShape(r,e,t,3)}addContainer(e,t){let r=this.element(this.shapes,this.shapeIndex,t[0],t[1]);hs(r,"techn",t[2]),hs(r,"descr",t[3]),this.finishShape(r,e,t,4)}addComponent(e,t){this.addContainer(e,t)}finishShape(e,t,r,a){Qt(e,"sprite",r[a]),Qt(e,"tags",r[a+1]),Qt(e,"link",r[a+2]),e.kind=t,e.parent=this.current}boundary(e,t){let r=this.element(this.boundaries,this.boundaryIndex,e[0],e[1]);return e[2]===void 0?r.type=t:Qt(r,"type",e[2]),r}open(e){e.parent=this.current,this.stack.push(this.current),this.current=e}addPersonOrSystemBoundary(e,t="system"){let r=this.boundary(e,t);Qt(r,"tags",e[3]),Qt(r,"link",e[4]),this.open(r)}addContainerBoundary(e){this.addPersonOrSystemBoundary(e,"container")}addDeploymentNode(e,t){let r=this.boundary(t,"node");hs(r,"descr",t[3]),Qt(r,"sprite",t[4]),Qt(r,"tags",t[5]),Qt(r,"link",t[6]),r.nodeType=e,this.open(r)}popBoundaryParseStack(){this.current=this.stack.pop()??this.boundaries[0]}addRel(e,t){let r=t[0],a=t[1];if(r===void 0||a===void 0||t[2]===void 0)return;let i=typeof r=="string"&&typeof a=="string",n=i?this.relIndex.get(r)?.get(a):void 0;if(n===void 0){if(n={type:e,from:"",to:"",label:""},this.rels.push(n),i){let l=this.relIndex.get(r);l===void 0&&this.relIndex.set(r,l=new Map),l.set(a,n)}typeof r=="string"?n.from=r:n.fromAttr=r,typeof a=="string"?n.to=a:n.toAttr=a}n.type=e,Fy(n,t[2]),hs(n,"techn",t[3]),hs(n,"descr",t[4]),Qt(n,"sprite",t[5]),Qt(n,"tags",t[6]),Qt(n,"link",t[7])}getC4Shape(e){return this.shapeIndex.get(e)??this.boundaryIndex.get(e)}updateElStyle(e,t){let r=typeof t[0]=="string"?this.getC4Shape(t[0]):void 0;r!==void 0&&(Qt(r,"bgColor",t[1]),Qt(r,"fontColor",t[2]),Qt(r,"borderColor",t[3]),Qt(r,"shadowing",t[4]),Qt(r,"shape",t[5]),Qt(r,"sprite",t[6]),Qt(r,"techn",t[7]),Qt(r,"legendText",t[8]),Qt(r,"legendSprite",t[9]))}updateRelStyle(e,t){let r=t[0],a=t[1],i=typeof r=="string"&&typeof a=="string"?this.relIndex.get(r)?.get(a):void 0;if(i===void 0)return;Qt(i,"textColor",t[2]),Qt(i,"lineColor",t[3]);let n=t[4],l=t[5];typeof n=="string"?i.offsetX=parseInt(n):n!==void 0&&Il(i,n),typeof l=="string"?i.offsetY=parseInt(l):l!==void 0&&Il(i,l)}updateLayoutConfig(e,t){let r=n=>n===void 0?NaN:parseInt(typeof n=="string"?n:n.value),a=r(t[0]),i=r(t[1]);a>=1&&(this.shapeInRow=a),i>=1&&(this.boundaryInRow=i)}},Wy=["$end","INVALID","direction_tb","direction_bt","direction_rl","direction_lr","title","accDescription","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","NEWLINE","C4_CONTEXT","C4_CONTAINER","C4_COMPONENT","C4_DYNAMIC","C4_DEPLOYMENT","PERSON","PERSON_EXT","SYSTEM","SYSTEM_DB","SYSTEM_QUEUE","SYSTEM_EXT","SYSTEM_EXT_DB","SYSTEM_EXT_QUEUE","CONTAINER","CONTAINER_DB","CONTAINER_QUEUE","CONTAINER_EXT","CONTAINER_EXT_DB","CONTAINER_EXT_QUEUE","COMPONENT","COMPONENT_DB","COMPONENT_QUEUE","COMPONENT_EXT","COMPONENT_EXT_DB","COMPONENT_EXT_QUEUE","ENTERPRISE_BOUNDARY","SYSTEM_BOUNDARY","BOUNDARY","CONTAINER_BOUNDARY","NODE","NODE_L","NODE_R","REL","BIREL","REL_U","REL_D","REL_L","REL_R","REL_B","REL_INDEX","UPDATE_EL_STYLE","UPDATE_REL_STYLE","UPDATE_LAYOUT_CONFIG","EOF_IN_STRUCT","ATTRIBUTE_EMPTY","STR","STR_KEY","STR_VALUE","LBRACE","RBRACE","EOF"],qC=new Map([["C4Context",14],["C4Container",15],["C4Component",16],["C4Dynamic",17],["C4Deployment",18],["Person",19],["Person_Ext",20],["System",21],["SystemDb",22],["SystemQueue",23],["System_Ext",24],["SystemDb_Ext",25],["SystemQueue_Ext",26],["Container",27],["ContainerDb",28],["ContainerQueue",29],["Container_Ext",30],["ContainerDb_Ext",31],["ContainerQueue_Ext",32],["Component",33],["ComponentDb",34],["ComponentQueue",35],["Component_Ext",36],["ComponentDb_Ext",37],["ComponentQueue_Ext",38],["Enterprise_Boundary",39],["System_Boundary",40],["Boundary",41],["Container_Boundary",42],["Deployment_Node",43],["Node",43],["Node_L",44],["Node_R",45],["Rel",46],["BiRel",47],["Rel_Up",48],["Rel_U",48],["Rel_Down",49],["Rel_D",49],["Rel_Left",50],["Rel_L",50],["Rel_Right",51],["Rel_R",51],["Rel_Back",52],["RelIndex",53],["UpdateElementStyle",54],["UpdateRelStyle",55],["UpdateLayoutConfig",56]]),rp=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y],ap=/[\n\r\u2028\u2029]/g;ip=["person","external_person","system","system_db","system_queue","external_system","external_system_db","external_system_queue","container","container_db","container_queue","external_container","external_container_db","external_container_queue","component","component_db","component_queue","external_component","external_component_db","external_component_queue"],jC=["rel","birel","rel_u","rel_d","rel_l","rel_r","rel_b","rel"],XC=["node","nodeL","nodeR"],VC="'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'C4_CONTEXT', 'C4_CONTAINER', 'C4_COMPONENT', 'C4_DYNAMIC', 'C4_DEPLOYMENT'",KC="'STR', 'STR_KEY', 'ATTRIBUTE', 'ATTRIBUTE_EMPTY'";ds=28,Rl=20,Xy=7,JC=8,e_=30,cp=88,Hc=160,pp=26,Vy=e=>Math.min(12,Math.max(6,e/14)),Ky=e=>Math.min(12,e/4);hp=6,r_=3,Yy=12,a_=class{constructor(){he(this,"upright",[]);he(this,"level",[]);he(this,"frames",[[],[]]);he(this,"taken",new Map);he(this,"squeezed",0)}free(e,t,r,a){let i=Math.min(r,a),n=Math.max(r,a),l=(s,o)=>{for(let c=0;c<s.length;c+=3)if(Math.abs(s[c]-t)<o&&s[c+1]<n&&s[c+2]>i)return!0;return!1};return!l(e?this.upright:this.level,hp)&&!l(this.frames[e?0:1],r_)}crossings(e){let t=0;for(let r=2;r<e.length;r+=2){let a=e[r]===e[r-2],i=a?e[r]:e[r+1],n=Math.min(a?e[r-1]:e[r-2],a?e[r+1]:e[r]),l=Math.max(a?e[r-1]:e[r-2],a?e[r+1]:e[r]),s=a?this.level:this.upright;for(let o=0;o<s.length;o+=3)s[o]>n&&s[o]<l&&s[o+1]<i&&s[o+2]>i&&t++}return t}frame(e){this.frames[0].push(e.x,e.y,e.y+e.h,e.x+e.w,e.y,e.y+e.h),this.frames[1].push(e.y,e.x,e.x+e.w,e.y+e.h,e.x,e.x+e.w)}take(e){for(let t=2;t<e.length;t+=2)e[t]===e[t-2]?this.upright.push(e[t],Math.min(e[t-1],e[t+1]),Math.max(e[t-1],e[t+1])):e[t+1]===e[t-1]&&this.level.push(e[t+1],Math.min(e[t-2],e[t]),Math.max(e[t-2],e[t]))}ports(e,t,r,a,i){let n=this.taken.get(e)??[],l=[];for(let s=0;s<9&&l.length<4;s++){let o=r+(s&1?1:-1)*Math.ceil(s/2)*Yy;if(o<a||o>i)continue;let c=!0;for(let f=0;f<n.length;f+=2)n[f]===t&&Math.abs(n[f+1]-o)<Yy&&(c=!1);c&&l.push(o)}return l.length?l:[r]}claim(e,t,r){let a=this.taken.get(e);a?a.push(t,r):this.taken.set(e,[t,r])}};dp=216,l_=64,Uy=14,o_=12,c_=100,h_=88,qy=Rl+8,Fc=48,Nl=16,fp=10,np=new Map([["person","person"],["box","rect"],["rounded","rect"],["component","rect"],["cylinder","cyl"],["database","cyl"],["db","cyl"],["queue","h-cyl"],["pipe","h-cyl"]]);u_=7,Yc=36,sp=24,jy=2e3,Wc=8,g_=[.5,.4,.6,.3,.7,.2,.8],m_=2e6;ex={type:"c4",parse(e,t,r){let a=new UC;return r&&(a.title=r),QC(e,a),a},render:y_}});var rx={};_t(rx,{c4:()=>ex});var ax=Xe(()=>{tx()});function x_(e){switch(e){case"[]":return"square";case"()":return"round";case"(())":return"circle";case">]":return"rect_left_inv_arrow";case"{}":return"diamond";case"{{}}":return"hexagon";case"([])":return"stadium";case"[[]]":return"subroutine";case"[()]":return"cylinder";case"((()))":return"doublecircle";case"[//]":return"lean_right";case"[\\\\]":return"lean_left";case"[/\\]":return"trapezoid";case"[\\/]":return"inv_trapezoid";case"<[]>":return"block_arrow";default:return"na"}}function w_(e){switch(e.trim().slice(-1)){case"x":return"arrow_cross";case"o":return"arrow_circle";case">":return"arrow_point";default:return""}}function b_(e){switch(e.trim().charAt(0)){case"x":return"arrow_cross";case"o":return"arrow_circle";case"<":return"arrow_point";default:return"arrow_open"}}function $_(e){return e.includes("==")?"thick":"normal"}function k_(e){return e.includes(".-")?"dotted":"solid"}function nx(e,t){let r=e.flat(),a=-1;for(let i of r)if(i.type==="column-setting"){a=i.columns??-1;break}return{list:r,at:0,parent:t,children:[],columns:a}}function v_(e){let t=e.length,r=[],a=[],i=[],n=[],l=0,s=0,o=(G,C,Z)=>(r.push(G),a.push(C),i.push(s),s=Z,!0),c=(G,C)=>o(G,e.slice(s,C),C),f=G=>{n.push(l),l=G},p=()=>{n.length>0&&(l=n.pop())},h=G=>{for(;G<t&&Ue(e.charCodeAt(G));)G++;return G},g=G=>{for(;G<t;){let C=e.charCodeAt(G);if(C<48||C>57)break;G++}return G},u=G=>{for(;G<t&&Qe(e.charCodeAt(G));)G++;return G},m=G=>e.startsWith(G,s)&&!Qe(e.charCodeAt(s+G.length)),b=()=>(e.charCodeAt(s+1)===96?(f(2),s+=2):(f(1),s++),!0),w=G=>{if(e.charCodeAt(G)!==46)return-1;do G++;while(e.charCodeAt(G)===46);if(e.charCodeAt(G)!==45)return-1;let C=e.charCodeAt(G+1);return C===120||C===111||C===62?G+2:G+1},v=G=>{let C=e.charCodeAt(G);(C===120||C===111||C===60)&&G++;let Z=e.charCodeAt(G);if(Z===46)return w(G);if(Z!==45&&Z!==61)return-1;let ee=G+1;for(;e.charCodeAt(ee)===Z;)ee++;if(ee-G===1)return Z===45?w(ee):-1;let H=e.charCodeAt(ee);return H===120||H===111||H===62?ee+1:ee-G>=3?ee:-1},k=()=>{let G=v(s);if(G>=0)return c(33,h(G));let C=e.charCodeAt(s)===60?s+1:s,Z=e.charCodeAt(C),ee=e.charCodeAt(C+1);return Z===45&&(ee===45||ee===46)||Z===61&&ee===61?(f(6),c(34,h(C+2))):!1},O=G=>{let C=e.indexOf(`
108
+ `,s);return C===-1&&(C=t),p(),c(G,C)},R=(G,C)=>{let Z=u(s);if(Z===s)return!1;for(;e.charCodeAt(Z)===44;){let ee=h(Z+1),H=u(ee);if(H===ee)break;Z=H}return l=C,c(G,Z)},L=G=>{if(Ue(G))return s=h(s+1),!0;let C;switch(G){case 98:if(e.startsWith("block",s)){if(m("block-beta"))return c(2,s+10);if(e.charCodeAt(s+5)===58)return c(3,s+6);if(!Qe(e.charCodeAt(s+5)))return c(2,s+5)}break;case 99:if(e.startsWith("columns",s)){if(C=h(s+7),C>s+7){if(e.startsWith("auto",C)&&!Qe(e.charCodeAt(C+4)))return o(4,"-1",C+4);let Z=g(C);if(Z>C)return o(4,e.slice(C,Z),Z)}}else if(e.startsWith("class",s)){let Z=e.startsWith("Def",s+5),ee=Z?s+8:s+5;if(C=h(ee),C>ee)return f(Z?7:9),c(Z?11:15,C)}break;case 34:return b();case 115:if(e.startsWith("space",s)){if(e.charCodeAt(s+5)===58){let Z=g(s+6);if(Z>s+6)return o(7,e.slice(s+6,Z),Z)}if(!Qe(e.charCodeAt(s+5)))return o(7,"1",s+5)}else if(e.startsWith("style",s)&&(C=h(s+5),C>s+5))return f(11),c(18,C);break;case 100:if(m("default"))return c(8,s+7);break;case 108:if(m("linkStyle"))return c(9,s+9);break;case 105:if(m("interpolate"))return c(10,s+11);break;case 97:if(e.startsWith("accTitle",s)){if(C=h(s+8),e.charCodeAt(C)===58)return f(13),c(21,h(C+1))}else if(e.startsWith("accDescr",s)){C=h(s+8);let Z=e.charCodeAt(C);if(Z===58)return f(14),c(23,h(C+1));if(Z===123)return f(15),s=h(C+1),!0}break;case 101:if(m("end"))return c(26,h(s+3));break;case 45:return e.charCodeAt(s+1)===41?(f(3),c(27,s+2)):k();case 61:return k();case 60:return e.charCodeAt(s+1)===91?(f(4),c(29,s+2)):k();case 40:{let Z=e.charCodeAt(s+1),ee=Z===45||Z===91?2:Z===40?e.charCodeAt(s+2)===40?3:2:1;return f(3),c(27,s+ee)}case 41:case 123:return f(3),c(27,e.charCodeAt(s+1)===G?s+2:s+1);case 62:return f(3),c(27,s+1);case 91:{let Z=e.charCodeAt(s+1);return f(3),c(27,Z===91||Z===124||Z===40||Z===92||Z===47?s+2:s+1)}case 58:{let Z=g(s+1);return Z>s+1?o(36,e.slice(s+1,Z),Z):!1}}for(C=s;C<t;){let Z=e.charCodeAt(C);if(Z<128?px[Z]===1:Ue(Z))break;C++}return C>s&&c(32,C)},P=G=>{let C=e.charCodeAt(s+1),Z=0;switch(G){case 34:return b();case 40:Z=C===45?2:C===40?e.charCodeAt(s+2)===40?3:2:1;break;case 41:Z=C===41?e.charCodeAt(s+2)===41?3:2:C===93?2:1;break;case 125:Z=C===125?2:1;break;case 45:Z=C===41?2:0;break;case 93:Z=C===93||C===41||C===62?2:1;break;case 92:case 47:Z=C===93?2:0;break}return Z===0?!1:(p(),c(28,s+Z))},B=G=>{if(G===41)return p(),p(),o(30,"]>",h(s+1));let C=h(G===44?s+1:s);for(let Z of A_)if(e.startsWith(Z,C)){let ee=h(C+Z.length);return o(31,e.slice(G===44?C:s,ee),ee)}return!1};for(;;){if(s>=t){let Z=-1;switch(l){case 0:Z=37;break;case 1:Z=6;break;case 8:Z=14;break;case 10:Z=17;break;case 12:Z=20;break;case 13:Z=22;break;case 14:Z=24;break;case 15:Z=25;break}s=t,Z!==-1&&o(Z,"",t);break}let G=e.charCodeAt(s),C=!0;switch(l){case 0:C=L(G);break;case 1:if(G===34)p(),s++;else{let Z=e.indexOf('"',s);c(6,Z===-1?t:Z)}break;case 2:if(G===96)C=e.charCodeAt(s+1)===34,C&&(p(),s+=2);else if(G===34)C=!1;else{let Z=s+1;for(;Z<t;){let ee=e.charCodeAt(Z);if(ee===96||ee===34)break;Z++}c(5,Z)}break;case 3:C=P(G);break;case 4:if(G===34)b();else if(G===93&&e.charCodeAt(s+1)===62){let Z=h(s+2);C=e.charCodeAt(Z)===40,C&&(f(5),s=Z+1)}else C=!1;break;case 5:C=B(G);break;case 6:if(G===34)e.charCodeAt(s+1)===96?b():(c(35,s+1),f(1));else{let Z=v(h(s));C=Z>=0,C&&(p(),c(33,h(Z)))}break;case 7:{let Z=12,ee=e.startsWith("DEFAULT",s)?s+7:s,H=h(ee);(ee===s||H===ee)&&(Z=13,ee=u(s),H=h(ee)),C=ee>s&&H>ee,C&&(l=8,c(Z,H));break}case 8:O(14);break;case 9:C=R(16,10);break;case 10:O(17);break;case 11:C=R(19,12);break;case 12:O(20);break;case 13:O(22);break;case 14:O(24);break;case 15:if(G===125)p(),s++;else{let Z=e.indexOf("}",s);c(25,Z===-1?t:Z)}break}if(!C)return r.push(1),a.push(""),i.push(s),{types:r,texts:a,starts:i}}return r.push(0),a.push(""),i.push(t),{types:r,texts:a,starts:i}}function lx(e){let t=e[e.length-1];return Array.isArray(t)?(e.pop(),e.concat(t)):e}function E_(e,t){let{types:r,texts:a,starts:i}=v_(e),n=0,l=h=>{let g=r[n];throw g===1?it("block",e,i[n],"",!0):it("block",e,i[n],`Expecting ${h}, got '${sx[g]}'`)},s=h=>(r[n]!==h&&l(`'${sx[h]}'`),a[n++]),o=()=>{let h=s(32);if(r[n]===27){let g=a[n++],u=s(6);return{id:h,label:u,typeStr:g+s(28)}}if(r[n]===29){let g=a[n++],u=s(6),m=[s(31)];for(;r[n]===31;)m.push(a[n++]);return{id:h,label:u,typeStr:g+s(30),directions:m}}return{id:h}},c=()=>{let h=o(),g=r[n]===36?parseInt(a[n++],10):1,u={id:h.id,label:h.label,type:t.typeStr2Type(h.typeStr),directions:h.directions,widthInColumns:g},m;for(;r[n]===33||r[n]===34;){let b="";r[n++]===34&&(s(35),b=s(6),s(33));let w=a[n-1],v=o(),k=t.edgeStrToEdgeData(w),O=t.edgeStrToEdgeStartData(w),R=t.edgeStrToThickness(w),L=t.edgeStrToPattern(w);m??(m=[{id:u.id,label:u.label,type:u.type,directions:u.directions}]),u={id:v.id,label:v.label,type:t.typeStr2Type(v.typeStr),directions:v.directions},m.push({id:m[m.length-1].id+"-"+v.id,start:m[m.length-1].id,end:v.id,label:b,type:"edge",thickness:R,pattern:L,directions:v.directions,arrowTypeEnd:k,arrowTypeStart:O},u)}return m??u};s(2);let f=[],p=[];for(;;)switch(r[n]){case 32:p.push(c());break;case 4:p.push({type:"column-setting",columns:parseInt(a[n++],10)});break;case 7:{let h=parseInt(a[n++],10);p.push({id:t.generateId(),type:"space",label:"",width:h,children:[]});break}case 2:n++,f.push({list:p,header:void 0}),p=[];break;case 3:n++,r[n]!==32&&l("'NODE_ID'"),f.push({list:p,header:c()}),p=[];break;case 26:{let h=f.pop();if(h===void 0||p.length===0)return l(Ll);n++;let g=t.generateId(),u=lx(p);p=h.list,p.push(h.header===void 0?{id:g,type:"composite",label:"",children:u}:{...h.header,type:"composite",children:u});break}case 11:{n++;let h=s(13).trim();p.push({type:"classDef",id:h,css:s(14).trim()});break}case 15:{n++;let h=s(16).trim();p.push({type:"applyClass",id:h,styleClass:s(17).trim()});break}case 18:{n++;let h=s(19).trim();p.push({type:"applyStyles",id:h,stylesStr:s(20).trim()});break}case 37:f.length>0&&l(Ll+", 'end'"),p.length===0&&l(Ll),t.setHierarchy(lx(p));return;default:l(p.length===0?Ll:Ll+(f.length>0?", 'end'":", 'EOF'"))}}function S_(e){let t=0;if(e)for(let r of e)switch(r.trim()){case"right":t|=Qa;break;case"left":t|=Ja;break;case"up":t|=ei;break;case"down":t|=ti;break;case"x":t|=Qa|Ja;break;case"y":t|=ei|ti;break}return t}function Gc(e){return e!==0&&!(e&(ei|ti))?"x":e!==0&&!(e&(Qa|Ja))?"y":""}function ox(e,t,r){let a=Gc(e),i=Fi(e,Ja)-Fi(e,Qa),n=Fi(e,ei)-Fi(e,ti);if(a==="x"){let l=Math.max(r+8,14)+2*us,s=Math.min(l/2,qc);return{w:Math.max(t+12,16)+s*(e===(Qa|Ja)?2:1),h:l,dx:i*s/2,dy:0}}if(a==="y"){let l=Math.max(t+16,14)+2*us,s=Math.min(l/2,qc);return{w:l,h:Math.max(r+8,16)+s*(e===(ei|ti)?2:1),dx:0,dy:n*s/2}}return{w:Math.max(t+16,24)+Wi*(Fi(e,Ja)+Fi(e,Qa)),h:Math.max(r+8,24)+Wi*(Fi(e,ei)+Fi(e,ti)),dx:i*Wi/2,dy:n*Wi/2}}function T_(e,t,r,a){let i=Gc(e),n=t/2,l=r/2,s;if(i==="x"){let c=Math.min(l,qc),f=l-us,p=e&Ja?-n+c:-n,h=e&Qa?n-c:n;s=[p,-f,h,-f],e&Qa&&s.push(h,-l,n,0,h,l),s.push(h,f,p,f),e&Ja&&s.push(p,l,-n,0,p,-l)}else if(i==="y"){let c=Math.min(n,qc),f=n-us,p=e&ei?-l+c:-l,h=e&ti?l-c:l;s=[f,p,f,h],e&ti&&s.push(n,h,0,l,-n,h),s.push(-f,h,-f,p),e&ei&&s.push(-n,p,0,-l,n,p)}else{let c=e&Ja?-n+Wi:-n,f=e&Qa?n-Wi:n,p=e&ei?-l+Wi:-l,h=e&ti?l-Wi:l,g=(c+f)/2,u=(p+h)/2,m=Math.min(10,(f-c)/2),b=Math.min(10,(h-p)/2);s=[c,p],e&ei&&s.push(g-m,p,g,-l,g+m,p),s.push(f,p),e&Qa&&s.push(f,u-b,n,u,f,u+b),s.push(f,h),e&ti&&s.push(g+m,h,g,l,g-m,h),s.push(c,h),e&Ja&&s.push(c,u+b,-n,u,c,u-b)}let o="";for(let c=0;c<s.length;c+=2)o+=(c?" ":"")+d(s[c])+","+d(s[c+1]);return`<polygon points="${o}" stroke-linejoin="round"${a}/>`}function __(e,t){if(e===0||!Number.isInteger(e))throw new je("Columns must be an integer !== 0.","semantic",{type:"block"});if(t<0||!Number.isInteger(t))throw new je("Position must be a non-negative integer."+t,"semantic",{type:"block"});return e<0?{px:t,py:0}:{px:t%e,py:Math.floor(t/e)}}function I_(e,t,r){let a=e.columns,i=[],n=0,l=0,s=0,o=0;for(let f of e.children){let{px:p,py:h}=__(a,n),g=f.span>=1?Math.min(f.span,C_):1;if(a>0&&g>a-p&&(g=a-p),f.span=g,f.col=p,f.row=h,n+=g,p+g>l&&(l=p+g),h===i.length&&i.push(0),f.children.length===0?i[h]=-1:i[h]>=0&&f.nh>i[h]&&(i[h]=f.nh),f.space)continue;let u=(f.nw-t*(g-1))/g;u>s&&(s=u),f.nh>o&&(o=f.nh)}let c=(i.length-1)*t;for(let f=0;f<i.length;f++)i[f]<0&&(i[f]=o),c+=i[f];e.cols=l,e.heights=i,e.nw=Math.max(e.nw,l*s+(l-1)*t+2*r),e.nh=c+2*r+e.head}function N_(e,t,r){let{cols:a,heights:i}=e,n=i.length,l=(e.w-2*r-(a-1)*t)/a,s=e.h-2*r-e.head-(n-1)*t,o=0;for(let u of i)o+=u;let c=o>0?s/o:0,f=o>0?0:s/n,p=e.x-e.w/2+r,h=e.y-e.h/2+r+e.head,g=0;for(let u of e.children){for(;g<u.row;g++)h+=i[g]*c+f+t;u.w=l*u.span+t*(u.span-1),u.h=i[g]*c+f,u.x=p+u.col*(l+t)+u.w/2,u.y=h+u.h/2}}function R_(e,t){let r=[e];for(let a=0;a<r.length;a++)for(let i of r[a].children)r.push(i);for(let a=r.length-1;a>=0;a--){let i=r[a];i.children.length>0&&I_(i,t,a===0?0:t)}e.w=e.nw,e.h=e.nh,e.x=e.w/2,e.y=e.h/2;for(let a=0;a<r.length;a++){let i=r[a];i.children.length>0&&N_(i,t,a===0?0:t)}return{width:e.w,height:e.h}}function jc(e){return e.kind===0&&(e.shape==="circle"||e.shape==="dbl-circ")}function fs(e,t,r){let a=e.bw/2,i=e.bh/2,n=Math.abs(t-e.x),l=i;return jc(e)?l=Math.sqrt(Math.max(a*a-n*n,0)):e.kind===0&&e.shape==="diam"?l=i*Math.max(1-n/a,0):e.kind===0?l=i-di(e.shape,e.bw,e.bh,r>0?2:0):e.kind===1&&Gc(e.mask)==="x"&&(l=i-us),e.y+r*l}function ps(e,t,r){let a=e.bw/2,i=e.bh/2,n=Math.abs(t-e.y),l=a;return jc(e)?l=Math.sqrt(Math.max(i*i-n*n,0)):e.kind===0&&e.shape==="diam"?l=a*Math.max(1-n/i,0):e.kind===0?l=a-di(e.shape,e.bw,e.bh,r>0?1:3):e.kind===1&&Gc(e.mask)==="y"&&(l=a-us),e.x+r*l}function fx(e,t,r,a){let i=t-e.x,n=r-e.y,l=e.bw/2,s=e.bh/2,o;jc(e)?o=l/(Math.hypot(i,n)||1):e.kind===0&&e.shape==="diam"?o=1/(Math.abs(i)/l+Math.abs(n)/s||1):o=Math.min(i===0?1/0:l/Math.abs(i),n===0?1/0:s/Math.abs(n)),o===1/0&&(o=0),a.push(e.x+i*o,e.y+n*o)}function U_(e,t,r,a,i){let n=i.x-i.bw/2+1,l=i.x+i.bw/2-1,s=i.y-i.bh/2+1,o=i.y+i.bh/2-1;if(e<n&&r<n||e>l&&r>l||t<s&&a<s||t>o&&a>o)return!1;if(e===r||t===a)return!0;let c=r-e,f=a-t,p=(g,u)=>Math.sign(c*(u-t)-f*(g-e)),h=p(n,s);return h===0||p(l,s)!==h||p(l,o)!==h||p(n,o)!==h}function up(e,t,r,a){let i=0;for(let n of a)if(!(n===t||n===r)){for(let l=0;l+3<e.length;l+=2)if(U_(e[l],e[l+1],e[l+2],e[l+3],n)){i++;break}}return i}function q_(e,t,r,a){let i=e.x-e.bw/2,n=e.x+e.bw/2,l=e.y-e.bh/2,s=e.y+e.bh/2,o=t.x-t.bw/2,c=t.x+t.bw/2,f=t.y-t.bh/2,p=t.y+t.bh/2,h=Math.max(i,o),g=Math.min(n,c),u=Math.max(l,f),m=Math.min(s,p),b=g-h>6,w=m-u>6;if(b&&w){let ee=e.bw*e.bh<=t.bw*t.bh?e:t,H=ee===e?t:e,Y=ee.y-ee.bh/2-(H.y-H.bh/2),_=H.y+H.bh/2-(ee.y+ee.bh/2),S=ee.x-ee.bw/2-(H.x-H.bw/2),$=H.x+H.bw/2-(ee.x+ee.bw/2),y=Math.min(Y,_,S,$),E;return y===_?E=[ee.x,fs(ee,ee.x,1),ee.x,H.y+H.bh/2]:y===Y?E=[ee.x,fs(ee,ee.x,-1),ee.x,H.y-H.bh/2]:y===$?E=[ps(ee,ee.y,1),ee.y,H.x+H.bw/2,ee.y]:E=[ps(ee,ee.y,-1),ee.y,H.x-H.bw/2,ee.y],ee===e?E:[E[2],E[3],E[0],E[1]]}if(b){let ee=Math.min(6,(g-h)/2),H=Math.min(Math.max((h+g)/2+r,h+ee),g-ee),Y=t.y>e.y?1:-1;return[H,fs(e,H,Y),H,fs(t,H,-Y)]}if(w){let ee=Math.min(6,(m-u)/2),H=Math.min(Math.max((u+m)/2+r,u+ee),m-ee),Y=t.x>e.x?1:-1;return[ps(e,H,Y),H,ps(t,H,-Y),H]}let v=t.x>e.x?1:-1,k=t.y>e.y?1:-1,O=[ps(e,e.y,v),e.y,t.x,e.y,t.x,fs(t,t.x,-k)],R=[e.x,fs(e,e.x,k),e.x,t.y,ps(t,t.y,-v),t.y],L=Math.abs(t.x-e.x)>=Math.abs(t.y-e.y),P=L?O:R;if(a===void 0)return P;let B=up(P,e,t,a);if(B===0)return P;let G=L?R:O,C=up(G,e,t,a);if(C<B&&(P=G,B=C),B===0)return P;let Z=[];return fx(e,t.x,t.y,Z),fx(t,e.x,e.y,Z),up(Z,e,t,a)<B?Z:P}function G_(e,t,r){let a=e.length,i=e[0],n=e[1],l=e[a-2],s=e[a-1],o=e[2]-i,c=e[3]-n,f=Math.hypot(o,c);o/=f||1,c/=f||1;let p=l-e[a-4],h=s-e[a-3],g=Math.hypot(p,h);if(p/=g||1,h/=g||1,a===4&&t+r>f){let m=f/(t+r);t*=m,r*=m}t=Math.min(t,f),r=Math.min(r,g);let u=`M${d(i+o*t)},${d(n+c*t)}`;if(a===6){let m=Math.max(0,Math.min(D_,f-t,g-r));u+=`L${d(e[2]-o*m)},${d(e[3]-c*m)}Q${d(e[2])},${d(e[3])} ${d(e[2]+p*m)},${d(e[3]+h*m)}`}return u+=`L${d(l-p*r)},${d(s-h*r)}`,{d:u,sx:i,sy:n,sdx:-o,sdy:-c,ex:l,ey:s,edx:p,edy:h}}function ux(e,t){let r=e.bw/2,a=e.bh/2,i=Math.max(1,Math.min(10+5*(t-1),r,a));if(jc(e)){let n=e.x+r*Math.SQRT1_2,l=e.y-r*Math.SQRT1_2,s=2*Math.asin(Math.min(1,i/(2*r))),o=c=>Math.atan2(e.y-r*Math.sin(c)-l,e.x+r*Math.cos(c)-n);return[n,l,i,o(Math.PI/4+s),o(Math.PI/4-s)]}if(e.kind===0&&e.shape==="diam"){let n=Math.atan2(a,r);return[e.x+r/2,e.y-a/2,i,n+Math.PI,n]}return[e.x+r,e.y-a,i,Math.PI,Math.PI/2]}function j_(e,t,r,a){let[i,n,l,s,o]=ux(e,t),c=s+r/l,f=o-a/l,p=(f-c)%(2*Math.PI);p<=0&&(p+=2*Math.PI);let h=i+l*Math.cos(c),g=n+l*Math.sin(c),u=i+l*Math.cos(f),m=n+l*Math.sin(f),b=i+l*Math.cos(s),w=n+l*Math.sin(s),v=i+l*Math.cos(o),k=n+l*Math.sin(o),O=Math.hypot(b-h,w-g),R=Math.hypot(v-u,k-m);return{d:`M${d(h)},${d(g)}A${d(l)},${d(l)} 0 ${p>Math.PI?1:0} 1 ${d(u)},${d(m)}`,sx:b,sy:w,sdx:O>0?(b-h)/O:Math.sin(s),sdy:O>0?(w-g)/O:-Math.cos(s),ex:v,ey:k,edx:R>0?(v-u)/R:-Math.sin(o),edy:R>0?(k-m)/R:Math.cos(o)}}function V_(e,t,r,a,i,n,l){if(l===void 0)return .5;for(let s of X_){let o=e[t]+(e[t+2]-e[t])*s,c=e[t+1]+(e[t+3]-e[t+1])*s,f=!0;for(let p of l)if(p!==i&&p!==n&&Math.abs(o-p.x)<(r+p.bw)/2&&Math.abs(c-p.y)<(a+p.bh)/2){f=!1;break}if(f)return s}return .5}function K_(e,t,r){return Nr(r,a=>Z_(e,t,r,a))}function Z_(e,t,r,a){let i=r.fontSize??16,n=Math.round(i*.875),l=r.measurer??et(r.fontFamily),s=r.padding??8,o=r.icons,c=t.block?.padding,f=Math.min(typeof c=="number"&&c>=0?Math.min(c,200):L_,a?6:1/0),p=a?80:cx,h=U=>{let D=[],I=z=>{for(let q of z)for(let j of q.split(";"))D.push(j)};for(let z of U.classes&&U.classes.length>0?U.classes:F_){let q=e.classes.get(z);q&&I(q.styles)}return U.styles&&I(U.styles),vt(D)},g=(U,D)=>{let I=U.type,z=I==="space"?vt(dx):h(U),q=(z.bold?1:0)|(z.italic?2:0),j=z.fontSize??i,Q=0,K="",W,X=0,te=0,se=0,oe=0,ae=0,ne=0;if(I==="space")Q=3,W=ze(void 0,!1,l,j,p);else if(I==="composite")Q=2,W=ze(U.label,!1,l,j,a?Nt(r):4e3,q),se=W.height>0?W.height+4:0,X=W.width+2*f,te=se+2*f;else if(I==="block_arrow"){Q=1,W=ze(U.label,!1,l,j,p,q);let J=!0;for(let fe of W.lines)for(let ye of fe)(ye.icon!==void 0||ye.text.trim()!=="")&&(J=!1);oe=S_(U.directions);let re=J?ox(oe,0,0):ox(oe,W.width,W.height);X=re.w,te=re.h,ae=re.dx,ne=re.dy}else{K=B_.get(I??"")??"rect",W=ze(U.label,!1,l,j,p,q);let J=Si(K,W.width,W.height);X=J.w,te=K==="cyl"?Math.max(J.h,W.height+40):J.h,ne=J.dy}return{children:[],columns:Q===2?U.columns??-1:-1,span:Q===3?1:U.widthInColumns??1,space:Q===3,head:se,nw:X,nh:te,col:0,row:0,cols:0,heights:z_,x:0,y:0,w:0,h:0,block:U,kind:Q,index:D,shape:K,label:W,style:z,mask:oe,dx:ae,dy:ne,bw:0,bh:0}},u=g(e.root,0);u.nw=0,u.nh=0;let m=[u],b=new Map;for(let U=0;U<m.length;U++){let D=m[U];if(D.kind===2)for(let I of D.block.children??P_){let z=g(I,m.length);D.children.push(z),m.push(z),z.kind!==3&&b.set(I.id,z)}}let w=R_(u,f),v=[];for(let U of m)U.kind===0&&Y_.has(U.shape)?(U.bw=U.nw,U.bh=U.nh):U.kind===1?(U.bw=U.span>1?U.w:U.nw,U.bh=U.nh):(U.bw=U.w,U.bh=U.kind===0&&H_.has(U.shape)?U.nh:U.h),U.kind===0&&U.shape==="cyl"&&(U.dy=Math.min(12,Math.max(6,U.bw/14))/2),(U.kind===0||U.kind===1)&&v.push(U);let k=new Map,O=new Set,R=[],L=[];for(let U of e.edges){let D=b.get(U.start??""),I=b.get(U.end??"");if(D===void 0||I===void 0)continue;let z=Math.min(D.index,I.index)*m.length+Math.max(D.index,I.index);k.set(z,(k.get(z)??0)+1),U.label&&O.add(z),R.push([D,I]),L.push(U)}let P=L.length*v.length<=W_?v:void 0,B=new Map,G=[],C=0,Z=0,ee=w.width,H=w.height,Y=(U,D,I,z)=>{U-I/2<C&&(C=U-I/2),U+I/2>ee&&(ee=U+I/2),D-z/2<Z&&(Z=D-z/2),D+z/2>H&&(H=D+z/2)};for(let U=0;U<L.length;U++){let[D,I]=R[U],z=Math.min(D.index,I.index)*m.length+Math.max(D.index,I.index),q=k.get(z)??1,j=B.get(z)??0;B.set(z,j+1);let Q=ze(L[U].label,!1,l,n,cx),K,W,X;if(D===I){let[te,se,oe]=ux(D,j+1);K=[],Y(te,se,2*oe+2,2*oe+2),W=te+oe+6+Q.width/2,X=se-oe/2}else{let te=O.has(z)?Math.round(n*1.5)+2:14;K=q_(D,I,(j-(q-1)/2)*te,P);let se=K.length,oe=Math.abs(K[2]-K[0])+Math.abs(K[3]-K[1]),ae=Math.abs(K[se-2]-K[se-4])+Math.abs(K[se-1]-K[se-3]),ne=se===6&&ae>oe?2:0,J=Q.width>0?V_(K,ne,Q.width+8,Q.height,D,I,P):.5;W=K[ne]+(K[ne+2]-K[ne])*J,X=K[ne+1]+(K[ne+3]-K[ne+1])*J}Q.width>0&&Y(W,X,Q.width+8,Q.height),G.push({edge:L[U],points:K,loop:D===I?j+1:0,label:Q,lx:W,ly:X})}let _=Cr(e.title,l,i,a?Nt(r):4e3),S=_.height>0?_.height+12:0,$=Math.max(ee-C,_.width),y=s-C+($-(ee-C))/2,E=s+S-Z;for(let U of m)U.x+=y,U.y+=E;let x=Math.ceil($+2*s),T=Math.ceil(H-Z+S+2*s),A="",M="";for(let U=1;U<m.length;U++){let D=m[U];if(D.kind===3)continue;let I=It((D.block.classes??dx).join(" ")),z=Oe(D.block.id);if(D.kind===2){let j=D.y-D.h/2;A+=`<g class="pele-cluster${I}" data-id="${z}"><rect x="${d(D.x-D.w/2)}" y="${d(j)}" width="${d(D.w)}" height="${d(D.h)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${ft(D.style.shape)}/>`+Re(D.label,D.x,j+(D.head+f)/2+2,` class="pele-cluster-label" fill="var(--_m)"${D.style.text}`,o)+"</g>";continue}let q=D.kind===1;M+=`<g class="pele-node pele-shape-${q?"block-arrow":D.shape}${I}" data-id="${z}" transform="translate(${d(D.x)},${d(D.y)})">`+(q?T_(D.mask,D.bw,D.bh,hx+D.style.shape):Ca(D.shape,D.bw,D.bh,hx+D.style.shape,O_+D.style.line))+Re(D.label,D.dx,D.dy,` class="pele-label"${D.style.text}`,o)+"</g>"}let N="",F="";for(let U=0;U<G.length;U++){let{edge:D,points:I,loop:z,label:q}=G[U],j=D.arrowTypeStart??"",Q=D.arrowTypeEnd??"",K;if(z>0)K=j_(R[U][0],z,gt(j),gt(Q));else{for(let X=0;X<I.length;X+=2)I[X]+=y,I[X+1]+=E;K=G_(I,gt(j),gt(Q))}let W=Oe(D.id);if(N+=`<g class="pele-edge" data-id="${W}"><path d="${K.d}"${D.thickness==="thick"?' stroke-width="2.5"':""}${D.pattern==="dotted"?' stroke-dasharray="3 4"':""}/>`+bt(j,K.sx,K.sy,K.sdx,K.sdy,"var(--_l)")+bt(Q,K.ex,K.ey,K.edx,K.edy,"var(--_l)")+"</g>",q.width>0){let X=G[U].lx+y,te=G[U].ly+E;F+=wr(D.id,q,X,te,"",o)}}return{svg:Je("block",x,T,i,r,e,Re(_,x/2,s+_.height/2,' class="pele-title" font-weight="var(--_tw)"')+(A?`<g class="pele-clusters">${A}</g>`:"")+(N?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${N}</g>`:"")+`<g class="pele-nodes">${M}</g>`+(F?`<g class="pele-edge-labels" font-size="${n}">${F}</g>`:"")),width:x,height:T,links:[]}}var ix,M_,sx,A_,px,Ll,Qa,Ja,ei,ti,us,qc,Wi,Fi,C_,L_,cx,D_,hx,O_,dx,P_,z_,F_,W_,B_,Y_,H_,X_,gx,mx=Xe(()=>{Ea();Ti();tr();zt();pr();ut();wt();ix=1e5;M_=class{constructor(e={}){he(this,"type","block");he(this,"title");he(this,"root",{id:"root",type:"composite",children:[],columns:-1});he(this,"blocks",[]);he(this,"edges",[]);he(this,"classes",new Map);he(this,"byId",new Map);he(this,"typeStr2Type",x_);he(this,"edgeStrToEdgeData",w_);he(this,"edgeStrToEdgeStartData",b_);he(this,"edgeStrToThickness",$_);he(this,"edgeStrToPattern",k_);he(this,"warn");he(this,"pending",new Set);he(this,"edgeCount",new Map);he(this,"ids",0);he(this,"colors",0);he(this,"spaces",0);this.warn=e.warn}generateId(){return"id-"+ ++this.ids}addStyleClass(e,t=""){let r=this.classes.get(e);r||(r={id:e,styles:[],textStyles:[]},this.classes.set(e,r));for(let a of t.split(",")){let i=a.indexOf(";"),n=(i===-1?a:a.slice(0,i)+a.slice(i+1)).trim();a.includes("color")&&r.textStyles.push(n.replace("fill","bgFill").replace("color","fill")),r.styles.push(n)}}addStyle2Node(e,t=""){this.named(e).styles=t.split(",")}setCssClass(e,t){var r;for(let a of e.split(","))((r=this.named(a.trim())).classes??(r.classes=[])).push(t)}named(e){let t=this.byId.get(e);return t===void 0&&(t={id:e,type:"na",children:[]},this.byId.set(e,t),this.pending.add(e)),t}setHierarchy(e){let t=[nx(e,this.root)];for(;t.length>0;){let r=t[t.length-1];if(r.at===r.list.length){r.parent.children=r.children,t.pop();continue}let a=r.list[r.at++];switch(r.columns>0&&a.type!=="column-setting"&&typeof a.widthInColumns=="number"&&a.widthInColumns>r.columns&&this.warn?.(`Block ${a.id} width ${a.widthInColumns} exceeds configured column width ${r.columns}`),a.type){case"classDef":this.addStyleClass(a.id,a.css);continue;case"applyClass":this.setCssClass(a.id,a.styleClass??"");continue;case"applyStyles":a.stylesStr&&this.addStyle2Node(a.id,a.stylesStr);continue;case"column-setting":r.parent.columns=a.columns??-1;continue;case"edge":{let s=(this.edgeCount.get(a.id)??0)+1;this.edgeCount.set(a.id,s),a.id=s+"-"+a.id,this.edges.push(a);continue}}a.id??(a.id=this.generateId()),a.label||(a.label=a.type==="composite"?"":a.id);let i=this.byId.get(a.id),n=i===void 0||this.pending.delete(a.id);n?(i&&(a.classes=i.classes,a.styles=i.styles),a.type==="composite"&&(a.colorIndex=this.colors++),this.byId.set(a.id,a)):(a.type!=="na"&&(i.type=a.type),a.label!==a.id&&(i.label=a.label));let l=a.children;if(a.children=[],a.type==="space"){let s=a.width??1;if(!(s<=ix-this.spaces))throw new je(`A block diagram can hold at most ${ix} space blocks.`,"limit",{type:"block"});this.spaces+=Math.max(s,0);for(let o=0;o<s;o++){let c={...a,id:a.id+"-"+o,children:[]};this.byId.set(c.id,c),r.children.push(c)}}else n&&r.children.push(a);l&&l.length>0&&t.push(nx(l,a))}this.blocks=this.root.children??[]}},sx=["$end","INVALID","BLOCK_DIAGRAM_KEY","id-block","COLUMNS","MD_STR","STR","SPACE_BLOCK","DEFAULT","LINKSTYLE","INTERPOLATE","classDef","DEFAULT_CLASSDEF_ID","CLASSDEF_ID","CLASSDEF_STYLEOPTS","class","CLASSENTITY_IDS","STYLECLASS","style","STYLE_ENTITY_IDS","STYLE_DEFINITION_DATA","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","end","NODE_DSTART","NODE_DEND","BLOCK_ARROW_START","BLOCK_ARROW_END","DIR","NODE_ID","LINK","START_LINK","LINK_LABEL","SIZE","EOF"],A_=["right","left","x","y","up","down"],px=new Uint8Array(128);for(let e of[9,10,11,12,13,32,40,41,45,58,60,61,62,91,123,125])px[e]=1;Ll="'NODE_ID', 'COLUMNS', 'SPACE_BLOCK', 'BLOCK_DIAGRAM_KEY', 'id-block', 'classDef', 'class', 'style'";Qa=1,Ja=2,ei=4,ti=8,us=7,qc=20,Wi=12;Fi=(e,t)=>e&t?1:0;C_=1e3;L_=12,cx=200,D_=8,hx=' fill="var(--_s)" stroke="var(--_b)"',O_=' stroke="var(--_b)"',dx=[],P_=[],z_=[],F_=["default"],W_=2e6,B_=new Map([["square","rect"],["round","rounded"],["circle","circle"],["doublecircle","dbl-circ"],["diamond","diam"],["hexagon","hex"],["stadium","stadium"],["subroutine","fr-rect"],["cylinder","cyl"],["rect_left_inv_arrow","odd"],["lean_right","lean-r"],["lean_left","lean-l"],["trapezoid","trap-b"],["inv_trapezoid","trap-t"]]),Y_=new Set(["circle","dbl-circ","diam"]),H_=new Set(["stadium","hex","odd","lean-r","lean-l","trap-b","trap-t"]);X_=[.5,.3,.7,.15,.85];gx={type:"block",math:!0,parse(e,t,r){let a=new M_;return a.title=r,E_(e,a),a},render:K_}});var yx={};_t(yx,{block:()=>gx});var xx=Xe(()=>{mx()});function Ix(e){return e===32||e>=9&&e<=13||e>127&&/\s/.test(String.fromCharCode(e))}function Q_(){let e=1/0;return(t,r)=>{if(!t.startsWith("accDescr",r))return-1;let a=t.length,i=r+8;for(;i<a&&(t.charCodeAt(i)===32||t.charCodeAt(i)===9);)i++;if(t.charCodeAt(i)===58){for(i++;i<a;i++){let l=t.charCodeAt(i);if(l===10||l===13||l===37&&t.charCodeAt(i+1)===37)break}return i}for(;i<a&&Ix(t.charCodeAt(i));)i++;if(t.charCodeAt(i)!==123||i>=e)return-1;let n=t.indexOf("}",i+1);return n===-1&&(e=i),n+1||-1}}function Mt(e,t){return{name:e,pattern:e,longer:t}}function th(e,t){return{...or(e),longer:[t]}}function $p(e){return{name:e,pattern:/[A-Z_a-z][\w-]*/y,first:Nx+"_"}}function kp(e){return{name:e,pattern:/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'/y,first:`"'`}}function rh(e){return[{name:e+"_WHITESPACE",pattern:/[\t \r\n]+/y,hidden:!0,first:` \r
109
+ `},{...jt,name:e+"_YAML",first:"-"},{...sr,name:e+"_DIRECTIVE",first:" %"},{...lr,name:e+"_SINGLE_LINE_COMMENT",first:" %"}]}function ms(e){if(!e.includes("\\"))return e.slice(1,-1);let t=e.length-1,r="";for(let a=1;a<t;a++){let i=e[a];i==="\\"&&a+1<t?(i=e[++a],r+=i==="n"?`
110
+ `:i==="r"?"\r":i==="t"?" ":i):r+=i}return r}function ah(e,t,r,a,i,n){let l=new Zt(Gt(e,t,"railroad"),t,"railroad"),s={$type:r,rules:[]};for(l.expect(0);;){let o=l.kind;if(o===a){let c=Xt(l.take()),f=c[0];s.title=(f==='"'||f==="'")&&c.endsWith(f)?i(c):c}else if(o===a+1)s.accTitle=Vt(l.take());else if(o===a+2)s.accDescr=Kt(l.take());else break}for(;l.kind!==-1;)s.rules.push(n(l));return s}function wp(e){let t=e,r=t.element??t.primary??t.suffix,a=t.alternatives??t.elements??(r?[r]:Rx);if(t.base){a=[t.base];for(let i of t.postfixes)i.except&&a.push(i.except)}return a}function nh(e){return e.length===1?e[0]:{type:"sequence",elements:e}}function sh(e){return e.length===1?e[0]:{type:"choice",alternatives:e}}function lh(e,t){return e.rules.map(r=>({name:r.name,definition:Lx(r.definition,wp,t)}))}function Lx(e,t,r){let a=[e],i=[t(e)],n=[[]];for(;;){let l=a.length-1,s=n[l];if(s.length<i[l].length){let o=i[l][s.length];a.push(o),i.push(t(o)),n.push([])}else{let o=r(a[l],s);if(l===0)return o;a.pop(),i.pop(),n.pop(),n[l-1].push(o)}}}function kx(e,t,r,a){let i={$type:"AbnfConcatenation",elements:[]};return t.alternatives.push(i),{alternation:t,concatenation:i,node:e,close:r,repeat:a}}function J_(e){let t=[],r=kx(void 0,{$type:"AbnfAlternation",alternatives:[]},-2,void 0);for(;;){let a=e.kind===14||e.kind===15?e.take():void 0,i,n=e.kind;switch(n){case 12:i={$type:"AbnfStringLiteral",value:e.take().slice(1,-1)};break;case 13:i={$type:"AbnfNumVal",value:e.take()};break;case 11:i={$type:"AbnfRuleName",name:e.take()};break;case 4:case 6:{e.i++;let l={$type:"AbnfAlternation",alternatives:[]};t.push(r),r=kx({$type:n===4?"AbnfGroup":"AbnfOptionalGroup",element:l},l,n+1,a);continue}default:e.fail("a string, a number, a name, or an opening bracket")}for(;;){r.concatenation.elements.push(a===void 0?{$type:"AbnfElement",primary:i}:{$type:"AbnfElement",repeat:a,primary:i});let l=e.kind;if(l===r.close){e.i++,i=r.node,a=r.repeat,r=t.pop();continue}if(l===3)e.i++,r.concatenation={$type:"AbnfConcatenation",elements:[]},r.alternation.alternatives.push(r.concatenation);else if(l!==12&&l!==13&&l!==11&&l!==4&&l!==6&&l!==14&&l!==15){if(t.length===0)return r.alternation;e.fail(`token of type '${Dx[r.close].name}'`)}break}}}function eI(e){return ah(e,Dx,"RailroadAbnf",8,t=>t.slice(1,-1),t=>{let r=t.expect(11);t.expect(1);let a=J_(t);return t.expect(2),{$type:"AbnfRule",name:r,definition:a}})}function tI(e,t){switch(e.$type){case"AbnfAlternation":return sh(t);case"AbnfConcatenation":return nh(t);case"AbnfElement":{let r=e.repeat;if(!r)return t[0];let a=r.indexOf("*"),i=a===-1,n=a>0||i?parseInt(r,10):0,l=i?n:a<r.length-1?parseInt(r.slice(a+1),10):1/0;return n===0&&l===1?gs(t[0]):Ol(t[0],n,l)}case"AbnfStringLiteral":case"AbnfNumVal":return Dl(e.value);case"AbnfRuleName":return ih(e.name);case"AbnfGroup":return t[0];case"AbnfOptionalGroup":return gs(t[0])}}function aI(e,t){if(e.charCodeAt(t)!==63)return-1;let r=!1;for(let a=t+1;a<e.length;a++){let i=e.charCodeAt(a);if(i===63)return r?a+1:-1;if(i===59)return-1;r||(r=!Ix(i))}return-1}function Sx(e,t,r,a){let i={$type:"EbnfSequence",elements:[]};return t.alternatives.push(i),{choice:t,sequence:i,term:void 0,node:e,close:r,except:a}}function nI(e){let t=[],r=Sx(void 0,{$type:"EbnfChoice",alternatives:[]},-2,!1),a=!1;for(;;){let i,n=e.kind;switch(n){case 20:i={$type:"EbnfTerminal",value:ms(e.take())};break;case 19:i={$type:"EbnfNonTerminal",name:e.take()};break;case 21:i={$type:"EbnfSpecial",text:e.take().slice(1,-1).trim()};break;case 6:case 8:case 10:{e.i++;let l={$type:"EbnfChoice",alternatives:[]};t.push(r),r=Sx({$type:iI[n-6>>1],element:l},l,n+1,a),a=!1;continue}default:e.fail("a terminal, a name, or an opening bracket")}for(;;){a?(r.term.postfixes.push({$type:"EbnfExceptionPostfix",except:i}),a=!1):(r.term={$type:"EbnfTerm",base:i,postfixes:[]},r.sequence.elements.push(r.term));let l=r.term.postfixes;for(;;){let o=e.kind;if(o===12)l.push({$type:"EbnfOptionalPostfix",operator:e.take()});else if(o===13)l.push({$type:"EbnfZeroOrMorePostfix",operator:e.take()});else if(o===14)l.push({$type:"EbnfOneOrMorePostfix",operator:e.take()});else break}let s=e.kind;if(s===r.close){e.i++,i=r.node,a=r.except,r=t.pop();continue}if(s===15)e.i++,a=!0;else if(s===5)e.i++;else if(s===4)e.i++,r.sequence={$type:"EbnfSequence",elements:[]},r.choice.alternatives.push(r.sequence);else if(s!==20&&s!==19&&s!==21&&s!==6&&s!==8&&s!==10){if(t.length===0)return r.choice;e.fail(`token of type '${Ox[r.close].name}'`)}break}}}function sI(e){return ah(e,Ox,"RailroadEbnf",16,ms,t=>{let r=t.expect(19);t.accept(2)||t.expect(1);let a={$type:"EbnfRule",name:r,definition:nI(t)};return t.expect(3),a})}function lI(e,t){switch(e.$type){case"EbnfChoice":return sh(t);case"EbnfSequence":return nh(t);case"EbnfTerm":{let r=t[0],a=1;for(let i of e.postfixes)i.$type==="EbnfOptionalPostfix"?r=gs(r):i.$type==="EbnfExceptionPostfix"?r={type:"sequence",elements:[r,Dl("-"),t[a++]]}:r=Ol(r,i.$type==="EbnfOneOrMorePostfix"?1:0);return r}case"EbnfTerminal":return Dl(e.value);case"EbnfNonTerminal":return ih(e.name);case"EbnfSpecial":return Kc(e.text);case"EbnfGroup":return t[0];case"EbnfOptional":return gs(t[0]);case"EbnfRepetition":return Ol(t[0],0)}}function gp(e){e.i++,e.expect(11);let t=ms(e.expect(18));return e.expect(13),t}function mp(e){return{$type:e,element:void 0}}function hI(e){let t=[];for(;;){let r;switch(e.kind){case 6:r={$type:"RailroadTerminalExpr",value:gp(e)};break;case 1:r={$type:"RailroadNonTerminalExpr",name:gp(e)};break;case 7:r={$type:"RailroadSpecialExpr",text:gp(e)};break;case 4:r={$type:"RailroadSequenceExpr",elements:[]};break;case 8:r={$type:"RailroadChoiceExpr",alternatives:[]};break;case 5:r=mp("RailroadOptionalExpr");break;case 3:r=mp("RailroadOneOrMoreExpr");break;case 2:r=mp("RailroadZeroOrMoreExpr");break;default:e.fail("an expression")}if("elements"in r||"alternatives"in r||"element"in r){e.i++,e.expect(11),t.push(r);continue}for(;;){let a=t[t.length-1];if(a===void 0)return r;if("element"in a)a.element=r;else if(("elements"in a?a.elements:a.alternatives).push(r),e.accept(12))break;e.expect(13),t.pop(),r=a}}}function dI(e){return ah(e,cI,"Railroad",14,ms,t=>{let r=t.expect(17);t.expect(9);let a=hI(t);return t.expect(10),{$type:"RailroadRule",name:r,definition:a}})}function fI(e,t){switch(e.$type){case"RailroadTerminalExpr":return Dl(e.value);case"RailroadNonTerminalExpr":return ih(e.name);case"RailroadSpecialExpr":return Kc(e.text);case"RailroadSequenceExpr":return nh(t);case"RailroadChoiceExpr":return sh(t);case"RailroadOptionalExpr":return gs(t[0]);default:return Ol(t[0],e.$type==="RailroadOneOrMoreExpr"?1:0)}}function Cx(e,t,r){let a={$type:"PegSequence",elements:[]};return t.alternatives.push(a),{choice:t,sequence:a,node:e,operator:r}}function gI(e){let t=[],r=Cx(void 0,{$type:"PegOrderedChoice",alternatives:[]},void 0);for(;;){let a=e.kind===4||e.kind===5?e.take():void 0,i;switch(e.kind){case 16:i={$type:"PegLiteral",value:ms(e.take())};break;case 15:i={$type:"PegIdentifier",name:e.take()};break;case 11:i={$type:"PegAny",dot:e.take()};break;case 9:{e.i++;let n={$type:"PegOrderedChoice",alternatives:[]};t.push(r),r=Cx({$type:"PegGroup",element:n},n,a);continue}default:e.fail("a literal, a name, a dot, or an opening parenthesis")}for(;;){let n={$type:"PegSuffix",primary:i};(e.kind===6||e.kind===7||e.kind===8)&&(n.operator=e.take()),r.sequence.elements.push(a===void 0?{$type:"PegPrefix",suffix:n}:{$type:"PegPrefix",operator:a,suffix:n});let l=e.kind;if(l===10&&t.length>0){e.i++,i=r.node,a=r.operator,r=t.pop();continue}if(l===3)e.i++,r.sequence={$type:"PegSequence",elements:[]},r.choice.alternatives.push(r.sequence);else if(l!==4&&l!==5&&l!==16&&l!==15&&l!==11&&l!==9){if(t.length===0)return r.choice;e.fail("token of type ')'")}break}}}function mI(e){return ah(e,uI,"RailroadPeg",12,ms,t=>{let r=t.expect(15);t.expect(1);let a={$type:"PegRule",name:r,definition:gI(t)};return t.expect(2),a})}function yI(e){switch(e.type){case"terminal":return`"${e.value}"`;case"nonterminal":return e.name;case"special":return e.text;default:return"(...)"}}function xI(e,t){let r=t[0];switch(e.$type){case"PegOrderedChoice":return sh(t);case"PegSequence":return nh(t);case"PegPrefix":return e.operator?Kc(e.operator+yI(r)):r;case"PegSuffix":return e.operator?e.operator==="?"?gs(r):Ol(r,e.operator==="+"?1:0):r;case"PegLiteral":return Dl(e.value);case"PegIdentifier":return ih(e.name);case"PegAny":return Kc(e.dot);case"PegGroup":return r}}function kI(e){let t=$I.exec(e);if(t===null)return;let r=t[1]?.toLowerCase();return r==="ebnf-"?"ebnf":r==="abnf-"?"abnf":r==="peg-"?"peg":"railroad"}function MI(e,t){switch(t){case"ebnf":{let r=sI(e);return[r,oI(r)]}case"abnf":{let r=eI(e);return[r,rI(r)]}case"peg":{let r=mI(e);return[r,wI(r)]}default:{let r=dI(e);return[r,pI(r)]}}}function AI(e,t,r){let[a,i]=MI(t,r);e.notation=r,a.accDescr&&e.setAccDescription(a.accDescr),a.accTitle&&e.setAccTitle(a.accTitle),a.title&&e.setTitle(a.title);for(let n of i)e.addRule(n)}function vI(e,t){let r=kI(e);if(r===void 0)throw new je("No railroad diagram keyword found.","syntax",{type:"railroad"});let a=new bI;return t&&(a.title=t),AI(a,e,r),a}function kn(e,t,r,a){let i=e.railroad?.[t];return typeof i=="number"&&i>=0?Math.min(i,a):r}function Vc(e){return(e.includes("\xB6\xDF")?At(e.replace(/&/g,"&amp;")):e).replace(TI,t=>t===`
111
+ `?"\\n":t==="\r"?"\\r":"\\t")}function Xc(e,t){for(let r=t,a=e.length-1;r<a;r++,a--){let i=e[r];e[r]=e[a],e[a]=i}}function Mp(e){return Math.ceil(e/2)*2}function xp(e,t,r,a,i){let n=i.height/2,l=Math.max(Mp(i.measurer.width(t,i.size,a)+2*i.padding),i.height);return{kind:e,width:l,up:n,down:n,kids:Rx,text:t,id:r,reach:0}}function CI(e,t){if(t===1/0&&e<=1)return"";let r=a=>Number.isFinite(a)?String(a):"\u221E";return e===t?r(e)+"\xD7":t===1/0?"\u2265"+r(e)+"\xD7":e===0?"\u2264"+r(t)+"\xD7":r(e)+"\u2013"+r(t)+"\xD7"}function Px(e,t,r,a){return Math.max(e+t.down+a.sep+r.up,2*a.arc)}function _x(e,t){let r=Math.max(e.up+t.sep,2*t.arc);return{kind:5,width:e.width+4*t.arc,up:r,down:e.down,kids:[e],text:"",id:"",reach:r}}function _I(e,t,r=1/0){let a=new Map,i=[[e,r]];for(let n=0;r!==1/0&&n<i.length;n++){let[l,s]=i[n];a.set(l,s);let o=l.type==="choice"||l.type==="optional"?4*t.arc:l.type==="repetition"?(l.min===0?6:2)*t.arc:l.type==="sequence"?6*t.arc:0;for(let c of wp(l))i.push([c,Math.max(40,s-o)])}return Lx(e,wp,(n,l)=>{let s=a.get(n)??1/0;switch(n.type){case"terminal":{let o=Vc(n.value);return xp(0,/^ +$/.test(o)?"\u2423".repeat(o.length):o,"",4,t)}case"nonterminal":return xp(1,Vc(n.name),n.name,0,t);case"special":return xp(2,"? "+Vc(n.text)+" ?","",2,t);case"sequence":{let o=Math.max(0,l.length-1)*t.gap,c=0,f=0;for(let v of l)o+=v.width,c=Math.max(c,v.up),f=Math.max(f,v.down);let p={kind:3,width:o,up:c,down:f,kids:l,text:"",id:"",reach:0};if(o<=s||l.length<2)return p;let h=[],g=[],u=0,m=()=>{let v=0,k=0;for(let O of g)v=Math.max(v,O.up),k=Math.max(k,O.down);h.push({kind:3,width:u,up:v,down:k,kids:g,text:"",id:"",reach:0}),g=[],u=0};for(let v of l)g.length&&u+t.gap+v.width>Math.max(40,s-6*t.arc)&&m(),u+=(g.length?t.gap:0)+v.width,g.push(v);if(m(),h.length<2)return p;let b=0,w=0;for(let v=0;v<h.length;v++)b=Math.max(b,h[v].width),v&&(w+=h[v-1].down+Math.max(t.sep,2*t.arc)+h[v].up);return{kind:7,width:b+6*t.arc,up:h[0].up,down:w+h[h.length-1].down,kids:h,text:"",id:"",reach:0}}case"choice":{let o=0,c=0;for(let p=0;p<l.length;p++)o=Math.max(o,l[p].width),p>0&&(c=Px(c,l[p-1],l[p],t));let f=l[l.length-1];return{kind:4,width:o+4*t.arc,up:l.length>0?l[0].up:0,down:f?c+f.down:0,kids:l,text:"",id:"",reach:0}}case"optional":return _x(l[0],t);case"repetition":{let{min:o,max:c}=n,f=l[0];if(o===1&&c===1)return f;let p=CI(o,c),h=Math.max(f.down+t.sep,2*t.arc),g=p===""?0:Mp(t.measurer.width(p,Zc,0)),u={kind:6,width:Math.max(f.width,g)+2*t.arc,up:f.up,down:h+(p===""?Da/2+1:Zc+6),kids:[f],text:p,id:"",reach:h};return o===0?_x(u,t):u}}})}function II(e,t,r){return Nr(r,a=>NI(e,t,r,a))}function NI(e,t,r,a){let i=r.fontSize??16,n=kn(t,"fontSize",0,200),l=n||Math.round(i*.875),s=n||i,o=kn(t,"padding",-1,200),c=Math.round(l*1.5),f={measurer:r.measurer??et(r.fontFamily,r.fontFamilyMono),size:l,padding:o<0?12:o,height:Mp(c+(o<0?9:2*o)),gap:Math.min(kn(t,"horizontalSeparation",16,500),a?12:1/0),sep:kn(t,"verticalSeparation",10,500),arc:Math.min(kn(t,"arcRadius",10,200),a?6:1/0)},p=t.railroad?.showMarkers===!1?0:kn(t,"markerRadius",4,50),h=kn(t,"strokeWidth",0,20),g=h>0?` stroke-width="${d(h)}"`:"",u=r.padding??8,{arc:m}=f,b=d(m),w=(F,U,D)=>`a${b},${b} 0 0 ${F} ${U}${b},${D}${b}`,v=w(1,"",""),k=w(0,"",""),O=w(0,"","-"),R=w(1,"","-"),L=w(0,"-",""),P=w(0,"-","-"),B=ze(e.title,!1,f.measurer,i,a?Nt(r):4e3,1),G=B.height>0?B.height+16:0,C=Math.round(s*1.5),Z=l*.35,ee=f.height/2,H="",Y="",_="",S=(F,U,D)=>{D>F&&(H+=`M${d(F)},${d(U)}H${d(D)}`)},$=(F,U,D)=>{let I=[F],z=[U,D];for(;I.length>0;){let q=I.pop(),j=z.pop(),Q=z.pop(),K=q.kids,W=Q+q.width;switch(q.kind){case 3:{let X=W;for(let te=K.length-1;te>=0;te--)X-=K[te].width,I.push(K[te]),z.push(X,j),te>0&&S(X-f.gap,j,X),X-=f.gap;break}case 7:{let X=Q+2*m,te=I.length,se=0;S(Q,j,X);for(let oe=0;oe<K.length;oe++){let ae=K[oe],ne=j+se;if(I.push(ae),z.push(ne,X),oe+1<K.length){let J=K[oe+1],re=se+ae.down+Math.max(f.sep,2*m)+J.up,fe=j+se+ae.down+Math.max(f.sep,2*m)/2;H+=`M${d(X+ae.width)},${d(ne)}H${d(W-2*m)}V${d(fe)}H${d(Q+m)}V${d(j+re)}H${d(X)}`,Y+=`M${d(X-Da)},${d(j+re-Da/2)}l${Da},${Da/2}l${-Da},${Da/2}z`,se=re}else H+=`M${d(X+ae.width)},${d(ne)}H${d(W-m)}V${d(j)}H${d(W)}`}Xc(I,te),Xc(z,2*te);break}case 4:{let X=q.width-4*m,te=Q+m,se=W-m,oe=I.length,ae=0;for(let ne=0;ne<K.length;ne++){let J=K[ne];ne>0&&(ae=Px(ae,K[ne-1],J,f));let re=j+ae,fe=Q+2*m+(X-J.width)/2,ye=ne===K.length-1;ne===0?(S(Q,j,fe),S(fe+J.width,j,W)):H+=(ye?`M${d(Q)},${d(j)}${v}V${d(re-m)}`:`M${d(te)},${d(re-m)}`)+k+(fe>te+m?`H${d(fe)}`:"")+`M${d(fe+J.width)},${d(re)}`+(fe>te+m?`H${d(se-m)}`:"")+O+(ye?`V${d(j+m)}${R}`:""),I.push(J),z.push(re,fe)}Xc(I,oe),Xc(z,2*oe);break}case 5:{let X=K[0],te=Q+2*m;S(Q,j,te),S(te+X.width,j,W),H+=`M${d(Q)},${d(j)}${O}V${d(j-q.reach+m)}${R}H${d(W-2*m)}${v}V${d(j-m)}${k}`,I.push(X),z.push(te,j);break}case 6:{let X=K[0],te=Q+(q.width-X.width)/2,se=j+q.reach,oe=Q+q.width/2;S(Q,j,te),S(te+X.width,j,W),H+=`M${d(Q+m)},${d(j)}${L}V${d(se-m)}${k}H${d(W-m)}${O}V${d(j+m)}${P}`,Y+=`M${d(oe-Da/2)},${d(se)}l${Da},${-Da/2}v${Da}z`,q.text!==""&&(_+=`<text class="pele-edge-label pele-count" x="${d(oe)}" y="${d(se+Zc+3)}" font-size="${Zc}" fill="var(--_m)">${Ve(q.text)}</text>`),I.push(X),z.push(te,j);break}default:{let X=q.text,te=X.startsWith(" ")||X.endsWith(" ")||X.includes(" ")?' xml:space="preserve"':"",se=`<rect x="${d(Q)}" y="${d(j-ee)}" width="${d(q.width)}" height="${d(f.height)}"`,oe=`<text x="${d(Q+q.width/2)}" y="${d(j+Z)}"${te}`;q.kind===0?_+=`<g class="pele-node pele-terminal">${se} rx="${d(ee)}" fill="var(--_s)" stroke="var(--_b)"${g}/>${oe} font-family="${qs}">${Ve(X)}</text></g>`:q.kind===1?_+=`<g class="pele-node pele-nonterminal" data-id="${Oe(q.id)}">${se} fill="var(--_bg)" stroke="var(--_b)"${g}${nt}/>${oe}>${Ve(X)}</text></g>`:_+=`<g class="pele-node pele-special">${se} fill="var(--_bg)" stroke="var(--_b)" stroke-dasharray="4 3"${g}${nt}/>${oe} font-style="italic"><tspan fill="var(--_m)">? </tspan>${Ve(X.slice(2,-2))}<tspan fill="var(--_m)"> ?</tspan></text></g>`}}}},y="",E=B.width,x=u+G,T=u+B.height;for(let F of e.rules){let U=_I(F.definition,f,a?Math.max(80,(r.maxWidth??320)-2*u-4*p-2*yp-1):1/0),D=Vc(F.name),I=x+C+EI+U.up,z=u+2*p,q=z+yp,j=q+U.width+yp;H="",Y="",_="",S(z,I,q),S(q+U.width,I,j),$(U,q,I);let Q=p>0?`<circle class="pele-marker pele-start" cx="${d(u+p)}" cy="${d(I)}" r="${d(p)}" fill="var(--_l)"/><circle class="pele-marker pele-end" cx="${d(j+p)}" cy="${d(I)}" r="${d(p)}" fill="var(--_l)"/>`:"";y+=`<g class="pele-rule" data-id="${Oe(F.name)}"><text class="pele-rule-name" x="${d(u)}" y="${d(x+C/2+s*.35)}" font-size="${d(s)}" font-weight="var(--_hw)" text-anchor="start">${Ve(D)}</text><path class="pele-edge pele-track" d="${H}" fill="none" stroke="var(--_l)"${g}/>`+(Y?`<path class="pele-marker" d="${Y}" fill="var(--_l)"/>`:"")+Q+_+"</g>",E=Math.max(E,j+2*p-u,f.measurer.width(D,s,1)),T=I+U.down,x=T+f.sep+SI}let A=Math.ceil(E+2*u),M=Math.ceil(T+u),N=Re(B,A/2,u+B.height/2,' class="pele-title" font-weight="var(--_tw)"')+(y?`<g class="pele-rules" transform="translate(0.5,0.5)" font-size="${d(l)}" text-anchor="middle">${y}</g>`:"");return{svg:Je("railroad",A,M,i,r,e,N),width:A,height:M,links:[]}}var Nx,Qc,Jc,eh,Rx,Dl,ih,Kc,gs,Ol,wx,bx,$x,Dx,rI,Mx,Ax,vx,Ex,Ox,iI,oI,bp,Bi,cI,pI,Tx,uI,wI,bI,$I,yp,EI,SI,Zc,Da,TI,zx,Fx=Xe(()=>{zt();Vr();ut();wt();Nx="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Qc={name:"TITLE",pattern:/title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|)/y,first:"t"},Jc={name:"ACC_TITLE",pattern:/accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/y,first:"a"},eh={name:"ACC_DESCR",pattern:/accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\s*{([^}]*)})/y,first:"a",scanner:Q_};Rx=[];Dl=e=>({type:"terminal",value:e}),ih=e=>({type:"nonterminal",name:e}),Kc=e=>({type:"special",text:e}),gs=e=>({type:"optional",element:e}),Ol=(e,t,r=1/0)=>({type:"repetition",element:e,min:t,max:r});wx="0123456789",bx={name:"ABNF_RULENAME",pattern:/[A-Za-z][A-Za-z0-9-]*/y,first:Nx},$x={name:"ABNF_COMMENT",pattern:/;[^\n\r]*/y,hidden:!0,first:";"},Dx=[th("railroad-abnf-beta",bx),Mt("="),Mt(";",[$x]),Mt("/"),Mt("("),Mt(")"),Mt("["),Mt("]"),Qc,Jc,eh,bx,{name:"ABNF_STRING",pattern:/"[^"]*"/y,first:'"'},{name:"ABNF_NUMVAL",pattern:/%[xXdDbB][0-9A-Fa-f]+(?:-[0-9A-Fa-f]+|\.[0-9A-Fa-f]+)*/y,first:"%"},{name:"ABNF_REPEAT",pattern:/[0-9]*\*[0-9]*/y,first:wx+"*"},{name:"ABNF_EXACT_REPEAT",pattern:/[0-9]+/y,first:wx},...rh("ABNF"),$x];rI=e=>lh(e,tI);Mx=$p("EBNF_ID"),Ax={name:"EBNF_SPECIAL_SEQUENCE",pattern:/\?(?=[^?;]*[^?\s;][^?;]*\?)[^?;]*\?/y,first:"?",scanner:()=>aI},vx=rh("EBNF"),Ex={name:"EBNF_ISO_COMMENT",pattern:/\(\*[\s\S]*?\*\)/y,hidden:!0,first:"(",opener:/\(\*/y},Ox=[th("railroad-ebnf-beta",Mx),Mt("::="),Mt("="),Mt(";"),Mt("|"),Mt(","),Mt("(",[Ex]),Mt(")"),Mt("["),Mt("]"),Mt("{"),Mt("}"),Mt("?",[Ax]),Mt("*"),Mt("+"),Mt("-",[vx[1]]),Qc,Jc,eh,Mx,kp("EBNF_STRING"),Ax,...vx,{name:"EBNF_BLOCK_COMMENT",pattern:/\/\*[\s\S]*?\*\//y,hidden:!0,first:"/",opener:/\/\*/y},Ex];iI=["EbnfGroup","EbnfOptional","EbnfRepetition"];oI=e=>lh(e,lI),bp=$p("RR_ID"),Bi=e=>Mt(e,[bp]),cI=[th("railroad-beta",bp),Bi("nonterminal"),Bi("zeroOrMore"),Bi("oneOrMore"),Bi("sequence"),Bi("optional"),Bi("terminal"),Bi("special"),Bi("choice"),Mt("="),Mt(";"),Mt("("),Mt(","),Mt(")"),Qc,Jc,eh,bp,kp("RR_STRING"),...rh("RR"),{name:"RR_BLOCK_COMMENT",pattern:/\/\*[\s\S]*?\*\//y,hidden:!0,first:"/",opener:/\/\*/y}];pI=e=>lh(e,fI),Tx=$p("PEG_ID"),uI=[th("railroad-peg-beta",Tx),Mt("<-"),Mt(";"),Mt("/"),Mt("&"),Mt("!"),Mt("?"),Mt("*"),Mt("+"),Mt("("),Mt(")"),Mt("."),Qc,Jc,eh,Tx,kp("PEG_STRING"),...rh("PEG"),{name:"PEG_LINE_COMMENT",pattern:/#[^\n\r]*/y,hidden:!0,first:"#"}];wI=e=>lh(e,xI),bI=class{constructor(){he(this,"type","railroad");he(this,"notation","railroad");he(this,"title");he(this,"accTitle");he(this,"accDescr");he(this,"rules",[]);he(this,"byName",new Map)}setTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
112
+ `)}addRule(e){this.rules.push(e),this.byName.set(e.name,e)}getRule(e){return this.byName.get(e)}},$I=/^\s*railroad-(ebnf-|abnf-|peg-)?beta/i;yp=12,EI=6,SI=18,Zc=12,Da=7;TI=/[\n\r\t]/g;zx={type:"railroad",parse:(e,t,r)=>vI(e,r),render:II}});var Wx={};_t(Wx,{railroad:()=>zx});var Bx=Xe(()=>{Fx()});function dh(e){return e&&(RI.get(e)??e)}function OI(e){return uo(e)||e==="constructor"}function PI(e,t){for(let r of e)r.isGroup||((!r.shape||r.shape==="squareRect"||r.shape==="rect")&&(r.shape=Pl),LI.has(r.shape)?(t.emitError("SHAPE_REMOVED",`shape "${r.shape}" was removed in v0.8.1, using "${Pl}"`,{nodeId:r.id}),r.shape=Pl):DI.has(r.shape)||(t.emitWarning("SHAPE_UNSUPPORTED",`shape "${r.shape}" is not supported, using "${Pl}"`,{nodeId:r.id}),r.shape=Pl))}function WI(e){return FI.has(e.type)}function Ap(e){return e==="markdown"||e==="string"||e==="text"?e:"markdown"}function Yx(e){return e.startsWith('"')&&e.endsWith('"')?e.substring(1,e.length-1):e}function _p(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function BI(e){let t=i=>Array.isArray(i)?[]:_p(i)?{}:i,r=t(e),a=[[e,r]];for(;a.length>0;){let[i,n]=a.pop();if(Array.isArray(i))for(let l of i){let s=t(l);n.push(s),typeof l=="object"&&l!==null&&a.push([l,s])}else if(_p(i))for(let l of Object.keys(i)){if(l==="__proto__"||l==="constructor"||l==="prototype")continue;let s=i[l],o=t(s);n[l]=o,typeof s=="object"&&s!==null&&a.push([s,o])}}return r}function oh(e,t){return Object.assign(e??{},t)}function UI(e){let t=!1,r=!1,a=0,i,n=[];for(let l of e.split(`
113
+ `)){if(i!==void 0){let f=l.length-l.trimStart().length;if(l.trim()===""||f>i){n.push(l);continue}i=void 0}let s=-1;for(let f=0;f<l.length;f++){let p=l[f];if(r)p==="\\"?f++:p==='"'&&(r=!1);else if(t)p==="'"&&(t=!1);else if(p==='"')r=!0;else if(p==="'")t=!0;else if(p==="#"&&(f===0||l[f-1]===" "||l[f-1]===" ")){s=f;break}else p==="["||p==="{"?a++:(p==="]"||p==="}")&&(a=Math.max(0,a-1))}if(t||r||a>0){n.push(l);continue}let o=s>=0?l.slice(0,s):l,c=s>=0?l.slice(s):"";if(YI.test(o)){i=l.length-l.trimStart().length,n.push(l);continue}n.push(o.replace(HI,"$1")+c)}return n.join(`
114
+ `)}function qI(e,t){if(e==="arrow_point"&&t==="normal")return"sequence";if(e==="arrow_cross"&&t==="normal")return"failure";if(e==="arrow_open"&&t==="dotted")return"reference"}function GI(e){let t=e.trim(),r=t.slice(0,-1),a="arrow_open";switch(t.slice(-1)){case"x":a="arrow_cross";break;case">":a="arrow_point";break;case"-":case".":r=t;break}let i="normal",n=r.length-1,l=0;for(let s=0;s<r.length;s++)r[s]==="."&&l++;return l>0&&(i="dotted",n=l),{type:a,stroke:i,length:n}}function Hx(e){if(!e)return;let t={},r=!1;for(let a of Object.keys(e))zI.has(a)||(t[a]=e[a],r=!0);return r?t:void 0}function s5(e){let t=e.length,r=[],a=[],i=[],n=[],l=[],s=0,o=0,c=1,f=0,p=!0,h=e.indexOf("direction"),g=e.indexOf("@"),u=-1,m=0,b=0,w=-1,v=-1,k=-1,O=-1,R=-1,L=-1,P=-1,B=D=>{let I=-1;for(let z=o;z<D;z++){let q=e.charCodeAt(z);q===10?(c++,I=z):q===13&&(z+1<D&&e.charCodeAt(z+1)===10&&z++,c++,I=z)}if(I<0)f+=D-o;else{let z=I+1;for(;z<D;){let q=e.charCodeAt(z);if(q===8232||q===8233)break;z++}f=z-I-1}o=D},G=(D,I)=>{r.push(D),a.push(e.slice(o,I)),i.push(o),n.push(c,f),B(I),n.push(c,f)},C=(D,I)=>{r.push(D),a.push(e.slice(o,I)),i.push(o),n.push(c,f),f+=I-o,o=I,n.push(c,f)},Z=(D,I)=>{r.push(D),a.push(e.slice(o,I)),i.push(o),n.push(c,f);for(let z=o;z<I;z++){let q=e.charCodeAt(z);q===10||q===13?(c++,f=0):f++}o=I,n.push(c,f)},ee=(D,I,z)=>{r.push(D),a.push(I),i.push(o),n.push(c,f),B(z),n.push(c,f)},H=D=>{l.push(s),s=D},Y=()=>{l.length>0&&(s=l.pop())},_=(D,I)=>(D.lastIndex=I,D.test(e)?D.lastIndex:-1),S=D=>e.startsWith(D,o)&&!Qe(e.charCodeAt(o+D.length)),$=D=>{if(D>=v&&D<=k)return k;let I=D;for(;I<t&&Ue(e.charCodeAt(I));)I++;return v=D,k=I,I},y=D=>{if(D>=O&&D<=R)return R;let I=D;for(;I<t;){let z=e.charCodeAt(I);if(z!==32&&z!==9)break;I++}return O=D,R=I,I},E=D=>{let I=$(D);if(I===P||e.charCodeAt(I)!==45||e.charCodeAt(I+1)!==45)return-1;let z=I+2;for(;e.charCodeAt(z)===45;)z++;let q=e.charCodeAt(z);return q===120||q===62?$(z+1):(P=I,-1)},x=()=>{let D=$(o);if(D===L||e.charCodeAt(D)!==45)return!1;let I=e.charCodeAt(D+1),z=D+2;if(I===45){for(;e.charCodeAt(z)===45;)z++;let q=e.charCodeAt(z);return q===120||q===62?G(42,$(z+1)):(H(10),G(43,$(D+2))),!0}if(I===46){for(;e.charCodeAt(z)===46;)z++;if(e.charCodeAt(z)===45)return G(42,$(z+1)),!0}return L=D,!1},T=D=>{if(e.charCodeAt(D)!==37||e.charCodeAt(D+1)!==37||e.charCodeAt(D+2)===123)return-1;let I=e.indexOf(`
115
+ `,D+2);return I===-1?t:I},A=()=>{e.charCodeAt(o+1)===96?(H(2),B(o+2)):(H(1),B(o+1))},M=D=>{let I=e.charCodeAt(o+1);return D===40?(I===45?(H(8),C(47,o+2)):I===91?(H(7),C(49,o+2)):I===40&&e.charCodeAt(o+2)===40?(H(7),C(57,o+3)):(H(7),C(72,o+1)),!0):D===91?(I===91?(H(7),C(51,o+2)):I===40?(H(7),C(55,o+2)):I===47?(H(9),C(60,o+2)):I===92?(H(9),C(61,o+2)):(H(7),C(74,o+1)),!0):D===124?(H(7),C(70,o+1),!0):D===123?(H(7),C(76,o+1),!0):!1},N=()=>{let D=o;for(;D<t;){let I=e.charCodeAt(D);if(I<128&&Kx[I]===1)D++;else if(I===45&&D+1<t){let z=e.charCodeAt(D+1);if(z===62||z===45||z===46)break;D++}else break}return D===o?!1:(C(67,D),!0)},F=D=>{let I=D;for(;I<t;){let z=e.charCodeAt(I);if(z!==32&&z!==9)break;I++}return I},U=D=>{let I;switch(D){case 97:if(e.startsWith("acc",o)){if((I=_(XI,o))>=0)return H(3),G(2,I),!0;if((I=_(VI,o))>=0)return H(4),G(4,I),!0;if((I=_(KI,o))>=0)return H(5),B(I),!0}if(S("agentflow-beta"))return p&&(p=!1,H(6)),C(20,o+14),!0;break;case 64:if(e.charCodeAt(o+1)===123)return H(14),ee(7,"",o+2),!0;break;case 99:if((I=_(ZI,o))>=0)return H(12),B(I),!0;if(S("classDef"))return C(16,o+8),!0;if(S("class"))return C(17,o+5),!0;if((I=_(QI,o))>=0)return H(11),B(I),!0;if(S("connector"))return C(22,o+9),!0;break;case 34:return A(),!0;case 115:if(S("style"))return C(12,o+5),!0;break;case 100:if(S("default"))return C(13,o+7),!0;break;case 108:if(S("linkStyle"))return C(14,o+9),!0;break;case 105:if(S("interpolate"))return C(15,o+11),!0;break;case 104:if(e.startsWith("href",o)&&Ue(e.charCodeAt(o+4)))return G(18,o+5),!0;break;case 102:if(S("flow"))return C(21,o+4),!0;break;case 103:if(S("global"))return C(23,F(o+6)),!0;break;case 101:if(S("end"))return C(24,F(o+3)),!0;break;case 95:if(S("_self"))return C(25,o+5),!0;if(S("_blank"))return C(25,o+6),!0;if(S("_parent"))return C(25,o+7),!0;if(S("_top"))return C(25,o+4),!0;break}if(h!==-1&&o>=m&&(h<o&&(h=e.indexOf("direction",o)),h!==-1&&(u<o&&(vp.lastIndex=o,u=vp.test(e)?vp.lastIndex-1:t),h<u))){for(let z=0;z<5;z++)if((I=_(a5[z],o))>=0)return G(28+z,I),!0;m=u}if(g!==-1&&D!==34&&!Ue(D)){if(o>=b){g<o&&(g=e.indexOf("@",o));let z=o;for(;z<t;){let q=e.charCodeAt(z);if(q===34||Ue(q))break;z++}if(b=z,w=-1,g!==-1&&g<z)for(let q=Math.min(z,t-1)-1;q>=g;q--){if(e.charCodeAt(q)!==64)continue;let j=e.charCodeAt(q+1);if(j!==123&&j!==34){w=q;break}}}if(w>o)return C(33,w+1),!0}if(D>=48&&D<=57){let z=o+1;for(;z<t;){let q=e.charCodeAt(z);if(q<48||q>57)break;z++}return C(34,z),!0}switch(D){case 35:return C(35,o+1),!0;case 58:return e.charCodeAt(o+1)===58&&e.charCodeAt(o+2)===58?C(36,o+3):C(37,o+1),!0;case 38:return C(38,o+1),!0;case 59:return C(39,o+1),!0;case 44:return C(40,o+1),!0;case 42:return C(41,o+1),!0;case 60:return C(62,o+1),!0;case 45:return x()||N()||C(68,o+1),!0;case 40:return M(D);case 91:return e.charCodeAt(o+1)===124?(C(52,o+2),!0):M(D);case 124:case 123:return M(D);case 62:return H(7),C(53,o+1),!0;case 94:return C(63,o+1),!0;case 92:return e.charCodeAt(o+1)===124?(C(64,o+2),!0):N();case 118:return Qe(e.charCodeAt(o+1))?N():(C(65,o+1),!0);case 37:return(I=T(o))>=0?(G(66,I),!0):N()}if(Ue(D)){if(x())return!0;if((D===32||D===9)&&(I=T(y(o)))>=0)return G(66,I),!0;for(I=o;;){let z=e.charCodeAt(I);if(z===10)I++;else if(z===13&&e.charCodeAt(I+1)===10)I+=2;else break}return I>o?G(77,I):G(78,o+1),!0}return D<128?N():Fn(D)?(C(69,o+1),!0):!1};e:for(;;){if(o>=t){let z=-1;switch(s){case 0:z=79;break;case 3:z=3;break;case 4:z=5;break;case 5:z=6;break;case 11:z=19;break;case 12:z=8;break;case 13:z=9;break}z!==-1&&C(z,t);break}let D=e.charCodeAt(o),I=!0;switch(s){case 0:I=U(D);break;case 1:if(D===34)e.charCodeAt(o+1)===96?(H(2),B(o+2)):(Y(),B(o+1));else{let z=e.indexOf('"',o);G(11,z===-1?t:z)}break;case 2:if(D===96)e.charCodeAt(o+1)===34?(Y(),B(o+2)):I=!1;else if(D===34)A();else{let z=o+1;for(;z<t;){let q=e.charCodeAt(z);if(q===96||q===34)break;z++}G(10,z)}break;case 3:case 4:{let z=e.indexOf(`
116
+ `,o);z===-1&&(z=t);let q=s===3?3:5;Y(),G(q,z);break}case 5:if(D===125)Y(),B(o+1);else{let z=e.indexOf("}",o);z===-1&&(z=t),G(6,z)}break;case 6:{let z;D===34?A():(z=_(JI,o))>=0?(Y(),G(26,z)):(z=_(e5,o))>=0||(z=_(t5,o))>=0||(z=_(r5,o))>=0?(Y(),G(27,z)):I=M(D);break}case 7:{let z=e.charCodeAt(o+1);switch(D){case 34:A();break;case 40:case 91:case 123:M(D);break;case 93:Y(),z===41?C(48,o+2):z===93?C(50,o+2):C(73,o+1);break;case 41:Y(),z===93?C(54,o+2):z===41&&e.charCodeAt(o+2)===41?C(56,o+3):C(71,o+1);break;case 124:Y(),C(70,o+1);break;case 125:Y(),C(75,o+1);break;case 37:{let q=T(o);q>=0?B(q):I=!1;break}default:{let q=o+1;for(;q<t;){let j=e.charCodeAt(q);if(j===91||j===93||j===40||j===41||j===123||j===125||j===124||j===34||j===37)break;q++}G(46,q)}}break}case 8:{let z=e.charCodeAt(o+1),q;if(D===34)A();else if(D===37&&(q=T(o))>=0)B(q);else if((D===45||D===47||D===41)&&z===41)Y(),C(45,o+2);else if(D===40||D===91||D===123)M(D);else if(D===41||D===93||D===125)I=!1;else{let j=o+1;for(;j<t;){let Q=e.charCodeAt(j);if(Q===34||Q===40||Q===41||Q===91||Q===93||Q===123||Q===125||(Q===45||Q===47)&&e.charCodeAt(j+1)===41||Q===37&&e.charCodeAt(j+1)===37&&e.charCodeAt(j+2)!==123)break;j++}Z(46,j)}break}case 9:{let z=e.charCodeAt(o+1);if(D===34){A();break}switch(D){case 40:z===45||z===91||z===40&&e.charCodeAt(o+2)===40?M(D):z===93?(Y(),C(58,o+2)):M(D);break;case 91:case 123:M(D);break;case 92:z===93?(Y(),C(58,o+2)):C(46,o+1);break;case 47:z===93?(Y(),C(59,o+2)):C(46,o+1);break;case 93:case 41:z===93?(Y(),C(58,o+2)):I=!1;break;case 125:I=!1;break;case 37:{let q=T(o);q>=0?B(q):I=!1;break}default:{if((D===63||D===61)&&z===93){Y(),C(58,o+2);break}let q=o+1;for(;q<t;){let j=e.charCodeAt(q);if(j===92||j===91||j===93||j===40||j===41||j===123||j===125||j===47||j===37)break;q++}G(46,q)}}break}case 10:{if(D===34){A();break}let z=E(o);if(z>=0){Y(),G(42,z);break}if(D===45&&e.charCodeAt(o+1)===45){I=!1;break}let q=o+1;for(;q<t;){let j=e.charCodeAt(q);if(j===34)break;if(j===45){if(e.charCodeAt(q+1)===45)break}else if(Ue(j)&&E(q)>=0)break;q++}Z(44,q);break}case 11:if(D===34)A();else if(Ue(D))Y(),B(o+1);else{let z=o+1;for(;z<t&&!Ue(e.charCodeAt(z));)z++;C(19,z)}break;case 12:if(D===40){let z=_(i5,o);Y(),z>=0?B(z):(H(13),B(o+1))}else{let z=e.indexOf("(",o);z===-1&&(z=t),G(8,z)}break;case 13:if(D===41)Y(),B(o+1);else{let z=e.indexOf(")",o);z===-1&&(z=t),G(9,z)}break;case 14:if(D===34)H(15),C(7,o+1);else if(D===125)Y(),B(o+1);else if(D===94)I=!1;else{let z=o+1;for(;z<t;){let q=e.charCodeAt(z);if(q===125||q===94||q===34)break;z++}G(7,z)}break;case 15:if(D===34)Y(),C(7,o+1);else{let z=e.indexOf('"',o);z===-1&&(z=t),ee(7,e.slice(o,z).replace(n5,"<br/>"),z)}break}if(!I)return r.push(1),a.push(""),i.push(o),n.push(c,f,c,f),{types:r,texts:a,starts:i,locs:n};continue e}return r.push(0),a.push(""),i.push(t),n.push(c,f,c,f),{types:r,texts:a,starts:i,locs:n}}function o5(e,t,r=!1){let a=!r&&e.includes("}")?e.replace(l5,`}
117
+ `):e,{types:i,texts:n,starts:l,locs:s}=s5(a),o=0,c,f=0,p=0,h=A=>{let M=i[o];throw M===1?it("agentflow",a,l[o],"",!0):it("agentflow",a,l[o],`Expecting ${A}, got '${Ux[M]}'`)},g=(A,M)=>({first_line:s[4*A],first_column:s[4*A+1],last_line:s[4*M+2],last_column:s[4*M+3]}),u=(A,M="")=>(i[o]!==A&&h(`'${Ux[A]}'${M?", "+M:""}`),n[o++]),m=()=>{ph[i[o]]===0&&h(Ep),o++},b=()=>{fh[i[o]]===0&&h("'NODE_STRING'");let A=n[o++];for(;fh[i[o]]===1;)A+=n[o++];return A},w=()=>{Ip[i[o]]===0&&h("'NODE_STRING'");let A=n[o++];for(;Ip[i[o]]===1;)A+=n[o++];return A},v=()=>{let A=i[o],M;if(A===11)M="string";else if(A===10)M="markdown";else if(A===46||A===62||A===53||A===69)M="text";else return h(`${qx}, 'TAGEND', 'STR', 'MD_STR'`);let N=n[o++];for(;;){let F=i[o];if(F!==46&&F!==62&&F!==53&&F!==69)break;N+=n[o++]}return{text:N,type:M}},k=A=>{u(A,qx)},O=()=>{let A=i[o],M;if(A===11)M="string";else if(A===10)M="markdown";else if(A===44||A===69)M="text";else return h("'EDGE_TEXT', 'STR', 'MD_STR'");let N=n[o++];for(;i[o]===44||i[o]===69;)N+=n[o++];return{text:N,type:M}},R=()=>{let A=i[o],M;if(A===11)M="text";else if(A===10)M="markdown";else if(Np[A]===1)M="text";else return h("'NODE_STRING', 'STR', 'MD_STR'");let N=n[o++];for(;Np[i[o]]===1;)N+=n[o++];return{text:N,type:M}},L=()=>{f=o;let A=n[o++];for(;i[o]===7;)A+=n[o++];return p=o-1,A},P=(A,M,N,F)=>{let U=g(N,F);t.addVertex(A,void 0,void 0,void 0,void 0,void 0,void 0,M,U),t.extendVertexMapping(A,U)},B=(A,M)=>{M.data!==void 0&&t.addVertex(A,void 0,void 0,void 0,void 0,void 0,void 0,M.data,g(M.dataFrom,M.dataTo))},G=()=>{let A=o,M=b(),N,F,U;switch(i[o]){case 74:o++,N=v(),k(73),F="square";break;case 57:o++,N=v(),k(56),F="doublecircle";break;case 72:o++,i[o]===72?(o++,N=v(),k(71),u(71),F="circle"):(N=v(),k(71),F="round");break;case 47:o++,N=v(),k(45),F="ellipse";break;case 49:o++,N=v(),k(48),F="stadium";break;case 51:o++,N=v(),k(50),F="subroutine";break;case 52:{o++;let D=u(67);u(37);let I=u(67);u(70),N=v(),k(73),F="rect",U={[D]:I};break}case 55:o++,N=v(),k(54),F="cylinder";break;case 76:o++,i[o]===76?(o++,N=v(),k(75),u(75),F="hexagon"):(N=v(),k(75),F="diamond");break;case 53:o++,N=v(),k(73),F="odd";break;case 60:o++,N=v(),i[o]===59?(o++,F="lean_right"):(k(58),F="trapezoid");break;case 61:o++,N=v(),i[o]===58?(o++,F="lean_left"):(k(59),F="inv_trapezoid");break}return U!==void 0?t.addVertex(M,N,F,void 0,void 0,void 0,U):F!==void 0?t.addVertex(M,N,F):t.addVertex(M),t.addVertexMapping(M,N,F,g(A,o-1)),M},C=()=>{let A=G();return i[o]===36&&(o++,t.setClass(A,b())),A},Z=()=>{let A=[C()];for(c=void 0;;){let M=i[o]===7?L():void 0,N=f,F=p;if(i[o]!==78)return c=M,A;do o++;while(i[o]===78);if(i[o]!==38)return M!==void 0&&h("'AMP'"),A;o++,i[o]!==78&&h("'SPACE'");do o++;while(i[o]===78);let U=C();M!==void 0&&P(A[A.length-1],M,N,F),A.push(U)}},ee=()=>{let A;if(i[o]===33&&(A=n[o++]),i[o]===42){let M=t.destructLink(n[o++]);return A!==void 0&&(M.id=A),i[o]===70&&(o++,M.text=v(),k(70),i[o]===78&&o++),M}if(i[o]===43){let M=n[o++],N=O(),F=u(42,"'EDGE_TEXT'"),U=t.destructLink(F,M);return U.text=N,A!==void 0&&(U.id=A),U}return h("'LINK', 'START_LINK'")},H=()=>{let A=o,M=Z();c!==void 0&&P(M[M.length-1],c,f,p);let N=M;for(;;){let F=i[o];if(F!==42&&F!==43&&F!==33)return N;let U=ee(),D=Z();c!==void 0&&P(D[D.length-1],c,f,p),t.addLink(M,D,U),t.addEdgeMapping(M,D,U,g(A,o-1)),N=D.concat(N),M=D}},Y=()=>{Rp[i[o]]===0&&h("'NODE_STRING', 'NUM', 'COLON', 'BRKT'");let A=n[o++];for(;Rp[i[o]]===1;)A+=n[o++];return A},_=()=>{let A=[Y()];for(;i[o]===40;)o++,A.push(Y());return A},S=()=>{o++,u(78);let A;if(i[o]===13)A=[n[o++]];else for(A=[u(34,"'DEFAULT'")];i[o]===40;)o++,A.push(u(34));if(u(78),i[o]!==15){t.updateLink(A,_());return}o++,u(78);let M=w();if(i[o]===78){o++;let N=_();t.updateLinkInterpolate(A,M),t.updateLink(A,N)}else t.updateLinkInterpolate(A,M)},$=(A,M)=>{if(i[o]!==78){t.setLink(A,M);return}if(o++,i[o]===25){t.setLink(A,M,n[o++]);return}let N=u(11,"'LINK_TARGET'");i[o]===78?(o++,t.setLink(A,M,u(25))):t.setLink(A,M),t.setTooltip(A,N)},y=()=>{let A=n[o++];switch(i[o]){case 8:{let M=n[o++],N=i[o]===9,F=N?n[o++]:void 0,U;i[o]===78&&(o++,U=u(11)),N?t.setClickEvent(A,M,F):t.setClickEvent(A,M),U!==void 0&&t.setTooltip(A,U);return}case 18:o++,$(A,u(11));return;case 11:$(A,n[o++]);return;default:{let M=w();if(i[o]===78){o++;let N=u(11);t.setClickEvent(A,M),t.setTooltip(A,N)}else t.setClickEvent(A,M)}}},E=A=>{u(78,Ep);let M=R(),N={text:"",type:"text"};i[o]===74&&(o++,N=v(),k(73));let F=i[o]===7?L():void 0;return ph[i[o]]===0&&h(`${Ep}, 'SHAPE_DATA'`),{global:!1,at:A,id:M,title:N,data:F,dataFrom:f,dataTo:p,list:[],collect:!1}},x=()=>{let A=i[o];switch(A){case 12:{o++,u(78);let M=b();return u(78),t.addVertex(M,void 0,void 0,_()),m(),zl}case 14:return S(),m(),zl;case 16:{o++,u(78);let M=b();return u(78),t.addClass(M,_()),m(),zl}case 17:{o++,u(78);let M=b();return u(78),t.setClass(M,b()),m(),zl}case 19:return y(),m(),zl;case 22:{let M=E(o++),N=o++,F=t.addConnector(M.id,M.title);return B(F,M),t.addConnectorMapping(M.id,M.title,g(M.at,M.at),g(N,N)),F}case 28:case 29:case 30:case 31:case 32:return o++,{stmt:"dir",value:c5[A-28]};case 2:{o++;let M=u(3).trim();return t.setAccTitle(M),M}case 4:{o++;let M=u(5).trim();return t.setAccDescription(M),M}case 6:{let M=n[o++].trim();return t.setAccDescription(M),M}default:{fh[A]===0&&h(Gx);let M=H();return m(),M}}},T=()=>{let A=[],M=[],N=!1;for(;;){let F=i[o];if(F===0)break;if(F===24){let U=A.pop();if(U===void 0)break;let D=o++;if(U.global){t.addGlobal(M),M=U.list,N=U.collect;continue}let I=t.addSubGraph(U.id,M,U.title,"flow");B(I,U),t.addSubgraphMapping(U.id,U.title,g(U.at,U.at),g(D,D)),M=U.list,N=U.collect,N&&M.push(I)}else if(F===39||F===77||F===78||F===79)N&&M.push(n[o]),o++;else if(F===66)o++;else if(F===21||F===23){let U=o++,D;F===23||ph[i[o]]===1?(D={global:F===23,at:U,id:void 0,title:void 0,data:void 0,dataFrom:0,dataTo:0,list:M,collect:N},m()):(D=E(U),D.list=M,D.collect=N,o++),A.push(D),M=[],N=!0}else{let U=x();N&&(!Array.isArray(U)||U.length>0)&&M.push(U)}}A.length>0&&h("'end'")};for(;i[o]===78||i[o]===77||i[o]===66;)o++;if(u(20,"'SPACE', 'NEWLINE', 'COMMENT'"),i[o]===26)o++,t.setDirection("TB");else{let A=u(27,"'NODIR'"),M=i[o];if(M===78){do o++;while(i[o]===78);M=i[o],M!==77&&h("'NEWLINE', 'SPACE'")}else M!==39&&M!==77&&M!==66&&h("'COMMENT', 'SEMI', 'NEWLINE', 'SPACE'");o++,t.setDirection(A)}T(),i[o]!==0&&h(Gx)}function f5(e,t,r,a){let i=r.size;for(let n of e){if(n.isGroup||n.shape==="collapsedGroup"){n.colorIndex=d5(r.get(n.id)??i++,a);continue}let l=t(n.id);l&&ys.has(l)&&(n.kind=l)}}function p5(e,t,r){let a=[],i=[],n=e.subgraphs,l=w=>{let v=[];for(let k of w){let O=e.classes.get(k);O?.styles&&(v=[...v,...O.styles].map(R=>R.trim())),O?.textStyles&&(v=[...v,...O.textStyles].map(R=>R.trim()))}return v},s=new Set,o=new Map,c=new Set;for(let w of n){if(w.metadata?.view!=="collapsed"||s.has(w.id))continue;let v=[w.id];for(;v.length>0;){let k=e.subgraph(v.pop())?.nodes;if(k!==void 0)for(let O of k)O===w.id||s.has(O)||(s.add(O),o.set(O,w.id),c.has(O)||v.push(O))}c.add(w.id)}let f=new Map;for(let w of s){let v=[w],k=o.get(w);for(;;){let O=f.get(k),R=O??o.get(k);if(R===void 0||(O===void 0&&v.push(k),k=R,O!==void 0))break}for(let O of v)f.set(O,k)}let p=new Map;n.forEach((w,v)=>p.set(w.id,v));let h=new Map,g=(w,v,k)=>{let O=p.get(w);if(O===void 0||O<k)return!1;let R=v;for(let L=0;R!==void 0&&L<=n.length;L++){if(R===w)return!0;R=h.get(R)}return!1};for(let w=n.length-1;w>=0;w--){let v=n[w];if(!s.has(v.id))for(let k of v.nodes){if(g(k,v.id,w)){e.emitWarning("CONTAINMENT_VIOLATION",`Container "${v.id}" cannot contain "${k}" because "${k}" already contains it. The nesting that would close the loop is dropped.`,{nodeId:k});continue}h.set(k,v.id)}}let u=new Map;for(let w=n.length-1;w>=0;w--){let v=n[w];if(s.has(v.id))continue;let k=v.metadata?.view==="collapsed",O={id:v.id,label:v.title,labelType:v.labelType,parentId:h.get(v.id),cssStyles:[],cssCompiledStyles:l(v.classes),cssClasses:v.classes.join(" "),shape:k?"collapsedGroup":"flowGroup",dir:v.dir,isGroup:!k,metadata:k?{...v.metadata,containerType:v.type}:v.metadata};a.push(O),u.set(v.id,O)}for(let w of e.nodes.values()){if(s.has(w.id))continue;let v=u.get(w.id);if(v){v.cssStyles=w.styles,v.cssCompiledStyles=l(w.classes),v.cssClasses=w.classes.join(" ");continue}let k=dh(w.type),O={id:w.id,label:w.text,labelType:w.labelType,parentId:h.get(w.id),cssStyles:w.styles,cssCompiledStyles:l(["default","node",...w.classes]),cssClasses:"default "+w.classes.join(" "),dir:w.dir,link:w.link,linkTarget:w.linkTarget,tooltip:e.tooltips.get(w.id),metadata:w.metadata,isGroup:!1,shape:k==="square"||k===void 0?"squareRect":k};a.push(O),u.set(w.id,O)}e.edges.forEach((w,v)=>{let k=f.get(w.start)??w.start,O=f.get(w.end)??w.end;if(k===O&&w.start!==w.end)return;let R=[...e.defaultEdgeStyle??[]];w.style&&R.push(...w.style);let L=w.type==="arrow_open"?"none":w.type==="arrow_cross"||w.type==="arrow_point"?w.type:"arrow_point";i.push({id:w.id||`L_${k}_${O}_${v}`,isUserDefinedId:w.isUserDefinedId,start:k,end:O,type:w.type??"normal",label:w.text,labelType:w.labelType,thickness:w.stroke,pattern:w.stroke,minlen:w.length,classes:"edge-thickness-normal edge-pattern-solid flowchart-link",arrowTypeStart:"none",arrowTypeEnd:L,cssCompiledStyles:l(w.classes),style:R,animate:w.animate,animation:w.animation,curve:w.interpolate||e.defaultInterpolate||r,metadata:w.metadata})}),PI(a,e);let m=new Map;for(let w of n){let v=h.get(w.id);if(v===void 0)continue;let k=m.get(v);k?k.push(w.id):m.set(v,[w.id])}let b=new Map;for(let w of n){if(h.get(w.id)!==void 0)continue;let v=[w.id];for(;v.length>0;){let k=v.pop();if(b.has(k))continue;b.set(k,b.size);let O=m.get(k);if(O)for(let R=O.length-1;R>=0;R--)v.push(O[R])}}return f5(a,w=>{if(e.connectors.has(w))return"connector";let v=e.nodes.get(w);return v?e.vertexKind(v):void 0},b,t),{nodes:a,edges:i}}function Qx(e,t){let r=Xx.get(e);if(r===void 0){let a=t.flowchart?.curve;r=p5(e,u5,typeof a=="string"?a:void 0),Xx.set(e,r)}return r}function hh(e,t,r){let a=e.agentflow?.[t];return typeof a=="number"&&a>0?Math.min(a,2e3):r}function Tp(e,t,r){let a=dt(e);return` fill="${a}"${w5.test(r.shape)?"":` fill-opacity="${t}"`} stroke="${a}"`}function b5(e,t,r){return jr(e.direction)?Bt(r,a=>Vx(e,t,r,a)):Vx(e,t,r,!1)}function Vx(e,t,r,a){let i=Qx(e,t),n=r.fontSize??16,l=Math.round(n*.875),s=r.measurer??et(r.fontFamily),o=hh(t,"wrappingWidth",120),c=hh(t,"minNodeWidth",120),f=r.padding??8,p=r.icons,h=new Map,g=[],u=[];i.nodes.forEach((z,q)=>h.set(z.id,q));for(let z of i.nodes){let q=z.cssStyles.length>0?z.cssCompiledStyles.concat(z.cssStyles):z.cssCompiledStyles,j=vt(q),Q=(j.bold?1:0)|(j.italic?2:0),K=z.labelType==="markdown",W=j.fontSize??n,X,te;if(z.isGroup){let se=ze(z.label,K,s,W,4e3,Q);X={node:z,style:j,label:se,shape:"group",w:0,h:0,dy:0,loops:0},te=Ut(0,0),te.isGroup=!0,te.dir=z.dir?br(z.dir):void 0,te.padX=Fl,te.padTop=se.height>0?se.height+16:Fl,te.padBottom=Fl,te.minW=se.width+2*Fl-12}else if(z.shape==="collapsedGroup"){let se=ze(z.label,K,s,W,o,Q),oe=Math.max(se.width,c)+2*mt,ae=se.height+2*$t+ch;X={node:z,style:j,label:se,shape:jx,w:oe,h:ae,dy:-ch/2,loops:0},te=Ut(oe,ae)}else{let se=go(z.shape),oe=ze(z.label,K,s,W,o,Q),ae=Si(se,se==="diam"?oe.width:Math.max(oe.width,c),oe.height);X={node:z,style:j,label:oe,shape:se,w:ae.w,h:ae.h,dy:ae.dy,loops:0},te=Ut(ae.w,ae.h)}te.seq=g.length,g.push(X),u.push(te)}i.nodes.forEach((z,q)=>{u[q].parent=z.parentId!==void 0?h.get(z.parentId)??-1:-1});let m=a?"TB":br(e.direction),b=z=>{let q;for(let j=u[z].parent,Q=0;j>=0&&q===void 0&&Q<1e4;j=u[j].parent,Q++)q=u[j].dir;return q??m},w=z=>{let q=b(z);return q==="LR"||q==="RL"},v=new Int32Array(u.length).fill(-1);for(let z=0;z<u.length;z++){let q=[],j=z;for(;j>=0&&v[j]<0&&q.length<=u.length;)q.push(j),j=u[j].parent;let Q=j>=0?v[j]+1:0;for(let K=q.length-1;K>=0;K--)v[q[K]]=Q++}let k=(z,q)=>{let j=q;for(let Q=v[q];Q>v[z];Q--)j=u[j].parent;return j===z&&q!==z},O=[],R=[],L=[],P=[];for(let z of i.edges){let q=h.get(z.start),j=h.get(z.end);if(q===void 0||j===void 0)continue;let Q=ze(z.label,z.labelType==="markdown",s,l,o);if(k(q,j)||k(j,q)){P.push({edge:z,label:Q,src:q,dst:j});continue}q===j&&(g[q].loops++,w(q)?u[q].h+=2*(Sp+(Q.height>0?Q.height+8:0)):u[q].w+=2*(Sp+(Q.width>0?Q.width+12:0))),L.push(z),R.push(Q),O.push({src:q,dst:j,minlen:z.minlen??1,labelW:Q.width>0?Q.width+12:0,labelH:Q.height>0?Q.height+4:0,route:[],labelX:0,labelY:0})}let B=Gr(u,O,m,{nodeSep:hh(t,"nodeSpacing",g5),edgeSep:m5,rankSep:hh(t,"rankSpacing",y5),portSep:20}),G=ze(e.title,!1,s,n,4e3,1),C=G.height>0?G.height+12:0,Z=Math.max(B.width,G.width),ee=f+(Z-B.width)/2,H=f+C;vi(u,O,ee,H);let Y=Math.ceil(Z+2*f),_=Math.ceil(B.height+C+2*f),S=[],$=[],y=[],E=[],x=P.length*u.length<2e6;for(let{edge:z,src:q,dst:j}of P){let Q=k(j,q),K=Q?j:q,W=Q?q:j,X=u[K],te=u[W],se=x5[X.dir??b(K)],oe=Q?se:se+2&3,ae=fe=>{let ye=(fe&1)===0,le=fe===0||fe===3?-1:1,we=ye?te.x:te.x+le*te.w/2,pe=ye?te.y+le*te.h/2:te.y,ge=ye?te.x:X.x+le*X.w/2,Ae=ye?X.y+le*X.h/2:te.y,Se=ye?0:1;return Q?[we,pe,Se,ge,Ae,Se]:[ge,Ae,Se,we,pe,Se]},ne=fe=>{for(let ye=0;ye<u.length;ye++){let le=u[ye];if(ye!==W&&!le.isGroup&&le.x+le.w/2>Math.min(fe[0],fe[3])-1&&le.x-le.w/2<Math.max(fe[0],fe[3])+1&&le.y+le.h/2>Math.min(fe[1],fe[4])-1&&le.y-le.h/2<Math.max(fe[1],fe[4])+1)return!0}return!1},J=ae(oe);if(x&&ne(J))for(let fe of[oe+1&3,oe+3&3,oe+2&3]){let ye=ae(fe);if(!ne(ye)){J=ye;break}}E.push(J),y.push((J[0]+J[3])/2,(J[1]+J[4])/2);let re=J.slice();rn(re,Q?0:3,g[W],te),$.push(zr(re,"linear",0,gt(z.arrowTypeEnd)))}let T=new Map,A=!1;for(let z of u)z.isGroup&&(A=!0);if(A){for(let z of O)va(T,z.route);for(let z of E)va(T,z)}let M="",N="";for(let z=0;z<g.length;z++){let q=g[z],j=u[z],Q=q.node,K=j.x,W=j.y,X=It(Q.cssClasses.replace(/^default\s?/,"")),te=Oe(Q.id);if(j.isGroup){let fe=Ai(j,q.label.width,T,Fl);M+=`<g class="pele-cluster pele-flow${X}" data-id="${te}"><rect x="${d(K-j.w/2)}" y="${d(W-j.h/2)}" width="${d(j.w)}" height="${d(j.h)}"${ft(Tp(Q.colorIndex??ys.size,"0.06",q.style)+q.style.shape)}/>`+Re(q.label,fe,W-j.h/2+8+q.label.height/2,` class="pele-cluster-label" fill="var(--_m)"${q.style.text}`,p)+"</g>";continue}let se=q.w,oe=q.h,ae="",ne;if(q.shape===jx){let fe=dt(Q.colorIndex??ys.size),ye=oe/2-ch-2,le=ye+(ch+2)/2;ne=`<rect x="${d(-se/2)}" y="${d(-oe/2)}" width="${d(se)}" height="${d(oe)}"${ft(Tp(Q.colorIndex??ys.size,"0.06",q.style)+q.style.shape)}/><path d="M${d(-se/2+10)},${d(ye)}H${d(se/2-10)}" fill="none" stroke="${fe}" stroke-dasharray="3 3"${q.style.line}/><path class="pele-collapsed-mark" d="${Cp(-9,le)}${Cp(0,le)}${Cp(9,le)}" fill="${fe}" stroke="none"/>`}else{let fe=ys.get(Q.kind??"task")??1;ae=` pele-kind-${Q.kind??"task"}`,ne=Ca(q.shape,se,oe,Tp(fe,"0.14",q.style)+q.style.shape,` stroke="${dt(fe)}"`+q.style.line)}let J=Re(q.label,0,q.dy,` class="pele-label"${q.style.text}`,p);if(/ internal-link(?: |$)/.test(X+" ")&&Q.label&&r.links!==!1){let fe=At(Q.label),ye=oi(Sa(fe),r)!==void 0,le=Ve(fe);J=`<a class="internal-link"${ye?` href="${le}"${ci(r)}`:""} data-href="${le}">${J}</a>`,S.push({id:Q.id,href:fe,internal:!0})}let re=ne+J;Q.tooltip&&(re=`<title>${Oe(Q.tooltip)}</title>`+re),Q.link&&(re=ua(re,Q.link,Q.id,S,r,Q.linkTarget?` target="${Ve(Q.linkTarget)}"`:"")),N+=`<g class="pele-node pele-shape-${q.shape}${ae}${X}" data-id="${te}" transform="translate(${d(K)},${d(W)})">${re}</g>`}let F="",U="",D=(z,q,j,Q,K)=>{let W=z.style.length>0||z.cssCompiledStyles.length>0?vt(z.cssCompiledStyles.concat(z.style)):void 0,X=z.arrowTypeEnd,te=W?.stroke?Ve(W.stroke):"var(--_l)",se=z.thickness==="dotted"?"reference":X==="arrow_cross"?"failure":"sequence",oe=It(z.classes.replace(/edge-thickness-normal|edge-pattern-solid|flowchart-link/g,""));F+=`<g class="pele-edge pele-edge-${se}${oe}" data-id="${Oe(z.id)}"${W?.line??""}><path d="${j.d}"${z.thickness==="dotted"?' stroke-dasharray="3 4"':""}/>`+bt(X,j.ex,j.ey,j.edx,j.edy,te)+"</g>",q.width>0&&(U+=wr(z.id,q,Q,K,W?.text??"",p))},I=new Map;for(let z=0;z<O.length;z++){let q=O[z],j=L[z],Q=R[z],K=j.arrowTypeEnd,W;if(q.src===q.dst){let X=g[q.src],te=I.get(q.src)??0;I.set(q.src,te+1),W=Ao(u[q.src],X.w,X.h,te,w(q.src),Sp,gt(K),q)}else{let X=q.route.slice();rn(X,0,g[q.src],u[q.src]),rn(X,X.length-3,g[q.dst],u[q.dst]),W=zr(X,j.curve,0,gt(K))}D(j,Q,W,q.labelX,q.labelY)}return P.forEach((z,q)=>D(z.edge,z.label,$[q],y[2*q],y[2*q+1])),{svg:Je("agentflow",Y,_,n,r,e,Re(G,Y/2,f+G.height/2,' class="pele-title" font-weight="var(--_tw)"')+(M?`<g class="pele-clusters">${M}</g>`:"")+(F?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${F}</g>`:"")+(U?`<g class="pele-edge-labels" font-size="${l}">${U}</g>`:"")+`<g class="pele-nodes">${N}</g>`),width:Y,height:_,links:S}}function Cp(e,t){return`M${d(e-1.75)},${d(t)}a1.75,1.75 0 1 0 3.5,0a1.75,1.75 0 1 0 -3.5,0Z`}var RI,LI,DI,Pl,zI,FI,YI,HI,jI,Ux,Kx,XI,VI,KI,ZI,QI,JI,e5,t5,r5,a5,vp,i5,n5,fh,Ip,Np,Rp,ph,qx,Ep,zl,l5,c5,Gx,ys,Zx,h5,d5,u5,g5,m5,y5,Fl,Sp,ch,jx,x5,Xx,w5,Jx,ew=Xe(()=>{gd();Dn();mo();Bn();Ei();hi();Ti();tr();zt();pr();ut();wt();RI=new Map([["task","roundedRect"],["tool","subroutine"],["input","lean-right"],["decision","diamond"],["refdoc","lin-doc"],["action","hexagon"],["round","rect"]]),LI=new Set(["doc","stadium","terminal","circle","trapezoid","inv_trapezoid","inv-trapezoid","doublecircle","double-circle","typeDeclaration","procs","lean_left","lean-left","in-out","cylinder","ellipse","odd","tag-rect","tagged-rectangle","delay","half-rounded-rectangle","lin-rect","lined-rectangle","win-pane","window-pane","curv-trap","curved-trapezoid"]),DI=new Set(["roundedRect","subroutine","subprocess","subproc","framed-rectangle","lean-right","diamond","lin-doc","lined-document","hexagon","hex","connector","collapsedGroup"]),Pl="roundedRect";zI=new Set(["shape","view","icon","img","form","pos","w","h","class","style","labelType"]),FI=new Set(["subroutine","subprocess","subproc","framed-rectangle","tool"]);YI=/:\s*[>|][\d+-]*\s*$/,HI=/,([\t ]*)$/;jI=class{constructor(e={}){he(this,"type","agentflow");he(this,"direction");he(this,"nodes",new Map);he(this,"edges",[]);he(this,"subgraphs",[]);he(this,"connectors",new Map);he(this,"classes",new Map);he(this,"tooltips",new Map);he(this,"defaultEdgeStyle");he(this,"defaultInterpolate");he(this,"mappings",[]);he(this,"diagnostics",[]);he(this,"title");he(this,"accTitle");he(this,"accDescr");he(this,"lineOffset");he(this,"subgraphLookup",new Map);he(this,"globalNodes",new Set);he(this,"members",new Set);he(this,"edgeById",new Map);he(this,"pairCount",new Map);he(this,"subCount",0);he(this,"bareMappings",new Set);he(this,"firstMapping",new Map);he(this,"reported",new Map);he(this,"options");this.options=e,this.lineOffset=e.lineOffset??0}metadata(e,t,r){let a=t.includes(`
118
+ `),i;try{i=Ma(a?t+`
119
+ `:`{
120
+ `+t+`
121
+ }`)}catch(n){let l=a?UI(t):t,s;if(l!==t)try{s=Ma(l+`
122
+ `)}catch{s=void 0}if(s===void 0){let o=r?` (${r.first_line+this.lineOffset}:${r.first_column+1})`:"";throw new je(`Metadata of "${e}" is not valid YAML. ${n.message}${o}`,"syntax",{type:"agentflow",line:r?r.first_line+this.lineOffset:0,column:r?r.first_column+1:0})}i=s}return BI(i??{})}shapeError(e,t){return new je(e,"semantic",{type:"agentflow",line:t?t.first_line+this.lineOffset:0,column:t?t.first_column+1:0})}addVertex(e,t,r,a,i,n,l={},s,o){if(!e||e.trim().length===0)return;let c,f,p;s!==void 0&&(c=this.metadata(e,s,o),_p(c)&&(f=c,typeof c.shape=="string"&&(p=c.shape,c.shape=dh(c.shape))));let h=this.subgraphLookup.get(e);if(h&&c){h.metadata=oh(h.metadata,c);return}let g=this.connectors.get(e);if(g&&c){g.metadata=oh(g.metadata,c);return}if(e==="connectors")return;let u=this.edgeById.get(e);if(u){f?.animate!==void 0&&(u.animate=f.animate),f?.animation!==void 0&&(u.animation=f.animation),f?.curve!==void 0&&(u.interpolate=f.curve),c&&(u.metadata=oh(u.metadata,c));return}let m=this.nodes.get(e);if(m===void 0&&(m={id:e,labelType:"text",styles:[],classes:[]},this.nodes.set(e,m)),t!==void 0?(m.labelType=t.type,m.text=Yx(t.text.trim())):m.text===void 0&&(m.text=e),r!==void 0&&(m.type=r),a!=null)for(let b of a)m.styles.push(b);if(i!=null)for(let b of i)m.classes.push(b);if(n!==void 0&&(m.dir=n),m.props===void 0?m.props=l:l!==void 0&&Object.assign(m.props,l),!!c&&(m.metadata=oh(m.metadata,c),f!==void 0)){if(f.shape){let b=p??f.shape;if(typeof b!="string")throw this.shapeError(`No such shape: ${JSON.stringify(b)}.`,o);if(b!==b.toLowerCase()||b.includes("_"))throw this.shapeError(`No such shape: ${b}. Shape names should be lowercase.`,o);let w=f.shape;if(!OI(w))throw this.shapeError(`No such shape: ${w}.`,o);m.type=w}f.label&&(m.text=String(f.label),m.labelType=Ap(f.labelType))}}addSingleLink(e,t,r,a){let i={start:e,end:t,type:void 0,text:"",labelType:"text",classes:[],isUserDefinedId:!1,interpolate:this.defaultInterpolate},n=r?.text;n!==void 0&&(i.text=Yx(n.text.trim()),i.labelType=Ap(n.type)),r!==void 0&&(i.type=r.type,i.stroke=r.stroke,i.length=r.length>10?10:r.length,r.edgeSemantic&&(i.edgeSemantic=r.edgeSemantic));let l=e+"\0"+t,s=this.pairCount.get(l)??0;a&&!this.edgeById.has(a)?(i.id=a,i.isUserDefinedId=!0):i.id=`L_${e}_${t}_${s===0?0:s+1}`;let o=this.options.maxEdges;if(o!==void 0&&this.edges.length>=o)throw new je(`Edge limit exceeded. ${this.edges.length} edges found, but the limit is ${o}.`,"limit",{type:"agentflow"});this.edges.push(i),this.pairCount.set(l,s+1),this.edgeById.has(i.id)||this.edgeById.set(i.id,i)}addLink(e,t,r){let a=typeof r?.id=="string"?r.id.replace("@",""):void 0,i=e[e.length-1],n=t[0];for(let l of e)for(let s of t)this.addSingleLink(l,s,r,l===i&&s===n?a:void 0)}updateLinkInterpolate(e,t){for(let r of e)r==="default"?this.defaultInterpolate=t:this.edgeAt(r).interpolate=t}updateLink(e,t){for(let r of e){if(r==="default"){this.defaultEdgeStyle=t;continue}let a=this.edgeAt(r);a.style=t,t.length>0&&!t.some(i=>i?.startsWith("fill"))&&t.push("fill:none")}}edgeAt(e){let t=this.edges[Number(e)];if(t===void 0)throw new je(`The index ${e} for linkStyle is out of bounds. Valid indices for linkStyle are between 0 and ${this.edges.length-1}. (Help: Ensure that the index is within the range of existing edges.)`,"semantic",{type:"agentflow"});return t}addClass(e,t){let r=t.join().replace(/\\,/g,"\xA7\xA7\xA7").replace(/,/g,";").replace(/§§§/g,",").split(";");for(let a of e.split(",")){let i=this.classes.get(a);i===void 0&&(i={id:a,styles:[],textStyles:[]},this.classes.set(a,i));for(let n of r)n.includes("color")&&i.textStyles.push(n.replace("fill","bgFill")),i.styles.push(n)}}setDirection(e){let t=e.trim();t.includes("<")&&(t="RL"),t.includes("^")&&(t="BT"),t.includes(">")&&(t="LR"),t.includes("v")&&(t="TB"),t==="TD"&&(t="TB"),this.direction=t}setClass(e,t){for(let r of e.split(","))this.nodes.get(r)?.classes.push(t),this.edgeById.get(r)?.classes.push(t),this.subgraphLookup.get(r)?.classes.push(t)}setTooltip(e,t){if(t!==void 0)for(let r of e.split(","))this.tooltips.set(r,t)}setLink(e,t,r){let a=t.trim();for(let i of e.split(",")){let n=this.nodes.get(i);n!==void 0&&(n.link=a?Ta(a):void 0,n.linkTarget=r)}this.setClass(e,"clickable")}setClickEvent(e,t,r){this.setClass(e,"clickable")}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
123
+ `)}addSubGraph(e,t,r,a){let i=e?.text?.trim(),n=r?.text||"";e!==void 0&&e===r&&/\s/.test(n)&&(i=void 0);let l=new Set,s=[],o;for(let g of t)if(typeof g=="string")g.trim()!==""&&!l.has(g)&&(l.add(g),s.push(g));else if(Array.isArray(g))for(let u of g)u.trim()!==""&&!l.has(u)&&(l.add(u),s.push(u));else o=g.value;o??(o=this.options.inheritDir?this.direction??this.options.direction:void 0),i??(i="subGraph"+this.subCount),this.subCount++;let c=this.members,f=s.filter(g=>g!==i&&!this.globalNodes.has(g)&&!c.has(g));for(let g of f)c.add(g);let p=this.subgraphLookup.get(i);if(p){for(let g of f)p.nodes.push(g);return n.trim()&&(p.title=n.trim()),o&&(p.dir=o),i}let h={id:i,nodes:f,title:n.trim(),classes:[],dir:o,labelType:Ap(r?.type),type:"flow"};return this.subgraphs.push(h),this.subgraphLookup.set(i,h),i}addGlobal(e){let t=!1,r=a=>{let i=a.trim();i!==""&&(this.globalNodes.add(i),this.members.delete(i)&&(t=!0))};for(let a of e)if(typeof a=="string")r(a);else if(Array.isArray(a))for(let i of a)r(i);if(t)for(let a of this.subgraphs)a.nodes=a.nodes.filter(i=>!this.globalNodes.has(i))}addConnector(e,t){let r=e?.text?.trim();if(!r)return"";let a=t?.text?.trim()??"",i=this.connectors.get(r);if(i)a.length>0&&(i.text=a);else{let n={id:r,labelType:"text",styles:[],classes:[],isConnector:!0,text:a.length>0?a:r};this.connectors.set(r,n),this.nodes.set(r,n)}return r}destructLink(e,t){let r=GI(e);return t&&(t.includes(".")?"dotted":"normal")!==r.stroke?{type:"INVALID",stroke:"INVALID"}:{...r,edgeSemantic:qI(r.type,r.stroke)}}subgraph(e){return this.subgraphLookup.get(e)}vertexKind(e){if(WI(e))return"tool";let t=dh(e.type);return t==="hexagon"||t==="hex"?"action":t==="lean-right"||t==="lean_right"?"input":t==="lin-doc"||t==="lined-document"?"refdoc":t==="diamond"?"decision":"task"}semanticModel(){let e=[],t=[];for(let[n,l]of this.nodes){if(this.subgraphLookup.has(n))continue;let s=Hx(l.metadata);if(l.isConnector){let f={id:n};l.text!==void 0&&l.text!==n&&(f.title=l.text),s&&(f.metadata=s),t.push(f);continue}let o={id:n};l.text!==void 0&&(o.label=l.text);let c=dh(l.type);c!==void 0&&(o.shape=c),o.vertexKind=this.vertexKind(l),s&&(o.metadata=s),e.push(o)}let r=this.edges.map(n=>{let l={start:n.start,end:n.end};return n.id!==void 0&&(l.id=n.id),n.text.length>0&&(l.label=n.text),n.type!==void 0&&(l.type=n.type),n.stroke!==void 0&&(l.stroke=n.stroke),n.edgeSemantic!==void 0&&(l.edgeSemantic=n.edgeSemantic),n.length!==void 0&&(l.length=n.length),n.metadata&&Object.keys(n.metadata).length>0&&(l.metadata={...n.metadata}),l}),a=this.subgraphs.map(n=>{let l={id:n.id,nodes:[...n.nodes],type:n.type,title:n.title};n.dir!==void 0&&(l.direction=n.dir);let s=Hx(n.metadata);return s&&(l.metadata=s),l}),i={vertices:e,edges:r,subGraphs:a,connectors:t,diagnostics:this.diagnostics};return this.direction!==void 0&&(i.direction=this.direction),i}position(e){let t=e?.first_line??0,r=e?.first_column??0;return{startLine:t+this.lineOffset,startColumn:r,endLine:(e?.last_line??t)+this.lineOffset,endColumn:e?.last_column??r,startIndex:0,endIndex:0}}pushMapping(e,t,r){let a={id:e,type:t,position:r};return this.mappings.push(a),this.firstMapping.has(e)||this.firstMapping.set(e,a),a}addVertexMapping(e,t,r,a){if(!e)return;let i=this.pushMapping(e,"vertex",this.position(a));r==null&&this.bareMappings.add(i)}extendVertexMapping(e,t){if(!e||!t)return;let r=this.position(t);for(let a=this.mappings.length-1;a>=0;a--){let i=this.mappings[a];if(i.type!=="vertex"||i.id!==e)continue;this.bareMappings.delete(i)&&(i.type="attachment");let n=i.position;(r.endLine>n.endLine||r.endLine===n.endLine&&r.endColumn>n.endColumn)&&(n.endLine=r.endLine,n.endColumn=r.endColumn);return}this.pushMapping(e,"attachment",r)}addEdgeMapping(e,t,r,a){let i=Array.isArray(t)?t.filter(n=>typeof n=="string"&&n!==""):[];this.pushMapping(i.length>0?i.join(">"):"edge","edge",this.position(a))}blockMapping(e,t,r,a){if(!e)return;let i=this.position(r),n=a?this.position(a):i;this.pushMapping(e,t,{startLine:i.startLine,startColumn:i.startColumn,endLine:n.endLine,endColumn:n.endColumn,startIndex:0,endIndex:0})}addSubgraphMapping(e,t,r,a){let i=typeof e=="string"?e:e?.text;this.blockMapping(i??"","subgraph",r,a)}addConnectorMapping(e,t,r,a){this.blockMapping(e?.text?.trim()??"","connector",r,a)}emit(e,t,r,a){let i=a?.nodeId??a?.edgeId,n={id:e,severity:t,message:r};a?.nodeId?n.nodeId=a.nodeId:a?.edgeId&&(n.edgeId=a.edgeId);let l=i?this.firstMapping.get(i):void 0;l&&(n.position=l.position);let s=i??"",o=this.reported.get(s);if(o===void 0)this.reported.set(s,[n]);else{for(let c of o)if(c.id===e&&c.severity===t&&c.message===r&&c.nodeId===n.nodeId&&c.edgeId===n.edgeId)return;o.push(n)}this.diagnostics.push(n),this.options.log?.(t,`agentflow[${e}]: ${r}`)}emitWarning(e,t,r){this.emit(e,"warning",t,r)}emitError(e,t,r){this.emit(e,"error",t,r)}},Ux=["$end","INVALID","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","SHAPE_DATA","CALLBACKNAME","CALLBACKARGS","MD_STR","STR","STYLE","DEFAULT","LINKSTYLE","INTERPOLATE","CLASSDEF","CLASS","HREF","CLICK","GRAPH","flow","connector","global","end","LINK_TARGET","NODIR","DIR","direction_tb","direction_bt","direction_rl","direction_lr","direction_td","LINK_ID","NUM","BRKT","STYLE_SEPARATOR","COLON","AMP","SEMI","COMMA","MULT","LINK","START_LINK","EDGE_TEXT","-)","TEXT","(-","STADIUMEND","STADIUMSTART","SUBROUTINEEND","SUBROUTINESTART","VERTEX_WITH_PROPS_START","TAGEND","CYLINDEREND","CYLINDERSTART","DOUBLECIRCLEEND","DOUBLECIRCLESTART","TRAPEND","INVTRAPEND","TRAPSTART","INVTRAPSTART","TAGSTART","UP","SEP","DOWN","COMMENT","NODE_STRING","MINUS","UNICODE_TEXT","PIPE","PE","PS","SQE","SQS","DIAMOND_STOP","DIAMOND_START","NEWLINE","SPACE","EOF"],Kx=new Uint8Array(128);for(let e of"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'*+.`?\\_/")Kx[e.charCodeAt(0)]=1;XI=/accTitle\s*:\s*/y,VI=/accDescr\s*:\s*/y,KI=/accDescr\s*\{\s*/y,ZI=/call\s+/y,QI=/click\s+/y,JI=/(?:\r?\n)*\s*\n/y,e5=/\s*(?:LR|RL|TB|BT|TD|BR)\b/y,t5=/\s*[<>^]/y,r5=/\s*v\b/y,a5=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y,/.*direction\s+TD[^\n]*/y],vp=/[\n\r\u2028\u2029]/g,i5=/\(\s*\)/y,n5=/\n\s*/g;fh=new Uint8Array(80);for(let e of[34,67,65,68,13,40,37,38,35,41,69])fh[e]=1;Ip=new Uint8Array(80);for(let e of[34,69,67,27,65,68,40,37,38,35,41])Ip[e]=1;Np=new Uint8Array(80);for(let e of[34,67,78,68,38,69,37,41,35,12,14,16,17,19,20,27,21,22,23,24,65,63,43])Np[e]=1;Rp=new Uint8Array(80);for(let e of[34,67,37,78,35,12])Rp[e]=1;ph=new Uint8Array(80);for(let e of[77,39,79,66])ph[e]=1;qx="'UNICODE_TEXT', 'TEXT', 'TAGSTART'",Ep="'COMMENT', 'SEMI', 'NEWLINE', 'EOF'",zl=[],l5=/}[^\S\n]*\n/g;c5=["TB","BT","RL","LR","TD"],Gx="'COMMENT', 'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'flow', 'global', 'connector', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'NODE_STRING'",ys=new Map([["tool",0],["task",1],["decision",2],["input",3],["refdoc",4],["connector",5],["action",6]]),Zx=ys.size,h5=e=>Math.max(1,e-Zx),d5=(e,t)=>{let r=Zx+e%h5(t);return t>0?r%t:r};u5=8,g5=40,m5=16,y5=48,Fl=20,Sp=26,ch=14,jx="collapsed",x5={TB:2,RL:3,BT:0,LR:1},Xx=new WeakMap;w5=/[";]fill:/;Jx={type:"agentflow",keepComments:!0,parse(e,t,r,a,i){let n=t.flowchart??{},l=new jI({inheritDir:n.inheritDir===!0,direction:typeof t.direction=="string"?t.direction:void 0,lineOffset:a,maxEdges:i.maxEdges});return r&&(l.title=r),o5(e,l),Qx(l,t),l},render:b5}});var tw={};_t(tw,{agentflow:()=>Jx});var rw=Xe(()=>{ew()});function $5(){let e=!1;return(t,r)=>{Lp.lastIndex=r;let a=Lp.exec(t);if(a===null)return-1;let i=Lp.lastIndex;if(a[1]===void 0)return i;if(e)return-1;let n=t.indexOf("}",i);return e=n===-1,n+1||-1}}function xs(e="ACC_DESCR"){return{...ur,name:e,scanner:$5}}var Lp,uh=Xe(()=>{Vr();Lp=/[\t ]*accDescr(?:[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)|\s*({))/y});function S5(e){return e.some(t=>Pp.test(t))}function T5(e){for(let t of e){let r=hw.exec(t);if(r?.index&&r.index>0)return r.index}return 4}function iw(e,t){return e.replace(/\bline\s+(\d+)\b/gi,(r,a)=>{let i=t.get(parseInt(a,10));return i?`line ${i}`:r})}function nw(e,t){throw new je(`Line ${e}: ${t}`,"syntax",{type:"treeView",line:e})}function C5(e){let t=new Map;if(!Pp.test(e))return{text:e,lineMap:t};let r=e.split(`
124
+ `),a=-1;for(let c=0;c<r.length;c++)if(r[c].trim()==="treeView-beta"){a=c;break}if(a===-1)return{text:e,lineMap:t};let i=c=>c.trim()===""||v5.test(c)||A5.test(c),n=[];for(let c=a+1;c<r.length;c++){let f=r[c];i(f)||aw.test(f)||n.push(f.replace(/\t/g," "))}if(!S5(n))return{text:e,lineMap:t};let l=T5(n),s=[],o=(c,f)=>{s.push(c),t.set(s.length,f+1)};for(let c=0;c<=a;c++)o(r[c],c);for(let c=a+1;c<r.length;c++){let f=r[c];if(i(f)){o(f,c);continue}if(aw.test(f))continue;let p=f.replace(/\t/g," "),h=hw.exec(p);if(h){let g=Math.round(h.index/l)+1,u=h.index+1;for(;u<p.length&&k5.test(p[u]);)u++;for(;u<p.length&&p[u]===" ";)u++;let m=p.slice(u).trimEnd();m||nw(c+1,"Empty node \u2014 expected a filename or directory name after the box-drawing prefix"),o(E5.repeat(g)+m,c)}else{if(M5.test(p))continue;Pp.test(p)?o(f,c):/^\s+/.test(p)?nw(c+1,"Unexpected indentation without box-drawing characters. In box-drawing format, use \u251C\u2500\u2500 or \u2514\u2500\u2500 prefixes for indented nodes."):o(f,c)}}return{text:s.join(`
125
+ `),lineMap:t}}function _5(e,t){if(e.startsWith("##",t)||e.startsWith("icon(",t))return!0;if(!e.startsWith(":::",t))return!1;let r=t+3;for(;pa(e.charCodeAt(r));)r++;let a=e.charCodeAt(r);return a>=65&&a<=90||a>=97&&a<=122||a===95}function I5(e,t){let r=e.charCodeAt(t);if(pa(r)||r===10||r===13||r===34||r===39||e.startsWith(":::",t)||e.startsWith("icon(",t)||e.startsWith("##",t))return-1;let a=e.length,i=t+1;for(;i<a;){let n=e.charCodeAt(i);if(n===10||n===13)break;if(pa(n)){let l=i+1;for(;pa(e.charCodeAt(l));)l++;if(_5(e,l))break;i=l}else i++}return i}function dw(e){let t=e.length;for(;t>0&&pa(e.charCodeAt(t-1));)t--;return t===e.length?e:e.slice(0,t)}function Dp(e,t){switch(e){case"INDENTATION":return t?.length||0;case"QUOTED_NAME":return t.substring(1,t.length-1);case"BARE_NAME":return dw(t);case"CLASS_ANNOTATION":return t.trim().substring(3).trim();case"ICON_ANNOTATION":{let r=t.trim();return r.substring(5,r.length-1)}case"DESC_ANNOTATION":return t.trim().substring(2).trim();default:return}}function N5(e){let t=new Zt(Gt(e,lw,"treeView"),lw,"treeView"),r={$type:"TreeView",nodes:[]};for(t.expect(0);;)if(t.kind===1)r.accDescr=Kt(t.take());else if(t.kind===2)r.accTitle=Vt(t.take());else if(t.kind===3)r.title=Xt(t.take());else break;for(;t.kind!==-1;){let a={$type:"TreeNode",name:""};if(t.kind===7&&(a.indent=t.take().length),t.kind===8){let i=t.take();a.name=i.substring(1,i.length-1)}else t.kind===12?a.name=dw(t.take()):t.fail("a name");for(;;)if(t.kind===4)a.classAnnotation=Dp("CLASS_ANNOTATION",t.take());else if(t.kind===5)a.iconAnnotation=Dp("ICON_ANNOTATION",t.take());else if(t.kind===6)a.descAnnotation=Dp("DESC_ANNOTATION",t.take());else break;r.nodes.push(a)}return r}function L5(e,t){for(let r of e.nodes){let a=typeof r.indent=="number"?r.indent:0,i=r.name,n=i.endsWith("/");n&&(i=i.slice(0,-1));let l=r.iconAnnotation;t.addNode(a,i,n?"directory":"file",r.classAnnotation||void 0,l!==void 0?l||"none":void 0,r.descAnnotation||void 0)}}function D5(e){let{text:t,lineMap:r}=C5(e);try{return N5(t)}catch(a){if(r.size===0||!(a instanceof je))throw a;let i=a.message.indexOf(`
126
+ `),n=i===-1?iw(a.message,r):iw(a.message.slice(0,i),r)+a.message.slice(i);throw new je(n,a.code,{type:a.type,line:r.get(a.line)??a.line,column:a.column,snippet:a.snippet})}}function O5(e,t){let r=new R5;return L5(e,r),{type:"treeView",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
127
+ `):void 0,root:r.root,count:r.count}}function Op(e,t){if(e===void 0||!Object.prototype.hasOwnProperty.call(e,t))return;let r=e[t];return typeof r=="string"?r:void 0}function P5(e,t){let r=Op(t?.filenameIcons,e);if(r)return r;let a=e.lastIndexOf(".");if(a>0){let i=e.substring(a).toLowerCase();return Op(t?.extensionIcons,i)??Op(t?.extensionIcons,i.slice(1))}}function ow(e,t){return e.includes(":")?e:zp.has(e)||!t?`${yh}:${e}`:`${t}:${e}`}function cw(e,t){if(e.icon!=="none"){if(e.icon)return ow(e.icon,t.defaultIconPack);if(t.showIcons){if(e.nodeType==="file"){let r=P5(e.name,t);if(r==="none")return;if(r)return ow(r,t.defaultIconPack)}return`${yh}:${e.nodeType==="directory"?"folder":"file"}`}}}function z5(e){let t=a=>typeof a=="object"&&a!==null&&!Array.isArray(a)?a:void 0,r=t(e.treeView)??{};return{showIcons:!!r.showIcons,defaultIconPack:typeof r.defaultIconPack=="string"?r.defaultIconPack:"",filenameIcons:t(r.filenameIcons),extensionIcons:t(r.extensionIcons)}}function mh(e,t,r,a,i){let n=e.treeView?.[t];return typeof n=="number"&&n>=a&&n<=i?n:r}function H5(e){return{paddingX:mh(e,"paddingX",5,0,100),paddingY:mh(e,"paddingY",2,0,100),rowIndent:mh(e,"rowIndent",15,0,400),lineThickness:mh(e,"lineThickness",1,.25,12)}}function U5(e,t,r){return Nr(r,a=>q5(e,t,r,a))}function q5(e,t,r,a){let i=r.fontSize??16,n=r.measurer??et(r.fontFamily),l=r.padding??8,s=z5(t),{paddingX:o,paddingY:c,rowIndent:f,lineThickness:p}=H5(t),h=0,g=e.root.children.map(T=>[T,0]);for(let T=0;a&&T<g.length;T++){let[A,M]=g[T];h=Math.max(h,M);for(let N of A.children)g.push([N,M+1])}let u=a?Math.min(f+o,Math.max(2,((r.maxWidth??320)-120)/Math.max(1,h))):f+o,m=Math.round(i*1.5)+2*c,b=i,w=ze(e.title,!1,n,i,a?Nt(r):4e3,1),v=w.height>0?w.height+12:0,k=T=>T.some(A=>cw(A,s)!==void 0),O=[],R=new Map,L=[],P=(T,A)=>{let M=k(T);for(let N=T.length-1;N>=0;N--)L.push([T[N],A,M])};P(e.root.children,0);let B=0,G=!1,C=0;for(;L.length>0;){let[T,A,M]=L.pop(),N=A*u,F=At(T.name),U=N+(M?b+F5:0),D=Math.max(40,(r.maxWidth??320)-2*l-2*gh-U),I=a?fn(F,n,i,D,T.nodeType==="directory"?1:0):void 0,z=a&&T.description?fn(At(T.description),n,i,D,2):void 0,q=I?I.width:n.width(F,i,T.nodeType==="directory"?1:0);U+q>B&&(B=U+q);let j=T.cssClass!==void 0&&T.cssClass.split(/\s+/).includes("highlight");j&&(G=!0);let Q=a?Math.max(m,(I?.height??0)+(z?.height??0)+2*c):m,K=C+(a?c+Math.max(b,I?.height??0)/2:Q/2),W={node:T,x:N,cy:K,icon:cw(T,s),text:F,labelX:U,highlighted:j,label:I,description:z,top:C,height:Q};C+=Q,O.push(W),R.set(T,W),P(T.children,A+1)}let Z=B+W5,ee=B;for(let T of O){let A=T.node.description;if(!A)continue;let M=T.description?T.description.width:n.width(At(A),i,2);ee=Math.max(ee,(a?T.labelX:Z)+M)}ee=Math.max(ee,w.width);let H=l+(G?gh:0),Y=l+v,_=Math.ceil(ee+2*H),S=Math.ceil(Y+C+l),$="";for(let T of O){let A=T.node.children;if(A.length===0)continue;let M=H+T.x+B5,N=Math.max(M,H+T.x+u-o),F=Y+R.get(A[A.length-1]).cy,U=Math.min(Y5,N-M),D=`M${d(M)},${d(Y+T.top+T.height-2)}V${d(F-U)}`;U>0&&(D+=`Q${d(M)},${d(F)} ${d(M+U)},${d(F)}H${d(N)}`);for(let I=0;I<A.length-1&&N>M;I++)D+=`M${d(M)},${d(Y+R.get(A[I]).cy)}H${d(N)}`;$+=`<path d="${D}"/>`}let y=i*.35,E="";for(let T of O){let A=T.node,M=Y+T.cy,N=A.nodeType==="directory",F="";if(T.highlighted){let U=H+T.x-gh;F+=`<rect class="pele-tree-highlight" x="${d(U)}" y="${d(Y+T.top+1)}" width="${d(_-H+gh-U)}" height="${d(T.height-2)}" fill="var(--_c)" fill-opacity="0.14"${nt}/>`}if(T.icon!==void 0){let U=T.icon.startsWith(yh+":")?T.icon.slice(yh.length+1):"",D=zp.get(U)??zp.get(N?"folder":"file"),I=r.icons?.(T.icon)??`<path d="${D}" stroke="var(--_m)" stroke-width="1.5"/>`;F+=`<svg class="pele-icon" data-icon="${Oe(T.icon)}" x="${d(H+T.x)}" y="${d(M-b/2)}" width="${d(b)}" height="${d(b)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${I}</svg>`}T.label?F+=yi(T.label,H+T.labelX,Y+T.top+c,` class="pele-label"${N?' font-weight="var(--_hw)"':""}`):T.text!==""&&(F+=`<text class="pele-label" x="${d(H+T.labelX)}" y="${d(M+y)}"${N?' font-weight="var(--_hw)"':""} xml:space="preserve">${Ve(T.text)}</text>`),T.description?F+=yi(T.description,H+T.labelX,Y+T.top+c+(T.label?.height??0),' class="pele-tree-description" font-style="italic" fill="var(--_m)"'):A.description&&(F+=`<text class="pele-tree-description" x="${d(H+Z)}" y="${d(M+y)}" font-style="italic" fill="var(--_m)" xml:space="preserve">${Ve(At(A.description))}</text>`),E+=`<g class="pele-node pele-tree-${N?"dir":"file"}${It(A.cssClass??"")}" data-id="${Oe(A.name)}">${F}</g>`}let x=Re(w,_/2,l+w.height/2,' class="pele-title" font-weight="var(--_tw)"')+($?`<g class="pele-tree-guides" fill="none" stroke="var(--_b)" stroke-width="${d(p)}">${$}</g>`:"")+E;return{svg:Je("treeView",_,S,i,r,e,x),width:_,height:S,links:[]}}var Pp,hw,k5,aw,M5,A5,v5,E5,sw,lw,R5,yh,zp,F5,W5,B5,Y5,gh,fw,pw=Xe(()=>{uh();un();tr();zt();Vr();ut();wt();Pp=/[─━│┃└┗├┣]/,hw=/[└┗├┣]/,k5=/[─━]/,aw=/^[\s│┃]+$/,M5=/^[\s─━│┃└┗├┣]+$/,A5=/^\s*(title[\t ]|accTitle[\t ]*:|accDescr[\t ]*[:{])/,v5=/^\s*%%/,E5=" ";sw={name:"BARE_NAME",pattern:/(?!:::|icon\(|##)[^ \t\n\r"'](?:(?![ \t]+:::[ \t]*[A-Za-z_]|[ \t]+icon\(|[ \t]+##)[^\n\r])*/y,match:I5},lw=[{...or("treeView-beta"),longer:[sw]},xs(),rr,ar,{name:"CLASS_ANNOTATION",pattern:/[ \t]+:::[ \t]*[A-Za-z_][\w-]*/y},{name:"ICON_ANNOTATION",pattern:/[ \t]+icon\([\w-]*(?::[\w-]+)?\)/y},{name:"DESC_ANNOTATION",pattern:/[ \t]+##[^\n\r]*/y},{name:"INDENTATION",pattern:/[ \t]{1,}/y},{name:"QUOTED_NAME",pattern:/"[^"]*"|'[^']*'/y},{name:"WS",pattern:/[ \t]+/y,hidden:!0},{name:"ML_COMMENT",pattern:/\%\%[^\n]*/y,hidden:!0},{name:"NL",pattern:/\r?\n/y,hidden:!0},sw];R5=class{constructor(){he(this,"count",1);he(this,"root",{id:0,level:-1,name:"/",nodeType:"directory",children:[]});he(this,"stack",[this.root])}addNode(e,t,r,a,i,n){let l=this.stack;for(;e<=l[l.length-1].level;)l.pop();let s={id:this.count++,level:e,name:t,nodeType:r,icon:i,cssClass:a,description:n,children:[]};l[l.length-1].children.push(s),l.push(s)}};yh="mermaid-treeview",zp=new Map([["folder","M3 6.5A1.5 1.5 0 0 1 4.5 5h4.6l2.4 2.5h8A1.5 1.5 0 0 1 21 9v9a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 18z"],["file","M6.5 3h7L19 8.5v11a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 5 19.5v-15A1.5 1.5 0 0 1 6.5 3zM13.5 3v5.5H19"]]);F5=6,W5=16,B5=7,Y5=4,gh=4;fw={type:"treeView",parse:(e,t,r)=>O5(D5(e),r),render:U5}});var uw={};_t(uw,{treeView:()=>fw});var gw=Xe(()=>{pw()});function j5(e,t){let r=new G5;return r.setDomains(e.domains),r.setTransitions(e.transitions),{type:"cynefin",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
128
+ `):void 0,domains:r.domains,transitions:r.transitions}}function X5(e){let t=new Zt(Gt(e,mw,"cynefin"),mw,"cynefin"),r={$type:"Cynefin",domains:[],transitions:[]},a=()=>{for(;t.kinds[t.i]===9;)t.i++},i=()=>{t.kind!==-1&&(t.kind!==9&&t.fail("a line break or the end of input"),a())};for(a(),t.kind!==1&&t.kind!==0&&t.fail("'cynefin-beta'"),t.i++;t.kind!==-1;)switch(t.kind){case 9:t.i++;break;case 5:r.accDescr=Kt(t.take()),i();break;case 6:r.accTitle=Vt(t.take()),i();break;case 7:r.title=Xt(t.take()),i();break;case 4:{let n=t.take();if(t.accept(2)){let s={$type:"Transition",from:n,to:t.expect(4)};t.accept(3)&&(s.label=$r(t.expect(8))),i(),r.transitions.push(s);break}let l={$type:"DomainBlock",domain:n,items:[]};for(a();t.kinds[t.i]===8;)l.items.push({$type:"DomainItem",label:$r(t.take())}),a();r.domains.push(l);break}default:t.fail("a domain, a transition, a title, or a line break")}return r}function yw(e){let t=e+1831565813|0;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function V5(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return t}function K5(e,t){return typeof e=="number"&&Number.isFinite(e)&&e!==0?e:V5(t)}function Fp(e,t,r,a,i,n){let l=(t-e)/n.segments,s=[],o=[];for(let f=0;f<=n.segments;f++){let p=f===0&&n.pinStart||f===n.segments&&n.pinEnd;s.push(e+f*l),o.push(p?r:r+yw(a+f*n.pointStep)*i*2-i)}let c=n.vertical?[o[0],s[0]]:[s[0],o[0]];for(let f=0;f<n.segments;f++){let p=(s[f]+s[f+1])/2,h=i*1.5*(f%2===0?1:-1)*yw(a+f*n.controlStep+n.controlShift);n.vertical?c.push(o[f]+h,p,o[f+1]-h,p,o[f+1],s[f+1]):c.push(p,o[f]+h,p,o[f+1]-h,s[f+1],o[f+1])}return c}function Q5(e,t,r,a){let i=r-t;return[e,t,e+a,t+i*.2,e-a*1.5,t+i*.55,e+a*.5,t+i*.75,e-a,t+i*.85,e+a*.3,t+i*.95,e,r]}function Wl(e){let t="";for(let r=2;r<e.length;r+=6)t+=`C${d(e[r])},${d(e[r+1])} ${d(e[r+2])},${d(e[r+3])} ${d(e[r+4])},${d(e[r+5])}`;return t}function xh(e){let t="";for(let r=e.length-6;r>=2;r-=6)t+=`C${d(e[r+2])},${d(e[r+3])} ${d(e[r])},${d(e[r+1])} ${d(e[r-2])},${d(e[r-1])}`;return t}function wh(e){return`M${d(e[0])},${d(e[1])}${Wl(e)}`}function J5(e,t,r,a){let i=`${d(r)},${d(a)}`;return`M${d(e-r)},${d(t)}A${i} 0 1,1 ${d(e+r)},${d(t)}A${i} 0 1,1 ${d(e-r)},${d(t)}Z`}function kh(e,t,r,a,i){let n=e.cynefin?.[t];return typeof n=="number"&&n>=a&&n<=i?n:r}function i6(e,t,r){let a=r.fontSize??16,i=Math.round(a*.8125),n=Math.round(a*.875),l=r.measurer??et(r.fontFamily),s=r.padding??8,o=r.icons,c=t.cynefin?.showDomainDescriptions!==!1,f=kh(t,"boundaryAmplitude",8,0,50),p=K5(kh(t,"seed",0,-1e15,1e15),r.idPrefix??"pele"),h=Math.round(n*1.5),g=(W,X)=>{let te=ze(W,!1,l,n,bw);return{text:W,label:te,w:te.width+2*r6,h:Math.max(te.height,h)+2*a6,overflow:X}},u=W=>{let X=t6.get(W),te=ze(X[0],!1,l,a,4e3,1),se=[];if(c)for(let fe of[X[1],X[2]])fe&&se.push(ze(fe,!1,l,i,4e3,2));let oe=e.domains.get(W)?.items??[],ae=W==="confusion"&&oe.length>ww?ww:oe.length,ne=[];for(let fe=0;fe<ae;fe++)ne.push(g(oe[fe].label,!1));ae<oe.length&&ne.push(g(`+${oe.length-ae} more`,!0));let J=te.width,re=te.height;for(let fe of se)J=Math.max(J,fe.width),re+=fe.height;ne.length>0&&(re+=$w-bh);for(let fe of ne)J=Math.max(J,fe.w),re+=bh+fe.h;return{name:W,title:te,subtitles:se,badges:ne,w:J,h:re,cx:0,cy:0}},m=Wp.map(([W])=>u(W)),b=u("confusion"),w=Math.max(88,b.w*.71+8),v=Math.max(64,b.h*.71+6),k=kh(t,"width",640,100,1e4)/2,O=kh(t,"height",440,100,1e4)/2;for(let W of m)k=Math.max(k,W.w+2*kw),O=Math.max(O,W.h+2*kw);for(let W of m){let X=(k-W.w)/2,te=(O-W.h)/2;if((X/(w+$h))**2+(te/(v+$h))**2>=1)continue;let se=W.w+2*(w+$h),oe=W.h+2*(v+$h);se*O<=k*oe?k=Math.max(k,se):O=Math.max(O,oe)}let R=ze(e.title,!1,l,a,4e3,1),L=R.height>0?R.height+12:0,P=2*k,B=2*O,G=s,C=s+L,Z=G+k,ee=C+O,H=G+P,Y=C+B,_=Fp(C,ee,Z,p,f,{...Z5,segments:4,pinEnd:!0}),S=Fp(G,Z,ee,p+100,f,{...xw,segments:4,pinEnd:!0}),$=Fp(Z,H,ee,p+200,f,{...xw,segments:4,pinStart:!0}),y=Q5(Z,ee,Y,P*.03),E=(W,X)=>X?`${d(W[W.length-2])},${d(W[W.length-1])}`:`${d(W[0])},${d(W[1])}`,x=new Map([["complex",`M${d(G)},${d(C)}L${E(_,!1)}${Wl(_)}${xh(S)}Z`],["complicated",`M${E(_,!1)}L${d(H)},${d(C)}L${E($,!0)}${xh($)}${xh(_)}Z`],["chaotic",`M${E(S,!1)}${Wl(S)}${Wl(y)}L${d(G)},${d(Y)}Z`],["clear",`M${E($,!1)}${Wl($)}L${d(H)},${d(Y)}L${E(y,!0)}${xh(y)}Z`]]),T="";for(let[W,,,X]of Wp)T+=`<path class="pele-cynefin-region" data-id="${W}" d="${x.get(W)}" fill="${dt(X)}" fill-opacity="0.14"/>`;let A=`<g class="pele-cynefin-boundaries" fill="none" stroke="var(--_b)" stroke-dasharray="6 3"><path d="${wh(_)}"/><path d="${wh(S)}"/><path d="${wh($)}"/><path class="pele-cynefin-cliff" d="${wh(y)}" stroke="var(--_l)" stroke-width="2" stroke-dasharray="none" stroke-linecap="round"/></g>`,M=J5(Z,ee,w,v),N=`<path d="${M}" fill="var(--_bg)"/><path class="pele-cynefin-region" data-id="confusion" d="${M}" fill="${dt(e6)}" fill-opacity="0.18" stroke="var(--_b)" stroke-dasharray="4 2"/>`,F=W=>{let X=W.cy-W.h/2,te=Re(W.title,W.cx,X+W.title.height/2,' class="pele-label" font-weight="var(--_hw)"');X+=W.title.height;for(let se of W.subtitles)te+=Re(se,W.cx,X+se.height/2,` class="pele-cynefin-subtitle" font-size="${i}" font-style="italic" fill="var(--_m)"`),X+=se.height;X+=$w-bh;for(let se of W.badges)X+=bh,te+=`<g class="pele-node${se.overflow?" pele-cynefin-overflow":""}"${se.overflow?"":` data-id="${Oe(se.text)}"`}><rect x="${d(W.cx-se.w/2)}" y="${d(X)}" width="${d(se.w)}" height="${d(se.h)}" fill="var(--_bg)" stroke="var(--_b)"${se.overflow?' stroke-dasharray="3 2"':""}${nt}/>`+Re(se.label,W.cx,X+se.h/2,` class="pele-label" font-size="${n}"${se.overflow?' fill="var(--_m)"':""}`,o)+"</g>",X+=se.h;return`<g class="pele-cynefin-domain" data-id="${W.name}">${te}</g>`},U=new Map,D="";Wp.forEach(([W,X,te],se)=>{let oe=m[se];oe.cx=G+k*(X+.5),oe.cy=C+O*(te+.5),U.set(W,oe),D+=F(oe)}),b.cx=Z,b.cy=ee,U.set("confusion",b),D+=F(b);let I=(W,X,te)=>W===b?((X-Z)/(w+4))**2+((te-ee)/(v+4))**2<=1:Math.abs(X-W.cx)<=W.w/2+8&&Math.abs(te-W.cy)<=W.h/2+8,z="",q=new Map;for(let W of e.transitions){let X=U.get(W.from),te=U.get(W.to);if(!X||!te||X===te)continue;let se=W.from<W.to?`${W.from} ${W.to}`:`${W.to} ${W.from}`,oe=q.get(se)??0;q.set(se,oe+1);let ae=te.cx-X.cx,ne=te.cy-X.cy,J=Math.hypot(ae,ne)||1,re=(X.cx+te.cx)/2,fe=(X.cy+te.cy)/2,ye=-ne*(re-Z)+ae*(fe-ee)>=0?1:-1,le=-ne/J*ye,we=ae/J*ye,pe=(X!==b&&te!==b&&Math.abs(ae)>1&&Math.abs(ne)>1?2*(Math.hypot(w*le,v*we)+16):J*.15)+oe*56,ge=re+le*pe,Ae=fe+we*pe,Se=$e=>{let ve=1-$e;return[ve*ve*X.cx+2*ve*$e*ge+$e*$e*te.cx,ve*ve*X.cy+2*ve*$e*Ae+$e*$e*te.cy]},ce=($e,ve,Te,De)=>{for(let _e=0;_e<16;_e++){let Ye=(ve+Te)/2;I($e,...Se(Ye))===De?ve=Ye:Te=Ye}return(ve+Te)/2},ue=48,xe=1;for(;xe<=ue&&I(X,...Se(xe/ue));)xe++;if(xe>ue)continue;let Ie=ce(X,(xe-1)/ue,xe/ue,!0);for(;xe<=ue&&!I(te,...Se(xe/ue));)xe++;let Le=xe>ue?1:ce(te,(xe-1)/ue,xe/ue,!1),[We,de]=Se(Ie),[ke,Ce]=Se(Le),be=($e,ve,Te)=>(1-Ie)*(1-Le)*$e+((1-Ie)*Le+Ie*(1-Le))*ve+Ie*Le*Te,Me=be(X.cx,ge,te.cx),Ne=be(X.cy,Ae,te.cy),Be=Math.hypot(ke-Me,Ce-Ne)||1,Pe=(ke-Me)/Be,V=(Ce-Ne)/Be,me=bt("arrow_point",ke,Ce,Pe,V,"var(--_l)");ke-=Pe*gt("arrow_point"),Ce-=V*gt("arrow_point");let ie="";if(W.label){let $e=ze(W.label,!1,l,i,bw),[ve,Te]=Se((Ie+Le)/2),De=Math.abs(le)*$e.width/2+Math.abs(we)*$e.height/2+6,_e=$e.width/2+4,Ye=Math.min(Math.max(ve+le*De,G+_e),Math.max(H-_e,G+_e));ie=Re($e,Ye,Te+we*De,` class="pele-edge-label" font-size="${i}"`,o)}z+=`<g class="pele-edge" data-id="${W.from}-${W.to}"><path d="M${d(We)},${d(de)}Q${d(Me)},${d(Ne)} ${d(ke)},${d(Ce)}" fill="none" stroke="var(--_l)"/>`+me+ie+"</g>"}let j=Math.ceil(Math.max(P,R.width)+2*s),Q=Math.ceil(B+L+2*s),K=Re(R,G+P/2,s+R.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-cynefin-regions">${T}</g>`+A+N+D+(z?`<g class="pele-edges">${z}</g>`:"");return{svg:Je("cynefin",j,Q,a,r,e,K),width:j,height:Q,links:[]}}var G5,mw,Z5,xw,Wp,e6,t6,ww,bw,r6,a6,bh,$w,kw,$h,Mw,Aw=Xe(()=>{Vr();pr();ut();wt();G5=class{constructor(){he(this,"domains",new Map);he(this,"transitions",[])}setDomains(e){if(e)for(let t of e){let r=t.domain;this.domains.set(r,{name:r,items:(t.items??[]).map(a=>({label:a.label}))})}}setTransitions(e){e&&(this.transitions=e.filter(t=>t.from!==t.to).map(t=>({from:t.from,to:t.to,label:t.label||void 0})))}};mw=[{name:"cynefin-beta:",pattern:"cynefin-beta:"},or("cynefin-beta"),{name:"-->",pattern:"-->"},{name:":",pattern:":"},{name:"DOMAIN_NAME",pattern:/complex|complicated|clear|chaotic|confusion/y},ur,rr,ar,Xr,Rr,Lr,jt,sr,lr];Z5={segments:7,vertical:!0,pointStep:17,controlStep:31,controlShift:7},xw={segments:7,vertical:!1,pointStep:23,controlStep:37,controlShift:11};Wp=[["complex",0,0,0],["complicated",1,0,1],["chaotic",0,1,3],["clear",1,1,2]],e6=4,t6=new Map([["complex",["Complex","Probe \u2192 Sense \u2192 Respond","Emergent Practices"]],["complicated",["Complicated","Sense \u2192 Analyse \u2192 Respond","Good Practices"]],["clear",["Clear","Sense \u2192 Categorise \u2192 Respond","Best Practices"]],["chaotic",["Chaotic","Act \u2192 Sense \u2192 Respond","Novel Practices"]],["confusion",["Confusion","","Disorder"]]]),ww=3,bw=200,r6=10,a6=4,bh=6,$w=10,kw=20,$h=10;Mw={type:"cynefin",parse:(e,t,r)=>j5(X5(e),r),render:i6}});var vw={};_t(vw,{cynefin:()=>Mw});var Ew=Xe(()=>{Aw()});function Ah(e,t){let r=e<=1?e*100:e;if(r<0||r>100)throw new je(`${t} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${e}`,"semantic",{type:"wardley"});return r}function Mn(e,t,r){return{x:Ah(t,`${r} evolution`),y:Ah(e,`${r} visibility`)}}function Sw(e){return e==="+<>"?"bidirectional":e==="+<"?"backward":e==="+>"?"forward":void 0}function s6(e){if(!e?.startsWith("+"))return{};let t=e.indexOf("'",2),r=e[1]==="'"&&t!==-1?e.slice(2,t):void 0;return e.includes("<>")?{flow:"bidirectional",label:r}:e.includes("<")?{flow:"backward",label:r}:e.includes(">")?{flow:"forward",label:r}:{label:r}}function Tw(e){return e?[(e.negX?-1:1)*e.offsetX,(e.negY?-1:1)*e.offsetY]:[void 0,void 0]}function l6(e,t){e.size&&t.setSize(e.size.width,e.size.height),e.evolution&&t.setAxes({stages:e.evolution.stages.map(r=>r.secondName?`${r.name.trim()} / ${r.secondName.trim()}`:r.name.trim()),stageBoundaries:e.evolution.stages.filter(r=>r.boundary!==void 0).map(r=>r.boundary)});for(let r of e.anchors){let a=Mn(r.visibility,r.evolution,`Anchor "${r.name}"`);t.addNode({id:r.name,label:r.name,x:a.x,y:a.y,className:"anchor"})}for(let r of e.components){let a=Mn(r.visibility,r.evolution,`Component "${r.name}"`),[i,n]=Tw(r.label);t.addNode({id:r.name,label:r.name,x:a.x,y:a.y,className:"component",labelOffsetX:i,labelOffsetY:n,inertia:r.inertia,sourceStrategy:r.decorator?.strategy})}for(let r of e.notes){let a=Mn(r.visibility,r.evolution,`Note "${r.text}"`);t.addNote({text:r.text,x:a.x,y:a.y})}for(let r of e.pipelines){let a=t.getNode(r.parent);if(!a||typeof a.y!="number")throw new je(`Pipeline "${r.parent}" must reference an existing component with coordinates.`,"semantic",{type:"wardley"});let i=a.y;t.startPipeline(r.parent);for(let n of r.components){let l=`${r.parent}_${n.name}`,[s,o]=Tw(n.label),c=Ah(n.evolution,`Pipeline component "${n.name}" evolution`);t.addNode({id:l,label:n.name,x:c,y:i,className:"pipeline-component",labelOffsetX:s,labelOffsetY:o,inertia:void 0,sourceStrategy:void 0}),t.addPipelineComponent(r.parent,l)}}for(let r of e.links){let a=!!r.arrow&&(r.arrow.includes("-.->")||r.arrow.includes(".-.")),i=s6(r.arrow),n=Sw(r.fromPort)??Sw(r.toPort)??i.flow;t.addLink({source:t.resolveNodeId(r.from),target:t.resolveNodeId(r.to),dashed:a,label:i.label??r.linkLabel,flow:n})}for(let r of e.evolves){let a=t.getNode(r.component);a?.y!==void 0&&t.addTrend({nodeId:r.component,targetX:Ah(r.target,`Evolve target for "${r.component}"`),targetY:a.y})}if(e.annotations.length>0){let r=Mn(e.annotations[0].x,e.annotations[0].y,"Annotations box");t.setAnnotationsBox(r.x,r.y)}for(let r of e.annotation){let a=Mn(r.x,r.y,`Annotation ${r.number}`);t.addAnnotation({number:r.number,coordinates:[{x:a.x,y:a.y}],text:r.text})}for(let r of e.accelerators){let a=Mn(r.x,r.y,`Accelerator "${r.name}"`);t.addAccelerator({name:r.name,x:a.x,y:a.y})}for(let r of e.deaccelerators){let a=Mn(r.x,r.y,`Deaccelerator "${r.name}"`);t.addDeaccelerator({name:r.name,x:a.x,y:a.y})}}function o6(e,t){let r=new n6;return l6(e,r),{type:"wardley",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
129
+ `):void 0,...r.build()}}function Cw(e,t){let r=t;for(let a=e.charCodeAt(r);a>=48&&a<=57;a=e.charCodeAt(r))r++;return r}function c6(){let e=0,t=0;return(r,a)=>{if((a<e||a>=t)&&(e=a,t=Cw(r,a)),t===a||r.charCodeAt(t)!==46)return-1;let i=Cw(r,t+1);return i>t+1?i:-1}}function h6(e){let t=new Zt(Gt(e,Nw,"wardley"),Nw,"wardley"),r={$type:"Wardley",anchors:[],components:[],links:[],evolves:[],pipelines:[],notes:[],annotations:[],annotation:[],accelerators:[],deaccelerators:[]},a=g=>t.kinds[t.i]===g,i=()=>a(36)||a(37)||a(30),n=()=>a(36)?$r(t.take()):a(37)||a(30)?t.take():t.fail("a name"),l=()=>Number(t.expect(10)),s=()=>parseInt(t.expect(35)),o=()=>a(10)?Number(t.take()):parseInt(t.expect(35)),c=()=>{if(!a(-1))for(a(38)||t.fail("a line break or the end of input");a(38);)t.i++},f=g=>{t.expect(0);let u=g();t.expect(1);let m=g();return t.expect(2),[u,m]},p=()=>{t.expect(21),t.expect(0);let g=t.accept(7),u=s();t.expect(1);let m=t.accept(7),b=s();return t.expect(2),{$type:"Label",negX:g,offsetX:u,negY:m,offsetY:b}},h=()=>{let g={$type:"EvolutionStage",name:n()};return t.accept(3)&&(g.boundary=l()),t.accept(4)&&(g.secondName=n()),g};for(;a(38);)t.i++;for(t.expect(16);!a(-1);)switch(t.kind){case 38:t.i++;break;case 32:r.accDescr=Kt(t.take()),c();break;case 33:r.accTitle=Vt(t.take()),c();break;case 34:r.title=Xt(t.take()),c();break;case 17:{t.i++;let[g,u]=f(s);c(),r.size={$type:"Size",width:g,height:u};break}case 18:{t.i++;let g=[h()];for(t.expect(11),g.push(h());t.accept(11);)g.push(h());c(),r.evolution={$type:"Evolution",stages:g};break}case 19:{t.i++;let g=n(),[u,m]=f(l);c(),r.anchors.push({$type:"Anchor",name:g,visibility:u,evolution:m});break}case 20:{t.i++;let g={$type:"Component",name:n(),visibility:0,evolution:0,inertia:!1};[g.visibility,g.evolution]=f(l),a(21)&&(g.label=p()),a(5)&&t.kinds[t.i+1]===15&&(t.i++,g.decorator={$type:"Decorator",strategy:t.take()},t.expect(6)),t.accept(22)?g.inertia=!0:t.accept(5)&&(t.expect(22),t.expect(6),g.inertia=!0),c(),r.components.push(g);break}case 23:{t.i++;let g=n(),u=l();c(),r.evolves.push({$type:"Evolve",component:g,target:u});break}case 24:{t.i++;let g=n();for(t.expect(8),t.expect(38);a(38);)t.i++;let u=[];do{t.expect(20);let m={$type:"PipelineComponent",name:n(),evolution:0};t.expect(0),m.evolution=l(),t.expect(2),a(21)&&(m.label=p()),c(),u.push(m)}while(a(20));t.expect(9),c(),r.pipelines.push({$type:"Pipeline",parent:g,components:u});break}case 25:{t.i++;let g=$r(t.expect(36)),[u,m]=f(l);c(),r.notes.push({$type:"Note",text:g,visibility:u,evolution:m});break}case 26:{t.i++;let[g,u]=f(o);c(),r.annotations.push({$type:"Annotations",x:g,y:u});break}case 27:{t.i++;let g=s();t.expect(1);let[u,m]=f(o),b=$r(t.expect(36));c(),r.annotation.push({$type:"Annotation",number:g,x:u,y:m,text:b});break}case 28:case 29:{let g=t.kind===29;t.i++;let u=n(),[m,b]=f(l);c(),g?r.deaccelerators.push({$type:"Deaccelerator",name:u,x:m,y:b}):r.accelerators.push({$type:"Accelerator",name:u,x:m,y:b});break}default:{i()||t.fail("a statement");let g={$type:"Link",from:n(),to:""};a(12)&&(g.fromPort=t.take()),(a(13)||a(11))&&(g.arrow=t.take()),g.to=n(),a(12)&&(g.toPort=t.take()),a(14)&&(g.linkLabel=t.take().substring(1).trim()),c(),r.links.push(g)}}return r}function g6(e,t,r,a,i){let n=e["wardley-beta"]?.[t];return typeof n=="number"&&n>=a&&n<=i?n:r}function ws(e,t,r){return e<t?t:e>r?r:e}function Lw(e,t,r,a){let i=li(e),n="",l=r;for(let s of e.lines){let o=!0;for(let c of s){if(c.icon!==void 0)continue;let f=Ya(c.style&~i);n+=`<tspan${o?` x="${d(t)}" y="${d(l)}"`:""}${f}>${Ve(c.text)}</tspan>`,o=!1}l+=e.lineHeight}return n===""?"":`<text${Aa(a,i)} xml:space="preserve">${n}</text>`}function Dw(e,t,r,a){let i=typeof t=="number"&&Number.isFinite(t)?t:g6(e,r,a,1,1e6);return ws(i,200,1e4)-2*f6}function m6(e,t,r){let a=Dw(t,e.size?.width,"width",900);return Ci(r,a,160,(i,n)=>y6(e,t,r,i,a,n))}function y6(e,t,r,a,i,n){let l=r.fontSize??16,s=Math.round(l*.8125),o=Math.round(l*.6875),c=r.measurer??et(r.fontFamily),f=r.padding??8,p=Dw(t,e.size?.height,"height",600)*Math.max(.75,a/i),h=t["wardley-beta"]?.showGrid===!0,g=0,u=0,m=a,b=p,w=(le,we,pe,ge)=>{le<g&&(g=le),we<u&&(u=we),pe>m&&(m=pe),ge>b&&(b=ge)},v=(le,we,pe,ge)=>(w(we-le.width/2,pe-le.height/2,we+le.width/2,pe+le.height/2),Re(le,we,pe,ge,r.icons)),k=(le,we,pe,ge)=>(w(we,pe-le.size,we+le.width,pe-le.size+le.height+4),Lw(le,we,pe,ge)),O=(le,we,pe=n?Math.max(64,Math.min(120,a/2)):4e3,ge=0)=>ze(le,!1,c,we,pe,ge),R=le=>le/100*a,L=le=>p-le/100*p,P=e.axes.stages&&e.axes.stages.length>0?e.axes.stages:d6,B=e.axes.stageBoundaries,G=B!==void 0&&B.length===P.length,C="",Z="",ee=p,H=0;if(P.forEach((le,we)=>{let pe=G?H:we/P.length,ge=G?ws(B[we],0,1):(we+1)/P.length;H=ge,we>0&&(C+=`<path class="pele-wardley-stage" d="M${d(pe*a)},0V${d(p)}" stroke="var(--_b)" stroke-dasharray="4 4"/>`);let Ae=O(le,s,Math.max(48,Math.abs(ge-pe)*a-12));Z+=v(Ae,(pe+ge)/2*a,p+8+Ae.height/2,` class="pele-wardley-stage-label" font-size="${s}" fill="var(--_m)"`),ee=Math.max(ee,p+8+Ae.height)}),h)for(let le=1;le<4;le++)C+=`<path class="pele-wardley-grid" d="M${d(a*le/4)},0V${d(p)}M0,${d(p*le/4)}H${d(a)}" stroke="var(--_b)" stroke-dasharray="2 6"/>`;C+=`<path class="pele-wardley-axis" d="M0,0V${d(p)}H${d(a)}" stroke="${oa}"/>`;let Y=O(e.axes.xLabel??"Evolution",s),_=O(e.axes.yLabel??"Visibility",s),S=` class="pele-wardley-axis-label" font-size="${s}" font-weight="var(--_hw)"`,$=v(Y,a/2,ee+6+Y.height/2,S)+Re(_,-16,p/2,`${S} transform="rotate(-90 -16 ${d(p/2)})"`);w(-16-_.height/2,0,0,0);let y=ee+6+Y.height+10,E=new Map;for(let le of e.nodes)E.set(le.id,{x:R(le.x),y:L(le.y),node:le});let x="",T=new Map;for(let le of e.pipelines){T.set(le.nodeId,new Set(le.componentIds));let we=[];for(let ue of le.componentIds){let xe=E.get(ue);xe&&we.push(xe)}if(we.length===0)continue;we.sort((ue,xe)=>ue.x-xe.x);let pe=we[0].x,ge=we[we.length-1].x,Ae=we[0].y,Se=Ae-2*qt,ce=E.get(le.nodeId);ce&&(ce.x=(pe+ge)/2,ce.y=Se-An/6),w(pe-Mh,Se,ge+Mh,Se+4*qt),x+=`<g class="pele-wardley-pipeline" data-id="${Oe(le.nodeId)}"><rect x="${d(pe-Mh)}" y="${d(Se)}" width="${d(ge-pe+2*Mh)}" height="${d(4*qt)}" fill="var(--_s)" stroke="var(--_b)"${nt}/>`+(we.length>1?`<path d="M${d(pe)},${d(Ae)}H${d(ge)}" stroke="${oa}" stroke-dasharray="4 4"/>`:"")+"</g>"}let A=new Map,M=(le,we,pe)=>{let ge=le.node;if(ge.className==="anchor"){let Ae=A.get(ge);return Ae||A.set(ge,Ae=O(ge.label,s,n?Math.max(64,a/2):4e3,1)),1/Math.hypot(we/(Ae.width/2+5),pe/(s*.8))}return ge.isPipelineParent?An/Math.SQRT2:ge.sourceStrategy?2*qt:qt},N=new Map,F=(le,we,pe)=>{Math.abs(we)<.25||Math.abs(pe)<.25||N.set(le,(N.get(le)??0)|(we>0?pe<0?1:2:pe<0?4:8))},U="";for(let le of e.links){let we=E.get(le.source),pe=E.get(le.target);if(!we||!pe||we===pe||T.get(le.target)?.has(le.source))continue;let ge=pe.x-we.x,Ae=pe.y-we.y,Se=Math.hypot(ge,Ae);if(Se<.01)continue;let ce=ge/Se,ue=Ae/Se,xe=M(we,ce,ue),Ie=M(pe,ce,ue);if(xe+Ie>=Se)continue;F(we,ce,ue),F(pe,-ce,-ue);let Le=we.x+ce*xe,We=we.y+ue*xe,de=pe.x-ce*Ie,ke=pe.y-ue*Ie,Ce="";(le.flow==="forward"||le.flow==="bidirectional")&&(Ce+=bt("arrow_point",de,ke,ce,ue,oa),de-=ce*gt("arrow_point"),ke-=ue*gt("arrow_point")),(le.flow==="backward"||le.flow==="bidirectional")&&(Ce+=bt("arrow_point",Le,We,-ce,-ue,oa),Le+=ce*gt("arrow_point"),We+=ue*gt("arrow_point"));let be="";if(le.label){let Me=O(le.label,o+1,200),Ne=ce>=0?1:-1,Be=ue*Ne,Pe=-ce*Ne,V=5+Math.abs(Be)*Me.width/2+Math.abs(Pe)*Me.height/2;be=v(Me,(we.x+pe.x)/2+Be*V,(we.y+pe.y)/2+Pe*V,` class="pele-edge-label" font-size="${o+1}" fill="var(--_m)"`)}U+=`<g class="pele-edge${le.dashed?" pele-wardley-dashed":""}" data-id="${Oe(le.source)}-${Oe(le.target)}"><path d="M${d(Le)},${d(We)}L${d(de)},${d(ke)}" stroke="${oa}"${le.dashed?' stroke-dasharray="6 6"':""}/>`+Ce+be+"</g>"}let D="";for(let le of e.trends){let we=E.get(le.nodeId);if(!we)continue;let pe=R(le.targetX),ge=L(le.targetY),Ae=pe-we.x,Se=ge-we.y,ce=Math.hypot(Ae,Se),ue="",xe=ce>0?M(we,Ae/ce,Se/ce):0;if(ce>xe+qt+4){let Ie=Ae/ce,Le=Se/ce,We=pe-Ie*(qt+2),de=ge-Le*(qt+2);ue=`<path d="M${d(we.x+Ie*xe)},${d(we.y+Le*xe)}L${d(We-Ie*gt("arrow_point"))},${d(de-Le*gt("arrow_point"))}" stroke="${Bp}" stroke-dasharray="4 4"/>`+bt("arrow_point",We,de,Ie,Le,Bp)}w(pe-qt,ge-qt,pe+qt,ge+qt),D+=`<g class="pele-wardley-trend" data-id="${Oe(le.nodeId)}">${ue}<circle cx="${d(pe)}" cy="${d(ge)}" r="${qt}" fill="var(--_bg)" stroke="${Bp}"/></g>`}let I="",z=1.2*qt,q=.7*qt;for(let le of E.values()){let we=le.node,{x:pe,y:ge}=le,Ae=we.className==="anchor",Se=we.sourceStrategy,ce="";if(Se){let Le=Se==="outsource"?"var(--_m)":Se==="buy"?"var(--_a)":Se==="build"?"var(--_s)":"var(--_bg)";ce+=`<circle class="pele-wardley-${Se}" cx="${d(pe)}" cy="${d(ge)}" r="${2*qt}" fill="${Le}" stroke="${oa}"/>`}if(Se==="market"){let Le=z*Math.cos(Math.PI/6),We=ge+z*Math.sin(Math.PI/6);ce+=`<path d="M${d(pe)},${d(ge-z)}L${d(pe-Le)},${d(We)}H${d(pe+Le)}Z" fill="none" stroke="${oa}"/>`;for(let[de,ke]of[[pe,ge-z],[pe-Le,We],[pe+Le,We]])ce+=`<circle cx="${d(de)}" cy="${d(ke)}" r="${d(q)}" fill="var(--_bg)" stroke="${oa}"/>`}else we.isPipelineParent?ce+=`<rect x="${d(pe-An/2)}" y="${d(ge-An/2)}" width="${An}" height="${An}" fill="var(--_bg)" stroke="${oa}"/>`:Ae||(ce+=`<circle cx="${d(pe)}" cy="${d(ge)}" r="${qt}" fill="var(--_bg)" stroke="${oa}"/>`);if(we.inertia===!0){let Le=(we.isPipelineParent?An/2:qt)+10+(Se?qt+4:0);ce+=`<rect class="pele-wardley-inertia" x="${d(pe+Le)}" y="${d(ge-qt)}" width="4" height="${2*qt}" fill="${oa}"/>`}let ue=we.labelOffsetX===void 0?void 0:ws(we.labelOffsetX,-5e3,5e3),xe=we.labelOffsetY===void 0?void 0:ws(we.labelOffsetY,-5e3,5e3),Ie;if(Ae){let Le=A.get(we)??O(we.label,s,n?Math.max(64,a/2):4e3,1);Ie=v(Le,pe+(ue??0),ge+(xe??-3),` class="pele-label" font-size="${s}" font-weight="var(--_hw)"`)}else{let Le=O(we.label,s),We=` class="pele-label" font-size="${s}"`,de=p6+(Se?10:0);if(ue!==void 0||xe!==void 0)Ie=k(Le,pe+(ue??de),ge+(xe??-de),We);else if(we.inPipeline)Ie=v(Le,pe,ge+2*qt+4+Le.height/2,We);else{let ke=N.get(le)??0,Ce=ke&1?ke&2?ke&4?ke&8?1:8:4:2:1,be=Ce===1||Ce===2,Me=Ce===1||Ce===4;Ie=k(Le,be?pe+de:pe-de-Le.width,Me?ge-de:ge+de+s*.75,We)}}w(pe-2*qt,ge-2*qt,pe+2*qt+20,ge+2*qt),I+=`<g class="pele-node pele-wardley-${Ae?"anchor":we.isPipelineParent?"pipeline-parent":we.inPipeline?"pipeline-component":"component"}" data-id="${Oe(we.id)}">${ce}${Ie}</g>`}let j="";for(let le of e.annotations){let we=O(String(le.number),o,4e3,1),pe="";for(let ge of le.coordinates){let Ae=R(ge.x),Se=L(ge.y),ce=Math.max(10,we.width/2+4);w(Ae-ce,Se-ce,Ae+ce,Se+ce),pe+=`<circle cx="${d(Ae)}" cy="${d(Se)}" r="${d(ce)}" fill="var(--_bg)" stroke="${oa}"/>`+Re(we,Ae,Se,` font-size="${o}" font-weight="var(--_hw)"`)}j+=`<g class="pele-wardley-annotation" data-id="${Oe(String(le.number))}">${pe}</g>`}let Q=e.annotations.filter(le=>le.text).sort((le,we)=>le.number-we.number);if(Q.length>0){let le=Q.map(xe=>O(`${xe.number}. ${xe.text}`,s,n?Math.max(80,a-20):320)),we=0,pe=0;for(let xe of le)we=Math.max(we,xe.width),pe+=xe.height;we+=20,pe+=14;let ge=e.annotationsBox,Ae=ge?ws(R(ge.x),0,Math.max(0,a-we)):0,Se=ge?ws(L(ge.y),0,Math.max(0,p-pe)):y;w(Ae,Se,Ae+we,Se+pe);let ce="",ue=Se+7;for(let xe of le)ce+=Lw(xe,Ae+10,ue+xe.lineHeight/2+s*.35,` font-size="${s}"`),ue+=xe.height;j+=`<g class="pele-wardley-annotations"><rect x="${d(Ae)}" y="${d(Se)}" width="${d(we)}" height="${d(pe)}" fill="var(--_bg)" stroke="var(--_b)"${nt}/>${ce}</g>`}let K="";for(let le of e.notes)K+=k(O(le.text,s,Math.min(360,a*.6),1),R(le.x),L(le.y),` class="pele-wardley-note" font-size="${s}" font-weight="var(--_hw)"`);let W="",X=(le,we,pe,ge)=>{let Ae=R(we),Se=L(pe),ce=u6/2,ue=ge?Ae+Bl:Ae,xe=ge?Ae:Ae+Bl,Ie=ge?Ae+Bl-Rw:Ae+Rw,Le=`M${d(xe)},${d(Se-ce)}H${d(Ie)}V${d(Se-ce-8)}L${d(ue)},${d(Se)}L${d(Ie)},${d(Se+ce+8)}V${d(Se+ce)}H${d(xe)}Z`;w(Ae,Se-ce-8,Ae+Bl,Se+ce+8),W+=`<g class="pele-wardley-${ge?"accelerator":"deaccelerator"}" data-id="${Oe(le)}"><path d="${Le}" fill="var(--_s)" stroke="${oa}"/>`+v(O(le,o+1,160,1),Ae+Bl/2,Se+ce+8+12,` font-size="${o+1}" font-weight="var(--_hw)"`)+"</g>"};for(let le of e.accelerators)X(le.name,le.x,le.y,!0);for(let le of e.deaccelerators)X(le.name,le.x,le.y,!1);let te=ze(e.title,!1,c,l,n?Math.max(80,a):4e3,1),se=te.height>0?te.height+12:0,oe=Math.min(g,a/2-te.width/2),ae=Math.max(m,a/2+te.width/2),ne=f-oe,J=f+se-u,re=Math.ceil(ae-oe+2*f),fe=Math.ceil(b-u+se+2*f),ye=Re(te,ne+a/2,f+te.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${d(ne)},${d(J)})"><g class="pele-wardley-frame" fill="none">${C}</g>`+Z+$+x+(U?`<g class="pele-edges" fill="none">${U}</g>`:"")+(D?`<g class="pele-wardley-trends" fill="none">${D}</g>`:"")+I+j+K+W+"</g>";return{svg:Je("wardley",re,fe,l,r,e,ye),width:re,height:fe,links:[]}}var n6,_w,Iw,Qr,Nw,d6,f6,qt,An,p6,Mh,Bl,u6,Rw,Bp,oa,Ow,Pw=Xe(()=>{uh();zt();Vr();pr();ut();wt();n6=class{constructor(){he(this,"nodes",new Map);he(this,"labels");he(this,"links",[]);he(this,"trends",new Map);he(this,"pipelines",new Map);he(this,"annotations",[]);he(this,"notes",[]);he(this,"accelerators",[]);he(this,"deaccelerators",[]);he(this,"annotationsBox");he(this,"axes",{});he(this,"size")}addNode(e){let t=this.nodes.get(e.id)??{id:e.id,label:e.label};this.nodes.set(e.id,{...t,...e,className:e.className??t.className,labelOffsetX:e.labelOffsetX??t.labelOffsetX,labelOffsetY:e.labelOffsetY??t.labelOffsetY}),this.labels=void 0}addLink(e){this.links.push(e)}addTrend(e){this.trends.set(e.nodeId,e)}startPipeline(e){this.pipelines.set(e,{nodeId:e,componentIds:[]});let t=this.nodes.get(e);t&&(t.isPipelineParent=!0)}addPipelineComponent(e,t){this.pipelines.get(e)?.componentIds.push(t);let r=this.nodes.get(t);r&&(r.inPipeline=!0)}addAnnotation(e){this.annotations.push(e)}addNote(e){this.notes.push(e)}addAccelerator(e){this.accelerators.push(e)}addDeaccelerator(e){this.deaccelerators.push(e)}setAnnotationsBox(e,t){this.annotationsBox={x:e,y:t}}setAxes(e){this.axes={...this.axes,...e}}setSize(e,t){this.size={width:e,height:t}}getNode(e){return this.nodes.get(e)}resolveNodeId(e){if(this.nodes.has(e))return e;if(!this.labels){this.labels=new Map;for(let[t,r]of this.nodes)this.labels.has(r.label)||this.labels.set(r.label,t)}return this.labels.get(e)??e}build(){let e=[];for(let t of this.nodes.values()){if(typeof t.x!="number"||typeof t.y!="number")throw new je(`Node "${t.label}" is missing coordinates`,"semantic",{type:"wardley"});e.push(t)}return{nodes:e,links:[...this.links],trends:[...this.trends.values()],pipelines:[...this.pipelines.values()],annotations:[...this.annotations],notes:[...this.notes],accelerators:[...this.accelerators],deaccelerators:[...this.deaccelerators],annotationsBox:this.annotationsBox,axes:{...this.axes},size:this.size}}};_w={name:"ARROW",pattern:/->/y,first:"-"},Iw={name:"LINK_ARROW",pattern:/-->|-\.->|>|\+'[^']*'<>|\+'[^']*'<|\+'[^']*'>/y,first:"->+"},Qr=(e,t)=>({name:e,pattern:new RegExp(t,"y"),first:t[0]}),Nw=[{name:"[",pattern:"["},{name:",",pattern:","},{name:"]",pattern:"]"},{name:"@",pattern:"@"},{name:"/",pattern:"/"},{name:"(",pattern:"("},{name:")",pattern:")"},{name:"-",pattern:"-",longer:[_w,Iw,jt]},{name:"{",pattern:"{"},{name:"}",pattern:"}"},{name:"WARDLEY_NUMBER",pattern:/[0-9]+\.[0-9]+/y,first:"0123456789",scanner:c6},_w,{name:"LINK_PORT",pattern:/\+<>|\+>|\+</y,first:"+"},Iw,{name:"LINK_LABEL",pattern:/;[^\n\r]+/y,first:";"},{name:"STRATEGY",pattern:/build|buy|outsource|market/y,first:"bom"},Qr("KW_WARDLEY","wardley-beta"),Qr("KW_SIZE","size"),Qr("KW_EVOLUTION","evolution"),Qr("KW_ANCHOR","anchor"),Qr("KW_COMPONENT","component"),Qr("KW_LABEL","label"),Qr("KW_INERTIA","inertia"),Qr("KW_EVOLVE","evolve"),Qr("KW_PIPELINE","pipeline"),Qr("KW_NOTE","note"),Qr("KW_ANNOTATIONS","annotations"),Qr("KW_ANNOTATION","annotation"),Qr("KW_ACCELERATOR","accelerator"),Qr("KW_DEACCELERATOR","deaccelerator"),{name:"NAME_WITH_SPACES",pattern:/(?!title\s|accTitle|accDescr)[A-Za-z](?:[A-Za-z0-9_()&]|-(?!>))*(?:[ \t]+[A-Za-z(](?:[A-Za-z0-9_()&]|-(?!>))*)*/y,first:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"},{name:"WS",pattern:/[ \t]+/y,hidden:!0,first:" "},xs(),rr,ar,{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y,first:"0123456789"},Xr,{name:"ID",pattern:/[\w]([-\w]*\w)?/y,first:"_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"},Rr,Lr,jt,sr,lr];d6=["Genesis","Custom Built","Product","Commodity"],f6=48,qt=6,An=10,p6=8,Mh=15,Bl=60,u6=30,Rw=20,Bp="var(--_c)",oa="var(--_l)";Ow={type:"wardley",section:"wardley-beta",parse:(e,t,r)=>o6(h6(e),r),render:m6}});var zw={};_t(zw,{wardley:()=>Ow});var Fw=Xe(()=>{Pw()});function b6(e){return e==="ui"||e==="processor"?"trigger":e==="event"?"stream":"state"}function Yp(e){let t=e.indexOf("{"),r=e.lastIndexOf("}"),a=(t!==-1&&r>t?e.slice(t+1,r):t===-1&&e.length>=2?e.slice(1,-1):"").replace(/\r/g,"").split(`
130
+ `);for(;a.length>0&&a[0].trim()==="";)a.shift();for(;a.length>0&&a[a.length-1].trim()==="";)a.pop();let i=1/0;for(let n of a)n.trim()!==""&&(i=Math.min(i,n.length-n.trimStart().length));return a.map(n=>n.slice(Math.min(i,n.length)).trimEnd()).join(`
131
+ `)}function $6(e,t){let r=new Set;for(let p of e.frames){if(r.has(p.name)){let h=Ys(e.$source,p.$offset).line;throw new je(`Duplicate event modeling frame ID "${p.name}" on line ${h}`,"semantic",{type:"eventmodeling",line:h})}r.add(p.name)}let a=new Map;for(let p of e.dataEntities)a.has(p.name)||a.set(p.name,p.dataBlockValue);let i=new Map,n=new Map,l=(p,h)=>{let g=b6(p),u=h===void 0?g:`${g} ${h}`,m=i.get(u);if(!m){let[b,w,v]=w6.get(g),k=b;h!==void 0&&(k=n.get(g)??b+1,n.set(g,k+1)),m={index:k,label:h===void 0?w:v+h,group:g,namespace:h},i.set(u,m)}return m},s=[],o=new Map,c=[];e.frames.forEach((p,h)=>{let g=p.entityIdentifier.split("."),u=g.length===2?g[0]:void 0,m=x6.get(p.modelEntityType)??"event",b=p.dataInlineValue===void 0?void 0:Yp(p.dataInlineValue);if(p.dataReference){let v=a.get(p.dataReference.$refText);v!==void 0&&(b=Yp(v))}let w={id:p.name,kind:m,entity:p.entityIdentifier,name:g.length===2?g[1]:p.entityIdentifier,namespace:u,reset:p.$type==="EmResetFrame",lane:l(m,u),data:b,dataType:p.dataType};if(s.push(w),o.set(w.id,w),p.sourceFrames.length>0){let v=new Set(p.sourceFrames.map(k=>k.$refText));for(let k of s)v.has(k.id)&&c.push({source:k,target:w})}else if(h>0&&!w.reset){for(let v=h-1;v>=0;v--)if(s[v].lane!==w.lane){c.push({source:s[v],target:w});break}}});let f=p=>p.map(h=>h.entityIdentifier.$refText);return{type:"eventmodeling",title:e.title&&Xt(e.title)||t,accTitle:e.accTitle?Vt(e.accTitle).replace(/^\s+/g,""):void 0,accDescr:e.accDescr?Kt(e.accDescr).replace(/\n\s+/g,`
132
+ `):void 0,boxes:s,lanes:[...i.values()].sort((p,h)=>p.index-h.index),relations:c,notes:e.noteEntities.map(p=>({frame:p.sourceFrame.$refText,text:Yp(p.dataBlockValue),dataType:p.dataType})),specifications:e.gwtEntities.map(p=>({frame:p.sourceFrame.$refText,given:f(p.givenStatements),when:f(p.whenStatements),then:f(p.thenStatements)})),entities:e.modelEntities.map(p=>p.name)}}function v6(e){let t=new Zt(Gt(e,Gp,"eventmodeling"),Gp,"eventmodeling"),r={$type:"EventModel",modelEntities:[],frames:[],dataEntities:[],noteEntities:[],gwtEntities:[],$source:e},a=o=>t.kinds[t.i]===o,i=(o,c)=>o.has(t.kinds[t.i])?t.take():t.fail(c),n=()=>{let o=t.expect(Ot.id);for(;t.accept(Ot.dot);)o+="."+t.expect(Ot.id);return o},l=()=>{if(!t.accept(Ot.tick))return;let o=i(A6,"a data type");return t.expect(Ot.tick),o},s=()=>{let o=[];do i(Hp,"an entity type"),o.push({$type:"EmGwtStatement",entityIdentifier:{$refText:t.expect(Ot.id)}});while(Hp.has(t.kinds[t.i]));return o};for(t.expect(Ot.keyword);!a(-1);){let o=t.kinds[t.i];if(o===Ot.accDescr)r.accDescr=t.take();else if(o===Ot.accTitle)r.accTitle=t.take();else if(o===Ot.title)r.title=t.take();else if(o===Ot.entity)t.i++,r.modelEntities.push({$type:"EmModelEntity",name:n()});else if(Ww.has(o)||M6.has(o)){let c={$type:Ww.has(o)?"EmTimeFrame":"EmResetFrame",name:"",modelEntityType:"",entityIdentifier:"",sourceFrames:[],$offset:t.tokens.starts[t.i]};for(t.i++,c.name=t.expect(Ot.frameId),c.modelEntityType=i(Hp,"an entity type"),c.entityIdentifier=n();t.accept(Ot.arrow);)c.sourceFrames.push({$refText:t.expect(Ot.frameId)});if(t.accept(Ot.open)&&(c.dataReference={$refText:t.expect(Ot.id)},t.expect(Ot.close)),a(Ot.tick)||a(Ot.inline)){let f=l();f!==void 0&&(c.dataType=f),c.dataInlineValue=t.expect(Ot.inline)}r.frames.push(c)}else if(o===Ot.data){t.i++;let c={$type:"EmDataEntity",name:t.expect(Ot.id),dataBlockValue:""},f=l();f!==void 0&&(c.dataType=f),c.dataBlockValue=t.expect(Ot.block),r.dataEntities.push(c)}else if(o===Ot.note){t.i++;let c={$type:"EmNoteEntity",sourceFrame:{$refText:t.expect(Ot.frameId)},dataBlockValue:""},f=l();f!==void 0&&(c.dataType=f),c.dataBlockValue=t.expect(Ot.block),r.noteEntities.push(c)}else if(o===Ot.gwt){t.i++;let c={$type:"EmGwt",sourceFrame:{$refText:t.expect(Ot.frameId)},givenStatements:[],whenStatements:[],thenStatements:[]};t.expect(Ot.given),c.givenStatements=s(),t.accept(Ot.when)&&(c.whenStatements=s()),t.expect(Ot.then),c.thenStatements=s(),r.gwtEntities.push(c)}else t.fail("a frame, an entity, a data block, a note, or a specification")}return r}function Up(e,t){let r=[];for(let a of At(e).split(`
133
+ `)){if(a.length<=t){r.push(a);continue}for(let i=0;i<a.length;i+=t)r.push(a.slice(i,i+t))}return r}function Eh(e,t,r,a,i){let n="";for(let l=0;l<e.length;l++)e[l]!==""&&(n+=`<tspan x="${d(t)}" y="${d(r+l*a)}">${Ve(e[l])}</tspan>`);return n===""?"":`<text${i} xml:space="preserve">${n}</text>`}function C6(e,t,r){return Bt(r,a=>_6(e,t,r,a))}function _6(e,t,r,a){if(a)return R6(e,r);let i=r.fontSize??16,n=Math.round(i*.875),l=Math.round(i*.8125),s=Math.round(i*.75),o=Math.round(s*1.4),c=Math.round(l*1.5),f=r.measurer??et(r.fontFamily,r.fontFamilyMono),p=r.padding??8,h=(A,M,N)=>{let F=0;for(let U of A)F=Math.max(F,f.width(U,M,N));return F},g=new Map,u=0;for(let A of e.lanes){let M=ze(A.label,!1,f,l,4e3,1);u=Math.max(u,M.width),g.set(A,{lane:A,label:M,right:-1/0,y:0,h:0})}u+=2*vh;let m=[],b=new Map,w;for(let A of e.boxes){let M=g.get(A.lane),N=ze(A.name,!1,f,n,4e3,1),F=A.data?Up(A.data,T6):[],U=Math.max(E6,Math.max(N.width,h(F,s,4))+2*vr),D=2*ca+N.height+(F.length>0?6+F.length*o:0),I=0;if(w){let q=w.x+Math.max(w.w/2,w.w-S6);I=w.box.lane===A.lane?M.right+Bw:Math.max(q,M.right+Bw)}let z={box:A,name:N,data:F,x:I,y:0,w:U,h:D};M.right=I+U,M.h=Math.max(M.h,D),m.push(z),b.set(A,z),w=z}let v=0;for(let A of m)v=Math.max(v,A.x+A.w);let k=u+v+vh,O=ze(e.title,!1,f,i,4e3,1),R=O.height>0?O.height+12:0,L=p,P=p+R,B=P,G="";for(let A of g.values())A.y=B,A.h+=2*vh,G+=`<g class="pele-cluster pele-em-lane" data-id="${Oe(A.lane.label)}"><rect x="${d(L)}" y="${d(B)}" width="${d(k)}" height="${d(A.h)}" fill="var(--_s)"${nt}/>`+Re(A.label,L+vh+A.label.width/2,B+A.h/2,` class="pele-cluster-label" font-size="${l}" font-weight="var(--_hw)" fill="var(--_m)"`)+"</g>",B+=A.h+Yw;let C=g.size>0?B-Yw:P,Z="";for(let A of m){let M=g.get(A.box.lane);A.x+=L+u,A.y=M.y+(M.h-A.h)/2;let N=qw.get(A.box.kind),F=`x="${d(A.x)}" y="${d(A.y)}" width="${d(A.w)}" height="${d(A.h)}"`,U=N===void 0?`<rect ${F} fill="var(--_bg)" stroke="var(--_b)"${nt}/>`:`<rect ${F} fill="var(--_bg)"${nt}/><rect ${F} fill="${dt(N)}" fill-opacity="0.22" stroke="${dt(N)}"${nt}/>`,D=A.y+ca+A.name.height/2,I=Re(A.name,A.x+A.w/2,D,` class="pele-label" font-size="${n}" font-weight="var(--_hw)"`)+Eh(A.data,A.x+vr,A.y+ca+A.name.height+6+o/2+s*.35,o,` class="pele-em-data" font-family="${qs}" font-size="${s}"`);Z+=`<g class="pele-node pele-em-${A.box.kind}${A.box.reset?" pele-em-reset":""}" data-id="${Oe(A.box.id)}">${U}${I}</g>`}let ee="",H=gt("arrow_point");for(let A of e.relations){let M=b.get(A.source),N=b.get(A.target);if(!M||!N||M===N)continue;let F,U;if(M.box.lane===N.box.lane){let D=N.x>=M.x,I=D?M.x+M.w:M.x,z=D?N.x:N.x+N.w,q=M.y+M.h/2,j=N.y+N.h/2,Q=z>=I?1:-1;F=`M${d(I)},${d(q)}L${d(z-Q*H)},${d(j)}`,U=bt("arrow_point",z,j,Q,0,"var(--_l)")}else{let D=N.y>M.y,I=Math.max(M.x,N.x),z=Math.min(M.x+M.w,N.x+N.w),q=oe=>Math.min(24,oe/4),j=z-I>=16?(I+z)/2:N.x>M.x?M.x+M.w-q(M.w):M.x+q(M.w),Q=z-I>=16?j:N.x>M.x?N.x+q(N.w):N.x+N.w-q(N.w),K=D?M.y+M.h:M.y,W=D?N.y:N.y+N.h,X=D?1:-1,te=W-X*H,se=(K+te)/2;F=j===Q?`M${d(j)},${d(K)}V${d(te)}`:`M${d(j)},${d(K)}C${d(j)},${d(se)} ${d(Q)},${d(se)} ${d(Q)},${d(te)}`,U=bt("arrow_point",Q,W,0,X,"var(--_l)")}ee+=`<g class="pele-edge" data-id="${Oe(A.source.id)}-${Oe(A.target.id)}"><path d="${F}" fill="none" stroke="var(--_l)"/>${U}</g>`}let Y=new Map;for(let A of e.boxes)Y.set(A.id,A.name);let _="",S=0,$=(A,M,N,F)=>{let U=ze(`${M} \xB7 ${N}${Y.has(N)?" "+Y.get(N):""}`,!1,f,l,4e3,1),D=Math.max(U.width,h(F,l,0))+2*vr,I=2*ca+U.height+F.length*c,z=C+(_===""&&g.size===0?0:Gw);_+=`<g class="pele-em-${A}" data-id="${Oe(N)}"><rect x="${d(L)}" y="${d(z)}" width="${d(D)}" height="${d(I)}" fill="var(--_bg)" stroke="var(--_b)"${nt}/>`+Re(U,L+vr+U.width/2,z+ca+U.height/2,` font-size="${l}" font-weight="var(--_hw)"`)+Eh(F,L+vr,z+ca+U.height+c/2+l*.35,c,` font-size="${l}"`)+"</g>",C=z+I,S=Math.max(S,D)};for(let A of e.notes)$("note","Note",A.frame,Up(A.text,Hw));for(let A of e.specifications){let M=[`Given ${A.given.join(", ")}`];A.when.length>0&&M.push(`When ${A.when.join(", ")}`),M.push(`Then ${A.then.join(", ")}`),$("specification","Given / When / Then",A.frame,M.flatMap(N=>Up(N,Hw)))}let y=Math.max(g.size>0?k:0,S,O.width),E=Math.ceil(y+2*p),x=Math.ceil(C+p),T=Re(O,E/2,p+O.height/2,' class="pele-title" font-weight="var(--_tw)"')+G+ee+Z+_;return{svg:Je("eventmodeling",E,x,i,r,e,T),width:E,height:x,links:[]}}function R6(e,t){let r=t.fontSize??16,a=Math.round(r*.875),i=Math.round(r*.75),n=t.padding??8,l=t.measurer??et(t.fontFamily,t.fontFamilyMono),s=Math.max(160,(t.maxWidth??320)-2*n),o=new Map(e.boxes.map((Y,_)=>[Y,_])),c=new Map,f=new Set;for(let Y of e.relations){let _=o.get(Y.source),S=o.get(Y.target);if(_===void 0||S===void 0||_===S)continue;if(Math.abs(_-S)<2){f.add(e.boxes[Math.max(_,S)]);continue}let $=c.get(Y.target);$?($[0]=Math.min($[0],_),$[1]=Math.max($[1],_)):c.set(Y.target,[Math.min(_,S),Math.max(_,S)])}let p=new Map,h=[];for(let[Y,[_,S]]of[...c].sort(($,y)=>$[1][0]-y[1][0])){let $=h.findIndex(y=>y<_);$<0&&($=h.length),h[$]=S,p.set(Y,$)}let g=24+Uw*Math.max(0,h.length-1),u=Math.max(I6,s-g),m=u-2*vr,b=ze(e.title,!1,l,r,s,1),w=n+(b.height?b.height+12:0),v=n+b.height,k=Math.max(b.width,u+g),O="",R="",L="",P=new Map,B=(Y,_,S=0)=>fn(At(Y),l,_,m,S);e.boxes.forEach((Y,_)=>{let S=f.has(Y)?m-N6:m,$=pn(ze(Y.lane.label,!1,l,a,S,1),l,S),y=ze(Y.name,!1,l,a,m-36,1),E=Y.data?B(Y.data,i,4):void 0,x=Math.max(u,$.width+2*vr,y.width+2*vr+36,(E?.width??0)+2*vr),T=$.height+12,A=2*ca+y.height+(E?E.height+6:0),M=qw.get(Y.kind),N=w+T,F=`x="${d(n)}" y="${d(N)}" width="${d(x)}" height="${d(A)}"`;O+=`<g class="pele-cluster pele-em-lane" data-id="${Oe(Y.lane.label)}">`+yi($,n+vr,w,` class="pele-cluster-label" font-size="${a}" font-weight="var(--_hw)" fill="var(--_m)"`)+`<g class="pele-node pele-em-${Y.kind}${Y.reset?" pele-em-reset":""}" data-id="${Oe(Y.id)}"><rect ${F} fill="var(--_bg)" stroke="var(--_b)"${nt}/>`+(M===void 0?"":`<rect ${F} fill="${dt(M)}" fill-opacity="0.22" stroke="${dt(M)}"${nt}/>`)+Re(y,n+vr+y.width/2,N+ca+y.height/2,` class="pele-label" font-size="${a}" font-weight="var(--_hw)"`)+`<text class="pele-em-frame" x="${d(n+x-vr)}" y="${d(N+ca+a)}" text-anchor="end" font-size="${i}" fill="var(--_m)">${Ve(Y.id)}</text>`+(E?Eh(E.lines.map(U=>U.map(D=>D.text).join("")),n+vr,N+ca+y.height+6+E.lineHeight/2+i*.35,E.lineHeight,` class="pele-em-data" font-family="${qs}" font-size="${i}"`):"")+"</g></g>",P.set(Y,{y:N,h:A,w:x,index:_,lane:$.width}),k=Math.max(k,x+g),v=N+A,w=v+28});for(let Y of e.relations){let _=P.get(Y.source),S=P.get(Y.target);if(!_||!S||_===S)continue;let $=S.y>_.y,y=$?1:-1,E=$?_.y+_.h:_.y,x=$?S.y:S.y+S.h,T,A;if(Math.abs(_.index-S.index)===1){let M=n+Math.max(Math.min(_.w,S.w)/2,vr+($?S:_).lane+16);T=`M${d(M)},${d(E)}V${d(x-y*gt("arrow_point"))}`,A=bt("arrow_point",M,x,0,y,"var(--_l)")}else{let M=n+k-g+12+Uw*(p.get(Y.target)??0),N=_.y+_.h/2-5,F=S.y+S.h/2+5;T=`M${d(n+_.w)},${d(N)}H${d(M)}V${d(F)}H${d(n+S.w+gt("arrow_point"))}`,A=bt("arrow_point",n+S.w,F,-1,0,"var(--_l)")}R+=`<g class="pele-edge" data-id="${Oe(Y.source.id)}-${Oe(Y.target.id)}"><path d="${T}" fill="none" stroke="var(--_l)"/>${A}</g>`}let G=new Map(e.boxes.map(Y=>[Y.id,Y.name])),C=(Y,_,S,$)=>{let y=ze(`${_} \xB7 ${S}${G.has(S)?" "+G.get(S):""}`,!1,l,a,m,1),E=B($,a),x=Math.max(u,y.width+2*vr,E.width+2*vr),T=2*ca+y.height+E.height;L+=`<g class="pele-em-${Y}" data-id="${Oe(S)}"><rect x="${d(n)}" y="${d(w)}" width="${d(x)}" height="${d(T)}" fill="var(--_bg)" stroke="var(--_b)"${nt}/>`+Re(y,n+vr+y.width/2,w+ca+y.height/2,` font-size="${a}" font-weight="var(--_hw)"`)+Eh(E.lines.map(A=>A.map(M=>M.text).join("")),n+vr,w+ca+y.height+E.lineHeight/2+a*.35,E.lineHeight,` font-size="${a}"`)+"</g>",v=w+T,w=v+Gw,k=Math.max(k,x)};for(let Y of e.notes)C("note","Note",Y.frame,Y.text);for(let Y of e.specifications){let _=[`Given ${Y.given.join(", ")}`];Y.when.length&&_.push(`When ${Y.when.join(", ")}`),_.push(`Then ${Y.then.join(", ")}`),C("specification","Given / When / Then",Y.frame,_.join(`
134
+ `))}let Z=Math.ceil(k+2*n),ee=Math.ceil(v+n),H=Re(b,Z/2,n+b.height/2,' class="pele-title" font-weight="var(--_tw)"')+R+O+L;return{svg:Je("eventmodeling",Z,ee,r,t,e,H),width:Z,height:ee,links:[]}}var x6,w6,qp,bs,Yl,k6,Gp,hr,Sh,Ot,Ww,M6,Hp,A6,qw,vr,ca,E6,Bw,S6,vh,Yw,T6,Hw,Gw,Uw,I6,N6,jw,Xw=Xe(()=>{uh();un();zt();Vr();pr();ut();wt();x6=new Map([["ui","ui"],["pcr","processor"],["processor","processor"],["rmo","readmodel"],["readmodel","readmodel"],["cmd","command"],["command","command"],["evt","event"],["event","event"]]),w6=new Map([["trigger",[0,"UI/Automation","UI/A: "]],["state",[100,"Command/Read Model","C/RM: "]],["stream",[200,"Events","Stream: "]]]);qp={name:"EM_ID",pattern:/[_a-zA-Z][\w_]*/y},bs=e=>({name:e,pattern:e,longer:[qp]}),Yl=e=>({name:e,pattern:e}),k6=["resetframe","readmodel","processor","timeframe","command","entity","event","jsobj","figma","given","json","salt","html","text","data","note","when","then","rmo","cmd","evt","pcr","uri"],Gp=[{...or("eventmodeling"),longer:[qp]},...k6.map(bs),Yl("->>"),bs("gwt"),bs("ui"),bs("md"),bs("tf"),Yl("[["),Yl("]]"),bs("rf"),Yl("`"),Yl("."),qp,{name:"EM_FID",pattern:/\d{1,3}/y},{name:"EM_DATA_INLINE",pattern:/\{(.*)\}|"(.*)"|'(.*)'/y},{name:"EM_DATA_BLOCK",pattern:/\{[\t ]*\r?\n(?:[\S\s]*?\r?\n)?\}(?:\r?\n|(?!\S))/y},xs("EM_ACC_DESCR"),{...rr,name:"EM_ACC_TITLE"},{...ar,name:"EM_TITLE"},{name:"EM_WS",pattern:/\s+/y,hidden:!0},{...jt,name:"EM_YAML"},{...sr,name:"EM_DIRECTIVE"},{...lr,name:"EM_SINGLE_LINE_COMMENT"},{name:"EM_ML_COMMENT",pattern:/\/\*[\s\S]*?\*\//y,hidden:!0},{name:"EM_SL_COMMENT",pattern:/\/\/[^\n\r]*/y,hidden:!0}],hr=e=>Gp.findIndex(t=>t.name===e),Sh=e=>new Set(e.map(hr)),Ot={keyword:0,arrow:hr("->>"),open:hr("[["),close:hr("]]"),tick:hr("`"),dot:hr("."),id:hr("EM_ID"),frameId:hr("EM_FID"),inline:hr("EM_DATA_INLINE"),block:hr("EM_DATA_BLOCK"),accDescr:hr("EM_ACC_DESCR"),accTitle:hr("EM_ACC_TITLE"),title:hr("EM_TITLE"),entity:hr("entity"),data:hr("data"),note:hr("note"),gwt:hr("gwt"),given:hr("given"),when:hr("when"),then:hr("then")},Ww=Sh(["tf","timeframe"]),M6=Sh(["rf","resetframe"]),Hp=Sh(["rmo","readmodel","ui","cmd","command","evt","event","pcr","processor"]),A6=Sh(["json","jsobj","figma","salt","uri","md","html","text"]);qw=new Map([["command",0],["event",1],["readmodel",2],["processor",6]]),vr=12,ca=10,E6=96,Bw=16,S6=80,vh=12,Yw=8,T6=48,Hw=80,Gw=8;Uw=8,I6=120,N6=20;jw={type:"eventmodeling",keepComments:!0,parse:(e,t,r)=>$6(v6(e),r),render:C6}});var Vw={};_t(Vw,{eventmodeling:()=>jw});var Kw=Xe(()=>{Xw()});function Th(e){return e<128&&(Hi[e]&Kl)!==0}function jp(e,t,r){for(let a=0;a<r.length;a++)if((e.charCodeAt(t+a)|32)!==r.charCodeAt(a))return!1;return!0}function L6(e,t,r){switch(r){case 97:return e.startsWith("actor",t)?2:0;case 115:return e.startsWith("systemBoundary",t)?3:e.startsWith("style",t)?16:0;case 101:return e.startsWith("end",t)?4:jp(e,t,"extend")?18:0;case 69:return jp(e,t,"extend")?18:0;case 100:return e.startsWith("direction",t)?5:0;case 84:return e.startsWith("TD",t)?6:e.startsWith("TB",t)?7:0;case 66:return e.startsWith("BT",t)?8:0;case 76:return e.startsWith("LR",t)?9:0;case 82:return e.startsWith("RL",t)?10:0;case 110:return e.startsWith("note",t)?11:0;case 102:return e.startsWith("for",t)?12:e.startsWith("false",t)?20:0;case 106:return e.startsWith("json",t)?13:0;case 99:return e.startsWith("classDef",t)?14:e.startsWith("class",t)?15:0;case 105:case 73:return jp(e,t,"include")?17:0;case 116:return e.startsWith("true",t)?19:0;case 117:return e.startsWith("usecase-beta",t)?1:0;default:return 0}}function Zl(e,t){let r=1,a=0;for(let i=0;i<t;i++){let n=e.charCodeAt(i);n!==10&&n!==13||(n===13&&i+1<t&&e.charCodeAt(i+1)===10&&i++,r++,a=i+1)}return[r,t-a+1]}function D6(e,t,r){let[a,i]=Zl(e,t);return`line ${a}, column ${i} [${t},${r})`}function gb(e,t,r){for(let a=t+1;a<e.length;a++){let i=e.charCodeAt(a);if(i===r)return a+1;if(i===10||i===13)return-1}return-1}function O6(e,t){let r=e.charCodeAt(t);return r!==34&&r!==39?!0:r===34&&e.charCodeAt(t+1)===96||gb(e,t,r)!==-1}function Qw(e,t,r){let[a,i]=Zl(e,t);return new je(`Error lexing usecase diagram: unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${r} characters. at line ${a}, column ${i} [${t},${t+r})`,"syntax",{type:"usecase",line:a,column:i})}function P6(e){let t=[],r=[],a=[],i=e.length,n=0,l=!0,s=!1;for(;n<i;){let o=e.charCodeAt(n);if(o===32||o===9){n++;continue}let c,f=n+1,p=!1;if(o<128&&Hi[o]&Kl){if(c=0,o===97&&l&&e.startsWith("acc",n)){let h=e.startsWith("Descr",n+3);if(h||e.startsWith("Title",n+3)){let g=n+8;for(;pa(e.charCodeAt(g));)g++;let u=e.charCodeAt(g);if(u===58)for(c=h?42:41,f=g+1;f<i&&e.charCodeAt(f)!==10&&e.charCodeAt(f)!==13;)f++;else if(u===123&&h&&!s){let m=e.indexOf("}",g+1);m===-1?s=!0:(c=40,f=m+1)}}}else if(o===106&&e.startsWith("json",n)&&pa(e.charCodeAt(n+4))){let h=n+5;for(;pa(e.charCodeAt(h));)h++;let g=h;for(;Th(e.charCodeAt(h));)h++;if(h>g){for(;pa(e.charCodeAt(h));)h++;if(e.charCodeAt(h)===64){for(h++;pa(e.charCodeAt(h));)h++;if(e.charCodeAt(h)===123){t.push(43),r.push(n),a.push(h),n=h;let u=0,m=!1,b=!1,w=h;for(;w<i;w++){let v=e.charCodeAt(w);if(m)b?b=!1:v===92?b=!0:v===34&&(m=!1);else if(v===34)m=!0;else if(v===123)u++;else if(v===125&&--u===0)break}t.push(w<i?44:45),r.push(h),n=w<i?w+1:i,a.push(n),l=!1;continue}}}}if(c===0){for(;f<i&&Th(e.charCodeAt(f));)f++;let h=L6(e,n,o);if(h!==0)h===1||f-n===Zw[h]?(c=h,f=n+Zw[h]):c=21;else if((o===111||o===120)&&e.charCodeAt(n+1)===45&&e.charCodeAt(n+2)===45)c=o===111?56:58,f=n+3;else if(pt(o)){let g=n+1;for(;pt(e.charCodeAt(g));)g++;if(e.charCodeAt(g)===46&&pt(e.charCodeAt(g+1))){for(c=22,f=g+2;pt(e.charCodeAt(f));)f++;for(;si(e.charCodeAt(f));)f++}else c=21}else for(c=21;e.charCodeAt(f)===45&&Th(e.charCodeAt(f+1));)for(c=27,f+=2;Th(e.charCodeAt(f));)f++}}else if(o===10)c=39,p=!0;else if(o===13)c=39,p=!0,e.charCodeAt(f)===10&&f++;else if(o===34||o===39){if(o===34&&e.charCodeAt(n+1)===96){let h=e.indexOf('`"',n+2);c=h===-1?37:36,f=h===-1?i:h+2}else if(c=35,f=gb(e,n,o),f===-1){let h=n+1;for(;h<i&&!O6(e,h);)h++;throw Qw(e,n,h-n)}}else if(o===37)if(l&&e.charCodeAt(f)===37)for(c=38;f<i&&e.charCodeAt(f)!==10&&e.charCodeAt(f)!==13;)f++;else c=31;else if(o===45)if(e.charCodeAt(f)!==45)c=29;else{for(;e.charCodeAt(f)===45;)f++;let h=e.charCodeAt(f),g=f-n===2;g&&h===124&&e.charCodeAt(f+1)===62?(c=46,f+=2):h===62?(c=53,f++):g&&(h===111||h===120)?(c=h===111?55:57,f++):c=59}else if(o===46){let h=e.charCodeAt(f);if(h===46&&e.charCodeAt(f+1)===62)c=47,f+=2;else if(pt(h)){for(c=22;pt(e.charCodeAt(f));)f++;for(;si(e.charCodeAt(f));)f++}else c=30}else if(o===60)if(e.charCodeAt(f)===60){if(t.push(48),r.push(n),a.push(n+2),l=!1,n+=2,n>=i)break;if(e.charCodeAt(n)===62&&e.charCodeAt(n+1)===62)c=49,f=n+2;else{let h=n,g=!1;for(;h<i;h++){let u=e.charCodeAt(h);if(u===10||u===13)break;if(u===62&&e.charCodeAt(h+1)===62){g=!0;break}}if(g&&e.slice(n,h).trim()!=="")t.push(50),r.push(n),a.push(h),c=49,n=h,f=h+2;else{for(;h<i&&e.charCodeAt(h)!==10&&e.charCodeAt(h)!==13;)h++;if(h===n){for(;h<i&&(e.charCodeAt(h)===10||e.charCodeAt(h)===13);)h++;throw Qw(e,n,h-n)}c=51,f=h}}}else if(e.charCodeAt(f)===45&&e.charCodeAt(f+1)===45)for(c=54,f+=2;e.charCodeAt(f)===45;)f++;else c=33;else if(o===58)e.charCodeAt(f)===58&&e.charCodeAt(f+1)===58?(c=52,f+=2):c=25;else if(o===64)e.charCodeAt(f)===123?(c=60,f++):c=23;else if(o===123)c=61;else if(o===125)c=62;else if(o===91)c=63;else if(o===93)c=64;else if(o===40)c=65;else if(o===41)c=66;else if(o===44)c=24;else if(o===35){for(;oo(e.charCodeAt(f));)f++;c=f>n+1?26:32}else if(o===92)e.charCodeAt(f)===44?(c=28,f++):c=33;else if(o<127&&o>32)c=Hi[o]&ub?32:33;else for(c=34;f<i;){let h=e.charCodeAt(f);if(h>=32&&h<127||h===9||h===10||h===13)break;f++}t.push(c),r.push(n),a.push(f),n=f,l=p}for(let o=0;o<3;o++)t.push(0),r.push(i),a.push(i);return{types:t,starts:r,ends:a}}function z6(){return{type:"usecase",actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,direction:"LR",title:void 0,accTitle:"",accDescr:"",accDescription:"",source:"",headerSpan:[0,0],statements:[]}}function F6(){return{elements:[],boundaries:[],jsons:[],relationships:[],notes:[],metadata:[],classes:[],styles:[],classDefs:[],direction:void 0,accTitle:"",accDescription:""}}function Xp(e,t){if(t.length===0)return;let r=new Set(e);for(let a of t)r.has(a)||(r.add(a),e.push(a))}function W6(e){let t=new Set(["actor","usecase","boundary","edge"]);for(let{key:r,value:a}of e)if(r==="icon")t.clear(),t.add("actor");else if(r==="animate"||r==="animation")t.clear(),t.add("edge");else if(r==="type")t.clear(),a==="rect"||a==="package"?t.add("boundary"):(a==="normal"||a==="hollow"||a==="awesome")&&t.add("actor");else if(r==="business")t.delete("boundary"),t.delete("edge");else return;return t.size===1?[...t][0]:void 0}function B6(e,t,r,a,i){let n=z6(),{actors:l,useCases:s,systemBoundaries:o}=n,c=new Map,f=new Map,p=new Map,h=new Map,g=new Map,u=x=>D6(e,x[0],x[1]),m=(x,T)=>{let[A,M]=Zl(e,T[0]);return new je(x,"semantic",{type:"usecase",line:A,column:M})},b=(x,T)=>{throw m(`${x} at ${u(T)}`,T)},w=(x,T,A,M,N)=>{let F=U=>U===void 0?"":` (label "${U}")`;throw m(`${x} at ${u(T)}${F(M)}; previous declaration at ${u(A)}${F(N)}`,T)},v=(x,T,A)=>b(`Metadata property '${A.key}' is invalid for ${T} '${x}'`,A.keySpan),k=(x,T)=>{let A=g.get(x);(A===void 0||T<A)&&g.set(x,T)},O=x=>[...x].sort((T,A)=>(g.get(T.id)??0)-(g.get(A.id)??0)),R=(x,T)=>{c.set(x.id,{kind:T,span:x.span,generated:x.generated,label:x.label.text})},L=(x,T)=>{let A=c.get(x.id);if(!A)return;let M=x.generated?x.label.text:void 0,N=A.generated?A.label:void 0;A.kind!==T&&w(`ID '${x.id}' is declared as both ${A.kind} and ${T}`,x.span,A.span,M,N),(A.generated||x.generated)&&w(`Generated ID '${x.id}' collides with another declaration`,x.span,A.span,M,N)},P=(x,T,A)=>{let M=c.get(x);M&&w(`ID '${x}' is declared more than once (${M.kind} and ${T})`,A,M.span,void 0,M.generated?M.label:void 0),c.set(x,{kind:T,span:A,generated:!1})},B=(x,T,A)=>{let{key:M,value:N}=T,F=U=>{!A&&U!==void 0&&U!==N&&w(`Actor '${x.id}' has conflicting ${M} metadata`,T.keySpan,x.span)};M==="type"&&(N==="normal"||N==="hollow"||N==="awesome")?(F(x.actorType),x.actorType=N):M==="icon"&&typeof N=="string"?(F(x.icon),x.icon=N):M==="business"&&typeof N=="boolean"?(F(x.business),x.business=N):v(x.id,"actor",T)},G=(x,T,A)=>{for(let M of T??[])x.kind==="actor"?B(x,M,A):M.key==="business"&&typeof M.value=="boolean"?(!A&&x.business!==void 0&&x.business!==M.value&&w(`Use case '${x.id}' has conflicting business metadata`,M.keySpan,x.span),x.business=M.value):v(x.id,"usecase",M)},C=x=>{let T;if(x.kind==="actor"){s.delete(x.id);let A={id:x.id,label:x.label.text,labelType:x.label.type,business:x.business??!1,classes:[...x.classes],type:x.icon?"icon":x.actorType??"normal",styles:l.get(x.id)?.styles??[]};x.icon&&(A.icon=x.icon),l.set(x.id,A),T=A}else l.delete(x.id),T={id:x.id,label:x.label.text,labelType:x.label.type,business:x.business??!1,classes:[...x.classes],shape:x.shape??"ellipse",styles:s.get(x.id)?.styles??[]},s.set(x.id,T);x.stereotype&&(T.stereotype=x.stereotype),x.parent?.id&&(T.parentId=x.parent.id)},Z=x=>{L(x,x.kind);let T=x.parent?.id?x.parent:void 0,A=f.get(x.id);if(!A){let M={kind:x.kind,id:x.id,label:x.label,span:x.span,generated:x.generated,classes:[...x.classes],parent:T,shape:x.shape,stereotype:x.stereotype,stereotypeSpan:x.stereotype?x.span:void 0};G(M,x.metadata,!1),f.set(x.id,M),R(x,x.kind);return}(A.label.text!==x.label.text||A.label.type!==x.label.type)&&w(`ID '${x.id}' has conflicting labels`,x.span,A.span),x.shape&&A.shape&&x.shape!==A.shape&&w(`Use case '${x.id}' has conflicting shapes`,x.span,A.span),T&&A.parent?.id&&T.id!==A.parent.id&&w(`Element '${x.id}' belongs to more than one system boundary`,T.span,A.parent.span),x.stereotype&&A.stereotype&&x.stereotype!==A.stereotype&&w(`Element '${x.id}' has conflicting stereotypes`,x.span,A.stereotypeSpan??A.span),A.shape??(A.shape=x.shape),A.parent??(A.parent=x.parent),A.stereotype??(A.stereotype=x.stereotype),A.stereotypeSpan??(A.stereotypeSpan=x.stereotype?x.span:void 0),Xp(A.classes,x.classes),G(A,x.metadata,!1)},ee=x=>{L(x,"boundary");let T=p.get(x.id);if(T){(T.label.text!==x.label.text||T.label.type!==x.label.type)&&w(`Boundary '${x.id}' has conflicting titles`,x.span,T.span),Xp(T.classes,x.classes);return}p.set(x.id,{...x,classes:[...x.classes],members:[]}),R(x,"boundary")},H=x=>{x.classed&&!x.declares&&b(`Relationship endpoint '${x.id}' uses ::: without declaring the node`,x.span);let T=c.get(x.id);return T?T.kind:(f.set(x.id,{...x,kind:"usecase",shape:"ellipse",classes:[]}),R(x,"usecase"),k(x.id,x.span[0]),"usecase")},Y=(x,T)=>{let A=c.get(x)?.kind;return(A==="actor"?l.get(x):A==="usecase"?s.get(x):A==="boundary"?o.get(x):A==="json"?n.jsonNodes.get(x):h.get(x))??b(`Class/style target '${x}' is unresolved or anonymous`,T)},_=[];for(let{source:x,target:T}of t.relationships)k(x.id,x.span[0]),k(T.id,T.span[0]);for(let x of t.elements)k(x.id,x.span[0]),_.push({offset:x.span[0],run:()=>Z(x)});for(let x of t.boundaries)k(x.id,x.span[0]),_.push({offset:x.span[0],run:()=>ee(x)});for(let x of t.jsons)k(x.id,x.span[0]),_.push({offset:x.span[0],run:()=>P(x.id,"json",x.span)});for(let{id:x,idSpan:T}of t.relationships)x&&T&&_.push({offset:T[0],run:()=>P(x,"edge",T)});_.sort((x,T)=>x.offset-T.offset);for(let x of _)x.run();for(let x of O(f.values()))C(x);for(let x of O(p.values()))o.set(x.id,{id:x.id,label:x.label.text,labelType:x.label.type,type:"rect",members:[],classes:[],styles:[]});for(let x of O(t.jsons))n.jsonNodes.set(x.id,{id:x.id,value:x.value,propertyOrder:x.propertyOrder,classes:[...x.classes],styles:[]});let S=0;for(let x of t.relationships){let{source:T,target:A,type:M}=x,N=H(T),F=H(A),U=z=>z==="actor"||z==="usecase"||z==="json";U(N)||w(`Relationship source '${T.id}' cannot be ${N}`,T.span,c.get(T.id).span),U(F)||w(`Relationship target '${A.id}' cannot be ${F}`,A.span,c.get(A.id).span),(M==="include"||M==="extend")&&(N!=="usecase"||F!=="usecase")&&b(`${M} relationship requires use-case endpoints`,x.span),M==="generalization"&&(N==="json"||N!==F)&&b("Generalization requires actor-to-actor or use-case-to-use-case endpoints",x.span),M==="association"&&(N==="json"||F==="json")&&x.arrowType>2&&b(`JSON relationship '${T.id}' to '${A.id}' permits only point, reversed-point, or markerless solid association`,x.span);let D=x.id??`edge-${S++}`,I={id:D,explicitId:!!x.id,source:T.id,target:A.id,type:M,arrowType:x.arrowType,minlen:x.minlen,classes:[],styles:[],animate:!1};x.label&&(I.label=x.label.text,I.labelType=x.label.type),n.relationships.push(I),h.set(D,I)}let $=new Map(l),y=new Map(s);l.clear(),s.clear();for(let x of O(f.values())){let T=$.get(x.id),A=y.get(x.id);T?l.set(x.id,T):A?s.set(x.id,A):C(x)}for(let{target:x,span:T,properties:A,statement:M}of t.metadata){let N=c.get(x);if(!N){let I=W6(A);return b(`Metadata target '${x}' is unresolved${I?` (metadata implies ${I})`:""}`,T)}let F=N.kind;F==="actor"||F==="usecase"?G(f.get(x),A,!0):F==="edge"&&(M.kind="edgeMetadata",M.edges=[{id:x,span:M.span,idSpan:T,metadata:M.metadata}],delete M.nodes);let U=p.get(x),D=h.get(x);for(let I of F==="actor"||F==="usecase"?[]:A){let{key:z,value:q}=I;F==="boundary"&&U&&z==="type"&&(q==="rect"||q==="package")?U.type=q:F==="edge"&&D&&z==="animate"&&typeof q=="boolean"?D.animate=q:F==="edge"&&D&&z==="animation"&&(q==="fast"||q==="slow")?(D.animation=q,D.animate=!0):v(x,F,I)}}for(let x of n.relationships)x.animation&&(x.animate=!0);for(let x of f.values())x.kind==="actor"?(x.icon&&x.actorType&&x.actorType!=="normal"&&b(`Actor '${x.id}' cannot combine icon with type '${x.actorType}'`,x.span),x.business&&(x.icon||x.actorType==="awesome")&&b(`Business actor '${x.id}' must use normal or hollow geometry`,x.span)):x.shape==="rect"&&x.business&&b(`Rectangular use case '${x.id}' cannot be a business use case`,x.span),C(x);for(let x of[...t.elements].sort((T,A)=>T.span[0]-A.span[0])){if(!x.parent?.id)continue;let T=p.get(x.parent.id).members;T.includes(x.id)||T.push(x.id)}for(let x of p.values()){let T=o.get(x.id);T.type=x.type??"rect",T.members=x.members,T.classes=[...x.classes]}let E=0;for(let x of t.notes){let T=c.get(x.target);if(!T)return b(`Note target '${x.target}' is unresolved`,x.span);T.kind!=="actor"&&T.kind!=="usecase"&&w(`Note target '${x.target}' must be an actor or use case, not ${T.kind}`,x.span,T.span);let A=`note-${E++}`;n.notes.set(A,{id:A,target:x.target,label:x.label.text,labelType:x.label.type})}for(let x of t.classDefs)for(let T of x.ids)n.classDefs.set(T,{id:T,styles:[...x.styles]});for(let x of t.classes)for(let T of x.targets)Xp(Y(T.id,T.span).classes,x.classes);for(let x of t.styles)Y(x.target,x.span).styles.push(...x.styles);return n.direction=t.direction??n.direction,n.title=i,n.accTitle=t.accTitle,n.accDescription=t.accDescription,n.accDescr=t.accDescription.replace(/\n\s+/g,`
135
+ `),n.source=e,n.headerSpan=r,n.statements=a,n}function Jw(e){let t=new Map,r=[],a=[],i=e.length,n=0,l="",s=0,o=()=>{for(;n<i;){let h=e.charCodeAt(n);if(h!==32&&h!==9&&h!==10&&h!==13)return;n++}},c=h=>{n++;let g="";for(;n<i;){let u=n,m=e[n++];if(m==='"')return g;if(m.charCodeAt(0)<32)throw new Jr(u);if(m!=="\\"){h&&(g+=m);continue}let b=n,w=e[n++],v;if(w==='"'||w==="\\"||w==="/")v=w;else if(w==="b")v="\b";else if(w==="f")v="\f";else if(w==="n")v=`
136
+ `;else if(w==="r")v="\r";else if(w==="t")v=" ";else if(w==="u"){let k=e.slice(n,n+4);if(!/^[\dA-Fa-f]{4}$/.test(k))throw new Jr(n);v=String.fromCharCode(parseInt(k,16)),n+=4}else throw new Jr(b);h&&(g+=v)}throw new Jr(n)},f=h=>{for(let g=0;g<h.length;g++)if(e[n+g]!==h[g])throw new Jr(n+g);n+=h.length},p=()=>{if(e.charCodeAt(n)===45&&n++,e.charCodeAt(n)===48)n++;else if(pt(e.charCodeAt(n)))for(;pt(e.charCodeAt(n));)n++;else throw new Jr(n);if(e.charCodeAt(n)===46){if(n++,!pt(e.charCodeAt(n)))throw new Jr(n);for(;pt(e.charCodeAt(n));)n++}if((e.charCodeAt(n)|32)===101){if(n++,(e.charCodeAt(n)===43||e.charCodeAt(n)===45)&&n++,!pt(e.charCodeAt(n)))throw new Jr(n);for(;pt(e.charCodeAt(n));)n++}};for(o();;)if(s===0){o();let h=e.charCodeAt(n);if(s=2,h===123){n++;let g=[];t.set(l,g),r.push(l),o(),e.charCodeAt(n)===125?n++:(a.push({object:!0,pointer:l,keys:g,ranges:new Map,key:"",from:0,index:0}),s=1)}else if(h===91)n++,o(),e.charCodeAt(n)===93?n++:(a.push({object:!1,pointer:l,keys:[],ranges:new Map,key:"",from:0,index:0}),l+="/0",s=0);else if(h===34)c(!1);else if(h===116)f("true");else if(h===102)f("false");else if(h===110)f("null");else if(h===45||pt(h))p();else throw new Jr(n)}else if(s===1){let h=a[a.length-1];if(e.charCodeAt(n)!==34)throw new Jr(n);let g=c(!0),u=h.ranges.get(g);if(u===void 0)h.keys.push(g);else for(let m=u[0];m<u[1];m++)t.delete(r[m]);if(h.key=g,h.from=r.length,o(),e.charCodeAt(n)!==58)throw new Jr(n);n++,l=`${h.pointer}/${g.replaceAll("~","~0").replaceAll("/","~1")}`,s=0}else{let h=a[a.length-1];if(h===void 0)break;h.object?h.ranges.set(h.key,[h.from,r.length]):h.index++,o();let g=e.charCodeAt(n);if(g===(h.object?125:93))n++,a.pop();else{if(g!==44)throw new Jr(n);n++,o(),l=`${h.pointer}/${h.index}`,s=h.object?1:0}}if(o(),n!==i)throw new Jr(n);return t}function tu(e,t,r,a){let i=Math.min(Math.max(t,0),e.length);for(let n=0;n<i;n++){let l=e.charCodeAt(n);l===13?(r++,a=1):l===10?(n===0||e.charCodeAt(n-1)!==13)&&(r++,a=1):a++}return[r,a]}function Y6(e,t,r,a){let i=/\bposition (\d+)\b/.exec(e);if(i)return tu(t,parseInt(i[1],10),r,a);let n=/\bline (\d+) column (\d+)\b/.exec(e);if(n){let l=parseInt(n[1],10),s=parseInt(n[2],10);return[r+l-1,l===1?a+s-1:s]}if(/unexpected end|end of json input/i.test(e))return tu(t,t.length,r,a)}function eb(e,t,r){return new je(`${e} (line ${t}, column ${r})`,"syntax",{type:"usecase",line:t,column:r})}function H6(e,t){let r;try{r=JSON.parse(e)}catch(a){let i=a instanceof Error?a.message:String(a),[n,l]=t(),s=Y6(i,e,n,l);if(!s){let o=0;try{Jw(e)}catch(c){c instanceof Jr&&(o=c.offset)}s=tu(e,o,n,l)}throw eb(`Invalid JSON: ${i}`,s[0],s[1])}if(typeof r!="object"||r===null||Array.isArray(r)){let[a,i]=t();throw eb("JSON value must have an object root",a,i)}return{value:r,propertyOrder:Jw(e)}}function Sn(e,t){for(let r of e.split("|"))if(r==="WORD")for(let a=1;a<=21;a++)Pa[a]|=t;else Pa[pb.indexOf(r)]|=t}function dr(e){return ea.slice(Sr[e],Br[e])}function ha(e){return[Sr[e],Br[e]]}function Fh(e){let[t,r]=Zl(ea,Sr[Fe]);throw new je(`Error parsing usecase diagram: ${e} at line ${t}, column ${r} [${Sr[Fe]},${Br[Fe]})`,"syntax",{type:"usecase",line:t,column:r})}function Eb(e){Fh(`Expecting token of type --> ${e} <-- but found --> '${dr(Fe)}' <--`)}function mr(e){return at[Fe]!==e&&Eb(pb[e]),Fe++}function wa(e){let t=e.split("|").map((r,a)=>` ${a+1}. [${r}]`);Fh(`Expecting: one of these possible Token sequences:
137
+ ${t.join(`
138
+ `)}
139
+ but found: '${dr(Fe)}'`)}function tb(){let e=zh.split("|"),t=e.flatMap(i=>["NEWLINE","IDENTIFIER","PLAIN_STRING","RBRACE"].map(n=>`${i}, METADATA_START, ${n}`)),r=`STEREOTYPE_START|CLASS_SEPARATOR|IDENTIFIER|${Ph}|NEWLINE|EOF`.split("|"),a=e.flatMap((i,n)=>(n===0?["LPAREN","LBRACKET",...r]:r).map(l=>`${i}, ${l}`));return[$b,...t,...a,...t].join("|")}function rb(e){return e>=1&&e<=21}function ab(e){return e>=1&&e<=34}function En(){Mb=Br[Fe-1],at[Fe]===39?Fe++:at[Fe]!==0&&wa("NEWLINE|EOF")}function Vl(e){let t=at[e]===36?2:at[e]===35?1:0;return[Sr[e]+t,Br[e]-t]}function au(e){let t=Vl(e);return{text:ea.slice(t[0],t[1]),type:at[e]===36?"markdown":"text",span:t}}function Sb(e){return e.replace(/\W/g,"_")}function Gl(){let e=at[Fe];if(e===35||e===36)return au(Fe++);ab(e)||wa(U6);let t=Fe;for(;ab(at[Fe]);)Fe++;let r=[Sr[t],Br[Fe-1]];return{text:ea.slice(r[0],r[1]),type:"text",span:r}}function vn(e){return e===21||e===35}function ib(){let e=Fe;vn(at[Fe])||wa("IDENTIFIER|PLAIN_STRING"),Fe++,mr(25);let t=Fe,r=at[Fe];!vn(r)&&r!==19&&r!==20&&wa("IDENTIFIER|PLAIN_STRING|TRUE|FALSE"),Fe++;let a=Vl(e),i=Vl(t);return{key:ea.slice(a[0],a[1]),value:r===19?!0:r===20?!1:ea.slice(i[0],i[1]),span:[Sr[e],Br[t]],keySpan:a,valueSpan:i}}function G6(){let e=at[Fe],t=at[Fe+1],r=at[Fe+2];return e===24?vn(t)||t===39&&(r===39||vn(r)):e!==39?!1:t===24||vn(t)||t===39&&(r===39||r===24||vn(r))}function su(){mr(60);let e=[];for(;at[Fe]===39;)Fe++;if(vn(at[Fe])){for(e.push(ib());G6();){if(at[Fe]===24)Fe++;else{for(;at[Fe]===39;)Fe++;at[Fe]===24&&Fe++}for(;at[Fe]===39;)Fe++;e.push(ib())}for(at[Fe]===24&&Fe++;at[Fe]===39;)Fe++}return mr(62),e}function lu(e){return e.map(({key:t,span:r,keySpan:a,valueSpan:i})=>({key:t,span:r,keySpan:a,valueSpan:i}))}function ou(e,t){do{Fe++;let r=mr(21);e.push(dr(r)),t.push(ha(r))}while(at[Fe]===24)}function Tb(e){let t=Fe,r=at[Fe],a={id:"",label:void 0,span:Vl(t),generated:r!==21,classes:[],classSpans:[],explicit:!1,nodeSpan:[0,0]};if(r===21){Fe++,a.id=dr(t);let i=at[Fe];i===65||e&&i===63?(Fe++,a.label=Gl(),mr(i===65?66:64),a.shape=i===65?"ellipse":"rect"):a.label=au(t)}else r===35||r===36?(Fe++,a.label=au(t),a.id=Sb(a.label.text)):wa(zh);return a}function Oh(e){let t=Fe,r=Tb(!e);if(e&&(r.shape=void 0),at[Fe]===60&&(r.metadata=su()),at[Fe]===48){Fe++;let a=mr(50);mr(49),r.stereotype=dr(a).trim(),r.stereotypeSpan=ha(a)}return at[Fe]===52&&ou(r.classes,r.classSpans),r.explicit=!!(r.shape||r.metadata||r.stereotype),r.nodeSpan=[Sr[t],Br[Fe-1]],r}function cu(e,t){return{id:e.id,kind:t,label:e.label,span:e.span,generated:e.generated,parent:Dh,shape:e.shape,metadata:e.metadata,stereotype:e.stereotype,classes:e.classes}}function nb(e,t){return{id:e.id,label:e.label,span:e.span,generated:e.generated,declares:t,classed:e.classes.length>0}}function hu(e,t){let r={id:e.id,span:e.nodeSpan,idSpan:e.span,labelSpan:e.label.span};return t&&(r.defines=!0),e.stereotypeSpan&&(r.stereotypeSpan=e.stereotypeSpan),e.metadata&&(r.metadata=lu(e.metadata)),e.classSpans.length>0&&(r.classSpans=e.classSpans),r}function Vp(e){if(at[Fe]<1||at[Fe]>36)return!1;for(let t=Fe+1;;t++){let r=at[t];if(r===59||Pa[r]&e)return!0;if(r<1||r>36)return!1}}function Hl(e){let t=Br[e]-Sr[e]-(at[e]===59?0:1);return Math.max(1,t-1)}function Cb(){let e=Fe,t={type:"association",arrowType:0,minlen:1,target:void 0,span:[0,0]};at[Fe]===21&&at[Fe+1]===23&&(t.explicitId=dr(Fe),t.explicitIdSpan=ha(Fe),Fe+=2);let r=Fe,a=at[Fe++];if(a===47)mr(25),at[Fe]!==17&&at[Fe]!==18&&wa("INCLUDE|EXTEND"),t.type=at[Fe]===17?"include":"extend",t.label={text:t.type,type:"text",span:ha(Fe)},Fe++;else if(a===46)t.type="generalization";else if(a===53)t.minlen=Hl(r);else if(a===54)t.arrowType=1,Br[r]-Sr[r]===3&&Vp(0)?(t.label=Gl(),t.minlen=Hl(mr(59))):t.minlen=Hl(r);else if(a===59)if(t.arrowType=2,Br[r]-Sr[r]===2&&Vp(wb)){t.label=Gl();let i=at[Fe];i===53?t.arrowType=0:i===55?t.arrowType=3:i===57?t.arrowType=4:i!==59&&wa("FORWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|FORWARD_CROSS"),(t.arrowType===0||t.arrowType===2)&&(t.minlen=Hl(Fe)),Fe++}else t.minlen=Hl(r);else a===55?t.arrowType=3:a===57?t.arrowType=4:a===56||a===58?(t.arrowType=a===56?5:6,Vp(0)&&(t.label=Gl(),mr(59))):(Fe--,wa(Ph));return t.target=Oh(!1),t.span=[Sr[e],Br[Fe-1]],t}function Oa(e){return{kind:e,span:[0,0]}}function _b(e,t,r,a){let i=r.target;i.explicit&&Er.elements.push(cu(i,"usecase")),Er.relationships.push({source:nb(e,t),target:nb(i,i.explicit),span:r.span,id:r.explicitId,idSpan:r.explicitIdSpan,type:r.type,arrowType:r.arrowType,label:r.label,minlen:r.minlen}),a.push(hu(i,i.explicit));let n=Oa("edge");return n.nodes=a,n.edges=[{id:r.explicitId??`edge-${Ab++}`,span:n.span}],r.explicitIdSpan&&(n.edges[0].idSpan=r.explicitIdSpan),r.label&&(n.edges[0].labelSpan=r.label.span),n}function Ib(e){let t=Oa("node");return t.nodes=e,t}function Nb(e){Fe++;let t=[Oh(!0)],r;if(at[Fe]===24)do Fe++,t.push(Oh(!0));while(at[Fe]===24);else e&&Pa[at[Fe]]&nu&&(r=Cb());En();for(let i of t)Er.elements.push(cu(i,"actor"));let a=t.map(i=>hu(i,!0));return r?_b(t[0],!0,r,a):Ib(a)}function Rb(e){let t=Oh(!1),r=e&&Pa[at[Fe]]&nu?Cb():void 0;En(),r||(t.explicit=!0,t.shape??(t.shape="ellipse")),t.explicit&&Er.elements.push(cu(t,"usecase"));let a=[hu(t,t.explicit)];return r?_b(t,t.explicit,r,a):Ib(a)}function j6(){Fe++;let e=Tb(!0),t={id:e.id,label:e.label,span:e.span,generated:e.generated,classes:e.classes},r=at[Fe]===60?su():void 0;at[Fe]===52&&ou(e.classes,e.classSpans),En(),Er.boundaries.push(t),Dh=t;let a=[];for(;Pa[at[Fe]]&xb;)a.push(Lb(!1));Dh=void 0;let i=mr(4);En();let n=Oa("group");return n.group=t.id,n.idSpan=t.span,n.titleSpan=t.label.span,n.endSpan=ha(i),n.classSpans=e.classSpans,a.length>0&&(n.children=a),r&&(n.metadata=lu(r),Er.metadata.push({target:t.id,span:t.span,properties:r,statement:n})),n}function sb(){let e=Fe,t=at[Fe];for(rb(t)||t===27?Fe++:t===59?(Fe++,rb(at[Fe])||Eb("WORD"),Fe++):wa("WORD|CSS_IDENTIFIER|MARKERLESS_SOLID"),mr(25),(Pa[at[Fe]]&ru)===0&&Fh(`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::
140
+ <[${kb.replaceAll("|","] ,[")}]>
141
+ but found: '${dr(Fe)}'`);Pa[at[Fe]]&ru;)Fe++;return ea.slice(Sr[e],Br[Fe-1]).replaceAll("\\,",",")}function lb(){let e=[sb()];for(;at[Fe]===24;)Fe++,e.push(sb());return e}function Kp(){let e=[mr(21)];for(;at[Fe]===24;)Fe++,e.push(mr(21));return e}function Ch(e){let t=Vl(e);return{id:dr(e),span:t,idSpan:t}}function X6(){let e=Fe,t=at[Fe],r;if(t===41||t===42||t===40){Fe++;let a=dr(e);t===40?Er.accDescription=a.slice(a.indexOf("{")+1,a.lastIndexOf("}")).trim():t===42?Er.accDescription=a.slice(a.indexOf(":")+1).trim():Er.accTitle=a.slice(a.indexOf(":")+1).trim(),r=Oa(t===41?"accTitle":"accDescr")}else if(t===5){Fe++;let a=at[Fe];(a<6||a>10)&&wa("TD|TB|BT|LR|RL"),Er.direction=a===6?"TB":dr(Fe),Fe++,r=Oa("direction")}else{if(t===2)return Nb(!0);if(t===3)return j6();if(t===11){Fe++,mr(12);let a=mr(21),i=Gl();Er.notes.push({target:dr(a),span:ha(a),label:i}),r=Oa("note"),r.ref=`note-${vb++}`,r.refSpan=i.span,r.nodes=[Ch(a)]}else if(t===43){Fe++;let a=mr(44),i=[],n=[];at[Fe]===52&&ou(i,n);let l=Sr[e]+4;for(;ea.charCodeAt(l)===32||ea.charCodeAt(l)===9;)l++;let s=l;for(;/\w/.test(ea.charAt(s));)s++;let o={id:ea.slice(l,s),value:{},propertyOrder:new Map,span:[l,s],classes:i};Er.jsons.push(o),Rh.push([o,a]),r=Oa("json"),r.nodes=[{id:o.id,span:o.span,idSpan:o.span,defines:!0,classSpans:n}],r.classSpans=n}else if(t===14){Fe++;let a=Kp();Er.classDefs.push({ids:a.map(dr),styles:lb()}),r=Oa("classDef"),r.ref=dr(a[0]),r.refSpan=ha(a[0])}else if(t===15){Fe++;let a=Kp(),i=Kp();Er.classes.push({targets:a.map(n=>({id:dr(n),span:ha(n)})),classes:i.map(dr)}),r=Oa("classAssign"),r.ref=dr(i[0]),r.refSpan=ha(i[0]),r.nodes=a.map(Ch)}else if(t===16){Fe++;let a=mr(21);Er.styles.push({target:dr(a),span:ha(a),styles:lb()}),r=Oa("style"),r.nodes=[Ch(a)]}else{let a=at[Fe+1];if(a===60){!(Pa[at[Fe+2]]&bb)&&wa(tb()),Fe++;let i=Ch(e);t!==21&&(i.id=Sb(ea.slice(i.span[0],i.span[1])));let n=su();r=Oa("metadata"),r.nodes=[i],r.metadata=lu(n),Er.metadata.push({target:i.id,span:i.span,properties:n,statement:r})}else return(!(Pa[a]&yb||t===21&&(a===65||a===63))||t===21&&q6.has(dr(e).toLowerCase()))&&wa(tb()),Rb(!0)}}return En(),r}function Lb(e){let t=Fe,r=at[Fe];if(r===39)return Fe++,{kind:"blank",span:ha(t)};if(r===38)return Fe++,En(),{kind:"comment",span:ha(t)};let a=e?X6():r===2?Nb(!1):Rb(!1);if(a.span=[Sr[t],Mb],a.edges)for(let i of a.edges)i.span=a.span;return a}function V6(e,t){ea=e,{types:at,starts:Sr,ends:Br}=P6(e),Fe=0,Er=F6(),Dh=void 0,Rh=[],Ab=0,vb=0;try{let r=mr(1);En();let a=[];for(;Pa[at[Fe]]&mb;)a.push(Lb(!0));at[Fe]!==0&&Fh(`Redundant input, expecting EOF but found: ${dr(Fe)}`);for(let[i,n]of Rh){let l=H6(dr(n),()=>Zl(e,Sr[n]));i.value=l.value,i.propertyOrder=l.propertyOrder}return B6(e,Er,ha(r),a,t)}finally{ea="",at=Sr=Br=Rh=[]}}function ob(e){return typeof e=="string"?e:e===null?"null":String(e)}function Z6(e){let t=[],r=[[e.value,"",""]],a=[];for(;r.length>0;){let[i,n,l]=r.pop();if(a.length=0,Array.isArray(i))i.length===0?t.push({key:n,accessibleKey:n,value:"[]"}):i.every(s=>s===null||typeof s!="object")?i.forEach((s,o)=>t.push({key:o===0?n:"",accessibleKey:n,value:ob(s)})):i.forEach((s,o)=>a.push([s,`${n}[${o}]`,`${l}/${o}`]));else if(i!==null&&typeof i=="object"){let s=i,o=e.propertyOrder.get(l)??Object.keys(s);o.length===0&&t.push({key:n,accessibleKey:n,value:"{}"});for(let c of o)a.push([Object.prototype.hasOwnProperty.call(s,c)?s[c]:void 0,n?`${n}.${c}`:c,`${l}/${c.replaceAll("~","~0").replaceAll("/","~1")}`])}else t.push({key:n,accessibleKey:n,value:ob(i)});for(let s=a.length-1;s>=0;s--)r.push(a[s])}return t}function Ul(...e){return e.filter(Boolean).join(" ")}function Q6(e){return e.type==="generalization"?["none","extension"]:e.type!=="association"?Zp[0]:Zp[e.arrowType]??Zp[2]}function J6(e){let t=[],r=[],a=i=>{let n=new Map;for(let l of["default",...i]){let s=e.classDefs.get(l);if(s)for(let o of s.styles){let c=o.trim(),f=c.indexOf(":"),p=(f===-1?c:c.slice(0,f)).trim();p&&n.set(p,c)}}return[...n.values()]};for(let i of e.actors.values())t.push({id:i.id,label:i.label,labelType:i.labelType,shape:K6[i.type],isGroup:!1,padding:10,cssClasses:Ul("default","usecase-actor",`usecase-actor-${i.type}`,i.business&&"usecase-business",...i.classes),cssStyles:[...i.styles],cssCompiledStyles:a(i.classes),actorType:i.type,business:i.business,icon:i.icon||void 0,stereotype:i.stereotype||void 0,parentId:i.parentId||void 0});for(let i of e.useCases.values()){let n=i.shape==="ellipse";t.push({id:i.id,label:i.label,labelType:i.labelType,shape:n?i.business?"usecaseBusiness":"usecaseEllipse":"rect",isGroup:!1,padding:n?20:10,cssClasses:Ul("default","usecase-element",`usecase-${i.shape}`,i.business&&"usecase-business",...i.classes),cssStyles:[...i.styles],cssCompiledStyles:a(i.classes),business:i.business,stereotype:i.stereotype||void 0,parentId:i.parentId||void 0})}for(let i of e.notes.values())t.push({id:i.id,label:i.label,labelType:i.labelType,shape:"note",isGroup:!1,padding:10,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:a([]),noteTarget:i.target});for(let i of e.jsonNodes.values())t.push({id:i.id,label:i.id,labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,cssClasses:Ul("default","usecase-json-table",...i.classes),cssStyles:[...i.styles],cssCompiledStyles:a(i.classes),jsonRows:Z6(i)});for(let i of e.systemBoundaries.values())t.push({id:i.id,label:i.label,labelType:i.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,cssClasses:Ul("default","system-boundary",`system-boundary-${i.type}`,...i.classes),cssStyles:[...i.styles],cssCompiledStyles:a(i.classes),boundaryType:i.type});for(let i of e.relationships){let n=i.type==="include"||i.type==="extend",[l,s]=Q6(i),o=i.animate||i.animation!==void 0,c={id:i.id,start:i.source,end:i.target,relationshipType:i.type,pattern:n?"dotted":"solid",arrowTypeStart:l,arrowTypeEnd:s,classes:Ul("default","relationship",`relationship-${i.type}`,...i.classes,o&&`edge-animation-${i.animation??"fast"}`),style:[...i.styles],cssCompiledStyles:a(i.classes),animate:i.animate,animation:i.animation,minlen:i.minlen,explicitId:i.explicitId,internal:!1};n?(c.label=i.type,c.labelType="text"):i.type==="association"&&(i.label&&(c.label=i.label),i.labelType&&(c.labelType=i.labelType)),r.push(c)}for(let i of e.notes.values())r.push({id:`${i.id}-edge`,start:i.id,end:i.target,relationshipType:"note",pattern:"dotted",arrowTypeStart:"none",arrowTypeEnd:"none",classes:"default relationship relationship-note",style:[],cssCompiledStyles:a([]),animate:!1,minlen:1,explicitId:!1,internal:!0});return{nodes:t,edges:r}}function hb(e,t,r){let a=e.usecase?.[t];return typeof a=="number"&&a>0?Math.min(a,2e3):r}function iN(e){return e.replace(/[&<>\\]/g,t=>`&#${t.charCodeAt(0)};`)}function Yi(e,t,r,a,i,n=0){return ze(e&&!t?iN(e):e,t,r,a,i,n)}function iu(e,t,r,a){let i=r===1||r===2?1:-1,n=r===1||r===3,l=(n?e.w:e.h)/2,s=0;if(e.kind===0)n?(l=du/2+3,s=(jl-e.h)/2):l+=2;else if(e.kind===1){let o=(n?e.h:e.w)/2;l*=Math.sqrt(Math.max(1-(a/o)**2,0))}return n?[t.x+i*l,t.y+s+a]:[t.x+a,t.y+i*l]}function Db(e,t){let r=t===1||t===3;if(e.kind===0)return r?jl*.5:du*.6;let a=r?e.h:e.w;return e.kind===1?a*.6:a-16}function nN(e,t,r){let a=new Map,i=(n,l,s,o)=>{let c=t[n];if(c.isGroup)return;let f=l[s]-c.x,p=l[s+1]-c.y,h;if(Math.abs(Math.abs(p)-c.h/2)<.5)h=p<0?0:2;else if(Math.abs(Math.abs(f)-c.w/2)<.5)h=f<0?3:1;else return;let g=n*4+h,u={route:l,at:s,toward:l[o+(h&1?1:0)]},m=a.get(g);m?m.push(u):a.set(g,[u])};for(let n of e){let l=n.route.length-3;n.src===n.dst||l<3||(i(n.src,n.route,0,3),i(n.dst,n.route,l,l-3))}for(let[n,l]of a){let s=n>>2,o=n&3,c=r[s],f=l.length>1?Math.min(aN,Db(c,o)/(l.length-1)):0;l.sort((p,h)=>p.toward-h.toward);for(let p=0;p<l.length;p++){let[h,g]=iu(c,t[s],o,(p-(l.length-1)/2)*f);l[p].route[l[p].at]=h,l[p].route[l[p].at+1]=g}}}function sN(e,t,r,a,i){let n=e-r*Lh,l=t-a*Lh,s=Lh*.5;return`<path class="pele-marker" d="M${d(e)},${d(t)}L${d(n-a*s)},${d(l+r*s)}L${d(n+a*s)},${d(l-r*s)}Z" fill="var(--_bg)" stroke="${i}" stroke-linejoin="round"/>`}function Nh(e){return e==="extension"?Lh:gt(e)}function db(e,t,r,a,i,n){return e==="extension"?sN(t,r,a,i,n):bt(e,t,r,a,i,n)}function lN(e,t){let r=e.node,a=e.style.shape,i=` fill="none" stroke="var(--_b)"${e.style.line}`,n=-21,l=9,s;return r.actorType==="hollow"?(l=8,s=`<circle cy="-21" r="8" fill="var(--_bg)" stroke="var(--_b)"${a}/><path d="M-20,-9H20V0H5.5L20,15.5L12,25.5L0,12L-12,25.5L-20,15.5L-5.5,0H-20Z" fill="var(--_bg)" stroke="var(--_b)" stroke-linejoin="round"${a}/>`):r.actorType==="awesome"?s=`<path d="M0,-30A11,11 0 1 1 0,-8A11,11 0 1 1 0,-30ZM-20,25C-20,9 -12,-3 0,-3C12,-3 20,9 20,25C20,28 18,30 15,30H-15C-18,30 -20,28 -20,25Z" fill="var(--_b)"${a}/>`:r.actorType==="icon"?(n=-14,l=12,s=`<rect x="-22" y="-26" width="44" height="44"${ft(Xl+a)}/><svg class="pele-icon" data-icon="${Oe(r.icon??"")}" x="-14" y="-18" width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${t?.(r.icon??"")??""}</svg>`):s=`<circle cy="-21" r="9"${Xl}${a}/><path d="M0,-12V10M-14,-3H14M0,10L-12,30M0,10L12,30"${i}/>`,r.business&&(s+=`<path class="pele-business" d="M${d(.12*l)},${d(n+.99*l)}L${d(.92*l)},${d(n-.39*l)}"${i}/>`),s}function oN(e,t,r){return jr(e.direction)?Bt(r,a=>fb(e,t,r,a)):fb(e,t,r,!1)}function fb(e,t,r,a){let i=J6(e),n=r.fontSize??16,l=Math.round(n*.875),s=Math.round(n*.8125),o=r.measurer??et(r.fontFamily),c=r.padding??8,f=r.icons,p=a?"TB":br(e.direction),h=p==="LR"||p==="RL",g=new Map,u=[],m=[];i.nodes.forEach(($,y)=>g.set($.id,y));for(let $ of i.nodes){let y=vt($.cssStyles.length>0?$.cssCompiledStyles.concat($.cssStyles):$.cssCompiledStyles),E=(y.bold?1:0)|(y.italic?2:0),x=y.fontSize??n,T=$.labelType==="markdown",A=Yi($.stereotype&&`\xAB${$.stereotype}\xBB`,!1,o,s,200,E),M={node:$,kind:2,style:y,label:A,stereotype:A,w:0,h:0,rows:[],keyW:0,headH:0,loops:0},N;if($.isGroup){M.kind=4,M.label=Yi($.label,T,o,x,4e3,E);let F=M.label.height;N=Ut(0,0),N.isGroup=!0,N.padX=_h,N.padBottom=_h,N.padTop=$.boundaryType==="package"?F+2*Jp+16:F>0?F+16:_h,N.minW=M.label.width+2*_h}else{if($.jsonRows){M.kind=3,M.label=Yi($.label,!1,o,x,4e3,E|1);let F=0;for(let U of $.jsonRows){let D=Yi(U.key,!1,o,l,4e3,E),I=Yi(U.value,!1,o,l,260,E);M.rows.push([D,I]),M.keyW=Math.max(M.keyW,D.width),F=Math.max(F,I.width),M.h+=Math.max(D.height,I.height,Math.round(l*1.5))+eu}M.keyW>0&&(M.keyW+=2*ql),M.headH=Math.max(M.label.height,Math.round(x*1.5))+eu,M.w=Math.max(M.label.width+2*ql,M.rows.length>0?M.keyW+F+2*ql:0,72),M.h+=M.headH}else if($.actorType)M.kind=0,M.label=Yi($.label,T,o,x,140,E),M.w=Math.max(du,M.label.width,A.width),M.h=jl+cb+A.height+M.label.height;else{M.label=Yi($.label,T,o,$.shape==="note"?l:x,180,E);let F=Math.max(M.label.width,A.width),U=M.label.height+A.height;$.shape==="usecaseEllipse"||$.shape==="usecaseBusiness"?(M.kind=1,M.w=Math.max(F+2*$.padding+($.business?16:4),88),M.h=Math.max(U+28,48)):$.shape==="note"?(M.w=F+2*$.padding+6,M.h=U+18):(M.w=Math.max(F+2*$.padding+12,80),M.h=Math.max(U+24,44))}N=Ut(M.w,M.h)}N.seq=u.length,u.push(M),m.push(N)}i.nodes.forEach(($,y)=>{m[y].parent=$.parentId!==void 0?g.get($.parentId)??-1:-1});let b=[],w=[],v=[];for(let $ of i.edges){let y=g.get($.start),E=g.get($.end);if(y===void 0||E===void 0)continue;let x=$.relationshipType==="include"||$.relationshipType==="extend",T=Yi(x?`\xAB${$.label}\xBB`:$.label,$.labelType==="markdown",o,l,200);y===E&&(u[y].loops++,h?m[y].h+=2*(Qp+(T.height>0?T.height+8:0)):m[y].w+=2*(Qp+(T.width>0?T.width+12:0))),v.push($),w.push(T),b.push({src:y,dst:E,minlen:$.minlen,labelW:T.width>0?T.width+12:0,labelH:T.height>0?T.height+4:0,route:[],labelX:0,labelY:0})}let k=Gr(m,b,p,{nodeSep:hb(t,"nodeSpacing",eN),edgeSep:tN,rankSep:hb(t,"rankSpacing",rN),portSep:20}),O=Cr(e.title,o,n,4e3),R=O.height>0?O.height+12:0,L=Math.max(k.width,O.width),P=c+(L-k.width)/2,B=c+R;vi(m,b,P,B);let G=Math.ceil(L+2*c),C=Math.ceil(k.height+R+2*c),Z=new Map;for(let $ of b)va(Z,$.route);nN(b,m,u);let ee="",H="";for(let $=0;$<u.length;$++){let y=u[$],E=m[$],x=y.node,T=It(x.cssClasses.replace(/^default\s?/,"")),A=Oe(x.id),M=y.style.text,N=y.style.shape,F=y.w,U=y.h;if(y.kind===4){let z=E.x-E.w/2,q=E.y-E.h/2,j=` fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${N}`,Q=` class="pele-cluster-label" fill="var(--_m)"${M}`,K;if(x.boundaryType==="package"){let W=Math.min(y.label.width+2*Jp+8,E.w),X=y.label.height+2*Jp;K=`<rect class="pele-boundary-tab" x="${d(z)}" y="${d(q)}" width="${d(W)}" height="${d(X)}"${j}/><rect x="${d(z)}" y="${d(q+X)}" width="${d(E.w)}" height="${d(E.h-X)}"${j}/>`+Re(y.label,z+W/2,q+X/2,Q,f)}else K=`<rect x="${d(z)}" y="${d(q)}" width="${d(E.w)}" height="${d(E.h)}"${ft(j)}/>`+Re(y.label,cN(E,y.label.width,Z),q+8+y.label.height/2,Q,f);ee+=`<g class="pele-cluster pele-boundary${T}" data-id="${A}">${K}</g>`;continue}let D,I;if(y.kind===0){I="pele-actor";let z=-U/2,q=z+jl+cb+y.stereotype.height/2;D=`<g class="pele-actor-figure" transform="translate(0,${d(z+jl/2)})">${lN(y,f)}</g>`+Re(y.stereotype,0,q,` class="pele-stereotype" font-size="${s}" fill="var(--_m)"`,f)+Re(y.label,0,U/2-y.label.height/2,` class="pele-label"${M}`,f)}else if(y.kind===3){I="pele-json";let z=-F/2,q=-U/2+y.headH,j="",Q=`M${d(z)},${d(q)}H${d(z+F)}`;y.keyW>0&&(Q+=`M${d(z+y.keyW)},${d(q)}V${d(U/2)}`);for(let[K,W]of y.rows){let X=Math.max(K.height,W.height,Math.round(l*1.5))+eu;j+=Re(K,z+ql+K.width/2,q+X/2,' class="pele-json-key" fill="var(--_m)"',f)+hN(W,z+y.keyW+ql,q+X/2,` class="pele-json-value"${M}`,f),q+=X}D=`<rect x="${d(z)}" y="${d(-U/2)}" width="${d(F)}" height="${d(U)}"${ft(Xl+N)}/><path class="pele-json-lines" d="${Q}" fill="none" stroke="var(--_b)"${y.style.line}/>`+Re(y.label,0,-U/2+y.headH/2,` class="pele-label" font-weight="var(--_hw)"${M}`,f)+`<g font-size="${l}">${j}</g>`}else{let z=y.stereotype.height/2,q;if(y.kind===1){if(I="pele-usecase",q=`<ellipse rx="${d(F/2)}" ry="${d(U/2)}"${Xl}${N}/>`,x.business){let j=F/2-15,Q=F/2-5,K=W=>U/2*Math.sqrt(1-(W/(F/2))**2);q+=`<path class="pele-business" d="M${d(j)},${d(K(j))}L${d(Q)},${d(-K(Q))}" fill="none" stroke="var(--_b)"${y.style.line}/>`}}else if(x.shape==="note"){I="pele-note";let j=F/2,Q=U/2;q=`<path d="M${d(-j)},${d(-Q)}H${d(j-Ih)}L${d(j)},${d(Ih-Q)}V${d(Q)}H${d(-j)}Z" fill="var(--_a)" stroke="var(--_b)" stroke-linejoin="round"${N}/><path d="M${d(j-Ih)},${d(-Q)}V${d(Ih-Q)}H${d(j)}" fill="none" stroke="var(--_b)" stroke-linejoin="round"${y.style.line}/>`}else I="pele-usecase",q=`<rect x="${d(-F/2)}" y="${d(-U/2)}" width="${d(F)}" height="${d(U)}"${ft(Xl+N)}/>`;D=q+Re(y.stereotype,0,-y.label.height/2,` class="pele-stereotype" font-size="${s}" fill="var(--_m)"`,f)+Re(y.label,0,z,` class="pele-label"${x.shape==="note"?` font-size="${l}"`:""}${M}`,f)}H+=`<g class="pele-node ${I}${T}" data-id="${A}" transform="translate(${d(E.x)},${d(E.y)})">${D}</g>`}let Y="",_="",S=new Map;for(let $=0;$<b.length;$++){let y=b[$],E=v[$],x=w[$],T=E.style.length>0||E.cssCompiledStyles.length>0?vt(E.cssCompiledStyles.concat(E.style)):void 0,A=E.arrowTypeStart,M=E.arrowTypeEnd,N;if(y.src===y.dst){let D=m[y.src],I=u[y.src],z=S.get(y.src)??0;S.set(y.src,z+1);let q=h?2:1,j=Math.min(Db(I,q)/2,8+z*6),Q=Qp+z*8,[K,W]=iu(I,D,q,-j),[X,te]=iu(I,D,q,j),se=Math.hypot(Q,j)||1,oe=h?j/se:Q/se,ae=h?Q/se:j/se,ne=Nh(A),J=Nh(M),re=(pe,ge,Ae,Se)=>h?`${d(pe+Ae*j*(Se?1:0))},${d(ge+Se)}`:`${d(pe+Se)},${d(ge+Ae*j*(Se?1:0))}`,fe=h?K-oe*ne:K+oe*ne,ye=h?W+ae*ne:W-ae*ne,le=X+oe*J,we=te+ae*J;N={d:`M${d(fe)},${d(ye)}C${re(K,W,-1,Q)} ${re(X,te,1,Q)} ${d(le)},${d(we)}`,sx:K,sy:W,sdx:h?oe:-oe,sdy:h?-ae:ae,ex:X,ey:te,edx:-oe,edy:-ae},h?(y.labelX=D.x,y.labelY=Math.max(W,te)+Q*.75+6+x.height/2):(y.labelX=Math.max(K,X)+Q*.75+8+x.width/2,y.labelY=D.y)}else{if(y.route.length<6)continue;N=zr(y.route,void 0,Nh(A),Nh(M))}let F=T?.stroke?Ve(T.stroke):"var(--_l)",U=E.internal?"2 3":E.pattern==="dotted"?"5 4":E.animate?"9 5":"";if(Y+=`<g class="pele-edge pele-${E.relationshipType}${It(E.classes.replace(/^default relationship relationship-\S+\s?/,""))}" data-id="${Oe(E.id)}"${T?.line??""}><path d="${N.d}"${U?` stroke-dasharray="${U}"`:""}/>`+db(A,N.sx,N.sy,N.sdx,N.sdy,F)+db(M,N.ex,N.ey,N.edx,N.edy,F)+"</g>",x.width>0){let D=y.labelX,I=y.labelY,z=E.relationshipType==="include"||E.relationshipType==="extend";_+=wr(E.id,x,D,I,(z?' fill="var(--_m)"':"")+(T?.text??""),f)}}return{svg:Je("usecase",G,C,n,r,e,Re(O,G/2,c+O.height/2,' class="pele-title" font-weight="var(--_tw)"')+(ee?`<g class="pele-clusters">${ee}</g>`:"")+(Y?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${Y}</g>`:"")+(_?`<g class="pele-edge-labels" font-size="${l}">${_}</g>`:"")+`<g class="pele-nodes">${H}</g>`),width:G,height:C,links:[]}}function cN(e,t,r){let a=r.get(Math.round(e.y-e.h/2));if(t===0||a===void 0)return e.x;let i=e.x-e.w/2+6,n=e.x+e.w/2-6,l=a.filter(h=>h>i&&h<n).sort((h,g)=>h-g);l.push(n);let s=t/2+6,o=e.x,c=1/0,f=0,p=i;for(let h of l){if(h-p>=2*s){let g=Math.min(Math.max(e.x,p+s),h-s);Math.abs(g-e.x)<c&&(c=Math.abs(g-e.x),o=g)}else c===1/0&&h-p>f&&(f=h-p,o=(p+h)/2);p=h}return o}function hN(e,t,r,a,i){if(e.lines.length<2)return Re(e,t+e.width/2,r,a,i);let n="";for(let l=0;l<e.lines.length;l++)n+=Re(Ua(e,l),t+e.widths[l]/2,r-e.height/2+Ha(e,l),a,i);return n}var pb,Kl,ub,Hi,Zw,Jr,mb,nu,ru,yb,xb,wb,bb,Ph,zh,U6,$b,kb,Pa,q6,ea,at,Sr,Br,Fe,Mb,Er,Dh,Rh,Ab,vb,K6,Zp,eN,tN,rN,_h,Qp,du,jl,cb,Jp,ql,eu,Ih,Lh,aN,Xl,Ob,Pb=Xe(()=>{Bn();Ei();Ea();tr();zt();pr();ut();wt();pb="EOF USECASE ACTOR SYSTEM_BOUNDARY END DIRECTION TD TB BT LR RL NOTE FOR JSON CLASS_DEF CLASS STYLE INCLUDE EXTEND TRUE FALSE IDENTIFIER NUMBER AT COMMA COLON HASH_COLOR CSS_IDENTIFIER CSS_ESCAPED_COMMA DASH DOT PERCENT CSS_PUNCTUATION LABEL_PUNCTUATION LABEL_SYMBOL PLAIN_STRING MARKDOWN_STRING UNCLOSED_MARKDOWN_STRING COMMENT NEWLINE ACC_DESCR_BLOCK ACC_TITLE_LINE ACC_DESCR_LINE JSON_DECLARATION_START JSON_OBJECT_LITERAL UNCLOSED_JSON_OBJECT_LITERAL GENERALIZATION DEPENDENCY_ARROW STEREOTYPE_START STEREOTYPE_END STEREOTYPE_TEXT UNCLOSED_STEREOTYPE_TEXT CLASS_SEPARATOR FORWARD_SOLID BACKWARD_SOLID FORWARD_CIRCLE BACKWARD_CIRCLE FORWARD_CROSS BACKWARD_CROSS MARKERLESS_SOLID METADATA_START LBRACE RBRACE LBRACKET RBRACKET LPAREN RPAREN".split(" "),Kl=1,ub=2,Hi=new Uint8Array(128);for(let e=48;e<=57;e++)Hi[e]=Kl;for(let e=65;e<=90;e++)Hi[e]=Hi[e+32]=Kl;Hi[95]=Kl;for(let e of"!#$&*+/=?^|~")Hi[e.charCodeAt(0)]=ub;Zw=[0,12,5,14,3,9,2,2,2,2,2,4,3,4,8,5,5,7,6,4,5];Jr=class extends Error{constructor(t){super("Invalid JSON token");he(this,"offset");this.offset=t}};mb=1,nu=2,ru=4,yb=8,xb=16,wb=32,bb=64,Ph="DEPENDENCY_ARROW|GENERALIZATION|FORWARD_SOLID|BACKWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|BACKWARD_CIRCLE|FORWARD_CROSS|BACKWARD_CROSS",zh="IDENTIFIER|PLAIN_STRING|MARKDOWN_STRING",U6="PLAIN_STRING|MARKDOWN_STRING|LABEL_TEXT",$b="ACC_TITLE_LINE|ACC_DESCR_LINE|ACC_DESCR_BLOCK|DIRECTION|ACTOR|SYSTEM_BOUNDARY|NOTE|JSON_DECLARATION_START|CLASS_DEF|CLASS|STYLE",kb="WORD|PLAIN_STRING|NUMBER|HASH_COLOR|CSS_IDENTIFIER|CSS_ESCAPED_COMMA|DASH|DOT|PERCENT|CSS_PUNCTUATION|COLON|LPAREN|RPAREN|LBRACKET|RBRACKET|LBRACE|RBRACE|AT|MARKERLESS_SOLID",Pa=new Uint8Array(67);Sn(`NEWLINE|COMMENT|${$b}|${zh}`,mb);Sn(`IDENTIFIER|${Ph}`,nu);Sn(kb,ru);Sn(`STEREOTYPE_START|CLASS_SEPARATOR|IDENTIFIER|${Ph}|NEWLINE|EOF`,yb);Sn(`NEWLINE|COMMENT|ACTOR|${zh}`,xb);Sn("FORWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|FORWARD_CROSS",wb);Sn("NEWLINE|IDENTIFIER|PLAIN_STRING|RBRACE",bb);q6=new Set(["allowmixing","newpage","package","rectangle","skinparam"]),ea="",at=[],Sr=[],Br=[],Fe=0,Mb=0,Rh=[],Ab=0,vb=0;K6={normal:"usecaseActor",hollow:"usecaseActorHollow",awesome:"usecaseActorAwesome",icon:"usecaseActorIcon"},Zp=[["none","arrow_point"],["arrow_point","none"],["none","none"],["none","arrow_circle"],["none","arrow_cross"],["arrow_circle","none"],["arrow_cross","none"]];eN=32,tN=16,rN=72,_h=20,Qp=26,du=40,jl=60,cb=6,Jp=6,ql=10,eu=8,Ih=9,Lh=12,aN=14,Xl=' fill="var(--_s)" stroke="var(--_b)"';Ob={type:"usecase",math:!0,parse:(e,t,r)=>V6(e,r),render:oN}});var zb={};_t(zb,{usecase:()=>Ob});var Fb=Xe(()=>{Pb()});function Tn(e){let t=e.trim();return t.length>=2&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t}function fu(e){return e.map(Tn).sort()}function mN(e,t){let r=new pN(e,t),a=-1,i=()=>a===-1?a=r.next():a,n=g=>{throw i()===1?it("venn",e,r.start,"",!0):it("venn",e,r.start,`Expecting ${g}, got '${Wb[a]}'`)},l=()=>(a=-1,r.text),s=g=>(i()!==g&&n(`'${Wb[g]}'`),l()),o=()=>(i()!==16&&a!==17&&n("'IDENTIFIER', 'STRING'"),l()),c=()=>{let g=[o()];for(;i()===18;)l(),g.push(o());return g},f=(g,u)=>{let m=i()===11?l():void 0,b;if(i()===19&&(l(),b=parseFloat(s(12))),u){if(g.length<2)throw new je("union requires multiple identifiers","semantic",{type:"venn"});t.validateUnionIdentifiers(g)}t.addSubsetData(g,m,b),t.setIndentMode(!0)},p=g=>{let u=i();u!==16&&u!==17&&u!==12&&n("'NUMERIC', 'IDENTIFIER', 'STRING'");let m=l(),b=u!==12&&i()===11?l():void 0;t.addTextData(g(),m,b)},h=()=>{let g=c(),u=[];for(;;){let m=s(16);s(19);let b;if(i()===17)b=l();else{let w=[];for(;i()===16||a>=12&&a<=15;)w.push(l());w.length===0&&n(gN),b=w.join(" ")}if(u.push([m,b]),i()!==18)break;l()}t.addStyleData(g,u)};for(;i()===3;)l();for(s(4);;){let g=i();if(g===2)return;if((g<3||g>10||g===4)&&n(uN),l(),g===5)t.setDiagramTitle(r.text.slice(6));else if(g===6)f([o()],!1);else if(g===7)f(c(),!0);else if(g===8){let u=c();p(()=>u)}else g===9?p(()=>{let u=t.getCurrentSets();if(!u)throw new je("text requires set","semantic",{type:"venn"});return u}):g===10&&h()}}function yN(e){let t=new Set,r=new Map;for(let i of e)t.add(JSON.stringify([...i.sets].sort())),i.sets.length===1&&r.set(i.sets[0],i.size);let a=[];for(let i of e){if(i.sets.length<3)continue;let n=[...i.sets].sort();for(let l=0;l<n.length-1;l++)for(let s=l+1;s<n.length;s++){let o=[n[l],n[s]],c=JSON.stringify(o);if(t.has(c))continue;t.add(c);let f=r.get(o[0]),p=r.get(o[1]);a.push({sets:o,size:f!==void 0&&p!==void 0?Math.min(f,p)/4:2.5,label:""})}}return a.length>0?[...e,...a]:e}function xN(e,t,r){if(r>=e+t)return 0;let a=Math.min(e,t);if(r<=Math.abs(e-t))return Math.PI*a*a;let i=e*e*Math.acos((r*r+e*e-t*t)/(2*r*e)),n=t*t*Math.acos((r*r+t*t-e*e)/(2*r*t)),l=.5*Math.sqrt(Math.max((-r+e+t)*(r+e-t)*(r-e+t)*(r+e+t),0));return i+n-l}function wN(e,t,r){let a=Math.abs(e-t),i=e+t;if(!(r>0))return i;if(r>=Math.PI*Math.min(e,t)**2)return a;for(let n=0;n<48;n++){let l=(a+i)/2;xN(e,t,l)>r?a=l:i=l}return(a+i)/2}function Bb(e,t,r,a,i,n){let l=1/0;for(let s of t){let o=e[s],c=a-o.x,f=i-o.y,p=o.r-Math.sqrt(c*c+f*f);if(p<l){if(p<n)return p;l=p}}for(let s of r){let o=e[s],c=a-o.x,f=i-o.y,p=Math.sqrt(c*c+f*f)-o.r;if(p<l){if(p<n)return p;l=p}}return l}function uu(e,t,r){let a=0,i=0,n=e[t[0]];for(let u of t){let m=e[u];a+=m.x/t.length,i+=m.y/t.length,m.r<n.r&&(n=m)}let l=n.r,s=a,o=i,c=Bb(e,t,r,s,o,-1/0),f=0,p=(u,m)=>{let b=Bb(e,t,r,u,m,c-l*1e-9);if(!(b>c-l*1e-9))return!1;let w=Math.hypot(u-a,m-i);return b>c+l*1e-9||w<f-l*1e-9?(c=b,f=w,s=u,o=m,!0):!1},h=10;for(let u=-h;u<=h;u++)for(let m=-h;m<=h;m++)m*m+u*u<=h*h&&p(n.x+m*l/h,n.y+u*l/h);let g=l/h;for(let u=0;u<40&&g>l*1e-6;u++){let m=!1;for(let b=0;b<8;b++){let w=b*Wh/8;p(s+Math.cos(w)*g,o+Math.sin(w)*g)&&(m=!0)}m||(g/=2)}return{x:s,y:o,margin:c}}function bN(e){let t=new Map;for(let b of e)for(let w of b.sets)t.has(w)||t.set(w,10);for(let b of e)b.sets.length===1&&t.set(b.sets[0],b.size);let r=new Map,a=[],i=0;for(let b of t.values())Number.isFinite(b)&&b>i&&(i=b);i===0&&(i=10);let n=Math.sqrt(i/Math.PI);for(let[b,w]of t){r.set(b,a.length);let v=Number.isFinite(w)&&w>0?Math.sqrt(w/Math.PI):0;a.push({id:b,x:0,y:0,r:Math.max(v,n*.3)})}let l=a.length;if(l<2)return a;let s=new Map;for(let b of yN(e)){if(b.sets.length!==2)continue;let w=r.get(b.sets[0]),v=r.get(b.sets[1]);w!==v&&s.set(Math.min(w,v)*l+Math.max(w,v),b.size)}let o=new Map;for(let[b,w]of s)o.set(b,wN(a[Math.floor(b/l)].r,a[b%l].r,w));let c=n*.15,f=(b,w)=>o.get(b*l+w)??a[b].r+a[w].r+c;if(l===2)return a[1].x=f(0,1),a;if(l===3){let b=f(0,1),w=f(0,2),v=f(1,2),k=e.some(O=>new Set(O.sets).size===3);for(let O=0;O<40;O++){let R=b>0?(b*b+w*w-v*v)/(2*b):0;if(a[1].x=b,a[2].x=Math.max(-w,Math.min(w,R)),a[2].y=Math.sqrt(Math.max(w*w-R*R,0)),!k||uu(a,[0,1,2],[]).margin>n*.12)break;b*=.94,w*=.94,v*=.94}return a}let p=0;for(let b of a)p+=2*b.r+c;let h=Math.min(300,Math.floor(3e6/(l*l)));if(l<=64){let b=p/Wh;a.forEach((w,v)=>{let k=v*Wh/l-Math.PI/2;w.x=Math.cos(k)*b,w.y=Math.sin(k)*b})}else{let b=Math.ceil(Math.sqrt(l)),w=2*n+c;a.forEach((v,k)=>{v.x=k%b*w,v.y=Math.floor(k/b)*w})}let g=new Float64Array(l),u=new Float64Array(l),m=new Int32Array(l);for(let b=0;b<h;b++){g.fill(0),u.fill(0),m.fill(0);for(let w=0;w<l;w++)for(let v=w+1;v<l;v++){let k=o.get(w*l+v),O=a[w].r+a[v].r+c,R=a[v].x-a[w].x,L=a[v].y-a[w].y,P=Math.hypot(R,L);if(k===void 0&&P>=O)continue;P<1e-9&&(R=Math.cos(w+v),L=Math.sin(w+v),P=1);let B=(P-(k??O))/2/P;g[w]+=R*B,u[w]+=L*B,g[v]-=R*B,u[v]-=L*B,m[w]++,m[v]++}for(let w=0;w<l;w++)m[w]!==0&&(a[w].x+=g[w]/m[w],a[w].y+=u[w]/m[w])}return a}function $N(e,t){let r=o=>`M${t(o.x-o.r)},${t(o.y)}A${t(o.r)},${t(o.r)} 0 1 1 ${t(o.x+o.r)},${t(o.y)}A${t(o.r)},${t(o.r)} 0 1 1 ${t(o.x-o.r)},${t(o.y)}Z`;if(e.length===1)return r(e[0]);let a=(o,c,f,p)=>{for(let h of e)if(h!==f&&h!==p&&Math.hypot(o-h.x,c-h.y)>h.r*(1+1e-9))return!1;return!0},i=[];for(let o=0;o<e.length;o++)for(let c=o+1;c<e.length;c++){let f=e[o],p=e[c],h=Math.hypot(p.x-f.x,p.y-f.y);if(h>=f.r+p.r||h<=Math.abs(f.r-p.r)||h===0)continue;let g=(f.r*f.r-p.r*p.r+h*h)/(2*h),u=Math.sqrt(Math.max(f.r*f.r-g*g,0)),m=f.x+(p.x-f.x)*g/h,b=f.y+(p.y-f.y)*g/h;for(let w of[1,-1]){let v=m+w*u*(p.y-f.y)/h,k=b-w*u*(p.x-f.x)/h;a(v,k,f,p)&&i.push({x:v,y:k,a:f,b:p})}}if(i.length<2){let o=e[0];for(let c of e)c.r<o.r&&(o=c);for(let c of e)if(c!==o&&Math.hypot(c.x-o.x,c.y-o.y)+o.r>c.r*(1+1e-9))return"";return r(o)}let n=0,l=0;for(let o of i)n+=o.x/i.length,l+=o.y/i.length;i.sort((o,c)=>Math.atan2(o.y-l,o.x-n)-Math.atan2(c.y-l,c.x-n));let s="";for(let o=0;o<i.length;o++){let c=i[o],f=i[(o+1)%i.length];o===0&&(s=`M${t(c.x)},${t(c.y)}`);let p,h=0,g=1/0;for(let u of[c.a,c.b]){if(u!==f.a&&u!==f.b)continue;let m=Math.atan2(c.y-u.y,c.x-u.x),b=Math.atan2(f.y-u.y,f.x-u.x)-m;b<=0&&(b+=Wh);let w=u.x+u.r*Math.cos(m+b/2),v=u.y+u.r*Math.sin(m+b/2),k=Math.hypot(w-(c.x+f.x)/2,v-(c.y+f.y)/2);k<g&&(g=k,p=u,h=b>Math.PI?1:0)}p===void 0?s+=`L${t(f.x)},${t(f.y)}`:s+=`A${t(p.r)},${t(p.r)} 0 ${h} 1 ${t(f.x)},${t(f.y)}`}return s+"Z"}function pu(e){return e.length===1?e[0]:JSON.stringify(e)}function AN(e,t,r){let a=r.fontSize??16,i=Math.round(a*.875),n=Math.round(a*.8125),l=r.measurer??et(r.fontFamily),s=r.padding??8,o=bN(e.subsets),c=new Map;o.forEach(($,y)=>c.set($.id,y));let f=new Map;for(let{targets:$,styles:y}of e.styles){let E=pu($),x=f.get(E);x||f.set(E,x=new Map);for(let[T,A]of y)x.set(T,A)}let p=$=>{let y=f.get($);if(!y)return Yb;let E=[];for(let[x,T]of y)E.push(`${x}:${T}`);return vt(E)},h=o.map(()=>[]);for(let $=0;$<o.length;$++)for(let y=$+1;y<o.length;y++)Math.hypot(o[$].x-o[y].x,o[$].y-o[y].y)<o[$].r+o[y].r&&(h[$].push(y),h[y].push($));let g=new Map;for(let $ of e.subsets)g.set(pu($.sets),$);let u=new Map;for(let[$,y]of g){let E=[...new Set(y.sets)],x=E.map(I=>c.get(I)),T=new Set(x),A=x[0];for(let I of x)o[I].r<o[A].r&&(A=I);let M=p($),N=y.label??(y.sets.length===1?y.sets[0]:void 0),F=(M.bold?1:0)|(M.italic?2:0),U=uu(o,x,h[A].filter(I=>!T.has(I)));U.margin<o[A].r*.2&&(U=uu(o,x,[]));let D={sets:E,inside:x,spot:U,lines:[],style:M};if(N){let I=E.length===1?a:i;D.lines.push({id:void 0,raw:N,size:I,base:F,label:ze(N,!1,l,I,4e3,F)})}u.set($,D)}for(let $ of e.textNodes){let y=$.label??$.id;u.get(pu($.sets))?.lines.push({id:$.id,raw:y,size:n,base:0,label:ze(y,!1,l,n,4e3)})}let m=0;for(let $ of o)$.r>m&&(m=$.r);let b=m>0?kN/m:1,w=1;for(let $ of u.values()){if($.spot.margin<=0)continue;let y=0,E=0;for(let T of $.lines)y=Math.max(y,T.label.width),E+=T.label.height;let x=Math.hypot(y,E)/2+4;w=Math.max(w,Math.min(x/($.spot.margin*b),MN))}b*=w;for(let $ of u.values()){let y=Math.max($.spot.margin*b*1.8,72);for(let E of $.lines)E.label.width>y&&(E.label=ze(E.raw,!1,l,E.size,y,E.base))}let v=1/0,k=1/0,O=-1/0,R=-1/0;for(let $ of o)v=Math.min(v,($.x-$.r)*b),k=Math.min(k,($.y-$.r)*b),O=Math.max(O,($.x+$.r)*b),R=Math.max(R,($.y+$.r)*b);for(let $ of u.values()){let y=0,E=0;for(let x of $.lines)y=Math.max(y,x.label.width),E+=x.label.height;v=Math.min(v,$.spot.x*b-y/2),O=Math.max(O,$.spot.x*b+y/2),k=Math.min(k,$.spot.y*b-E/2),R=Math.max(R,$.spot.y*b+E/2)}o.length===0&&(v=k=O=R=0);let L=ze(e.title&&Tn(e.title),!1,l,a,4e3,1),P=L.height>0?L.height+12:0,B=Math.max(O-v,L.width),G=s+(B-(O-v))/2-v,C=s+P-k,Z=Math.ceil(B+2*s),ee=Math.ceil(R-k+P+2*s),H=o.map($=>({id:$.id,x:$.x*b+G,y:$.y*b+C,r:$.r*b})),Y="";H.forEach(($,y)=>{let E=dt(y),x=u.get($.id)?.style??Yb;Y+=`<circle class="pele-venn-set" data-id="${Oe($.id)}" cx="${d($.x)}" cy="${d($.y)}" r="${d($.r)}" fill="${E}" fill-opacity="0.2" stroke="${E}"${x.shape}/>`});let _="",S="";for(let $ of u.values()){let y=Oe($.sets.join("|"));if($.sets.length>1&&$.style.shape!==""){let M=$N($.inside.map(N=>H[N]),d);M!==""&&(_+=`<path class="pele-venn-overlap" data-id="${y}" d="${M}" fill="none"${$.style.shape}/>`)}let E=0;for(let M of $.lines)E+=M.label.height;if(E===0)continue;let x=$.spot.x*b+G,T=$.spot.y*b+C-E/2,A="";for(let M of $.lines){let N=M.id===void 0?` class="pele-label"${M.size===a?"":` font-size="${M.size}"`}${$.style.text}`:` class="pele-venn-text" data-id="${Oe(M.id)}" font-size="${n}" fill="var(--_m)"${p(M.id).text}`;A+=Re(M.label,x,T+M.label.height/2,N),T+=M.label.height}S+=`<g class="pele-venn-region" data-id="${y}">${A}</g>`}return{svg:Je("venn",Z,ee,a,r,{},Re(L,Z/2,s+L.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-venn-sets">${Y}</g>`+(_?`<g class="pele-venn-overlaps">${_}</g>`:"")+(S?`<g class="pele-venn-labels">${S}</g>`:"")),width:Z,height:ee,links:[]}}var dN,Wb,fN,pN,uN,gN,Wh,kN,MN,Yb,Hb,Ub=Xe(()=>{tr();ut();wt();dN=class{constructor(){he(this,"type","venn");he(this,"title");he(this,"subsets",[]);he(this,"textNodes",[]);he(this,"styles",[]);he(this,"known",new Set);he(this,"current");he(this,"indent",!1)}setDiagramTitle(e){this.title=e}addSubsetData(e,t,r){let a=fu(e);this.current=a,a.length===1&&this.known.add(a[0]),this.subsets.push({sets:a,size:r??10/e.length**2,label:t?Tn(t):void 0})}addTextData(e,t,r){this.textNodes.push({sets:fu(e),id:Tn(t),label:r?Tn(r):void 0})}addStyleData(e,t){let r=new Map;for(let[a,i]of t)r.set(a,i&&Tn(i));this.styles.push({targets:fu(e),styles:r})}validateUnionIdentifiers(e){let t=e.map(Tn).filter(r=>!this.known.has(r));if(t.length>0)throw new je(`unknown set identifier: ${t.join(", ")}`,"semantic",{type:"venn"})}getCurrentSets(){return this.current}getIndentMode(){return this.indent}setIndentMode(e){this.indent=e}},Wb=["$end","INVALID","EOF","NEWLINE","VENN","TITLE","SET","UNION","TEXT","INDENT_TEXT","STYLE","BRACKET_LABEL","NUMERIC","HEXCOLOR","RGBCOLOR","RGBACOLOR","IDENTIFIER","STRING","COMMA","COLON"],fN=[["venn-beta",4],["set",6],["union",7],["text",8],["style",10]],pN=class{constructor(e,t){he(this,"src");he(this,"host");he(this,"text","");he(this,"start",0);he(this,"at",0);he(this,"lineStart",!1);he(this,"ended",!1);this.src=e,this.host=t}word(e,t){let r=this.src;for(let a=0;a<t.length;a++){let i=r.charCodeAt(e+a),n=t.charCodeAt(a);if(i!==n&&(i+32!==n||i<65||i>90))return!1}return!0}keyword(e,t){return this.word(e,t)&&!Qe(this.src.charCodeAt(e+t.length))}color(e,t){let r=this.src,a=e+1;for(let i=0;i<t;i++){for(;Ue(r.charCodeAt(a));)a++;let n=a;for(;pt(r.charCodeAt(a))||r.charCodeAt(a)===46;)a++;if(a===n)return-1;for(;Ue(r.charCodeAt(a));)a++;if(r.charCodeAt(a)!==(i===t-1?41:44))return-1;a++}return a}lineEnd(e){let t=this.src.indexOf(`
142
+ `,e);return t===-1?this.src.length:t}next(){let e=this.src,t=e.length;for(;;){let r=this.at;if(this.start=r,this.text="",r>=t)return this.ended?0:(this.ended=!0,2);let a=e.charCodeAt(r);if(a===37&&e.charCodeAt(r+1)===37&&e.charCodeAt(r+2)!==123||a!==125&&e.charCodeAt(r+1)===37&&e.charCodeAt(r+2)===37){this.at=this.lineEnd(r+2);continue}if(this.lineStart){if(a===32||a===9){let i=r+1;for(;e.charCodeAt(i)===32||e.charCodeAt(i)===9;)i++;if(this.at=i,this.keyword(i,"text")&&this.host.getIndentMode())return this.at=i+4,this.lineStart=!1,this.text=e.slice(r,i),9;continue}a!==10&&a!==13&&(this.host.setIndentMode(!1),this.lineStart=!1)}if(a===10||a===13){for(r++;e.charCodeAt(r)===10||e.charCodeAt(r)===13;)r++;return this.lineStart=!0,this.token(3,r)}if(a===37&&e.charCodeAt(r+1)===37){this.at=this.lineEnd(r);continue}if(a===32||a===9){for(r++;e.charCodeAt(r)===32||e.charCodeAt(r)===9;)r++;this.at=r;continue}if((a|32)>=97&&(a|32)<=122||a===95){if(this.word(r,"title")&&Ue(e.charCodeAt(r+5))){let i=r+6;for(;i<t;){let n=e.charCodeAt(i);if(n===35||n===10||n===59)break;i++}if(i>r+6)return this.token(5,i)}for(let[i,n]of fN)if(this.keyword(r,i))return this.token(n,r+i.length);if(this.word(r,"rgb")){let i=(e.charCodeAt(r+3)|32)===97,n=r+(i?4:3),l=e.charCodeAt(n)===40?this.color(n,i?4:3):-1;if(l!==-1)return this.token(i?15:14,l)}for(r++;Qe(e.charCodeAt(r))||e.charCodeAt(r)===45;)r++;return this.token(16,r)}if(a===91){if(e.charCodeAt(r+1)===34){let n=e.indexOf('"',r+2);return n===-1||e.charCodeAt(n+1)!==93?1:(this.at=n+2,this.text=e.slice(r+2,n),11)}let i=r+1;for(;i<t&&e.charCodeAt(i)!==93&&e.charCodeAt(i)!==34;)i++;return i===r+1||e.charCodeAt(i)!==93?1:(this.at=i+1,this.text=e.slice(r+1,i).trim(),11)}if(pt(a)||a===46||a===43||a===45){(a===43||a===45)&&r++;let i=r;for(;pt(e.charCodeAt(r));)r++;if(r>i){if(e.charCodeAt(r)===46&&pt(e.charCodeAt(r+1)))for(r+=2;pt(e.charCodeAt(r));)r++}else if(e.charCodeAt(r)===46&&pt(e.charCodeAt(r+1)))for(r+=2;pt(e.charCodeAt(r));)r++;else return 1;return this.token(12,r)}if(a===35){let i=r+1;for(;i<r+9&&oo(e.charCodeAt(i));)i++;return i>=r+4?this.token(13,i):1}if(a===34){let i=e.indexOf('"',r+1);return i===-1?1:this.token(17,i+1)}return a===44?this.token(18,r+1):a===58?this.token(19,r+1):1}}token(e,t){return this.text=this.src.slice(this.at,t),this.at=t,e}},uN="'EOF', 'NEWLINE', 'TITLE', 'SET', 'UNION', 'TEXT', 'INDENT_TEXT', 'STYLE'",gN="'NUMERIC', 'IDENTIFIER', 'STRING', 'HEXCOLOR', 'RGBCOLOR', 'RGBACOLOR'";Wh=Math.PI*2;kN=100,MN=1.6,Yb=vt([]);Hb={type:"venn",parse(e,t,r){let a=new dN;return r&&(a.title=r),mN(e,a),a},render:AN}});var qb={};_t(qb,{venn:()=>Hb});var Gb=Xe(()=>{Ub()});function SN(e,t){let r="ishikawa-beta",a=0;for(;a<13;){let i=e.charCodeAt(t+a),n=r.charCodeAt(a);if(i!==n&&(i+32!==n||i<65||i>90))break;a++}return a===13&&!Qe(e.charCodeAt(t+13))?13:a>=8&&!Qe(e.charCodeAt(t+8))?8:0}function TN(e){let t=[],r=[],a=[],i=e.length,n=0;for(;n<i;){let l=n,s=-1;for(;l<i&&Ue(e.charCodeAt(l));)e.charCodeAt(l)===10&&(s=l),l++;let o,c;if(e.charCodeAt(l)===37&&e.charCodeAt(l+1)===37)for(o=2,c=l+2;c<i;){let f=e.charCodeAt(c);if(f===10||f===13||f===8232||f===8233)break;c++}else if(l===n){let f=SN(e,n);f>0?(o=4,c=n+f):(o=6,c=e.indexOf(`
143
+ `,n),c===-1&&(c=i))}else s>n?(o=2,c=s+1):s===n?(o=3,c=n+1):(o=5,c=l);t.push(o),r.push(n),a.push(c),n=c}return t.push(1,0),r.push(i,i),a.push(i,i),{types:t,starts:r,ends:a}}function CN(e,t){let{types:r,starts:a,ends:i}=TN(e),n=0,l=s=>{throw it("ishikawa",e,a[n],`Expecting ${s}, got '${EN[r[n]]}'`)};if(r[n]===2){for(n++;r[n]===2||r[n]===3;)n++;r[n]!==4&&l("'SPACELINE', 'NL', 'ISHIKAWA'")}else r[n]!==4&&l("'SPACELINE', 'ISHIKAWA'");for(n++,r[n]===3&&n++;;){let s=r[n];if(s===6||s===5&&r[n+1]===6){let o=s===6?n:n+1;n=o+1,r[n]!==2&&r[n]!==3&&r[n]!==1&&l(gu),t.addNode(s===6?0:i[o-1]-a[o-1],e.slice(a[o],i[o]).trim())}else s===2||s===5?(n++,r[n]!==2&&r[n]!==3&&r[n]!==1&&l(s===5?`${gu}, 'TEXT'`:gu)):l("'SPACELINE', 'SPACELIST', 'TEXT'");for(n++;r[n]===3||r[n]===1;)n++;if(r[n]===0)return}}function zN(e,t,r,a,i){let n=ze(e.text,!1,r,a,180),l=Math.round(i*1.5),s=[],o=[],c=[],f=(u,m,b)=>{let w=u.length;for(let v=w-1;v>=0;v--)c.push({node:u[t?w-1-v:v],depth:m,parent:b,slot:v,bone:-1})};for(f(e.children,2,-1);c.length>0;){let u=c.pop();if(u.bone!==-1){o.push(u.bone);continue}let m=s.length;s.push({label:ze(u.node.text,!1,r,i,200),depth:u.depth,parent:u.parent,slot:u.slot,kids:u.node.children.length,rise:0,at:0,textEnd:0}),u.depth%2===0?o.push(m):(u.bone=m,c.push(u)),f(u.node.children,u.depth+1,m)}let p=_N;for(let u of o){let m=Math.max(s[u].label.height,l)+IN;s[u].rise=p+m/2,p+=m}let h=n.width+2*ON,g=h/2;for(let u of s){let m=u.parent===-1?void 0:s[u.parent];u.depth%2===0?(u.at=m?m.at:0,u.textEnd=u.at-(u.kids>0?(u.kids+1)*jb:RN)-mu):(u.at=m.at-(m.kids-u.slot)*jb,u.textEnd=u.at-mu),g=Math.max(g,u.label.width-u.textEnd)}return{node:e,label:n,boxW:h,boxH:n.height+2*PN,bones:s,rise:p+NN,reach:g}}function FN(e,t,r){return Bt(r,a=>WN(e,t,r,a))}function WN(e,t,r,a){let i=r.fontSize??16,n=Math.round(i*.875),l=r.measurer??et(r.fontFamily),s=r.padding??8;if(a)return BN(e,r);let o=e.root,c=ze(e.title,!1,l,i,4e3,1),f=c.height>0?c.height+12:0,p="",h=0,g=0,u=0,m=0;if(o){let R=ze(o.text,!1,l,i,200,1),L=Math.max(R.height+24,48),P=R.width+24+L/2,B=o.children.map((Y,_)=>zN(Y,_%2===0,l,i,n));for(let Y of B)Y.rise=Math.max(Y.rise,L/2+14);let G=[],C=-Xb;for(let Y=0;Y<B.length;Y+=2){if(Y>0){let _=0;for(let S=0;S<2;S++){let $=B[Y-2+S],y=B[Y+S];$&&(_=Math.max(_,$.reach+(y?y.boxW/2:0)))}C-=_+LN}G.push(C,C)}let Z=B.length>0?C-DN:-Xb;g=P,h=Z,u=-L/2,m=L/2;let ee="";B.forEach((Y,_)=>{let S=_%2===0?-1:1,$=G[_],y=(F,U)=>$+F-U*Yh,E=y(0,Y.rise),x=S*Y.rise,T=Yt-1,A=`M${d($-Yh/Bh*T)},${d(S*T/Bh)}L${d(E)},${d(x)}`,M="";for(let F of Y.bones){let U=S*F.rise;if(F.depth%2===0)A+=`M${d(y(F.at,F.rise))},${d(U)}H${d(y(F.textEnd+mu,F.rise))}`;else{let I=Y.bones[F.parent].rise;A+=`M${d(y(F.at,I))},${d(S*I)}L${d(y(F.at,F.rise))},${d(U)}`}let D=y(F.textEnd,F.rise);M+=Re(F.label,D-F.label.width/2,U,F.depth>2?' fill="var(--_m)"':""),h=Math.min(h,D-F.label.width)}let N=x+S*(Y.boxH/2);h=Math.min(h,E-Y.boxW/2),g=Math.max(g,E+Y.boxW/2),u=Math.min(u,N-Y.boxH/2),m=Math.max(m,N+Y.boxH/2),ee+=`<g class="pele-ishikawa-category" data-id="${Oe(Y.node.text)}"><path class="pele-ishikawa-bones" d="${A}" fill="none" stroke="var(--_l)"/>`+bt("arrow_point",$,0,Yh/Bh,-S/Bh,"var(--_l)")+`<rect x="${d(E-Y.boxW/2)}" y="${d(N-Y.boxH/2)}" width="${d(Y.boxW)}" height="${d(Y.boxH)}" fill="var(--_s)" stroke="var(--_b)"${nt}/>`+Re(Y.label,E,N,' class="pele-label"')+(M?`<g class="pele-ishikawa-causes" font-size="${n}">${M}</g>`:"")+"</g>"});let H=L/2;p=`<path class="pele-ishikawa-spine" d="M${d(Z)},0H${d(-(Yt-1))}" fill="none" stroke="var(--_l)"/>`+bt("arrow_point",0,0,1,0,"var(--_l)")+ee+`<g class="pele-ishikawa-head" data-id="${Oe(o.text)}"><path d="M0,${d(-H)}H${d(P-H)}A${d(H)},${d(H)} 0 0 1 ${d(P-H)},${d(H)}H0Z" fill="var(--_s)" stroke="var(--_b)" stroke-linejoin="round"/>`+Re(R,12+R.width/2,0,' class="pele-label" font-weight="var(--_hw)"')+"</g>"}let b=Math.max(g-h,c.width),w=Math.ceil(b+2*s),v=Math.ceil(m-u+f+2*s),k=s+(b-(g-h))/2-h,O=s+f-u;return{svg:Je("ishikawa",w,v,i,r,{},Re(c,w/2,s+c.height/2,' class="pele-title" font-weight="var(--_tw)"')+(p?`<g transform="translate(${d(k)},${d(O)})">${p}</g>`:"")),width:w,height:v,links:[]}}function BN(e,t){let r=t.fontSize??16,a=Math.round(r*.875),i=t.measurer??et(t.fontFamily),n=t.padding??8,l=Math.max(140,(t.maxWidth??320)-2*n),s=ze(e.title,!1,i,r,Nt(t),1),o=[],c=e.root?[{node:e.root,depth:0,parent:-1}]:[],f=0;for(;c.length;){let k=c.pop(),O=o.length;o.push({...k,x:0,y:0,w:0,h:0}),f=Math.max(f,k.depth);for(let R=k.node.children.length-1;R>=0;R--)c.push({node:k.node.children[R],depth:k.depth+1,parent:O})}let p=Math.min(20,Math.max(2,(l-120)/Math.max(1,f))),h=n+(s.height?s.height+12:0),g=s.width,u="",m="";for(let k of o){k.x=n+k.depth*p;let O=Math.max(60,l-k.depth*p-20);k.label=pn(ze(k.node.text,!1,i,k.depth<2?r:a,O,k.depth<2?1:0),i,O),k.w=k.label.width+20,k.h=k.label.height+12,k.y=h,h+=k.h+12,g=Math.max(g,k.x-n+k.w);let R=k.depth<2;if(u+=`<g class="pele-node ${k.depth===0?"pele-ishikawa-head":k.depth===1?"pele-ishikawa-category":"pele-ishikawa-cause"}" data-id="${Oe(k.node.text)}">`+(R?`<rect x="${d(k.x)}" y="${d(k.y)}" width="${d(k.w)}" height="${d(k.h)}" rx="${k.depth===0?12:4}" fill="var(--_s)" stroke="var(--_b)"/>`:"")+Re(k.label,k.x+k.w/2,k.y+k.h/2,` class="pele-label"${k.depth<2?' font-weight="var(--_hw)"':""}${k.depth>1?` font-size="${a}"`:""}`)+"</g>",k.parent>=0){let L=o[k.parent],P=L.x+p/2;m+=`<path class="pele-edge" d="M${d(P)},${d(L.y+L.h)}V${d(k.y+k.h/2)}H${d(k.x)}" fill="none" stroke="var(--_b)"/>`}}let b=Math.ceil(g+2*n),w=Math.ceil(Math.max(n+s.height,h-12)+n),v=Re(s,b/2,n+s.height/2,' class="pele-title" font-weight="var(--_tw)"')+m+u;return{svg:Je("ishikawa",b,w,r,t,{},v),width:b,height:w,links:[]}}var vN,EN,gu,Yh,Bh,_N,IN,NN,jb,RN,mu,LN,Xb,DN,ON,PN,Vb,Kb=Xe(()=>{un();tr();zt();pr();ut();wt();vN=class{constructor(){he(this,"type","ishikawa");he(this,"title");he(this,"root");he(this,"stack",[]);he(this,"baseLevel")}addNode(e,t){let r={text:t,children:[]};if(!this.root){this.root=r,this.stack=[{level:0,node:r}];return}this.baseLevel??(this.baseLevel=e);let a=Math.max(e-this.baseLevel+1,1),i=this.stack;for(;i.length>1&&i[i.length-1].level>=a;)i.pop();i[i.length-1].node.children.push(r),i.push({level:a,node:r})}},EN=["$end","EOF","SPACELINE","NL","ISHIKAWA","SPACELIST","TEXT"];gu="'SPACELINE', 'NL', 'EOF'";Yh=.5,Bh=Math.hypot(Yh,1),_N=14,IN=6,NN=8,jb=22,RN=18,mu=5,LN=26,Xb=34,DN=28,ON=10,PN=5;Vb={type:"ishikawa",parse(e,t,r){let a=new vN;return a.title=r,CN(e,a),a},render:FN}});var Zb={};_t(Zb,{ishikawa:()=>Vb});var Qb=Xe(()=>{Kb()});function XN(e,t,r,a,i=HN){let n=e.length;if(n===0)return{width:0,height:0};let l=r==="LR"||r==="RL",s=r==="BT"||r==="RL",o=[];for(let H=n-1;H>=0;H--)e[H].parent<0&&e[H].isGroup&&o.push(H);let c=Math.max(1,o.length),f=new Int32Array(n).fill(-1);o.forEach((H,Y)=>f[H]=Y);let p=new Uint8Array(n);for(let H=0;H<n;H++)e[H].parent>=0&&(p[e[H].parent]=1);let h=new Float64Array(c).fill(i),g=i,u=H=>{let Y=H,_=i;for(let $=0;e[Y].parent>=0&&$<Jb;$++)Y=e[Y].parent,f[Y]<0&&(_+=Math.max(e[Y].padX,e[Y].padTop,e[Y].padBottom));let S=Math.max(0,f[Y]);return _>h[S]&&(h[S]=_),_>g&&(g=_),S},m=new Int32Array(n).fill(-1),b=[];for(let H=0;H<n;H++)f[H]>=0||(!e[H].isGroup||!p[H])&&(m[H]=b.length,b.push(H));let w=H=>l?H.w:H.h,v=H=>l?H.h:H.w,k=b.map(H=>Zi(v(e[H]),w(e[H]))),O=[],R=[],L=1;{let H=new Set;for(let Y=0;Y<t.length;Y++){let _=t[Y],S=m[_.src],$=m[_.dst];if(S<0||$<0||S===$)continue;let y=Math.min(S,$)*b.length+Math.max(S,$);(_.labelW>0||H.has(y))&&(L=2),H.add(y),O.push(Qi(S,$,_.minlen,l?_.labelH:_.labelW,l?_.labelW:_.labelH)),R.push(Y)}}Xs(k,O),Vs(k,O,L);let P=O.length,B=Int32Array.from(b,u),G=(H,Y)=>{let _=h.map((V,me)=>Y[me]?Math.max(V,r$):V),S=new Uint8Array(c),$=0,y=new Int32Array(P);for(let V=0;V<P;V++)y[V]=Math.abs(k[O[V].head].rank-k[O[V].tail].rank),H[V]||($+=y[V]-1);let E=$>qN,x=b.length+(E?0:$),T=new Int32Array(x),A=new Int32Array(x),M=new Float64Array(x),N=new Float64Array(x),F=new Uint8Array(x),U=0;for(let V=0;V<b.length;V++)T[V]=k[V].rank,A[V]=B[V],M[V]=k[V].w,N[V]=k[V].h,T[V]>U&&(U=T[V]);let D=new Int32Array(P).fill(-1),I=new Int32Array(P).fill(-1),z=[];{let V=b.length;for(let me=0;me<P;me++){let ie=O[me],$e=ie.reversed?ie.head:ie.tail,ve=ie.reversed?ie.tail:ie.head;if(E||y[me]<2||H[me]){z.push($e,ve);continue}let Te=T[$e],De=T[ve],_e=-1;ie.labelW>0&&(_e=Te+(De-Te>>1),L===2&&!(_e&1)&&_e--),D[me]=V;let Ye=$e;for(let Ee=Te+1;Ee<De;Ee++){let qe=V++;T[qe]=Ee,A[qe]=A[$e]+Math.round((A[ve]-A[$e])*(Ee-Te)/(De-Te)),F[qe]=1,Ee===_e&&(M[qe]=ie.labelW,N[qe]=ie.labelH,I[me]=qe),z.push(Ye,qe),Ye=qe}z.push(Ye,ve)}}let q=new Int32Array(x+1),j=new Int32Array(x+1);for(let V=0;V<z.length;V+=2)j[z[V]+1]++,q[z[V+1]+1]++;for(let V=0;V<x;V++)q[V+1]+=q[V],j[V+1]+=j[V];let Q=new Int32Array(z.length/2),K=new Int32Array(z.length/2);{let V=q.slice(0,x),me=j.slice(0,x);for(let ie=0;ie<z.length;ie+=2)K[me[z[ie]]++]=z[ie+1],Q[V[z[ie+1]]++]=z[ie]}let W=[];for(let V=0;V<=U;V++)W.push([]);for(let V=0;V<x;V++)W[T[V]].push(V);let X=new Float64Array(x),te=new Float64Array(x),se=V=>{V.sort((me,ie)=>A[me]-A[ie]||te[me]-te[ie]||me-ie);for(let me=0;me<V.length;me++)X[V[me]]=me};for(let V of W){for(let me=0;me<V.length;me++)te[V[me]]=me;se(V)}for(let V=0;V<UN&&U>0;V++){let me=(V&1)===0;for(let ie=1;ie<=U;ie++){let $e=W[me?ie:U-ie],ve=me?q:j,Te=me?Q:K;for(let De of $e){let _e=0,Ye=ve[De+1]-ve[De];for(let Ee=ve[De];Ee<ve[De+1];Ee++)_e+=X[Te[Ee]];te[De]=Ye>0?_e/Ye:X[De]}se($e)}}let oe=(V,me)=>F[V]||F[me]?a.edgeSep:a.nodeSep,ae=(V,me)=>{let ie=0;for(;ie<V.length;){let $e=ie;for(;$e+1<V.length&&A[V[$e+1]]===A[V[ie]];)$e++;me(V,ie,$e),ie=$e+1}},ne=(V,me,ie)=>{let $e=M[V[me]];for(let ve=me;ve<ie;ve++)$e+=oe(V[ve],V[ve+1])+M[V[ve+1]];return $e},J=new Float64Array(c),re=o.length>0?YN:0;for(let V=0;V<o.length;V++){let me=e[o[V]];J[V]=Math.max(0,me.minW-2*_[V]),me.padTop>re&&(re=me.padTop)}for(let V of W)ae(V,(me,ie,$e)=>{let ve=ne(V,ie,$e);ve>J[A[V[ie]]]&&(J[A[V[ie]]]=ve)});let fe=new Float64Array(c+1);for(let V=0;V<c;V++)fe[V+1]=fe[V]+J[V]+2*_[V];let ye=new Float64Array(x),le=new Float64Array(x),we=(V,me,ie)=>{let $e=A[V[me]],ve=(fe[$e]+_[$e]+(fe[$e+1]-_[$e])-ne(V,me,ie))/2;for(let Te=me;Te<=ie;Te++)ye[V[Te]]=ve+M[V[Te]]/2,Te<ie&&(ve+=M[V[Te]]+oe(V[Te],V[Te+1]))},pe=(V,me,ie)=>{let $e=A[V[me]],ve=fe[$e]+_[$e];for(let De=me;De<=ie;De++){let _e=V[De];ye[_e]=Math.max(le[_e],ve+M[_e]/2),De<ie&&(ve=ye[_e]+M[_e]/2+oe(_e,V[De+1]))}let Te=fe[$e+1]-_[$e];for(let De=ie;De>=me;De--){let _e=V[De];ye[_e]=Math.min(ye[_e],Te-M[_e]/2),De>me&&(Te=ye[_e]-M[_e]/2-oe(V[De-1],_e))}};for(let V of W)ae(V,we);for(let V=0;V<4&&U>0;V++){let me=(V&1)===0;for(let ie=1;ie<=U;ie++){let $e=W[me?ie:U-ie],ve=me?q:j,Te=me?Q:K;for(let De of $e){let _e=0,Ye=0;for(let Ee=ve[De];Ee<ve[De+1];Ee++)A[Te[Ee]]===A[De]&&(_e+=ye[Te[Ee]],Ye++);le[De]=Ye>0?_e/Ye:ye[De]}ae($e,pe)}}let ge=new Float64Array(U+1),Ae=new Float64Array(U+1),Se=new Float64Array(U+1).fill(a.rankSep/L);if(H.some(V=>V===1)){let V=a.rankSep/L;Se.fill(V/jN);for(let me=0;me<P;me++){let ie=O[me],$e=ie.reversed?ie.head:ie.tail,ve=ie.reversed?ie.tail:ie.head;if(H[me]){if(ie.labelH<=0||y[me]>L)continue;let De=Math.min(V,(ie.labelH+2*xu-Math.min(N[$e],N[ve])/2)/y[me]);for(let _e=T[$e];_e<T[ve];_e++)De>Se[_e]&&(Se[_e]=De);continue}let Te=D[me];if(Te<0||y[me]<=L*ie.minlen){for(let De=T[$e];De<T[ve];De++)Se[De]=V;continue}for(let De=Te-1;De<Te+y[me]-1;De++){let _e=De<Te?$e:De,Ye=De+1<Te+y[me]-1?De+1:ve;(A[_e]!==A[Ye]||Math.abs(ye[_e]-ye[Ye])>=.5)&&(Se[T[_e]]=V)}}}let ce=re+g;for(let V=0;V<=U;V++){let me=0;for(let ie of W[V])N[ie]>me&&(me=N[ie]);ge[V]=ce,Ae[V]=ce+me,ce+=me+(V===U?0:Se[V])}let ue=ce+g,xe=fe[c],Ie=V=>s?re+ue-V:V,Le=(V,me)=>l?Ie(me):V,We=(V,me)=>l?V:Ie(me),de=l?1:0;for(let V=0;V<b.length;V++){let me=e[b[V]],ie=(ge[T[V]]+Ae[T[V]])/2;me.x=Le(ye[V],ie),me.y=We(ye[V],ie)}for(let V=0;V<o.length;V++){let me=e[o[V]],ie=(fe[V]+fe[V+1])/2,$e=fe[V+1]-fe[V];me.x=l?ue/2:ie,me.y=l?ie:ue/2,me.w=l?ue:$e,me.h=l?$e:ue,me.padTop=re}let ke=new Int32Array(n),Ce=[];for(let V=0;V<n;V++){if(!e[V].isGroup||f[V]>=0||m[V]>=0)continue;let me=0;for(let ie=e[V].parent;ie>=0&&me<Jb;ie=e[ie].parent)me++;ke[V]=me,Ce.push(V)}Ce.sort((V,me)=>ke[me]-ke[V]||V-me);let be=new Float64Array(n*4);for(let V=0;V<n;V++)be[V*4]=1/0,be[V*4+1]=1/0,be[V*4+2]=-1/0,be[V*4+3]=-1/0;let Me=(V,me)=>{me.x-me.w/2<be[V*4]&&(be[V*4]=me.x-me.w/2),me.y-me.h/2<be[V*4+1]&&(be[V*4+1]=me.y-me.h/2),me.x+me.w/2>be[V*4+2]&&(be[V*4+2]=me.x+me.w/2),me.y+me.h/2>be[V*4+3]&&(be[V*4+3]=me.y+me.h/2)};for(let V of b)e[V].parent>=0&&f[e[V].parent]<0&&Me(e[V].parent,e[V]);for(let V of Ce){let me=e[V];if(be[V*4]===1/0)continue;let ie=Math.max(be[V*4+2]-be[V*4]+2*me.padX,me.minW);me.x=(be[V*4]+be[V*4+2])/2,me.w=ie,me.y=(be[V*4+1]-me.padTop+be[V*4+3]+me.padBottom)/2,me.h=be[V*4+3]-be[V*4+1]+me.padTop+me.padBottom,me.parent>=0&&f[me.parent]<0&&Me(me.parent,me)}for(let V of t)V.route=[];for(let V=0;V<P;V++){let me=O[V],ie=t[R[V]],$e=me.reversed?me.head:me.tail,ve=me.reversed?me.tail:me.head,Te=[ye[$e],Ae[T[$e]]-(Ae[T[$e]]-ge[T[$e]]-N[$e])/2],De=D[V];if(De>=0)for(let Ee=De;Ee<De+y[V]-1;Ee++)Te.push(ye[Ee],ge[T[Ee]]),Ae[T[Ee]]>ge[T[Ee]]&&Te.push(ye[Ee],Ae[T[Ee]]);Te.push(ye[ve],ge[T[ve]]+(Ae[T[ve]]-ge[T[ve]]-N[ve])/2);let _e=[];for(let Ee=0;Ee<Te.length;Ee+=2)_e.push(Le(Te[Ee],Te[Ee+1]),We(Te[Ee],Te[Ee+1]),de);if(me.reversed)for(let Ee=0,qe=_e.length-3;Ee<qe;Ee+=3,qe-=3)for(let Ge=0;Ge<2;Ge++){let rt=_e[Ee+Ge];_e[Ee+Ge]=_e[qe+Ge],_e[qe+Ge]=rt}ie.route=_e;let Ye=I[V];if(Ye>=0){let Ee=(ge[T[Ye]]+Ae[T[Ye]])/2;ie.labelX=Le(ye[Ye],Ee),ie.labelY=We(ye[Ye],Ee)}else ie.labelX=(_e[0]+_e[_e.length-3])/2,ie.labelY=(_e[1]+_e[_e.length-2])/2}for(let V of t){if(V.route.length>0||V.src===V.dst)continue;let me=e[V.src],ie=e[V.dst],[$e,ve]=i$(me,ie),[Te,De]=i$(ie,me),_e=Math.abs(Te-$e)>Math.abs(De-ve)?1:0;V.route=[$e,ve,_e,Te,De,_e],V.labelX=($e+Te)/2,V.labelY=(ve+De)/2}let Ne=new Uint8Array(P),Be=t.reduce((V,me)=>V+me.route.length/3,0),Pe=P*(b.length+t.length+Be);if(Pe<=yu){let V=_e=>(ge[T[_e]]+Ae[T[_e]])/2,me=t.map(_e=>[l?_e.labelY:_e.labelX,Ie(l?_e.labelX:_e.labelY)]),ie=(_e,Ye,Ee,qe,Ge,rt,ct,tt)=>Ee>Ge-ct/2&&_e<Ge+ct/2&&qe>rt-tt/2&&Ye<rt+tt/2,$e=(_e,Ye,Ee,qe,Ge,rt,ct)=>{for(let tt=0;tt<b.length;tt++)if(tt!==Ge&&tt!==rt&&ie(_e,Ye,Ee,qe,ye[tt],V(tt),M[tt]+8,N[tt]+8))return!1;for(let tt=0;tt<t.length;tt++){let lt=t[tt];if(tt!==ct&&lt.labelW>0&&lt.src!==lt.dst&&ie(_e,Ye,Ee,qe,me[tt][0],me[tt][1],l?lt.labelH:lt.labelW,l?lt.labelW:lt.labelH))return!1}return!0},ve=(_e,Ye,Ee,qe,Ge)=>{let rt=0;for(let ct=0;ct<t.length;ct++){if(ct===Ge)continue;let tt=t[ct].route;for(let lt=3;lt<tt.length;lt+=3)if(Math.max(tt[lt-3],tt[lt])>_e&&Math.min(tt[lt-3],tt[lt])<Ee&&Math.max(tt[lt-2],tt[lt+1])>Ye&&Math.min(tt[lt-2],tt[lt+1])<qe){rt++;break}}return rt},Te=(_e,Ye,Ee)=>{let qe=0;for(let Ge=0;Ge<t.length;Ge++){let rt=t[Ge].route;if(Ge===Ee||rt.length===0)continue;let ct=rt.length-3;(Math.abs(rt[0]-_e)<1&&Math.abs(rt[1]-Ye)<1||Math.abs(rt[ct]-_e)<1&&Math.abs(rt[ct+1]-Ye)<1)&&qe++}return qe},De=(_e,Ye,Ee,qe,Ge)=>{let rt=Math.abs(Ee-_e)<.5,ct=rt?Math.min(Ye,qe):Math.min(_e,Ee),tt=rt?Math.max(Ye,qe):Math.max(_e,Ee),lt=rt?_e:Ye;for(let st=0;st<t.length;st++){let Wt=t[st];if(st===Ge||Wt.src===t[Ge].src||Wt.dst===t[Ge].dst)continue;let Ct=Wt.route;for(let kt=3;kt<Ct.length;kt+=3){let Ft=Ct[kt-3+(rt?0:1)],He=Ct[kt+(rt?0:1)];if(Math.abs(Ft-lt)>=e$||Math.abs(He-lt)>=e$)continue;let ht=Ct[kt-3+(rt?1:0)],yt=Ct[kt+(rt?1:0)];if(Math.min(tt,Math.max(ht,yt))-Math.max(ct,Math.min(ht,yt))>1)return!0}}return!1};for(let _e=0;_e<P;_e++){let Ye=O[_e],Ee=R[_e],qe=t[Ee],Ge=Ye.tail,rt=Ye.head;if(A[Ge]===A[rt]||Math.abs(ye[rt]-ye[Ge])<1)continue;let ct=ye[Ge],tt=ye[rt],lt=V(Ge),st=V(rt),Wt=Math.sign(tt-ct),Ct=Math.sign(st-lt),kt=(He,ht)=>{for(let Ze=2;Ze<He.length;Ze+=2)if(!$e(Math.min(He[Ze-2],He[Ze])-ht,Math.min(He[Ze-1],He[Ze+1])-ht,Math.max(He[Ze-2],He[Ze])+ht,Math.max(He[Ze-1],He[Ze+1])+ht,Ge,rt,Ee)||De(Le(He[Ze-2],He[Ze-1]),We(He[Ze-2],He[Ze-1]),Le(He[Ze],He[Ze+1]),We(He[Ze],He[Ze+1]),Ee))return!1;let yt=0,ot=0,er=-1;if(qe.labelW>0){let Ze=Ye.labelW,xt=Ye.labelH;for(let Dt=2;Dt<He.length;Dt+=2){let Rt=(He[Dt-2]+He[Dt])/2,ir=(He[Dt-1]+He[Dt+1])/2,ia=Math.abs(He[Dt]-He[Dt-2]),ka=Math.abs(He[Dt+1]-He[Dt-1]),Cs=ia+ka;if(Cs<=er||(ia>0?ia<Ze+8:ka<xt+8)||Rt-Ze/2<0||Rt+Ze/2>xe||ir-xt/2<0||ir+xt/2>ue||!$e(Rt-Ze/2,ir-xt/2,Rt+Ze/2,ir+xt/2,-1,-1,Ee))continue;let _s=Le(Rt,ir),Is=We(Rt,ir);ve(_s-qe.labelW/2,Is-qe.labelH/2,_s+qe.labelW/2,Is+qe.labelH/2,Ee)>0||(yt=Rt,ot=ir,er=Cs)}if(er<0)return!1}let St=[He[0],He[1]];for(let Ze=2;Ze<He.length;Ze+=2){let xt=He[Ze]-He[Ze-2],Dt=He[Ze+1]-He[Ze-1],Rt=Math.abs(xt)+Math.abs(Dt),ir=Ze>2?xu:0,ia=Ze+2<He.length?xu:0;Rt>ir+ia+1&&(ir&&St.push(He[Ze-2]+xt/Rt*ir,He[Ze-1]+Dt/Rt*ir),ia&&St.push(He[Ze]-xt/Rt*ia,He[Ze+1]-Dt/Rt*ia)),St.push(He[Ze],He[Ze+1])}qe.route=[];for(let Ze=0;Ze<St.length;Ze+=2){let xt=Ze===0?St[0]!==St[2]:St[Ze]!==St[Ze-2];qe.route.push(Le(St[Ze],St[Ze+1]),We(St[Ze],St[Ze+1]),xt?1-de:de)}return qe.labelW>0&&(qe.labelX=Le(yt,ot),qe.labelY=We(yt,ot),me[Ee]=[yt,ot]),Ne[_e]=1,!0};if(kt([ct+Wt*M[Ge]/2,lt,tt,lt,tt,st-Ct*N[rt]/2],2)||kt([ct,lt+Ct*N[Ge]/2,ct,st,tt-Wt*M[rt]/2,st],2)||Pe>yu/t$)continue;let Ft=[];for(let He of A[Ge]<A[rt]?[A[rt],A[Ge]]:[A[Ge],A[rt]]){let ht=Math.max(_[He]-a$,Math.min(_[He]/2,r$-a$));for(let yt of[fe[He]+ht,fe[He+1]-ht]){if(Math.abs(yt-ct)<M[Ge]/2+4||Math.abs(yt-tt)<M[rt]/2+4)continue;let ot=[ct+Math.sign(yt-ct)*M[Ge]/2,lt,yt,lt,yt,st,tt+Math.sign(yt-tt)*M[rt]/2,st],er=(Te(Le(ot[0],ot[1]),We(ot[0],ot[1]),Ee)+Te(Le(ot[6],ot[7]),We(ot[6],ot[7]),Ee))*1e6;for(let St=2;St<ot.length;St+=2){let Ze=Le(ot[St-2],ot[St-1]),xt=We(ot[St-2],ot[St-1]),Dt=Le(ot[St],ot[St+1]),Rt=We(ot[St],ot[St+1]);er+=ve(Math.min(Ze,Dt),Math.min(xt,Rt),Math.max(Ze,Dt),Math.max(xt,Rt),Ee)*1e6+Math.abs(Dt-Ze)+Math.abs(Rt-xt)}Ft.push({pts:ot,cost:er,lane:He})}}Ft.sort((He,ht)=>He.cost-ht.cost);for(let He of Ft)if(kt(He.pts,1)){S[He.lane]=1;break}}}return{width:l?ue:xe,height:l?xe:ue,routed:Ne,margins:S,work:Pe}},C=new Uint8Array(P),Z=new Uint8Array(c),ee=G(C,Z);for(let H=0;H<GN&&ee.work<=yu/t$;H++){let Y=H===0?ee.routed:C.map((_,S)=>_&ee.routed[S]);if(Y.every((_,S)=>_===C[S])&&ee.margins.every((_,S)=>_===Z[S]))break;C=Y,Z=ee.margins,ee=G(C,Z)}return C.some((H,Y)=>H&&!ee.routed[Y])&&(ee=G(new Uint8Array(P),new Uint8Array(c))),{width:ee.width,height:ee.height}}function i$(e,t){let r=t.x-e.x,a=t.y-e.y,i=Math.max(e.w/2,.5),n=Math.max(e.h/2,.5);if(Math.abs(r)<i&&Math.abs(a)<n){let s=i-Math.abs(r),o=n-Math.abs(a);return s<o?[e.x+(r<0?-i:i),t.y]:[t.x,e.y+(a<0?-n:n)]}let l=Math.min(r!==0?i/Math.abs(r):1/0,a!==0?n/Math.abs(a):1/0);return[e.x+r*l,e.y+a*l]}function VN(e){let t=!1;for(let r of e.nodes)r.isGroup?r.dir=void 0:r.parentId===void 0&&(t=!0);if(t){for(let r of e.nodes)!r.isGroup&&r.parentId===void 0&&(r.parentId=n$);e.nodes.push({id:n$,label:void 0,labelType:"text",shape:"rect",isGroup:!0,parentId:void 0,cssStyles:[],cssCompiledStyles:[],cssClasses:"",dir:void 0})}}function KN(e,t,r,a,i,n,l){let s=e.x-e.w/2,o=e.y-e.h/2,c=n==="LR"||n==="RL",f=c?s+e.padTop/2:e.x,p=c?e.y:o+e.padTop/2,h=Re(t,f,p,` class="pele-cluster-label" fill="var(--_m)"${r.text}`,l);return`<g class="pele-cluster pele-lane${a}" data-id="${i}"><rect x="${d(s)}" y="${d(o)}" width="${d(e.w)}" height="${d(e.h)}" fill="none" stroke="var(--_b)"/><rect x="${d(s)}" y="${d(o)}" width="${d(c?e.padTop:e.w)}" height="${d(c?e.h:e.padTop)}" fill="var(--_a)" stroke="var(--_b)"${r.shape}/>`+(c&&h?`<g transform="rotate(-90 ${d(f)} ${d(p)})">${h}</g>`:h)+"</g>"}var YN,HN,UN,qN,Jb,yu,e$,GN,t$,xu,r$,a$,jN,n$,ZN,s$,l$=Xe(()=>{Od();pr();ut();YN=34,HN=24,UN=8,qN=2e4,Jb=1e4,yu=2e6,e$=4,GN=3,t$=8,xu=20,r$=20,a$=14,jN=3;n$="__swimlane_default__";ZN={type:"swimlane",prepare:VN,layout:(e,t,r,a,i)=>XN(e,t,r,a,i?12:void 0),drawGroup:KN},s$={type:"swimlane",math:!0,parse:Lo.parse,render:(e,t,r)=>Dd(e,t,r,ZN)}});var o$={};_t(o$,{swimlane:()=>s$});var c$=Xe(()=>{l$()});var Fa="#ffffff";var Ns="#1e1e1e",ro={flowchart:{curve:"linear"},maxEdges:500,maxTextSize:5e4};var Ur=class{constructor({converter:t}){this.convert=(r,a)=>this.converter(r,{...a,fontSize:a.fontSize||20}),this.converter=t}};var _r;(function(e){e.ROUND="round",e.STADIUM="stadium",e.DOUBLECIRCLE="doublecircle",e.CIRCLE="circle",e.DIAMOND="diamond",e.CYLINDER="cylinder"})(_r||(_r={}));var ai;(function(e){e.COLOR="color"})(ai||(ai={}));var Tr;(function(e){e.FILL="fill",e.STROKE="stroke",e.STROKE_WIDTH="stroke-width",e.STROKE_DASHARRAY="stroke-dasharray"})(Tr||(Tr={}));var Eu=Mk(vu(),1),vk=e=>{let t="\uE000";for(;e.includes(t);)t+="\uE000";return(0,Eu.removeMarkdown)(e.replace(/\n/g,t)).replace(new RegExp(t,"g"),`
144
+ `)},ji,Ek=()=>{if(ji!==void 0)return ji;if(typeof document>"u")return ji=null,ji;try{ji=document.createElement("canvas").getContext("2d")}catch{ji=null}return ji},Wa=(e,t)=>{let r=Ek();return r?(r.font=`${t}px Excalifont, sans-serif`,r.measureText(e).width):e.length*t*.6},Sk={arrow_circle:{endArrowhead:"circle"},arrow_cross:{endArrowhead:"bar"},arrow_open:{endArrowhead:null,startArrowhead:null},double_arrow_circle:{endArrowhead:"circle",startArrowhead:"circle"},double_arrow_cross:{endArrowhead:"bar",startArrowhead:"bar"},double_arrow_point:{endArrowhead:"arrow",startArrowhead:"arrow"}},Su=e=>Sk[e],ii=e=>{let t=e.text;return e.labelType==="markdown"&&(t=vk(t)),Tk(t)},Tk=e=>{let t=/\s?(fa|fab):[a-zA-Z0-9-]+/g;return e.replace(t,"")},ki=e=>{let t={};return Object.keys(e).forEach(r=>{switch(r){case Tr.FILL:{t.backgroundColor=e[r],t.fillStyle="solid";break}case Tr.STROKE:{t.strokeColor=e[r];break}case Tr.STROKE_WIDTH:{t.strokeWidth=Number(e[r]?.split("px")[0]);break}case Tr.STROKE_DASHARRAY:{t.strokeStyle="dashed";break}}}),t},Rs=e=>{let t={};return Object.keys(e).forEach(r=>{switch(r){case ai.COLOR:{t.strokeColor=e[r];break}}}),t};var Ls=(e,t)=>[e,t],qr=e=>{let t={type:"line",x:e.startX,y:e.startY,points:[Ls(0,0),Ls(e.endX-e.startX,e.endY-e.startY)],width:e.endX-e.startX,height:e.endY-e.startY,strokeStyle:e.strokeStyle||"solid",strokeColor:e.strokeColor||"#000",strokeWidth:e.strokeWidth||1};return e.groupId&&Object.assign(t,{groupIds:[e.groupId]}),e.id&&Object.assign(t,{id:e.id}),t},fa=e=>{let t={type:"text",x:e.x,y:e.y,width:e.width,height:e.height,text:e.text||"",fontSize:e.fontSize,verticalAlign:"top",strokeColor:e.color};return e.textAlign&&Object.assign(t,{textAlign:e.textAlign}),e.groupId&&Object.assign(t,{groupIds:[e.groupId]}),e.id&&Object.assign(t,{id:e.id}),t},ni=e=>{let t={text:e?.label?.text||"",fontSize:e?.label?.fontSize,textAlign:e.label?.textAlign,verticalAlign:e.label?.verticalAlign||"middle",strokeColor:e.label?.color||"#000",...e.groupId?{groupIds:[e.groupId]}:{}},r={};e.type==="rectangle"&&e.subtype==="activation"&&(r={backgroundColor:"#e9ecef",fillStyle:"solid"});let a={id:e.id,type:e.type,x:e.x,y:e.y,width:e.width,height:e.height,label:t,strokeStyle:e?.strokeStyle,strokeWidth:e?.strokeWidth,strokeColor:e?.strokeColor,backgroundColor:e?.bgColor,fillStyle:"solid",...r};return e.groupId&&Object.assign(a,{groupIds:[e.groupId]}),a},In=e=>{let t={type:"arrow",x:e.startX,y:e.startY,points:e.points?.map(([r,a])=>Ls(r,a))||[Ls(0,0),Ls(e.endX-e.startX,e.endY-e.startY)],width:e.endX-e.startX,height:e.endY-e.startY,strokeStyle:e?.strokeStyle||"solid",endArrowhead:e?.endArrowhead||null,startArrowhead:e?.startArrowhead||null,label:{text:e?.label?.text||"",fontSize:16,textAlign:e?.label?.textAlign,verticalAlign:e?.label?.verticalAlign,...e?.label?.labelPosition!==void 0?{labelPosition:e.label.labelPosition}:{}},roundness:e.roundness===void 0?{type:2}:e.roundness,start:e.start,end:e.end};return e.groupId&&Object.assign(t,{groupIds:[e.groupId]}),t};var Ck=(e,t)=>[e,t],_k=32,Iu=.62,Ik=12,Nk=12,Nu=1.25,Os=5,Rk=8,Tu=3*Math.PI/2,Ru=(e,t)=>{let r=Math.max(...e.split(`
145
+ `).map(a=>a.length));return Math.max(20,Math.ceil(r*t*Iu))},Lu=e=>({x:e.x??0,y:e.y??0,width:e.width||0,height:e.height||0}),ad=e=>{let{x:t,y:r,width:a,height:i}=Lu(e);return{x:t+a/2,y:r+i/2}},Lk=(e,t)=>{let{x:r,y:a,width:i,height:n}=Lu(t);return e.x>=r&&e.x<=r+i&&e.y>=a&&e.y<=a+n},Cu=(e,t)=>{let r=ad(e),a=t.x-r.x,i=t.y-r.y,n=(e.width||0)/2,l=(e.height||0)/2,s=Math.min(a?n/Math.abs(a):Number.POSITIVE_INFINITY,i?l/Math.abs(i):Number.POSITIVE_INFINITY);return Number.isFinite(s)?{x:r.x+a*s,y:r.y+i*s}:r},_u=(e,t,r,a)=>{let i=r==="start"?e:e.slice().reverse(),n=i.findIndex(s=>!Lk(s,t));if(n===-1){let s=[...i];return s[0]=Cu(t,a),r==="start"?s:s.reverse()}let l=[Cu(t,i[n]),...i.slice(n)];return r==="start"?l:l.reverse()},Dk=(e,t)=>new Map(e.subGraphs.map(r=>{let a=Ru(ii(r),t),i=r.laneHeader?0:a+_k*2,n=Math.max(r.width,i),l=r.x-(n-r.width)/2;return[r.id,{x:l,width:n,leftExpansion:r.x-l,rightExpansion:l+n-(r.x+r.width)}]})),Ok=(e,t)=>{let r=new Map;e.subGraphs.forEach(s=>{s.nodeIds.forEach(o=>r.set(o,s.id))});let a=[...Object.keys(e.vertices),...e.subGraphs.map(s=>s.id)],i=s=>{let o=new Set,c=s;for(;r.has(c)&&!o.has(c);)o.add(c),c=r.get(c);return c},n=new Map;a.forEach(s=>{let o=i(s),c=n.get(o)||[];c.push(s),n.set(o,c)});let l=new Map(a.map(s=>[s,0]));return e.subGraphs.forEach(s=>{if(r.has(s.id)||!ii(s).includes(`
146
+ `))return;let o=t.get(s.id);if(!o||!o.leftExpansion&&!o.rightExpansion)return;let c=s.x+s.width/2;n.forEach((f,p)=>{if(p===s.id)return;let h=e.subGraphs.find(b=>b.id===p),g=e.vertices[p],m=(h?h.x+h.width/2:g?g.x+g.width/2:c)<c?-o.leftExpansion:o.rightExpansion;f.forEach(b=>l.set(b,(l.get(b)||0)+m))})}),l},Pk=(e,t,r)=>Math.min(...r.map(a=>{let i=e.vertices[a];return i?i.y:e.subGraphs.find(n=>n.id===a&&n.id!==t)?.y??Number.POSITIVE_INFINITY})),Du=(e,t)=>{let r=e.split(`
147
+ `).length;return r<2?0:Math.ceil(r*t*Nu+Os*2)},zk=(e,t)=>{let r=[];return e.subGraphs.forEach(a=>{let i=a.laneHeader?0:Du(ii(a),t);if(!i)return;let n=Pk(e,a.id,a.nodeIds);if(!Number.isFinite(n))return;let l=Math.ceil(i-(n-a.y));if(l<=0)return;let s=r.find(o=>Math.abs(o.y-n)<.5);if(s){s.y=Math.min(s.y,n),s.amount=Math.max(s.amount,l);return}r.push({y:n,amount:l})}),r.sort((a,i)=>a.y-i.y)},Ds=(e,t)=>e.reduce((r,a)=>a.y<=t?r+a.amount:r,0),Fk=(e,t,r)=>{let a=new Map,i=new Map(e.subGraphs.map(l=>[l.id,l])),n=l=>{let s=a.get(l);if(s)return s;let o=i.get(l);if(!o)return null;let c=o.y+Ds(t,o.y),f=o.laneHeader?0:Du(ii(o),r),p=c+Math.max(o.height,f);o.nodeIds.forEach(g=>{let u=e.vertices[g];if(u){let b=u.y+Ds(t,u.y)+u.height;b>p&&(p=b+Os*2);return}if(g===l)return;let m=n(g);m&&m.y+m.height>p&&(p=m.y+m.height+Os*2)});let h={y:c,height:p-c};return a.set(l,h),h};return e.subGraphs.forEach(l=>n(l.id)),a},Wk=(e,t,r,a)=>{let i=a||20;if(e!==_r.CYLINDER||!t)return i;let n=Math.max(20,r-Ik);if(Ru(t,i)<=n)return i;let s=Math.max(...t.split(`
148
+ `).map(o=>o.length));return Math.max(Nk,Math.floor(n/(s*Iu)))},Bk=e=>({elbowed:!0,roundness:null,fixedSegments:e.slice(2,-1).map((t,r)=>({start:e[r+1],end:t,index:r+2}))}),Yk=({width:e,height:t,vertical:r},a)=>{let i=r?{x:a.x,y:a.y,width:e,height:a.height}:{x:a.x,y:a.y,width:a.width,height:t},n=a.containerStyle.strokeColor??Ns,l=[qr({type:"line",startX:r?i.x+i.width:i.x,startY:r?i.y:i.y+i.height,endX:i.x+i.width,endY:i.y+i.height,strokeColor:n,strokeWidth:a.containerStyle.strokeWidth??2,strokeStyle:a.containerStyle.strokeStyle})];if(a.text){let[s,o]=r?[i.height,i.width]:[i.width,i.height];l.unshift({id:a.id,type:"rectangle",x:i.x+(i.width-s)/2,y:i.y+(i.height-o)/2,width:s,height:o,...r?{angle:Tu}:{},strokeColor:"transparent",backgroundColor:"transparent",label:{text:a.text,fontSize:a.fontSize,strokeColor:n,...a.labelStyle,...r?{angle:Tu}:{}}})}return l},Ou=new Ur({converter:(e,t)=>{let r=[],a=[],i=[],n=[],l=t.fontSize,s=l||20,o=zk(e,s),c=Fk(e,o,s),f=Dk(e,s),p=Ok(e,f),h=new Set(e.subGraphs.map(u=>u.id)),g=new Set(e.subGraphs.filter(u=>{let m=f.get(u.id),b=c.get(u.id);return ii(u).includes(`
149
+ `)&&m?.width!==u.width||b?.height!==u.height}).map(u=>u.id));return e.subGraphs.slice().reverse().forEach(u=>{let m=[],b=ii(u),w=s,v=f.get(u.id)||{x:u.x,width:u.width},k=v.width,O=v.x+(p.get(u.id)||0),R=c.get(u.id)||u,L=ki(u.containerStyle),P=Rs(u.labelStyle),B={id:u.id,type:"rectangle",groupIds:m,x:O,y:R.y,width:k,height:R.height,...L};if(r.push(B),u.laneHeader)n.push(...Yk(u.laneHeader,{id:`${u.id}__title`,x:O,y:R.y,width:k,height:R.height,text:b,fontSize:w,containerStyle:L,labelStyle:P}));else if(b){let G=L.strokeWidth??2,C=b.split(`
150
+ `),Z=Math.min(k-G*2,Math.max(...C.map(ee=>Wa(ee,w)))+(Os+Rk)*2+2);n.push({id:`${u.id}__title`,type:"rectangle",groupIds:m,x:O+(k-Z)/2,y:R.y+G+4,width:Math.max(1,Z),height:C.length*w*Nu+Os*2,strokeColor:"transparent",backgroundColor:L.backgroundColor??Fa,fillStyle:"solid",roughness:0,label:{groupIds:m,text:b,fontSize:w,strokeColor:L.strokeColor??Ns,...P}})}}),Object.values(e.vertices).forEach(u=>{if(!u)return;let m=[],b=ii(u),w=u.x+(p.get(u.id)||0),v=u.y+Ds(o,u.y),k=Wk(u.type,b,u.width,l),O=ki(u.containerStyle),R=Rs(u.labelStyle),L={id:u.id,type:"rectangle",groupIds:m,x:w,y:v,width:u.width,height:u.height,strokeWidth:2,...u.type!==_r.DOUBLECIRCLE&&{label:{groupIds:m,text:b,fontSize:k,...R}},link:u.link||null,backgroundColor:Fa,fillStyle:"solid",...O},P;switch(u.type){case _r.STADIUM:{L={...L,roundness:{type:3}};break}case _r.ROUND:{L={...L,roundness:{type:3}};break}case _r.DOUBLECIRCLE:{m.push(`doublecircle_${u.id}}`),P={type:"ellipse",groupIds:m,x:w+5,y:v+5,width:u.width-5*2,height:u.height-5*2,strokeWidth:2,roundness:{type:3},label:{groupIds:m,text:b,fontSize:k,...R}},L={...L,groupIds:m,type:"ellipse"};break}case _r.CIRCLE:{L.type="ellipse";break}case _r.DIAMOND:{L.type="diamond";break}}i.push(L),P&&i.push(P)}),e.edges.forEach(u=>{let m=[],{startX:b,startY:w,reflectionPoints:v}=u,k=p.get(u.start)||0,O=p.get(u.end)||0,R=v.map((Y,_)=>{let S=v.length>1?_/(v.length-1):0;return{...Y,x:Y.x+k+(O-k)*S,y:Y.y+Ds(o,Y.y)}}),L=Su(u.type||"arrow_point"),P=[...i,...r].find(Y=>Y.id===u.start),B=[...i,...r].find(Y=>Y.id===u.end);if(!P||!B)return;let G=h.has(u.start);g.has(u.start)&&(R=_u(R,P,"start",ad(B))),g.has(u.end)&&(R=_u(R,B,"end",ad(P)));let C=R.map(Y=>Ck(Y.x-R[0].x,Y.y-R[0].y)),Z=G?R[0].y:w+Ds(o,w),H={id:`${u.start}_${u.end}`,type:"arrow",groupIds:m,x:G?R[0].x:b+k,y:Z,strokeWidth:u.stroke==="thick"?4:2,strokeStyle:u.stroke==="dotted"?"dashed":void 0,points:C,...u.text?{label:{text:ii(u),fontSize:l,groupIds:m,...u.labelPosition!==void 0?{labelPosition:u.labelPosition}:{}}}:{},roundness:{type:2},...u.orthogonal?Bk(C):{},...L,start:{id:P.id||""},end:{id:B.id||""}};a.push(H)}),{elements:[...r,...a,...n,...i]}}});var xr=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,r)=>(r&=63,r<36?t+=r.toString(36):r<62?t+=(r-26).toString(36).toUpperCase():r>62?t+="-":t+="_",t),"");var Pu=new Ur({converter:e=>{let t=xr(),{width:r,height:a}=e,i={type:"image",x:0,y:0,width:r,height:a,status:"saved",fileId:t};return{files:{[t]:{id:t,mimeType:e.mimeType,dataURL:e.dataURL}},elements:[i]}}});var Nn=10,id=16,Hk=24,Uk=4,qk=1.25,Gk=e=>{if(!e)return!0;let t=e.trim().toLowerCase();return t==="transparent"||t==="none"||t==="rgba(0,0,0,0)"||t==="rgba(0, 0, 0, 0)"},jk=(e,t)=>{let r=Math.max(...e.split(`
151
+ `).map(a=>a.length));return Math.max(20,Math.round(r*t*.6))},Xk=(e,t)=>Math.max(Hk,e.split(`
152
+ `).length*t*qk),zu=new Ur({converter:e=>{let t=[],r=[],a=[];Object.values(e.nodes).forEach(n=>{!n||!n.length||n.forEach(l=>{let s;switch(l.type){case"line":s=qr(l);break;case"rectangle":case"ellipse":s=ni(l);break;case"text":s=fa(l);break;default:throw`unknown type ${l.type}`}l.type==="rectangle"&&l?.subtype==="activation"?r.push(s):l.type==="rectangle"&&l.subtype==="note"?a.push(s):t.push(s)})}),Object.values(e.lines).forEach(n=>{n&&t.push(qr(n))});let i=[];if(Object.values(e.arrows).forEach(n=>{n&&(t.push(In(n)),n.sequenceNumber&&i.push(ni(n.sequenceNumber)))}),t.push(...r),t.push(...a),t.push(...i),e.loops){let{lines:n,texts:l,nodes:s}=e.loops;n.forEach(o=>{t.push(qr(o))}),l.forEach(o=>{t.push(fa(o))}),s.forEach(o=>{t.push(ni(o))})}return e.groups&&e.groups.forEach(n=>{let{actorKeys:l,name:s}=n,o=s?Xk(s,id):0,c=s?jk(s,id):0,f,p,h,g;if(n.bounds)({x:f,y:p,width:h,height:g}=n.bounds);else{if(!l.length)return;let m=t.filter(R=>{if(R.id){let L=R.id.indexOf("-"),P=R.id.substring(0,L);return l.includes(P)}return!1});if(!m.length)return;let b=1/0,w=1/0,v=0,k=0;if(m.forEach(R=>{R.x===void 0||R.y===void 0||R.width===void 0||R.height===void 0||(b=Math.min(b,R.x),w=Math.min(w,R.y),v=Math.max(v,R.x+R.width),k=Math.max(k,R.y+R.height))}),!Number.isFinite(b)||!Number.isFinite(w)||!Number.isFinite(v)||!Number.isFinite(k))return;let O=v-b+Nn*2;h=Math.max(O,c+Nn*2),f=b-Nn-(h-O)/2,p=w-Nn-o,g=k-w+Nn*2+o}let u=ni({type:"rectangle",x:f,y:p,width:h,height:g,bgColor:Gk(n.fill)?void 0:n.fill,strokeColor:"#1f1f1f",strokeWidth:1,id:xr()});if(t.unshift(u),s){let m=fa({type:"text",id:xr(),text:s,x:f+Uk,y:p+Nn,width:c,height:o,fontSize:id,color:"#1f1f1f"});t.push(m)}}),{elements:t}}});var Fu=new Ur({converter:e=>{let t=[];return Object.values(e.arrows).forEach(r=>{if(!r)return;let a=In(r);t.push(a)}),e.nodes.forEach(r=>{!r||!r.length||r.forEach(a=>{let i;switch(a.type){case"line":i=qr(a);break;case"rectangle":case"ellipse":i=ni({...a,bgColor:a.bgColor??Fa});break;case"text":i=fa(a);break;default:throw`unknown type ${a.type}`}t.push(i)})}),Object.values(e.lines).forEach(r=>{r&&t.push(qr(r))}),Object.values(e.text).forEach(r=>{let a=fa(r);t.push(a)}),Object.values(e.namespaces).forEach(r=>{let a=Object.keys(r.classes),i=[...a],n=[...e.lines,...e.arrows,...e.text];a.forEach(s=>{let o=n.filter(c=>c.metadata&&c.metadata.classId===s).map(c=>c.id);o.length&&i.push(...o)});let l={type:"frame",id:xr(),name:r.id,children:i};t.push(l)}),{elements:t}}});var Wu=new Ur({converter:e=>{let t=[];return e.arrows.forEach(r=>{t.push(In(r))}),e.nodes.forEach(r=>{!r||!r.length||r.forEach(a=>{let i;switch(a.type){case"line":i=qr(a);break;case"rectangle":case"ellipse":i=ni({...a,bgColor:a.bgColor??Fa});break;case"text":i=fa(a);break;default:throw`unknown type ${a.type}`}t.push(i)})}),e.lines.forEach(r=>{t.push(qr(r))}),e.text.forEach(r=>{t.push(fa(r))}),{elements:t}}});var no=(e,t)=>[e,t],qu=16,Gu=14,Vk=1,nd="#000000",ju=5,Xu=ju*2,Vu=ju*2,Ku=1.25,Zu=new Set(["choice","fork","join","stateStart","stateEnd","divider"]),sd=e=>e.shape==="stateEnd"?[`state_end_group_${e.id}`]:void 0,Qu=e=>e.shape==="rectWithTitle"&&e.description.length?[e.text,...e.description].join(`
153
+ `):e.text,Kk=(e,t,r)=>{if(Wa(e,t)<=r)return[e];let a=[],i="";for(let n of e){let l=`${i}${n}`;if(i&&Wa(l,t)>r){a.push(i),i=n;continue}i=l}return i&&a.push(i),a},Zk=(e,t,r)=>{if(!e.trim()||Wa(e,t)<=r)return e;let a=e.split(/\s+/).filter(Boolean),i=[],n="";for(let l of a){let s=Kk(l,t,r);for(let[o,c]of s.entries()){let p=n?`${n}${n&&o===0?" ":""}${c}`:c;if(Wa(p,t)<=r){n=p;continue}n&&i.push(n),n=c}s.length>1}return i.push(n),i.join(`
154
+ `)},Qk=(e,t,r)=>{let i=e.map(s=>Zk(s,t,r)).join(`
155
+ `).split(`
156
+ `),n=Math.max(...i.map(s=>Wa(s,t))),l=i.length*t*Ku;return{width:n,height:l}},Jk=(e,t,r,a,i)=>{let n=e.split(`
157
+ `);for(let l=i;l>=Gu;l-=Vk){let{height:s}=Qk(n,l,t);if(s<=r)return l}return a},eM=e=>{let t=Qu(e),r=e.fontSize??qu;if(!t||Zu.has(e.shape))return r;let a=Math.max(1,e.width-Xu),i=Math.max(1,e.height-Vu),n=t.split(`
158
+ `);return n.length>1&&Math.max(...n.map(s=>Wa(s,r)))<=a?r:Jk(t,a,i,n.length===1?r:Gu,r)},Ju=e=>{if(Zu.has(e.shape))return;let t=Qu(e);if(t)return{text:t,fontSize:eM(e),verticalAlign:e.shape==="rectWithTitle"||e.shape==="roundedWithTitle"?"top":"middle",...Rs(e.labelStyle)}},Bu=(e,{withLabel:t=!0}={})=>{let r=ki(e.containerStyle),a=t?Ju(e):void 0,i=e.shape==="choice"?"diamond":e.shape==="stateStart"||e.shape==="stateEnd"?"ellipse":"rectangle",n=e.shape==="rect"||e.shape==="rectWithTitle"||e.shape==="roundedWithTitle",l=e.shape==="stateStart"||e.shape==="fork"||e.shape==="join",s=e.shape==="rect"||e.shape==="rectWithTitle"||e.shape==="choice"||e.shape==="note",o=r.backgroundColor||r.strokeColor||nd,c=r.strokeColor||r.backgroundColor||nd;return{id:e.id,type:i,...sd(e)?{groupIds:sd(e)}:{},x:e.x,y:e.y,width:e.width,height:e.height,...a?{label:a}:{},...s?{backgroundColor:Fa,fillStyle:"solid"}:{},...r,...n?{roundness:{type:3}}:{},...l?{backgroundColor:o,strokeColor:c,fillStyle:"solid"}:{}}},Yu=32,Hu=.25,tM=(e,t)=>{let r=Math.min(e,t);return r<=Yu/Hu?r*Hu:Yu},rM=e=>{let t=Ju(e);if(!t)return null;let r=ki(e.containerStyle),a=r.strokeWidth??2,i=t.fontSize??qu,n=t.text.split(`
159
+ `),l=e.dividerLine?.startY??e.y+n.length*i*Ku+Vu,s=Math.max(...n.map(c=>Wa(c,i)))+Xu+2,o=Math.min(e.width-a*2,Math.max(e.width-tM(e.width,e.height)*2,s));return{id:`${e.id}__title`,type:"rectangle",x:e.x+(e.width-o)/2,y:e.y+a+4,width:o,height:Math.max(1,l-e.y-a-4),label:{strokeColor:r.strokeColor??Ns,...t,verticalAlign:"middle"},strokeColor:"transparent",backgroundColor:r.backgroundColor??Fa,fillStyle:"solid",roughness:0}},Uu=e=>{if(!e.dividerLine)return null;let t=ki(e.containerStyle);return{id:`${e.id}__divider`,type:"line",x:e.dividerLine.startX,y:e.dividerLine.startY,width:e.dividerLine.endX-e.dividerLine.startX,height:e.dividerLine.endY-e.dividerLine.startY,points:[no(0,0),no(e.dividerLine.endX-e.dividerLine.startX,e.dividerLine.endY-e.dividerLine.startY)],strokeColor:t.strokeColor||"#000",strokeWidth:t.strokeWidth||1}},aM=e=>{let t=ki(e.containerStyle),r=Math.max(2,Math.min(e.width,e.height)*.32),a=e.endInnerColor||t.strokeColor||t.backgroundColor||nd;return{id:`${e.id}__inner`,type:"ellipse",groupIds:sd(e),x:e.x+r,y:e.y+r,width:Math.max(1,e.width-r*2),height:Math.max(1,e.height-r*2),backgroundColor:a,strokeColor:a,fillStyle:"solid",strokeWidth:1}},iM=e=>{let t=e.reflectionPoints.map((r,a,i)=>{let n=i[0];return a===0?no(0,0):no(r.x-n.x,r.y-n.y)});return{id:e.id,type:"arrow",x:e.startX,y:e.startY,width:e.endX-e.startX,height:e.endY-e.startY,points:t,strokeColor:e.strokeColor||"#000",strokeWidth:e.strokeWidth||2,strokeStyle:e.strokeStyle||"solid",endArrowhead:e.isNoteEdge?null:"triangle",roundness:{type:2},start:{id:e.start},end:{id:e.end},...e.text?{label:{text:e.text,fontSize:16,...e.labelPosition!==void 0?{labelPosition:e.labelPosition}:{}}}:{}}},e0=new Ur({converter:e=>{let t=[],r=l=>{let s=Bu(l);t.push(s);let o=Uu(l);o&&t.push(o),l.shape==="stateEnd"&&t.push(aM(l))},a=e.nodes.filter(l=>l.isRenderable),i=l=>l.shape==="roundedWithTitle",n=a.filter(i);return n.forEach(l=>{t.push(Bu(l,{withLabel:!1}))}),e.lines?.forEach(l=>{t.push(qr(l))}),e.edges.forEach(l=>{t.push(iM(l))}),n.forEach(l=>{let s=rM(l);s&&t.push(s);let o=Uu(l);o&&t.push(o)}),a.filter(l=>!i(l)).forEach(r),e.texts?.forEach(l=>{t.push(fa(l))}),{elements:t}}});var nM=e=>e.replace(/fl°°/g,"#").replace(/fl°/g,"&").replace(/¶ß/g,";"),t0=e=>{e=nM(e);let t=e.replace(/#(\d+);/g,"&#$1;").replace(/#([a-z]+);/g,"&$1;"),r=document.createElement("textarea");return r.innerHTML=t,r.value};var r0=(e,t=.5)=>{let r=[];return e.forEach(a=>{let i=r[r.length-1];if(!i){r.push(a);return}Math.hypot(a[0]-i[0],a[1]-i[1])<=t||r.push(a)}),r};var sM=e=>({...e,elements:e.elements.map(t=>{if(!("points"in t)||!Array.isArray(t.points))return t;let r=t.points;if(r.length<2)return t;let a=r0(r);return a.length===r.length?t:{...t,points:a}})}),a0=(e,t={})=>{let r=(()=>{switch(e.type){case"graphImage":return Pu.convert(e,t);case"flowchart":return Ou.convert(e,t);case"sequence":return zu.convert(e,t);case"class":return Fu.convert(e,t);case"erd":return Wu.convert(e,t);case"state":return e0.convert(e,t);default:throw new Error(`graphToExcalidraw: unknown graph type "${e.type}, only flowcharts are supported!"`)}})();return sM(r)};Dn();tr();wt();var RM=[["flowchart","flowchart-elk",/^\s*flowchart-elk/],["mindmap","mindmap",/^\s*mindmap/],["architecture","architecture",/^\s*architecture/],["agentflow","agentflow",/^\s*agentflow-beta\b/],["c4","c4",/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/],["kanban","kanban",/^\s*kanban/],["class","classDiagram",/^\s*classDiagram/],["er","er",/^\s*erDiagram/],["gantt","gantt",/^\s*gantt/],["info","info",/^\s*info/],["pie","pie",/^\s*pie/],["requirement","requirement",/^\s*requirement(Diagram)?/],["sequence","sequence",/^\s*sequenceDiagram/],["swimlane","swimlane",/^\s*swimlane-beta\b/],["flowchart","flowchart-v2",/^\s*(graph|flowchart)/],["timeline","timeline",/^\s*timeline/],["gitGraph","gitGraph",/^\s*gitGraph/],["state","stateDiagram",/^\s*stateDiagram/],["journey","journey",/^\s*journey/],["quadrantChart","quadrantChart",/^\s*quadrantChart/],["sankey","sankey",/^\s*sankey(-beta)?/],["packet","packet",/^\s*packet(-beta)?/],["xychart","xychart",/^\s*xychart(-beta)?/],["block","block",/^\s*block(-beta)?/],["eventmodeling","eventmodeling",/^\s*eventmodeling/],["treeView","treeView",/^\s*treeView-beta/],["radar","radar",/^\s*radar-beta/],["ishikawa","ishikawa",/^\s*ishikawa(-beta)?\b/i],["treemap","treemap",/^\s*treemap/],["railroad","railroad",/^\s*railroad-beta/i],["railroad","railroadEbnf",/^\s*railroad-ebnf-beta/i],["railroad","railroadAbnf",/^\s*railroad-abnf-beta/i],["railroad","railroadPeg",/^\s*railroad-peg-beta/i],["venn","venn",/^\s*venn-beta/],["wardley","wardley",/^\s*wardley-beta/i],["cynefin","cynefin",/^\s*cynefin-beta(?:[\s:]|$)/],["usecase","usecase",/^\s*usecase-beta(?:\s|$)/]];function w0(e){for(let[t,r,a]of RM)if(a.test(e))return{type:t,mermaidType:r};return null}var LM=/^\s*%%(?!{)[^\n]+\n?/gm,zn=/%{2}{\s*(?:(\w+)\s*:|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi,DM=/<(\w+)([^>]*)>/g,OM=/="([^"]*)"/g,PM=new Set(["__proto__","constructor","prototype"]);function zM(e){return(e.includes("%%")?e.replace(LM,""):e).trimStart()}function ho(e){return e===`
160
+ `||e==="\r"}function hd(e){return e!==void 0&&/\s/.test(e)}function FM(e){let t=0;for(;t<e.length&&hd(e[t])&&!ho(e[t]);)t++;let r=e.slice(0,t);if(!e.startsWith("---",t))return;let a=[];for(let p=t+3;p<e.length&&hd(e[p]);p++)ho(e[p])&&a.push(p);if(a.length===0)return;let i=r+"---",n=p=>{if(!ho(e[p])||!e.startsWith(i,p+1))return-1;let h=-1;for(let g=p+1+i.length;g<e.length&&hd(e[g]);g++)ho(e[g])&&(h=g);return h},l=`
161
+ `+i,s=-1;for(let p=e.lastIndexOf(l);p>a[0];p=e.lastIndexOf(l,p-1))if(n(p)!==-1){s=p;break}if(s===-1)return;let o=a[0];for(let p of a)p<s&&(o=p);let c=o+1,f=c>0?c-1:0;for(let p=e.indexOf(l,f);p!==-1&&p<=s;p=e.indexOf(l,p+1)){if(p<c)continue;let h=n(p);if(h!==-1)return{indent:r,body:e.slice(c,p),length:h+1}}}function Ki(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function fo(e,t){for(let r of Object.keys(t)){if(PM.has(r))continue;let a=t[r],i=e[r];Ki(a)&&Ki(i)?fo(i,a):Ki(a)?e[r]=fo({},a):e[r]=a}return e}function WM(e,t){if(!e.includes("%%{"))return e;let r=e.trim().replace(/'/g,'"');zn.lastIndex=0;let a;for(;(a=zn.exec(r))!==null;){a.index===zn.lastIndex&&zn.lastIndex++;let i=a[1]??a[2];if(i==="wrap")t.wrap=!0;else if((i==="init"||i==="initialize")&&a[4])try{let n=JSON.parse(a[4].trim());Ki(n)&&fo(t,n)}catch{}}return zn.lastIndex=0,e.replace(zn,"")}function b0(e){let t=e.includes("\r")?e.replace(/\r\n?/g,`
162
+ `):e,r=t.includes("<")?t.lastIndexOf(">"):-1;r>0&&(t=t.slice(0,r+1).replace(DM,(s,o,c)=>"<"+o+c.replace(OM,"='$1'")+">")+t.slice(r+1));let a={},i,n=0,l=t.includes("---")?FM(t):void 0;if(l){let s=l.indent?l.body.split(`
163
+ `).map(c=>c.startsWith(l.indent)?c.slice(l.indent.length):c).join(`
164
+ `):l.body,o;try{o=Ma(s)}catch(c){throw new je(`Front matter is not valid YAML. ${c.message}`,"syntax")}if(Ki(o)&&(o.title&&(i=String(o.title)),Ki(o.config)&&fo(a,o.config),o.displayMode)){let c=Ki(a.gantt)?a.gantt:a.gantt={};c.displayMode=String(o.displayMode)}for(let c=t.indexOf(`
165
+ `);c!==-1&&c<l.length;c=t.indexOf(`
166
+ `,c+1))n++;t=t.slice(l.length)}return t=WM(t,a),{text:zM(t),title:i,config:a,withComments:t,lineOffset:n}}var BM=/#\w+;/g,YM=/^\+?\d+$/,dd=new RegExp("[\\n\\r\u2028\u2029]","g");function x0(e,t){let r=e.indexOf(t);if(r===-1)return e;let a="",i=0;for(;r!==-1;){dd.lastIndex=r;let n=dd.test(e)?dd.lastIndex-1:e.length,l=!1,s=-1;for(let o=r+t.length;o<n;o++){let c=e.charCodeAt(o);if(c===58)l=!0;else if(c===35){if(l){s=o;break}}else Ue(c)&&(l=!1)}if(s!==-1){let o=e.lastIndexOf(";",n-1);o>s&&(a+=e.slice(i,o),i=o+1)}r=n>=e.length?-1:e.indexOf(t,n+1)}return i===0?e:a+e.slice(i)}function HM(e){return e.includes("#")?x0(x0(e,"style"),"classDef").replace(BM,t=>{let r=t.substring(1,t.length-1);return(YM.test(r)?"\uFB02\xB0\xB0":"\uFB02\xB0")+r+"\xB6\xDF"}):e}var fD=Math.random().toString(36).slice(2,7);var fd=new Map;function $0(...e){for(let t of e)fd.set(t.type,t)}function k0(e){return fd.has(e)}var UM=5e4,qM=4e6,GM=5e3;function M0(e){try{return e()}catch(t){throw t instanceof RangeError?new je("Diagram is nested too deeply.","limit"):t}}function A0(e,t){try{return t()}catch(r){throw r instanceof RangeError?new je("Diagram is nested too deeply.","limit",e):(r instanceof je&&(r.type??(r.type=e.type),r.mermaidType??(r.mermaidType=e.mermaidType)),r)}}var v0=new WeakMap;function E0(e,t=UM,r=GM,a){if(e.length>t)throw new je(`Diagram source is longer than the limit of ${t} characters.`,"limit");let i=b0(e),n=w0(i.text);if(n===null)throw new je("No diagram type detected for the given text.","unsupported-diagram");let l=fd.get(n.type);if(l===void 0)throw new je(`Diagram type "${n.type}" is not supported yet.`,"unsupported-diagram",n);let s=a?{...a,...i.config}:i.config,o=l.keepComments?i.withComments:i.text,c=A0(n,()=>l.parse(HM(o)+`
167
+ `,s,i.title,i.lineOffset,{maxEdges:r}));return{...n,diagram:l,model:c,config:s}}function jM(e,t){if(typeof e=="string")return E0(e,t.limit,t.maxEdges,t.config);let r=v0.get(e);if(r===void 0)throw new TypeError("render() takes diagram text or a model that parse() returned.");return r}function pd(e){return w0(b0(e).text)?.type??null}function ud(e,t={}){return M0(()=>{let r=E0(e,t.limit,t.maxEdges,t.config),a=r.model;return Object.defineProperty(a,"mermaidType",{value:r.mermaidType,enumerable:!0}),v0.set(a,r),a})}function Mi(e,t={}){return M0(()=>{let{type:r,mermaidType:a,diagram:i,model:n,config:l}=jM(e,t),s=l[i.section??r],o=typeof s=="object"&&s!==null&&!Array.isArray(s)&&s.useMaxWidth===!1,c=t.responsive??!o,f=t.icons,p=f&&(u=>f(At(u))),h=A0({type:r,mermaidType:a},()=>u0(i.math?t.math:void 0,()=>p0(p,()=>i.render(n,l,{...t,responsive:c,icons:p})))),g=t.outputLimit??qM;if(h.svg.length>g)throw new je(`Diagram output is longer than the limit of ${g} characters.`,"limit",{type:r,mermaidType:a});for(let u of h.links)u.id=At(u.id);return{type:r,mermaidType:a,...h}})}wt();var QN=new Map([["flowchart",()=>Promise.resolve().then(()=>($1(),b1)).then(e=>e.flowchart)],["pie",()=>Promise.resolve().then(()=>(C1(),T1)).then(e=>e.pie)],["er",()=>Promise.resolve().then(()=>(G1(),q1)).then(e=>e.er)],["mindmap",()=>Promise.resolve().then(()=>(ng(),ig)).then(e=>e.mindmap)],["kanban",()=>Promise.resolve().then(()=>(cg(),og)).then(e=>e.kanban)],["timeline",()=>Promise.resolve().then(()=>(yg(),mg)).then(e=>e.timeline)],["journey",()=>Promise.resolve().then(()=>(Mg(),kg)).then(e=>e.journey)],["class",()=>Promise.resolve().then(()=>(Fg(),zg)).then(e=>e.classDiagram)],["quadrantChart",()=>Promise.resolve().then(()=>(Zg(),Kg)).then(e=>e.quadrantChart)],["xychart",()=>Promise.resolve().then(()=>(um(),pm)).then(e=>e.xychart)],["state",()=>Promise.resolve().then(()=>(Sm(),Em)).then(e=>e.state)],["gantt",()=>Promise.resolve().then(()=>(Qm(),Zm)).then(e=>e.gantt)],["architecture",()=>Promise.resolve().then(()=>(h2(),c2)).then(e=>e.architecture)],["requirement",()=>Promise.resolve().then(()=>(k2(),$2)).then(e=>e.requirement)],["sankey",()=>Promise.resolve().then(()=>(R2(),N2)).then(e=>e.sankey)],["packet",()=>Promise.resolve().then(()=>(z2(),P2)).then(e=>e.packet)],["radar",()=>Promise.resolve().then(()=>(X2(),j2)).then(e=>e.radar)],["treemap",()=>Promise.resolve().then(()=>(ry(),ty)).then(e=>e.treemap)],["info",()=>Promise.resolve().then(()=>(ly(),sy)).then(e=>e.info)],["sequence",()=>Promise.resolve().then(()=>(Ey(),vy)).then(e=>e.sequence)],["gitGraph",()=>Promise.resolve().then(()=>(zy(),Py)).then(e=>e.gitGraph)],["c4",()=>Promise.resolve().then(()=>(ax(),rx)).then(e=>e.c4)],["block",()=>Promise.resolve().then(()=>(xx(),yx)).then(e=>e.block)],["railroad",()=>Promise.resolve().then(()=>(Bx(),Wx)).then(e=>e.railroad)],["agentflow",()=>Promise.resolve().then(()=>(rw(),tw)).then(e=>e.agentflow)],["treeView",()=>Promise.resolve().then(()=>(gw(),uw)).then(e=>e.treeView)],["cynefin",()=>Promise.resolve().then(()=>(Ew(),vw)).then(e=>e.cynefin)],["wardley",()=>Promise.resolve().then(()=>(Fw(),zw)).then(e=>e.wardley)],["eventmodeling",()=>Promise.resolve().then(()=>(Kw(),Vw)).then(e=>e.eventmodeling)],["usecase",()=>Promise.resolve().then(()=>(Fb(),zb)).then(e=>e.usecase)],["venn",()=>Promise.resolve().then(()=>(Gb(),qb)).then(e=>e.venn)],["ishikawa",()=>Promise.resolve().then(()=>(Qb(),Zb)).then(e=>e.ishikawa)],["swimlane",()=>Promise.resolve().then(()=>(c$(),o$)).then(e=>e.swimlane)]]),wu=new Map;function h$(e){if(e===null)return Promise.resolve(!1);if(k0(e))return Promise.resolve(!0);let t=wu.get(e);if(t===void 0){let r=QN.get(e);if(r===void 0)return Promise.resolve(!1);t=r().then(a=>($0(a),!0),a=>{throw wu.delete(e),a}),wu.set(e,t)}return t}var d$=/<br\s*\/?>/gi,JN=/\\+n/g,eR=(e,t)=>e.replace(JN,r=>{let a=r.length-1,i="\\".repeat(Math.floor(a/2));return a%2?`${i}${t}`:`${i}n`}),tR=e=>eR(e.replace(d$,`
168
+ `),`
169
+ `),rR=/<\/?(?:a|abbr|b|big|cite|code|del|em|font|i|ins|kbd|mark|q|s|samp|small|span|strike|strong|sub|sup|tt|u|var)(?:\s[^<>]*)?\/?>/g,ta=e=>t0(tR(e).replace(rR,"")),f$=async(e,t)=>{try{return await t(e)}catch(r){let a=e.replace(d$,"\\n");if(a===e)throw r;try{return await t(a)}catch{throw r}}};var p$=e=>e.replace(/\s*!important\s*$/i,"").trim(),aR=(e,t)=>{let r=t;for(;r<e.length&&/\s/.test(e[r]);)r+=1;let a=r;for(;r<e.length&&/[a-z-]/i.test(e[r]);)r+=1;if(r===a)return!1;for(;r<e.length&&/\s/.test(e[r]);)r+=1;return e[r]===":"},Ql=e=>{let t=[],r=0;for(;r<e.length;){for(;r<e.length&&/[\s;,]/.test(e[r]);)r+=1;if(r>=e.length)break;let a=r;for(;r<e.length&&e[r]!==":"&&!(e[r]===";"||e[r]===",");)r+=1;if(r>=e.length||e[r]!==":")break;let i=e.substring(a,r).trim().toLowerCase();r+=1;let n=r,l=0,s=null;for(;r<e.length;){let c=e[r];if(s){c===s&&e[r-1]!=="\\"&&(s=null),r+=1;continue}if(c==='"'||c==="'"){s=c,r+=1;continue}if(c==="("){l+=1,r+=1;continue}if(c===")"){l=Math.max(0,l-1),r+=1;continue}if(l===0&&(c===";"||c===","||/\s/.test(c)&&aR(e,r)))break;r+=1}let o=p$(e.substring(n,r));i&&o&&t.push({property:i,value:o}),r<e.length&&(e[r]===";"||e[r]===",")&&(r+=1)}return t},Hh=e=>{let t=p$(e);if(!t)return!1;if(typeof CSS<"u"&&typeof CSS.supports=="function")return CSS.supports("color",t);if(typeof document<"u"){let r=document.createElement("div");return r.style.color="",r.style.color=t,r.style.color!==""}return!1};var $s=e=>{let t=new DOMParser().parseFromString(e,"image/svg+xml").documentElement;if(t.tagName!=="svg")throw new Error("Pele returned an invalid SVG");return t},nr=(e,t)=>{let r=new Map;return e.querySelectorAll(t).forEach(a=>{let i=a.getAttribute("data-id");i!==null&&!r.has(i)&&r.set(i,a)}),r},iR=/translate\(\s*([^\s,)]+)(?:[\s,]+([^\s,)]+))?\s*\)/,ks=(e,t)=>{let r={x:0,y:0};for(let a=e;a&&a!==t;a=a.parentElement){let i=a.getAttribute("transform")?.match(iR);i&&(r.x+=Number(i[1])||0,r.y+=Number(i[2])||0)}return r},da=(e,t)=>Number(e.getAttribute(t))||0,nR=/[a-zA-Z]|-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi,Uh=e=>{let t=e.match(nR)||[],r=[],a=0,i="",n={x:0,y:0},l={x:0,y:0},s=c=>c!==void 0&&/^[a-zA-Z]$/.test(c),o=()=>Number(t[a++]);for(;a<t.length;){if(s(t[a]))i=t[a++];else if(!i||i.toUpperCase()==="Z")break;let c=i===i.toLowerCase(),f=(g,u)=>c?{x:n.x+g,y:n.y+u}:{x:g,y:u},p,h;switch(i.toUpperCase()){case"M":case"L":case"T":p=[f(o(),o())];break;case"H":{let g=o();p=[{x:c?n.x+g:g,y:n.y}];break}case"V":{let g=o();p=[{x:n.x,y:c?n.y+g:g}];break}case"C":p=[f(o(),o()),f(o(),o()),f(o(),o())];break;case"S":case"Q":p=[f(o(),o()),f(o(),o())];break;case"A":{h={rx:o(),ry:o(),rotation:o(),largeArc:o()!==0,sweep:o()!==0},p=[f(o(),o())];break}case"Z":p=[l];break;default:throw new Error(`Unsupported SVG path command "${i}"`)}if(p.some(g=>!Number.isFinite(g.x)||!Number.isFinite(g.y)))break;r.push({command:i.toUpperCase(),points:p,...h?{arc:h}:{}}),n=p[p.length-1],i.toUpperCase()==="M"&&(l=n,i=c?"l":"L")}return r},x$=e=>{if(!e.length)return null;let t=e.map(n=>n.x),r=e.map(n=>n.y),a=Math.min(...t),i=Math.min(...r);return{x:a,y:i,width:Math.max(...t)-a,height:Math.max(...r)-i}},u$=24,sR=(e,t,{rx:r,ry:a,rotation:i,largeArc:n,sweep:l})=>{if(!r||!a)return[];let s=i*Math.PI/180,o=Math.cos(s),c=Math.sin(s),f=(e.x-t.x)/2,p=(e.y-t.y)/2,h=o*f+c*p,g=-c*f+o*p,u=h*h/(r*r)+g*g/(a*a),m=Math.max(1,Math.sqrt(u));r=Math.abs(r)*m,a=Math.abs(a)*m;let b=(n!==l?1:-1)*Math.sqrt(Math.max(0,(r*r*a*a-r*r*g*g-a*a*h*h)/(r*r*g*g+a*a*h*h))),w=b*r*g/a,v=-b*a*h/r,k=o*w-c*v+(e.x+t.x)/2,O=c*w+o*v+(e.y+t.y)/2,R=(B,G)=>Math.atan2(G,B),L=R((h-w)/r,(g-v)/a),P=R((-h-w)/r,(-g-v)/a)-L;return l&&P<0?P+=Math.PI*2:!l&&P>0&&(P-=Math.PI*2),Array.from({length:u$+1},(B,G)=>{let C=L+P*G/u$;return{x:k+r*o*Math.cos(C)-a*c*Math.sin(C),y:O+r*c*Math.cos(C)+a*o*Math.sin(C)}})},w$=e=>{switch(e.tagName.toLowerCase()){case"rect":case"image":{let t=da(e,"x"),r=da(e,"y");return[{x:t,y:r},{x:t+da(e,"width"),y:r+da(e,"height")}]}case"circle":case"ellipse":{let t=da(e,"cx"),r=da(e,"cy"),a=da(e,e.hasAttribute("r")?"r":"rx"),i=da(e,e.hasAttribute("r")?"r":"ry");return[{x:t-a,y:r-i},{x:t+a,y:r+i}]}case"polygon":case"polyline":{let t=(e.getAttribute("points")||"").split(/[\s,]+/).filter(Boolean).map(Number),r=[];for(let a=0;a+1<t.length;a+=2)r.push({x:t[a],y:t[a+1]});return r}case"path":{let t={x:0,y:0};return Uh(e.getAttribute("d")||"").flatMap(({points:r,arc:a})=>{let i=t;return t=r[r.length-1],a?[...sR(i,t,a),...r]:r})}default:return[]}},b$="rect, circle, ellipse, polygon, polyline, path, image",lR=new Set(b$.split(", ")),yr=(e,t)=>{let a=(lR.has(e.tagName.toLowerCase())?[e]:Array.from(e.querySelectorAll(b$))).flatMap(i=>{let n=ks(i,t);return w$(i).map(l=>({x:l.x+n.x,y:l.y+n.y}))});return x$(a)},Ui=(e,t)=>{let r=ks(e,t),a={x:0,y:0};return Uh(e.getAttribute("d")||"").flatMap(({command:i,points:n})=>{let l=a;if(a=n[n.length-1],i==="Q")return n;if(i==="C"){let[s,o,c]=n;return[{x:(l.x+3*s.x+3*o.x+c.x)/8,y:(l.y+3*s.y+3*o.y+c.y)/8},c]}return[a]}).map(i=>({x:i.x+r.x,y:i.y+r.y}))},Ms=(e,t=.5)=>{let r=e.filter((a,i)=>i===0||Math.hypot(a.x-e[i-1].x,a.y-e[i-1].y)>t);return r.filter((a,i)=>{if(i===0||i===r.length-1)return!0;let n=r[i-1],l=r[i+1],s=(a.x-n.x)*(l.y-n.y)-(a.y-n.y)*(l.x-n.x),o=Math.hypot(l.x-n.x,l.y-n.y);return!o||Math.abs(s)/o>t})},g$=(e,t)=>{let r=e[e.length-1],a=e[e.length-2],i=r.x-a.x,n=r.y-a.y,l=Math.hypot(i,n),s=Math.abs(i)<.5;if(l>=t||!l||!s&&Math.abs(n)>=.5)return e;let o=g=>s?(r.y-g.y)*Math.sign(n):(r.x-g.x)*Math.sign(i),c=-1;for(let g=e.length-2;g>0;g--){let u=e[g-1],m=e[g];if(Math.hypot(m.x-u.x,m.y-u.y)<t)continue;if(s?Math.abs(m.x-u.x)<.5:Math.abs(m.y-u.y)<.5){c=g;break}if(o(u)>=t+4){c=g-1;break}}if(c<0)return e;let f=o(e[c]),p=Math.min(t,f-4);if(p<=l)return e;let h=(f-p)/(f-l);return e.map((g,u)=>{if(u<=c||u===e.length-1)return g;let m=p+(o(g)-l)*h;return s?{x:g.x,y:r.y-Math.sign(n)*m}:{x:r.x-Math.sign(i)*m,y:g.y}})},qh=(e,t=30)=>e.length<3?e:g$(g$(e,t).slice().reverse(),t).reverse(),Gh=(e,t=3)=>{let r=[...e];for(let a=0;a<e.length*8;a++){let i=r.slice(1).map((h,g)=>Math.hypot(h.x-r[g].x,h.y-r[g].y)),n=i.findIndex((h,g)=>g>0&&Math.min(h,i[g-1])>1&&Math.max(h,i[g-1])>t*Math.min(h,i[g-1]));if(n===-1)break;let l=i[n]>i[n-1],s=r[n],o=r[l?n+1:n-1],c=i[l?n:n-1],p=2*i[l?n-1:n]/c;r.splice(l?n+1:n,0,{x:s.x+(o.x-s.x)*p,y:s.y+(o.y-s.y)*p})}return r},As=(e,t)=>{let r=0,a={distance:1/0,length:0};for(let i=1;i<e.length;i++){let n=e[i-1],l=e[i].x-n.x,s=e[i].y-n.y,o=Math.hypot(l,s),c=o?Math.min(1,Math.max(0,((t.x-n.x)*l+(t.y-n.y)*s)/o**2)):0,f=Math.hypot(n.x+c*l-t.x,n.y+c*s-t.y);f<a.distance&&(a={distance:f,length:r+c*o}),r+=o}return r?a.length/r:.5},oR=(e,t)=>{let r=ks(e,t),a=e.tagName.toLowerCase()==="circle";return{points:(a?[{x:da(e,"cx"),y:da(e,"cy")}]:w$(e)).map(n=>({x:n.x+r.x,y:n.y+r.y})),radius:a?da(e,"r"):0}},m$=(e,t,r)=>{let a=Math.hypot(e.x-t.x,e.y-t.y);if(!a||!r.length)return e;let i={x:(e.x-t.x)/a,y:(e.y-t.y)/a},n=Math.max(0,...r.flatMap(({points:l,radius:s})=>l.map(o=>(o.x-e.x)*i.x+(o.y-e.y)*i.y+s)));return{x:e.x+i.x*n,y:e.y+i.y*n}},bu=(e,t,r)=>{let a=[],i=[];if(!e.length)return{startMarkers:a,endMarkers:i};let n=e[0],l=e[e.length-1];return t.forEach(s=>{let o=oR(s,r),c=x$(o.points);if(!c)return;let f=c.x+c.width/2,p=c.y+c.height/2,h=Math.hypot(f-n.x,p-n.y),g=Math.hypot(f-l.x,p-l.y);(h<g?a:i).push(o)}),{startMarkers:a,endMarkers:i}},y$=(e,t,r)=>{let a={x:t.x-e.x,y:t.y-e.y},i={x:r.x-t.x,y:r.y-t.y};return Math.abs(a.x*i.y-a.y*i.x)<.01*Math.hypot(a.x,a.y)&&a.x*i.x+a.y*i.y<0},cR=e=>{let t=e;for(;t.length>2&&y$(t[t.length-3],t[t.length-2],t.at(-1));)t=[...t.slice(0,-2),t.at(-1)];for(;t.length>2&&y$(t[2],t[1],t[0]);)t=[t[0],...t.slice(2)];return t},jh=(e,t,r)=>{if(e.length<2||!t.length)return e;let a=cR(e),i=a[0],n=a[a.length-1],{startMarkers:l,endMarkers:s}=bu(a,t,r),o=[...a];return o[0]=m$(i,a[1],l),o[o.length-1]=m$(n,a[a.length-2],s),o},$$=e=>`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(e)))}`,ba=(e,t,r)=>{for(let a=e;a&&a!==t;a=a.parentElement){let i=Number(a.getAttribute("font-size"));if(i)return i}return r},ra=e=>{if(!e)return[];let t=Array.from(e.querySelectorAll("tspan"));return t.length?t.reduce((r,a)=>((a.hasAttribute("y")||!r.length)&&r.push(""),r[r.length-1]+=a.textContent||"",r),[]):[e.textContent||""]},hR=.35,dR=1.25,k$=(e,t,r)=>{let a=ks(e,t),i=ba(e,t,r),n=[e,...Array.from(e.querySelectorAll("tspan"))].filter(h=>h.hasAttribute("y")),l=n.map(h=>da(h,"y")),s=n.length?da(n[0],"x"):0,o=ra(e),c=l.length?(Math.min(...l)+Math.max(...l))/2-hR*i:0,f=o.length*i*dR,p=e.getAttribute("text-anchor");return{text:o.join(`
170
+ `),x:s+a.x,y:c-f/2+a.y,height:f,fontSize:i,textAlign:p==="middle"?"center":p==="end"?"right":"left"}},fR=e=>!/\bvar\(/i.test(e)&&Hh(e),fr=(e,t)=>{let r=ri(e,t);return r&&fR(r)?r:void 0},ri=(e,t)=>Ql(e?.getAttribute("style")||"").find(r=>r.property===t)?.value;var qi=(e,t)=>{let r=ra(t),a=i=>i.replace(/\s+/g," ").trim();return r.length>e.split(`
171
+ `).length&&a(r.join(" "))===a(e)?r.join(`
172
+ `):e},bi=(e,t)=>(e.getAttribute("class")||"").split(/\s+/).includes(t),Yr=(e,t,r,a={})=>{let{text:i,x:n,y:l,height:s,fontSize:o,textAlign:c}=k$(e,t,r);return{type:"text",text:i,x:n,y:l,height:s,fontSize:o,textAlign:c,color:fr(e,"fill"),...a}},Xh=(e,t,r={})=>({type:"line",startX:e.x,startY:e.y,endX:t.x,endY:t.y,...r}),za=(e,t,r={})=>{let a=ks(e,t),i=[],n;return Uh(e.getAttribute("d")||"").forEach(({command:l,points:s})=>{let o=s[s.length-1];l!=="M"&&n&&i.push(Xh({x:n.x+a.x,y:n.y+a.y},{x:o.x+a.x,y:o.y+a.y},r)),n=o}),i},Gi=(e,t)=>{let r=Array.from(e.children).find(s=>s.tagName.toLowerCase()==="path"&&!bi(s,"pele-marker"));if(!r)return;let a=Array.from(e.querySelectorAll(".pele-marker")),i=Ui(r,t),{startMarkers:n,endMarkers:l}=bu(i,a,t);return{line:r,route:Ms(jh(i,a,t)),hasStartMarker:n.length>0,hasEndMarker:l.length>0}},M$=(e,t)=>Math.hypot(Math.max(t.x-e.x,0,e.x-(t.x+t.width)),Math.max(t.y-e.y,0,e.y-(t.y+t.height))),Vh=(e,t,r)=>{let a=t??r;if(!a||e.length<2)return e;let i=M$(e[0],a),n=M$(e[e.length-1],a);return(t?i>n:i<n)?[...e].reverse():e},Cn=(e,t={})=>{let[r]=e,a=e[e.length-1];return{type:"arrow",startX:r.x,startY:r.y,endX:a.x,endY:a.y,points:e.map(i=>[i.x-r.x,i.y-r.y]),...t}},Kh=(e,t,r)=>{let a=t&&yr(t,r);return a?As(e,{x:a.x+a.width/2,y:a.y+a.height/2}):void 0},vs=e=>({x:e.x,y:e.y,width:e.width??0,height:e.height??0});var S$="rect, circle, ellipse, polygon, path",T$=5,C$=1.25,_$=e=>!/\bvar\(/i.test(e)&&Hh(e),I$=e=>{let t={};return Ql(e?.getAttribute("style")||"").forEach(({property:r,value:a})=>{switch(r){case Tr.FILL:case Tr.STROKE:_$(a)&&(t[r]=a);break;case Tr.STROKE_WIDTH:case Tr.STROKE_DASHARRAY:t[r]=a;break}}),t},N$=e=>{let t={};return Ql(e?.getAttribute("style")||"").forEach(({property:r,value:a})=>{(r==="fill"||r===ai.COLOR)&&_$(a)&&(t[ai.COLOR]=a)}),t},pR=(e,t,r)=>{let a=yr(t,r);if(a)return{id:e.id,type:e.type,labelType:e.labelType,text:e.type===_r.DIAMOND?ta(e.text??e.id):qi(ta(e.text??e.id),t.querySelector(".pele-label")),...a,link:t.querySelector("a[href]")?.getAttribute("href")||void 0,containerStyle:I$(t.querySelector(S$)),labelStyle:N$(t.querySelector(".pele-label"))}},uR=(e,t)=>Math.abs(t.x-(e.x+e.width/2))/(e.width/2)+Math.abs(t.y-(e.y+e.height/2))/(e.height/2),A$=(e,t)=>Math.hypot((t.x-(e.x+e.width/2))/(e.width/2),(t.y-(e.y+e.height/2))/(e.height/2)),gR=5,R$={[_r.DIAMOND]:{ratio:2,inset:0,getDistance:uR},[_r.CIRCLE]:{ratio:Math.SQRT2,inset:0,getDistance:A$},[_r.DOUBLECIRCLE]:{ratio:Math.SQRT2,inset:gR*2,getDistance:A$}},v$=4,mR=1.35,yR=.02,xR=1/4,wR=(e,t,r)=>{let a=[];for(let i of e.split(`
173
+ `)){let n=[],l="",s=0;for(let o of i.split(" ").filter(Boolean)){let c=l?`${l} ${o}`:o,f=r(c);if(f===null)return null;if(f<=t){l=c,s=f;continue}let p=r(o)??1/0;if(p>t)return null;l&&n.push(s),l=o,s=p}n.push(s),a.push(n)}return a},bR=(e,{fontSize:t,measureText:r})=>{if(!e.text||!r||r(e.text)===null)return e;let a=T$*2,i=t*C$,n=(f,{withoutOrphans:p=!1}={})=>{let h=Math.round(e.width*f/2)-a-1,g=Math.round(e.height*f/2)-a,u=wR(e.text,h,r);return!!u&&u.flat().length*i<=g&&(!p||u.every(m=>m.length<2||m[m.length-1]>=h*xR))},l=(f,p)=>{for(let h=1;h<=f;h+=yR)if(n(h,p))return h;return null},s=l(mR,{withoutOrphans:!0})??l(v$)??v$,o=e.width*s,c=e.height*s;return{...e,x:e.x-(o-e.width)/2,y:e.y-(c-e.height)/2,width:o,height:c}},$R=(e,t,r)=>{if(e.type===_r.DIAMOND)return bR(e,r);let{fontSize:a,measureText:i}=r,n=R$[e.type];if(!n||!t.length)return e;let l=t.map(g=>i?.(g)??null);if(l.some(g=>g===null))return e;let s=T$*2,o=Math.max(...l),c=t.length*a*C$,f=Math.max(e.width,e.height,n.ratio*(o+s+1)+n.inset,n.ratio*(c+s+1)+n.inset),p=f,h=f;return{...e,x:e.x-(p-e.width)/2,y:e.y-(h-e.height)/2,width:p,height:h}},kR=(e,t,r,a)=>{let i=yr(t,a);if(!i)return;let n=bi(t,"pele-lane")?Array.from(t.children).filter(s=>s.tagName.toLowerCase()==="rect")[1]:void 0,l=n&&yr(n,a);return{id:e.id,nodeIds:e.nodes,text:ta(e.title),labelType:e.labelType,...i,containerStyle:I$(t.querySelector(S$)),labelStyle:N$(t.querySelector(".pele-cluster-label")||r?.querySelector(".pele-cluster-label")||null),...l?{laneHeader:{...l,vertical:l.height>=i.height-1}}:{}}},E$=(e,t)=>{let r=R$[t.type];if(!r)return e;let a=e.findIndex((o,c)=>c>0&&r.getDistance(t,o)>1.01);if(a===-1)return e;let i=e[a],n=t.x+t.width/2,l=t.y+t.height/2,s=1/r.getDistance(t,i);return[{x:n+(i.x-n)*s,y:l+(i.y-l)*s},...e.slice(a)]},MR=(e,t,r,a,i,{inSwimlanes:n=!1}={})=>{let s=Array.from(t.querySelectorAll("path")).find(m=>!m.getAttribute("class")?.includes("pele-marker"));if(!s)return;let o=jh(Ui(s,a),Array.from(t.querySelectorAll(".pele-marker")),a),c=i[e.start];c&&(o=E$(o,c));let f=i[e.end];if(f&&(o=E$(o.reverse(),f).reverse()),o=Ms(o),o.length<2)return;let p=n&&o.every((m,b)=>b===0||Math.abs(m.x-o[b-1].x)<.5||Math.abs(m.y-o[b-1].y)<.5),h=o[0],g=o[o.length-1],u=r&&yr(r,a);return{id:e.id,start:e.start,end:e.end,type:e.type,text:qi(ta(e.text),r?.querySelector("text")??null),labelType:e.labelType,stroke:e.stroke,startX:h.x,startY:h.y,endX:g.x,endY:g.y,reflectionPoints:p?o:Gh(o),...p?{orthogonal:p}:{},...e.text&&u?{labelPosition:As(o,{x:u.x+u.width/2,y:u.y+u.height/2})}:{}}},L$=(e,t,r)=>{let a=nr(t,"g.pele-node[data-id]"),i=nr(t,"g.pele-edge[data-id]"),n=nr(t,"g.pele-edge-label[data-id]"),l=nr(t,"g.pele-cluster[data-id]"),s=nr(t,"g.pele-cluster-title[data-id]"),o={};e.nodes.forEach((u,m)=>{let b=a.get(m),w=b&&pR(u,b,t);w&&(o[m]=$R(w,ra(b.querySelector(".pele-label")),r))});let c=new Map;e.subgraphs.forEach(u=>u.nodes.forEach(m=>c.set(m,u.id)));let f=(u,m)=>{let b=new Set;for(let w=c.get(u);w!==void 0&&!b.has(w);w=c.get(w)){if(w===m)return!0;b.add(w)}return!1},p=e.mermaidType==="swimlane",h=e.edges.flatMap(u=>{if(f(u.start,u.end)||f(u.end,u.start))return[];let m=u.id!==void 0&&i.get(u.id),b=m&&MR(u,m,n.get(u.id)??void 0,t,o,{inSwimlanes:p});return b?[b]:[]});return{type:"flowchart",subGraphs:e.subgraphs.flatMap(u=>{let m=l.get(u.id),b=m&&kR(u,m,s.get(u.id)||null,t);return b?[b]:[]}),vertices:o,edges:h}};var AR="#999",D$="#adb5bd",vR="#e9ecef",ER="#e9ecef",$u=14,O$=28,SR=2*5+4,TR="#ffffff",Zh=16,CR=1.25,Es=yr,_R=(e,t,r)=>{let a=yr(e,t);if(!a)return[];let{x:i,y:n,width:l,height:s}=a,o=[{x:i,y:n},{x:i+l,y:n},{x:i+l,y:n+s},{x:i,y:n+s}];return o.map((c,f)=>Xh(c,o[(f+1)%o.length],r))},IR=(e,t,r)=>{let a=[];return t.querySelectorAll("g.pele-node.pele-actor[data-id]").forEach(i=>{let n=i.getAttribute("data-id"),l=bi(i,"pele-actor-footer")?"bottom":"top",s=`${n}-${l}`,o=i.querySelector(".pele-label");if(bi(i,"pele-actor-actor")){let h=xr(),g=[];Array.from(i.children).forEach(u=>{let m=`${s}-${g.length}`;switch(u.tagName.toLowerCase()){case"circle":{let b=Es(u,t);b&&g.push({type:"ellipse",id:m,...b,groupId:h});break}case"path":case"line":g.push(...za(u,t,{groupId:h}).map((b,w)=>({...b,id:`${m}-${w}`})));break;case"text":g.push(Yr(u,t,r.fontSize,{id:m,groupId:h}));break}}),a.push(g);return}let c=Es(i,t);if(!c)return;let f=i.querySelector("rect, path, polygon, circle"),p=e.actors.get(n);a.push([{type:"rectangle",id:s,...c,label:{text:qi(ta(p?.description??n),o),fontSize:o?ba(o,t,r.fontSize):r.fontSize},bgColor:f?fr(f,"fill"):void 0,strokeColor:f?fr(f,"stroke"):void 0,subtype:"actor"}])}),a},NR=e=>Array.from(e.querySelectorAll("path.pele-lifeline")).flatMap(t=>{let r=Ui(t,e);return r.length<2?[]:[Xh(r[0],r[r.length-1],{strokeColor:AR,strokeWidth:1})]}),z$=e=>typeof e.message=="string"?ta(e.message):"",RR=(e,t,r)=>{let a=new Map(e.messages.map(s=>[`i${s.id}`,s])),i=nr(t,"g.pele-edge-label[data-id]"),n=[],l=[];return nr(t,"g.pele-edge.pele-message[data-id]").forEach((s,o)=>{let c=a.get(o),f=Gi(s,t);if(!c||!f||f.route.length<2)return;let p=c.from!==void 0&&c.from===c.to&&i.get(o)?.querySelector("text");if(p){let k=Yr(p,t,r.fontSize),{height:O=0}=k,R=O*Zh/k.fontSize;l.push({...k,fontSize:Zh,y:k.y+(O-R)/2,height:R})}let h=p?"":z$(c),g=h?h.split(`
174
+ `).length*Zh*CR/2:0,u=f.route.map(k=>({x:k.x,y:k.y-g})),m=Cn(u,{label:h?{text:h}:void 0,strokeStyle:f.line.hasAttribute("stroke-dasharray")?"dotted":"solid",startArrowhead:f.hasStartMarker?"arrow":null,endArrowhead:f.hasEndMarker?"arrow":null}),b=s.querySelector(".pele-sequence-number"),w=b?.querySelector("rect, circle"),v=w&&yr(w,t);if(b&&v){let k=b.textContent||"",O=O$,R=r.measureText?.(k,$u)??k.length*$u*.7,L=Math.max(O$,R+SR);m.sequenceNumber={type:"rectangle",x:v.x+v.width/2-L/2,y:v.y+v.height/2-g-O/2,width:L,height:O,label:{text:k,fontSize:$u},bgColor:ER,subtype:"sequence"}}n.push(m)}),{arrows:n,texts:l}},LR=(e,t,r)=>{let a=new Map(e.messages.map(i=>[`i${i.id}`,i]));return Array.from(nr(t,"g.pele-note[data-id]")).flatMap(([i,n])=>{let l=n.querySelector("rect"),s=l&&Es(l,t),o=a.get(i);if(!l||!s)return[];let c=n.querySelector(".pele-label");return[{type:"rectangle",...s,label:{text:o?qi(z$(o),c):c?.textContent||"",fontSize:c?ba(c,t,r.fontSize):r.fontSize},bgColor:fr(l,"fill")??TR,strokeStyle:"dashed",subtype:"note"}]})},P$=(e,t,r)=>Array.from(e.querySelectorAll(t)).flatMap(a=>{let i=Es(a,e);return i?[{type:"rectangle",...i,label:{text:"",fontSize:Zh},...r==="highlight"?{bgColor:fr(a,"fill"),strokeColor:"transparent"}:{},subtype:r}]:[]}),DR=(e,t)=>{let r=[],a=[],i=[],n={strokeStyle:"dotted",strokeColor:D$,strokeWidth:2};return e.querySelectorAll("g.pele-frame").forEach(l=>{let s=Array.from(l.children).find(p=>p.tagName.toLowerCase()==="rect"&&p.getAttribute("fill")==="none");s&&r.push(..._R(s,e,n)),Array.from(l.children).filter(p=>p.tagName.toLowerCase()==="path"&&p.hasAttribute("stroke-dasharray")).forEach(p=>r.push(...za(p,e,n)));let o=l.querySelector(".pele-frame-kind"),c=o?.previousElementSibling,f=c&&Es(c,e);o&&f&&i.push({type:"rectangle",x:f.x,y:f.y,height:f.height,label:{text:o.textContent||"",fontSize:ba(o,e,t.fontSize)},strokeColor:D$,bgColor:vR}),l.querySelectorAll(".pele-frame-label").forEach(p=>a.push(Yr(p,e,t.fontSize)))}),{lines:r,texts:a,nodes:i}},F$=(e,t,r)=>{let a=IR(e,t,r),i=Array.from(t.querySelectorAll("g.pele-box")),n=Array.from(t.querySelectorAll("path.pele-destroy")).flatMap(s=>za(s,t)),l=RR(e,t,r);return{type:"sequence",nodes:[P$(t,"rect.pele-rect","highlight"),...a,LR(e,t,r),P$(t,"rect.pele-activation","activation"),n,l.texts],lines:NR(t),arrows:l.arrows,loops:DR(t,r),groups:e.boxes.map((s,o)=>{let c=i[o]?.querySelector("rect"),f=c&&Es(c,t);return{name:ta(s.name??""),actorKeys:s.actorKeys,fill:s.fill,...f?{bounds:f}:{}}})}};var OR={0:"diamond_outline",1:"triangle_outline",2:"diamond",3:"arrow",4:"circle_outline"},PR=1,zR=(e,t,r)=>{let a=e.getAttribute("data-id"),i=e.querySelector("rect"),n=i&&yr(i,t);if(!i||!n)return;let l=xr(),s={classId:a},o=fr(i,"stroke"),c=parseFloat(ri(i,"stroke-width")||""),f=ri(i,"stroke-dasharray")?"dashed":void 0,p=e.querySelector(".pele-label"),h=Array.from(e.querySelectorAll(".pele-annotation")),g=h.length?[...h,...p?[p]:[]].map(w=>Yr(w,t,r.fontSize,{id:xr(),groupId:l,metadata:s})):[],u={type:"rectangle",id:a,groupId:l,metadata:s,...n,label:h.length?void 0:{text:ra(p).join(`
175
+ `),fontSize:p?ba(p,t,r.fontSize):r.fontSize,color:fr(p,"fill"),verticalAlign:"top"},bgColor:fr(i,"fill"),strokeColor:o,strokeWidth:Number.isFinite(c)?c:void 0,strokeStyle:f},m=Array.from(e.querySelectorAll(".pele-divider")).flatMap(w=>za(w,t).map(v=>({...v,id:xr(),strokeColor:o,strokeWidth:u.strokeWidth,strokeStyle:f,groupId:l,metadata:s}))),b=[...g,...Array.from(e.querySelectorAll(".pele-member")).map(w=>Yr(w,t,r.fontSize,{id:xr(),groupId:l,metadata:s}))];return{container:u,lines:m,text:b}},FR=(e,t,r,a)=>{let i=nr(t,"g.pele-edge-label[data-id]"),n=[],l=new Map(Array.from(nr(t,"g.pele-edge.pele-relation[data-id]")).map(([o,c])=>[o.match(/_(\d+)$/)?.[1],c]).filter(([o])=>o!==void 0));return{arrows:e.relations.flatMap((o,c)=>{let f=l.get(String(c+1)),p=f&&Gi(f,t),h=r.get(o.id1),g=r.get(o.id2);if(!f||!p||p.route.length<2||!h&&!g)return[];let u=o.id1===o.id2,m=u?p.route:Vh(p.route,h&&vs(h),g&&vs(g)),b=O=>O==="none"?null:OR[O]??"arrow",w=o.title?ta(o.title):"",v=i.get(f.getAttribute("data-id")),k=u&&v?.querySelector("text");return k&&n.push(Yr(k,t,a.fontSize)),[Cn(m,{label:w&&!k?{text:w,labelPosition:Kh(m,v,t)}:void 0,strokeStyle:o.relation.lineType===PR?"dotted":"solid",startArrowhead:b(o.relation.type1),endArrowhead:b(o.relation.type2),...h?{start:{type:"rectangle",id:o.id1}}:{},...g?{end:{type:"rectangle",id:o.id2}}:{},...m.length>2&&!u?{roundness:null}:{}})]}),labels:n}},WR=(e,t,r)=>{let a=[],i=[],n=nr(t,"g.pele-note-edge[data-id]");return nr(t,"g.pele-node.pele-note[data-id]").forEach((l,s)=>{let o=yr(l,t),c=e.notes.get(s);if(!o)return;let f=l.querySelector(".pele-label");a.push({type:"rectangle",id:s,...o,label:{text:c?qi(ta(c.text),f):ra(f).join(`
176
+ `),fontSize:f?ba(f,t,r.fontSize):r.fontSize},strokeStyle:"dashed",subtype:"note"});let h=n.get(`edgeNote${s.replace(/^note/,"")}`)?.querySelector("path"),g=h&&Ms(Ui(h,t));!c?.class||!g||g.length<2||i.push(Cn(g,{strokeStyle:"dotted",startArrowhead:null,endArrowhead:null,start:{type:"rectangle",id:s},end:{type:"rectangle",id:c.class}}))}),{notes:a,connectors:i}},W$=(e,t,r)=>{let a=[],i=[],n=[],l=new Map;t.querySelectorAll("g.pele-node.pele-interface .pele-label").forEach(p=>n.push(Yr(p,t,r.fontSize))),t.querySelectorAll("g.pele-node.pele-class[data-id]").forEach(p=>{let h=zR(p,t,r);h&&(a.push(h.container),i.push(...h.lines),n.push(...h.text),l.set(h.container.id,h.container))});let{arrows:s,labels:o}=FR(e,t,l,r),{notes:c,connectors:f}=WR(e,t,r);return t.querySelectorAll(".pele-cardinality").forEach(p=>n.push(Yr(p,t,r.fontSize))),n.push(...o),{type:"class",nodes:[a,c],lines:i,arrows:[...s,...f],text:n,namespaces:Array.from(e.namespaces.values()).map(p=>({id:p.id,classes:Object.fromEntries(p.classes)}))}};var B$={ONLY_ONE:"cardinality_exactly_one",ZERO_OR_ONE:"cardinality_zero_or_one",ZERO_OR_MORE:"cardinality_zero_or_many",ONE_OR_MORE:"cardinality_one_or_many",MD_PARENT:"cardinality_one"},BR=(e,t,r,a)=>{let i=Array.from(t.children).find(b=>b.tagName.toLowerCase()==="rect"),n=i&&yr(i,r);if(!i||!n)return;let l=e.attributes.length>0,s=l?xr():void 0,o={entityId:e.id,entityLabel:e.label,entityAlias:e.alias},c=fr(i,"stroke"),f=parseFloat(ri(i,"stroke-width")||""),p=ri(i,"stroke-dasharray")?"dashed":void 0,h=Array.from(t.children).find(b=>(b.getAttribute("class")||"").includes("pele-label")),g={type:"rectangle",id:e.id,groupId:s,metadata:o,...n,label:{text:ra(h??null).join(`
177
+ `),fontSize:h?ba(h,r,a.fontSize):a.fontSize,color:fr(h,"fill"),textAlign:"center",verticalAlign:l?"top":"middle"},bgColor:fr(i,"fill"),strokeColor:c,strokeWidth:Number.isFinite(f)?f:void 0,strokeStyle:p},u=Array.from(t.querySelectorAll(".pele-er-divider")).flatMap(b=>za(b,r).map(w=>({...w,id:xr(),strokeColor:c,strokeWidth:g.strokeWidth,strokeStyle:p,groupId:s,metadata:{entityId:e.id}}))),m=Array.from(t.querySelectorAll(".pele-er-attributes text")).map(b=>Yr(b,r,a.fontSize,{id:xr(),groupId:s,metadata:{entityId:e.id}}));return{container:g,lines:u,text:m}},YR=(e,t,r,a)=>{let i=nr(t,"g.pele-edge-label[data-id]"),n=[],l=new Map(Array.from(nr(t,"g.pele-edges > g.pele-edge[data-id]")).map(([o,c])=>[o.match(/_(\d+)$/)?.[1],c]).filter(([o])=>o!==void 0));return{arrows:e.relationships.flatMap((o,c)=>{let f=l.get(String(c)),p=f&&Gi(f,t),h=r.get(o.entityA),g=r.get(o.entityB);if(!f||!p||p.route.length<2||!h||!g)return[];let u=o.entityA===o.entityB,m=u?p.route:qh(Vh(p.route,vs(h),vs(g))),b=ta(o.roleA||""),w=i.get(f.getAttribute("data-id")),v=u&&w?.querySelector("text");return v&&n.push(Yr(v,t,a.fontSize)),[Cn(m,{label:b&&!v?{text:b,textAlign:"center",labelPosition:Kh(m,w,t)}:void 0,strokeStyle:o.relSpec.relType==="NON_IDENTIFYING"?"dashed":"solid",startArrowhead:B$[o.relSpec.cardB]??null,endArrowhead:B$[o.relSpec.cardA]??null,start:{type:"rectangle",id:o.entityA},end:{type:"rectangle",id:o.entityB},...m.length>2&&!u?{roundness:null}:{}})]}),labels:n}},Y$=(e,t,r)=>{let a=[],i=[],n=[],l=new Map,s=nr(t,"g.pele-node.pele-entity[data-id]");e.entities.forEach((f,p)=>{let h=s.get(p),g=h&&BR(f,h,t,r);g&&(a.push(g.container),i.push(...g.lines),n.push(...g.text),l.set(f.id,g.container))});let{arrows:o,labels:c}=YR(e,t,l,r);return{type:"erd",nodes:[a],lines:i,arrows:o,text:[...n,...c]}};var HR=[["pele-state-start","stateStart"],["pele-state-end","stateEnd"],["pele-state-choice","choice"],["pele-state-fork","fork"],["pele-state-join","join"],["pele-note","note"]],UR=e=>{let t={},r=fr(e,"fill"),a=fr(e,"stroke"),i=ri(e,"stroke-width"),n=ri(e,"stroke-dasharray");return r&&(t[Tr.FILL]=r),a&&(t[Tr.STROKE]=a),i&&(t[Tr.STROKE_WIDTH]=i),n&&(t[Tr.STROKE_DASHARRAY]=n),t},qR=e=>{let t={},r=fr(e,"fill");return r&&(t[ai.COLOR]=r),t},GR=(e,t)=>{let r=Array.from(e.children).find(i=>i.tagName.toLowerCase()==="path"&&!i.getAttribute("class")&&i.getAttribute("fill")==="none"),[a]=r?za(r,t):[];return a?{startX:a.startX,startY:a.startY,endX:a.endX,endY:a.endY}:void 0},H$=(e,t,r,a)=>{let i=e.getAttribute("data-id"),n=e.querySelector("rect, circle, polygon, path"),l=yr(e,t);if(i===null||!l)return;let s=e.querySelectorAll(".pele-state-description"),o=r?"roundedWithTitle":HR.find(([f])=>bi(e,f))?.[1]??(s.length?"rectWithTitle":"rect"),c=e.querySelector(".pele-label, .pele-cluster-label");return{fontSize:c?ba(c,t,a):a,id:i,shape:o,text:ra(c).join(`
178
+ `),description:Array.from(s).flatMap(ra),...l,containerStyle:UR(n),labelStyle:qR(c),dividerLine:o==="rectWithTitle"||o==="roundedWithTitle"?GR(e,t):void 0,isRenderable:!0}},jR=(e,t)=>{let r=t.x+t.width,a=t.y+t.height;return e.x>=t.x&&e.x<=r&&e.y>=t.y&&e.y<=a?Math.min(e.x-t.x,r-e.x,e.y-t.y,a-e.y):Math.hypot(Math.max(t.x-e.x,0,e.x-r),Math.max(t.y-e.y,0,e.y-a))},U$=(e,t)=>t.reduce((r,a)=>{let i=jR(e,a);return!r||i<r.distance-.5||i<r.distance+.5&&a.width*a.height<r.node.width*r.node.height?{node:a,distance:i}:r},void 0)?.node,q$=(e,t,r)=>{let a=Array.from(t.querySelectorAll("g.pele-cluster.pele-state-composite[data-id]")).flatMap(f=>H$(f,t,!0,r.fontSize)??[]),i=Array.from(t.querySelectorAll("g.pele-nodes > g.pele-node[data-id], g.pele-nodes > g.pele-note[data-id]")).flatMap(f=>H$(f,t,!1,r.fontSize)??[]),n=[...a,...i],l=nr(t,"g.pele-edge-label[data-id]"),s=[],o=Array.from(t.querySelectorAll("g.pele-edges > g.pele-edge[data-id]")).flatMap(f=>{let p=f.getAttribute("data-id"),h=Gi(f,t);if(!h||h.route.length<2)return[];let g=qh(h.route),u=U$(g[0],n),m=U$(g[g.length-1],n);if(!u||!m)return[];let b=l.get(p)?.querySelector("text"),w=u===m;b&&w&&s.push(Yr(b,t,r.fontSize));let v=bi(f,"pele-note-edge"),k=g[0],O=g[g.length-1],R=b&&!w?yr(l.get(p),t):null;return[{id:p,start:u.id,end:m.id,text:b&&!w?ra(b).join(`
179
+ `):"",startX:k.x,startY:k.y,endX:O.x,endY:O.y,reflectionPoints:Gh(g),strokeColor:fr(f,"stroke"),strokeStyle:v?"dashed":void 0,isNoteEdge:v,...R?{labelPosition:As(g,{x:R.x+R.width/2,y:R.y+R.height/2})}:{}}]}),c=Array.from(t.querySelectorAll("path.pele-divider")).flatMap(f=>za(f,t,{strokeStyle:"dashed"}));return{type:"state",nodes:n,edges:o,lines:c,texts:s}};var j$="Excalifont, Xiaolai, sans-serif, Segoe UI Emoji",Ss,G$=(e,t)=>{if(Ss===void 0)try{Ss=typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1).getContext("2d"):typeof document<"u"?document.createElement("canvas").getContext("2d"):null}catch{Ss=null}return Ss?(Ss.font=`${t}px ${j$}`,Ss.measureText(e).width):null},Jh=1.5,Qh=(e,t)=>({nodeSpacing:e*Jh,rankSpacing:t*Jh}),X$=e=>({flowchart:{curve:e.curve??ro.flowchart.curve,...Qh(40,48)},class:Qh(40,56),er:Qh(48,64),state:Qh(40,44),sequence:{actorMargin:40*Jh,messageMargin:35*Jh}}),ku=e=>({fontSize:e.fontSize??20,responsive:!1,autoDirection:!1,config:X$(e)}),XR=new Set(["flowchart","sequence","class","er","state"]),Jl=(e,t)=>XR.has(e.type)?{...ku(t),fontFamily:j$}:ku(t),VR=(e,t)=>{if(!(e instanceof je)||e.code!=="syntax"||e.snippet.split(`
180
+ `)[0].trim())return e;let r=t.split(/\r?\n/),a=r.length-1;for(;a>=0&&!r[a].trim();)a--;let i=e.line-1-(r.length-1-a);if(a<0||i<1)return e;let n=r[a],l=`${n}
181
+ ${"-".repeat(n.length)}^`;return e.message=e.message.replace(`on line ${e.line}`,`on line ${i}`).replace(e.snippet,l),e.line=i,e.column=n.length+1,e.snippet=l,e},KR=async e=>{let t=null;try{t=pd(e)}catch{}await h$(t)},ZR=async(e,t)=>{try{return await KR(e),await f$(e,async r=>ud(r,{limit:t.maxTextSize??ro.maxTextSize,maxEdges:t.maxEdges??ro.maxEdges,config:X$(t)}))}catch(r){throw VR(r,e)}},QR=(e,t)=>{let{svg:r,width:a,height:i}=Mi(e,ku(t));return{type:"graphImage",mimeType:"image/svg+xml",dataURL:$$(r),width:a,height:i}};var V$=async(e,t={})=>{let r=await ZR(e,t);try{switch(r.type){case"flowchart":{let{svg:a}=Mi(r,Jl(r,t)),i=t.fontSize??20;return L$(r,$s(a),{fontSize:i,measureText:n=>G$(n,i)})}case"sequence":{let{svg:a}=Mi(r,Jl(r,t));return F$(r,$s(a),{fontSize:t.fontSize??20,measureText:G$})}case"class":{let{svg:a}=Mi(r,Jl(r,t));return W$(r,$s(a),{fontSize:t.fontSize??20})}case"er":{let{svg:a}=Mi(r,Jl(r,t));return Y$(r,$s(a),{fontSize:t.fontSize??20})}case"state":{let{svg:a}=Mi(r,Jl(r,t));return q$(r,$s(a),{fontSize:t.fontSize??20})}}}catch(a){console.error("Error processing Pele diagram:",a)}return QR(r,t)};var K$=(e,t={})=>V$(e,{fontSize:parseInt(t.themeVariables?.fontSize??"")||20,maxEdges:t.maxEdges,maxTextSize:t.maxTextSize,curve:t.flowchart?.curve});var Z$=async(e,t)=>{let r=parseInt(t?.themeVariables?.fontSize??"")||20,a=await K$(e,t);return a0(a,{fontSize:r})};var ek={flowchart:"flowchart",graph:"flowchart",sequenceDiagram:"sequence",classDiagram:"class",stateDiagram:"state","stateDiagram-v2":"state",erDiagram:"er"},tk=/^---\s*\n([\s\S]*?)\n---[^\n]*\n?/;function rk(e){return e.replace(tk,"").split(/\r?\n/).map(r=>r.trim()).find(r=>r&&!r.startsWith("%%"))?.split(/\s+/)[0]??""}var Mu=900,JR={flowchart:/(<?-->|<?==>|<?-\.->|---|-\.-|===|~~~|--[ox]|<-->)/g,sequence:/<{0,2}-{1,2}(?:>>|>|x|\))/g,class:/(<\|--|--\|>|<\|\.\.|\.\.\|>|\*--|--\*|o--|--o|<--|-->|<\.\.|\.\.>|--|\.\.)/g,state:/-->/g,er:/[|}o]{1,2}(?:--|\.\.)[|{o]{1,2}/g};function eL(e){let t=new Map,r,a=0,i={},n=JR[ek[rk(e)]??"flowchart"],l=e.match(tk);l&&(r=l[1].match(/^\s*title:\s*(.+)$/m)?.[1]?.trim());for(let s of e.slice(l?.[0].length??0).split(/\r?\n/)){let o=s.trim(),c=o.match(/^%%\s*([#>]|title\b)\s*(.*)$/);if(c){c[1]==="#"?i.chapter=c[2].trim():c[1]===">"?i.say=c[2].trim():r=c[2].trim();continue}if(o.startsWith("%%"))continue;let f=(o.match(n)??[]).length;f&&(i.chapter||i.say)&&(t.set(a,i),i={}),a+=f}return{notes:t,title:r}}var ak={};for(let[e,t]of Object.entries({rect:"rect proc process rectangle",rounded:"rounded event",stadium:"stadium pill terminal",cylinder:"cyl cylinder db database",circle:"circle circ",double:"dbl-circ double-circle",diamond:"diam diamond decision question",hexagon:"hex hexagon prepare","lean-r":"lean-r lean-right in-out","lean-l":"lean-l lean-left out-in","trap-b":"trap-b trapezoid priority","trap-t":"trap-t inv-trapezoid manual",flag:"odd asymmetric flag",subroutine:"fr-rect subproc subprocess subroutine framed-rectangle"}))for(let r of t.split(" "))ak[r]=e;function tL(e){let t=new Map,r=e.replace(/^---\s*\n[\s\S]*?\n---[^\n]*\n?/,"").split(/\r?\n/).filter(i=>!i.trim().startsWith("%%")).join(`
182
+ `),a=/(?:^|[\s&;>|])([A-Za-z0-9_][\w-]*)\s*(@\{[^}]*\}|\(\(\(|\(\[|\[\(|\[\[|\(\(|\{\{|\[\/|\[\\|>|\(|\[|\{)/gm;for(let i of r.matchAll(a)){let[,n,l]=i;if(/^(flowchart|graph|subgraph|end|click|style|classDef|class|linkStyle|direction)$/.test(n))continue;let s;if(l.startsWith("@"))s=ak[l.match(/shape:\s*([\w-]+)/)?.[1]??""];else if(l==="[/"||l==="[\\"){let c=r.slice((i.index??0)+i[0].length).match(/([/\\])\]/)?.[1];s=l==="[/"?c==="\\"?"trap-b":"lean-r":c==="/"?"trap-t":"lean-l"}else s={"(((":"double","([":"stadium","[(":"cylinder","[[":"subroutine","((":"circle","{{":"hexagon",">":"flag","(":"rounded","[":"rect","{":"diamond"}[l];s&&t.set(n,s)}return t}var Q$=new Set(["stadium","rounded","cylinder"]);function rL(e,t,r,a,i){let[n,l,s]=[t+a,r+i,r+i/2],o=(p,h,g,u,m,b,w=7)=>Array.from({length:w+1},(v,k)=>{let O=(m+(b-m)*k/w)*Math.PI/180;return[Et(p+g*Math.cos(O)),Et(h+u*Math.sin(O))]}),c=[[t,r],[n,r],[n,l],[t,l]],f=Math.min(i*.35,a*.2);switch(e){case"stadium":{let p=i/2;return{outline:[...o(t+p,s,p,p,90,270),...o(n-p,s,p,p,-90,90)],inner:[]}}case"rounded":{let p=Math.min(i,a)*.22;return{outline:[...o(t+p,r+p,p,p,180,270,3),...o(n-p,r+p,p,p,270,360,3),...o(n-p,l-p,p,p,0,90,3),...o(t+p,l-p,p,p,90,180,3)],inner:[]}}case"cylinder":{let p=Math.min(i*.14,12);return{outline:[...o(t+a/2,l-p,a/2,p,180,0,9),...o(t+a/2,r+p,a/2,p,0,-180,9)],inner:[o(t+a/2,r+p,a/2,p,180,0,9)]}}case"hexagon":return{outline:[[t+f,r],[n-f,r],[n,s],[n-f,l],[t+f,l],[t,s]],inner:[]};case"lean-r":return{outline:[[t+f,r],[n,r],[n-f,l],[t,l]],inner:[]};case"lean-l":return{outline:[[t,r],[n-f,r],[n,l],[t+f,l]],inner:[]};case"trap-b":return{outline:[[t+f,r],[n-f,r],[n,l],[t,l]],inner:[]};case"trap-t":return{outline:[[t,r],[n,r],[n-f,l],[t+f,l]],inner:[]};case"flag":return{outline:[[t,r],[n,r],[n,l],[t,l],[t+i/3,s]],inner:[]};case"subroutine":{let p=Math.min(10,a*.08);return{outline:c,inner:[[[t+p,r],[t+p,l]],[[n-p,r],[n-p,l]]]}}case"diamond":return{outline:[[t+a/2,r],[n,s],[t+a/2,l],[t,s]],inner:[]};default:return{outline:c,inner:[]}}}var aL={cardinality_exactly_one:"1",cardinality_one_or_many:"1..n",cardinality_zero_or_many:"0..n",cardinality_zero_or_one:"0..1",cardinality_many:"n",cardinality_one:"1"},_n=e=>(typeof e.label=="string"?e.label:e.label?.text)??"",J$=e=>/^[A-Za-z_][\w-]*$/.test(e)?e:`n_${e.replace(/[^\w-]/g,"_")}`,Et=e=>Math.round(e*10)/10;async function ik(e,t,r={}){let a=rk(e),i=ek[a],n=()=>new Error(`chalk-talk draws Mermaid flowchart, sequence, class, state and ER diagrams; not \xAB${a}\xBB yet.`);if(!i)throw n();let l=(await t(e)).elements;if(l.some(N=>N.type==="image"))throw n();let{notes:s,title:o}=eL(e),c=i==="flowchart"?tL(e):new Map,f=l.filter(N=>N.type==="arrow"),p=new Map(l.filter(N=>N.id?.endsWith("__title")).map(N=>[N.id.slice(0,-7),_n(N)])),h=l.filter(N=>N.type!=="arrow"&&!N.id?.endsWith("__title")),g=h.filter(N=>N.type==="rectangle"||N.type==="ellipse"||N.type==="diamond");if(!g.length)throw new Error("This Mermaid diagram has no shapes chalk-talk can draw.");let u=N=>N.points?.length?N.points.map(F=>[N.x+F[0],N.y+F[1]]):[[N.x,N.y],[N.x+(N.width??0),N.y+(N.height??0)]],m=[...h,...f].flatMap(u),b=m.map(N=>N[0]),w=m.map(N=>N[1]),[v,k,O,R]=[Math.min(...b),Math.max(...b),Math.min(...w),Math.max(...w)],L=o?100:50,P=Math.min((Mu-120)/Math.max(1,k-v),(720-L-50)/Math.max(1,R-O),2.4),B=Math.round(Math.max(300,Math.min(720,(R-O)*P+L+50))),G=(Mu-(k-v)*P)/2-v*P,C=(N,F)=>[Et(G+N*P),Et(L+(F-O)*P)],Z=Math.round(Math.max(18,Math.min(30,15*P))),ee=N=>N.strokeStyle==="dashed"||N.strokeStyle==="dotted"?{style:{dashed:!0}}:{},H=[];o&&H.push({type:"text",at:[40,60],text:o,size:36});let Y=new Set,_=g.filter(N=>N.id&&p.has(N.id)),S=N=>{let[F,U]=C(N.x,N.y),[D,I]=[Et((N.width??0)*P),Et((N.height??0)*P)],z=N.id?{id:J$(N.id)}:{},q=_n(N),j=N.id&&c.get(N.id)||(N.type==="ellipse"?"circle":N.type==="diamond"?"diamond":"rect"),Q=(se,oe={})=>({type:"ellipse",center:[Et(F+D/2),Et(U+I/2)],rx:Et(D/2-se),ry:Et(I/2-se),...oe}),K;if(D<2||I<2)K=[];else if(j==="circle")K=[Q(0,{...z,...ee(N)})];else if(j==="double")K=[Q(0,z),Q(Math.min(5,D/8))];else{let{outline:se,inner:oe}=rL(j,F,U,D,I),ae=se.map(([J,re])=>[Et(J),Et(re)]),ne=J=>J.map(([re,fe])=>[Et(re),Et(fe)]);K=[Q$.has(j)?{type:"curve",points:[...ae,ae[0]],...z}:{type:"polygon",points:ae,...z,...ee(N)},...oe.map(J=>Q$.has(j)?{type:"curve",points:ne(J)}:{type:"polyline",points:ne(J)})]}if(!q)return K;let W=j==="cylinder"?Math.min(I*.14,12)/2:0;if(!K.length)return[{type:"text",at:[Et(F+6),Et(U+Z*.9)],text:q,size:Math.round(Z*.75),anchor:"start"}];let X=Z,te=typeof N.label=="object"&&N.label.verticalAlign==="top"?U+6*P+X*.9:U+I/2+W+X*.35;return[...K,{type:"text",at:[Et(F+D/2),Et(te)],text:q,size:X,anchor:"middle"}]},$=N=>{let F=(N.points??[]).map(q=>C(N.x+q[0],N.y+q[1]));if(F.length<2)return[];let U=q=>q?.startsWith("cardinality_")?aL[q]??"":void 0;if(U(N.startArrowhead)!==void 0||U(N.endArrowhead)!==void 0){let q=Math.round(Z*.75),j=(Q,K,W)=>{if(!W)return[];let[X,te]=[K[0]-Q[0],K[1]-Q[1]],se=Math.hypot(X,te)||1,[oe,ae]=[X/se,te/se],[ne,J]=[ae,-oe],re=Math.abs(ne)<.3?"middle":ne>0?"start":"end";return[{type:"text",at:[Et(Q[0]+oe*q*1.3+ne*q*.5),Et(Q[1]+ae*q*1.3+J*q*.9+q*.35)],text:W,size:q,anchor:re}]};return[{type:"polyline",points:F,...ee(N)},...j(F[0],F[1],U(N.startArrowhead)??""),...j(F[F.length-1],F[F.length-2],U(N.endArrowhead)??""),...y(F,_n(N))]}let D=N.endArrowhead===void 0?"arrow":N.endArrowhead;!D&&N.startArrowhead&&(F=[...F].reverse());let I=[];return!!(D||N.startArrowhead)?(F.length>2&&I.push({type:"polyline",points:F.slice(0,-1),...ee(N)}),I.push({type:"arrow",from:F[F.length-2],to:F[F.length-1],...ee(N)})):I.push({type:"polyline",points:F,...ee(N)}),[...I,...y(F,_n(N))]},y=(N,F)=>{let U=[];if(F){let D=Math.round(Z*.8),I=X=>{let[te,se]=[Math.abs(N[X+1][0]-N[X][0]),Math.abs(N[X+1][1]-N[X][1])];return Math.hypot(te,se)*(Math.min(te,se)<2?2:1)},z=0;for(let X=1;X<N.length-1;X++)I(X)>I(z)&&(z=X);let[q,j]=[N[z],N[z+1]],[Q,K]=[(q[0]+j[0])/2,(q[1]+j[1])/2],W=Math.abs(j[0]-q[0])>=Math.abs(j[1]-q[1]);U.push(W?{type:"text",at:[Et(Q),Et(K-D*.55)],text:F,size:D,anchor:"middle"}:{type:"text",at:[Et(Q+D*.5),Et(K+D*.35)],text:F,size:D,anchor:"start"})}return U},E=N=>{if(!N||Y.has(N))return[];if(Y.add(N),N.type==="arrow")return $(N);if(N.type==="line"){let I=(N.points??[]).map(z=>C(N.x+z[0],N.y+z[1]));return I.length>=2?[{type:"polyline",points:I,...ee(N)}]:[]}if(N.type==="text"){let I=N.text??_n(N);if(!I.trim())return[];let z=Math.round(Math.max(14,Math.min(Z,(N.fontSize??16)*P*.95))),[q,j]=C(N.x,N.y),Q=(N.width??0)*P,[K,W]=N.textAlign==="left"?[q,"start"]:N.textAlign==="right"?[q+Q,"end"]:[q+Q/2,"middle"];return[{type:"text",at:[Et(K),Et(j+(N.height??0)*P/2+z*.35)],text:I,size:z,anchor:W}]}let F=S(N),[U,D]=[N.x+(N.width??0),N.y+(N.height??0)];for(let I of h){if(Y.has(I)||I.type!=="line"&&I.type!=="text")continue;u(I).every(([q,j])=>q>=N.x-1&&q<=U+1&&j>=N.y-1&&j<=D+1)&&F.push(...E(I))}return F},x=N=>N?g.find(F=>F.id===N):void 0;for(let N of _){let[F,U]=C(N.x,N.y),[D,I]=[Et((N.width??0)*P),Et((N.height??0)*P)];Y.add(N),H.push({type:"polygon",points:[[F,U],[Et(F+D),U],[Et(F+D),Et(U+I)],[F,Et(U+I)]],id:J$(N.id),style:{dashed:!0,color:"#8C8578"}}),p.get(N.id)&&H.push({type:"text",at:[Et(F+10),Et(U+Z+6)],text:p.get(N.id),size:Math.round(Z*.85),style:{color:"#5E5A52"}})}let T=H.length,A=(N,F)=>{let U=s.get(F);U&&N.length&&Object.assign(N[0],U.chapter?{chapter:U.chapter}:{},U.say?{say:U.say}:{}),H.push(...N)};if(i==="sequence"){let N=g.filter(K=>((K.width??0)*P<2||(K.height??0)*P<2)&&_n(K)).flatMap(S),U=[...f.flatMap(K=>y((K.points??[]).map(W=>C(K.x+W[0],K.y+W[1])),_n(K))),...N].map(K=>{let[W,X]=K.at,[te,se]=[K.size,String(K.text).length],oe=se*te*.48,ae=K.anchor==="middle"?W-oe/2:K.anchor==="end"?W-oe:W;return{x0:ae-4,x1:ae+oe+4,y0:X-te*.9,y1:X+te*.3}}),D=f.map(K=>C(K.x,K.y)[1]).sort((K,W)=>K-W),I=[];for(let K of h.filter(W=>W.type==="line"&&(W.points?.length??0)===2&&Math.abs(W.width??0)<1)){let[[W,X],[,te]]=(K.points??[]).map(J=>C(K.x+J[0],K.y+J[1]));Y.add(K);let[se,oe]=[Math.min(X,te),Math.max(X,te)],ae=U.filter(J=>W>J.x0&&W<J.x1).map(J=>[J.y0,J.y1]).sort((J,re)=>J[0]-re[0]),ne=[se,...D.filter(J=>J>se+1&&J<oe-1),oe];for(let J=0;J<ne.length-1;J++){let re=[],fe=ne[J];for(let[ye,le]of ae)le<=fe||ye>=ne[J+1]||(ye>fe&&re.push([fe,ye]),fe=Math.max(fe,le));fe<ne[J+1]&&re.push([fe,ne[J+1]]),I.push({y:ne[J],steps:re.map(([ye,le])=>({type:"polyline",points:[[Et(W),Et(ye)],[Et(W),Et(le)]],...ee(K)}))})}}let z=K=>C(0,Math.min(K.y,K.y+(K.height??0)))[1],q=[...[...h,...f].filter(K=>!Y.has(K)).map(K=>({y:z(K),x:K.x,element:K})),...I.map(K=>({y:K.y+.01,x:0,steps:K.steps}))].sort((K,W)=>K.y-W.y||K.x-W.x),j=0,Q=T;for(let K of q){if(K.steps){H.push(...K.steps);continue}let W=K.element;if(Y.has(W))continue;if(W.type!=="arrow"){H.push(...E(W));continue}let X=E(W),te=s.get(j++),se=H.length>Q?H[Q]:X[0];te&&se&&Object.assign(se,te.chapter?{chapter:te.chapter}:{},te.say?{say:te.say}:{}),H.push(...X),Q=H.length}}else{f.forEach((N,F)=>A([...E(x(N.start?.id)),...E(N),...E(x(N.end?.id))],F));for(let N of g)H.push(...E(N));for(let N of[...h].sort((F,U)=>F.y-U.y))H.push(...E(N))}let M=H.findIndex(N=>N.chapter);if(M>0&&M===T){let{chapter:N,say:F}=H[M];Object.assign(H[0],{chapter:N},F?{say:F}:{}),delete H[M].chapter,delete H[M].say}return{id:(o??"mermaid").toLowerCase().normalize("NFD").replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,60)||"mermaid",title:o??"Mermaid",width:Mu,height:B,background:"plain",...r.locale?{locale:r.locale}:{},steps:H}}var nk=["and","or","not"];var Au=["person","person-pointing","person-sitting","house","car","bus","coin","phone","document","server","bank","cloud","queue","desk","computer","clock","lock","money-arrow","tree","school","hospital","factory","truck","cart","safe","bulb","gear","database","robot"],sk={pessoa:"person","pessoa-apontando":"person-pointing","pessoa-sentada":"person-sitting",casa:"house",carro:"car",onibus:"bus",moeda:"coin",celular:"phone",documento:"document",servidor:"server",banco:"bank",nuvem:"cloud",fila:"queue",mesa:"desk",computador:"computer",relogio:"clock",cadeado:"lock","seta-dinheiro":"money-arrow"},ok=e=>Au.includes(e)?e:typeof e=="string"&&Object.hasOwn(sk,e)?sk[e]:void 0;var ck=e=>ok(e)!==void 0,Ke={skin:"#E8C6A5",shirt:"#A9BCC3",wood:"#D8C29C",gold:"#F2C94C",paper:"#FFFFFF",screen:"#DCE8F0",device:"#5B6B7C",roof:"#D9785F",wall:"#F3E3C3",car:"#7FA7C9",bus:"#E9C46A",green:"#7DBE8A",dark:"#4A4A4A",metal:"#C9D3DD"},Tt=(e,t,r,a,i,n)=>({kind:"polygon",points:[[e,t],[e+r,t],[e+r,t+a],[e,t+a]],fill:i,main:n}),Lt=(...e)=>({kind:"polyline",points:e});function hk(e){return[{kind:"polygon",points:[[-.15,-.72],[.15,-.72],[.19,-.38],[-.19,-.38]],fill:Ke.shirt,main:!0},{kind:"circle",c:[0,-.87],r:.11,fill:Ke.skin},...e,Lt([-.08,-.38],[-.1,0]),Lt([.08,-.38],[.1,0])]}var lk=hk([Lt([-.15,-.7],[-.25,-.42]),Lt([.15,-.7],[.25,-.42])]);function iL(e,t,r){let a=([i,n])=>[r+i*t,n*t];return e.map(i=>i.kind==="circle"?{...i,c:a(i.c),r:i.r*t}:{...i,points:i.points.map(a)})}function nL(){let e=[[-.28,-.3,.18],[-.06,-.45,.25],[.2,-.4,.21],[.37,-.27,.13]],t=[];for(let r=0;r<=24;r++){let a=-.46+.96*r/24,i=e.filter(([n,,l])=>Math.abs(a-n)<=l).map(([n,l,s])=>l-Math.sqrt(Math.max(0,s*s-(a-n)**2)));i.length&&t.push([a,Math.min(...i)])}return[...t,[.42,-.12],[-.4,-.12]]}var oW={person:lk,"person-pointing":hk([Lt([-.15,-.7],[-.25,-.42]),Lt([.15,-.69],[.47,-.73])]),"person-sitting":[Lt([-.3,-.8],[-.27,-.4]),Lt([-.32,-.4],[.2,-.4]),Lt([-.27,-.4],[-.27,0]),Lt([.16,-.4],[.16,0]),{kind:"polygon",points:[[-.22,-.77],[.04,-.77],[.06,-.44],[-.22,-.44]],fill:Ke.shirt,main:!0},{kind:"circle",c:[-.08,-.9],r:.1,fill:Ke.skin},Lt([-.1,-.44],[.3,-.44],[.32,0]),Lt([0,-.74],[.18,-.55],[.3,-.58])],house:[Tt(-.4,-.6,.8,.6,Ke.wall,!0),{kind:"polygon",points:[[-.5,-.58],[0,-1],[.5,-.58]],fill:Ke.roof},Tt(-.08,-.32,.16,.32,Ke.wood),Tt(.16,-.46,.16,.14,Ke.screen)],car:[{kind:"polygon",fill:Ke.car,main:!0,points:[[-.5,-.14],[-.5,-.32],[-.3,-.36],[-.18,-.56],[.2,-.56],[.32,-.36],[.5,-.32],[.5,-.14]]},{kind:"polygon",points:[[-.14,-.51],[.17,-.51],[.25,-.37],[-.22,-.37]],fill:Ke.screen},{kind:"circle",c:[-.28,-.12],r:.1,fill:Ke.dark},{kind:"circle",c:[.28,-.12],r:.1,fill:Ke.dark}],bus:[Tt(-.5,-.66,1,.52,Ke.bus,!0),...[-.42,-.21,0,.21].map(e=>Tt(e,-.6,.15,.16,Ke.screen)),Lt([-.5,-.3],[.5,-.3]),{kind:"circle",c:[-.3,-.12],r:.1,fill:Ke.dark},{kind:"circle",c:[.3,-.12],r:.1,fill:Ke.dark}],coin:[{kind:"circle",c:[0,-.42],r:.4,fill:Ke.gold,main:!0},{kind:"circle",c:[0,-.42],r:.3},{kind:"curve",points:[[.1,-.56],[-.08,-.57],[-.09,-.46],[.08,-.39],[.08,-.29],[-.11,-.28]]},Lt([0,-.64],[0,-.2])],phone:[Tt(-.26,-1,.52,1,Ke.device,!0),Tt(-.2,-.92,.4,.76,Ke.screen),{kind:"circle",c:[0,-.08],r:.035,fill:Ke.paper}],document:[{kind:"polygon",points:[[-.36,-1],[.16,-1],[.36,-.8],[.36,0],[-.36,0]],fill:Ke.paper,main:!0},Lt([.16,-1],[.16,-.8],[.36,-.8]),...[-.66,-.5,-.34,-.18].map(e=>Lt([-.22,e],[.22,e]))],server:[-1,-.66,-.32].flatMap(e=>[Tt(-.36,e,.72,.3,Ke.metal,!0),Lt([-.26,e+.15],[.06,e+.15]),{kind:"circle",c:[.22,e+.15],r:.035,fill:Ke.green}]),bank:[{kind:"polygon",points:[[-.5,-.74],[0,-1],[.5,-.74]],fill:Ke.wall,main:!0},Tt(-.45,-.74,.9,.08,Ke.wall),...[-.33,-.11,.11,.33].map(e=>Tt(e-.04,-.66,.08,.56,Ke.paper)),Tt(-.5,-.1,1,.1,Ke.wall)],cloud:[{kind:"polygon",points:nL(),fill:Ke.paper,main:!0}],queue:[-.32,0,.32].flatMap(e=>iL(lk,.7,e)),desk:[Tt(-.5,-.5,1,.07,Ke.wood,!0),Lt([-.42,-.43],[-.42,0]),Lt([.42,-.43],[.42,0])],computer:[Tt(-.45,-1,.9,.6,Ke.device,!0),Tt(-.39,-.94,.78,.48,Ke.screen),{kind:"polygon",points:[[-.06,-.4],[.06,-.4],[.1,-.1],[-.1,-.1]],fill:Ke.device},Tt(-.25,-.1,.5,.08,Ke.device)],clock:[{kind:"circle",c:[0,-.48],r:.45,fill:Ke.paper,main:!0},...[[0,-.9,0,-.82],[.42,-.48,.34,-.48],[0,-.06,0,-.14],[-.42,-.48,-.34,-.48]].map(([e,t,r,a])=>Lt([e,t],[r,a])),Lt([0,-.48],[0,-.78]),Lt([0,-.48],[.2,-.48])],lock:[{kind:"curve",points:[[-.22,-.52],[-.22,-.76],[0,-.96],[.22,-.76],[.22,-.52]]},Tt(-.36,-.54,.72,.54,Ke.bus,!0),{kind:"circle",c:[0,-.32],r:.06,fill:Ke.dark},Lt([0,-.28],[0,-.14])],"money-arrow":[{kind:"polygon",fill:Ke.green,main:!0,points:[[-.5,-.4],[.12,-.4],[.12,-.56],[.5,-.3],[.12,-.04],[.12,-.2],[-.5,-.2]]},{kind:"circle",c:[-.2,-.3],r:.16,fill:Ke.gold},Lt([-.2,-.4],[-.2,-.2])],tree:[Tt(-.07,-.36,.14,.36,Ke.wood),{kind:"circle",c:[0,-.64],r:.3,fill:Ke.green,main:!0}],school:[Tt(-.45,-.6,.9,.6,Ke.wall,!0),{kind:"polygon",points:[[-.5,-.6],[0,-.82],[.5,-.6]],fill:Ke.roof},Tt(-.08,-.28,.16,.28,Ke.wood),Tt(-.36,-.48,.16,.12,Ke.screen),Tt(.2,-.48,.16,.12,Ke.screen),Lt([0,-.82],[0,-1]),{kind:"polygon",points:[[0,-1],[.17,-.95],[0,-.9]],fill:Ke.roof}],hospital:[Tt(-.4,-.8,.8,.8,Ke.paper,!0),Tt(-.045,-.7,.09,.26,"#C8442C"),Tt(-.13,-.615,.26,.09,"#C8442C"),Tt(-.1,-.24,.2,.24,Ke.metal)],factory:[{kind:"polygon",points:[[-.5,0],[-.5,-.5],[-.25,-.65],[-.25,-.5],[0,-.65],[0,-.5],[.25,-.65],[.25,-.5],[.5,-.5],[.5,0]],fill:Ke.wall,main:!0},Tt(.3,-.95,.12,.3,Ke.dark),Tt(-.38,-.32,.16,.12,Ke.screen),Tt(-.08,-.32,.16,.12,Ke.screen),Tt(.22,-.32,.16,.12,Ke.screen)],truck:[Tt(-.5,-.62,.62,.46,Ke.metal,!0),{kind:"polygon",points:[[.12,-.16],[.12,-.5],[.34,-.5],[.48,-.32],[.48,-.16]],fill:Ke.bus},{kind:"polygon",points:[[.18,-.46],[.32,-.46],[.42,-.33],[.18,-.33]],fill:Ke.screen},{kind:"circle",c:[-.3,-.1],r:.1,fill:Ke.dark},{kind:"circle",c:[.3,-.1],r:.1,fill:Ke.dark}],cart:[Lt([-.48,-.78],[-.4,-.62]),{kind:"polygon",points:[[-.4,-.62],[.42,-.62],[.32,-.26],[-.3,-.26]],fill:Ke.metal,main:!0},Lt([-.3,-.26],[-.3,-.14],[.32,-.14]),{kind:"circle",c:[-.22,-.07],r:.06,fill:Ke.dark},{kind:"circle",c:[.24,-.07],r:.06,fill:Ke.dark}],safe:[Tt(-.4,-.82,.8,.82,Ke.device,!0),Tt(-.3,-.72,.6,.62,Ke.metal),{kind:"circle",c:[0,-.41],r:.13,fill:Ke.paper},Lt([0,-.41],[.08,-.47])],bulb:[{kind:"circle",c:[0,-.62],r:.3,fill:Ke.gold,main:!0},Tt(-.13,-.33,.26,.2,Ke.metal),{kind:"curve",points:[[-.09,-.52],[0,-.66],[.09,-.52]]},Lt([-.08,-.08],[.08,-.08])],gear:[{kind:"polygon",points:[[.42,-.5],[.296,-.378],[.297,-.203],[.122,-.204],[0,-.08],[-.122,-.204],[-.297,-.203],[-.296,-.378],[-.42,-.5],[-.296,-.622],[-.297,-.797],[-.122,-.796],[-0,-.92],[.122,-.796],[.297,-.797],[.296,-.622]],fill:Ke.metal,main:!0},{kind:"circle",c:[0,-.5],r:.12,fill:Ke.paper}],database:[{kind:"polygon",points:[[-.35,-.8],[.35,-.8],[.35,-.16],[-.35,-.16]],fill:Ke.screen,main:!0},{kind:"polygon",points:[[.35,-.8],[.303,-.755],[.175,-.722],[0,-.71],[-.175,-.722],[-.303,-.755],[-.35,-.8],[-.303,-.845],[-.175,-.878],[-0,-.89],[.175,-.878],[.303,-.845]],fill:Ke.metal},{kind:"curve",points:[[-.35,-.16],[0,-.06],[.35,-.16]]},{kind:"curve",points:[[-.35,-.58],[0,-.48],[.35,-.58]]},{kind:"curve",points:[[-.35,-.37],[0,-.27],[.35,-.37]]}],robot:[Lt([0,-.95],[0,-1]),Tt(-.22,-.95,.44,.3,Ke.metal),{kind:"circle",c:[-.09,-.81],r:.045,fill:Ke.screen},{kind:"circle",c:[.09,-.81],r:.045,fill:Ke.screen},Tt(-.28,-.62,.56,.42,Ke.metal,!0),Lt([-.28,-.55],[-.42,-.35]),Lt([.28,-.55],[.42,-.35]),Tt(-.2,-.2,.12,.2,Ke.device),Tt(.08,-.2,.12,.2,Ke.device)]},dk=["happy","sad","surprised","worried","idea"],sL={person:[0,-.87,.11],"person-pointing":[0,-.87,.11],"person-sitting":[-.08,-.9,.1]},fk=e=>{let t=ok(e);return!!t&&t in sL};var lL=["card","line","arrow","polyline","polygon","curve","circle","ellipse","plot","text","highlight","pause","prop","repeat","when","move","link","counter","row","column","grid","axis","timeline","balloon","brace","note","table","bars"],ed=["text","prop","card","counter","circle","ellipse"],pk=["row","column","grid"],oL=50;function Or(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t}: expected an object.`)}function Jt(e,t){if(typeof e!="string"||!e.trim()||e.length>2e3)throw new Error(`${t}: expected text of 1 to 2000 characters.`)}function Pt(e,t,r=-1e4,a=1e4){if(typeof e!="number"||!Number.isFinite(e)||e<r||e>a)throw new Error(`${t}: expected a number between ${r} and ${a}.`)}function aa(e,t){if(typeof e=="string"){if(Jt(e,t),e.length>300)throw new Error(`${t}: expression too long.`)}else Pt(e,t)}function Hr(e,t){if(!Array.isArray(e)||e.length!==2)throw new Error(`${t}: expected [x, y].`);e.forEach((r,a)=>aa(r,`${t}[${a}]`))}function $i(e,t){e!==void 0&&Jt(e,t)}function $a(e,t,r){if(e!==void 0&&(typeof e!="string"||!t.includes(e)))throw new Error(`${r}: choose one of ${t.join(", ")}.`)}function td(e){if(!/^[A-Za-z_][A-Za-z_0-9]*$/.test(e)||["__proto__","constructor","prototype",...nk].includes(e))throw new Error(`Invalid variable name: "${e}".`)}var eo=(e,t)=>t.includes("{")||e.exact.has(t)||[...e.repeated].some(r=>t.startsWith(`${r}-`)&&/^\d+$/.test(t.slice(r.length+1)));function Ts(e,t,r,a){a&&e[t]===void 0&&(e[t]=[0,0]),Hr(e[t],`${r}.${t}`)}function rd(e,t,r,a,i=!1){if(Or(e,t),++r.count>500)throw new Error(`${t}: a recipe draws at most 500 steps, counting those inside repeat and when.`);if(a){for(let s of["chapter","say","duration"])if(e[s]!==void 0)throw new Error(`${t}.${s}: put it on the ${a} step itself, not on a step inside it.`);if(e.type==="pause")throw new Error(`${t}: a pause cannot go inside ${a}.`);if(e.type==="repeat"&&a==="repeat")throw new Error(`${t}: a repeat cannot go inside another repeat.`);if(pk.includes(a)&&e.place!==void 0)throw new Error(`${t}.place: the ${a} places the steps inside it.`)}if(!lL.includes(e.type))throw new Error(`${t}: unknown type "${e.type}".`);for(let s of["id","say","chapter"])$i(e[s],`${t}.${s}`);if(e.duration!==void 0&&Pt(e.duration,`${t}.duration`,0,3e4),e.nudge!==void 0){if(["pause","move","link"].includes(e.type))throw new Error(`${t}.nudge: a ${e.type} has no place of its own to move.`);if(!Array.isArray(e.nudge)||e.nudge.length!==2)throw new Error(`${t}.nudge: use [dx, dy].`);e.nudge.forEach((s,o)=>Pt(s,`${t}.nudge[${o}]`,-900,900))}let n=a!==null&&pk.includes(a)||i;if(e.place!==void 0){if(!ed.includes(e.type))throw new Error(`${t}.place: only ${ed.join(", ")} can be placed.`);if(Or(e.place,`${t}.place`),Jt(e.place.to,`${t}.place.to`),!eo(r,String(e.place.to)))throw new Error(`${t}.place.to: no earlier step has the id "${e.place.to}".`);if(!["below","above","left","right"].includes(e.place.side))throw new Error(`${t}.place.side: choose one of below, above, left, right.`);e.place.gap!==void 0&&Pt(e.place.gap,`${t}.place.gap`,-200,400),$a(e.place.align,["center","start","end"],`${t}.place.align`)}let l=n||e.place!==void 0;if(e.style!==void 0){Or(e.style,`${t}.style`);for(let s of["color","fill"]){let o=e.style[s];if(o!==void 0&&(typeof o!="string"||!/^(#[\da-f]{3,8}|[a-z]+)$/i.test(o)))throw new Error(`${t}.style.${s}: use a hex colour or a colour name, no URLs.`)}for(let s of["width","roughness","bowing"])e.style[s]!==void 0&&Pt(e.style[s],`${t}.style.${s}`,0,20);if(e.style.opacity!==void 0&&Pt(e.style.opacity,`${t}.style.opacity`,0,1),e.style.dashed!==void 0&&typeof e.style.dashed!="boolean")throw new Error(`${t}: dashed must be a boolean.`);$a(e.style.fillStyle,["hachure","solid","zigzag","cross-hatch","dots"],`${t}.style.fillStyle`)}switch(e.type){case"line":case"arrow":case"highlight":Hr(e.from,`${t}.from`),Hr(e.to,`${t}.to`),e.thickness!==void 0&&Pt(e.thickness,`${t}.thickness`,1,200);break;case"polyline":case"polygon":case"curve":if(!Array.isArray(e.points)||e.points.length<(e.type==="polygon"?3:2)||e.points.length>500)throw new Error(`${t}: points needs ${e.type==="polygon"?3:2} to 500 points.`);e.points.forEach((s,o)=>Hr(s,`${t}.points[${o}]`));break;case"circle":case"ellipse":Ts(e,"center",t,l);for(let s of e.type==="circle"?["r"]:["rx","ry"])aa(e[s],`${t}.${s}`),typeof e[s]=="number"&&Pt(e[s],`${t}.${s}`,0);break;case"text":Ts(e,"at",t,l),Jt(e.text,`${t}.text`),e.size!==void 0&&Pt(e.size,`${t}.size`,1,200),e.rotate!==void 0&&Pt(e.rotate,`${t}.rotate`,-360,360),$a(e.font,["hand","body"],`${t}.font`),$a(e.anchor,["start","middle","end"],`${t}.anchor`);break;case"card":Ts(e,"at",t,l),aa(e.w,`${t}.w`),aa(e.h,`${t}.h`);for(let s of["w","h"])typeof e[s]=="number"&&Pt(e[s],`${t}.${s}`,40);if(Jt(e.title,`${t}.title`),e.lines!==void 0){if(!Array.isArray(e.lines)||e.lines.length>6)throw new Error(`${t}: at most 6 lines per card.`);e.lines.forEach((s,o)=>Jt(s,`${t}.lines[${o}]`))}break;case"plot":Jt(e.fn,`${t}.fn`),e.var!==void 0&&(Jt(e.var,`${t}.var`),td(String(e.var))),Hr(e.domain,`${t}.domain`),Hr(e.range,`${t}.range`),Or(e.box,`${t}.box`);for(let s of["x","y","w","h"])aa(e.box[s],`${t}.box.${s}`);if(e.samples!==void 0&&(Pt(e.samples,`${t}.samples`,2,1e3),!Number.isInteger(e.samples)))throw new Error(`${t}: samples must be an integer.`);break;case"pause":Pt(e.ms,`${t}.ms`,0,3e4),$i(e.ask,`${t}.ask`);break;case"prop":if(!ck(e.name))throw new Error(`${t}.name: unknown prop "${String(e.name)}"; use one of ${Au.join(", ")}.`);if(Ts(e,"at",t,l),e.size!==void 0&&(aa(e.size,`${t}.size`),typeof e.size=="number"&&Pt(e.size,`${t}.size`,10,1e3)),$i(e.label,`${t}.label`),e.flip!==void 0&&typeof e.flip!="boolean")throw new Error(`${t}.flip: expected true or false.`);if(e.mood!==void 0){if(!fk(e.name))throw new Error(`${t}.mood: only a person (person, person-pointing, person-sitting) has a face.`);$a(e.mood,dk,`${t}.mood`)}break;case"repeat":if(aa(e.times,`${t}.times`),typeof e.times=="number"&&(Pt(e.times,`${t}.times`,0,oL),!Number.isInteger(e.times)))throw new Error(`${t}.times: expected a whole number.`);rd(e.step,`${t}.step`,r,"repeat",n);break;case"when":if(aa(e.if,`${t}.if`),!Array.isArray(e.steps)||e.steps.length===0||e.steps.length>50)throw new Error(`${t}.steps: expected 1 to 50 steps.`);e.steps.forEach((s,o)=>rd(s,`${t}.steps[${o}]`,r,a??"when"));break;case"move":if(Jt(e.target,`${t}.target`),!eo(r,String(e.target)))throw new Error(`${t}.target: no earlier step has the id "${e.target}".`);Hr(e.to,`${t}.to`),$a(e.along,["line","curve"],`${t}.along`),e.ms!==void 0&&Pt(e.ms,`${t}.ms`,200,5e3);break;case"link":for(let s of["from","to"])if(Jt(e[s],`${t}.${s}`),!eo(r,String(e[s])))throw new Error(`${t}.${s}: no earlier step has the id "${e[s]}".`);$i(e.label,`${t}.label`);break;case"counter":if(Ts(e,"at",t,l),aa(e.value,`${t}.value`),e.format!==void 0&&(Jt(e.format,`${t}.format`),!String(e.format).includes("{v")))throw new Error(`${t}.format: show the number as {v}, e.g. "R$ {v:0}".`);e.size!==void 0&&Pt(e.size,`${t}.size`,1,200),$a(e.anchor,["start","middle","end"],`${t}.anchor`);break;case"row":case"column":case"grid":if(n)throw new Error(`${t}: a ${e.type} cannot go inside another ${a}.`);if(Ts(e,"at",t,!1),e.gap!==void 0&&Pt(e.gap,`${t}.gap`,0,400),e.type==="grid"){if(Pt(e.columns,`${t}.columns`,1,12),!Number.isInteger(e.columns))throw new Error(`${t}.columns: expected a whole number.`)}else $a(e.align,["center","start","end"],`${t}.align`);if(!Array.isArray(e.steps)||e.steps.length===0||e.steps.length>50)throw new Error(`${t}.steps: expected 1 to 50 steps.`);e.steps.forEach((s,o)=>{Or(s,`${t}.steps[${o}]`);let c=s.type==="repeat"?s.step?.type:s.type;if(!ed.includes(c))throw new Error(`${t}.steps[${o}]: a ${e.type} holds only ${ed.join(", ")} (or a repeat of one).`);rd(s,`${t}.steps[${o}]`,r,e.type)});break;case"axis":case"timeline":if(Hr(e.from,`${t}.from`),Hr(e.to,`${t}.to`),Hr(e.domain,`${t}.domain`),e.type==="axis"){if(e.ticks!==void 0){if(Array.isArray(e.ticks)){if(e.ticks.length>30)throw new Error(`${t}.ticks: at most 30 marks.`);e.ticks.forEach((s,o)=>Pt(s,`${t}.ticks[${o}]`))}else if(Pt(e.ticks,`${t}.ticks`,0,30),!Number.isInteger(e.ticks))throw new Error(`${t}.ticks: expected a whole number.`)}if($i(e.label,`${t}.label`),e.format!==void 0&&(Jt(e.format,`${t}.format`),!String(e.format).includes("{v")))throw new Error(`${t}.format: show the number as {v}, e.g. "{v} km".`)}else{if(!Array.isArray(e.marks)||e.marks.length===0||e.marks.length>20)throw new Error(`${t}.marks: expected 1 to 20 marks.`);e.marks.forEach((s,o)=>{Or(s,`${t}.marks[${o}]`),aa(s.at,`${t}.marks[${o}].at`),$i(s.label,`${t}.marks[${o}].label`),$i(s.text,`${t}.marks[${o}].text`)})}break;case"balloon":if(Jt(e.to,`${t}.to`),!eo(r,String(e.to)))throw new Error(`${t}.to: no earlier step has the id "${e.to}".`);if(Jt(e.text,`${t}.text`),String(e.text).length>300)throw new Error(`${t}.text: keep a balloon under 300 characters.`);$a(e.side,["below","above","left","right"],`${t}.side`),$a(e.kind,["speech","thought"],`${t}.kind`),e.width!==void 0&&Pt(e.width,`${t}.width`,80,600),e.size!==void 0&&Pt(e.size,`${t}.size`,12,60);break;case"brace":if(Hr(e.from,`${t}.from`),Hr(e.to,`${t}.to`),$i(e.label,`${t}.label`),e.flip!==void 0&&typeof e.flip!="boolean")throw new Error(`${t}.flip: expected true or false.`);break;case"note":if(Hr(e.at,`${t}.at`),Jt(e.text,`${t}.text`),e.to===void 0==(e.point===void 0))throw new Error(`${t}: a note points either to an element (to) or to a point (point).`);if(e.to!==void 0){if(Jt(e.to,`${t}.to`),!eo(r,String(e.to)))throw new Error(`${t}.to: no earlier step has the id "${e.to}".`)}else Hr(e.point,`${t}.point`);e.size!==void 0&&Pt(e.size,`${t}.size`,12,60);break;case"table":if(Hr(e.at,`${t}.at`),!Array.isArray(e.rows)||e.rows.length===0||e.rows.length>12)throw new Error(`${t}.rows: expected 1 to 12 rows.`);if(e.rows.forEach((s,o)=>{if(!Array.isArray(s)||s.length===0||s.length>6)throw new Error(`${t}.rows[${o}]: expected 1 to 6 cells.`);s.forEach((c,f)=>{if(typeof c!="string"||c.length>120)throw new Error(`${t}.rows[${o}][${f}]: expected text of up to 120 characters.`)})}),e.header!==void 0&&typeof e.header!="boolean")throw new Error(`${t}.header: expected true or false.`);e.size!==void 0&&Pt(e.size,`${t}.size`,12,40);break;case"bars":Or(e.box,`${t}.box`);for(let s of["x","y","w","h"])aa(e.box[s],`${t}.box.${s}`);if(!Array.isArray(e.values)||e.values.length===0||e.values.length>12)throw new Error(`${t}.values: expected 1 to 12 values.`);if(e.values.forEach((s,o)=>aa(s,`${t}.values[${o}]`)),e.labels!==void 0){if(!Array.isArray(e.labels)||e.labels.length>e.values.length)throw new Error(`${t}.labels: at most one label per value.`);e.labels.forEach((s,o)=>Jt(s,`${t}.labels[${o}]`))}if(e.max!==void 0&&aa(e.max,`${t}.max`),e.format!==void 0&&(Jt(e.format,`${t}.format`),!String(e.format).includes("{v")))throw new Error(`${t}.format: show the number as {v}, e.g. "{v}%".`);break}typeof e.id=="string"&&(a==="repeat"?r.repeated:r.exact).add(e.id)}function uk(e){Or(e,"The recipe");let t=e;Pt(t.width,"width",100,4e3),Pt(t.height,"height",100,4e3);for(let a of["id","title","category"])$i(t[a],a);if(t.locale!==void 0&&!(typeof t.locale=="string"&&/^[a-zA-Z]{2,3}(-[a-zA-Z0-9]{2,8})*$/.test(t.locale)&&Intl.NumberFormat.supportedLocalesOf([t.locale]).length>0))throw new Error('locale: expected a language tag such as "en-US" or "pt-BR".');if($a(t.background,["dots","grid","plain"],"background"),$a(t.theme,["paper","chalkboard"],"theme"),t.quiz!==void 0){if(Or(t.quiz,"quiz"),Jt(t.quiz.question,"quiz.question"),!Array.isArray(t.quiz.options)||t.quiz.options.length<2||t.quiz.options.length>4)throw new Error("quiz.options: expected 2 to 4 options.");if(t.quiz.options.forEach((a,i)=>{if(Or(a,`quiz.options[${i}]`),Jt(a.text,`quiz.options[${i}].text`),Jt(a.why,`quiz.options[${i}].why`),typeof a.right!="boolean")throw new Error(`quiz.options[${i}].right: expected true or false.`)}),t.quiz.options.filter(a=>a.right===!0).length!==1)throw new Error("quiz.options: exactly one option is right.")}if(t.learning!==void 0){Or(t.learning,"learning");for(let a of["goal","question","answer","caveat"])Jt(t.learning[a],`learning.${a}`)}if(t.params!==void 0){Or(t.params,"params");for(let[a,i]of Object.entries(t.params))if(td(a),Or(i,`params.${a}`),Jt(i.label,`params.${a}.label`),Pt(i.min,`${a}.min`),Pt(i.max,`${a}.max`),Pt(i.step,`${a}.step`,1e-6),Pt(i.value,`${a}.value`,i.min,i.max),i.max<=i.min)throw new Error(`${a}: max must be greater than min.`)}if(t.vars!==void 0){Or(t.vars,"vars");for(let[a,i]of Object.entries(t.vars))td(a),aa(i,`vars.${a}`)}if(t.switches!==void 0){Or(t.switches,"switches");let a=Object.entries(t.switches);if(a.length>8)throw new Error("switches: at most 8.");for(let[i,n]of a){if(td(i),Object.hasOwn(t.params??{},i)||Object.hasOwn(t.vars??{},i))throw new Error(`switches.${i}: the name is already a param or a var.`);if(Or(n,`switches.${i}`),Jt(n.label,`switches.${i}.label`),typeof n.on!="boolean")throw new Error(`switches.${i}.on: expected true or false.`)}}if(!Array.isArray(t.steps)||t.steps.length===0||t.steps.length>250)throw new Error("A recipe needs 1 to 250 steps.");let r={exact:new Set,repeated:new Set,count:0};return t.steps.forEach((a,i)=>rd(a,`Step ${i+1}`,r,null)),{...t,id:t.id??"pasted",title:t.title??"",background:t.background??"dots"}}async function mW(e,t={}){return uk(await ik(e,Z$,t))}export{mW as readMermaid};