@straydragon/dsh-halcyon-uiux 0.0.0-stage → 0.1.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.
package/dist/client.js ADDED
@@ -0,0 +1,1439 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "@straydragon/dsh-halcyon-uiux",
3
+ factory: (require) => {
4
+ const __dshRequire = require;
5
+ "use strict";var __halcyon=(()=>{var Dd=Object.defineProperty;var Ev=Object.getOwnPropertyDescriptor;var Av=Object.getOwnPropertyNames;var Tv=Object.prototype.hasOwnProperty;var Sv=(e,t)=>{for(var r in t)Dd(e,r,{get:t[r],enumerable:!0})},Cv=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Av(t))!Tv.call(e,i)&&i!==r&&Dd(e,i,{get:()=>t[i],enumerable:!(n=Ev(t,i))||n.enumerable});return e};var Iv=e=>Cv(Dd({},"__esModule",{value:!0}),e);var w8={};Sv(w8,{apply:()=>_v,default:()=>b8,inject:()=>Mv});var De=__dshRequire("react"),ue=De.createElement;var er=e=>e!=null&&typeof e=="object"&&!Array.isArray(e);function An(e){return typeof e=="string"?e:void 0}function Ga(e){return e===void 0?[]:Array.isArray(e)?e:[e]}function Pd(e){let t=[],r=0;for(let n of Ga(e))typeof n=="string"?t.push(n):(t.push("expr"),r+=1);return{names:t,opaque:r}}function zd(e){if(typeof e=="string")return{targets:[e],partial:!1};if(er(e)){let t=e.target;if(typeof t=="string")return{targets:[t],partial:!1};if(Array.isArray(t)){let r=t.filter(n=>typeof n=="string");return{targets:r,partial:r.length!==t.length}}return{targets:[],partial:t!==void 0}}return{targets:[],partial:e!==void 0}}function Nv(e,t){let r=e.on;if(er(r)){for(let[n,i]of Object.entries(r))if(!n.startsWith("__"))for(let a of Ga(i)){if(typeof a=="string"){t({event:n,kind:"on",target:a,guard:void 0,actions:void 0,description:void 0,partial:!1});continue}if(er(a)){t({event:n,kind:"on",target:a.target,guard:a.guard??a.cond,actions:a.actions,description:a.description,partial:a.__spreads!==void 0||a.__computed!==void 0});continue}t({event:n,kind:"on",target:void 0,guard:void 0,actions:void 0,description:void 0,partial:!0})}}}function Rv(e,t){let r=e.after;if(er(r))for(let[n,i]of Object.entries(r)){if(n.startsWith("__"))continue;let a=er(i)&&Array.isArray(i.__array)?i.__array:Ga(i);for(let l of a){if(typeof l=="string"){t({event:`after ${n}`,kind:"after",delay:n,target:l,guard:void 0,actions:void 0,description:void 0,partial:!1});continue}if(er(l)){t({event:`after ${n}`,kind:"after",delay:n,target:l.target,guard:l.guard??l.cond,actions:l.actions,description:void 0,partial:l.__spreads!==void 0});continue}t({event:`after ${n}`,kind:"after",delay:n,target:void 0,guard:void 0,actions:void 0,description:void 0,partial:!0})}}}function Ov(e,t){for(let r of Ga(e.always)){if(typeof r=="string"){t({event:"",kind:"always",target:r,guard:void 0,actions:void 0,description:void 0,partial:!1});continue}if(er(r)){t({event:"",kind:"always",target:r.target,guard:r.guard??r.cond,actions:r.actions,description:void 0,partial:r.__spreads!==void 0});continue}t({event:"",kind:"always",target:void 0,guard:void 0,actions:void 0,description:void 0,partial:!0})}}function Lv(e){let t=[];for(let r of Ga(e.invoke)){if(!er(r)){t.push({src:"expr"});continue}let n=An(r.src)??An(r.id)??"expr";t.push({id:An(r.id),src:n,onDone:zd(r.onDone).targets[0],onError:zd(r.onError).targets[0]})}return t}function Dv(e,t){let r=An(e.type);return r==="parallel"?"parallel":r==="final"?"final":r==="history"?"history":t>0?"compound":"atomic"}function Pv(e){let t=e.tags;return typeof t=="string"?[t]:Array.isArray(t)?t.filter(r=>typeof r=="string"):[]}function zv(e,t,r,n){let{targets:i,partial:a}=zd(e.target),l=An(e.guard)??(e.guard!==void 0?"expr":void 0),s=Pd(e.actions);return{event:e.event,kind:e.kind,delay:e.delay,targets:i,resolved:i.map(o=>Fd(t,o,n,r)),guard:l,actions:s.names,partial:e.partial||a}}function Fd(e,t,r,n){if(t.startsWith("#")){let l=t.slice(1),s=r!==""&&l.startsWith(`${r}.`)?l.slice(r.length+1):l;return n.has(s)?s:`?${t}`}if(t.startsWith(".")){let l=`${e}${t}`;return n.has(l)?l:`?${t}`}let i=[];e!==""&&i.push(e);let a=n.get(e)?.parent??null;for(;a!==null;)i.push(a),a=n.get(a)?.parent??null;for(let l of i){let s=l===""?t:`${l}.${t}`;if(n.has(s))return s}return`?${t}`}function ig(e){if(e.__spreads!==void 0||e.__computed!==void 0)return!0;let t=e.states;return er(t)?Object.keys(t).some(r=>!r.startsWith("__")&&er(t[r])&&ig(t[r])):!1}function Tn(e){let t=e.states;if(!er(t)||Object.keys(t).filter(p=>!p.startsWith("__")&&er(t[p])).length===0)return null;let n=An(e.id)??"(machine)",i=new Map,a=[],l=0,s=new Map,o=new Map,c=(p,g,m)=>{let v=g.join("."),x=er(p.states)?p.states:{},k=Object.keys(x).filter(G=>!G.startsWith("__")&&er(x[G])),b=Dv(p,k.length),C=An(p.history),N=b==="compound"?An(p.initial):void 0,R=[];Nv(p,G=>R.push(G)),Rv(p,G=>R.push(G)),Ov(p,G=>R.push(G)),s.set(v,R);let O=Lv(p);o.set(v,O);let P=Pd(p.entry),H=Pd(p.exit);l+=P.opaque+H.opaque;let I=ig(p);i.set(v,{id:v,key:g[g.length-1]??n,parent:m,kind:b,initial:N,history:b==="history"?C==="deep"?"deep":"shallow":void 0,tags:Pv(p),on:[],always:[],after:[],entry:P.names,exit:H.names,invokes:O,children:k.map(G=>v===""?G:`${v}.${G}`),partial:I}),a.push(v);for(let G of k)c(x[G],[...g,G],v)};c(e,[],null);let h=(p,g)=>{let m=[];for(let v of g.invokes)v.onDone!==void 0&&m.push({event:"done.invoke",kind:"on",targets:[v.onDone],resolved:[Fd(p,v.onDone,n,i)],actions:[],partial:!1}),v.onError!==void 0&&m.push({event:"error.invoke",kind:"on",targets:[v.onError],resolved:[Fd(p,v.onError,n,i)],actions:[],partial:!1});return m};for(let[p,g]of s){let m=i.get(p);if(m===void 0)continue;let v=[];for(let x of g){let k=zv(x,p,i,n);l+=k.guard==="expr"?1:0,v.push(k)}v.push(...h(p,m)),m.on=v.filter(x=>x.kind==="on"),m.always=v.filter(x=>x.kind==="always"),m.after=v.filter(x=>x.kind==="after")}let u=l,d=!1;for(let p of i.values())p.partial&&(d=!0),u+=p.invokes.filter(g=>g.src==="expr").length;return{id:n,order:a,nodes:i,context:er(e.context)||e.context===void 0?e.context:void 0,partial:d,opaqueCount:u}}function ag(e){let t=new Set;for(let r of e.order){let n=e.nodes.get(r);if(n!==void 0)for(let i of[...n.on,...n.after])i.event!==""&&!i.event.startsWith("done.")&&!i.event.startsWith("error.")&&t.add(i.event)}return[...t]}function Wd(e,t,r){let n=e.nodes.get(t);if(n!==void 0){if(r.add(t),n.kind==="compound"&&n.initial!==void 0){let i=n.children.find(a=>a===(t===""?n.initial:`${t}.${n.initial}`));if(i!==void 0){Wd(e,i,r);return}}if(n.kind==="parallel")for(let i of n.children)Wd(e,i,r)}}function Li(e){let t=new Set;return Wd(e,"",t),t}function ng(e,t){let r=new Set,n=t;for(;n!==null;)r.add(n),n=e.nodes.get(n)?.parent??null;let i=new Set,a=l=>{let s=e.nodes.get(l);if(s===void 0)return;if(i.add(l),s.kind==="parallel"){for(let u of s.children)a(u);return}if(s.kind!=="compound")return;let o=s.children.find(u=>r.has(u)||[...r].some(d=>d.startsWith(`${u}.`))),c=s.initial!==void 0?s.children.find(u=>u===(l===""?s.initial:`${l}.${s.initial}`)):void 0,h=o??c??s.children[0];h!==void 0&&a(h)};return a(""),i}function Sl(e,t,r){let n=[...t].sort((i,a)=>a.split(".").length-i.split(".").length||(i<a?1:-1));for(let i of n){let a=e.nodes.get(i);if(a===void 0)continue;let l=a.on.find(s=>s.event===r);if(l!==void 0){if(l.resolved.length>0){let s=l.resolved.find(c=>!c.startsWith("?"))??a.parent??"",o=e.nodes.get(s)?.kind==="history"?e.nodes.get(s)?.parent??"":s;return{active:ng(e,o),fired:{from:i,event:r,to:l.resolved},ignored:!1}}return{active:ng(e,i),fired:{from:i,event:r,to:[]},ignored:!1}}}return{active:new Set(t),ignored:!0}}var Va={"{":"}","[":"]","(":")"},Cl=new Set(["}","]",")"]),sg=/[A-Za-z_$]/,Fv=/[A-Za-z0-9_$]/,Wv=/[0-9a-fA-FxX._]/,lg=":,;",og=/\s/;function Bv(e){let t=[],r=0,n=e.length,i=a=>e[r+a]??"";for(;r<n;){let a=i(0);if(a==="/"&&i(1)==="/"){let s=e.indexOf(`
6
+ `,r);r=s<0?n:s;continue}if(a==="/"&&i(1)==="*"){let s=e.indexOf("*/",r+2);r=s<0?n:s+2;continue}if(og.test(a)){r+=1;continue}if(a==='"'||a==="'"||a==="`"){let s=r;r=Hv(e,r),t.push({t:"str",v:e.slice(s,r)});continue}if(sg.test(a)){let s=r;for(;r<n&&Fv.test(i(0));)r+=1;t.push({t:"id",v:e.slice(s,r)});continue}if(/[0-9]/.test(a)){let s=r;for(;r<n&&Wv.test(i(0));)r+=1;t.push({t:"num",v:e.slice(s,r)});continue}if(Va[a]!==void 0||Cl.has(a)||lg.includes(a)){t.push({t:"p",v:a}),r+=1;continue}let l=r;for(;r<n&&!og.test(i(0))&&Va[i(0)]===void 0&&!Cl.has(i(0))&&!lg.includes(i(0))&&i(0)!=='"'&&i(0)!=="'"&&i(0)!=="`"&&!sg.test(i(0))&&!/[0-9]/.test(i(0));)r+=1;r===l&&(r+=1),t.push({t:"op",v:e.slice(l,r)})}return t}function Hv(e,t){let r=e[t],n=t+1,i=0;for(;n<e.length;){let a=e[n];if(r==="`"&&a==="$"&&e[n+1]==="{"){i+=1,n+=2;continue}if(r==="`"&&i>0&&a==="}"){i-=1,n+=1;continue}if(i===0&&a==="\\"){n+=2;continue}if(i===0&&a===r)return n+1;n+=1}return n}function dg(e){return/createMachine\s*[(<]/.test(e)||/createStateConfig\s*[(<]/.test(e)}function jv(e){let t=Bv(e);for(let r=0;r<t.length;r+=1){let n=t[r];if(n===void 0||n.t!=="id"||n.v!=="createMachine"&&n.v!=="createStateConfig")continue;let i=n.v,a=r+1;if(t[a]?.v==="<"){let c=0;for(;a<t.length;a+=1){let h=t[a]?.v;if(h===void 0)break;if(h==="<")c+=1;else if(h===">"){if(c-=1,c===0){a+=1;break}}else if(h===">>"&&(c-=2,c<=0)){a+=1;break}}}if(t[a]?.v!=="("||t[a+1]?.v!=="{")continue;let l=0,s=a+1,o=-1;for(let c=s;c<t.length;c+=1){let h=t[c]?.v;if(h==="{")l+=1;else if(h==="}"&&(l-=1,l===0)){o=c;break}}return o<0?{ok:!1,reason:"unterminated-literal"}:{ok:!0,tokens:t.slice(s,o+1),call:i}}return{ok:!1,reason:"no-machine-call"}}var Bd=class{constructor(t){this.tokens=t}tokens;i=0;peek(t=0){return this.tokens[this.i+t]}next(){return this.tokens[this.i++]}eof(){return this.i>=this.tokens.length}};function hg(e){let t=e[0],r=e.slice(1,-1);return t==="`"?r.includes("${")?void 0:r:r.replace(/\\(.)/g,(n,i)=>i==="n"?`
7
+ `:i==="t"?" ":i==="r"?"\r":i)}function Tr(e){return{__opaque:!0,source:e}}function ug(e){return e.join(" ").replace(/\s+/g," ").trim()}function cg(e,t){let r=Va[t],n=[t],i=1;for(;!e.eof()&&i>0;){let a=e.next();if(a===void 0)break;n.push(a.v),Va[a.v]!==void 0?i+=1:(a.v===r||Cl.has(a.v))&&(i-=1)}return ug(n)}function Zn(e){let t=[],r=0;for(;!e.eof();){let n=e.peek();if(n===void 0||r===0&&(n.v===","||n.v==="}"||n.v==="]"))break;e.next(),t.push(n.v),Va[n.v]!==void 0?r+=1:Cl.has(n.v)&&(r-=1)}return ug(t)}function Hd(e){let t=e.peek();if(t===void 0)return Tr("");if(t.t==="str"){e.next();let r=hg(t.v);return r===void 0?Tr(t.v):r}if(t.t==="num"){e.next();let r=Number(t.v.replace(/_/g,""));return Number.isFinite(r)?r:Tr(t.v)}if(t.t==="id")return t.v==="true"||t.v==="false"||t.v==="null"?(e.next(),t.v==="true"?!0:t.v==="false"?!1:null):t.v==="undefined"?(e.next(),Tr("undefined")):Tr(Zn(e));if(t.v==="-"){e.next();let r=e.next();if(r!==void 0&&r.t==="num"){let n=-Number(r.v.replace(/_/g,""));return Number.isFinite(n)?n:Tr(`-${r.v}`)}return Tr(Zn(e))}return t.v==="{"?fg(e):t.v==="["?Uv(e):Tr(Zn(e))}function Uv(e){e.next();let t=[];for(;!e.eof()&&e.peek()?.v!=="]";){if(e.peek()?.v===","){e.next();continue}if(e.peek()?.t==="op"&&e.peek()?.v==="..."){e.next(),t.push(Tr(Zn(e)));continue}let r=e.peek(),n=Hd(e);e.peek()===r&&e.next(),t.push(n)}return e.peek()?.v==="]"&&e.next(),t}function fg(e){e.next();let t={};for(;!e.eof()&&e.peek()?.v!=="}";){let r=e.peek();if(r===void 0)break;if(r.v===","){e.next();continue}if(r.t==="op"&&r.v==="..."){e.next(),t.__spreads=[...t.__spreads??[],Zn(e)];continue}if(r.v==="["){e.next();let a=Zn(e);e.peek()?.v==="]"&&e.next(),e.peek()?.v===":"&&e.next(),t.__computed=[...t.__computed??[],{key:a,value:Hd(e)}];continue}let n=null;if(r.t==="id"||r.t==="str"||r.t==="num")e.next(),n=r.t==="str"?hg(r.v)??r.v:r.v;else{Zn(e);continue}let i=e.peek();i!==void 0&&i.v===":"?(e.next(),t[n]=Hd(e)):i!==void 0&&i.v==="("?(cg(e,"("),e.peek()?.v==="{"&&cg(e,"{"),t[n]=Tr(`method ${n}()`)):t[n]=Tr(n),e.peek()?.v===","&&e.next()}return e.peek()?.v==="}"&&e.next(),t}function Yv(e){let t=new Bd(e);return t.peek()?.v!=="{"?null:fg(t)}function Sr(e){let t=jv(e);if(!t.ok)return t;let r=Yv(t.tokens);return r===null?{ok:!1,reason:"unterminated-literal"}:{ok:!0,call:t.call,config:r}}var Gv=8;function Vv(e){return e.querySelector(".heading .language")??e.querySelector(".language")??e.querySelector("[data-language]")??e.firstElementChild}var qv=new Set(["","code","代码","text","plaintext","txt"]),Xv=new Set(["sequencediagram","classdiagram","statediagram","statediagram-v2","erdiagram","journey","gantt","pie","quadrantchart","requirementdiagram","gitgraph","c4context","c4container","c4component","c4dynamic","c4deployment","mindmap","timeline","sankey-beta","xychart-beta","block-beta","packet-beta","kanban","architecture-beta","radar-beta","treemap-beta"]),Kv=/^(?:flowchart|graph)\s+(?:TD|TB|BT|LR|RL)(?![A-Za-z0-9_])/i;function Di(e){let t=e.trim().toLowerCase();return t.startsWith("language-")&&(t=t.slice(9).trim()),t==="mermaidjs"&&(t="mermaid"),t}function Gd(e){let t=Di(e);return t==="mermaid"||t==="mmd"}var Zv=new Set(["xstate","statemachine","machine","stately"]);function Qv(e){return Zv.has(Di(e))}function Ud(e){return qv.has(e)}function Jv(e){let t=e.split(/\r?\n/),r=0;for(;r<t.length&&(t[r]??"").trim()==="";)r+=1;if(r<t.length&&(t[r]??"").trim().startsWith("%%{")){for(;r<t.length;){let n=(t[r]??"").trim();if(r+=1,n.includes("}%%"))break}for(;r<t.length&&(t[r]??"").trim()==="";)r+=1}return(t[r]??"").trim()}function e$(e){let t=Jv(e);if(t==="")return!1;if(Kv.test(t))return!0;let r=t.split(/\s+/,1)[0]??"";return Xv.has(r.toLowerCase())}function Yd(e){if(e===null)return"";let t=e.getAttribute("class");if(t===null||t.trim()==="")return"";for(let r of t.split(/\s+/)){let n=Di(r);if(Gd(n))return n}return""}var t$=/^[a-z0-9][a-z0-9+#._-]{0,31}$/i;function r$(e){return t$.test(e)}function Il(e){let t=e.querySelector(".heading .language"),r=e.querySelector(".language"),n=e.querySelector("[data-language]"),i=e.firstElementChild,a=i?.textContent?.trim().split(/\s+/,1)[0]??"",l=[{text:t?.textContent,element:t},{text:r?.textContent,element:r},{text:n?.getAttribute("data-language"),element:n},{text:a,element:i}],s="";for(let o of l){let c=typeof o.text=="string"?Di(o.text):"";if(Gd(c))return c;if(c===""||Ud(c)){let h=Yd(o.element)||Yd(e);if(h!=="")return h}if(!(c===""||s!=="")){if(Ud(c)){s=c;continue}if(r$(c))return c}}return s}function Pi(e){let t=typeof document>"u"?null:document.body,r=e,n=null;for(let a=0;a<6&&r!==null&&(n=r.querySelector("[data-code-block-content]"),n===null);a+=1){let l=r.parentElement;if(l===null||l===t)break;r=l}if(n!==null){let a=n.querySelector("pre");if(a!==null)return a.textContent??"";let l=n.querySelector("code");return l!==null?l.textContent??"":n.textContent??""}return e.parentElement?.querySelector("pre")?.textContent??""}function Qn(e){return e.closest("[data-chat-flow-kind]")!==null||e.closest("[data-chat-node-key]")!==null?"chat":e.closest("[data-sidebar-right-session]")!==null?"sidebar":null}function Nl(e){if(e===null||Qn(e)!=="sidebar")return null;let t=e.closest("[data-dockkit-float]")??e.closest("[data-sidebar-right-session]");if(t===null)return null;let r=t.getBoundingClientRect();return r.width<=0&&r.height<=0?null:{left:r.left,top:r.top,width:r.width,height:r.height}}function n$(e){let t=e.querySelector(".heading .language"),r=e.querySelector(".language"),n=e.querySelector("[data-language]"),a=e.firstElementChild?.textContent?.trim().split(/\s+/,1)[0]??"",l=new Set,s=[t?.textContent,r?.textContent,n?.getAttribute("data-language"),a];for(let o of s)typeof o=="string"&&o!==""&&l.add(Di(o));for(let o of[t,r,n,e]){let c=Yd(o);c!==""&&l.add(Di(c))}return[...l]}var jd=new WeakMap,i$=800;function qa(e){if(Qn(e)===null)return null;let t=jd.get(e);if(t!==void 0&&Date.now()-t.at<i$)return t.kind;let r=n$(e);if(r.some(l=>Gd(l)))return jd.set(e,{source:"",kind:"mermaid",at:Date.now()}),"mermaid";let n=Pi(e);if(t!==void 0&&t.source===n)return t.at=Date.now(),t.kind;let i=l=>{let s=Sr(l);return s.ok?Tn(s.config)!==null:!1},a=null;if(r.some(l=>Qv(l)))a=i(n)?"xstate":null;else if(dg(n)&&i(n))a="xstate";else{let l=Il(e);Ud(l)&&e$(n)&&(a="mermaid")}return jd.set(e,{source:n,kind:a,at:Date.now()}),a}function a$(e){if(e===null||typeof e!="object")return null;let t=e;return typeof t.nodeType!="number"?null:t.nodeType===1?t:t.parentElement}function Xa(e){let t=a$(e);if(t===null||t.closest("[data-halcyon-trigger]")!==null)return null;let r=t.closest("[data-code-block-banner]");if(r===null)return null;let n=r,i=qa(n);return i===null?null:{banner:n,kind:i}}function s$(e,t){if(e===t)return 0;let r=e.compareDocumentPosition(t);return(r&1)!==0?0:(r&4)!==0?-1:1}function pg(e,t){let r=e.closest("[data-chat-node-key]")??e.closest("[data-chat-flow-kind]")??e.closest("[data-document-markdown]")??e.closest("[data-textpreview-body]")??e.parentElement??e,n=new Set,i=[];for(let a of r.querySelectorAll("[data-code-block-banner]"))n.has(a)||a===e||(n.add(a),qa(a)===t&&i.push(a));return n.has(e)||i.push(e),i.sort(s$),i.map(a=>({banner:a,source:Pi(a),language:Il(a),kind:t,surface:Qn(a)??"chat"}))}function Vd(e){let t=Vv(e),r=(t??e).getBoundingClientRect(),n={x:r.right+Gv,y:r.top+r.height/2},i=e.lastElementChild;return i!==null&&i!==t&&e.getBoundingClientRect().width>0&&(n.limit=i.getBoundingClientRect().left),n}var gg=Object.freeze(["mmd","mermaid"]),Ol=Object.freeze({zoom:!0,defaultTranslucent:!1,panelOpacity:70}),Ka=Object.freeze({enabled:!0,codeButton:!0,allowLinks:!1,multiInstance:!1}),Rl=Object.freeze({enabled:!0,multiInstance:!1,execution:"confirm"}),qd=Object.freeze({codeBlocks:!0,mermaidFile:!0}),Xd=Object.freeze(["off","confirm","auto"]),Za=30,Dl=100,Ll=5;function Jn(e){let t=typeof e=="number"?e:Number(e);if(!Number.isFinite(t))return Ol.panelOpacity;let r=Math.min(Dl,Math.max(Za,t));return Math.round(r/Ll)*Ll}var T8=Object.freeze({panels:Ol,behaviors:Object.freeze({mermaid:Ka,xstate:Rl,sidebar:qd})});function zi(e){return e!==null&&typeof e=="object"?e:void 0}function jr(e,t,r){let n=e?.[t];return typeof n=="boolean"?n:r}function Pl(e){let t=zi(e),r=zi(t?.panels),n=zi(t?.behaviors),i=zi(n?.mermaid),a=zi(n?.xstate),l=zi(n?.sidebar),s=a?.execution,o=Xd.find(c=>c===s);return{panels:{zoom:jr(r,"zoom",Ol.zoom),defaultTranslucent:jr(r,"defaultTranslucent",Ol.defaultTranslucent),panelOpacity:Jn(r?.panelOpacity)},behaviors:{mermaid:{enabled:jr(i,"enabled",Ka.enabled),codeButton:jr(i,"codeButton",Ka.codeButton),allowLinks:jr(i,"allowLinks",Ka.allowLinks),multiInstance:jr(i,"multiInstance",Ka.multiInstance)},xstate:{enabled:jr(a,"enabled",Rl.enabled),multiInstance:jr(a,"multiInstance",Rl.multiInstance),execution:o??Rl.execution},sidebar:{codeBlocks:jr(l,"codeBlocks",qd.codeBlocks),mermaidFile:jr(l,"mermaidFile",qd.mermaidFile)}}}}var Fi="dsh-halcyon-uiux",ei=Fi,Kd=`${Fi}/mermaid-file`;var mg={meta:{title:"Halcyon UI/UX",description:"Thoughtful UI/UX behavior for the DeepSeek Harness Web GUI: floating viewers for Mermaid diagrams and XState machines in chat and sidebar documents, plus a Mermaid file preview."},"section.title":"Halcyon-UIUX","section.intro":"Small, switchable behaviors that make the Web GUI calmer to read and easier to navigate.","section.loading":"Loading settings…","section.saved":"Saved","section.saving":"Saving…","section.error":"Could not save","section.readonly":"This configuration is read-only.","section.panels.title":"Floating windows","section.panels.zoom":"Enable zoom and pan","section.panels.zoom.hint":"Use the toolbar, plain mouse wheel, trackpad pinch, or drag inside the diagram. Double-click resets the view.","section.panels.defaultTranslucent":"Start windows translucent","section.panels.defaultTranslucent.hint":"On: new floating windows open with the glass background already on. The title-bar translucency button still toggles each window on its own.","section.panels.opacity":"Translucent background opacity","section.panels.opacity.hint":"How much of the panel background stays opaque when the title-bar translucency button is on. Default 70%; lower is more see-through.","section.behavior.mermaid.title":"Mermaid viewer","section.behavior.mermaid.description":"Render Mermaid code blocks in chat in a draggable floating window. The original source block stays in the message.","section.behavior.mermaid.master":"Enable Mermaid viewer","section.behavior.mermaid.master.hint":"Turning this off hides the trigger and closes the viewer immediately. Your settings stay saved.","section.behavior.mermaid.codeButton":"Show the hover trigger","section.behavior.mermaid.codeButton.hint":`A small "View diagram" chip appears beside the block's language label. It also appears when the copy button receives keyboard focus.`,"section.behavior.mermaid.allowLinks":"Allow links in diagrams","section.behavior.mermaid.allowLinks.hint":"Links use http, https, and mailto only. Leave this off if you open diagrams from untrusted sources.","section.behavior.mermaid.multiInstance":"Open each diagram in its own window","section.behavior.mermaid.multiInstance.hint":"On: every view opens a new floating window (up to six). Off: one window switches its content. The title-bar button toggles this anytime.","section.behavior.xstate.title":"State-machine viewer","section.behavior.xstate.description":"Detect XState machines in chat code blocks, show their nested state structure in a floating window, and simulate events. Parsing happens locally; message code is never executed as a script.","section.behavior.xstate.master":"Enable state-machine viewer","section.behavior.xstate.master.hint":"Off: machine code blocks are no longer detected. Windows already open stay.","section.behavior.xstate.multiInstance":"Open each machine in its own window","section.behavior.xstate.multiInstance.hint":"On: every view opens a new floating window (up to six). Off: one window switches its content.","section.behavior.xstate.execution":"Simulation tier","section.behavior.xstate.execution.hint":"Static: structure only, clicked events are walked without side effects. Confirm: the static graph loads first; simulation starts after you press run. Auto: simulation starts when the window opens. Simulation rebuilds the machine with a bundled engine; function bodies never run.","section.behavior.xstate.execution.off":"Static","section.behavior.xstate.execution.confirm":"Confirm to simulate","section.behavior.xstate.execution.auto":"Simulate automatically","section.preview":"Try the viewer","section.preview.hint":"Opens a sample diagram in the floating window, using the current settings.","section.preview.xstate.hint":"Opens a sample state machine in the floating window, using the current settings.","section.preview.xstate.action":"Open sample machine","trigger.label":"View diagram","trigger.open":"Open Mermaid diagram","trigger.hint":"Open in a floating window","trigger.xstate.label":"View machine","trigger.xstate.open":"Open the state-machine viewer","panel.title":"Mermaid","panel.xstate.title":"State machine","panel.close":"Close viewer","panel.zoomIn":"Zoom in","panel.zoomOut":"Zoom out","panel.fit":"Fit to window","panel.fullscreen":"In-page fullscreen","panel.exitFullscreen":"Exit fullscreen","panel.collapse":"Collapse to title bar","panel.expand":"Expand window","panel.translucent":"Translucent ({opacity}% background)","panel.opaque":"Restore opaque background","panel.copySource":"Copy source","panel.copied":"Source copied","panel.copyFailed":"Copy failed","panel.downloadSvg":"Download SVG","panel.downloadFailed":"Download failed","panel.prev":"Previous diagram","panel.next":"Next diagram","panel.of":"{current} of {total}","panel.loading":"Rendering diagram…","panel.error":"This diagram could not be rendered.","panel.empty":"The code block is empty.","panel.retry":"Read the source again","panel.source":"Source","panel.sourceHint":"The message keeps the original code block.","panel.help":"Wheel to zoom · drag to pan · drag text to select · double-click to reset","panel.streamingHint":"If the message is still streaming, read the source again after it finishes.","panel.unknownType":"diagram","panel.resize":"Drag to resize · double-click to reset","panel.locate":"Scroll to the code block","panel.modeToMulti":"Switch to multi-window: every open creates a new panel","panel.modeToSingle":"Switch to single window: replace the content of one panel","xstate.loading":"Parsing the machine…","xstate.parseError":"No state machine could be parsed from this code.","xstate.empty":"The code block is empty.","xstate.static":"Static mode: no code runs, clicked events are structure-only walks","xstate.stopped":"Simulation stopped","xstate.run":"Run simulation","xstate.run.hint":"Rebuilds the machine from the parsed configuration and starts simulating; function bodies never run.","xstate.reset":"Reset simulation","xstate.state":"Current state","xstate.context":"context","xstate.log":"Event log","xstate.log.empty":"No events yet.","xstate.initial":"initial","xstate.final":"final","xstate.parallel":"parallel","xstate.history":"history","xstate.entry":"entry","xstate.exit":"exit","xstate.after":"after","xstate.guard":"guard","xstate.actions":"actions","xstate.invoke":"invoke","xstate.unresolved":"unresolved target","xstate.opaque":"expression","xstate.noEvents":"No events available in the current state.","section.behavior.mermaid.sample":"Open a Mermaid sample","section.behavior.xstate.sample":"Open an XState sample","panel.viewGraph":"Event-graph view","panel.viewCards":"Card view","panel.copyMermaid":"Copy Mermaid","panel.copyDot":"Copy DOT","panel.graphHelp":"Click an arrow or event label to fire a transition · the event graph is fixed; layout is automatic","section.behavior.sidebar.title":"Sidebar documents","section.behavior.sidebar.description":"Extend the viewers to documents opened in the right sidebar, such as Markdown files and Mermaid source files.","section.behavior.sidebar.codeBlocks":"Show the trigger in sidebar documents","section.behavior.sidebar.codeBlocks.hint":"Mermaid and state-machine code blocks inside sidebar documents get the same hover trigger as in chat. Their window opens beside the sidebar so the document stays visible.","section.behavior.sidebar.mermaidFile":"Preview Mermaid files as a diagram","section.behavior.sidebar.mermaidFile.hint":"Opening a .mmd or .mermaid file in the sidebar renders it as a diagram with a source toggle. Off: the file opens as plain text.","mermaidFile.title":"Mermaid diagram","mermaidFile.loading":"Reading the diagram source…","mermaidFile.rendering":"Rendering the diagram…","mermaidFile.empty":"This file is empty.","mermaidFile.error":"This file could not be rendered as a Mermaid diagram.","mermaidFile.viewSource":"View source","mermaidFile.viewDiagram":"View diagram","mermaidFile.renderAgain":"Render again"};var yg={meta:{title:"Halcyon UI/UX",description:"为 DeepSeek Harness Web GUI 提供舒适、易用的界面行为:聊天与侧栏文档中的 Mermaid 图表、XState 状态机浮动查看器,以及 Mermaid 文件预览。"},"section.title":"Halcyon-UIUX","section.intro":"一些可以随时开关的小行为,让 Web GUI 更安静、更顺手。","section.loading":"正在读取设置…","section.saved":"已保存","section.saving":"保存中…","section.error":"保存失败","section.readonly":"当前配置为只读。","section.panels.title":"浮窗","section.panels.zoom":"启用缩放与平移","section.panels.zoom.hint":"可用工具栏、鼠标滚轮、触控板捏合或拖动图表操作,双击恢复视图。","section.panels.defaultTranslucent":"默认启用透明化","section.panels.defaultTranslucent.hint":"开启后新打开的浮窗直接使用毛玻璃背景;仍可用顶栏「透明化」按钮单独切换当前浮窗。","section.panels.opacity":"浮窗透明化的不透明度","section.panels.opacity.hint":"点顶栏「透明化」按钮时,浮窗背景保留的不透明度。默认 70%,数值越低越透明。","section.behavior.mermaid.title":"Mermaid 查看器","section.behavior.mermaid.description":"在可拖动的浮窗中渲染聊天里的 Mermaid 代码块,消息中的原始代码块会保留。","section.behavior.mermaid.master":"启用 Mermaid 查看器","section.behavior.mermaid.master.hint":"关闭后立即隐藏触发按钮并收起浮窗,已保存的设置不会丢失。","section.behavior.mermaid.codeButton":"显示悬停触发按钮","section.behavior.mermaid.codeButton.hint":"鼠标悬停在 Mermaid 代码块上时,语言标签旁显示「查看图表」。复制按钮获得键盘焦点时也会显示。","section.behavior.mermaid.allowLinks":"允许图表中的链接","section.behavior.mermaid.allowLinks.hint":"仅允许 http、https 和 mailto 链接。打开来源不可信的图表时建议关闭。","section.behavior.mermaid.multiInstance":"多窗口打开图表","section.behavior.mermaid.multiInstance.hint":"开启后每次查看都会打开新的浮窗(最多六个);关闭时在单个浮窗内切换图表。顶栏按钮可随时切换。","section.behavior.xstate.title":"状态机查看器","section.behavior.xstate.description":"识别聊天代码块里的 XState 状态机,在浮窗中展示嵌套状态结构,并可发事件模拟运行。解析在本地完成,不会把消息中的代码当作脚本执行。","section.behavior.xstate.master":"启用状态机查看器","section.behavior.xstate.master.hint":"关闭后不再探测状态机代码块,已打开的浮窗保留。","section.behavior.xstate.multiInstance":"多窗口打开状态机","section.behavior.xstate.multiInstance.hint":"开启后每次查看都会打开新的浮窗(最多六个);关闭时在单个浮窗内切换状态机。","section.behavior.xstate.execution":"模拟方式","section.behavior.xstate.execution.hint":"静态:只看结构,点击事件仅做无副作用的推演。确认:先看静态图,点「运行」后才启动真实模拟。自动:打开浮窗即开始模拟。模拟由内置引擎重建,源码中的函数不会被执行。","section.behavior.xstate.execution.off":"静态","section.behavior.xstate.execution.confirm":"确认后模拟","section.behavior.xstate.execution.auto":"自动模拟","section.preview":"试用查看器","section.preview.hint":"用当前设置打开一张示例图表。","section.preview.xstate.hint":"用当前设置打开一个示例状态机。","section.preview.xstate.action":"打开状态机示例","trigger.label":"查看图表","trigger.open":"打开 Mermaid 图表","trigger.hint":"在浮窗中查看","trigger.xstate.label":"查看状态机","trigger.xstate.open":"打开状态机查看器","panel.title":"Mermaid","panel.xstate.title":"状态机","panel.close":"关闭查看器","panel.zoomIn":"放大","panel.zoomOut":"缩小","panel.fit":"适应窗口","panel.fullscreen":"页面内全屏","panel.exitFullscreen":"退出全屏","panel.collapse":"缩小到顶栏","panel.expand":"展开浮窗","panel.translucent":"透明化(背景不透明度 {opacity}%)","panel.opaque":"恢复不透明","panel.copySource":"复制源码","panel.copied":"源码已复制","panel.copyFailed":"复制失败","panel.downloadSvg":"下载 SVG","panel.downloadFailed":"下载失败","panel.prev":"上一张图表","panel.next":"下一张图表","panel.of":"第 {current} / {total} 张","panel.loading":"正在渲染图表…","panel.error":"这张图表无法渲染。","panel.empty":"代码块是空的。","panel.retry":"重新读取源码","panel.source":"源码","panel.sourceHint":"消息中的原始代码块仍然保留。","panel.help":"滚轮缩放 · 拖空白平移 · 拖文字选中 · 双击复位","panel.streamingHint":"如果消息仍在生成,可以等生成结束后再重新读取源码。","panel.unknownType":"图表","panel.resize":"拖动调整大小 · 双击恢复默认","panel.locate":"定位到代码块","panel.modeToMulti":"切换为多窗口:每次打开新浮窗","panel.modeToSingle":"切换为单窗口:同一浮窗内切换内容","xstate.loading":"正在解析状态机…","xstate.parseError":"这段代码无法解析出状态机。","xstate.empty":"代码块是空的。","xstate.static":"静态模式:不执行代码,点击事件仅为结构推演","xstate.stopped":"模拟已停止","xstate.run":"运行模拟","xstate.run.hint":"从源码解析出的配置重建状态机并开始模拟;函数体不会执行。","xstate.reset":"重置模拟","xstate.state":"当前状态","xstate.context":"context","xstate.log":"事件日志","xstate.log.empty":"还没有事件。","xstate.initial":"初始","xstate.final":"终态","xstate.parallel":"并行","xstate.history":"历史","xstate.entry":"进入","xstate.exit":"退出","xstate.after":"延迟","xstate.guard":"条件","xstate.actions":"动作","xstate.invoke":"调用","xstate.unresolved":"未解析目标","xstate.opaque":"表达式","xstate.noEvents":"当前状态没有可触发的事件。","section.behavior.mermaid.sample":"打开 Mermaid 示例","section.behavior.xstate.sample":"打开 XState 示例","panel.viewGraph":"事件图视图","panel.viewCards":"卡片视图","panel.copyMermaid":"复制 Mermaid","panel.copyDot":"复制 DOT","panel.graphHelp":"点击箭头或事件标签触发转移 · 事件图不可拖动缩放,节点布局自动生成","section.behavior.sidebar.title":"侧栏文档","section.behavior.sidebar.description":"把查看器延伸到右侧栏打开的文档,例如 Markdown 文件和 Mermaid 源文件。","section.behavior.sidebar.codeBlocks":"侧栏文档的代码块显示查看按钮","section.behavior.sidebar.codeBlocks.hint":"右侧栏文档里的 Mermaid 与状态机代码块,和聊天里一样悬停即显示查看按钮。浮窗开在侧栏旁边,文档保持可见。","section.behavior.sidebar.mermaidFile":"将 Mermaid 文件预览为图表","section.behavior.sidebar.mermaidFile.hint":"在右侧栏打开 .mmd 或 .mermaid 文件时直接渲染为图表,并可切换到源码。关闭后按纯文本打开。","mermaidFile.title":"Mermaid 图表","mermaidFile.loading":"正在读取图表源码…","mermaidFile.rendering":"正在渲染图表…","mermaidFile.empty":"这个文件是空的。","mermaidFile.error":"这个文件无法渲染为 Mermaid 图表。","mermaidFile.viewSource":"查看源码","mermaidFile.viewDiagram":"查看图表","mermaidFile.renderAgain":"重新渲染"};function Zd(e,t="",r={}){if(e===null||typeof e!="object"||Array.isArray(e))return r;for(let[n,i]of Object.entries(e)){let a=t===""?n:`${t}.${n}`;typeof i=="string"?r[a]=i:Zd(i,a,r)}return r}var c$={en:Zd(mg),zh:Zd(yg)};function xg(e){e.effect(()=>e.locale.register(ei,c$),"dsh-halcyon-uiux: locale dictionaries")}var bg=6,wg=Object.freeze({windows:[]});function vg(e,t){return t===0?0:Math.max(0,Math.min(t-1,e))}function d$(e,t,r,n,i,a){let l=r.map(s=>({kind:s.kind,source:s.source,banner:s.banner}));return{id:e,z:t,items:l,index:vg(n,l.length),returnFocus:i,avoid:a}}var zl=class{state=wg;seq=0;zSeq=0;listeners=new Set;getSnapshot=()=>this.state;subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});top(){let t=this.state.windows;if(t.length!==0)return t.reduce((r,n)=>n.z>r.z?n:r)}open(t,r,n,i,a=null){if(t.length===0)return;let l=d$(++this.seq,++this.zSeq,t,r,n,a);this.set({windows:i?[...this.state.windows.slice(-(bg-1)),l]:[l]})}openSource(t,r=null,n=!1,i="mermaid",a=null){let l={id:++this.seq,z:++this.zSeq,items:[{kind:i,source:t,banner:null}],index:0,returnFocus:r,avoid:a};this.set({windows:n?[...this.state.windows.slice(-(bg-1)),l]:[l]})}close(t){this.state.windows.some(r=>r.id===t)&&this.set({windows:this.state.windows.filter(r=>r.id!==t)})}closeAll(){this.state.windows.length!==0&&this.set(wg)}raise(t){let r=this.top();r!==void 0&&r.id===t||this.patch(t,n=>({...n,z:++this.zSeq}))}setIndex(t,r){this.patch(t,n=>{let i=vg(r,n.items.length);return i===n.index?n:{...n,index:i}})}next(t){let r=this.find(t);r!==void 0&&this.setIndex(t,r.index+1)}previous(t){let r=this.find(t);r!==void 0&&this.setIndex(t,r.index-1)}updateSource(t,r,n){this.patch(t,i=>{let a=i.items[r];if(a===void 0||a.source===n)return i;let l=i.items.map((s,o)=>o===r?{...s,source:n}:s);return{...i,items:l}})}find(t){return this.state.windows.find(r=>r.id===t)}patch(t,r){let n=this.state.windows,i=!1,a=n.map(l=>{if(l.id!==t)return l;let s=r(l);return s!==l&&(i=!0),s});i&&this.set({windows:a})}set(t){this.state=t;for(let r of this.listeners)r()}};function $g(e){return De.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function Wi(e){let t=De.useCallback(i=>e.subscribe(i),[e]),r=De.useCallback(()=>e.getSnapshot(),[e]),n=De.useSyncExternalStore(t,r,r);return{settings:Pl(n.value),status:n.status,writable:n.status==="ready"&&n.writable,revision:n.revision}}function Qa(e,t,r){return e.mutate([{op:"set",path:[...t],value:r}])}function Lt(e,t){return ue("svg",{width:e.size??16,height:e.size??16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:!1,className:e.className},t)}function pn(e){return Lt(e,[ue("rect",{key:"a",x:3,y:3,width:7,height:5,rx:1.5}),ue("rect",{key:"b",x:14,y:16,width:7,height:5,rx:1.5}),ue("rect",{key:"c",x:14,y:3,width:7,height:5,rx:1.5}),ue("path",{key:"d",d:"M10 5.5h4M17.5 8v8M10 18.5h4"})])}function kg(e){return Lt(e,[ue("circle",{key:"a",cx:18,cy:5,r:2.6}),ue("circle",{key:"b",cx:6,cy:12,r:2.6}),ue("circle",{key:"c",cx:18,cy:19,r:2.6}),ue("path",{key:"d",d:"M8.4 10.8 15.6 6.4M8.4 13.2l7.2 4.4"})])}function Sn(e){return Lt(e,[ue("circle",{key:"a",cx:5,cy:6,r:2.2}),ue("circle",{key:"b",cx:19,cy:6,r:2.2}),ue("rect",{key:"c",x:9.5,y:14.5,width:5,height:5,rx:1.2}),ue("path",{key:"d",d:"M7.2 6h9.6M12 6v8.5M5 8.2v4.3a2 2 0 0 0 2 2h5M19 8.2v4.3a2 2 0 0 1-2 2h-5"})])}function Mg(e){return Lt(e,ue("path",{d:"M12 5v14M5 12h14"}))}function _g(e){return Lt(e,ue("path",{d:"M5 12h14"}))}function Qd(e){return Lt(e,[ue("path",{key:"a",d:"M8 3H5a2 2 0 0 0-2 2v3M16 3h3a2 2 0 0 1 2 2v3M8 21H5a2 2 0 0 1-2-2v-3M16 21h3a2 2 0 0 0 2-2v-3"}),ue("rect",{key:"b",x:7,y:7,width:10,height:10,rx:1.5})])}function Eg(e){return Lt(e,ue("path",{d:"M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"}))}function Ag(e){return Lt(e,ue("path",{d:"M4 14h6v6M20 10h-6V4M14 10l7-7M3 21l7-7"}))}function Ja(e){return Lt(e,[ue("rect",{key:"a",x:8,y:8,width:12,height:12,rx:2}),ue("path",{key:"b",d:"M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2"})])}function Fl(e){return Lt(e,[ue("path",{key:"a",d:"M12 3v12"}),ue("path",{key:"b",d:"m7 10 5 5 5-5"}),ue("path",{key:"c",d:"M4 19v1a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-1"})])}function Tg(e){return Lt(e,ue("path",{d:"M6 6l12 12M18 6L6 18"}))}function Sg(e){return Lt(e,ue("path",{d:"M15 5l-7 7 7 7"}))}function Cg(e){return Lt(e,ue("path",{d:"M9 5l7 7-7 7"}))}function Wl(e){return Lt(e,[ue("path",{key:"a",d:"M12 3 2.5 20h19L12 3Z"}),ue("path",{key:"b",d:"M12 9v5M12 17.5v.1"})])}function Ig(e){return Lt(e,[ue("circle",{key:"a",cx:12,cy:12,r:7}),ue("circle",{key:"b",cx:12,cy:12,r:1.6}),ue("path",{key:"c",d:"M12 2v3M12 19v3M2 12h3M19 12h3"})])}function Ng(e){return Lt(e,ue("path",{d:"m8 7-5 5 5 5M16 7l5 5-5 5"}))}function Rg(e){return Lt(e,[ue("path",{key:"a",d:"m12 2 10 5-10 5L2 7l10-5Z"}),ue("path",{key:"b",d:"m2 12 10 5 10-5"}),ue("path",{key:"c",d:"m2 17 10 5 10-5"})])}function Og(e){return Lt(e,ue("rect",{x:4.5,y:4.5,width:15,height:15,rx:2.5}))}function Lg(e){return Lt(e,[ue("rect",{key:"a",x:4,y:4.5,width:16,height:15,rx:2.5}),ue("path",{key:"b",d:"M4 9.5h16"}),ue("path",{key:"c",d:"m9 15 3-3 3 3"})])}function Dg(e){return Lt(e,[ue("rect",{key:"a",x:4,y:4.5,width:16,height:15,rx:2.5}),ue("path",{key:"b",d:"M4 9.5h16"}),ue("path",{key:"c",d:"m9 13 3 3 3-3"})])}function Pg(e){return Lt(e,[ue("circle",{key:"a",cx:12,cy:12,r:8}),ue("path",{key:"b",d:"M12 4a8 8 0 0 1 0 16Z",fill:"currentColor",stroke:"none",opacity:.32})])}function Bl(e){return Lt(e,[ue("path",{key:"a",d:"M8 4.5h9.5A2.5 2.5 0 0 1 20 7v9.5"}),ue("rect",{key:"b",x:4,y:8,width:13,height:11.5,rx:2.5}),ue("path",{key:"c",d:"M4 12h13"})])}var zg=Object.freeze({visible:!1,banner:null,anchor:null,kind:"mermaid"}),eh=.5,Bi=160,h$=3500,u$=36,f$=28,p$=6;function th(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Wg(e){if(e===null||typeof e!="object")return null;let t=e;return typeof t.nodeType!="number"?null:t.nodeType===1?t:t.parentElement}function Jd(e){let t=Wg(e);return t!==null&&t.closest("[data-halcyon-trigger]")!==null}function g$(e){let t=Wg(e);return t===null?!1:th(t)&&t.isContentEditable?!0:t.closest('input, textarea, select, [contenteditable=""], [contenteditable="true"]')!==null}function m$(e,t){return e===void 0||t===void 0?e===t:Math.abs(e-t)<eh}function Fg(e,t){return Math.abs(e.x-t.x)<eh&&Math.abs(e.y-t.y)<eh&&m$(e.limit,t.limit)}function Bg(e){let{enabled:t,onOpen:r,t:n}=e,[i,a]=De.useState(zg),[l,s]=De.useState(!1),o=De.useRef(t);o.current=t;let c=De.useRef(e.kinds);c.current=e.kinds;let h=De.useRef(e.surfaces);h.current=e.surfaces;let u=De.useRef(r);u.current=r;let d=De.useRef(null),p=De.useRef(null),g=De.useRef(!1),m=De.useRef(null),v=De.useRef(null),x=De.useCallback(()=>{m.current!==null&&(clearTimeout(m.current),m.current=null)},[]),k=De.useCallback(()=>{x(),d.current=null,p.current=null,g.current=!1,a(G=>G.banner===null&&!G.visible?G:zg)},[x]),b=De.useCallback((G=Bi)=>{x(),m.current=setTimeout(()=>{m.current=null,k()},G)},[x,k]),C=De.useCallback((G,Z)=>{if(!c.current[Z]||!h.current.sidebar&&Qn(G)==="sidebar"){b(0);return}x();let z=Vd(G),W=g.current&&d.current===G&&p.current!==null&&Fg(p.current,z);d.current=G,p.current=z,g.current=!0,!W&&a({visible:!0,banner:G,anchor:z,kind:Z})},[x,b]),N=De.useCallback(G=>{if(G===null||!o.current||!h.current.sidebar&&Qn(G)==="sidebar")return;let Z=qa(G);if(Z===null||!c.current[Z])return;let z=pg(G,Z),W=z.findIndex(E=>E.banner===G),A=(W>=0?z[W]:void 0)??{banner:G,source:Pi(G),language:Il(G),kind:Z,surface:Qn(G)??"chat"},$=typeof document>"u"?null:document.activeElement,y=null;if(th($)&&G.contains($)&&(y=$),y===null){let E=G.querySelector("button");y=th(E)?E:G}u.current(A,z,W>=0?W:0,y),k()},[k]);De.useEffect(()=>{if(!t||typeof document>"u"){k();return}let G=!1,Z=null,z=null,W=()=>{Z===null&&(Z=window.requestAnimationFrame(()=>{if(Z=null,G)return;let T=d.current;if(T===null)return;if(!T.isConnected||qa(T)===null){k();return}let _=Vd(T),M=p.current;M!==null&&Fg(M,_)||(p.current=_,a(U=>U.banner===T?{...U,anchor:_}:U))}))},S=T=>{if(Jd(T.target)){x();return}let _=Xa(T.target);if(_!==null){C(_.banner,_.kind);return}g.current&&b(Bi)},A=T=>{if(T.pointerType!=="touch")return;let _=Xa(T.target);_!==null&&(C(_.banner,_.kind),b(h$))},$=T=>{if(Jd(T.target)){x();return}let _=Xa(T.target);if(_!==null){C(_.banner,_.kind);return}b(Bi)},y=()=>{z!==null&&clearTimeout(z),z=setTimeout(()=>{if(z=null,G)return;let T=d.current;if(T===null)return;let _=document.activeElement;_!==null&&(T.contains(_)||Jd(_))||b(Bi)},0)},E=T=>{if(g$(T.target))return;if(T.key==="Escape"){if(!g.current&&d.current===null)return;k();return}if(!T.altKey||T.key!=="Enter")return;let _=Xa(T.target),M=d.current??_?.banner??null;M!==null&&(T.preventDefault(),N(M))},w=()=>{d.current!==null&&W()};return document.addEventListener("pointermove",S,{passive:!0}),document.addEventListener("pointerdown",A,{passive:!0}),document.addEventListener("focusin",$),document.addEventListener("focusout",y),document.addEventListener("keydown",E),document.addEventListener("scroll",w,!0),window.addEventListener("resize",w,{passive:!0}),()=>{G=!0,document.removeEventListener("pointermove",S),document.removeEventListener("pointerdown",A),document.removeEventListener("focusin",$),document.removeEventListener("focusout",y),document.removeEventListener("keydown",E),document.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w),Z!==null&&window.cancelAnimationFrame(Z),z!==null&&clearTimeout(z),x()}},[t,x,k,N,b,C]),De.useEffect(()=>{e.surfaces.sidebar||k()},[e.surfaces.sidebar,k]);let{visible:R,anchor:O,kind:P}=i;if(De.useLayoutEffect(()=>{let G=O?.limit,Z=v.current?.scrollWidth??0;s(G!==void 0&&O!==null&&O.x+u$+Z>G)},[O]),!t||O===null)return null;let H=O.limit,I=l&&H!==void 0?Math.min(O.x,H-f$-p$):O.x;return ue("button",{type:"button",className:"hx-trigger","data-halcyon-trigger":"","data-visible":R?"true":"false","data-compact":l?"true":"false",style:{left:`${I}px`,top:`${O.y}px`},tabIndex:R?0:-1,"aria-hidden":!R,"aria-label":n(P==="xstate"?"trigger.xstate.open":"trigger.open"),title:n("trigger.hint"),onPointerEnter:()=>x(),onFocus:()=>x(),onPointerLeave:()=>b(Bi),onBlur:()=>b(Bi),onClick:()=>N(d.current),onPointerDown:G=>G.stopPropagation()},P==="xstate"?ue(Sn,{size:13,className:"hx-trigger__icon"}):ue(pn,{size:13,className:"hx-trigger__icon"}),ue("span",{ref:v,className:"hx-trigger__label"},n(P==="xstate"?"trigger.xstate.label":"trigger.label")))}function Hl(e,t){if(e===void 0||e==="")throw new Error("No SVG to download");let r=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),n=URL.createObjectURL(r);try{let i=document.createElement("a");i.href=n,i.download=`mermaid-${t!==void 0&&t!==""?t:"diagram"}-${Date.now()}.svg`,i.rel="noopener",i.click()}finally{URL.revokeObjectURL(n)}}var y$=[["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 x$(e){for(let[t,r,n]of y$)if(n.test(e))return{type:t,mermaidType:r};return null}var Je=class extends Error{code;type;mermaidType;line;column;snippet;constructor(e,t="syntax",r={}){super(e),this.name="PeleError",this.code=t,this.type=r.type??null,this.mermaidType=r.mermaidType??null,this.line=r.line??0,this.column=r.column??0,this.snippet=r.snippet??""}};function qf(e,t){let r=1,n=0;for(let s=e.indexOf(`
8
+ `);s!==-1&&s<t;s=e.indexOf(`
9
+ `,s+1))r++,n=s+1;let i=e.indexOf(`
10
+ `,t);i===-1&&(i=e.length);let a=t-n+1,l=e.slice(n,i);return{line:r,column:a,snippet:l+`
11
+ `+"-".repeat(a-1)+"^"}}function vt(e,t,r,n,i=!1){let a=qf(t,r),l=i?`Lexical error on line ${a.line}. Unrecognized text.`:`Parse error on line ${a.line}:`,s=i?`${l}
12
+ ${a.snippet}`:`${l}
13
+ ${a.snippet}
14
+ ${n}`;return new Je(s,"syntax",{type:e,...a})}var b$="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",jl;function w$(e){if(!jl){jl=new Map;for(let t of b$.split(",")){let r=t.indexOf(":");jl.set(t.slice(0,r),String.fromCodePoint(Number(t.slice(r+1))))}}return jl.get(e)}function Hg(e,t){return e>0&&e<=1114111&&(e<55296||e>57343)?String.fromCodePoint(e):t}var v$=/&(?:#(\d+)|#[xX]([0-9a-fA-F]+)|(\w+));/g,jg="fl°",$$="¶ß";function k$(e){let t="",r=0,n=e.indexOf(jg);for(;n!==-1;){let i=e.indexOf("¶",n+2);if(i===-1)break;if(e[i+1]==="ß"){let a=e[n+2]==="°";t+=e.slice(r,n)+(a?"&#":"&")+e.slice(n+(a?3:2),i)+";",r=i+2}n=e.indexOf(jg,i+1)}return r===0?e:t+e.slice(r)}function It(e){return e.includes($$)&&(e=k$(e)),e.includes("&")&&(e=e.replace(v$,(t,r,n,i)=>r?Hg(Number(r),t):n?Hg(parseInt(n,16),t):w$(i)??t)),e}var Ps,zs=new Map;function M$(e,t){let r=Ps,n=zs;Ps=e,zs=new Map;try{return t()}finally{Ps=r,zs=n}}function Xf(e){if(Ps===void 0)return"";let t=zs.get(e);return t===void 0&&(t=Ps(e)??"",zs.set(e,t)),t}var Qr,ya=new Map;function _$(e,t){let r=Qr,n=ya;Qr=e,ya=new Map;try{return t()}finally{Qr=r,ya=n}}function E$(){return Qr!==void 0}function Ug(e){return Number.isFinite(e)&&e>0}function A$(e,t){if(Qr===void 0)return;let r=t+`
15
+ `+e;if(ya.has(r))return ya.get(r);let n=Qr(e,t)??void 0,i=n&&Ug(n.width)&&Ug(n.height)&&typeof("svg"in n?n.svg:n.html)=="string"?n:void 0;return ya.set(r,i),i}function T$(e){if(Qr===void 0)return e();let t=Qr;Qr=void 0;try{return e()}finally{Qr=t}}var ha=class{constructor(e){this.message=e}message},Dx=64;function ic(e,t,r){t==="__proto__"?Object.defineProperty(e,t,{value:r,enumerable:!0,writable:!0,configurable:!0}):e[t]=r}var S$=class{lines;i=0;constructor(e){this.lines=(e.includes("\r")?e.replace(/\r\n?/g,`
16
+ `):e).split(`
17
+ `)}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}},C$=/^[-+]?(?:0|[1-9][0-9]*)$/,I$=/^[-+]?0x[0-9a-fA-F]+$/,N$=/^[-+]?0o[0-7]+$/,R$=/^[-+]?0b[01]+$/,O$=/^[-+]?(?:[0-9][0-9]*(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][-+]?[0-9]+)?$/,L$=/[\s#:,[\]{}&*!|>'"%@`]/;function es(e){return e===" "||e===" "||e===`
18
+ `||e==="\r"}function rh(e){let t=e[0],r,n;if(t==='"'||t==="'"){let a=1;for(;;){if(a>=e.length)return null;let l=e[a];if(t==='"'&&l==="\\")a+=2;else if(l===t){if(t==='"'||e[a+1]!=="'")break;a+=2}else a++}for(r=a+1,n=r;es(e[n]);)n++;if(e[n]!==":")return null}else{if(t===void 0||L$.test(t)||t==="-"&&(e.length<2||es(e[1])||e[1]===":"||e[1]==="#"))return null;for(n=1;n<e.length&&e[n]!==":"&&e[n]!=="#";)n++;if(e[n]!==":")return null;for(r=n;es(e[r-1]);)r--}let i=n+1;if(i<e.length&&!es(e[i]))return null;for(;es(e[i]);)i++;return{key:e.slice(0,r),length:i}}function rf(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(C$.test(t)||O$.test(t))return Number(t);if(I$.test(t)||N$.test(t)||R$.test(t)){let n=t[0]==="-",i=Number(n||t[0]==="+"?t.slice(1):t);return n?-i:i}return/^[-+]?\.(?:inf|Inf|INF)$/.test(t)?t[0]==="-"?-1/0:1/0:/^\.(?:nan|NaN|NAN)$/.test(t)?NaN:t}var Yg={0:"\0",a:"\x07",b:"\b",t:" ",n:`
19
+ `,v:"\v",f:"\f",r:"\r",e:"\x1B"," ":" ",'"':'"',"/":"/","\\":"\\",N:"…",_:" ",L:"\u2028",P:"\u2029"};function Fs(e){if(!e.includes(`
20
+ `))return e;let t=e.split(`
21
+ `),r=t.length-1;for(let n=0;n<=r;n++){let i=t[n],a=0,l=i.length;if(n>0)for(;a<l&&(i.charCodeAt(a)===32||i.charCodeAt(a)===9);)a++;if(n<r)for(;l>a&&(i.charCodeAt(l-1)===32||i.charCodeAt(l-1)===9);)l--;t[n]=i.slice(a,l)}return t.join(`
22
+ `).replace(/\n+/g,n=>n.length===1?" ":`
23
+ `.repeat(n.length-1))}function D$(e){if(!e.includes("\\"))return Fs(e);let t="",r=Fs(e.replace(/\\\n[ \t]*/g,""));for(let n=0;n<r.length;n++){let i=r[n];if(i!=="\\"){t+=i;continue}let a=r[++n];if(a==="x"||a==="u"||a==="U"){let l=a==="x"?2:a==="u"?4:8;t+=String.fromCodePoint(parseInt(r.slice(n+1,n+1+l),16)),n+=l}else if(a in Yg)t+=Yg[a];else throw new Error("YAML: unknown escape sequence")}return t}function pi(e,t,r){for(;t<e.length;){let n=e[t];if(n===" "||n===`
24
+ `||n===" "||n==="\r"||r&&n===",")t++;else if(n==="#"&&(t===0||/\s/.test(e[t-1]))){let i=e.indexOf(`
25
+ `,t);t=i===-1?e.length:i}else break}return t}function Gg(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 xa(e,t,r,n=0){if(n>Dx)throw new Error("YAML: nesting is too deep");t=pi(e,t,!1);let i=e[t];if(i==="{"){let l={};t++;let s=!0;for(;;){if(t=pi(e,t,!1),t>=e.length)throw new ha("YAML: unexpected end of the stream within a flow collection");if(e[t]==="}")return[l,t+1];Gg(e[t],s);let o;[o,t]=xa(e,t,":,}",n+1),t=pi(e,t,!1);let c=null;e[t]===":"&&([c,t]=xa(e,t+1,",}",n+1)),ic(l,String(o),c),t=pi(e,t,!1),s=e[t]===",",s&&t++}}if(i==="["){let l=[];t++;let s=!0;for(;;){if(t=pi(e,t,!1),t>=e.length)throw new ha("YAML: unexpected end of the stream within a flow collection");if(e[t]==="]")return[l,t+1];Gg(e[t],s);let o;[o,t]=xa(e,t,",]",n+1),l.push(o),t=pi(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 ha("YAML: unexpected end of the stream within a double quoted scalar");return[D$(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 ha("YAML: unexpected end of the stream within a single quoted scalar");return[Fs(e.slice(t+1,l)).replace(/''/g,"'"),l+1]}let a=t;for(;a<e.length;){let l=e[a];if(r.includes(l)&&(l!==":"||a+1>=e.length||/[\s,[\]{}]/.test(e[a+1])))break;if(l==="#"&&a>t&&/\s/.test(e[a-1])){let s=e.indexOf(`
26
+ `,a);return[rf(Fs(e.slice(t,a).trim())),s===-1?e.length:s]}a++}return[rf(Fs(e.slice(t,a).trim())),a]}function Ws(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(t)n==="\\"&&t==='"'?r++:n===t&&(t="");else if(n==='"'||n==="'")t=n;else if(n==="#"&&(r===0||e[r-1]===" "||e[r-1]===" "))return e.slice(0,r)}return e}function P$(e,t,r){let n=t[0]===">",i=t.includes("-")?"-":t.includes("+")?"+":"",a=/[1-9]/.exec(t),l=a?r+Number(a[0]):-1,s=[];for(;e.i<e.lines.length;){let h=e.lines[e.i];if(h.trim()===""){s.push(""),e.i++;continue}let u=h.length-h.trimStart().length;if(l===-1){if(u<=r)break;l=u}if(u<l)break;s.push(h.slice(l)),e.i++}let o=0;for(;s.length>0&&s[s.length-1]==="";)s.pop(),o++;let c;if(n){c="";for(let h=0;h<s.length;h++){let u=s[h];if(h>0){let d=s[h-1];u===""?c+=`
27
+ `:d!==""&&(c+=/^[ \t]/.test(d)||/^[ \t]/.test(u)?`
28
+ `:" ")}c+=u}}else c=s.join(`
29
+ `);return s.length===0?i==="+"?`
30
+ `.repeat(o):"":i==="-"?c:i==="+"?c+`
31
+ `.repeat(o+1):c+`
32
+ `}function nh(e,t,r){let n=t[0];if((n==="|"||n===">")&&/^[|>][-+0-9]*\s*(?:#.*)?$/.test(t))return P$(e,t,r);if(n==="{"||n==="["||n==='"'||n==="'"){let a=e.i,l=t,s=0,o=1;for(;;)try{let[c,h]=xa(l,0,""),u=0;for(let p=l.indexOf(`
33
+ `);p!==-1&&p<h;p=l.indexOf(`
34
+ `,p+1))u++;let d=l.indexOf(`
35
+ `,h);if(Ws(l.slice(h,d===-1?l.length:d)).trim()!=="")throw new Error("YAML: unexpected content after a value");return e.i=a+u,c}catch(c){if(!(c instanceof ha))throw c;if(a+s>=e.lines.length)throw new Error(c.message);let h=e.lines.slice(a+s,a+s+o);l+=`
36
+ `+h.join(`
37
+ `),s+=h.length,o*=2}}let i=Ws(t).trim();for(;e.i<e.lines.length;){let a=e.lines[e.i];if(a.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+=`
38
+ `.repeat(s-e.i),e.i=s;continue}if(a.length-a.trimStart().length<=r)break;let l=Ws(a).trim();i+=(i.endsWith(`
39
+ `)?"":" ")+l,e.i++}return rf(i)}function ac(e,t,r=0){if(r>Dx)throw new Error("YAML: nesting is too deep");if(e.skipBlank(),e.i>=e.lines.length)return null;let n=e.indent();if(n<t)return null;let i=e.lines[e.i].slice(n);if(i==="-"||i.startsWith("- ")){let l=[];for(;e.i<e.lines.length&&(e.skipBlank(),!(e.i>=e.lines.length||e.indent()!==n));){let s=e.lines[e.i].slice(n);if(s!=="-"&&!s.startsWith("- "))break;let o=s.slice(1),c=o.length-o.trimStart().length+1,h=Ws(o).trim();h===""?(e.i++,l.push(ac(e,n+1,r+1))):rh(h)!==null?(e.lines[e.i]=" ".repeat(n+c)+o.trimStart(),l.push(ac(e,n+c,r+1))):(e.i++,l.push(nh(e,o.trim(),n)))}return l}if(rh(i)===null)return e.i++,nh(e,i.trim(),n-1);let a={};for(;e.i<e.lines.length&&(e.skipBlank(),!(e.i>=e.lines.length));){let l=e.indent();if(l<n)break;if(l>n)throw new Error("YAML: bad indentation of a mapping entry");let s=e.lines[e.i].slice(n),o=rh(s);if(!o)throw new Error("YAML: can not read a block mapping entry");let c=String(xa(o.key,0,"")[0]),h=s.slice(o.length);if(e.i++,Ws(h).trim()==="")if(e.skipBlank(),e.i<e.lines.length){let u=e.indent(),d=e.lines[e.i].slice(u),p=d==="-"||d.startsWith("- ");ic(a,c,u>n||p&&u===n?ac(e,p?n:n+1,r+1):null)}else ic(a,c,null);else ic(a,c,nh(e,h.trim(),n))}return a}function va(e){let t=e.trim();if(t[0]==="{"||t[0]==="[")try{let[i,a]=xa(t,0,"");if(pi(t,a,!1)===t.length)return i}catch(i){throw i instanceof ha?new Error(i.message):i}let r=new S$(e),n=ac(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 n}function Xe(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 Kr(e){return e===32||e===9}function _c(e){return e===10||e===13||e===8232||e===8233}function gt(e){return e>=48&&e<=57}function $a(e){return e>=65&&e<=90||e>=97&&e<=122}function Px(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function nt(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95}var z$=/^\s*%%(?!{)[^\n]+\n?/gm,Hi=/%{2}{\s*(?:(\w+)\s*:|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi,F$=/<(\w+)([^>]*)>/g,W$=/="([^"]*)"/g,B$=new Set(["__proto__","constructor","prototype"]);function H$(e){return(e.includes("%%")?e.replace(z$,""):e).trimStart()}function Ul(e){return e===`
40
+ `||e==="\r"}function ih(e){return e!==void 0&&/\s/.test(e)}function j$(e){let t=0;for(;t<e.length&&ih(e[t])&&!Ul(e[t]);)t++;let r=e.slice(0,t);if(!e.startsWith("---",t))return;let n=[];for(let u=t+3;u<e.length&&ih(e[u]);u++)Ul(e[u])&&n.push(u);if(n.length===0)return;let i=r+"---",a=u=>{if(!Ul(e[u])||!e.startsWith(i,u+1))return-1;let d=-1;for(let p=u+1+i.length;p<e.length&&ih(e[p]);p++)Ul(e[p])&&(d=p);return d},l=`
41
+ `+i,s=-1;for(let u=e.lastIndexOf(l);u>n[0];u=e.lastIndexOf(l,u-1))if(a(u)!==-1){s=u;break}if(s===-1)return;let o=n[0];for(let u of n)u<s&&(o=u);let c=o+1,h=c>0?c-1:0;for(let u=e.indexOf(l,h);u!==-1&&u<=s;u=e.indexOf(l,u+1)){if(u<c)continue;let d=a(u);if(d!==-1)return{indent:r,body:e.slice(c,u),length:d+1}}}function vi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ec(e,t){for(let r of Object.keys(t)){if(B$.has(r))continue;let n=t[r],i=e[r];vi(n)&&vi(i)?Ec(i,n):vi(n)?e[r]=Ec({},n):e[r]=n}return e}function U$(e,t){if(!e.includes("%%{"))return e;let r=e.trim().replace(/'/g,'"');Hi.lastIndex=0;let n;for(;(n=Hi.exec(r))!==null;){n.index===Hi.lastIndex&&Hi.lastIndex++;let i=n[1]??n[2];if(i==="wrap")t.wrap=!0;else if((i==="init"||i==="initialize")&&n[4])try{let a=JSON.parse(n[4].trim());vi(a)&&Ec(t,a)}catch{}}return Hi.lastIndex=0,e.replace(Hi,"")}function Y$(e){let t=e.includes("\r")?e.replace(/\r\n?/g,`
42
+ `):e,r=t.includes("<")?t.lastIndexOf(">"):-1;r>0&&(t=t.slice(0,r+1).replace(F$,(s,o,c)=>"<"+o+c.replace(W$,"='$1'")+">")+t.slice(r+1));let n={},i,a=0,l=t.includes("---")?j$(t):void 0;if(l){let s=l.indent?l.body.split(`
43
+ `).map(c=>c.startsWith(l.indent)?c.slice(l.indent.length):c).join(`
44
+ `):l.body,o;try{o=va(s)}catch(c){throw new Je(`Front matter is not valid YAML. ${c.message}`,"syntax")}if(vi(o)&&(o.title&&(i=String(o.title)),vi(o.config)&&Ec(n,o.config),o.displayMode)){let c=vi(n.gantt)?n.gantt:n.gantt={};c.displayMode=String(o.displayMode)}for(let c=t.indexOf(`
45
+ `);c!==-1&&c<l.length;c=t.indexOf(`
46
+ `,c+1))a++;t=t.slice(l.length)}return t=U$(t,n),{text:H$(t),title:i,config:n,withComments:t,lineOffset:a}}var G$=/#\w+;/g,V$=/^\+?\d+$/,ah=new RegExp("[\\n\\r\u2028\u2029]","g");function Vg(e,t){let r=e.indexOf(t);if(r===-1)return e;let n="",i=0;for(;r!==-1;){ah.lastIndex=r;let a=ah.test(e)?ah.lastIndex-1:e.length,l=!1,s=-1;for(let o=r+t.length;o<a;o++){let c=e.charCodeAt(o);if(c===58)l=!0;else if(c===35){if(l){s=o;break}}else Xe(c)&&(l=!1)}if(s!==-1){let o=e.lastIndexOf(";",a-1);o>s&&(n+=e.slice(i,o),i=o+1)}r=a>=e.length?-1:e.indexOf(t,a+1)}return i===0?e:n+e.slice(i)}function q$(e){return e.includes("#")?Vg(Vg(e,"style"),"classDef").replace(G$,t=>{let r=t.substring(1,t.length-1);return(V$.test(r)?"fl°°":"fl°")+r+"¶ß"}):e}var X$="7q7q9vfgfgopij5b9999atg87q997q7qfgfgfgfgfgfgfgfgfgfg7q7qg8g8g8fgs7ijijk2k2ijgzlmk27qdwijfgn5k2lmijlmk2ijgzk2ijq8ijijgz7q7q7qd1fg99fgfgdwfgfg7qfgfg6666dw66n5fgfgfgfg99dw7qfgdwk2dwdwdw9a789ag8",K$="7q99d6fgfgopk26m9999atg87q997q7qfgfgfgfgfgfgfgfgfgfg9999g8g8g8gzr3k2k2k2k2ijgzlmk27qfgk2gzn5k2lmijlmk2ijgzk2ijq8ijijgz997q99g8fg99fggzfggzfg99gzgz7q7qfg7qopgzgzgzgzatfg99gzfglmfgfgdwat7satg8";function qg(e){let t=new Uint16Array(95);for(let r=0;r<95;r++)t[r]=parseInt(e.substr(r*2,2),36);return t}var Z$,Q$;function J$(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 ek(e){return e>=768&&e<=879||e>=8203&&e<=8207||e>=56320&&e<=57343||e>=65024&&e<=65039||e===65279}var tk={width(e,t,r){let n=(r&4)!==0,i=r&1?Q$??=qg(K$):Z$??=qg(X$),a=0;for(let l=0;l<e.length;l++){let s=e.charCodeAt(l);if(!(s<32))if(s<127)a+=n?600:i[s-32];else{if(ek(s))continue;J$(s)?a+=n?1200:1e3:a+=n?600:580}}return a*t/1e3}};function rk(){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}var nk=2e4;function Xg(){let e=globalThis;return e.document?.fonts??e.fonts}function ik(e,t,r){try{return e?.check(t,r)??!0}catch{return!0}}function ak(e,t="monospace"){let r=rk();if(!r)return null;let n=new Map,i="",a=Xg()?.size;return{width(l,s,o){let c=Xg();c?.size!==a&&(a=c?.size,n.clear());let h=(o&2?"italic ":"")+(o&1?"bold ":"")+s+"px "+(o&4?t:e),u=n.get(h);u||n.set(h,u=new Map);let d=u.get(l);return d===void 0&&(h!==i&&(r.font=i=h),d=r.measureText(l).width,ik(c,h,l)&&(u.size>=nk&&u.clear(),u.set(l,d))),d}}}var nf=new Map;function bt(e="sans-serif",t="monospace"){let r=e+`
47
+ `+t,n=nf.get(r);return n||(n=ak(e,t)??tk,nf.set(r,n)),n}function sk(){nf.clear()}function Bs(e){return e.ownerDocument?.defaultView??globalThis}function Kg(e,t){let r=e.clientWidth-(parseFloat(t.paddingLeft)||0)-(parseFloat(t.paddingRight)||0);return r>0?r:0}function lk(e,t,r,n,i){let a=t.width/r,l=t.height/r,s=(o,c,h)=>c>=h?Math.min(Math.max(o,h-c),0):Math.min(Math.max(o,0),h-c);return{x:s(n,a,e.width),y:s(i,l,e.height),width:a,height:l}}var ji=1.25,Yl=48,ok="--_bg:var(--pele-bg,#fff);--_fg:var(--pele-fg,#1f1f1f);--_b:var(--pele-border,#8a8a8a);position:absolute;top:var(--pele-zoom-top,8px);right:var(--pele-zoom-right,8px);bottom:var(--pele-zoom-bottom,auto);left:var(--pele-zoom-left,auto);display:flex;flex-direction:column;gap:2px;padding:2px;width:auto;max-width:none;border:1px solid var(--_b);border-radius:var(--pele-radius,4px);background:var(--_bg);color:var(--_fg);line-height:0",ck="appearance:none;display:grid;place-items:center;width:24px;height:24px;margin:0;padding:0;border:0;border-radius:calc(var(--pele-radius,4px) - 1px);background:transparent;color:inherit;font:inherit;cursor:pointer",dk={zoomIn:"M5 12h14M12 5v14",zoomOut:"M5 12h14",reset:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8M3 3v5h5"},hk={zoomIn:"Zoom in",zoomOut:"Zoom out",reset:"Reset zoom"};function uk(e,t,r){let n=null,i={width:0,height:0},a={width:0,height:0},l={width:0,height:0},s=!1,o="",c={width:"",height:"",maxWidth:"",margin:"",display:""},h=0,u=0,d=0,p=0,g=()=>Bs(e),m=()=>i.width>0&&a.width>0?a.width/i.width:1,v=()=>Math.max(m(),t.maxScale??3),x=()=>n!==null&&i.width>0&&(t.always===!0||m()<.999),k=()=>{if(!n||h!==0)return;let J=n.getBoundingClientRect();a={width:J.width,height:J.height},l={width:Math.max(a.width,e.clientWidth),height:Math.max(a.height,e.clientHeight)},s=l.width>a.width+1||l.height>a.height+1,s||(l=a);let te=g().getComputedStyle(e);o=["Top","Right","Bottom","Left"].map(ae=>`${-(parseFloat(te.getPropertyValue(`padding-${ae.toLowerCase()}`))||0)}px`).join(" ")},b,C={},N=!1,R=()=>{if(t.controls===!1)return;let J=x();if(!b){if(!J)return;let ae=e.ownerDocument;b=ae.createElement("div"),b.className="pele pele-zoom",b.setAttribute("style",ok);let ee={zoomIn:()=>H((h||m())*ji*ji),zoomOut:()=>H((h||m())/(ji*ji)),reset:()=>P()};for(let re of["zoomIn","zoomOut","reset"]){let de=ae.createElement("button"),ye=t.labels?.[re]??hk[re];de.type="button",de.className=`pele-zoom-${re==="zoomIn"?"in":re==="zoomOut"?"out":"reset"}`,de.setAttribute("style",ck),de.setAttribute("aria-label",ye),de.title=ye,de.innerHTML=`<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${dk[re]}"/></svg>`,de.addEventListener("click",ee[re]),C[re]=de,b.append(de)}}J&&!N&&g().getComputedStyle(e).position==="static"&&(e.style.position="relative",N=!0),J&&b.parentNode!==e&&e.append(b),b.hidden=!J,b.style.display=J?"flex":"none";let te=(ae,ee)=>{ae&&(ae.disabled=ee,ae.style.opacity=ee?"0.35":"",ae.style.cursor=ee?"default":"pointer")};te(C.zoomIn,(h||m())>=v()*.999),te(C.zoomOut,h===0),C.reset&&(C.reset.style.display=h===0?"none":"grid")},O=J=>b!==void 0&&J.target instanceof g().Node&&b.contains(J.target),P=()=>{n&&(h=0,n.setAttribute("viewBox",`0 0 ${i.width} ${i.height}`),n.style.width=c.width,n.style.height=c.height,n.style.maxWidth=c.maxWidth,n.style.margin=c.margin,n.style.display=c.display,n.style.cursor="",n.style.userSelect="",k(),n.style.touchAction=x()?"pan-y":"",x()?n.setAttribute("tabindex","0"):n.removeAttribute("tabindex"),le(x()),R())},H=(J,te,ae)=>{if(!n||(h===0&&k(),!x()))return;let ee=h||m(),re=Math.min(Math.max(J,m()),v());if(re<=m()*1.001){P();return}let de=n.getBoundingClientRect(),ye=te??de.left+de.width/2,oe=ae??de.top+de.height/2,xe=(h?u:0)+(ye-de.left)/ee,fe=(h?d:0)+(oe-de.top)/ee;h=re;let pe=de;s&&(n.style.maxWidth="none",n.style.margin=o,n.style.display="block",n.style.width=`${l.width}px`,n.style.height=`${l.height}px`,pe=n.getBoundingClientRect()),I(xe-(ye-pe.left)/h,fe-(oe-pe.top)/h),n.style.cursor="grab",n.style.userSelect="none",n.style.touchAction="none",R()},I=(J,te)=>{if(!n)return;let ae=lk(i,l,h,J,te);u=ae.x,d=ae.y,n.setAttribute("viewBox",`${u} ${d} ${ae.width} ${ae.height}`)},G=(J,te)=>{h!==0&&I(u-J/h,d-te/h)},Z=()=>{S();let J=e.clientWidth+e.clientHeight;J!==p&&(p=J,P())},z,W,S=()=>{if(!r)return;let J=g();J!==W&&(z?.disconnect(),W=J,z=J.ResizeObserver?new J.ResizeObserver(Z):void 0,z?.observe(e))},A=()=>{S();let J=e.firstElementChild;if(n=J&&J.localName==="svg"?J:null,h=0,!n){b?.remove(),le(!1);return}i={width:Number(n.getAttribute("width"))||0,height:Number(n.getAttribute("height"))||0},c={width:n.style.width,height:n.style.height,maxWidth:n.style.maxWidth,margin:n.style.margin,display:n.style.display},P()},$=new Map,y=!1,E=0,w=0,T=()=>{let[J,te]=[...$.values()];return{distance:Math.hypot(J.x-te.x,J.y-te.y),x:(J.x+te.x)/2,y:(J.y+te.y)/2}},_=J=>{!x()||O(J)||J.pointerType==="mouse"&&J.button!==0||($.set(J.pointerId,{x:J.clientX,y:J.clientY}),E=0,$.size===2&&(w=T().distance),($.size===2||h!==0)&&(e.setPointerCapture?.(J.pointerId),n&&(n.style.cursor="grabbing")))},M=J=>{let te=$.get(J.pointerId);if(te){if($.size===2){let ae=T();$.set(J.pointerId,{x:J.clientX,y:J.clientY});let ee=T();w>0&&ee.distance>0&&H((h||m())*(ee.distance/ae.distance),ee.x,ee.y),G(ee.x-ae.x,ee.y-ae.y),y=!0;return}$.set(J.pointerId,{x:J.clientX,y:J.clientY}),h!==0&&(E+=Math.abs(J.clientX-te.x)+Math.abs(J.clientY-te.y),E>4&&(y=!0),G(J.clientX-te.x,J.clientY-te.y))}},U=J=>{$.delete(J.pointerId)&&(w=0,$.size===0&&n&&h!==0&&(n.style.cursor="grab"))},j=J=>{y&&(y=!1,J.preventDefault(),J.stopPropagation())},Y=J=>{if(!(J.ctrlKey||J.metaKey)||!x())return;J.preventDefault(),h===0&&k();let te=Math.min(Math.max(-J.deltaY,-24),24);H((h||m())*2**(te*.02),J.clientX,J.clientY)},D=J=>{!x()||O(J)||(J.preventDefault(),h!==0?P():H(Math.max(1,m()*2),J.clientX,J.clientY))},L=J=>{if(!x()||O(J)||J.ctrlKey||J.metaKey||J.altKey)return;let te=J.key;if(te==="+"||te==="=")H((h||m())*ji);else if(te==="-")H((h||m())/ji);else{if(h===0)return;if(te==="0"||te==="Escape")P();else if(te==="ArrowLeft")G(Yl,0);else if(te==="ArrowRight")G(-Yl,0);else if(te==="ArrowUp")G(0,Yl);else if(te==="ArrowDown")G(0,-Yl);else return}J.preventDefault()},F=J=>{if(!n||J.target!==n)return;let te=!0;try{te=n.matches(":focus-visible")}catch{}n.style.outline=te?"":"none"},V=0,X=J=>{x()&&(J.preventDefault(),h===0&&k(),V=h||m())},Q=J=>{if(V===0)return;J.preventDefault();let{scale:te,clientX:ae,clientY:ee}=J;H(V*te,ae,ee)},ne=()=>{V=0},B=[["pointerdown",_],["pointermove",M],["pointerup",U],["pointercancel",U],["click",j,{capture:!0}],["dblclick",D],["keydown",L],["focusin",F]];for(let[J,te,ae]of B)e.addEventListener(J,te,ae);let K=[["wheel",Y,{passive:!1}],["gesturestart",X,{passive:!1}],["gesturechange",Q,{passive:!1}],["gestureend",ne,{passive:!1}]],ie=!1;function le(J){if(J!==ie){ie=J;for(let[te,ae,ee]of K)J?e.addEventListener(te,ae,ee):e.removeEventListener(te,ae,ee);J||(V=0)}}return p=e.clientWidth+e.clientHeight,A(),{get scale(){return h||m()},get fit(){return m()},zoomBy(J){H((h||m())*J)},zoomTo(J){H(J)},reset:P,refresh:A,resized:Z,destroy(){P(),n&&(n.style.touchAction="",n.removeAttribute("tabindex")),b?.remove(),N&&(e.style.position=""),z?.disconnect(),le(!1);for(let[J,te,ae]of B)e.removeEventListener(J,te,ae)}}}function sh(e,t){let r=t?Bs(t).getComputedStyle(t):e;return{family:r.getPropertyValue("--pele-font").trim()||e.fontFamily||void 0,mono:r.getPropertyValue("--pele-font-mono").trim()||void 0}}function fk(e){return[...new Set([e.ownerDocument?.fonts,globalThis.document?.fonts])].filter(t=>t!==void 0)}var lh=new WeakMap;function pk(e){let t=lh.get(e);return t||(t=e.ready.then(()=>{lh.delete(e),sk()}),lh.set(e,t)),t}var af=new WeakMap;function gk(e,t){Promise.all(e.map(pk)).then(()=>{let r=t.deref();r&&af.get(r)?.()})}var Gl=new WeakMap,mk=0,yk=Math.random().toString(36).slice(2,7),xk="position:relative;height:1.3em;margin-top:-1.3em;line-height:1.3;font-size:0.8em;color:var(--pele-error,#e45756);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;",bk="margin:0;font-size:0.8em;font-family:var(--pele-font-mono,monospace);color:var(--pele-error,#e45756);white-space:pre-wrap;";function wk(e){return e instanceof Error?e.message:String(e)}function vk(e){let t=e.split(`
48
+ `).filter(r=>r.trim()!=="");return t.length>1?`${t[0]} ${t[t.length-1]}`:t[0]??""}function $k(e,t,r,n={}){Gl.get(t)?.destroy();let i=r,a=n,l,s,o=!1,c,h,u,d=`pele-${yk}-${++mk}`,p={},g,m=-1,v=!1,x=!1,k=!1,b=(T,_)=>{let{onRender:M,onError:U,sanitize:j,...Y}=a,D={...Y,idPrefix:Y.idPrefix??d,fontFamily:Y.fontFamily??p.family,fontFamilyMono:Y.fontFamilyMono??p.mono,maxWidth:void 0};_&&(h=e.render(l,D),g=void 0);let L=a.maxWidth??Kg(t,T);return m=L,L>0&&L<h.width&&(g??=e.render(l,{...D,maxWidth:1}).svg!==h.svg,g)?e.render(l,{...D,maxWidth:L}):h},C=T=>{a.sanitize?t.replaceChildren(a.sanitize(T)):t.innerHTML=T},N,R=()=>{let T=u?t.firstElementChild:null;if(T?.style&&(T.style.opacity=c===void 0?"":"0.4"),c===void 0){N?.remove(),N=void 0;return}let _=t.ownerDocument;if(!_)return;N??=_.createElement("div"),N.className="pele pele-error";let M=wk(c);T?(N.textContent=vk(M),N.title=M,N.setAttribute("style",xk),N.parentNode!==t&&t.append(N)):(N.textContent=M,N.removeAttribute("title"),N.setAttribute("style",bk),t.replaceChildren(N))},O=T=>{c=T,R(),a.onError?.(T)},P=()=>{if(x||k)return;let T=fk(t).filter(_=>_.status==="loading");T.length!==0&&(x=!0,gk(T,new WeakRef(w)))},H=()=>{x=!1,v=!0,A()},I=(T,_=!T)=>{let M=Bs(t).getComputedStyle(t),U=t.firstElementChild??null,j={fonts:p,natural:h,adapts:g,drawnFor:m,stale:v},Y;try{if(T&&(p=sh(M,U),v=t.isConnected===!1),Y=b(M,T),_&&Y.svg===u?.svg){T&&(s=l),o&&c!==void 0&&(c=void 0,R());return}C(Y.svg)}catch(D){throw{fonts:p,natural:h,adapts:g,drawnFor:m,stale:v}=j,D}if(T&&(s=l),T&&!U&&t.firstElementChild){let D=sh(M,t.firstElementChild);if(D.family!==p.family||D.mono!==p.mono){let L={fonts:p,natural:h,adapts:g,drawnFor:m};p=D;try{let F=b(M,!0);C(F.svg),Y=F}catch{({fonts:p,natural:h,adapts:g,drawnFor:m}=L)}}}u=Y,o&&(c=void 0),R(),G?.refresh(),P(),a.onRender?.(Y)},G,Z=!1,z=()=>{let T=a.zoom??"auto";T!==Z&&(G?.destroy(),Z=T,G=T===!1?void 0:uk(t,typeof T=="object"?T:{always:T===!0},!1))},W=()=>t.isConnected===!1||!(t.clientWidth>0),S=()=>t.isConnected!==!1&&!(t.clientWidth>0),A=()=>{if(k||(E(),!l||W()))return;let T=Bs(t).getComputedStyle(t),_=sh(T,t.firstElementChild??null);try{if(v||_.family!==p.family||_.mono!==p.mono)I(!0,!0);else if(g!==!1&&a.maxWidth===void 0){let M=Kg(t,T);M!==m&&M!==u?.width&&I(!1)}}catch(M){v=!1,o&&(c=M),l!==s&&(l=s,o=!1),R(),a.onError?.(M)}G?.resized(),P()},$,y,E=()=>{let T=Bs(t);T!==$&&(y?.disconnect(),$=T,y=T.ResizeObserver?new T.ResizeObserver(A):void 0,y?.observe(t))},w={get result(){return u},get source(){return i},get error(){return c},get zoom(){return G},update(T,_=a){let M=!o||T!==i||_.limit!==a.limit||_.maxEdges!==a.maxEdges||_.config!==a.config;i=T,a=_;let U=l;if(M)try{U=e.parse(T,_)}catch(Y){o=!1,O(Y),z();return}let j=u;if(l=U,o=!0,S()){v=!0,z();return}try{I(!0)}catch(Y){if(u!==j)throw z(),Y;l=s,o=!1,O(Y)}z()},refresh:A,destroy(){k=!0,y?.disconnect(),y=void 0,$=void 0,G?.destroy(),af.delete(w),Gl.get(t)===w&&Gl.delete(t)}};af.set(w,H);try{l=e.parse(r,n),o=!0,I(!0)}catch(T){if(u)throw T;l=s,o=!1,O(T)}return z(),E(),Gl.set(t,w),w}var zx=new Map;function kk(...e){for(let t of e)zx.set(t.type,t)}var Mk=5e4,_k=4e6,Ek=5e3;function Fx(e){try{return e()}catch(t){throw t instanceof RangeError?new Je("Diagram is nested too deeply.","limit"):t}}function Wx(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??=e.type,r.mermaidType??=e.mermaidType),r)}}var Bx=new WeakMap;function Hx(e,t=Mk,r=Ek,n){if(e.length>t)throw new Je(`Diagram source is longer than the limit of ${t} characters.`,"limit");let i=Y$(e),a=x$(i.text);if(a===null)throw new Je("No diagram type detected for the given text.","unsupported-diagram");let l=zx.get(a.type);if(l===void 0)throw new Je(`Diagram type "${a.type}" is not supported yet.`,"unsupported-diagram",a);let s=n?{...n,...i.config}:i.config,o=l.keepComments?i.withComments:i.text,c=Wx(a,()=>l.parse(q$(o)+`
49
+ `,s,i.title,i.lineOffset,{maxEdges:r}));return{...a,diagram:l,model:c,config:s}}function Ak(e,t){if(typeof e=="string")return Hx(e,t.limit,t.maxEdges,t.config);let r=Bx.get(e);if(r===void 0)throw new TypeError("render() takes diagram text or a model that parse() returned.");return r}function Tk(e,t={}){return Fx(()=>{let r=Hx(e,t.limit,t.maxEdges,t.config),n=r.model;return Object.defineProperty(n,"mermaidType",{value:r.mermaidType,enumerable:!0}),Bx.set(n,r),n})}function Sk(e,t={}){return Fx(()=>{let{type:r,mermaidType:n,diagram:i,model:a,config:l}=Ak(e,t),s=l[i.section??r],o=typeof s=="object"&&s!==null&&!Array.isArray(s)&&s.useMaxWidth===!1,c=t.responsive??!o,h=t.icons,u=h&&(g=>h(It(g))),d=Wx({type:r,mermaidType:n},()=>_$(i.math?t.math:void 0,()=>M$(u,()=>i.render(a,l,{...t,responsive:c,icons:u})))),p=t.outputLimit??_k;if(d.svg.length>p)throw new Je(`Diagram output is longer than the limit of ${p} characters.`,"limit",{type:r,mermaidType:n});for(let g of d.links)g.id=It(g.id);return{type:r,mermaidType:n,...d}})}function Kf(e,t,r={}){return $k({parse:Tk,render:Sk},e,t,r)}var Ck=/[&<>"\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/,Ik=/[&<>"]|[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]+/g,Nk={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function tt(e){return Ck.test(e)?e.replace(Ik,t=>Nk[t]??""):e}function Ge(e){return tt(It(e))}var sf=[];for(let e=0;e<100;e++)sf.push(e===0?"":e%10===0?"."+e/10:"."+(e<10?"0"+e:e));function f(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+sf[t-r*100]}}else if(t>-1e11){let r=-t,n=Math.floor(r/100);return"-"+n+sf[r-n*100]}return String(t/100)}function Le(e,t,r,n,i){let a=e.lines;if(a.length===0)return"";let l=e.lineHeight,s=e.heights,o=e.size*.35,c=r-e.height/2,h=a.length===1&&a[0].length===1?a[0][0]:void 0;if(h&&h.icon===void 0&&h.math===void 0&&h.style===0)return`<text${n} x="${f(t)}" y="${f(c+l/2+o)}" text-anchor="middle">${tt(h.text)}</text>`;let u=ll(e),d=n,p;n=Sa(n,u);let g="",m="";for(let v=0;v<a.length;v++){let x=a[v],k=s?s[v]:l,b=c+k/2,C=b+o,N=!1;for(let R of x)(R.icon!==void 0||R.math)&&(N=!0);if(N){let R=t-e.widths[v]/2;for(let O of x){if(O.math){let P=`x="${f(R)}" y="${f(b-O.math.height/2)}" width="${f(O.math.width)}" height="${f(O.math.height)}"`;p??=zk(d),m+=p.halo===void 0?Fk(O.math,P,e.size,p.attrs):`<rect ${P} rx="2" fill="${p.halo}"/>`}else if(O.icon!==void 0){let P=e.size*1.1,H=i?.(O.icon)??"";m+=`<svg class="pele-icon" data-icon="${Ge(O.icon)}" x="${f(R)}" y="${f(b-P/2)}" width="${f(P)}" height="${f(P)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${H}</svg>`}else O.text!==""&&(g+=`<tspan x="${f(R)}" y="${f(C)}" text-anchor="start"${ka(O.style&~u)}>${tt(O.text)}</tspan>`);R+=O.width}}else{for(let R=0;R<x.length;R++){let O=x[R],P=R===0?` x="${f(t)}" y="${f(C)}"`:"";g+=`<tspan${P}${ka(O.style&~u)}>${tt(O.text)}</tspan>`}x.length===0&&(g+=`<tspan x="${f(t)}" y="${f(C)}"> </tspan>`)}c+=k}return`<text${n} text-anchor="middle" xml:space="preserve">${g}</text>${m}`}var Rk=/ fill="([^"]*)"/,Ok=/ stroke="([^"]*)"/,Lk=/ style="([^"]*)"/,Dk=/(?:^|;)\s*fill:([^;]*)/,Pk=/(?:^|;)\s*opacity:([^;]*)/;function zk(e){let t=Lk.exec(e)?.[1]??"",r=(Dk.exec(t)?.[1]??Rk.exec(e)?.[1]??"").trim();if(r==="none")return{attrs:"",halo:Ok.exec(e)?.[1]??"none"};let n=Pk.exec(t)?.[1].trim();return{attrs:(r===""?"":` color="${r}"`)+(n?` opacity="${n}"`:"")}}function Fk(e,t,r,n){return"svg"in e?`<svg class="pele-math" ${t} overflow="visible"${n}>${e.svg}</svg>`:`<foreignObject class="pele-math" ${t} overflow="visible"${n}><div xmlns="http://www.w3.org/1999/xhtml" style="display:flex;align-items:center;justify-content:center;width:100%;height:100%;font-size:${f(r)}px;line-height:normal;white-space:nowrap">${e.html}</div></foreignObject>`}var jx=' font-weight="var(--_w)"',Ux=' font-style="italic"';function ka(e){return(e&1?jx:"")+(e&2?Ux:"")}function ll(e){let t=3,r=!1;for(let n of e.lines)for(let i of n)i.icon!==void 0||i.text===""||(t&=i.style,r=!0);return r?t:0}function Sa(e,t){return e+(t&1&&!e.includes(' font-weight="')?jx:"")+(t&2&&!e.includes(' font-style="')?Ux:"")}var ts="about:blank",Wk=/^([^\w]*)(javascript|data|vbscript)/im,Zg=/&#(\w+)(^\w|;)?/g,Qg=/&(newline|tab);/gi,oh=/[\u0000-\u001F\u007F-\u009F -‍]/gim,Bk=/^.+(:|&colon;)/gim,Jg=/(\\|%5[cC])((%(6[eE]|72|74))|[nrt])/g;function e0(e){try{return decodeURIComponent(e)}catch{return e}}function Ca(e){if(!e)return ts;let t=e0(e.trim()),r,n=0;do{if(++n>32)return ts;t=t.replace(oh,"").replace(Zg,(o,c)=>String.fromCharCode(c)).replace(Qg,"").replace(oh,"").replace(Jg,"").trim(),t=e0(t),r=t.match(oh)||t.match(Zg)||t.match(Qg)||t.match(Jg)}while(r&&r.length>0);if(!t)return ts;if(t[0]==="."||t[0]==="/")return t;let i=t.trimStart(),a=i.match(Bk);if(!a)return t;let l=a[0].toLowerCase().trim();if(Wk.test(l))return ts;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 ts}return o.protocol=o.protocol.toLowerCase(),o.hostname=o.hostname.toLowerCase(),o.toString()}return s}function Ia(e){return Ca(It(e))}var Hk=["http","https","mailto","tel"],jk=["http","https"],Uk=/^([a-z][a-z0-9+.-]*):/i,Yk=/^[\\/]{2}/;function Yx(e,t){if(Yk.test(e))return;let r=Uk.exec(e);return!r||t.includes(r[1].toLowerCase())?e:void 0}function ol(e,t){return t.links===!1?void 0:Yx(e,t.linkSchemes??Hk)}function Gk(e,t){return t.images===!1?void 0:Yx(e,t.imageSchemes??jk)}function Na(e,t,r,n,i,a=""){let l=ol(t,i);return l===void 0?e:(n.push({id:r,href:l,internal:!1}),`<a href="${tt(l)}"${a}${cl(i)}>${e}</a>`)}function cl(e){let t=e.linkRel??"noopener";return t?` rel="${tt(t)}"`:""}var Vk=[["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"]],qk=["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"],Xk=new Map([["square","rect"],["round","rounded"],["ellipse","ellipse"],["hexagon","hex"],["diamond","diam"]]),Kc=new Map;for(let e of Vk)for(let t of e)Kc.set(t,e[0]);for(let e of qk)Kc.set(e,e);function Gx(e){return Kc.has(e)}function Vx(e){return e===void 0?"rect":Xk.get(e)??Kc.get(e)??"rect"}var Kk=new Map([["task","roundedRect"],["tool","subroutine"],["input","lean-right"],["decision","diamond"],["refdoc","lin-doc"],["action","hexagon"],["round","rect"]]),Zk=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"]),Qk=new Set(["roundedRect","subroutine","subprocess","subproc","framed-rectangle","lean-right","diamond","lin-doc","lined-document","hexagon","hex","connector","collapsedGroup"]),rs="roundedRect";function sc(e){return e&&(Kk.get(e)??e)}function Jk(e){return Gx(e)||e==="constructor"}function eM(e,t){for(let r of e)r.isGroup||((!r.shape||r.shape==="squareRect"||r.shape==="rect")&&(r.shape=rs),Zk.has(r.shape)?(t.emitError("SHAPE_REMOVED",`shape "${r.shape}" was removed in v0.8.1, using "${rs}"`,{nodeId:r.id}),r.shape=rs):Qk.has(r.shape)||(t.emitWarning("SHAPE_UNSUPPORTED",`shape "${r.shape}" is not supported, using "${rs}"`,{nodeId:r.id}),r.shape=rs))}var tM=new Set(["shape","view","icon","img","form","pos","w","h","class","style","labelType"]),rM=new Set(["subroutine","subprocess","subproc","framed-rectangle","tool"]);function nM(e){return rM.has(e.type)}function ch(e){return e==="markdown"||e==="string"||e==="text"?e:"markdown"}function t0(e){return e.startsWith('"')&&e.endsWith('"')?e.substring(1,e.length-1):e}function lf(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function iM(e){let t=i=>Array.isArray(i)?[]:lf(i)?{}:i,r=t(e),n=[[e,r]];for(;n.length>0;){let[i,a]=n.pop();if(Array.isArray(i))for(let l of i){let s=t(l);a.push(s),typeof l=="object"&&l!==null&&n.push([l,s])}else if(lf(i))for(let l of Object.keys(i)){if(l==="__proto__"||l==="constructor"||l==="prototype")continue;let s=i[l],o=t(s);a[l]=o,typeof s=="object"&&s!==null&&n.push([s,o])}}return r}function Vl(e,t){return Object.assign(e??{},t)}var aM=/:\s*[>|][\d+-]*\s*$/,sM=/,([\t ]*)$/;function lM(e){let t=!1,r=!1,n=0,i,a=[];for(let l of e.split(`
50
+ `)){if(i!==void 0){let h=l.length-l.trimStart().length;if(l.trim()===""||h>i){a.push(l);continue}i=void 0}let s=-1;for(let h=0;h<l.length;h++){let u=l[h];if(r)u==="\\"?h++:u==='"'&&(r=!1);else if(t)u==="'"&&(t=!1);else if(u==='"')r=!0;else if(u==="'")t=!0;else if(u==="#"&&(h===0||l[h-1]===" "||l[h-1]===" ")){s=h;break}else u==="["||u==="{"?n++:(u==="]"||u==="}")&&(n=Math.max(0,n-1))}if(t||r||n>0){a.push(l);continue}let o=s>=0?l.slice(0,s):l,c=s>=0?l.slice(s):"";if(aM.test(o)){i=l.length-l.trimStart().length,a.push(l);continue}a.push(o.replace(sM,"$1")+c)}return a.join(`
51
+ `)}function oM(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 cM(e){let t=e.trim(),r=t.slice(0,-1),n="arrow_open";switch(t.slice(-1)){case"x":n="arrow_cross";break;case">":n="arrow_point";break;case"-":case".":r=t;break}let i="normal",a=r.length-1,l=0;for(let s=0;s<r.length;s++)r[s]==="."&&l++;return l>0&&(i="dotted",a=l),{type:n,stroke:i,length:a}}function r0(e){if(!e)return;let t={},r=!1;for(let n of Object.keys(e))tM.has(n)||(t[n]=e[n],r=!0);return r?t:void 0}var dM=class{type="agentflow";direction;nodes=new Map;edges=[];subgraphs=[];connectors=new Map;classes=new Map;tooltips=new Map;defaultEdgeStyle;defaultInterpolate;mappings=[];diagnostics=[];title;accTitle;accDescr;lineOffset;subgraphLookup=new Map;globalNodes=new Set;members=new Set;edgeById=new Map;pairCount=new Map;subCount=0;bareMappings=new Set;firstMapping=new Map;reported=new Map;options;constructor(e={}){this.options=e,this.lineOffset=e.lineOffset??0}metadata(e,t,r){let n=t.includes(`
52
+ `),i;try{i=va(n?t+`
53
+ `:`{
54
+ `+t+`
55
+ }`)}catch(a){let l=n?lM(t):t,s;if(l!==t)try{s=va(l+`
56
+ `)}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. ${a.message}${o}`,"syntax",{type:"agentflow",line:r?r.first_line+this.lineOffset:0,column:r?r.first_column+1:0})}i=s}return iM(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,n,i,a,l={},s,o){if(!e||e.trim().length===0)return;let c,h,u;s!==void 0&&(c=this.metadata(e,s,o),lf(c)&&(h=c,typeof c.shape=="string"&&(u=c.shape,c.shape=sc(c.shape))));let d=this.subgraphLookup.get(e);if(d&&c){d.metadata=Vl(d.metadata,c);return}let p=this.connectors.get(e);if(p&&c){p.metadata=Vl(p.metadata,c);return}if(e==="connectors")return;let g=this.edgeById.get(e);if(g){h?.animate!==void 0&&(g.animate=h.animate),h?.animation!==void 0&&(g.animation=h.animation),h?.curve!==void 0&&(g.interpolate=h.curve),c&&(g.metadata=Vl(g.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=t0(t.text.trim())):m.text===void 0&&(m.text=e),r!==void 0&&(m.type=r),n!=null)for(let v of n)m.styles.push(v);if(i!=null)for(let v of i)m.classes.push(v);if(a!==void 0&&(m.dir=a),m.props===void 0?m.props=l:l!==void 0&&Object.assign(m.props,l),!!c&&(m.metadata=Vl(m.metadata,c),h!==void 0)){if(h.shape){let v=u??h.shape;if(typeof v!="string")throw this.shapeError(`No such shape: ${JSON.stringify(v)}.`,o);if(v!==v.toLowerCase()||v.includes("_"))throw this.shapeError(`No such shape: ${v}. Shape names should be lowercase.`,o);let x=h.shape;if(!Jk(x))throw this.shapeError(`No such shape: ${x}.`,o);m.type=x}h.label&&(m.text=String(h.label),m.labelType=ch(h.labelType))}}addSingleLink(e,t,r,n){let i={start:e,end:t,type:void 0,text:"",labelType:"text",classes:[],isUserDefinedId:!1,interpolate:this.defaultInterpolate},a=r?.text;a!==void 0&&(i.text=t0(a.text.trim()),i.labelType=ch(a.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;n&&!this.edgeById.has(n)?(i.id=n,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 n=typeof r?.id=="string"?r.id.replace("@",""):void 0,i=e[e.length-1],a=t[0];for(let l of e)for(let s of t)this.addSingleLink(l,s,r,l===i&&s===a?n: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 n=this.edgeAt(r);n.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,"§§§").replace(/,/g,";").replace(/§§§/g,",").split(";");for(let n of e.split(",")){let i=this.classes.get(n);i===void 0&&(i={id:n,styles:[],textStyles:[]},this.classes.set(n,i));for(let a of r)a.includes("color")&&i.textStyles.push(a.replace("fill","bgFill")),i.styles.push(a)}}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 n=t.trim();for(let i of e.split(",")){let a=this.nodes.get(i);a!==void 0&&(a.link=n?Ia(n):void 0,a.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,`
57
+ `)}addSubGraph(e,t,r,n){let i=e?.text?.trim(),a=r?.text||"";e!==void 0&&e===r&&/\s/.test(a)&&(i=void 0);let l=new Set,s=[],o;for(let p of t)if(typeof p=="string")p.trim()!==""&&!l.has(p)&&(l.add(p),s.push(p));else if(Array.isArray(p))for(let g of p)g.trim()!==""&&!l.has(g)&&(l.add(g),s.push(g));else o=p.value;o??=this.options.inheritDir?this.direction??this.options.direction:void 0,i??="subGraph"+this.subCount,this.subCount++;let c=this.members,h=s.filter(p=>p!==i&&!this.globalNodes.has(p)&&!c.has(p));for(let p of h)c.add(p);let u=this.subgraphLookup.get(i);if(u){for(let p of h)u.nodes.push(p);return a.trim()&&(u.title=a.trim()),o&&(u.dir=o),i}let d={id:i,nodes:h,title:a.trim(),classes:[],dir:o,labelType:ch(r?.type),type:"flow"};return this.subgraphs.push(d),this.subgraphLookup.set(i,d),i}addGlobal(e){let t=!1,r=n=>{let i=n.trim();i!==""&&(this.globalNodes.add(i),this.members.delete(i)&&(t=!0))};for(let n of e)if(typeof n=="string")r(n);else if(Array.isArray(n))for(let i of n)r(i);if(t)for(let n of this.subgraphs)n.nodes=n.nodes.filter(i=>!this.globalNodes.has(i))}addConnector(e,t){let r=e?.text?.trim();if(!r)return"";let n=t?.text?.trim()??"",i=this.connectors.get(r);if(i)n.length>0&&(i.text=n);else{let a={id:r,labelType:"text",styles:[],classes:[],isConnector:!0,text:n.length>0?n:r};this.connectors.set(r,a),this.nodes.set(r,a)}return r}destructLink(e,t){let r=cM(e);return t&&(t.includes(".")?"dotted":"normal")!==r.stroke?{type:"INVALID",stroke:"INVALID"}:{...r,edgeSemantic:oM(r.type,r.stroke)}}subgraph(e){return this.subgraphLookup.get(e)}vertexKind(e){if(nM(e))return"tool";let t=sc(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[a,l]of this.nodes){if(this.subgraphLookup.has(a))continue;let s=r0(l.metadata);if(l.isConnector){let h={id:a};l.text!==void 0&&l.text!==a&&(h.title=l.text),s&&(h.metadata=s),t.push(h);continue}let o={id:a};l.text!==void 0&&(o.label=l.text);let c=sc(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(a=>{let l={start:a.start,end:a.end};return a.id!==void 0&&(l.id=a.id),a.text.length>0&&(l.label=a.text),a.type!==void 0&&(l.type=a.type),a.stroke!==void 0&&(l.stroke=a.stroke),a.edgeSemantic!==void 0&&(l.edgeSemantic=a.edgeSemantic),a.length!==void 0&&(l.length=a.length),a.metadata&&Object.keys(a.metadata).length>0&&(l.metadata={...a.metadata}),l}),n=this.subgraphs.map(a=>{let l={id:a.id,nodes:[...a.nodes],type:a.type,title:a.title};a.dir!==void 0&&(l.direction=a.dir);let s=r0(a.metadata);return s&&(l.metadata=s),l}),i={vertices:e,edges:r,subGraphs:n,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 n={id:e,type:t,position:r};return this.mappings.push(n),this.firstMapping.has(e)||this.firstMapping.set(e,n),n}addVertexMapping(e,t,r,n){if(!e)return;let i=this.pushMapping(e,"vertex",this.position(n));r==null&&this.bareMappings.add(i)}extendVertexMapping(e,t){if(!e||!t)return;let r=this.position(t);for(let n=this.mappings.length-1;n>=0;n--){let i=this.mappings[n];if(i.type!=="vertex"||i.id!==e)continue;this.bareMappings.delete(i)&&(i.type="attachment");let a=i.position;(r.endLine>a.endLine||r.endLine===a.endLine&&r.endColumn>a.endColumn)&&(a.endLine=r.endLine,a.endColumn=r.endColumn);return}this.pushMapping(e,"attachment",r)}addEdgeMapping(e,t,r,n){let i=Array.isArray(t)?t.filter(a=>typeof a=="string"&&a!==""):[];this.pushMapping(i.length>0?i.join(">"):"edge","edge",this.position(n))}blockMapping(e,t,r,n){if(!e)return;let i=this.position(r),a=n?this.position(n):i;this.pushMapping(e,t,{startLine:i.startLine,startColumn:i.startColumn,endLine:a.endLine,endColumn:a.endColumn,startIndex:0,endIndex:0})}addSubgraphMapping(e,t,r,n){let i=typeof e=="string"?e:e?.text;this.blockMapping(i??"","subgraph",r,n)}addConnectorMapping(e,t,r,n){this.blockMapping(e?.text?.trim()??"","connector",r,n)}emit(e,t,r,n){let i=n?.nodeId??n?.edgeId,a={id:e,severity:t,message:r};n?.nodeId?a.nodeId=n.nodeId:n?.edgeId&&(a.edgeId=n.edgeId);let l=i?this.firstMapping.get(i):void 0;l&&(a.position=l.position);let s=i??"",o=this.reported.get(s);if(o===void 0)this.reported.set(s,[a]);else{for(let c of o)if(c.id===e&&c.severity===t&&c.message===r&&c.nodeId===a.nodeId&&c.edgeId===a.edgeId)return;o.push(a)}this.diagnostics.push(a),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)}},hM="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",uM;function fM(){let e=hM.split(" "),t=new Uint16Array(e.length),r=0;for(let n=0;n<e.length;n+=2){let i=r+parseInt(e[n],36);r=i+parseInt(e[n+1],36),t[n]=i,t[n+1]=r}return t}function Zf(e){if(e<170||e>65500)return!1;let t=uM??=fM(),r=0,n=(t.length>>1)-1;for(;r<=n;){let i=r+n>>1;if(e<t[i*2])n=i-1;else if(e>t[i*2+1])r=i+1;else return!0}return!1}var n0=["$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"],qx=new Uint8Array(128);for(let e of"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'*+.`?\\_/")qx[e.charCodeAt(0)]=1;var pM=/accTitle\s*:\s*/y,gM=/accDescr\s*:\s*/y,mM=/accDescr\s*\{\s*/y,yM=/call\s+/y,xM=/click\s+/y,bM=/(?:\r?\n)*\s*\n/y,wM=/\s*(?:LR|RL|TB|BT|TD|BR)\b/y,vM=/\s*[<>^]/y,$M=/\s*v\b/y,kM=[/.*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],dh=/[\n\r\u2028\u2029]/g,MM=/\(\s*\)/y,_M=/\n\s*/g;function EM(e){let t=e.length,r=[],n=[],i=[],a=[],l=[],s=0,o=0,c=1,h=0,u=!0,d=e.indexOf("direction"),p=e.indexOf("@"),g=-1,m=0,v=0,x=-1,k=-1,b=-1,C=-1,N=-1,R=-1,O=-1,P=D=>{let L=-1;for(let F=o;F<D;F++){let V=e.charCodeAt(F);V===10?(c++,L=F):V===13&&(F+1<D&&e.charCodeAt(F+1)===10&&F++,c++,L=F)}if(L<0)h+=D-o;else{let F=L+1;for(;F<D;){let V=e.charCodeAt(F);if(V===8232||V===8233)break;F++}h=F-L-1}o=D},H=(D,L)=>{r.push(D),n.push(e.slice(o,L)),i.push(o),a.push(c,h),P(L),a.push(c,h)},I=(D,L)=>{r.push(D),n.push(e.slice(o,L)),i.push(o),a.push(c,h),h+=L-o,o=L,a.push(c,h)},G=(D,L)=>{r.push(D),n.push(e.slice(o,L)),i.push(o),a.push(c,h);for(let F=o;F<L;F++){let V=e.charCodeAt(F);V===10||V===13?(c++,h=0):h++}o=L,a.push(c,h)},Z=(D,L,F)=>{r.push(D),n.push(L),i.push(o),a.push(c,h),P(F),a.push(c,h)},z=D=>{l.push(s),s=D},W=()=>{l.length>0&&(s=l.pop())},S=(D,L)=>(D.lastIndex=L,D.test(e)?D.lastIndex:-1),A=D=>e.startsWith(D,o)&&!nt(e.charCodeAt(o+D.length)),$=D=>{if(D>=k&&D<=b)return b;let L=D;for(;L<t&&Xe(e.charCodeAt(L));)L++;return k=D,b=L,L},y=D=>{if(D>=C&&D<=N)return N;let L=D;for(;L<t;){let F=e.charCodeAt(L);if(F!==32&&F!==9)break;L++}return C=D,N=L,L},E=D=>{let L=$(D);if(L===O||e.charCodeAt(L)!==45||e.charCodeAt(L+1)!==45)return-1;let F=L+2;for(;e.charCodeAt(F)===45;)F++;let V=e.charCodeAt(F);return V===120||V===62?$(F+1):(O=L,-1)},w=()=>{let D=$(o);if(D===R||e.charCodeAt(D)!==45)return!1;let L=e.charCodeAt(D+1),F=D+2;if(L===45){for(;e.charCodeAt(F)===45;)F++;let V=e.charCodeAt(F);return V===120||V===62?H(42,$(F+1)):(z(10),H(43,$(D+2))),!0}if(L===46){for(;e.charCodeAt(F)===46;)F++;if(e.charCodeAt(F)===45)return H(42,$(F+1)),!0}return R=D,!1},T=D=>{if(e.charCodeAt(D)!==37||e.charCodeAt(D+1)!==37||e.charCodeAt(D+2)===123)return-1;let L=e.indexOf(`
58
+ `,D+2);return L===-1?t:L},_=()=>{e.charCodeAt(o+1)===96?(z(2),P(o+2)):(z(1),P(o+1))},M=D=>{let L=e.charCodeAt(o+1);return D===40?(L===45?(z(8),I(47,o+2)):L===91?(z(7),I(49,o+2)):L===40&&e.charCodeAt(o+2)===40?(z(7),I(57,o+3)):(z(7),I(72,o+1)),!0):D===91?(L===91?(z(7),I(51,o+2)):L===40?(z(7),I(55,o+2)):L===47?(z(9),I(60,o+2)):L===92?(z(9),I(61,o+2)):(z(7),I(74,o+1)),!0):D===124?(z(7),I(70,o+1),!0):D===123?(z(7),I(76,o+1),!0):!1},U=()=>{let D=o;for(;D<t;){let L=e.charCodeAt(D);if(L<128&&qx[L]===1)D++;else if(L===45&&D+1<t){let F=e.charCodeAt(D+1);if(F===62||F===45||F===46)break;D++}else break}return D===o?!1:(I(67,D),!0)},j=D=>{let L=D;for(;L<t;){let F=e.charCodeAt(L);if(F!==32&&F!==9)break;L++}return L},Y=D=>{let L;switch(D){case 97:if(e.startsWith("acc",o)){if((L=S(pM,o))>=0)return z(3),H(2,L),!0;if((L=S(gM,o))>=0)return z(4),H(4,L),!0;if((L=S(mM,o))>=0)return z(5),P(L),!0}if(A("agentflow-beta"))return u&&(u=!1,z(6)),I(20,o+14),!0;break;case 64:if(e.charCodeAt(o+1)===123)return z(14),Z(7,"",o+2),!0;break;case 99:if((L=S(yM,o))>=0)return z(12),P(L),!0;if(A("classDef"))return I(16,o+8),!0;if(A("class"))return I(17,o+5),!0;if((L=S(xM,o))>=0)return z(11),P(L),!0;if(A("connector"))return I(22,o+9),!0;break;case 34:return _(),!0;case 115:if(A("style"))return I(12,o+5),!0;break;case 100:if(A("default"))return I(13,o+7),!0;break;case 108:if(A("linkStyle"))return I(14,o+9),!0;break;case 105:if(A("interpolate"))return I(15,o+11),!0;break;case 104:if(e.startsWith("href",o)&&Xe(e.charCodeAt(o+4)))return H(18,o+5),!0;break;case 102:if(A("flow"))return I(21,o+4),!0;break;case 103:if(A("global"))return I(23,j(o+6)),!0;break;case 101:if(A("end"))return I(24,j(o+3)),!0;break;case 95:if(A("_self"))return I(25,o+5),!0;if(A("_blank"))return I(25,o+6),!0;if(A("_parent"))return I(25,o+7),!0;if(A("_top"))return I(25,o+4),!0;break}if(d!==-1&&o>=m&&(d<o&&(d=e.indexOf("direction",o)),d!==-1&&(g<o&&(dh.lastIndex=o,g=dh.test(e)?dh.lastIndex-1:t),d<g))){for(let F=0;F<5;F++)if((L=S(kM[F],o))>=0)return H(28+F,L),!0;m=g}if(p!==-1&&D!==34&&!Xe(D)){if(o>=v){p<o&&(p=e.indexOf("@",o));let F=o;for(;F<t;){let V=e.charCodeAt(F);if(V===34||Xe(V))break;F++}if(v=F,x=-1,p!==-1&&p<F)for(let V=Math.min(F,t-1)-1;V>=p;V--){if(e.charCodeAt(V)!==64)continue;let X=e.charCodeAt(V+1);if(X!==123&&X!==34){x=V;break}}}if(x>o)return I(33,x+1),!0}if(D>=48&&D<=57){let F=o+1;for(;F<t;){let V=e.charCodeAt(F);if(V<48||V>57)break;F++}return I(34,F),!0}switch(D){case 35:return I(35,o+1),!0;case 58:return e.charCodeAt(o+1)===58&&e.charCodeAt(o+2)===58?I(36,o+3):I(37,o+1),!0;case 38:return I(38,o+1),!0;case 59:return I(39,o+1),!0;case 44:return I(40,o+1),!0;case 42:return I(41,o+1),!0;case 60:return I(62,o+1),!0;case 45:return w()||U()||I(68,o+1),!0;case 40:return M(D);case 91:return e.charCodeAt(o+1)===124?(I(52,o+2),!0):M(D);case 124:case 123:return M(D);case 62:return z(7),I(53,o+1),!0;case 94:return I(63,o+1),!0;case 92:return e.charCodeAt(o+1)===124?(I(64,o+2),!0):U();case 118:return nt(e.charCodeAt(o+1))?U():(I(65,o+1),!0);case 37:return(L=T(o))>=0?(H(66,L),!0):U()}if(Xe(D)){if(w())return!0;if((D===32||D===9)&&(L=T(y(o)))>=0)return H(66,L),!0;for(L=o;;){let F=e.charCodeAt(L);if(F===10)L++;else if(F===13&&e.charCodeAt(L+1)===10)L+=2;else break}return L>o?H(77,L):H(78,o+1),!0}return D<128?U():Zf(D)?(I(69,o+1),!0):!1};e:for(;;){if(o>=t){let F=-1;switch(s){case 0:F=79;break;case 3:F=3;break;case 4:F=5;break;case 5:F=6;break;case 11:F=19;break;case 12:F=8;break;case 13:F=9;break}F!==-1&&I(F,t);break}let D=e.charCodeAt(o),L=!0;switch(s){case 0:L=Y(D);break;case 1:if(D===34)e.charCodeAt(o+1)===96?(z(2),P(o+2)):(W(),P(o+1));else{let F=e.indexOf('"',o);H(11,F===-1?t:F)}break;case 2:if(D===96)e.charCodeAt(o+1)===34?(W(),P(o+2)):L=!1;else if(D===34)_();else{let F=o+1;for(;F<t;){let V=e.charCodeAt(F);if(V===96||V===34)break;F++}H(10,F)}break;case 3:case 4:{let F=e.indexOf(`
59
+ `,o);F===-1&&(F=t);let V=s===3?3:5;W(),H(V,F);break}case 5:if(D===125)W(),P(o+1);else{let F=e.indexOf("}",o);F===-1&&(F=t),H(6,F)}break;case 6:{let F;D===34?_():(F=S(bM,o))>=0?(W(),H(26,F)):(F=S(wM,o))>=0||(F=S(vM,o))>=0||(F=S($M,o))>=0?(W(),H(27,F)):L=M(D);break}case 7:{let F=e.charCodeAt(o+1);switch(D){case 34:_();break;case 40:case 91:case 123:M(D);break;case 93:W(),F===41?I(48,o+2):F===93?I(50,o+2):I(73,o+1);break;case 41:W(),F===93?I(54,o+2):F===41&&e.charCodeAt(o+2)===41?I(56,o+3):I(71,o+1);break;case 124:W(),I(70,o+1);break;case 125:W(),I(75,o+1);break;case 37:{let V=T(o);V>=0?P(V):L=!1;break}default:{let V=o+1;for(;V<t;){let X=e.charCodeAt(V);if(X===91||X===93||X===40||X===41||X===123||X===125||X===124||X===34||X===37)break;V++}H(46,V)}}break}case 8:{let F=e.charCodeAt(o+1),V;if(D===34)_();else if(D===37&&(V=T(o))>=0)P(V);else if((D===45||D===47||D===41)&&F===41)W(),I(45,o+2);else if(D===40||D===91||D===123)M(D);else if(D===41||D===93||D===125)L=!1;else{let X=o+1;for(;X<t;){let Q=e.charCodeAt(X);if(Q===34||Q===40||Q===41||Q===91||Q===93||Q===123||Q===125||(Q===45||Q===47)&&e.charCodeAt(X+1)===41||Q===37&&e.charCodeAt(X+1)===37&&e.charCodeAt(X+2)!==123)break;X++}G(46,X)}break}case 9:{let F=e.charCodeAt(o+1);if(D===34){_();break}switch(D){case 40:F===45||F===91||F===40&&e.charCodeAt(o+2)===40?M(D):F===93?(W(),I(58,o+2)):M(D);break;case 91:case 123:M(D);break;case 92:F===93?(W(),I(58,o+2)):I(46,o+1);break;case 47:F===93?(W(),I(59,o+2)):I(46,o+1);break;case 93:case 41:F===93?(W(),I(58,o+2)):L=!1;break;case 125:L=!1;break;case 37:{let V=T(o);V>=0?P(V):L=!1;break}default:{if((D===63||D===61)&&F===93){W(),I(58,o+2);break}let V=o+1;for(;V<t;){let X=e.charCodeAt(V);if(X===92||X===91||X===93||X===40||X===41||X===123||X===125||X===47||X===37)break;V++}H(46,V)}}break}case 10:{if(D===34){_();break}let F=E(o);if(F>=0){W(),H(42,F);break}if(D===45&&e.charCodeAt(o+1)===45){L=!1;break}let V=o+1;for(;V<t;){let X=e.charCodeAt(V);if(X===34)break;if(X===45){if(e.charCodeAt(V+1)===45)break}else if(Xe(X)&&E(V)>=0)break;V++}G(44,V);break}case 11:if(D===34)_();else if(Xe(D))W(),P(o+1);else{let F=o+1;for(;F<t&&!Xe(e.charCodeAt(F));)F++;I(19,F)}break;case 12:if(D===40){let F=S(MM,o);W(),F>=0?P(F):(z(13),P(o+1))}else{let F=e.indexOf("(",o);F===-1&&(F=t),H(8,F)}break;case 13:if(D===41)W(),P(o+1);else{let F=e.indexOf(")",o);F===-1&&(F=t),H(9,F)}break;case 14:if(D===34)z(15),I(7,o+1);else if(D===125)W(),P(o+1);else if(D===94)L=!1;else{let F=o+1;for(;F<t;){let V=e.charCodeAt(F);if(V===125||V===94||V===34)break;F++}H(7,F)}break;case 15:if(D===34)W(),I(7,o+1);else{let F=e.indexOf('"',o);F===-1&&(F=t),Z(7,e.slice(o,F).replace(_M,"<br/>"),F)}break}if(!L)return r.push(1),n.push(""),i.push(o),a.push(c,h,c,h),{types:r,texts:n,starts:i,locs:a};continue e}return r.push(0),n.push(""),i.push(t),a.push(c,h,c,h),{types:r,texts:n,starts:i,locs:a}}var lc=new Uint8Array(80);for(let e of[34,67,65,68,13,40,37,38,35,41,69])lc[e]=1;var of=new Uint8Array(80);for(let e of[34,69,67,27,65,68,40,37,38,35,41])of[e]=1;var cf=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])cf[e]=1;var df=new Uint8Array(80);for(let e of[34,67,37,78,35,12])df[e]=1;var oc=new Uint8Array(80);for(let e of[77,39,79,66])oc[e]=1;var i0="'UNICODE_TEXT', 'TEXT', 'TAGSTART'",hh="'COMMENT', 'SEMI', 'NEWLINE', 'EOF'",ns=[],AM=/}[^\S\n]*\n/g;function TM(e,t,r=!1){let n=!r&&e.includes("}")?e.replace(AM,`}
60
+ `):e,{types:i,texts:a,starts:l,locs:s}=EM(n),o=0,c,h=0,u=0,d=_=>{let M=i[o];throw M===1?vt("agentflow",n,l[o],"",!0):vt("agentflow",n,l[o],`Expecting ${_}, got '${n0[M]}'`)},p=(_,M)=>({first_line:s[4*_],first_column:s[4*_+1],last_line:s[4*M+2],last_column:s[4*M+3]}),g=(_,M="")=>(i[o]!==_&&d(`'${n0[_]}'${M?", "+M:""}`),a[o++]),m=()=>{oc[i[o]]===0&&d(hh),o++},v=()=>{lc[i[o]]===0&&d("'NODE_STRING'");let _=a[o++];for(;lc[i[o]]===1;)_+=a[o++];return _},x=()=>{of[i[o]]===0&&d("'NODE_STRING'");let _=a[o++];for(;of[i[o]]===1;)_+=a[o++];return _},k=()=>{let _=i[o],M;if(_===11)M="string";else if(_===10)M="markdown";else if(_===46||_===62||_===53||_===69)M="text";else return d(`${i0}, 'TAGEND', 'STR', 'MD_STR'`);let U=a[o++];for(;;){let j=i[o];if(j!==46&&j!==62&&j!==53&&j!==69)break;U+=a[o++]}return{text:U,type:M}},b=_=>{g(_,i0)},C=()=>{let _=i[o],M;if(_===11)M="string";else if(_===10)M="markdown";else if(_===44||_===69)M="text";else return d("'EDGE_TEXT', 'STR', 'MD_STR'");let U=a[o++];for(;i[o]===44||i[o]===69;)U+=a[o++];return{text:U,type:M}},N=()=>{let _=i[o],M;if(_===11)M="text";else if(_===10)M="markdown";else if(cf[_]===1)M="text";else return d("'NODE_STRING', 'STR', 'MD_STR'");let U=a[o++];for(;cf[i[o]]===1;)U+=a[o++];return{text:U,type:M}},R=()=>{h=o;let _=a[o++];for(;i[o]===7;)_+=a[o++];return u=o-1,_},O=(_,M,U,j)=>{let Y=p(U,j);t.addVertex(_,void 0,void 0,void 0,void 0,void 0,void 0,M,Y),t.extendVertexMapping(_,Y)},P=(_,M)=>{M.data!==void 0&&t.addVertex(_,void 0,void 0,void 0,void 0,void 0,void 0,M.data,p(M.dataFrom,M.dataTo))},H=()=>{let _=o,M=v(),U,j,Y;switch(i[o]){case 74:o++,U=k(),b(73),j="square";break;case 57:o++,U=k(),b(56),j="doublecircle";break;case 72:o++,i[o]===72?(o++,U=k(),b(71),g(71),j="circle"):(U=k(),b(71),j="round");break;case 47:o++,U=k(),b(45),j="ellipse";break;case 49:o++,U=k(),b(48),j="stadium";break;case 51:o++,U=k(),b(50),j="subroutine";break;case 52:{o++;let D=g(67);g(37);let L=g(67);g(70),U=k(),b(73),j="rect",Y={[D]:L};break}case 55:o++,U=k(),b(54),j="cylinder";break;case 76:o++,i[o]===76?(o++,U=k(),b(75),g(75),j="hexagon"):(U=k(),b(75),j="diamond");break;case 53:o++,U=k(),b(73),j="odd";break;case 60:o++,U=k(),i[o]===59?(o++,j="lean_right"):(b(58),j="trapezoid");break;case 61:o++,U=k(),i[o]===58?(o++,j="lean_left"):(b(59),j="inv_trapezoid");break}return Y!==void 0?t.addVertex(M,U,j,void 0,void 0,void 0,Y):j!==void 0?t.addVertex(M,U,j):t.addVertex(M),t.addVertexMapping(M,U,j,p(_,o-1)),M},I=()=>{let _=H();return i[o]===36&&(o++,t.setClass(_,v())),_},G=()=>{let _=[I()];for(c=void 0;;){let M=i[o]===7?R():void 0,U=h,j=u;if(i[o]!==78)return c=M,_;do o++;while(i[o]===78);if(i[o]!==38)return M!==void 0&&d("'AMP'"),_;o++,i[o]!==78&&d("'SPACE'");do o++;while(i[o]===78);let Y=I();M!==void 0&&O(_[_.length-1],M,U,j),_.push(Y)}},Z=()=>{let _;if(i[o]===33&&(_=a[o++]),i[o]===42){let M=t.destructLink(a[o++]);return _!==void 0&&(M.id=_),i[o]===70&&(o++,M.text=k(),b(70),i[o]===78&&o++),M}if(i[o]===43){let M=a[o++],U=C(),j=g(42,"'EDGE_TEXT'"),Y=t.destructLink(j,M);return Y.text=U,_!==void 0&&(Y.id=_),Y}return d("'LINK', 'START_LINK'")},z=()=>{let _=o,M=G();c!==void 0&&O(M[M.length-1],c,h,u);let U=M;for(;;){let j=i[o];if(j!==42&&j!==43&&j!==33)return U;let Y=Z(),D=G();c!==void 0&&O(D[D.length-1],c,h,u),t.addLink(M,D,Y),t.addEdgeMapping(M,D,Y,p(_,o-1)),U=D.concat(U),M=D}},W=()=>{df[i[o]]===0&&d("'NODE_STRING', 'NUM', 'COLON', 'BRKT'");let _=a[o++];for(;df[i[o]]===1;)_+=a[o++];return _},S=()=>{let _=[W()];for(;i[o]===40;)o++,_.push(W());return _},A=()=>{o++,g(78);let _;if(i[o]===13)_=[a[o++]];else for(_=[g(34,"'DEFAULT'")];i[o]===40;)o++,_.push(g(34));if(g(78),i[o]!==15){t.updateLink(_,S());return}o++,g(78);let M=x();if(i[o]===78){o++;let U=S();t.updateLinkInterpolate(_,M),t.updateLink(_,U)}else t.updateLinkInterpolate(_,M)},$=(_,M)=>{if(i[o]!==78){t.setLink(_,M);return}if(o++,i[o]===25){t.setLink(_,M,a[o++]);return}let U=g(11,"'LINK_TARGET'");i[o]===78?(o++,t.setLink(_,M,g(25))):t.setLink(_,M),t.setTooltip(_,U)},y=()=>{let _=a[o++];switch(i[o]){case 8:{let M=a[o++],U=i[o]===9,j=U?a[o++]:void 0,Y;i[o]===78&&(o++,Y=g(11)),U?t.setClickEvent(_,M,j):t.setClickEvent(_,M),Y!==void 0&&t.setTooltip(_,Y);return}case 18:o++,$(_,g(11));return;case 11:$(_,a[o++]);return;default:{let M=x();if(i[o]===78){o++;let U=g(11);t.setClickEvent(_,M),t.setTooltip(_,U)}else t.setClickEvent(_,M)}}},E=_=>{g(78,hh);let M=N(),U={text:"",type:"text"};i[o]===74&&(o++,U=k(),b(73));let j=i[o]===7?R():void 0;return oc[i[o]]===0&&d(`${hh}, 'SHAPE_DATA'`),{global:!1,at:_,id:M,title:U,data:j,dataFrom:h,dataTo:u,list:[],collect:!1}},w=()=>{let _=i[o];switch(_){case 12:{o++,g(78);let M=v();return g(78),t.addVertex(M,void 0,void 0,S()),m(),ns}case 14:return A(),m(),ns;case 16:{o++,g(78);let M=v();return g(78),t.addClass(M,S()),m(),ns}case 17:{o++,g(78);let M=v();return g(78),t.setClass(M,v()),m(),ns}case 19:return y(),m(),ns;case 22:{let M=E(o++),U=o++,j=t.addConnector(M.id,M.title);return P(j,M),t.addConnectorMapping(M.id,M.title,p(M.at,M.at),p(U,U)),j}case 28:case 29:case 30:case 31:case 32:return o++,{stmt:"dir",value:SM[_-28]};case 2:{o++;let M=g(3).trim();return t.setAccTitle(M),M}case 4:{o++;let M=g(5).trim();return t.setAccDescription(M),M}case 6:{let M=a[o++].trim();return t.setAccDescription(M),M}default:{lc[_]===0&&d(a0);let M=z();return m(),M}}},T=()=>{let _=[],M=[],U=!1;for(;;){let j=i[o];if(j===0)break;if(j===24){let Y=_.pop();if(Y===void 0)break;let D=o++;if(Y.global){t.addGlobal(M),M=Y.list,U=Y.collect;continue}let L=t.addSubGraph(Y.id,M,Y.title,"flow");P(L,Y),t.addSubgraphMapping(Y.id,Y.title,p(Y.at,Y.at),p(D,D)),M=Y.list,U=Y.collect,U&&M.push(L)}else if(j===39||j===77||j===78||j===79)U&&M.push(a[o]),o++;else if(j===66)o++;else if(j===21||j===23){let Y=o++,D;j===23||oc[i[o]]===1?(D={global:j===23,at:Y,id:void 0,title:void 0,data:void 0,dataFrom:0,dataTo:0,list:M,collect:U},m()):(D=E(Y),D.list=M,D.collect=U,o++),_.push(D),M=[],U=!0}else{let Y=w();U&&(!Array.isArray(Y)||Y.length>0)&&M.push(Y)}}_.length>0&&d("'end'")};for(;i[o]===78||i[o]===77||i[o]===66;)o++;if(g(20,"'SPACE', 'NEWLINE', 'COMMENT'"),i[o]===26)o++,t.setDirection("TB");else{let _=g(27,"'NODIR'"),M=i[o];if(M===78){do o++;while(i[o]===78);M=i[o],M!==77&&d("'NEWLINE', 'SPACE'")}else M!==39&&M!==77&&M!==66&&d("'COMMENT', 'SEMI', 'NEWLINE', 'SPACE'");o++,t.setDirection(_)}T(),i[o]!==0&&d(a0)}var SM=["TB","BT","RL","LR","TD"],a0="'COMMENT', 'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'flow', 'global', 'connector', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'NODE_STRING'";function Is(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 Ns(e,t,r=1,n=0,i=0){return{tail:e,head:t,minlen:r,labelW:n,labelH:i,tailDx:0,headDx:0,tailFixed:!1,headFixed:!1,reversed:!1,points:[],labelX:0,labelY:0}}var CM=24,s0=2e4,hf=16,l0=8,IM=.125,o0=3,NM=18,RM=10,OM=14,LM=2,DM=28,c0=12,PM=12,zM=8,FM=4,d0=.5,Xr=.5,h0=12,WM=40,u0=400,ua=16,uh=new Float64Array(2*ua+2),fh=new Float64Array(2*ua+2);function fa(e){return e===1||e===2}function f0(e,t,r,n){for(let i=t+1;i<r;i++){let a=e[i],l=n[a],s=i-1;for(;s>=t&&(n[e[s]]>l||n[e[s]]===l&&e[s]>a);)e[s+1]=e[s],s--;e[s+1]=a}}function BM(e,t,r,n,i,a){let l=(c,h)=>r[c]<r[h]||r[c]===r[h]&&(i?n[c]>n[h]:n[c]<n[h]);for(let c=0;c<t;c+=8)for(let h=c+1,u=Math.min(t,c+8);h<u;h++){let d=e[h],p=h-1;for(;p>=c&&l(d,e[p]);)e[p+1]=e[p],p--;e[p+1]=d}let s=e,o=a;for(let c=8;c<t;c*=2){for(let u=0;u<t;u+=2*c){let d=Math.min(t,u+c),p=Math.min(t,u+2*c),g=u,m=d,v=u;for(;g<d&&m<p;)o[v++]=l(s[m],s[g])?s[m++]:s[g++];for(;g<d;)o[v++]=s[g++];for(;m<p;)o[v++]=s[m++]}let h=s;s=o,o=h}if(s!==e)for(let c=0;c<t;c++)e[c]=s[c]}function ph(e,t,r){let n=e.length;if(n===0)return{width:0,height:0};let i=t.length;if(n===1&&i===0&&e[0].kind===0){let he=e[0];return he.rank=0,he.x=he.w/2,he.y=he.h/2,{width:he.w,height:he.h}}let a=1;if(i>0){let he=new Set;for(let $e of t){let Se=Math.min($e.tail,$e.head),we=Math.max($e.tail,$e.head),ke=Se*n+we;if($e.labelW>0||he.has(ke)){a=2;break}he.add(ke)}}Qf(e,t),Jf(e,t,a);let l=new Int32Array(i),s=0;for(let he=0;he<i;he++){let $e=t[he];l[he]=Math.abs(e[$e.head].rank-e[$e.tail].rank),l[he]>1&&(s+=l[he]-1)}let o=new Uint8Array(i);if(s>s0){let he=[];for(let $e=0;$e<i;$e++)l[$e]>1&&he.push($e);he.sort(($e,Se)=>l[Se]-l[$e]||$e-Se);for(let $e of he){if(s<=s0)break;o[$e]=1,s-=l[$e]-1}}let c=n+s,h=new Float64Array(c),u=new Float64Array(c),d=new Uint8Array(c),p=new Int32Array(c),g=0;for(let he=0;he<n;he++){let $e=e[he];h[he]=$e.w,u[he]=$e.h,d[he]=$e.kind,p[he]=$e.rank,$e.rank>g&&(g=$e.rank)}let m=0;for(let he=0;he<i;he++)o[he]||(m+=l[he]);let v=new Int32Array(m),x=new Int32Array(m),k=new Float64Array(m),b=new Float64Array(m),C=new Int32Array(i).fill(-1),N=new Uint8Array(g+1),R=new Int32Array(i).fill(-1),O=!1;for(let he=0;he<n;he++)e[he].span>0&&e[he].kind===0&&(O=!0);let P=O?new Uint8Array(m):void 0,H=O?new Uint8Array(m):void 0,I=new Int32Array(i).fill(-1),G=new Int32Array(i).fill(-1),Z=new Float64Array(c).fill(NaN);for(let he=0;he<n;he++)Z[he]=e[he].key;let z=!1;{let he=n,$e=0;for(let Se=0;Se<i;Se++){if(o[Se])continue;let we=t[Se],ke=we.reversed?we.head:we.tail,Ne=we.reversed?we.tail:we.head,Be=we.reversed?we.headDx:we.tailDx,Pe=we.reversed?we.tailDx:we.headDx;(Be!==0||Pe!==0)&&(z=!0);let q=p[ke],me=p[Ne],se=-1;we.labelW>0&&(se=q+(me-q>>1),a===2&&me-q>=4?(se&1)===1&&(se+=we.reversed?1:-1):a===2&&(se&1)===0&&(se+=we.reversed?1:-1));let ve=ke;me-q>1&&(C[Se]=he),I[Se]=$e,P&&!(we.reversed?we.headFixed:we.tailFixed)&&(P[$e]=we.reversed?2:1);for(let _e=q+1;_e<me;_e++){let Te=he++;p[Te]=_e,Z[Te]=Z[ke]+(Z[Ne]-Z[ke])*(_e-q)/(me-q),_e===se?(h[Te]=we.labelW,u[Te]=we.labelH,d[Te]=2,R[Se]=Te,N[_e]|=we.reversed?2:1):d[Te]=1,v[$e]=ve,x[$e]=Te,k[$e]=ve===ke?Be:0,$e++,ve=Te}v[$e]=ve,x[$e]=Ne,k[$e]=ve===ke?Be:0,b[$e]=Pe,H&&!(we.reversed?we.tailFixed:we.headFixed)&&(H[$e]=we.reversed?1:2),G[Se]=$e,$e++}}let W;if(r.groups){let{of:he,parent:$e}=r.groups;W=new Int32Array(c);for(let ke=0;ke<n;ke++)W[ke]=he[ke];let Se=ke=>{let Ne=0;for(;ke>=0;ke=$e[ke])Ne++;return Ne},we=(ke,Ne)=>{let Be=Se(ke),Pe=Se(Ne);for(;Be>Pe;Be--)ke=$e[ke];for(;Pe>Be;Pe--)Ne=$e[Ne];for(;ke!==Ne;)ke=$e[ke],Ne=$e[Ne];return ke};for(let ke=0;ke<i;ke++){if(C[ke]<0)continue;let Ne=t[ke],Be=we(he[Ne.tail],he[Ne.head]);for(let Pe=C[ke],q=Pe+l[ke]-1;Pe<q;Pe++)W[Pe]=Be}}let S=new Int32Array(c+1),A=new Int32Array(c+1);for(let he=0;he<m;he++)S[v[he]+1]++,A[x[he]+1]++;for(let he=0;he<c;he++)S[he+1]+=S[he],A[he+1]+=A[he];let $=new Int32Array(m),y=new Int32Array(m);{let he=S.slice(0,c),$e=A.slice(0,c);for(let Se=0;Se<m;Se++)$[he[v[Se]]++]=Se,y[$e[x[Se]]++]=Se}let E=new Int32Array(g+2);for(let he=0;he<c;he++)E[p[he]+1]++;for(let he=0;he<=g;he++)E[he+1]+=E[he];let w=new Int32Array(c),T=new Int32Array(c);{let he=new Int32Array(c),$e=E.slice(0,g+1);for(let ke=0;ke<c;ke++)he[$e[p[ke]]++]=ke;for(let ke=0;ke<=g;ke++)$e[ke]=E[ke];let Se=new Uint8Array(c),we=[];for(let ke=0;ke<c;ke++)if(!Se[he[ke]])for(we.push(he[ke]);we.length>0;){let Ne=we.pop();if(!Se[Ne]){Se[Ne]=1,w[$e[p[Ne]]++]=Ne;for(let Be=S[Ne+1]-1;Be>=S[Ne];Be--){let Pe=x[$[Be]];Se[Pe]||we.push(Pe)}}}}let _=(he,$e)=>{let Se=E[he],we=E[he+1];if(we-Se<2)return!1;for(let Be=Se;Be<we;Be++)if(Number.isNaN($e(w[Be])))return!1;let ke=Array.from(w.subarray(Se,we)),Ne=new Map;return ke.forEach((Be,Pe)=>Ne.set(Be,Pe)),ke.sort((Be,Pe)=>$e(Be)-$e(Pe)||Ne.get(Be)-Ne.get(Pe)),w.set(ke,Se),!0};for(let he=0;he<=g;he++)_(he,$e=>Z[$e]);let M=!1;for(let he=0;he<n;he++)e[he].pin!==0&&(M=!0);if(M)for(let he=0;he<=g;he++){let $e=Array.from(w.subarray(E[he],E[he+1])),Se=new Map;$e.forEach((ke,Ne)=>Se.set(ke,Ne));let we=ke=>ke<n?e[ke].pin:0;$e.sort((ke,Ne)=>we(ke)-we(Ne)||Se.get(ke)-Se.get(Ne)),w.set($e,E[he])}let U=new Uint8Array(g+1),j=he=>he<n&&(e[he].kind===3||e[he].kind===4)?e[he].hint:NaN;for(let he of[0,g])_(he,j)&&(U[he]=1);let Y=()=>{for(let he=0;he<=g;he++){let $e=E[he];for(let Se=$e,we=E[he+1];Se<we;Se++)T[w[Se]]=Se-$e}};Y();let D={n:c,real:n,maxRank:g,W:h,KIND:d,RANK:p,EF:v,ET:x,EFD:k,ETD:b,succStart:S,succE:$,predStart:A,predE:y,layerStart:E,order:w,pos:T,offsets:z,fixed:U,GRP:W,groupParent:r.groups?.parent},L=0,F=0;if(m>0&&g>0&&([L,F]=ZM(D,e),Y()),r.orderOnly){let he=p0(D,r);for(let $e=0;$e<n;$e++)e[$e].x=he[$e];for(let $e=0;$e<i;$e++){let Se=t[$e],we=Se.reversed?Se.head:Se.tail,ke=Se.reversed?Se.tail:Se.head,Ne=[p[we],he[we]];if(!o[$e]&&C[$e]>=0)for(let Be=C[$e],Pe=Be+l[$e]-1;Be<Pe;Be++)Ne.push(p[Be],he[Be]);Ne.push(p[ke],he[ke]),Se.points=Ne}return{width:0,height:0,crossings:L,declared:F}}P&&H&&HM(D,e,P,H);let V=p0(D,r),X=VM(D);if(P&&H){let he=jM(D,P,H);UM(D,e,V,he,r,X),YM(D,e,V,P,H,he,X),GM(D,V,X,r);for(let $e=0;$e<i;$e++){if(o[$e])continue;let Se=t[$e],we=k[I[$e]],ke=b[G[$e]];Se.tailDx=Se.reversed?ke:we,Se.headDx=Se.reversed?we:ke}}let Q=new Uint8Array(c);X&&!r.tracks&&XM(D,V,X,C,l,r.apart?0:r.edgeSep,Q),r.tracks||KM(D,V,C,l,r.edgeSep,Q);let ne=new Int32Array(i+1),B=r.tracks||P&&!r.straight?{from:[],to:[],rank:[],lower:[],track:[],levels:[],wide:[]}:void 0,K=new Int32Array(g+1);if(B){for(let he=0;he<i;he++){if(ne[he]=B.from.length,o[he])continue;let $e=C[he],Se=!1;for(let Ne=$e,Be=$e<0?$e:$e+l[he]-1;Ne<Be;Ne++){let Pe=X!==void 0&&X[p[Ne]]===1;!r.tracks&&Pe!==(Q[Ne]===1)&&(Se=!0)}if(Se)continue;let we=V[v[I[he]]]+k[I[he]],ke=p[v[I[he]]];for(let Ne=$e,Be=$e<0?$e:$e+l[he]-1;Ne<Be;Ne++)X&&X[p[Ne]]||(B.from.push(we),B.to.push(V[Ne]),B.rank.push(ke),B.lower.push(Ne),we=V[Ne],ke=p[Ne]);B.from.push(we),B.to.push(V[x[G[he]]]+b[G[he]]),B.rank.push(ke),B.lower.push(-1)}ne[i]=B.from.length}let ie=(he,$e)=>{let Se=!1;for(let we=E[he];we<E[he+1];we++){let ke=d[w[we]];if(ke===$e)Se=!0;else if(ke!==1)return!1}return Se},le=ie(0,3)?a:0,J=ie(g,4)?a:0,te=new Float64Array(g+1);for(let he=0;he<m;he++){let $e=Math.abs(V[v[he]]+k[he]-V[x[he]]-b[he]);$e>te[p[v[he]]]&&(te[p[v[he]]]=$e)}let ae=new Float64Array(g+1),ee=new Float64Array(g+1),re=he=>(he<le||he>=g-J?r.portSep:r.rankSep)/a,de=new Float64Array(g+1);for(let he=0;he<g;he++)de[he]=B?re(he):Math.max(re(he),Math.min(o0*r.rankSep/a,te[he]*IM));let ye=new Uint8Array(g+1).fill(1);for(let he=0;he<n;he++)ye[p[he]]=0;for(let he=1;he<g;he++){if(r.tracks||!ye[he]||N[he]!==1&&N[he]!==2)continue;let $e=Math.min((r.headRoom??0)/2,de[N[he]===1?he-1:he]/2);de[he-1]+=N[he]===1?-$e:$e,de[he]+=N[he]===1?$e:-$e}let oe=he=>d[he]===1&&ye[p[he]]&&!r.tracks?(ee[p[he]]-ae[p[he]])/4:0,xe=r.tracks?NM:DM,fe=r.tracks?RM:c0,pe=r.tracks?OM:c0,Me=new Int32Array(g+1);if(B){let he=new Float64Array(g+1);for(let Se=0;Se<g;Se++){if(X&&X[Se])continue;let we=Se+1;for(he[Se]=de[Se];we<g&&X&&X[we];)he[Se]+=de[we++];Me[Se]=we}for(let Se=0;Se<B.from.length;Se++)B.wide.push(Math.abs(B.from[Se]-B.to[Se])>LM*he[B.rank[Se]]?1:0);let $e=new Float64Array(g+1);qM(B,K,!r.tracks,he,$e);for(let Se=0;Se<g;Se++)K[Se]>0?de[Se]+=Math.max(0,2*xe+(K[Se]-1)*fe-he[Se]):$e[Se]>0&&(de[Se]+=Math.max(0,Math.min(o0*r.rankSep,$e[Se])-he[Se]))}let Ae=0;for(let he=0;he<=g;he++){let $e=0;for(let Se=E[he];Se<E[he+1];Se++)u[w[Se]]>$e&&($e=u[w[Se]]);ae[he]=Ae,ee[he]=Ae+$e,Ae+=$e+de[he]}let ce=Ae,ge=(he,$e=B.track[he])=>{let Se=B.rank[he],we=ee[Se],ke=ae[Me[Se]],Ne=r.tracks?K[Se]:B.levels[he],Be=Ne>1?Math.min(pe,(ke-we-2*xe)/(Ne-1)):0;return(we+ke)/2+($e-(Ne-1)/2)*Be},be=1/0,Ie=-1/0;for(let he=0;he<c;he++){let $e=h[he]/2;V[he]-$e<be&&(be=V[he]-$e),V[he]+$e>Ie&&(Ie=V[he]+$e)}let Re=new Uint8Array(g+1),ze=new Uint8Array(g+1);for(let he=0;he<n;he++)d[he]!==0||!P||(A[he+1]>A[he]&&(Re[p[he]]=1),S[he+1]>S[he]&&(ze[p[he]]=1));for(let he=0;he<n;he++){let $e=e[he],Se=$e.rank;$e.x=V[he]-be,d[he]===0&&ze[Se]&&!Re[Se]?$e.y=ee[Se]-$e.h/2:d[he]===0&&Re[Se]&&!ze[Se]?$e.y=ae[Se]+$e.h/2:$e.y=(ae[Se]+ee[Se])/2}for(let he=0;he<i;he++){let $e=t[he],Se=e[$e.reversed?$e.head:$e.tail],we=e[$e.reversed?$e.tail:$e.head],ke=[Se.x+($e.reversed?$e.headDx:$e.tailDx),Se.y+Se.h/2],Ne=C[he];if(B&&ne[he+1]>ne[he])for(let Pe=ne[he];Pe<ne[he+1];Pe++){if(B.track[Pe]>=0&&(r.tracks||B.wide[Pe]===1)){let me=ge(Pe);ke.push(B.from[Pe]-be,me,B.to[Pe]-be,me)}else B.track[Pe]>0&&ke.push(B.from[Pe]-be,ge(Pe,B.track[Pe]-1));let q=B.lower[Pe];q<0||(ke.push(V[q]-be,ae[p[q]]+oe(q)),ee[p[q]]>ae[p[q]]&&ke.push(V[q]-be,ee[p[q]]-oe(q)))}else if(Ne>=0)for(let Pe=Ne,q=Ne+l[he]-1;Pe<q;Pe++){if(Q[Pe])continue;let me=V[Pe]-be,se=ae[p[Pe]],ve=ee[p[Pe]];ke.push(me,se+oe(Pe)),ve>se&&ke.push(me,ve-oe(Pe))}if(ke.push(we.x+($e.reversed?$e.tailDx:$e.headDx),we.y-we.h/2),$e.reversed)for(let Pe=0,q=ke.length-2;Pe<q;Pe+=2,q-=2){let me=ke[Pe],se=ke[Pe+1];ke[Pe]=ke[q],ke[Pe+1]=ke[q+1],ke[q]=me,ke[q+1]=se}$e.points=ke;let Be=R[he];Be>=0?($e.labelX=V[Be]-be,$e.labelY=(ae[p[Be]]+ee[p[Be]])/2):$e.labelW>0&&($e.labelX=(ke[0]+ke[ke.length-2])/2,$e.labelY=(ke[1]+ke[ke.length-1])/2)}return{width:Ie-be,height:ce}}function Qf(e,t){let r=e.length,n=t.length,i=new Int32Array(r+1);for(let c=0;c<n;c++){let h=t[c];h.reversed=e[h.head].kind===3||e[h.tail].kind===4,h.reversed||i[h.tail+1]++}for(let c=0;c<r;c++)i[c+1]+=i[c];let a=new Int32Array(i[r]);{let c=i.slice(0,r);for(let h=0;h<n;h++)t[h].reversed||(a[c[t[h].tail]++]=h)}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 h=o[o.length-1];if(s[h]<i[h+1]){let u=t[a[s[h]++]],d=u.head;l[d]===1?u.reversed=!0:l[d]===0&&(l[d]=1,o.push(d))}else l[h]=2,o.pop()}}function Jf(e,t,r){let n=e.length,i=t.length,a=new Int32Array(i),l=new Int32Array(i),s=new Int32Array(i),o=new Int32Array(n+1),c=new Int32Array(n+1);for(let b=0;b<i;b++){let C=t[b],N=C.reversed?C.head:C.tail,R=C.reversed?C.tail:C.head;a[b]=N,l[b]=R,s[b]=Math.max(1,C.minlen)*r,o[N+1]++,c[R+1]++}for(let b=0;b<n;b++)o[b+1]+=o[b],c[b+1]+=c[b];let h=new Int32Array(i),u=new Int32Array(i);{let b=o.slice(0,n),C=c.slice(0,n);for(let N=0;N<i;N++)h[b[a[N]]++]=N,u[C[l[N]]++]=N}let d=new Int32Array(n),p=new Int32Array(n);for(let b=0;b<n;b++)p[b]=c[b+1]-c[b];let g=new Int32Array(n),m=0;for(let b=0;b<n;b++)p[b]===0&&(g[m++]=b);for(let b=0;b<m;b++){let C=g[b];for(let N=o[C];N<o[C+1];N++){let R=h[N],O=l[R];d[C]+s[R]>d[O]&&(d[O]=d[C]+s[R]),--p[O]===0&&(g[m++]=O)}}for(let b=0;b<8;b++){let C=!1;for(let N=m-1;N>=0;N--){let R=g[N],O=c[R+1]-c[R],P=o[R+1]-o[R];if(O===0&&P===0)continue;let H=-1/0,I=1/0;for(let Z=c[R];Z<c[R+1];Z++){let z=u[Z];H=Math.max(H,d[a[z]]+s[z])}for(let Z=o[R];Z<o[R+1];Z++){let z=h[Z];I=Math.min(I,d[l[z]]-s[z])}let G=d[R];P>O&&I!==1/0?G=I:O>P&&H!==-1/0&&(G=H),G!==d[R]&&(d[R]=G,C=!0)}if(!C)break}let v=1/0,x=-1/0,k=!1;for(let b=0;b<n;b++){let C=e[b].kind;C===3&&(k=!0),!(C===3||C===4)&&(d[b]<v&&(v=d[b]),d[b]>x&&(x=d[b]))}v===1/0&&(v=0,x=0);for(let b=0;b<n;b++)e[b].kind===3?d[b]=v-r:e[b].kind===4&&(d[b]=x+r);k&&(v-=r);for(let b=0;b<n;b++)e[b].rank=d[b]-v}function Xx(e,t,r,n,i,a,l){let s=r===0?e.predStart:e.succStart,o=r===0?e.predE:e.succE,c=r===0?e.EF:e.ET,h=e.pos;for(let g=s[t];g<s[t+1];g++)i[o[g]]!==0&&a.push(o[g]);if(a.length<2)return 0;a.sort((g,m)=>h[c[g]]-h[c[m]]||g-m);let u=g=>{let m=0;l[0]=0;for(let v=1;v<a.length;v++){let x=i[a[v]]===i[a[v-1]];l[v]=g(x&&i[a[v]]===1,x),m+=l[v]}return m},d=u(()=>1);if(n/d<l0&&(d=u(g=>g?.5:1)),n/d<l0&&(d=u((g,m)=>m?0:1)),d===0)return 0;let p=Math.min(hf,n/d);for(let g=1;g<a.length;g++)l[g]*=p;return d*p}function HM(e,t,r,n){let{real:i,W:a,EFD:l,ETD:s}=e;for(let o=0;o<i;o++){let c=Math.min(t[o].span,a[o]);if(!(c<=0||t[o].kind!==0))for(let h=0;h<2;h++){let u=[],d=[],p=Xx(e,o,h,c,h===0?n:r,u,d);if(p===0)continue;let g=h===0?s:l,m=-p/2;for(let v=0;v<u.length;v++)m+=d[v],g[u[v]]=m}}}function Ac(e,t,r,n){if(!t)return r;let{KIND:i,RANK:a,EF:l,ET:s,succStart:o,succE:c,predStart:h,predE:u}=e;for(let d=0;d<1e5;d++){let p=n===0?l[r]:s[r];if(i[p]!==1||!t[a[p]])break;r=n===0?u[h[p]]:c[o[p]]}return r}function jM(e,t,r){let n=[new Int32Array(e.n),new Int32Array(e.n)];for(let i=0;i<e.EF.length;i++)r[i]!==0&&n[0][e.ET[i]]++,t[i]!==0&&n[1][e.EF[i]]++;return n}function Tc(e,t){return Math.max(.25,Math.min(.5,4*Math.abs(t)/(Math.abs(e)||1)))}function UM(e,t,r,n,i,a){let l=i.edgeSep,{n:s,real:o,maxRank:c,KIND:h,RANK:u,W:d,EF:p,ET:g,EFD:m,ETD:v,succStart:x,succE:k,predStart:b,predE:C,layerStart:N,order:R,pos:O}=e,P=W=>h[W]===2||h[W]===1&&!(a!==void 0&&a[u[W]]===1),H=(W,S)=>{let A=S===0?p[W]:g[W];return[S===0?r[A]+m[W]:r[A]+v[W],A<o&&t[A].kind===0?n[1-S][A]:0]},I=W=>{let S=N[u[W]],A=S+O[W],$=y=>d[y]/2+d[W]/2+(h[y]===0?i.nodeSep/2+l/2:h[y]===h[W]?l:l/2);return[A>S?r[R[A-1]]+$(R[A-1]):-1/0,A+1<N[u[W]+1]?r[R[A+1]]-$(R[A+1]):1/0]},G=(W,S,A,$,y)=>{let E=(S[1]!==A[1]?S[1]<A[1]:Math.abs(S[0]-W)<=Math.abs(A[0]-W))?[S[0],A[0]]:[A[0],S[0]];return E.find(w=>w>=$&&w<=y)??Math.max($,Math.min(y,E[0]))},Z=new Uint8Array(s),z=[];for(let W=1;W<c;W++)for(let S=N[W];S<N[W+1];S++){if(!P(R[S])||Z[R[S]])continue;let A=R[S];for(;fa(h[p[C[b[A]]]]);)A=p[C[b[A]]];let $=A,y=-1/0,E=1/0;z.length=0;for(let w=A;fa(h[w]);w=g[k[x[w]]]){if($=w,!P(w))continue;Z[w]=1,z.push(w);let[T,_]=I(w);T>y&&(y=T),_<E&&(E=_)}if(y<=E){let w=G(r[z[0]],H(C[b[A]],0),H(k[x[$]],1),y,E);for(let T of z)r[T]=w;continue}for(let w of z){let[T,_]=I(w);T>_||(r[w]=G(r[w],H(Ac(e,a,C[b[w]],0),0),H(Ac(e,a,k[x[w]],1),1),T,_))}}}function YM(e,t,r,n,i,a,l){let{real:s,W:o,EF:c,ET:h,EFD:u,ETD:d,succStart:p,succE:g,predStart:m,predE:v,pos:x}=e,k=(C,N,R,O,P)=>{if(a[N][R]<2)return 0;C=Ac(e,l,C,N);let H=N===0?c[C]:h[C],I=N===0?r[H]+u[C]:r[H]+d[C];if(P&&Math.abs(I-r[R])<=O/2+Xr)return Math.max(-O/2,Math.min(O/2,I-r[R]));let G=I,Z=0;H<s&&t[H].kind===0&&(N===0?n:i)[C]!==0&&a[1-N][H]>=2&&(Z=Math.max(0,Math.min(t[H].span,o[H])),Z>0&&(G=r[H]));let z=Math.max(r[R]-O/2,G-Z/2),W=Math.min(r[R]+O/2,G+Z/2);if(z>W+Xr){let A=Math.max(0,O/2-WM);return Math.max(-A,Math.min(A,I-r[R]))}let S=(r[R]*Z+G*O)/(Z+O);return Math.max(z,Math.min(W,S))-r[R]},b=[];for(let C=0;C<s;C++){let N=Math.min(t[C].span,o[C]);if(!(N<=0||t[C].kind!==0))for(let R=0;R<2;R++){let O=R===0?c:h,P=R===0?m:p,H=R===0?v:g,I=[],G=[];if(Xx(e,C,R,N,R===0?i:n,I,G),I.length===0)continue;I.length===1&&(G[0]=0);let Z=[];for(let z=P[C];z<P[C+1];z++)Z.push(H[z]);Z.sort((z,W)=>x[O[z]]-x[O[W]]||z-W),b.push({v:C,side:R,span:N,ids:I,room:G,all:Z})}}for(let C=0,N=!0;N&&C<6;C++){N=!1;for(let{v:R,side:O,span:P,ids:H,room:I,all:G}of b){let Z=O===0?i:n,z=O===0?d:u,W=0,S=-P/2;for(let A=0;A<=G.length;A++){let $=A<G.length&&Z[G[A]]===0;if(A<G.length&&!$)continue;let y=0;for(let w=A-1;w>=0&&Z[G[w]]!==0;w--)y++;let E=$?z[G[A]]-hf:P/2;if(y>0){let w=[],T=[],_=0;for(let j=0;j<y;j++){j>0&&(_+=I[W+j]),w.push(k(H[W+j],O,R,P,C>0)-_),T.push(1);let Y=j>0&&I[W+j]===0;for(;w.length>1&&(Y||w[w.length-2]/T[T.length-2]>w[w.length-1]/T[T.length-1]);){Y=!1;let D=w.pop(),L=T.pop();w[w.length-1]+=D,T[T.length-1]+=L}}let M=_,U=0;_=0;for(let j=0;j<w.length;j++){let Y=E-M<S?(S+E-M)/2:Math.max(S,Math.min(E-M,w[j]/T[j]));for(let D=0;D<T[j];D++,U++)U>0&&(_+=I[W+U]),Math.abs(z[H[W+U]]-Y-_)>.01&&(N=!0),z[H[W+U]]=Y+_}W+=y}$&&(S=z[G[A]]+hf)}}}}function GM(e,t,r,n){let{n:i,KIND:a,RANK:l,EF:s,ET:o,EFD:c,ETD:h,layerStart:u,order:d,pos:p}=e,g=I=>r!==void 0&&a[I]===1&&r[l[I]]===1,m=[],v=[],x=[],k=[];for(let I=0;I<s.length;I++){if(g(s[I]))continue;let G=Ac(e,r,I,1);m.push(s[I]),v.push(o[G]),x.push(c[I]),k.push(h[G])}let b=I=>t[v[I]]+k[I]-t[m[I]]-x[I],C=new Int32Array(i),N=[];for(let I=0;I<i;I++)C[I]=I,N.push([I]);let R=(I,G)=>{let Z=C[I],z=C[G];if(Z!==z){N[Z].length<N[z].length&&([Z,z]=[z,Z]);for(let W of N[z])C[W]=Z,N[Z].push(W);N[z]=[]}},O=[];for(let I=0;I<m.length;I++){let G=Math.abs(b(I));G<.01?R(m[I],v[I]):G<=h0&&O.push(I)}if(O.length===0)return;O.sort((I,G)=>Math.abs(b(I))-Math.abs(b(G))||I-G);let P=I=>Kx(e,n,I),H=(I,G)=>{for(let Z of N[I]){let z=u[l[Z]],W=u[l[Z]+1],S=z+p[Z];if(S>z&&C[d[S-1]]!==I&&t[Z]+G-t[d[S-1]]<P(Z)+P(d[S-1])-.01||S+1<W&&C[d[S+1]]!==I&&t[d[S+1]]-t[Z]-G<P(Z)+P(d[S+1])-.01)return!1}return!0};for(let I of O){let G=b(I);if(Math.abs(G)<.01){R(m[I],v[I]);continue}if(Math.abs(G)>h0||C[m[I]]===C[v[I]])continue;let Z=C[m[I]],z=C[v[I]],W=N[Z].length<=N[z].length?Z:z;for(let S of[W,W===Z?z:Z]){let A=S===Z?G:-G;if(H(S,A)){for(let $ of N[S])t[$]+=A;R(m[I],v[I]);break}}}}function VM(e){let{maxRank:t,KIND:r,layerStart:n,order:i}=e,a=new Uint8Array(t+1),l=!1;for(let s=1;s<t;s++){let o=n[s+1]>n[s];for(let c=n[s];o&&c<n[s+1];c++)r[i[c]]!==1&&(o=!1);o&&(a[s]=1,l=!0)}return l?a:void 0}function qM(e,t,r,n,i){let{from:a,to:l,rank:s,track:o,levels:c,wide:h}=e,u=a.length,d=new Map;for(let I=0;I<u;I++){if(o.push(-1),c.push(0),Math.abs(a[I]-l[I])<Xr)continue;let G=d.get(s[I]);G?G.push(I):d.set(s[I],[I])}if(d.size===0)return;let p=new Float64Array(u),g=new Float64Array(u);for(let I=0;I<u;I++)p[I]=Math.min(a[I],l[I]),g[I]=Math.max(a[I],l[I]);let m=(I,G)=>I>=p[G]-Xr&&I<=g[G]+Xr?1:0,v=(I,G)=>Math.abs(a[I]-a[G])<Xr||Math.abs(l[I]-l[G])<Xr,x=(I,G)=>p[I]<g[G]-Xr&&p[G]<g[I]-Xr,k=(I,G)=>x(I,G)&&!v(I,G),b=(I,G)=>x(I,G)||m(l[I],G)+m(a[G],I)+m(l[G],I)+m(a[I],G)>0,C=(I,G)=>m(l[I],G)+m(a[G],I),N=I=>{let G=I.map((z,W)=>W).sort((z,W)=>p[I[z]]-p[I[W]]),Z=[];for(let z=0;z<G.length;z++){let W=G[z],S=g[I[W]]+4*Xr;for(let A=z+1;A<G.length&&p[I[G[A]]]<=S;A++){let $=G[A];Z.push(Math.min(W,$),Math.max(W,$))}}return Z},R=I=>{I.sort((U,j)=>g[j]-p[j]-(g[U]-p[U])||p[U]-p[j]||U-j);let G=I.length,Z=[],z=I.map((U,j)=>j),W=U=>{for(;z[U]!==U;)U=z[U]=z[z[U]];return U},S=G<=u0,A=S?N(I):[],$=S?I.map(()=>[]):[];for(let U=0;U<A.length;U+=2){let j=A[U],Y=A[U+1];k(I[j],I[Y])&&($[j].push(Y),$[Y].push(j))}let y=I.map((U,j)=>j);if(S){let U=new Int32Array(G),j=[];for(let D=0;D<G;D++)Z.push([]),j.push([]);for(let D=0;D<A.length;D+=2){let L=A[D],F=A[D+1],V=I[L],X=I[F];if(!b(V,X))continue;z[W(L)]=W(F);let Q=C(V,X),ne=C(X,V);if(Q===ne)continue;let B=Q<ne?L:F,K=Q<ne?F:L;Z[K].push(B),j[B].push(K),U[K]++}let Y=new Uint8Array(G);y=[];for(let D=0;D<G;D++){let L=-1;for(let F=0;F<G&&!(!Y[F]&&((L<0||U[F]<U[L])&&(L=F),U[F]===0));F++);Y[L]=1,y.push(L);for(let F of j[L])U[F]--}}let E=new Set,w=[],T=0;for(let U of y){let j=I[U],Y=0;for(let D of Z[U]??[])o[I[D]]>=Y&&(Y=o[I[D]]+1);if(S){E.clear();for(let D of $[U])E.add(o[I[D]]);for(;E.has(Y);)Y++}else{for(;w[Y]?.some(D=>k(j,D));)Y++;(w[Y]??=[]).push(j)}o[j]=Y,Y>=T&&(T=Y+1)}let _=new Int32Array(G).fill(T),M=new Int32Array(G).fill(-1);for(let U=0;U<G;U++){let j=W(U);_[j]=Math.min(_[j],o[I[U]]),M[j]=Math.max(M[j],o[I[U]])}for(let U=0;U<G;U++){let j=W(U);c[I[U]]=M[j]-_[j]+1,r&&(o[I[U]]-=_[j])}return T},O=(I,G,Z)=>{let z=Tc(l[I]-a[I],G);for(let W=0;W<=ua;W++){let S=W/ua,A=1-S;Z[2*W]=a[I]+(l[I]-a[I])*S*S*(3-2*S),Z[2*W+1]=G*(3*z*S*A*A+3*(1-z)*S*S*A+S*S*S)}},P=(I,G,Z)=>{let z=Z*Z*1.000000001;for(let W=0;W<=ua;W++){let S=I[2*W],A=I[2*W+1];for(let $=0;$<ua;$++){let y=G[2*$+2]-G[2*$],E=G[2*$+3]-G[2*$+1],w=Math.max(0,Math.min(1,((S-G[2*$])*y+(A-G[2*$+1])*E)/(y*y+E*E||1))),T=S-G[2*$]-w*y,_=A-G[2*$+1]-w*E;if(T*T+_*_<z&&Math.hypot(T,_)<Z)return!0}}return!1},H=(I,G,Z,z)=>{let W=Math.max(Z/2,Z-2*PM);return O(I,W,uh),O(G,W,fh),P(uh,fh,z)||P(fh,uh,z)};for(let[I,G]of d){if(!r){t[I]=R(G);continue}if(G.length>u0)continue;let Z=G.filter(w=>h[w]===1);R(Z);let z=new Set(Z.filter(w=>c[w]>1)),W=N(G);for(let w=0;w<W.length;w+=2){let T=G[W[w]],_=G[W[w+1]];z.has(T)&&z.has(_)||!k(T,_)||a[T]<l[T]!=a[_]<l[_]||H(T,_,n[I],h[T]===1||h[_]===1?zM:FM)&&z.add(T).add(_)}for(let w of Z)o[w]=-1,c[w]=0;if(z.size===0)continue;let S=0,A=0,$=new Set;for(let w=0;w<W.length;w+=2){let T=G[W[w]],_=G[W[w+1]];if(z.has(T)&&z.has(_)){if(!x(T,_))continue;a[T]<l[T]!=a[_]<l[_]?S++:v(T,_)||A++}else(z.has(T)||z.has(_))&&b(T,_)&&$.add(T).add(_)}if(S>A){for(let w of G)(g[w]-p[w])*d0>i[I]&&(i[I]=(g[w]-p[w])*d0);continue}let y=G.filter(w=>z.has(w)||h[w]!==1&&$.has(w));R(y);let E=0;for(let w of y)c[w]>E&&(E=c[w]);t[I]=E}}function XM(e,t,r,n,i,a,l){let{maxRank:s,EF:o,ET:c,EFD:h,ETD:u,succStart:d,succE:p,predStart:g,predE:m,layerStart:v,order:x}=e,k=new Float64Array(t.length),b=new Float64Array(t.length),C=new Float64Array(t.length);for(let R=0;R<n.length;R++){let O=n[R];if(O<0)continue;let P=O+i[R]-1,H=e.RANK[O];for(let I=O;I<P;I++){if(!r[H+I-O])continue;let G=I;for(;G+1<P&&r[H+G+1-O];)G++;let Z=m[g[I]],z=p[d[G]],W=t[o[Z]]+h[Z],S=t[c[z]]+u[z],A=G-I+2;for(let $=I;$<=G;$++)k[$]=W+(S-W)*($-I+1)/A,b[$]=W,C[$]=S;I=G}}let N=[];for(let R=1;R<s;R++){if(!r[R])continue;let O=v[R],P=v[R+1],H=Array.from(x.subarray(O,P)).sort((I,G)=>b[I]-b[G]||C[I]-C[G]||I-G);for(let I=0;I<H.length;){N.length=0;let G=I;for(;G<H.length&&Math.abs(b[H[G]]-b[H[I]])<1&&Math.abs(C[H[G]]-C[H[I]])<1;G++)N.push(H[G]);N.sort((Z,z)=>e.pos[Z]-e.pos[z]);for(let Z=0;Z<N.length;Z++){let z=N[Z];t[z]=k[z]+(Z-(N.length-1)/2)*a,(N.length===1||a===0)&&(l[z]=1)}I=G}}}function KM(e,t,r,n,i,a){let{maxRank:l,W:s,KIND:o,RANK:c,EF:h,ET:u,EFD:d,ETD:p,succStart:g,succE:m,predStart:v,predE:x,layerStart:k,order:b}=e,C=new Uint8Array(l+1),N=!1;for(let R=1;R<l;R++){let O=!1,P=!1;for(let H=k[R];H<k[R+1];H++){let I=o[b[H]];I===2?O=!0:I!==1&&(P=!0)}O&&!P&&(C[R]=1,N=!0)}if(N)for(let R=0;R<r.length;R++){let O=r[R];if(!(O<0))for(let P=O,H=O+n[R]-1;P<H;P++){if(o[P]!==1||!C[c[P]])continue;let I=P,G=P;for(;I>O&&a[I-1];)I--;for(;G+1<H&&a[G+1];)G++;let Z=x[v[I]],z=m[g[G]],W=t[h[Z]]+d[Z],S=t[u[z]]+p[z],A=Math.min(W,S)-i,$=Math.max(W,S)+i,y=!0,E=c[P];for(let T=k[E];y&&T<k[E+1];T++){let _=b[T];o[_]===2&&t[_]+s[_]/2>A&&t[_]-s[_]/2<$&&(y=!1)}if(!y)continue;a[P]=1;let w=G-I+2;for(let T=I;T<=G;T++)t[T]=W+(S-W)*(T-I+1)/w}}}function ZM(e,t){let{n:r,real:n,maxRank:i,W:a,EF:l,ET:s,EFD:o,ETD:c,succStart:h,succE:u,predStart:d,predE:p,layerStart:g,order:m,pos:v,offsets:x,fixed:k,GRP:b,groupParent:C}=e,N=0;for(let te=0;te<=i;te++)N=Math.max(N,g[te+1]-g[te]);if(N<2)return[0,0];let R=x?new Int32Array(l.length):void 0,O=new Int32Array(R?l.length:0),P=new Int32Array(R?r:0),H=R?u.slice():u,I=new Uint8Array(R?r:0);if(R){let te=p.slice(),ae=(ee,re,de,ye)=>{for(let oe=re+1;oe<de;oe++)if(ye[ee[oe]]!==ye[ee[re]])return ee.subarray(re,de).sort((xe,fe)=>ye[xe]-ye[fe]),!0;return!1};for(let ee=0;ee<r;ee++){if(P[ee]=1,ae(te,d[ee],d[ee+1],c))for(let re=d[ee]+1;re<d[ee+1];re++)c[te[re]]!==c[te[re-1]]&&P[ee]++,O[te[re]]=P[ee]-1;ae(H,h[ee],h[ee+1],o)&&(I[ee]=1)}}let G=1;for(;G<(R?N+l.length:N);)G<<=1;let Z=new Int32Array(2*G),z=new Int32Array(l.length),W=()=>{let te=0;for(let ae=0;ae<i;ae++){let ee=g[ae+2]-g[ae+1];if(R){let ye=0;for(let oe=g[ae+1];oe<g[ae+2];oe++){let xe=m[oe];for(let fe=d[xe];fe<d[xe+1];fe++)R[p[fe]]=ye+O[p[fe]];ye+=P[xe]}ee=ye}if(ee<2)continue;let re=0;for(let ye=g[ae];ye<g[ae+1];ye++){let oe=m[ye],xe=h[oe],fe=h[oe+1],pe=re;for(let Ae=xe;Ae<fe;Ae++)z[re++]=R?R[H[Ae]]:v[s[u[Ae]]];let Me=re-pe;if(!(Me<2))if(R&&I[oe])for(let Ae=pe+1;Ae<re;Ae++){let ce=z[Ae],ge=o[H[xe+Ae-pe]],be=Ae-1;for(;be>=pe&&o[H[xe+be-pe]]===ge&&z[be]>ce;)z[be+1]=z[be],be--;z[be+1]=ce}else if(Me<=12)for(let Ae=pe+1;Ae<re;Ae++){let ce=z[Ae],ge=Ae-1;for(;ge>=pe&&z[ge]>ce;)z[ge+1]=z[ge],ge--;z[ge+1]=ce}else z.subarray(pe,re).sort()}if(re<2)continue;let de=1;for(;de<ee;)de<<=1;Z.fill(0,0,2*de);for(let ye=0;ye<re;ye++){let oe=z[ye]+de;for(Z[oe]++;oe>1;)(oe&1)===0&&(te+=Z[oe+1]),oe>>=1,Z[oe]++}}return te},S=W(),A=new Float64Array(r),$=new Int32Array(N),y=new Int32Array(N),E=C?C.length:0,w=new Int32Array(E);for(let te=0;te<E;te++)for(let ae=te;ae>=0;ae=C[ae])w[te]++;let T=new Float64Array(E),_=new Int32Array(E),M=new Int32Array(E),U=(te,ae)=>{let ee=g[te],re=g[te+1];for(let fe=ee;fe<re;fe++)for(let pe=b[m[fe]];pe>=0;pe=C[pe])T[pe]=0,_[pe]=0;for(let fe=ee;fe<re;fe++){let pe=m[fe];for(let Me=b[pe];Me>=0;Me=C[Me])_[Me]===0&&(M[Me]=fe),T[Me]+=ae[pe],_[Me]++}let de=fe=>fe>=r?T[fe-r]/_[fe-r]:ae[fe],ye=fe=>fe>=r?M[fe-r]:ee+v[fe],oe=(fe,pe)=>{let Me=fe,Ae=pe,ce=b[fe],ge=b[pe],be=ce<0?0:w[ce],Ie=ge<0?0:w[ge];for(;be>Ie;be--)Me=r+ce,ce=C[ce];for(;Ie>be;Ie--)Ae=r+ge,ge=C[ge];for(;ce!==ge;)Me=r+ce,ce=C[ce],Ae=r+ge,ge=C[ge];return de(Me)-de(Ae)||ye(Me)-ye(Ae)},xe=Array.from(m.subarray(ee,re)).sort(oe);m.set(xe,ee);for(let fe=ee;fe<re;fe++)v[m[fe]]=fe-ee};if(b){let te=new Float64Array(r);for(let ae=0;ae<=i;ae++){for(let ee=g[ae];ee<g[ae+1];ee++)te[m[ee]]=ee-g[ae];U(ae,te)}}let j=b?W():S;if(j===0)return[0,S];let Y=m.slice(),D=Math.min(j,S),L=(te,ae)=>{let ee=te?d:h,re=te?p:u,de=te?l:s,ye=te?o:c;for(let oe=1;oe<=i;oe++){let xe=te?oe:i-oe;if(k[xe])continue;let fe=g[xe],pe=g[xe+1],Me=0;for(let ce=fe;ce<pe;ce++){let ge=m[ce],be=ge<n?t[ge].pin:0;if(be!==0){A[ge]=be*1e9,$[Me++]=ge;continue}let Ie=ee[ge],Re=ee[ge+1];if(Ie===Re){if(b){let he=te?g[xe]-g[xe-1]:g[xe+2]-g[xe+1];A[ge]=(ce-fe)*he/(pe-fe);continue}A[ge]=-1;continue}let ze=0;for(let he=Ie;he<Re;he++){let $e=de[re[he]];ze+=v[$e],x&&a[$e]>0&&(ze+=ye[re[he]]/a[$e])}A[ge]=ze/(Re-Ie),$[Me++]=ge}if(b){U(xe,A);continue}if(Me<2)continue;BM($,Me,A,v,ae,y);let Ae=0;for(let ce=fe;ce<pe;ce++)A[m[ce]]!==-1&&(m[ce]=$[Ae++]);for(let ce=fe;ce<pe;ce++)v[m[ce]]=ce-fe}},F=()=>{let te=0;for(let ae=0;ae<=i;ae++)for(let ee=g[ae];ee<g[ae+1];ee++)if(!(m[ee]>=n))for(let re=ee+1;re<g[ae+1];re++)m[re]<m[ee]&&te++;return te},V=()=>{for(let te=0;te<=i;te++)for(let ae=g[te];ae<g[te+1];ae++)v[m[ae]]=ae-g[te]},X=te=>te<n?t[te].pin:0,Q=(te,ae)=>{let ee=ae?l[te]:s[te];return x&&a[ee]>0?v[ee]+(ae?o[te]:c[te])/a[ee]:v[ee]},ne=(te,ae)=>{let ee=0;for(let re=d[te];re<d[te+1];re++){let de=Q(p[re],!0);for(let ye=d[ae];ye<d[ae+1];ye++)de>Q(p[ye],!0)&&ee++}for(let re=h[te];re<h[te+1];re++){let de=Q(u[re],!1);for(let ye=h[ae];ye<h[ae+1];ye++)de>Q(u[ye],!1)&&ee++}return ee},B=()=>{for(let te=0;te<8;te++){let ae=!1;for(let ee=0;ee<=i;ee++){if(k[ee])continue;let re=g[ee];for(let de=re;de+1<g[ee+1];de++){let ye=m[de],oe=m[de+1];X(ye)!==X(oe)||b&&b[ye]!==b[oe]||ne(oe,ye)>=ne(ye,oe)||(m[de]=oe,m[de+1]=ye,v[oe]=de-re,v[ye]=de+1-re,ae=!0)}}if(!ae)break}},K=m.slice(),ie=r<=600,le=Y,J=1/0;for(let te=0;te<(ie?2:1);te++){te>0&&(m.set(K),V());let ae=D,ee=K.slice();for(let de=0,ye=0;ye<4&&de<CM;de++,ye++){L((de+te)%2===0,de%4>=2);let oe=W();if(oe<ae&&(ae=oe,ee.set(m),ye=0,oe===0))break}if(m.set(ee),ie&&ae>0){V(),B();let de=W();de<ae&&(ae=de,ee.set(m))}let re=ie?F():0;(te===0||ae<j||ae===j&&re<J)&&(j=ae,le=ee,J=re)}if(m.set(le),V(),Y.set(le),b&&(j=W()),!ie)return[j,S];for(let te=0;te<n;te++)if(t[te].pin!==0)return[j,S];if(J===0||k[0]||k[i])return[j,S];for(let te=0;te<=i;te++)m.subarray(g[te],g[te+1]).reverse();return V(),(W()>j||F()>=J)&&m.set(Y),[j,S]}function Kx(e,t,r){return e.W[r]/2+(e.KIND[r]===0?t.nodeSep:t.edgeSep)/2}function p0(e,t){let{n:r,maxRank:n,W:i,KIND:a,EF:l,ET:s,EFD:o,ETD:c,succStart:h,succE:u,predStart:d,predE:p,layerStart:g,order:m,pos:v}=e,x=l.length,k=new Float64Array(r);for(let M=0;M<r;M++)k[M]=Kx(e,t,M);let b=new Int32Array(x);for(let M=0;M<x;M++)b[M]=v[s[M]];for(let M=0;M<r;M++)h[M+1]-h[M]>1&&f0(u,h[M],h[M+1],b);for(let M=0;M<x;M++)b[M]=v[l[M]];for(let M=0;M<r;M++)d[M+1]-d[M]>1&&f0(p,d[M],d[M+1],b);let C=new Uint8Array(x);for(let M=1;M<=n;M++){let U=g[M]-g[M-1],j=g[M],Y=g[M+1],D=0,L=j;for(let F=j;F<Y;F++){let V=m[F],X=-1;if(fa(a[V])){let ne=l[p[d[V]]];fa(a[ne])&&(X=ne)}let Q=X>=0?v[X]:U;if(X>=0||F===Y-1){for(let ne=L;ne<=F;ne++){let B=m[ne],K=fa(a[B]);for(let ie=d[B];ie<d[B+1];ie++){let le=p[ie],J=v[l[le]];(J<D||Q<J)&&!(K&&fa(a[l[le]]))&&(C[le]=1)}}L=F+1,D=Q}}}let N=[],R=new Int32Array(r),O=new Int32Array(r),P=new Float64Array(r),H=new Int32Array(r),I=new Int32Array(r),G=new Float64Array(r),Z=new Int32Array(r),z=new Int32Array(r+1),W=new Int32Array(r),S=new Int32Array(r),A=new Int32Array(r),$=new Float64Array(r);for(let M=0;M<4;M++){let U=M<2,j=(M&1)===1,Y=U?d:h,D=U?p:u,L=U?l:s,F=U?c:o,V=U?o:c;for(let B=0;B<r;B++)R[B]=B,O[B]=B,P[B]=0,Z[B]=0,z[B+1]=0,$[B]=0;for(let B=0;B<=n;B++){let K=U?B:n-B,ie=g[K],le=g[K+1],J=U?K-1:K+1,te=J>=0&&J<=n?g[J+1]-g[J]-1:0,ae=-1;for(let ee=j?le-1:ie;j?ee>=ie:ee<le;j?ee--:ee++){let re=m[ee],de=Y[re],ye=Y[re+1]-de;if(ye===0)continue;let oe=de+(ye-1>>1),xe=de+(ye>>1);for(let fe=0;fe<2&&!(fe===1&&oe===xe);fe++){let pe=D[fe===0!==j?oe:xe],Me=L[pe],Ae=j?te-v[Me]:v[Me];O[re]===re&&ae<Ae&&C[pe]===0&&(O[Me]=re,O[re]=R[re]=R[Me],P[re]=P[Me]+V[pe]-F[pe],ae=Ae)}}}let X=0;for(let B=0;B<=n;B++){let K=g[B],ie=g[B+1];for(let le=K+1;le<ie;le++){let J=j?m[le]:m[le-1],te=j?m[le-1]:m[le],ae=k[J]+k[te];H[X]=R[J],I[X]=R[te],G[X]=j?ae-P[J]+P[te]:ae+P[J]-P[te],Z[R[te]]++,z[R[J]+1]++,X++}}for(let B=0;B<r;B++)z[B+1]+=z[B];for(let B=0;B<r;B++)S[B]=z[B];for(let B=0;B<X;B++)W[S[H[B]]++]=B;let Q=0;for(let B=0;B<r;B++)R[B]===B&&Z[B]===0&&(A[Q++]=B);for(let B=0;B<Q;B++){let K=A[B];for(let ie=z[K];ie<z[K+1];ie++){let le=W[ie],J=I[le];$[K]+G[le]>$[J]&&($[J]=$[K]+G[le]),--Z[J]===0&&(A[Q++]=J)}}for(let B=Q-1;B>=0;B--){let K=A[B],ie=1/0;for(let le=z[K];le<z[K+1];le++){let J=W[le],te=$[I[J]]-G[J];te<ie&&(ie=te)}ie!==1/0&&ie>$[K]&&($[K]=ie)}let ne=new Float64Array(r);for(let B=0;B<r;B++)ne[B]=(j?-$[R[B]]:$[R[B]])+P[B];N.push(ne)}let y=0,E=1/0,w=[],T=[];for(let M=0;M<4;M++){let U=1/0,j=-1/0,Y=N[M];for(let D=0;D<r;D++){let L=i[D]/2;Y[D]-L<U&&(U=Y[D]-L),Y[D]+L>j&&(j=Y[D]+L)}w.push(U),T.push(j),j-U<E&&(E=j-U,y=M)}for(let M=0;M<4;M++){let U=(M&1)===0?w[y]-w[M]:T[y]-T[M];if(U!==0){let j=N[M];for(let Y=0;Y<r;Y++)j[Y]+=U}}let _=new Float64Array(r);for(let M=0;M<r;M++){let U=N[0][M],j=N[1][M],Y=N[2][M],D=N[3][M],L;U>j&&(L=U,U=j,j=L),Y>D&&(L=Y,Y=D,D=L),U>Y&&(L=U,U=Y,Y=L),j>D&&(L=j,j=D,D=L),j>Y&&(L=j,j=Y,Y=L),_[M]=(j+Y)/2}return _}function Pr(e){return e==="BT"||e==="LR"||e==="RL"?e:"TB"}var QM=4e4,JM=400,e_=500,t_=1.5,r_=4;function g0(e,t,r,n){let i=[];for(let s of e)i.push(s.x,s.y,s.w,s.h);let a=[];for(let s of t)a.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:a,levels:l,total:n}}function m0(e,t,r,n){t.forEach((a,l)=>{a.x=e.nodes[4*l],a.y=e.nodes[4*l+1],a.w=e.nodes[4*l+2],a.h=e.nodes[4*l+3]}),r.forEach((a,l)=>{a.route=e.routes[l],a.labelX=e.labels[2*l],a.labelY=e.labels[2*l+1]});let i=0;for(let a of n){a.x=e.levels[i++],a.y=e.levels[i++];for(let l of a.ports)l.px=e.levels[i++],l.py=e.levels[i++]}return e.total}var y0=24,oa=.5,uf=3,ff=2,n_=Math.max(3,uf,ff+1),ql=.62,i_=128;function a_(e){return e.tracks?1:e.straight?2:0}function Xl(e,t,r=0){let n=0;for(let S of t)S.src!==S.dst&&S.route.length>3&&(n+=(S.route.length/3-1)*n_);let i=new Float64Array(n),a=new Float64Array(n),l=new Float64Array(n),s=new Float64Array(n),o=new Float64Array(n),c=new Float64Array(n),h=new Int32Array(n),u=new Uint8Array(n),d=0,p=1/0,g=-1/0,m=NaN,v=NaN,x=NaN,k=NaN,b=(S,A,$,y,E,w)=>{let T=d-1;$===x&&y===k&&(w===y&&v===y||E===$&&m===$)&&h[T]===S&&u[T]===A&&($-m)*(E-$)+(y-v)*(w-y)>0&&(d--,$=m,y=v),m=$,v=y,x=E,k=w,u[d]=A,i[d]=Math.min($,E),l[d]=Math.max($,E),a[d]=$<=E?y:w,s[d]=$<=E?w:y,o[d]=Math.min(y,w),c[d]=Math.max(y,w),o[d]<p&&(p=o[d]),c[d]>g&&(g=c[d]),h[d++]=S};for(let S=0;S<t.length;S++){let A=t[S];if(A.src===A.dst)continue;let $=A.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]),w=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],_=$[1];for(let M=3;M<$.length;M+=3){let U=(M===3?1:0)|(M===$.length-3?2:0),j=T,Y=_,D=$[M],L=$[M+1];if(T=D,_=L,y(M)||r===2){if(!w(M)){b(S,U,j,Y,D,L);continue}let ne=w(M-3)?E(M)/2:E(M),B=w(M+3)?E(M+3)/2:E(M+3),K=(D-$[M-3])/E(M),ie=(L-$[M-2])/E(M),le=($[M+3]-D)/E(M+3),J=($[M+4]-L)/E(M+3),te=D-K*ne,ae=L-ie*ne;b(S,U,j,Y,te,ae);let ee=D-K*ne*(1-ql),re=L-ie*ne*(1-ql),de=D+le*B*(1-ql),ye=L+J*B*(1-ql);T=D+le*B,_=L+J*B;let oe=U|(M+3===$.length-3?2:0),xe=te,fe=ae;for(let pe=1;pe<=ff;pe++){let Me=pe/ff,Ae=1-Me,ce=Ae*Ae*Ae*te+3*Ae*Ae*Me*ee+3*Ae*Me*Me*de+Me*Me*Me*T,ge=Ae*Ae*Ae*ae+3*Ae*Ae*Me*re+3*Ae*Me*Me*ye+Me*Me*Me*_;b(S,oe,xe,fe,ce,ge),xe=ce,fe=ge}continue}if(r===1){let ne=$[M+2]===0,B=ne?j:(j+D)/2,K=ne?(Y+L)/2:Y;b(S,U,j,Y,B,K),b(S,U,B,K,ne?D:B,ne?K:L),b(S,U,ne?D:B,ne?K:L,D,L);continue}let F=$[M+2]===0,V=F?Tc(D-j,L-Y):Tc(L-Y,D-j),X=j,Q=Y;for(let ne=1;ne<=uf;ne++){let B=ne/uf,K=1-B,ie=B*B*(3-2*B),le=3*V*B*K*K+3*(1-V)*B*B*K+B*B*B,J=j+(D-j)*(F?ie:le),te=Y+(L-Y)*(F?le:ie);b(S,U,X,Q,J,te),X=J,Q=te}}}let C=g>p?Math.round(Math.sqrt(d)):1,N=g>p?C/(g-p):0,R=S=>Math.min(C-1,Math.floor((S-p)*N)),O=new Int32Array(d),P=new Int32Array(C+1);for(let S=0;S<d;S++){O[S]=R(o[S]);for(let A=O[S],$=R(c[S]);A<=$;A++)P[A+1]++}for(let S=0;S<C;S++)P[S+1]+=P[S];let H=P.slice(0,C),I=new Int32Array(P[C]);for(let S=0;S<d;S++)for(let A=O[S],$=R(c[S]);A<=$;A++)I[H[A]++]=S;let G=new Float64Array(t.length*8),Z=(S,A,$,y)=>Math.abs(S[A]-S[$])<oa&&Math.abs(S[A]-S[y])<oa||Math.abs(S[A+1]-S[$+1])<oa&&Math.abs(S[A+1]-S[y+1])<oa;for(let S=0;S<t.length;S++){let A=t[S].route;if(A.length<6)continue;let $=3;for(;$+3<A.length&&Z(A,0,$,$+3);)$+=3;let y=A.length-3,E=y-3;for(;E>=3&&Z(A,y,E,E-3);)E-=3;G.set([A[0],A[1],A[$],A[$+1],A[E],A[E+1],A[y],A[y+1]],S*8)}let z=(S,A,$,y)=>{let E=S*8+(A===1?0:4),w=G[E],T=G[E+1],_=G[E+2]-w,M=G[E+3]-T,U=_*_+M*M,j=U>0?Math.max(0,Math.min(1,(($-w)*_+(y-T)*M)/U)):0;return Math.hypot($-w-j*_,y-T-j*M)<oa},W=0;for(let S=0;S<C;S++){let A=P[S+1];if(A-P[S]>i_)I.subarray(P[S],A).sort(($,y)=>i[$]-i[y]||$-y);else for(let $=P[S]+1;$<A;$++){let y=I[$],E=$;for(;E>P[S]&&i[I[E-1]]>i[y];E--)I[E]=I[E-1];I[E]=y}for(let $=P[S];$<A;$++){let y=I[$],E=l[y]-i[y],w=s[y]-a[y],T=O[y]===S;for(let _=$+1;_<A;_++){let M=I[_];if(i[M]>l[y])break;if(c[M]<o[y]||o[M]>c[y]||h[y]===h[M]||!T&&O[M]!==S)continue;let U=E*(a[M]-a[y])-w*(i[M]-i[y]),j=E*(s[M]-a[y])-w*(l[M]-i[y]);if(U>0==j>0)continue;let Y=l[M]-i[M],D=s[M]-a[M],L=Y*(a[y]-a[M])-D*(i[y]-i[M]),F=Y*(s[y]-a[M])-D*(l[y]-i[M]);if(L>0==F>0)continue;let V=t[h[y]],X=t[h[M]],Q=L/(L-F),ne=i[y]+Q*E,B=a[y]+Q*w,K=(ie,le,J)=>(u[y]&le)!==0&&(u[M]&J)!==0||Math.abs(ne-e[ie].x)<e[ie].w/2+y0&&Math.abs(B-e[ie].y)<e[ie].h/2+y0||z(h[y],le,ne,B)&&z(h[M],J,ne,B);V.src===X.src&&K(V.src,1,1)||V.src===X.dst&&K(V.src,1,2)||V.dst===X.src&&K(V.dst,2,1)||V.dst===X.dst&&K(V.dst,2,2)||W++}}}return W}function Zc(e,t,r,n){for(let i of e)i.x+=r,i.y+=n;for(let i of t){for(let a=0;a<i.route.length;a+=3)i.route[a]+=r,i.route[a+1]+=n;i.labelX+=r,i.labelY+=n}}function Bt(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 Kl(e){return e==="TB"?0:e==="BT"?2:e==="LR"?3:1}function is(e){return e+2&3}function Ai(e,t,r,n){let i=e.length,a=new Map,l=[],s=(A,$)=>{let y={id:A,dir:$,items:[],edges:[],ports:[],portOf:new Map,routes:new Map,x:0,y:0};return a.set(A,y),y},o=s(-1,r),c=[];for(let A=0;A<i;A++)c.push([]);let h=[];for(let A=0;A<i;A++){let $=e[A].parent;$>=0&&$<i&&$!==A&&e[$].isGroup?c[$].push(A):(e[A].parent=-1,h.push(A))}o.items=h,l.push(o);let u=new Int32Array(i),d=new Uint8Array(i),p=A=>{for(let $=A;$<l.length;$++){let y=l[$];for(let E of y.items)if(d[E]=1,u[E]=y.id<0?0:u[y.id]+1,e[E].isGroup){let w=s(E,e[E].dir??y.dir);w.items=c[E],l.push(w)}}};p(0);for(let A=0;A<i;A++){if(d[A])continue;let $=e[A].parent;if(c[$]=c[$].filter(y=>y!==A),e[A].parent=-1,o.items.push(A),d[A]=1,u[A]=0,e[A].isGroup){let y=l.length,E=s(A,e[A].dir??r);E.items=c[A],l.push(E),p(y)}}for(let A=l.length-1;A>0;A--){let $=l[A],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 A of l)A.items.sort(($,y)=>e[$].seq-e[y].seq||$-y);let g=0;for(let A of t){let $=A.src,y=A.dst,E=0;for(;u[$]>u[y];E++)$=e[$].parent;for(;u[y]>u[$];E++)y=e[y].parent;for(;$!==y&&e[$].parent!==e[y].parent;E+=2)$=e[$].parent,y=e[y].parent;$!==y&&(g+E>QM?(A.src=$,A.dst=y):g+=E)}let m=[],v=[];for(let A=0;A<t.length;A++){let $=t[A];if($.route=[],$.src===$.dst){m.push(A);continue}let y=$.src,E=$.dst,w=[],T=[];for(;u[y]>u[E];)w.push(y),y=e[y].parent;for(;u[E]>u[y];)T.push(E),E=e[E].parent;if(y===E){v.push(A);continue}for(;e[y].parent!==e[E].parent;)w.push(y),T.push(E),y=e[y].parent,E=e[E].parent;a.get(e[y].parent).edges.push({e:A,a:y,b:E});for(let[_,M]of[[w,!0],[T,!1]])for(let U of _){let j=a.get(e[U].parent),Y={e:A,inner:U,out:M,side:0,hint:NaN,px:0,py:0,route:[]};j.ports.push(Y),j.portOf.set(A*2+(M?0:1),Y)}}let x=new Int32Array(i),k=(A,$,y)=>(y?$.src:$.dst)!==A,b=(A,$)=>{let y=A.dir==="TB"||A.dir==="BT",E=Kl(A.dir),w=[],T=[];A.items.forEach((j,Y)=>{x[j]=Y;let D=e[j],L=$?Is(y?D.w:D.h,y?D.h:D.w):Is(0,0);L.span=D.isGroup?Math.min(D.span,L.w-2*D.padX):D.span,L.key=R?N[j]:NaN,w.push(L)});let _=(j,Y,D)=>e[j].isGroup&&k(j,t[Y],D),M=(j,Y,D)=>{if(!$||!e[j].isGroup||!k(j,t[Y],D))return 0;let L=a.get(j).portOf.get(Y*2+(D?0:1));return y?L.px-e[j].w/2:L.py-e[j].h/2};for(let j of A.edges){let Y=t[j.e],D=Ns(x[j.a],x[j.b],Y.minlen);$&&(D.labelW=y?Y.labelW:Y.labelH,D.labelH=y?Y.labelH:Y.labelW,D.tailDx=M(j.a,j.e,!0),D.headDx=M(j.b,j.e,!1),D.tailFixed=_(j.a,j.e,!0),D.headFixed=_(j.b,j.e,!1)),T.push(D)}let U=new Int32Array(A.ports.length).fill(-1);return A.ports.forEach((j,Y)=>{if(j.side===E||j.side===is(E)){let D=w.length,L=Is(0,0,j.side===E?3:4);L.key=R?N[j.out?t[j.e].dst:t[j.e].src]:NaN,L.hint=Number.isNaN(j.hint)&&R&&P?P(A,j):j.hint,w.push(L),U[Y]=D;let F=j.out?Ns(x[j.inner],D):Ns(D,x[j.inner]);j.out?(F.tailDx=M(j.inner,j.e,!0),F.tailFixed=_(j.inner,j.e,!0)):(F.headDx=M(j.inner,j.e,!1),F.headFixed=_(j.inner,j.e,!1)),T.push(F)}else w[x[j.inner]].pin=j.side===0||j.side===3?-1:1}),{lnodes:w,ledges:T,dummies:U}},C=g>1&&g<=JM&&t.length<=e_,N=new Float64Array(i).fill(NaN),R=!1,O=0,P,H=l.length>1&&C;for(let A of l)A.dir!==r&&(H=!1);if(H){let A=r==="TB"||r==="BT",$=new Int32Array(i).fill(-1),y=new Int32Array(i).fill(-1),E=[],w=[],T=[];for(let L=0;L<i;L++)e[L].isGroup&&(y[L]=T.length,T.push(-1));for(let L=0;L<i;L++){let F=e[L].parent;e[L].isGroup?T[y[L]]=F>=0?y[F]:-1:($[L]=E.length,E.push(Is(A?e[L].w:e[L].h,A?e[L].h:e[L].w)),w.push(F>=0?y[F]:-1))}let _=[],M=new Int32Array(t.length).fill(-1);t.forEach((L,F)=>{L.src===L.dst||$[L.src]<0||$[L.dst]<0||(M[F]=_.length,_.push(Ns($[L.src],$[L.dst],L.minlen,A?L.labelW:L.labelH,A?L.labelH:L.labelW)))});let U=ph(E,_,{...n,groups:{of:Int32Array.from(w),parent:Int32Array.from(T)},orderOnly:!0});O=Math.min(U.crossings??0,U.declared??0);let j=new Float64Array(i),Y=new Int32Array(i),D=new Int32Array(i).fill(-1);for(let L=0;L<i;L++)if(!($[L]<0)){N[L]=E[$[L]].x;for(let F=e[L].parent;F>=0;F=e[F].parent)j[F]+=N[L],Y[F]++,D[F]=Math.max(D[F],E[$[L]].rank)}for(let L=0;L<i;L++)Y[L]>0&&(N[L]=j[L]/Y[L]);P=(L,F)=>{let V=M[F.e];if(V<0||L.id<0||!F.out||F.side!==is(Kl(L.dir)))return NaN;let X=_[V].points,Q=N[t[F.e].src],ne=0;for(let B=0;B<X.length;B+=2)X[B]===D[L.id]&&(Q=X[B+1]),X[B]===D[L.id]+1&&(ne=X[B+1]);return Q+ne*1e-6}}let I=new Map,G=(A,$,y)=>{if(!C)return{lnodes:$,ledges:y,size:ph($,y,n)};let E=[];for(let _ of $)E.push(_.w,_.h,_.kind,_.pin,_.hint,_.key,_.span);for(let _ of y)E.push(_.tail,_.head,_.minlen,_.labelW,_.labelH,_.tailDx,_.headDx,+_.tailFixed,+_.headFixed);let w=I.get(A.id);w||I.set(A.id,w=[]);for(let _ of w){let M=_.given.length===E.length;for(let U=0;M&&U<E.length;U++)M=Object.is(_.given[U],E[U]);if(M)return _}let T={given:E,lnodes:$,ledges:y,size:ph($,y,n)};return w.push(T),T},Z={width:0,height:0},z=()=>{for(let $ of l){for(let _ of $.ports)e[_.inner].isGroup&&k(_.inner,t[_.e],_.out)&&(a.get(_.inner).portOf.get(_.e*2+(_.out?0:1)).side=_.side);if($.edges.length===0)continue;let y=!1;for(let _ of $.edges){let M=t[_.e];(e[_.a].isGroup&&M.src!==_.a||e[_.b].isGroup&&M.dst!==_.b)&&(y=!0)}if(!y)continue;let{lnodes:E,ledges:w}=b($,!1);Qf(E,w),Jf(E,w,1);let T=Kl($.dir);$.edges.forEach((_,M)=>{let U=t[_.e],j=!w[M].reversed;e[_.a].isGroup&&U.src!==_.a&&(a.get(_.a).portOf.get(_.e*2).side=j?is(T):T),e[_.b].isGroup&&U.dst!==_.b&&(a.get(_.b).portOf.get(_.e*2+1).side=j?T:is(T))})}for(let $=l.length-1;$>=0;$--){let y=l[$],E=y.id>=0?e[y.id]:void 0,w=y.dir==="TB"||y.dir==="BT",T=y.dir==="BT"||y.dir==="RL",_=b(y,!0),{lnodes:M,ledges:U,size:j}=G(y,_.lnodes,_.ledges),Y=_.dummies,D=w?j.width:j.height,L=w?j.height:j.width,F=E?E.padX:0,V=E?E.padTop:0,X=Math.max(D+2*F,E?E.minW:0),Q=L+V+(E?E.padBottom:0),ne=(X-D)/2,B=V,K=(ae,ee)=>ne+(w?ae:T?j.height-ee:ee),ie=(ae,ee)=>B+(w?T?j.height-ee:ee:ae),le=w?0:1,J=ae=>{let ee=[];for(let re=0;re<ae.length;re+=2)ee.push(K(ae[re],ae[re+1]),ie(ae[re],ae[re+1]),le);return ee};y.items.forEach((ae,ee)=>{e[ae].x=K(M[ee].x,M[ee].y),e[ae].y=ie(M[ee].x,M[ee].y)}),y.edges.forEach((ae,ee)=>{let re=U[ee];y.routes.set(ae.e,J(re.points));let de=t[ae.e];de.labelW>0&&(de.labelX=K(re.labelX,re.labelY),de.labelY=ie(re.labelX,re.labelY))});let te=y.edges.length;y.ports.forEach((ae,ee)=>{let re=e[ae.inner];if(Y[ee]>=0){let pe=J(U[te++].points),Me=ae.out?pe.length-3:0,Ae=pe[Me],ce=pe[Me+1];ae.side===0?ce=0:ae.side===2?ce=Q:ae.side===3?Ae=0:Ae=X,ae.out?pe.push(Ae,ce,le):pe.unshift(Ae,ce,le),ae.px=Ae,ae.py=ce,ae.route=pe;return}let de=re.x,ye=re.y;if(re.isGroup&&k(ae.inner,t[ae.e],ae.out)){let pe=a.get(ae.inner).portOf.get(ae.e*2+(ae.out?0:1));de+=pe.px-re.w/2,ye+=pe.py-re.h/2}else ae.side===0?ye-=re.h/2:ae.side===2?ye+=re.h/2:ae.side===3?de-=re.w/2:de+=re.w/2;let oe=de,xe=ye;ae.side===0?xe=0:ae.side===2?xe=Q:ae.side===3?oe=0:oe=X;let fe=ae.side===0||ae.side===2?0:1;ae.px=oe,ae.py=xe,ae.route=ae.out?[de,ye,fe,oe,xe,fe]:[oe,xe,fe,de,ye,fe]}),E?(E.w=X,E.h=Q):Z={width:X,height:Q}}for(let $ of l){let y=$.x,E=$.y;for(let w of $.items){let T=e[w];if(T.x+=y,T.y+=E,T.isGroup){let _=a.get(w);_.x=T.x-T.w/2,_.y=T.y-T.h/2}}}let A=($,y,E,w)=>{for(let T=0;T<y.length;T+=3){let _=y[T]+E,M=y[T+1]+w,U=$.length;U>=3&&Math.abs($[U-3]-_)<.01&&Math.abs($[U-2]-M)<.01||$.push(_,M,y[T+2])}};for(let $ of l)for(let y of $.edges){let E=t[y.e],w=[],T=[];for(let M=E.src;e[M].parent!==$.id;M=e[M].parent)T.push(a.get(e[M].parent));for(let M of T)A(w,M.portOf.get(y.e*2).route,M.x,M.y);A(w,$.routes.get(y.e),$.x,$.y);let _=[];for(let M=E.dst;e[M].parent!==$.id;M=e[M].parent)_.push(a.get(e[M].parent));for(let M=_.length-1;M>=0;M--)A(w,_[M].portOf.get(y.e*2+1).route,_[M].x,_[M].y);E.route=w,E.labelW>0&&(E.labelX+=$.x,E.labelY+=$.y)}},W=a_(n);R=H,z();let S=-1;if(H&&(S=Xl(e,t,W),S>O*t_+r_)){let A=g0(e,t,l,Z);R=!1,z();let $=Xl(e,t,W);$>=S?(R=!0,Z=m0(A,e,t,l)):S=$}if(R===H&&C){let A=!1;for(let $ of l){if($.id<0)continue;let y=e[$.id],E=$.dir==="TB"||$.dir==="BT",w=is(Kl($.dir)),T=[];for(let _ of $.ports){if(_.side!==w)continue;let M=t[_.e].route,U=$.x+_.px,j=$.y+_.py,Y=-1;for(let F=0;F<M.length&&(Y<0||_.out);F+=3)Math.abs(M[F]-U)<.01&&Math.abs(M[F+1]-j)<.01&&(Y=F);if(Y<0)continue;let D=E?0:1,L=_.out?Y+3:Y-3;for(;L>=0&&L<M.length&&Math.abs(M[L+D]-M[Y+D])<oa;)L+=_.out?3:-3;L<0||L>=M.length||(_.hint=M[L+D]-(E?y.x-y.w/2:y.y-y.h/2),T.push([E?_.px:_.py,_.hint]))}T.sort((_,M)=>_[0]-M[0]);for(let _=1;_<T.length;_++)T[_-1][1]>T[_][1]&&(A=!0)}if(A){let $=S>=0?S:Xl(e,t,W),y=$>0?g0(e,t,l,Z):void 0;y&&(z(),Xl(e,t,W)>=$&&(Z=m0(y,e,t,l)))}}for(let A of v){let $=t[A],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 A of m){let $=t[A],y=e[$.src];$.labelX=y.x+y.w/2+28+$.labelW/2,$.labelY=y.y}return Z}function Ma(e,t){for(let r=0;r<t.length;r+=3){let n=Math.round(t[r+1]),i=e.get(n);i?i.push(t[r]):e.set(n,[t[r]])}}function Qc(e,t,r,n){if(t===0)return e.x;let i=e.y-e.h/2,a=e.x-e.w/2,l=t/2,s=[a+n-6+l,e.x,a+e.w-n+6-l],o=r.get(Math.round(i));if(o===void 0)return s[0];let c=s[0],h=-1;for(let u of s){let d=1/0;for(let p of o)p>a&&p<a+e.w&&(d=Math.min(d,Math.abs(p-u)-l));if(d>=6)return u;d>h+.5&&(h=d,c=u)}return c}function Zx(e,t,r,n){let i=t>0?n.get(Math.round(e.y-e.h/2)):void 0;if(i===void 0)return!1;let a=e.x-e.w/2;for(let l of i)if(l>a&&l<a+e.w&&Math.abs(l-r)<t/2+4)return!0;return!1}function Qx(e,t,r,n,i,a,l,s){let o=1;for(let h=a[l].parent;h>=0&&o<8;h=a[h].parent)o++;let c=`color-mix(in srgb,var(--_a) ${f(100*(1-.5**o))}%,var(--_bg))`;return`<g class="pele-cluster-title" data-id="${i}">`+Le(e,t,r,` fill="none" stroke="${c}" stroke-width="5" stroke-linejoin="round"`,s)+Le(e,t,r,n,s)+"</g>"}var Rt=8,s_=12,Zl=.62,Hs=6;function Jx(){let e=new Map;return{add(t,r,n){let i=Et(n);r>=0&&i>0&&i+Hs>(e.get(t*4+r)??0)&&e.set(t*4+r,i+Hs)},of:(t,r)=>r>=0?e.get(t*4+r)??0:0}}function jn(e,t,r,n,i=r>0?r+Hs:0,a=n>0?n+Hs:0){let l=t==="linear",s=t==="step"||t==="stepBefore"||t==="stepAfter",o=[],c=[],h=[],u=(y,E,w,T)=>Math.abs(y-w)<.01&&Math.abs(E-T)<.01;for(let y=0;y<e.length;y+=3){let E=e[y],w=e[y+1],T=e[y+2],_=o.length-1;if(s&&_>=0&&Math.abs(E-o[_])>=.01&&Math.abs(w-c[_])>=.01){let M=o[_],U=c[_],j=t==="stepBefore"?U:t==="stepAfter"?w:(U+w)/2,Y=t==="stepBefore"?M:t==="stepAfter"?E:(M+E)/2,D=T===0?[M,j,E,j]:[Y,U,Y,w];for(let L=0;L<4;L+=2)u(D[L],D[L+1],M,U)||u(D[L],D[L+1],E,w)||(o.push(D[L]),c.push(D[L+1]),h.push(T))}o.push(E),c.push(w),h.push(T)}let d=o.length-1,p=y=>Math.abs(o[y]-o[y-1])<.01||Math.abs(c[y]-c[y-1])<.01,g=y=>l||p(y),m=(y,E,w)=>{if(!g(Math.max(y,E)))return w===0?[0,Math.sign(c[E]-c[y])||1]:[Math.sign(o[E]-o[y])||1,0];let T=o[E]-o[y],_=c[E]-c[y],M=Math.hypot(T,_)||1;return[T/M,_/M]},[v,x]=m(0,1,h[1]),[k,b]=m(d-1,d,h[d]),C=o[0],N=c[0],R=o[d],O=c[d];o[0]+=v*r,c[0]+=x*r,o[d]-=k*n,c[d]-=b*n;let P=y=>Math.abs(o[y]-o[y-1])+Math.abs(c[y]-c[y-1]),H=y=>!l&&y>0&&y<d&&p(y)&&p(y+1)&&P(y)>=.01&&P(y+1)>=.01&&Math.abs(o[y]-o[y-1])<.01!=Math.abs(o[y+1]-o[y])<.01,I=(y,E,w)=>Math.abs(o[y]-o[y-1])*Math.abs(E)+Math.abs(c[y]-c[y-1])*Math.abs(w),G=(y,E,w)=>{let T=Math.min(Math.max(0,y-Hs-E),w/4);return T+Math.min(y-E-T,(w-T)/4)},Z=a>n&&(!g(d)||H(d-1))?G(a,n,I(d,k,b)):0,z=i>r&&(!g(1)||H(1))?G(i,r,I(1,v,x)):0;Z>=1&&(o.splice(d,0,o[d]-k*Z),c.splice(d,0,c[d]-b*Z),h.splice(d,0,h[d]),d++),z>=1&&(o.splice(1,0,o[0]+v*z),c.splice(1,0,c[0]+x*z),h.splice(1,0,h[1]),d++);let W=`M${f(o[0])},${f(c[0])}`,S=o[0],A=c[0],$=(y,E)=>{u(y,E,S,A)||(W+=`L${f(y)},${f(E)}`,S=y,A=E)};for(let y=1;y<=d;y++){let E=o[y],w=c[y];if(!g(y)){let D=h[y]===0,L=D?w-A:E-S,F=Math.abs(L)*Tc(D?E-S:w-A,L),V=D?0:Math.sign(L)*F,X=D?Math.sign(L)*F:0;W+=`C${f(S+V)},${f(A+X)} ${f(E-V)},${f(w-X)} ${f(E)},${f(w)}`,S=E,A=w;continue}if(!H(y)){if(y<d&&p(y)&&p(y+1)&&(E-o[y-1])*(o[y+1]-E)+(w-c[y-1])*(c[y+1]-w)>0)continue;$(E,w);continue}let T=H(y-1)?P(y)/2:P(y),_=H(y+1)?P(y+1)/2:P(y+1);s&&(T=_=Math.min(s_,T,_));let[M,U]=m(y-1,y,h[y]),[j,Y]=m(y,y+1,h[y+1]);$(E-M*T,w-U*T),S=E+j*_,A=w+Y*_,s?W+=`Q${f(E)},${f(w)} ${f(S)},${f(A)}`:W+=`C${f(E-M*T*(1-Zl))},${f(w-U*T*(1-Zl))} ${f(E+j*_*(1-Zl))},${f(w+Y*_*(1-Zl))} ${f(S)},${f(A)}`}return{d:W,sx:C,sy:N,sdx:-v,sdy:-x,ex:R,ey:O,edx:k,edy:b}}function Et(e){return e==="arrow_point"?Rt-1:e==="arrow_circle"?Rt:e==="arrow_cross"?4:0}function Ct(e,t,r,n,i,a){let l=-i,s=n;if(e==="arrow_point"){let o=t-n*Rt,c=r-i*Rt,h=Rt*.42;return`<path class="pele-marker" d="M${f(t)},${f(r)}L${f(o+l*h)},${f(c+s*h)}L${f(o-l*h)},${f(c-s*h)}Z" fill="${a}" stroke="none"/>`}if(e==="arrow_circle")return`<circle class="pele-marker" cx="${f(t-n*4)}" cy="${f(r-i*4)}" r="3.5" fill="${a}" stroke="none"/>`;if(e==="arrow_cross"){let o=t-n*4,c=r-i*4,h=3.5,u=(n+l)*h,d=(i+s)*h,p=(n-l)*h,g=(i-s)*h;return`<path class="pele-marker" d="M${f(o-u)},${f(c-d)}L${f(o+u)},${f(c+d)}M${f(o-p)},${f(c-g)}L${f(o+p)},${f(c+g)}"/>`}return""}function kn(e,t,r,n,i,a){let l=t.width+8,s=t.height;return`<g class="pele-edge-label" data-id="${Ge(e)}"><rect x="${f(r-l/2)}" y="${f(n-s/2)}" width="${f(l)}" height="${f(s)}" rx="3" fill="var(--_bg)"/>`+Le(t,r,n,i,a)+"</g>"}function eb(e,t,r,n,i,a,l,s){let o=(i?t:r)/2,c=Math.min(o-4,8+n*6),h=a+n*8,u=Math.hypot(h,c)||1,d=(m,v)=>i?`${f(e.x+v)},${f(e.y+r/2+m)}`:`${f(e.x+t/2+m)},${f(e.y+v)}`,p=h/u*l,g=c/u*l;return i?(s.labelX=e.x,s.labelY=e.y+r/2+h+4+s.labelH/2):(s.labelX=e.x+t/2+h+4+s.labelW/2,s.labelY=e.y),{d:`M${d(0,-c)}C${d(h,-c*2)} ${d(h,c*2)} ${d(p,c+g)}`,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/u:-h/u,edy:i?-h/u:-c/u}}var l_="--_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)",ep="var(--_fm)",o_="var(--pele-radius,4px)",xt=' style="rx:var(--_r)"';function _t(e){let t=e.indexOf(' style="');return t<0?e+xt:`${e.slice(0,t+8)}rx:var(--_r);${e.slice(t+8)}`}var pf="var(--pele-critical,#e45756)",x0=String.raw`(?:"[^"'\\\n<>{}();:@]*"|'[^"'\\\n<>{}();:@]*'|[\p{L}\p{N}_-][\p{L}\p{N}_ .-]*)`,c_=new RegExp(String.raw`^\s*${x0}(?:\s*,\s*${x0})*\s*$`,"u");function b0(e,t){return e&&c_.test(e)?e:t}function d_(e,t,r){return`;--_fm:var(--pele-font-mono,${b0(r,"monospace")});font:${e}px sans-serif;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;font-family:var(--pele-font,${b0(t,"sans-serif")})`}var h_=new Set(["fill","fill-opacity","stroke","stroke-width","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-opacity","opacity","rx","ry"]),u_=new Set(["color","font-size","font-family","font-weight","font-style","text-decoration","letter-spacing","word-spacing","opacity"]),f_=/url\s*\(|expression\s*\(|javascript:|[<>{};\\]|@import|image-set|\/\*/i,w0={shape:"",line:"",text:"",stroke:void 0,bold:!1,italic:!1,fontSize:void 0};function Ot(e){if(e.length===0)return w0;let t=new Map,r=new Map;for(let c of e){let h=c.indexOf(":");if(h<=0)continue;let u=c.slice(0,h).trim().toLowerCase(),d=c.slice(h+1).replace(/!important/gi,"").trim();d===""||f_.test(d)||(h_.has(u)&&t.set(u,d),u_.has(u)&&r.set(u==="color"?"fill":u,d))}if(t.size===0&&r.size===0)return w0;let n="",i="";for(let[c,h]of t)n+=`${c}:${h};`,c!=="fill"&&c!=="fill-opacity"&&(i+=`${c}:${h};`);let a="";for(let[c,h]of r)a+=`${c}:${h};`;let l=r.get("font-weight"),s=r.get("font-size"),o=s&&/^[\d.]+(px)?$/.test(s)?parseFloat(s):void 0;return{shape:n?` style="${tt(n)}"`:"",line:i?` style="${tt(i)}"`:"",text:a?` style="${tt(a)}"`:"",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}}var p_=/[^\w-]+/g;function jt(e){let t=e.replace(p_," ").trim();return t===""?"":" "+t}var g_=["#4c78a8","#f58518","#54a24b","#e45756","#72b7b2","#eeca3b","#b279a2","#9d755d"];function kt(e){let t=(e%8+8)%8;return`var(--pele-series-${t+1},${g_[t]})`}var m_=[["tw","title"],["hw","heading"],["w","bold"]],y_=/var\(--_(r|tw|hw|w)\)/g;function mt(e,t,r,n,i,a,l){let s=tt(i.idPrefix??"pele"),o="",c="";a.accTitle&&(o+=`<title id="${s}-title">${Ge(a.accTitle)}</title>`,c+=` aria-labelledby="${s}-title"`),a.accDescr&&(o+=`<desc id="${s}-desc">${Ge(a.accDescr)}</desc>`,c+=` aria-describedby="${s}-desc"`);let h=i.responsive===!1?"":"max-width:100%;height:auto;",u=new Set;for(let[,p]of l.matchAll(y_))if(u.add(p),u.size===4)break;let d=u.has("r")?`;--_r:${o_}`:"";for(let[p,g]of m_)u.has(p)&&(d+=`;--_${p}:var(--pele-${g}-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="${h}${l_}${d}${tt(d_(n,i.fontFamily,i.fontFamilyMono))}" fill="var(--_fg)" role="graphics-document document" aria-roledescription="${e}"${c}>`+o+l+"</svg>"}var ut=18,ft=12,pa=12,ur=(e,t,r)=>(r?t:e)-2*pa,as=e=>(t,r,n)=>n?0:t-2*e(r)-2*pa;function Sc(e,t,r){let n=Math.min(1,Math.abs(e)/t);return r*(1-Math.sqrt(1-n*n))}var ti=(e,t,r,n)=>r&1?Sc(n,t/2,e/2):Sc(n,e/2,t/2),ri=(e,t,r)=>(r?t:e)*.6,v0=(e,t,r,n)=>r&1?0:Sc(n,e/2,Math.min(12,Math.max(6,e/14))),ni=(e,t)=>()=>({w:e,h:t,dy:0});function $0(e,t,r){let n=Math.max(1.6*e+40,80),i=(t+10)/(1-(e+8)/n),a=i/2-10-t/2;return{w:n,h:i,dy:r?-a:a}}function Ui(e,t){return`<path d="${e}"${t}/>`}var Ql=(e,t,r)=>r&1?t/8:0,ss=(e,t)=>({w:Math.max(e+2*ut,2*ut+12),h:t+2*ft,dy:0});function tr(e,t){let r="";for(let n=0;n<e.length;n+=2)r+=(n?" ":"")+f(e[n])+","+f(e[n+1]);return`<polygon points="${r}"${t}/>`}function Zt(e,t,r,n=""){return`<rect x="${f(-e/2)}" y="${f(-t/2)}" width="${f(e)}" height="${f(t)}"${n}${r}/>`}var tb={rect:{size:ss,span:ur,draw:(e,t,r)=>Zt(e,t,_t(r))},rounded:{size:ss,span:ur,draw:(e,t,r)=>Zt(e,t,r,` rx="${f(Math.min(12,t/2))}"`)},stadium:{inset:(e,t,r,n)=>r&1?Sc(n,t/2,t/2):0,span:(e,t,r)=>r?t*.6:e-t,size:(e,t)=>{let r=t+2*ft;return{w:e+r*.5+2*ut-8,h:r,dy:0}},draw:(e,t,r)=>Zt(e,t,r,` rx="${f(t/2)}"`)},"fr-rect":{span:ur,size:(e,t)=>({w:e+2*ut+16,h:t+2*ft,dy:0}),draw:(e,t,r,n)=>{let i=e/2-8;return Zt(e,t,_t(r))+`<path d="M${f(-i)},${f(-t/2)}V${f(t/2)}M${f(i)},${f(-t/2)}V${f(t/2)}" fill="none"${n}/>`}},cyl:{inset:v0,span:(e,t,r)=>r?t-2*pa-12:e*.6,size:(e,t)=>{let r=Math.max(e+2*ut,56),n=Math.min(12,Math.max(6,r/14));return{w:r,h:t+2*ft+2*n,dy:n/2}},draw:(e,t,r,n)=>{let i=e/2,a=Math.min(12,Math.max(6,e/14)),l=-t/2+a,s=t/2-a;return`<path d="M${f(-i)},${f(l)}A${f(i)},${f(a)} 0 0 1 ${f(i)},${f(l)}V${f(s)}A${f(i)},${f(a)} 0 0 1 ${f(-i)},${f(s)}Z"${r}/><path d="M${f(-i)},${f(l)}A${f(i)},${f(a)} 0 0 0 ${f(i)},${f(l)}" fill="none"${n}/>`}},circle:{inset:ti,span:ri,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="${f(e/2)}"${r}/>`},"dbl-circ":{inset:ti,span:ri,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,n)=>`<circle r="${f(e/2)}"${r}/><circle r="${f(e/2-5)}" fill="none"${n}/>`},ellipse:{inset:ti,span:ri,size:(e,t)=>({w:e*1.3+2*ut,h:t*1.2+2*ft,dy:0}),draw:(e,t,r)=>`<ellipse rx="${f(e/2)}" ry="${f(t/2)}"${r}/>`},diam:{inset:(e,t,r,n)=>r&1?Math.abs(n)*e/t:Math.abs(n)*t/e,span:(e,t,r)=>(r?t:e)*.6,size:(e,t)=>{let r=e+16,n=t+8;return{w:r+1.6*n,h:r/1.6+n,dy:0}},draw:(e,t,r)=>tr([0,-t/2,e/2,0,0,t/2,-e/2,0],r)},hex:{inset:(e,t,r,n)=>r&1?Math.abs(n)/2:0,span:(e,t,r)=>r?t*.5:e-t/2-pa,size:(e,t)=>{let r=t+2*ft;return{w:e+2*ut+r/2,h:r,dy:0}},draw:(e,t,r)=>{let n=t/4;return tr([-e/2+n,-t/2,e/2-n,-t/2,e/2,0,e/2-n,t/2,-e/2+n,t/2,-e/2,0],r)}},odd:{inset:(e,t,r)=>r===3?t/4:0,span:as(()=>0),size:(e,t)=>{let r=t+2*ft;return{w:e+2*ut+r/4,h:r,dy:0}},draw:(e,t,r)=>{let n=t/4;return tr([-e/2,-t/2,e/2,-t/2,e/2,t/2,-e/2,t/2,-e/2+n,0],r)}},"lean-r":{inset:Ql,span:as(e=>e/4),size:(e,t)=>{let r=t+2*ft;return{w:e+2*ut+r/2,h:r,dy:0}},draw:(e,t,r)=>{let n=t/4;return tr([-e/2+n,-t/2,e/2,-t/2,e/2-n,t/2,-e/2,t/2],r)}},"lean-l":{inset:Ql,span:as(e=>e/4),size:(e,t)=>{let r=t+2*ft;return{w:e+2*ut+r/2,h:r,dy:0}},draw:(e,t,r)=>{let n=t/4;return tr([-e/2,-t/2,e/2-n,-t/2,e/2,t/2,-e/2+n,t/2],r)}},"trap-b":{inset:Ql,span:as(e=>e/4),size:(e,t)=>{let r=t+2*ft;return{w:e+2*ut+r/2,h:r,dy:0}},draw:(e,t,r)=>{let n=t/4;return tr([-e/2+n,-t/2,e/2-n,-t/2,e/2,t/2,-e/2,t/2],r)}},"trap-t":{inset:Ql,span:as(e=>e/4),size:(e,t)=>{let r=t+2*ft;return{w:e+2*ut+r/2,h:r,dy:0}},draw:(e,t,r)=>{let n=t/4;return tr([-e/2,-t/2,e/2,-t/2,e/2-n,t/2,-e/2+n,t/2],r)}},text:{span:ur,size:(e,t)=>({w:e+8,h:t+8,dy:0}),draw:(e,t)=>Zt(e,t,' fill="none" stroke="none"')},"sm-circ":{noLabel:!0,inset:ti,span:ri,size:ni(14,14),draw:(e,t,r)=>`<circle r="${f(e/2)}"${r}/>`},"f-circ":{noLabel:!0,inset:ti,span:ri,size:ni(14,14),draw:(e,t,r,n)=>`<circle r="${f(e/2)}" fill="var(--_l)"${n}/>`},"fr-circ":{noLabel:!0,inset:ti,span:ri,size:ni(18,18),draw:(e,t,r,n)=>`<circle r="${f(e/2)}"${r}/><circle r="${f(e/2-4)}" fill="var(--_l)"${n}/>`},fork:{noLabel:!0,span:(e,t,r)=>(r?t:e)-8,size:ni(72,8),draw:(e,t,r,n)=>Zt(e,t,` fill="var(--_l)"${n}`,' rx="2"')},"notch-rect":{size:ss,span:ur,draw:(e,t,r)=>tr([-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:ur,size:(e,t)=>({w:e+2*ut+8,h:t+2*ft,dy:0}),draw:(e,t,r,n)=>Zt(e,t,_t(r))+`<path d="M${f(-e/2+8)},${f(-t/2)}V${f(t/2)}" fill="none"${n}/>`},"div-rect":{span:ur,size:(e,t)=>({w:e+2*ut,h:t+2*ft+8,dy:4}),draw:(e,t,r,n)=>Zt(e,t,_t(r))+`<path d="M${f(-e/2)},${f(-t/2+8)}H${f(e/2)}" fill="none"${n}/>`},"win-pane":{span:ur,size:(e,t)=>({w:e+2*ut+8,h:t+2*ft+8,dy:4}),draw:(e,t,r,n)=>Zt(e,t,_t(r))+`<path d="M${f(-e/2+8)},${f(-t/2)}V${f(t/2)}M${f(-e/2)},${f(-t/2+8)}H${f(e/2)}" fill="none"${n}/>`},tri:{inset:(e,t,r)=>r&1?e/4:0,size:(e,t)=>$0(e,t,!1),draw:(e,t,r)=>tr([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)=>$0(e,t,!0),draw:(e,t,r)=>tr([-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*ut,h:t+2*ft+10,dy:5}),draw:(e,t,r)=>tr([-e/2,-t/2+10,e/2,-t/2,e/2,t/2,-e/2,t/2],r)},"notch-pent":{span:ur,size:(e,t)=>({w:e+2*ut,h:t+2*ft,dy:0}),draw:(e,t,r)=>tr([-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:ni(32,40),draw:(e,t,r)=>tr([-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*ft;return{w:e+2*ut+r/4,h:r,dy:0}},draw:(e,t,r)=>{let n=t/2;return`<path d="M${f(-e/2)},${f(-n)}H${f(e/2-n)}A${f(n)},${f(n)} 0 0 1 ${f(e/2-n)},${f(n)}H${f(-e/2)}Z"${r}/>`}},"h-cyl":{size:(e,t)=>{let r=t+2*ft,n=Math.min(12,r/4);return{w:e+2*ut+2*n,h:r,dy:0}},draw:(e,t,r,n)=>{let i=t/2,a=Math.min(12,t/4),l=-e/2+a,s=e/2-a;return`<path d="M${f(l)},${f(-i)}H${f(s)}A${f(a)},${f(i)} 0 0 1 ${f(s)},${f(i)}H${f(l)}A${f(a)},${f(i)} 0 0 1 ${f(l)},${f(-i)}Z"${r}/><path d="M${f(s)},${f(-i)}A${f(a)},${f(i)} 0 0 0 ${f(s)},${f(i)}" fill="none"${n}/>`}},"cross-circ":{noLabel:!0,inset:ti,span:ri,size:ni(44,44),draw:(e,t,r,n)=>{let i=e/2,a=i*Math.SQRT1_2;return`<circle r="${f(i)}"${r}/><path d="M${f(-a)},${f(-a)}L${f(a)},${f(a)}M${f(a)},${f(-a)}L${f(-a)},${f(a)}" fill="none"${n}/>`}},"st-rect":{span:(e,t,r)=>(r?t:e)-2*pa-8,size:(e,t)=>({w:e+2*ut+8,h:t+2*ft+8,dy:4}),draw:(e,t,r)=>{let n=e-8,i=t-8,a="";for(let l=0;l<3;l++){let s=-e/2+(2-l)*4,o=-t/2+l*4;a+=`<rect x="${f(s)}" y="${f(o)}" width="${f(n)}" height="${f(i)}"${_t(r)}/>`}return a}},doc:{inset:(e,t,r)=>r===2?10:0,size:(e,t)=>({w:e+2*ut,h:t+2*ft+10,dy:-5}),draw:(e,t,r)=>eo(e,t,r)},flag:{inset:(e,t,r)=>r&1?0:8,size:(e,t)=>({w:e+2*ut,h:t+2*ft+16,dy:0}),draw:(e,t,r)=>{let n=e/2,i=t/2-8,a=e/4;return`<path d="M${f(-n)},${f(-i)}q${f(a)},-10 ${f(2*a)},0t${f(2*a)},0V${f(i)}q${f(-a)},10 ${f(-2*a)},0t${f(-2*a)},0Z"${r}/>`}},datastore:{size:ss,span:ur,draw:(e,t,r,n)=>Zt(e,t,r.replace('stroke="var(--_b)"','stroke="none"'))+`<path d="M${f(-e/2)},${f(-t/2)}H${f(e/2)}M${f(-e/2)},${f(t/2)}H${f(e/2)}" fill="none"${n}/>`},folder:{size:(e,t)=>({w:Math.max(e+2*ut,64),h:t+2*ft+8,dy:4}),draw:(e,t,r)=>{let n=e/2,i=t/2,a=Math.min(e*.4,48);return Ui(`M${f(-n)},${f(-i)}H${f(-n+a)}L${f(-n+a+8)},${f(-i+8)}H${f(n)}V${f(i)}H${f(-n)}Z`,r)}},bucket:{size:(e,t)=>({w:e+2*ut+20,h:t+2*ft+10,dy:3}),inset:(e,t,r)=>r&1?t/12:0,draw:(e,t,r,n)=>{let i=e/2,a=t/2,l=5,s=t/6;return Ui(`M${f(-i)},${f(-a+l)}A${f(i)},${f(l)} 0 0 1 ${f(i)},${f(-a+l)}L${f(i-s)},${f(a-l)}A${f(i-s)},${f(l)} 0 0 1 ${f(-i+s)},${f(a-l)}Z`,r)+`<path d="M${f(-i)},${f(-a+l)}A${f(i)},${f(l)} 0 0 0 ${f(i)},${f(-a+l)}" fill="none"${n}/>`}},console:{span:ur,size:(e,t)=>({w:Math.max(e+2*ut,72),h:t+2*ft+12,dy:6}),draw:(e,t,r,n)=>Zt(e,t,_t(r))+`<path d="M${f(-e/2)},${f(-t/2+12)}H${f(e/2)}M${f(-e/2+7)},${f(-t/2+4)}l3,2.5l-3,2.5M${f(-e/2+13)},${f(-t/2+9)}h4" fill="none"${n}/>`},browser:{span:ur,size:(e,t)=>({w:Math.max(e+2*ut,72),h:t+2*ft+12,dy:6}),draw:(e,t,r,n)=>{let i="";for(let a=0;a<3;a++)i+=`<circle cx="${f(-e/2+8+a*7)}" cy="${f(-t/2+6)}" r="1.5" fill="none"${n}/>`;return Zt(e,t,_t(r))+`<path d="M${f(-e/2)},${f(-t/2+12)}H${f(e/2)}" fill="none"${n}/>`+i}},person:{size:(e,t)=>({w:Math.max(e+2*ut,56),h:t+2*ft+26,dy:13}),draw:(e,t,r)=>{let n=-t/2;return`<rect x="${f(-e/2)}" y="${f(n+26)}" width="${f(e)}" height="${f(t-26)}" rx="12"${r}/><circle cy="${f(n+14)}" r="13"${r}/>`}},bang:{size:(e,t)=>({w:e+2*ut+28,h:t+2*ft+24,dy:0}),inset:()=>3,draw:(e,t,r)=>{let n=[];for(let i=0;i<28;i++){let a=Math.PI*i/14-Math.PI/2,l=i%2===0?1:.82;n.push(Math.cos(a)*(e/2)*l,Math.sin(a)*(t/2)*l)}return tr(n,r)}},cloud:{size:(e,t)=>({w:e+2*ut+32,h:t+2*ft+24,dy:0}),inset:(e,t,r)=>r&1?2:1,draw:(e,t,r)=>{let n=e/2,i=t/2,a=i*.55;return Ui(`M${f(-n+a)},${f(i)}A${f(a)},${f(a)} 0 0 1 ${f(-n+a*.6)},${f(-i*.1)}A${f(n*.42)},${f(i*.7)} 0 0 1 ${f(-n*.1)},${f(-i*.72)}A${f(n*.4)},${f(i*.62)} 0 0 1 ${f(n*.62)},${f(-i*.42)}A${f(a*1.05)},${f(a*1.05)} 0 0 1 ${f(n-a)},${f(i)}Z`,r)}},brace:{size:(e,t)=>({w:e+2*ut+12,h:t+2*ft,dy:0}),draw:(e,t,r,n)=>Zt(e,t,' fill="none" stroke="none"')+Jl(-e/2+12,t,-1,n)},"brace-r":{size:(e,t)=>({w:e+2*ut+12,h:t+2*ft,dy:0}),draw:(e,t,r,n)=>Zt(e,t,' fill="none" stroke="none"')+Jl(e/2-12,t,1,n)},braces:{size:(e,t)=>({w:e+2*ut+24,h:t+2*ft,dy:0}),draw:(e,t,r,n)=>Zt(e,t,' fill="none" stroke="none"')+Jl(-e/2+12,t,-1,n)+Jl(e/2-12,t,1,n)},bolt:{noLabel:!0,size:ni(36,56),inset:(e,t,r)=>r&1?e/4:0,draw:(e,t,r)=>tr([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:v0,span:(e,t,r)=>r?t-2*pa-20:e*.6,size:(e,t)=>{let r=Math.max(e+2*ut,56),n=Math.min(12,Math.max(6,r/14));return{w:r,h:t+2*ft+2*n+8,dy:n/2+4}},draw:(e,t,r,n)=>{let i=e/2,a=Math.min(12,Math.max(6,e/14)),l=-t/2+a,s=t/2-a,o=c=>`M${f(-i)},${f(c)}A${f(i)},${f(a)} 0 0 0 ${f(i)},${f(c)}`;return Ui(`M${f(-i)},${f(l)}A${f(i)},${f(a)} 0 0 1 ${f(i)},${f(l)}V${f(s)}A${f(i)},${f(a)} 0 0 1 ${f(-i)},${f(s)}Z`,r)+`<path d="${o(l)}${o(l+8)}" fill="none"${n}/>`}},"curv-trap":{size:(e,t)=>{let r=t+2*ft;return{w:e+2*ut+r*.6,h:r,dy:0}},draw:(e,t,r)=>{let n=e/2,i=t/2,a=t*.3;return Ui(`M${f(-n+a)},${f(-i)}H${f(n-a)}A${f(a)},${f(i)} 0 0 1 ${f(n-a)},${f(i)}H${f(-n+a)}L${f(-n)},0Z`,r)}},docs:{size:(e,t)=>({w:e+2*ut+8,h:t+2*ft+18,dy:-1}),inset:(e,t,r)=>r===2?10:0,draw:(e,t,r)=>{let n="";for(let i=0;i<3;i++)n+=`<g transform="translate(${(1-i)*4},${(i-1)*4})">${eo(e-8,t-8,r)}</g>`;return n}},"bow-rect":{size:(e,t)=>{let r=t+2*ft;return{w:e+2*ut+r*.4,h:r,dy:0}},inset:(e,t,r)=>r===1?t*.2:0,draw:(e,t,r)=>{let n=e/2,i=t/2,a=t*.2;return Ui(`M${f(-n+a)},${f(-i)}H${f(n)}A${f(a)},${f(i)} 0 0 0 ${f(n)},${f(i)}H${f(-n+a)}A${f(a)},${f(i)} 0 0 1 ${f(-n+a)},${f(-i)}Z`,r)}},"tag-rect":{size:ss,span:ur,draw:(e,t,r,n)=>Zt(e,t,_t(r))+`<path d="M${f(e/2-12)},${f(t/2)}L${f(e/2)},${f(t/2-12)}" fill="none"${n}/>`},"tag-doc":{size:(e,t)=>({w:e+2*ut,h:t+2*ft+10,dy:-5}),inset:(e,t,r)=>r===2?10:0,draw:(e,t,r,n)=>eo(e,t,r)+`<path d="M${f(e/2-12)},${f(t/2-14)}L${f(e/2)},${f(t/2-26)}" fill="none"${n}/>`},"lin-doc":{size:(e,t)=>({w:e+2*ut+8,h:t+2*ft+10,dy:-5}),inset:(e,t,r)=>r===2?10:0,draw:(e,t,r,n)=>eo(e,t,r)+`<path d="M${f(-e/2+8)},${f(-t/2)}V${f(t/2-6)}" fill="none"${n}/>`},collapsedGroup:{size:(e,t)=>({w:e+2*ut+8,h:t+2*ft+8,dy:-2}),draw:(e,t,r)=>`<rect x="${f(-e/2+6)}" y="${f(-t/2+8)}" width="${f(e-12)}" height="${f(t-8)}"${_t(r)}/><rect x="${f(-e/2)}" y="${f(-t/2)}" width="${f(e)}" height="${f(t-4)}"${_t(r)}/>`}};function Jl(e,t,r,n){let i=t/2,a=6*r;return`<path d="M${f(e)},${f(-i)}q${f(a)},0 ${f(a)},6V-6q0,6 ${f(a)},6q${f(-a)},0 ${f(-a)},6V${f(i-6)}q0,6 ${f(-a)},6" fill="none"${n}/>`}function eo(e,t,r){let n=e/2,i=-t/2,a=t/2-10,l=e/4;return`<path d="M${f(-n)},${f(i)}H${f(n)}V${f(a)}q${f(-l)},-12 ${f(-2*l)},0t${f(-2*l)},0Z"${r}/>`}var rb=tb.rect,dl=new Map(Object.entries(tb));function Jc(e,t,r){return(dl.get(e)??rb).size(t,r)}function _a(e,t,r,n,i){return(dl.get(e)??rb).draw(t,r,n,i)}function $i(e,t,r,n,i=0){return dl.get(e)?.inset?.(t,r,n,i)??0}function x_(e,t,r,n){return Math.max(0,dl.get(e)?.span?.(t,r,n)??0)}function b_(e){return dl.get(e)?.noLabel!==!0}function wn(e,t,r){let n=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(n)-r.w/2)<.5?n<0?3:1:-1}function js(e,t,r,n){if(n.isGroup)return;let i=wn(e,t,n);if(i===0||i===2){let a=$i(r.shape,r.w,r.h,i,e[t]-n.x)+(n.h-r.h)/2;e[t+1]+=i===0?a:-a}else if(i>=0){let a=$i(r.shape,r.w,r.h,i,e[t+1]-n.y)+(n.w-r.w)/2;e[t]+=i===3?a:-a}}var w_=1.5,v_=/<br\s*\/?>|\\n|\n/gi,k0=/<\/?([a-zA-Z][\w-]*)(?:\s[^<>]*)?\/?>/y,M0=/(fa[bklrs]?):fa-([\w-]+)/g,$_=/[<\\\n*_]|fa[bklrs]?:fa-/,gf="\\u2e80-\\u9fff\\uf900-\\ufaff\\uff00-\\uff60",_0="、。,.:;!?)]}」』】〕〉》〙〗ー…‥・ゝゞぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮ,.:;!?)\\]}",k_="([{「『【〔〈《〘〖([{",M_=new RegExp(`[${gf}]`),__=new RegExp(`\\s*(?:[${k_}]*[${gf}][${_0}]*|[^\\s${gf}]+[${_0}]*)\\s*|\\s+`,"g"),nb=57344,E_=6400,A_=/\$\$(.+?)\$\$/g,ib=/[\ue000-\uf8ff]/,T_=/([\ue000-\uf8ff])/,Us,S_={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};function C_(e){let t=e.split(`
61
+ `),r=1/0;for(let n of t){if(n.trim()==="")continue;let i=n.length-n.trimStart().length;i<r&&(r=i)}return r===1/0||r===0?e:t.map(n=>n.slice(Math.min(r,n.length-n.trimStart().length))).join(`
62
+ `)}function Cc(e){return e!==void 0&&e.icon===void 0&&e.math===void 0}function gh(e,t,r){if(t!==""){if(Us!==void 0&&ib.test(t)){let n=Us,i=t.split(T_);for(let a=0;a<i.length;a++){if(a%2===0){i[a]!==""&&mh(e,i[a],r);continue}let l=i[a].charCodeAt(0)-nb,s=n.math[l];s?e.push({text:"",style:r,math:s,width:s.width}):mh(e,`$$${n.tex[l]}$$`,r)}return}mh(e,t,r)}}function mh(e,t,r){let n=It(t),i=e[e.length-1];Cc(i)&&i.style===r?i.text+=n:e.push({text:n,style:r,width:0})}function I_(e,t,r){if(!t.includes(":fa-")){gh(e,t,r);return}let n=0;M0.lastIndex=0;let i;for(;(i=M0.exec(t))!==null;){let a=`${i[1]}:fa-${i[2]}`;if(gh(e,t.slice(n,i.index),r),n=i.index+i[0].length,Xf(a)!=="")e.push({text:"",style:r,icon:a,width:0});else if(t[n]===" ")n++;else if(n===t.length){let l=e[e.length-1];Cc(l)&&(l.text=l.text.trimEnd())}}gh(e,t.slice(n),r)}function N_(e,t,r,n,i){let a=i,l=0,s="",o=0,c=t.length,h=()=>{I_(e,s,a),s=""};for(;o<c;){let u=t[o];if(u==="<"){k0.lastIndex=o;let d=k0.exec(t);if(d&&d.index===o){let p=d[1].toLowerCase(),g=t[o+1]==="/",m=p==="b"||p==="strong"?1:p==="i"||p==="em"?2:0;m&&(h(),i=g?i&~m|n&m:i|m,a=g?a&~m|n&m:a|m),o+=d[0].length;continue}}else if(r&&(u==="*"||u==="_")){let d=t[o+1]===u,p=d?1:2,g=d?2:1,m=(l&p)===0,v=o>0?t[o-1]:" ",x=o+g<c?t[o+g]:" ",k=m&&x.trim()!==""&&t.indexOf(d?u+u:u,o+g)!==-1,b=!m&&v.trim()!=="",C=u==="_"&&/\w/.test(v)&&/\w/.test(x);if((k||b)&&!C){h(),l=k?l|p:l&~p,a=k?a|p:a&~p|n&p,o+=g;continue}}s+=u,o++}return h(),i}function R_(e,t,r){let n=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),n+=i.width;return n}function ab(e,t,r,n,i,a){let l=[],s=0,o=()=>{let c=l[l.length-1];if(Cc(c)){let h=c.text.trimEnd();if(h!==c.text){c.text=h;let u=t.width(h,r,c.style);s+=u-c.width,c.width=u}}i.push(l),a.push(s),l=[],s=0};for(let c of e){if(c.icon!==void 0||c.math){let h=c.math?c.math.width:r*1.25;s>0&&s+h>n&&o(),l.push({...c,width:h}),s+=h;continue}for(let h of c.text.match(__)??[]){let u=h;s>0&&s+t.width(u.trimEnd(),r,c.style)>n&&(o(),u=u.trimStart());let d=l[l.length-1];if(Cc(d)&&d.style===c.style){d.text+=u,d.width=t.width(d.text,r,d.style),s=0;for(let p of l)s+=p.width}else{let p=t.width(u,r,c.style);l.push({text:u,style:c.style,width:p}),s+=p}}}(l.length>0||i.length===0)&&o()}function Ve(e,t,r,n,i,a=0){if(e===void 0||e==="")return S_;let l=Math.round(n*w_);if(E$()&&e.includes("$$")&&!ib.test(e)){let s={tex:[],math:[]},o=e.replace(A_,(c,h)=>s.tex.length===E_?c:(s.tex.push(h),String.fromCharCode(nb+s.tex.length-1)));if(s.tex.length>0){for(let c of s.tex)s.math.push(A$(It(c),n));return E0(o,t,r,n,i,a,l,s)}}if(!$_.test(e)&&!e.includes("&")&&!e.includes("fl")){let s=e.trim(),o=r.width(s,n,a);if(o<=i||!(s.includes(" ")||M_.test(s)))return{lines:[[{text:s,style:a,width:o}]],widths:[o],width:o,height:l,size:n,lineHeight:l};let c=[],h=[];ab([{text:s,style:a,width:o}],r,n,i,c,h);let u=0;for(let d of h)d>u&&(u=d);return{lines:c,widths:h,width:u,height:c.length*l,size:n,lineHeight:l}}return E0(e,t,r,n,i,a,l)}function E0(e,t,r,n,i,a,l,s){let o=Us;Us=s;try{let c=O_(e,t,r,n,i,a,l);return s?tp(c):c}finally{Us=o}}function O_(e,t,r,n,i,a,l){let s=t?C_(e.replace(/\r\n?/g,`
63
+ `)).trim():e.trim(),o=[],c=[],h=0,u=a;for(let d of s.split(v_)){let p=[];u=N_(p,d.trim(),t,a,u);let g=R_(p,r,n);g>i?ab(p,r,n,i,o,c):(o.push(p),c.push(g))}for(let d of c)d>h&&(h=d);return{lines:o,widths:c,width:h,height:o.length*l,size:n,lineHeight:l}}function tp(e){let t;for(let n=0;n<e.lines.length;n++){let i=e.lineHeight;for(let a of e.lines[n])a.math&&(i=Math.max(i,Math.ceil(a.math.height+e.size/4)));i!==e.lineHeight&&t===void 0&&(t=e.lines.map(()=>e.lineHeight)),t&&(t[n]=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 n of t)r+=n;return{...e,heights:t,height:r}}function rp(e){for(let t of e)if(t.math)return!0;return!1}function hl(e,t){let r=e.heights;if(!r)return(t+.5)*e.lineHeight;let n=0;for(let i=0;i<t;i++)n+=r[i];return n+r[t]/2}function ul(e,t){let r=e.widths[t],n=e.heights?e.heights[t]:e.lineHeight,i={lines:[e.lines[t]],widths:[r],width:r,height:n,size:e.size,lineHeight:e.lineHeight};return n!==e.lineHeight&&(i.heights=[n]),i}function ed(e,t,r,n){let i=n(t,!1),a=e.maxWidth;if(a===void 0||!(a>0)||i.width<=a)return i;let l=Math.min(r,t),s=t;i=n(s,!0);for(let o=0;o<3&&i.width>a&&s>l;o++)s=Math.max(l,s-(i.width-a)),i=n(s,!0);return i}function Xt(e){let t=e.maxWidth;return t!==void 0&&t>0?Math.max(80,t-2*(e.padding??8)):4e3}function td(e,t,r,n=0){let i=e.maxWidth;return i===void 0||!(i>0)?t:Math.max(Math.min(r,t),Math.min(t,i-n))}var L_=640;function dr(e,t){let r=t(!1),n=e.maxWidth;if(e.autoDirection===!1||n===void 0||!(n>0)||r.width<=n)return r;let i=e.directionBreakpoint;if(n>=(i!==void 0&&i>0?i:L_))return r;let a=t(!0);return a.width<r.width?a:r}function Ti(e){return e==="LR"||e==="RL"}function Yn(e,t){let r=t(!1),n=e.maxWidth;if(n===void 0||!(n>0)||r.width<=n)return r;let i=t(!0);return i.width<r.width?i:r}var ga=new Map([["tool",0],["task",1],["decision",2],["input",3],["refdoc",4],["connector",5],["action",6]]),sb=ga.size,D_=e=>Math.max(1,e-sb),P_=(e,t)=>{let r=sb+e%D_(t);return t>0?r%t:r};function z_(e,t,r,n){let i=r.size;for(let a of e){if(a.isGroup||a.shape==="collapsedGroup"){a.colorIndex=P_(r.get(a.id)??i++,n);continue}let l=t(a.id);l&&ga.has(l)&&(a.kind=l)}}function F_(e,t,r){let n=[],i=[],a=e.subgraphs,l=x=>{let k=[];for(let b of x){let C=e.classes.get(b);C?.styles&&(k=[...k,...C.styles].map(N=>N.trim())),C?.textStyles&&(k=[...k,...C.textStyles].map(N=>N.trim()))}return k},s=new Set,o=new Map,c=new Set;for(let x of a){if(x.metadata?.view!=="collapsed"||s.has(x.id))continue;let k=[x.id];for(;k.length>0;){let b=e.subgraph(k.pop())?.nodes;if(b!==void 0)for(let C of b)C===x.id||s.has(C)||(s.add(C),o.set(C,x.id),c.has(C)||k.push(C))}c.add(x.id)}let h=new Map;for(let x of s){let k=[x],b=o.get(x);for(;;){let C=h.get(b),N=C??o.get(b);if(N===void 0||(C===void 0&&k.push(b),b=N,C!==void 0))break}for(let C of k)h.set(C,b)}let u=new Map;a.forEach((x,k)=>u.set(x.id,k));let d=new Map,p=(x,k,b)=>{let C=u.get(x);if(C===void 0||C<b)return!1;let N=k;for(let R=0;N!==void 0&&R<=a.length;R++){if(N===x)return!0;N=d.get(N)}return!1};for(let x=a.length-1;x>=0;x--){let k=a[x];if(!s.has(k.id))for(let b of k.nodes){if(p(b,k.id,x)){e.emitWarning("CONTAINMENT_VIOLATION",`Container "${k.id}" cannot contain "${b}" because "${b}" already contains it. The nesting that would close the loop is dropped.`,{nodeId:b});continue}d.set(b,k.id)}}let g=new Map;for(let x=a.length-1;x>=0;x--){let k=a[x];if(s.has(k.id))continue;let b=k.metadata?.view==="collapsed",C={id:k.id,label:k.title,labelType:k.labelType,parentId:d.get(k.id),cssStyles:[],cssCompiledStyles:l(k.classes),cssClasses:k.classes.join(" "),shape:b?"collapsedGroup":"flowGroup",dir:k.dir,isGroup:!b,metadata:b?{...k.metadata,containerType:k.type}:k.metadata};n.push(C),g.set(k.id,C)}for(let x of e.nodes.values()){if(s.has(x.id))continue;let k=g.get(x.id);if(k){k.cssStyles=x.styles,k.cssCompiledStyles=l(x.classes),k.cssClasses=x.classes.join(" ");continue}let b=sc(x.type),C={id:x.id,label:x.text,labelType:x.labelType,parentId:d.get(x.id),cssStyles:x.styles,cssCompiledStyles:l(["default","node",...x.classes]),cssClasses:"default "+x.classes.join(" "),dir:x.dir,link:x.link,linkTarget:x.linkTarget,tooltip:e.tooltips.get(x.id),metadata:x.metadata,isGroup:!1,shape:b==="square"||b===void 0?"squareRect":b};n.push(C),g.set(x.id,C)}e.edges.forEach((x,k)=>{let b=h.get(x.start)??x.start,C=h.get(x.end)??x.end;if(b===C&&x.start!==x.end)return;let N=[...e.defaultEdgeStyle??[]];x.style&&N.push(...x.style);let R=x.type==="arrow_open"?"none":x.type==="arrow_cross"||x.type==="arrow_point"?x.type:"arrow_point";i.push({id:x.id||`L_${b}_${C}_${k}`,isUserDefinedId:x.isUserDefinedId,start:b,end:C,type:x.type??"normal",label:x.text,labelType:x.labelType,thickness:x.stroke,pattern:x.stroke,minlen:x.length,classes:"edge-thickness-normal edge-pattern-solid flowchart-link",arrowTypeStart:"none",arrowTypeEnd:R,cssCompiledStyles:l(x.classes),style:N,animate:x.animate,animation:x.animation,curve:x.interpolate||e.defaultInterpolate||r,metadata:x.metadata})}),eM(n,e);let m=new Map;for(let x of a){let k=d.get(x.id);if(k===void 0)continue;let b=m.get(k);b?b.push(x.id):m.set(k,[x.id])}let v=new Map;for(let x of a){if(d.get(x.id)!==void 0)continue;let k=[x.id];for(;k.length>0;){let b=k.pop();if(v.has(b))continue;v.set(b,v.size);let C=m.get(b);if(C)for(let N=C.length-1;N>=0;N--)k.push(C[N])}}return z_(n,x=>{if(e.connectors.has(x))return"connector";let k=e.nodes.get(x);return k?e.vertexKind(k):void 0},v,t),{nodes:n,edges:i}}var W_=8,B_=40,H_=16,j_=48,ls=20,yh=26,to=14,A0="collapsed",U_={TB:2,RL:3,BT:0,LR:1},T0=new WeakMap;function lb(e,t){let r=T0.get(e);if(r===void 0){let n=t.flowchart?.curve;r=F_(e,W_,typeof n=="string"?n:void 0),T0.set(e,r)}return r}function ro(e,t,r){let n=e.agentflow?.[t];return typeof n=="number"&&n>0?Math.min(n,2e3):r}var Y_=/[";]fill:/;function xh(e,t,r){let n=kt(e);return` fill="${n}"${Y_.test(r.shape)?"":` fill-opacity="${t}"`} stroke="${n}"`}function G_(e,t,r){return Ti(e.direction)?dr(r,n=>S0(e,t,r,n)):S0(e,t,r,!1)}function S0(e,t,r,n){let i=lb(e,t),a=r.fontSize??16,l=Math.round(a*.875),s=r.measurer??bt(r.fontFamily),o=ro(t,"wrappingWidth",120),c=ro(t,"minNodeWidth",120),h=r.padding??8,u=r.icons,d=new Map,p=[],g=[];i.nodes.forEach((F,V)=>d.set(F.id,V));for(let F of i.nodes){let V=F.cssStyles.length>0?F.cssCompiledStyles.concat(F.cssStyles):F.cssCompiledStyles,X=Ot(V),Q=(X.bold?1:0)|(X.italic?2:0),ne=F.labelType==="markdown",B=X.fontSize??a,K,ie;if(F.isGroup){let le=Ve(F.label,ne,s,B,4e3,Q);K={node:F,style:X,label:le,shape:"group",w:0,h:0,dy:0,loops:0},ie=Bt(0,0),ie.isGroup=!0,ie.dir=F.dir?Pr(F.dir):void 0,ie.padX=ls,ie.padTop=le.height>0?le.height+16:ls,ie.padBottom=ls,ie.minW=le.width+2*ls-12}else if(F.shape==="collapsedGroup"){let le=Ve(F.label,ne,s,B,o,Q),J=Math.max(le.width,c)+2*ut,te=le.height+2*ft+to;K={node:F,style:X,label:le,shape:A0,w:J,h:te,dy:-to/2,loops:0},ie=Bt(J,te)}else{let le=Vx(F.shape),J=Ve(F.label,ne,s,B,o,Q),te=Jc(le,le==="diam"?J.width:Math.max(J.width,c),J.height);K={node:F,style:X,label:J,shape:le,w:te.w,h:te.h,dy:te.dy,loops:0},ie=Bt(te.w,te.h)}ie.seq=p.length,p.push(K),g.push(ie)}i.nodes.forEach((F,V)=>{g[V].parent=F.parentId!==void 0?d.get(F.parentId)??-1:-1});let m=n?"TB":Pr(e.direction),v=F=>{let V;for(let X=g[F].parent,Q=0;X>=0&&V===void 0&&Q<1e4;X=g[X].parent,Q++)V=g[X].dir;return V??m},x=F=>{let V=v(F);return V==="LR"||V==="RL"},k=new Int32Array(g.length).fill(-1);for(let F=0;F<g.length;F++){let V=[],X=F;for(;X>=0&&k[X]<0&&V.length<=g.length;)V.push(X),X=g[X].parent;let Q=X>=0?k[X]+1:0;for(let ne=V.length-1;ne>=0;ne--)k[V[ne]]=Q++}let b=(F,V)=>{let X=V;for(let Q=k[V];Q>k[F];Q--)X=g[X].parent;return X===F&&V!==F},C=[],N=[],R=[],O=[];for(let F of i.edges){let V=d.get(F.start),X=d.get(F.end);if(V===void 0||X===void 0)continue;let Q=Ve(F.label,F.labelType==="markdown",s,l,o);if(b(V,X)||b(X,V)){O.push({edge:F,label:Q,src:V,dst:X});continue}V===X&&(p[V].loops++,x(V)?g[V].h+=2*(yh+(Q.height>0?Q.height+8:0)):g[V].w+=2*(yh+(Q.width>0?Q.width+12:0))),R.push(F),N.push(Q),C.push({src:V,dst:X,minlen:F.minlen??1,labelW:Q.width>0?Q.width+12:0,labelH:Q.height>0?Q.height+4:0,route:[],labelX:0,labelY:0})}let P=Ai(g,C,m,{nodeSep:ro(t,"nodeSpacing",B_),edgeSep:H_,rankSep:ro(t,"rankSpacing",j_),portSep:20}),H=Ve(e.title,!1,s,a,4e3,1),I=H.height>0?H.height+12:0,G=Math.max(P.width,H.width),Z=h+(G-P.width)/2,z=h+I;Zc(g,C,Z,z);let W=Math.ceil(G+2*h),S=Math.ceil(P.height+I+2*h),A=[],$=[],y=[],E=[],w=O.length*g.length<2e6;for(let{edge:F,src:V,dst:X}of O){let Q=b(X,V),ne=Q?X:V,B=Q?V:X,K=g[ne],ie=g[B],le=U_[K.dir??v(ne)],J=Q?le:le+2&3,te=de=>{let ye=(de&1)===0,oe=de===0||de===3?-1:1,xe=ye?ie.x:ie.x+oe*ie.w/2,fe=ye?ie.y+oe*ie.h/2:ie.y,pe=ye?ie.x:K.x+oe*K.w/2,Me=ye?K.y+oe*K.h/2:ie.y,Ae=ye?0:1;return Q?[xe,fe,Ae,pe,Me,Ae]:[pe,Me,Ae,xe,fe,Ae]},ae=de=>{for(let ye=0;ye<g.length;ye++){let oe=g[ye];if(ye!==B&&!oe.isGroup&&oe.x+oe.w/2>Math.min(de[0],de[3])-1&&oe.x-oe.w/2<Math.max(de[0],de[3])+1&&oe.y+oe.h/2>Math.min(de[1],de[4])-1&&oe.y-oe.h/2<Math.max(de[1],de[4])+1)return!0}return!1},ee=te(J);if(w&&ae(ee))for(let de of[J+1&3,J+3&3,J+2&3]){let ye=te(de);if(!ae(ye)){ee=ye;break}}E.push(ee),y.push((ee[0]+ee[3])/2,(ee[1]+ee[4])/2);let re=ee.slice();js(re,Q?0:3,p[B],ie),$.push(jn(re,"linear",0,Et(F.arrowTypeEnd)))}let T=new Map,_=!1;for(let F of g)F.isGroup&&(_=!0);if(_){for(let F of C)Ma(T,F.route);for(let F of E)Ma(T,F)}let M="",U="";for(let F=0;F<p.length;F++){let V=p[F],X=g[F],Q=V.node,ne=X.x,B=X.y,K=jt(Q.cssClasses.replace(/^default\s?/,"")),ie=Ge(Q.id);if(X.isGroup){let de=Qc(X,V.label.width,T,ls);M+=`<g class="pele-cluster pele-flow${K}" data-id="${ie}"><rect x="${f(ne-X.w/2)}" y="${f(B-X.h/2)}" width="${f(X.w)}" height="${f(X.h)}"${_t(xh(Q.colorIndex??ga.size,"0.06",V.style)+V.style.shape)}/>`+Le(V.label,de,B-X.h/2+8+V.label.height/2,` class="pele-cluster-label" fill="var(--_m)"${V.style.text}`,u)+"</g>";continue}let le=V.w,J=V.h,te="",ae;if(V.shape===A0){let de=kt(Q.colorIndex??ga.size),ye=J/2-to-2,oe=ye+(to+2)/2;ae=`<rect x="${f(-le/2)}" y="${f(-J/2)}" width="${f(le)}" height="${f(J)}"${_t(xh(Q.colorIndex??ga.size,"0.06",V.style)+V.style.shape)}/><path d="M${f(-le/2+10)},${f(ye)}H${f(le/2-10)}" fill="none" stroke="${de}" stroke-dasharray="3 3"${V.style.line}/><path class="pele-collapsed-mark" d="${bh(-9,oe)}${bh(0,oe)}${bh(9,oe)}" fill="${de}" stroke="none"/>`}else{let de=ga.get(Q.kind??"task")??1;te=` pele-kind-${Q.kind??"task"}`,ae=_a(V.shape,le,J,xh(de,"0.14",V.style)+V.style.shape,` stroke="${kt(de)}"`+V.style.line)}let ee=Le(V.label,0,V.dy,` class="pele-label"${V.style.text}`,u);if(/ internal-link(?: |$)/.test(K+" ")&&Q.label&&r.links!==!1){let de=It(Q.label),ye=ol(Ca(de),r)!==void 0,oe=tt(de);ee=`<a class="internal-link"${ye?` href="${oe}"${cl(r)}`:""} data-href="${oe}">${ee}</a>`,A.push({id:Q.id,href:de,internal:!0})}let re=ae+ee;Q.tooltip&&(re=`<title>${Ge(Q.tooltip)}</title>`+re),Q.link&&(re=Na(re,Q.link,Q.id,A,r,Q.linkTarget?` target="${tt(Q.linkTarget)}"`:"")),U+=`<g class="pele-node pele-shape-${V.shape}${te}${K}" data-id="${ie}" transform="translate(${f(ne)},${f(B)})">${re}</g>`}let j="",Y="",D=(F,V,X,Q,ne)=>{let B=F.style.length>0||F.cssCompiledStyles.length>0?Ot(F.cssCompiledStyles.concat(F.style)):void 0,K=F.arrowTypeEnd,ie=B?.stroke?tt(B.stroke):"var(--_l)",le=F.thickness==="dotted"?"reference":K==="arrow_cross"?"failure":"sequence",J=jt(F.classes.replace(/edge-thickness-normal|edge-pattern-solid|flowchart-link/g,""));j+=`<g class="pele-edge pele-edge-${le}${J}" data-id="${Ge(F.id)}"${B?.line??""}><path d="${X.d}"${F.thickness==="dotted"?' stroke-dasharray="3 4"':""}/>`+Ct(K,X.ex,X.ey,X.edx,X.edy,ie)+"</g>",V.width>0&&(Y+=kn(F.id,V,Q,ne,B?.text??"",u))},L=new Map;for(let F=0;F<C.length;F++){let V=C[F],X=R[F],Q=N[F],ne=X.arrowTypeEnd,B;if(V.src===V.dst){let K=p[V.src],ie=L.get(V.src)??0;L.set(V.src,ie+1),B=eb(g[V.src],K.w,K.h,ie,x(V.src),yh,Et(ne),V)}else{let K=V.route.slice();js(K,0,p[V.src],g[V.src]),js(K,K.length-3,p[V.dst],g[V.dst]),B=jn(K,X.curve,0,Et(ne))}D(X,Q,B,V.labelX,V.labelY)}return O.forEach((F,V)=>D(F.edge,F.label,$[V],y[2*V],y[2*V+1])),{svg:mt("agentflow",W,S,a,r,e,Le(H,W/2,h+H.height/2,' class="pele-title" font-weight="var(--_tw)"')+(M?`<g class="pele-clusters">${M}</g>`:"")+(j?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${j}</g>`:"")+(Y?`<g class="pele-edge-labels" font-size="${l}">${Y}</g>`:"")+`<g class="pele-nodes">${U}</g>`),width:W,height:S,links:A}}function bh(e,t){return`M${f(e-1.75)},${f(t)}a1.75,1.75 0 1 0 3.5,0a1.75,1.75 0 1 0 -3.5,0Z`}var V_={type:"agentflow",keepComments:!0,parse(e,t,r,n,i){let a=t.flowchart??{},l=new dM({inheritDir:a.inheritDir===!0,direction:typeof t.direction=="string"?t.direction:void 0,lineOffset:n,maxEdges:i.maxEdges});return r&&(l.title=r),TM(e,l),lb(l,t),l},render:G_};function Ur(e){throw new Je(e,"semantic",{type:"architecture"})}var q_=class{type="architecture";title;accTitle;accDescr;nodes=new Map;groups=new Map;edges=[];layoutHints=[];registered=new Map;register(e,t,r){this.registered.has(t)&&Ur(`The ${e} id [${t}] is already in use by another ${this.registered.get(t)}`),r!==void 0&&(t===r&&Ur(`The ${e} [${t}] cannot be placed within itself`),this.registered.has(r)||Ur(`The ${e} [${t}]'s parent does not exist. Please make sure the parent is created before this ${e}`),this.registered.get(r)==="node"&&Ur(`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:n,in:i}){this.register("service",e,i),this.nodes.set(e,{id:e,type:"service",icon:t,iconText:r,title:n,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:n}){this.register("group",e,n),this.groups.set(e,{id:e,icon:t,title:r,in:n})}addEdge({lhsId:e,rhsId:t,lhsDir:r,rhsDir:n,lhsInto:i,rhsInto:a,lhsGroup:l,rhsGroup:s,title:o}){let c=[["left",e,l],["right",t,s]];for(let[u,d]of c)this.registered.has(d)||Ur(`The ${u}-hand id [${d}] does not yet exist. Please create the service/group before declaring an edge to it.`);for(let[u,d]of c)this.nodes.has(d)||Ur(`The ${u}-hand id [${d}] is a group. Add {group} to a service inside it instead.`);let h=this.nodes.get(e).in;if(h!==void 0&&h===this.nodes.get(t).in)for(let[u,d,p]of c)p&&Ur(`The ${u}-hand id [${d}] 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:n,rhsInto:a,rhsGroup:s,title:o})}addLayoutHint(e){e.members.length<2&&Ur(`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"&&Ur(`align ${e.direction} references [${r}], which is not a service or junction`),t.has(r)&&Ur(`align ${e.direction} lists [${r}] more than once`),t.add(r);this.layoutHints.push(e)}};function X_(e,t){e.accDescr&&(t.accDescr=e.accDescr.replace(/\n\s+/g,`
64
+ `)),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]})}var ob=new WeakMap;function K_(e){let t=e.map((i,a)=>a),r=[];for(let i=0;i<128;i++){let a=String.fromCharCode(i);r.push(t.filter(l=>{let{pattern:s,first:o}=e[l];return typeof s=="string"?s[0]===a:o===void 0||o.includes(a)}))}let n={starting:r,every:t,longer:e.map(i=>i.longer?.map(a=>e.indexOf(a)))};return ob.set(e,n),n}function $r(e,t,r){let n=[],i=[],a=[],l=new Uint8Array(t.length),{starting:s,every:o,longer:c}=ob.get(t)??K_(t),h=[],u=e.length,d=(g,m)=>{if(l[g])return-1;let v=t[g];if(v.match!==void 0)return v.match(e,m);if(v.scanner!==void 0)return(h[g]??=v.scanner())(e,m);let x=v.pattern;return typeof x=="string"?e.startsWith(x,m)?m+x.length:-1:(x.lastIndex=m,x.test(e)?x.lastIndex:(v.opener!==void 0&&(v.opener.lastIndex=m,v.opener.test(e)&&(l[g]=1)),-1))},p=0;e:for(;p<u;){let g=e.charCodeAt(p);for(let m of g<128?s[g]:o){let v=d(m,p);if(v<=p)continue;let x=m,k=c[m];if(k!==void 0)for(let b of k){let C=d(b,p);if(C>v){x=b,v=C;break}}t[x].hidden||(n.push(x),i.push(p),a.push(v)),p=v;continue e}throw vt(r,e,p,"",!0)}return n.push(-1),i.push(u),a.push(u),{kinds:n,starts:i,ends:a,src:e}}var nn={name:"ACC_DESCR",pattern:/[\t ]*accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\s*{([^}]*)})/y,first:" a"},Wr={name:"ACC_TITLE",pattern:/[\t ]*accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/y,first:" a"},Br={name:"TITLE",pattern:/[\t ]*title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|)/y,first:" t"},Si={name:"STRING",pattern:/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'/y,first:`"'`},Gn={name:"NEWLINE",pattern:/\r?\n/y,first:`\r
65
+ `},Vn={name:"WHITESPACE",pattern:/[\t ]+/y,hidden:!0,first:" "},cr={name:"YAML",pattern:/---[\t ]*\r?\n(?:[\S\s]*?\r?\n)?---(?:\r?\n|(?!\S))/y,hidden:!0,opener:/---[\t ]*\r?\n/y,first:"-"},an={name:"DIRECTIVE",pattern:/[\t ]*%%{[\S\s]*?}%%(?:\r?\n|(?!\S))/y,hidden:!0,opener:/[\t ]*%%{/y,first:" %"},sn={name:"SINGLE_LINE_COMMENT",pattern:/[\t ]*%%[^\n\r]*/y,first:" %",hidden:!0};function zr(e){return{name:e,pattern:new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"(?:(?=%%)|(?!\\S))","y"),first:e[0]}}var Z_=/accDescr(?:[\t ]*:([^\n\r]*)|\s*{([^}]*)})/,Q_=/accTitle[\t ]*:([^\n\r]*)/,J_=/title([\t ][^\n\r]*|)/;function np(e){return e.trim().replace(/[\t ]{2,}/gm," ")}function kr(e){return np(J_.exec(e)[1])}function Mr(e){return np(Q_.exec(e)[1])}function _r(e){let t=Z_.exec(e);return t[1]!==void 0?np(t[1]):t[2].replace(/^\s*/gm,"").replace(/\s+$/gm,"").replace(/[\t ]{2,}/gm," ").replace(/[\n\r]{2,}/gm,`
66
+ `)}var eE=new Map([["b","\b"],["f","\f"],["n",`
67
+ `],["r","\r"],["t"," "],["v","\v"],["0","\0"]]);function Dr(e){if(!e.includes("\\"))return e.slice(1,-1);let t="";for(let r=1;r<e.length-1;r++){let n=e[r];if(n==="\\"){let i=e[++r];t+=eE.get(i)??i}else t+=n}return t}var Er=class{constructor(e,t,r){this.tokens=e,this.types=t,this.diagram=r,this.kinds=e.kinds}tokens;types;diagram;i=0;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 vt(this.diagram,this.tokens.src,this.tokens.starts[this.i],`Expecting ${e} but found ${t}.`)}},cb={name:"ID",pattern:/[\w]([-\w]*\w)?/y};function Cn(e){return{name:e,pattern:e,longer:[cb]}}var C0=[Cn("architecture-beta"),Cn("junction"),Cn("service"),Cn("column"),Cn("group"),Cn("align"),Cn("row"),{name:"--",pattern:"--",longer:[cr]},Cn("in"),{name:":",pattern:":"},{name:"-",pattern:"-",longer:[cr]},{name:"ARROW_DIRECTION",pattern:/L|R|T|B/y},{name:"ARROW_GROUP",pattern:/\{group\}/y},{name:"ARROW_INTO",pattern:/<|>/y},nn,Wr,Br,Si,cb,Gn,Vn,cr,an,sn,{name:"ARCH_ICON",pattern:/\([\w-:]+\)/y},{name:"ARCH_TITLE",pattern:/\[(?:"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|[^\[\]\r\n]+)\]/y}];function wh(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 tE(e){let t=new Er($r(e,C0,"architecture"),C0,"architecture"),r={$type:"Architecture",groups:[],services:[],junctions:[],edges:[],alignments:[]},n=a=>t.kinds[t.i]===a,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=_r(t.take());break;case 15:r.accTitle=Mr(t.take());break;case 16:r.title=kr(t.take());break;case 4:{t.i++;let a={$type:"Group",id:t.expect(18)};n(24)&&(a.icon=t.take().slice(1,-1)),n(25)&&(a.title=wh(t.take())),t.accept(8)&&(a.in=t.expect(18)),r.groups.push(a);break}case 2:{t.i++;let a={$type:"Service",id:t.expect(18)};n(17)?a.iconText=Dr(t.take()):n(24)&&(a.icon=t.take().slice(1,-1)),n(25)&&(a.title=wh(t.take())),t.accept(8)&&(a.in=t.expect(18)),r.services.push(a);break}case 1:{t.i++;let a={$type:"Junction",id:t.expect(18)};t.accept(8)&&(a.in=t.expect(18)),r.junctions.push(a);break}case 18:{let a=t.take(),l=t.accept(12);t.expect(9);let s=t.expect(11),o=t.accept(13),c;t.accept(7)||(n(10)||t.fail("'--' or '-'"),t.i++,c=wh(t.expect(25)),t.expect(10));let h=t.accept(13),u=t.expect(11);t.expect(9);let d=t.expect(18),p=t.accept(12);r.edges.push({$type:"Edge",lhsId:a,lhsGroup:l,lhsDir:s,lhsInto:o,title:c,rhsInto:h,rhsDir:u,rhsId:d,rhsGroup:p});break}case 5:{t.i++,!n(6)&&!n(3)&&t.fail("'row' or 'column'");let a=t.take(),l=[t.expect(18),t.expect(18)];for(;n(18);)l.push(t.take());r.alignments.push({$type:"Alignment",direction:a,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}var rE=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"]]);function nE(e){let t=rE.get(e);return t===void 0?"":`<path d="${t}" stroke="var(--_fg)" stroke-width="1.5"/>`}var os=[-1,1,0,0],no=[0,0,-1,1];function Ic(e){return e==="L"?0:e==="R"?1:e==="T"?2:3}var I0=64,io=2**25,N0=2**26;function iE(e,t,r,n){let i=e.length,a=t.length,l=a,s=new Map,o=new Map,c=new Int32Array(i+a).fill(l),h=new Int32Array(a+1),u=[];for(let X=0;X<=a;X++)u.push([]);t.forEach((X,Q)=>{o.set(X.id,Q);let ne=X.in===void 0?void 0:o.get(X.in);ne!==void 0&&ne!==Q?(c[i+Q]=ne,h[Q]=h[ne]+1):h[Q]=1}),e.forEach((X,Q)=>{s.set(X.id,Q);let ne=X.in===void 0?void 0:o.get(X.in);ne!==void 0&&(c[Q]=ne),u[c[Q]].push(Q)});for(let X=0;X<a;X++)u[c[i+X]].push(i+X);let d=[],p=[],g=[],m=[],v=[],x=[],k=new Array(i+a),b=new Array(i+a),C=(X,Q,ne,B,K)=>{if(X===Q)return;let ie=X,le=Q,J=c[X],te=c[Q];for(;J!==te;)h[J]>=h[te]?(ie=i+J,J=c[ie]):(le=i+te,te=c[le]);let ae=d.length;d.push(X),p.push(Q),g.push(ne),m.push(B),v.push(ie),x.push(le),(K[ie]??=[]).push(ae),(K[le]??=[]).push(ae)};for(let X of n){let Q=X.direction==="row";for(let ne=1;ne<X.members.length;ne++){let B=s.get(X.members[ne-1]),K=s.get(X.members[ne]);B!==void 0&&K!==void 0&&C(B,K,Q?1:3,Q?0:2,k)}}for(let X of[!1,!0])for(let Q of r){if(Q.lhsDir===Q.rhsDir!==X)continue;let ne=s.get(Q.lhsId),B=s.get(Q.rhsId);ne!==void 0&&B!==void 0&&C(ne,B,Ic(Q.lhsDir),Ic(Q.rhsDir),b)}let N=new Int32Array(i+a),R=new Int32Array(i+a),O=new Int32Array(i+a).fill(1),P=new Int32Array(i+a).fill(1),H=new Uint8Array(i+a),I=[],G=new Map,Z=[],z=new Map,W=0,S=0,A=0,$=(X,Q)=>{S=0,A=0;for(let ne=X;ne!==Q;ne=i+c[ne])S+=N[ne],A+=R[ne]},y=(X,Q,ne)=>{if(N[X]=Q,R[X]=ne,H[X]=1,I.push(X),O[X]*P[X]>I0){Z.push(X);return}for(let B=ne;B<ne+P[X];B++)for(let K=Q;K<Q+O[X];K++)G.set((K+io)*N0+B+io,X)},E=(X,Q,ne,B,K)=>N[X]<Q+B&&Q<N[X]+O[X]&&R[X]<ne+K&&ne<R[X]+P[X],w=(X,Q,ne,B)=>{if(ne*B>I0){for(let K=W;K<I.length;K++)if(E(I[K],X,Q,ne,B))return I[K];return-1}for(let K=Q;K<Q+B;K++)for(let ie=X;ie<X+ne;ie++){let le=G.get((ie+io)*N0+K+io);if(le!==void 0)return le}for(let K of Z)if(E(K,X,Q,ne,B))return K;return-1},T=(X,Q,ne,B,K,ie)=>{let le=`${X},${Q},${ne},${B},${K},${ie}`,J=z.get(le)??0;for(;;){let te=w(X+J*K,Q+J*ie,ne,B);if(te<0)break;J=K>0?N[te]+O[te]-X:K<0?X+ne-N[te]:ie>0?R[te]+P[te]-Q:Q+B-R[te]}return z.set(le,J),J},_=(X,Q)=>{let ne=v[Q]===X,B=ne?x[Q]:v[Q];if(H[B])return;let K=ne?g[Q]:m[Q],ie=ne?m[Q]:g[Q];$(ne?d[Q]:p[Q],X);let le=S,J=A;$(ne?p[Q]:d[Q],B);let te=os[K],ae=no[K],ee=0,re=0,de=os[K]+os[ie]===0&&no[K]+no[ie]===0;K===ie?(te=os[K]===0?1:0,ae=1-te):de||(ee=-os[ie],re=-no[ie]);let ye,oe;if(te!==0?(ye=te>0?N[X]+O[X]:N[X]-O[B],oe=R[X]+J+re-A):(oe=ae>0?R[X]+P[X]:R[X]-P[B],ye=N[X]+le+ee-S),de){let xe=b[B];if(xe!==void 0&&xe.length>1){let ge=[];for(let be of xe){let Ie=x[be]===B,Re=Ie?v[be]:x[be];if(!H[Re]||(Ie?g[be]:m[be])!==K||(Ie?m[be]:g[be])!==ie)continue;$(Ie?d[be]:p[be],Re);let ze=te!==0?R[Re]+A:N[Re]+S;$(Ie?p[be]:d[be],B),ge.push(ze-(te!==0?A:S))}ge.length>1&&(ge.sort((be,Ie)=>be-Ie),te!==0?oe=ge[ge.length-1>>1]:ye=ge[ge.length-1>>1])}let fe=te===0?1:0,pe=1-fe,Me=T(ye,oe,O[B],P[B],fe,pe),Ae=Me===0?0:T(ye,oe,O[B],P[B],-fe,-pe),ce=Me<=Ae?Me:-Ae;ye+=fe*ce,oe+=pe*ce}else{let xe=T(ye,oe,O[B],P[B],te,ae);ye+=te*xe,oe+=ae*xe}y(B,ye,oe)},M=X=>{let Q=u[X];if(Q.length===0)return;I.length=0;let ne=[];for(let xe of Q){if(H[xe])continue;W=I.length,ne.push(W),G.clear(),Z.length=0,z.clear(),y(xe,0,0);let fe=W,pe=W,Me=0;for(;;){if(fe<I.length){let ce=I[fe++],ge=k[ce];if(ge!==void 0)for(let be of ge)_(ce,be);continue}if(pe>=I.length)break;let Ae=b[I[pe]];if(Ae===void 0||Me>=Ae.length){pe++,Me=0;continue}_(I[pe],Ae[Me++])}}ne.push(I.length);let B=ne.length-1,K=new Array(B),ie=new Array(B),le=new Array(B),J=new Array(B),te=0,ae=0;for(let xe=0;xe<B;xe++){let fe=1/0,pe=1/0,Me=-1/0,Ae=-1/0;for(let ce=ne[xe];ce<ne[xe+1];ce++){let ge=I[ce];fe=Math.min(fe,N[ge]),pe=Math.min(pe,R[ge]),Me=Math.max(Me,N[ge]+O[ge]),Ae=Math.max(Ae,R[ge]+P[ge])}K[xe]=fe,ie[xe]=pe,le[xe]=Me-fe,J[xe]=Ae-pe,te+=le[xe]*J[xe],ae=Math.max(ae,le[xe])}let ee=Math.max(ae,Math.ceil(Math.sqrt(te*2))),re=0,de=0,ye=0,oe=0;for(let xe=0;xe<B;xe++){re>0&&re+le[xe]>ee&&(de+=ye,re=0,ye=0);for(let fe=ne[xe];fe<ne[xe+1];fe++)N[I[fe]]+=re-K[xe],R[I[fe]]+=de-ie[xe];re+=le[xe],ye=Math.max(ye,J[xe]),oe=Math.max(oe,re)}X<a&&(O[i+X]=oe,P[i+X]=de+ye)};for(let X=a-1;X>=0;X--)M(X);M(l);let U=new Int32Array(a),j=new Int32Array(a),Y=new Int32Array(a),D=new Uint8Array(a);for(let X=0;X<a;X++){let Q=c[i+X];Y[X]=Q===l?-1:Q,U[X]=N[i+X]+(Q===l?0:U[Q]),j[X]=R[i+X]+(Q===l?0:j[Q]),u[X].length===0&&(D[X]=1)}let L=new Int32Array(i),F=new Int32Array(i),V=new Int32Array(i);for(let X=0;X<i;X++){let Q=c[X];V[X]=Q===l?-1:Q,L[X]=N[X]+(Q===l?0:U[Q]),F[X]=R[X]+(Q===l?0:j[Q])}return{col:L,row:F,groupCol:U,groupRow:j,groupCols:O.slice(i),groupRows:P.slice(i),groupParent:Y,groupEmpty:D,nodeParent:V}}var rr=12,aE=6,R0=4,O0=3,sE=[-1,1,0,0],lE=[0,0,-1,1];function vh(e,t,r,n,i){let a=e.architecture,l=a!==null&&typeof a=="object"&&!Array.isArray(a)?a[t]:void 0;return typeof l=="number"&&Number.isFinite(l)?Math.min(i,Math.max(n,l)):r}function L0(e){let t=new Map;for(let r of e.sort((n,i)=>n-i))t.has(r)||t.set(r,t.size);return t}function D0(e,t,r,n,i){return`<svg class="pele-icon" data-icon="${Ge(e)}" x="${f(t)}" y="${f(r)}" width="${f(n)}" height="${f(n)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i?.(e)??nE(e)}</svg>`}function oE(e,t,r,n){let i=e.lines.length>r;if(!i&&e.width<=t)return e;let a=n.width("…",e.size,0),l=[],s=[],o=0;for(let c=0;c<Math.min(r,e.lines.length);c++){let h=e.lines[c].map(d=>({...d})),u=e.widths[c];if(u>t||i&&c===r-1)for(;;){let d=h[h.length-1];if(d===void 0){h.push({text:"…",style:0,width:a}),u=a;break}let p=u-d.width;if(d.icon===void 0&&p+a<t){let g=0,m=d.text.length;for(;g<m;){let x=g+m+1>>1;p+n.width(d.text.slice(0,x),e.size,d.style)+a<=t?g=x:m=x-1}let v=g>0?d.text.charCodeAt(g-1):0;v>=55296&&v<=56319&&g--,d.text=d.text.slice(0,g).trimEnd()+"…",d.width=n.width(d.text,e.size,d.style),u=p+d.width;break}h.pop(),u=p}l.push(h),s.push(u),o=Math.max(o,u)}return{...e,lines:l,widths:s,width:o,height:l.length*e.lineHeight}}function cE(e,t){let{x:r,y:n,dx:i,dy:a}=e,{x:l,y:s,dx:o,dy:c}=t,h=r+i*rr,u=n+a*rr,d=l+o*rr,p=s+c*rr;if(i*o+a*c===0){let x=i!==0?l:r,k=i!==0?n:s;return(x-r)*i+(k-n)*a>0&&(x-l)*o+(k-s)*c>0?[r,n,x,k,l,s]:i!==0?[r,n,h,u,h,p,d,p,l,s]:[r,n,h,u,d,u,d,p,l,s]}let g=i!==0,m=g?s-n:l-r;if(i===-o&&a===-c){if((l-r)*i+(s-n)*a>0){if(Math.abs(m)<.5)return[r,n,l,s];if(g){let C=i>0?e.x1:t.x1,N=i>0?t.x0:e.x0,R=C<N?(C+N)/2:(r+l)/2;return[r,n,R,n,R,s,l,s]}let x=a>0?e.y1:t.y1,k=a>0?t.y0:e.y0,b=x<k?(x+k)/2:(n+s)/2;return[r,n,r,b,l,b,l,s]}}else if(Math.abs(m)>=1){if(g){let k=i>0?Math.max(r,l)+rr:Math.min(r,l)-rr;return[r,n,k,n,k,s,l,s]}let x=a>0?Math.max(n,s)+rr:Math.min(n,s)-rr;return[r,n,r,x,l,x,l,s]}if(g){let x=e.y1+rr<=t.y0?(e.y1+t.y0)/2:t.y1+rr<=e.y0?(t.y1+e.y0)/2:Math.max(e.y1,t.y1)+rr;return[r,n,h,n,h,x,d,x,d,s,l,s]}let v=e.x1+rr<=t.x0?(e.x1+t.x0)/2:t.x1+rr<=e.x0?(t.x1+e.x0)/2:Math.max(e.x1,t.x1)+rr;return[r,n,r,u,v,u,v,p,l,p,l,s]}function dE(e){let t=[e[0],e[1]];for(let r=2;r<e.length;r+=2){let n=e[r],i=e[r+1],a=t.length,l=Math.abs(n-t[a-2])<.01,s=Math.abs(i-t[a-1])<.01;l&&s||(a>=4&&(l&&Math.abs(t[a-4]-t[a-2])<.01||s&&Math.abs(t[a-3]-t[a-1])<.01)?(t[a-2]=n,t[a-1]=i):t.push(n,i))}return t}function hE(e,t,r){let n=e.length/2,i=new Array(n),a=new Array(n);for(let o=0;o<n;o++)i[o]=e[o*2],a[o]=e[o*2+1];let l=(o,c,h)=>{let u=Math.hypot(i[c]-i[o],a[c]-a[o]),d=Math.min(h,Math.max(0,u-1));u>0&&d>0&&(i[o]+=(i[c]-i[o])/u*d,a[o]+=(a[c]-a[o])/u*d)};l(0,1,t),l(n-1,n-2,r);let s=`M${f(i[0])},${f(a[0])}`;for(let o=1;o<n-1;o++){let c=Math.hypot(i[o]-i[o-1],a[o]-a[o-1]),h=Math.hypot(i[o+1]-i[o],a[o+1]-a[o]),u=Math.min(aE,c/2,h/2);if(u<.5){s+=`L${f(i[o])},${f(a[o])}`;continue}let d=i[o]-(i[o]-i[o-1])/c*u,p=a[o]-(a[o]-a[o-1])/c*u,g=i[o]+(i[o+1]-i[o])/h*u,m=a[o]+(a[o+1]-a[o])/h*u;s+=`L${f(d)},${f(p)}Q${f(i[o])},${f(a[o])} ${f(g)},${f(m)}`}return s+`L${f(i[n-1])},${f(a[n-1])}`}function uE(e,t,r){return Yn(r,n=>fE(e,t,r,n))}function fE(e,t,r,n){let i=vh(t,"iconSize",48,8,512),a=vh(t,"fontSize",r.fontSize??16,4,128),l=Math.min(vh(t,"padding",20,0,256),n?12:1/0),s=Math.round(a*.875),o=r.measurer??bt(r.fontFamily),c=r.padding??8,h=r.icons,u=i/2,d=[...e.nodes.values()],p=[...e.groups.values()],g=d.length,m=p.length,v=iE(d,p,e.edges,e.layoutHints),x=new Map;d.forEach((se,ve)=>x.set(se.id,ve));let k=new Array(g),b=new Float64Array(g),C=new Float64Array(g),N=n?Math.max(i,64):Math.max(i*2.25,96);for(let se=0;se<g;se++){let ve=d[se],_e=Ve(ve.type==="service"?ve.title:void 0,!0,o,a,N);k[se]=_e,b[se]=Math.max(i,2*Math.ceil(_e.width/2)),C[se]=i+(_e.height>0?R0+_e.height:0)}let R=[],O=[];for(let se=0;se<g;se++)R.push(v.col[se]),O.push(v.row[se]);for(let se=0;se<m;se++)v.groupEmpty[se]&&(R.push(v.groupCol[se]),O.push(v.groupRow[se]));let P=L0(R),H=L0(O),I=P.size,G=H.size,Z=new Float64Array(I),z=new Float64Array(G),W=n?Math.max(24,2*rr):Math.max(40,Math.round(i*.75)),S=new Float64Array(I).fill(W),A=new Float64Array(G).fill(W),$=new Int32Array(g),y=new Int32Array(g);for(let se=0;se<g;se++){let ve=$[se]=P.get(v.col[se]),_e=y[se]=H.get(v.row[se]);Z[ve]=Math.max(Z[ve],b[se]),z[_e]=Math.max(z[_e],C[se])}for(let se=0;se<m;se++){if(!v.groupEmpty[se])continue;let ve=P.get(v.groupCol[se]),_e=H.get(v.groupRow[se]);Z[ve]=Math.max(Z[ve],i),z[_e]=Math.max(z[_e],u)}let E=e.edges.length,w=new Array(E),T=new Int32Array(E*2);for(let se=0;se<E;se++){let ve=e.edges[se],_e=T[se*2]=x.get(ve.lhsId)??-1,Te=T[se*2+1]=x.get(ve.rhsId)??-1,Oe=Ve(ve.title,!0,o,s,160);if(w[se]=Oe,!(Oe.width===0||_e<0||Te<0)){if($[_e]!==$[Te]){let Ce=Math.min($[_e],$[Te]);S[Ce]=Math.max(S[Ce],Math.ceil(Oe.width)+28)}else if(Z[$[_e]]=Math.max(Z[$[_e]],2*Math.ceil(Oe.width/2)+8),y[_e]!==y[Te]){let Ce=Math.min(y[_e],y[Te]);A[Ce]=Math.max(A[Ce],Math.ceil(Oe.height)+24)}}}let _=new Array(m),M=new Int32Array(m),U=new Int32Array(m),j=new Int32Array(m),Y=new Int32Array(m),D=new Float64Array(m),L=new Float64Array(m),F=new Float64Array(m),V=new Float64Array(m),X=new Float64Array(m),Q=new Float64Array(m),ne=new Float64Array(I),B=new Float64Array(I),K=new Float64Array(G),ie=new Float64Array(G),le=Math.round(a*1.25);for(let se=0;se<m;se++){M[se]=P.get(v.groupCol[se]),U[se]=P.get(v.groupCol[se]+v.groupCols[se]-1),j[se]=H.get(v.groupRow[se]),Y[se]=H.get(v.groupRow[se]+v.groupRows[se]-1);let ve=Ve(p[se].title,!0,o,a,n?Math.max(80,Xt(r)/2):320);_[se]=ve;let _e=p[se].icon?le:0;X[se]=ve.width+_e+(ve.width>0&&_e>0?6:0),Q[se]=Math.max(ve.height,_e)}for(let se=m-1;se>=0;se--){let ve=l+D[se],_e=l+L[se],Te=(Q[se]>0?Math.max(l,Q[se]+12):l)+F[se],Oe=l+V[se];if(X[se]>0){let He=ve+_e;for(let Ee=M[se];Ee<=U[se];Ee++)He+=Z[Ee]+(Ee<U[se]?B[Ee]+S[Ee]+ne[Ee+1]:0);X[se]+20>He&&(_e+=Math.ceil(X[se]+20-He))}D[se]=ve,L[se]=_e,F[se]=Te,V[se]=Oe,ne[M[se]]=Math.max(ne[M[se]],ve),B[U[se]]=Math.max(B[U[se]],_e),K[j[se]]=Math.max(K[j[se]],Te),ie[Y[se]]=Math.max(ie[Y[se]],Oe);let Ce=v.groupParent[se];Ce<0||(M[Ce]===M[se]&&(D[Ce]=Math.max(D[Ce],ve)),U[Ce]===U[se]&&(L[Ce]=Math.max(L[Ce],_e)),j[Ce]===j[se]&&(F[Ce]=Math.max(F[Ce],Te)),Y[Ce]===Y[se]&&(V[Ce]=Math.max(V[Ce],Oe)))}let J=new Float64Array(I),te=new Float64Array(G),ae=0;for(let se=0;se<I;se++)J[se]=ae+ne[se],ae=J[se]+Z[se]+B[se]+(se<I-1?S[se]:0);let ee=0;for(let se=0;se<G;se++)te[se]=ee+K[se],ee=te[se]+z[se]+ie[se]+(se<G-1?A[se]:0);let re=0,de=0,ye=ae,oe=ee,xe=se=>J[M[se]]-D[se],fe=se=>J[U[se]]+Z[U[se]]+L[se],pe=se=>te[j[se]]-F[se],Me=se=>te[Y[se]]+z[Y[se]]+V[se],Ae=se=>J[$[se]]+Z[$[se]]/2,ce=(se,ve,_e)=>{let Te=sE[ve],Oe=lE[ve],Ce=Ae(se),He=te[y[se]],Ee={x:Ce,y:He+u,dx:Te,dy:Oe,x0:Ce-b[se]/2,y0:He,x1:Ce+b[se]/2,y1:He+C[se],gap:0,wire:!1};d[se].type==="junction"?(Ee.x0=Ee.x1=Ce,Ee.y0=Ee.y1=Ee.y,Ee.gap=O0):Te!==0?Ee.x=Ce+Te*u:Ee.y=Oe<0?He:He+C[se]+(k[se].height>0?2:0);let Ye=_e?v.nodeParent[se]:-1;return Ye>=0&&(Ee.x0=xe(Ye),Ee.x1=fe(Ye),Ee.y0=pe(Ye),Ee.y1=Me(Ye),Ee.gap=0,Ee.wire=d[se].type==="junction",Te!==0?Ee.x=Te<0?Ee.x0:Ee.x1:Ee.y=Oe<0?Ee.y0:Ee.y1),Ee},ge="",be="",Ie=[],Re=Et("arrow_point");for(let se=0;se<E;se++){let ve=e.edges[se],_e=T[se*2],Te=T[se*2+1];if(_e<0||Te<0)continue;let Oe=ce(_e,Ic(ve.lhsDir),ve.lhsGroup),Ce=ce(Te,Ic(ve.rhsDir),ve.rhsGroup);Oe.x===Ce.x&&Oe.y===Ce.y&&Oe.dx===Ce.dx&&(Oe.x-=8*Math.abs(Oe.dy),Oe.y-=8*Math.abs(Oe.dx),Ce.x+=8*Math.abs(Oe.dy),Ce.y+=8*Math.abs(Oe.dx));let He=cE(Oe,Ce);Oe.wire&&He.unshift(Ae(_e),te[y[_e]]+u),Ce.wire&&He.push(Ae(Te),te[y[Te]]+u);let Ee=dE(He);if(Ee.length<4)continue;let Ye=Ge(`${ve.lhsId}-${ve.rhsId}`);ge+=`<g class="pele-edge" data-id="${Ye}"><path d="${hE(Ee,ve.lhsInto&&!Oe.wire?Re+Oe.gap:0,ve.rhsInto&&!Ce.wire?Re+Ce.gap:0)}"/>`+(ve.lhsInto?Ct("arrow_point",Oe.x+Oe.dx*Oe.gap,Oe.y+Oe.dy*Oe.gap,-Oe.dx,-Oe.dy,"var(--_l)"):"")+(ve.rhsInto?Ct("arrow_point",Ce.x+Ce.dx*Ce.gap,Ce.y+Ce.dy*Ce.gap,-Ce.dx,-Ce.dy,"var(--_l)"):"")+"</g>";let qe=-1,Qe=-1,lt=-1,Ze=-1,it=w[se];for(let rt=0;rt<Ee.length;rt+=2)re=Math.min(re,Ee[rt]-4),ye=Math.max(ye,Ee[rt]+4),de=Math.min(de,Ee[rt+1]-4),oe=Math.max(oe,Ee[rt+1]+4);for(let rt=0;rt+3<Ee.length;rt+=2){let wt=Math.abs(Ee[rt+1]-Ee[rt+3])<.01,je=Math.abs(Ee[rt]-Ee[rt+2])+Math.abs(Ee[rt+1]-Ee[rt+3]);wt||Ie.push(Ee[rt],Math.min(Ee[rt+1],Ee[rt+3]),Math.max(Ee[rt+1],Ee[rt+3])),je>Qe&&(qe=rt,Qe=je),wt&&je>Ze&&(lt=rt,Ze=je)}if(it.width>0){let rt=Ze>=it.width+8?lt:qe,wt=(Ee[rt]+Ee[rt+2])/2,je=(Ee[rt+1]+Ee[rt+3])/2,Ue=it.width+8,ot=Math.abs(Ee[rt]-Ee[rt+2])<.01;for(let Fe of[Oe,Ce])wt+Ue/2<=Fe.x0||wt-Ue/2>=Fe.x1||je+it.height/2<=Fe.y0||je-it.height/2>=Fe.y1||(ot?wt=wt>=(Fe.x0+Fe.x1)/2?Fe.x1+Ue/2+4:Fe.x0-Ue/2-4:je=je>=(Fe.y0+Fe.y1)/2?Fe.y1+it.height/2+4:Fe.y0-it.height/2-4);re=Math.min(re,wt-Ue/2),ye=Math.max(ye,wt+Ue/2),de=Math.min(de,je-it.height/2),oe=Math.max(oe,je+it.height/2),be+=kn(`${ve.lhsId}-${ve.rhsId}`,it,wt,je,"",h)}}let ze="";for(let se=0;se<m;se++){let ve=p[se],_e=xe(se),Te=pe(se),Oe=fe(se)-_e,Ce=_[se],He="";if(X[se]>0){let Ee=Te+Q[se]+12,Ye=[];for(let Ze=0;Ze<Ie.length;Ze+=3)Ie[Ze+1]<Ee&&Ie[Ze+2]>Te&&Ie[Ze]>_e&&Ie[Ze]<_e+Oe&&Ye.push(Ie[Ze]);Ye.sort((Ze,it)=>Ze-it),Ye.push(_e+Oe-4);let qe=_e+10;for(let Ze of Ye){if(Ze-6-qe>=X[se])break;qe=Math.max(qe,Ze+6)}qe+X[se]>_e+Oe-4&&(qe=_e+10);let Qe=Te+6+Q[se]/2,lt=qe;ve.icon&&(He+=D0(ve.icon,qe,Qe-le/2,le,h),lt+=le+6),He+=Le(Ce,lt+Ce.width/2,Qe,' class="pele-cluster-label" fill="var(--_m)"',h)}ze+=`<g class="pele-cluster" data-id="${Ge(ve.id)}"><rect x="${f(_e)}" y="${f(Te)}" width="${f(Oe)}" height="${f(Me(se)-Te)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${xt}/>`+He+"</g>"}let he="",$e=i*.5,Se=Math.max(6,Math.round(a*.75));for(let se=0;se<g;se++){let ve=d[se],_e=`data-id="${Ge(ve.id)}" transform="translate(${f(Ae(se))},${f(te[y[se]])})"`;if(ve.type==="junction"){he+=`<g class="pele-node pele-junction" ${_e}><circle cy="${f(u)}" r="${O0}" fill="var(--_l)"/></g>`;continue}let Te="";if(ve.icon)Te=D0(ve.icon,-$e/2,(i-$e)/2,$e,h);else if(ve.iconText){let Oe=Ve(ve.iconText,!1,o,Se,i-8),Ce=Math.max(1,Math.floor((i-4)/(Oe.lineHeight||1)));Te=Le(oE(Oe,i-8,Ce,o),0,u,` class="pele-icon-text" font-size="${Se}"`,h)}he+=`<g class="pele-node pele-service" ${_e}><rect x="${f(-u)}" width="${f(i)}" height="${f(i)}" fill="var(--_s)" stroke="var(--_b)"${xt}/>`+Te+Le(k[se],0,i+R0+k[se].height/2,' class="pele-label"',h)+"</g>"}let we=Ve(e.title,!1,o,a,n?Xt(r):4e3,1),ke=we.height>0?we.height+12:0,Ne=Math.ceil(Math.max(ye-re,we.width)+2*c),Be=Math.ceil(oe-de+ke+2*c),Pe=Math.round((Ne-(ye-re))/2-re),q=Math.round(c+ke-de),me=(ze?`<g class="pele-clusters">${ze}</g>`:"")+(ge?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round" stroke-linejoin="round">${ge}</g>`:"")+(be?`<g class="pele-edge-labels" font-size="${s}">${be}</g>`:"")+(he?`<g class="pele-nodes">${he}</g>`:"");return{svg:mt("architecture",Ne,Be,a,r,e,Le(we,Ne/2,c+we.height/2,' class="pele-title" font-weight="var(--_tw)"')+(me?`<g transform="translate(${Pe},${q})">${me}</g>`:"")),width:Ne,height:Be,links:[]}}var pE={type:"architecture",parse(e,t,r){let n=new q_;return r&&(n.title=r),X_(tE(e),n),n},render:uE},P0=1e5;function gE(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 mE(e){switch(e.trim().slice(-1)){case"x":return"arrow_cross";case"o":return"arrow_circle";case">":return"arrow_point";default:return""}}function yE(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 xE(e){return e.includes("==")?"thick":"normal"}function bE(e){return e.includes(".-")?"dotted":"solid"}function z0(e,t){let r=e.flat(),n=-1;for(let i of r)if(i.type==="column-setting"){n=i.columns??-1;break}return{list:r,at:0,parent:t,children:[],columns:n}}var wE=class{type="block";title;root={id:"root",type:"composite",children:[],columns:-1};blocks=[];edges=[];classes=new Map;byId=new Map;typeStr2Type=gE;edgeStrToEdgeData=mE;edgeStrToEdgeStartData=yE;edgeStrToThickness=xE;edgeStrToPattern=bE;warn;pending=new Set;edgeCount=new Map;ids=0;colors=0;spaces=0;constructor(e={}){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 n of t.split(",")){let i=n.indexOf(";"),a=(i===-1?n:n.slice(0,i)+n.slice(i+1)).trim();n.includes("color")&&r.textStyles.push(a.replace("fill","bgFill").replace("color","fill")),r.styles.push(a)}}addStyle2Node(e,t=""){this.named(e).styles=t.split(",")}setCssClass(e,t){for(let r of e.split(","))(this.named(r.trim()).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=[z0(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 n=r.list[r.at++];switch(r.columns>0&&n.type!=="column-setting"&&typeof n.widthInColumns=="number"&&n.widthInColumns>r.columns&&this.warn?.(`Block ${n.id} width ${n.widthInColumns} exceeds configured column width ${r.columns}`),n.type){case"classDef":this.addStyleClass(n.id,n.css);continue;case"applyClass":this.setCssClass(n.id,n.styleClass??"");continue;case"applyStyles":n.stylesStr&&this.addStyle2Node(n.id,n.stylesStr);continue;case"column-setting":r.parent.columns=n.columns??-1;continue;case"edge":{let s=(this.edgeCount.get(n.id)??0)+1;this.edgeCount.set(n.id,s),n.id=s+"-"+n.id,this.edges.push(n);continue}}n.id??=this.generateId(),n.label||(n.label=n.type==="composite"?"":n.id);let i=this.byId.get(n.id),a=i===void 0||this.pending.delete(n.id);a?(i&&(n.classes=i.classes,n.styles=i.styles),n.type==="composite"&&(n.colorIndex=this.colors++),this.byId.set(n.id,n)):(n.type!=="na"&&(i.type=n.type),n.label!==n.id&&(i.label=n.label));let l=n.children;if(n.children=[],n.type==="space"){let s=n.width??1;if(!(s<=P0-this.spaces))throw new Je(`A block diagram can hold at most ${P0} space blocks.`,"limit",{type:"block"});this.spaces+=Math.max(s,0);for(let o=0;o<s;o++){let c={...n,id:n.id+"-"+o,children:[]};this.byId.set(c.id,c),r.children.push(c)}}else a&&r.children.push(n);l&&l.length>0&&t.push(z0(l,n))}this.blocks=this.root.children??[]}},F0=["$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"],vE=["right","left","x","y","up","down"],db=new Uint8Array(128);for(let e of[9,10,11,12,13,32,40,41,45,58,60,61,62,91,123,125])db[e]=1;function $E(e){let t=e.length,r=[],n=[],i=[],a=[],l=0,s=0,o=(H,I,G)=>(r.push(H),n.push(I),i.push(s),s=G,!0),c=(H,I)=>o(H,e.slice(s,I),I),h=H=>{a.push(l),l=H},u=()=>{a.length>0&&(l=a.pop())},d=H=>{for(;H<t&&Xe(e.charCodeAt(H));)H++;return H},p=H=>{for(;H<t;){let I=e.charCodeAt(H);if(I<48||I>57)break;H++}return H},g=H=>{for(;H<t&&nt(e.charCodeAt(H));)H++;return H},m=H=>e.startsWith(H,s)&&!nt(e.charCodeAt(s+H.length)),v=()=>(e.charCodeAt(s+1)===96?(h(2),s+=2):(h(1),s++),!0),x=H=>{if(e.charCodeAt(H)!==46)return-1;do H++;while(e.charCodeAt(H)===46);if(e.charCodeAt(H)!==45)return-1;let I=e.charCodeAt(H+1);return I===120||I===111||I===62?H+2:H+1},k=H=>{let I=e.charCodeAt(H);(I===120||I===111||I===60)&&H++;let G=e.charCodeAt(H);if(G===46)return x(H);if(G!==45&&G!==61)return-1;let Z=H+1;for(;e.charCodeAt(Z)===G;)Z++;if(Z-H===1)return G===45?x(Z):-1;let z=e.charCodeAt(Z);return z===120||z===111||z===62?Z+1:Z-H>=3?Z:-1},b=()=>{let H=k(s);if(H>=0)return c(33,d(H));let I=e.charCodeAt(s)===60?s+1:s,G=e.charCodeAt(I),Z=e.charCodeAt(I+1);return G===45&&(Z===45||Z===46)||G===61&&Z===61?(h(6),c(34,d(I+2))):!1},C=H=>{let I=e.indexOf(`
68
+ `,s);return I===-1&&(I=t),u(),c(H,I)},N=(H,I)=>{let G=g(s);if(G===s)return!1;for(;e.charCodeAt(G)===44;){let Z=d(G+1),z=g(Z);if(z===Z)break;G=z}return l=I,c(H,G)},R=H=>{if(Xe(H))return s=d(s+1),!0;let I;switch(H){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(!nt(e.charCodeAt(s+5)))return c(2,s+5)}break;case 99:if(e.startsWith("columns",s)){if(I=d(s+7),I>s+7){if(e.startsWith("auto",I)&&!nt(e.charCodeAt(I+4)))return o(4,"-1",I+4);let G=p(I);if(G>I)return o(4,e.slice(I,G),G)}}else if(e.startsWith("class",s)){let G=e.startsWith("Def",s+5),Z=G?s+8:s+5;if(I=d(Z),I>Z)return h(G?7:9),c(G?11:15,I)}break;case 34:return v();case 115:if(e.startsWith("space",s)){if(e.charCodeAt(s+5)===58){let G=p(s+6);if(G>s+6)return o(7,e.slice(s+6,G),G)}if(!nt(e.charCodeAt(s+5)))return o(7,"1",s+5)}else if(e.startsWith("style",s)&&(I=d(s+5),I>s+5))return h(11),c(18,I);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(I=d(s+8),e.charCodeAt(I)===58)return h(13),c(21,d(I+1))}else if(e.startsWith("accDescr",s)){I=d(s+8);let G=e.charCodeAt(I);if(G===58)return h(14),c(23,d(I+1));if(G===123)return h(15),s=d(I+1),!0}break;case 101:if(m("end"))return c(26,d(s+3));break;case 45:return e.charCodeAt(s+1)===41?(h(3),c(27,s+2)):b();case 61:return b();case 60:return e.charCodeAt(s+1)===91?(h(4),c(29,s+2)):b();case 40:{let G=e.charCodeAt(s+1),Z=G===45||G===91?2:G===40?e.charCodeAt(s+2)===40?3:2:1;return h(3),c(27,s+Z)}case 41:case 123:return h(3),c(27,e.charCodeAt(s+1)===H?s+2:s+1);case 62:return h(3),c(27,s+1);case 91:{let G=e.charCodeAt(s+1);return h(3),c(27,G===91||G===124||G===40||G===92||G===47?s+2:s+1)}case 58:{let G=p(s+1);return G>s+1?o(36,e.slice(s+1,G),G):!1}}for(I=s;I<t;){let G=e.charCodeAt(I);if(G<128?db[G]===1:Xe(G))break;I++}return I>s&&c(32,I)},O=H=>{let I=e.charCodeAt(s+1),G=0;switch(H){case 34:return v();case 40:G=I===45?2:I===40?e.charCodeAt(s+2)===40?3:2:1;break;case 41:G=I===41?e.charCodeAt(s+2)===41?3:2:I===93?2:1;break;case 125:G=I===125?2:1;break;case 45:G=I===41?2:0;break;case 93:G=I===93||I===41||I===62?2:1;break;case 92:case 47:G=I===93?2:0;break}return G===0?!1:(u(),c(28,s+G))},P=H=>{if(H===41)return u(),u(),o(30,"]>",d(s+1));let I=d(H===44?s+1:s);for(let G of vE)if(e.startsWith(G,I)){let Z=d(I+G.length);return o(31,e.slice(H===44?I:s,Z),Z)}return!1};for(;;){if(s>=t){let G=-1;switch(l){case 0:G=37;break;case 1:G=6;break;case 8:G=14;break;case 10:G=17;break;case 12:G=20;break;case 13:G=22;break;case 14:G=24;break;case 15:G=25;break}s=t,G!==-1&&o(G,"",t);break}let H=e.charCodeAt(s),I=!0;switch(l){case 0:I=R(H);break;case 1:if(H===34)u(),s++;else{let G=e.indexOf('"',s);c(6,G===-1?t:G)}break;case 2:if(H===96)I=e.charCodeAt(s+1)===34,I&&(u(),s+=2);else if(H===34)I=!1;else{let G=s+1;for(;G<t;){let Z=e.charCodeAt(G);if(Z===96||Z===34)break;G++}c(5,G)}break;case 3:I=O(H);break;case 4:if(H===34)v();else if(H===93&&e.charCodeAt(s+1)===62){let G=d(s+2);I=e.charCodeAt(G)===40,I&&(h(5),s=G+1)}else I=!1;break;case 5:I=P(H);break;case 6:if(H===34)e.charCodeAt(s+1)===96?v():(c(35,s+1),h(1));else{let G=k(d(s));I=G>=0,I&&(u(),c(33,d(G)))}break;case 7:{let G=12,Z=e.startsWith("DEFAULT",s)?s+7:s,z=d(Z);(Z===s||z===Z)&&(G=13,Z=g(s),z=d(Z)),I=Z>s&&z>Z,I&&(l=8,c(G,z));break}case 8:C(14);break;case 9:I=N(16,10);break;case 10:C(17);break;case 11:I=N(19,12);break;case 12:C(20);break;case 13:C(22);break;case 14:C(24);break;case 15:if(H===125)u(),s++;else{let G=e.indexOf("}",s);c(25,G===-1?t:G)}break}if(!I)return r.push(1),n.push(""),i.push(s),{types:r,texts:n,starts:i}}return r.push(0),n.push(""),i.push(t),{types:r,texts:n,starts:i}}var cs="'NODE_ID', 'COLUMNS', 'SPACE_BLOCK', 'BLOCK_DIAGRAM_KEY', 'id-block', 'classDef', 'class', 'style'";function W0(e){let t=e[e.length-1];return Array.isArray(t)?(e.pop(),e.concat(t)):e}function kE(e,t){let{types:r,texts:n,starts:i}=$E(e),a=0,l=d=>{let p=r[a];throw p===1?vt("block",e,i[a],"",!0):vt("block",e,i[a],`Expecting ${d}, got '${F0[p]}'`)},s=d=>(r[a]!==d&&l(`'${F0[d]}'`),n[a++]),o=()=>{let d=s(32);if(r[a]===27){let p=n[a++],g=s(6);return{id:d,label:g,typeStr:p+s(28)}}if(r[a]===29){let p=n[a++],g=s(6),m=[s(31)];for(;r[a]===31;)m.push(n[a++]);return{id:d,label:g,typeStr:p+s(30),directions:m}}return{id:d}},c=()=>{let d=o(),p=r[a]===36?parseInt(n[a++],10):1,g={id:d.id,label:d.label,type:t.typeStr2Type(d.typeStr),directions:d.directions,widthInColumns:p},m;for(;r[a]===33||r[a]===34;){let v="";r[a++]===34&&(s(35),v=s(6),s(33));let x=n[a-1],k=o(),b=t.edgeStrToEdgeData(x),C=t.edgeStrToEdgeStartData(x),N=t.edgeStrToThickness(x),R=t.edgeStrToPattern(x);m??=[{id:g.id,label:g.label,type:g.type,directions:g.directions}],g={id:k.id,label:k.label,type:t.typeStr2Type(k.typeStr),directions:k.directions},m.push({id:m[m.length-1].id+"-"+k.id,start:m[m.length-1].id,end:k.id,label:v,type:"edge",thickness:N,pattern:R,directions:k.directions,arrowTypeEnd:b,arrowTypeStart:C},g)}return m??g};s(2);let h=[],u=[];for(;;)switch(r[a]){case 32:u.push(c());break;case 4:u.push({type:"column-setting",columns:parseInt(n[a++],10)});break;case 7:{let d=parseInt(n[a++],10);u.push({id:t.generateId(),type:"space",label:"",width:d,children:[]});break}case 2:a++,h.push({list:u,header:void 0}),u=[];break;case 3:a++,r[a]!==32&&l("'NODE_ID'"),h.push({list:u,header:c()}),u=[];break;case 26:{let d=h.pop();if(d===void 0||u.length===0)return l(cs);a++;let p=t.generateId(),g=W0(u);u=d.list,u.push(d.header===void 0?{id:p,type:"composite",label:"",children:g}:{...d.header,type:"composite",children:g});break}case 11:{a++;let d=s(13).trim();u.push({type:"classDef",id:d,css:s(14).trim()});break}case 15:{a++;let d=s(16).trim();u.push({type:"applyClass",id:d,styleClass:s(17).trim()});break}case 18:{a++;let d=s(19).trim();u.push({type:"applyStyles",id:d,stylesStr:s(20).trim()});break}case 37:h.length>0&&l(cs+", 'end'"),u.length===0&&l(cs),t.setHierarchy(W0(u));return;default:l(u.length===0?cs:cs+(h.length>0?", 'end'":", 'EOF'"))}}function Mn(e,t,r,n){return T$(()=>Ve(e,!1,t,r,n,1))}function hb(e,t,r,n,i,a,l){let s=Mn(e,t,r,4e3);if(s.height===0)return{width:i,height:a,content:l};let o=s.height+12,c=Math.max(i,Math.ceil(s.width+2*n));return{width:c,height:Math.ceil(a+o),content:Le(s,c/2,n+s.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${f((c-i)/2)},${f(o)})">${l}</g>`}}var Jr=1,en=2,tn=4,rn=8,Ea=7,Nc=20,Fn=12;function ME(e){let t=0;if(e)for(let r of e)switch(r.trim()){case"right":t|=Jr;break;case"left":t|=en;break;case"up":t|=tn;break;case"down":t|=rn;break;case"x":t|=Jr|en;break;case"y":t|=tn|rn;break}return t}var In=(e,t)=>e&t?1:0;function rd(e){return e!==0&&(e&(tn|rn))===0?"x":e!==0&&(e&(Jr|en))===0?"y":""}function B0(e,t,r){let n=rd(e),i=In(e,en)-In(e,Jr),a=In(e,tn)-In(e,rn);if(n==="x"){let l=Math.max(r+8,14)+2*Ea,s=Math.min(l/2,Nc);return{w:Math.max(t+12,16)+s*(e===(Jr|en)?2:1),h:l,dx:i*s/2,dy:0}}if(n==="y"){let l=Math.max(t+16,14)+2*Ea,s=Math.min(l/2,Nc);return{w:l,h:Math.max(r+8,16)+s*(e===(tn|rn)?2:1),dx:0,dy:a*s/2}}return{w:Math.max(t+16,24)+Fn*(In(e,en)+In(e,Jr)),h:Math.max(r+8,24)+Fn*(In(e,tn)+In(e,rn)),dx:i*Fn/2,dy:a*Fn/2}}function _E(e,t,r,n){let i=rd(e),a=t/2,l=r/2,s;if(i==="x"){let c=Math.min(l,Nc),h=l-Ea,u=e&en?-a+c:-a,d=e&Jr?a-c:a;s=[u,-h,d,-h],e&Jr&&s.push(d,-l,a,0,d,l),s.push(d,h,u,h),e&en&&s.push(u,l,-a,0,u,-l)}else if(i==="y"){let c=Math.min(a,Nc),h=a-Ea,u=e&tn?-l+c:-l,d=e&rn?l-c:l;s=[h,u,h,d],e&rn&&s.push(a,d,0,l,-a,d),s.push(-h,d,-h,u),e&tn&&s.push(-a,u,0,-l,a,u)}else{let c=e&en?-a+Fn:-a,h=e&Jr?a-Fn:a,u=e&tn?-l+Fn:-l,d=e&rn?l-Fn:l,p=(c+h)/2,g=(u+d)/2,m=Math.min(10,(h-c)/2),v=Math.min(10,(d-u)/2);s=[c,u],e&tn&&s.push(p-m,u,p,-l,p+m,u),s.push(h,u),e&Jr&&s.push(h,g-v,a,g,h,g+v),s.push(h,d),e&rn&&s.push(p+m,d,p,l,p-m,d),s.push(c,d),e&en&&s.push(c,g+v,-a,g,c,g-v)}let o="";for(let c=0;c<s.length;c+=2)o+=(c?" ":"")+f(s[c])+","+f(s[c+1]);return`<polygon points="${o}" stroke-linejoin="round"${n}/>`}var EE=1e3;function AE(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 TE(e,t,r){let n=e.columns,i=[],a=0,l=0,s=0,o=0;for(let h of e.children){let{px:u,py:d}=AE(n,a),p=h.span>=1?Math.min(h.span,EE):1;if(n>0&&p>n-u&&(p=n-u),h.span=p,h.col=u,h.row=d,a+=p,u+p>l&&(l=u+p),d===i.length&&i.push(0),h.children.length===0?i[d]=-1:i[d]>=0&&h.nh>i[d]&&(i[d]=h.nh),h.space)continue;let g=(h.nw-t*(p-1))/p;g>s&&(s=g),h.nh>o&&(o=h.nh)}let c=(i.length-1)*t;for(let h=0;h<i.length;h++)i[h]<0&&(i[h]=o),c+=i[h];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 SE(e,t,r){let{cols:n,heights:i}=e,a=i.length,l=(e.w-2*r-(n-1)*t)/n,s=e.h-2*r-e.head-(a-1)*t,o=0;for(let g of i)o+=g;let c=o>0?s/o:0,h=o>0?0:s/a,u=e.x-e.w/2+r,d=e.y-e.h/2+r+e.head,p=0;for(let g of e.children){for(;p<g.row;p++)d+=i[p]*c+h+t;g.w=l*g.span+t*(g.span-1),g.h=i[p]*c+h,g.x=u+g.col*(l+t)+g.w/2,g.y=d+g.h/2}}function CE(e,t){let r=[e];for(let n=0;n<r.length;n++)for(let i of r[n].children)r.push(i);for(let n=r.length-1;n>=0;n--){let i=r[n];i.children.length>0&&TE(i,t,n===0?0:t)}e.w=e.nw,e.h=e.nh,e.x=e.w/2,e.y=e.h/2;for(let n=0;n<r.length;n++){let i=r[n];i.children.length>0&&SE(i,t,n===0?0:t)}return{width:e.w,height:e.h}}var IE=12,H0=200,NE=8,j0=' fill="var(--_s)" stroke="var(--_b)"',RE=' stroke="var(--_b)"',U0=[],OE=[],LE=[],DE=["default"],PE=2e6,zE=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"]]),FE=new Set(["circle","dbl-circ","diam"]),WE=new Set(["stadium","hex","odd","lean-r","lean-l","trap-b","trap-t"]);function nd(e){return e.kind===0&&(e.shape==="circle"||e.shape==="dbl-circ")}function Yi(e,t,r){let n=e.bw/2,i=e.bh/2,a=Math.abs(t-e.x),l=i;return nd(e)?l=Math.sqrt(Math.max(n*n-a*a,0)):e.kind===0&&e.shape==="diam"?l=i*Math.max(1-a/n,0):e.kind===0?l=i-$i(e.shape,e.bw,e.bh,r>0?2:0):e.kind===1&&rd(e.mask)==="x"&&(l=i-Ea),e.y+r*l}function Gi(e,t,r){let n=e.bw/2,i=e.bh/2,a=Math.abs(t-e.y),l=n;return nd(e)?l=Math.sqrt(Math.max(i*i-a*a,0)):e.kind===0&&e.shape==="diam"?l=n*Math.max(1-a/i,0):e.kind===0?l=n-$i(e.shape,e.bw,e.bh,r>0?1:3):e.kind===1&&rd(e.mask)==="y"&&(l=n-Ea),e.x+r*l}function Y0(e,t,r,n){let i=t-e.x,a=r-e.y,l=e.bw/2,s=e.bh/2,o;nd(e)?o=l/(Math.hypot(i,a)||1):e.kind===0&&e.shape==="diam"?o=1/(Math.abs(i)/l+Math.abs(a)/s||1):o=Math.min(i===0?1/0:l/Math.abs(i),a===0?1/0:s/Math.abs(a)),o===1/0&&(o=0),n.push(e.x+i*o,e.y+a*o)}function BE(e,t,r,n,i){let a=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<a&&r<a||e>l&&r>l||t<s&&n<s||t>o&&n>o)return!1;if(e===r||t===n)return!0;let c=r-e,h=n-t,u=(p,g)=>Math.sign(c*(g-t)-h*(p-e)),d=u(a,s);return d===0||u(l,s)!==d||u(l,o)!==d||u(a,o)!==d}function $h(e,t,r,n){let i=0;for(let a of n)if(!(a===t||a===r)){for(let l=0;l+3<e.length;l+=2)if(BE(e[l],e[l+1],e[l+2],e[l+3],a)){i++;break}}return i}function HE(e,t,r,n){let i=e.x-e.bw/2,a=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,h=t.y-t.bh/2,u=t.y+t.bh/2,d=Math.max(i,o),p=Math.min(a,c),g=Math.max(l,h),m=Math.min(s,u),v=p-d>6,x=m-g>6;if(v&&x){let Z=e.bw*e.bh<=t.bw*t.bh?e:t,z=Z===e?t:e,W=Z.y-Z.bh/2-(z.y-z.bh/2),S=z.y+z.bh/2-(Z.y+Z.bh/2),A=Z.x-Z.bw/2-(z.x-z.bw/2),$=z.x+z.bw/2-(Z.x+Z.bw/2),y=Math.min(W,S,A,$),E;return y===S?E=[Z.x,Yi(Z,Z.x,1),Z.x,z.y+z.bh/2]:y===W?E=[Z.x,Yi(Z,Z.x,-1),Z.x,z.y-z.bh/2]:y===$?E=[Gi(Z,Z.y,1),Z.y,z.x+z.bw/2,Z.y]:E=[Gi(Z,Z.y,-1),Z.y,z.x-z.bw/2,Z.y],Z===e?E:[E[2],E[3],E[0],E[1]]}if(v){let Z=Math.min(6,(p-d)/2),z=Math.min(Math.max((d+p)/2+r,d+Z),p-Z),W=t.y>e.y?1:-1;return[z,Yi(e,z,W),z,Yi(t,z,-W)]}if(x){let Z=Math.min(6,(m-g)/2),z=Math.min(Math.max((g+m)/2+r,g+Z),m-Z),W=t.x>e.x?1:-1;return[Gi(e,z,W),z,Gi(t,z,-W),z]}let k=t.x>e.x?1:-1,b=t.y>e.y?1:-1,C=[Gi(e,e.y,k),e.y,t.x,e.y,t.x,Yi(t,t.x,-b)],N=[e.x,Yi(e,e.x,b),e.x,t.y,Gi(t,t.y,-k),t.y],R=Math.abs(t.x-e.x)>=Math.abs(t.y-e.y),O=R?C:N;if(n===void 0)return O;let P=$h(O,e,t,n);if(P===0)return O;let H=R?N:C,I=$h(H,e,t,n);if(I<P&&(O=H,P=I),P===0)return O;let G=[];return Y0(e,t.x,t.y,G),Y0(t,e.x,e.y,G),$h(G,e,t,n)<P?G:O}function jE(e,t,r){let n=e.length,i=e[0],a=e[1],l=e[n-2],s=e[n-1],o=e[2]-i,c=e[3]-a,h=Math.hypot(o,c);o/=h||1,c/=h||1;let u=l-e[n-4],d=s-e[n-3],p=Math.hypot(u,d);if(u/=p||1,d/=p||1,n===4&&t+r>h){let m=h/(t+r);t*=m,r*=m}t=Math.min(t,h),r=Math.min(r,p);let g=`M${f(i+o*t)},${f(a+c*t)}`;if(n===6){let m=Math.max(0,Math.min(NE,h-t,p-r));g+=`L${f(e[2]-o*m)},${f(e[3]-c*m)}Q${f(e[2])},${f(e[3])} ${f(e[2]+u*m)},${f(e[3]+d*m)}`}return g+=`L${f(l-u*r)},${f(s-d*r)}`,{d:g,sx:i,sy:a,sdx:-o,sdy:-c,ex:l,ey:s,edx:u,edy:d}}function ub(e,t){let r=e.bw/2,n=e.bh/2,i=Math.max(1,Math.min(10+5*(t-1),r,n));if(nd(e)){let a=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)-a);return[a,l,i,o(Math.PI/4+s),o(Math.PI/4-s)]}if(e.kind===0&&e.shape==="diam"){let a=Math.atan2(n,r);return[e.x+r/2,e.y-n/2,i,a+Math.PI,a]}return[e.x+r,e.y-n,i,Math.PI,Math.PI/2]}function UE(e,t,r,n){let[i,a,l,s,o]=ub(e,t),c=s+r/l,h=o-n/l,u=(h-c)%(2*Math.PI);u<=0&&(u+=2*Math.PI);let d=i+l*Math.cos(c),p=a+l*Math.sin(c),g=i+l*Math.cos(h),m=a+l*Math.sin(h),v=i+l*Math.cos(s),x=a+l*Math.sin(s),k=i+l*Math.cos(o),b=a+l*Math.sin(o),C=Math.hypot(v-d,x-p),N=Math.hypot(k-g,b-m);return{d:`M${f(d)},${f(p)}A${f(l)},${f(l)} 0 ${u>Math.PI?1:0} 1 ${f(g)},${f(m)}`,sx:v,sy:x,sdx:C>0?(v-d)/C:Math.sin(s),sdy:C>0?(x-p)/C:-Math.cos(s),ex:k,ey:b,edx:N>0?(k-g)/N:-Math.sin(o),edy:N>0?(b-m)/N:Math.cos(o)}}var YE=[.5,.3,.7,.15,.85];function GE(e,t,r,n,i,a,l){if(l===void 0)return .5;for(let s of YE){let o=e[t]+(e[t+2]-e[t])*s,c=e[t+1]+(e[t+3]-e[t+1])*s,h=!0;for(let u of l)if(u!==i&&u!==a&&Math.abs(o-u.x)<(r+u.bw)/2&&Math.abs(c-u.y)<(n+u.bh)/2){h=!1;break}if(h)return s}return .5}function VE(e,t,r){return Yn(r,n=>qE(e,t,r,n))}function qE(e,t,r,n){let i=r.fontSize??16,a=Math.round(i*.875),l=r.measurer??bt(r.fontFamily),s=r.padding??8,o=r.icons,c=t.block?.padding,h=Math.min(typeof c=="number"&&c>=0?Math.min(c,200):IE,n?6:1/0),u=n?80:H0,d=Y=>{let D=[],L=F=>{for(let V of F)for(let X of V.split(";"))D.push(X)};for(let F of Y.classes&&Y.classes.length>0?Y.classes:DE){let V=e.classes.get(F);V&&L(V.styles)}return Y.styles&&L(Y.styles),Ot(D)},p=(Y,D)=>{let L=Y.type,F=L==="space"?Ot(U0):d(Y),V=(F.bold?1:0)|(F.italic?2:0),X=F.fontSize??i,Q=0,ne="",B,K=0,ie=0,le=0,J=0,te=0,ae=0;if(L==="space")Q=3,B=Ve(void 0,!1,l,X,u);else if(L==="composite")Q=2,B=Ve(Y.label,!1,l,X,n?Xt(r):4e3,V),le=B.height>0?B.height+4:0,K=B.width+2*h,ie=le+2*h;else if(L==="block_arrow"){Q=1,B=Ve(Y.label,!1,l,X,u,V);let ee=!0;for(let de of B.lines)for(let ye of de)(ye.icon!==void 0||ye.text.trim()!=="")&&(ee=!1);J=ME(Y.directions);let re=ee?B0(J,0,0):B0(J,B.width,B.height);K=re.w,ie=re.h,te=re.dx,ae=re.dy}else{ne=zE.get(L??"")??"rect",B=Ve(Y.label,!1,l,X,u,V);let ee=Jc(ne,B.width,B.height);K=ee.w,ie=ne==="cyl"?Math.max(ee.h,B.height+40):ee.h,ae=ee.dy}return{children:[],columns:Q===2?Y.columns??-1:-1,span:Q===3?1:Y.widthInColumns??1,space:Q===3,head:le,nw:K,nh:ie,col:0,row:0,cols:0,heights:LE,x:0,y:0,w:0,h:0,block:Y,kind:Q,index:D,shape:ne,label:B,style:F,mask:J,dx:te,dy:ae,bw:0,bh:0}},g=p(e.root,0);g.nw=0,g.nh=0;let m=[g],v=new Map;for(let Y=0;Y<m.length;Y++){let D=m[Y];if(D.kind===2)for(let L of D.block.children??OE){let F=p(L,m.length);D.children.push(F),m.push(F),F.kind!==3&&v.set(L.id,F)}}let x=CE(g,h),k=[];for(let Y of m)Y.kind===0&&FE.has(Y.shape)?(Y.bw=Y.nw,Y.bh=Y.nh):Y.kind===1?(Y.bw=Y.span>1?Y.w:Y.nw,Y.bh=Y.nh):(Y.bw=Y.w,Y.bh=Y.kind===0&&WE.has(Y.shape)?Y.nh:Y.h),Y.kind===0&&Y.shape==="cyl"&&(Y.dy=Math.min(12,Math.max(6,Y.bw/14))/2),(Y.kind===0||Y.kind===1)&&k.push(Y);let b=new Map,C=new Set,N=[],R=[];for(let Y of e.edges){let D=v.get(Y.start??""),L=v.get(Y.end??"");if(D===void 0||L===void 0)continue;let F=Math.min(D.index,L.index)*m.length+Math.max(D.index,L.index);b.set(F,(b.get(F)??0)+1),Y.label&&C.add(F),N.push([D,L]),R.push(Y)}let O=R.length*k.length<=PE?k:void 0,P=new Map,H=[],I=0,G=0,Z=x.width,z=x.height,W=(Y,D,L,F)=>{Y-L/2<I&&(I=Y-L/2),Y+L/2>Z&&(Z=Y+L/2),D-F/2<G&&(G=D-F/2),D+F/2>z&&(z=D+F/2)};for(let Y=0;Y<R.length;Y++){let[D,L]=N[Y],F=Math.min(D.index,L.index)*m.length+Math.max(D.index,L.index),V=b.get(F)??1,X=P.get(F)??0;P.set(F,X+1);let Q=Ve(R[Y].label,!1,l,a,H0),ne,B,K;if(D===L){let[ie,le,J]=ub(D,X+1);ne=[],W(ie,le,2*J+2,2*J+2),B=ie+J+6+Q.width/2,K=le-J/2}else{let ie=C.has(F)?Math.round(a*1.5)+2:14;ne=HE(D,L,(X-(V-1)/2)*ie,O);let le=ne.length,J=Math.abs(ne[2]-ne[0])+Math.abs(ne[3]-ne[1]),te=Math.abs(ne[le-2]-ne[le-4])+Math.abs(ne[le-1]-ne[le-3]),ae=le===6&&te>J?2:0,ee=Q.width>0?GE(ne,ae,Q.width+8,Q.height,D,L,O):.5;B=ne[ae]+(ne[ae+2]-ne[ae])*ee,K=ne[ae+1]+(ne[ae+3]-ne[ae+1])*ee}Q.width>0&&W(B,K,Q.width+8,Q.height),H.push({edge:R[Y],points:ne,loop:D===L?X+1:0,label:Q,lx:B,ly:K})}let S=Mn(e.title,l,i,n?Xt(r):4e3),A=S.height>0?S.height+12:0,$=Math.max(Z-I,S.width),y=s-I+($-(Z-I))/2,E=s+A-G;for(let Y of m)Y.x+=y,Y.y+=E;let w=Math.ceil($+2*s),T=Math.ceil(z-G+A+2*s),_="",M="";for(let Y=1;Y<m.length;Y++){let D=m[Y];if(D.kind===3)continue;let L=jt((D.block.classes??U0).join(" ")),F=Ge(D.block.id);if(D.kind===2){let X=D.y-D.h/2;_+=`<g class="pele-cluster${L}" data-id="${F}"><rect x="${f(D.x-D.w/2)}" y="${f(X)}" width="${f(D.w)}" height="${f(D.h)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${_t(D.style.shape)}/>`+Le(D.label,D.x,X+(D.head+h)/2+2,` class="pele-cluster-label" fill="var(--_m)"${D.style.text}`,o)+"</g>";continue}let V=D.kind===1;M+=`<g class="pele-node pele-shape-${V?"block-arrow":D.shape}${L}" data-id="${F}" transform="translate(${f(D.x)},${f(D.y)})">`+(V?_E(D.mask,D.bw,D.bh,j0+D.style.shape):_a(D.shape,D.bw,D.bh,j0+D.style.shape,RE+D.style.line))+Le(D.label,D.dx,D.dy,` class="pele-label"${D.style.text}`,o)+"</g>"}let U="",j="";for(let Y=0;Y<H.length;Y++){let{edge:D,points:L,loop:F,label:V}=H[Y],X=D.arrowTypeStart??"",Q=D.arrowTypeEnd??"",ne;if(F>0)ne=UE(N[Y][0],F,Et(X),Et(Q));else{for(let K=0;K<L.length;K+=2)L[K]+=y,L[K+1]+=E;ne=jE(L,Et(X),Et(Q))}let B=Ge(D.id);if(U+=`<g class="pele-edge" data-id="${B}"><path d="${ne.d}"${D.thickness==="thick"?' stroke-width="2.5"':""}${D.pattern==="dotted"?' stroke-dasharray="3 4"':""}/>`+Ct(X,ne.sx,ne.sy,ne.sdx,ne.sdy,"var(--_l)")+Ct(Q,ne.ex,ne.ey,ne.edx,ne.edy,"var(--_l)")+"</g>",V.width>0){let K=H[Y].lx+y,ie=H[Y].ly+E;j+=kn(D.id,V,K,ie,"",o)}}return{svg:mt("block",w,T,i,r,e,Le(S,w/2,s+S.height/2,' class="pele-title" font-weight="var(--_tw)"')+(_?`<g class="pele-clusters">${_}</g>`:"")+(U?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${U}</g>`:"")+`<g class="pele-nodes">${M}</g>`+(j?`<g class="pele-edge-labels" font-size="${a}">${j}</g>`:"")),width:w,height:T,links:[]}}var XE={type:"block",math:!0,parse(e,t,r){let n=new wE;return n.title=r,kE(e,n),n},render:VE},KE=new Set(["label","type","descr","techn","sprite","tags","link","bgColor","fontColor","borderColor","shadowing","shape","legendText","legendSprite"]),ZE=new Set(["label","descr","techn","sprite","tags","link","textColor","lineColor"]);function Ys(e,t){let{key:r,value:n}=t;"from"in e&&(r==="offsetX"||r==="offsetY")?e[r]=parseInt(n):("from"in e?ZE:KE).has(r)?e[r]=n:(e.extra??=new Map).set(r,n)}function Nt(e,t,r){r!==void 0&&(typeof r=="string"?e[t]=r:Ys(e,r))}function Vi(e,t,r){r===void 0?e[t]??="":Nt(e,t,r)}function G0(e,t){e.labelAttr=void 0,typeof t=="object"?(e.label="",e.labelAttr=t,Ys(e,t)):e.label=t??""}var QE=class{type="c4";c4Type;title;accTitle;accDescr;shapes=[];boundaries=[{alias:"global",label:"global",type:"global",parent:void 0}];rels=[];shapeInRow=4;boundaryInRow=2;shapeIndex=new Map;boundaryIndex=new Map;relIndex=new Map;current=this.boundaries[0];stack=[];setC4Type(e){this.c4Type=e}setTitle(e){this.title=e}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
69
+ `)}element(e,t,r,n){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,Ys(i,r))),G0(i,n),i}addPersonOrSystem(e,t){let r=this.element(this.shapes,this.shapeIndex,t[0],t[1]);Vi(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]);Vi(r,"techn",t[2]),Vi(r,"descr",t[3]),this.finishShape(r,e,t,4)}addComponent(e,t){this.addContainer(e,t)}finishShape(e,t,r,n){Nt(e,"sprite",r[n]),Nt(e,"tags",r[n+1]),Nt(e,"link",r[n+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:Nt(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);Nt(r,"tags",e[3]),Nt(r,"link",e[4]),this.open(r)}addContainerBoundary(e){this.addPersonOrSystemBoundary(e,"container")}addDeploymentNode(e,t){let r=this.boundary(t,"node");Vi(r,"descr",t[3]),Nt(r,"sprite",t[4]),Nt(r,"tags",t[5]),Nt(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],n=t[1];if(r===void 0||n===void 0||t[2]===void 0)return;let i=typeof r=="string"&&typeof n=="string",a=i?this.relIndex.get(r)?.get(n):void 0;if(a===void 0){if(a={type:e,from:"",to:"",label:""},this.rels.push(a),i){let l=this.relIndex.get(r);l===void 0&&this.relIndex.set(r,l=new Map),l.set(n,a)}typeof r=="string"?a.from=r:a.fromAttr=r,typeof n=="string"?a.to=n:a.toAttr=n}a.type=e,G0(a,t[2]),Vi(a,"techn",t[3]),Vi(a,"descr",t[4]),Nt(a,"sprite",t[5]),Nt(a,"tags",t[6]),Nt(a,"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&&(Nt(r,"bgColor",t[1]),Nt(r,"fontColor",t[2]),Nt(r,"borderColor",t[3]),Nt(r,"shadowing",t[4]),Nt(r,"shape",t[5]),Nt(r,"sprite",t[6]),Nt(r,"techn",t[7]),Nt(r,"legendText",t[8]),Nt(r,"legendSprite",t[9]))}updateRelStyle(e,t){let r=t[0],n=t[1],i=typeof r=="string"&&typeof n=="string"?this.relIndex.get(r)?.get(n):void 0;if(i===void 0)return;Nt(i,"textColor",t[2]),Nt(i,"lineColor",t[3]);let a=t[4],l=t[5];typeof a=="string"?i.offsetX=parseInt(a):a!==void 0&&Ys(i,a),typeof l=="string"?i.offsetY=parseInt(l):l!==void 0&&Ys(i,l)}updateLayoutConfig(e,t){let r=a=>a===void 0?NaN:parseInt(typeof a=="string"?a:a.value),n=r(t[0]),i=r(t[1]);n>=1&&(this.shapeInRow=n),i>=1&&(this.boundaryInRow=i)}},V0=["$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"],JE=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]]),kh=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y],Mh=/[\n\r\u2028\u2029]/g;function eA(e){let t=e.length,r=[],n=[],i=[],a=0,l=9,s=0,o=!1,c=-2,h=-1,u=0,d=(v,x,k)=>{r.push(v),n.push(x),i.push(k),s=k},p=v=>{for(;v<t&&Xe(e.charCodeAt(v));)v++;return v},g=(v,x)=>{let k=e.indexOf(v,x);return k===-1?t:k},m=(v,x)=>{let k=s+v.length;if(!e.startsWith(v,s)||!Xe(e.charCodeAt(k)))return!1;let b=++k;for(;k<t;){let C=e.charCodeAt(k);if(C===35||C===10||C===59)break;k++}return k===b?!1:(d(x,s,k),!0)};for(;;){if(o){d(0,t,t);break}s>=t&&(o=!0);let v=e.charCodeAt(s);if(a===0){if(s>=t){d(64,t,t);continue}if(c!==-1&&s>=u&&(c<s&&(c=e.indexOf("direction",s)),c!==-1&&(h<s&&(Mh.lastIndex=s,h=Mh.test(e)?Mh.lastIndex-1:t),c<h))){let x=!1;for(let k=0;k<4&&!x;k++)kh[k].lastIndex=s,kh[k].test(e)&&(d(2+k,s,kh[k].lastIndex),x=!0);if(x)continue;u=h}if(v===116&&m("title",6))continue;if(v===97){if(m("accDescription",7))continue;let x=e.startsWith("accTitle",s);if(x||e.startsWith("accDescr",s)){let k=p(s+8),b=e.charCodeAt(k);if(b===58){d(x?8:10,s,p(k+1)),l=x?9:11,a=7;continue}if(b===123&&!x){s=p(k+1),a=8;continue}}}if(v===37&&e.charCodeAt(s+1)===37){let x=g(`
70
+ `,s+2);for(;x<t&&(e.charCodeAt(x)===10||e.charCodeAt(x)===13);)x++;s=x;continue}if(Xe(v)){let x=s,k=-1;for(;x<t;){let b=e.charCodeAt(x);if(!Xe(b))break;b===10&&(k=x),x++}k!==-1?d(13,s,k+1):s=x;continue}if(v===123){d(62,s,s+1);continue}if(v===125){d(63,s,s+1);continue}if(nt(v)){let x=s+1;for(;x<t&&nt(e.charCodeAt(x));)x++;let k=x-s<=19?JE.get(e.slice(s,x)):void 0;if(k!==void 0){k>18&&(a=1),d(k,s,x);continue}}d(1,s,s);break}if(a===1){if(s>=t)d(57,t,t);else if(v===40){let x=s+1;for(;e.charCodeAt(x)===32;)x++;e.charCodeAt(x)===44?d(58,s,x+1):s++,a=2}else if(v===41)s++,a=0;else{d(1,s,s);break}continue}if(a===2){if(s>=t)continue;if(v===41)s++,a=0;else if(v===44)e.charCodeAt(s+1)===44?d(58,s,s+2):s++;else{let x=s;for(;e.charCodeAt(x)===32;)x++;let k=e.charCodeAt(x);k===34?e.charCodeAt(x+1)===34?d(58,s,x+2):(s=x+1,a=3):k===36?(s=x+1,a=4):d(59,s,g(",",s))}continue}if(a===3){v===34?(s++,a=2):d(59,s,g('"',s));continue}if(a===4){d(60,s,g("=",s)),a=5;continue}if(a===5){if(s>=t)continue;let x=s+1;if(v===61)for(;e.charCodeAt(x)===32;)x++;if(v!==61||e.charCodeAt(x)!==34){d(1,s,s);break}s=x+1,a=6;continue}if(a===6){if(s>=t)continue;v===34?(s++,a=2):d(61,s,g('"',s));continue}if(a===7){d(l,s,g(`
71
+ `,s)),a=0;continue}v===125?(s++,a=0):d(12,s,g("}",s))}return{types:r,starts:n,ends:i}}var _h=["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"],tA=["rel","birel","rel_u","rel_d","rel_l","rel_r","rel_b","rel"],rA=["node","nodeL","nodeR"],nA="'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'C4_CONTEXT', 'C4_CONTAINER', 'C4_COMPONENT', 'C4_DYNAMIC', 'C4_DEPLOYMENT'",iA="'STR', 'STR_KEY', 'ATTRIBUTE', 'ATTRIBUTE_EMPTY'";function aA(e){return e===6||e===7||e===8||e===10||e===12}function q0(e){return e>=19&&e<=56}function sA(e,t){let{types:r,starts:n,ends:i}=eA(e),a=0,l=m=>e.slice(n[m],i[m]),s=m=>{let v=r[a];throw v===1?vt("c4",e,n[a],"",!0):vt("c4",e,n[a],`Expecting ${m}, got '${V0[v]}'`)},o=m=>{r[a]!==m&&s(`'${V0[m]}'`),a++},c=()=>{let m=[];for(;;){let v=r[a];if(v===59)m.push(l(a++).trim());else if(v===58)m.push(""),a++;else if(v===60)a++,r[a]!==61&&s("'STR_VALUE'"),m.push({key:l(a-1).trim(),value:l(a).trim()}),a++;else break}return m.length===0&&s(iA),m},h=m=>{m===6?t.setTitle(l(a++).substring(6)):m===7?t.setAccDescription(l(a++).substring(15)):m===12?t.setAccDescription(l(a++).trim()):(a++,m===8?(r[a]!==9&&s("'acc_title_value'"),t.setTitle(l(a++).trim())):(r[a]!==11&&s("'acc_descr_value'"),t.setAccDescription(l(a++).trim())))},u=m=>{a++;let v=c();if(m<=26)t.addPersonOrSystem(_h[m-19],v);else if(m<=32)t.addContainer(_h[m-19],v);else if(m<=38)t.addComponent(_h[m-19],v);else{if(m<=45)return m===39?v.splice(2,0,"ENTERPRISE"):m===40?v.splice(2,0,"SYSTEM"):m===42&&v.splice(2,0,"CONTAINER"),m>=43?t.addDeploymentNode(rA[m-43],v):m===42?t.addContainerBoundary(v):t.addPersonOrSystemBoundary(v),r[a]===62?(a++,o(13)):r[a]===13?(a++,o(62),r[a]===13&&a++):s("'NEWLINE', 'LBRACE'"),!0;m<=53?(m===53&&v.splice(0,1),t.addRel(tA[m-46],v)):m===54?t.updateElStyle("update_el_style",v):m===55?t.updateRelStyle("update_rel_style",v):t.updateLayoutConfig("update_layout_config",v)}return!1},d=r[a];(d<14||d>18)&&s(nA),a++,o(13);let p=0,g=0;for(;;){let m=r[a];if(g===3||g===4){if(m===13){a++,g=2;continue}if(g===3&&q0(m)){g=1;continue}}else if(q0(m)){u(m)?(p++,g=1):g=4;continue}else if(aA(m)&&g!==1){h(m),g=3;continue}else g!==2&&s("'title', 'accDescription', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'PERSON', 'REL'");if(p>0)m!==63&&s("'NEWLINE', 'RBRACE'"),a++,t.popBoundaryParseStack(),p--,g=4;else{m!==64&&s("'NEWLINE', 'EOF'"),a++,o(0),t.setC4Type(l(0));return}}}var Eh=/\s/;function Rc(e,t,r,n,i=0){let a=[];for(let c of e.split(`
72
+ `)){let h=Array.from(c);h.length===0&&a.push("");let u=0;for(;u<h.length;){let d=k=>t.width(h.slice(u,u+k).join(""),r,i)<=n,p=1;for(;p<h.length-u&&d(p);)p=Math.min(h.length-u,p*2);let g=1;for(;g<p;){let k=Math.ceil((g+p)/2);d(k)?g=k:p=k-1}let m=g,v=u+m<h.length;if(v&&!Eh.test(h[u+m])){for(let k=m-1;k>0;k--)if(Eh.test(h[u+k])){m=k+1;break}}let x=h.slice(u,u+m).join("");for(a.push(v&&x.trimEnd()||x),u+=m;v&&u<h.length&&Eh.test(h[u]);)u++}}e===""&&(a.length=0);let l=a.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:a.map((c,h)=>[{text:c,style:i,width:l[h]}]),widths:l,width:s,height:a.length*o,size:r,lineHeight:o}}function Oc(e,t,r){if(e.width<=r)return e;let n=[],i=[];for(let s=0;s<e.lines.length;s++){if(e.widths[s]<=r){n.push(e.lines[s]),i.push(e.widths[s]);continue}let o=[],c=0,h=()=>{n.push(o),i.push(c),o=[],c=0};for(let u of e.lines[s]){if(u.icon!==void 0||u.math){o.length&&c+u.width>r&&h(),o.push(u),c+=u.width;continue}for(let d of Array.from(u.text)){let p=o[o.length-1],g=p&&p.icon===void 0&&p.math===void 0&&p.style===u.style,m=t.width(g?p.text+d:d,e.size,u.style)-(g?p.width:0);o.length&&c+m>r&&(h(),p=void 0,m=t.width(d,e.size,u.style)),p&&p.icon===void 0&&p.math===void 0&&p.style===u.style?(p.text+=d,p.width+=m):o.push({text:d,style:u.style,width:m}),c+=m}}(o.length||!e.lines[s].length)&&h()}let a=0;for(let s of i)a=Math.max(a,s);let l={...e,lines:n,widths:i,width:a,height:n.length*e.lineHeight};return e.heights?tp(l):l}function ba(e,t,r,n){let i=ll(e),a="<text"+Sa(n,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(u=>u.icon!==void 0)){let u=e.widths[s];l+=Le({...e,lines:[o],widths:[u],width:u,height:e.lineHeight},t+u/2,c,n);continue}let h="";for(let u of o){let d=ka(u.style&~i);h+=d?`<tspan${d}>${tt(u.text)}</tspan>`:tt(u.text)}h!==""&&(l+=`${a} x="${f(t)}" y="${f(c+e.size*.35)}" text-anchor="start" xml:space="preserve">${h}</text>`)}return l}var qi=28,rl=20,fb=7,lA=8,oA=30,mf=88,Lc=160,ip=26,pb=e=>Math.min(12,Math.max(6,e/14)),gb=e=>Math.min(12,e/4);function xi(e,t,r,n,i,a,l,s){let o=0,c=1;if(l===0){if(i<e||i>r)return 1/0}else{let h=(e-i)/l,u=(r-i)/l;o=Math.max(o,Math.min(h,u)),c=Math.min(c,Math.max(h,u))}if(s===0){if(a<t||a>n)return 1/0}else{let h=(t-a)/s,u=(n-a)/s;o=Math.max(o,Math.min(h,u)),c=Math.min(c,Math.max(h,u))}return o<=c?o:1/0}function ds(e,t,r,n,i,a,l,s){let o=l/r,c=s/n,h=(i-e)/r,u=(a-t)/n,d=o*o+c*c,p=2*(o*h+c*u),g=h*h+u*u-1,m=p*p-4*d*g;if(d===0||m<0)return 1/0;let v=(-p-Math.sqrt(m))/(2*d);return v>=0&&v<=1?v:g<=0?0:1/0}function mr(e,t,r,n,i){let{x:a,y:l,w:s,h:o}=e,c=n-t,h=i-r;if(e.form==="person")return Math.min(xi(a,l+ip,a+s,l+o,t,r,c,h),ds(a+s/2,l+14,13,13,t,r,c,h));if(e.form==="cyl"){let u=pb(s);return Math.min(xi(a,l+u,a+s,l+o-u,t,r,c,h),ds(a+s/2,l+u,s/2,u,t,r,c,h),ds(a+s/2,l+o-u,s/2,u,t,r,c,h))}if(e.form==="h-cyl"){let u=gb(o);return Math.min(xi(a+u,l,a+s-u,l+o,t,r,c,h),ds(a+u,l+o/2,u,o/2,t,r,c,h),ds(a+s-u,l+o/2,u,o/2,t,r,c,h))}return xi(a,l,a+s,l+o,t,r,c,h)}function mb(e,t,r,n,i){for(let a=2;a<e.length;a+=2){let l=e[a-2],s=e[a-1];if(xi(t,r,n,i,l,s,e[a]-l,e[a+1]-s)<=1)return!0}return!1}function Dc(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 cA(e,t,r){let n=e.x+e.w/2,i=e.y+e.h/2,a=t.x+t.w/2,l=t.y+t.h/2,s=Dc(e,t);if(s||Dc(t,e)){let N=s?e:t,R=s?t:e,O=R.x+R.w/2,P=R.y+R.h/2,H=R.x-N.x,I=N.x+N.w-R.x-R.w,G=R.y-N.y,Z=N.y+N.h-R.y-R.h,z=Math.min(H,I,G,Z),W=z===H?N.x:z===I?N.x+N.w:O,S=z===H||z===I?P:z===Z?N.y+N.h:N.y,A=Math.min(mr(R,W,S,O,P),1),$=W+(O-W)*A,y=S+(P-S)*A;return s?[W,S,$,y]:[$,y,W,S]}let o=n,c=i,h=a,u=l,d=Math.max(e.x,t.x),p=Math.min(e.x+e.w,t.x+t.w),g=Math.max(e.y,t.y),m=Math.min(e.y+e.h,t.y+t.h);d<p?o=h=(d+p)/2:g<m&&(c=u=(g+m)/2);let v=Math.hypot(h-o,u-c)||1,x=-(u-c)/v*r,k=(h-o)/v*r,b=mr(e,h+x,u+k,o+x,c+k),C=mr(t,o+x,c+k,h+x,u+k);return b<=1&&C<=1?(o+=x,c+=k,h+=x,u+=k):(o=n,c=i,h=a,u=l,b=Math.min(mr(e,h,u,o,c),1),C=Math.min(mr(t,o,c,h,u),1)),[h+(o-h)*b,u+(c-u)*b,o+(h-o)*C,c+(u-c)*C]}var yf=6,dA=3,X0=12,hA=class{upright=[];level=[];frames=[[],[]];taken=new Map;squeezed=0;free(e,t,r,n){let i=Math.min(r,n),a=Math.max(r,n),l=(s,o)=>{for(let c=0;c<s.length;c+=3)if(Math.abs(s[c]-t)<o&&s[c+1]<a&&s[c+2]>i)return!0;return!1};return!l(e?this.upright:this.level,yf)&&!l(this.frames[e?0:1],dA)}crossings(e){let t=0;for(let r=2;r<e.length;r+=2){let n=e[r]===e[r-2],i=n?e[r]:e[r+1],a=Math.min(n?e[r-1]:e[r-2],n?e[r+1]:e[r]),l=Math.max(n?e[r-1]:e[r-2],n?e[r+1]:e[r]),s=n?this.level:this.upright;for(let o=0;o<s.length;o+=3)s[o]>a&&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,n,i){let a=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)*X0;if(o<n||o>i)continue;let c=!0;for(let h=0;h<a.length;h+=2)a[h]===t&&Math.abs(a[h+1]-o)<X0&&(c=!1);c&&l.push(o)}return l.length?l:[r]}claim(e,t,r){let n=this.taken.get(e);n?n.push(t,r):this.taken.set(e,[t,r])}};function uA(e,t,r){let n=e.length,i=Math.sign(e[2]-e[0]),a=Math.sign(e[3]-e[1]),l=`M${f(e[0]+i*t)},${f(e[1]+a*t)}`;for(let c=2;c<n-2;c+=2){let h=e[c],u=e[c+1],d=Math.sign(h-e[c-2]),p=Math.sign(u-e[c-1]),g=Math.sign(e[c+2]-h),m=Math.sign(e[c+3]-u),v=Math.min(lA,Math.abs(h-e[c-2]+u-e[c-1])/2,Math.abs(e[c+2]-h+e[c+3]-u)/2);l+=`${d?"H"+f(h-d*v):"V"+f(u-p*v)}Q${f(h)},${f(u)} ${f(h+g*v)},${f(u+m*v)}`}let s=Math.sign(e[n-2]-e[n-4]),o=Math.sign(e[n-1]-e[n-3]);return l+(s?"H"+f(e[n-2]-s*r):"V"+f(e[n-1]-o*r))}function yb(e,t,r,n){for(let i of t)if(i!==r&&i!==n&&mb(e,i.x,i.y,i.x+i.w,i.y+i.h))return!1;return!0}function xb(e,t,r,n,i){let a=e.length;return{d:uA(e,r,n),sx:e[0],sy:e[1],sdx:-Math.sign(e[2]-e[0]),sdy:-Math.sign(e[3]-e[1]),ex:e[a-2],ey:e[a-1],edx:Math.sign(e[a-2]-e[a-4]),edy:Math.sign(e[a-1]-e[a-3]),x0:e[t],y0:e[t+1],x1:e[t+2],y1:e[t+3],nx:0,ny:0,lean:0,room:Lc,...i,points:e}}function K0(e,t){let r=[],n=(e+t)/2,i=Math.max(fb,(t-e)/4);for(let a=0;a<9;a++){let l=n+(a&1?1:-1)*Math.ceil(a/2)*i;l>=e+yf&&l<=t-yf&&r.push(l)}return r}function fA(e,t,r,n,i,a){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,h,u=(m,v,x)=>{if(!yb(m,r,e,t))return;for(let b=2;b<m.length;b+=2){let C=m[b]===m[b-2];if(!n.free(C,C?m[b]:m[b+1],C?m[b-1]:m[b-2],C?m[b+1]:m[b]))return}let k=n.crossings(m)*1e6;for(let b=2;b<m.length;b+=2)k+=Math.abs(m[b]-m[b-2])+Math.abs(m[b+1]-m[b-1]);(!h||k<h.cost)&&(h={points:m,cost:k,upright:v,sides:x})};if(e.x+e.w<=t.x||t.x+t.w<=e.x){let m=o>l,v=Math.sign(c-s),x=m?[1,0]:[0,1],k=K0(m?e.x+e.w:t.x+t.w,m?t.x:e.x);e:for(let b of n.ports(e,x[0],s+v*e.h/4,e.y+8,e.y+e.h-8))for(let C of n.ports(t,x[1],c-v*t.h/4,t.y+8,t.y+t.h-8))for(let N of k){let R=N+(l-N)*Math.min(mr(e,N,b,l,b),1),O=N+(o-N)*Math.min(mr(t,N,C,o,C),1),P=h;if(u([R,b,N,b,N,C,O,C],!0,x),h!==P)break e}}if(e.y+e.h<=t.y||t.y+t.h<=e.y){let m=c>s,v=Math.sign(o-l),x=m?[3,2]:[2,3],k=K0(m?e.y+e.h:t.y+t.h,m?t.y:e.y);e:for(let b of n.ports(e,x[0],l+v*e.w/4,e.x+8,e.x+e.w-8))for(let C of n.ports(t,x[1],o-v*t.w/4,t.x+8,t.x+t.w-8))for(let N of k){let R=N+(s-N)*Math.min(mr(e,b,N,b,s),1),O=N+(c-N)*Math.min(mr(t,C,N,C,c),1),P=h;if(u([b,R,b,N,C,N,C,O],!1,x),h!==P)break e}}if(!h)return;let{points:d,upright:p,sides:g}=h;return n.take(d),n.claim(e,g[0],p?d[1]:d[0]),n.claim(t,g[1],p?d[7]:d[6]),xb(d,2,i,a,{room:p?mf:Lc})}function pA(e,t,r,n,i,a,l){if(e===t){let v=Math.min(e.h/2-4,10),x=Math.hypot(qi,v),k=e.x+e.w,b=e.y+e.h/2,C=qi/x,N=v/x;return{d:`M${f(k+C*a)},${f(b-v-N*a)}C${f(k+qi)},${f(b-v*2)} ${f(k+qi)},${f(b+v*2)} ${f(k+C*l)},${f(b+v+N*l)}`,sx:k,sy:b-v,sdx:-C,sdy:N,ex:k,ey:b+v,edx:-C,edy:-N,x0:k+qi+4,y0:b,x1:k+qi+4,y1:b,nx:1,ny:0,lean:0,room:64,points:[]}}let[s,o,c,h]=cA(e,t,r),u=s===c,d=!1;if(n&&!Dc(e,t)&&!Dc(t,e))for(let v of n)v!==e&&v!==t&&xi(v.x,v.y,v.x+v.w,v.y+v.h,s,o,c-s,h-o)<=1&&(d=!0);if(n&&d&&!u&&o!==h){let v=fA(e,t,n,i,a,l);if(v)return v;i.squeezed++}if(n&&d&&(u||o===h)){let v=M=>{let U=M?-1/0:1/0,j=Y=>{let D=u?Y.x:Y.y;U=M?Math.max(U,D+(u?Y.w:Y.h)):Math.min(U,D)};j(e),j(t);for(let Y of n)Y!==e&&Y!==t&&xi(Y.x,Y.y,Y.x+Y.w,Y.y+Y.h,s,o,c-s,h-o)<=1&&j(Y);return U},x=u?Math.min(e.y,t.y):Math.min(e.x,t.x),k=u?Math.max(e.y+e.h,t.y+t.h):Math.max(e.x+e.w,t.x+t.w),b=(M,U)=>{for(let j of n){if(j===e||j===t)continue;let Y=u?j.y<k&&j.y+j.h>x:j.x<k&&j.x+j.w>x,D=u?j.x:j.y,L=D+(u?j.w:j.h);if(Y&&(M?L>U:D<U))return!1}return!0},C=e.x+e.w/2,N=e.y+e.h/2,R=t.x+t.w/2,O=t.y+t.h/2,P=Math.sign(u?O-N:R-C),H=M=>{let U=v(M),j=M?1:-1,Y=u?M?1:0:M?3:2,D=u?i.ports(e,Y,N+P*e.h/4,e.y+8,e.y+e.h-8)[0]:i.ports(e,Y,C+P*e.w/4,e.x+8,e.x+e.w-8)[0],L=u?i.ports(t,Y,O-P*t.h/4,t.y+8,t.y+t.h-8)[0]:i.ports(t,Y,R-P*t.w/4,t.x+8,t.x+t.w-8)[0],F=X=>{if(u){let B=X+(C-X)*Math.min(mr(e,X,D,C,D),1),K=X+(R-X)*Math.min(mr(t,X,L,R,L),1);return[B,D,X,D,X,L,K,L]}let Q=X+(N-X)*Math.min(mr(e,D,X,D,N),1),ne=X+(O-X)*Math.min(mr(t,L,X,L,O),1);return[D,Q,D,X,L,X,L,ne]},V=F(U+j*rl);for(let X=0;X<=4;X++){let Q=U+j*(rl+X*fb),ne=F(Q);if(yb(ne,n,e,t)&&(V=ne,i.free(u,Q,D,L)))return{points:V,side:Y,p0:D,p1:L,step:X}}return{points:V,side:Y,p0:D,p1:L,step:5}},I=u?h>o:c<s,G=b(I,v(I)),Z=b(!I,v(!I)),z=H(I),W=G===Z?H(!I):void 0,S=M=>i.crossings(M.points)*8+M.step,A=Z&&!G||W&&S(W)<S(z)?!I:I,{points:$,side:y,p0:E,p1:w,step:T}=A===I?z:W??H(!I),_=A?1:-1;return T>4&&i.squeezed++,i.take($),i.claim(e,y,E),i.claim(t,y,w),xb($,2,a,l,u?{nx:_,lean:oA,room:mf}:{room:Lc})}let p=Math.hypot(c-s,h-o)||1,g=(c-s)/p,m=(h-o)/p;return(u||o===h)&&i.take([s,o,c,h]),{d:`M${f(s+g*a)},${f(o+m*a)}L${f(c-g*l)},${f(h-m*l)}`,sx:s,sy:o,sdx:-g,sdy:-m,ex:c,ey:h,edx:g,edy:m,x0:s,y0:o,x1:c,y1:h,nx:r?-m:0,ny:r?g:0,lean:0,room:Math.abs(g)>Math.abs(m)?mf:Lc,points:[s,o,c,h]}}var xf=216,gA=64,Z0=14,mA=12,yA=100,xA=88,Q0=rl+8,ao=48,Gs=16,bf=10,Ah=new Map([["person","person"],["box","rect"],["rounded","rect"],["component","rect"],["cylinder","cyl"],["database","cyl"],["db","cyl"],["queue","h-cyl"],["pipe","h-cyl"]]);function bA(e){let t=Ah.get((e.shape??"").toLowerCase())??Ah.get((e.sprite??"").toLowerCase());if(t)return t;if(e.tags)for(let n of e.tags.split(",")){let i=Ah.get(n.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 wA(e,t,r,n,i=xf){let a=bA(e),l=a==="h-cyl"?36:0,s=a==="person"?ip:a==="cyl"?24:0,o=i-2*Z0-l,c=[Ve("«"+e.kind.replace(/_/g," ")+"»",!1,t,n-1,o),Ve(e.label,!1,t,r,o,1),Ve(e.techn?`[${e.techn}]`:void 0,!1,t,n,o),Ve(e.descr,!1,t,n,o)],h=0,u=c[3].height>0?4:0;for(let d of c)h=Math.max(h,d.width),u+=d.height;return{shape:e,form:a,labels:c,textH:u,x:0,y:0,w:Math.max(i,h+2*Z0+l),h:Math.max(gA,u+2*mA+s)}}function J0(e,t,r,n,i){let a=0,l=0;for(let s=0;s<e.length;s+=t){let o=Math.min(e.length,s+t),c=0,h=0;for(let u=s;u<o;u++)h=Math.max(h,e[u].h);for(let u=s;u<o;u++){let d=e[u];d.x=c,d.y=l,i&&(d.h=h),c+=d.w+r}a=Math.max(a,c-r),l+=h+n}return[a,e.length>0?l-n:0]}function vA(e,t,r,n,i,a){let l=i===void 0?Q0:12,s=new Map;for(let m of e.boundaries){let v=i===void 0?4e3:Math.max(80,i-2*Gs-2*Q0*2),x=m.parent?[Ve(m.label,!1,t,r,v,1),Ve(m.type?`[${m.type}]`:void 0,!1,t,n,v),Ve(m.descr,!1,t,n,v)]:[],k=0,b=0;for(let C of x)k+=C.height,b=Math.max(b,C.width);s.set(m,{boundary:m,kids:[],nodes:[],labels:x,head:k>0?k+bf+6+rl:l,headW:b,headX:Gs,x:0,y:0,w:0,h:0,form:"rect"})}let o=s.get(e.boundaries[0]);for(let m of s.values()){let v=m.boundary.parent;v&&s.get(v)?.kids.push(m)}let c=[o],h=new Map([[o.boundary,0]]);for(let m=0;m<c.length;m++)for(let v of c[m].kids)h.set(v.boundary,h.get(c[m].boundary)+1),c.push(v);for(let m of e.shapes)if(m.parent){let v=h.get(m.parent)??0,x=i===void 0?xf:Math.max(100,Math.min(xf,i-2*v*l-32));s.get(m.parent)?.nodes.push(wA(m,t,r,n,x))}let u=Math.max(1,e.shapeInRow),d=Math.max(1,e.boundaryInRow),p=new Map;for(let m=c.length-1;m>=0;m--){let v=c[m],x=i===void 0?yA:a,k=(H,I,G)=>{if(i===void 0)return I;let Z=1;for(let z of H)Z=Math.max(Z,z.w);return Math.max(1,Math.min(I,Math.floor((i+G-2*l)/(Z+G))))},[b,C]=J0(v.nodes,k(v.nodes,u,x),x,xA,!0),[N,R]=J0(v.kids,k(v.kids,d,ao),ao,ao,!1),O=C>0&&R>0?ao:0,P=v===o?0:l;p.set(v,C+O),v.w=Math.max(b,N,v.headW+2*Gs-2*P)+2*P,v.h=(P&&v.head)+C+O+R+P}let g=new Map;for(let m of c){let v=m.x+(m===o?0:l),x=m.y+(m===o?0:m.head);for(let k of m.nodes)k.x+=v,k.y+=x,g.set(k.shape,k);for(let k of m.kids)k.x+=v,k.y+=x+p.get(m);m!==o&&g.set(m.boundary,m)}return{order:c,boxes:g}}var $A=7,cc=36,Th=24,e1=2e3,so=8,kA=[.5,.4,.6,.3,.7,.2,.8],MA=2e6;function lo(e,t,r){let n=[];return e&&n.push("fill:"+e),t&&n.push("stroke:"+t),r&&n.push("color:"+r),Ot(n)}function Sh(e,t,r,n,i){return t?Na(e,Ca(t.includes("¶ß")?t.replace(/\ufb02\u00b0\u00b0?/g,"#").replace(/\u00b6\u00df/g,";"):t),r,n,i):e}function _A(e,t,r){return Yn(r,n=>{if(!n)return Ch(e,t,r,!1)[0];let[i,a]=Ch(e,t,r,!0,cc);for(let l=cc+Th;a>0&&l<=cc+3*Th;l+=Th){let[s,o]=Ch(e,t,r,!0,l);o<a&&([i,a]=[s,o])}return i})}function Ch(e,t,r,n,i=cc){let a=r.fontSize??16,l=Math.round(a*.8125),s=r.measurer??bt(r.fontFamily),o=r.padding??8,c=[],{order:h,boxes:u}=vA(e,s,a,l,n?Math.max(80,(r.maxWidth??320)-2*o):void 0,i),d=h[0],p=0,g=0,m=d.w,v=d.h,x=(M,U,j,Y)=>{p=Math.min(p,M),g=Math.min(g,U),m=Math.max(m,j),v=Math.max(v,Y)},k=[],b=new Map;for(let M of e.rels){let U=M.fromAttr?void 0:e.getC4Shape(M.from),j=M.toAttr?void 0:e.getC4Shape(M.to),Y=U&&u.get(U),D=j&&u.get(j);if(!Y||!D)throw new Je(`C4 rel "${M.from}" -> "${M.to}" references an unknown shape or boundary`,"semantic",{type:"c4"});k.push(Y,D);let L=b.get(Y);L||b.set(Y,L=new Set),L.add(D)}let C=[],N=[];for(let M of h)for(let U of M.nodes)C.push(U),N.push(U.x+so,U.y+so,U.x+U.w-so,U.y+U.h-so);let R=e.rels.length*(C.length+h.length+3*e.rels.length)<=MA,O=(M,U,j,Y)=>{let D=0;for(let L=0;L<N.length;L+=4){let F=Math.min(j,N[L+2])-Math.max(M,N[L]);if(F<=0)continue;let V=Math.min(Y,N[L+3])-Math.max(U,N[L+1]);V>0&&(D+=F*V)}return D},P=M=>M?Math.max(-e1,Math.min(e1,M)):0,H="",I=Et("arrow_point"),G=new hA;for(let M of h)M!==d&&G.frame(M);let Z=e.rels.map((M,U)=>{let j=k[U*2],Y=k[U*2+1],D=lo(void 0,M.lineColor,void 0),L=D.stroke?tt(D.stroke):"var(--_l)",F=M.type==="birel"||M.type==="rel_b",V=M.type!=="rel_b",X=j!==Y&&b.get(Y)?.has(j)===!0,Q=pA(j,Y,X?$A:0,R?C:void 0,G,F?I:0,V?I:0);return x(Math.min(Q.x0,Q.x1),Math.min(Q.y0,Q.y1),Math.max(Q.x0,Q.x1),Math.max(Q.y0,Q.y1)),F&&R&&N.push(Q.sx-Rt,Q.sy-Rt,Q.sx+Rt,Q.sy+Rt),V&&R&&N.push(Q.ex-Rt,Q.ey-Rt,Q.ex+Rt,Q.ey+Rt),H+=`<g class="pele-edge" data-id="${Ge(M.from+"-"+M.to)}"${D.line}><path d="${Q.d}"/>`+(F?Ct("arrow_point",Q.sx,Q.sy,Q.sdx,Q.sdy,L):"")+(V?Ct("arrow_point",Q.ex,Q.ey,Q.edx,Q.edy,L):"")+"</g>",Q});for(let M of h){if(!R||M.headW===0)continue;let U=M.y+bf,j=M.y+M.head-rl,Y=1/0;for(let D of[Gs,(M.w-M.headW)/2,M.w-Gs-M.headW]){let L=0;for(let F of Z)mb(F.points,M.x+D-4,U,M.x+D+M.headW+4,j)&&L++;if(L<Y&&(Y=L,M.headX=D),L===0)break}N.push(M.x+M.headX-4,U,M.x+M.headX+M.headW+4,j)}let z="";e.rels.forEach((M,U)=>{let j=Z[U],Y=M.from+"-"+M.to,D=lo(void 0,void 0,M.textColor),L=(e.c4Type==="C4Dynamic"?U+1+": ":"")+M.label,F=Ve(L,!1,s,l,j.room),V=Ve(M.techn?`[${M.techn}]`:void 0,!1,s,l,j.room,2),X=Math.max(F.width,V.width)+8,Q=F.height+V.height;if(Q===0)return;let ne=Math.abs(j.nx)*(X/2)+Math.abs(j.ny)*(Q/2)+2,B=j.lean?Math.max(0,Math.min(j.lean,ne-14)):ne,K=j.nx*B+(n?0:P(M.offsetX)),ie=j.ny*B+(n?0:P(M.offsetY)),le=.5;if(R){let ae=1/0,ee=K!==j.nx*B||ie!==j.ny*B;for(let re=0;re<(ee?2:1)&&ae>0;re++){let de=re?j.nx*B:K,ye=re?j.ny*B:ie;for(let oe of kA){let xe=j.x0+(j.x1-j.x0)*oe+de,fe=j.y0+(j.y1-j.y0)*oe+ye,pe=O(xe-X/2,fe-Q/2,xe+X/2,fe+Q/2);if(pe<ae&&(ae=pe,le=oe,K=de,ie=ye),pe===0)break}}}let J=j.x0+(j.x1-j.x0)*le+K,te=j.y0+(j.y1-j.y0)*le+ie-Q/2;R&&N.push(J-X/2,te,J+X/2,te+Q),x(J-X/2,te,J+X/2,te+Q),z+=`<g class="pele-edge-label" data-id="${Ge(Y)}">`+(M.descr?`<title>${Ge(M.descr)}</title>`:"")+`<rect x="${f(J-X/2)}" y="${f(te)}" width="${f(X)}" height="${f(Q)}" rx="3" fill="var(--_bg)"/>`+Sh(Le(F,J,te+F.height/2,D.text)+Le(V,J,te+F.height+V.height/2,` class="pele-c4-techn" fill="var(--_m)"${D.text}`),M.link,Y,c,r)+"</g>"});let W="",S="";for(let M of h){if(M!==d){let U=M.boundary,j=lo(U.bgColor,U.borderColor,U.fontColor),Y=M.x+M.headX,D=M.y+bf,L=ba(M.labels[0],Y,D,` class="pele-cluster-label" font-weight="var(--_hw)"${j.text}`);D+=M.labels[0].height,L+=ba(M.labels[1],Y,D,` class="pele-c4-type" font-size="${l}" fill="var(--_m)"${j.text}`),D+=M.labels[1].height,L+=ba(M.labels[2],Y,D,` class="pele-c4-descr" font-size="${l}" fill="var(--_m)"${j.text}`),W+=`<g class="pele-cluster pele-c4-${U.nodeType?"node":"boundary"}" data-id="${Ge(U.alias)}"><rect x="${f(M.x)}" y="${f(M.y)}" width="${f(M.w)}" height="${f(M.h)}" fill="none" stroke="var(--_b)"${U.nodeType?"":' stroke-dasharray="6 4"'}${_t(j.shape)}/>`+Sh(L,U.link,U.alias,c,r)+"</g>"}for(let U of M.nodes){let j=U.shape,Y=j.kind.startsWith("external"),D=lo(j.bgColor,j.borderColor,j.fontColor),L=' stroke="var(--_b)"'+(Y?' stroke-dasharray="4 3"':""),{w:F,h:V,form:X,labels:Q}=U,ne=X==="h-cyl"?-gb(V)/2:0,B=X==="person"?ip/2:X==="cyl"?pb(F)/2:0,K=` fill="var(--_m)"${D.text}`,ie=B-U.textH/2,le=Le(Q[0],ne,ie+Q[0].height/2,` class="pele-c4-type" font-size="${l-1}"${K}`);ie+=Q[0].height,le+=Le(Q[1],ne,ie+Q[1].height/2,` class="pele-label" font-weight="var(--_hw)"${D.text}`),ie+=Q[1].height,le+=Le(Q[2],ne,ie+Q[2].height/2,` class="pele-c4-techn" font-size="${l}"${K}`),ie+=Q[2].height+4,le+=Le(Q[3],ne,ie+Q[3].height/2,` class="pele-c4-descr" font-size="${l}"${D.text}`),S+=`<g class="pele-node pele-shape-${X} pele-c4-${j.kind}${Y?" pele-c4-external":""}" data-id="${Ge(j.alias)}" transform="translate(${f(U.x+F/2)},${f(U.y+V/2)})">`+Sh(_a(X,F,V,` fill="var(${Y?"--_bg":"--_s"})"${L}${D.shape}`,L+D.line)+le,j.link,j.alias,c,r)+"</g>"}}let A=Ve(e.title,!1,s,a,n?Xt(r):4e3,1),$=A.height>0?A.height+12:0,y=Math.max(m-p,A.width),E=Math.ceil(y+2*o),w=Math.ceil(v-g+$+2*o),T=o-p+(y-(m-p))/2,_=o+$-g;return[{svg:mt("c4",E,w,a,r,e,Le(A,E/2,o+A.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${f(T)},${f(_)})">`+(W?`<g class="pele-clusters">${W}</g>`:"")+(H?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${H}</g>`:"")+(S?`<g class="pele-nodes">${S}</g>`:"")+(z?`<g class="pele-edge-labels" font-size="${l}">${z}</g>`:"")+"</g>"),width:E,height:w,links:c},G.squeezed]}var EA={type:"c4",parse(e,t,r){let n=new QE;return r&&(n.title=r),sA(e,n),n},render:_A};function wf(e){let t=0;for(let r=e.indexOf("~");r!==-1;r=e.indexOf("~",r+1))t++;return t}function AA(e){let t=wf(e);if(t<=1)return e;let r=t%2!==0&&e.startsWith("~"),n=e.split(""),i=[];for(let a=r?1:0;a<n.length;a++)n[a]==="~"&&i.push(a);for(let a=0,l=i.length-1;a<l;a++,l--)n[i[a]]="<",n[i[l]]=">";return n.join("")}function Vs(e){if(!e.includes("~"))return e;let t=e.split(/(,)/),r=[];for(let n=0;n<t.length;n++){let i=t[n];i===","&&n>0&&n+1<t.length&&wf(t[n-1])===1&&wf(t[n+1])===1&&(i=t[n-1]+","+t[n+1],n++,r.pop()),r.push(AA(i))}return r.join("")}function t1(e){return e==="#"||e==="+"||e==="~"||e==="-"}var r1=class{id="";memberType;visibility="";classifier="";parameters="";returnType="";constructor(e,t){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 n=r;for(;n<t&&!_c(e.charCodeAt(n));)n++;let i=n-1;for(;i>r&&e.charCodeAt(i)!==41;)i--;let a=i-1;for(;a>r&&e.charCodeAt(a)!==40;)a--;if(a>r){let l=e[r],s=t1(l)&&a>r+1;s&&(this.visibility=l),this.id=e.slice(s?r+1:r,a),this.parameters=e.slice(a+1,i).trim();let o=i+1,c="";if(o<t){let u=e[o];(u==="$"||u==="*"||u.trim()==="")&&(c=u.trim(),o++)}let h=o;for(;h<t&&!_c(e.charCodeAt(h));)h++;if(this.returnType=e.slice(o,h).trim(),c===""){let u=this.returnType.slice(-1);(u==="$"||u==="*")&&(c=u,this.returnType=this.returnType.slice(0,-1))}return this.classifier=c,!0}r=n+1}return this.memberType="attribute",!1}parseAttribute(e){let t=e.slice(0,1),r=e.slice(-1);t1(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+Vs(this.id);return this.memberType==="method"&&(e+=`(${Vs(this.parameters.trim())})`,this.returnType&&(e+=" : "+Vs(this.returnType))),{displayText:e.trim(),cssStyle:this.parseClassifier()}}parseClassifier(){return this.classifier==="*"?"font-style:italic;":this.classifier==="$"?"text-decoration:underline;":""}},TA={LINE:0,DOTTED_LINE:1},qs={AGGREGATION:0,EXTENSION:1,COMPOSITION:2,DEPENDENCY:3,LOLLIPOP:4},SA="classId-";function Dn(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 n1(e){let t=e.charCodeAt(0);return Dn(t>=48&&t<=57?SA+e:e).className}var CA=class{type="class";lineType=TA;relationType=qs;direction="TB";classes=new Map;relations=[];notes=new Map;namespaces=new Map;interfaces=[];styleClasses=new Map;title;accTitle;accDescr;namespaceStack=[];withCssClass=new Map;addClass(e){let{className:t,type:r}=Dn(e);if(this.classes.has(t))return;let n={id:t,type:r,label:t,cssClasses:"default",methods:[],members:[],annotations:[],styles:[]};this.classes.set(t,n),this.tag(n,"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(Dn(e).className)}setClassLabel(e,t){this.ensure(e).label=t}addRelation(e){let{type1:t,type2:r}=e.relation;t===qs.LOLLIPOP&&r==="none"?(this.addClass(e.id2),e.id1=this.addInterface(e.id1,e.id2)):r===qs.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=Dn(e.id1).className,e.id2=Dn(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 n=t.trim();if(n.startsWith("<<")&&n.endsWith(">>"))r.annotations.push(n.substring(2,n.length-2));else if(n.indexOf(")")>0){let i=new r1(n,"method");(i.memberType==="method"?r.methods:r.members).push(i)}else n&&r.members.push(new r1(n,"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,n=`note${r}`;return this.notes.set(n,{id:n,class:t,text:e,index:r}),n}cleanupLabel(e){return(e.startsWith(":")?e.substring(1):e).trim()}setCssClass(e,t){for(let r of e.split(",")){let n=this.classes.get(n1(r));if(n!==void 0){n.cssClasses+=" "+t;for(let i of t.split(" "))this.tag(n,i)}}}defineClass(e,t){for(let r of e){let n=this.styleClasses.get(r);if(n===void 0&&(n={id:r,styles:[],textStyles:[]},this.styleClasses.set(r,n)),!t)continue;for(let l of t)l.includes("color")&&n.textStyles.push(l.replace("fill","bgFill")),n.styles.push(l);let i=this.withCssClass.get(r);if(i===void 0)continue;let a=t.flatMap(l=>l.split(","));for(let l of i)for(let s of a)l.styles.push(s)}}setTooltip(e,t){if(t!==void 0)for(let r of e.split(",")){let n=this.classes.get(Dn(r).className);n&&(n.tooltip=t)}}setLink(e,t,r){let n=It(t).trim();for(let i of e.split(",")){let a=this.classes.get(n1(i));a&&(a.link=n?Ca(n):void 0,a.linkTarget=typeof r=="string"?r:"_blank")}this.setCssClass(e,"clickable")}setClickEvent(e,t,r){for(let n of e.split(",")){let i=this.classes.get(Dn(n).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,`
73
+ `)}addNamespace(e,t){let r=this.namespaceStack[this.namespaceStack.length-1],n=r?`${r}.${e}`:e;this.namespaceStack.push(n);let i=this.namespaces.get(n);if(i)return i.explicit=!0,t&&(i.label=t),n;let a=r||void 0,l=r?r.length+1:0;for(;;){let s=n.indexOf(".",l),o=s===-1,c=o?n:n.slice(0,s),h=this.namespaces.get(c);if(h===void 0){let d=n.slice(l,o?n.length:s);h={id:c,label:o&&t?t:d,classes:new Map,notes:new Map,children:new Map,parent:a,explicit:o},this.namespaces.set(c,h)}else o&&(h.explicit=!0);let u=a?this.namespaces.get(a):void 0;if(u&&(u.children.has(c)||u.children.set(c,h),h.parent??=a),o)return n;a=c,l=s+1}}popNamespace(){this.namespaceStack.pop()}addClassesToNamespace(e,t,r){let n=this.namespaces.get(e);if(n!==void 0){for(let i of t){let{className:a}=Dn(i),l=this.classes.get(a);l!==void 0&&(l.parent=e,n.classes.set(a,l))}for(let i of r){let a=this.notes.get(i);a!==void 0&&(a.parent=e,n.notes.set(i,a))}}}setCssStyle(e,t){let r=this.classes.get(e);if(!(!t||!r))for(let n of t)for(let i of n.split(","))r.styles.push(i)}},i1=["$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"],IA=[4,6,4,9,44,45,12,14,15,4,56,4,56],NA=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y],Ih=/[\n\r\u2028\u2029]/g;function RA(e){let t=e.length,r=[],n=[],i=[],a=[],l=0,s=0,o=e.indexOf("direction"),c=-1,h=0,u=(R,O,P)=>(r.push(R),n.push(e.slice(O,P)),i.push(O),s=P,!0),d=R=>{a.push(l),l=R},p=()=>{a.length>0&&(l=a.pop())},g=R=>e.startsWith(R,s)&&!nt(e.charCodeAt(s+R.length)),m=R=>{for(;R<t&&Xe(e.charCodeAt(R));)R++;return R},v=R=>{let O=e.indexOf(R,s);return O===-1?t:O},x=R=>{let O=s,P=-1;for(let H=e.charCodeAt(O);O<t&&Xe(H);H=e.charCodeAt(++O))H===10&&(P=O);if(P<0){s=O;return}R&&p(),u(3,s,P+1)},k=R=>{switch(R){case 99:if(g("cssClass"))return u(48,s,s+8);if(g("callback"))return u(40,s,s+8);if(g("click"))return u(43,s,s+5);break;case 108:if(g("link"))return u(41,s,s+4);break;case 110:if(g("note for"))return u(24,s,s+8);if(g("note"))return u(25,s,s+4);break;case 60:if(e.charCodeAt(s+1)===60)return u(20,s,s+2);break;case 62:if(e.charCodeAt(s+1)===62)return u(21,s,s+2);break;case 104:if(g("href"))return u(46,s,s+4);break}return!1},b=R=>{if(k(R))return!0;let O=e.charCodeAt(s+1);switch(R){case 34:return d(1),s++,!0;case 126:return d(3),s++,!0;case 96:return d(2),s++,!0;case 95:if(g("_self"))return u(42,s,s+5);if(g("_blank"))return u(42,s,s+6);if(g("_parent"))return u(42,s,s+7);if(g("_top"))return u(42,s,s+4);break;case 60:return O===124?u(34,s,s+2):u(36,s,s+1);case 124:return O===62&&u(34,s,s+2);case 62:return u(36,s,s+1);case 42:return u(35,s,s+1);case 111:if(!nt(O))return u(33,s,s+1);break;case 40:return O===41&&u(37,s,s+2);case 45:return O===45?u(38,s,s+2):u(52,s,s+1);case 46:return O===46?u(39,s,s+2):u(8,s,s+1);case 58:{let P=s+1;for(;P<t;){let H=e.charCodeAt(P);if(H===58||H===10||H===59)break;P++}return P>s+1?u(10,s,P):O===58&&e.charCodeAt(s+2)===58&&u(19,s,s+3)}case 43:return u(58,s,s+1);case 37:return u(51,s,s+1);case 61:return u(59,s,s+1);case 91:return u(5,s,s+1);case 93:return u(7,s,s+1);case 33:case 35:case 36:case 38:case 39:case 44:case 63:case 92:case 47:return u(60,s,s+1)}if(nt(R)){let P=s+1;for(;nt(e.charCodeAt(P));)P++;return u(27,s,P)}return Zf(R)&&u(53,s,s+1)},C=()=>{if(o===-1||s<h||(o<s&&(o=e.indexOf("direction",s)),o===-1)||(c<s&&(Ih.lastIndex=s,c=Ih.test(e)?Ih.lastIndex-1:t),o>=c))return!1;for(let R=0;R<4;R++){let O=NA[R];if(O.lastIndex=s,O.test(e))return u(29+R,s,O.lastIndex)}return h=c,!1},N=R=>{if(C())return!0;if(Xe(R))return x(!1),!0;switch(R){case 37:if(e.charCodeAt(s+1)===37){let O=v(`
74
+ `);for(;O<t&&(e.charCodeAt(O)===10||e.charCodeAt(O)===13);)O++;return s=O,!0}break;case 97:{let O=e.startsWith("accTitle",s);if(!O&&!e.startsWith("accDescr",s))break;let P=m(s+8),H=e.charCodeAt(P);if(H===58)return u(O?11:13,s,m(P+1)),d(O?6:7),!0;if(H===123&&!O)return s=m(P+1),d(8),!0;break}case 99:if(g("classDiagram-v2"))return u(2,s,s+15);if(g("classDiagram"))return u(2,s,s+12);if(e.startsWith("call",s)&&Xe(e.charCodeAt(s+4)))return s=m(s+4),d(4),!0;if(g("classDef"))return u(26,s,s+8);if(g("class"))return d(9),u(22,s,s+5);break;case 91:if(e.startsWith("*]",s+1))return u(55,s,s+3);break;case 115:if(g("style"))return u(47,s,s+5);break;case 110:if(g("namespace"))return d(11),u(18,s,s+9);break;case 44:return u(28,s,s+1);case 35:return u(50,s,s+1)}return b(R)||R===58&&u(49,s,s+1)};for(;;){if(s>=t){r.push(IA[l]),n.push(""),i.push(t);break}let R=e.charCodeAt(s),O=!0;switch(l){case 0:O=N(R);break;case 9:Xe(R)?x(!0):R===125?(p(),p(),u(17,s,s+1)):R===123?(d(10),u(16,s,s+1)):O=b(R);break;case 10:if(R===34)d(1),s++;else if(R===125)p(),u(17,s,s+1);else if(R===91&&e.startsWith("*]",s+1))u(55,s,s+3);else if(R===123)u(57,s,s+1);else if(R===10)s++;else{let P=s+1;for(;P<t;){let H=e.charCodeAt(P);if(H===123||H===125||H===10)break;P++}u(23,s,P)}break;case 11:Xe(R)?x(!0):R===123?(d(12),u(16,s,s+1)):R===125?p():R===110&&g("namespace")?(d(11),u(18,s,s+9)):O=b(R);break;case 12:Xe(R)?x(!1):R===125?(p(),u(17,s,s+1)):R===110&&g("namespace")?(d(11),u(18,s,s+9)):R===91&&e.startsWith("*]",s+1)?u(55,s,s+3):R===99&&g("class")?(d(9),u(22,s,s+5)):O=b(R);break;case 1:R===34?(p(),s++):u(6,s,v('"'));break;case 3:if(R===34)d(1),s++;else{if(k(R))break;R===126?(p(),s++):u(9,s,v("~"))}break;case 2:if(R===34)d(1),s++;else{if(k(R))break;R===126?(d(3),s++):R===96?(p(),s++):u(54,s,v("`"))}break;case 4:if(R===40){let P=m(s+1);p(),e.charCodeAt(P)===41?s=P+1:(d(5),s++)}else u(44,s,v("("));break;case 5:R===41?(p(),s++):u(45,s,v(")"));break;case 6:case 7:u(l===6?12:14,s,v(`
75
+ `)),p();break;case 8:R===125?(p(),s++):u(15,s,v("}"));break}if(!O)return r.push(1),n.push(""),i.push(s),{types:r,texts:n,starts:i}}return r.push(0),n.push(""),i.push(t),{types:r,texts:n,starts:i}}var ap=61,dc=new Uint8Array(ap);for(let e of[53,27,52])dc[e]=1;var vf=new Uint8Array(ap);for(let e of[27,49,50,47,51,10])vf[e]=1;var Mi=new Uint8Array(ap);Mi[33]=1;Mi[34]=2;Mi[35]=3;Mi[36]=4;Mi[37]=5;var OA="'UNICODE_TEXT', 'NUM', 'ALPHA', 'MINUS', 'BQUOTE_STR'";function LA(e,t){let{types:r,texts:n,starts:i}=RA(e),a=0,l=R=>{let O=r[a];throw O===1?vt("class",e,i[a],"",!0):vt("class",e,i[a],`Expecting ${R}, got '${i1[O]}'`)},s=R=>(r[a]!==R&&l(`'${i1[R]}'`),n[a++]),o=()=>(dc[r[a]]===0&&l("'UNICODE_TEXT', 'NUM', 'ALPHA', 'MINUS'"),n[a++]),c=R=>{let O="";for(;;){if(r[a]===54){O+=n[a++];break}dc[r[a]]===0&&l(OA),O+=n[a++];let P=r[a];if(P===8)O+=".",a++;else if(dc[P]===0&&P!==54)break}return R&&r[a]===9&&(O+="~"+n[a++]+"~"),O},h=()=>{a++;let R=s(6);return s(7),R},u=()=>{r[a]!==23&&l("'STRUCT_STOP', 'MEMBER'");let R=[];for(;r[a]===23;)R.push(n[a++]);return s(17),R.reverse()},d=()=>{a++;let R=c(!0);switch(t.addClass(R),r[a]===5&&t.setClassLabel(R,h()),r[a]){case 19:{a++;let O=o();t.setCssClass(R,O),r[a]===16&&(a++,t.addMembers(R,u()));break}case 16:a++,r[a]===17?a++:t.addMembers(R,u());break;case 20:{a++;let O=o();s(21),t.addAnnotation(R,O),r[a]===16&&(a++,r[a]===17?a++:t.addMembers(R,u()));break}}return R},p=()=>{if(r[a++]===25)return t.addNote(s(6));let R=c(!0);return t.addNote(s(6),R)},g=()=>{let R=[];for(;;){a++;let O=c(!1),P=r[a]===5?t.addNamespace(O,h()):t.addNamespace(O);s(16),r[a]===3&&a++,R.push({id:P,classes:[],notes:[]});let H=!0;for(;H;){let I=R[R.length-1],G=r[a];if(G===18)break;for(G===22?I.classes.push(d()):G===25||G===24?I.notes.push(p()):l("'NAMESPACE', 'CLASS', 'NOTE_FOR', 'NOTE'");;){if(r[a]===3){let z=r[a+1];if(z===18||z===22||z===25||z===24){a++;break}a++}s(17);let Z=R.pop();if(t.addClassesToNamespace(Z.id,Z.classes,Z.notes),t.popNamespace(),R.length===0){H=!1;break}}}if(R.length===0)return}},m=()=>{let R=Mi[r[a]];return R===0?"none":(a++,R-1)},v=()=>{let R=c(!0),O=r[a];if(O===10){t.addMember(R,t.cleanupLabel(n[a++]));return}let P="none";if(O===6)P=n[a++],O=r[a];else if(Mi[O]===0&&O!==38&&O!==39)return;let H=m();O=r[a],O!==38&&O!==39&&l("'AGGREGATION', 'EXTENSION', 'COMPOSITION', 'DEPENDENCY', 'LOLLIPOP', 'LINE', 'DOTTED_LINE'"),a++;let I=m(),G=r[a]===6?n[a++]:"none",Z=c(!0),z={id1:R,id2:Z,relation:{type1:H,type2:I,lineType:O===38?0:1},relationTitle1:P,relationTitle2:G};r[a]===10&&(z.title=t.cleanupLabel(n[a++])),t.addRelation(z)},x=()=>{let R=[];for(;;){vf[r[a]]===0&&l("'ALPHA', 'NUM', 'COLON', 'UNIT', 'SPACE', 'BRKT', 'STYLE', 'PCT', 'LABEL'");let O=n[a++];for(;vf[r[a]]===1;)O+=n[a++];if(R.push(O),r[a]!==28)return R;a++}},k=R=>{r[a]===6&&t.setTooltip(R,n[a++])},b=R=>{let O=s(6),P=r[a]===6?n[a++]:void 0;r[a]===42?t.setLink(R,O,n[a++]):t.setLink(R,O),P!==void 0&&t.setTooltip(R,P)},C=()=>{let R=r[a];switch(R){case 53:case 27:case 52:case 54:v();return;case 18:g();return;case 22:d();return;case 23:a++;return;case 20:{a++;let O=o();s(21),t.addAnnotation(c(!0),O);return}case 40:{a++;let O=c(!0);t.setClickEvent(O,s(6)),k(O);return}case 41:a++,b(c(!0));return;case 43:{a++;let O=c(!0);if(r[a]===46){a++,b(O);return}let P=s(44);r[a]===45?t.setClickEvent(O,P,n[a++]):t.setClickEvent(O,P),k(O);return}case 47:{a++;let O=s(27);t.setCssStyle(O,x());return}case 48:{a++;let O=s(6);t.setCssClass(O,s(27));return}case 25:case 24:p();return;case 26:{a++;let O=[s(27)];for(;r[a]===28;)a++,O.push(s(27));t.defineClass(O,x());return}case 29:case 30:case 31:case 32:a++,t.setDirection(R===29?"TB":R===30?"BT":R===31?"RL":"LR");return;case 11:a++,t.setAccTitle(s(12).trim());return;case 13:a++,t.setAccDescription(s(14).trim());return;case 15:t.setAccDescription(n[a++].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'")},N=r[a]===2;for(N&&(a++,s(3));C(),!(r[a]!==3||(a++,r[a]===4||r[a]===0)););N&&s(4),s(0)}var DA=["aggregation","extension","composition","dependency","lollipop"];function a1(e){return typeof e=="number"&&DA[e]||"none"}function PA(e,t=!0){let r=[],n=[],i=new Map,a=new Map,l=new Map,s=new Map,o=d=>{if(t||d===void 0)return d;let p=[],g=d,m;for(;g;){if(s.has(g)){m=s.get(g);break}let v=e.namespaces.get(g);if(v===void 0)break;if(v.explicit){m=g;break}p.push(g),g=v.parent}for(let v of p)s.set(v,m);return m},c=d=>d===void 0?-1:i.get(d)??-1;for(let d of e.namespaces.values())!t&&!d.explicit||(i.set(d.id,r.length),r.push({id:d.id,label:t?d.label:d.id,isGroup:!0,shape:"rect",parentId:t?d.parent:void 0,parent:-1}));for(let d of r)d.parent=c(d.parentId);let h=0;for(let d of e.classes.values()){let p=o(d.parent);a.set(d.id,r.length),r.push({id:d.id,label:d.label,isGroup:!1,shape:"classBox",parentId:p,parent:c(p),classNode:d,colorIndex:h++})}for(let d of e.notes.values()){let p=o(d.parent),g=d.class===void 0?void 0:a.get(d.class);g!==void 0&&n.push({id:`edgeNote${d.index}`,start:d.id,end:r[g].id,source:r.length,target:g,label:void 0,arrowTypeStart:"none",arrowTypeEnd:"none",startLabelRight:"",endLabelLeft:"",pattern:"dotted",classes:"relation"}),r.push({id:d.id,label:d.text,isGroup:!1,shape:"note",parentId:p,parent:c(p)})}for(let d of e.interfaces){let p=a.get(d.classId);l.set(d.id,r.length),r.push({id:d.id,label:d.label,isGroup:!1,shape:"interface",parentId:void 0,parent:p===void 0?-1:r[p].parent})}let u=0;for(let d of e.relations){u++;let{type1:p,type2:g}=d.relation,m=p===qs.LOLLIPOP&&g==="none"?l:a,v=m===a&&g===qs.LOLLIPOP&&p==="none"?l:a;n.push({id:`id_${d.id1}_${d.id2}_${u}`,start:d.id1,end:d.id2,source:m.get(d.id1)??-1,target:v.get(d.id2)??-1,label:d.title,arrowTypeStart:a1(p),arrowTypeEnd:a1(g),startLabelRight:d.relationTitle1==="none"?"":d.relationTitle1,endLabelLeft:d.relationTitle2==="none"?"":d.relationTitle2,pattern:d.relation.lineType===1?"dashed":"solid",classes:"relation"})}return{nodes:r,edges:n}}var $f=12,Rs=16,hs=6,hc=5;function s1(e){switch(e){case"extension":return $f;case"composition":case"aggregation":return Rs;case"lollipop":return 2*hc;case"dependency":return Et("arrow_point")}return 0}function l1(e,t,r,n,i,a){let l=-i,s=n;switch(e){case"extension":{let o=t-n*$f,c=r-i*$f;return`<path class="pele-marker" d="M${f(t)},${f(r)}L${f(o+l*hs)},${f(c+s*hs)}L${f(o-l*hs)},${f(c-s*hs)}Z" stroke-linejoin="round"/>`}case"composition":case"aggregation":{let o=t-n*Rs/2,c=r-i*Rs/2,h=hs-1;return`<path class="pele-marker" d="M${f(t)},${f(r)}L${f(o+l*h)},${f(c+s*h)}L${f(t-n*Rs)},${f(r-i*Rs)}L${f(o-l*h)},${f(c-s*h)}Z" stroke-linejoin="round"${e==="composition"?` fill="${a}"`:""}/>`}case"lollipop":return`<circle class="pele-marker" cx="${f(t-n*hc)}" cy="${f(r-i*hc)}" r="${hc}"/>`;case"dependency":return Ct("arrow_point",t,r,n,i,a)}return""}var zA=40,FA=16,o1=56,ii=20,c1=26,Nh=12,oo=8,d1=6,WA=10,BA=64,co=8,Rh="var(--_l)",HA=new Set(["_self","_blank","_parent","_top"]);function h1(e,t,r){let n=e[t];return typeof n=="number"&&n>0?Math.min(n,2e3):r}var ho=[],uo=[];function u1(e,t,r){let n=It(e.getDisplayDetails().displayText).trim();return{text:n,width:t.width(n,r,e.classifier==="*"?2:0),classifier:e.classifier}}function jA(e,t,r){let n=i=>Yn(r,a=>UA(e,t,r,i,a));return Ti(e.direction)?dr(r,n):n(!1)}function UA(e,t,r,n,i){let a=t.class??{},l=PA(e,a.hierarchicalNamespaces!==!1),s=a.hideEmptyMembersBox===!0,o=r.fontSize??16,c=Math.round(o*.875),h=Math.round(o*.8),u=Math.round(h*1.4),d=r.measurer??bt(r.fontFamily),p=r.padding??8,g=(ce,ge)=>{if(!ce.includes("$$"))return;let be=Ve(ce,!1,d,ge,4e3);return be.lines.some(rp)?be:void 0},m=ce=>ce?g(ce,h)?.width??d.width(It(ce),h,0):0,v=n?"TB":Pr(e.direction),x=new Map,k=new Map,b=new Map,C=ce=>{let ge=x.get(ce);if(ge===void 0){let be=Ot([ce]);ge=be.shape===""&&be.text===""?"":ce.slice(0,ce.indexOf(":")).trim().toLowerCase(),x.set(ce,ge)}ge!==""&&b.set(ge,ce)},N=ce=>{b.clear();let ge=k.get(ce.cssClasses);if(ge===void 0){for(let be of ce.cssClasses.split(" ")){let Ie=e.styleClasses.get(be);if(Ie)for(let Re of Ie.styles)for(let ze of Re.split(","))C(ze)}ge=[...b],k.set(ce.cssClasses,ge)}else for(let[be,Ie]of ge)b.set(be,Ie);for(let be of ce.styles)C(be);return Ot(b.size===0?uo:[...b.values()])},R=new Int32Array(l.nodes.length);for(let ce of l.nodes)ce.parent>=0&&R[ce.parent]++;let O=new Uint8Array(l.nodes.length);for(let ce of l.edges){if(ce.source<0||ce.target<0)continue;let ge=l.nodes[ce.source].parent,be=l.nodes[ce.target].parent;if(ge!==be){for(let Ie=ge;Ie>=0&&O[Ie]===0;Ie=l.nodes[Ie].parent)O[Ie]=1;for(let Ie=be;Ie>=0&&O[Ie]===0;Ie=l.nodes[Ie].parent)O[Ie]=1}}let P=[],H=[];l.nodes.forEach((ce,ge)=>{let be,Ie;if(ce.isGroup){let Re=Ve(ce.label,!1,d,o,4e3);be=I(ce,Re,0,0,o),R[ge]>0?(Ie=Bt(0,0),Ie.isGroup=!0,Ie.padX=ii,Ie.padTop=Re.height>0?Re.height+16:ii,Ie.padBottom=ii,Ie.minW=Re.width+2*ii-12+(O[ge]===1&&!i?Math.min(Re.width+24,240):0)):(be.w=Math.max(Re.width+2*ii,80),be.h=Re.height+2*ii,Ie=Bt(be.w,be.h))}else if(ce.classNode)be=G(ce,ce.classNode),Ie=Bt(be.w,be.h);else if(ce.shape==="note"){let Re=Ve(ce.label,!0,d,c,260);be=I(ce,Re,Math.max(Re.width+2*Nh,40),Re.height+2*oo,c),Ie=Bt(be.w,be.h)}else{let Re=Ve(ce.label,!1,d,c,200);be=I(ce,Re,Math.max(Re.width,12)+4,Math.max(Re.height,12),c),Ie=Bt(be.w,be.h)}Ie.parent=ce.parent,Ie.seq=ge,P.push(be),H.push(Ie)});function I(ce,ge,be,Ie,Re){return{node:ce,style:Ot(uo),label:ge,w:be,h:Ie,loops:0,annotations:uo,attributes:ho,methods:ho,titleH:0,attributesH:0,fontSize:Re}}function G(ce,ge){let be=N(ge),Ie=be.fontSize??o,Re=Math.round(Ie*.875),ze=Math.round(Re*1.5),he=ge.type?"&lt;"+Vs(ge.type).replace(/</g,"&lt;").replace(/>/g,"&gt;")+"&gt;":"",$e=Ve(ge.label+he,!1,d,Ie,4e3,1|(be.italic?2:0)),Se=ge.annotations.length>0?ge.annotations.map(ve=>g(`«${ve.trim()}»`,h)??`«${It(ve).trim()}»`):uo,we=ge.members.length>0?ge.members.map(ve=>u1(ve,d,Re)):ho,ke=ge.methods.length>0?ge.methods.map(ve=>u1(ve,d,Re)):ho,Ne=$e.width,Be=0;for(let ve of Se)Ne=Math.max(Ne,typeof ve=="string"?d.width(ve,h,0):ve.width),Be+=typeof ve=="string"?u:Math.max(u,ve.height);for(let ve of we)Ne=Math.max(Ne,ve.width);for(let ve of ke)Ne=Math.max(Ne,ve.width);let Pe=!(s&&we.length===0&&ke.length===0),q=ve=>Pe?ve>0?2*d1+ve*ze:WA:0,me=2*oo+Be+Math.max($e.height,Math.round(Ie*1.5)),se=q(we.length);return{node:ce,style:be,label:$e,w:Math.max(Ne+2*Nh,BA),h:me+se+q(ke.length),loops:0,annotations:Se,attributes:we,methods:ke,titleH:me,attributesH:se,fontSize:Ie}}let Z=[],z=[],W=[],S=[],A=[],$=new Float64Array(P.length*4),y=(ce,ge,be)=>{$[ce*4+ge]++,be>$[ce*4+ge+1]&&($[ce*4+ge+1]=be)};for(let ce of l.edges){if(ce.source<0||ce.target<0)continue;let ge=Ve(ce.label,!0,d,c,200),be=m(ce.startLabelRight),Ie=m(ce.endLabelLeft);ce.source===ce.target?(P[ce.source].loops++,H[ce.source].w+=2*(c1+(ge.width>0?ge.width+12:0))):(y(ce.source,0,be),y(ce.target,2,Ie)),S.push(be),A.push(Ie),z.push(ce),W.push(ge),Z.push({src:ce.source,dst:ce.target,minlen:1,labelW:ge.width>0?ge.width+12:0,labelH:ge.height>0?ge.height+4:0,route:[],labelX:0,labelY:0})}if(v==="TB"||v==="BT")for(let ce=0;ce<P.length;ce++){if(!P[ce].node.classNode)continue;let ge=0;for(let be=0;be<4;be+=2){let Ie=$[ce*4+be],Re=$[ce*4+be+1];Ie>1&&(ge=Math.max(ge,(Ie-1)*(Re>0?Re+24:14)+24))}ge=Math.min(ge,480),ge>P[ce].w&&(H[ce].w+=ge-P[ce].w,P[ce].w=ge)}let E=!1;for(let ce=0;ce<z.length&&!E;ce++)E=S[ce]>0||A[ce]>0;let w=0;if(v==="TB"||v==="BT"){let ce=ge=>ge?Math.max(u,g(ge,h)?.height??0):0;for(let ge of z)w=Math.max(w,ce(ge.startLabelRight)+ce(ge.endLabelLeft)-2*u)}let T=Ai(H,Z,v,{nodeSep:h1(a,"nodeSpacing",zA),edgeSep:FA,rankSep:h1(a,"rankSpacing",E?o1+16:o1)+w,portSep:20,apart:!0}),_=new Map,M=[],U=(ce,ge,be,Ie,Re)=>{let ze=ce.route,he=H[be],$e=wn(ze,ge,he);if($e<0)return;let Se=(he.w-P[be].w)/2;$e===1?ze[ge]-=Se:$e===3&&(ze[ge]+=Se);let we=$e&1,ke=ze[(ge===0?3:ge-3)+we],Ne=ke-ze[ge+we],Be={route:ze,at:ge,toward:ke,order:Re,room:Ie,side:$e,after:we?Ne>0:Ne>=0},Pe=be*4+$e,q=_.get(Pe);return q?q.push(Be):_.set(Pe,[Be]),Be},j=[],Y=[];for(let ce=0;ce<Z.length;ce++){let ge=Z[ce],be=ge.src!==ge.dst&&ge.route.length>=6;j.push(be?U(ge,0,ge.src,S[ce],ce):void 0),Y.push(be?U(ge,ge.route.length-3,ge.dst,A[ce],ce):void 0)}let D=(ce,ge,be)=>{for(let Ie=H[ce].parent,Re=0;Ie>=0&&Re<1e4;Ie=H[Ie].parent,Re++){let ze=H[Ie],he=Math.abs(ge-ze.x),$e=Math.abs(be-ze.y);if(Math.abs($e-ze.h/2)<.5&&he<=ze.w/2+.5||Math.abs(he-ze.w/2)<.5&&$e<=ze.h/2+.5)return!0}return!1},L=[];for(let[ce,ge]of _){if(ge.length<2)continue;let be=ce>>2,Ie=ce&1,Re=Ie?P[be].h:P[be].w;ge.sort((Se,we)=>Se.toward-we.toward||Se.order-we.order);let ze=0;for(let Se=0;Se+1<ge.length;Se++){let we=ge[Se],ke=ge[Se+1],Ne=Ie?20:24;we.room>0&&we.after&&(Ne+=Ie?u+6:we.room),ke.room>0&&!ke.after&&(Ne+=Ie?u+6:ke.room),L[Se]=Ne,ze+=Ne}let he=Math.min(1,(Re-24)/ze);if(he<=0)continue;let $e=(Ie?H[be].y:H[be].x)-ze*he/2;for(let Se=0;Se<ge.length;Se++){let{route:we,at:ke}=ge[Se],Ne=ke===0?3:-3,Be=ke+Ne,Pe=-1;for(let q=Be;q>=0&&q<we.length&&Math.abs(we[q+Ie]-we[Be+Ie])<.5;q+=Ne)if(D(be,we[q],we[q+1])){Pe=q;break}if(Pe>=0&&Math.abs(we[Be+Ie]-$e)<=24)for(let q=Be;q!==Pe+Ne;q+=Ne)we[q+Ie]=$e;we[ke+Ie]=$e,$e+=L[Se]*he}}let F=(ce,ge,be,Ie)=>{if(ge===void 0||be<=0)return;let Re=ge.side&1,ze=Ie?0:ce.length-3,he=ze+1-Re,$e=Math.abs(ce[(Ie?3:ze-3)+1-Re]-ce[he]),Se=Math.min(Re?be+10:u+6,$e*.35);if(Se<4)return;let we=[ce[ze],ce[ze+1],ce[ze+2]];we[1-Re]+=(ge.side===0||ge.side===3?-1:1)*Se,ce.splice(Ie?3:ze,0,we[0],we[1],we[2])};for(let ce=0;ce<Z.length;ce++)F(Z[ce].route,j[ce],S[ce],!0),F(Z[ce].route,Y[ce],A[ce],!1);let V=0,X=0,Q=T.width,ne=T.height,B=(ce,ge,be,Ie,Re,ze)=>{if(!ce)return;let he=g(ce,h),$e=he?Math.max(u,he.height):u,Se=be,we=Ie;Re&1?(Se+=(Re===3?-1:1)*(5+ge/2),we+=(ze?1:-1)*(7+$e/2)):(Se+=(ze?1:-1)*(9+ge/2),we+=(Re===0?-1:1)*(3+$e/2)),M.push({text:It(ce),math:he,x:Se,y:we}),V=Math.min(V,Se-ge/2),Q=Math.max(Q,Se+ge/2),X=Math.min(X,we-$e/2),ne=Math.max(ne,we+$e/2)},K=new Map,ie=new Int32Array(Z.length);for(let ce=0;ce<Z.length;ce++){let ge=Z[ce],be=z[ce],Ie=ge.route;if(ge.src===ge.dst){let Re=K.get(ge.src)??0;K.set(ge.src,Re+1),ie[ce]=Re;let ze=H[ge.src],he=P[ge.src],$e=ze.x+he.w/2,Se=Math.min(he.h/2-4,8+Re*6);B(be.startLabelRight,S[ce],$e,ze.y-Se,1,!1),B(be.endLabelLeft,A[ce],$e,ze.y+Se,1,!0)}else if(Ie.length>=6){let Re=Ie.length-3,ze=j[ce],he=Y[ce];B(be.startLabelRight,S[ce],Ie[0],Ie[1],ze?ze.side:2,ze?ze.after:!0),B(be.endLabelLeft,A[ce],Ie[Re],Ie[Re+1],he?he.side:0,he?he.after:!0)}}let le=p-V,J=p-X,te=Math.ceil(Q-V+2*p),ae=Math.ceil(ne-X+2*p),ee=[],re=new Map;if(l.nodes.length>0&&l.nodes[0].isGroup)for(let ce of Z)Ma(re,ce.route);let de="",ye="",oe="";for(let ce=0;ce<P.length;ce++){let ge=P[ce],be=H[ce],Ie=ge.node,Re=be.x+le,ze=be.y+J,he=Ge(Ie.id),$e=be.isGroup?be.w:ge.w,Se=be.isGroup?be.h:ge.h;if(Ie.isGroup){let ke=be.isGroup?Qc(be,ge.label.width,re,ii):be.x,Ne=ze-Se/2+8+ge.label.height/2,Be=' class="pele-cluster-label" fill="var(--_m)"',Pe=be.isGroup&&Zx(be,ge.label.width,ke,re);Pe&&(ye+=Qx(ge.label,ke+le,Ne,Be,he,l.nodes,ce)),de+=`<g class="pele-cluster pele-namespace" data-id="${he}"><rect x="${f(Re-$e/2)}" y="${f(ze-Se/2)}" width="${f($e)}" height="${f(Se)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${xt}/>`+(Pe?"":Le(ge.label,ke+le,Ne,Be))+"</g>";continue}let we=` transform="translate(${f(Re)},${f(ze)})"`;if(Ie.classNode)oe+=xe(ge,Ie.classNode,he,we);else if(Ie.shape==="note"){let ke=$e/2,Ne=-Se/2;oe+=`<g class="pele-node pele-note" data-id="${he}"${we}><path d="M${f(-ke)},${f(Ne)}H${f(ke-co)}L${f(ke)},${f(Ne+co)}V${f(-Ne)}H${f(-ke)}Z" fill="var(--_a)" stroke="var(--_b)" stroke-linejoin="round"/><path d="M${f(ke-co)},${f(Ne)}V${f(Ne+co)}H${f(ke)}" fill="none" stroke="var(--_b)" stroke-linejoin="round"/>`+Le(ge.label,0,0,` class="pele-label" font-size="${c}"`,r.icons)+"</g>"}else oe+=`<g class="pele-node pele-interface" data-id="${he}"${we}>`+Le(ge.label,0,0,` class="pele-label" font-size="${c}"`,r.icons)+"</g>"}function xe(ce,ge,be,Ie){let{w:Re,h:ze,style:he}=ce,$e=-Re/2,Se=-ze/2,we=Math.round(ce.fontSize*.875),ke=Math.round(we*1.5),Ne=`<rect x="${f($e)}" y="${f(Se)}" width="${f(Re)}" height="${f(ze)}" fill="var(--_s)" stroke="var(--_b)"${_t(he.shape)}/>`,Be=Se+ce.titleH,Pe=Be+ce.attributesH;if(ze>ce.titleH){let ve=he.stroke?` style="stroke:${tt(he.stroke)}"`:"";Ne+=`<path class="pele-divider" d="M${f($e)},${f(Be)}H${f(-$e)}M${f($e)},${f(Pe)}H${f(-$e)}" fill="none" stroke="var(--_b)"${ve}/>`}let q=Se+oo;for(let ve of ce.annotations)if(typeof ve=="string")Ne+=`<text class="pele-annotation" x="0" y="${f(q+u/2+h*.35)}" text-anchor="middle" font-size="${h}" fill="var(--_m)">${tt(ve)}</text>`,q+=u;else{let _e=Math.max(u,ve.height);Ne+=Le(ve,0,q+_e/2,` class="pele-annotation" font-size="${h}" fill="var(--_m)"`,r.icons),q+=_e}let me=ce.fontSize===o?"":` font-size="${f(ce.fontSize)}"`;Ne+=Le(ce.label,0,(q+Be-oo)/2,` class="pele-label"${me} font-weight="var(--_hw)"${he.text}`,r.icons);let se=(ve,_e,Te)=>{let Oe="",Ce=Te+d1+ke/2+we*.35;for(let He of ve){let Ee=He.classifier==="$"?` pele-static"${he.text?he.text.slice(0,-1)+'text-decoration:underline"':' style="text-decoration:underline"'}`:He.classifier==="*"?` pele-abstract" font-style="italic"${he.text}`:`"${he.text}`;Oe+=`<text class="pele-member pele-${_e}${Ee} x="${f($e+Nh)}" y="${f(Ce)}">${tt(He.text)}</text>`,Ce+=ke}return Oe};return(ce.attributes.length>0||ce.methods.length>0)&&(Ne+=`<g class="pele-members" font-size="${we}">${se(ce.attributes,"attribute",Be)}${se(ce.methods,"method",Pe)}</g>`),ge.tooltip&&(Ne=`<title>${Ge(ge.tooltip)}</title>`+Ne),ge.link&&(Ne=Na(Ne,ge.link,ge.id,ee,r,ge.linkTarget&&HA.has(ge.linkTarget)?` target="${ge.linkTarget}"`:"")),`<g class="pele-node pele-class${jt(ge.cssClasses.replace(/^default\s?/,""))}" data-id="${be}"${Ie}>${Ne}</g>`}let fe="",pe="";for(let ce=0;ce<Z.length;ce++){let ge=Z[ce],be=z[ce],Ie=W[ce],Re=be.arrowTypeStart,ze=be.arrowTypeEnd,he=s1(Re),$e=s1(ze),Se;if(ge.src===ge.dst){let ke=H[ge.src],Ne=P[ge.src],Be=ie[ce],Pe=ke.x+le+Ne.w/2,q=ke.y+J,me=Math.min(Ne.h/2-4,8+Be*6),se=c1+Be*8;Se={d:`M${f(Pe+he)},${f(q-me)}C${f(Pe+se+he)},${f(q-me)} ${f(Pe+se+$e)},${f(q+me)} ${f(Pe+$e)},${f(q+me)}`,sx:Pe,sy:q-me,sdx:-1,sdy:0,ex:Pe,ey:q+me,edx:-1,edy:0},ge.labelX=ke.x+Ne.w/2+se+4+ge.labelW/2,ge.labelY=ke.y}else{let ke=ge.route;for(let Ne=0;Ne<ke.length;Ne+=3)ke[Ne]+=le,ke[Ne+1]+=J;Se=jn(ke,void 0,he,$e)}let we=be.pattern==="dashed"?' stroke-dasharray="6 4"':be.pattern==="dotted"?' stroke-dasharray="2 4"':"";if(fe+=`<g class="pele-edge${be.pattern==="dotted"?" pele-note-edge":" pele-relation"}" data-id="${Ge(be.id)}"><path d="${Se.d}"${we}/>`+l1(Re,Se.sx,Se.sy,Se.sdx,Se.sdy,Rh)+l1(ze,Se.ex,Se.ey,Se.edx,Se.edy,Rh)+"</g>",Ie.width>0){let ke=ge.labelX+le,Ne=ge.labelY+J;pe+=kn(be.id,Ie,ke,Ne,"",r.icons)}}let Me="";for(let ce of M)Me+=ce.math?Le(ce.math,ce.x+le,ce.y+J,' class="pele-cardinality"',r.icons):`<text class="pele-cardinality" x="${f(ce.x+le)}" y="${f(ce.y+J+h*.35)}" text-anchor="middle">${tt(ce.text)}</text>`;let Ae=hb(e.title,d,o,p,te,ae,(de?`<g class="pele-clusters">${de}</g>`:"")+(fe?`<g class="pele-edges" fill="none" stroke="${Rh}" stroke-linecap="round">${fe}</g>`:"")+(ye?`<g class="pele-cluster-titles">${ye}</g>`:"")+(pe?`<g class="pele-edge-labels" font-size="${c}">${pe}</g>`:"")+(Me?`<g class="pele-cardinalities" font-size="${h}" fill="var(--_m)">${Me}</g>`:"")+`<g class="pele-nodes">${oe}</g>`);return{svg:mt("class",Ae.width,Ae.height,o,r,e,Ae.content),width:Ae.width,height:Ae.height,links:ee}}var YA={type:"class",math:!0,parse(e,t,r){let n=new CA;return r&&(n.title=r),LA(e,n),n},render:jA},GA=class{domains=new Map;transitions=[];setDomains(e){if(e)for(let t of e){let r=t.domain;this.domains.set(r,{name:r,items:(t.items??[]).map(n=>({label:n.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})))}};function VA(e,t){let r=new GA;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,`
76
+ `):void 0,domains:r.domains,transitions:r.transitions}}var f1=[{name:"cynefin-beta:",pattern:"cynefin-beta:"},zr("cynefin-beta"),{name:"-->",pattern:"-->"},{name:":",pattern:":"},{name:"DOMAIN_NAME",pattern:/complex|complicated|clear|chaotic|confusion/y},nn,Wr,Br,Si,Gn,Vn,cr,an,sn];function qA(e){let t=new Er($r(e,f1,"cynefin"),f1,"cynefin"),r={$type:"Cynefin",domains:[],transitions:[]},n=()=>{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"),n())};for(n(),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=_r(t.take()),i();break;case 6:r.accTitle=Mr(t.take()),i();break;case 7:r.title=kr(t.take()),i();break;case 4:{let a=t.take();if(t.accept(2)){let s={$type:"Transition",from:a,to:t.expect(4)};t.accept(3)&&(s.label=Dr(t.expect(8))),i(),r.transitions.push(s);break}let l={$type:"DomainBlock",domain:a,items:[]};for(n();t.kinds[t.i]===8;)l.items.push({$type:"DomainItem",label:Dr(t.take())}),n();r.domains.push(l);break}default:t.fail("a domain, a transition, a title, or a line break")}return r}function p1(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 XA(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t|=0;return t}function KA(e,t){return typeof e=="number"&&Number.isFinite(e)&&e!==0?e:XA(t)}var ZA={segments:7,vertical:!0,pointStep:17,controlStep:31,controlShift:7},g1={segments:7,vertical:!1,pointStep:23,controlStep:37,controlShift:11};function Oh(e,t,r,n,i,a){let l=(t-e)/a.segments,s=[],o=[];for(let h=0;h<=a.segments;h++){let u=h===0&&a.pinStart||h===a.segments&&a.pinEnd;s.push(e+h*l),o.push(u?r:r+p1(n+h*a.pointStep)*i*2-i)}let c=a.vertical?[o[0],s[0]]:[s[0],o[0]];for(let h=0;h<a.segments;h++){let u=(s[h]+s[h+1])/2,d=i*1.5*(h%2===0?1:-1)*p1(n+h*a.controlStep+a.controlShift);a.vertical?c.push(o[h]+d,u,o[h+1]-d,u,o[h+1],s[h+1]):c.push(u,o[h]+d,u,o[h+1]-d,s[h+1],o[h+1])}return c}function QA(e,t,r,n){let i=r-t;return[e,t,e+n,t+i*.2,e-n*1.5,t+i*.55,e+n*.5,t+i*.75,e-n,t+i*.85,e+n*.3,t+i*.95,e,r]}function Os(e){let t="";for(let r=2;r<e.length;r+=6)t+=`C${f(e[r])},${f(e[r+1])} ${f(e[r+2])},${f(e[r+3])} ${f(e[r+4])},${f(e[r+5])}`;return t}function fo(e){let t="";for(let r=e.length-6;r>=2;r-=6)t+=`C${f(e[r+2])},${f(e[r+3])} ${f(e[r])},${f(e[r+1])} ${f(e[r-2])},${f(e[r-1])}`;return t}function po(e){return`M${f(e[0])},${f(e[1])}${Os(e)}`}function JA(e,t,r,n){let i=`${f(r)},${f(n)}`;return`M${f(e-r)},${f(t)}A${i} 0 1,1 ${f(e+r)},${f(t)}A${i} 0 1,1 ${f(e-r)},${f(t)}Z`}var Lh=[["complex",0,0,0],["complicated",1,0,1],["chaotic",0,1,3],["clear",1,1,2]],eT=4,tT=new Map([["complex",["Complex","Probe → Sense → Respond","Emergent Practices"]],["complicated",["Complicated","Sense → Analyse → Respond","Good Practices"]],["clear",["Clear","Sense → Categorise → Respond","Best Practices"]],["chaotic",["Chaotic","Act → Sense → Respond","Novel Practices"]],["confusion",["Confusion","","Disorder"]]]),m1=3,y1=200,rT=10,nT=4,go=6,x1=10,b1=20,mo=10;function yo(e,t,r,n,i){let a=e.cynefin?.[t];return typeof a=="number"&&a>=n&&a<=i?a:r}function iT(e,t,r){let n=r.fontSize??16,i=Math.round(n*.8125),a=Math.round(n*.875),l=r.measurer??bt(r.fontFamily),s=r.padding??8,o=r.icons,c=t.cynefin?.showDomainDescriptions!==!1,h=yo(t,"boundaryAmplitude",8,0,50),u=KA(yo(t,"seed",0,-1e15,1e15),r.idPrefix??"pele"),d=Math.round(a*1.5),p=(B,K)=>{let ie=Ve(B,!1,l,a,y1);return{text:B,label:ie,w:ie.width+2*rT,h:Math.max(ie.height,d)+2*nT,overflow:K}},g=B=>{let K=tT.get(B),ie=Ve(K[0],!1,l,n,4e3,1),le=[];if(c)for(let de of[K[1],K[2]])de&&le.push(Ve(de,!1,l,i,4e3,2));let J=e.domains.get(B)?.items??[],te=B==="confusion"&&J.length>m1?m1:J.length,ae=[];for(let de=0;de<te;de++)ae.push(p(J[de].label,!1));te<J.length&&ae.push(p(`+${J.length-te} more`,!0));let ee=ie.width,re=ie.height;for(let de of le)ee=Math.max(ee,de.width),re+=de.height;ae.length>0&&(re+=x1-go);for(let de of ae)ee=Math.max(ee,de.w),re+=go+de.h;return{name:B,title:ie,subtitles:le,badges:ae,w:ee,h:re,cx:0,cy:0}},m=Lh.map(([B])=>g(B)),v=g("confusion"),x=Math.max(88,v.w*.71+8),k=Math.max(64,v.h*.71+6),b=yo(t,"width",640,100,1e4)/2,C=yo(t,"height",440,100,1e4)/2;for(let B of m)b=Math.max(b,B.w+2*b1),C=Math.max(C,B.h+2*b1);for(let B of m){let K=(b-B.w)/2,ie=(C-B.h)/2;if((K/(x+mo))**2+(ie/(k+mo))**2>=1)continue;let le=B.w+2*(x+mo),J=B.h+2*(k+mo);le*C<=b*J?b=Math.max(b,le):C=Math.max(C,J)}let N=Ve(e.title,!1,l,n,4e3,1),R=N.height>0?N.height+12:0,O=2*b,P=2*C,H=s,I=s+R,G=H+b,Z=I+C,z=H+O,W=I+P,S=Oh(I,Z,G,u,h,{...ZA,segments:4,pinEnd:!0}),A=Oh(H,G,Z,u+100,h,{...g1,segments:4,pinEnd:!0}),$=Oh(G,z,Z,u+200,h,{...g1,segments:4,pinStart:!0}),y=QA(G,Z,W,O*.03),E=(B,K)=>K?`${f(B[B.length-2])},${f(B[B.length-1])}`:`${f(B[0])},${f(B[1])}`,w=new Map([["complex",`M${f(H)},${f(I)}L${E(S,!1)}${Os(S)}${fo(A)}Z`],["complicated",`M${E(S,!1)}L${f(z)},${f(I)}L${E($,!0)}${fo($)}${fo(S)}Z`],["chaotic",`M${E(A,!1)}${Os(A)}${Os(y)}L${f(H)},${f(W)}Z`],["clear",`M${E($,!1)}${Os($)}L${f(z)},${f(W)}L${E(y,!0)}${fo(y)}Z`]]),T="";for(let[B,,,K]of Lh)T+=`<path class="pele-cynefin-region" data-id="${B}" d="${w.get(B)}" fill="${kt(K)}" fill-opacity="0.14"/>`;let _=`<g class="pele-cynefin-boundaries" fill="none" stroke="var(--_b)" stroke-dasharray="6 3"><path d="${po(S)}"/><path d="${po(A)}"/><path d="${po($)}"/><path class="pele-cynefin-cliff" d="${po(y)}" stroke="var(--_l)" stroke-width="2" stroke-dasharray="none" stroke-linecap="round"/></g>`,M=JA(G,Z,x,k),U=`<path d="${M}" fill="var(--_bg)"/><path class="pele-cynefin-region" data-id="confusion" d="${M}" fill="${kt(eT)}" fill-opacity="0.18" stroke="var(--_b)" stroke-dasharray="4 2"/>`,j=B=>{let K=B.cy-B.h/2,ie=Le(B.title,B.cx,K+B.title.height/2,' class="pele-label" font-weight="var(--_hw)"');K+=B.title.height;for(let le of B.subtitles)ie+=Le(le,B.cx,K+le.height/2,` class="pele-cynefin-subtitle" font-size="${i}" font-style="italic" fill="var(--_m)"`),K+=le.height;K+=x1-go;for(let le of B.badges)K+=go,ie+=`<g class="pele-node${le.overflow?" pele-cynefin-overflow":""}"${le.overflow?"":` data-id="${Ge(le.text)}"`}><rect x="${f(B.cx-le.w/2)}" y="${f(K)}" width="${f(le.w)}" height="${f(le.h)}" fill="var(--_bg)" stroke="var(--_b)"${le.overflow?' stroke-dasharray="3 2"':""}${xt}/>`+Le(le.label,B.cx,K+le.h/2,` class="pele-label" font-size="${a}"${le.overflow?' fill="var(--_m)"':""}`,o)+"</g>",K+=le.h;return`<g class="pele-cynefin-domain" data-id="${B.name}">${ie}</g>`},Y=new Map,D="";Lh.forEach(([B,K,ie],le)=>{let J=m[le];J.cx=H+b*(K+.5),J.cy=I+C*(ie+.5),Y.set(B,J),D+=j(J)}),v.cx=G,v.cy=Z,Y.set("confusion",v),D+=j(v);let L=(B,K,ie)=>B===v?((K-G)/(x+4))**2+((ie-Z)/(k+4))**2<=1:Math.abs(K-B.cx)<=B.w/2+8&&Math.abs(ie-B.cy)<=B.h/2+8,F="",V=new Map;for(let B of e.transitions){let K=Y.get(B.from),ie=Y.get(B.to);if(!K||!ie||K===ie)continue;let le=B.from<B.to?`${B.from} ${B.to}`:`${B.to} ${B.from}`,J=V.get(le)??0;V.set(le,J+1);let te=ie.cx-K.cx,ae=ie.cy-K.cy,ee=Math.hypot(te,ae)||1,re=(K.cx+ie.cx)/2,de=(K.cy+ie.cy)/2,ye=-ae*(re-G)+te*(de-Z)>=0?1:-1,oe=-ae/ee*ye,xe=te/ee*ye,fe=(K!==v&&ie!==v&&Math.abs(te)>1&&Math.abs(ae)>1?2*(Math.hypot(x*oe,k*xe)+16):ee*.15)+J*56,pe=re+oe*fe,Me=de+xe*fe,Ae=ve=>{let _e=1-ve;return[_e*_e*K.cx+2*_e*ve*pe+ve*ve*ie.cx,_e*_e*K.cy+2*_e*ve*Me+ve*ve*ie.cy]},ce=(ve,_e,Te,Oe)=>{for(let Ce=0;Ce<16;Ce++){let He=(_e+Te)/2;L(ve,...Ae(He))===Oe?_e=He:Te=He}return(_e+Te)/2},ge=48,be=1;for(;be<=ge&&L(K,...Ae(be/ge));)be++;if(be>ge)continue;let Ie=ce(K,(be-1)/ge,be/ge,!0);for(;be<=ge&&!L(ie,...Ae(be/ge));)be++;let Re=be>ge?1:ce(ie,(be-1)/ge,be/ge,!1),[ze,he]=Ae(Ie),[$e,Se]=Ae(Re),we=(ve,_e,Te)=>(1-Ie)*(1-Re)*ve+((1-Ie)*Re+Ie*(1-Re))*_e+Ie*Re*Te,ke=we(K.cx,pe,ie.cx),Ne=we(K.cy,Me,ie.cy),Be=Math.hypot($e-ke,Se-Ne)||1,Pe=($e-ke)/Be,q=(Se-Ne)/Be,me=Ct("arrow_point",$e,Se,Pe,q,"var(--_l)");$e-=Pe*Et("arrow_point"),Se-=q*Et("arrow_point");let se="";if(B.label){let ve=Ve(B.label,!1,l,i,y1),[_e,Te]=Ae((Ie+Re)/2),Oe=Math.abs(oe)*ve.width/2+Math.abs(xe)*ve.height/2+6,Ce=ve.width/2+4,He=Math.min(Math.max(_e+oe*Oe,H+Ce),Math.max(z-Ce,H+Ce));se=Le(ve,He,Te+xe*Oe,` class="pele-edge-label" font-size="${i}"`,o)}F+=`<g class="pele-edge" data-id="${B.from}-${B.to}"><path d="M${f(ze)},${f(he)}Q${f(ke)},${f(Ne)} ${f($e)},${f(Se)}" fill="none" stroke="var(--_l)"/>`+me+se+"</g>"}let X=Math.ceil(Math.max(O,N.width)+2*s),Q=Math.ceil(P+R+2*s),ne=Le(N,H+O/2,s+N.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-cynefin-regions">${T}</g>`+_+U+D+(F?`<g class="pele-edges">${F}</g>`:"");return{svg:mt("cynefin",X,Q,n,r,e,ne),width:X,height:Q,links:[]}}var aT={type:"cynefin",parse:(e,t,r)=>VA(qA(e),r),render:iT};function sT(e){return e==="markdown"||e==="string"||e==="text"?e:"markdown"}var lT=class{type="er";direction="TB";entities=new Map;relationships=[];classes=new Map;subgraphs=[];title;accTitle;accDescr;subgraphLookup=new Map;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 n=t.length-1;n>=0;n--){let i=t[n];i.keys??=[],i.comment??="",r.attributes.push(i)}}addRelationship(e,t,r,n){let i=this.subgraphLookup.has(e)?e:this.addEntity(e).id,a=this.subgraphLookup.has(r)?r:this.addEntity(r).id;this.relationships.push({entityA:i,roleA:t,entityB:a,relSpec:n})}setDirection(e){this.direction=e}addCssStyles(e,t){if(t)for(let r of e){let n=this.entities.get(r);if(n)for(let a of t)n.cssStyles.push(a);let i=this.subgraphLookup.get(r);if(i)for(let a of t)i.cssStyles.push(a)}}addClass(e,t){for(let r of e){let n=this.classes.get(r);if(n===void 0&&(n={id:r,styles:[],textStyles:[]},this.classes.set(r,n)),!!t)for(let i of t)i.includes("color")&&n.textStyles.push(i.replace("fill","bgFill")),n.styles.push(i)}}setClass(e,t){for(let r of e){let n=this.entities.get(r);if(n)for(let a of t)n.cssClasses+=" "+a;let i=this.subgraphLookup.get(r);if(i)for(let a of t)i.classes.push(a)}}addSubGraph(e,t,r){let n=e.text.trim(),i=new Set,a=[],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)||a.push(o))}for(let o of a)this.claimed.add(o);let s={id:n,nodes:a,title:(r.text||"").trim(),classes:[],cssStyles:[],dir:l,labelType:sT(r.type)};return this.subgraphs.push(s),this.subgraphLookup.set(n,s),n}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
77
+ `)}},w1=["$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"],nl=1,Pc=2,sp=4,fl=8,Lr=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&&(Lr[e]|=nl|Pc|fl),r&&(Lr[e]|=sp)}for(let e of"-*")Lr[e.charCodeAt(0)]|=nl|Pc|fl;Lr[46]|=nl|fl;Lr[42]|=sp;for(let e of"[](),")Lr[e.charCodeAt(0)]|=fl;var oT=/accTitle\s*:\s*/iy,cT=/accDescr\s*:\s*/iy,dT=/accDescr\s*\{\s*/iy,hT=[/.*direction\s+TB[^\n]*/iy,/.*direction\s+BT[^\n]*/iy,/.*direction\s+RL[^\n]*/iy,/.*direction\s+LR[^\n]*/iy],Dh=/direction/gi,Ph=/[\n\r\u2028\u2029]/g;function v1(e,t){return e<128?(Lr[e]&t)!==0:e>=192||e===181}function uT(e){let t=e.length,r=[],n=[],i=[],a=0,l=0,s=-2,o=0,c=-1,h=-2,u=-1,d=-1,p=-1,g=(z,W,S)=>{r.push(z),n.push(e.slice(W,S)),i.push(W),l=S},m=(z,W)=>(z.lastIndex=W,z.test(e)?z.lastIndex:-1),v=z=>{for(let W=0;W<z.length;W++){let S=z.charCodeAt(W),A=e.charCodeAt(l+W);if(A!==S&&(S<97||S>122||(A|32)!==S))return!1}return!0},x=z=>v(z)&&!nt(e.charCodeAt(l+z.length)),k=z=>{let W=e.charCodeAt(z);return W>=65&&W<=90?W+32:W},b=z=>(Ph.lastIndex=z,Ph.test(e)?Ph.lastIndex-1:t),C=z=>{for(;gt(e.charCodeAt(z));)z++;return z},N=()=>{if(s===-1||s<l&&(Dh.lastIndex=l,s=Dh.test(e)?Dh.lastIndex-9:-1,s===-1)||l<o||(c<l&&(c=b(l)),s>=c))return!1;for(let z=0;z<4;z++){let W=m(hT[z],l);if(W>=0)return g(18+z,l,W),!0}return o=c,!1},R=()=>{let z=e.indexOf('"',l+1);if(z===-1){g(45,l,l+1);return}let W=z>l+1;for(let S=l+1;W&&S<z;S++){let A=e.charCodeAt(S);(A===37||A===92||A===13||A===10||A===11||A===8)&&(W=!1)}g(W?31:44,l,z+1)},O=z=>{let W=e.charCodeAt(l+1);if(W===43&&(z===49||z===48)){g(z===49?39:38,l,l+2);return}let S=C(l+1);if(e.charCodeAt(S)===46&&gt(e.charCodeAt(S+1))){g(32,l,C(S+2));return}if(z===49){if(Xe(W)){let A=l+2;for(;Xe(e.charCodeAt(A));)A++;let $=e.charCodeAt(A);if(nt($)||$===34||$===39){g(40,l,l+1);return}}else if(W===45||W===46){let A=e.charCodeAt(l+2);if(A===45||A===46){g(40,l,l+1);return}}if(!nt(W)){g(33,l,l+1);return}}g(29,l,S)},P=z=>{let W=e.charCodeAt(l+1);switch(z){case 101:if(x("erdiagram"))g(2,l,l+9);else if(x("end")){let S=l+3;for(;Xe(e.charCodeAt(S));)S++;g(16,l,S)}else return!1;return!0;case 115:if(x("style"))a=6,g(27,l,l+5);else if(x("subgraph"))g(17,l,l+8);else return!1;return!0;case 99:if(x("classdef"))a=6,g(22,l,l+8);else if(x("class"))g(26,l,l+5);else return!1;return!0;case 111:if(x("one or zero"))g(37,l,l+11);else if(x("one or more")||x("one or many"))g(39,l,l+11);else if(x("one"))g(40,l,l+3);else if(x("only one"))g(40,l,l+8);else if(W===124)g(37,l,l+2);else if(W===123)g(38,l,l+2);else if(x("optionally to"))g(42,l,l+13);else return!1;return!0;case 122:if(x("zero or one"))g(37,l,l+11);else if(x("zero or more")||x("zero or many"))g(38,l,l+12);else return!1;return!0;case 109:if(v("many(0)"))g(38,l,l+7);else if(v("many(1)"))g(39,l,l+7);else if(x("many"))g(38,l,l+4);else return!1;return!0;case 116:return x("to")?(g(43,l,l+2),!0):!1;case 117:return W!==46&&W!==45&&W!==124?!1:(g(41,l,l+1),!0);case 124:if(k(l+1)===111&&!nt(e.charCodeAt(l+2)))g(37,l,l+2);else if(W===124)g(40,l,l+2);else if(W===123)g(39,l,l+2);else return!1;return!0;case 125:if(k(l+1)===111&&!nt(e.charCodeAt(l+2)))g(38,l,l+2);else if(W===124)g(39,l,l+2);else return!1;return!0;case 46:return W!==46&&W!==45?!1:(g(42,l,l+2),!0);case 45:if(W===45)g(43,l,l+2);else if(W===46)g(42,l,l+2);else return!1;return!0}return!1},H=z=>{let W;if((z===97||z===65)&&v("acc")){if((W=m(oT,l))>=0){a=3,g(11,l,W);return}if((W=m(cT,l))>=0){a=4,g(13,l,W);return}if((W=m(dT,l))>=0){a=5,l=W;return}}if(!N()){switch(z){case 32:case 9:case 13:W=l+1;for(let S=e.charCodeAt(W);S===32||S===9||S===13;S=e.charCodeAt(W))W++;l=W;return;case 10:for(W=l+1;e.charCodeAt(W)===10;)W++;g(4,l,W);return;case 34:R();return;case 123:a=1,g(7,l,l+1);return;case 35:g(30,l,l+1);return;case 44:g(25,l,l+1);return;case 58:e.charCodeAt(l+1)===58&&e.charCodeAt(l+2)===58?g(6,l,l+3):g(5,l,l+1);return;case 91:g(9,l,l+1);return;case 93:g(10,l,l+1);return}if(gt(z)){O(z);return}if(!P(z>=65&&z<=90?z+32:z)){if(z>=128||(Lr[z]&nl)!==0){W=l+1;for(let S=e.charCodeAt(W);S>=128||(Lr[S]&nl)!==0;S=e.charCodeAt(W))W++;g(23,l,W);return}g(45,l,l+1)}}},I=()=>{if(h===-1||h<l&&(h=e.indexOf("~",l),h===-1))return!1;if(p<l){let W=l;for(;W<t&&!Xe(e.charCodeAt(W));)W++;p=W}if(h>=p||(u<l&&(u=b(l),d=e.lastIndexOf("~",u-1)),d<=h))return!1;let z=d+1;for(;z<t&&!Xe(e.charCodeAt(z));)z++;return g(34,l,z),!0},G=z=>{if(Xe(z)){for(l++;Xe(e.charCodeAt(l));)l++;return}let W=z|32;if((W===112||W===102||W===117)&&(e.charCodeAt(l+1)|32)===107&&!nt(e.charCodeAt(l+2))){g(35,l,l+2);return}if(!I()){if(v1(z,sp)){let S=l+1;for(;S<t&&v1(e.charCodeAt(S),fl);)S++;g(34,l,S);return}if(z===96){a=2,l++;return}if(z===34){let S=e.indexOf('"',l+1);if(S!==-1){g(36,l,S+1);return}}else if(z===125){a=0,g(8,l,l+1);return}g(45,l,l+1)}};for(;l<t;){let z=e.charCodeAt(l),W;switch(a){case 0:H(z);break;case 1:G(z);break;case 2:z===96?(a=1,l++):(W=e.indexOf("`",l),g(34,l,W===-1?t:W));break;case 3:case 4:W=e.indexOf(`
78
+ `,l),g(a===3?12:14,l,W===-1?t:W),a=0;break;case 5:z===125?(a=0,l++):(W=e.indexOf("}",l),g(15,l,W===-1?t:W));break;case 6:if(z===10){for(W=l+1;e.charCodeAt(W)===10;)W++;a=0,g(4,l,W)}else if(Xe(z))for(l++;Xe(e.charCodeAt(l));)l++;else if(z===58)g(5,l,l+1);else if(z===44)g(25,l,l+1);else if(z===35)g(30,l,l+1);else if(z===59)g(28,l,l+1);else if(z>=128||(Lr[z]&Pc)!==0){W=l+1;for(let S=e.charCodeAt(W);S>=128||(Lr[S]&Pc)!==0;S=e.charCodeAt(W))W++;g(24,l,W)}else return r.push(1),n.push(""),i.push(l),{types:r,texts:n,starts:i};break}}let Z=a===0?3:a===3?12:a===4?14:a===5?15:-1;return Z!==-1&&(r.push(Z),n.push(""),i.push(t)),r.push(0),n.push(""),i.push(t),{types:r,texts:n,starts:i}}var zh=new Map([[37,"ZERO_OR_ONE"],[38,"ZERO_OR_MORE"],[39,"ONE_OR_MORE"],[40,"ONLY_ONE"],[41,"MD_PARENT"]]),fT=["TB","BT","RL","LR"],bb="'UNICODE_TEXT', 'NUM', 'ENTITY_NAME', 'DECIMAL_NUM', 'ENTITY_ONE'",pT="'ZERO_OR_ONE', 'ZERO_OR_MORE', 'ONE_OR_MORE', 'ONLY_ONE', 'MD_PARENT'",xo="'EOF', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'SUBGRAPH', 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'CLASSDEF', 'CLASS', 'STYLE', "+bb;function gT(e,t){let{types:r,texts:n,starts:i}=uT(e),a=0,l=O=>{let P=r[a];throw P===1?vt("er",e,i[a],"",!0):vt("er",e,i[a],`Expecting ${O}, got '${P===45?n[a]:w1[P]}'`)},s=O=>(r[a]!==O&&l(`'${w1[O]}'`),n[a++]),o=()=>{let O=r[a];O!==4&&O!==28&&O!==3&&l("'EOF', 'NEWLINE', 'SEMI'"),a++},c=O=>O===23||O===31||O===29||O===32||O===33,h=()=>{let O=r[a];c(O)||l(bb);let P=n[a++];return O===31?P.slice(1,-1):P},u=()=>{let O=[];for(;;){let P=r[a];if(P!==23&&P!==24&&l("'UNICODE_TEXT', 'STYLE_TEXT'"),O.push(n[a++]),r[a]!==25)return O;a++}},d=O=>O===24||O===29||O===5||O===30,p=()=>{let O=[];for(;;){d(r[a])||l("'STYLE_TEXT', 'COLON', 'NUM', 'BRKT'");let P=n[a++];for(;d(r[a]);)P+=n[a++];if(O.push(P),r[a]!==25)return O;a++}},g=()=>{let O=zh.get(r[a++]),P=r[a];P!==43&&P!==42&&l("'NON_IDENTIFYING', 'IDENTIFYING'");let H=P===43?"IDENTIFYING":"NON_IDENTIFYING";a++;let I=zh.get(r[a]);return I===void 0?l(pT):(a++,{cardA:I,relType:H,cardB:O})},m=()=>{let O=r[a];O!==44&&O!==31&&O!==23&&l("'UNICODE_TEXT', 'ENTITY_NAME', 'WORD'");let P=n[a++];return O===23?P:P.slice(1,-1)},v=O=>r[a]===45&&n[a]===O,x=()=>{let O=[];do{let P=s(34);v("?")&&(P+=n[a++]),r[a]!==34&&l(P.endsWith("?")?"'ATTRIBUTE_WORD'":"'ATTRIBUTE_WORD', '?'");let H={type:P,name:n[a++]};if(r[a]===35){let I=[n[a++]];for(;v(",");)a++,I.push(s(35));H.keys=I}r[a]===36&&(H.comment=n[a++].slice(1,-1)),O.push(H)}while(r[a]!==8);return O.reverse()},k=()=>{if(r[a]!==7)return;if(a++,r[a]===8){a++;return}let O=x();return a++,O},b=()=>{let O=h(),P=r[a];if(P===9){a++;let G=h();s(10);let Z;r[a]===6&&(a++,Z=u());let z=k();return t.addEntity(O,G),z&&t.addAttributes(O,z),Z&&t.setClass([O],Z),[O]}let H;if(P===6&&(a++,H=u(),P=r[a]),zh.has(P)){let G=g(),Z=h(),z;r[a]===6&&(a++,z=u()),s(5);let W=m();return t.addEntity(O),t.addEntity(Z),t.addRelationship(O,W,Z,G),H&&t.setClass([O],H),z&&t.setClass([Z],z),[O,Z]}let I=k();return t.addEntity(O),I&&t.addAttributes(O,I),H&&t.setClass([O],H),[O]};s(2);let C=[{id:"",title:"",list:[]}],N=C[0],R=!1;for(;;){let O=r[a];switch(O){case 4:a++;break;case 3:a++,R&&l(`'END', ${xo}`);return;case 16:{R||l(xo),a++;let P=t.addSubGraph({text:N.id},N.list,{text:N.title});C.pop(),N=C[C.length-1],R=C.length>1,R&&N.list.push(P);break}case 17:{a++;let P=h(),H=P;if(r[a]===9){for(a++,H=h();c(r[a]);)H+=" "+h();s(10)}o(),N={id:P,title:H,list:[]},C.push(N),R=!0;break}case 11:{a++;let P=s(12).trim();t.setAccTitle(P),R&&N.list.push(P);break}case 13:{a++;let P=s(14).trim();t.setAccDescription(P),R&&N.list.push(P);break}case 15:{let P=n[a++].trim();t.setAccDescription(P),R&&N.list.push(P);break}case 18:case 19:case 20:case 21:{a++;let P=fT[O-18];R?N.list.push({stmt:"dir",value:P}):t.setDirection(P);break}case 22:{let P=n[a++],H=u(),I=p();o(),t.addClass(H,I),R&&N.list.push(P);break}case 26:{let P=n[a++],H=u();t.setClass(H,u()),R&&N.list.push(P);break}case 27:{let P=n[a++],H=u(),I=p();o(),t.addCssStyles(H,I),R&&N.list.push(P);break}default:{c(O)||l(R?`'END', ${xo}`:xo);let P=b();if(R)for(let H of P)N.list.push(H)}}}}var mT=[];function yT(e){let t=[],r=[],n=e.subgraphs,i=o=>{let c=[];for(let h of o){let u=e.classes.get(h);if(u!==void 0){for(let d of u.styles)c.push(d.trim());for(let d of u.textStyles)c.push(d.trim())}}return c},a=new Map,l=new Set;for(let o=n.length-1;o>=0;o--){let c=n[o];l.add(c.id);for(let h of c.nodes)a.set(h,c.id)}for(let o=n.length-1;o>=0;o--){let c=n[o];t.push({id:c.id,label:c.title,alias:"",attributes:mT,isGroup:!0,parentId:a.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:a.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}}var gn=18,$1=5,k1=6,Fh=10,M1=3.5;function Xi(e,t,r,n,i){let a=(h,u)=>f(t-n*h-i*u)+","+f(r-i*h+n*u),l=h=>`M${a(h,-$1)}L${a(h,$1)}`,s=`M${a(0,-k1)}L${a(Fh,0)}L${a(0,k1)}`,o=h=>`<circle class="pele-marker" cx="${f(t-n*h)}" cy="${f(r-i*h)}" r="${M1}" fill="var(--_bg)"/>`,c=h=>`<path class="pele-marker" d="${h}"/>`;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(Fh+3.5));case"zero_or_more":return c(s)+o(Fh+M1+.5);case"md_parent":return`<path class="pele-marker" d="M${a(0,0)}L${a(6,4)}L${a(12,0)}L${a(6,-4)}Z" fill="var(--_bg)"/>`}return""}var xT=48,bT=20,wT=64,us=20,fs=28,vT=38,_1=96,E1=18,$T=12,kT=9,Wh=12,A1=16,Bh=9,MT=260,Hh=1e6,_T=[],ET=18,AT=14,T1=' fill="var(--_s)" stroke="var(--_b)"';function S1(e,t,r){let n=e.er?.[t];return typeof n=="number"&&n>0?Math.min(n,2e3):r}function bo(e,t,r,n,i){let a=e.lines;if(a.length===0)return"";let l=a.length===1&&a[0].length===1?a[0][0]:void 0;if(l&&l.icon===void 0&&l.math===void 0&&l.style===0)return`<text${n} x="${f(t)}" y="${f(r)}">${tt(l.text)}</text>`;let s=ll(e),o=e.size*.35,c=r-o-e.lineHeight/2,h="",u="";for(let d=0;d<a.length;d++){let p=a[d],g=c+hl(e,d);if(rp(p)){u+=Le(ul(e,d),t+e.widths[d]/2,g,n,i);continue}r=g+o;let m=!1;for(let k of p)k.icon!==void 0&&(m=!0);let v=t,x=!1;for(let k of p){if(k.icon!==void 0){let b=e.size*1.1;u+=`<svg class="pele-icon" data-icon="${Ge(k.icon)}" x="${f(v)}" y="${f(r-e.size*.35-b/2)}" width="${f(b)}" height="${f(b)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i?.(k.icon)??""}</svg>`}else if(k.text!==""){let b=m||!x?` x="${f(v)}" y="${f(r)}"`:"";h+=`<tspan${b}${ka(k.style&~s)}>${tt(k.text)}</tspan>`,x=!0}v+=k.width}}return`<text${Sa(n,s)} xml:space="preserve">${h}</text>${u}`}function jh(e){let t=Vs(e);return t===e?e:t.replace(/</g,"&lt;").replace(/>/g,"&gt;")}function TT(e,t,r){return Ti(e.direction)?dr(r,n=>C1(e,t,r,n)):C1(e,t,r,!1)}function C1(e,t,r,n){let i=yT(e),a=r.fontSize??16,l=Math.round(a*.875),s=r.measurer??bt(r.fontFamily),o=r.padding??8,c=r.icons,h=new Map,u=[],d=[];i.nodes.forEach((E,w)=>h.set(E.id,w));let p=[],g=[],m=[],v=new Map,x=[];for(let E of i.edges){let w=h.get(E.start),T=h.get(E.end);if(w===void 0||T===void 0)continue;let _=Ve(E.label,!0,s,l,200),M;if(w===T){M={label:_,band:0,at:0};let U=v.get(w);U?U.push(M):v.set(w,[M])}x.push(M),m.push(E),g.push(_),p.push({src:w,dst:T,minlen:1,labelW:_.width>0?_.width+12:0,labelH:_.height>0?_.height+4:0,route:[],labelX:0,labelY:0})}let k=E=>{let w=E;for(let T=0;T<i.nodes.length;T++){let _=i.nodes[w].parentId,M=_===void 0?void 0:h.get(_);if(M===void 0)break;let U=i.nodes[M].dir;if(U)return U==="LR"||U==="RL";w=M}return e.direction==="LR"||e.direction==="RL"};for(let E=0;E<i.nodes.length;E++){let w=i.nodes[E],T=Ot(w.cssStyles.length>0?w.cssCompiledStyles.concat(w.cssStyles):w.cssCompiledStyles),_=(T.bold?1:0)|(T.italic?2:0),M=T.fontSize??a,U=T.fontSize??l,j=T.fontSize??Math.round(a*.75),Y=w.isGroup?Ve(w.label,!0,s,M,4e3,_):Ve(w.alias||w.label,!0,s,M,240,_),D=v.get(E)??_T,L=D.length>0&&!w.isGroup&&k(E),F={node:w,style:T,label:Y,w:0,h:0,headH:0,rows:[],cols:[],rowSize:U,keySize:j,below:L},V=0,X=0;for(let B of D)B.band=Math.max(vT,L?B.label.width+12:B.label.height+6),X+=B.band,V=Math.max(V,L?B.label.height:B.label.width);let Q=Math.max(_1,L?X+8:0),ne;if(w.isGroup)ne=Bt(0,0),ne.isGroup=!0,ne.dir=w.dir?Pr(w.dir):void 0,ne.padX=us,ne.padTop=F.label.height>0?F.label.height+16:us,ne.padBottom=us,ne.minW=Math.max(F.label.width+2*us-12,_1);else{let B=Math.max(Y.height,Math.round(M*1.5));if(w.attributes.length===0)F.w=Math.max(Y.width+2*E1,Q),F.h=Math.max(B+2*$T,L?0:X+8);else{let ie=Math.round(U*1.5),le=[0,0,0,0];for(let re of w.attributes){let de=[Ve(jh(re.type),!0,s,U,Hh,_),Ve(jh(re.name),!0,s,U,Hh,_),Ve(re.keys.join(", "),!1,s,j,Hh,_),Ve(jh(re.comment),!0,s,U,MT,_)],ye=ie;for(let oe=0;oe<4;oe++)de[oe].width>le[oe]&&(le[oe]=de[oe].width),de[oe].height>ye&&(ye=de[oe].height);F.rows.push({cells:de,h:ye+Bh}),F.h+=ye+Bh}let J=0,te=0;for(let re of le)re!==0&&(te+=re+(J>0?A1:0),J++);F.w=Math.max(te+2*Wh,Y.width+2*E1,Q);let ae=J>0?(F.w-te-2*Wh)/J:0,ee=Wh;for(let re of le)F.cols.push(ee),re>0&&(ee+=re+ae+A1);F.headH=B+2*kT,F.h+=F.headH}let K=D.length>0?2*(gn+fs*.75+10+V):0;ne=L?Bt(F.w,F.h+K):Bt(F.w+K,F.h)}ne.seq=u.length,u.push(F),d.push(ne)}i.nodes.forEach((E,w)=>{d[w].parent=E.parentId!==void 0?h.get(E.parentId)??-1:-1});let b=Ai(d,p,n?"TB":Pr(e.direction),{nodeSep:S1(t,"nodeSpacing",xT),edgeSep:bT,rankSep:S1(t,"rankSpacing",wT),portSep:24});CT(p,d,u);let C=b.width;for(let[E,w]of v){let T=d[E];if(!T.isGroup)continue;let _=0;for(let M of w)_=Math.max(_,M.label.width);C=Math.max(C,T.x+T.w/2+gn+fs*.75+10+_)}let N=Mn(e.title,s,a,4e3),R=N.height>0?N.height+12:0,O=Math.max(C,N.width),P=o+(O-C)/2,H=o+R;Zc(d,p,P,H);let I=Math.ceil(O+2*o),G=Math.ceil(b.height+R+2*o),Z=[],z=new Map,W=!1;for(let E of d)E.isGroup&&(W=!0);if(W)for(let E of p)Ma(z,E.route);let S="",A="";for(let E=0;E<u.length;E++){let w=u[E],T=d[E],_=w.node,M=jt(_.cssClasses.replace(/^default\s?/,""));if(T.isGroup){w.w=T.w,w.h=T.h;let ne=T.x-T.w/2,B=T.y-T.h/2,K=Qc(T,w.label.width,z,us);S+=`<g class="pele-cluster${M}" data-id="${Ge(_.id)}"><rect x="${f(ne)}" y="${f(B)}" width="${f(T.w)}" height="${f(T.h)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${_t(w.style.shape)}/>`+Le(w.label,K,B+8+w.label.height/2,` class="pele-cluster-label" fill="var(--_m)"${w.style.text}`,c)+"</g>";continue}let U=w.w,j=w.h,Y=-U/2,D=-j/2,L=w.style.text,F=`x="${f(Y)}" y="${f(D)}" width="${f(U)}" height="${f(j)}"`,V=Le(w.label,0,w.rows.length>0?D+w.headH/2:0,` class="pele-label"${L}`,c),X=It(_.alias||_.label);if(/ internal-link(?: |$)/.test(M+" ")&&V!==""&&r.links!==!1){let ne=ol(Ca(X),r)!==void 0,B=tt(X);V=`<a class="internal-link"${ne?` href="${B}"${cl(r)}`:""} data-href="${B}">${V}</a>`,Z.push({id:_.label,href:X,internal:!0})}let Q;if(w.rows.length===0)Q=`<rect ${F}${_t(T1+w.style.shape)}/>`+V;else{let ne=Math.round(w.rowSize*1.5),B=w.style.stroke?tt(w.style.stroke):"var(--_b)",K="",ie="",le=D+w.headH;for(let te=0;te<w.rows.length;te++){let ae=w.rows[te];if(te%2===0){let xe=`x="${f(Y)}" width="${f(U)}"`;te===w.rows.length-1?K+=`<rect ${xe} y="${f(le)}" height="${f(ae.h)}"${xt}/><rect ${xe} y="${f(le)}" height="${f(ae.h/2)}"/>`:K+=`<rect ${xe} y="${f(le)}" height="${f(ae.h)}"/>`}let ee=le+Bh/2+ne/2+w.rowSize*.35,[re,de,ye,oe]=ae.cells;ie+=bo(re,Y+w.cols[0],ee,` class="pele-er-type" fill="var(--_m)"${L}`,c)+bo(de,Y+w.cols[1],ee,` class="pele-er-name"${L}`,c)+bo(ye,Y+w.cols[2],ee,` class="pele-er-keys" font-size="${w.keySize}" fill="var(--_m)"${L}`,c)+bo(oe,Y+w.cols[3],ee,` class="pele-er-comment" fill="var(--_m)"${L}`,c),le+=ae.h}let J=f(D+w.headH);Q=`<rect ${F}${_t(T1+w.style.shape)}/><g class="pele-er-stripes" fill="var(--_bg)"${w.style.shape.includes("fill:")?' opacity="0.6"':""}>${K}</g><path class="pele-er-divider" d="M${f(Y)},${J}H${f(Y+U)}" stroke="${B}"/><rect ${F} fill="none" stroke="var(--_b)"${_t(w.style.line)}/>`+V+`<g class="pele-er-attributes" font-size="${w.rowSize}">${ie}</g>`}A+=`<g class="pele-node pele-entity${M}" data-id="${Ge(_.label)}" transform="translate(${f(T.x)},${f(T.y)})">${Q}</g>`}for(let[E,w]of v){let T=u[E],_=0;for(let j of w)_+=j.band;let M=Math.min(1,Math.max((T.below?T.w:T.h)-8,0)/_),U=-_*M/2;for(let j of w)j.band*=M,j.at=U+j.band/2,U+=j.band}let $="",y="";for(let E=0;E<p.length;E++){let w=p[E],T=m[E],_=g[E],M,U,j,Y=x[E];if(Y){let L=d[w.src],F=u[w.src],V=Math.max(Math.min(Y.band/2-6,13),1),X=gn+fs*.75+6;if(F.below){let Q=L.x+Y.at,ne=L.y+F.h/2,B=f(ne+gn),K=f(ne+gn+fs);M=`M${f(Q-V)},${f(ne)}V${B}C${f(Q-V)},${K} ${f(Q+V)},${K} ${f(Q+V)},${B}V${f(ne)}`,U=Xi(T.arrowTypeStart,Q-V,ne,0,-1),j=Xi(T.arrowTypeEnd,Q+V,ne,0,-1),w.labelX=Q,w.labelY=ne+X+_.height/2}else{let Q=L.x+F.w/2,ne=L.y+Y.at,B=f(Q+gn),K=f(Q+gn+fs);M=`M${f(Q)},${f(ne-V)}H${B}C${K},${f(ne-V)} ${K},${f(ne+V)} ${B},${f(ne+V)}H${f(Q)}`,U=Xi(T.arrowTypeStart,Q,ne-V,-1,0),j=Xi(T.arrowTypeEnd,Q,ne+V,-1,0),w.labelX=Q+X+_.width/2,w.labelY=ne}}else{let L=ST(w.route);if(L.length<6)continue;I1(L,0,u[w.src],d[w.src]),I1(L,L.length-3,u[w.dst],d[w.dst]);let F=Math.abs(L[L.length-3]-L[0]),V=Math.abs(L[L.length-2]-L[1]),X=L.length===6&&(F<.01||V<.01||Math.hypot(F,V)<=3*gn)?0:gn,Q=jn(L,void 0,X,X);M=X>0?`M${f(Q.sx)},${f(Q.sy)}L${Q.d.slice(1)}L${f(Q.ex)},${f(Q.ey)}`:Q.d,U=Xi(T.arrowTypeStart,Q.sx,Q.sy,Q.sdx,Q.sdy),j=Xi(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="${Ge(T.id)}"><path d="${M}"${D?' stroke-dasharray="4 3"':""}/>`+U+j+"</g>",_.width>0){let L=w.labelX,F=w.labelY;y+=kn(T.id,_,L,F,"",c)}}return{svg:mt("er",I,G,a,r,e,Le(N,I/2,o+N.height/2,' class="pele-title" font-weight="var(--_tw)"')+(S?`<g class="pele-clusters">${S}</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">${A}</g>`),width:I,height:G,links:Z}}function ST(e){let t=e.slice(0,3);for(let r=3;r<e.length;r+=3){let n=t.length-3,i=a=>Math.abs(t[n+a]-e[r+a])<.01&&Math.abs(e[r+a]-e[r+3+a])<.01;r+3<e.length&&(i(0)||i(1))||t.push(e[r],e[r+1],e[r+2])}return t}function CT(e,t,r){let n=new Map,i=(a,l,s,o)=>{let c=t[a],h=l[s]-c.x,u=l[s+1]-c.y,d;if(Math.abs(Math.abs(u)-c.h/2)<.5)d=u<0?0:2;else if(Math.abs(Math.abs(h)-c.w/2)<.5)d=h<0?3:1;else return;let p=a*4+d,g={route:l,at:s,toward:l[o+(d&1?1:0)]},m=n.get(p);m?m.push(g):n.set(p,[g])};for(let a of e){let l=a.route.length-3;a.src===a.dst||l<3||(i(a.src,a.route,0,3),i(a.dst,a.route,l,l-3))}for(let[a,l]of n){if(l.length<2)continue;let s=a>>2,o=(a&1)===1,c=t[s].isGroup?t[s]:r[s],h=o?c.h:c.w,u=Math.max(Math.min(ET,(h-2*AT)/(l.length-1)),0),d=o?t[s].y:t[s].x;l.sort((p,g)=>p.toward-g.toward);for(let p=0;p<l.length;p++)l[p].route[l[p].at+(o?1:0)]=d+(p-(l.length-1)/2)*u}}function I1(e,t,r,n){if(n.isGroup)return;let i=e[t]-n.x,a=e[t+1]-n.y;n.w!==r.w&&Math.abs(Math.abs(i)-n.w/2)<.5&&(e[t]-=Math.sign(i)*(n.w-r.w)/2),n.h!==r.h&&Math.abs(Math.abs(a)-n.h/2)<.5&&(e[t+1]-=Math.sign(a)*(n.h-r.h)/2)}var IT={type:"er",math:!0,parse(e,t,r){let n=new lT;return r&&(n.title=r),gT(e,n),n},render:TT},NT=new Map([["ui","ui"],["pcr","processor"],["processor","processor"],["rmo","readmodel"],["readmodel","readmodel"],["cmd","command"],["command","command"],["evt","event"],["event","event"]]),RT=new Map([["trigger",[0,"UI/Automation","UI/A: "]],["state",[100,"Command/Read Model","C/RM: "]],["stream",[200,"Events","Stream: "]]]);function OT(e){return e==="ui"||e==="processor"?"trigger":e==="event"?"stream":"state"}function Uh(e){let t=e.indexOf("{"),r=e.lastIndexOf("}"),n=(t!==-1&&r>t?e.slice(t+1,r):t===-1&&e.length>=2?e.slice(1,-1):"").replace(/\r/g,"").split(`
79
+ `);for(;n.length>0&&n[0].trim()==="";)n.shift();for(;n.length>0&&n[n.length-1].trim()==="";)n.pop();let i=1/0;for(let a of n)a.trim()!==""&&(i=Math.min(i,a.length-a.trimStart().length));return n.map(a=>a.slice(Math.min(i,a.length)).trimEnd()).join(`
80
+ `)}function LT(e,t){let r=new Set;for(let u of e.frames){if(r.has(u.name)){let d=qf(e.$source,u.$offset).line;throw new Je(`Duplicate event modeling frame ID "${u.name}" on line ${d}`,"semantic",{type:"eventmodeling",line:d})}r.add(u.name)}let n=new Map;for(let u of e.dataEntities)n.has(u.name)||n.set(u.name,u.dataBlockValue);let i=new Map,a=new Map,l=(u,d)=>{let p=OT(u),g=d===void 0?p:`${p} ${d}`,m=i.get(g);if(!m){let[v,x,k]=RT.get(p),b=v;d!==void 0&&(b=a.get(p)??v+1,a.set(p,b+1)),m={index:b,label:d===void 0?x:k+d,group:p,namespace:d},i.set(g,m)}return m},s=[],o=new Map,c=[];e.frames.forEach((u,d)=>{let p=u.entityIdentifier.split("."),g=p.length===2?p[0]:void 0,m=NT.get(u.modelEntityType)??"event",v=u.dataInlineValue===void 0?void 0:Uh(u.dataInlineValue);if(u.dataReference){let k=n.get(u.dataReference.$refText);k!==void 0&&(v=Uh(k))}let x={id:u.name,kind:m,entity:u.entityIdentifier,name:p.length===2?p[1]:u.entityIdentifier,namespace:g,reset:u.$type==="EmResetFrame",lane:l(m,g),data:v,dataType:u.dataType};if(s.push(x),o.set(x.id,x),u.sourceFrames.length>0){let k=new Set(u.sourceFrames.map(b=>b.$refText));for(let b of s)k.has(b.id)&&c.push({source:b,target:x})}else if(d>0&&!x.reset){for(let k=d-1;k>=0;k--)if(s[k].lane!==x.lane){c.push({source:s[k],target:x});break}}});let h=u=>u.map(d=>d.entityIdentifier.$refText);return{type:"eventmodeling",title:e.title&&kr(e.title)||t,accTitle:e.accTitle?Mr(e.accTitle).replace(/^\s+/g,""):void 0,accDescr:e.accDescr?_r(e.accDescr).replace(/\n\s+/g,`
81
+ `):void 0,boxes:s,lanes:[...i.values()].sort((u,d)=>u.index-d.index),relations:c,notes:e.noteEntities.map(u=>({frame:u.sourceFrame.$refText,text:Uh(u.dataBlockValue),dataType:u.dataType})),specifications:e.gwtEntities.map(u=>({frame:u.sourceFrame.$refText,given:h(u.givenStatements),when:h(u.whenStatements),then:h(u.thenStatements)})),entities:e.modelEntities.map(u=>u.name)}}var Yh=/[\t ]*accDescr(?:[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)|\s*({))/y;function DT(){let e=!1;return(t,r)=>{Yh.lastIndex=r;let n=Yh.exec(t);if(n===null)return-1;let i=Yh.lastIndex;if(n[1]===void 0)return i;if(e)return-1;let a=t.indexOf("}",i);return e=a===-1,a+1||-1}}function lp(e="ACC_DESCR"){return{...nn,name:e,scanner:DT}}var kf={name:"EM_ID",pattern:/[_a-zA-Z][\w_]*/y},Ki=e=>({name:e,pattern:e,longer:[kf]}),ps=e=>({name:e,pattern:e}),PT=["resetframe","readmodel","processor","timeframe","command","entity","event","jsobj","figma","given","json","salt","html","text","data","note","when","then","rmo","cmd","evt","pcr","uri"],Mf=[{...zr("eventmodeling"),longer:[kf]},...PT.map(Ki),ps("->>"),Ki("gwt"),Ki("ui"),Ki("md"),Ki("tf"),ps("[["),ps("]]"),Ki("rf"),ps("`"),ps("."),kf,{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},lp("EM_ACC_DESCR"),{...Wr,name:"EM_ACC_TITLE"},{...Br,name:"EM_TITLE"},{name:"EM_WS",pattern:/\s+/y,hidden:!0},{...cr,name:"EM_YAML"},{...an,name:"EM_DIRECTIVE"},{...sn,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}],Pt=e=>Mf.findIndex(t=>t.name===e),id=e=>new Set(e.map(Pt)),Mt={keyword:0,arrow:Pt("->>"),open:Pt("[["),close:Pt("]]"),tick:Pt("`"),dot:Pt("."),id:Pt("EM_ID"),frameId:Pt("EM_FID"),inline:Pt("EM_DATA_INLINE"),block:Pt("EM_DATA_BLOCK"),accDescr:Pt("EM_ACC_DESCR"),accTitle:Pt("EM_ACC_TITLE"),title:Pt("EM_TITLE"),entity:Pt("entity"),data:Pt("data"),note:Pt("note"),gwt:Pt("gwt"),given:Pt("given"),when:Pt("when"),then:Pt("then")},N1=id(["tf","timeframe"]),zT=id(["rf","resetframe"]),Gh=id(["rmo","readmodel","ui","cmd","command","evt","event","pcr","processor"]),FT=id(["json","jsobj","figma","salt","uri","md","html","text"]);function WT(e){let t=new Er($r(e,Mf,"eventmodeling"),Mf,"eventmodeling"),r={$type:"EventModel",modelEntities:[],frames:[],dataEntities:[],noteEntities:[],gwtEntities:[],$source:e},n=o=>t.kinds[t.i]===o,i=(o,c)=>o.has(t.kinds[t.i])?t.take():t.fail(c),a=()=>{let o=t.expect(Mt.id);for(;t.accept(Mt.dot);)o+="."+t.expect(Mt.id);return o},l=()=>{if(!t.accept(Mt.tick))return;let o=i(FT,"a data type");return t.expect(Mt.tick),o},s=()=>{let o=[];do i(Gh,"an entity type"),o.push({$type:"EmGwtStatement",entityIdentifier:{$refText:t.expect(Mt.id)}});while(Gh.has(t.kinds[t.i]));return o};for(t.expect(Mt.keyword);!n(-1);){let o=t.kinds[t.i];if(o===Mt.accDescr)r.accDescr=t.take();else if(o===Mt.accTitle)r.accTitle=t.take();else if(o===Mt.title)r.title=t.take();else if(o===Mt.entity)t.i++,r.modelEntities.push({$type:"EmModelEntity",name:a()});else if(N1.has(o)||zT.has(o)){let c={$type:N1.has(o)?"EmTimeFrame":"EmResetFrame",name:"",modelEntityType:"",entityIdentifier:"",sourceFrames:[],$offset:t.tokens.starts[t.i]};for(t.i++,c.name=t.expect(Mt.frameId),c.modelEntityType=i(Gh,"an entity type"),c.entityIdentifier=a();t.accept(Mt.arrow);)c.sourceFrames.push({$refText:t.expect(Mt.frameId)});if(t.accept(Mt.open)&&(c.dataReference={$refText:t.expect(Mt.id)},t.expect(Mt.close)),n(Mt.tick)||n(Mt.inline)){let h=l();h!==void 0&&(c.dataType=h),c.dataInlineValue=t.expect(Mt.inline)}r.frames.push(c)}else if(o===Mt.data){t.i++;let c={$type:"EmDataEntity",name:t.expect(Mt.id),dataBlockValue:""},h=l();h!==void 0&&(c.dataType=h),c.dataBlockValue=t.expect(Mt.block),r.dataEntities.push(c)}else if(o===Mt.note){t.i++;let c={$type:"EmNoteEntity",sourceFrame:{$refText:t.expect(Mt.frameId)},dataBlockValue:""},h=l();h!==void 0&&(c.dataType=h),c.dataBlockValue=t.expect(Mt.block),r.noteEntities.push(c)}else if(o===Mt.gwt){t.i++;let c={$type:"EmGwt",sourceFrame:{$refText:t.expect(Mt.frameId)},givenStatements:[],whenStatements:[],thenStatements:[]};t.expect(Mt.given),c.givenStatements=s(),t.accept(Mt.when)&&(c.whenStatements=s()),t.expect(Mt.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}var wb=new Map([["command",0],["event",1],["readmodel",2],["processor",6]]),Yt=12,gr=10,BT=96,R1=16,HT=80,wo=12,O1=8,jT=48,L1=80,vb=8;function Vh(e,t){let r=[];for(let n of It(e).split(`
82
+ `)){if(n.length<=t){r.push(n);continue}for(let i=0;i<n.length;i+=t)r.push(n.slice(i,i+t))}return r}function zc(e,t,r,n,i){let a="";for(let l=0;l<e.length;l++)e[l]!==""&&(a+=`<tspan x="${f(t)}" y="${f(r+l*n)}">${tt(e[l])}</tspan>`);return a===""?"":`<text${i} xml:space="preserve">${a}</text>`}function UT(e,t,r){return dr(r,n=>YT(e,t,r,n))}function YT(e,t,r,n){if(n)return qT(e,r);let i=r.fontSize??16,a=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),h=r.measurer??bt(r.fontFamily,r.fontFamilyMono),u=r.padding??8,d=(_,M,U)=>{let j=0;for(let Y of _)j=Math.max(j,h.width(Y,M,U));return j},p=new Map,g=0;for(let _ of e.lanes){let M=Ve(_.label,!1,h,l,4e3,1);g=Math.max(g,M.width),p.set(_,{lane:_,label:M,right:-1/0,y:0,h:0})}g+=2*wo;let m=[],v=new Map,x;for(let _ of e.boxes){let M=p.get(_.lane),U=Ve(_.name,!1,h,a,4e3,1),j=_.data?Vh(_.data,jT):[],Y=Math.max(BT,Math.max(U.width,d(j,s,4))+2*Yt),D=2*gr+U.height+(j.length>0?6+j.length*o:0),L=0;if(x){let V=x.x+Math.max(x.w/2,x.w-HT);L=x.box.lane===_.lane?M.right+R1:Math.max(V,M.right+R1)}let F={box:_,name:U,data:j,x:L,y:0,w:Y,h:D};M.right=L+Y,M.h=Math.max(M.h,D),m.push(F),v.set(_,F),x=F}let k=0;for(let _ of m)k=Math.max(k,_.x+_.w);let b=g+k+wo,C=Ve(e.title,!1,h,i,4e3,1),N=C.height>0?C.height+12:0,R=u,O=u+N,P=O,H="";for(let _ of p.values())_.y=P,_.h+=2*wo,H+=`<g class="pele-cluster pele-em-lane" data-id="${Ge(_.lane.label)}"><rect x="${f(R)}" y="${f(P)}" width="${f(b)}" height="${f(_.h)}" fill="var(--_s)"${xt}/>`+Le(_.label,R+wo+_.label.width/2,P+_.h/2,` class="pele-cluster-label" font-size="${l}" font-weight="var(--_hw)" fill="var(--_m)"`)+"</g>",P+=_.h+O1;let I=p.size>0?P-O1:O,G="";for(let _ of m){let M=p.get(_.box.lane);_.x+=R+g,_.y=M.y+(M.h-_.h)/2;let U=wb.get(_.box.kind),j=`x="${f(_.x)}" y="${f(_.y)}" width="${f(_.w)}" height="${f(_.h)}"`,Y=U===void 0?`<rect ${j} fill="var(--_bg)" stroke="var(--_b)"${xt}/>`:`<rect ${j} fill="var(--_bg)"${xt}/><rect ${j} fill="${kt(U)}" fill-opacity="0.22" stroke="${kt(U)}"${xt}/>`,D=_.y+gr+_.name.height/2,L=Le(_.name,_.x+_.w/2,D,` class="pele-label" font-size="${a}" font-weight="var(--_hw)"`)+zc(_.data,_.x+Yt,_.y+gr+_.name.height+6+o/2+s*.35,o,` class="pele-em-data" font-family="${ep}" font-size="${s}"`);G+=`<g class="pele-node pele-em-${_.box.kind}${_.box.reset?" pele-em-reset":""}" data-id="${Ge(_.box.id)}">${Y}${L}</g>`}let Z="",z=Et("arrow_point");for(let _ of e.relations){let M=v.get(_.source),U=v.get(_.target);if(!M||!U||M===U)continue;let j,Y;if(M.box.lane===U.box.lane){let D=U.x>=M.x,L=D?M.x+M.w:M.x,F=D?U.x:U.x+U.w,V=M.y+M.h/2,X=U.y+U.h/2,Q=F>=L?1:-1;j=`M${f(L)},${f(V)}L${f(F-Q*z)},${f(X)}`,Y=Ct("arrow_point",F,X,Q,0,"var(--_l)")}else{let D=U.y>M.y,L=Math.max(M.x,U.x),F=Math.min(M.x+M.w,U.x+U.w),V=J=>Math.min(24,J/4),X=F-L>=16?(L+F)/2:U.x>M.x?M.x+M.w-V(M.w):M.x+V(M.w),Q=F-L>=16?X:U.x>M.x?U.x+V(U.w):U.x+U.w-V(U.w),ne=D?M.y+M.h:M.y,B=D?U.y:U.y+U.h,K=D?1:-1,ie=B-K*z,le=(ne+ie)/2;j=X===Q?`M${f(X)},${f(ne)}V${f(ie)}`:`M${f(X)},${f(ne)}C${f(X)},${f(le)} ${f(Q)},${f(le)} ${f(Q)},${f(ie)}`,Y=Ct("arrow_point",Q,B,0,K,"var(--_l)")}Z+=`<g class="pele-edge" data-id="${Ge(_.source.id)}-${Ge(_.target.id)}"><path d="${j}" fill="none" stroke="var(--_l)"/>${Y}</g>`}let W=new Map;for(let _ of e.boxes)W.set(_.id,_.name);let S="",A=0,$=(_,M,U,j)=>{let Y=Ve(`${M} · ${U}${W.has(U)?" "+W.get(U):""}`,!1,h,l,4e3,1),D=Math.max(Y.width,d(j,l,0))+2*Yt,L=2*gr+Y.height+j.length*c,F=I+(S===""&&p.size===0?0:vb);S+=`<g class="pele-em-${_}" data-id="${Ge(U)}"><rect x="${f(R)}" y="${f(F)}" width="${f(D)}" height="${f(L)}" fill="var(--_bg)" stroke="var(--_b)"${xt}/>`+Le(Y,R+Yt+Y.width/2,F+gr+Y.height/2,` font-size="${l}" font-weight="var(--_hw)"`)+zc(j,R+Yt,F+gr+Y.height+c/2+l*.35,c,` font-size="${l}"`)+"</g>",I=F+L,A=Math.max(A,D)};for(let _ of e.notes)$("note","Note",_.frame,Vh(_.text,L1));for(let _ of e.specifications){let M=[`Given ${_.given.join(", ")}`];_.when.length>0&&M.push(`When ${_.when.join(", ")}`),M.push(`Then ${_.then.join(", ")}`),$("specification","Given / When / Then",_.frame,M.flatMap(U=>Vh(U,L1)))}let y=Math.max(p.size>0?b:0,A,C.width),E=Math.ceil(y+2*u),w=Math.ceil(I+u),T=Le(C,E/2,u+C.height/2,' class="pele-title" font-weight="var(--_tw)"')+H+Z+G+S;return{svg:mt("eventmodeling",E,w,i,r,e,T),width:E,height:w,links:[]}}var D1=8,GT=120,VT=20;function qT(e,t){let r=t.fontSize??16,n=Math.round(r*.875),i=Math.round(r*.75),a=t.padding??8,l=t.measurer??bt(t.fontFamily,t.fontFamilyMono),s=Math.max(160,(t.maxWidth??320)-2*a),o=new Map(e.boxes.map((W,S)=>[W,S])),c=new Map,h=new Set;for(let W of e.relations){let S=o.get(W.source),A=o.get(W.target);if(S===void 0||A===void 0||S===A)continue;if(Math.abs(S-A)<2){h.add(e.boxes[Math.max(S,A)]);continue}let $=c.get(W.target);$?($[0]=Math.min($[0],S),$[1]=Math.max($[1],S)):c.set(W.target,[Math.min(S,A),Math.max(S,A)])}let u=new Map,d=[];for(let[W,[S,A]]of[...c].sort(($,y)=>$[1][0]-y[1][0])){let $=d.findIndex(y=>y<S);$<0&&($=d.length),d[$]=A,u.set(W,$)}let p=24+D1*Math.max(0,d.length-1),g=Math.max(GT,s-p),m=g-2*Yt,v=Ve(e.title,!1,l,r,s,1),x=a+(v.height?v.height+12:0),k=a+v.height,b=Math.max(v.width,g+p),C="",N="",R="",O=new Map,P=(W,S,A=0)=>Rc(It(W),l,S,m,A);e.boxes.forEach((W,S)=>{let A=h.has(W)?m-VT:m,$=Oc(Ve(W.lane.label,!1,l,n,A,1),l,A),y=Ve(W.name,!1,l,n,m-36,1),E=W.data?P(W.data,i,4):void 0,w=Math.max(g,$.width+2*Yt,y.width+2*Yt+36,(E?.width??0)+2*Yt),T=$.height+12,_=2*gr+y.height+(E?E.height+6:0),M=wb.get(W.kind),U=x+T,j=`x="${f(a)}" y="${f(U)}" width="${f(w)}" height="${f(_)}"`;C+=`<g class="pele-cluster pele-em-lane" data-id="${Ge(W.lane.label)}">`+ba($,a+Yt,x,` class="pele-cluster-label" font-size="${n}" font-weight="var(--_hw)" fill="var(--_m)"`)+`<g class="pele-node pele-em-${W.kind}${W.reset?" pele-em-reset":""}" data-id="${Ge(W.id)}"><rect ${j} fill="var(--_bg)" stroke="var(--_b)"${xt}/>`+(M===void 0?"":`<rect ${j} fill="${kt(M)}" fill-opacity="0.22" stroke="${kt(M)}"${xt}/>`)+Le(y,a+Yt+y.width/2,U+gr+y.height/2,` class="pele-label" font-size="${n}" font-weight="var(--_hw)"`)+`<text class="pele-em-frame" x="${f(a+w-Yt)}" y="${f(U+gr+n)}" text-anchor="end" font-size="${i}" fill="var(--_m)">${tt(W.id)}</text>`+(E?zc(E.lines.map(Y=>Y.map(D=>D.text).join("")),a+Yt,U+gr+y.height+6+E.lineHeight/2+i*.35,E.lineHeight,` class="pele-em-data" font-family="${ep}" font-size="${i}"`):"")+"</g></g>",O.set(W,{y:U,h:_,w,index:S,lane:$.width}),b=Math.max(b,w+p),k=U+_,x=k+28});for(let W of e.relations){let S=O.get(W.source),A=O.get(W.target);if(!S||!A||S===A)continue;let $=A.y>S.y,y=$?1:-1,E=$?S.y+S.h:S.y,w=$?A.y:A.y+A.h,T,_;if(Math.abs(S.index-A.index)===1){let M=a+Math.max(Math.min(S.w,A.w)/2,Yt+($?A:S).lane+16);T=`M${f(M)},${f(E)}V${f(w-y*Et("arrow_point"))}`,_=Ct("arrow_point",M,w,0,y,"var(--_l)")}else{let M=a+b-p+12+D1*(u.get(W.target)??0),U=S.y+S.h/2-5,j=A.y+A.h/2+5;T=`M${f(a+S.w)},${f(U)}H${f(M)}V${f(j)}H${f(a+A.w+Et("arrow_point"))}`,_=Ct("arrow_point",a+A.w,j,-1,0,"var(--_l)")}N+=`<g class="pele-edge" data-id="${Ge(W.source.id)}-${Ge(W.target.id)}"><path d="${T}" fill="none" stroke="var(--_l)"/>${_}</g>`}let H=new Map(e.boxes.map(W=>[W.id,W.name])),I=(W,S,A,$)=>{let y=Ve(`${S} · ${A}${H.has(A)?" "+H.get(A):""}`,!1,l,n,m,1),E=P($,n),w=Math.max(g,y.width+2*Yt,E.width+2*Yt),T=2*gr+y.height+E.height;R+=`<g class="pele-em-${W}" data-id="${Ge(A)}"><rect x="${f(a)}" y="${f(x)}" width="${f(w)}" height="${f(T)}" fill="var(--_bg)" stroke="var(--_b)"${xt}/>`+Le(y,a+Yt+y.width/2,x+gr+y.height/2,` font-size="${n}" font-weight="var(--_hw)"`)+zc(E.lines.map(_=>_.map(M=>M.text).join("")),a+Yt,x+gr+y.height+E.lineHeight/2+n*.35,E.lineHeight,` font-size="${n}"`)+"</g>",k=x+T,x=k+vb,b=Math.max(b,w)};for(let W of e.notes)I("note","Note",W.frame,W.text);for(let W of e.specifications){let S=[`Given ${W.given.join(", ")}`];W.when.length&&S.push(`When ${W.when.join(", ")}`),S.push(`Then ${W.then.join(", ")}`),I("specification","Given / When / Then",W.frame,S.join(`
83
+ `))}let G=Math.ceil(b+2*a),Z=Math.ceil(k+a),z=Le(v,G/2,a+v.height/2,' class="pele-title" font-weight="var(--_tw)"')+N+C+R;return{svg:mt("eventmodeling",G,Z,r,t,e,z),width:G,height:Z,links:[]}}var XT={type:"eventmodeling",keepComments:!0,parse:(e,t,r)=>LT(WT(e),r),render:UT};function qh(e){return e==="markdown"||e==="string"||e==="text"?e:"markdown"}function P1(e){return e.startsWith('"')&&e.endsWith('"')?e.substring(1,e.length-1):e}function KT(e,t){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function ZT(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 n="normal";return t.includes("=")&&(n="thick"),t.includes(".")&&(n="dotted"),{type:r,stroke:n}}function QT(e){let t=e.trim(),r=t.slice(0,-1),n="arrow_open";switch(t.slice(-1)){case"x":n="arrow_cross",t.startsWith("x")&&(n="double_"+n,r=r.slice(1));break;case">":n="arrow_point",t.startsWith("<")&&(n="double_"+n,r=r.slice(1));break;case"o":n="arrow_circle",t.startsWith("o")&&(n="double_"+n,r=r.slice(1));break}let i="normal",a=r.length-1;r.startsWith("=")&&(i="thick"),r.startsWith("~")&&(i="invisible");let l=KT(".",r);return l&&(i="dotted",a=l),{type:n,stroke:i,length:a}}var JT=class{type="flowchart";direction;nodes=new Map;edges=[];subgraphs=[];classes=new Map;tooltips=new Map;defaultEdgeStyle;defaultInterpolate;title;accTitle;accDescr;subgraphLookup=new Map;members=new Set;edgeById=new Map;pairCount=new Map;subCount=0;options;constructor(e={}){this.options=e}addVertex(e,t,r,n,i,a,l,s){if(!e||e.trim().length===0)return;let o;if(s!==void 0){let p=s.includes(`
84
+ `)?s+`
85
+ `:`{
86
+ `+s+`
87
+ }`,g;try{g=va(p)}catch(m){throw new Je(`Metadata of "${e}" is not valid YAML. ${m.message}`,"syntax",{type:"flowchart"})}o=g!==null&&typeof g=="object"&&!Array.isArray(g)?g:void 0}let c=this.subgraphLookup.get(e);if(c&&o){c.metadata={...c.metadata,...o};return}let h=this.edgeById.get(e);if(h){o?.animate!==void 0&&(h.animate=o.animate),o?.animation!==void 0&&(h.animation=o.animation),o?.curve!==void 0&&(h.interpolate=o.curve);return}let u=this.nodes.get(e);if(u===void 0&&(t===void 0&&r===void 0&&n!==void 0&&n!==null&&this.options.warn?.(`Style applied to unknown node "${e}". This may indicate a typo. The node will be created automatically.`),u={id:e,labelType:"text",styles:[],classes:[]},this.nodes.set(e,u)),t!==void 0?(u.labelType=t.type,u.text=P1(t.text.trim())):u.text===void 0&&(u.text=e),r!==void 0&&(u.type=r),n!=null)for(let p of n)u.styles.push(p);if(i!=null)for(let p of i)u.classes.push(p);if(a!==void 0&&(u.dir=a),u.props===void 0?u.props=l??{}:l!==void 0&&Object.assign(u.props,l),o===void 0)return;if(o.shape){let p=String(o.shape);if(p!==p.toLowerCase()||p.includes("_"))throw new Je(`No such shape: ${p}. Shape names should be lowercase.`,"semantic",{type:"flowchart"});if(!Gx(p))throw new Je(`No such shape: ${p}.`,"semantic",{type:"flowchart"});u.type=p}let d=typeof o.label=="string"?o.label:void 0;o.label&&(u.text=String(o.label),u.labelType=qh(o.labelType)),o.icon&&(u.icon=String(o.icon),!d?.trim()&&u.text===e&&(u.text="")),o.form&&(u.form=String(o.form)),o.pos&&(u.pos=String(o.pos)),o.img&&(u.img=String(o.img),!d?.trim()&&u.text===e&&(u.text="")),o.constraint&&(u.constraint=String(o.constraint)),o.w&&(u.assetWidth=Number(o.w)),o.h&&(u.assetHeight=Number(o.h))}addSingleLink(e,t,r,n){let i={start:e,end:t,type:void 0,text:"",labelType:"text",classes:[],isUserDefinedId:!1,interpolate:this.defaultInterpolate},a=r?.text;a!==void 0&&(i.text=P1(a.text.trim()),i.labelType=qh(a.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;n&&!this.edgeById.has(n)?(i.id=n,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 n=typeof r?.id=="string"?r.id.replace("@",""):void 0,i=e[e.length-1],a=t[0];for(let l of e)for(let s of t)this.addSingleLink(l,s,r,l===i&&s===a?n: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 n=this.edgeAt(r);n.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,"§§§").replace(/,/g,";").replace(/§§§/g,",").split(";");for(let n of e.split(",")){let i=this.classes.get(n);i===void 0&&(i={id:n,styles:[],textStyles:[]},this.classes.set(n,i));for(let a of r)a.includes("color")&&i.textStyles.push(a.replace("fill","bgFill")),i.styles.push(a)}}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 n=t.trim();for(let i of e.split(",")){let a=this.nodes.get(i);a!==void 0&&(a.link=n?Ia(n):void 0,a.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,`
88
+ `)}addSubGraph(e,t,r){let n=e?.text.trim(),i=r?.text??"";e!==void 0&&e===r&&/\s/.test(i)&&(n=void 0);let a=new Set,l=[],s;for(let u of t)if(typeof u=="string")u.trim()!==""&&!a.has(u)&&(a.add(u),l.push(u));else if(Array.isArray(u))for(let d of u)d.trim()!==""&&!a.has(d)&&(a.add(d),l.push(d));else s=u.value;s??=this.options.inheritDir?this.direction??this.options.direction:void 0,n??="subGraph"+this.subCount,i=i||"",this.subCount++;let o={id:n,nodes:l,title:i.trim(),classes:[],dir:s,labelType:qh(r?.type)},c=this.members;o.nodes=l.filter(u=>!c.has(u)&&u!==n);for(let u of o.nodes)c.add(u);let h=this.subgraphLookup.get(n);if(h)for(let u of o.nodes)h.nodes.push(u);else this.subgraphs.push(o);return this.subgraphLookup.set(n,h??o),n}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 n of t)for(let i of n.nodes)r.add(i);return{nodes:e.nodes.filter(n=>!r.has(n))}}destructLink(e,t){let r=QT(e);if(!t)return r;let n=ZT(t);if(n.stroke!==r.stroke)return{type:"INVALID",stroke:"INVALID"};if(n.type==="arrow_open")n.type=r.type;else{if(n.type!==r.type)return{type:"INVALID",stroke:"INVALID"};n.type="double_"+n.type}return n.type==="double_arrow"&&(n.type="double_arrow_point"),n.length=r.length,n}subgraph(e){return this.subgraphLookup.get(e)}},z1=["$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"],$b=new Uint8Array(128);for(let e of"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'*+.`?\\_/")$b[e.charCodeAt(0)]=1;var eS=/accTitle\s*:\s*/y,tS=/accDescr\s*:\s*/y,rS=/accDescr\s*\{\s*/y,nS=/call\s+/y,iS=/click\s+/y,aS=/(?:\r?\n)*\s*\n/y,sS=/\s*(?:LR|RL|TB|BT|TD|BR)\b/y,lS=/\s*[<>^]/y,oS=/\s*v\b/y,cS=[/.*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],Xh=/[\n\r\u2028\u2029]/g,F1=/\s*[xo<]?--+[-xo>]\s*/y,dS=/\s*[xo<]?--\s*/y,W1=/\s*[xo<]?==+[=xo>]\s*/y,hS=/\s*[xo<]?==\s*/y,Kh=/\s*[xo<]?-?\.+-[xo>]?\s*/y,uS=/\s*[xo<]?-\.\s*/y,B1=/\s*~~~+\s*/y,fS=/(?:\r?\n)+/y,pS=/[^\S\n\r]+/y,gS=/\(\s*\)/y,mS=/\n\s*/g;function yS(e){let t=e.length,r=[],n=[],i=[],a=[],l=0,s=0,o=!0,c=e.indexOf("direction"),h=e.indexOf("@"),u=-1,d=0,p=0,g=-1,m=-1,v=-1,x=(A,$,y)=>{r.push(A),n.push(e.slice($,y)),i.push($),s=y},k=A=>{a.push(l),l=A},b=()=>{a.length>0&&(l=a.pop())},C=(A,$)=>(A.lastIndex=$,A.test(e)?A.lastIndex:-1),N=A=>e.startsWith(A,s)&&!nt(e.charCodeAt(s+A.length)),R=A=>{let $=A;if(A>=m&&A<=v)$=v;else if(Xe(e.charCodeAt(A))){for(;$<t&&Xe(e.charCodeAt($));)$++;m=A,v=$}let y=e.charCodeAt($);return y===120||y===111||y===60?e.charCodeAt($+1):y},O=A=>{let $=A;if(A>=m&&A<=v)$=v;else if(Xe(e.charCodeAt(A))){for(;$<t&&Xe(e.charCodeAt($));)$++;m=A,v=$}return e.charCodeAt($)===126},P=()=>{e.charCodeAt(s+1)===96?(k(2),s+=2):(k(1),s++)},H=()=>{if(!O(s))return!1;let A=C(B1,s);return A<0?!1:(x(40,s,A),!0)},I=A=>{let $=e.charCodeAt(s+1);return A===40?($===45?(k(8),x(45,s,s+2)):$===91?(k(7),x(47,s,s+2)):$===40&&e.charCodeAt(s+2)===40?(k(7),x(55,s,s+3)):(k(7),x(69,s,s+1)),!0):A===91?($===91?(k(7),x(49,s,s+2)):$===40?(k(7),x(53,s,s+2)):$===47?(k(9),x(58,s,s+2)):$===92?(k(9),x(59,s,s+2)):(k(7),x(71,s,s+1)),!0):A===124?(k(7),x(67,s,s+1),!0):A===123?(k(7),x(73,s,s+1),!0):!1},G=A=>{o&&(o=!1,k(6)),x(20,s,s+A)},Z=()=>{let A=s;for(;A<t;){let $=e.charCodeAt(A);if($<128&&$b[$]===1)A++;else if($===45&&A+1<t){let y=e.charCodeAt(A+1);if(y===62||y===45||y===46)break;A++}else break}return A===s?!1:(x(64,s,A),!0)},z=A=>{let $=R(s),y;if($===45){if((y=C(F1,s))>=0)return x(40,s,y),!0;if((y=C(dS,s))>=0)return k(10),x(41,s,y),!0;if((y=C(Kh,s))>=0)return x(40,s,y),!0;if((y=C(uS,s))>=0)return k(12),x(41,s,y),!0}else if($===61){if((y=C(W1,s))>=0)return x(40,s,y),!0;if((y=C(hS,s))>=0)return k(11),x(41,s,y),!0}else if($===46&&(y=C(Kh,s))>=0)return x(40,s,y),!0;return A!==45&&A!==61&&A!==46&&H()},W=A=>{let $;switch(A){case 97:if(e.startsWith("acc",s)){if(($=C(eS,s))>=0)return k(3),x(2,s,$),!0;if(($=C(tS,s))>=0)return k(4),x(4,s,$),!0;if(($=C(rS,s))>=0)return k(5),s=$,!0}break;case 64:if(e.charCodeAt(s+1)===123)return k(16),r.push(7),n.push(""),i.push(s),s+=2,!0;break;case 99:if(($=C(nS,s))>=0)return k(14),s=$,!0;if(N("classDef"))return x(16,s,s+8),!0;if(N("class"))return x(17,s,s+5),!0;if(($=C(iS,s))>=0)return k(13),s=$,!0;break;case 34:return P(),!0;case 115:if(N("style"))return x(12,s,s+5),!0;if(N("swimlane-beta"))return G(13),!0;if(N("subgraph"))return x(21,s,s+8),!0;break;case 100:if(N("default"))return x(13,s,s+7),!0;break;case 108:if(N("linkStyle"))return x(14,s,s+9),!0;break;case 105:if(N("interpolate"))return x(15,s,s+11),!0;break;case 104:if(e.startsWith("href",s)&&Xe(e.charCodeAt(s+4)))return x(18,s,s+5),!0;break;case 102:if(N("flowchart-elk"))return G(13),!0;if(N("flowchart"))return G(9),!0;break;case 103:if(N("graph"))return G(5),!0;break;case 101:if(N("end")){for($=s+3;$<t&&Xe(e.charCodeAt($));)$++;return x(22,s,$),!0}break;case 95:if(N("_self"))return x(23,s,s+5),!0;if(N("_blank"))return x(23,s,s+6),!0;if(N("_parent"))return x(23,s,s+7),!0;if(N("_top"))return x(23,s,s+4),!0;break}if(c!==-1&&s>=d&&(c<s&&(c=e.indexOf("direction",s)),c!==-1&&(u<s&&(Xh.lastIndex=s,u=Xh.test(e)?Xh.lastIndex-1:t),c<u))){for(let y=0;y<5;y++)if(($=C(cS[y],s))>=0)return x(26+y,s,$),!0;d=u}if(h!==-1&&A!==34&&!Xe(A)){if(s>=p){h<s&&(h=e.indexOf("@",s));let y=s;for(;y<t;){let E=e.charCodeAt(y);if(E===34||Xe(E))break;y++}if(p=y,g=-1,h!==-1&&h<y)for(let E=Math.min(y,t-1)-1;E>=h;E--){if(e.charCodeAt(E)!==64)continue;let w=e.charCodeAt(E+1);if(w!==123&&w!==34){g=E;break}}}if(g>s)return x(31,s,g+1),!0}if(A>=48&&A<=57){let y=s+1;for(;y<t;){let E=e.charCodeAt(y);if(E<48||E>57)break;y++}return x(32,s,y),!0}switch(A){case 35:return x(33,s,s+1),!0;case 58:return e.charCodeAt(s+1)===58&&e.charCodeAt(s+2)===58?x(34,s,s+3):x(35,s,s+1),!0;case 38:return x(36,s,s+1),!0;case 59:return x(37,s,s+1),!0;case 44:return x(38,s,s+1),!0;case 42:return x(39,s,s+1),!0;case 120:case 111:return z(A)||Z();case 60:return z(A)||x(60,s,s+1),!0;case 45:return z(A)||Z()||x(65,s,s+1),!0;case 61:return z(A);case 46:return z(A)||Z();case 126:return H();case 40:return I(A);case 91:return e.charCodeAt(s+1)===124?(x(50,s,s+2),!0):I(A);case 124:case 123:return I(A);case 62:return k(7),x(51,s,s+1),!0;case 94:return x(61,s,s+1),!0;case 92:return e.charCodeAt(s+1)===124?(x(62,s,s+2),!0):Z();case 118:return nt(e.charCodeAt(s+1))?Z():(x(63,s,s+1),!0)}return Xe(A)?z(A)?!0:($=C(fS,s))>=0?(x(74,s,$),!0):($=C(pS,s))>=0?(x(75,s,$),!0):!1:A<128?Z():Zf(A)?(x(66,s,s+1),!0):!1},S=(A,$,y,E)=>{if(A===34)return P(),!0;let w=R(s);if(w===y||w===E){let _=C($,s);if(_>=0)return b(),x(40,s,_),!0}if(A===y&&(y!==45||e.charCodeAt(s+1)===45))return!1;let T=s+1;for(;T<t;){let _=e.charCodeAt(T);if(_===34)break;if(_===y){if(y!==45||e.charCodeAt(T+1)===45)break}else if(_===120||_===111||_===60||_===E||Xe(_)){let M=R(T);if((M===y||M===E)&&C($,T)>=0)break}T++}return x(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&&x(y,t,t);break}let A=e.charCodeAt(s),$=!0;switch(l){case 0:$=W(A);break;case 1:if(A===34)e.charCodeAt(s+1)===96?(k(2),s+=2):(b(),s++);else{let y=e.indexOf('"',s);x(11,s,y===-1?t:y)}break;case 2:if(A===96)e.charCodeAt(s+1)===34?(b(),s+=2):$=!1;else if(A===34)P();else{let y=s+1;for(;y<t;){let E=e.charCodeAt(y);if(E===96||E===34)break;y++}x(10,s,y)}break;case 3:case 4:{let y=e.indexOf(`
89
+ `,s);y===-1&&(y=t);let E=l===3?3:5;b(),x(E,s,y);break}case 5:if(A===125)b(),s++;else{let y=e.indexOf("}",s);y===-1&&(y=t),x(6,s,y)}break;case 6:{let y;A===34?P():(y=C(aS,s))>=0?(b(),x(24,s,y)):(y=C(sS,s))>=0||(y=C(lS,s))>=0||(y=C(oS,s))>=0?(b(),x(25,s,y)):$=H()||I(A);break}case 7:{let y=e.charCodeAt(s+1);switch(A){case 34:P();break;case 40:case 91:case 123:I(A);break;case 93:b(),y===41?x(46,s,s+2):y===93?x(48,s,s+2):x(70,s,s+1);break;case 41:b(),y===93?x(52,s,s+2):y===41&&e.charCodeAt(s+2)===41?x(54,s,s+3):x(68,s,s+1);break;case 124:b(),x(67,s,s+1);break;case 125:b(),x(72,s,s+1);break;default:{if((A===126||Xe(A))&&H())break;let E=s+1;for(;E<t;){let w=e.charCodeAt(E);if(w===91||w===93||w===40||w===41||w===123||w===125||w===124||w===34)break;E++}x(44,s,E)}}break}case 8:{let y=e.charCodeAt(s+1);if(A===34)P();else{if((A===126||Xe(A))&&H())break;if((A===45||A===47||A===41)&&y===41)b(),x(43,s,s+2);else if(A===40||A===91||A===123)I(A);else if(A===41||A===93||A===125)$=!1;else{let E=s+1;for(;E<t;){let w=e.charCodeAt(E);if(w===34||w===40||w===41||w===91||w===93||w===123||w===125||(w===45||w===47)&&e.charCodeAt(E+1)===41||(w===126||Xe(w))&&O(E)&&C(B1,E)>=0)break;E++}x(44,s,E)}}break}case 9:{let y=e.charCodeAt(s+1);if(A===34){P();break}if((A===126||Xe(A))&&H())break;switch(A){case 40:y===45||y===91||y===40&&e.charCodeAt(s+2)===40?I(A):y===93?(b(),x(56,s,s+2)):I(A);break;case 91:case 123:I(A);break;case 92:y===93?(b(),x(56,s,s+2)):x(44,s,s+1);break;case 47:y===93?(b(),x(57,s,s+2)):x(44,s,s+1);break;case 93:case 41:y===93?(b(),x(56,s,s+2)):$=!1;break;case 125:$=!1;break;default:{if((A===63||A===61)&&y===93){b(),x(56,s,s+2);break}let E=s+1;for(;E<t;){let w=e.charCodeAt(E);if(w===92||w===91||w===93||w===40||w===41||w===123||w===125||w===47)break;E++}x(44,s,E)}}break}case 10:$=S(A,F1,45,-1);break;case 11:$=S(A,W1,61,-1);break;case 12:$=S(A,Kh,46,45);break;case 13:if(A===34)P();else if(Xe(A))b(),s++;else{let y=s+1;for(;y<t&&!Xe(e.charCodeAt(y));)y++;x(19,s,y)}break;case 14:if(A===40){let y=C(gS,s);b(),y>=0?s=y:(k(15),s++)}else{let y=e.indexOf("(",s);y===-1&&(y=t),x(8,s,y)}break;case 15:if(A===41)b(),s++;else{let y=e.indexOf(")",s);y===-1&&(y=t),x(9,s,y)}break;case 16:if(A===34)k(17),x(7,s,s+1);else if(A===125)b(),s++;else if(A===94)$=!1;else{let y=s+1;for(;y<t;){let E=e.charCodeAt(y);if(E===125||E===94||E===34)break;y++}x(7,s,y)}break;case 17:if(A===34)b(),x(7,s,s+1);else{let y=e.indexOf('"',s);y===-1&&(y=t),r.push(7),n.push(e.slice(s,y).replace(mS,"<br/>")),i.push(s),s=y}break}if(!$)return r.push(1),n.push(""),i.push(s),{types:r,texts:n,starts:i};continue e}return r.push(0),n.push(""),i.push(t),{types:r,texts:n,starts:i}}var uc=new Uint8Array(77);for(let e of[32,64,63,65,13,38,35,36,33,39,66])uc[e]=1;var _f=new Uint8Array(77);for(let e of[32,66,64,25,63,65,38,35,36,33,39])_f[e]=1;var Ef=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])Ef[e]=1;var Af=new Uint8Array(77);for(let e of[32,64,35,75,33,12])Af[e]=1;var H1="'UNICODE_TEXT', 'TEXT', 'TAGSTART'",gs=[],xS=/}\s*\n/g;function bS(e,t){let r=e.includes("}")?e.replace(xS,`}
90
+ `):e,{types:n,texts:i,starts:a}=yS(r),l=0,s,o=S=>{let A=n[l];throw A===1?vt("flowchart",r,a[l],"",!0):vt("flowchart",r,a[l],`Expecting ${S}, got '${z1[A]}'`)},c=(S,A="")=>(n[l]!==S&&o(`'${z1[S]}'${A?", "+A:""}`),i[l++]),h=()=>{let S=n[l];S!==74&&S!==37&&S!==76&&o("'SEMI', 'NEWLINE', 'EOF'"),l++},u=()=>{uc[n[l]]===0&&o("'NODE_STRING'");let S=i[l++];for(;uc[n[l]]===1;)S+=i[l++];return S},d=()=>{_f[n[l]]===0&&o("'NODE_STRING'");let S=i[l++];for(;_f[n[l]]===1;)S+=i[l++];return S},p=()=>{let S=n[l],A;if(S===11)A="string";else if(S===10)A="markdown";else if(S===44||S===60||S===51||S===66)A="text";else return o(`${H1}, 'TAGEND', 'STR', 'MD_STR'`);let $=i[l++];for(;;){let y=n[l];if(y!==44&&y!==60&&y!==51&&y!==66)break;$+=i[l++]}return{text:$,type:A}},g=S=>{c(S,H1)},m=()=>{let S=n[l],A;if(S===11)A="string";else if(S===10)A="markdown";else if(S===42||S===66)A="text";else return o("'EDGE_TEXT', 'STR', 'MD_STR'");let $=i[l++];for(;n[l]===42||n[l]===66;)$+=i[l++];return{text:$,type:A}},v=()=>{let S=n[l],A;if(S===11)A="text";else if(S===10)A="markdown";else if(Ef[S]===1)A="text";else return o("'NODE_STRING', 'STR', 'MD_STR'");let $=i[l++];for(;Ef[n[l]]===1;)$+=i[l++];return{text:$,type:A}},x=()=>{let S=i[l++];for(;n[l]===7;)S+=i[l++];return S},k=()=>{let S=u(),A;switch(n[l]){case 71:l++,A=p(),g(70),t.addVertex(S,A,"square");break;case 55:l++,A=p(),g(54),t.addVertex(S,A,"doublecircle");break;case 69:l++,n[l]===69?(l++,A=p(),g(68),c(68),t.addVertex(S,A,"circle")):(A=p(),g(68),t.addVertex(S,A,"round"));break;case 45:l++,A=p(),g(43),t.addVertex(S,A,"ellipse");break;case 47:l++,A=p(),g(46),t.addVertex(S,A,"stadium");break;case 49:l++,A=p(),g(48),t.addVertex(S,A,"subroutine");break;case 50:{l++;let $=c(64);c(35);let y=c(64);c(67),A=p(),g(70),t.addVertex(S,A,"rect",void 0,void 0,void 0,{[$]:y});break}case 53:l++,A=p(),g(52),t.addVertex(S,A,"cylinder");break;case 73:l++,n[l]===73?(l++,A=p(),g(72),c(72),t.addVertex(S,A,"hexagon")):(A=p(),g(72),t.addVertex(S,A,"diamond"));break;case 51:l++,A=p(),g(70),t.addVertex(S,A,"odd");break;case 58:l++,A=p(),n[l]===57?(l++,t.addVertex(S,A,"lean_right")):(g(56),t.addVertex(S,A,"trapezoid"));break;case 59:l++,A=p(),n[l]===56?(l++,t.addVertex(S,A,"lean_left")):(g(57),t.addVertex(S,A,"inv_trapezoid"));break;default:t.addVertex(S)}return S},b=()=>{let S=k();return n[l]===34&&(l++,t.setClass(S,u())),S},C=()=>{let S=[b()];for(s=void 0;;){let A=n[l]===7?x():void 0;if(n[l]!==75)return s=A,S;do l++;while(n[l]===75);if(n[l]!==36)return A!==void 0&&o("'AMP'"),S;l++,n[l]!==75&&o("'SPACE'");do l++;while(n[l]===75);let $=b();A!==void 0&&t.addVertex(S[S.length-1],void 0,void 0,void 0,void 0,void 0,void 0,A),S.push($)}},N=()=>{let S;if(n[l]===31&&(S=i[l++]),n[l]===40){let A=t.destructLink(i[l++]);return S!==void 0&&(A.id=S),n[l]===67&&(l++,A.text=p(),g(67),n[l]===75&&l++),A}if(n[l]===41){let A=i[l++],$=m(),y=c(40,"'EDGE_TEXT'"),E=t.destructLink(y,A);return E.text=$,S!==void 0&&(E.id=S),E}return o("'LINK', 'START_LINK'")},R=S=>{let A=C();s!==void 0&&t.addVertex(A[A.length-1],void 0,void 0,void 0,void 0,void 0,void 0,s);let $=A;for(;;){let y=n[l];if(y!==40&&y!==41&&y!==31)return $;let E=N(),w=C();s!==void 0&&t.addVertex(w[w.length-1],void 0,void 0,void 0,void 0,void 0,void 0,s),t.addLink(A,w,E),S&&($=w.concat($)),A=w}},O=()=>{Af[n[l]]===0&&o("'NODE_STRING', 'NUM', 'COLON', 'BRKT'");let S=i[l++];for(;Af[n[l]]===1;)S+=i[l++];return S},P=()=>{let S=[O()];for(;n[l]===38;)l++,S.push(O());return S},H=()=>{l++,c(75);let S;if(n[l]===13)S=[i[l++]];else for(S=[c(32,"'DEFAULT'")];n[l]===38;)l++,S.push(c(32));if(c(75),n[l]!==15){t.updateLink(S,P());return}l++,c(75);let A=d();if(n[l]===75){l++;let $=P();t.updateLinkInterpolate(S,A),t.updateLink(S,$)}else t.updateLinkInterpolate(S,A)},I=(S,A)=>{if(n[l]!==75){t.setLink(S,A);return}if(l++,n[l]===23){t.setLink(S,A,i[l++]);return}let $=c(11,"'LINK_TARGET'");n[l]===75?(l++,t.setLink(S,A,c(23))):t.setLink(S,A),t.setTooltip(S,$)},G=()=>{let S=i[l++];switch(n[l]){case 8:{let A=i[l++],$=n[l]===9,y=$?i[l++]:void 0,E;n[l]===75&&(l++,E=c(11)),$?t.setClickEvent(S,A,y):t.setClickEvent(S,A),E!==void 0&&t.setTooltip(S,E);return}case 18:l++,I(S,c(11));return;case 11:I(S,i[l++]);return;default:{let A=d();if(n[l]===75){l++;let $=c(11);t.setClickEvent(S,A),t.setTooltip(S,$)}else t.setClickEvent(S,A)}}},Z=()=>{l++;let S=n[l];if(S===74||S===37||S===76)return l++,{id:void 0,title:void 0,list:[],collect:!1};c(75,"'SEMI', 'NEWLINE', 'EOF'");let A=v(),$=A;return n[l]===71&&(l++,$=p(),g(70)),S=n[l],S!==74&&S!==37&&S!==76&&o("'SEMI', 'NEWLINE', 'EOF', 'SQS'"),l++,{id:A,title:$,list:[],collect:!1}},z=S=>{let A=n[l];switch(A){case 12:{l++,c(75);let $=u();return c(75),t.addVertex($,void 0,void 0,P()),h(),gs}case 14:return H(),h(),gs;case 16:{l++,c(75);let $=u();return c(75),t.addClass($,P()),h(),gs}case 17:{l++,c(75);let $=u();return c(75),t.setClass($,u()),h(),gs}case 19:return G(),h(),gs;case 26:case 27:case 28:case 29:case 30:return l++,{stmt:"dir",value:wS[A-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:{uc[A]===0&&o(j1);let $=R(S);return h(),$}}},W=()=>{let S=[],A=[],$=!1;for(;;){let y=n[l];if(y===0)break;if(y===22){let E=S.pop();if(E===void 0)break;l++;let w=t.addSubGraph(E.id,A,E.title);A=E.list,$=E.collect,$&&A.push(w)}else if(y===37||y===74||y===75||y===76)$&&A.push(i[l]),l++;else if(y===21){let E=Z();E.list=A,E.collect=$,S.push(E),A=[],$=!0}else{let E=z($);$&&(!Array.isArray(E)||E.length>0)&&A.push(E)}}S.length>0&&o("'end'")};for(;n[l]===75||n[l]===74;)l++;if(c(20,"'SPACE', 'NEWLINE'"),n[l]===24)l++,t.setDirection("TB");else{let S=c(25,"'NODIR'"),A=n[l];if(A===75){do l++;while(n[l]===75);A=n[l],A!==74&&o("'NEWLINE', 'SPACE'")}else A!==37&&A!==74&&o("'SEMI', 'NEWLINE', 'SPACE'");l++,t.setDirection(S)}W(),n[l]!==0&&o(j1)}var wS=["TB","BT","RL","LR","TD"],j1="'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'subgraph', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'STYLE', 'LINKSTYLE', 'CLASSDEF', 'CLASS', 'CLICK', 'NODE_STRING'";function vS(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 $S(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 kS(e,t){let r=[],n=[],i=e.subgraphs,a=b=>{let C=[];for(let N of b){let R=e.classes.get(N);if(R!==void 0){for(let O of R.styles)C.push(O.trim());for(let O of R.textStyles)C.push(O.trim())}}return C},l=new Map;for(let b of i)for(let C of b.nodes)e.subgraph(C)&&l.set(C,b.id);let s=new Map,o=new Map;for(let b of i){let C=l.get(b.id);if(C===void 0)continue;let N=o.get(C);N?N.push(b.id):o.set(C,[b.id])}let c=0;for(let b of i){if(l.has(b.id))continue;let C=[b.id];for(;C.length>0;){let N=C.pop();if(s.has(N))continue;s.set(N,c++);let R=o.get(N);if(R)for(let O=R.length-1;O>=0;O--)C.push(R[O])}}let h=b=>e.subgraph(b)?.metadata?.view==="collapsed",u=!1;for(let b of i)b.metadata?.view==="collapsed"&&(u=!0);let d=new Map,p=b=>{let C=[],N=new Set,R=b;for(;R!==void 0&&!d.has(R)&&!N.has(R);)N.add(R),C.push(R),R=l.get(R);let O=R!==void 0?d.get(R):void 0;for(let P=C.length-1;P>=0;P--)O===void 0&&h(C[P])&&(O=C[P]),d.set(C[P],O);return O},g=new Set,m=new Map;for(let b of u?i:[]){let C=p(b.id);if(C!==void 0){b.id!==C&&(g.add(b.id),m.set(b.id,C));for(let N of b.nodes)N!==C&&(g.add(N),m.set(N,C))}}let v=new Map,x=new Set;for(let b=i.length-1;b>=0;b--){let C=i[b];if(!g.has(C.id)){C.nodes.length>0&&x.add(C.id);for(let N of C.nodes)v.set(N,C.id)}}let k=new Map;for(let b=i.length-1;b>=0;b--){let C=i[b];if(g.has(C.id))continue;let N=C.metadata?.view==="collapsed",R={id:C.id,label:C.title,labelType:C.labelType,parentId:v.get(C.id),cssStyles:[],cssCompiledStyles:a(C.classes),cssClasses:C.classes.join(" "),shape:N?"collapsedGroup":"rect",dir:C.dir,isGroup:!N,colorIndex:s.get(C.id)};N||(R.metadata=C.metadata),r.push(R),k.set(C.id,R)}for(let b of e.nodes.values()){if(g.has(b.id))continue;let C=k.get(b.id);if(C){C.cssStyles=b.styles,C.cssCompiledStyles=a(b.classes),C.cssClasses=b.classes.join(" ");continue}let N=x.has(b.id),R={id:b.id,label:b.text,labelType:b.labelType,parentId:v.get(b.id),cssStyles:b.styles,cssCompiledStyles:a(["default","node",...b.classes]),cssClasses:"default "+b.classes.join(" "),dir:b.dir,link:b.link,linkTarget:b.linkTarget,tooltip:e.tooltips.get(b.id),icon:b.icon,pos:b.pos,img:b.img,assetWidth:b.assetWidth,assetHeight:b.assetHeight,constraint:b.constraint,isGroup:N,shape:N?"rect":vS(b)};r.push(R)}return e.edges.forEach((b,C)=>{let N=m.get(b.start)??b.start,R=m.get(b.end)??b.end;if(N===R&&(m.has(b.start)||m.has(b.end)))return;let[O,P]=$S(b.type),H=[...e.defaultEdgeStyle??[]];b.style&&H.push(...b.style);let I=b.stroke==="invisible"||b.type==="arrow_open";n.push({id:b.id||`L_${N}_${R}_${C}`,isUserDefinedId:b.isUserDefinedId,start:N,end:R,type:b.type??"normal",label:b.text,labelType:b.labelType,thickness:b.stroke,pattern:b.stroke,minlen:b.length,classes:b.stroke==="invisible"?"":"edge-thickness-normal edge-pattern-solid flowchart-link",arrowTypeStart:I?"none":O,arrowTypeEnd:I?"none":P,cssCompiledStyles:a(b.classes),style:H,animate:b.animate,animation:b.animation,curve:b.interpolate||e.defaultInterpolate||t})}),{nodes:r,edges:n}}var MS=40,_S=16,ES=48,U1=20,Zh=26,Qh=' fill="var(--_s)" stroke="var(--_b)"',AS=' stroke="var(--_b)"';function Jh(e,t,r){let n=e[t];return typeof n=="number"&&n>0?Math.min(n,2e3):r}function ms(e,t){return e!==void 0&&e>0&&e<=4e3?e:t}function kb(e,t,r,n){let i=a=>Yn(r,l=>TS(e,t,r,n,a,l));return Ti(e.direction)?dr(r,i):i(!1)}function TS(e,t,r,n,i,a){let l=a?12:U1,s=n?t[n.type]:void 0,o=typeof s=="object"&&s!==null&&!Array.isArray(s)?s:t.flowchart??{},c=kS(e,typeof o.curve=="string"?o.curve:void 0);n?.prepare(c);let h=r.fontSize??16,u=Math.round(h*.875),d=r.measurer??bt(r.fontFamily),p=Math.min(Jh(o,"wrappingWidth",200),n&&a?100:1/0),g=r.padding??8,m=r.icons,v=new Map,x=[],k=[];c.nodes.forEach((D,L)=>v.set(D.id,L));for(let D of c.nodes){let L=Ot(D.cssStyles.length>0?D.cssCompiledStyles.concat(D.cssStyles):D.cssCompiledStyles),F=(L.bold?1:0)|(L.italic?2:0),V=D.labelType==="markdown",X=L.fontSize??h,Q,ne;if(D.isGroup){let B=Ve(D.label,V,d,X,n&&a?Math.max(80,Xt(r)/2):4e3,F);Q={node:D,style:L,label:B,shape:"group",w:0,h:0,dy:0,loops:0},ne=Bt(0,0),ne.isGroup=!0,ne.dir=D.dir?Pr(D.dir):void 0,ne.padX=l,ne.padTop=B.height>0?B.height+16:U1,ne.padBottom=l,ne.minW=B.width+2*l-12}else{let B=Vx(D.shape),K=D.img||D.icon||b_(B)?D.label:void 0,ie=Ve(K,V,d,X,p,F),le,J,te=0;if(D.img||D.icon){let ae=D.img?80:48,ee=ms(D.assetWidth,ae),re=ms(D.assetHeight,ae);le=Math.max(ee,ie.width+8),J=re+(ie.height>0?ie.height+6:0),te=D.pos==="t"?-re/2:re/2,ie.height===0&&(te=0)}else{let ae=Jc(B,ie.width,ie.height);le=ae.w,J=ae.h,te=ae.dy}Q={node:D,style:L,label:ie,shape:B,w:le,h:J,dy:te,loops:0},ne=Bt(le,J)}ne.seq=x.length,x.push(Q),k.push(ne)}c.nodes.forEach((D,L)=>{k[L].parent=D.parentId!==void 0?v.get(D.parentId)??-1:-1});let b=i?"TB":Pr(e.direction),C=D=>{let L;for(let F=k[D].parent,V=0;F>=0&&L===void 0&&V<1e4;F=k[F].parent,V++)L=k[F].dir;return L??=b,L==="LR"||L==="RL"};x.forEach((D,L)=>{D.node.isGroup?k[L].span=1/0:!D.node.img&&!D.node.icon&&(k[L].span=x_(D.shape,D.w,D.h,C(L)))});let N=[],R=[],O=[];for(let D of c.edges){let L=v.get(D.start),F=v.get(D.end);if(L===void 0||F===void 0)continue;let V=Ve(D.label,D.labelType==="markdown",d,u,p);L===F&&(x[L].loops++,C(L)?k[L].h+=2*(Zh+(V.height>0?V.height+8:0)):k[L].w+=2*(Zh+(V.width>0?V.width+12:0))),O.push(D),R.push(V),N.push({src:L,dst:F,minlen:D.minlen??1,labelW:V.width>0?V.width+12:0,labelH:V.height>0?V.height+4:0,route:[],labelX:0,labelY:0})}let P={nodeSep:Jh(o,"nodeSpacing",MS)*(a?.5:1),edgeSep:_S,rankSep:Jh(o,"rankSpacing",ES)*(a?.75:1),portSep:20,tracks:typeof o.curve=="string"&&/^step/.test(o.curve),straight:o.curve==="linear",headRoom:Et("arrow_point")},H=n?n.layout(k,N,b,P,a):Ai(k,N,b,P),I=Mn(e.title,d,h,a?Xt(r):4e3),G=I.height>0?I.height+12:0,Z=Math.max(H.width,I.width),z=g+(Z-H.width)/2,W=g+G;Zc(k,N,z,W);let S=Math.ceil(Z+2*g),A=Math.ceil(H.height+G+2*g),$=[],y=new Map,E=!1;for(let D of k)D.isGroup&&(E=!0);if(E)for(let D of N)Ma(y,D.route);let w="",T="",_="";for(let D=0;D<x.length;D++){let L=x[D],F=k[D],V=L.node,X=F.x,Q=F.y,ne=jt(V.cssClasses.replace(/^default\s?/,"")),B=Ge(V.id);if(F.isGroup&&n?.drawGroup&&F.parent<0){w+=n.drawGroup(F,L.label,L.style,ne,B,b,m);continue}if(F.isGroup){let ae=Qc(F,L.label.width,y,l),ee=Q-F.h/2+8+L.label.height/2,re=` class="pele-cluster-label" fill="var(--_m)"${L.style.text}`,de=Zx(F,L.label.width,ae,y);de&&(T+=Qx(L.label,ae,ee,re,B,k,D,m)),w+=`<g class="pele-cluster${ne}" data-id="${B}"><rect x="${f(X-F.w/2)}" y="${f(Q-F.h/2)}" width="${f(F.w)}" height="${f(F.h)}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${_t(L.style.shape)}/>`+(de?"":Le(L.label,ae,ee,re,m))+"</g>";continue}let K=L.w,ie=L.h,le;if(V.img){let ae=ms(V.assetWidth,80),ee=ms(V.assetHeight,80),re=L.label.height>0?V.pos==="t"?ie/2-ee:-ie/2:-ee/2,de=Gk(Ia(V.img),r);le=de===void 0?"":`<image href="${tt(de)}" x="${f(-ae/2)}" y="${f(re)}" width="${f(ae)}" height="${f(ee)}" preserveAspectRatio="${V.constraint==="on"?"xMidYMid meet":"none"}"/>`}else if(V.icon){let ae=ms(V.assetHeight,48),ee=L.label.height>0?V.pos==="t"?ie/2-ae:-ie/2:-ae/2,re=V.shape==="icon"?"":V.shape==="iconCircle"?`<circle cy="${f(ee+ae/2)}" r="${f(ae/2)}"${Qh}${L.style.shape}/>`:`<rect x="${f(-ae/2)}" y="${f(ee)}" width="${f(ae)}" height="${f(ae)}" rx="${V.shape==="iconRounded"?8:0}"${Qh}${L.style.shape}/>`,de=ae*.6;le=re+`<svg class="pele-icon" data-icon="${Ge(V.icon)}" x="${f(-de/2)}" y="${f(ee+(ae-de)/2)}" width="${f(de)}" height="${f(de)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${m?.(V.icon)??""}</svg>`}else le=_a(L.shape,K,ie,Qh+L.style.shape,AS+L.style.line);let J=Le(L.label,0,L.dy,` class="pele-label"${L.style.text}`,m);if(/ internal-link(?: |$)/.test(ne+" ")&&V.label&&r.links!==!1){let ae=It(V.label),ee=ol(Ca(ae),r)!==void 0,re=tt(ae);J=`<a class="internal-link"${ee?` href="${re}"${cl(r)}`:""} data-href="${re}">${J}</a>`,$.push({id:V.id,href:ae,internal:!0})}let te=le+J;V.tooltip&&(te=`<title>${Ge(V.tooltip)}</title>`+te),V.link&&(te=Na(te,V.link,V.id,$,r,V.linkTarget?` target="${tt(V.linkTarget)}"`:"")),_+=`<g class="pele-node pele-shape-${L.shape}${ne}" data-id="${B}" transform="translate(${f(X)},${f(Q)})">${te}</g>`}let M=Jx();for(let D=0;D<N.length;D++){let L=N[D];L.src===L.dst||O[D].thickness==="invisible"||L.route.length<6||(M.add(L.src,wn(L.route,0,k[L.src]),O[D].arrowTypeStart),M.add(L.dst,wn(L.route,L.route.length-3,k[L.dst]),O[D].arrowTypeEnd))}let U="",j="",Y=new Map;for(let D=0;D<N.length;D++){let L=N[D],F=O[D],V=R[D],X=F.style.length>0||F.cssCompiledStyles.length>0?Ot(F.cssCompiledStyles.concat(F.style)):void 0;if(F.thickness!=="invisible"){let Q=F.arrowTypeStart,ne=F.arrowTypeEnd,B;if(L.src===L.dst){let J=x[L.src],te=Y.get(L.src)??0;Y.set(L.src,te+1),B=eb(k[L.src],J.w,J.h,te,C(L.src),Zh,Et(ne),L)}else{let J=L.route.slice(),te=M.of(L.src,wn(J,0,k[L.src])),ae=M.of(L.dst,wn(J,J.length-3,k[L.dst]));js(J,0,x[L.src],k[L.src]),js(J,J.length-3,x[L.dst],k[L.dst]),B=jn(J,F.curve,Et(Q),Et(ne),te,ae)}let K=X?.stroke&&F.thickness!=="invisible"?tt(X.stroke):"var(--_l)",ie="";F.thickness==="thick"?ie+=' stroke-width="2.5"':F.thickness==="dotted"&&(ie+=' stroke-dasharray="3 4"');let le=jt(F.classes.replace(/edge-thickness-normal|edge-pattern-solid|flowchart-link/g,""));U+=`<g class="pele-edge${le}" data-id="${Ge(F.id)}"${X?.line??""}><path d="${B.d}"${ie}/>`+Ct(Q,B.sx,B.sy,B.sdx,B.sdy,K)+Ct(ne,B.ex,B.ey,B.edx,B.edy,K)+"</g>"}if(V.width>0){let Q=L.labelX,ne=L.labelY;j+=kn(F.id,V,Q,ne,X?.text??"",m)}}return{svg:mt(n?.type??"flowchart",S,A,h,r,e,Le(I,S/2,g+I.height/2,' class="pele-title" font-weight="var(--_tw)"')+(w?`<g class="pele-clusters">${w}</g>`:"")+(U?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${U}</g>`:"")+(T?`<g class="pele-cluster-titles">${T}</g>`:"")+(j?`<g class="pele-edge-labels" font-size="${u}">${j}</g>`:"")+`<g class="pele-nodes">${_}</g>`),width:S,height:A,links:$}}var Mb={type:"flowchart",math:!0,parse(e,t,r,n,i){let a=t.flowchart??{},l=new JT({inheritDir:a.inheritDir===!0,maxEdges:i.maxEdges});return r&&(l.title=r),bS(e,l),l},render:kb},Aa=["January","February","March","April","May","June","July","August","September","October","November","December"],ki=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Xs(e){return!Number.isNaN(e.getTime())}function pr(e,t){let r=String(e);return r.length>=t?r:"0".repeat(t-r.length)+r}function _b(e){let t=["th","st","nd","rd"],r=e%100;return e+(t[(r-20)%10]||t[r]||t[0])}function Tf(e){let t=-Math.round(e.getTimezoneOffset()/15)*15;return t===0?0:t}function Y1(e){let t=Tf(e),r=Math.abs(t);return(t>=0?"+":"-")+pr(Math.floor(r/60),2)+":"+pr(r%60,2)}function Eb(e){return e.getDay()||7}function Bn(e,t){let r=new Date(e);return r.setDate(r.getDate()+t),r}function SS(e){let t=new Date(e.getFullYear(),e.getMonth()+1,0);return t.setHours(23,59,59,999),t.getDate()}function G1(e,t){let r=new Date(e);return r.setDate(1),t(r),r.setDate(Math.min(e.getDate(),SS(r))),r}function Ab(e,t,r){switch(r){case"M":return G1(e,n=>n.setMonth(e.getMonth()+t));case"y":return G1(e,n=>n.setFullYear(e.getFullYear()+t));case"d":return Bn(e,Math.round(t));case"w":return Bn(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 Tb(e){return Bn(e,4-Eb(e))}function V1(e){let t=Tb(e),r=new Date(t.getFullYear(),0,1),n=Eb(r),i=Bn(r,4-n+(n>4?7:0)),a=(Tf(i)-Tf(t))*6e4,l=(t.getTime()-i.getTime()-a)/6048e5;return(l<0?Math.ceil(l)||0:Math.floor(l))+1}var CS=/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,IS=/\[([^\]]+)]|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,NS="YYYY-MM-DDTHH:mm:ssZ";function Sb(e,t){if(!Xs(e))return"Invalid Date";let r=t||NS;if(r==="YYYY-MM-DD")return Cb(e);let n=!1,i=r.replace(CS,l=>{switch(l){case"Q":return String(Math.ceil((e.getMonth()+1)/3));case"Do":return"["+_b(e.getDate())+"]";case"GGGG":return String(Tb(e).getFullYear());case"W":return String(V1(e));case"WW":return pr(V1(e),2);case"k":return String(e.getHours()||24);case"kk":return pr(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 n=!0,l;default:return l}});if(n)return;let a=e.getHours();return i.replace(IS,(l,s)=>{if(s)return s;switch(l){case"YY":return String(e.getFullYear()).slice(-2);case"YYYY":return pr(e.getFullYear(),4);case"M":return String(e.getMonth()+1);case"MM":return pr(e.getMonth()+1,2);case"MMM":return Aa[e.getMonth()].slice(0,3);case"MMMM":return Aa[e.getMonth()];case"D":return String(e.getDate());case"DD":return pr(e.getDate(),2);case"d":return String(e.getDay());case"dd":return ki[e.getDay()].slice(0,2);case"ddd":return ki[e.getDay()].slice(0,3);case"dddd":return ki[e.getDay()];case"H":return String(a);case"HH":return pr(a,2);case"h":return String(a%12||12);case"hh":return pr(a%12||12,2);case"a":return a<12?"am":"pm";case"A":return a<12?"AM":"PM";case"m":return String(e.getMinutes());case"mm":return pr(e.getMinutes(),2);case"s":return String(e.getSeconds());case"ss":return pr(e.getSeconds(),2);case"SSS":return pr(e.getMilliseconds(),3);case"Z":return Y1(e);default:return Y1(e).replace(":","")}})}function Cb(e){let t=e.getFullYear(),r=e.getMonth()+1,n=e.getDate();return(t>=1e3&&t<=9999?t:pr(t,4))+(r<10?"-0":"-")+r+(n<10?"-0":"-")+n}var RS=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,OS=/\[[^\]]+]/g,q1=/\d/,ys=/\d\d/,LS=/\d{3}/,DS=/\d{4}/,Cr=/\d\d?/,PS=/[+-]?\d+/,X1=/[+-]\d\d:?(\d\d)?|Z/,xs=/\d*[^-_:/,()\s\d]+/;function Qt(e){return(t,r)=>(t[e]=+r,!0)}var K1=(e,t)=>{if(t==="Z")return e.offset=0,!0;let r=t.match(/([+-]|\d\d)/g),n=+r[1]*60+(+r[2]||0);return e.offset=n===0?0:r[0]==="+"?-n:n,!0};function Z1(e){return(t,r)=>{let n=e.indexOf(r)+1;return n<1?!1:(t.month=n%12||n,!0)}}var zS=new Map([["A",{re:xs,read:(e,t)=>(e.afternoon=t==="PM",!0)}],["a",{re:xs,read:(e,t)=>(e.afternoon=t==="pm",!0)}],["Q",{re:q1,read:(e,t)=>(e.month=(+t-1)*3+1,!0)}],["S",{re:q1,read:(e,t)=>(e.milliseconds=+t*100,!0)}],["SS",{re:ys,read:(e,t)=>(e.milliseconds=+t*10,!0)}],["SSS",{re:LS,read:(e,t)=>(e.milliseconds=+t,!0)}],["s",{re:Cr,read:Qt("seconds")}],["ss",{re:Cr,read:Qt("seconds")}],["m",{re:Cr,read:Qt("minutes")}],["mm",{re:Cr,read:Qt("minutes")}],["H",{re:Cr,read:Qt("hours")}],["h",{re:Cr,read:Qt("hours")}],["HH",{re:Cr,read:Qt("hours")}],["hh",{re:Cr,read:Qt("hours")}],["D",{re:Cr,read:Qt("day")}],["DD",{re:ys,read:Qt("day")}],["Do",{re:xs,read:(e,t)=>{let r=t.match(/\d+/);if(!r)return!1;e.day=+r[0],e.dayGiven=!0;for(let n=1;n<=31;n++)_b(n)===t&&(e.day=n);return!0}}],["w",{re:Cr,read:Qt("week")}],["ww",{re:ys,read:Qt("week")}],["M",{re:Cr,read:Qt("month")}],["MM",{re:ys,read:Qt("month")}],["MMM",{re:xs,read:Z1(Aa.map(e=>e.slice(0,3)))}],["MMMM",{re:xs,read:Z1(Aa)}],["Y",{re:PS,read:Qt("year")}],["YY",{re:ys,read:(e,t)=>(e.year=+t+(+t>68?1900:2e3),!0)}],["YYYY",{re:DS,read:Qt("year")}],["Z",{re:X1,read:K1}],["ZZ",{re:X1,read:K1}]]),Q1,vo=null;function FS(e){if(e===Q1)return vo;if(Q1=e,vo=null,/[Ll]/.test(e.replace(OS,"")))return null;let t=e.match(RS);return t?(vo=t.map(r=>zS.get(r)??r.replace(/^\[|\]$/g,"")),vo):null}function WS(e,t,r){if(t==="x"||t==="X")return new Date((t==="X"?1e3:1)*Number(e));let n=FS(t);if(!n)return;let i={},a=e,l=0;for(let g of n){if(typeof g=="string"){l+=g.length;continue}let m=g.re.exec(a.slice(l));if(!m||!g.read(i,m[0]))return;a=a.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 h=i.hours||0,u=i.minutes||0,d=i.seconds||0,p=i.milliseconds||0;if(i.offset!==void 0)return new Date(Date.UTC(o,c,s,h,u,d,p+i.offset*6e4));if(!i.week)return new Date(o,c,s,h,u,d,p)}function BS(e,t,r){let n=WS(e,t,r);return n&&Xs(n)&&Sb(n,t)===e?n:void 0}var HS=/^[YMDHhmsSZXx\-/.:, T]*$/,jS=/^\s*(active|done|crit|milestone|vert)\s*$/,US=/^after\s+([\d\w- ]+)/,YS=/^until\s+([\d\w- ]+)/,GS=/^(\d+(?:\.\d+)?)([Mdhmswy]|ms)$/,VS=/[\s,]+/,qS=/^\d+$/,XS=new Set(ki.map(e=>e.toLowerCase())),KS=4e8,ZS=400,QS=200,JS=400;function Ib(e){let t=e===void 0?NaN:+e;return Number.isFinite(t)?t:Date.now()}function e4(e){let t=GS.exec(e.trim());return t?[Number.parseFloat(t[1]),t[2]]:[NaN,"ms"]}function J1(e,t){let r=new Set(e);for(let n of t.toLowerCase().split(VS))n!==""&&r.add(n);return[...r]}var t4=class{type="gantt";title;accTitle;accDescr;dateFormat="";axisFormat="";tickInterval;todayMarker="";includes=[];excludes=[];inclusiveEndDates=!1;topAxis=!1;displayMode="";weekday;weekend="saturday";sections=[];links=new Map;tasks=[];byId=new Map;currentSection="";taskCount=0;lastOrder=0;lastTaskId;options;now=0;work=0;includeSet=new Set;excludeSet=new Set;excludedDays=[];datedTokens=!1;constructor(e={}){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=J1(this.includes,e)}setExcludes(e){this.excludes=J1(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,`
91
+ `)}addSection(e){this.currentSection=e,this.sections.push(e)}addTask(e,t){let r=(t.startsWith(":")?t.slice(1):t).split(","),n={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=jS.exec(r[0]))!==null;)n[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 a=0;a<r.length;a++)r[a]=r[a].trim();r.length===3?n.id=r[0]:(this.taskCount++,n.id="task"+this.taskCount),r.length>1&&(n.raw.start=r[r.length-2]),n.raw.end=r[r.length-1],n.vert||(n.order=this.lastOrder++),this.tasks.push(n),this.lastTaskId=n.id,this.byId.set(n.id,n)}setLink(e,t){let r=Ia(t);for(let n of e.split(","))this.byId.has(n)&&this.links.set(n,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=Ib(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=ki.map((i,a)=>{let l=a||7;return r&&(l===t||l===t+1)||this.excludeSet.has(i.toLowerCase())}),this.datedTokens=this.includes.length>0||!HS.test(this.dateFormat.trim());for(let i of this.excludes)i!=="weekends"&&!XS.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 n=this.compileTasks();for(let i=0;!n&&i<10;i++)n=this.compileTasks();return this.tasks}isInvalidDate(e){let t=this.excludedDays[e.getDay()];if(!this.datedTokens)return t;let r=this.dateFormat.trim(),n=Cb(e),i=n;this.spend(QS),r!=="YYYY-MM-DD"&&(this.spend(JS+r.length*8),i=Sb(e,r));let a=l=>l.has(n)||i!==void 0&&l.has(i);return a(this.includeSet)?!1:t||a(this.excludeSet)}spend(e){if(this.work+=e,this.work>KS)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)),BS(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=[],n;for(let i of t.split(" ")){if(i==="")continue;let a=this.byId.get(i);a?r.push(a):(n??=[]).push(i)}if(n){let i=n;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")&&qS.test(t))return this.checked(new Date(Number(t)),t);let n=US.exec(t);if(n!==null){let l=this.references("after",n[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 a=new Date(t);if(!Xs(a)||a.getFullYear()<-1e4||a.getFullYear()>1e4)throw new Je("Invalid date:"+t,"semantic",{type:"gantt"});return a}checked(e,t){if(!Xs(e))throw new Je("Invalid date:"+t,"semantic",{type:"gantt"});return e}getEndDate(e,t){let r=t.trim(),n=YS.exec(r);if(n!==null){let c=this.references("until",n[1]),h;for(let u of c)(!h||u.startTime<h.startTime)&&(h=u);return h?h.startTime:this.today()}let i=this.dateFormat.trim(),a=this.parse(r,i);if(a)return this.inclusiveEndDates?Bn(a,1):a;let[l,s]=e4(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=Ab(e,l,s);return Xs(o)?o:new Date(e)}checkTaskDates(e){if(this.excludes.length===0||e.manualEndTime)return;let t=Bn(e.startTime,1),r=new Date(e.endTime),n=+Bn(r,1e4),i=!1,a=null;for(;+t<=+r;){if(this.spend(ZS),i||(a=+r),i=this.isInvalidDate(t),i&&(r.setDate(r.getDate()+1),+r>n))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=a===null?null:new Date(a)}},r4=["$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"],n4=/accTitle\s*:\s*/iy,i4=/accDescr\s*:\s*/iy,a4=/accDescr\s*\{\s*/iy,s4=/href\s+"/iy,l4=/call\s+/iy,o4=/click\s+/iy,c4=/\(\s*\)/y,eu=/weekday\s+(monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/iy,d4=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],tu=/weekend\s+(?:(friday)|saturday)\b/iy,h4=/\d\d\d\d-\d\d-\d\d\b/y,u4=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]]]]);function f4(e){let t=e.length,r=[],n=[],i=[],a=0,l=0,s=(u,d,p)=>{r.push(u),n.push(e.slice(d,p)),i.push(d),l=p},o=u=>(u.lastIndex=l,u.test(e)?u.lastIndex:-1),c=(u,d)=>{let p=e.indexOf(u,d);return p===-1?t:p},h=u=>{let d;switch(u|32){case 97:if((d=o(n4))>=0)return a=1,s(3,l,d),!0;if((d=o(i4))>=0)return a=2,s(5,l,d),!0;if((d=o(a4))>=0)return a=3,l=d,!0;break;case 104:if((d=o(s4))>=0)return a=4,l=d,!0;break;case 99:if((d=o(l4))>=0)return a=5,l=d,!0;if((d=o(o4))>=0)return a=7,l=d,!0;break;case 119:{eu.lastIndex=l;let g=eu.exec(e);if(g)return s(22+d4.indexOf(g[1].toLowerCase()),l,eu.lastIndex),!0;if(tu.lastIndex=l,g=tu.exec(e),g)return s(g[1]!==void 0?29:30,l,tu.lastIndex),!0;break}}let p=u4.get(u|32);if(p){for(let[g,m]of p)if((d=o(g))>=0)return s(m,l,d),!0}return!1};for(;;){if(l>=t){let d=38;switch(a){case 1:d=4;break;case 2:d=6;break;case 3:d=7;break;case 4:d=9;break;case 5:d=10;break;case 6:d=11;break;case 7:d=12;break}s(d,t,t);break}let u=e.charCodeAt(l);switch(a){case 0:{let d=e.charCodeAt(l+1);if(u===37)if(d!==37){let p=c(`
92
+ `,l+1);for(;e.charCodeAt(p)===10;)p++;l=p}else{if(e.charCodeAt(l+2)===123)return s(2,l,l+3),s(1,l,l),{types:r,texts:n,starts:i};l=c(`
93
+ `,l+2)}else if(u!==125&&d===37)l=c(`
94
+ `,l+2);else if(u===10){let p=l+1;for(;e.charCodeAt(p)===10;)p++;s(8,l,p)}else if(Xe(u))for(l++;l<t&&Xe(e.charCodeAt(l));)l++;else{if(h(u))break;if(u>=48&&u<=57&&o(h4)>=0)s(31,l,l+10);else if(u!==58){let p=l+1;for(;p<t;){let g=e.charCodeAt(p);if(g===58||g===10)break;p++}s(35,l,p)}else{let p=l+1;for(;p<t;){let g=e.charCodeAt(p);if(g===35||g===10||g===59)break;p++}s(p>l+1?36:37,l,p)}}break}case 1:case 2:{let d=a===1?4:6;a=0,s(d,l,c(`
95
+ `,l));break}case 3:u===125?(a=0,l++):s(7,l,c("}",l));break;case 4:u===34?(a=0,l++):s(9,l,c('"',l));break;case 5:if(u===40){let d=o(c4);d>=0?(a=0,l=d):(a=6,l++)}else s(10,l,c("(",l));break;case 6:u===41?(a=0,l++):s(11,l,c(")",l));break;case 7:if(Xe(u))a=0,l++;else{let d=l+1;for(;d<t&&!Xe(e.charCodeAt(d));)d++;s(12,l,d)}break}}return r.push(0),n.push(""),i.push(t),{types:r,texts:n,starts:i}}var p4=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],em="'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'",Fc=new Uint8Array(39);for(let e=22;e<=30;e++)Fc[e]=1;for(let e of[38,8,14,15,16,17,18,20,19,21,32,3,5,7,34,35,12])Fc[e]=1;function g4(e,t){let{types:r,texts:n,starts:i}=f4(e),a=0,l=o=>{let c=r[a];throw vt("gantt",e,i[a],`Expecting ${o}, got '${c===0?"1":r4[c]}'`)},s=(o="")=>{Fc[r[a]]!==1&&l(em+o)};for(r[a]!==13&&l("'gantt'"),a++;;){let o=r[a],c=n[a];switch(Fc[o]!==1&&l(em),a++,o){case 38:if(r[a]===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[a]!==4&&l("'acc_title_value'");let h=n[a++];s(),t.setAccTitle(h.trim());break}case 5:{r[a]!==6&&l("'acc_descr_value'");let h=n[a++];s(),t.setAccDescription(h.trim());break}case 7:s(),t.setAccDescription(c.trim());break;case 34:s(),t.addSection(c.slice(8));break;case 35:{r[a]!==36&&l("'taskData'");let h=n[a++];s(),t.addTask(c,h);break}case 12:{let h,u=null,d;r[a]===10?(h=n[a++],r[a]===11&&(u=n[a++]),r[a]===9?(d=n[a++],s()):s(u===null?", 'callbackargs', 'href'":", 'href'")):r[a]===9?(d=n[a++],r[a]===10?(h=n[a++],r[a]===11?(u=n[a++],s()):s(", 'callbackargs'")):s(", 'callbackname'")):l("'callbackname', 'href'"),h!==void 0&&t.setClickEvent(c,h,u),d!==void 0&&t.setLink(c,d);break}default:s(),t.setWeekday(p4[o-22])}}}var vn=1e3,$n=60*vn,bi=60*$n,_i=24*bi,pl=7*_i,Sf=30*_i,Wc=365*_i;function fc(e){e.setHours(0,0,0,0)}function ad(e){return{floor(t){t.setDate(t.getDate()-(t.getDay()+7-e)%7),fc(t)},offset:(t,r)=>t.setDate(t.getDate()+r*7),cycle:1/0,ms:pl}}var Ks={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*vn),field:e=>e.getUTCSeconds(),cycle:60,ms:vn},minute:{floor:e=>e.setTime(+e-e.getMilliseconds()-e.getSeconds()*vn),offset:(e,t)=>e.setTime(+e+t*$n),field:e=>e.getMinutes(),cycle:60,ms:$n},hour:{floor:e=>e.setTime(+e-e.getMilliseconds()-e.getSeconds()*vn-e.getMinutes()*$n),offset:(e,t)=>e.setTime(+e+t*bi),field:e=>e.getHours(),cycle:24,ms:bi},day:{floor:fc,offset:(e,t)=>e.setDate(e.getDate()+t),field:e=>e.getDate()-1,cycle:31,ms:_i},month:{floor(e){e.setDate(1),fc(e)},offset:(e,t)=>e.setMonth(e.getMonth()+t),field:e=>e.getMonth(),cycle:12,ms:Sf},year:{floor(e){e.setMonth(0,1),fc(e)},offset:(e,t)=>e.setFullYear(e.getFullYear()+t),cycle:1/0,ms:Wc}};function Bc(e,t,r){return Math.floor((+t-+e-(t.getTimezoneOffset()-e.getTimezoneOffset())*$n)/r)}function m4(e,t){return(e%t+t)%t}function pc(e,t,r){let n=e==="week"?ad(r):Ks[e];if(t<=1)return n;if(e==="millisecond")return{...n,floor:l=>l.setTime(Math.floor(+l/t)*t),offset:(l,s)=>l.setTime(+l+s*t)};if(e==="year")return{...n,floor(l){l.setFullYear(Math.floor(l.getFullYear()/t)*t),n.floor(l)},offset:(l,s)=>l.setFullYear(l.getFullYear()+s*t)};if(e==="week"){let l=new Date(0);return n.floor(l),{...n,floor(s){n.floor(s),n.offset(s,-m4(Bc(l,s,pl),t))},offset:(s,o)=>n.offset(s,o*t)}}let i=n.field,a=l=>i(l)%t===0;return{...n,floor(l){for(n.floor(l);Number.isFinite(+l)&&!a(l);n.floor(l))l.setTime(+l-1)},offset(l,s){for(let o=0;o<s&&Number.isFinite(+l);o++)do n.offset(l,1);while(Number.isFinite(+l)&&!a(l))}}}function Nb(e,t,r,n){let i=new Date(t-1);e.floor(i),e.offset(i,1),e.floor(i);let a=[],l=-1/0;for(;+i<=r&&+i>l;){if(a.length>=n)return;l=+i,a.push(l),e.offset(i,1),e.floor(i)}return a}function tm(e,t,r){let n=(t-e)/Math.max(0,r),i=Math.floor(Math.log10(n)),a=n/Math.pow(10,i),l=a>=Math.sqrt(50)?10:a>=Math.sqrt(10)?5:a>=Math.SQRT2?2:1;return Math.pow(10,i)*l}var Zi=[["second",1,vn],["second",5,5*vn],["second",15,15*vn],["second",30,30*vn],["minute",1,$n],["minute",5,5*$n],["minute",15,15*$n],["minute",30,30*$n],["hour",1,bi],["hour",3,3*bi],["hour",6,6*bi],["hour",12,12*bi],["day",1,_i],["day",2,2*_i],["week",1,pl],["month",1,Sf],["month",3,3*Sf],["year",1,Wc]];function y4(e,t,r){let n=(t-e)/r,i=0;for(;i<Zi.length&&Zi[i][2]<=n;)i++;let a;if(i===Zi.length)a=pc("year",Math.max(1,tm(e/Wc,t/Wc,r)),0);else if(i===0)a=pc("millisecond",Math.max(tm(e,t,r),1),0);else{let[l,s]=Zi[n/Zi[i-1][2]<Zi[i][2]/n?i-1:i];a=pc(l,s,0)}return Nb(a,e,t,4*r+8)??[]}var x4=/^([1-9]\d*)(millisecond|second|minute|hour|day|week|month)$/,b4=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function w4(e,t,r,n,i){let a=x4.exec(e);if(!a)return;let l=parseInt(a[1],10),s=a[2],o=pc(s,l,Math.max(0,b4.indexOf(t)));if(!((n-r)/(Math.min(l,o.cycle)*o.ms)>i))return Nb(o,r,n,i)}function Ut(e,t,r){let n=e<0?"-":"",i=String(n?-e:e);return n+(i.length<r?t.repeat(r-i.length)+i:i)}function Wn(e,t){let r=new Date(+e);return t.floor(r),r}function rm(e,t){let r=ad(t),n=Wn(e,Ks.year);return Bc(Wn(new Date(+n-1),r),Wn(e,r),pl)}function ru(e){let t=ad(4),r=e.getDay(),n=Wn(r>=4||r===0?e:new Date(+e-1),t);return r>=4||r===0||(t.offset(n,1),t.floor(n)),n}var v4=new Map([["-",""],["_"," "],["0","0"]]);function gc(e,t){let r="",n=0,i=e.length;for(let a=0;a<i;a++){if(e.charCodeAt(a)!==37)continue;r+=e.slice(n,a);let l=e.charAt(++a),s=v4.get(l);s!==void 0?l=e.charAt(++a):s=l==="e"?" ":"0",r+=$4(l,t,s),n=a+1}return r+e.slice(n)}function $4(e,t,r){switch(e){case"a":return ki[t.getDay()].slice(0,3);case"A":return ki[t.getDay()];case"b":return Aa[t.getMonth()].slice(0,3);case"B":return Aa[t.getMonth()];case"c":return gc("%x, %X",t);case"d":case"e":return Ut(t.getDate(),r,2);case"f":return Ut(t.getMilliseconds(),r,3)+"000";case"g":return Ut(ru(t).getFullYear()%100,r,2);case"G":return Ut(ru(t).getFullYear()%1e4,r,4);case"H":return Ut(t.getHours(),r,2);case"I":return Ut(t.getHours()%12||12,r,2);case"j":return Ut(1+Bc(Wn(t,Ks.year),Wn(t,Ks.day),_i),r,3);case"L":return Ut(t.getMilliseconds(),r,3);case"m":return Ut(t.getMonth()+1,r,2);case"M":return Ut(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 Ut(t.getSeconds(),r,2);case"u":return String(t.getDay()||7);case"U":return Ut(rm(t,0),r,2);case"V":{let n=ru(t),i=Wn(n,Ks.year),a=Wn(i,ad(4));return Ut(Bc(a,n,pl)+(i.getDay()===4?1:0),r,2)}case"w":return String(t.getDay());case"W":return Ut(rm(t,1),r,2);case"x":return gc("%-m/%-d/%Y",t);case"X":return gc("%-I:%M:%S %p",t);case"y":return Ut(t.getFullYear()%100,r,2);case"Y":return Ut(t.getFullYear()%1e4,r,4);case"Z":{let n=t.getTimezoneOffset(),i=Math.abs(n);return(n>0?"-":"+")+Ut(Math.floor(i/60),"0",2)+Ut(i%60,"0",2)}case"%":return"%";default:return e}}var k4=800,M4=240,Qi=8,_4=/<br\s*\/?>/gi;function Yr(e,t,r,n){let i=e.gantt?.[t];return typeof i=="number"&&Number.isFinite(i)?Math.min(n,Math.max(r,i)):void 0}function nu(e,t){let r=e.gantt?.[t];return typeof r=="string"?r:void 0}function E4(e,t){return e.gantt?.[t]===!0}function nm(e,t,r){let n=Ve(e.replace(_4," "),!1,t,r,4e3);return n.lines.length<=1?n:{...n,lines:[n.lines[0]],widths:[n.widths[0]],width:n.widths[0],height:n.lineHeight}}function mc(e){return Number.isFinite(+e.startTime)&&Number.isFinite(+e.endTime)}function A4(e,t,r){let n=e.filter(mc).sort((l,s)=>+l.startTime-+s.startTime||l.order-s.order),i=[];for(let l of n){let s=+l.startTime,o=0;for(;o<i.length&&s<i[o];)o++;i[o]=+l.endTime,r.set(l,t+o)}let a=i.length;for(let l of e)r.has(l)||r.set(l,t+a++);return Math.max(a,1)}function T4(e,t,r){let n=r.fontSize??16,i=r.measurer??bt(r.fontFamily),a=r.padding??8,l=Ib(r.now),s=Yr(t,"fontSize",4,72)??Math.round(n*.8125),o=Yr(t,"sectionFontSize",4,72)??s,c=Math.round(n*.75),h=Yr(t,"barHeight",4,400)??Math.round(s*1.85),u=Yr(t,"barGap",0,400)??Math.round(h/4),d=h+u,p=Math.round(Yr(t,"numberSectionStyles",1,1e3)??4),g=e.displayMode==="compact",m=e.topAxis||E4(t,"topAxis"),v=e.getTasks(l),x=v.filter(we=>!we.vert),k=v.filter(we=>we.vert&&mc(we)),b=new Map;for(let we of x)b.has(we.section)||b.set(we.section,b.size);let C=new Map,N=[];if(g){let we=new Map;for(let ke of x){let Ne=we.get(ke.section);Ne?Ne.push(ke):we.set(ke.section,[ke])}for(let[ke,Ne]of we){let Be=A4(Ne,N.length,C);for(let Pe=0;Pe<Be;Pe++)N.push(ke)}}else for(let we of x)C.set(we,N.length),N.push(we.section);let R=N.length,O=1/0,P=-1/0;for(let we of v)mc(we)&&(O=Math.min(O,+we.startTime),P=Math.max(P,+we.endTime));let H=O<=P,I=Ve(e.title,!1,i,n,4e3,1),G=I.height>0?I.height+16:0;if(!H){let we=Math.ceil(Math.max(I.width,1)+2*a),ke=Math.ceil(Math.max(I.height,1)+2*a),Ne=Le(I,we/2,a+I.height/2,' class="pele-title" font-weight="var(--_tw)"');return{svg:mt("gantt",we,ke,n,r,e,Ne),width:we,height:ke,links:[]}}let Z=new Map,z=0;for(let we of b.keys()){let ke=Ve(we,!1,i,o,180);Z.set(we,ke),z=Math.max(z,ke.width)}let W=e.axisFormat||(e.dateFormat==="D"?"%d":nu(t,"axisFormat")??"%Y-%m-%d"),S=we=>gc(W,new Date(we)),A=Math.max(i.width(S(O),c,0),i.width(S(P),c,0)),$=a+(Yr(t,"leftPadding",0,2e3)??Math.max(z>0?z+24:0,A/2)),y=Yr(t,"rightPadding",0,2e3)??Math.max(16,A/2),E=td(r,Yr(t,"useWidth",100,2e4)??k4,280),w=Math.max(M4,E-$-y-a),T=$+w,_=P>O?w/(P-O):0,M=we=>_===0?$+w/2:$+(we-O)*_,U=Math.round(c*1.75),j=Yr(t,"topPadding",0,2e3),Y=Yr(t,"gridLineStartPadding",0,2e3),D=a+G+(m?U:0),L=Math.max(D,j??0),F=j!==void 0&&Y!==void 0?Math.max(0,Math.min(j-Y,L-D)):0,V=Math.max(R,1)*d,X=L+V,Q=[],ne=T+y;for(let we of x){let ke=nm(we.task,i,s),Ne=C.get(we);if(!mc(we)){let se=$+Qi+ke.width/2;ne=Math.max(ne,se+ke.width/2),Q.push({task:we,label:ke,row:Ne,x0:NaN,x1:NaN,labelX:se,inside:!1});continue}let Be=M(+we.startTime),Pe=Math.max(M(+(we.renderEndTime??we.endTime)),Be+(we.milestone?0:2));if(we.milestone){let se=Be+(M(+we.endTime)-Be)/2;Be=se-h/2,Pe=se+h/2}let q=!we.milestone&&ke.width+2*Qi<=Pe-Be,me=(Be+Pe)/2;if(!q){let se=Pe+Qi+ke.width<=T+y,ve=Be-Qi-ke.width>=$;me=se||!ve?Pe+Qi+ke.width/2:Be-Qi-ke.width/2,ne=Math.max(ne,me+ke.width/2)}Q.push({task:we,label:ke,row:Ne,x0:Be,x1:Pe,labelX:me,inside:q})}let B=e.tickInterval||nu(t,"tickInterval")||"",K=e.weekday??nu(t,"weekday")??"sunday",ie=Math.max(2,Math.min(10,Math.floor(w/(A+24)))),le=w4(B,K,O,P,Math.ceil(w/3))??y4(O,P,ie),J="",te="",ae="",ee=-1/0,re="",de=X+U/2+2,ye=L-F-U/2-2;for(let we of le){let ke=M(we);J+=`M${f(ke)},${f(L-F)}V${f(X)}`;let Ne=S(we),Be=i.width(Ne,c,0);if(ke-Be/2<ee+8||Ne===re)continue;ee=ke+Be/2,re=Ne,ne=Math.max(ne,ee);let Pe=`text-anchor="middle">${tt(Ne)}</text>`;te+=`<text x="${f(ke)}" y="${f(de+c*.35)}" ${Pe}`,m&&(ae+=`<text x="${f(ke)}" y="${f(ye+c*.35)}" ${Pe}`)}let oe="",xe="",fe=[],pe=X+U+4,Me=Math.round(s*1.5);for(let we of[...k].sort((ke,Ne)=>+ke.startTime-+Ne.startTime)){let ke=M(+we.startTime),Ne=nm(we.task,i,s),Be=Math.max(a+Ne.width/2,ke),Pe=0;for(;Pe<fe.length&&Be-Ne.width/2<fe[Pe]+8;)Pe++;fe[Pe]=Be+Ne.width/2,ne=Math.max(ne,fe[Pe]),oe+=`<path class="pele-vert" data-id="${Ge(we.id)}" d="M${f(ke)},${f(L-F)}V${f(X)}"/>`,xe+=Le(Ne,Be,pe+Pe*Me+Me/2,` class="pele-vert-label" data-id="${Ge(we.id)}"`)}let Ae=Math.ceil(Math.max(ne,a+I.width)+a),ce=Math.ceil(X+U+(fe.length>0?4+fe.length*Me:0)+a),ge="",be="";for(let we=0;we<R;){let ke=N[we],Ne=we+1;for(;Ne<R&&N[Ne]===ke;)Ne++;let Be=b.get(ke)%p,Pe=L+we*d,q=(Ne-we)*d;(b.size>1||ke!=="")&&(ge+=`<rect class="pele-section pele-section-${Be}" x="0" y="${f(Pe)}" width="${Ae}" height="${f(q)}" fill="${Be%2===0?"var(--_s)":"none"}"/>`);let me=Z.get(ke);be+=Le(me,a+8+me.width/2,Pe+q/2,` class="pele-section-label" data-id="${Ge(ke)}"`,r.icons),we=Ne}let Ie="";if((e.excludes.length>0||e.includes.length>0)&&+Ab(new Date(O),6,"y")>P){let we,ke,Ne=()=>{if(!we||!ke)return;let Be=new Date(we);Be.setHours(0,0,0,0);let Pe=new Date(ke);Pe.setHours(23,59,59,999);let q=Math.max($,M(+Be)),me=Math.min(T,M(+Pe));me>q&&(Ie+=`<rect x="${f(q)}" y="${f(L)}" width="${f(me-q)}" height="${f(V)}"/>`),we=ke=void 0};for(let Be=new Date(O);+Be<=P;Be=Bn(Be,1))e.isInvalidDate(Be)?(we??=Be,ke=Be):Ne();Ne()}let Re=[],ze="";for(let we of Q){let ke=we.task,Ne=L+we.row*d+d/2,Be=ke.active?"active":ke.done?"done":"",Pe="pele-task";Be&&(Pe+=" pele-"+Be),ke.crit&&(Pe+=" pele-crit"),ke.milestone&&(Pe+=" pele-milestone"),ke.classes.includes("clickable")&&(Pe+=" pele-clickable");let q="",me="";if(Number.isNaN(we.x0))Pe+=" pele-unscheduled",me=' fill="var(--_m)"';else{let _e=ke.crit?pf:"var(--_c)",Te=Be==="done"?'fill="var(--_a)"':Be==="active"?`fill="${_e}" fill-opacity="0.25"`:`fill="${_e}"`,Oe=`stroke="${Be==="done"&&!ke.crit?"var(--_b)":_e}"`;if(ke.milestone){let Ce=(we.x0+we.x1)/2,He=h/2;q=`<path d="M${f(Ce)},${f(Ne-He)}L${f(Ce+He)},${f(Ne)}L${f(Ce)},${f(Ne+He)}L${f(Ce-He)},${f(Ne)}Z" ${Te} ${Oe} stroke-linejoin="round"/>`}else q=`<rect x="${f(we.x0)}" y="${f(Ne-h/2)}" width="${f(we.x1-we.x0)}" height="${f(h)}" ${Te} ${Oe}${xt}/>`;we.inside?me=Be===""?' fill="var(--_bg)"':"":Be==="done"&&(me=' fill="var(--_m)"')}let se=q+Le(we.label,we.labelX,Ne,` class="pele-label"${me}`),ve=e.links.get(ke.id);ve!==void 0&&(se=Na(se,ve,ke.id,Re,r)),ze+=`<g class="${Pe}" data-id="${Ge(ke.id)}">${se}</g>`}let he="";if(e.todayMarker!=="off"&&l>=O&&l<=P&&P>O){let we=M(l),ke=L-F,Ne=e.todayMarker?Ot(e.todayMarker.split(",")).line:"";he=`<g class="pele-today"><path d="M${f(we)},${f(ke)}V${f(X)}" fill="none" stroke="var(--_c)" stroke-width="2"${Ne}/>`+(Ne?"":`<path d="M${f(we-4)},${f(ke-5)}H${f(we+4)}L${f(we)},${f(ke+1)}Z" fill="var(--_c)"/>`)+"</g>"}let $e=`M${f($)},${f(X)}H${f(T)}`+(m?`M${f($)},${f(L-F)}H${f(T)}`:""),Se=Le(I,Ae/2,a+I.height/2,' class="pele-title" font-weight="var(--_tw)"')+(ge?`<g class="pele-sections">${ge}</g>`:"")+(Ie?`<g class="pele-excluded" fill="var(--_a)">${Ie}</g>`:"")+`<g class="pele-grid" fill="none"><path d="${J}" stroke="var(--_b)" stroke-dasharray="1 3"/><path d="${$e}" stroke="var(--_b)"/></g>`+(oe?`<g class="pele-verts" fill="none" stroke="var(--_l)" stroke-width="1.5" stroke-dasharray="4 3">${oe}</g>`:"")+he+`<g class="pele-tasks" font-size="${f(s)}">${ze}</g><g class="pele-section-labels" font-size="${f(o)}">${be}</g><g class="pele-axis" font-size="${c}" fill="var(--_m)">${te}${ae}</g>`+(xe?`<g class="pele-vert-labels" font-size="${f(s)}">${xe}</g>`:"");return{svg:mt("gantt",Ae,ce,n,r,e,Se),width:Ae,height:ce,links:Re}}var S4={type:"gantt",parse(e,t,r){let n=new t4;r&&(n.title=r);let i=t.gantt?.displayMode;return typeof i=="string"&&(n.displayMode=i),g4(e,n),n},render:T4},Wt={NORMAL:0,REVERSE:1,HIGHLIGHT:2,MERGE:3,CHERRY_PICK:4};function ar(e){throw new Je(e,"semantic",{type:"gitGraph"})}function im(e){return e==="REVERSE"?Wt.REVERSE:e==="HIGHLIGHT"?Wt.HIGHLIGHT:Wt.NORMAL}function C4(e,t){e.dir&&t.setDirection(e.dir);for(let r of e.statements)I4(r,t)}function I4(e,t){switch(e.$type){case"Commit":t.commit({id:e.id,msg:e.message??"",type:e.type!==void 0?im(e.type):Wt.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?im(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 N4(e,t,r){let n=t.gitGraph,i=typeof n?.mainBranchName=="string"?n.mainBranchName:"main",a=typeof n?.mainBranchOrder=="number"?n.mainBranchOrder:0,l=new Map,s=new Map([[i,null]]),o=new Map([[i,a]]),c=[],h=null,u=i,d="LR",p=0,g=()=>{for(let k=p+1;;k+=2654435761){let b=`${p}-${(Math.imul(k,2654435761)>>>0).toString(16).padStart(8,"0").slice(0,7)}`;if(!l.has(b))return b}},m=k=>{h=k,l.set(k.id,k),s.set(u,k.id)},v=k=>{s.has(k)||ar(`Trying to checkout branch which is not yet created. (Help try using "branch ${k}")`),u=k;let b=s.get(k);h=b?l.get(b)??null:null};C4(e,{setDirection(k){d=k},commit({msg:k,id:b,type:C,tags:N}){let R={id:b||g(),message:k,seq:p++,type:C??Wt.NORMAL,tags:N?[...N]:[],parents:h===null?[]:[h.id],branch:u};l.has(R.id)&&c.push(`Commit ID ${R.id} already exists`),m(R)},branch({name:k,order:b}){s.has(k)&&ar(`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${k}")`),s.set(k,h!==null?h.id:null),o.set(k,b),v(k)},merge({branch:k,id:b,type:C,tags:N}){let R=s.get(u),O=s.get(k),P=R?l.get(R):void 0,H=O?l.get(O):void 0;P&&H&&P.branch===k&&ar(`Cannot merge branch '${k}' into itself.`),u===k&&ar('Incorrect usage of "merge". Cannot merge a branch to itself'),P===void 0&&ar(`Incorrect usage of "merge". Current branch (${u})has no commits`),s.has(k)||ar(`Incorrect usage of "merge". Branch to be merged (${k}) does not exist`),H===void 0&&ar(`Incorrect usage of "merge". Branch to be merged (${k}) has no commits`),P===H&&ar('Incorrect usage of "merge". Both branches have same head'),b&&l.has(b)&&ar(`Incorrect usage of "merge". Commit with id:${b} already exists, use different custom id`),m({id:b||g(),message:`merged branch ${k} into ${u}`,seq:p++,parents:h===null?[]:[h.id,O||""],branch:u,type:Wt.MERGE,customType:C,customId:!!b,tags:N?[...N]:[]})},cherryPick({id:k,targetId:b,tags:C,parent:N}){let R=k?l.get(k):void 0;if(R===void 0&&ar('Incorrect usage of "cherryPick". Source commit id should exist and provided'),N&&!R.parents.includes(N)&&ar("Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit."),R.type===Wt.MERGE&&!N&&ar("Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified."),b&&l.has(b))return;R.branch===u&&ar('Incorrect usage of "cherryPick". Source commit is already on current branch');let O=s.get(u);(!O||!l.has(O))&&ar(`Incorrect usage of "cherry-pick". Current branch (${u})has no commits`),m({id:g(),message:`cherry-picked ${R.message} into ${u}`,seq:p++,parents:h===null?[]:[h.id,R.id],branch:u,type:Wt.CHERRY_PICK,tags:C?C.filter(Boolean):[`cherry-pick:${R.id}${R.type===Wt.MERGE?`|parent:${N}`:""}`]})},checkout:v});let x=[...o].map(([k,b],C)=>({name:k,order:b??parseFloat(`0.${C}`)})).sort((k,b)=>k.order-b.order).map(k=>k.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,`
96
+ `):void 0,direction:d,commits:l,branches:s,lanes:x,currentBranch:u,head:h,warnings:c}}var Rb={name:"REFERENCE",pattern:/\w([-\./\w]*[-\w])?/y},Ob=[Rb];function xr(e){return{name:e,pattern:e,longer:Ob}}var am=[xr("cherry-pick"),{name:"gitGraph:",pattern:"gitGraph:"},xr("HIGHLIGHT"),{...zr("gitGraph"),longer:Ob},xr("checkout"),xr("REVERSE"),{name:"parent:",pattern:"parent:"},xr("commit"),xr("NORMAL"),xr("branch"),{name:"order:",pattern:"order:"},xr("switch"),{name:"type:",pattern:"type:"},xr("merge"),{name:"msg:",pattern:"msg:"},{name:"tag:",pattern:"tag:"},{name:"id:",pattern:"id:"},xr("LR"),xr("TB"),xr("BT"),{name:":",pattern:":"},{...nn,opener:/[\t ]*accDescr\s*{/y},Wr,Br,{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y},Si,Gn,Vn,cr,an,sn,Rb];function R4(e){let t=new Er($r(e,am,"gitGraph"),am,"gitGraph"),r={$type:"GitGraph",statements:[]},n=()=>{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?Dr(t.take()):t.fail("a branch name"),a=()=>Dr(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=_r(t.take()),n();break;case 22:r.accTitle=Mr(t.take()),n();break;case 23:r.title=kr(t.take()),n();break;case 7:{t.i++;let s={$type:"Commit",tags:[]};for(;;)if(t.accept(16))s.id=a();else if(t.accept(15))s.tags.push(a());else if(t.accept(12))s.type=l();else if(t.accept(14)||t.kinds[t.i]===25)s.message=a();else break;n(),r.statements.push(s);break}case 9:{t.i++;let s={$type:"Branch",name:i()};t.accept(10)&&(s.order=parseInt(t.expect(24))),n(),r.statements.push(s);break}case 13:{t.i++;let s={$type:"Merge",branch:i(),tags:[]};for(;;)if(t.accept(16))s.id=a();else if(t.accept(15))s.tags.push(a());else if(t.accept(12))s.type=l();else break;n(),r.statements.push(s);break}case 4:case 11:{t.i++;let s={$type:"Checkout",branch:i()};n(),r.statements.push(s);break}case 0:{t.i++;let s={$type:"CherryPicking",tags:[]};for(;;)if(t.accept(16))s.id=a();else if(t.accept(15))s.tags.push(a());else if(t.accept(6))s.parent=a();else break;n(),r.statements.push(s);break}default:t.fail("a statement, a title, or a line break")}return r}var O4=/<(?!br\s*\/?>)/gi,L4=/:fa-/g,D4=/<br\s*\/?>|fl°°?\w+¶ß|&#?\w+;|[\ud800-\udbff][\udc00-\udfff]|[\s\S]/gi;function Hn(e,t,r,n,i=0){let a=e;return a!==void 0&&(a.includes("<")&&(a=a.replace(O4,"&lt;")),a.includes(":fa-")&&(a=a.replace(L4,"&colon;fa-"))),Ve(a,!1,t,r,n,i)}function wr(e,t,r,n,i=0){let a=Hn(e,t,r,n,i);if(e===void 0||a.width<=n)return a;let l="",s=0;for(let o of e.match(D4)??[]){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>n&&(l+=`
97
+ `,s=0),s+=c}l+=o}return Hn(l,t,r,n,i)}var zt=7,P4=44,z4=44,$o=36,ko=8,ai=20,bs=20,Ls=7,sm=6,iu=Math.SQRT1_2,lm=["normal","reverse","highlight","merge","cherry-pick"];function Mo(e,t,r){let n=e.gitGraph?.[t];return typeof n=="boolean"?n:r}function om(e){return Ls+4+e.width+6}function F4(e,t,r,n){let i=`cx="${f(t)}" cy="${f(r)}"`;if(e===Wt.HIGHLIGHT)return`<rect x="${f(t-zt-1)}" y="${f(r-zt-1)}" width="${2*zt+2}" height="${2*zt+2}" rx="2" fill="${n}"/>`;if(e===Wt.MERGE)return`<circle ${i} r="${zt-1}" fill="var(--_bg)" stroke="${n}" stroke-width="2"/><circle ${i} r="2.5" fill="${n}"/>`;let a=`<circle ${i} r="${zt}" fill="${n}"/>`;return e===Wt.REVERSE?a+`<path d="M${f(t-3)},${f(r-3)}l6,6M${f(t-3)},${f(r+3)}l6,-6" fill="none" stroke="var(--_bg)" stroke-width="1.5" stroke-linecap="round"/>`:e===Wt.CHERRY_PICK?a+`<path d="M${f(t-2.6)},${f(r+1)}L${f(t+.8)},${f(r-4.2)}L${f(t+2.6)},${f(r+1)}" fill="none" stroke="var(--_bg)" stroke-linejoin="round"/><circle cx="${f(t-2.6)}" cy="${f(r+2.2)}" r="1.8" fill="var(--_bg)"/><circle cx="${f(t+2.6)}" cy="${f(r+2.2)}" r="1.8" fill="var(--_bg)"/>`:a}function W4(e,t,r){return e.direction!=="LR"?cm(e,t,r,e.direction):dr(r,n=>cm(e,t,r,n?"TB":"LR"))}function cm(e,t,r,n){let i=r.fontSize??16,a=Math.round(i*.75),l=r.measurer??bt(r.fontFamily),s=r.padding??8,o=Mo(t,"showBranches",!0),c=Mo(t,"showCommitLabel",!0),h=Mo(t,"rotateCommitLabel",!0),u=Mo(t,"parallelCommits",!1),d=n!=="LR",p=n==="BT",g=new Map;e.lanes.forEach((B,K)=>g.set(B,K));let m=e.lanes.length,v=Math.round(i*.875),x=e.lanes.map(B=>Hn(o?B:"",l,v,4e3)),k=[],b=new Map;for(let B of[...e.commits.values()].sort((K,ie)=>K.seq-ie.seq)){let K=c&&B.type!==Wt.CHERRY_PICK&&(B.type!==Wt.MERGE||B.customId===!0),ie=[];for(let J of B.tags){let te=Hn(J,l,a,4e3);te.lines.length>0&&ie.push(te)}let le={commit:B,index:k.length,lane:g.get(B.branch)??0,m:0,label:K?Hn(B.id,l,a,4e3):void 0,tags:ie};k.push(le),b.set(B.id,le)}let C=new Float64Array(k.length),N=new Float64Array(k.length),R=new Float64Array(m).fill(zt),O=new Float64Array(m).fill(zt);k.forEach((B,K)=>{let{label:ie,tags:le}=B,J=0,te=0;for(let oe of le){let xe=om(oe);d?(J=Math.max(J,oe.height),te+=xe+4):(J=Math.max(J,xe),te+=oe.height+3)}let ae=0,ee=0;ie!==void 0&&ie.lines.length>0&&(h?ee=3+iu*(ie.width+ie.height):(ae=d?ie.height:ie.width,ee=6+(d?ie.width:ie.height))),C[K]=Math.max(zt,J/2,ae/2),N[K]=J/2;let re=zt+(le.length>0?sm+te:0),de=zt+ee,ye=B.lane;R[ye]=Math.max(R[ye],d?de:re),O[ye]=Math.max(O[ye],d?re:de)});let P=new Float64Array(k.length);d||k.forEach((B,K)=>{if(N[K]!==0)for(let ie of B.commit.parents){let le=b.get(ie);le!==void 0&&le.lane<B.lane&&(P[K]=N[K]+4)}});let H=(B,K)=>Math.max(P4,C[B]+C[K]+ko,P[K]>0?C[B]+$o+P[K]:0);k.forEach((B,K)=>{if(!u){B.m=K===0?0:k[K-1].m+H(K-1,K);return}let ie=0;for(let le of B.commit.parents){let J=b.get(le);J===void 0||J.index>=K||(ie=Math.max(ie,J.m+H(J.index,K)))}B.m=ie});let I=0;for(let B of k)I=Math.max(I,B.m);let G=new Float64Array(m);for(let B=0;B<m;B++){let K=x[B],ie=K.lines.length===0?0:d?K.width/2+8:K.height/2+2;R[B]=Math.max(R[B],ie),O[B]=Math.max(O[B],ie),B>0&&(G[B]=G[B-1]+Math.max(z4,O[B-1]+R[B]+ko))}let Z=(B,K)=>d?K:B,z=(B,K)=>d?p?-B:B:K,W=(B,K)=>`${f(Z(B,K))},${f(z(B,K))}`,S=1/0,A=1/0,$=-1/0,y=-1/0,E=(B,K,ie,le)=>{B<S&&(S=B),K<A&&(A=K),ie>$&&($=ie),le>y&&(y=le)},w="";if(o)for(let B=0;B<m;B++){let K=x[B],ie=kt(B),le=G[B],J=K.width+16,te=K.height+4,ae=K.lines.length===0?-ai:-ai-(d?te:J),ee=Z(ae+(d?te:J)/2,le),re=z(ae+(d?te:J)/2,le);E(Z(-ai,le),z(-ai,le),Z(-ai,le),z(-ai,le)),E(Z(I+bs,le),z(I+bs,le),Z(I+bs,le),z(I+bs,le)),w+=`<g class="pele-branch" data-id="${Ge(e.lanes[B])}"><path class="pele-lane" d="M${W(-ai,le)}L${W(I+bs,le)}" stroke="${ie}" stroke-dasharray="2 4"/>`,K.lines.length>0&&(E(ee-J/2,re-te/2,ee+J/2,re+te/2),w+=`<rect x="${f(ee-J/2)}" y="${f(re-te/2)}" width="${f(J)}" height="${f(te)}" fill="${ie}"${xt}/>`+Le(K,ee,re,' class="pele-label" fill="var(--_bg)"')),w+="</g>"}let T=Array.from({length:m},()=>[]);for(let B of k)T[B.lane].push(B.m);if(u)for(let B of T)B.sort((K,ie)=>K-ie);let _=(B,K,ie)=>{let le=T[B],J=0,te=le.length;for(;J<te;){let ae=J+te>>1;le[ae]<=K?J=ae+1:te=ae}return J<le.length&&le[J]<ie},M="",U="";for(let B of k){let{commit:K}=B,ie=G[B.lane],le=B.m;for(let J=0;J<K.parents.length;J++){let te=b.get(K.parents[J]);if(te===void 0||te===B)continue;let ae=G[te.lane],ee=te.m;if(te.lane===B.lane){U+=`<path class="pele-edge" d="M${W(ee,ae)}L${W(le,ie)}" stroke="${kt(B.lane)}"/>`;continue}let re=J>0&&K.type===Wt.MERGE,de=J>0&&!re,ye=`M${W(ee,ae)}`;if(le<=ee){let oe=(ee+le)/2;ye+=`C${W(oe,ae)} ${W(oe,ie)} ${W(le,ie)}`}else if(!re&&!_(B.lane,ee,le)){let oe=Math.min($o,le-ee);ye+=`C${W(ee+oe/2,ae)} ${W(ee+oe/2,ie)} ${W(ee+oe,ie)}L${W(le,ie)}`}else{let oe=te.lane<B.lane&&le-P[B.index]>ee?le-P[B.index]:le,xe=Math.min($o,oe-ee),fe=ae;(!re||_(te.lane,ee,le))&&(fe=ae>ie?ie+O[B.lane]+ko/2:ie-R[B.lane]-ko/2,xe=Math.min($o,(oe-ee)/2),ye+=`C${W(ee+xe/2,ae)} ${W(ee+xe/2,fe)} ${W(ee+xe,fe)}`),ye+=`L${W(oe-xe,fe)}C${W(oe-xe/2,fe)} ${W(oe-xe/2,ie)} ${W(oe,ie)}`,oe<le&&(ye+=`L${W(le,ie)}`)}M+=`<path class="pele-edge${re?" pele-edge-merge":de?" pele-edge-cherry-pick":""}" d="${ye}" stroke="${kt(re?te.lane:B.lane)}"${de?' stroke-dasharray="4 3"':""}/>`}}let j="";for(let B of k){let{commit:K,label:ie,tags:le}=B,J=Z(B.m,G[B.lane]),te=z(B.m,G[B.lane]),ae=K.customType??K.type;E(J-zt-1,te-zt-1,J+zt+1,te+zt+1);let ee=K.type<Wt.MERGE&&K.message!==""?`<title>${Ge(K.message)}</title>`:"";if(ee+=F4(ae,J,te,kt(B.lane)),ie!==void 0&&ie.lines.length>0){let ye=ie.width,oe=ie.height,xe=(fe,pe)=>`<rect x="${f(fe-ye/2-2)}" y="${f(pe-oe/2+2)}" width="${f(ye+4)}" height="${f(oe-4)}" rx="3" fill="var(--_bg)"/>`;if(h){let fe=iu*oe/2,pe=d?J-zt-3-fe:J+3,Me=d?te:te+zt+3+fe,Ae=iu*ye+fe;E(pe-Ae,p?Me-Ae:Me-fe,pe+fe,p?Me+fe:Me+Ae),ee+=`<g class="pele-commit-label" transform="rotate(${p?45:-45} ${f(pe)} ${f(Me)})">`+xe(pe-ye/2,Me)+Le(ie,pe-ye/2,Me,"")+"</g>"}else{let fe=d?J-zt-6-ye/2:J,pe=d?te:te+zt+6+oe/2;E(fe-ye/2,pe-oe/2,fe+ye/2,pe+oe/2),ee+=`<g class="pele-commit-label">${xe(fe,pe)}${Le(ie,fe,pe,"")}</g>`}}let re=zt+sm;for(let ye=d?0:le.length-1;ye>=0&&ye<le.length;ye+=d?1:-1){let oe=le[ye],xe=om(oe),fe=oe.height,pe=d?J+re:J-xe/2,Me=d?te:te-re-fe/2;re+=d?xe+4:fe+3,E(pe,Me-fe/2,pe+xe,Me+fe/2),ee+=`<g class="pele-tag"><path d="M${f(pe)},${f(Me)}L${f(pe+Ls)},${f(Me-fe/2)}H${f(pe+xe)}V${f(Me+fe/2)}H${f(pe+Ls)}Z" fill="var(--_s)" stroke="var(--_b)" stroke-linejoin="round"/><circle cx="${f(pe+Ls)}" cy="${f(Me)}" r="1.5" fill="var(--_b)"/>`+Le(oe,pe+Ls+4+oe.width/2,Me,' fill="var(--_fg)"')+"</g>"}let de=K.type===Wt.MERGE&&ae!==Wt.MERGE?" pele-commit-merge":"";j+=`<g class="pele-commit pele-commit-${lm[ae]??lm[0]}${de}" data-id="${Ge(K.id)}">${ee}</g>`}S>$&&E(0,0,0,0);let Y=Ve(e.title,!1,l,i,4e3,1),D=Y.height>0?Y.height+16:0,L=Math.max($-S,Y.width),F=Math.ceil(L+2*s),V=Math.ceil(y-A+D+2*s),X=s-S+(L-($-S))/2,Q=s+D-A,ne=Le(Y,F/2,s+Y.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${f(X)},${f(Q)})">`+(w?`<g class="pele-branches" fill="none" font-size="${v}">${w}</g>`:"")+(M||U?`<g class="pele-edges" fill="none" stroke-width="2" stroke-linecap="round">${M}${U}</g>`:"")+(j?`<g class="pele-commits" font-size="${a}" fill="var(--_m)">${j}</g>`:"")+"</g>";return{svg:mt("gitGraph",F,V,i,r,e,ne),width:F,height:V,links:[]}}var B4={type:"gitGraph",parse:(e,t,r)=>N4(R4(e),t,r),render:W4};function H4(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,`
98
+ `):void 0}}var dm=[zr("showInfo"),zr("info"),nn,Wr,Br,Gn,Vn,cr,an,sn];function j4(e){let t=new Er($r(e,dm,"info"),dm,"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 n=t.kind;if(n===2?r.accDescr=_r(t.take()):n===3?r.accTitle=Mr(t.take()):n===4?r.title=kr(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}var U4="1.8.0";function Y4(e,t,r){let n=r.fontSize??16,i=r.measurer??bt(r.fontFamily),a=r.padding??8,l=Ve(e.title,!1,i,n,4e3,1),s=l.height>0?l.height+8:0,o=Ve(`Pele v${U4}`,!1,i,n,4e3),c=Math.ceil(Math.max(l.width,o.width)+2*a),h=Math.ceil(s+o.height+2*a),u=Le(l,c/2,a+l.height/2,' class="pele-title" font-weight="var(--_tw)"')+Le(o,c/2,a+s+o.height/2,' class="pele-version" fill="var(--_m)"');return{svg:mt("info",c,h,n,r,e,u),width:c,height:h,links:[]}}var G4={type:"info",parse:(e,t,r)=>H4(j4(e),r),render:Y4},V4=class{type="ishikawa";title;root;stack=[];baseLevel;addNode(e,t){let r={text:t,children:[]};if(!this.root){this.root=r,this.stack=[{level:0,node:r}];return}this.baseLevel??=e;let n=Math.max(e-this.baseLevel+1,1),i=this.stack;for(;i.length>1&&i[i.length-1].level>=n;)i.pop();i[i.length-1].node.children.push(r),i.push({level:n,node:r})}},q4=["$end","EOF","SPACELINE","NL","ISHIKAWA","SPACELIST","TEXT"];function X4(e,t){let r="ishikawa-beta",n=0;for(;n<13;){let i=e.charCodeAt(t+n),a=r.charCodeAt(n);if(i!==a&&(i+32!==a||i<65||i>90))break;n++}return n===13&&!nt(e.charCodeAt(t+13))?13:n>=8&&!nt(e.charCodeAt(t+8))?8:0}function K4(e){let t=[],r=[],n=[],i=e.length,a=0;for(;a<i;){let l=a,s=-1;for(;l<i&&Xe(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 h=e.charCodeAt(c);if(h===10||h===13||h===8232||h===8233)break;c++}else if(l===a){let h=X4(e,a);h>0?(o=4,c=a+h):(o=6,c=e.indexOf(`
99
+ `,a),c===-1&&(c=i))}else s>a?(o=2,c=s+1):s===a?(o=3,c=a+1):(o=5,c=l);t.push(o),r.push(a),n.push(c),a=c}return t.push(1,0),r.push(i,i),n.push(i,i),{types:t,starts:r,ends:n}}var au="'SPACELINE', 'NL', 'EOF'";function Z4(e,t){let{types:r,starts:n,ends:i}=K4(e),a=0,l=s=>{throw vt("ishikawa",e,n[a],`Expecting ${s}, got '${q4[r[a]]}'`)};if(r[a]===2){for(a++;r[a]===2||r[a]===3;)a++;r[a]!==4&&l("'SPACELINE', 'NL', 'ISHIKAWA'")}else r[a]!==4&&l("'SPACELINE', 'ISHIKAWA'");for(a++,r[a]===3&&a++;;){let s=r[a];if(s===6||s===5&&r[a+1]===6){let o=s===6?a:a+1;a=o+1,r[a]!==2&&r[a]!==3&&r[a]!==1&&l(au),t.addNode(s===6?0:i[o-1]-n[o-1],e.slice(n[o],i[o]).trim())}else s===2||s===5?(a++,r[a]!==2&&r[a]!==3&&r[a]!==1&&l(s===5?`${au}, 'TEXT'`:au)):l("'SPACELINE', 'SPACELIST', 'TEXT'");for(a++;r[a]===3||r[a]===1;)a++;if(r[a]===0)return}}var yc=.5,_o=Math.hypot(yc,1),Q4=14,J4=6,e3=8,hm=22,t3=18,Cf=5,r3=26,um=34,n3=28,i3=10,a3=5;function s3(e,t,r,n,i){let a=Ve(e.text,!1,r,n,180),l=Math.round(i*1.5),s=[],o=[],c=[],h=(g,m,v)=>{let x=g.length;for(let k=x-1;k>=0;k--)c.push({node:g[t?x-1-k:k],depth:m,parent:v,slot:k,bone:-1})};for(h(e.children,2,-1);c.length>0;){let g=c.pop();if(g.bone!==-1){o.push(g.bone);continue}let m=s.length;s.push({label:Ve(g.node.text,!1,r,i,200),depth:g.depth,parent:g.parent,slot:g.slot,kids:g.node.children.length,rise:0,at:0,textEnd:0}),g.depth%2===0?o.push(m):(g.bone=m,c.push(g)),h(g.node.children,g.depth+1,m)}let u=Q4;for(let g of o){let m=Math.max(s[g].label.height,l)+J4;s[g].rise=u+m/2,u+=m}let d=a.width+2*i3,p=d/2;for(let g of s){let m=g.parent===-1?void 0:s[g.parent];g.depth%2===0?(g.at=m?m.at:0,g.textEnd=g.at-(g.kids>0?(g.kids+1)*hm:t3)-Cf):(g.at=m.at-(m.kids-g.slot)*hm,g.textEnd=g.at-Cf),p=Math.max(p,g.label.width-g.textEnd)}return{node:e,label:a,boxW:d,boxH:a.height+2*a3,bones:s,rise:u+e3,reach:p}}function l3(e,t,r){return dr(r,n=>o3(e,t,r,n))}function o3(e,t,r,n){let i=r.fontSize??16,a=Math.round(i*.875),l=r.measurer??bt(r.fontFamily),s=r.padding??8;if(n)return c3(e,r);let o=e.root,c=Ve(e.title,!1,l,i,4e3,1),h=c.height>0?c.height+12:0,u="",d=0,p=0,g=0,m=0;if(o){let N=Ve(o.text,!1,l,i,200,1),R=Math.max(N.height+24,48),O=N.width+24+R/2,P=o.children.map((W,S)=>s3(W,S%2===0,l,i,a));for(let W of P)W.rise=Math.max(W.rise,R/2+14);let H=[],I=-um;for(let W=0;W<P.length;W+=2){if(W>0){let S=0;for(let A=0;A<2;A++){let $=P[W-2+A],y=P[W+A];$&&(S=Math.max(S,$.reach+(y?y.boxW/2:0)))}I-=S+r3}H.push(I,I)}let G=P.length>0?I-n3:-um;p=O,d=G,g=-R/2,m=R/2;let Z="";P.forEach((W,S)=>{let A=S%2===0?-1:1,$=H[S],y=(j,Y)=>$+j-Y*yc,E=y(0,W.rise),w=A*W.rise,T=Rt-1,_=`M${f($-yc/_o*T)},${f(A*T/_o)}L${f(E)},${f(w)}`,M="";for(let j of W.bones){let Y=A*j.rise;if(j.depth%2===0)_+=`M${f(y(j.at,j.rise))},${f(Y)}H${f(y(j.textEnd+Cf,j.rise))}`;else{let L=W.bones[j.parent].rise;_+=`M${f(y(j.at,L))},${f(A*L)}L${f(y(j.at,j.rise))},${f(Y)}`}let D=y(j.textEnd,j.rise);M+=Le(j.label,D-j.label.width/2,Y,j.depth>2?' fill="var(--_m)"':""),d=Math.min(d,D-j.label.width)}let U=w+A*(W.boxH/2);d=Math.min(d,E-W.boxW/2),p=Math.max(p,E+W.boxW/2),g=Math.min(g,U-W.boxH/2),m=Math.max(m,U+W.boxH/2),Z+=`<g class="pele-ishikawa-category" data-id="${Ge(W.node.text)}"><path class="pele-ishikawa-bones" d="${_}" fill="none" stroke="var(--_l)"/>`+Ct("arrow_point",$,0,yc/_o,-A/_o,"var(--_l)")+`<rect x="${f(E-W.boxW/2)}" y="${f(U-W.boxH/2)}" width="${f(W.boxW)}" height="${f(W.boxH)}" fill="var(--_s)" stroke="var(--_b)"${xt}/>`+Le(W.label,E,U,' class="pele-label"')+(M?`<g class="pele-ishikawa-causes" font-size="${a}">${M}</g>`:"")+"</g>"});let z=R/2;u=`<path class="pele-ishikawa-spine" d="M${f(G)},0H${f(-(Rt-1))}" fill="none" stroke="var(--_l)"/>`+Ct("arrow_point",0,0,1,0,"var(--_l)")+Z+`<g class="pele-ishikawa-head" data-id="${Ge(o.text)}"><path d="M0,${f(-z)}H${f(O-z)}A${f(z)},${f(z)} 0 0 1 ${f(O-z)},${f(z)}H0Z" fill="var(--_s)" stroke="var(--_b)" stroke-linejoin="round"/>`+Le(N,12+N.width/2,0,' class="pele-label" font-weight="var(--_hw)"')+"</g>"}let v=Math.max(p-d,c.width),x=Math.ceil(v+2*s),k=Math.ceil(m-g+h+2*s),b=s+(v-(p-d))/2-d,C=s+h-g;return{svg:mt("ishikawa",x,k,i,r,{},Le(c,x/2,s+c.height/2,' class="pele-title" font-weight="var(--_tw)"')+(u?`<g transform="translate(${f(b)},${f(C)})">${u}</g>`:"")),width:x,height:k,links:[]}}function c3(e,t){let r=t.fontSize??16,n=Math.round(r*.875),i=t.measurer??bt(t.fontFamily),a=t.padding??8,l=Math.max(140,(t.maxWidth??320)-2*a),s=Ve(e.title,!1,i,r,Xt(t),1),o=[],c=e.root?[{node:e.root,depth:0,parent:-1}]:[],h=0;for(;c.length;){let b=c.pop(),C=o.length;o.push({...b,x:0,y:0,w:0,h:0}),h=Math.max(h,b.depth);for(let N=b.node.children.length-1;N>=0;N--)c.push({node:b.node.children[N],depth:b.depth+1,parent:C})}let u=Math.min(20,Math.max(2,(l-120)/Math.max(1,h))),d=a+(s.height?s.height+12:0),p=s.width,g="",m="";for(let b of o){b.x=a+b.depth*u;let C=Math.max(60,l-b.depth*u-20);b.label=Oc(Ve(b.node.text,!1,i,b.depth<2?r:n,C,b.depth<2?1:0),i,C),b.w=b.label.width+20,b.h=b.label.height+12,b.y=d,d+=b.h+12,p=Math.max(p,b.x-a+b.w);let N=b.depth<2;if(g+=`<g class="pele-node ${b.depth===0?"pele-ishikawa-head":b.depth===1?"pele-ishikawa-category":"pele-ishikawa-cause"}" data-id="${Ge(b.node.text)}">`+(N?`<rect x="${f(b.x)}" y="${f(b.y)}" width="${f(b.w)}" height="${f(b.h)}" rx="${b.depth===0?12:4}" fill="var(--_s)" stroke="var(--_b)"/>`:"")+Le(b.label,b.x+b.w/2,b.y+b.h/2,` class="pele-label"${b.depth<2?' font-weight="var(--_hw)"':""}${b.depth>1?` font-size="${n}"`:""}`)+"</g>",b.parent>=0){let R=o[b.parent],O=R.x+u/2;m+=`<path class="pele-edge" d="M${f(O)},${f(R.y+R.h)}V${f(b.y+b.h/2)}H${f(b.x)}" fill="none" stroke="var(--_b)"/>`}}let v=Math.ceil(p+2*a),x=Math.ceil(Math.max(a+s.height,d-12)+a),k=Le(s,v/2,a+s.height/2,' class="pele-title" font-weight="var(--_tw)"')+m+g;return{svg:mt("ishikawa",v,x,r,t,{},k),width:v,height:x,links:[]}}var d3={type:"ishikawa",parse(e,t,r){let n=new V4;return n.title=r,Z4(e,n),n},render:l3};function op(e){let t=new Set;for(let r of e)for(let n of r.people)t.add(n);return[...t].sort()}var h3=class{type="journey";title;accTitle;accDescr;sections=[];tasks=[];currentSection="";setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
100
+ `)}addSection(e){this.currentSection=e,this.sections.push(e)}addTask(e,t){let r=t.substring(1).split(":"),n=r.length===1?[]:r[1].split(",").map(i=>i.trim());this.tasks.push({task:e,score:Number(r[0]),people:n,section:this.currentSection})}getActors(){return op(this.tasks)}};function Zs(e,t){let r=e.indexOf(`
101
+ `,t);return r===-1?e.length:r}function Zr(e,t,r){for(let n=0;n<r.length;n++)if((e.charCodeAt(t+n)|32)!==r.charCodeAt(n))return!1;return!0}function Lb(e,t){let r=e.length,n=t;for(;n<r;){let i=e.charCodeAt(n);if(i===37&&e.charCodeAt(n+1)!==123)n=Zs(e,n);else if(i!==125&&e.charCodeAt(n+1)===37&&e.charCodeAt(n+2)===37)n=Zs(e,n+3);else{if(i===10)return n;if(Xe(i))do n++;while(n<r&&Xe(e.charCodeAt(n)));else if(i===35)n=Zs(e,n);else return n}}return n}function su(e,t){let r=t;for(;Xe(e.charCodeAt(r));)r++;return r}function Db(e,t,r,n){let i=Zr(e,t,"accdescr");if(!i&&!Zr(e,t,"acctitle"))return t;let a=e.length,l=su(e,t+8),s=e.charCodeAt(l),o=(c,h,u)=>{r.types.push(c),r.texts.push(e.slice(h,u)),r.starts.push(h)};if(s===58){l=su(e,l+1);let c=Zs(e,l);return o(i?n+2:n,t,l),o(i?n+3:n+1,l,c),c}if(!i||s!==123)return t;for(l=su(e,l+1);e.charCodeAt(l)!==125;){let c=e.indexOf("}",l);if(c===-1&&(c=a),o(n+4,l,c),l===a)return a;l=c}return l+1}var u3=["$end","EOF","INVALID","NEWLINE","journey","title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","section","taskName","taskData",":"];function Eo(e,t,r){let n=e.length,i=t;for(;i<n;i++){let a=e.charCodeAt(i);if(a===35||a===10||a===59||r&&a===58)break}return i}function f3(e){let t=e.length,r=[],n=[],i=[],a={types:r,texts:n,starts:i},l=0,s=(o,c)=>{r.push(o),n.push(e.slice(l,c)),i.push(l),l=c};for(;l=Lb(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(Zr(e,l,"journey")&&!nt(e.charCodeAt(l+7))){s(4,l+7);continue}if(Zr(e,l,"title")&&Xe(e.charCodeAt(l+5))&&(c=Eo(e,l+6,!1),c>l+6)){s(5,c);continue}if(c=Db(e,l,a,6),c!==l){l=c;continue}if(Zr(e,l,"section")&&Xe(e.charCodeAt(l+7))&&(c=Eo(e,l+8,!0),c>l+8)){s(11,c);continue}o===58?(c=Eo(e,l+1,!1),s(c>l+1?13:14,c>l+1?c:l+1)):o===59?s(2,l+1):s(12,Eo(e,l+1,!0))}return(i.length===0||i[i.length-1]<t)&&s(1,t),s(0,t),a}var p3="'EOF', 'SPACE', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'taskName'";function g3(e,t){let{types:r,texts:n,starts:i}=f3(e),a=(l,s)=>{let o=r[l]===0?"1":u3[r[l]];throw vt("journey",e,i[l],`Expecting ${s}, got '${o}'`)};r[0]!==4&&a(0,"'journey'");for(let l=1;;l++){let s=n[l];switch(r[l]){case 3:break;case 5:t.setDiagramTitle(s.substring(6));break;case 6:t.setAccTitle(n[++l].trim());break;case 8:t.setAccDescription(n[++l].trim());break;case 10:t.setAccDescription(s.trim());break;case 11:t.addSection(s.substring(8));break;case 12:r[++l]!==13&&a(l,"'taskData'"),t.addTask(s,n[l]);break;case 1:return;default:a(l,p3)}}}var xc=10,zn=8,m3=124,y3=200,Ao=12,fm=6,lu=24,ou=26,wa=11,qr=5,x3=13,b3=20,w3='<circle cx="-3.6" cy="-2.8" r="1.3"/><circle cx="3.6" cy="-2.8" r="1.3"/>',v3={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"};function Pb(e,t,r){return`<g class="pele-face pele-face-${r}" transform="translate(${f(e)},${f(t)})"><circle r="${wa}" fill="var(--_bg)" stroke="var(--_l)"/><g fill="var(--_l)">${w3}</g><path d="${v3[r]}" fill="none" stroke="var(--_l)" stroke-linecap="round"/></g>`}function $3(e,t,r){return dr(r,n=>k3(e,t,r,n))}function k3(e,t,r,n){let i=r.fontSize??16,a=Math.round(i*.875),l=Math.round(i*.75),s=r.measurer??bt(r.fontFamily),o=r.padding??8;if(n)return M3(e,r);let c=e.tasks,h=c.length,u=op(c).filter(F=>F!==""),d=new Map;u.forEach((F,V)=>d.set(F,V));let p=m3,g=c.map(F=>Hn(F.task,s,a,p)),m=0;for(let F of g)m=Math.max(m,F.width);m>p&&(p=Math.min(Math.ceil(m),y3),g=c.map(F=>wr(F.task,s,a,p)));let v=p+2*xc,x=v+Ao,k=h>0?h*x-Ao:0,b=Math.round(a*1.5),C=Math.max(k,240),N=[],R=0,O=0,P=0;for(let F of u){let V=wr(F,s,a,C-2*qr-6),X=2*qr+6+V.width;P>0&&P+X>C&&(P=0,O+=4);let Q=P>0?N[N.length-1].y:O,ne=Math.max(V.height,b);N.push({name:F,label:V,x:P,y:Q,h:ne}),P+=X,R=Math.max(R,P),O=Math.max(O,Q+ne),P+=b3}let H=h>0?lu+k:0,I=wr(e.title,s,i,Math.max(H,320),1),G=I.height>0?I.height+16:0,Z=Math.max(H,I.width,h>0?lu+R:0),z=o+(Z-H)/2+lu,W=o+G,S=[],A=0;for(let F=0;F<h;){let V=F+1;for(;V<h&&c[V].section===c[F].section;)V++;let X;c[F].section!==""&&(X=wr(c[F].section,s,a,(V-F)*x-Ao-2*xc,1),A=Math.max(A,Math.max(X.height,b)+2*fm)),S.push({start:F,count:V-F,label:X}),F=V}let $=b;for(let F of g)$=Math.max($,F.height);let y=u.length>0?2*qr+6:0,E=$+y+2*zn,w=W+(A>0?A+fm:0),T=w+E+wa+16,_=T+4*ou,M=z+k,U="",j=W;if(h>0){let F="",V="";for(let K=5;K>=1;K--){let ie=T+(5-K)*ou;F+=`M${f(z-6)},${f(ie)}H${f(M)}`,V+=`<text x="${f(z-12)}" y="${f(ie+l*.35)}">${K}</text>`}U+=`<path class="pele-grid" d="${F}" fill="none" stroke="var(--_a)"/><g class="pele-scale" font-size="${l}" text-anchor="end" fill="var(--_m)">${V}</g>`;let X="",Q="",ne="",B=[];c.forEach((K,ie)=>{let le=z+ie*x,J=le+v/2,te=K.score,ae=Number.isNaN(te)?3:Math.min(5,Math.max(1,te)),ee=T+(5-ae)*ou;X+=`${ie===0?"M":"L"}${f(J)},${f(ee)}`,Q+=`M${f(J)},${f(w+E)}V${f(ee-wa)}`,ne+=Pb(J,ee,te>3?"happy":te<3?"sad":"neutral");let re="",de=K.people.filter(oe=>oe!==""),ye=Math.min(x3,(v-2*xc-2*qr)/Math.max(de.length-1,1));de.forEach((oe,xe)=>{re+=`<circle class="pele-actor" cx="${f(J+(xe-(de.length-1)/2)*ye)}" cy="${f(w+E-zn-qr)}" r="${qr}" fill="${kt(d.get(oe)??0)}" stroke="var(--_s)"><title>${Ge(oe)}</title></circle>`}),B.push(`<g class="pele-node pele-task" data-id="${Ge(K.task.trim())}"><rect x="${f(le)}" y="${f(w)}" width="${f(v)}" height="${f(E)}" fill="var(--_s)" stroke="var(--_b)"${xt}/>`+Le(g[ie],J,w+zn+$/2,` font-size="${a}"`)+re+"</g>")}),U+=`<path class="pele-stems" d="${Q}" fill="none" stroke="var(--_b)" stroke-dasharray="2 3"/>`+(h>1?`<path class="pele-edge" d="${X}" fill="none" stroke="var(--_l)" stroke-linejoin="round"/>`:"")+ne;for(let K of S){let ie=B.slice(K.start,K.start+K.count).join("");if(!K.label){U+=ie;continue}let le=z+K.start*x,J=K.count*x-Ao;U+=`<g class="pele-cluster pele-section" data-id="${Ge(c[K.start].section.trim())}"><rect x="${f(le)}" y="${f(W)}" width="${f(J)}" height="${f(A)}" fill="var(--_a)"${xt}/>`+Le(K.label,le+J/2,W+A/2,` font-size="${a}" font-weight="var(--_hw)"`)+ie+"</g>"}if(j=_+wa,N.length>0){let K=z+(k-R)/2,ie=j+16,le="";for(let J of N){let te=ie+J.y+J.h/2;le+=`<g class="pele-legend-item" data-id="${Ge(J.name)}"><circle cx="${f(K+J.x+qr)}" cy="${f(te)}" r="${qr}" fill="${kt(d.get(J.name)??0)}"/>`+Le(J.label,K+J.x+2*qr+6+J.label.width/2,te,"")+"</g>"}U+=`<g class="pele-legend" font-size="${a}">${le}</g>`,j=ie+O}}let Y=Math.ceil(Z+2*o),D=Math.ceil(Math.max(j,o)+o),L=Le(I,o+Z/2,o+I.height/2,' class="pele-title" font-weight="var(--_tw)"')+U;return{svg:mt("journey",Y,D,i,r,e,L),width:Y,height:D,links:[]}}function M3(e,t){let r=t.fontSize??16,n=Math.round(r*.875),i=t.measurer??bt(t.fontFamily),a=t.padding??8,l=Math.max(140,(t.maxWidth??320)-2*a),s=wr(e.title,i,r,l,1),o=op(e.tasks).filter(x=>x!==""),c=new Map(o.map((x,k)=>[x,k])),h=a+(s.height?s.height+16:0),u,d="",p=s.width;e.tasks.forEach((x,k)=>{if(x.section!==u){u=x.section;let I=wr(u,i,r,l-16,1);I.height&&(d+=Le(I,a+8+I.width/2,h+I.height/2,' class="pele-cluster-label" font-weight="var(--_hw)"'),p=Math.max(p,I.width+16),h+=I.height+8)}let b=wr(x.task,i,n,l-72),C=x.people.filter(I=>I!=="").map(I=>({name:I,label:wr(I,i,n,l-44)})),N=Math.max(b.height,42),R=2*zn+N;for(let I of C)R+=Math.max(16,I.label.height)+4;let O=Math.max(l,b.width+72);d+=`<g class="pele-node pele-journey-step" data-id="${k}"><rect x="${f(a)}" y="${f(h)}" width="${f(O)}" height="${f(R)}" fill="var(--_s)" stroke="var(--_b)"${xt}/>`,d+=Le(b,a+xc+b.width/2,h+zn+b.height/2,' class="pele-label"');let P=a+O-28;d+=Pb(P,h+zn+wa,x.score>3?"happy":x.score<3?"sad":"neutral"),Number.isNaN(x.score)||(d+=`<text class="pele-journey-score" x="${f(P)}" y="${f(h+zn+2*wa+n)}" font-size="${n}" text-anchor="middle">${f(Math.min(5,Math.max(1,x.score)))}</text>`);let H=h+zn+N+4;for(let I of C){let G=Math.max(16,I.label.height);d+=`<circle class="pele-actor" cx="${f(a+16)}" cy="${f(H+G/2)}" r="${qr}" fill="${kt(c.get(I.name))}"/>`+Le(I.label,a+28+I.label.width/2,H+G/2,` class="pele-journey-actor" font-size="${n}"`),H+=G+4}d+="</g>",h+=R,k+1<e.tasks.length&&(d+=`<path class="pele-edge" d="M${f(a+O/2)},${f(h)}v16" fill="none" stroke="var(--_l)"/>`),h+=16,p=Math.max(p,O)});let g=Math.ceil(p+2*a),m=Math.ceil(Math.max(a+s.height,h-(e.tasks.length?16:0))+a),v=Le(s,g/2,a+s.height/2,' class="pele-title" font-weight="var(--_tw)"')+d;return{svg:mt("journey",g,m,r,t,e,v),width:g,height:m,links:[]}}var _3={type:"journey",parse(e,t,r){let n=new h3;return n.title=r,g3(e,n),n},render:$3},E3=["1","INVALID","SPACELINE","NL","EOF","","SPACELIST","ICON","CLASS","NODE_DSTART","NODE_ID","NODE_DESCR","NODE_DEND","SHAPE_DATA"];function pm(e,t){return e===5?t?"KANBAN":"MINDMAP":E3[e]}var Nn={DEFAULT:0,NO_BORDER:0,ROUNDED_RECT:1,RECT:2,CIRCLE:3,CLOUD:4,BANG:5,HEXAGON:6};function zb(e,t){switch(e){case"[":return Nn.RECT;case"(":return t===")"?Nn.ROUNDED_RECT:Nn.CLOUD;case"((":return Nn.CIRCLE;case")":return Nn.CLOUD;case"))":return Nn.BANG;case"{{":return Nn.HEXAGON;default:return Nn.DEFAULT}}var A3=/\s+/y,cu=/.+/y,T3=/[^([\n){}]+/y,S3=/[^([\n){}@]+/y,C3=/[^)\](}]+/y,I3=/[^`"]+/y,N3=/[^}^"]+/y,R3=/\n\s*/g;function gm(e,t,r){for(let n=0;n<r.length;n++)if((e.charCodeAt(t+n)|32)!==r.charCodeAt(n))return!1;return!0}function O3(e,t){let r=e.length,n=[],i=[],a=[],l=t?"kanban":"mindmap",s=t?S3:T3,o=0,c=0,h=-1,u=(m,v,x)=>{n.push(m),i.push(v),a.push(c),c=x},d=(m,v,x)=>{u(m,e.slice(c,v),v),o=x},p=(m,v)=>(m.lastIndex=v,m.test(e)?m.lastIndex:-1),g=m=>{let v=e.indexOf(m,c);return v===-1?r:v};for(;c<r;){let m=e.charCodeAt(c),v=e.charCodeAt(c+1),x;if(o===0){let k=m<=32||m>=160?Math.max(p(A3,c),c):c;if(t&&m===64&&v===123)u(13,"",c+2),o=6;else if(e.charCodeAt(k)===37&&e.charCodeAt(k+1)===37)d(2,p(cu,k),0);else if(k>c)h<c&&(h=g(`
102
+ `)),h>=k?d(6,k,0):(x=e.lastIndexOf(`
103
+ `,k-1))>c?d(2,x+1,0):d(3,c+1,0);else if(gm(e,c,l)&&!nt(e.charCodeAt(c+l.length)))d(5,c+l.length,0);else if(m===58&&v===58&&e.charCodeAt(c+2)===58)c+=3,o=1;else if(m===58&&v===58&&gm(e,c+2,"icon")&&e.charCodeAt(c+6)===40)c+=7,o=2;else if(m===45&&v===41||m===40&&(v===45||v===40)||(m===41||m===123)&&v===m)d(9,c+2,3);else if(m===41||m===40||m===91)d(9,c+1,3);else if((x=p(s,c))!==-1)d(10,x,0);else break}else if(o===3)m===34?(o=v===96?5:4,c+=v===96?2:1):m===41||m===40?d(12,v===m||m===40&&v===45?c+2:c+1,0):m===93?d(12,c+1,0):m===125&&v===125||m===45&&v===41?d(12,c+2,0):d(11,p(m===125?cu:C3,c),3);else if(o===4)m===34?(c++,o=3):d(11,g('"'),4);else if(o===5)if(m===96&&v===34)c+=2,o=3;else if((x=p(I3,c))!==-1)d(11,x,5);else break;else if(o===1)if((x=p(cu,c))!==-1)d(8,x,0);else if(m===10)c++,o=0;else break;else if(o===2)m===41?(c++,o=0):d(7,g(")"),2);else if(o===6)if(m===34)d(13,c+1,7);else if(m===125)c++,o=0;else if((x=p(N3,c))!==-1)d(13,x,6);else break;else m===34?d(13,c+1,6):(x=g('"'),u(13,e.slice(c,x).replace(R3,"<br/>"),x))}return c<r?u(1,"",c):(o===0&&u(4,"",r),u(0,"",r)),{types:n,texts:i,starts:a}}var si="'SPACELINE', 'NL', 'EOF'",Fb=new Uint8Array(14);for(let e of[2,6,7,8,9,10])Fb[e]=1;function Ji(e){return e===2||e===3||e===4}function Wb(e,t,r){let n=r?"kanban":"mindmap",{types:i,texts:a,starts:l}=O3(e,r),s=r?", 'SHAPE_DATA'":"",o=0,c=d=>{let p=i[o];throw p===1?vt(n,e,l[o],"",!0):vt(n,e,l[o],`Expecting ${d}, got '${pm(p,r)}'`)},h=`'${pm(5,r)}'`;if(i[o]===2){for(o++;i[o]===2||i[o]===3;)o++;i[o]!==5&&c(`'SPACELINE', 'NL', ${h}`)}else i[o]!==5&&c(`'SPACELINE', ${h}`);o++;let u="'SPACELINE', 'NL', 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'";for(i[o]===3&&(o++,u="'SPACELINE', 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'");;){let d=i[o],p=0,g=d===6;if(g&&(p=a[o++].length,d=i[o]),d===10||d===9){let m,v,x=0;if(d===10&&(m=a[o++]),i[o]===9){let k=a[o++];i[o]!==11&&c("'NODE_DESCR'"),v=a[o++],i[o]!==12&&c("'NODE_DEND'");let b=a[o++];!Ji(i[o])&&i[o]!==13&&c(si+s),x=t.getType(k,b)}else!Ji(i[o])&&i[o]!==13&&c(si+", 'NODE_DSTART'"+s),v=m;if(i[o]===13){let k=a[o++];for(;i[o]===13;)k+=a[o++];Ji(i[o])||c(si+s),t.addNode(p,m??v,v,x,k)}else t.addNode(p,m??v,v,x)}else if(d===7||d===8){let m=a[o++];Ji(i[o])||c(si),t.decorateNode(d===7?{icon:m}:{class:m})}else g?Ji(d)||c(si+", 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'"):d===2?Ji(i[++o])||c(si):c(u);for(o++;i[o]===3||i[o]===4;)o++;if(i[o]===0)return;Fb[i[o]]===0&&c(si+", 'SPACELIST', 'ICON', 'CLASS', 'NODE_DSTART', 'NODE_ID'")}}var L3=class{type="kanban";title;sections=[];getType=zb;last;sectionLevel=0;misplaced;addNode(e,t,r,n,i){let a={id:t,level:e,label:r};if(i!==void 0){let s=i.includes(`
104
+ `)?i+`
105
+ `:`{
106
+ `+i+`
107
+ }`,o;try{o=va(s)}catch(c){throw new Je(`Metadata of "${a.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&&(a.label=String(o.label)),o.icon&&(a.icon=String(o.icon)),o.assigned&&(a.assigned=String(o.assigned)),o.ticket&&(a.ticket=String(o.ticket)),o.priority&&(a.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=a,e===this.sectionLevel){let s=a;s.items=[],l.push(s)}else l[l.length-1].items.push(a),e<this.sectionLevel&&(this.misplaced=a)}decorateNode(e){let t=this.last;!e||!t||(e.icon&&(t.icon=e.icon),e.class&&(t.cssClasses=e.class))}};function D3(e,t){Wb(e,t,!0)}function If(e,t,r,n,i){return`<svg class="pele-icon" data-icon="${Ge(e)}" x="${f(t)}" y="${f(r)}" width="${f(n)}" height="${f(n)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i?.(e)??""}</svg>`}var Gr=12,Vr=8,Ir=10,du=8,P3=4,ws=6,z3=new Map([["very high",`stroke="${pf}"`],["high",`stroke="${pf}" opacity="0.5"`],["low",'stroke="var(--_m)" opacity="0.5"'],["very low",'stroke="var(--_m)"']]);function To(e,t,r,n,i,a=0){let l=Ve(e,t,r,n,i,a);if(l.width<=i)return l;let s=[],o=[],c=0,h=[],u=0,d=()=>{s.push(h),o.push(u),c=Math.max(c,u),h=[],u=0};for(let g=0;g<l.lines.length;g++){if(l.widths[g]<=i){h=l.lines[g],u=l.widths[g],d();continue}for(let m of l.lines[g]){if(m.icon!==void 0||m.math){u>0&&u+m.width>i&&d(),h.push(m),u+=m.width;continue}let v="",x=u;for(let k of m.text){let b=r.width(k,n,m.style);u>0&&u+b>i&&(v&&h.push({text:v,style:m.style,width:u-x}),d(),v="",x=0),v+=k,u+=b}v&&h.push({text:v,style:m.style,width:u-x})}d()}let p={...l,lines:s,widths:o,width:c,height:s.length*l.lineHeight};return l.heights?tp(p):p}function vs(e,t,r,n,i,a=!1){let l="";for(let s=0;s<e.lines.length;s++){let o=e.lines[s],c=r+hl(e,s);if(o.length===1&&o[0].icon===void 0&&o[0].math===void 0)l+=`<text${Sa(n,o[0].style)} x="${f(t)}" y="${f(c+e.size*.35)}"${a?' text-anchor="end"':""}>${tt(o[0].text)}</text>`;else{let h=e.widths[s];l+=Le(ul(e,s),t+(a?-h:h)/2,c,n,i)}}return l}var ea=e=>!!e&&Xf(e)!=="";function F3(e,t,r){let n=r.fontSize??16,i=Math.round(n*.875),a=Math.round(n*1.5),l=Math.round(i*1.5),s=r.measurer??bt(r.fontFamily),o=r.padding??8,c=r.icons,h=t.kanban??{},u=h.sectionWidth,d=i*1.25,p=0,g=(L,F,V)=>{if(!(!L||!L.includes("$$")))for(let X of Ve(L,!0,s,F,1/0).lines)for(let Q of X)Q.math&&(p=Math.max(p,Q.math.width+V))};for(let L of e.sections){let F=s.width(String(L.items.length),i,0);g(L.label,n,2*Vr+8+F+12+(ea(L.icon)?d+ws:0));for(let V of L.items){let X=2*(Vr+Ir);g(V.label,i,X+(ea(V.icon)?d+ws:0)),g(V.ticket,i,X),g(V.assigned,i,X)}}let m=Math.max(typeof u=="number"&&u>0?Math.min(Math.max(u,80),2e3):200,Math.ceil(p)),v=r.maxWidth!==void 0&&r.maxWidth>0?r.maxWidth-2*o:1/0,x=e.sections.length,k=x*(m+Gr)-Gr<=v,b=k?Math.max(x,1):Math.max(1,Math.floor((v+Gr)/(m+Gr))),C=k?m:Math.max(Math.min(m,v),Math.min(Math.floor((v+Gr)/b)-Gr,m*2),Math.ceil(p)),N=typeof h.ticketBaseUrl=="string"?h.ticketBaseUrl:"",R=C-2*Vr,O=R-2*Ir,P=[],H=e.sections,I=[],G=[],Z=[],z=a,W=[];for(let L of H){let F=s.width(String(L.items.length),i,0),V=F+12+(ea(L.icon)?d+ws:0),X=To(L.label,!0,s,n,R-8-V,1);z=Math.max(z,X.height),G.push(F),I.push(X);let Q=[],ne=0;for(let B of L.items){let K=To(B.label,!0,s,i,O-(ea(B.icon)?d+ws:0)),ie=To(B.ticket,!1,s,i,O),le=To(B.assigned,!1,s,i,O),J=ie.width+le.width+8>O?ie.height+le.height:Math.max(ie.height,le.height),te=2*Ir+Math.max(K.height,l)+(J?P3+J:0);Q.push({item:B,label:K,ticket:ie,assigned:le,meta:J,height:te}),ne+=te+du}Z.push(Q),W.push(ne)}z+=2*Vr;let S=[],A=[];for(let L=0,F=0;L<H.length;L+=b){let V=du;for(let X=L;X<Math.min(L+b,H.length);X++)V=Math.max(V,W[X]);A.push(F),S.push(z+V),F+=z+V+Gr}let $=S.length>0?A[A.length-1]+S[S.length-1]:0,y=Mn(e.title,s,n,Xt(r)),E=y.height>0?y.height+16:0,w=Math.max(Math.min(H.length,b)*(C+Gr)-Gr,0),T=Math.max(w,y.width),_=o+(T-w)/2,M=C-Vr-4,U="";for(let L=0;L<H.length;L++){let F=H[L],V=Math.floor(L/b),X=`<rect width="${C}" height="${f(S[V])}" fill="var(--_s)"${xt}/>`+vs(I[L],Vr+4,Vr,' class="pele-cluster-label" font-weight="var(--_hw)"',c)+`<text class="pele-count" x="${M}" y="${f(Vr+a/2+i*.35)}" text-anchor="end" font-size="${i}" fill="var(--_m)">${F.items.length}</text>`;ea(F.icon)&&(X+=If(F.icon,M-G[L]-ws-d,Vr+(a-d)/2,d,c));let Q=z;for(let ne of Z[L]){let B=ne.item,K=(B.priority??"").trim().toLowerCase(),ie=z3.get(K),le=`<rect width="${R}" height="${f(ne.height)}" fill="var(--_bg)" stroke="var(--_b)"${xt}/>`;ie!==void 0&&(le+=`<path class="pele-priority" d="M2.5,5V${f(ne.height-5)}" fill="none" ${ie} stroke-width="3" stroke-linecap="round"/>`),le+=vs(ne.label,Ir,Ir,' class="pele-label"',c),ea(B.icon)&&(le+=If(B.icon,R-Ir-d,Ir+(l-d)/2,d,c));let J=ne.height-Ir;if(B.ticket){let te=J-ne.meta,ae=N?ol(Ia(N.replace("#TICKET#",()=>B.ticket)),r):void 0;ae===void 0?le+=vs(ne.ticket,Ir,te,' class="pele-ticket" fill="var(--_m)"',c):(le+=`<a href="${tt(ae)}" target="_blank"${cl(r)}>`+vs(ne.ticket,Ir,te,' class="pele-ticket" fill="var(--_c)"',c)+"</a>",P.push({id:B.id,href:ae,internal:!1}))}B.assigned&&(le+=vs(ne.assigned,R-Ir,J-ne.assigned.height,' class="pele-assigned" fill="var(--_m)"',c,!0)),X+=`<g class="pele-node pele-card${ie===void 0?"":" pele-priority-"+K.replace(" ","-")}${jt(B.cssClasses??"")}" data-id="${Ge(B.id)}" transform="translate(${Vr},${f(Q)})" font-size="${i}">${le}</g>`,Q+=ne.height+du}U+=`<g class="pele-cluster pele-column${jt(F.cssClasses??"")}" data-id="${Ge(F.id)}" transform="translate(${f(_+L%b*(C+Gr))},${f(o+E+A[V])})">${X}</g>`}let j=Math.ceil(T+2*o),Y=Math.ceil($+E+2*o),D=Le(y,j/2,o+y.height/2,' class="pele-title" font-weight="var(--_tw)"')+U;return{svg:mt("kanban",j,Y,n,r,{},D),width:j,height:Y,links:P}}var W3={type:"kanban",math:!0,parse(e,t,r){let n=new L3;return n.title=r,D3(e,n),n},render:F3},B3=11,H3=class{type="mindmap";title;nodes=[];getType=zb;baseLevel=0;open=[];addNode(e,t,r,n){let i=this.nodes.length===0;i&&(this.baseLevel=e),e-=this.baseLevel;let a=this.open,l=a.length;for(;l>0&&a[l-1].level>=e;)l--;let s=a[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:n,children:[],isRoot:i};s&&(o.section=s.isRoot?s.children.length%B3:s.section,s.children.push(o)),a.length=l,a.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))}};function j3(e,t){Wb(e,t,!1)}var U3=["","rounded","rect","circle","cloud","bang","hex"],mm="stadium",Y3=36,G3=8,V3=18,q3=52,ym=28,xm=6,X3=12,K3=.22,hu=6,uu=28,bm=12,wm=8,vm=10;function Z3(e,t,r,n){if(e.lines.length<2)return Le(e,t+e.width/2,r,' class="pele-label"',n);let i="",a=r-e.height/2;for(let l=0;l<e.lines.length;l++)i+=Le(ul(e,l),t+e.widths[l]/2,a+hl(e,l),' class="pele-label"',n);return i}function Q3(e,t,r){return dr(r,n=>J3(e,t,r,n))}function J3(e,t,r,n){let i=r.fontSize??16,a=r.measurer??bt(r.fontFamily),l=r.padding??8,s=r.icons,o=t.mindmap?.maxNodeWidth,c=typeof o=="number"&&o>0?Math.min(o,2e3):200,h=i*1.25,u=e.nodes,d=u.length,p=new Int32Array(d),g=new Int32Array(d);for(let ne=0;ne<d;ne++)for(let B of u[ne].children)p[B.id]=ne,g[B.id]=g[ne]+1;let m=n&&r.maxWidth!==void 0&&r.maxWidth>0?r.maxWidth-2*l:1/0,v=new Array(d),x=new Array(d),k=new Float64Array(d),b=new Float64Array(d),C=new Float64Array(d),N=new Float64Array(d),R=new Uint8Array(d);for(let ne=0;ne<d;ne++){let B=u[ne];R[ne]=B.icon!==void 0&&Xf(B.icon)!==""?1:0;let K=Math.min(c,Math.max(72,m-g[ne]*uu-2*xm-(R[ne]?h+hu:0))),ie=v[ne]=Ve(B.descr,!0,a,i,K),le=ie.width+(R[ne]?h+(ie.width>0?hu:0):0),J=Math.max(ie.height,Math.round(i*1.5)),te=U3[B.type]||(ne===0?mm:"");if(n&&ne===0&&te!=="rect"&&te!=="rounded"&&(te=mm),x[ne]=te,te===""){let ae=B.children.length>0;k[ne]=le+2*(ae?X3:xm),b[ne]=J+(ae?6:0),N[ne]=b[ne]/2}else{let ae=Jc(te,le,J);k[ne]=ae.w,b[ne]=ae.h,C[ne]=ae.dy,N[ne]=ae.h/2}}let O=new Float64Array(d),P=new Float64Array(d),H=new Float64Array(d),I=new Float64Array(d),G=0,Z=(ne,B,K,ie)=>{let le=0,J=0;for(let ee=B;ee<K;ee++){let re=ne[ee].id;P[re]=le,J=ne[ee].children.length>0||ee+1<K&&ne[ee+1].children.length>0?Math.max(ie,V3):ie,le+=O[re]+J}G=le-J;let te=ne[B].id,ae=ne[K-1].id;return(P[te]+H[te]+N[te]+P[ae]+H[ae]+N[ae])/2};for(let ne=d-1;ne>0;ne--){let B=u[ne].children;if(B.length===0){O[ne]=b[ne];continue}let K=Z(B,0,B.length,G3)-N[ne],ie=Math.min(0,K);O[ne]=Math.max(G,K+b[ne])-ie,H[ne]=K-ie,I[ne]=-ie}let z=new Float64Array(d),W=new Float64Array(d),S=new Float64Array(d),A=new Int8Array(d),$=new Float64Array(d);if(n){let ne=0;for(let B=0;B<d;B++)B>0&&p[B]===0&&(ne+=vm),z[B]=g[B]*uu+k[B]/2,W[B]=ne,ne+=b[B]+vm}else if(d>0){let ne=u[0].children,B=ne.length,K=0;for(let te of ne)K+=O[te.id];let ie=B,le=1/0,J=0;for(let te=1;te<B;te++){J+=O[ne[te-1].id];let ae=Math.abs(2*J-K+(2*te-B)*ym);ae<le&&(le=ae,ie=te)}for(let te=0,ae=ie,ee=1;te<B;te=ae,ae=B,ee=-1){let re=Z(ne,te,ae,ym);for(let de=te;de<ae;de++){let ye=ne[de].id;S[ye]=P[ye]-re,A[ye]=ee}}W[0]=-b[0]/2;for(let te=0;te<d;te++){te>0&&(W[te]=S[te]+H[te]);for(let ae of u[te].children){let ee=ae.id;te>0&&(A[ee]=A[te],S[ee]=S[te]+I[te]+P[ee]),z[ee]=z[te]+A[ee]*(k[te]/2+(te>0?Y3:q3)+k[ee]/2)}}}let y=0,E=0,w=0,T=0,_="",M="",U="",j="",Y=ne=>{U!==""&&(_+=`<g class="pele-branch pele-section-${ne??0}"><g class="pele-edges" fill="none" stroke="${j}" stroke-width="1.5">${M}</g>${U}</g>`,M=U="")};for(let ne=1;ne<=d;ne++){let B=ne%d,K=u[B],ie=x[B],le=v[B],J=z[B],te=W[B];if(y=Math.min(y,J-k[B]/2),E=Math.max(E,J+k[B]/2),w=Math.min(w,te),T=Math.max(T,te+b[B]),(B===0||p[B]===0)&&Y(u[ne-1].section),B>0&&n){p[B]===0&&(j=kt(K.section??0));let oe=p[B],xe=oe===0?Math.min(Math.max(bm,b[0]/2),uu-wm):bm,fe=z[oe]-k[oe]/2+Math.min(xe,k[oe]/2),pe=$[oe]||W[oe]+b[oe],Me=J-k[B]/2+(ie?$i(ie,k[B],b[B],3):0),Ae=te+N[B],ce=Math.max(0,Math.min(wm,Me-fe,Ae-pe));$[oe]=Ae-ce,M+=`<path class="pele-edge" d="M${f(fe)},${f(pe)}V${f(Ae-ce)}Q${f(fe)},${f(Ae)} ${f(fe+ce)},${f(Ae)}H${f(Me)}"/>`}else if(B>0){p[B]===0&&(j=kt(K.section??0));let oe=p[B],xe=A[B],fe=xe>0?1:3,pe=z[oe]+xe*(k[oe]/2-(x[oe]?$i(x[oe],k[oe],b[oe],fe):0)),Me=W[oe]+N[oe],Ae=J-xe*k[B]/2+(ie?xe*$i(ie,k[B],b[B],4-fe):0),ce=te+N[B],ge=f((pe+Ae)/2);M+=`<path class="pele-edge" d="M${f(pe)},${f(Me)}C${ge},${f(Me)} ${ge},${f(ce)} ${f(Ae)},${f(ce)}"/>`}let ae=!ie&&K.children.length>0,ee=` fill="${j}" fill-opacity="${K3}" stroke="${j}"`,re="";ie?re=B>0?_a(ie,k[B],b[B],ee,` stroke="${j}"`):_a(ie,k[B],b[B],' fill="var(--_s)" stroke="var(--_b)"',' stroke="var(--_b)"'):ae&&(re=`<rect x="${f(-k[B]/2)}" y="${f(-b[B]/2)}" width="${f(k[B])}" height="${f(b[B])}" rx="${f(b[B]/2)}"${ee}/>`);let de=0;K.icon&&R[B]&&(de=(h+(le.width>0?hu:0))/2,re+=If(K.icon,-de-le.width/2,C[B]-h/2,h,s));let ye=`<g class="pele-node pele-shape-${ie||(ae?"branch":"text")}${B>0?"":" pele-root"}${jt(K.class??"")}" data-id="${Ge(K.nodeId)}" transform="translate(${f(J)},${f(te+b[B]/2)})">`+re+(n&&!ie?Z3(le,de-le.width/2,C[B],s):Le(le,de,C[B],' class="pele-label"',s))+"</g>";B>0?U+=ye:_+=ye}let D=Mn(e.title,a,i,Xt(r)),L=D.height>0?D.height+16:0,F=Math.max(E-y,D.width),V=Math.ceil(F+2*l),X=Math.ceil(T-w+L+2*l),Q=Le(D,V/2,l+D.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${f(l-y+(F-E+y)/2)},${f(l+L-w)})">${_}</g>`;return{svg:mt("mindmap",V,X,i,r,{},Q),width:V,height:X,links:[]}}var eC={type:"mindmap",math:!0,parse(e,t,r){let n=new H3;return n.title=r,j3(e,n),n},render:Q3},tC=1e4;function Ds(e,t,r,n,i){let a=e.packet?.[t];return typeof a=="number"&&a>=n?Math.min(a,i):r}function fu(e){return new Je(e,"semantic",{type:"packet"})}function rC(e,t,r){let n=Math.floor(Ds(t,"bitsPerRow",32,1,4096)),i=[],a=-1,l=[],s=1;for(let o of e.blocks){let{start:c,end:h,bits:u}=o;if(c!==void 0&&h!==void 0&&h<c)throw fu(`Packet block ${c} - ${h} is invalid. End must be greater than start.`);if(c??=a+1,c!==a+1)throw fu(`Packet block ${c} - ${h??c} is not contiguous. It should start from ${a+1}.`);if(u===0)throw fu(`Packet block ${c} is invalid. Cannot have a zero bit field.`);for(h??=c+(u??1)-1,u??=h-c+1,a=h;l.length<=n+1&&i.length<tC;){let d=s*n-1;if(h<=d){l.push({start:c,end:h,bits:u,label:o.label}),h===d&&(i.push(l),l=[],s++);break}l.push({start:c,end:d,bits:d-c,label:o.label}),i.push(l),l=[],s++,c=d+1,u=h-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,`
108
+ `):void 0,bitsPerRow:n,rows:i}}var $m=[{name:"packet-beta",pattern:"packet-beta"},zr("packet"),{name:"-",pattern:"-",longer:[cr]},{name:"+",pattern:"+"},{name:":",pattern:":"},nn,Wr,Br,{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y},Si,Gn,Vn,cr,an,sn];function nC(e){let t=new Er($r(e,$m,"packet"),$m,"packet"),r={$type:"Packet",blocks:[]},n=()=>{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=_r(t.take()),n();break;case 6:r.accTitle=Mr(t.take()),n();break;case 7:r.title=kr(t.take()),n();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=Dr(t.expect(9)),r.blocks.push(i),n();break}default:t.fail("a field, a title, or a line break")}return r}function Nf(e,t,r,n,i,a=0){if(e===""||t<=0)return;let l=i.width(e,r,a);if(l<=t)return{text:e,size:r,width:l};let s=Math.max(n,Math.floor(r*t/l));for(;s>=n;){if(l=i.width(e,s,a),l<=t)return{text:e,size:s,width:l};s--}let o=Array.from(e),c=0,h=o.length-1;for(;c<h;){let d=c+h+1>>1;i.width(o.slice(0,d).join("").trimEnd()+"…",n,a)<=t?c=d:h=d-1}if(c===0)return;let u=o.slice(0,c).join("").trimEnd()+"…";return l=i.width(u,n,a),l<=t?{text:u,size:n,width:l}:void 0}function iC(e,t,r){return dr(r,n=>aC(e,t,r,n))}function aC(e,t,r,n){let i=r.fontSize??16,a=Math.round(i*.875),l=Math.round(i*.625),s=r.measurer??bt(r.fontFamily),o=r.padding??8,c=t.packet??{},h=Ds(t,"rowHeight",32,1,400),u=Ds(t,"bitWidth",32,1,400),d=Ds(t,"paddingX",5,0,400),p=Ds(t,"paddingY",5,0,400),g=c.showBits!==!1,m=c.bitOrder==="descending",v=e.bitsPerRow,x=e.rows;if(n){let E=Math.max(1,Math.floor(((r.maxWidth??320)-2*o)/Math.min(u,18)));v=Math.min(v,Math.max(8,2**Math.floor(Math.log2(E))));let w=e.rows[e.rows.length-1],T=w?.[w.length-1]?.end??0;Math.ceil((T+1)/v)>1e4&&(v=e.bitsPerRow),u=Math.min(u,Math.max(18,((r.maxWidth??320)-2*o)/v));let _=U=>U.bits===U.end-U.start,M=[];for(let U of e.rows)for(let j of U){let Y=M[M.length-1];Y&&_(Y)&&_(j)&&Y.label===j.label&&j.start===Y.end+1&&j.start%e.bitsPerRow===0?(Y.end=j.end,Y.bits=Y.end-Y.start):M.push({...j})}x=[];for(let U of M)for(let j=U.start;j<=U.end;){let Y=Math.min(U.end,(Math.floor(j/v)+1)*v-1),D=Math.floor(j/v);(x[D]??(x[D]=[])).push({...U,start:j,end:Y}),j=Y+1}}let k=new Map;if(n)for(let E of x)for(let w of E){let T=Math.max(1,(w.end-w.start+1)*u-Math.min(d,u-1)-6),_=Rc(It(w.label).trim(),s,a,T);k.set(w,_)}let b=g?l+4:0,C=x.map(E=>{let w=h;if(n)for(let T of E)w=Math.max(w,k.get(T).height+10);return w}),N=[],R=0;for(let E of C)N.push(R),R+=b+E+p;x.length&&(R-=p);let O=Math.min(d,u-1),P=x.length>0?v*u-O:0,H=Ve(e.title,!1,s,i,n?Xt(r):4e3,1),I=H.height>0?H.height+(R>0?12:0):0,G=new Map,Z=(E,w)=>{let T=G.get(E);return T||G.set(E,T=new Map),T.has(w)||T.set(w,Nf(It(E).trim(),w,a,Math.round(i*.5),s)),T.get(w)},z=o+Math.max(0,(H.width-P)/2),W="",S="";x.forEach((E,w)=>{let T=o+N[w]+b,_=C[w];for(let M of E){let U=M.end-M.start+1,j=M.start%v,Y=z+(m?v-j-U:j)*u,D=U*u-O,L=n?void 0:Z(M.label,D-6);if(W+=`<g class="pele-node" data-id="${M.start}-${M.end}"><rect x="${f(Y)}" y="${f(T)}" width="${f(D)}" height="${f(_)}" fill="var(--_s)" stroke="var(--_b)"${xt}/>`+(n?Le(k.get(M),Y+D/2,T+_/2,""):L&&L.size<=_?`<text x="${f(Y+D/2)}" y="${f(T+_/2+L.size*.35)}"${L.size===a?"":` font-size="${f(L.size)}"`}>${tt(L.text)}</text>`:"")+"</g>",!g)continue;let F=m?M.end:M.start,V=m?M.start:M.end;U===1?S+=`<text x="${f(Y+D/2)}" y="${f(T-4)}" text-anchor="middle">${F}</text>`:S+=`<text x="${f(Y)}" y="${f(T-4)}">${F}</text><text x="${f(Y+D)}" y="${f(T-4)}" text-anchor="end">${V}</text>`}});let A=Math.ceil(Math.max(P,H.width)+2*o),$=Math.ceil(R+I+2*o),y=(W?`<g class="pele-packet-fields" font-size="${a}" text-anchor="middle">${W}</g>`:"")+(S?`<g class="pele-packet-bits" font-size="${l}" fill="var(--_m)">${S}</g>`:"")+Le(H,A/2,$-o-H.height/2,' class="pele-title" font-weight="var(--_tw)"');return{svg:mt("packet",A,$,i,r,e,y),width:A,height:$,links:[]}}var sC={type:"packet",parse:(e,t,r)=>rC(nC(e),t,r),render:iC};function lC(e,t){let r=new Map;for(let{label:n,value:i}of e.sections){if(i<0)throw new Je(`"${n}" has invalid value: ${i}. Negative values are not allowed in pie charts. All slice values must be >= 0.`,"semantic",{type:"pie"});r.has(n)||r.set(n,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,`
109
+ `):void 0,showData:e.showData,sections:r}}function km(e,t){let r=t;for(let n=e.charCodeAt(r);n>=48&&n<=57;n=e.charCodeAt(r))r++;return r}function oC(){let e=0,t=0,r=-1;return(n,i)=>{let a=n.charCodeAt(i)===45?i+1:i;if((a<e||a>=t)&&(e=a,t=km(n,a),r=-1,t>a&&n.charCodeAt(t)===46)){let l=km(n,t+1),s=l-t-1;s>0&&n.charCodeAt(l)!==46?r=l:s>1&&(r=l-1)}return t===a?-1:r>=0?r:n.charCodeAt(a)===48?n.charCodeAt(a+1)===46?-1:a+1:n.charCodeAt(t)!==46?t:t-1>a?t-1:-1}}var Mm=[zr("showData"),zr("pie"),{name:":",pattern:":"},{name:"NUMBER_PIE",pattern:/(?:-?[0-9]+\.[0-9]+(?!\.))|(?:-?(0|[1-9][0-9]*)(?!\.))/y,scanner:oC,first:"-0123456789"},nn,Wr,Br,Si,Gn,Vn,cr,an,sn];function cC(e){let t=new Er($r(e,Mm,"pie"),Mm,"pie"),r={$type:"Pie",showData:!1,sections:[]},n=()=>{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=_r(t.take()),n();break;case 5:r.accTitle=Mr(t.take()),n();break;case 6:r.title=kr(t.take()),n();break;case 7:{let i=Dr(t.take());t.expect(2);let a=Number(t.expect(3));r.sections.push({$type:"PieSection",label:i,value:a}),n();break}default:t.fail("a section, a title, or a line break")}return r}var dC=120,$s=12,pu=26,gu=32,_m=28;function mu(e,t){return e.pie?.[t]}function ta(e,t){return`${f(Math.sin(e)*t)},${f(-Math.cos(e)*t)}`}function hC(e,t,r,n){if(t-e>=Math.PI*2-1e-9){let a=(l,s)=>`M0,${f(-l)}A${f(l)},${f(l)} 0 1 ${s} 0,${f(l)}A${f(l)},${f(l)} 0 1 ${s} 0,${f(-l)}Z`;return a(r,1)+(n>0?a(n,0):"")}let i=t-e>Math.PI?1:0;return n<=0?`M0,0L${ta(e,r)}A${f(r)},${f(r)} 0 ${i} 1 ${ta(t,r)}Z`:`M${ta(e,r)}A${f(r)},${f(r)} 0 ${i} 1 ${ta(t,r)}L${ta(t,n)}A${f(n)},${f(n)} 0 ${i} 0 ${ta(e,n)}Z`}function uC(e,t,r){return ed(r,dC*2,140,(n,i)=>fC(e,t,r,n/2,i))}function fC(e,t,r,n,i){let a=r.fontSize??16,l=Math.round(a*.875),s=r.measurer??bt(r.fontFamily),o=r.padding??8,c=mu(t,"textPosition"),h=typeof c=="number"&&c>=0&&c<=1?c:.75,u=mu(t,"donutHole"),d=typeof u=="number"&&u>0&&u<=.9?u*n:0,p=String(mu(t,"legendPosition")??"right"),g=i&&(p==="left"||p==="right")?"bottom":p,m=[...e.sections],v=0;for(let[,V]of m)v+=V;let x=m.map(([V,X])=>Ve(e.showData?`${V} [${X}]`:V,!1,s,l,4e3)),k=0;for(let V of x)k=Math.max(k,V.width);k+=x.length>0?$s+8:0;let b=x.length*pu,C=Ve(e.title,!1,s,a,Xt(r),1),N=C.height>0?C.height+16:0,R=m.map(([,V])=>{let X=v>0?V/v:0;return X*100>=1&&(X*100).toFixed(0)!=="0"?X:0}),O=R.map(V=>V===0||V>=.5?!1:2*n*h*Math.sin(V*Math.PI)<s.width((V*100).toFixed(0)+"%",l,0)+6),P=O.includes(!0)?_m:0,H=g==="left"||g==="right"||g==="center"?g:"",I=g==="top"||g==="bottom",G=(n+P)*2,Z=G,z=G;H==="left"||H==="right"?(Z+=k>0?gu+k:0,z=Math.max(z,b)):I&&(Z=Math.max(Z,k),z+=b>0?20+b:0),Z=Math.max(Z,C.width);let W=o+(H==="left"?k+gu+G/2:H==="right"?G/2:Z/2),S=o+N,A=S+(g==="top"?b+20+G/2:I?G/2:z/2),$="",y="",E="",w=0,T=n+_m/2,_=[],M=(V,X,Q)=>_.every(ne=>Math.abs(V-ne.x)>=(Q+ne.width)/2+2||Math.abs(X-ne.y)>=l+2);m.forEach(([V],X)=>{let Q=R[X];if(Q===0)return;let ne=w+Q*Math.PI*2;$+=`<path class="pele-slice" data-id="${Ge(V)}" d="${hC(w,ne,n,d)}" fill="${kt(X)}"/>`;let B=(w+ne)/2,K=(Q*100).toFixed(0)+"%";if(O[X]){let ie=s.width(K,l,0),le=B;for(let ae=0;ae<360&&!M(Math.sin(le)*T,-Math.cos(le)*T,ie);ae++)le+=2/T;let J=Math.sin(le)*T,te=-Math.cos(le)*T;_.push({x:J,y:te,width:ie}),E+=`<text x="${f(J)}" y="${f(te+l*.35)}">${K}</text>`}else{let ie=n*h;y+=`<text x="${f(Math.sin(B)*ie)}" y="${f(-Math.cos(B)*ie+l*.35)}">${K}</text>`}w=ne}),$===""&&($=`<circle class="pele-slice" r="${n}" fill="none" stroke="var(--_b)"/>`);let U="",j,Y;H==="right"?(j=W+G/2+gu,Y=S+(z-b)/2):H==="left"?(j=o,Y=S+(z-b)/2):H==="center"?(j=W-k/2,Y=A-b/2):(j=o+(Z-k)/2,Y=g==="top"?S:S+G+20),x.forEach((V,X)=>{let Q=Y+X*pu+pu/2;U+=`<g class="pele-legend-item" data-id="${Ge(m[X][0])}"><rect x="${f(j)}" y="${f(Q-$s/2)}" width="${$s}" height="${$s}" rx="2" fill="${kt(X)}"/>`+Le(V,j+$s+8+V.width/2,Q,"")+"</g>"});let D=Math.ceil(Z+2*o),L=Math.ceil(z+N+2*o),F=Le(C,D/2,o+C.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-slices" transform="translate(${f(W)},${f(A)})" stroke="var(--_bg)" stroke-width="1" stroke-linejoin="round">${$}</g>`+(y?`<g class="pele-slice-labels" transform="translate(${f(W)},${f(A)})" font-size="${l}" text-anchor="middle" fill="var(--_bg)">${y}</g>`:"")+(E?`<g class="pele-slice-labels" transform="translate(${f(W)},${f(A)})" font-size="${l}" text-anchor="middle">${E}</g>`:"")+(U?`<g class="pele-legend" font-size="${l}">${U}</g>`:"");return{svg:mt("pie",D,L,a,r,e,F),width:D,height:L,links:[]}}var pC={type:"pie",parse:(e,t,r)=>lC(cC(e),r),render:uC},gC=/^\d+$/,Em=/^#?([\dA-Fa-f]{6}|[\dA-Fa-f]{3})$/,mC=/^\d+px$/;function So(e,t,r){return new Je(`value for ${e} ${t} is invalid, please use a valid ${r}`,"semantic",{type:"quadrantChart"})}function yC(e){let t=e.trim(),r=t.indexOf(":");if(r===-1)return[t,"undefined"];let n=t.slice(r+1).trimStart(),i=n.indexOf(":");return[t.slice(0,r).trimEnd(),i===-1?n:n.slice(0,i).trimEnd()]}function Am(e){let t={};for(let r of e){let[n,i]=yC(r);if(n==="radius"){if(!gC.test(i))throw So(n,i,"number");t.radius=parseInt(i)}else if(n==="color"){if(!Em.test(i))throw So(n,i,"hex code");t.color=i}else if(n==="stroke-color"){if(!Em.test(i))throw So(n,i,"hex code");t.strokeColor=i}else if(n==="stroke-width"){if(!mC.test(i))throw So(n,i,"number of pixels (eg. 10px)");t.strokeWidth=i}else throw new Je(`style named ${n} is not supported.`,"semantic",{type:"quadrantChart"})}return t}function mn(e){return{text:e.text.trim(),type:e.type}}var xC=class{type="quadrantChart";title;accTitle;accDescr;quadrants=[void 0,void 0,void 0,void 0];xAxisLeft;xAxisRight;yAxisBottom;yAxisTop;points=[];classes=new Map;setQuadrant1Text(e){this.quadrants[0]=mn(e)}setQuadrant2Text(e){this.quadrants[1]=mn(e)}setQuadrant3Text(e){this.quadrants[2]=mn(e)}setQuadrant4Text(e){this.quadrants[3]=mn(e)}setXAxisLeftText(e){this.xAxisLeft=mn(e)}setXAxisRightText(e){this.xAxisRight=mn(e)}setYAxisBottomText(e){this.yAxisBottom=mn(e)}setYAxisTopText(e){this.yAxisTop=mn(e)}addPoint(e,t,r,n,i){this.points.push({x:Number(r),y:Number(n),text:mn(e),className:t,...Am(i)})}addClass(e,t){this.classes.set(e,Am(t))}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
110
+ `)}};function Jt(e,t,r){for(let n=0;n<r.length;n++){let i=e.charCodeAt(t+n),a=r.charCodeAt(n);if(i!==a&&!(a>=97&&a<=122&&i===a-32))return!1}return!0}var Tm=["$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"],yu=[41,4,6,8,9,19],Rf=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++)Rf[e.charCodeAt(r)]=t;function bC(e){let t=e.length,r=[],n=[],i=[],a=[],l=0,s=0,o=0,c=0,h=0,u=0,d=0,p=0,g=0,m=0,v=(O,P,H)=>{r.push(O),n.push(e.slice(P,H)),i.push(P),s=H},x=O=>{a.push(l),l=O},k=()=>{a.length>0&&(l=a.pop())},b=O=>{let P=e.indexOf(`
111
+ `,O);return P===-1?t:P},C=O=>{for(;e.charCodeAt(O)===32;)O++;return O},N=O=>{for(;O<t&&Xe(e.charCodeAt(O));)O++;return O},R=O=>{let P=e.charCodeAt(O);if(P===49)return O+1;if(P!==48)return-1;let H=O+1;if(H<t&&!_c(e.charCodeAt(H))&&gt(e.charCodeAt(H+1)))for(H+=2;gt(e.charCodeAt(H));)H++;return H};e:for(;s<t;){let O=e.charCodeAt(s),P=e.charCodeAt(s+1);switch(l){case 0:break;case 1:case 2:case 3:v(yu[l],s,b(s)),k();continue;case 4:if(O===125)s++,k();else{let S=e.indexOf("}",s);v(9,s,S===-1?t:S)}continue;case 5:if(O===34)s++,k();else{let S=e.indexOf('"',s);v(19,s,S===-1?t:S)}continue;case 6:if(O===96&&P===34){s+=2,k();continue}if(O!==96&&O!==34){let S=s+1;for(let A=e.charCodeAt(S);S<t&&A!==96&&A!==34;A=e.charCodeAt(++S));v(18,s,S);continue}break e;case 7:if(nt(O)){let S=s+1;for(;nt(e.charCodeAt(S));)S++;v(20,s,S),k();continue}break e;case 8:{let S=R(s);if(S!==-1){v(22,s,S),x(9);continue}let A=N(s);if(e.charCodeAt(A)===93){s=C(A+1),k();continue}break e}case 9:{let S=N(s);if(e.charCodeAt(S)===44){s=N(S+1),l=10;continue}break e}case 10:{let S=R(s);if(S!==-1){v(23,s,S),k();continue}break e}}if(O===37&&P===37){s=b(s+2);continue}if(O!==125&&P===37&&e.charCodeAt(s+2)===37){s=b(s+3);continue}if(O===10||O===13){let S=s+1;for(let A=e.charCodeAt(S);A===10||A===13;A=e.charCodeAt(++S));v(2,s,S);continue}let H=O|32;if(H===116&&Jt(e,s,"title")&&!nt(e.charCodeAt(s+5))){v(3,s,s+5),x(1);continue}if(H===97&&Jt(e,s,"acc")){let S=Jt(e,s+3,"descr");if(S||Jt(e,s+3,"title")){let A=N(s+8),$=e.charCodeAt(A);if($===58){v(S?7:5,s,N(A+1)),x(S?3:2);continue}if($===123&&S){s=N(A+1),x(4);continue}}}let I=s;O===32&&((s<o||s>=c)&&(o=s,c=C(s)),I=c);let G=e.charCodeAt(I),Z=G|32,z=0,W=0;if(Z===120&&Jt(e,I,"x-axis"))z=10,W=I+6;else if(Z===121&&Jt(e,I,"y-axis"))z=11,W=I+6;else if(G===45){if(I<h||I>=u)for(h=I,u=I;e.charCodeAt(u)===45;)u++;u-I>=2&&e.charCodeAt(u)===62&&(z=12,W=u+1)}else if(Z===113&&Jt(e,I,"quadrant")){let S=e.charCodeAt(I+9);e.charCodeAt(I+8)===45&&S>=49&&S<=52?(z=13+S-49,W=I+10):Jt(e,I+8,"chart")&&(z=24,W=I+13)}if(z!==0){v(z,s,C(W));continue}if(H===99&&Jt(e,s,"classdef")&&!nt(e.charCodeAt(s+8))){v(17,s,s+8);continue}if(O===34){P===96?(s+=2,x(6)):(s++,x(5));continue}if(O===58&&P===58&&e.charCodeAt(s+2)===58){s+=3,x(7);continue}if(O===58||Xe(O)){let S=s;if(O!==58&&((s<d||s>=p)&&(d=s,p=N(s)),S=p),e.charCodeAt(S)===58&&((S+1<g||S+1>=m)&&(g=S+1,m=N(S+1)),e.charCodeAt(m)===91)){v(21,s,N(m+1)),x(8);continue}}if($a(O)){let S=s+1;for(;$a(e.charCodeAt(S));)S++;v(25,s,S);continue}if(O>=128){let S=s+1;for(;e.charCodeAt(S)>=128;)S++;v(26,s,S);continue}if(gt(O)){let S=s+1;for(;gt(e.charCodeAt(S));)S++;v(37,s,S);continue}if(Rf[O]!==0){v(Rf[O],s,s+1);continue}break}return s<t?(r.push(1),n.push(""),i.push(s),{types:r,texts:n,starts:i}):(l<yu.length&&(r.push(yu[l]),n.push(""),i.push(t)),r.push(0),n.push(""),i.push(t),{types:r,texts:n,starts:i})}function sd(...e){let t=new Uint8Array(42);for(let r of e)t[r]=1;return t}var Sm=sd(40,35,37,25,29,28,30,31,34,32,33,26),Cm=sd(25,37,36,29,27,35,32,31,26),xu=sd(25,37,27,38,32,36),Im=sd(2,39,41),wC=["setQuadrant1Text","setQuadrant2Text","setQuadrant3Text","setQuadrant4Text"],vC="'STR', 'MD_STR', 'ALPHA', 'NUM', 'UNICODE_TEXT', 'PUNCTUATION'";function $C(e,t){let{types:r,texts:n,starts:i}=bC(e),a=0,l=u=>{let d=r[a];throw d===1?vt("quadrantChart",e,i[a],"",!0):vt("quadrantChart",e,i[a],`Expecting ${u}, got '${Tm[d]}'`)},s=u=>(r[a]!==u&&l(`'${Tm[u]}'`),n[a++]),o=u=>u===19||u===18||Sm[u]===1,c=()=>{let u=r[a];o(u)||l(vC);let d=n[a++];for(;Sm[r[a]]===1||r[a]===38||r[a]===36;)d+=n[a++];return{text:d,type:u===18?"markdown":"text"}},h=()=>{let u=[];for(;;){xu[r[a]]===0&&l("'ALPHA', 'NUM', 'COLON', 'SPACE', 'BRKT', 'MINUS'");let d=n[a++];for(;xu[r[a]]===1;)d+=n[a++];if(u.push(d.trim()),r[a]!==29)return u;a++}};for(;Im[r[a]]===1||r[a]===38;)a++;for(s(24);r[a]!==0;){for(;r[a]===38;)a++;let u=r[a];switch(u){case 17:{a++,s(38),Cm[r[a]]===0&&l("'ALPHA', 'NUM', 'UNICODE_TEXT'");let d=n[a++];for(;Cm[r[a]]===1;)d+=n[a++];s(38),t.addClass(d,h());break}case 10:case 11:{a++;let d=c(),p;r[a]===12&&(a++,o(r[a])?p=c():d.text+=" ⟶ "),u===10?(t.setXAxisLeftText(d),p&&t.setXAxisRightText(p)):(t.setYAxisBottomText(d),p&&t.setYAxisTopText(p));break}case 13:case 14:case 15:case 16:a++,t[wC[u-13]](c());break;case 3:a++,t.setDiagramTitle(s(4).trim());break;case 5:a++,t.setAccTitle(s(6).trim());break;case 7:a++,t.setAccDescription(s(8).trim());break;case 9:t.setAccDescription(n[a++].trim());break;default:if(o(u)){let d=c(),p=r[a]===20?n[a++]:"";s(21);let g=s(22),m=s(23);t.addPoint(d,p,g,m,xu[r[a]]===1?h():[])}}Im[r[a]]===0&&l("'NEWLINE', 'SEMI', 'EOF'"),a++}}var Nm=4,kC=300;function Of(e,t){return e.quadrantChart?.[t]}function yn(e,t,r,n){let i=Of(e,t);return typeof i=="number"&&i>=0?Math.min(i,n):r}function Rm(e){return e.startsWith("#")?e:"#"+e}function MC(e,t,r){let n=r.fontSize??16,i=Math.round(n*.875),a=Math.round(n*.75),l=r.measurer??bt(r.fontFamily),s=Math.round(Math.max(100,yn(t,"chartWidth",500,4e3))),o=Math.round(td(r,s,280)),c=Math.round(Math.max(100,yn(t,"chartHeight",500,4e3))*o/s),h=yn(t,"quadrantPadding",r.padding??8,200),u=yn(t,"xAxisLabelPadding",5,200),d=yn(t,"yAxisLabelPadding",5,200),p=e.points.length>0,g=(K,ie,le)=>Ve(K?.text,K?.type==="markdown",l,ie,Math.max(le,40)),m=Ve(e.title,!1,l,n,Math.max(o-2*h,40),1),v=yn(t,"titlePadding",10,200),x=m.height>0?m.height+v:0,k=!!(e.xAxisLeft?.text||e.xAxisRight?.text),b=!!(e.yAxisBottom?.text||e.yAxisTop?.text),C=p||Of(t,"xAxisPosition")==="bottom",N=Of(t,"yAxisPosition")==="right",R=o-2*h,O=g(e.xAxisLeft,i,e.xAxisRight?R/2-16:R),P=g(e.xAxisRight,i,R/2-16),H=Math.max(O.height,P.height),I=k?H+u:0,G=c-2*h-x-I,Z=g(e.yAxisBottom,i,e.yAxisTop?G/2-16:G),z=g(e.yAxisTop,i,G/2-16),W=Math.max(Z.height,z.height),S=b?W+d:0,A=h+(N?0:S),$=h+x+(C?0:I),y=Math.max(0,R-S),E=Math.max(0,G),w=Math.max(0,(y-Nm)/2),T=Math.max(0,(E-Nm)/2),_=[A+w,$,A+y-w,$+E,A,$+T,A+y,$+E-T],M=(K,ie,le,J,te)=>{for(let ae=K;ae<_.length;ae+=4)if(ie<_[ae+2]&&J>_[ae]&&le<_[ae+3]&&te>_[ae+1])return!1;return!0},U=yn(t,"quadrantTextTopPadding",5,200),j="";for(let K=0;K<4;K++){let ie=K===0||K===3?A+y-w:A,le=K<2?$:$+E-T,J=g(e.quadrants[K],n,w-16),te=ie+w/2,ae=p?le+U+J.height/2:le+T/2;_.push(te-J.width/2,ae-J.height/2,te+J.width/2,ae+J.height/2),j+=`<g class="pele-quadrant" data-id="${K+1}"><rect x="${f(ie)}" y="${f(le)}" width="${f(w)}" height="${f(T)}"${xt}/>`+Le(J,te,ae,' class="pele-label" fill="var(--_fg)" stroke="none"')+"</g>"}let Y="";if(k){let K=C?$+E+u+H/2:$-u-H/2;Y+=Le(O,P.height>0?A+y/4:A+O.width/2,K,"")+Le(P,A+y*3/4,K,"")}if(b){let K=N?A+y+d+W/2:A-d-W/2,ie=(le,J)=>le.height>0?`<g transform="translate(${f(K)},${f(J)}) rotate(-90)">${Le(le,0,0,"")}</g>`:"";Y+=ie(Z,z.height>0?$+E*3/4:$+E-Z.width/2)+ie(z,$+E/4)}let D=yn(t,"pointRadius",5,200),L=yn(t,"pointTextPadding",5,200),F=kt(0),V=[],X=[];for(let K of e.points){if(!(K.x>=0&&K.x<=1&&K.y>=0&&K.y<=1))continue;let ie=e.classes.get(K.className),le=Math.min(K.radius??ie?.radius??D,2e3),J=K.color??ie?.color,te=K.strokeColor??ie?.strokeColor,ae=K.strokeWidth??ie?.strokeWidth,ee=[];J&&ee.push("fill:"+Rm(J)),ae&&(te&&ee.push("stroke:"+Rm(te)),ee.push("stroke-width:"+ae));let re=A+K.x*y,de=$+(1-K.y)*E;V.push({cx:re,cy:de,reach:le+(ae?Math.min(parseInt(ae),400)/2:0),text:g(K.text,a,200)}),X.push(`<circle class="pele-point${jt(K.className)}" data-id="${Ge(K.text.text)}" cx="${f(re)}" cy="${f(de)}" r="${f(le)}"${ae&&!te?` stroke="${F}"`:""}${Ot(ee).shape}/>`)}let Q=V.length<=kC;if(Q)for(let{cx:K,cy:ie,reach:le}of V)_.push(K-le,ie-le,K+le,ie+le);let ne="";for(let{cx:K,cy:ie,reach:le,text:J}of V){let te=J.width/2,ae=J.size*.6+(J.height-J.lineHeight)/2,ee=le+L,re=[K,ie+ee+ae,K,ie-ee-ae,K+ee+te,ie,K-ee-te,ie],de=K,ye=re[1],oe=!1;for(let xe=0;xe<16;xe+=2){let fe=xe%8,pe=fe<4&&J.width<y?Math.min(Math.max(re[fe],A+te),A+y-te):re[fe],Me=re[fe+1];if(pe-te<A||pe+te>A+y||Me-ae<$||Me+ae>$+E)continue;let Ae=!Q||M(xe<8?0:8,pe-te,Me-ae,pe+te,Me+ae);if((!oe||Ae)&&(de=pe,ye=Me,oe=!0),Ae)break}Q&&_.push(de-te,ye-ae,de+te,ye+ae),ne+=Le(J,de,ye,' class="pele-label"')}let B=Le(m,o/2,v/2+m.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-quadrants" fill="var(--_s)" stroke="var(--_b)">${j}</g>`+(Y?`<g class="pele-axis-labels" font-size="${i}" fill="var(--_m)">${Y}</g>`:"")+(V.length>0?`<g class="pele-points" fill="${F}">${X.reverse().join("")}</g><g class="pele-point-labels" font-size="${a}">${ne}</g>`:"");return{svg:mt("quadrantChart",o,c,n,r,e,B),width:o,height:c,links:[]}}var _C={type:"quadrantChart",parse(e,t,r){let n=new xC;return n.title=r,$C(e,n),n},render:MC},Om=32;function Lm(e){return new Je(e,"semantic",{type:"radar"})}function EC(e,t){let r=e.axes.map(a=>({name:a.name,label:a.label??a.name})),n=e.curves.map(a=>{let l;if(a.entries[0].axis===void 0)l=a.entries.map(s=>s.value);else{if(r.length===0)throw Lm("Axes must be populated before curves for reference entries");let s=new Map;for(let o of a.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 Lm("Missing entry for axis "+o.label);return c})}return{name:a.name,label:a.label??a.name,entries:l}}),i={showLegend:!0,ticks:5,max:null,min:0,graticule:"circle"};for(let a of e.options)a.name==="showLegend"?i.showLegend=a.value:a.name==="graticule"?i.graticule=a.value:i[a.name]=a.value;return i.ticks>Om&&(i.ticks=Om),{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,`
112
+ `):void 0,axes:r,curves:n,options:i}}var Lf=0,bc=0;function Dm(e,t){let r=t;for(let n=e.charCodeAt(r);n>=48&&n<=57;n=e.charCodeAt(r))r++;return r}function AC(e,t){(t<Lf||t>=bc)&&(Lf=t,bc=Dm(e,t));let r=bc;if(r===t)return-1;let n=e.charCodeAt(r)===46;if(n){let i=Dm(e,r+1),a=i-r-1;if(a>0&&e.charCodeAt(i)!==46)return i;if(a>1)return i-1}return e.charCodeAt(t)===48?t+1:n?r-1>t?r-1:-1:r}var bu=nn.pattern,wu=/[\t ]*accDescr\s*{/y,wc=-2;function TC(e,t){return wu.lastIndex=t,wu.test(e)&&(wc===-2&&(wc=e.lastIndexOf("}")),wu.lastIndex>wc)?-1:(bu.lastIndex=t,bu.test(e)?bu.lastIndex:-1)}var Df={name:"ID",pattern:/[\w]([-\w]*\w)?/y},li=e=>({name:e,pattern:e,longer:[Df]}),oi=e=>({name:e,pattern:e}),Bb=[oi("radar-beta:"),{...zr("radar-beta"),longer:[Df]},li("showLegend"),li("graticule"),li("curve"),li("ticks"),li("axis"),li("max"),li("min"),oi(":"),oi(","),oi("["),oi("]"),oi("{"),oi("}"),{name:"GRATICULE",pattern:/circle|polygon/y},{name:"BOOLEAN",pattern:/true|false/y},{...nn,match:TC},Wr,Br,{name:"NUMBER",pattern:/(?:[0-9]+\.[0-9]+(?!\.))|(?:0|[1-9][0-9]*(?!\.))/y,match:AC},Si,Df,Gn,Vn,cr,an,sn];function SC(e){return Lf=bc=0,wc=-2,$r(e,Bb,"radar")}function CC(e){let t=new Er(SC(e),Bb,"radar"),r={$type:"Radar",axes:[],curves:[],options:[]},n=()=>{for(;t.kind===23;)t.i++},i=()=>{t.kind!==-1&&(t.kind!==23&&t.fail("a line break or the end of input"),n())},a=()=>{if(!t.accept(11))return;let u=Dr(t.expect(21));return t.expect(12),u},l=u=>{if(!u)return{$type:"Entry",value:Number(t.expect(20))};let d={$refText:t.expect(22)};return t.accept(9),{$type:"Entry",axis:d,value:Number(t.expect(20))}},s=()=>{let u=t.expect(22),d=a(),p={$type:"Curve",name:u,entries:[]};d!==void 0&&(p.label=d),t.expect(13),n(),t.kind!==20&&t.kind!==22&&t.fail("a number or an axis name");let g=t.kind===22;for(p.entries.push(l(g));t.accept(10);)n(),p.entries.push(l(g));return n(),t.expect(14),p},o=()=>{let u={$type:"Axis",name:t.expect(22)},d=a();return d!==void 0&&(u.label=d),u},c=()=>{let u=t.kind,d=t.take(),p;return u===2?p=t.expect(16)==="true":u===3?p=t.expect(15):p=Number(t.expect(20)),{$type:"Option",name:d,value:p}},h=()=>t.kind===2||t.kind===5||t.kind===7||t.kind===8||t.kind===3;for(n(),t.accept(0)||(t.expect(1),t.accept(9)),n();t.kind!==-1;)switch(t.kind){case 23:t.i++;break;case 17:r.accDescr=_r(t.take()),i();break;case 18:r.accTitle=Mr(t.take()),i();break;case 19:r.title=kr(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(h()||t.fail("an axis, a curve, an option, a title, or a line break"),r.options.push(c());t.accept(10);)h()||t.fail("an option"),r.options.push(c())}return r}var ra=12,vu=26,Pm=24;function xn(e,t,r,n,i){let a=e.radar?.[t];return typeof a=="number"&&a>=n?Math.min(a,i):r}function IC(e,t,r,n){let i=Math.min(Math.max(e,t),r);return n*(i-t)/(r-t)}function NC(e,t){let r=e.length,n=`M${f(e[0].x)},${f(e[0].y)}`;for(let i=0;i<r;i++){let a=e[(i-1+r)%r],l=e[i],s=e[(i+1)%r],o=e[(i+2)%r];n+=` C${f(l.x+(s.x-a.x)*t)},${f(l.y+(s.y-a.y)*t)} ${f(s.x-(o.x-l.x)*t)},${f(s.y-(o.y-l.y)*t)} ${f(s.x)},${f(s.y)}`}return n+" Z"}function zm(e){let t="";for(let r of e)t+=(t?" ":"")+f(r.x)+","+f(r.y);return t}function RC(e,t,r){let n=xn(t,"width",320,1,4e3);return ed(r,n,160,(i,a)=>OC(e,t,r,i,xn(t,"height",320,1,4e3)*i/n,a))}function OC(e,t,r,n,i,a){let l=r.fontSize??16,s=Math.round(l*.875),o=r.measurer??bt(r.fontFamily),c=r.padding??8,h=xn(t,"axisScaleFactor",1,0,10),u=xn(t,"axisLabelFactor",1.05,0,10),d=xn(t,"curveTension",.17,0,1),p=Math.min(n,i)/2,{axes:g,curves:m}=e,{ticks:v,graticule:x,min:k}=e.options,b=g.length,C=g.map((D,L)=>{let F=2*Math.PI*L/b-Math.PI/2;return{x:Math.cos(F),y:Math.sin(F)}}),N=e.options.max;if(N===null){N=-1/0;for(let D of m)for(let L of D.entries)L>N&&(N=L)}let R=-n/2-xn(t,"marginLeft",16,0,2e3),O=n/2+xn(t,"marginRight",16,0,2e3),P=-i/2-xn(t,"marginTop",16,0,2e3),H=i/2+xn(t,"marginBottom",16,0,2e3),I="";for(let D=0;D<v;D++){let L=Math.min(p,p*(D+1)/v);x==="circle"?I+=`<circle r="${f(L)}"/>`:I+=`<polygon points="${zm(C.map(F=>({x:F.x*L,y:F.y*L})))}"/>`}let G="",Z="";C.forEach((D,L)=>{let F=p*h;G+=`M0,0L${f(D.x*F)},${f(D.y*F)}`;let V=Ve(g[L].label,!1,o,s,4e3),X=p*u+6,Q=D.x*X+(D.x>.01?V.width/2:D.x<-.01?-V.width/2:0),ne=D.y*X+(D.y>.01?V.height/2:D.y<-.01?-V.height/2:0);Z+=`<g class="pele-axis-label" data-id="${Ge(g[L].name)}">${Le(V,Q,ne,"")}</g>`,R=Math.min(R,Q-V.width/2),O=Math.max(O,Q+V.width/2),P=Math.min(P,ne-V.height/2),H=Math.max(H,ne+V.height/2)});let z="";m.forEach((D,L)=>{if(D.entries.length!==b)return;let F=D.entries.map((Q,ne)=>{let B=IC(Q,k,N,p),K=Number.isFinite(B)?B:0;return{x:C[ne].x*K,y:C[ne].y*K}}),V=kt(L),X=` class="pele-curve" data-id="${Ge(D.name)}" fill="${V}" stroke="${V}"`;z+=x==="circle"?`<path${X} d="${NC(F,d)}"/>`:`<polygon${X} points="${zm(F)}"/>`});let W=e.options.showLegend?m.map(D=>Ve(D.label,!1,o,s,4e3)):[],S=0;for(let D of W)S=Math.max(S,D.width);let A=W.length*vu,$=a?-(ra+8+S)/2:O+Pm,y=a?H+Pm/2:-A/2;W.length>0&&a?(R=Math.min(R,$),O=Math.max(O,-$),H=y+A):W.length>0&&(O=$+ra+8+S,P=Math.min(P,-A/2),H=Math.max(H,A/2));let E="";W.forEach((D,L)=>{let F=y+L*vu+vu/2,V=kt(L);E+=`<g class="pele-legend-item" data-id="${Ge(m[L].name)}"><rect x="${f($)}" y="${f(F-ra/2)}" width="${ra}" height="${ra}" rx="2" fill="${V}" fill-opacity="0.4" stroke="${V}"/>`+Le(D,$+ra+8+D.width/2,F,"")+"</g>"});let w=Ve(e.title,!1,o,l,Xt(r),1),T=w.height>0?w.height+8:0,_=Math.max(O-R,w.width),M=Math.ceil(_+2*c),U=Math.ceil(H-P+T+2*c),j=`translate(${f(c+(_-(O-R))/2-R)},${f(c+T-P)})`,Y=Le(w,M/2,c+w.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="${j}">`+(I?`<g class="pele-graticule" fill="none" stroke="var(--_a)">${I}</g>`:"")+(G?`<path class="pele-axes" d="${G}" fill="none" stroke="var(--_b)"/>`:"")+(z?`<g class="pele-curves" fill-opacity="0.2" stroke-width="1.5" stroke-linejoin="round">${z}</g>`:"")+(Z?`<g class="pele-axis-labels" font-size="${s}">${Z}</g>`:"")+(E?`<g class="pele-legend" font-size="${s}">${E}</g>`:"")+"</g>";return{svg:mt("radar",M,U,l,r,e,Y),width:M,height:U,links:[]}}var LC={type:"radar",parse:(e,t,r)=>EC(CC(e),r),render:RC};function Hb(e){return e===32||e>=9&&e<=13||e>127&&/\s/.test(String.fromCharCode(e))}function DC(){let e=1/0;return(t,r)=>{if(!t.startsWith("accDescr",r))return-1;let n=t.length,i=r+8;for(;i<n&&(t.charCodeAt(i)===32||t.charCodeAt(i)===9);)i++;if(t.charCodeAt(i)===58){for(i++;i<n;i++){let l=t.charCodeAt(i);if(l===10||l===13||l===37&&t.charCodeAt(i+1)===37)break}return i}for(;i<n&&Hb(t.charCodeAt(i));)i++;if(t.charCodeAt(i)!==123||i>=e)return-1;let a=t.indexOf("}",i+1);return a===-1&&(e=i),a+1||-1}}var jb="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",ld={name:"TITLE",pattern:/title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|)/y,first:"t"},od={name:"ACC_TITLE",pattern:/accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/y,first:"a"},cd={name:"ACC_DESCR",pattern:/accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\s*{([^}]*)})/y,first:"a",scanner:DC};function pt(e,t){return{name:e,pattern:e,longer:t}}function dd(e,t){return{...zr(e),longer:[t]}}function cp(e){return{name:e,pattern:/[A-Z_a-z][\w-]*/y,first:jb+"_"}}function dp(e){return{name:e,pattern:/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'/y,first:`"'`}}function hd(e){return[{name:e+"_WHITESPACE",pattern:/[\t \r\n]+/y,hidden:!0,first:` \r
113
+ `},{...cr,name:e+"_YAML",first:"-"},{...an,name:e+"_DIRECTIVE",first:" %"},{...sn,name:e+"_SINGLE_LINE_COMMENT",first:" %"}]}function Ra(e){if(!e.includes("\\"))return e.slice(1,-1);let t=e.length-1,r="";for(let n=1;n<t;n++){let i=e[n];i==="\\"&&n+1<t?(i=e[++n],r+=i==="n"?`
114
+ `:i==="r"?"\r":i==="t"?" ":i):r+=i}return r}function ud(e,t,r,n,i,a){let l=new Er($r(e,t,"railroad"),t,"railroad"),s={$type:r,rules:[]};for(l.expect(0);;){let o=l.kind;if(o===n){let c=kr(l.take()),h=c[0];s.title=(h==='"'||h==="'")&&c.endsWith(h)?i(c):c}else if(o===n+1)s.accTitle=Mr(l.take());else if(o===n+2)s.accDescr=_r(l.take());else break}for(;l.kind!==-1;)s.rules.push(a(l));return s}var Ub=[];function Pf(e){let t=e,r=t.element??t.primary??t.suffix,n=t.alternatives??t.elements??(r?[r]:Ub);if(t.base){n=[t.base];for(let i of t.postfixes)i.except&&n.push(i.except)}return n}var il=e=>({type:"terminal",value:e}),fd=e=>({type:"nonterminal",name:e}),Hc=e=>({type:"special",text:e}),Ta=e=>({type:"optional",element:e}),al=(e,t,r=1/0)=>({type:"repetition",element:e,min:t,max:r});function pd(e){return e.length===1?e[0]:{type:"sequence",elements:e}}function gd(e){return e.length===1?e[0]:{type:"choice",alternatives:e}}function md(e,t){return e.rules.map(r=>({name:r.name,definition:Yb(r.definition,Pf,t)}))}function Yb(e,t,r){let n=[e],i=[t(e)],a=[[]];for(;;){let l=n.length-1,s=a[l];if(s.length<i[l].length){let o=i[l][s.length];n.push(o),i.push(t(o)),a.push([])}else{let o=r(n[l],s);if(l===0)return o;n.pop(),i.pop(),a.pop(),a[l-1].push(o)}}}var Fm="0123456789",Wm={name:"ABNF_RULENAME",pattern:/[A-Za-z][A-Za-z0-9-]*/y,first:jb},Bm={name:"ABNF_COMMENT",pattern:/;[^\n\r]*/y,hidden:!0,first:";"},Gb=[dd("railroad-abnf-beta",Wm),pt("="),pt(";",[Bm]),pt("/"),pt("("),pt(")"),pt("["),pt("]"),ld,od,cd,Wm,{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:Fm+"*"},{name:"ABNF_EXACT_REPEAT",pattern:/[0-9]+/y,first:Fm},...hd("ABNF"),Bm];function Hm(e,t,r,n){let i={$type:"AbnfConcatenation",elements:[]};return t.alternatives.push(i),{alternation:t,concatenation:i,node:e,close:r,repeat:n}}function PC(e){let t=[],r=Hm(void 0,{$type:"AbnfAlternation",alternatives:[]},-2,void 0);for(;;){let n=e.kind===14||e.kind===15?e.take():void 0,i,a=e.kind;switch(a){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=Hm({$type:a===4?"AbnfGroup":"AbnfOptionalGroup",element:l},l,a+1,n);continue}default:e.fail("a string, a number, a name, or an opening bracket")}for(;;){r.concatenation.elements.push(n===void 0?{$type:"AbnfElement",primary:i}:{$type:"AbnfElement",repeat:n,primary:i});let l=e.kind;if(l===r.close){e.i++,i=r.node,n=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 '${Gb[r.close].name}'`)}break}}}function zC(e){return ud(e,Gb,"RailroadAbnf",8,t=>t.slice(1,-1),t=>{let r=t.expect(11);t.expect(1);let n=PC(t);return t.expect(2),{$type:"AbnfRule",name:r,definition:n}})}function FC(e,t){switch(e.$type){case"AbnfAlternation":return gd(t);case"AbnfConcatenation":return pd(t);case"AbnfElement":{let r=e.repeat;if(!r)return t[0];let n=r.indexOf("*"),i=n===-1,a=n>0||i?parseInt(r,10):0,l=i?a:n<r.length-1?parseInt(r.slice(n+1),10):1/0;return a===0&&l===1?Ta(t[0]):al(t[0],a,l)}case"AbnfStringLiteral":case"AbnfNumVal":return il(e.value);case"AbnfRuleName":return fd(e.name);case"AbnfGroup":return t[0];case"AbnfOptionalGroup":return Ta(t[0])}}var WC=e=>md(e,FC);function BC(e,t){if(e.charCodeAt(t)!==63)return-1;let r=!1;for(let n=t+1;n<e.length;n++){let i=e.charCodeAt(n);if(i===63)return r?n+1:-1;if(i===59)return-1;r||=!Hb(i)}return-1}var jm=cp("EBNF_ID"),Um={name:"EBNF_SPECIAL_SEQUENCE",pattern:/\?(?=[^?;]*[^?\s;][^?;]*\?)[^?;]*\?/y,first:"?",scanner:()=>BC},Ym=hd("EBNF"),Gm={name:"EBNF_ISO_COMMENT",pattern:/\(\*[\s\S]*?\*\)/y,hidden:!0,first:"(",opener:/\(\*/y},Vb=[dd("railroad-ebnf-beta",jm),pt("::="),pt("="),pt(";"),pt("|"),pt(","),pt("(",[Gm]),pt(")"),pt("["),pt("]"),pt("{"),pt("}"),pt("?",[Um]),pt("*"),pt("+"),pt("-",[Ym[1]]),ld,od,cd,jm,dp("EBNF_STRING"),Um,...Ym,{name:"EBNF_BLOCK_COMMENT",pattern:/\/\*[\s\S]*?\*\//y,hidden:!0,first:"/",opener:/\/\*/y},Gm];function Vm(e,t,r,n){let i={$type:"EbnfSequence",elements:[]};return t.alternatives.push(i),{choice:t,sequence:i,term:void 0,node:e,close:r,except:n}}var HC=["EbnfGroup","EbnfOptional","EbnfRepetition"];function jC(e){let t=[],r=Vm(void 0,{$type:"EbnfChoice",alternatives:[]},-2,!1),n=!1;for(;;){let i,a=e.kind;switch(a){case 20:i={$type:"EbnfTerminal",value:Ra(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=Vm({$type:HC[a-6>>1],element:l},l,a+1,n),n=!1;continue}default:e.fail("a terminal, a name, or an opening bracket")}for(;;){n?(r.term.postfixes.push({$type:"EbnfExceptionPostfix",except:i}),n=!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,n=r.except,r=t.pop();continue}if(s===15)e.i++,n=!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 '${Vb[r.close].name}'`)}break}}}function UC(e){return ud(e,Vb,"RailroadEbnf",16,Ra,t=>{let r=t.expect(19);t.accept(2)||t.expect(1);let n={$type:"EbnfRule",name:r,definition:jC(t)};return t.expect(3),n})}function YC(e,t){switch(e.$type){case"EbnfChoice":return gd(t);case"EbnfSequence":return pd(t);case"EbnfTerm":{let r=t[0],n=1;for(let i of e.postfixes)i.$type==="EbnfOptionalPostfix"?r=Ta(r):i.$type==="EbnfExceptionPostfix"?r={type:"sequence",elements:[r,il("-"),t[n++]]}:r=al(r,i.$type==="EbnfOneOrMorePostfix"?1:0);return r}case"EbnfTerminal":return il(e.value);case"EbnfNonTerminal":return fd(e.name);case"EbnfSpecial":return Hc(e.text);case"EbnfGroup":return t[0];case"EbnfOptional":return Ta(t[0]);case"EbnfRepetition":return al(t[0],0)}}var GC=e=>md(e,YC),zf=cp("RR_ID"),Rn=e=>pt(e,[zf]),VC=[dd("railroad-beta",zf),Rn("nonterminal"),Rn("zeroOrMore"),Rn("oneOrMore"),Rn("sequence"),Rn("optional"),Rn("terminal"),Rn("special"),Rn("choice"),pt("="),pt(";"),pt("("),pt(","),pt(")"),ld,od,cd,zf,dp("RR_STRING"),...hd("RR"),{name:"RR_BLOCK_COMMENT",pattern:/\/\*[\s\S]*?\*\//y,hidden:!0,first:"/",opener:/\/\*/y}];function $u(e){e.i++,e.expect(11);let t=Ra(e.expect(18));return e.expect(13),t}function ku(e){return{$type:e,element:void 0}}function qC(e){let t=[];for(;;){let r;switch(e.kind){case 6:r={$type:"RailroadTerminalExpr",value:$u(e)};break;case 1:r={$type:"RailroadNonTerminalExpr",name:$u(e)};break;case 7:r={$type:"RailroadSpecialExpr",text:$u(e)};break;case 4:r={$type:"RailroadSequenceExpr",elements:[]};break;case 8:r={$type:"RailroadChoiceExpr",alternatives:[]};break;case 5:r=ku("RailroadOptionalExpr");break;case 3:r=ku("RailroadOneOrMoreExpr");break;case 2:r=ku("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 n=t[t.length-1];if(n===void 0)return r;if("element"in n)n.element=r;else if(("elements"in n?n.elements:n.alternatives).push(r),e.accept(12))break;e.expect(13),t.pop(),r=n}}}function XC(e){return ud(e,VC,"Railroad",14,Ra,t=>{let r=t.expect(17);t.expect(9);let n=qC(t);return t.expect(10),{$type:"RailroadRule",name:r,definition:n}})}function KC(e,t){switch(e.$type){case"RailroadTerminalExpr":return il(e.value);case"RailroadNonTerminalExpr":return fd(e.name);case"RailroadSpecialExpr":return Hc(e.text);case"RailroadSequenceExpr":return pd(t);case"RailroadChoiceExpr":return gd(t);case"RailroadOptionalExpr":return Ta(t[0]);default:return al(t[0],e.$type==="RailroadOneOrMoreExpr"?1:0)}}var ZC=e=>md(e,KC),qm=cp("PEG_ID"),QC=[dd("railroad-peg-beta",qm),pt("<-"),pt(";"),pt("/"),pt("&"),pt("!"),pt("?"),pt("*"),pt("+"),pt("("),pt(")"),pt("."),ld,od,cd,qm,dp("PEG_STRING"),...hd("PEG"),{name:"PEG_LINE_COMMENT",pattern:/#[^\n\r]*/y,hidden:!0,first:"#"}];function Xm(e,t,r){let n={$type:"PegSequence",elements:[]};return t.alternatives.push(n),{choice:t,sequence:n,node:e,operator:r}}function JC(e){let t=[],r=Xm(void 0,{$type:"PegOrderedChoice",alternatives:[]},void 0);for(;;){let n=e.kind===4||e.kind===5?e.take():void 0,i;switch(e.kind){case 16:i={$type:"PegLiteral",value:Ra(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 a={$type:"PegOrderedChoice",alternatives:[]};t.push(r),r=Xm({$type:"PegGroup",element:a},a,n);continue}default:e.fail("a literal, a name, a dot, or an opening parenthesis")}for(;;){let a={$type:"PegSuffix",primary:i};(e.kind===6||e.kind===7||e.kind===8)&&(a.operator=e.take()),r.sequence.elements.push(n===void 0?{$type:"PegPrefix",suffix:a}:{$type:"PegPrefix",operator:n,suffix:a});let l=e.kind;if(l===10&&t.length>0){e.i++,i=r.node,n=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 eI(e){return ud(e,QC,"RailroadPeg",12,Ra,t=>{let r=t.expect(15);t.expect(1);let n={$type:"PegRule",name:r,definition:JC(t)};return t.expect(2),n})}function tI(e){switch(e.type){case"terminal":return`"${e.value}"`;case"nonterminal":return e.name;case"special":return e.text;default:return"(...)"}}function rI(e,t){let r=t[0];switch(e.$type){case"PegOrderedChoice":return gd(t);case"PegSequence":return pd(t);case"PegPrefix":return e.operator?Hc(e.operator+tI(r)):r;case"PegSuffix":return e.operator?e.operator==="?"?Ta(r):al(r,e.operator==="+"?1:0):r;case"PegLiteral":return il(e.value);case"PegIdentifier":return fd(e.name);case"PegAny":return Hc(e.dot);case"PegGroup":return r}}var nI=e=>md(e,rI),iI=class{type="railroad";notation="railroad";title;accTitle;accDescr;rules=[];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,`
115
+ `)}addRule(e){this.rules.push(e),this.byName.set(e.name,e)}getRule(e){return this.byName.get(e)}},aI=/^\s*railroad-(ebnf-|abnf-|peg-)?beta/i;function sI(e){let t=aI.exec(e);if(t===null)return;let r=t[1]?.toLowerCase();return r==="ebnf-"?"ebnf":r==="abnf-"?"abnf":r==="peg-"?"peg":"railroad"}function lI(e,t){switch(t){case"ebnf":{let r=UC(e);return[r,GC(r)]}case"abnf":{let r=zC(e);return[r,WC(r)]}case"peg":{let r=eI(e);return[r,nI(r)]}default:{let r=XC(e);return[r,ZC(r)]}}}function oI(e,t,r){let[n,i]=lI(t,r);e.notation=r,n.accDescr&&e.setAccDescription(n.accDescr),n.accTitle&&e.setAccTitle(n.accTitle),n.title&&e.setTitle(n.title);for(let a of i)e.addRule(a)}function cI(e,t){let r=sI(e);if(r===void 0)throw new Je("No railroad diagram keyword found.","syntax",{type:"railroad"});let n=new iI;return t&&(n.title=t),oI(n,e,r),n}var Mu=12,dI=6,hI=18,jc=12,Rr=7;function ci(e,t,r,n){let i=e.railroad?.[t];return typeof i=="number"&&i>=0?Math.min(i,n):r}var uI=/[\n\r\t]/g;function vc(e){return(e.includes("¶ß")?It(e.replace(/&/g,"&amp;")):e).replace(uI,t=>t===`
116
+ `?"\\n":t==="\r"?"\\r":"\\t")}function Co(e,t){for(let r=t,n=e.length-1;r<n;r++,n--){let i=e[r];e[r]=e[n],e[n]=i}}function hp(e){return Math.ceil(e/2)*2}function _u(e,t,r,n,i){let a=i.height/2,l=Math.max(hp(i.measurer.width(t,i.size,n)+2*i.padding),i.height);return{kind:e,width:l,up:a,down:a,kids:Ub,text:t,id:r,reach:0}}function fI(e,t){if(t===1/0&&e<=1)return"";let r=n=>Number.isFinite(n)?String(n):"∞";return e===t?r(e)+"×":t===1/0?"≥"+r(e)+"×":e===0?"≤"+r(t)+"×":r(e)+"–"+r(t)+"×"}function qb(e,t,r,n){return Math.max(e+t.down+n.sep+r.up,2*n.arc)}function Km(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 pI(e,t,r=1/0){let n=new Map,i=[[e,r]];for(let a=0;r!==1/0&&a<i.length;a++){let[l,s]=i[a];n.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 Pf(l))i.push([c,Math.max(40,s-o)])}return Yb(e,Pf,(a,l)=>{let s=n.get(a)??1/0;switch(a.type){case"terminal":{let o=vc(a.value);return _u(0,/^ +$/.test(o)?"␣".repeat(o.length):o,"",4,t)}case"nonterminal":return _u(1,vc(a.name),a.name,0,t);case"special":return _u(2,"? "+vc(a.text)+" ?","",2,t);case"sequence":{let o=Math.max(0,l.length-1)*t.gap,c=0,h=0;for(let k of l)o+=k.width,c=Math.max(c,k.up),h=Math.max(h,k.down);let u={kind:3,width:o,up:c,down:h,kids:l,text:"",id:"",reach:0};if(o<=s||l.length<2)return u;let d=[],p=[],g=0,m=()=>{let k=0,b=0;for(let C of p)k=Math.max(k,C.up),b=Math.max(b,C.down);d.push({kind:3,width:g,up:k,down:b,kids:p,text:"",id:"",reach:0}),p=[],g=0};for(let k of l)p.length&&g+t.gap+k.width>Math.max(40,s-6*t.arc)&&m(),g+=(p.length?t.gap:0)+k.width,p.push(k);if(m(),d.length<2)return u;let v=0,x=0;for(let k=0;k<d.length;k++)v=Math.max(v,d[k].width),k&&(x+=d[k-1].down+Math.max(t.sep,2*t.arc)+d[k].up);return{kind:7,width:v+6*t.arc,up:d[0].up,down:x+d[d.length-1].down,kids:d,text:"",id:"",reach:0}}case"choice":{let o=0,c=0;for(let u=0;u<l.length;u++)o=Math.max(o,l[u].width),u>0&&(c=qb(c,l[u-1],l[u],t));let h=l[l.length-1];return{kind:4,width:o+4*t.arc,up:l.length>0?l[0].up:0,down:h?c+h.down:0,kids:l,text:"",id:"",reach:0}}case"optional":return Km(l[0],t);case"repetition":{let{min:o,max:c}=a,h=l[0];if(o===1&&c===1)return h;let u=fI(o,c),d=Math.max(h.down+t.sep,2*t.arc),p=u===""?0:hp(t.measurer.width(u,jc,0)),g={kind:6,width:Math.max(h.width,p)+2*t.arc,up:h.up,down:d+(u===""?Rr/2+1:jc+6),kids:[h],text:u,id:"",reach:d};return o===0?Km(g,t):g}}})}function gI(e,t,r){return Yn(r,n=>mI(e,t,r,n))}function mI(e,t,r,n){let i=r.fontSize??16,a=ci(t,"fontSize",0,200),l=a||Math.round(i*.875),s=a||i,o=ci(t,"padding",-1,200),c=Math.round(l*1.5),h={measurer:r.measurer??bt(r.fontFamily,r.fontFamilyMono),size:l,padding:o<0?12:o,height:hp(c+(o<0?9:2*o)),gap:Math.min(ci(t,"horizontalSeparation",16,500),n?12:1/0),sep:ci(t,"verticalSeparation",10,500),arc:Math.min(ci(t,"arcRadius",10,200),n?6:1/0)},u=t.railroad?.showMarkers===!1?0:ci(t,"markerRadius",4,50),d=ci(t,"strokeWidth",0,20),p=d>0?` stroke-width="${f(d)}"`:"",g=r.padding??8,{arc:m}=h,v=f(m),x=(j,Y,D)=>`a${v},${v} 0 0 ${j} ${Y}${v},${D}${v}`,k=x(1,"",""),b=x(0,"",""),C=x(0,"","-"),N=x(1,"","-"),R=x(0,"-",""),O=x(0,"-","-"),P=Ve(e.title,!1,h.measurer,i,n?Xt(r):4e3,1),H=P.height>0?P.height+16:0,I=Math.round(s*1.5),G=l*.35,Z=h.height/2,z="",W="",S="",A=(j,Y,D)=>{D>j&&(z+=`M${f(j)},${f(Y)}H${f(D)}`)},$=(j,Y,D)=>{let L=[j],F=[Y,D];for(;L.length>0;){let V=L.pop(),X=F.pop(),Q=F.pop(),ne=V.kids,B=Q+V.width;switch(V.kind){case 3:{let K=B;for(let ie=ne.length-1;ie>=0;ie--)K-=ne[ie].width,L.push(ne[ie]),F.push(K,X),ie>0&&A(K-h.gap,X,K),K-=h.gap;break}case 7:{let K=Q+2*m,ie=L.length,le=0;A(Q,X,K);for(let J=0;J<ne.length;J++){let te=ne[J],ae=X+le;if(L.push(te),F.push(ae,K),J+1<ne.length){let ee=ne[J+1],re=le+te.down+Math.max(h.sep,2*m)+ee.up,de=X+le+te.down+Math.max(h.sep,2*m)/2;z+=`M${f(K+te.width)},${f(ae)}H${f(B-2*m)}V${f(de)}H${f(Q+m)}V${f(X+re)}H${f(K)}`,W+=`M${f(K-Rr)},${f(X+re-Rr/2)}l${Rr},${Rr/2}l${-Rr},${Rr/2}z`,le=re}else z+=`M${f(K+te.width)},${f(ae)}H${f(B-m)}V${f(X)}H${f(B)}`}Co(L,ie),Co(F,2*ie);break}case 4:{let K=V.width-4*m,ie=Q+m,le=B-m,J=L.length,te=0;for(let ae=0;ae<ne.length;ae++){let ee=ne[ae];ae>0&&(te=qb(te,ne[ae-1],ee,h));let re=X+te,de=Q+2*m+(K-ee.width)/2,ye=ae===ne.length-1;ae===0?(A(Q,X,de),A(de+ee.width,X,B)):z+=(ye?`M${f(Q)},${f(X)}${k}V${f(re-m)}`:`M${f(ie)},${f(re-m)}`)+b+(de>ie+m?`H${f(de)}`:"")+`M${f(de+ee.width)},${f(re)}`+(de>ie+m?`H${f(le-m)}`:"")+C+(ye?`V${f(X+m)}${N}`:""),L.push(ee),F.push(re,de)}Co(L,J),Co(F,2*J);break}case 5:{let K=ne[0],ie=Q+2*m;A(Q,X,ie),A(ie+K.width,X,B),z+=`M${f(Q)},${f(X)}${C}V${f(X-V.reach+m)}${N}H${f(B-2*m)}${k}V${f(X-m)}${b}`,L.push(K),F.push(ie,X);break}case 6:{let K=ne[0],ie=Q+(V.width-K.width)/2,le=X+V.reach,J=Q+V.width/2;A(Q,X,ie),A(ie+K.width,X,B),z+=`M${f(Q+m)},${f(X)}${R}V${f(le-m)}${b}H${f(B-m)}${C}V${f(X+m)}${O}`,W+=`M${f(J-Rr/2)},${f(le)}l${Rr},${-Rr/2}v${Rr}z`,V.text!==""&&(S+=`<text class="pele-edge-label pele-count" x="${f(J)}" y="${f(le+jc+3)}" font-size="${jc}" fill="var(--_m)">${tt(V.text)}</text>`),L.push(K),F.push(ie,X);break}default:{let K=V.text,ie=K.startsWith(" ")||K.endsWith(" ")||K.includes(" ")?' xml:space="preserve"':"",le=`<rect x="${f(Q)}" y="${f(X-Z)}" width="${f(V.width)}" height="${f(h.height)}"`,J=`<text x="${f(Q+V.width/2)}" y="${f(X+G)}"${ie}`;V.kind===0?S+=`<g class="pele-node pele-terminal">${le} rx="${f(Z)}" fill="var(--_s)" stroke="var(--_b)"${p}/>${J} font-family="${ep}">${tt(K)}</text></g>`:V.kind===1?S+=`<g class="pele-node pele-nonterminal" data-id="${Ge(V.id)}">${le} fill="var(--_bg)" stroke="var(--_b)"${p}${xt}/>${J}>${tt(K)}</text></g>`:S+=`<g class="pele-node pele-special">${le} fill="var(--_bg)" stroke="var(--_b)" stroke-dasharray="4 3"${p}${xt}/>${J} font-style="italic"><tspan fill="var(--_m)">? </tspan>${tt(K.slice(2,-2))}<tspan fill="var(--_m)"> ?</tspan></text></g>`}}}},y="",E=P.width,w=g+H,T=g+P.height;for(let j of e.rules){let Y=pI(j.definition,h,n?Math.max(80,(r.maxWidth??320)-2*g-4*u-2*Mu-1):1/0),D=vc(j.name),L=w+I+dI+Y.up,F=g+2*u,V=F+Mu,X=V+Y.width+Mu;z="",W="",S="",A(F,L,V),A(V+Y.width,L,X),$(Y,V,L);let Q=u>0?`<circle class="pele-marker pele-start" cx="${f(g+u)}" cy="${f(L)}" r="${f(u)}" fill="var(--_l)"/><circle class="pele-marker pele-end" cx="${f(X+u)}" cy="${f(L)}" r="${f(u)}" fill="var(--_l)"/>`:"";y+=`<g class="pele-rule" data-id="${Ge(j.name)}"><text class="pele-rule-name" x="${f(g)}" y="${f(w+I/2+s*.35)}" font-size="${f(s)}" font-weight="var(--_hw)" text-anchor="start">${tt(D)}</text><path class="pele-edge pele-track" d="${z}" fill="none" stroke="var(--_l)"${p}/>`+(W?`<path class="pele-marker" d="${W}" fill="var(--_l)"/>`:"")+Q+S+"</g>",E=Math.max(E,X+2*u-g,h.measurer.width(D,s,1)),T=L+Y.down,w=T+h.sep+hI}let _=Math.ceil(E+2*g),M=Math.ceil(T+g),U=Le(P,_/2,g+P.height/2,' class="pele-title" font-weight="var(--_tw)"')+(y?`<g class="pele-rules" transform="translate(0.5,0.5)" font-size="${f(l)}" text-anchor="middle">${y}</g>`:"");return{svg:mt("railroad",_,M,i,r,e,U),width:_,height:M,links:[]}}var yI={type:"railroad",parse:(e,t,r)=>cI(e,r),render:gI},na={REQUIREMENT:"Requirement",FUNCTIONAL_REQUIREMENT:"Functional Requirement",INTERFACE_REQUIREMENT:"Interface Requirement",PERFORMANCE_REQUIREMENT:"Performance Requirement",PHYSICAL_REQUIREMENT:"Physical Requirement",DESIGN_CONSTRAINT:"Design Constraint"},Eu={LOW_RISK:"Low",MED_RISK:"Medium",HIGH_RISK:"High"},Io={VERIFY_ANALYSIS:"Analysis",VERIFY_DEMONSTRATION:"Demonstration",VERIFY_INSPECTION:"Inspection",VERIFY_TEST:"Test"},Pn={CONTAINS:"contains",COPIES:"copies",DERIVES:"derives",SATISFIES:"satisfies",VERIFIES:"verifies",REFINES:"refines",TRACES:"traces"},xI=1e6,bI=class{type="requirement";direction="TB";requirements=new Map;elements=new Map;relations=[];classes=new Map;title;accTitle;accDescr;newId="";newText="";newRisk="";newVerifyMethod="";newElementType="";newDocRef="";styleCopies=0;copy(e,t){if(this.styleCopies+=t.length,this.styleCopies>xI)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 n=this.node(r);if(!t||!n)return;for(let i of t)this.copy(n.cssStyles,i.includes(",")?i.split(","):[i])}}setClass(e,t){for(let r of e){let n=this.node(r);if(n)for(let i of t){n.classes.push(i);let a=this.classes.get(i)?.styles;a&&this.copy(n.cssStyles,a)}}}defineClass(e,t){for(let r of e){let n=this.classes.get(r);n===void 0&&(n={id:r,styles:[],textStyles:[]},this.classes.set(r,n));for(let a of t)a.includes("color")&&n.textStyles.push(a.replace("fill","bgFill")),n.styles.push(a);let i=t.flatMap(a=>a.split(","));for(let a of this.requirements.values())a.classes.includes(r)&&this.copy(a.cssStyles,i);for(let a of this.elements.values())a.classes.includes(r)&&this.copy(a.cssStyles,i)}}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
117
+ `)}},Zm=["$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"],wI=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]]),vI=/accTitle\s*:\s*/iy,$I=/accDescr\s*:\s*/iy,kI=/accDescr\s*\{\s*/iy,No=/direction\s+(?:(TB)|(BT)|(RL)|LR)/gi,Au=/[\n\r\u2028\u2029]/g,MI=22,Xb=new Uint8Array(128);for(let e of`:,\r
118
+ {<>-=`)Xb[e.charCodeAt(0)]=1;function _I(e){let t=e.length,r=[],n=[],i=[],a=[],l=0,s=0,o=[[],[],[],[]],c=[[],[],[],[]],h=[0,0,0,0],u=!1,d=-1;No.lastIndex=0;for(let R=No.exec(e);R!==null;R=No.exec(e)){let O=R[1]!==void 0?0:R[2]!==void 0?1:R[3]!==void 0?2:3;o[O].push(R.index),c[O].push(No.lastIndex),u=!0}let p=(R,O,P)=>{r.push(R),n.push(e.slice(O,P)),i.push(O),s=P},g=R=>{a.push(l),l=R},m=()=>{a.length>0&&(l=a.pop())},v=(R,O)=>(R.lastIndex=O,R.test(e)?R.lastIndex:-1),x=R=>{let O=e.indexOf(`
119
+ `,R);return O===-1?t:O},k=()=>{if(d<s){Au.lastIndex=s,d=Au.test(e)?Au.lastIndex-1:t;for(let R=0;R<4;R++){let O=o[R],P=h[R];for(;P<O.length&&O[P]<=d;)P++;h[R]=P}}for(let R=0;R<4;R++){let O=h[R]-1;if(O>=0&&o[R][O]>=s)return p(8+R,s,x(c[R][O])),!0}return!1},b=R=>{let O=R|32;if(O===116&&e.slice(s+1,s+5).toLowerCase()==="itle"&&Xe(e.charCodeAt(s+5))){let P=s+6;for(;P<t;){let H=e.charCodeAt(P);if(H===35||H===10||H===59)break;P++}if(P>s+6)return p(2,s,P),!0}if(O===97&&(e.charCodeAt(s+1)|32)===99&&(e.charCodeAt(s+2)|32)===99){let P;if((P=v(vI,s))>=0)return g(3),p(3,s,P),!0;if((P=v($I,s))>=0)return g(4),p(5,s,P),!0;if((P=v(kI,s))>=0)return g(5),s=P,!0}if(u&&!_c(R)&&k())return!0;if(R===10||R===13&&e.charCodeAt(s+1)===10){let P=s;for(;P<t;){let H=e.charCodeAt(P);if(H===10)P++;else if(H===13&&e.charCodeAt(P+1)===10)P+=2;else break}return p(12,s,P),!0}if(Xe(R)){for(s++;s<t&&Xe(e.charCodeAt(s));)s++;return!0}if(R===35||R===37)return s=x(s),!0;if(nt(R)){let P=s+1;for(;P<t&&nt(e.charCodeAt(P));)P++;if(P-s<=MI){let H=wI.get(e.slice(s,P).toLowerCase());if(H!==void 0)return(H===46||H===47||H===48)&&g(2),p(H,s,P),!0}for(;P<t;){let H=e.charCodeAt(P);if(H<128&&Xb[H]===1)break;P++}return r.push(59),n.push(e.slice(s,P).trim()),i.push(s),s=P,!0}switch(R){case 123:return p(15,s,s+1),!0;case 125:return p(16,s,s+1),!0;case 58:return e.charCodeAt(s+1)===58&&e.charCodeAt(s+2)===58?p(17,s,s+3):p(18,s,s+1),!0;case 60:return e.charCodeAt(s+1)!==45?!1:(p(55,s,s+2),!0);case 45:return e.charCodeAt(s+1)===62?p(56,s,s+2):p(57,s,s+1),!0;case 34:return g(1),s++,!0;case 44:return p(60,s,s+1),!0}return!1},C=R=>{if(nt(R)){let O=s+1;for(;O<t&&nt(e.charCodeAt(O));)O++;return p(49,s,O),!0}switch(R){case 58:return p(50,s,s+1),!0;case 59:return p(51,s,s+1),!0;case 37:return p(52,s,s+1),!0;case 45:return p(53,s,s+1),!0;case 35:return p(54,s,s+1),!0;case 32:return s++,!0;case 34:return g(1),s++,!0;case 10:return m(),s++,!0;case 44:return p(60,s,s+1),!0}return!1};for(;s<t;){let R=e.charCodeAt(s),O=!0;switch(l){case 0:O=b(R);break;case 2:O=C(R);break;case 1:if(R===34)m(),s++;else{let P=e.indexOf('"',s);p(58,s,P===-1?t:P)}break;case 3:m(),p(4,s,x(s));break;case 4:m(),p(6,s,x(s));break;case 5:if(R===125)m(),s++;else{let P=e.indexOf("}",s);p(7,s,P===-1?t:P)}break}if(!O)return r.push(1),n.push(""),i.push(s),{types:r,texts:n,starts:i}}let N=l===0?13:l===1?58:l===3?4:l===4?6:l===5?7:-1;return N!==-1&&p(N,t,t),p(0,t,t),{types:r,texts:n,starts:i}}var EI=[na.REQUIREMENT,na.FUNCTIONAL_REQUIREMENT,na.INTERFACE_REQUIREMENT,na.PERFORMANCE_REQUIREMENT,na.PHYSICAL_REQUIREMENT,na.DESIGN_CONSTRAINT,Eu.LOW_RISK,Eu.MED_RISK,Eu.HIGH_RISK,Io.VERIFY_ANALYSIS,Io.VERIFY_DEMONSTRATION,Io.VERIFY_INSPECTION,Io.VERIFY_TEST,"",Pn.CONTAINS,Pn.COPIES,Pn.DERIVES,Pn.SATISFIES,Pn.VERIFIES,Pn.REFINES,Pn.TRACES];function Qm(e){return e===49||e===50||e===54||e===53||e===51}function AI(e,t){let{types:r,texts:n,starts:i}=_I(e),a=0,l=[],s=[],o=(x,k=x,...b)=>{let C=r[a];if(C===1)throw vt("requirement",e,i[a],"",!0);for(let R=k;R>=x;R--)b.unshift(R);let N=b.map(R=>`'${Zm[R]}'`).join(", ");throw vt("requirement",e,i[a],`Expecting ${N}, got '${Zm[C]}'`)},c=x=>(r[a]!==x&&o(x),n[a++]),h=(x,k)=>{let b=r[a];return(b<x||b>k)&&o(x,k),a++,EI[b-23]},u=()=>{let x=r[a];return x!==59&&x!==58&&o(58,59),n[a++]},d=()=>{let x=r[a];if(x===3)a++,t.setAccTitle(c(4).trim());else if(x===5)a++,t.setAccDescription(c(6).trim());else if(x===7)t.setAccDescription(n[a++].trim());else return!1;return!0},p=()=>{let x=[];for(;;){let k=r[a];if(k!==49&&k!==59&&k!==58&&o(58,59,49),x.push(n[a++]),r[a]!==60)return x;a++}},g=()=>{let x=[];for(;;){Qm(r[a])||o(49,51,53,54);let k=n[a++];for(;Qm(r[a]);)k+=n[a++];if(x.push(k),r[a]!==60)return x;a++}},m=()=>{let x;return r[a]===17?(a++,x=p(),c(15)):r[a]===15?a++:o(15,15,17),c(12),x},v=x=>{for(l.length=0,s.length=0;;){let k=r[a];if(k===16){a++;break}if(k===12){a++;continue}(x?k<19||k>22:k!==44&&k!==45)&&(x&&o(19,22,12,16),o(44,45,12,16)),a++,c(18),s.push(k===21?h(29,31):k===22?h(32,35):u()),l.push(k),c(12)}for(let k=l.length-1;k>=0;k--){let b=s[k];switch(l[k]){case 19:t.setNewReqId(b);break;case 20:t.setNewReqText(b);break;case 21:t.setNewReqRisk(b);break;case 22:t.setNewReqVerifyMethod(b);break;case 44:t.setNewElementType(b);break;default:t.setNewElementDocRef(b)}}};for(;d();)r[a]===12&&a++;for(r[a]!==14&&o(14,14,3,5,7),a++,c(12);;){let x=r[a];if(x===13)return;if(x===12)a++;else{if(d())continue;if(x>=8&&x<=11)a++,t.setDirection(x===8?"TB":x===9?"BT":x===10?"RL":"LR");else if(x>=23&&x<=28){let k=h(23,28),b=u(),C=m();v(!0),t.addRequirement(b,k),C&&t.setClass([b],C)}else if(x===36){a++;let k=u(),b=m();v(!1),t.addElement(k),b&&t.setClass([k],b)}else if(x===46){a++;let k=p();t.setCssStyle(k,g())}else if(x===47){a++;let k=p();t.defineClass(k,g())}else if(x===48){a++;let k=p();t.setClass(k,p())}else if(x===59||x===58){let k=n[a++],b=r[a];if(b===17)a++,t.setClass([k],p());else if(b===55||b===57){a++;let C=h(37,43);c(b===57?56:57);let N=u();b===57?t.addRelationship(C,k,N):t.addRelationship(C,N,k)}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 TI(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,n=e.relations.map((i,a)=>({id:`${i.src}-${i.dst}-${a}`,start:r(i.src),end:r(i.dst),type:i.type,contains:i.type===Pn.CONTAINS}));return{nodes:t,edges:n,direction:e.direction}}var SI=40,CI=16,II=56,Ro=14,ks=10,Tu=2,Jm=12,NI=120,RI=280,OI=240,Su=26,Kb=6,ey=9,Oo=4.5,LI=28,DI=14;function Lo(e,t,r){if(t===0||e.lines.length===0)return e;let n=0,i=[],a=e.lines.map(l=>{let s=0,o=l.map(c=>{let h=c.style|t,u=c.icon!==void 0||c.math?c.width:r.width(c.text,e.size,h);return s+=u,{...c,style:h,width:u}});return i.push(s),s>n&&(n=s),o});return{...e,lines:a,widths:i,width:n}}function ty(e,t,r,n){let i=ll(e),a="",l="";for(let s=0;s<e.lines.length;s++){let o=e.lines[s],c=r+hl(e,s);if(rp(o)){l+=Le(ul(e,s),t+e.widths[s]/2,c,n);continue}let h=c+e.size*.35,u=!0;for(let d of o)d.icon!==void 0||d.text===""||(a+=`<tspan${u?` x="${f(t)}" y="${f(h)}"`:""}${ka(d.style&~i)}>${tt(d.text)}</tspan>`,u=!1)}return(a===""?"":`<text${Sa(n,i)} text-anchor="start" xml:space="preserve">${a}</text>`)+l}function PI(e,t,r,n){let i=Kb,a=e-r*i,l=t-n*i;return`<circle class="pele-marker" cx="${f(a)}" cy="${f(l)}" r="${i}"/><path class="pele-marker" d="M${f(a-r*i)},${f(l-n*i)}L${f(a+r*i)},${f(l+n*i)}M${f(a+n*i)},${f(l-r*i)}L${f(a-n*i)},${f(l+r*i)}"/>`}function zI(e,t,r,n){let i=e-r*ey,a=t-n*ey;return`<path class="pele-marker" d="M${f(i-n*Oo)},${f(a+r*Oo)}L${f(e)},${f(t)}L${f(i+n*Oo)},${f(a-r*Oo)}" stroke-linejoin="round"/>`}function FI(e,t,r){let n=new Map;for(let i of t){let a=i.route;if(!(i.src===i.dst||a.length<6))for(let l of[0,a.length-3]){let s=l===0?i.src:i.dst,o=e[s],c=a[l]-o.x,h=a[l+1]-o.y,u=l===0?3:l-3,d;if(Math.abs(Math.abs(h)-o.h/2)<.5)d=h<0?0:2;else if(Math.abs(Math.abs(c)-o.w/2)<.5)d=c<0?3:1;else continue;let p=s*4+d,g={route:a,at:l,toward:a[d%2===0?u:u+1]},m=n.get(p);m?m.push(g):n.set(p,[g])}}for(let[i,a]of n){if(a.length<2)continue;let l=i>>2,s=i%2===1,o=(s?r[l].h:r[l].w)-2*DI,c=Math.max(0,Math.min(LI,o/(a.length-1)));a.sort((h,u)=>h.toward-u.toward);for(let h=0;h<a.length;h++){let u=(h-(a.length-1)/2)*c;s?a[h].route[a[h].at+1]=e[l].y+u:a[h].route[a[h].at]=e[l].x+u}}}function WI(e,t,r){return Ti(e.direction)?dr(r,n=>ry(e,t,r,n)):ry(e,t,r,!1)}function ry(e,t,r,n){let i=TI(e),a=r.fontSize??16,l=Math.round(a*.875),s=r.measurer??bt(r.fontFamily),o=r.padding??8,c=new Map,h=[],u=[];for(let z of i.nodes){let W=Ot(z.cssStyles),S=(W.bold?1:0)|(W.italic?2:0),A=W.fontSize??a,$=W.fontSize??l,y=z.requirement,E=z.element,w=Lo(Ve(`«${y?y.type:"Element"}»`,!1,s,$,4e3),S,s),T=Lo(Ve(z.id,!0,s,A,RI),S|1,s),_=y?[["ID",y.requirementId],["Text",y.text],["Risk",y.risk],["Verification",y.verifyMethod]]:[["Type",E.type],["Doc Ref",E.docRef]],M=[],U=0,j=0,Y=0;for(let[V,X]of _){if(!X)continue;let Q=Lo(Ve(V,!1,s,$,4e3),S,s),ne=Lo(Ve(X,!0,s,$,OI),S,s),B=Math.max(Q.height,ne.height);M.push({key:Q,value:ne,height:B}),U=Math.max(U,Q.width),j=Math.max(j,ne.width),Y+=B+Tu}M.length>0&&(Y+=2*ks-Tu);let D=2*ks+w.height+T.height,L=Math.max(NI,Math.max(w.width,T.width)+2*Ro,M.length>0?U+Jm+j+2*Ro:0);c.has(z.id)||c.set(z.id,h.length);let F=Bt(L,D+Y);F.seq=h.length,h.push({node:z,style:W,kind:w,name:T,rows:M,keyWidth:U,headHeight:D,w:L,h:D+Y}),u.push(F)}let d=n?"TB":Pr(i.direction),p=d==="LR"||d==="RL",g=[],m=[],v=[];for(let z of i.edges){let W=z.start===void 0?void 0:c.get(z.start),S=z.end===void 0?void 0:c.get(z.end);if(W===void 0||S===void 0)continue;let A=Ve(`«${z.type}»`,!1,s,l,4e3);W===S&&(p?u[W].h+=2*(Su+A.height+8):u[W].w+=2*(Su+A.width+12)),v.push(z),m.push(A),g.push({src:W,dst:S,minlen:1,labelW:A.width+12,labelH:A.height+4,route:[],labelX:0,labelY:0})}let x=Ai(u,g,d,{nodeSep:SI,edgeSep:CI,rankSep:II,portSep:20});FI(u,g,h);let k=Mn(e.title,s,a,4e3),b=k.height>0?k.height+12:0,C=Math.max(x.width,k.width),N=o+(C-x.width)/2,R=o+b,O=Math.ceil(C+2*o),P=Math.ceil(x.height+b+2*o),H="";for(let z=0;z<h.length;z++){let W=h[z],{w:S,h:A,style:$}=W,y=-S/2,E=-A/2,w=`<rect x="${f(y)}" y="${f(E)}" width="${f(S)}" height="${f(A)}" fill="var(--_s)" stroke="var(--_b)"${_t($.shape)}/>`+Le(W.kind,0,E+ks+W.kind.height/2,` class="pele-stereotype" font-size="${W.kind.size}" fill="var(--_m)"${$.text}`)+Le(W.name,0,E+ks+W.kind.height+W.name.height/2,` class="pele-label" font-size="${W.name.size}" font-weight="var(--_hw)"${$.text}`);if(W.rows.length>0){let T=E+W.headHeight;w+=`<path class="pele-divider" d="M${f(y)},${f(T)}H${f(-y)}" stroke="var(--_b)"${$.line}/>`;let _=T+ks,M="";for(let U of W.rows)M+=ty(U.key,y+Ro,_,` class="pele-field" fill="var(--_m)"${$.text}`)+ty(U.value,y+Ro+W.keyWidth+Jm,_,` class="pele-value"${$.text}`),_+=U.height+Tu;w+=`<g class="pele-fields" font-size="${W.rows[0].key.size}">${M}</g>`}H+=`<g class="pele-node ${W.node.requirement?"pele-requirement":"pele-element"}${jt(W.node.cssClasses.replace(/^default\s?/,""))}" data-id="${Ge(W.node.id)}" transform="translate(${f(u[z].x+N)},${f(u[z].y+R)})">${w}</g>`}let I="",G="",Z=new Map;for(let z=0;z<g.length;z++){let W=g[z],S=v[z],A=m[z],$=S.contains?2*Kb:0,y,E=W.labelX+N,w=W.labelY+R;if(W.src===W.dst){let T=h[W.src],_=u[W.src].x+N,M=u[W.src].y+R,U=Z.get(W.src)??0;Z.set(W.src,U+1);let j=(p?T.w:T.h)/2,Y=Math.min(j-4,12+U*6),D=Su+U*8,L=(V,X)=>p?`${f(_+X)},${f(M+T.h/2+V)}`:`${f(_+T.w/2+V)},${f(M+X)}`,F=D/.75;y={d:`M${L($,-Y)}C${L(F,-Y)} ${L(F,Y)} ${L(0,Y)}`,sx:p?_-Y:_+T.w/2,sy:p?M+T.h/2:M-Y,sdx:p?0:-1,sdy:p?-1:0,ex:p?_+Y:_+T.w/2,ey:p?M+T.h/2:M+Y,edx:p?0:-1,edy:p?-1:0},p?(E=_,w=M+T.h/2+D+4+W.labelH/2):(E=_+T.w/2+D+4+W.labelW/2,w=M)}else{let T=W.route.slice();for(let _=0;_<T.length;_+=3)T[_]+=N,T[_+1]+=R;y=jn(T,void 0,$,0)}I+=`<g class="pele-edge pele-relationship-${S.contains?"contains":"arrow"}" data-id="${Ge(S.id)}"><path d="${y.d}"${S.contains?"":' stroke-dasharray="5 4"'}/>`+(S.contains?PI(y.sx,y.sy,y.sdx,y.sdy):zI(y.ex,y.ey,y.edx,y.edy))+"</g>",G+=kn(S.id,A,E,w,"")}return{svg:mt("requirement",O,P,a,r,e,Le(k,O/2,o+k.height/2,' class="pele-title" font-weight="var(--_tw)"')+(I?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${I}</g>`:"")+(G?`<g class="pele-edge-labels" font-size="${l}" fill="var(--_m)">${G}</g>`:"")+`<g class="pele-nodes">${H}</g>`),width:O,height:P,links:[]}}var BI={type:"requirement",math:!0,parse(e,t,r){let n=new bI;return r&&(n.title=r),AI(e,n),n},render:WI},HI=class{type="sankey";nodes=[];links=[];title;accTitle;accDescr;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})}},Cu=["$end","STUCK","SANKEY","NEWLINE","COMMA","DQUOTE","NON_ESCAPED_TEXT","ESCAPED_TEXT","EOF"];function ny(e){return e>=32&&e<=126&&e!==34&&e!==44}function jI(e){let t=e.length,r=[],n=[],i=[],a=[],l=0,s=0,o=(h,u,d)=>{r.push(h),n.push(e.slice(u,d)),i.push(u),s=d},c=h=>e.slice(s,s+h.length).toLowerCase()===h&&!nt(e.charCodeAt(s+h.length));for(;s<t;){let h=e.charCodeAt(s),u=s,d=s;if(l===2){if(h===34&&e.charCodeAt(s+1)!==34){a.length>0&&(l=a.pop()),o(5,s,s+1);continue}for(;d<t;){let p=e.charCodeAt(d);if(ny(p)||p===44||p===13||p===10)d++;else if(p===34&&e.charCodeAt(d+1)===34)d+=2;else break}o(7,s,d)}else{if(l===0&&(h|32)===115){let p=c("sankey-beta")?11:c("sankey")?6:0;if(p>0){a.push(l),l=1,o(2,s,s+p);continue}}if(h===10||h===13&&e.charCodeAt(s+1)===10){o(3,s,h===10?s+1:s+2);continue}if(h===44){o(4,s,s+1);continue}if(h===34){a.push(l),l=2,o(5,s,s+1);continue}for(;d<t&&ny(e.charCodeAt(d));)d++;o(6,s,d)}if(d===u)return o(1,s,s),{types:r,texts:n,starts:i}}return o(l===2?7:8,t,t),o(0,t,t),{types:r,texts:n,starts:i}}var UI=/[\n\r]+/g;function iy(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 YI(e){let t=0,r=e.length;for(;t<r&&iy(e.charCodeAt(t));)t++;for(;r>t&&iy(e.charCodeAt(r-1));)r--;return e.slice(t,r).replace(UI,`
120
+ `).trim()}function GI(e,t){let{types:r,texts:n,starts:i}=jI(e),a=0,l=h=>{let u=r[a],d=u===1?Cu[r[a-1]]:Cu[u];throw vt("sankey",e,i[a],`Expecting ${h}, got '${d}'`)},s=(h,u="")=>{r[a]!==h&&l(`'${Cu[h]}'${u}`),a++},o=()=>{if(r[a]===6)return n[a++];r[a]!==5&&l("'DQUOTE', 'NON_ESCAPED_TEXT'"),a++,r[a]!==7&&l("'ESCAPED_TEXT'");let h=n[a++];return s(5),h},c=()=>o().trim().replaceAll('""','"');for(s(2),s(3);;){let h=c();s(4,", 'NEWLINE', 'EOF'");let u=c();s(4,", 'NEWLINE', 'EOF'");let d=o(),p=t.findOrCreateNode(h),g=t.findOrCreateNode(u);if(t.addLink(p,g,parseFloat(d.trim())),r[a]!==3)break;a++}r[a]===8&&a++,r[a]!==0&&l("'NEWLINE', 'EOF'")}var VI=6;function Iu(e,t){if(e.length>8){e.sort(t);return}for(let r=1;r<e.length;r++){let n=e[r],i=r-1;for(;i>=0&&t(e[i],n)>0;)e[i+1]=e[i],i--;e[i+1]=n}}function qI(e,t){let r=e.nodes.length,n=e.links.map($=>({source:$.source.index,target:$.target.index,value:Number.isFinite($.value)&&$.value>0?$.value:0,thickness:0,sourceY:0,targetY:0})),i=[],a=[];for(let $=0;$<r;$++)i.push([]),a.push([]);n.forEach(($,y)=>{i[$.source].push(y),a[$.target].push(y)});let l=new Int32Array(r),s=new Int32Array(r),o=[];for(let $=0;$<r;$++)s[$]=a[$].length,s[$]===0&&o.push($);for(let $=0;$<o.length;$++){let y=o[$];for(let E of i[y]){let w=n[E].target;l[w]<l[y]+1&&(l[w]=l[y]+1),--s[w]===0&&o.push(w)}}if(o.length<r){let $=0;for(;s[$]===0;)$++;let y=new Uint8Array(r);for(;y[$]===0;){y[$]=1;for(let E of a[$])if(s[n[E].source]>0){$=n[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 h=new Int32Array(r);for(let $=r-1;$>=0;$--){let y=o[$];for(let E of i[y])h[y]<h[n[E].target]+1&&(h[y]=h[n[E].target]+1)}let u=0;for(let $ of n)$.value>u&&(u=$.value);let d=u>0?1/u:0,p=[],g=new Float64Array(r),m=[];for(let $=0;$<c;$++)m.push([]);let v=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-h[$];else if(t.alignment==="center"){if(y=l[$],a[$].length===0&&i[$].length>0){y=c;for(let M of i[$])l[n[M].target]-1<y&&(y=l[n[M].target]-1)}}else y=i[$].length>0?l[$]:c-1;let E=0,w=0,T=0,_=0;for(let M of a[$])E+=n[M].value*d,T+=n[M].value;for(let M of i[$])w+=n[M].value*d,_+=n[M].value;g[$]=Math.max(E,w),p.push({layer:y,value:Math.max(T,_),x:y*v,y:0,height:0}),m[y].push($)}let x=1;for(let $ of m)$.length>x&&(x=$.length);let k=x>1?Math.min(t.nodePadding,t.height/(x-1)):t.nodePadding,b=1/0;for(let $ of m){let y=0;for(let E of $)y+=g[E];y>0&&(b=Math.min(b,(t.height-($.length-1)*k)/y))}(!Number.isFinite(b)||b<0)&&(b=0);let C=Math.max(0,t.labelHeight-k),N=$=>{for(let y of m){let E=(y.length-1)*k;for(let w of y)E+=Math.max(g[w]*$,C);if(E>t.height+1e-6)return!1}return!0};if(C>0&&!N(b))if(N(0)){let $=0;for(let y=0;y<40;y++){let E=($+b)/2;N(E)?$=E:b=E}b=$}else C=0;let R=new Float64Array(r);for(let $ of n)$.thickness=$.value*d*b;for(let $ of m){let y=0;for(let w of $)p[w].height=g[w]*b,R[w]=Math.max(0,C-p[w].height)/2,p[w].y=y+R[w],y+=p[w].height+2*R[w]+k;let E=(t.height-y+k)/($.length+1);$.forEach((w,T)=>p[w].y+=E*(T+1))}let O=$=>p[$].y+p[$].height/2,P=new Float64Array(n.length),H=new Float64Array(n.length),I=($,y)=>O(n[$].target)-O(n[y].target)||$-y,G=($,y)=>O(n[$].source)-O(n[y].source)||$-y,Z=($,y)=>O($)-O(y)||$-y,z=$=>{let y=0;Iu(i[$],I);for(let E of i[$])P[E]=y+n[E].thickness/2,y+=n[E].thickness},W=$=>{let y=0;Iu(a[$],G);for(let E of a[$])H[E]=y+n[E].thickness/2,y+=n[E].thickness},S=()=>{for(let $=0;$<r;$++)z($),W($)},A=($,y,E)=>{for(let T of $){let _=E?a[T]:i[T];if(_.length===0)continue;E?W(T):z(T);let M=0,U=0,j=0;for(let D of _){let L=E?p[n[D].source].y+P[D]-H[D]:p[n[D].target].y+H[D]-P[D];M+=L*n[D].thickness,U+=n[D].thickness,j+=O(E?n[D].source:n[D].target)-p[T].height/2}let Y=U>0?M/U:j/_.length;p[T].y+=(Y-p[T].y)*y}Iu($,Z);let w=0;for(let T of $)p[T].y-R[T]<w&&(p[T].y=w+R[T]),w=p[T].y+p[T].height+R[T]+k;w=t.height;for(let T=$.length-1;T>=0;T--){let _=$[T];p[_].y+p[_].height+R[_]>w&&(p[_].y=w-p[_].height-R[_]),w=p[_].y-R[_]-k}};S();for(let $=0;$<VI;$++){let y=Math.pow(.99,$);for(let E=c-2;E>=0;E--)A(m[E],y,!1);S();for(let E=1;E<c;E++)A(m[E],y,!0);S()}for(let $=0;$<n.length;$++)n[$].sourceY=p[n[$].source].y+P[$],n[$].targetY=p[n[$].target].y+H[$];return{nodes:p,links:n}}var ay=6,XI=15;function Zb(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $c(e,t,r,n,i){let a=e[t];return typeof a=="number"&&a>=n?Math.min(a,i):r}function sy(e,t){let r=e[t];return typeof r=="string"||typeof r=="number"&&Number.isFinite(r)?String(r):""}function ly(e){return Math.abs(e)<1e15?Math.round(e*100)/100:e}function oy(e){return typeof e=="string"?Ot([`fill:${e}`]).shape:""}function KI(e,t,r){let n=Zb(t.sankey)?t.sankey:{};return ed(r,$c(n,"width",600,1,1e4),160,i=>ZI(e,n,r,i))}function ZI(e,t,r,n){let i=r.fontSize??16,a=Math.round(i*.875),l=r.measurer??bt(r.fontFamily),s=r.padding??8,o=$c(t,"height",400,1,1e4),c=Math.min($c(t,"nodeWidth",10,1,200),n),h=t.showValues!==!1,u=sy(t,"prefix"),d=sy(t,"suffix"),p=t.labelStyle==="outlined",g=t.nodeAlignment==="left"||t.nodeAlignment==="right"||t.nodeAlignment==="center"?t.nodeAlignment:"justify",m=typeof t.linkColor=="string"?t.linkColor:"gradient",{nodes:v,links:x}=qI(e,{width:n,height:o,nodeWidth:c,nodePadding:$c(t,"nodePadding",12,0,200)+(h?XI:0),labelHeight:a*1.15,alignment:g}),k=new Map;if(Zb(t.nodeColors))for(let[T,_]of Object.entries(t.nodeColors)){let M=oy(_);M&&k.set(T,M)}let b=T=>k.get(e.nodes[T].id)??"",C=0,N=0;v.forEach(T=>{T.value>N&&(N=T.value,C=T.layer)});let R=0,O=n,P=0,H=o,I="",G="";v.forEach((T,_)=>{let M=e.nodes[_].id,U=Math.max(T.height,1);G+=`<rect class="pele-sankey-node" data-id="${Ge(M)}" x="${f(T.x)}" y="${f(T.y)}" width="${f(c)}" height="${f(U)}" rx="${f(Math.min(2,U/2))}" fill="${kt(_)}"${b(_)}/>`;let j=h?`${u}${ly(T.value)}${d}`:"",Y=p?T.layer>=C:T.x<n/2,D=l.width(j?`${M} ${j}`:M,a,0),L=Y?T.x+c+ay:T.x-ay,F=T.y+T.height/2;R=Math.min(R,Y?L:L-D),O=Math.max(O,Y?L+D:L),P=Math.min(P,F-a*.75),H=Math.max(H,F+a*.75);let V=` x="${f(L)}" y="${f(F+a*.35)}" text-anchor="${Y?"start":"end"}"`,X=tt(M)+(j?` <tspan class="pele-sankey-value" fill="var(--_m)">${tt(j)}</tspan>`:"");I+=`<g class="pele-label" data-id="${Ge(M)}">`+(p?`<text${V} fill="none" stroke="var(--_bg)" stroke-width="3" stroke-linejoin="round">${tt(M)}${j?" "+tt(j):""}</text>`:"")+`<text${V}>${X}</text></g>`});let Z=m==="gradient"||m==="source"||m==="target"?"":oy(m),z="";for(let T of x){let _=m==="target"?T.target:T.source,M=Math.max(T.thickness,1)/2,U=v[T.source].x+c,j=v[T.target].x,Y=f((U+j)/2),D=Ge(e.nodes[T.source].id),L=Ge(e.nodes[T.target].id);z+=`<path class="pele-sankey-link" data-id="${D}-&gt;${L}" d="M${f(U)},${f(T.sourceY-M)}C${Y},${f(T.sourceY-M)} ${Y},${f(T.targetY-M)} ${f(j)},${f(T.targetY-M)}L${f(j)},${f(T.targetY+M)}C${Y},${f(T.targetY+M)} ${Y},${f(T.sourceY+M)} ${f(U)},${f(T.sourceY+M)}Z" fill="${kt(_)}"${Z||b(_)}><title>${D} → ${L}: ${Ge(u)}${ly(T.value)}${Ge(d)}</title></path>`}let W=Ve(e.title,!1,l,i,Xt(r),1),S=W.height>0?W.height+12:0,A=Math.max(O-R,W.width),$=s-R+(A-(O-R))/2,y=s+S-P,E=Math.ceil(A+2*s),w=Math.ceil(H-P+S+2*s);return{svg:mt("sankey",E,w,i,r,e,Le(W,E/2,s+W.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${f($)},${f(y)})"><g class="pele-sankey-links" fill-opacity="0.4">${z}</g><g class="pele-sankey-nodes">${G}</g><g class="pele-labels" font-size="${a}">${I}</g></g>`),width:E,height:w,links:[]}}var QI={type:"sankey",parse(e,t,r){let n=new HI;return r&&(n.title=r),GI(YI(e),n),n},render:KI},JI="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",cy,eN=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?(%|deg|grad|rad|turn)?$/i;function Qb(e){if(e.toLowerCase()==="none")return 4;let t=eN.exec(e);return t?t[1]===void 0?1:t[1]==="%"?2:3:0}function tN(e,t){let r=Qb(e);return r===1||r===2||t&&r===4}function rN(e){let t=e.startsWith("hsl"),r=e.indexOf("("),n=e.slice(0,r);if(n!=="rgb"&&n!=="rgba"&&n!=="hsl"&&n!=="hsla"||e.length>120||e.indexOf(")")!==e.length-1)return!1;let i=e.slice(r+1,-1).trim(),a,l,s=i.includes(",");if(s)a=i.split(",").map(c=>c.trim()),a.length===4&&(l=a.pop());else{let c=i.split("/");if(c.length>2)return!1;a=c[0].trim().split(/\s+/),c.length===2&&(l=c[1].trim())}if(a.length!==3||l!==void 0&&!tN(l,!s))return!1;let o=a.map(Qb);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 h=o[c];if(!(h===1||h===4||(t&&c===0?h===3:h===2)))return!1}return!0}function nN(e){return e.includes("(")?rN(e):(cy??=new Set(JI.split(" ")),cy.has(e.toLowerCase()))}var iN=/^:?wrap:/,aN=/^:?nowrap:/,sN=/^:?(?:no)?wrap:/,lN=/^(?:rgba?|hsla?)\s*\(/,dy=/[\r\u2028\u2029]/,oN=/^\w*/;function Ms(e){throw new Je(e,"semantic",{type:"sequence"})}function hy(e){let t=e.trim(),r=iN.test(t)?!0:aN.test(t)?!1:void 0;return{text:(r===void 0?t:t.replace(sN,"")).trim(),wrap:r}}function cN(e){let t=lN.exec(e);if(t){let n=e.lastIndexOf(")");if(n>=t[0].length)return dy.test(e.slice(t[0].length))?void 0:[e.slice(0,n+1),e.slice(n+1)]}if(dy.test(e))return;let r=oN.exec(e)[0];return[r,e.slice(r.length)]}function uy(e){return typeof e=="string"?[...e].map((t,r)=>[String(r),t]):e!==null&&typeof e=="object"?Object.entries(e):[]}var dN=class{type="sequence";actors=new Map;createdActors=new Map;destroyedActors=new Map;boxes=[];messages=[];notes=[];title;accTitle;accDescr;prevActor;currentBox;lastCreated;lastDestroyed;wrapEnabled;sequenceWrap;active=new Map;constructor(e={}){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,`
121
+ `)}setDiagramTitle(e){this.title=e}parseMessage(e){return hy(e)}parseBoxData(e){let t=cN(e),r=t?.[0]?t[0].trim():"transparent",n=t?.[1]?t[1].trim():void 0;if(nN(r)||(r="transparent",n=e.trim()),n===void 0)return{text:void 0,color:r,wrap:void 0};let{text:i,wrap:a}=hy(n);return{text:i||void 0,color:r,wrap:a}}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,n,i){let a=this.currentBox,l;if(i!==void 0){let h;try{h=va(i.includes(`
122
+ `)?i+`
123
+ `:`{
124
+ `+i+`
125
+ }`)}catch(u){throw new Je(`Config of participant "${e}" is not valid YAML. ${u.message}`,"syntax",{type:"sequence"})}h!==null&&typeof h=="object"&&!Array.isArray(h)&&(l=h)}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&&(n=String(s)),o&&(!r||r.text===t)&&(r={text:String(o),wrap:r?.wrap,type:n});let c=this.actors.get(e);if(!(c&&(this.currentBox&&c.box&&this.currentBox!==c.box&&Ms(`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.`),a=c.box?c.box:this.currentBox,c.box=a,t===c.name&&r==null))){if((r?.text==null||n==null)&&(r={text:t,type:n}),this.actors.set(e,{box:a,name:t,description:r.text,wrap:r.wrap??this.autoWrap(),prevActor:this.prevActor,links:new Map,properties:new Map,type:n??"participant"}),this.prevActor){let h=this.actors.get(this.prevActor);h&&(h.nextActor=e)}this.currentBox&&this.currentBox.actorKeys.push(e),this.prevActor=e}}addMessage(e,t,r,n){this.messages.push({id:String(this.messages.length),from:e,to:t,message:r.text,wrap:r.wrap??this.autoWrap(),answer:n})}addSignal(e,t,r,n,i=!1,a){if(n===18){let l=e?this.active.get(e)??0:0;l<1&&Ms(`Trying to inactivate an inactive participant (${e})`),this.active.set(e,l-1)}else n===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:n,activate:i,centralConnection:a??0}),!0}addNote(e,t,r){let n=r.wrap??this.autoWrap(),i={actor:e,placement:t,message:r.text,wrap:n},a=typeof e=="string"?[e,e]:e;this.notes.push(i),this.messages.push({id:String(this.messages.length),from:a[0],to:a[1],message:r.text,wrap:n,type:2,placement:t})}addLinks(e,t){let r=this.actors.get(e);if(r)try{let n=JSON.parse(t.text);for(let[i,a]of uy(n))r.links.set(i,a)}catch{return}}addALink(e,t){let r=this.actors.get(e);if(!r)return;let n=t.text.indexOf("@");r.links.set(t.text.slice(0,n-1).trim(),t.text.slice(n+1).trim())}addProperties(e,t){let r=this.actors.get(e);if(r)try{let n=JSON.parse(t.text);for(let[i,a]of uy(n))r.properties.set(i,a)}catch{return}}addDetails(e,t){let r=this.actors.get(e);r&&(r.details=t.text)}apply(e){let t=[],r=[],n=e;for(;;){n!==void 0&&(Array.isArray(n)?(t.push(n),r.push(0)):typeof n!="string"&&this.applyOne(n));let i=t.length-1;if(i<0)return;let a=t[i];r[i]<a.length?n=a[r[i]++]:(t.pop(),r.pop(),n=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)&&Ms("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&&Ms(`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&&Ms(`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"],Jb=new Uint8Array(128);for(let e=0;e<128;e++){let t=String.fromCharCode(e),r=e===32||e>=9&&e<=13,n=0;`/\\+()<->:
126
+ ,;`.includes(t)||(n|=1),`+<->:
127
+ ,;`.includes(t)||(n|=2),`<>:
128
+ ,;@`.includes(t)||(n|=8|(r?0:4)),`#
129
+ ;`.includes(t)||(n|=16),!`/\\+()<>:
130
+ ,;-`.includes(t)&&!r&&(n|=32),Jb[e]=n}function hN(e){let t=e.length,r=[],n=[],i=[],a=[],l=0,s=0,o=-1,c=(y,E,w)=>{r.push(y),n.push(e.slice(E,w)),i.push(E),s=w},h=(y,E,w,T)=>{r.push(y),n.push(T),i.push(E),s=w},u=y=>{a.push(l),l=y},d=()=>{a.length>0&&(l=a.pop())},p=y=>(o<y&&(o=e.indexOf(`
131
+ `,y),o===-1&&(o=t)),o),g=(y,E)=>{let w=e.charCodeAt(y);return w<128?(Jb[w]&E)!==0:E===4||E===32?!Xe(w):!0},m=(y,E)=>{for(let w=0;w<E.length;w++){let T=E.charCodeAt(w),_=e.charCodeAt(y+w);if(T>=97&&T<=122?(_|32)!==T:_!==T)return!1}return!0},v=y=>m(s,y)&&!nt(e.charCodeAt(s+y.length)),x=y=>{for(;y<t&&Xe(e.charCodeAt(y));)y++;return y},k=()=>{let y=s;for(;y<t;){let E=e.charCodeAt(y);if(E===10||!Xe(E))break;y++}return y===s?!1:(s=y,!0)},b=y=>{for(;y<t&&g(y,16);)y++;return y},C=(y,E,w)=>{c(y,s,s+E),u(w)},N=(y,E,w=-1)=>v(y)?(c(E,s,s+y.length),w>=0&&u(w),!0):!1,R=(y,E)=>{if(!m(s,y))return!1;let w=s+y.length,T=e.charCodeAt(w);if(T!==32&&T!==9)return!1;for(;T===32||T===9;)T=e.charCodeAt(++w);return w>=t||!g(w,32)?!1:(c(E,s,s+y.length),!0)},O=y=>{let E=e.charCodeAt(y),w=e.charCodeAt(y+1);if(E===45){if(w===120||w===88||w===41||w===92||w===47||w===45)return!0;let T=e.charCodeAt(y+2);return w===124&&(T===92||T===47)}return E===47||E===92?(w===124||w===E)&&e.charCodeAt(y+2)===45:E===40&&w===41},P=()=>{let y=s+1;for(;y<t&&g(y,1);)y++;for(;y<t&&!O(y);){let E=y;for(;e.charCodeAt(E)===45;)E++;if(E>=t||!g(E,2))break;for(E++;E<t&&g(E,2);)E++;y=E}h(48,s,y,e.slice(s,y).trim())},H=()=>{let y=s;for(;gt(e.charCodeAt(y));)y++;let E=y>s;if(e.charCodeAt(y)===46&&gt(e.charCodeAt(y+1))){let T=gt(e.charCodeAt(y+2))?y+3:y+2,_=e.charCodeAt(T);if(_===32||_===10)return c(10,s,T),!0}let w=e.charCodeAt(y);return E&&(w===32||w===10)?(c(10,s,y),!0):!1},I=()=>{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 w=e.charCodeAt(s+3);E===62?c(w===62?57:54,s,s+(w===62?4:3)):E===120||E===88?c(60,s,s+3):E===41?c(62,s,s+3):E===124&&w===92?c(67,s,s+4):E===124&&w===47?c(68,s,s+4):E===92&&w===92?c(69,s,s+4):E===47&&w===47?c(70,s,s+4):c(46,s,s+1)}else c(46,s,s+1)},G=y=>{let E=e.charCodeAt(s+1);if(E!==124&&E!==y||e.charCodeAt(s+2)!==45)return!1;let w=e.charCodeAt(s+3)===45,T=y===47,_;return E===124?w?_=T?75:76:_=T?71:72:w?_=T?77:78:_=T?73:74,c(_,s,s+(w?4:3)),!0},Z=()=>{if(!m(s,"title"))return!1;let y=s+5,E=e.charCodeAt(y)===58;return E&&y++,!Xe(e.charCodeAt(y))||y+1>=t||!g(y+1,16)?!1:(c(E?15:14,s,b(y+1)),!0)},z=()=>{let y=m(s,"accdescr");if(!y&&!m(s,"acctitle"))return!1;let E=x(s+8),w=e.charCodeAt(E);return w===58?(c(y?18:16,s,x(E+1)),u(y?6:5),!0):y&&w===123?(s=x(E+1),u(7),!0):!1},W=y=>{switch(y|32){case 97:return N("actor",34,1)||N("alt",24,3)||N("and",30,3)||N("activate",12,1)||z()||N("autonumber",9);case 98:return N("box",6,3)||N("break",28,3);case 99:return N("create",5)||N("critical",27,3);case 100:return N("destroy",35,1)||R("details",41)||N("deactivate",13,1);case 101:return N("else",31,3)||N("end",8);case 108:return N("loop",21,3)||N("left of",43)||R("links",38)||R("link",39);case 110:return N("note",36);case 111:return N("opt",23,3)||N("option",29,3)||N("over",37)||N("off",11);case 112:return N("participant",32,1)||N("par",25,3)||N("par_over",26,3)||R("properties",40);case 114:return N("rect",22,3)||N("right of",44);case 115:return N("sequencediagram",4);case 116:return Z();default:return!1}},S=()=>{let y=e.charCodeAt(s);if(y===10){let E=s+1;for(;e.charCodeAt(E)===10;)E++;c(3,s,E);return}if(Xe(y)){s=x(s+1);return}if(y===35||y===37&&e.charCodeAt(s+1)!==123){s=p(s);return}if(y!==125&&e.charCodeAt(s+1)===37&&e.charCodeAt(s+2)===37){s=p(s);return}if(!((gt(y)||y===46)&&H())&&!(y<128&&(y|32)>=97&&(y|32)<=122&&W(y)))if(y===44)c(42,s,s+1);else if(y===59)c(3,s,s+1);else if(g(s,1))P();else if(y===45)I();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)&&G(y))return;y===58?c(52,s,b(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)}},A=()=>{if(k())return!0;let y=e.charCodeAt(s);if(y===35)return s=p(s),!0;if(y===64&&e.charCodeAt(s+1)===123)return C(49,2,4),!0;let E=s;for(;E<t&&g(E,4);)E++;if(E>s){let T=x(E);if(e.charCodeAt(T)===64&&e.charCodeAt(T+1)===123)return c(48,s,E),!0;if(T>E&&m(T,"as")&&Xe(e.charCodeAt(T+2)))return c(48,s,E),u(2),!0}let w=E;for(;w<t&&g(w,8);)w++;if(w>s){let T=e.charCodeAt(w),_=w;if(w<t&&T!==10&&T!==59)for(_--;_>s&&e.charCodeAt(_)!==35;)_--;if(_>s)return h(48,s,_,e.slice(s,_).trim()),d(),!0}if(e.charCodeAt(w)===60)return c(2,s,p(s)),d(),!0;if(y!==10){let T=p(s);return h(2,s,T,e.slice(s,T).trim()),d(),!0}return!1},$=()=>{switch(l){case 0:return S(),!0;case 1:return A();case 2:return k()?!0:e.charCodeAt(s)===35?(s=p(s),!0):(d(),d(),v("as")?C(33,2,3):c(3,s,s),!0);case 3:return k()?!0:e.charCodeAt(s)===35?(s=p(s),!0):(c(7,s,b(s)),d(),!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=x(s+1),E=y>s+1&&m(y,"as")&&Xe(e.charCodeAt(y+2));return c(51,s,s+1),d(),E?u(2):d(),!0}case 5:case 6:return c(l===5?17:19,s,p(s)),d(),!0;default:if(e.charCodeAt(s)===125)s++,d();else{let y=e.indexOf("}",s);y===-1&&(y=t),c(20,s,y)}return!0}};for(;s<t;)if(!$())return r.push(1),n.push(""),i.push(s),{types:r,texts:n,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),n.push(""),i.push(t),{types:r,texts:n,starts:i}}var At=new Int8Array(79).fill(-1);At[53]=5;At[54]=6;At[55]=0;At[57]=1;At[56]=33;At[58]=34;At[59]=3;At[60]=4;At[61]=24;At[62]=25;At[63]=41;At[64]=42;At[65]=43;At[66]=44;At[67]=51;At[68]=52;At[69]=53;At[70]=54;At[71]=45;At[72]=46;At[73]=47;At[74]=48;At[75]=55;At[76]=56;At[77]=57;At[78]=58;var ln=new Int8Array(79).fill(-1);ln[21]=2;ln[22]=3;ln[23]=4;ln[28]=5;ln[24]=6;ln[25]=7;ln[26]=7;ln[27]=8;ln[6]=1;var uN="'SOLID_OPEN_ARROW', 'DOTTED_OPEN_ARROW', 'SOLID_ARROW', 'DOTTED_ARROW', 'SOLID_CROSS', 'DOTTED_CROSS', 'SOLID_POINT', 'DOTTED_POINT'";function fN(e,t){let{types:r,texts:n,starts:i}=hN(e),a=0,l=b=>{let C=r[a];throw C===1?vt("sequence",e,i[a],"",!0):vt("sequence",e,i[a],`Expecting ${b}, got '${fy[C]}'`)},s=b=>(r[a]!==b&&l(`'${fy[b]}'`),n[a++]),o=()=>{let b=r[a];return b!==48&&b!==39&&l("'ACTOR'"),{type:"addParticipant",actor:n[a++]}},c=()=>t.parseMessage(s(52).trim().substring(1)),h=()=>{let b=r[a++];if(b===35){let N=o();return s(3),N.type="destroyParticipant",N}let C=o();if(r[a]===49&&r[a-1]===48){a++;let N=s(50);s(51),C.config=N.trim()}if(C.draw=b===32?"participant":"actor",r[a]===33){a++;let N=s(7);s(3),C.description=t.parseMessage(N)}else r[a]===3?a++:l("'AS', 'NEWLINE'");return C},u=b=>{let C=!1;r[a]===47&&(C=!0,a++);let N=At[r[a]];N<0&&l(uN),a++;let R=r[a];(R===47||!C&&(R===45||R===46))&&a++;let O=o(),P=c(),H={type:"addMessage",from:b.actor,to:O.actor,signalType:N,msg:P},I=[b,O,H];if(C){let G=R===47;H.activate=G,H.centralConnection=G?61:60,G&&I.push({type:"centralConnection",signalType:59,actor:O.actor}),I.push({type:"centralConnectionReverse",signalType:60,actor:b.actor})}else R===45?(H.activate=!0,I.push({type:"activeStart",signalType:17,actor:O.actor})):R===46?I.push({type:"activeEnd",signalType:18,actor:b.actor}):R===47&&(H.activate=!0,H.centralConnection=59,I.push({type:"centralConnection",signalType:59,actor:O.actor}));return I},d=b=>{a++;let C=o();return[C,{type:b,actor:C.actor,text:c()}]},p=()=>{a++;let b=r[a];if(b===37){a++;let R=o(),O=R,P=[R.actor,R.actor];if(r[a]===42){a++;let H=o();O=[R,H],P=[R.actor,H.actor]}return[O,{type:"addNote",placement:2,actor:P,text:c()}]}b!==43&&b!==44&&l("'over', 'left_of', 'right_of'"),a++;let C=o();return[C,{type:"addNote",placement:b===43?0:1,actor:C.actor,text:c()}]},g=()=>{a++;let b={type:"sequenceIndex",sequenceVisible:!0,signalType:26};return r[a]===10?(b.sequenceIndex=Number(n[a++]),b.sequenceIndexStep=r[a]===10?Number(n[a++]):1):r[a]===11&&(a++,b.sequenceVisible=!1),r[a]!==3&&l("'NEWLINE', 'NUM', 'off'"),a++,b},m=(b,C,N,R)=>{let O=b.list,P=b.sections;if(P)for(let H=P.length-2;H>=0;H-=2){let I={type:C,signalType:R};I[N]=t.parseMessage(P[H+1]),O=P[H].concat([I,O])}return O},v=b=>{let C=b.text,N=b.list;switch(b.kind){case 1:N[0]={type:"boxStart",boxData:t.parseBoxData(C)},N.push({type:"boxEnd",boxText:C});break;case 2:N[0]={type:"loopStart",loopText:t.parseMessage(C),signalType:10},N.push({type:"loopEnd",loopText:C,signalType:11});break;case 3:N[0]={type:"rectStart",color:t.parseMessage(C),signalType:22},N.push({type:"rectEnd",color:t.parseMessage(C),signalType:23});break;case 4:N[0]={type:"optStart",optText:t.parseMessage(C),signalType:15},N.push({type:"optEnd",optText:t.parseMessage(C),signalType:16});break;case 5:N[0]={type:"breakStart",breakText:t.parseMessage(C),signalType:30},N.push({type:"breakEnd",optText:t.parseMessage(C),signalType:31});break;case 6:N=m(b,"else","altText",13),N[0]={type:"altStart",altText:t.parseMessage(C),signalType:12},N.push({type:"altEnd",signalType:14});break;case 7:N=m(b,"and","parText",20),N[0]={type:"parStart",parText:t.parseMessage(C),signalType:b.startType},N.push({type:"parEnd",signalType:21});break;default:N=m(b,"option","optionText",28),N[0]={type:"criticalStart",criticalText:t.parseMessage(C),signalType:27},N.push({type:"criticalEnd",signalType:29})}return N};for(;r[a]===3;)a++;s(4);let x=[],k={kind:0,text:"",startType:0,list:[],sections:void 0};for(;;){let b=r[a],C=k.list;if(k.kind===1){if(b===32||b===34||b===35)C.push(h());else if(b===3)C.push([]),a++;else if(b===8){a++;let N=v(k);k=x.pop(),k.list.push(N)}else l("'end', 'NEWLINE', 'participant', 'participant_actor', 'destroy'");continue}switch(b){case 3:case 2:C.push([]),a++;break;case 32:case 34:case 35:C.push(h());break;case 5:{a++;let N=r[a];N!==32&&N!==34&&N!==35&&l("'participant', 'participant_actor', 'destroy'");let R=h();R.type="createParticipant",C.push(R);break}case 48:C.push(u(o())),s(3);break;case 39:{let N=r[a+1];C.push(N===48||N===39?d("addALink"):u(o())),s(3);break}case 38:C.push(d("addLinks")),s(3);break;case 40:C.push(d("addProperties")),s(3);break;case 41:C.push(d("addDetails")),s(3);break;case 36:C.push(p()),s(3);break;case 9:C.push(g());break;case 12:case 13:{a++;let N=o();s(3),C.push(b===12?{type:"activeStart",signalType:17,actor:N.actor}:{type:"activeEnd",signalType:18,actor:N.actor});break}case 14:case 15:{let N=n[a++].substring(b===14?6:7);t.setDiagramTitle(N),C.push(N);break}case 16:{a++;let N=s(17).trim();t.setAccTitle(N),C.push(N);break}case 18:{a++;let N=s(19).trim();t.setAccDescription(N),C.push(N);break}case 20:{let N=n[a++].trim();t.setAccDescription(N),C.push(N);break}case 21:case 22:case 23:case 28:case 24:case 25:case 26:case 27:case 6:{a++;let N=s(7);x.push(k),k={kind:ln[b],text:N,startType:b===26?32:19,list:[[]],sections:void 0};break}case 31:case 30:case 29:{k.kind!==(b===31?6:b===30?7:8)&&l("'end'"),a++;let N=s(7);(k.sections??=[]).push(C,N),k.list=[];break}case 8:{k.kind===0&&l("'NEWLINE', 'EOF'"),a++;let N=v(k);k=x.pop(),k.list.push(N);break}case 0:k.kind!==0&&l("'end'"),t.apply(C);return;default:l("'NEWLINE', 'ACTOR', 'participant', 'note', 'end'")}}}var pN=16,gN=10,e2=34,t2=4,mi=5,gi=6,bn=' fill="var(--_s)" stroke="var(--_b)"',ca=' fill="none" stroke="var(--_b)"',mN=new Set(["participant","actor","boundary","control","entity","database","collections","queue"]),yN=new Set(["actor","boundary","control","entity","database"]);function xN(e){return mN.has(e)?e:"participant"}function up(e){return yN.has(e)}function bN(e,t,r,n,i=pN){if(up(e))return{w:Math.max(40,t.width+8),h:e2+(t.height>0?t2+t.height:0)};let a=e==="collections"?mi:e==="queue"?2*gi:0;return{w:Math.max(r,t.width+2*i)+a,h:Math.max(n,t.height+2*gN)+(e==="collections"?mi:0)}}function wN(e,t,r){let n=f(t),i=a=>f(r+a);switch(e){case"actor":return`<circle cx="${n}" cy="${i(7)}" r="6"${bn}/><path d="M${n},${i(13)}V${i(24)}M${f(t-10)},${i(17)}H${f(t+10)}M${f(t-8)},${i(34)}L${n},${i(24)}L${f(t+8)},${i(34)}"${ca}/>`;case"boundary":return`<path d="M${f(t-19)},${i(6)}V${i(28)}M${f(t-19)},${i(17)}H${f(t-8)}"${ca}/><circle cx="${f(t+3)}" cy="${i(17)}" r="11"${bn}/>`;case"control":return`<circle cx="${n}" cy="${i(21)}" r="11"${bn}/><path d="M${f(t+5)},${i(5)}L${f(t-1)},${i(10)}L${f(t+5)},${i(15)}"${ca}/>`;case"entity":return`<circle cx="${n}" cy="${i(15)}" r="11"${bn}/><path d="M${f(t-11)},${i(30)}H${f(t+11)}"${ca}/>`;default:{let a=f(t-14),l=f(t+14);return`<path d="M${a},${i(7)}V${i(27)}A14,5 0 0 0 ${l},${i(27)}V${i(7)}A14,5 0 0 0 ${a},${i(7)}Z"${bn}/><path d="M${a},${i(7)}A14,5 0 0 0 ${l},${i(7)}"${ca}/>`}}}function vN(e,t,r,n,i,a){let{w:l,h:s}=n,o=' class="pele-label"';if(up(e))return wN(e,t,r)+Le(i,t,r+e2+t2+i.height/2,o,a);let c=t-l/2;if(e==="collections"){let h=l-mi,u=s-mi,d=`<rect x="${f(c+mi)}" y="${f(r)}" width="${f(h)}" height="${f(u)}"${bn}${xt}/>`,p=`<rect x="${f(c)}" y="${f(r+mi)}" width="${f(h)}" height="${f(u)}"${bn}${xt}/>`;return d+p+Le(i,c+h/2,r+mi+u/2,o,a)}if(e==="queue"){let h=f(c+gi),u=f(c+l-gi),d=f(r+s),p=f(s/2);return`<path d="M${h},${f(r)}H${u}A${gi},${p} 0 0 1 ${u},${d}H${h}A${gi},${p} 0 0 1 ${h},${f(r)}Z"${bn}/><path d="M${u},${f(r)}A${gi},${p} 0 0 0 ${u},${d}"${ca}/>`+Le(i,t-gi/2,r+s/2,o,a)}return`<rect x="${f(c)}" y="${f(r)}" width="${f(l)}" height="${f(s)}"${bn}${xt}/>`+Le(i,t,r+s/2,o,a)}var fp=[];function Vt(e,t,r,n=1,i=!1){fp[e]={dotted:t,head:r,atStart:n!==1,atEnd:n!==0,bottom:i}}Vt(0,!1,1);Vt(1,!0,1);Vt(3,!1,2);Vt(4,!0,2);Vt(5,!1,0);Vt(6,!0,0);Vt(24,!1,3);Vt(25,!0,3);Vt(33,!1,1,2);Vt(34,!0,1,2);for(let e of[!1,!0]){let t=e?10:0;Vt(41+t,e,4),Vt(42+t,e,4,1,!0),Vt(43+t,e,5),Vt(44+t,e,5,1,!0),Vt(45+t,e,4,0),Vt(46+t,e,4,0,!0),Vt(47+t,e,5,0),Vt(48+t,e,5,0,!0)}var $N=new Map([[10,"loop"],[12,"alt"],[15,"opt"],[19,"par"],[32,"par"],[27,"critical"],[30,"break"],[22,"rect"]]),kN=12,Nu=28,py=22,Nr=10,gy=4,MN=14,ia=10,_N=16,EN=20,AN=10,Do=20,my=240,Po=16,aa=4,yy=' stroke-dasharray="4 4"';function Ff(e){return e!==void 0&&fp[e]!==void 0}function TN(e,t){let r=new Array(e.length),n=new Array(e.length),i=1,a=1,l=!1;for(let s=0;s<e.length;s++){let o=e[s];if(r[s]=NaN,n[s]=!1,o.type===26){let c=o.message;i=c.start||i,a=c.step||a,l=c.visible}else Ff(o.type)&&(r[s]=i,n[s]=l||t,i=Math.round((i+a)*100)/100)}return{index:r,shown:n,visible:l}}var xy={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};function di(e,t,r){let n=e[t];return typeof n=="number"&&n>=0&&n<=2e3?n:r}function by(e,t,r,n,i){let a=f(e-r*Rt);return i?`<path class="pele-marker" d="M${f(e)},${f(t)}L${a},${f(t+n*5)}"/>`:`<path class="pele-marker" d="M${f(e)},${f(t)}L${a},${f(t+n*4.5)}V${f(t)}Z" fill="var(--_l)" stroke="none"/>`}function zo(e,t,r,n,i){switch(e){case 1:return Ct("arrow_point",t,r,n,0,"var(--_l)");case 2:return Ct("arrow_cross",t,r,n,0,"var(--_l)");case 3:return`<path class="pele-marker" d="M${f(t-n*Rt)},${f(r-4.5)}L${f(t)},${f(r)}L${f(t-n*Rt)},${f(r+4.5)}" stroke-linejoin="round"/>`;case 4:return by(t,r,n,i,!1);case 5:return by(t,r,n,i,!0);default:return""}}function SN(e){return e===1?Rt-1:e===2?4:0}function CN(e,t,r){return Yn(r,n=>IN(e,t,r,n))}function IN(e,t,r,n){let i=t.sequence??{},a=r.fontSize??16,l=Math.round(a*.875),s=Math.round(a*.75),o=r.measurer??bt(r.fontFamily),c=r.icons,h=r.padding??8,u=i.mirrorActors!==!1,d=i.rightAngles===!0,p=Math.min(di(i,"actorMargin",40),n?8:1/0),g=Math.min(di(i,"width",64),n?48:1/0),m=di(i,"height",Math.round(a*1.5)+20),v=Math.min(di(i,"width",160),n?Math.max(32,((r.maxWidth??320)-2*h)/Math.max(1,e.actors.size)-p-24):1/0),x=Math.max(4,14+di(i,"messageMargin",35)-35),k=Math.min(di(i,"noteMargin",10),n?6:1/0),b=Math.min(di(i,"boxMargin",10),n?6:1/0),C=i.messageAlign==="left"?-1:i.messageAlign==="right"?1:0,N=n?6:kN,R=n?8:_N,O=n?12:EN,P=n?6:AN,H=e.messages,I=H.length,G=TN(H,i.showSequenceNumbers===!0),Z=(q,me,se,ve=v,_e=0)=>{let Te=Ve(q,!1,o,me,n||se?ve:1/0,_e);return n?Oc(Te,o,Math.max(120,ve)):Te},z;if(i.hideUnusedParticipants===!0){z=new Set;for(let q of H)z.add(q.from).add(q.to)}let W=new Int32Array(I+1);W[I]=-1;for(let q=I-1;q>=0;q--)W[q]=Ff(H[q].type)?q:W[q+1];let S=[],A=new Map;for(let[q,me]of e.actors){if(z&&!z.has(q))continue;let se=xN(me.type),ve=Z(me.description,a,me.wrap),_e=e.createdActors.get(q),Te=e.destroyedActors.get(q),Oe=_e===void 0?-1:W[Math.min(_e,I)];Oe>=0&&H[Oe].to!==q&&(Oe=-1);let Ce=Te===void 0?-1:W[Math.min(Te,I)];Ce>=0&&H[Ce].to!==q&&H[Ce].from!==q&&(Ce=-1),A.set(q,S.length),S.push({id:q,actor:me,kind:se,label:ve,size:bN(se,ve,g,m,n?8:void 0),x:0,createAt:Oe,destroyAt:Ce,top:0,lifeStart:0,lifeEnd:-1,activations:[]})}let $=S.length-1,y=new Map,E=(q,me,se)=>{if(q<0||me>$)return;let ve=q*S.length+me;(y.get(ve)??0)<se&&y.set(ve,se)},w=q=>G.shown[q]?Math.max(Po,o.width(String(G.index[q]),s,0)+8):0,T=new Array(I);for(let q=0;q<I;q++){let me=H[q],se=me.from===void 0?void 0:A.get(me.from),ve=me.to===void 0?void 0:A.get(me.to);if(!(se===void 0||ve===void 0||typeof me.message!="string")){if(me.type===2){let _e=Z(me.message,l,me.wrap),Te=_e.width+2*k;me.placement===0?E(se-1,se,Te+2*ia+Nr):me.placement===1?E(se,se+1,Te+2*ia+Nr):se===ve?(E(se-1,se,Te/2+ia),E(se,se+1,Te/2+ia)):E(Math.min(se,ve),Math.max(se,ve),Te-2*R),T[q]={kind:2,a:se,b:ve,label:_e,x:0,w:Te}}else if(Ff(me.type)){let _e=Z(me.message,l,me.wrap),Te=w(q);if(se===ve)E(se,se+1,Nu+8+_e.width+16+Nr+Te),T[q]={kind:1,a:se,b:ve,label:_e,x:0,w:0};else{let Oe=S[ve].createAt===q?S[ve].size.w/2:0,Ce=me.centralConnection?4*aa:0;E(Math.min(se,ve),Math.max(se,ve),(n?Math.min(_e.width,Math.max(16,v-16)):_e.width)+2*N+Nr+Te+Oe+Ce),T[q]={kind:0,a:se,b:ve,label:_e,x:0,w:0}}}}}let _=[];for(let q=0;q<=$;q++){let me=S[q].actor.box,se=_[_.length-1];me&&se&&se.box===me&&se.last===q-1?se.last=q:me&&_.push({box:me,first:q,last:q,title:Z(me.name,l,me.wrap),grow:0})}let M=new Array(Math.max($,0));for(let q=0;q<$;q++){let me=S[q],se=S[q+1],ve=me.actor.box!==se.actor.box?(me.actor.box?b:0)+(se.actor.box?b:0):0;M[q]=Math.max(me.size.w/2+se.size.w/2+p+ve,y.get(q*S.length+q+1)??0)}let U=[];for(let[q,me]of y){let se=Math.floor(q/S.length),ve=q%S.length;ve-se>1&&U.push([se,ve,me])}U.sort((q,me)=>q[1]-q[0]-(me[1]-me[0])||q[0]-me[0]);for(let[q,me,se]of U){let ve=0;for(let Te=q;Te<me;Te++)ve+=M[Te];if(ve>=se)continue;let _e=(se-ve)/(me-q);for(let Te=q;Te<me;Te++)M[Te]+=_e}let j=()=>{for(let q=1;q<=$;q++)S[q].x=S[q-1].x+M[q-1]};j();for(let q of _){let me=S[q.last].x+S[q.last].size.w/2-(S[q.first].x-S[q.first].size.w/2);q.grow=Math.max(0,(q.title.width-me)/2),q.grow!==0&&(q.first>0&&(M[q.first-1]+=q.grow),q.last<$&&(M[q.last]+=q.grow))}j();let Y=1/0,D=-1/0,L=(q,me)=>{q<Y&&(Y=q),me>D&&(D=me)};for(let q of S)L(q.x-q.size.w/2,q.x+q.size.w/2);for(let q of _)L(S[q.first].x-S[q.first].size.w/2-b-q.grow,S[q.last].x+S[q.last].size.w/2+b+q.grow);let F=new Array(I),V=[],X=()=>$<0?[0,120]:[S[0].x-O,S[$].x+O];for(let q=0;q<I;q++){let me=H[q],se=me.type,ve=se===void 0?void 0:$N.get(se),_e=T[q];if(ve!==void 0){let Te={kind:ve,x0:1/0,x1:-1/0,top:0,title:xy,tabW:0,fill:ve==="rect"&&typeof me.message=="string"?me.message:"",dividers:[q],dividerY:[],dividerLabels:[]};F[q]=Te,V.push(Te)}else if(se===13||se===20||se===28)V[V.length-1]?.dividers.push(q);else if(se===11||se===14||se===16||se===21||se===29||se===31||se===23){let Te=V.pop();if(!Te)continue;if(F[q]=Te,Te.x0>Te.x1&&([Te.x0,Te.x1]=X()),Te.kind!=="rect"){Te.tabW=o.width(Te.kind,s,1)+14;for(let Ce=0;Ce<Te.dividers.length;Ce++){let He=H[Te.dividers[Ce]].message,Ee=Ce===0?Te.tabW+8:0,Ye=Te.x1-Te.x0-16-Ee,qe=He?Z(`[${He}]`,l,!0,Math.max(Ye,n?Math.min(my,v):my)):xy;qe.width>Ye&&(Te.x1+=qe.width-Ye),Ce===0?Te.title=qe:Te.dividerLabels.push(qe)}}L(Te.x0,Te.x1);let Oe=V[V.length-1];Oe&&(Oe.x0=Math.min(Oe.x0,Te.x0-P),Oe.x1=Math.max(Oe.x1,Te.x1+P))}else if(_e){let Te=S[_e.a],Oe=S[_e.b],Ce,He;if(_e.kind===2){if(me.placement===0)_e.x=Te.x-ia-_e.w;else if(me.placement===1)_e.x=Te.x+ia;else if(_e.a===_e.b)_e.x=Te.x-_e.w/2;else{let Ye=Math.min(Te.x,Oe.x)-R,qe=Math.max(Te.x,Oe.x)+R;(n||me.wrap)&&(_e.label=Z(me.message,l,!0,Math.max(v,qe-Ye-2*k))),_e.w=Math.max(qe-Ye,_e.label.width+2*k),_e.x=(Ye+qe-_e.w)/2}Ce=_e.x,He=_e.x+_e.w}else _e.kind===1?(Ce=Te.x,He=Te.x+Nr+Nu+8+_e.label.width+w(q)):(Ce=Math.min(Te.x,Oe.x),He=Math.max(Te.x,Oe.x),(n||me.wrap)&&(_e.label=Z(me.message,l,!0,Math.max(v,He-Ce-2*N-Nr))),Oe.createAt===q&&(Oe.x>Te.x?He+=Oe.size.w/2:Ce-=Oe.size.w/2));L(Ce,He);let Ee=V[V.length-1];Ee&&(Ee.x0=Math.min(Ee.x0,Ce-O),Ee.x1=Math.max(Ee.x1,He+O))}}let Q=0;for(let q of _)Q=Math.max(Q,q.title.height);let ne=_.length>0?b+(Q>0?Q+4:0):0,B=0;for(let q of S)q.createAt<0&&(B=Math.max(B,q.size.h));let K=ne+B;for(let q of S)q.top=K-q.size.h,q.lifeStart=K;let ie=S.map(q=>q.x),le=(q,me)=>{let se=0,ve=ie.length;for(;se<ve;){let _e=se+ve>>1;ie[_e]<=q?se=_e+1:ve=_e}return se<ie.length&&ie[se]<me},J=(q,me,se,ve)=>{if(q.width===0)return"";let _e=me-q.width/2;return(le(_e,_e+q.width)?`<rect x="${f(_e-3)}" y="${f(se-q.height/2+2)}" width="${f(q.width+6)}" height="${f(q.height-4)}" rx="3" fill="var(--_bg)" stroke="none"/>`:"")+Le(q,me,se,ve,c)},te=(q,me=0)=>q.activations.length+me>0?q.x-Nr/2:q.x,ae=(q,me=0)=>{let se=q.activations.length+me;return se>0?q.x+Nr/2+(se-1)*gy:q.x},ee=[],re=[],de="",ye="",oe="",xe="",fe="",pe="",Me=(q,me)=>{let se=q.activations.pop(),ve=Math.max(me,se+MN),_e=q.x-Nr/2+q.activations.length*gy;return L(_e,_e+Nr),re.push(`<rect class="pele-activation" data-id="${Ge(q.id)}" x="${f(_e)}" y="${f(se)}" width="${Nr}" height="${f(ve-se)}" rx="2"/>`),ve},Ae=(q,me)=>{let se=q.x,ve=me+16;return q.lifeEnd=ve,pe+=`<path class="pele-destroy" data-id="${Ge(q.id)}" d="M${f(se-6)},${f(ve-6)}L${f(se+6)},${f(ve+6)}M${f(se+6)},${f(ve-6)}L${f(se-6)},${f(ve+6)}"/>`,ve+6},ce=(q,me,se)=>{let ve=q.actor.properties.get("class");return`<g class="pele-node pele-actor pele-actor-${q.kind}${se?" pele-actor-footer":""}${typeof ve=="string"?jt(ve):""}" data-id="${Ge(q.id)}">`+vN(q.kind,q.x,me,q.size,q.label,c)+"</g>"},ge=(q,me,se,ve)=>`<g class="pele-sequence-number"><rect x="${f(me-ve/2)}" y="${f(se-Po/2)}" width="${f(ve)}" height="${Po}" rx="${Po/2}" fill="var(--_l)" stroke="none"/><text x="${f(me)}" y="${f(se+s*.35)}" text-anchor="middle" font-size="${s}" fill="var(--_bg)" stroke="none">${tt(String(G.index[q]))}</text></g>`,be=K+6,Ie=[];for(let q=0;q<I;q++){let me=H[q],se=me.type,ve=T[q],_e=F[q];if(se===17){let Te=me.from===void 0?void 0:A.get(me.from);Te!==void 0&&S[Te].activations.push(be)}else if(se===18){let Te=me.from===void 0?void 0:A.get(me.from);Te!==void 0&&S[Te].activations.length>0&&(be=Math.max(be,Me(S[Te],be)))}else if(_e&&_e.dividers[0]===q)Ie.push(_e),_e.kind==="rect"?(_e.top=be+8,be=_e.top):(_e.top=be+12,be=_e.top+Math.max(Do,_e.title.height+2));else if(_e){Ie.pop();let Te=be+12,Oe=f(_e.x0),Ce=f(_e.x1-_e.x0);if(_e.kind==="rect"){let He=_e.fill?Ot([`fill:${_e.fill}`]).shape:"";ee.push(`<rect class="pele-rect" x="${Oe}" y="${f(_e.top)}" width="${Ce}" height="${f(Te-_e.top)}"${_t((He?"":' fill-opacity="0.5"')+He)}/>`)}else{let He=`<rect x="${Oe}" y="${f(_e.top)}" width="${Ce}" height="${f(Te-_e.top)}" fill="none"${xt}/>`;for(let Ee=0;Ee<_e.dividerY.length;Ee++){let Ye=_e.dividerY[Ee],qe=_e.dividerLabels[Ee];He+=`<path d="M${Oe},${f(Ye)}H${f(_e.x1)}"${yy}/>`+J(qe,_e.x0+8+qe.width/2,Ye+2+qe.height/2,' class="pele-frame-label" fill="var(--_m)" stroke="none"')}He+=`<rect x="${Oe}" y="${f(_e.top)}" width="${f(_e.tabW)}" height="${Do}" fill="var(--_s)"${xt}/><text class="pele-frame-kind" x="${f(_e.x0+_e.tabW/2)}" y="${f(_e.top+Do/2+s*.35)}" text-anchor="middle" font-size="${s}" font-weight="var(--_hw)" fill="var(--_m)" stroke="none">${_e.kind}</text>`+J(_e.title,_e.x0+_e.tabW+8+_e.title.width/2,_e.top+Math.max(Do,_e.title.height)/2,' class="pele-frame-label" fill="var(--_m)" stroke="none"'),de+=`<g class="pele-frame pele-frame-${_e.kind}">${He}</g>`}be=Te}else if(se===13||se===20||se===28){let Te=Ie[Ie.length-1];if(Te){let Oe=Te.dividerLabels[Te.dividerY.length];Te.dividerY.push(be+12),be+=12+(Oe.height>0?Oe.height:0)}}else if(ve&&ve.kind===2){let Te=S[ve.a],Oe=ve.label.height+2*Math.max(4,k-4),Ce=be+10,He=ve.x;me.placement===1?He+=ae(Te)-Te.x:me.placement===0&&(He+=te(Te)-Te.x),L(He,He+ve.w),xe+=`<g class="pele-note" data-id="i${Ge(me.id)}"><rect x="${f(He)}" y="${f(Ce)}" width="${f(ve.w)}" height="${f(Oe)}"${xt}/>`+Le(ve.label,He+ve.w/2,Ce+Oe/2,' class="pele-label" stroke="none" fill="var(--_fg)"',c)+"</g>",be=Ce+Oe}else if(ve){let Te=fp[se],Oe=S[ve.a],Ce=S[ve.b],He=ve.label,Ee=w(q),Ye=0;for(let Fe=q+1;Fe<I;Fe++){let at=H[Fe].type;if(at===17)H[Fe].from===me.to&&Ye++;else if(at!==18&&at!==59&&at!==60)break}let qe=Te.bottom?1:-1,Qe=Te.dotted?yy:"",lt=me.centralConnection,Ze=lt===59||lt===61,it=lt===60||lt===61,rt=(Fe,at)=>`<circle class="pele-central" cx="${f(Fe)}" cy="${f(at)}" r="${aa}" fill="var(--_l)" stroke="none"/>`,wt=Te.atStart&&!Te.atEnd,je=SN(Te.head),Ue="",ot;if(ve.kind===1){let Fe=be+x+Math.max(0,(He.height-py)/2),at=Fe+py,ct=it?Oe.x+aa:ae(Oe),st=Ze?Oe.x+aa:ae(Oe,Ye),Tt=Math.max(ct,st)+Nu+Ee/2;it&&(Ue+=rt(Oe.x,Fe)),Ze&&(Ue+=rt(Oe.x,at)),Ee>0&&(Ue+=ge(q,wt?st:ct,wt?at:Fe,Ee),wt?st+=Ee/2:ct+=Ee/2);let ht=(Te.atStart?zo(Te.head,ct,Fe,-1,qe):"")+(Te.atEnd?zo(Te.head,st,at,-1,-qe):""),Ke=f(ct+(Te.atStart?je:0)),dt=f(st+(Te.atEnd?je:0));Ue=`<path d="${d?`M${Ke},${f(Fe)}H${f(Tt)}V${f(at)}H${dt}`:`M${Ke},${f(Fe)}H${f(Tt-6)}A6,6 0 0 1 ${f(Tt)},${f(Fe+6)}V${f(at-6)}A6,6 0 0 1 ${f(Tt-6)},${f(at)}H${dt}`}"${Qe}/>`+ht+Ue,L(Oe.x,Tt+8+He.width),He.width>0&&(oe+=`<g class="pele-edge-label" data-id="i${Ge(me.id)}">${Le(He,Tt+8+He.width/2,(Fe+at)/2,"",c)}</g>`),ot=Math.max(at,(Fe+at)/2+He.height/2)}else{let Fe=Ce.x>Oe.x?1:-1,at=Ce.createAt===q;ot=be+x+Math.max(He.height>0?He.height+2:6,at?Ce.size.h/2-x+6:0);let ct=Fe>0?ae(Oe):te(Oe),st=Fe>0?te(Ce,Ye):ae(Ce,Ye);if(at&&(Ce.top=ot-Ce.size.h/2,Ce.lifeStart=Ce.top+Ce.size.h,st=Ce.x-Fe*(up(Ce.kind)?18:Ce.size.w/2+1)),it&&(Ue+=rt(Oe.x,ot),ct=Oe.x+Fe*aa),Ze&&(Ue+=rt(Ce.x,ot),st=Ce.x-Fe*aa),Ee>0)if(wt){let dt=Ze?st-Fe*(Ee/2+2):st;Ue+=ge(q,dt,ot,Ee),st=dt-Fe*Ee/2}else{let dt=it?ct+Fe*(Ee/2+2):ct;Ue+=ge(q,dt,ot,Ee),ct=dt+Fe*Ee/2}let Tt=(Te.atStart?zo(Te.head,ct,ot,-Fe,qe*Fe):"")+(Te.atEnd?zo(Te.head,st,ot,Fe,qe*Fe):""),ht=ct+(Te.atStart?Fe*je:0),Ke=st-(Te.atEnd?Fe*je:0);if(Ue=`<path d="M${f(ht)},${f(ot)}H${f(Ke)}"${Qe}/>`+Tt+Ue,He.width>0){let dt=Math.min(ct,st),yt=Math.max(ct,st),$t=C<0?dt+N+He.width/2:C>0?yt-N-He.width/2:(dt+yt)/2;L($t-He.width/2,$t+He.width/2),oe+=`<g class="pele-edge-label" data-id="i${Ge(me.id)}">${J(He,$t,ot-4-He.height/2,"")}</g>`}at&&(be=ot+Ce.size.h/2-6)}ye+=`<g class="pele-edge pele-message" data-id="i${Ge(me.id)}">${Ue}</g>`,be=Math.max(be,ot),Oe.destroyAt===q&&(be=Math.max(be,Ae(Oe,ot))),Ce.destroyAt===q&&Ce!==Oe&&(be=Math.max(be,Ae(Ce,ot)))}}be+=20;for(let q of S)for(;q.activations.length>0;)Me(q,be);let Re=be;if(u){let q=0;for(let me of S)me.lifeEnd>=0||(q=Math.max(q,me.size.h),fe+=ce(me,be,!0));Re=be+q}let ze="";for(let q of S){fe+=ce(q,q.top,!1);let me=q.lifeEnd>=0?q.lifeEnd:be;me>q.lifeStart&&(ze+=`<path class="pele-lifeline" data-id="${Ge(q.id)}" d="M${f(q.x)},${f(q.lifeStart)}V${f(me)}"/>`)}let he="";for(let q of _){let me=S[q.first].x-S[q.first].size.w/2-b-q.grow,se=S[q.last].x+S[q.last].size.w/2+b+q.grow,ve=q.box.fill==="transparent"?"":Ot([`fill:${q.box.fill}`]).shape;he+=`<g class="pele-cluster pele-box"${q.box.name?` data-id="${Ge(q.box.name)}"`:""}><rect x="${f(me)}" y="0" width="${f(se-me)}" height="${f(Re+b)}" fill="var(--_a)" stroke="var(--_b)"${_t((ve?"":' fill-opacity="0.5"')+ve)}/>`+Le(q.title,(me+se)/2,b/2+2+q.title.height/2,' class="pele-cluster-label" fill="var(--_m)"',c)+"</g>"}_.length>0&&(Re+=b);let $e=0,Se="",we=Xt(r),ke=Mn(e.title,o,a,n?we:1/0),Ne=n?Oc(ke,o,Math.max(120,we)):ke;if(Y>D&&L(0,Math.max(Ne.width,40)),Ne.width>0){let q=(Y+D)/2;L(q-Ne.width/2,q+Ne.width/2),$e=-Ne.height-12,Se=Le(Ne,q,$e+Ne.height/2,' class="pele-title" font-weight="var(--_tw)"',c)}let Be=Math.ceil(D-Y+2*h),Pe=Math.ceil(Re-$e+2*h);return{svg:mt("sequence",Be,Pe,a,r,e,`<g transform="translate(${f(h-Y)},${f(h-$e)})">`+Se+(he?`<g class="pele-boxes" font-size="${l}">${he}</g>`:"")+(ee.length>0?`<g class="pele-rects" fill="var(--_a)">${ee.reverse().join("")}</g>`:"")+(ze?`<g class="pele-lifelines" fill="none" stroke="var(--_b)">${ze}</g>`:"")+(re.length>0?`<g class="pele-activations" fill="var(--_s)" stroke="var(--_b)">${re.reverse().join("")}</g>`:"")+(de?`<g class="pele-frames" font-size="${l}" stroke="var(--_b)">${de}</g>`:"")+(ye?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${ye}</g>`:"")+(pe?`<g class="pele-destroys" fill="none" stroke="var(--_l)" stroke-width="1.5" stroke-linecap="round">${pe}</g>`:"")+(oe?`<g class="pele-edge-labels" font-size="${l}">${oe}</g>`:"")+(xe?`<g class="pele-notes" font-size="${l}" fill="var(--_a)" stroke="var(--_b)">${xe}</g>`:"")+(fe?`<g class="pele-nodes">${fe}</g>`:"")+"</g>"),width:Be,height:Pe,links:[]}}var NN={type:"sequence",math:!0,parse(e,t,r){let n=t.sequence??{},i=new dN({wrap:typeof t.wrap=="boolean"?t.wrap:void 0,sequenceWrap:n.wrap===!0});return r&&i.setDiagramTitle(r),fN(e,i),i},render:CN};function RN(e){let t="TB";for(let r of e)typeof r!="string"&&r.stmt==="dir"&&(t=r.value);return t}function ON(e,t,r){let n=[],i=[],a=new Map,l=new Map,s=new Map,o=0,c=0,h=p=>{if(!p.id||p.id==="</join></fork>"||p.id==="</choice>")return;if(p.cssClasses){let m;for(let v of p.cssClasses.split(" ")){let x=r.get(v);if(x){m??=p.cssCompiledStyles.slice();for(let k of x.styles)m.push(k)}}m&&(p.cssCompiledStyles=m)}let g=a.get(p.id);if(g){let m=p.parentId??g.parentId;Object.assign(g,p),m!==void 0&&(g.parentId=m)}else a.set(p.id,p),n.push(p)},u=(p,g,m)=>{let v=g.id;if(v==="root")return;let x=t.get(v),k=x?.classes?.join(" ")??"",b=x?.styles??[],C=l.get(v);if(!C){let z="rect";g.start===!0?z="stateStart":g.start===!1&&(z="stateEnd"),g.type!=="default"&&(z=g.type),C={shape:z,description:v,cssClasses:`${k} statediagram-state`,cssStyles:b,type:void 0,dir:void 0,colorIndex:void 0},l.set(v,C)}if(g.description&&(Array.isArray(C.description)?(C.shape="rectWithTitle",C.description=C.description.concat(g.description)):C.description.length>0?(C.shape="rectWithTitle",C.description=C.description===v?[g.description].flat():[C.description,g.description].flat()):(C.shape="rect",C.description=Array.isArray(g.description)?g.description.slice():g.description)),C.description.length===1&&C.shape==="rectWithTitle"&&(C.shape=C.type==="group"?"roundedWithTitle":"rect"),!C.type&&g.doc){if(C.type="group",C.dir=RN(g.doc),C.shape=g.type==="divider"?"divider":"roundedWithTitle",C.shape==="divider"&&p?.id!==void 0&&s.has(p.id))C.colorIndex=s.get(p.id);else{let z=c++;C.colorIndex=k.trim()!==""||b.length>0?void 0:z}s.set(v,C.colorIndex),C.cssClasses=`${C.cssClasses} statediagram-cluster ${m?"statediagram-cluster-alt":""}`}let N=C.description,R={id:v,shape:C.shape,label:Array.isArray(N)?N[0]:N,description:Array.isArray(N)?N.slice(1):[],cssClasses:C.cssClasses,cssCompiledStyles:[],cssStyles:C.cssStyles,type:C.type,isGroup:C.type==="group",dir:C.dir,colorIndex:C.colorIndex};R.shape==="divider"&&(R.label=""),p&&p.id!=="root"&&(R.parentId=p.id);let O=g.note;if(!O){h(R);return}let P=(z,W,S,A)=>({id:z,shape:W,label:O.text,description:[],cssClasses:S,cssCompiledStyles:[],cssStyles:[],type:A?"group":"node",isGroup:A,dir:void 0,position:O.position}),H=P(`${v}----note-${o++}`,"note","statediagram-note",!1);H.parentId=`${v}----parent`,H.noteFor=v,h(P(H.parentId,"noteGroup",C.cssClasses,!0)),h(H),h(R);let I=O.position==="left of",G=I?H.id:v,Z=I?v:H.id;i.push({id:`${G}-${Z}`,start:G,end:Z,label:"",classes:"transition note-edge",pattern:"dashed"})},d=[{item:void 0,doc:e,at:0,alt:!0}];for(;d.length>0;){let p=d[d.length-1];if(p.at>=p.doc.length){d.pop();continue}let g=p.doc[p.at++];typeof g!="string"&&(g.stmt==="state"?(u(p.item,g,p.alt),g.doc&&d.push({item:g,doc:g.doc,at:0,alt:!p.alt})):g.stmt==="relation"&&(u(p.item,g.state1,p.alt),u(p.item,g.state2,p.alt),i.push({id:`edge${o++}`,start:g.state1.id,end:g.state2.id,label:g.description??"",classes:"transition"})))}for(let p of n)if(p.isGroup&&p.description.length>0)throw new Je(`Group nodes can only have label. Remove the additional description for node [${p.id}]`,"semantic",{type:"state"});return{nodes:n,edges:i}}var LN=class{type="state";rootDoc=[];states=new Map;relations=[];classes=new Map;links=new Map;graph={nodes:[],edges:[]};title;accTitle;accDescr;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 n=r.styleClass.split(",").map(i=>i.replace(/;/g,"").trim());for(let i of this.named(r.id.trim()))i.styles=n.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=ON(t,this.states,this.classes)}translate(){let e=[["root",{stmt:"root",id:"root",doc:this.rootDoc},!0]];for(;e.length>0;){let[t,r,n]=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+(n?"_start":"_end"),r.start=n):r.id=r.id.trim();else if(r.stmt!=="root")continue;if(!r.doc)continue;let i=[],a=[];for(let l of r.doc)typeof l!="string"&&l.stmt==="state"&&l.type==="divider"&&!l.doc?(i.push({...l,doc:a}),a=[]):a.push(l);i.length>0&&(a.length>0&&i.push({stmt:"state",id:this.getDividerId(),type:"divider",doc:a}),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,n,i,a){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)),n)for(let o of Array.isArray(n)?n:[n])this.addDescription(l,o.trim());if(i&&(s.note=i),a)for(let o of a)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 n of[e,t])this.addState(n.id,n.type,n.doc,n.description,n.note,n.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 n of t.split(",")){let i=n.replace(";","").trim();n.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,`
132
+ `)}named(e){let t=[];for(let r of e.split(",")){let n=this.states.get(r);n||(this.addState(r),n=this.states.get(r.trim())),n&&t.push(n)}return t}},wy=["$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"],DN=/direction/gi,PN=/<<(?:fork|join|choice)>>|\[\[(?:fork|join|choice)\]\]/gi,zN=/[\n\r\u2028\u2029]/g,FN=/%%/g,WN=/\{/g;function _s(e,t){let r=0,n=-2;return i=>{if(n===-2||i<r||n!==-1&&i>n){e.lastIndex=i;let a=e.exec(t);n=a?a.index:-1,r=i}return n}}function BN(e){let t=e.length,r=[],n=[],i=[],a=[],l=0,s=0,o,c=_s(DN,e),h=_s(PN,e),u=_s(zN,e),d=_s(FN,e),p=_s(WN,e),g=-1,m=-1,v=[-1,-1,-1,-1],x=[0,0,0,0],k=-1,b=-1,C=[-1,-1,-1,-1,-1,-1],N=(y,E,w)=>{r.push(y),n.push(e.slice(E,w)),i.push(E),s=w},R=(y,E,w,T)=>{r.push(y),n.push(E),i.push(w),s=T},O=y=>{a.push(l),l=y},P=()=>{a.length>0&&(l=a.pop())},H=(y,E)=>{for(let w=0;w<y.length;w++){let T=y.charCodeAt(w),_=e.charCodeAt(E+w);if(_!==T&&!(T>=97&&T<=122&&_===T-32))return!1}return!0},I=y=>{let E=y;for(;E<t&&Xe(e.charCodeAt(E));)E++;return E},G=y=>{let E=y;for(;E<t&&nt(e.charCodeAt(E));)E++;return E},Z=y=>{let E=e.indexOf(`
133
+ `,y);return E===-1?t:E},z=y=>{let E=u(y);return E===-1?t:E},W=y=>{if(y<g||y>m){let E=c(y),w=E===-1?t:z(y);g=y,m=w,v[0]=v[1]=v[2]=v[3]=-1;for(let T=E;T!==-1&&T<w;T=c(T+1)){let _=I(T+9);if(_===T+9)continue;let M=H("tb",_)?0:H("bt",_)?1:H("rl",_)?2:H("lr",_)?3:-1;M!==-1&&(v[M]=T,x[M]=_+2)}}for(let E=0;E<4;E++)if(v[E]>=y)return E;return-1},S=y=>{if(y<k||y>b){let E=h(y),w=E===-1?t:z(y);k=y,b=w,C.fill(-1);for(let T=E;T!==-1&&T<w;T=h(T+1)){let _=e.charCodeAt(T+2)|32;C[(e.charCodeAt(T)===60?0:3)+(_===102?0:_===106?1:2)]=T}}for(let E=0;E<6;E++)if(C[E]>=y)return E;return-1},A=(y,E)=>{let w=d(y);return w===-1||w+2>E?(N(14,y,E),!0):w===y?(s=E,!1):(N(14,y,w),!0)},$=y=>(r.push(y),n.push(""),i.push(s),{types:r,texts:n,starts:i,error:o});for(;;){if(s>=t){switch(l){case 0:N(2,t,t);break;case 6:N(22,t,t);break;case 7:N(24,t,t);break;case 8:N(25,t,t);break;case 10:N(32,t,t);break;case 12:N(39,t,t);break;case 14:N(36,t,t);break;case 3:N(12,t,t);break;case 18:N(20,t,t);break;case 4:case 19:N(14,t,t);break}return $(0)}let y=e.charCodeAt(s);switch(l){case 0:case 1:{let E=l===0,w=y|32;if(E){if(w===99&&H("click",s)&&!nt(e.charCodeAt(s+5))){N(26,s,s+5);continue}if(w===104&&H("href",s)&&!nt(e.charCodeAt(s+4))){N(28,s,s+4);continue}if(y===34){let M=e.indexOf('"',s+1);if(M!==-1){N(27,s,M+1);continue}}if(w===100&&H("default",s)&&!nt(e.charCodeAt(s+7))){N(33,s,s+7);continue}let _=W(s);if(_!==-1){N(40+_,s,Z(x[_]));continue}if(y===10){let M=s+1;for(;e.charCodeAt(M)===10;)M++;N(2,s,M);continue}if(Xe(y)){s=I(s);continue}}else if(y!==10&&Xe(y)){let _=s+1;for(;_<t&&e.charCodeAt(_)!==10&&Xe(e.charCodeAt(_));)_++;s=_;continue}if(y===35||y===37&&e.charCodeAt(s+1)===37&&e.charCodeAt(s+2)!==123){s=Z(s);continue}if(w===115){if(E&&H("scale",s)){let _=I(s+5);if(_>s+5){N(7,s,_),O(5);continue}}if(H("style",s)){let _=I(s+5);if(_>s+5){N(34,s,_),O(13);continue}}if(H("state",s)){let _=I(s+5);if(_>s+5){s=_,O(2);continue}if(E&&H("diagram",s+5)){let M=H("-v2",s+12)?s+15:s+12;if(_=I(M),_>M){N(3,s,_);continue}}}}else if(w===99){if(H("class",s)){let _=H("def",s+5),M=_?s+8:s+5,U=I(M);if(U>M){N(_?29:37,s,U),O(_?9:11);continue}}}else if(w===97&&E&&(H("acctitle",s)||H("accdescr",s))){let _=(e.charCodeAt(s+3)|32)===116,M=I(s+8),U=e.charCodeAt(M);if(U===58){N(_?21:23,s,I(M+1)),O(_?6:7);continue}if(U===123&&!_){s=I(M+1),O(8);continue}}if(E){if(y===123){N(10,s,s+1),O(1);continue}}else{let _=W(s);if(_!==-1){N(40+_,s,Z(x[_]));continue}if(y===125){N(11,s,s+1),P();continue}if(y===10){s++;continue}}if(w===110&&H("note",s)){let _=I(s+4);if(_>s+4){N(19,s,_),O(15);continue}}if(E&&w===104&&H("hide empty description",s)&&!nt(e.charCodeAt(s+22))){N(6,s,s+22);continue}if(y===91&&e.charCodeAt(s+1)===42&&e.charCodeAt(s+2)===93){N(44,s,s+3);continue}let T=s;for(;T<t;){let _=e.charCodeAt(T);if(_===58||_===45||_===123||Xe(_))break;T++}if(T>s){A(s,T);continue}if(y===58){for(T=s+1;T<t;){let _=e.charCodeAt(T);if(_===10||_===59)break;if(_===58){let M=e.charCodeAt(T+1);if(T+1>=t||M===58||M===10||M===59)break;T++}T++}if(T>s+1){R(4,e.slice(s,T).trim(),s,T);continue}if(e.charCodeAt(s+1)===58&&e.charCodeAt(s+2)===58){N(45,s,s+3);continue}}else if(y===45&&e.charCodeAt(s+1)===45){if(e.charCodeAt(s+2)===62){N(5,s,s+3);continue}if(!E){N(18,s,s+2);continue}}if(!E)return $(1);N(48,s,s+1);continue}case 2:{if(y!==10&&Xe(y)){let _=s+1;for(;_<t&&e.charCodeAt(_)!==10&&Xe(e.charCodeAt(_));)_++;s=_;continue}if(y===35||y===37&&e.charCodeAt(s+1)===37&&e.charCodeAt(s+2)!==123){s=Z(s);continue}let E=S(s);if(E!==-1){let _=C[E],M=E===2||E===5;R(M?17:E%3===0?15:16,e.slice(s,_).trim(),s,_+(M?10:8)),P();continue}if(y===34){s++,O(3);continue}let w=y===10?I(s):s;if(H("as",w)){let _=I(w+2);if(_>w+2){N(13,s,_),O(4);continue}}if(y===10){s++,P();continue}if(y===123){N(10,s,s+1),P(),O(1);continue}if(nt(y)){let _=G(s),M=I(_);if(M>_&&nt(e.charCodeAt(M))){let U=p(M+1);if(U!==-1&&U<z(M))return o=`Error: State name must be a single word. Found: "${e.slice(s,U+1).trim()}"`,$(1)}}let T=s+1;for(;T<t;){let _=e.charCodeAt(T);if(_===123||Xe(_))break;T++}N(9,s,T);continue}case 3:{if(y===34){s++,P();continue}let E=e.indexOf('"',s);N(12,s,E===-1?t:E);continue}case 4:{let E=s;for(;E<t;){let w=e.charCodeAt(E);if(w===10||w===123)break;E++}A(s,E)&&P();continue}case 5:{if(y>=48&&y<=57){let w=s+1;for(;w<t&&e.charCodeAt(w)>=48&&e.charCodeAt(w)<=57;)w++;N(8,s,w);continue}let E=I(s);if(E>s&&H("width",E)&&!nt(e.charCodeAt(E+5))){s=E+5,P();continue}return $(1)}case 6:N(22,s,Z(s)),P();continue;case 7:N(24,s,Z(s)),P();continue;case 8:{if(y===125){s++,P();continue}let E=e.indexOf("}",s);N(25,s,E===-1?t:E);continue}case 9:{let E=H("default",s)&&I(s+7)>s+7,w=E?s+7:G(s),T=I(w);if(w===s||T===w)return $(1);N(E?31:30,s,T),P(),O(10);continue}case 10:N(32,s,Z(s)),P();continue;case 11:{let E=G(s);if(E===s)return $(1);for(;e.charCodeAt(E)===44;){let w=I(E+1),T=G(w);if(T===w)break;E=T}N(38,s,E),P(),O(12);continue}case 12:N(39,s,Z(s)),P();continue;case 13:{let E=s;for(;E<t&&(nt(e.charCodeAt(E))||e.charCodeAt(E)===44);)E++;let w=I(E);if(E===s||w===E)return $(1);N(35,s,w),P(),O(14);continue}case 14:N(36,s,Z(s)),P();continue;case 15:{if(H("left of",s)&&!nt(e.charCodeAt(s+7))){N(46,s,s+7),P(),O(16);continue}if(H("right of",s)&&!nt(e.charCodeAt(s+8))){N(47,s,s+8),P(),O(16);continue}if(y===34){s++,P(),O(18);continue}return $(1)}case 16:{let E=I(s),w=E;for(;w<t;){let T=e.charCodeAt(w);if(T===58||T===45||Xe(T))break;w++}if(w===E)return $(1);A(s,w)&&(P(),O(17));continue}case 17:{let E=I(s);if(e.charCodeAt(E)===58){let _=E+1;for(;_<t;){let M=e.charCodeAt(_);if(M===58||M===10||M===59)break;_++}if(_>E+1){R(20,e.slice(s+2,_).trim(),s,_),P();continue}}let w=e.indexOf(`
134
+ `,s),T=-1;for(;w!==-1&&(T=I(w),!(H("end note",T)&&!nt(e.charCodeAt(T+8))));)w=e.indexOf(`
135
+ `,T);if(w===-1)return $(1);R(20,e.slice(s,T).trim(),s,T+8),P();continue}case 18:{let E=I(s);if(H("as",E)){N(13,s,I(E+2)),P(),O(19);continue}if(y===34){s++;continue}let w=e.indexOf('"',s);N(20,s,w===-1?t:w);continue}case 19:A(s,Z(s))&&P();continue}}}var HN=["TB","BT","RL","LR"],Fo="'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'";function jN(e,t){let{types:r,texts:n,starts:i,error:a}=BN(e),l=0,s=g=>{let m=r[l];throw m===1?a!==void 0?new Je(a,"syntax",{type:"state",...qf(e,i[l])}):vt("state",e,i[l],"",!0):vt("state",e,i[l],`Expecting ${g}, got '${wy[m]}'`)},o=g=>(r[l]!==g&&s(`'${wy[g]}'`),n[l++]),c=()=>{let g=r[l];g!==14&&g!==44&&s("'ID', 'EDGE_STATE'");let m=n[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 h=[],u=[],d=g=>{g!=="nl"&&h.push(g)},p=(g,m)=>{l++;let v=[];h.push({stmt:"state",id:g,type:"default",description:m,doc:v}),u.push(h),h=v};for(;;){let g=r[l];switch(g){case 2:l++;break;case 14:case 44:{let m=c();if(r[l]===4)m.description=t.trimColon(n[l++]),d(m);else if(r[l]===5){l++;let v=c();r[l]===4?d({stmt:"relation",state1:m,state2:v,description:t.trimColon(n[l++])}):d({stmt:"relation",state1:m,state2:v})}else d(m);break}case 6:d(n[l++]);break;case 7:l++,o(8),d(n[l-2]);break;case 9:r[l+1]===10?p(n[l++],""):d(n[l++]);break;case 12:{let m=n[l++];o(13);let v=o(14);if(r[l]===10)p(v,m);else if(v.includes(":")){let x=v.split(":");d({stmt:"state",id:x[0],type:"default",description:[m.trim(),x[1]]})}else d({stmt:"state",id:v,type:"default",description:m.trim()});break}case 15:d({stmt:"state",id:n[l++],type:"fork"});break;case 16:d({stmt:"state",id:n[l++],type:"join"});break;case 17:d({stmt:"state",id:n[l++],type:"choice"});break;case 18:l++,d({stmt:"state",id:t.getDividerId(),type:"divider"});break;case 19:{let m=n[l++];if(r[l]===46||r[l]===47){let v=n[l++].trim(),x=o(14).trim();d({stmt:"state",id:x,note:{position:v,text:o(20).trim()}})}else r[l]!==20&&s("'NOTE_TEXT', 'left_of', 'right_of'"),l++,o(13),o(14),d(m);break}case 40:case 41:case 42:case 43:{let m=HN[g-40];l++,t.setDirection(m),d({stmt:"dir",value:m});break}case 21:{l++;let m=o(22).trim();t.setAccTitle(m),d(m);break}case 23:{l++;let m=o(24).trim();t.setAccDescription(m),d(m);break}case 25:{let m=n[l++].trim();t.setAccDescription(m),d(m);break}case 26:{l++;let m=c(),v,x="";r[l]===28?(l++,v=o(27)):(r[l]!==27&&s("'STRING', 'HREF'"),v=n[l++],x=o(27)),o(2),d({stmt:"click",id:m,url:v,tooltip:x});break}case 29:{l++;let m=o(30).trim();d({stmt:"classDef",id:m,classes:o(32).trim()});break}case 34:{l++;let m=o(35).trim();d({stmt:"style",id:m,styleClass:o(36).trim()});break}case 37:{l++;let m=o(38).trim();d({stmt:"applyClass",id:m,styleClass:o(39).trim()});break}case 11:u.length===0&&s(`'$end', ${Fo}`),l++,h=u.pop();break;case 0:return u.length>0&&s(`'STRUCT_STOP', ${Fo}`),t.setRootDoc(h),h;default:s(u.length>0?`'STRUCT_STOP', ${Fo}`:`'$end', ${Fo}`)}}}var UN=40,YN=16,GN=44,ma=16,Ru=10,VN=16,vy=10,Ou=26,$y=8,qN=320,Lu=10,ky=8,My=' fill="var(--_s)" stroke="var(--_b)"',Wo=' fill="none" stroke="var(--_b)"',XN=/(?:^| )statediagram-(?:state|cluster-alt|cluster|note)(?= |$)/g,KN=new Map([["rectWithTitle",1],["stateStart",2],["stateEnd",3],["choice",4],["fork",5],["join",6],["note",7],["divider",10]]),ZN=["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"];function _y(e){return e==="TB"||e==="BT"}function Du(e,t,r){let n=e.state?.[t];return typeof n=="number"&&n>0?Math.min(n,2e3):r}function Ey(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 Ay(e,t,r){return e<t?t:e>r?r:e}function Bo(e,t,r,n,i){return`<rect x="${f(e)}" y="${f(t)}" width="${f(r)}" height="${f(n)}"${i}/>`}function Ho(e,t,r,n){let i=Bt(0,0);return i.isGroup=!0,i.dir=e,i.padX=t,i.padTop=r,i.padBottom=n,i}function QN(e,t,r){return Ti(e.direction)?dr(r,n=>Ty(e,t,r,n)):Ty(e,t,r,!1)}function Ty(e,t,r,n){let i=e.graph,a=r.fontSize??16,l=Math.round(a*.875),s=r.measurer??bt(r.fontFamily),o=Du(t,"wrappingWidth",200),c=r.padding??8,h=r.icons,u=n?"TB":Pr(e.direction),d=Ve(void 0,!1,s,a,0),p=(ee,re,de,ye=0)=>Ve(ee,!0,s,re,de,ye),g=new Map,m=[],v=[],x=(ee,re,de)=>(m.push({node:ee,kind:re,style:void 0,label:d,lines:[],w:0,h:0,titleH:0}),de&&v.push(de),m.length-1);for(let ee of i.nodes){if(ee.shape==="noteGroup")continue;let re=ee.isGroup?ee.shape==="divider"?9:8:KN.get(ee.shape)??0;g.set(ee.id,x(ee,re,void 0))}let k=m.length,b=[];for(let ee=0;ee<k;ee++){let re=m[ee].node.parentId,de=re===void 0?void 0:g.get(re);b.push(de!==void 0&&de!==ee&&m[de].node.isGroup?de:-1)}{let ee=[];for(let fe=0;fe<k;fe++)ee.push([]);let re=[],de=new Uint8Array(k);for(let fe=0;fe<k;fe++)b[fe]===-1?(de[fe]=1,re.push(fe)):ee[b[fe]].push(fe);let ye=0,oe=()=>{for(;ye<re.length;ye++)for(let fe of ee[re[ye]])de[fe]||(de[fe]=1,re.push(fe))};oe();let xe=new Int32Array(k).fill(-1);for(let fe=0;fe<k;fe++){if(de[fe])continue;let pe=fe;for(;xe[pe]!==fe;)xe[pe]=fe,pe=b[pe];b[pe]=-1,de[pe]=1,re.push(pe),oe()}}let C=new Int32Array(k).fill(-1);for(let ee=0;ee<k;ee++){let re=m[ee].node.noteFor,de=re===void 0?void 0:g.get(re);de!==void 0&&(C[ee]=de,b[ee]=b[de])}let N=ee=>Pr(m[ee].node.dir),R=ee=>_y(b[ee]===-1?u:N(b[ee])),O=new Int32Array(k),P=new Uint8Array(k),H=new Array(k).fill(1/0),I=0,G=new Int32Array(2*k);for(let ee of i.edges){let re=g.get(ee.start),de=g.get(ee.end);if(!(re===void 0||de===void 0)){if(ee.pattern==="dashed"){P[m[re].kind===7?de:re]=1;continue}O[re]=Math.max(O[re],++G[2*re]),O[de]=Math.max(O[de],++G[2*de+1]),H[re]===1/0&&(H[re]=I++),H[de]===1/0&&(H[de]=I++)}}for(let ee=0;ee<k;ee++){let re=m[ee],de=re.node,ye=Ot(de.cssStyles.length>0?de.cssCompiledStyles.concat(de.cssStyles):de.cssCompiledStyles),oe=(ye.bold?1:0)|(ye.italic?2:0),xe=ye.fontSize??a;re.style=ye;let fe;switch(re.kind){case 8:re.label=p(de.label,xe,4e3,oe),re.titleH=re.label.height>0?re.label.height+12:0,fe=Ho(N(ee),ma,re.titleH+ma,ma),fe.minW=re.label.width+2*ma;break;case 9:fe=Ho(N(ee),Ru,Ru,Ru);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 pe=Ay(40*O[ee]+16,72,320);re.w=R(ee)?pe:ky,re.h=R(ee)?ky:pe;break}case 10:break;case 7:re.label=p(de.label,l,Math.max(o,qN)),re.w=re.label.width+24,re.h=re.label.height+16;break;default:{re.label=p(de.label,xe,o,oe);let pe=re.label.width,Me=re.label.height+2*vy;if(re.kind===1){Me+=14;for(let Ae of de.description){let ce=p(Ae===""?" ":Ae,l,o,oe);re.lines.push(ce),ce.width>pe&&(pe=ce.width),Me+=ce.height}}re.w=Math.max(pe+2*VN,56),re.h=Me}}fe??=Bt(re.w,re.h),(re.kind===0||re.kind===1)&&(fe.span=(R(ee)?re.w:re.h)-24),v.push(fe)}let Z=[],z=[],W=[],S=new Int32Array(k),A=new Float64Array(k),$=new Float64Array(k),y=new Map,E=(ee,re)=>{if(!v[ee].isGroup)return!1;for(let de=b[re];de!==-1;de=b[de])if(de===ee)return!0;return!1},w=(ee,re)=>(y.set(Z.length,ee),H.push(re?-1:1/0),x(void 0,10,Bt(0,0,ee)));for(let ee of i.edges){let re=g.get(ee.start),de=g.get(ee.end);if(re===void 0||de===void 0)continue;let ye=p(ee.label,l,o),oe=ye.width>0?ye.width+12:0;re===de?(S[re]++,A[re]=Math.max(A[re],oe),$[re]+=ye.height):E(re,de)?re=w(re,!0):E(de,re)&&(de=w(de,!1)),W.push(ee),z.push(ye),Z.push({src:re,dst:de,minlen:1,labelW:oe,labelH:ye.height>0?ye.height+4:0,route:[],labelX:0,labelY:0})}for(let ee=0;ee<k;ee++){if(C[ee]!==-1)continue;let re=v[ee],de=0;if(S[ee]>0){let oe=Ou+(S[ee]-1)*8;de=R(ee)?oe+A[ee]:oe*.75+4+$[ee],re.isGroup||(R(ee)?(re.w+=2*de,re.h=Math.max(re.h,$[ee])):(re.h+=2*de,re.w=Math.max(re.w,A[ee])),de=0)}if(!P[ee]&&de===0){re.parent=b[ee];continue}let ye=R(ee)?Ho("LR",de,0,0):Ho("TB",0,de,de);ye.parent=b[ee],H.push(H[ee]),v[ee].parent=x(void 0,10,ye)}for(let ee=0;ee<k;ee++)C[ee]!==-1&&(v[ee].parent=v[C[ee]].parent);{let ee=[];for(let fe=0;fe<v.length;fe++)ee.push([]);let re=[];for(let fe=0;fe<v.length;fe++){let pe=v[fe].parent;pe>=0?ee[pe].push(fe):re.push(fe)}let de=fe=>m[fe].kind===2?0:1,ye=(fe,pe)=>de(fe)-de(pe)||(H[fe]===H[pe]?0:H[fe]<H[pe]?-1:1)||fe-pe,oe=0,xe=re.sort(ye).reverse();for(;xe.length>0;){let fe=xe.pop();v[fe].seq=oe++;let pe=ee[fe].sort(ye);for(let Me=pe.length-1;Me>=0;Me--)xe.push(pe[Me])}}let T=Ai(v,Z,u,{nodeSep:Du(t,"nodeSpacing",UN),edgeSep:YN,rankSep:Du(t,"rankSpacing",GN),portSep:20,headRoom:Et("arrow_point")}),_=Math.ceil(T.width+2*c),M=Math.ceil(T.height+2*c),U=[],j=new Map;for(let ee of Z){let re=ee.route;for(let de=3;de<re.length-3;de+=3){let ye=Math.round(re[de+1]),oe=j.get(ye);oe?oe.push(re[de]):j.set(ye,[re[de]])}}let Y=[];for(let ee=0;ee<v.length;ee++)Y.push([]);let D=[];for(let ee=0;ee<v.length;ee++){let re=v[ee].parent;re>=0?Y[re].push(ee):D.push(ee)}let L=D.slice();for(let ee=0;ee<D.length;ee++)for(let re of Y[D[ee]])D.push(re);let F="",V="",X="",Q="",ne=(ee,re,de,ye,oe)=>{let xe=ee.filter(Me=>m[Me].kind===9);if(xe.length<2)return;let fe=(Me,Ae)=>Ae?v[Me].x-v[Me].w/2:v[Me].y-v[Me].h/2,pe=(Me,Ae)=>Ae?v[Me].x+v[Me].w/2:v[Me].y+v[Me].h/2;for(let Me of[!0,!1]){let Ae=xe.slice().sort((ge,be)=>fe(ge,Me)-fe(be,Me)||ge-be),ce=!0;for(let ge=1;ge<Ae.length;ge++)pe(Ae[ge-1],Me)>fe(Ae[ge],Me)+.5&&(ce=!1);if(ce){for(let ge=1;ge<Ae.length;ge++){let be=f((pe(Ae[ge-1],Me)+fe(Ae[ge],Me))/2+c);V+=`<path class="pele-divider" d="M${Me?`${be},${f(de)}V${f(oe)}`:`${f(re)},${be}H${f(ye)}`}"/>`}return}}for(let Me of xe){let Ae=v[Me];V+=Bo(Ae.x-Ae.w/2+c,Ae.y-Ae.h/2+c,Ae.w,Ae.h,` class="pele-divider" rx="${Lu}"`)}};ne(L,c/2,c/2,_-c/2,M-c/2);for(let ee of D){let re=m[ee],de=re.node,ye=re.style;if(de===void 0||ye===void 0||re.kind>=9)continue;let oe=v[ee],xe=oe.x+c,fe=oe.y+c,pe=re.w,Me=re.h,Ae=` class="pele-label"${ye.text}`,ce;switch(re.kind){case 8:{let Ie=xe-oe.w/2,Re=fe-oe.h/2;ce=Bo(Ie,Re,oe.w,oe.h,` rx="${Lu}" fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${ye.shape}`),re.titleH>0&&(ce+=`<path d="M${f(Ie)},${f(Re+re.titleH)}H${f(Ie+oe.w)}"${Wo}${ye.line}/>`+Le(re.label,JN(oe,re.label.width,j)+c,Re+re.titleH/2,` class="pele-cluster-label"${ye.text}`,h)),ne(Y[ee],Ie,Re+re.titleH,Ie+oe.w,Re+oe.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,${f(-Me/2)} ${f(pe/2)},0 0,${f(Me/2)} ${f(-pe/2)},0"${My}${ye.shape}/>`;break;case 5:case 6:ce=Bo(-pe/2,-Me/2,pe,Me,` rx="2" fill="var(--_l)"${ye.shape}`);break;case 7:{let Ie=f(pe/2),Re=f(Me/2),ze=f(pe/2-$y),he=f($y-Me/2);ce=`<path d="M-${Ie},-${Re}H${ze}L${Ie},${he}V${Re}H-${Ie}Z" fill="var(--_bg)" stroke="var(--_b)"/><path d="M${ze},-${Re}V${he}H${Ie}"${Wo}/>`+Le(re.label,0,0,` class="pele-label" font-size="${l}" fill="var(--_m)"`,h);break}default:{if(ce=Bo(-pe/2,-Me/2,pe,Me,` rx="${f(Math.min(Lu,Me/2))}"${My}${ye.shape}`),re.kind===0){ce+=Le(re.label,0,0,Ae,h);break}let Ie=vy-Me/2+re.label.height;ce+=`<path d="M${f(-pe/2)},${f(Ie+6)}H${f(pe/2)}"${Wo}${ye.line}/>`+Le(re.label,0,Ie-re.label.height/2,Ae,h),Ie+=14;for(let Re of re.lines)ce+=Le(Re,0,Ie+Re.height/2,` class="pele-state-description" font-size="${l}"${ye.text}`,h),Ie+=Re.height}}let ge=e.links.get(de.id);if(ge){let Ie=It(Ey(ge.tooltip));Ie&&(ce=`<title>${tt(Ie)}</title>`+ce),ce=Na(ce,Ia(Ey(ge.url)),de.id,U,r,' target="_blank"')}let be=`<g class="${ZN[re.kind]}${jt(de.cssClasses.replace(XN,""))}" data-id="${Ge(de.id)}"`;re.kind===8?F+=`${be}>${ce}</g>`:re.kind===7?Q+=`${be} transform="translate(${f(xe)},${f(fe)})">${ce}</g>`:X+=`${be} transform="translate(${f(xe)},${f(fe)})">${ce}</g>`}let B=(ee,re,de)=>{let ye=v[de];if(ye.isGroup)return;let oe=m[de],xe=oe.kind===5||oe.kind===6,fe=re===0?3:re-3;for(let pe of[1,0]){let Me=pe?ye.h:ye.w,Ae=pe?oe.h:oe.w,ce=pe?oe.w:oe.h,ge=(pe?ye.y:ye.x)+c,be=(pe?ye.x:ye.y)+c,Ie=ee[re+pe]-ge;if(!(Math.abs(Math.abs(Ie)-Me/2)>=.5)){ee[re+pe]-=Math.sign(Ie)*(Me-Ae)/2,xe&&ce>Ae&&(ee[re+1-pe]=Ay(ee[fe+1-pe],be-ce/2+6,be+ce/2-6));return}}},K=Jx();for(let ee=0;ee<Z.length;ee++){let re=Z[ee];re.src===re.dst||re.route.length<6||W[ee].pattern==="dashed"||K.add(re.dst,wn(re.route,re.route.length-3,v[re.dst]),"arrow_point")}let ie="",le="",J=new Int32Array(k),te=new Float64Array(k);for(let ee=0;ee<Z.length;ee++){let re=Z[ee],de=W[ee],ye=z[ee],oe=de.pattern==="dashed",xe=oe?"none":"arrow_point",fe;if(re.src===re.dst){let pe=v[re.src],Me=m[re.src],Ae=J[re.src]++,ce=R(re.src),ge=pe.isGroup?pe.w:Me.w,be=pe.isGroup?pe.h:Me.h,Ie=(ce?ge:be)/2,Re=Math.max(Math.min((ce?be:ge)/2-4,8+Ae*6),2),ze=Ou+Ae*8,he=Et(xe)/(Math.hypot(ze,Re)||1),$e=(Pe,q)=>pe.x+c+(ce?Ie+Pe:-q),Se=(Pe,q)=>pe.y+c+(ce?q:Ie+Pe),we=(Pe,q)=>`${f($e(Pe,q))},${f(Se(Pe,q))}`;fe={d:`M${we(0,-Re)}C${we(ze,-2*Re)} ${we(ze,2*Re)} ${we(ze*he,Re+Re*he)}`,sx:0,sy:0,sdx:0,sdy:0,ex:$e(0,Re),ey:Se(0,Re),edx:$e(-ze,-Re)-$e(0,0),edy:Se(-ze,-Re)-Se(0,0)};let ke=Math.hypot(fe.edx,fe.edy)||1;fe.edx/=ke,fe.edy/=ke;let Ne=Ou+(S[re.src]-1)*8,Be=te[re.src]+ye.height/2;te[re.src]+=ye.height,re.labelX=ce?pe.x+Ie+Ne+4+re.labelW/2:pe.x,re.labelY=ce?pe.y-$[re.src]/2+Be:pe.y+Ie+Ne*.75+4+Be}else{let pe=re.route.slice(),Me=K.of(re.src,wn(pe,0,v[re.src])),Ae=K.of(re.dst,wn(pe,pe.length-3,v[re.dst]));for(let ge=0;ge<pe.length;ge+=3)pe[ge]+=c,pe[ge+1]+=c;B(pe,0,re.src),B(pe,pe.length-3,re.dst);let ce=y.get(ee);if(ce!==void 0&&pe.length>=6){let ge=v[ce],be=m[re.src].kind===10,Ie=be?0:pe.length-3,Re=(ge.dir==="TB"||ge.dir==="LR")===be,ze=_y(ge.dir)?[pe[Ie],ge.y+c+(Re?m[ce].titleH-ge.h/2:ge.h/2),0]:[ge.x+c+(Re?-ge.w/2:ge.w/2),pe[Ie+1],1];pe=be?ze.concat(pe):pe.concat(ze)}fe=jn(pe,void 0,0,Et(xe),Me,Ae)}if(ie+=`<g class="pele-edge ${oe?'pele-note-edge" stroke="var(--_b)" stroke-dasharray="3 4':"pele-transition"}" data-id="${Ge(de.id)}"><path d="${fe.d}"/>`+Ct(xe,fe.ex,fe.ey,fe.edx,fe.edy,"var(--_l)")+"</g>",ye.width>0){let pe=re.labelX+c,Me=re.labelY+c;le+=kn(de.id,ye,pe,Me,"",h)}}let ae=hb(e.title,s,a,c,_,M,(F?`<g class="pele-clusters">${F}</g>`:"")+(V?`<g class="pele-dividers" stroke-dasharray="4 4"${Wo}>${V}</g>`:"")+(ie?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${ie}</g>`:"")+(le?`<g class="pele-edge-labels" font-size="${l}">${le}</g>`:"")+`<g class="pele-nodes">${X}${Q}</g>`);return{svg:mt("state",ae.width,ae.height,a,r,e,ae.content),width:ae.width,height:ae.height,links:U}}function JN(e,t,r){let n=r.get(Math.round(e.y-e.h/2));if(n===void 0||t===0)return e.x;let i=e.x-e.w/2,a=t/2,l=e.x,s=-1;for(let o of[e.x,i+ma+a,i+e.w-ma-a]){let c=1/0;for(let h of n)h>i&&h<i+e.w&&(c=Math.min(c,Math.abs(h-o)-a));if(c>=6)return o;c>s+.5&&(s=c,l=o)}return l}var eR={type:"state",math:!0,parse(e,t,r){let n=new LN;return r&&(n.title=r),jN(e,n),n},render:QN},tR=34,rR=24,nR=8,iR=2e4,Sy=1e4,Pu=2e6,Cy=4,aR=3,Iy=8,zu=20,Ny=20,Ry=14,sR=3;function lR(e,t,r,n,i=rR){let a=e.length;if(a===0)return{width:0,height:0};let l=r==="LR"||r==="RL",s=r==="BT"||r==="RL",o=[];for(let z=a-1;z>=0;z--)e[z].parent<0&&e[z].isGroup&&o.push(z);let c=Math.max(1,o.length),h=new Int32Array(a).fill(-1);o.forEach((z,W)=>h[z]=W);let u=new Uint8Array(a);for(let z=0;z<a;z++)e[z].parent>=0&&(u[e[z].parent]=1);let d=new Float64Array(c).fill(i),p=i,g=z=>{let W=z,S=i;for(let $=0;e[W].parent>=0&&$<Sy;$++)W=e[W].parent,h[W]<0&&(S+=Math.max(e[W].padX,e[W].padTop,e[W].padBottom));let A=Math.max(0,h[W]);return S>d[A]&&(d[A]=S),S>p&&(p=S),A},m=new Int32Array(a).fill(-1),v=[];for(let z=0;z<a;z++)h[z]>=0||(!e[z].isGroup||!u[z])&&(m[z]=v.length,v.push(z));let x=z=>l?z.w:z.h,k=z=>l?z.h:z.w,b=v.map(z=>Is(k(e[z]),x(e[z]))),C=[],N=[],R=1;{let z=new Set;for(let W=0;W<t.length;W++){let S=t[W],A=m[S.src],$=m[S.dst];if(A<0||$<0||A===$)continue;let y=Math.min(A,$)*v.length+Math.max(A,$);(S.labelW>0||z.has(y))&&(R=2),z.add(y),C.push(Ns(A,$,S.minlen,l?S.labelH:S.labelW,l?S.labelW:S.labelH)),N.push(W)}}Qf(b,C),Jf(b,C,R);let O=C.length,P=Int32Array.from(v,g),H=(z,W)=>{let S=d.map((q,me)=>W[me]?Math.max(q,Ny):q),A=new Uint8Array(c),$=0,y=new Int32Array(O);for(let q=0;q<O;q++)y[q]=Math.abs(b[C[q].head].rank-b[C[q].tail].rank),z[q]||($+=y[q]-1);let E=$>iR,w=v.length+(E?0:$),T=new Int32Array(w),_=new Int32Array(w),M=new Float64Array(w),U=new Float64Array(w),j=new Uint8Array(w),Y=0;for(let q=0;q<v.length;q++)T[q]=b[q].rank,_[q]=P[q],M[q]=b[q].w,U[q]=b[q].h,T[q]>Y&&(Y=T[q]);let D=new Int32Array(O).fill(-1),L=new Int32Array(O).fill(-1),F=[];{let q=v.length;for(let me=0;me<O;me++){let se=C[me],ve=se.reversed?se.head:se.tail,_e=se.reversed?se.tail:se.head;if(E||y[me]<2||z[me]){F.push(ve,_e);continue}let Te=T[ve],Oe=T[_e],Ce=-1;se.labelW>0&&(Ce=Te+(Oe-Te>>1),R===2&&(Ce&1)===0&&Ce--),D[me]=q;let He=ve;for(let Ee=Te+1;Ee<Oe;Ee++){let Ye=q++;T[Ye]=Ee,_[Ye]=_[ve]+Math.round((_[_e]-_[ve])*(Ee-Te)/(Oe-Te)),j[Ye]=1,Ee===Ce&&(M[Ye]=se.labelW,U[Ye]=se.labelH,L[me]=Ye),F.push(He,Ye),He=Ye}F.push(He,_e)}}let V=new Int32Array(w+1),X=new Int32Array(w+1);for(let q=0;q<F.length;q+=2)X[F[q]+1]++,V[F[q+1]+1]++;for(let q=0;q<w;q++)V[q+1]+=V[q],X[q+1]+=X[q];let Q=new Int32Array(F.length/2),ne=new Int32Array(F.length/2);{let q=V.slice(0,w),me=X.slice(0,w);for(let se=0;se<F.length;se+=2)ne[me[F[se]]++]=F[se+1],Q[q[F[se+1]]++]=F[se]}let B=[];for(let q=0;q<=Y;q++)B.push([]);for(let q=0;q<w;q++)B[T[q]].push(q);let K=new Float64Array(w),ie=new Float64Array(w),le=q=>{q.sort((me,se)=>_[me]-_[se]||ie[me]-ie[se]||me-se);for(let me=0;me<q.length;me++)K[q[me]]=me};for(let q of B){for(let me=0;me<q.length;me++)ie[q[me]]=me;le(q)}for(let q=0;q<nR&&Y>0;q++){let me=(q&1)===0;for(let se=1;se<=Y;se++){let ve=B[me?se:Y-se],_e=me?V:X,Te=me?Q:ne;for(let Oe of ve){let Ce=0,He=_e[Oe+1]-_e[Oe];for(let Ee=_e[Oe];Ee<_e[Oe+1];Ee++)Ce+=K[Te[Ee]];ie[Oe]=He>0?Ce/He:K[Oe]}le(ve)}}let J=(q,me)=>j[q]||j[me]?n.edgeSep:n.nodeSep,te=(q,me)=>{let se=0;for(;se<q.length;){let ve=se;for(;ve+1<q.length&&_[q[ve+1]]===_[q[se]];)ve++;me(q,se,ve),se=ve+1}},ae=(q,me,se)=>{let ve=M[q[me]];for(let _e=me;_e<se;_e++)ve+=J(q[_e],q[_e+1])+M[q[_e+1]];return ve},ee=new Float64Array(c),re=o.length>0?tR:0;for(let q=0;q<o.length;q++){let me=e[o[q]];ee[q]=Math.max(0,me.minW-2*S[q]),me.padTop>re&&(re=me.padTop)}for(let q of B)te(q,(me,se,ve)=>{let _e=ae(q,se,ve);_e>ee[_[q[se]]]&&(ee[_[q[se]]]=_e)});let de=new Float64Array(c+1);for(let q=0;q<c;q++)de[q+1]=de[q]+ee[q]+2*S[q];let ye=new Float64Array(w),oe=new Float64Array(w),xe=(q,me,se)=>{let ve=_[q[me]],_e=(de[ve]+S[ve]+(de[ve+1]-S[ve])-ae(q,me,se))/2;for(let Te=me;Te<=se;Te++)ye[q[Te]]=_e+M[q[Te]]/2,Te<se&&(_e+=M[q[Te]]+J(q[Te],q[Te+1]))},fe=(q,me,se)=>{let ve=_[q[me]],_e=de[ve]+S[ve];for(let Oe=me;Oe<=se;Oe++){let Ce=q[Oe];ye[Ce]=Math.max(oe[Ce],_e+M[Ce]/2),Oe<se&&(_e=ye[Ce]+M[Ce]/2+J(Ce,q[Oe+1]))}let Te=de[ve+1]-S[ve];for(let Oe=se;Oe>=me;Oe--){let Ce=q[Oe];ye[Ce]=Math.min(ye[Ce],Te-M[Ce]/2),Oe>me&&(Te=ye[Ce]-M[Ce]/2-J(q[Oe-1],Ce))}};for(let q of B)te(q,xe);for(let q=0;q<4&&Y>0;q++){let me=(q&1)===0;for(let se=1;se<=Y;se++){let ve=B[me?se:Y-se],_e=me?V:X,Te=me?Q:ne;for(let Oe of ve){let Ce=0,He=0;for(let Ee=_e[Oe];Ee<_e[Oe+1];Ee++)_[Te[Ee]]===_[Oe]&&(Ce+=ye[Te[Ee]],He++);oe[Oe]=He>0?Ce/He:ye[Oe]}te(ve,fe)}}let pe=new Float64Array(Y+1),Me=new Float64Array(Y+1),Ae=new Float64Array(Y+1).fill(n.rankSep/R);if(z.some(q=>q===1)){let q=n.rankSep/R;Ae.fill(q/sR);for(let me=0;me<O;me++){let se=C[me],ve=se.reversed?se.head:se.tail,_e=se.reversed?se.tail:se.head;if(z[me]){if(se.labelH<=0||y[me]>R)continue;let Oe=Math.min(q,(se.labelH+2*zu-Math.min(U[ve],U[_e])/2)/y[me]);for(let Ce=T[ve];Ce<T[_e];Ce++)Oe>Ae[Ce]&&(Ae[Ce]=Oe);continue}let Te=D[me];if(Te<0||y[me]<=R*se.minlen){for(let Oe=T[ve];Oe<T[_e];Oe++)Ae[Oe]=q;continue}for(let Oe=Te-1;Oe<Te+y[me]-1;Oe++){let Ce=Oe<Te?ve:Oe,He=Oe+1<Te+y[me]-1?Oe+1:_e;(_[Ce]!==_[He]||Math.abs(ye[Ce]-ye[He])>=.5)&&(Ae[T[Ce]]=q)}}}let ce=re+p;for(let q=0;q<=Y;q++){let me=0;for(let se of B[q])U[se]>me&&(me=U[se]);pe[q]=ce,Me[q]=ce+me,ce+=me+(q===Y?0:Ae[q])}let ge=ce+p,be=de[c],Ie=q=>s?re+ge-q:q,Re=(q,me)=>l?Ie(me):q,ze=(q,me)=>l?q:Ie(me),he=l?1:0;for(let q=0;q<v.length;q++){let me=e[v[q]],se=(pe[T[q]]+Me[T[q]])/2;me.x=Re(ye[q],se),me.y=ze(ye[q],se)}for(let q=0;q<o.length;q++){let me=e[o[q]],se=(de[q]+de[q+1])/2,ve=de[q+1]-de[q];me.x=l?ge/2:se,me.y=l?se:ge/2,me.w=l?ge:ve,me.h=l?ve:ge,me.padTop=re}let $e=new Int32Array(a),Se=[];for(let q=0;q<a;q++){if(!e[q].isGroup||h[q]>=0||m[q]>=0)continue;let me=0;for(let se=e[q].parent;se>=0&&me<Sy;se=e[se].parent)me++;$e[q]=me,Se.push(q)}Se.sort((q,me)=>$e[me]-$e[q]||q-me);let we=new Float64Array(a*4);for(let q=0;q<a;q++)we[q*4]=1/0,we[q*4+1]=1/0,we[q*4+2]=-1/0,we[q*4+3]=-1/0;let ke=(q,me)=>{me.x-me.w/2<we[q*4]&&(we[q*4]=me.x-me.w/2),me.y-me.h/2<we[q*4+1]&&(we[q*4+1]=me.y-me.h/2),me.x+me.w/2>we[q*4+2]&&(we[q*4+2]=me.x+me.w/2),me.y+me.h/2>we[q*4+3]&&(we[q*4+3]=me.y+me.h/2)};for(let q of v)e[q].parent>=0&&h[e[q].parent]<0&&ke(e[q].parent,e[q]);for(let q of Se){let me=e[q];if(we[q*4]===1/0)continue;let se=Math.max(we[q*4+2]-we[q*4]+2*me.padX,me.minW);me.x=(we[q*4]+we[q*4+2])/2,me.w=se,me.y=(we[q*4+1]-me.padTop+we[q*4+3]+me.padBottom)/2,me.h=we[q*4+3]-we[q*4+1]+me.padTop+me.padBottom,me.parent>=0&&h[me.parent]<0&&ke(me.parent,me)}for(let q of t)q.route=[];for(let q=0;q<O;q++){let me=C[q],se=t[N[q]],ve=me.reversed?me.head:me.tail,_e=me.reversed?me.tail:me.head,Te=[ye[ve],Me[T[ve]]-(Me[T[ve]]-pe[T[ve]]-U[ve])/2],Oe=D[q];if(Oe>=0)for(let Ee=Oe;Ee<Oe+y[q]-1;Ee++)Te.push(ye[Ee],pe[T[Ee]]),Me[T[Ee]]>pe[T[Ee]]&&Te.push(ye[Ee],Me[T[Ee]]);Te.push(ye[_e],pe[T[_e]]+(Me[T[_e]]-pe[T[_e]]-U[_e])/2);let Ce=[];for(let Ee=0;Ee<Te.length;Ee+=2)Ce.push(Re(Te[Ee],Te[Ee+1]),ze(Te[Ee],Te[Ee+1]),he);if(me.reversed)for(let Ee=0,Ye=Ce.length-3;Ee<Ye;Ee+=3,Ye-=3)for(let qe=0;qe<2;qe++){let Qe=Ce[Ee+qe];Ce[Ee+qe]=Ce[Ye+qe],Ce[Ye+qe]=Qe}se.route=Ce;let He=L[q];if(He>=0){let Ee=(pe[T[He]]+Me[T[He]])/2;se.labelX=Re(ye[He],Ee),se.labelY=ze(ye[He],Ee)}else se.labelX=(Ce[0]+Ce[Ce.length-3])/2,se.labelY=(Ce[1]+Ce[Ce.length-2])/2}for(let q of t){if(q.route.length>0||q.src===q.dst)continue;let me=e[q.src],se=e[q.dst],[ve,_e]=Oy(me,se),[Te,Oe]=Oy(se,me),Ce=Math.abs(Te-ve)>Math.abs(Oe-_e)?1:0;q.route=[ve,_e,Ce,Te,Oe,Ce],q.labelX=(ve+Te)/2,q.labelY=(_e+Oe)/2}let Ne=new Uint8Array(O),Be=t.reduce((q,me)=>q+me.route.length/3,0),Pe=O*(v.length+t.length+Be);if(Pe<=Pu){let q=Ce=>(pe[T[Ce]]+Me[T[Ce]])/2,me=t.map(Ce=>[l?Ce.labelY:Ce.labelX,Ie(l?Ce.labelX:Ce.labelY)]),se=(Ce,He,Ee,Ye,qe,Qe,lt,Ze)=>Ee>qe-lt/2&&Ce<qe+lt/2&&Ye>Qe-Ze/2&&He<Qe+Ze/2,ve=(Ce,He,Ee,Ye,qe,Qe,lt)=>{for(let Ze=0;Ze<v.length;Ze++)if(Ze!==qe&&Ze!==Qe&&se(Ce,He,Ee,Ye,ye[Ze],q(Ze),M[Ze]+8,U[Ze]+8))return!1;for(let Ze=0;Ze<t.length;Ze++){let it=t[Ze];if(Ze!==lt&&it.labelW>0&&it.src!==it.dst&&se(Ce,He,Ee,Ye,me[Ze][0],me[Ze][1],l?it.labelH:it.labelW,l?it.labelW:it.labelH))return!1}return!0},_e=(Ce,He,Ee,Ye,qe)=>{let Qe=0;for(let lt=0;lt<t.length;lt++){if(lt===qe)continue;let Ze=t[lt].route;for(let it=3;it<Ze.length;it+=3)if(Math.max(Ze[it-3],Ze[it])>Ce&&Math.min(Ze[it-3],Ze[it])<Ee&&Math.max(Ze[it-2],Ze[it+1])>He&&Math.min(Ze[it-2],Ze[it+1])<Ye){Qe++;break}}return Qe},Te=(Ce,He,Ee)=>{let Ye=0;for(let qe=0;qe<t.length;qe++){let Qe=t[qe].route;if(qe===Ee||Qe.length===0)continue;let lt=Qe.length-3;(Math.abs(Qe[0]-Ce)<1&&Math.abs(Qe[1]-He)<1||Math.abs(Qe[lt]-Ce)<1&&Math.abs(Qe[lt+1]-He)<1)&&Ye++}return Ye},Oe=(Ce,He,Ee,Ye,qe)=>{let Qe=Math.abs(Ee-Ce)<.5,lt=Qe?Math.min(He,Ye):Math.min(Ce,Ee),Ze=Qe?Math.max(He,Ye):Math.max(Ce,Ee),it=Qe?Ce:He;for(let rt=0;rt<t.length;rt++){let wt=t[rt];if(rt===qe||wt.src===t[qe].src||wt.dst===t[qe].dst)continue;let je=wt.route;for(let Ue=3;Ue<je.length;Ue+=3){let ot=je[Ue-3+(Qe?0:1)],Fe=je[Ue+(Qe?0:1)];if(Math.abs(ot-it)>=Cy||Math.abs(Fe-it)>=Cy)continue;let at=je[Ue-3+(Qe?1:0)],ct=je[Ue+(Qe?1:0)];if(Math.min(Ze,Math.max(at,ct))-Math.max(lt,Math.min(at,ct))>1)return!0}}return!1};for(let Ce=0;Ce<O;Ce++){let He=C[Ce],Ee=N[Ce],Ye=t[Ee],qe=He.tail,Qe=He.head;if(_[qe]===_[Qe]||Math.abs(ye[Qe]-ye[qe])<1)continue;let lt=ye[qe],Ze=ye[Qe],it=q(qe),rt=q(Qe),wt=Math.sign(Ze-lt),je=Math.sign(rt-it),Ue=(Fe,at)=>{for(let Ke=2;Ke<Fe.length;Ke+=2)if(!ve(Math.min(Fe[Ke-2],Fe[Ke])-at,Math.min(Fe[Ke-1],Fe[Ke+1])-at,Math.max(Fe[Ke-2],Fe[Ke])+at,Math.max(Fe[Ke-1],Fe[Ke+1])+at,qe,Qe,Ee)||Oe(Re(Fe[Ke-2],Fe[Ke-1]),ze(Fe[Ke-2],Fe[Ke-1]),Re(Fe[Ke],Fe[Ke+1]),ze(Fe[Ke],Fe[Ke+1]),Ee))return!1;let ct=0,st=0,Tt=-1;if(Ye.labelW>0){let Ke=He.labelW,dt=He.labelH;for(let yt=2;yt<Fe.length;yt+=2){let $t=(Fe[yt-2]+Fe[yt])/2,Dt=(Fe[yt-1]+Fe[yt+1])/2,hr=Math.abs(Fe[yt]-Fe[yt-2]),Ar=Math.abs(Fe[yt+1]-Fe[yt-1]),ja=hr+Ar;if(ja<=Tt||(hr>0?hr<Ke+8:Ar<dt+8)||$t-Ke/2<0||$t+Ke/2>be||Dt-dt/2<0||Dt+dt/2>ge||!ve($t-Ke/2,Dt-dt/2,$t+Ke/2,Dt+dt/2,-1,-1,Ee))continue;let Ua=Re($t,Dt),Ya=ze($t,Dt);_e(Ua-Ye.labelW/2,Ya-Ye.labelH/2,Ua+Ye.labelW/2,Ya+Ye.labelH/2,Ee)>0||(ct=$t,st=Dt,Tt=ja)}if(Tt<0)return!1}let ht=[Fe[0],Fe[1]];for(let Ke=2;Ke<Fe.length;Ke+=2){let dt=Fe[Ke]-Fe[Ke-2],yt=Fe[Ke+1]-Fe[Ke-1],$t=Math.abs(dt)+Math.abs(yt),Dt=Ke>2?zu:0,hr=Ke+2<Fe.length?zu:0;$t>Dt+hr+1&&(Dt&&ht.push(Fe[Ke-2]+dt/$t*Dt,Fe[Ke-1]+yt/$t*Dt),hr&&ht.push(Fe[Ke]-dt/$t*hr,Fe[Ke+1]-yt/$t*hr)),ht.push(Fe[Ke],Fe[Ke+1])}Ye.route=[];for(let Ke=0;Ke<ht.length;Ke+=2){let dt=Ke===0?ht[0]!==ht[2]:ht[Ke]!==ht[Ke-2];Ye.route.push(Re(ht[Ke],ht[Ke+1]),ze(ht[Ke],ht[Ke+1]),dt?1-he:he)}return Ye.labelW>0&&(Ye.labelX=Re(ct,st),Ye.labelY=ze(ct,st),me[Ee]=[ct,st]),Ne[Ce]=1,!0};if(Ue([lt+wt*M[qe]/2,it,Ze,it,Ze,rt-je*U[Qe]/2],2)||Ue([lt,it+je*U[qe]/2,lt,rt,Ze-wt*M[Qe]/2,rt],2)||Pe>Pu/Iy)continue;let ot=[];for(let Fe of _[qe]<_[Qe]?[_[Qe],_[qe]]:[_[qe],_[Qe]]){let at=Math.max(S[Fe]-Ry,Math.min(S[Fe]/2,Ny-Ry));for(let ct of[de[Fe]+at,de[Fe+1]-at]){if(Math.abs(ct-lt)<M[qe]/2+4||Math.abs(ct-Ze)<M[Qe]/2+4)continue;let st=[lt+Math.sign(ct-lt)*M[qe]/2,it,ct,it,ct,rt,Ze+Math.sign(ct-Ze)*M[Qe]/2,rt],Tt=(Te(Re(st[0],st[1]),ze(st[0],st[1]),Ee)+Te(Re(st[6],st[7]),ze(st[6],st[7]),Ee))*1e6;for(let ht=2;ht<st.length;ht+=2){let Ke=Re(st[ht-2],st[ht-1]),dt=ze(st[ht-2],st[ht-1]),yt=Re(st[ht],st[ht+1]),$t=ze(st[ht],st[ht+1]);Tt+=_e(Math.min(Ke,yt),Math.min(dt,$t),Math.max(Ke,yt),Math.max(dt,$t),Ee)*1e6+Math.abs(yt-Ke)+Math.abs($t-dt)}ot.push({pts:st,cost:Tt,lane:Fe})}}ot.sort((Fe,at)=>Fe.cost-at.cost);for(let Fe of ot)if(Ue(Fe.pts,1)){A[Fe.lane]=1;break}}}return{width:l?ge:be,height:l?be:ge,routed:Ne,margins:A,work:Pe}},I=new Uint8Array(O),G=new Uint8Array(c),Z=H(I,G);for(let z=0;z<aR&&Z.work<=Pu/Iy;z++){let W=z===0?Z.routed:I.map((S,A)=>S&Z.routed[A]);if(W.every((S,A)=>S===I[A])&&Z.margins.every((S,A)=>S===G[A]))break;I=W,G=Z.margins,Z=H(I,G)}return I.some((z,W)=>z&&!Z.routed[W])&&(Z=H(new Uint8Array(O),new Uint8Array(c))),{width:Z.width,height:Z.height}}function Oy(e,t){let r=t.x-e.x,n=t.y-e.y,i=Math.max(e.w/2,.5),a=Math.max(e.h/2,.5);if(Math.abs(r)<i&&Math.abs(n)<a){let s=i-Math.abs(r),o=a-Math.abs(n);return s<o?[e.x+(r<0?-i:i),t.y]:[t.x,e.y+(n<0?-a:a)]}let l=Math.min(r!==0?i/Math.abs(r):1/0,n!==0?a/Math.abs(n):1/0);return[e.x+r*l,e.y+n*l]}var Ly="__swimlane_default__";function oR(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=Ly);e.nodes.push({id:Ly,label:void 0,labelType:"text",shape:"rect",isGroup:!0,parentId:void 0,cssStyles:[],cssCompiledStyles:[],cssClasses:"",dir:void 0})}}function cR(e,t,r,n,i,a,l){let s=e.x-e.w/2,o=e.y-e.h/2,c=a==="LR"||a==="RL",h=c?s+e.padTop/2:e.x,u=c?e.y:o+e.padTop/2,d=Le(t,h,u,` class="pele-cluster-label" fill="var(--_m)"${r.text}`,l);return`<g class="pele-cluster pele-lane${n}" data-id="${i}"><rect x="${f(s)}" y="${f(o)}" width="${f(e.w)}" height="${f(e.h)}" fill="none" stroke="var(--_b)"/><rect x="${f(s)}" y="${f(o)}" width="${f(c?e.padTop:e.w)}" height="${f(c?e.h:e.padTop)}" fill="var(--_a)" stroke="var(--_b)"${r.shape}/>`+(c&&d?`<g transform="rotate(-90 ${f(h)} ${f(u)})">${d}</g>`:d)+"</g>"}var dR={type:"swimlane",prepare:oR,layout:(e,t,r,n,i)=>lR(e,t,r,n,i?12:void 0),drawGroup:cR},hR={type:"swimlane",math:!0,parse:Mb.parse,render:(e,t,r)=>kb(e,t,r,dR)},uR=class{type="timeline";title;accTitle;accDescr;direction="LR";sections=[];periods=[];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,`
136
+ `)}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)}},fR=["$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"];function pR(e){let t=e.length,r=[],n=[],i=[],a={types:r,texts:n,starts:i},l=0,s=(o,c)=>{r.push(o),n.push(e.slice(l,c)),i.push(l),l=c};for(;l=Lb(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(Zr(e,l,"timeline")){for(c=l+8;e.charCodeAt(c)===32||e.charCodeAt(c)===9;)c++;let h=Zr(e,c,"lr");if(c>l+8&&(h||Zr(e,c,"td"))&&!nt(e.charCodeAt(c+2))){s(h?5:6,c+2);continue}if(!nt(e.charCodeAt(l+8))){s(4,l+8);continue}}if(Zr(e,l,"title")&&Xe(e.charCodeAt(l+5))&&l+6<t&&e.charCodeAt(l+6)!==10){s(7,Zs(e,l+6));continue}if(c=Db(e,l,a,8),c!==l){l=c;continue}if(Zr(e,l,"section")&&Xe(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 h=e.charCodeAt(c);c<t&&h!==35&&h!==58&&h!==10;h=e.charCodeAt(++c));s(14,c);continue}if(Xe(e.charCodeAt(l+1))){for(c=l+2;c<t;c++){let h=e.charCodeAt(c);if(h===10||h===58&&Xe(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),a}var gR="'EOF', 'SPACE', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'period', 'event'";function mR(e,t){let{types:r,texts:n,starts:i}=pR(e),a=(s,o)=>{let c=r[s]===0?"1":fR[r[s]];throw vt("timeline",e,i[s],`Expecting ${o}, got '${c}'`)},l=r[0];l!==4&&l!==5&&l!==6&&a(0,"'timeline', 'timeline_lr', 'timeline_td'"),l!==4&&t.setDirection(l===5?"LR":"TD");for(let s=1;;s++){let o=n[s];switch(r[s]){case 3:break;case 7:t.getCommonDb().setDiagramTitle(o.substring(6));break;case 8:t.getCommonDb().setAccTitle(n[++s].trim());break;case 10:t.getCommonDb().setAccDescription(n[++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:a(s,gR)}}}var jo=12,Dy=8,yR=152,xR=216,bR=264,hi=20,sa=20,Uo=14,Es=8,Fu=8,Yo=12,Py=' fill="var(--_bg)"',zy=' fill="none" stroke="var(--_b)"';function Wu(e,t,r,n,i){return`<rect x="${f(e)}" y="${f(t)}" width="${f(r)}" height="${f(n)}"${_t(i)}/>`}function wR(e,t,r){return e.direction==="TD"?Fy(e,t,r,!0):dr(r,n=>Fy(e,t,r,n))}function Fy(e,t,r,n){let i=r.fontSize??16,a=Math.round(i*.875),l=r.measurer??bt(r.fontFamily),s=r.padding??8,o=t.timeline?.disableMulticolor!==!0,c=e.periods,h=e.sections.length>0,u=e.sections.map((K,ie)=>({section:ie,periods:[]})),d={section:-1,periods:[]};c.forEach((K,ie)=>(u[K.sectionIndex]??d).periods.push(ie)),d.periods.length>0&&u.unshift(d);let p=n&&r.maxWidth!==void 0&&r.maxWidth>0?r.maxWidth-2*s:1/0,g=sa+Uo*2+4*jo,m=Math.min(yR,Math.max(80,Math.round((p-g)*.38))),v=Math.min(bR,Math.max(110,p-g-m)),x=m,k=()=>n?v:x,b=c.map(K=>Hn(K.text,l,i,x)),C=c.map(K=>K.events.map(ie=>Hn(ie,l,a,k()))),N=0;for(let K of b)N=Math.max(N,K.width);if(!n)for(let K of C)for(let ie of K)N=Math.max(N,ie.width);let R=N>x;if(n)for(let K of C)for(let ie of K)R||=ie.width>v;R&&(x=Math.min(Math.max(Math.ceil(N),m),p===1/0?xR:m),b=c.map(K=>wr(K.text,l,i,x)),C=c.map(K=>K.events.map(ie=>wr(ie,l,a,k()))));let O=Math.round(i*1.5),P=x+2*jo,H=k()+2*jo,I=K=>Math.max(K.height,O)+2*Dy,G=K=>Math.max(K.height,Math.round(a*1.5))+2*Dy,Z=(K,ie)=>K.section>=0?kt(K.section):h?"var(--_m)":kt(o?ie:0),z=!1;for(let K of C)K.length>0&&(z=!0);let W=0;for(let K of u)W+=Math.max(K.periods.length,1);let S=P+hi,A=c.length>0,$=n?P+(z?sa+Uo*2+H:A?sa+Yo:0):W>0?W*S-hi+(A?Yo+Rt:0):0,y=wr(e.title,l,i,Math.max($,320),1),E=y.height>0?y.height+16:0,w=Math.max($,y.width),T=s+(w-$)/2,_=s+E,M=(K,ie)=>wr(e.sections[K.section],l,i,ie-2*jo,1),U=(K,ie,le,J,te,ae)=>Wu(le,J,te,ae,` fill="${kt(K.section)}"`)+Le(ie,le+te/2,J+ae/2,' font-weight="var(--_hw)"'+Py),j=(K,ie,le,J,te)=>Wu(le,J,P,te,` fill="${ie}"`)+Le(b[K],le+P/2,J+te/2,Py),Y=(K,ie,le,J,te)=>'<g class="pele-node pele-event">'+Wu(le,J,H,te,` fill="${ie}" fill-opacity="0.16"`)+Le(K,le+H/2,J+te/2,` font-size="${a}"`)+"</g>",D=(K,ie,le)=>`<circle class="pele-dot" cx="${f(K)}" cy="${f(ie)}" r="4" fill="${le}" stroke="var(--_bg)" stroke-width="2"/>`,L=K=>K.section>=0?`<g class="pele-cluster pele-section" data-id="${Ge(e.sections[K.section].trim())}">`:"",F=K=>`<g class="pele-node pele-period" data-id="${Ge(c[K].text.trim())}">`,V="",X;if(n){let K=T+P+sa,ie=K+Uo,le=ie+Uo,J=_;for(let te of u){if(V+=L(te),te.section>=0){let ae=M(te,$),ee=I(ae);V+=U(te,ae,T,J,$,ee),J+=ee+Fu+4}for(let ae of te.periods){let ee=Z(te,ae),re=I(b[ae]),de=C[ae].length>0?G(C[ae][0]):re,ye=J+Math.max(re,de)/2,oe=`M${f(T+P)},${f(ye)}H${f(K)}`,xe="",fe=ye-de/2,pe=ye;for(let Me of C[ae]){let Ae=G(Me);pe=fe+Ae/2,oe+=`M${f(ie)},${f(pe)}H${f(le)}`,xe+=Y(Me,ee,le,fe,Ae),fe+=Ae+Es}xe&&(oe+=`M${f(K)},${f(ye)}H${f(ie)}V${f(pe)}`),V+=F(ae)+j(ae,ee,T,ye-re/2,re)+`<path class="pele-edge" d="${oe}"${zy}/>`+D(K,ye,ee)+xe+"</g>",J=Math.max(ye+re/2,fe-Es)+hi}te.periods.length===0&&(J+=hi-Fu-4),te.section>=0&&(V+="</g>")}if(u.length>0&&(J-=hi),A){let te=J+Yo+Rt;V=`<path class="pele-axis" d="M${f(K)},${f(_)}V${f(te-Rt+1)}" fill="none" stroke="var(--_l)"/>`+Ct("arrow_point",K,te,0,1,"var(--_l)")+V,J=te}X=J+s}else{let K=0,ie=u.map(de=>{if(de.section<0)return;let ye=M(de,Math.max(de.periods.length,1)*S-hi);return K=Math.max(K,I(ye)),ye}),le=0;for(let de of b)le=Math.max(le,I(de));let J=_+(h?K+Fu:0),te=J+le+(le>0?sa:0),ae=te+sa,ee=A?te+Yo:_+K,re=0;if(u.forEach((de,ye)=>{let oe=Math.max(de.periods.length,1),xe=T+re*S;V+=L(de);let fe=ie[ye];fe&&(V+=U(de,fe,xe,_,oe*S-hi,K)),de.periods.forEach((pe,Me)=>{let Ae=Z(de,pe),ce=xe+Me*S,ge=ce+P/2,be=`M${f(ge)},${f(J+le)}V${f(C[pe].length>0?ae:te)}`,Ie="",Re=ae;for(let ze of C[pe]){let he=G(ze);Re>ae&&(be+=`M${f(ge)},${f(Re-Es)}V${f(Re)}`),Ie+=Y(ze,Ae,ce,Re,he),Re+=he+Es}ee=Math.max(ee,Re-Es),V+=F(pe)+j(pe,Ae,ce,J,le)+`<path class="pele-edge" d="${be}"${zy}/>`+D(ge,te,Ae)+Ie+"</g>"}),de.section>=0&&(V+="</g>"),re+=oe}),A){let de=T+$;V=`<path class="pele-axis" d="M${f(T)},${f(te)}H${f(de-Rt+1)}" fill="none" stroke="var(--_l)"/>`+Ct("arrow_point",de,te,1,0,"var(--_l)")+V}X=ee+s}let Q=Math.ceil(w+2*s),ne=Math.ceil(Math.max(X,s*2)),B=Le(y,Q/2,s+y.height/2,' class="pele-title" font-weight="var(--_tw)"')+V;return{svg:mt("timeline",Q,ne,i,r,e,B),width:Q,height:ne,links:[]}}var vR={type:"timeline",parse(e,t,r){let n=new uR;return n.title=r,mR(e,n),n},render:wR},Wf=/[─━│┃└┗├┣]/,r2=/[└┗├┣]/,$R=/[─━]/,Wy=/^[\s│┃]+$/,kR=/^[\s─━│┃└┗├┣]+$/,MR=/^\s*(title[\t ]|accTitle[\t ]*:|accDescr[\t ]*[:{])/,_R=/^\s*%%/,ER=" ";function AR(e){return e.some(t=>Wf.test(t))}function TR(e){for(let t of e){let r=r2.exec(t);if(r?.index&&r.index>0)return r.index}return 4}function By(e,t){return e.replace(/\bline\s+(\d+)\b/gi,(r,n)=>{let i=t.get(parseInt(n,10));return i?`line ${i}`:r})}function Hy(e,t){throw new Je(`Line ${e}: ${t}`,"syntax",{type:"treeView",line:e})}function SR(e){let t=new Map;if(!Wf.test(e))return{text:e,lineMap:t};let r=e.split(`
137
+ `),n=-1;for(let c=0;c<r.length;c++)if(r[c].trim()==="treeView-beta"){n=c;break}if(n===-1)return{text:e,lineMap:t};let i=c=>c.trim()===""||_R.test(c)||MR.test(c),a=[];for(let c=n+1;c<r.length;c++){let h=r[c];i(h)||Wy.test(h)||a.push(h.replace(/\t/g," "))}if(!AR(a))return{text:e,lineMap:t};let l=TR(a),s=[],o=(c,h)=>{s.push(c),t.set(s.length,h+1)};for(let c=0;c<=n;c++)o(r[c],c);for(let c=n+1;c<r.length;c++){let h=r[c];if(i(h)){o(h,c);continue}if(Wy.test(h))continue;let u=h.replace(/\t/g," "),d=r2.exec(u);if(d){let p=Math.round(d.index/l)+1,g=d.index+1;for(;g<u.length&&$R.test(u[g]);)g++;for(;g<u.length&&u[g]===" ";)g++;let m=u.slice(g).trimEnd();m||Hy(c+1,"Empty node — expected a filename or directory name after the box-drawing prefix"),o(ER.repeat(p)+m,c)}else{if(kR.test(u))continue;Wf.test(u)?o(h,c):/^\s+/.test(u)?Hy(c+1,"Unexpected indentation without box-drawing characters. In box-drawing format, use ├── or └── prefixes for indented nodes."):o(h,c)}}return{text:s.join(`
138
+ `),lineMap:t}}function CR(e,t){if(e.startsWith("##",t)||e.startsWith("icon(",t))return!0;if(!e.startsWith(":::",t))return!1;let r=t+3;for(;Kr(e.charCodeAt(r));)r++;let n=e.charCodeAt(r);return n>=65&&n<=90||n>=97&&n<=122||n===95}function IR(e,t){let r=e.charCodeAt(t);if(Kr(r)||r===10||r===13||r===34||r===39||e.startsWith(":::",t)||e.startsWith("icon(",t)||e.startsWith("##",t))return-1;let n=e.length,i=t+1;for(;i<n;){let a=e.charCodeAt(i);if(a===10||a===13)break;if(Kr(a)){let l=i+1;for(;Kr(e.charCodeAt(l));)l++;if(CR(e,l))break;i=l}else i++}return i}var jy={name:"BARE_NAME",pattern:/(?!:::|icon\(|##)[^ \t\n\r"'](?:(?![ \t]+:::[ \t]*[A-Za-z_]|[ \t]+icon\(|[ \t]+##)[^\n\r])*/y,match:IR},Uy=[{...zr("treeView-beta"),longer:[jy]},lp(),Wr,Br,{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},jy];function n2(e){let t=e.length;for(;t>0&&Kr(e.charCodeAt(t-1));)t--;return t===e.length?e:e.slice(0,t)}function Bu(e,t){switch(e){case"INDENTATION":return t?.length||0;case"QUOTED_NAME":return t.substring(1,t.length-1);case"BARE_NAME":return n2(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 NR(e){let t=new Er($r(e,Uy,"treeView"),Uy,"treeView"),r={$type:"TreeView",nodes:[]};for(t.expect(0);;)if(t.kind===1)r.accDescr=_r(t.take());else if(t.kind===2)r.accTitle=Mr(t.take());else if(t.kind===3)r.title=kr(t.take());else break;for(;t.kind!==-1;){let n={$type:"TreeNode",name:""};if(t.kind===7&&(n.indent=t.take().length),t.kind===8){let i=t.take();n.name=i.substring(1,i.length-1)}else t.kind===12?n.name=n2(t.take()):t.fail("a name");for(;;)if(t.kind===4)n.classAnnotation=Bu("CLASS_ANNOTATION",t.take());else if(t.kind===5)n.iconAnnotation=Bu("ICON_ANNOTATION",t.take());else if(t.kind===6)n.descAnnotation=Bu("DESC_ANNOTATION",t.take());else break;r.nodes.push(n)}return r}var RR=class{count=1;root={id:0,level:-1,name:"/",nodeType:"directory",children:[]};stack=[this.root];addNode(e,t,r,n,i,a){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:n,description:a,children:[]};l[l.length-1].children.push(s),l.push(s)}};function OR(e,t){for(let r of e.nodes){let n=typeof r.indent=="number"?r.indent:0,i=r.name,a=i.endsWith("/");a&&(i=i.slice(0,-1));let l=r.iconAnnotation;t.addNode(n,i,a?"directory":"file",r.classAnnotation||void 0,l!==void 0?l||"none":void 0,r.descAnnotation||void 0)}}function LR(e){let{text:t,lineMap:r}=SR(e);try{return NR(t)}catch(n){if(r.size===0||!(n instanceof Je))throw n;let i=n.message.indexOf(`
139
+ `),a=i===-1?By(n.message,r):By(n.message.slice(0,i),r)+n.message.slice(i);throw new Je(a,n.code,{type:n.type,line:r.get(n.line)??n.line,column:n.column,snippet:n.snippet})}}function DR(e,t){let r=new RR;return OR(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,`
140
+ `):void 0,root:r.root,count:r.count}}var Uc="mermaid-treeview",Bf=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"]]);function Hu(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 PR(e,t){let r=Hu(t?.filenameIcons,e);if(r)return r;let n=e.lastIndexOf(".");if(n>0){let i=e.substring(n).toLowerCase();return Hu(t?.extensionIcons,i)??Hu(t?.extensionIcons,i.slice(1))}}function Yy(e,t){return e.includes(":")?e:Bf.has(e)||!t?`${Uc}:${e}`:`${t}:${e}`}function Gy(e,t){if(e.icon!=="none"){if(e.icon)return Yy(e.icon,t.defaultIconPack);if(t.showIcons){if(e.nodeType==="file"){let r=PR(e.name,t);if(r==="none")return;if(r)return Yy(r,t.defaultIconPack)}return`${Uc}:${e.nodeType==="directory"?"folder":"file"}`}}}function zR(e){let t=n=>typeof n=="object"&&n!==null&&!Array.isArray(n)?n: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)}}var FR=6,WR=16,BR=7,HR=4,Go=4;function Vo(e,t,r,n,i){let a=e.treeView?.[t];return typeof a=="number"&&a>=n&&a<=i?a:r}function jR(e){return{paddingX:Vo(e,"paddingX",5,0,100),paddingY:Vo(e,"paddingY",2,0,100),rowIndent:Vo(e,"rowIndent",15,0,400),lineThickness:Vo(e,"lineThickness",1,.25,12)}}function UR(e,t,r){return Yn(r,n=>YR(e,t,r,n))}function YR(e,t,r,n){let i=r.fontSize??16,a=r.measurer??bt(r.fontFamily),l=r.padding??8,s=zR(t),{paddingX:o,paddingY:c,rowIndent:h,lineThickness:u}=jR(t),d=0,p=e.root.children.map(T=>[T,0]);for(let T=0;n&&T<p.length;T++){let[_,M]=p[T];d=Math.max(d,M);for(let U of _.children)p.push([U,M+1])}let g=n?Math.min(h+o,Math.max(2,((r.maxWidth??320)-120)/Math.max(1,d))):h+o,m=Math.round(i*1.5)+2*c,v=i,x=Ve(e.title,!1,a,i,n?Xt(r):4e3,1),k=x.height>0?x.height+12:0,b=T=>T.some(_=>Gy(_,s)!==void 0),C=[],N=new Map,R=[],O=(T,_)=>{let M=b(T);for(let U=T.length-1;U>=0;U--)R.push([T[U],_,M])};O(e.root.children,0);let P=0,H=!1,I=0;for(;R.length>0;){let[T,_,M]=R.pop(),U=_*g,j=It(T.name),Y=U+(M?v+FR:0),D=Math.max(40,(r.maxWidth??320)-2*l-2*Go-Y),L=n?Rc(j,a,i,D,T.nodeType==="directory"?1:0):void 0,F=n&&T.description?Rc(It(T.description),a,i,D,2):void 0,V=L?L.width:a.width(j,i,T.nodeType==="directory"?1:0);Y+V>P&&(P=Y+V);let X=T.cssClass!==void 0&&T.cssClass.split(/\s+/).includes("highlight");X&&(H=!0);let Q=n?Math.max(m,(L?.height??0)+(F?.height??0)+2*c):m,ne=I+(n?c+Math.max(v,L?.height??0)/2:Q/2),B={node:T,x:U,cy:ne,icon:Gy(T,s),text:j,labelX:Y,highlighted:X,label:L,description:F,top:I,height:Q};I+=Q,C.push(B),N.set(T,B),O(T.children,_+1)}let G=P+WR,Z=P;for(let T of C){let _=T.node.description;if(!_)continue;let M=T.description?T.description.width:a.width(It(_),i,2);Z=Math.max(Z,(n?T.labelX:G)+M)}Z=Math.max(Z,x.width);let z=l+(H?Go:0),W=l+k,S=Math.ceil(Z+2*z),A=Math.ceil(W+I+l),$="";for(let T of C){let _=T.node.children;if(_.length===0)continue;let M=z+T.x+BR,U=Math.max(M,z+T.x+g-o),j=W+N.get(_[_.length-1]).cy,Y=Math.min(HR,U-M),D=`M${f(M)},${f(W+T.top+T.height-2)}V${f(j-Y)}`;Y>0&&(D+=`Q${f(M)},${f(j)} ${f(M+Y)},${f(j)}H${f(U)}`);for(let L=0;L<_.length-1&&U>M;L++)D+=`M${f(M)},${f(W+N.get(_[L]).cy)}H${f(U)}`;$+=`<path d="${D}"/>`}let y=i*.35,E="";for(let T of C){let _=T.node,M=W+T.cy,U=_.nodeType==="directory",j="";if(T.highlighted){let Y=z+T.x-Go;j+=`<rect class="pele-tree-highlight" x="${f(Y)}" y="${f(W+T.top+1)}" width="${f(S-z+Go-Y)}" height="${f(T.height-2)}" fill="var(--_c)" fill-opacity="0.14"${xt}/>`}if(T.icon!==void 0){let Y=T.icon.startsWith(Uc+":")?T.icon.slice(Uc.length+1):"",D=Bf.get(Y)??Bf.get(U?"folder":"file"),L=r.icons?.(T.icon)??`<path d="${D}" stroke="var(--_m)" stroke-width="1.5"/>`;j+=`<svg class="pele-icon" data-icon="${Ge(T.icon)}" x="${f(z+T.x)}" y="${f(M-v/2)}" width="${f(v)}" height="${f(v)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${L}</svg>`}T.label?j+=ba(T.label,z+T.labelX,W+T.top+c,` class="pele-label"${U?' font-weight="var(--_hw)"':""}`):T.text!==""&&(j+=`<text class="pele-label" x="${f(z+T.labelX)}" y="${f(M+y)}"${U?' font-weight="var(--_hw)"':""} xml:space="preserve">${tt(T.text)}</text>`),T.description?j+=ba(T.description,z+T.labelX,W+T.top+c+(T.label?.height??0),' class="pele-tree-description" font-style="italic" fill="var(--_m)"'):_.description&&(j+=`<text class="pele-tree-description" x="${f(z+G)}" y="${f(M+y)}" font-style="italic" fill="var(--_m)" xml:space="preserve">${tt(It(_.description))}</text>`),E+=`<g class="pele-node pele-tree-${U?"dir":"file"}${jt(_.cssClass??"")}" data-id="${Ge(_.name)}">${j}</g>`}let w=Le(x,S/2,l+x.height/2,' class="pele-title" font-weight="var(--_tw)"')+($?`<g class="pele-tree-guides" fill="none" stroke="var(--_b)" stroke-width="${f(u)}">${$}</g>`:"")+E;return{svg:mt("treeView",S,A,i,r,e,w),width:S,height:A,links:[]}}var GR={type:"treeView",parse:(e,t,r)=>DR(LR(e),r),render:UR};function VR(e){let t=[],r=[];for(let n of e){let i=n.type==="Leaf",a={name:n.name,children:i?void 0:[]};for(a.classSelector=n.classSelector,n.cssCompiledStyles&&(a.cssCompiledStyles=n.cssCompiledStyles),i&&n.value!==void 0&&(a.value=n.value);r.length>0&&r[r.length-1].level>=n.level;)r.pop();r.length===0?t.push(a):r[r.length-1].node.children.push(a),i||r.push({node:a,level:n.level})}return t}function qR(e,t){let r=new Map;for(let i of e.TreemapRows){if(i.$type!=="ClassDefStatement")continue;let a=r.get(i.className);a||r.set(i.className,a=[]);let l=(i.styleText??"").replace(/\\,/g,"§§§").replace(/,/g,";").replace(/§§§/g,",");for(let s of l.split(";"))a.push(s)}let n=[];for(let i of e.TreemapRows){if(i.$type!=="TreemapRow")continue;let a=i.item,l=a.classSelector?r.get(a.classSelector):void 0;n.push({level:i.indent??0,name:a.name,type:a.$type,value:a.$type==="Leaf"?a.value:void 0,classSelector:a.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,`
141
+ `):void 0,roots:VR(n),classes:r}}var Vy=[nn,Wr,Br,{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}],XR=/classDef\s+([A-Z_a-z]\w+)(?:\s+([^\n\r;]*))?;?/;function KR(e){let t=new Er($r(e,Vy,"treemap"),Vy,"treemap"),r=t.kinds,n={$type:"Treemap",TreemapRows:[]},i=()=>t.accept(5)?t.expect(12):void 0;for(t.expect(3);t.kind!==-1;){let a=t.kind;if(a===0){n.accDescr=_r(t.take());continue}if(a===1){n.accTitle=Mr(t.take());continue}if(a===2){n.title=kr(t.take());continue}a!==8&&a!==14&&a!==4&&t.fail("a node, a class definition, or a title");let l=a===8?t.take().length:void 0;if(t.kind===4){let d=XR.exec(t.take()),p={$type:"ClassDefStatement",className:d[1]};d[2]&&(p.styleText=d[2]),l!==void 0&&(p.indent=l),n.TreemapRows.push(p);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 h=i();h!==void 0&&(c.classSelector=h);let u={$type:"TreemapRow",item:c};l!==void 0&&(u.indent=l),n.TreemapRows.push(u)}return n}var qy=/^(?:.?[<>=^])?([-+( ])?(\$)?0?\d*(,)?(?:\.(\d+))?(~)?([a-zA-Z%])?$/;function Xy(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 ZR(e){let t=qy.exec(e==="$0,0"?"$,":e)??qy.exec(","),r=t[1]==="+",n=t[3]!==void 0,i=t[4]===void 0?void 0:Math.min(Number(t[4]),20),a=t[6]??"";return l=>{let s=Math.abs(l),o,c="";if(a==="f"?o=s.toFixed(i??6):a==="%"?(o=(s*100).toFixed(i??6),c="%"):a==="d"?o=Math.round(s).toFixed(0):a==="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+$/,"")),n&&!o.includes("e")){let h=o.indexOf(".");o=h===-1?Xy(o):Xy(o.slice(0,h))+o.slice(h)}return(l<0?"-":r?"+":"")+(t[2]??"")+o+c}}function Ky(e,t,r){let n=e.children===void 0&&Number.isFinite(e.value)&&e.value>0?e.value:0;return{node:e,parent:t,series:r,value:n,children:[],x:0,y:0,w:0,h:0}}function QR(e,t,r,n,i,a,l){let s=t,o=0;for(;o<e.length;){let c=i*a/s,h=Math.min(i,a),u=e[o].value*c,d=u,p=Math.max(h*h*d/(u*u),u*u/(h*h*d)),g=o+1;for(;g<e.length;){let x=e[g].value*c,k=u+x,b=Math.max(h*h*d/(k*k),k*k/(h*h*x));if(b>p)break;p=b,u=k,g++}let m=u/h,v=0;for(let x=o;x<g;x++){let k=e[x],b=x===g-1?h-v:k.value*c/m,C=i>=a?r:r+v,N=i>=a?n+v:n,R=Math.round(C+l/2),O=Math.round(N+l/2);k.x=R,k.y=O,k.w=Math.round(C+(i>=a?m:b)-l/2)-R,k.h=Math.round(N+(i>=a?b:m)-l/2)-O,v+=b,s-=k.value}i>=a?(r+=m,i-=m):(n+=m,a-=m),o=g}}function JR(e,t,r,n){let i=e.map((u,d)=>Ky(u,void 0,d)),a=i.slice();for(let u=0;u<a.length;u++){let d=a[u];for(let p of d.node.children??[]){let g=Ky(p,d,d.series);d.children.push(g),a.push(g)}}for(let u=a.length-1;u>=0;u--){let d=a[u];d.parent&&(d.parent.value+=d.value)}let{gap:l,header:s,side:o}=n,c=[],h=(u,d,p,g,m)=>{if(g<=0||m<=0)return;let v=u.filter(k=>k.value>0).sort((k,b)=>b.value-k.value),x=0;for(let k of v)x+=k.value;if(!(v.length===0||!Number.isFinite(x))){QR(v,x,d-l/2,p-l/2,g+l,m+l,l);for(let k of v)k.w>0&&k.h>0&&c.push(k)}};h(i,0,0,t,r);for(let u=0;u<c.length;u++){let d=c[u];d.children.length>0&&h(d.children,d.x+o,d.y+s,d.w-2*o,d.h-s-o)}return c}var ju=28,qo=6,Xo=1.25;function Ko(e,t,r,n,i){let a=e.treemap?.[t];return typeof a=="number"&&a>=n?Math.min(a,i):r}function e5(e,t,r){let n=r.fontSize??16,i=Math.round(n*.875),a=Math.round(n*.75),l=Math.round(n*.5625),s=r.measurer??bt(r.fontFamily),o=t.treemap??{},c=r.padding??Ko(t,"diagramPadding",8,0,2e3),h=Math.round(td(r,Ko(t,"nodeWidth",64,1,400)*10,200,2*c)),u=Math.round(Ko(t,"nodeHeight",40,1,400)*10),d=o.showValues!==!1,p=ZR(typeof o.valueFormat=="string"?o.valueFormat:","),g=JR(e.roots,h,u,{gap:Ko(t,"padding",4,0,200),header:ju,side:qo}),m=Ve(e.title,!1,s,n,Xt(r),1),v=m.height>0?m.height+8:0,x=c+Math.max(0,(m.width-h)/2),k=c+v,b="",C="";for(let P of g){let H=P.node,I=Ot(H.cssCompiledStyles??[]),G=kt(P.series),Z=x+P.x,z=k+P.y,W=It(H.name).trim(),S=d?p(P.value):"",A=`data-id="${Ge(H.name)}">`,$=`<rect x="${f(Z)}" y="${f(z)}" width="${f(P.w)}" height="${f(P.h)}" fill="${G}"`;if(H.children!==void 0){let _="";if(P.h>=ju){let U=P.w-2*qo-4,j=S?s.width(S,a,0):0,Y=j>0&&U-j-12>=3*i,D=Nf(W,Y?U-j-12:U,i,i,s,1),L=z+ju/2+1;D&&(_+=`<text x="${f(Z+qo+2)}" y="${f(L+i*.35)}" font-weight="var(--_hw)"${I.text}>${tt(D.text)}</text>`),Y&&(_+=`<text class="pele-value" x="${f(Z+P.w-qo-2)}" y="${f(L+a*.35)}" font-size="${a}" text-anchor="end" fill="var(--_m)"${I.text}>${tt(S)}</text>`)}let M=/[";]fill:/.test(I.shape)?"":' fill-opacity="0.12"';b+=`<g class="pele-node pele-section${jt(H.classSelector??"")}" ${A}${$}${_t(`${M} stroke="${G}"${I.shape}`)}/>${_}</g>`;continue}let y="",E=P.w-8,w=Math.min(n,Math.floor((P.h-4)/Xo)),T=w>=l?Nf(W,E,w,l,s):void 0;if(T){let _=f(Z+P.w/2),M=z+P.h/2,U=Math.max(l,Math.round(T.size*.8)),j=(T.size+U)*Xo;if(S&&j<=P.h-4&&s.width(S,U,0)<=E){let Y=M-j/2+T.size*Xo/2,D=M+j/2-U*Xo/2;y=`<text x="${_}" y="${f(Y+T.size*.35)}" font-size="${f(T.size)}"${I.text}>${tt(T.text)}</text><text class="pele-value" x="${_}" y="${f(D+U*.35)}" font-size="${f(U)}"${I.text}>${tt(S)}</text>`}else y=`<text x="${_}" y="${f(M+T.size*.35)}" font-size="${f(T.size)}"${I.text}>${tt(T.text)}</text>`}C+=`<g class="pele-node pele-leaf${jt(H.classSelector??"")}" ${A}${$}${_t(I.shape)}/>${y}</g>`}let N=Math.ceil(Math.max(h,m.width)+2*c),R=Math.ceil(u+v+2*c),O=Le(m,N/2,c+m.height/2,' class="pele-title" font-weight="var(--_tw)"')+(b?`<g class="pele-sections" font-size="${i}">${b}</g>`:"")+(C?`<g class="pele-leaves" text-anchor="middle" fill="var(--_bg)">${C}</g>`:"");return{svg:mt("treemap",N,R,n,r,e,O),width:N,height:R,links:[]}}var t5={type:"treemap",parse:(e,t,r)=>qR(KR(e),r),render:e5},i2="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(" "),gl=1,a2=2,Un=new Uint8Array(128);for(let e=48;e<=57;e++)Un[e]=gl;for(let e=65;e<=90;e++)Un[e]=Un[e+32]=gl;Un[95]=gl;for(let e of"!#$&*+/=?^|~")Un[e.charCodeAt(0)]=a2;var Zy=[0,12,5,14,3,9,2,2,2,2,2,4,3,4,8,5,5,7,6,4,5];function Zo(e){return e<128&&(Un[e]&gl)!==0}function Uu(e,t,r){for(let n=0;n<r.length;n++)if((e.charCodeAt(t+n)|32)!==r.charCodeAt(n))return!1;return!0}function r5(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:Uu(e,t,"extend")?18:0;case 69:return Uu(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 Uu(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 ml(e,t){let r=1,n=0;for(let i=0;i<t;i++){let a=e.charCodeAt(i);a!==10&&a!==13||(a===13&&i+1<t&&e.charCodeAt(i+1)===10&&i++,r++,n=i+1)}return[r,t-n+1]}function n5(e,t,r){let[n,i]=ml(e,t);return`line ${n}, column ${i} [${t},${r})`}function s2(e,t,r){for(let n=t+1;n<e.length;n++){let i=e.charCodeAt(n);if(i===r)return n+1;if(i===10||i===13)return-1}return-1}function i5(e,t){let r=e.charCodeAt(t);return r!==34&&r!==39?!0:r===34&&e.charCodeAt(t+1)===96||s2(e,t,r)!==-1}function Qy(e,t,r){let[n,i]=ml(e,t);return new Je(`Error lexing usecase diagram: unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${r} characters. at line ${n}, column ${i} [${t},${t+r})`,"syntax",{type:"usecase",line:n,column:i})}function a5(e){let t=[],r=[],n=[],i=e.length,a=0,l=!0,s=!1;for(;a<i;){let o=e.charCodeAt(a);if(o===32||o===9){a++;continue}let c,h=a+1,u=!1;if(o<128&&(Un[o]&gl)!==0){if(c=0,o===97&&l&&e.startsWith("acc",a)){let d=e.startsWith("Descr",a+3);if(d||e.startsWith("Title",a+3)){let p=a+8;for(;Kr(e.charCodeAt(p));)p++;let g=e.charCodeAt(p);if(g===58)for(c=d?42:41,h=p+1;h<i&&e.charCodeAt(h)!==10&&e.charCodeAt(h)!==13;)h++;else if(g===123&&d&&!s){let m=e.indexOf("}",p+1);m===-1?s=!0:(c=40,h=m+1)}}}else if(o===106&&e.startsWith("json",a)&&Kr(e.charCodeAt(a+4))){let d=a+5;for(;Kr(e.charCodeAt(d));)d++;let p=d;for(;Zo(e.charCodeAt(d));)d++;if(d>p){for(;Kr(e.charCodeAt(d));)d++;if(e.charCodeAt(d)===64){for(d++;Kr(e.charCodeAt(d));)d++;if(e.charCodeAt(d)===123){t.push(43),r.push(a),n.push(d),a=d;let g=0,m=!1,v=!1,x=d;for(;x<i;x++){let k=e.charCodeAt(x);if(m)v?v=!1:k===92?v=!0:k===34&&(m=!1);else if(k===34)m=!0;else if(k===123)g++;else if(k===125&&--g===0)break}t.push(x<i?44:45),r.push(d),a=x<i?x+1:i,n.push(a),l=!1;continue}}}}if(c===0){for(;h<i&&Zo(e.charCodeAt(h));)h++;let d=r5(e,a,o);if(d!==0)d===1||h-a===Zy[d]?(c=d,h=a+Zy[d]):c=21;else if((o===111||o===120)&&e.charCodeAt(a+1)===45&&e.charCodeAt(a+2)===45)c=o===111?56:58,h=a+3;else if(gt(o)){let p=a+1;for(;gt(e.charCodeAt(p));)p++;if(e.charCodeAt(p)===46&&gt(e.charCodeAt(p+1))){for(c=22,h=p+2;gt(e.charCodeAt(h));)h++;for(;$a(e.charCodeAt(h));)h++}else c=21}else for(c=21;e.charCodeAt(h)===45&&Zo(e.charCodeAt(h+1));)for(c=27,h+=2;Zo(e.charCodeAt(h));)h++}}else if(o===10)c=39,u=!0;else if(o===13)c=39,u=!0,e.charCodeAt(h)===10&&h++;else if(o===34||o===39){if(o===34&&e.charCodeAt(a+1)===96){let d=e.indexOf('`"',a+2);c=d===-1?37:36,h=d===-1?i:d+2}else if(c=35,h=s2(e,a,o),h===-1){let d=a+1;for(;d<i&&!i5(e,d);)d++;throw Qy(e,a,d-a)}}else if(o===37)if(l&&e.charCodeAt(h)===37)for(c=38;h<i&&e.charCodeAt(h)!==10&&e.charCodeAt(h)!==13;)h++;else c=31;else if(o===45)if(e.charCodeAt(h)!==45)c=29;else{for(;e.charCodeAt(h)===45;)h++;let d=e.charCodeAt(h),p=h-a===2;p&&d===124&&e.charCodeAt(h+1)===62?(c=46,h+=2):d===62?(c=53,h++):p&&(d===111||d===120)?(c=d===111?55:57,h++):c=59}else if(o===46){let d=e.charCodeAt(h);if(d===46&&e.charCodeAt(h+1)===62)c=47,h+=2;else if(gt(d)){for(c=22;gt(e.charCodeAt(h));)h++;for(;$a(e.charCodeAt(h));)h++}else c=30}else if(o===60)if(e.charCodeAt(h)===60){if(t.push(48),r.push(a),n.push(a+2),l=!1,a+=2,a>=i)break;if(e.charCodeAt(a)===62&&e.charCodeAt(a+1)===62)c=49,h=a+2;else{let d=a,p=!1;for(;d<i;d++){let g=e.charCodeAt(d);if(g===10||g===13)break;if(g===62&&e.charCodeAt(d+1)===62){p=!0;break}}if(p&&e.slice(a,d).trim()!=="")t.push(50),r.push(a),n.push(d),c=49,a=d,h=d+2;else{for(;d<i&&e.charCodeAt(d)!==10&&e.charCodeAt(d)!==13;)d++;if(d===a){for(;d<i&&(e.charCodeAt(d)===10||e.charCodeAt(d)===13);)d++;throw Qy(e,a,d-a)}c=51,h=d}}}else if(e.charCodeAt(h)===45&&e.charCodeAt(h+1)===45)for(c=54,h+=2;e.charCodeAt(h)===45;)h++;else c=33;else if(o===58)e.charCodeAt(h)===58&&e.charCodeAt(h+1)===58?(c=52,h+=2):c=25;else if(o===64)e.charCodeAt(h)===123?(c=60,h++):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(;Px(e.charCodeAt(h));)h++;c=h>a+1?26:32}else if(o===92)e.charCodeAt(h)===44?(c=28,h++):c=33;else if(o<127&&o>32)c=(Un[o]&a2)!==0?32:33;else for(c=34;h<i;){let d=e.charCodeAt(h);if(d>=32&&d<127||d===9||d===10||d===13)break;h++}t.push(c),r.push(a),n.push(h),a=h,l=u}for(let o=0;o<3;o++)t.push(0),r.push(i),n.push(i);return{types:t,starts:r,ends:n}}function s5(){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 l5(){return{elements:[],boundaries:[],jsons:[],relationships:[],notes:[],metadata:[],classes:[],styles:[],classDefs:[],direction:void 0,accTitle:"",accDescription:""}}function Yu(e,t){if(t.length===0)return;let r=new Set(e);for(let n of t)r.has(n)||(r.add(n),e.push(n))}function o5(e){let t=new Set(["actor","usecase","boundary","edge"]);for(let{key:r,value:n}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(),n==="rect"||n==="package"?t.add("boundary"):(n==="normal"||n==="hollow"||n==="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 c5(e,t,r,n,i){let a=s5(),{actors:l,useCases:s,systemBoundaries:o}=a,c=new Map,h=new Map,u=new Map,d=new Map,p=new Map,g=w=>n5(e,w[0],w[1]),m=(w,T)=>{let[_,M]=ml(e,T[0]);return new Je(w,"semantic",{type:"usecase",line:_,column:M})},v=(w,T)=>{throw m(`${w} at ${g(T)}`,T)},x=(w,T,_,M,U)=>{let j=Y=>Y===void 0?"":` (label "${Y}")`;throw m(`${w} at ${g(T)}${j(M)}; previous declaration at ${g(_)}${j(U)}`,T)},k=(w,T,_)=>v(`Metadata property '${_.key}' is invalid for ${T} '${w}'`,_.keySpan),b=(w,T)=>{let _=p.get(w);(_===void 0||T<_)&&p.set(w,T)},C=w=>[...w].sort((T,_)=>(p.get(T.id)??0)-(p.get(_.id)??0)),N=(w,T)=>{c.set(w.id,{kind:T,span:w.span,generated:w.generated,label:w.label.text})},R=(w,T)=>{let _=c.get(w.id);if(!_)return;let M=w.generated?w.label.text:void 0,U=_.generated?_.label:void 0;_.kind!==T&&x(`ID '${w.id}' is declared as both ${_.kind} and ${T}`,w.span,_.span,M,U),(_.generated||w.generated)&&x(`Generated ID '${w.id}' collides with another declaration`,w.span,_.span,M,U)},O=(w,T,_)=>{let M=c.get(w);M&&x(`ID '${w}' is declared more than once (${M.kind} and ${T})`,_,M.span,void 0,M.generated?M.label:void 0),c.set(w,{kind:T,span:_,generated:!1})},P=(w,T,_)=>{let{key:M,value:U}=T,j=Y=>{!_&&Y!==void 0&&Y!==U&&x(`Actor '${w.id}' has conflicting ${M} metadata`,T.keySpan,w.span)};M==="type"&&(U==="normal"||U==="hollow"||U==="awesome")?(j(w.actorType),w.actorType=U):M==="icon"&&typeof U=="string"?(j(w.icon),w.icon=U):M==="business"&&typeof U=="boolean"?(j(w.business),w.business=U):k(w.id,"actor",T)},H=(w,T,_)=>{for(let M of T??[])w.kind==="actor"?P(w,M,_):M.key==="business"&&typeof M.value=="boolean"?(!_&&w.business!==void 0&&w.business!==M.value&&x(`Use case '${w.id}' has conflicting business metadata`,M.keySpan,w.span),w.business=M.value):k(w.id,"usecase",M)},I=w=>{let T;if(w.kind==="actor"){s.delete(w.id);let _={id:w.id,label:w.label.text,labelType:w.label.type,business:w.business??!1,classes:[...w.classes],type:w.icon?"icon":w.actorType??"normal",styles:l.get(w.id)?.styles??[]};w.icon&&(_.icon=w.icon),l.set(w.id,_),T=_}else l.delete(w.id),T={id:w.id,label:w.label.text,labelType:w.label.type,business:w.business??!1,classes:[...w.classes],shape:w.shape??"ellipse",styles:s.get(w.id)?.styles??[]},s.set(w.id,T);w.stereotype&&(T.stereotype=w.stereotype),w.parent?.id&&(T.parentId=w.parent.id)},G=w=>{R(w,w.kind);let T=w.parent?.id?w.parent:void 0,_=h.get(w.id);if(!_){let M={kind:w.kind,id:w.id,label:w.label,span:w.span,generated:w.generated,classes:[...w.classes],parent:T,shape:w.shape,stereotype:w.stereotype,stereotypeSpan:w.stereotype?w.span:void 0};H(M,w.metadata,!1),h.set(w.id,M),N(w,w.kind);return}(_.label.text!==w.label.text||_.label.type!==w.label.type)&&x(`ID '${w.id}' has conflicting labels`,w.span,_.span),w.shape&&_.shape&&w.shape!==_.shape&&x(`Use case '${w.id}' has conflicting shapes`,w.span,_.span),T&&_.parent?.id&&T.id!==_.parent.id&&x(`Element '${w.id}' belongs to more than one system boundary`,T.span,_.parent.span),w.stereotype&&_.stereotype&&w.stereotype!==_.stereotype&&x(`Element '${w.id}' has conflicting stereotypes`,w.span,_.stereotypeSpan??_.span),_.shape??=w.shape,_.parent??=w.parent,_.stereotype??=w.stereotype,_.stereotypeSpan??=w.stereotype?w.span:void 0,Yu(_.classes,w.classes),H(_,w.metadata,!1)},Z=w=>{R(w,"boundary");let T=u.get(w.id);if(T){(T.label.text!==w.label.text||T.label.type!==w.label.type)&&x(`Boundary '${w.id}' has conflicting titles`,w.span,T.span),Yu(T.classes,w.classes);return}u.set(w.id,{...w,classes:[...w.classes],members:[]}),N(w,"boundary")},z=w=>{w.classed&&!w.declares&&v(`Relationship endpoint '${w.id}' uses ::: without declaring the node`,w.span);let T=c.get(w.id);return T?T.kind:(h.set(w.id,{...w,kind:"usecase",shape:"ellipse",classes:[]}),N(w,"usecase"),b(w.id,w.span[0]),"usecase")},W=(w,T)=>{let _=c.get(w)?.kind;return(_==="actor"?l.get(w):_==="usecase"?s.get(w):_==="boundary"?o.get(w):_==="json"?a.jsonNodes.get(w):d.get(w))??v(`Class/style target '${w}' is unresolved or anonymous`,T)},S=[];for(let{source:w,target:T}of t.relationships)b(w.id,w.span[0]),b(T.id,T.span[0]);for(let w of t.elements)b(w.id,w.span[0]),S.push({offset:w.span[0],run:()=>G(w)});for(let w of t.boundaries)b(w.id,w.span[0]),S.push({offset:w.span[0],run:()=>Z(w)});for(let w of t.jsons)b(w.id,w.span[0]),S.push({offset:w.span[0],run:()=>O(w.id,"json",w.span)});for(let{id:w,idSpan:T}of t.relationships)w&&T&&S.push({offset:T[0],run:()=>O(w,"edge",T)});S.sort((w,T)=>w.offset-T.offset);for(let w of S)w.run();for(let w of C(h.values()))I(w);for(let w of C(u.values()))o.set(w.id,{id:w.id,label:w.label.text,labelType:w.label.type,type:"rect",members:[],classes:[],styles:[]});for(let w of C(t.jsons))a.jsonNodes.set(w.id,{id:w.id,value:w.value,propertyOrder:w.propertyOrder,classes:[...w.classes],styles:[]});let A=0;for(let w of t.relationships){let{source:T,target:_,type:M}=w,U=z(T),j=z(_),Y=F=>F==="actor"||F==="usecase"||F==="json";Y(U)||x(`Relationship source '${T.id}' cannot be ${U}`,T.span,c.get(T.id).span),Y(j)||x(`Relationship target '${_.id}' cannot be ${j}`,_.span,c.get(_.id).span),(M==="include"||M==="extend")&&(U!=="usecase"||j!=="usecase")&&v(`${M} relationship requires use-case endpoints`,w.span),M==="generalization"&&(U==="json"||U!==j)&&v("Generalization requires actor-to-actor or use-case-to-use-case endpoints",w.span),M==="association"&&(U==="json"||j==="json")&&w.arrowType>2&&v(`JSON relationship '${T.id}' to '${_.id}' permits only point, reversed-point, or markerless solid association`,w.span);let D=w.id??`edge-${A++}`,L={id:D,explicitId:!!w.id,source:T.id,target:_.id,type:M,arrowType:w.arrowType,minlen:w.minlen,classes:[],styles:[],animate:!1};w.label&&(L.label=w.label.text,L.labelType=w.label.type),a.relationships.push(L),d.set(D,L)}let $=new Map(l),y=new Map(s);l.clear(),s.clear();for(let w of C(h.values())){let T=$.get(w.id),_=y.get(w.id);T?l.set(w.id,T):_?s.set(w.id,_):I(w)}for(let{target:w,span:T,properties:_,statement:M}of t.metadata){let U=c.get(w);if(!U){let L=o5(_);return v(`Metadata target '${w}' is unresolved${L?` (metadata implies ${L})`:""}`,T)}let j=U.kind;j==="actor"||j==="usecase"?H(h.get(w),_,!0):j==="edge"&&(M.kind="edgeMetadata",M.edges=[{id:w,span:M.span,idSpan:T,metadata:M.metadata}],delete M.nodes);let Y=u.get(w),D=d.get(w);for(let L of j==="actor"||j==="usecase"?[]:_){let{key:F,value:V}=L;j==="boundary"&&Y&&F==="type"&&(V==="rect"||V==="package")?Y.type=V:j==="edge"&&D&&F==="animate"&&typeof V=="boolean"?D.animate=V:j==="edge"&&D&&F==="animation"&&(V==="fast"||V==="slow")?(D.animation=V,D.animate=!0):k(w,j,L)}}for(let w of a.relationships)w.animation&&(w.animate=!0);for(let w of h.values())w.kind==="actor"?(w.icon&&w.actorType&&w.actorType!=="normal"&&v(`Actor '${w.id}' cannot combine icon with type '${w.actorType}'`,w.span),w.business&&(w.icon||w.actorType==="awesome")&&v(`Business actor '${w.id}' must use normal or hollow geometry`,w.span)):w.shape==="rect"&&w.business&&v(`Rectangular use case '${w.id}' cannot be a business use case`,w.span),I(w);for(let w of[...t.elements].sort((T,_)=>T.span[0]-_.span[0])){if(!w.parent?.id)continue;let T=u.get(w.parent.id).members;T.includes(w.id)||T.push(w.id)}for(let w of u.values()){let T=o.get(w.id);T.type=w.type??"rect",T.members=w.members,T.classes=[...w.classes]}let E=0;for(let w of t.notes){let T=c.get(w.target);if(!T)return v(`Note target '${w.target}' is unresolved`,w.span);T.kind!=="actor"&&T.kind!=="usecase"&&x(`Note target '${w.target}' must be an actor or use case, not ${T.kind}`,w.span,T.span);let _=`note-${E++}`;a.notes.set(_,{id:_,target:w.target,label:w.label.text,labelType:w.label.type})}for(let w of t.classDefs)for(let T of w.ids)a.classDefs.set(T,{id:T,styles:[...w.styles]});for(let w of t.classes)for(let T of w.targets)Yu(W(T.id,T.span).classes,w.classes);for(let w of t.styles)W(w.target,w.span).styles.push(...w.styles);return a.direction=t.direction??a.direction,a.title=i,a.accTitle=t.accTitle,a.accDescription=t.accDescription,a.accDescr=t.accDescription.replace(/\n\s+/g,`
142
+ `),a.source=e,a.headerSpan=r,a.statements=n,a}var lr=class extends Error{constructor(e){super("Invalid JSON token"),this.offset=e}offset};function Jy(e){let t=new Map,r=[],n=[],i=e.length,a=0,l="",s=0,o=()=>{for(;a<i;){let d=e.charCodeAt(a);if(d!==32&&d!==9&&d!==10&&d!==13)return;a++}},c=d=>{a++;let p="";for(;a<i;){let g=a,m=e[a++];if(m==='"')return p;if(m.charCodeAt(0)<32)throw new lr(g);if(m!=="\\"){d&&(p+=m);continue}let v=a,x=e[a++],k;if(x==='"'||x==="\\"||x==="/")k=x;else if(x==="b")k="\b";else if(x==="f")k="\f";else if(x==="n")k=`
143
+ `;else if(x==="r")k="\r";else if(x==="t")k=" ";else if(x==="u"){let b=e.slice(a,a+4);if(!/^[\dA-Fa-f]{4}$/.test(b))throw new lr(a);k=String.fromCharCode(parseInt(b,16)),a+=4}else throw new lr(v);d&&(p+=k)}throw new lr(a)},h=d=>{for(let p=0;p<d.length;p++)if(e[a+p]!==d[p])throw new lr(a+p);a+=d.length},u=()=>{if(e.charCodeAt(a)===45&&a++,e.charCodeAt(a)===48)a++;else if(gt(e.charCodeAt(a)))for(;gt(e.charCodeAt(a));)a++;else throw new lr(a);if(e.charCodeAt(a)===46){if(a++,!gt(e.charCodeAt(a)))throw new lr(a);for(;gt(e.charCodeAt(a));)a++}if((e.charCodeAt(a)|32)===101){if(a++,(e.charCodeAt(a)===43||e.charCodeAt(a)===45)&&a++,!gt(e.charCodeAt(a)))throw new lr(a);for(;gt(e.charCodeAt(a));)a++}};for(o();;)if(s===0){o();let d=e.charCodeAt(a);if(s=2,d===123){a++;let p=[];t.set(l,p),r.push(l),o(),e.charCodeAt(a)===125?a++:(n.push({object:!0,pointer:l,keys:p,ranges:new Map,key:"",from:0,index:0}),s=1)}else if(d===91)a++,o(),e.charCodeAt(a)===93?a++:(n.push({object:!1,pointer:l,keys:[],ranges:new Map,key:"",from:0,index:0}),l+="/0",s=0);else if(d===34)c(!1);else if(d===116)h("true");else if(d===102)h("false");else if(d===110)h("null");else if(d===45||gt(d))u();else throw new lr(a)}else if(s===1){let d=n[n.length-1];if(e.charCodeAt(a)!==34)throw new lr(a);let p=c(!0),g=d.ranges.get(p);if(g===void 0)d.keys.push(p);else for(let m=g[0];m<g[1];m++)t.delete(r[m]);if(d.key=p,d.from=r.length,o(),e.charCodeAt(a)!==58)throw new lr(a);a++,l=`${d.pointer}/${p.replaceAll("~","~0").replaceAll("/","~1")}`,s=0}else{let d=n[n.length-1];if(d===void 0)break;d.object?d.ranges.set(d.key,[d.from,r.length]):d.index++,o();let p=e.charCodeAt(a);if(p===(d.object?125:93))a++,n.pop();else{if(p!==44)throw new lr(a);a++,o(),l=`${d.pointer}/${d.index}`,s=d.object?1:0}}if(o(),a!==i)throw new lr(a);return t}function Hf(e,t,r,n){let i=Math.min(Math.max(t,0),e.length);for(let a=0;a<i;a++){let l=e.charCodeAt(a);l===13?(r++,n=1):l===10?(a===0||e.charCodeAt(a-1)!==13)&&(r++,n=1):n++}return[r,n]}function d5(e,t,r,n){let i=/\bposition (\d+)\b/.exec(e);if(i)return Hf(t,parseInt(i[1],10),r,n);let a=/\bline (\d+) column (\d+)\b/.exec(e);if(a){let l=parseInt(a[1],10),s=parseInt(a[2],10);return[r+l-1,l===1?n+s-1:s]}if(/unexpected end|end of json input/i.test(e))return Hf(t,t.length,r,n)}function ex(e,t,r){return new Je(`${e} (line ${t}, column ${r})`,"syntax",{type:"usecase",line:t,column:r})}function h5(e,t){let r;try{r=JSON.parse(e)}catch(n){let i=n instanceof Error?n.message:String(n),[a,l]=t(),s=d5(i,e,a,l);if(!s){let o=0;try{Jy(e)}catch(c){c instanceof lr&&(o=c.offset)}s=Hf(e,o,a,l)}throw ex(`Invalid JSON: ${i}`,s[0],s[1])}if(typeof r!="object"||r===null||Array.isArray(r)){let[n,i]=t();throw ex("JSON value must have an object root",n,i)}return{value:r,propertyOrder:Jy(e)}}var l2=1,pp=2,jf=4,o2=8,c2=16,d2=32,h2=64,yd="DEPENDENCY_ARROW|GENERALIZATION|FORWARD_SOLID|BACKWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|BACKWARD_CIRCLE|FORWARD_CROSS|BACKWARD_CROSS",xd="IDENTIFIER|PLAIN_STRING|MARKDOWN_STRING",u5="PLAIN_STRING|MARKDOWN_STRING|LABEL_TEXT",u2="ACC_TITLE_LINE|ACC_DESCR_LINE|ACC_DESCR_BLOCK|DIRECTION|ACTOR|SYSTEM_BOUNDARY|NOTE|JSON_DECLARATION_START|CLASS_DEF|CLASS|STYLE",f2="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",Fr=new Uint8Array(67);function Ci(e,t){for(let r of e.split("|"))if(r==="WORD")for(let n=1;n<=21;n++)Fr[n]|=t;else Fr[i2.indexOf(r)]|=t}Ci(`NEWLINE|COMMENT|${u2}|${xd}`,l2);Ci(`IDENTIFIER|${yd}`,pp);Ci(f2,jf);Ci(`STEREOTYPE_START|CLASS_SEPARATOR|IDENTIFIER|${yd}|NEWLINE|EOF`,o2);Ci(`NEWLINE|COMMENT|ACTOR|${xd}`,c2);Ci("FORWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|FORWARD_CROSS",d2);Ci("NEWLINE|IDENTIFIER|PLAIN_STRING|RBRACE",h2);var f5=new Set(["allowmixing","newpage","package","rectangle","skinparam"]),or="",et=[],qt=[],nr=[],We=0,p2=0,Gt,Yc,kc=[],g2=0,m2=0;function Ft(e){return or.slice(qt[e],nr[e])}function yr(e){return[qt[e],nr[e]]}function bd(e){let[t,r]=ml(or,qt[We]);throw new Je(`Error parsing usecase diagram: ${e} at line ${t}, column ${r} [${qt[We]},${nr[We]})`,"syntax",{type:"usecase",line:t,column:r})}function y2(e){bd(`Expecting token of type --> ${e} <-- but found --> '${Ft(We)}' <--`)}function Ht(e){return et[We]!==e&&y2(i2[e]),We++}function vr(e){let t=e.split("|").map((r,n)=>` ${n+1}. [${r}]`);bd(`Expecting: one of these possible Token sequences:
144
+ ${t.join(`
145
+ `)}
146
+ but found: '${Ft(We)}'`)}function tx(){let e=xd.split("|"),t=e.flatMap(i=>["NEWLINE","IDENTIFIER","PLAIN_STRING","RBRACE"].map(a=>`${i}, METADATA_START, ${a}`)),r=`STEREOTYPE_START|CLASS_SEPARATOR|IDENTIFIER|${yd}|NEWLINE|EOF`.split("|"),n=e.flatMap((i,a)=>(a===0?["LPAREN","LBRACKET",...r]:r).map(l=>`${i}, ${l}`));return[u2,...t,...n,...t].join("|")}function rx(e){return e>=1&&e<=21}function nx(e){return e>=1&&e<=34}function Ei(){p2=nr[We-1],et[We]===39?We++:et[We]!==0&&vr("NEWLINE|EOF")}function sl(e){let t=et[e]===36?2:et[e]===35?1:0;return[qt[e]+t,nr[e]-t]}function Uf(e){let t=sl(e);return{text:or.slice(t[0],t[1]),type:et[e]===36?"markdown":"text",span:t}}function x2(e){return e.replace(/\W/g,"_")}function Qs(){let e=et[We];if(e===35||e===36)return Uf(We++);nx(e)||vr(u5);let t=We;for(;nx(et[We]);)We++;let r=[qt[t],nr[We-1]];return{text:or.slice(r[0],r[1]),type:"text",span:r}}function wi(e){return e===21||e===35}function ix(){let e=We;wi(et[We])||vr("IDENTIFIER|PLAIN_STRING"),We++,Ht(25);let t=We,r=et[We];!wi(r)&&r!==19&&r!==20&&vr("IDENTIFIER|PLAIN_STRING|TRUE|FALSE"),We++;let n=sl(e),i=sl(t);return{key:or.slice(n[0],n[1]),value:r===19?!0:r===20?!1:or.slice(i[0],i[1]),span:[qt[e],nr[t]],keySpan:n,valueSpan:i}}function p5(){let e=et[We],t=et[We+1],r=et[We+2];return e===24?wi(t)||t===39&&(r===39||wi(r)):e!==39?!1:t===24||wi(t)||t===39&&(r===39||r===24||wi(r))}function gp(){Ht(60);let e=[];for(;et[We]===39;)We++;if(wi(et[We])){for(e.push(ix());p5();){if(et[We]===24)We++;else{for(;et[We]===39;)We++;et[We]===24&&We++}for(;et[We]===39;)We++;e.push(ix())}for(et[We]===24&&We++;et[We]===39;)We++}return Ht(62),e}function mp(e){return e.map(({key:t,span:r,keySpan:n,valueSpan:i})=>({key:t,span:r,keySpan:n,valueSpan:i}))}function yp(e,t){do{We++;let r=Ht(21);e.push(Ft(r)),t.push(yr(r))}while(et[We]===24)}function b2(e){let t=We,r=et[We],n={id:"",label:void 0,span:sl(t),generated:r!==21,classes:[],classSpans:[],explicit:!1,nodeSpan:[0,0]};if(r===21){We++,n.id=Ft(t);let i=et[We];i===65||e&&i===63?(We++,n.label=Qs(),Ht(i===65?66:64),n.shape=i===65?"ellipse":"rect"):n.label=Uf(t)}else r===35||r===36?(We++,n.label=Uf(t),n.id=x2(n.label.text)):vr(xd);return n}function Gc(e){let t=We,r=b2(!e);if(e&&(r.shape=void 0),et[We]===60&&(r.metadata=gp()),et[We]===48){We++;let n=Ht(50);Ht(49),r.stereotype=Ft(n).trim(),r.stereotypeSpan=yr(n)}return et[We]===52&&yp(r.classes,r.classSpans),r.explicit=!!(r.shape||r.metadata||r.stereotype),r.nodeSpan=[qt[t],nr[We-1]],r}function xp(e,t){return{id:e.id,kind:t,label:e.label,span:e.span,generated:e.generated,parent:Yc,shape:e.shape,metadata:e.metadata,stereotype:e.stereotype,classes:e.classes}}function ax(e,t){return{id:e.id,label:e.label,span:e.span,generated:e.generated,declares:t,classed:e.classes.length>0}}function bp(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=mp(e.metadata)),e.classSpans.length>0&&(r.classSpans=e.classSpans),r}function Gu(e){if(et[We]<1||et[We]>36)return!1;for(let t=We+1;;t++){let r=et[t];if(r===59||(Fr[r]&e)!==0)return!0;if(r<1||r>36)return!1}}function As(e){let t=nr[e]-qt[e]-(et[e]===59?0:1);return Math.max(1,t-1)}function w2(){let e=We,t={type:"association",arrowType:0,minlen:1,target:void 0,span:[0,0]};et[We]===21&&et[We+1]===23&&(t.explicitId=Ft(We),t.explicitIdSpan=yr(We),We+=2);let r=We,n=et[We++];if(n===47)Ht(25),et[We]!==17&&et[We]!==18&&vr("INCLUDE|EXTEND"),t.type=et[We]===17?"include":"extend",t.label={text:t.type,type:"text",span:yr(We)},We++;else if(n===46)t.type="generalization";else if(n===53)t.minlen=As(r);else if(n===54)t.arrowType=1,nr[r]-qt[r]===3&&Gu(0)?(t.label=Qs(),t.minlen=As(Ht(59))):t.minlen=As(r);else if(n===59)if(t.arrowType=2,nr[r]-qt[r]===2&&Gu(d2)){t.label=Qs();let i=et[We];i===53?t.arrowType=0:i===55?t.arrowType=3:i===57?t.arrowType=4:i!==59&&vr("FORWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|FORWARD_CROSS"),(t.arrowType===0||t.arrowType===2)&&(t.minlen=As(We)),We++}else t.minlen=As(r);else n===55?t.arrowType=3:n===57?t.arrowType=4:n===56||n===58?(t.arrowType=n===56?5:6,Gu(0)&&(t.label=Qs(),Ht(59))):(We--,vr(yd));return t.target=Gc(!1),t.span=[qt[e],nr[We-1]],t}function Or(e){return{kind:e,span:[0,0]}}function v2(e,t,r,n){let i=r.target;i.explicit&&Gt.elements.push(xp(i,"usecase")),Gt.relationships.push({source:ax(e,t),target:ax(i,i.explicit),span:r.span,id:r.explicitId,idSpan:r.explicitIdSpan,type:r.type,arrowType:r.arrowType,label:r.label,minlen:r.minlen}),n.push(bp(i,i.explicit));let a=Or("edge");return a.nodes=n,a.edges=[{id:r.explicitId??`edge-${g2++}`,span:a.span}],r.explicitIdSpan&&(a.edges[0].idSpan=r.explicitIdSpan),r.label&&(a.edges[0].labelSpan=r.label.span),a}function $2(e){let t=Or("node");return t.nodes=e,t}function k2(e){We++;let t=[Gc(!0)],r;if(et[We]===24)do We++,t.push(Gc(!0));while(et[We]===24);else e&&(Fr[et[We]]&pp)!==0&&(r=w2());Ei();for(let i of t)Gt.elements.push(xp(i,"actor"));let n=t.map(i=>bp(i,!0));return r?v2(t[0],!0,r,n):$2(n)}function M2(e){let t=Gc(!1),r=e&&(Fr[et[We]]&pp)!==0?w2():void 0;Ei(),r||(t.explicit=!0,t.shape??="ellipse"),t.explicit&&Gt.elements.push(xp(t,"usecase"));let n=[bp(t,t.explicit)];return r?v2(t,t.explicit,r,n):$2(n)}function g5(){We++;let e=b2(!0),t={id:e.id,label:e.label,span:e.span,generated:e.generated,classes:e.classes},r=et[We]===60?gp():void 0;et[We]===52&&yp(e.classes,e.classSpans),Ei(),Gt.boundaries.push(t),Yc=t;let n=[];for(;(Fr[et[We]]&c2)!==0;)n.push(_2(!1));Yc=void 0;let i=Ht(4);Ei();let a=Or("group");return a.group=t.id,a.idSpan=t.span,a.titleSpan=t.label.span,a.endSpan=yr(i),a.classSpans=e.classSpans,n.length>0&&(a.children=n),r&&(a.metadata=mp(r),Gt.metadata.push({target:t.id,span:t.span,properties:r,statement:a})),a}function sx(){let e=We,t=et[We];for(rx(t)||t===27?We++:t===59?(We++,rx(et[We])||y2("WORD"),We++):vr("WORD|CSS_IDENTIFIER|MARKERLESS_SOLID"),Ht(25),(Fr[et[We]]&jf)===0&&bd(`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::
147
+ <[${f2.replaceAll("|","] ,[")}]>
148
+ but found: '${Ft(We)}'`);(Fr[et[We]]&jf)!==0;)We++;return or.slice(qt[e],nr[We-1]).replaceAll("\\,",",")}function lx(){let e=[sx()];for(;et[We]===24;)We++,e.push(sx());return e}function Vu(){let e=[Ht(21)];for(;et[We]===24;)We++,e.push(Ht(21));return e}function Qo(e){let t=sl(e);return{id:Ft(e),span:t,idSpan:t}}function m5(){let e=We,t=et[We],r;if(t===41||t===42||t===40){We++;let n=Ft(e);t===40?Gt.accDescription=n.slice(n.indexOf("{")+1,n.lastIndexOf("}")).trim():t===42?Gt.accDescription=n.slice(n.indexOf(":")+1).trim():Gt.accTitle=n.slice(n.indexOf(":")+1).trim(),r=Or(t===41?"accTitle":"accDescr")}else if(t===5){We++;let n=et[We];(n<6||n>10)&&vr("TD|TB|BT|LR|RL"),Gt.direction=n===6?"TB":Ft(We),We++,r=Or("direction")}else{if(t===2)return k2(!0);if(t===3)return g5();if(t===11){We++,Ht(12);let n=Ht(21),i=Qs();Gt.notes.push({target:Ft(n),span:yr(n),label:i}),r=Or("note"),r.ref=`note-${m2++}`,r.refSpan=i.span,r.nodes=[Qo(n)]}else if(t===43){We++;let n=Ht(44),i=[],a=[];et[We]===52&&yp(i,a);let l=qt[e]+4;for(;or.charCodeAt(l)===32||or.charCodeAt(l)===9;)l++;let s=l;for(;/\w/.test(or.charAt(s));)s++;let o={id:or.slice(l,s),value:{},propertyOrder:new Map,span:[l,s],classes:i};Gt.jsons.push(o),kc.push([o,n]),r=Or("json"),r.nodes=[{id:o.id,span:o.span,idSpan:o.span,defines:!0,classSpans:a}],r.classSpans=a}else if(t===14){We++;let n=Vu();Gt.classDefs.push({ids:n.map(Ft),styles:lx()}),r=Or("classDef"),r.ref=Ft(n[0]),r.refSpan=yr(n[0])}else if(t===15){We++;let n=Vu(),i=Vu();Gt.classes.push({targets:n.map(a=>({id:Ft(a),span:yr(a)})),classes:i.map(Ft)}),r=Or("classAssign"),r.ref=Ft(i[0]),r.refSpan=yr(i[0]),r.nodes=n.map(Qo)}else if(t===16){We++;let n=Ht(21);Gt.styles.push({target:Ft(n),span:yr(n),styles:lx()}),r=Or("style"),r.nodes=[Qo(n)]}else{let n=et[We+1];if(n===60){(Fr[et[We+2]]&h2)===0&&vr(tx()),We++;let i=Qo(e);t!==21&&(i.id=x2(or.slice(i.span[0],i.span[1])));let a=gp();r=Or("metadata"),r.nodes=[i],r.metadata=mp(a),Gt.metadata.push({target:i.id,span:i.span,properties:a,statement:r})}else return(!((Fr[n]&o2)!==0||t===21&&(n===65||n===63))||t===21&&f5.has(Ft(e).toLowerCase()))&&vr(tx()),M2(!0)}}return Ei(),r}function _2(e){let t=We,r=et[We];if(r===39)return We++,{kind:"blank",span:yr(t)};if(r===38)return We++,Ei(),{kind:"comment",span:yr(t)};let n=e?m5():r===2?k2(!1):M2(!1);if(n.span=[qt[t],p2],n.edges)for(let i of n.edges)i.span=n.span;return n}function y5(e,t){or=e,{types:et,starts:qt,ends:nr}=a5(e),We=0,Gt=l5(),Yc=void 0,kc=[],g2=0,m2=0;try{let r=Ht(1);Ei();let n=[];for(;(Fr[et[We]]&l2)!==0;)n.push(_2(!0));et[We]!==0&&bd(`Redundant input, expecting EOF but found: ${Ft(We)}`);for(let[i,a]of kc){let l=h5(Ft(a),()=>ml(e,qt[a]));i.value=l.value,i.propertyOrder=l.propertyOrder}return c5(e,Gt,yr(r),n,t)}finally{or="",et=qt=nr=kc=[]}}var x5={normal:"usecaseActor",hollow:"usecaseActorHollow",awesome:"usecaseActorAwesome",icon:"usecaseActorIcon"},qu=[["none","arrow_point"],["arrow_point","none"],["none","none"],["none","arrow_circle"],["none","arrow_cross"],["arrow_circle","none"],["arrow_cross","none"]];function ox(e){return typeof e=="string"?e:e===null?"null":String(e)}function b5(e){let t=[],r=[[e.value,"",""]],n=[];for(;r.length>0;){let[i,a,l]=r.pop();if(n.length=0,Array.isArray(i))i.length===0?t.push({key:a,accessibleKey:a,value:"[]"}):i.every(s=>s===null||typeof s!="object")?i.forEach((s,o)=>t.push({key:o===0?a:"",accessibleKey:a,value:ox(s)})):i.forEach((s,o)=>n.push([s,`${a}[${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:a,accessibleKey:a,value:"{}"});for(let c of o)n.push([Object.prototype.hasOwnProperty.call(s,c)?s[c]:void 0,a?`${a}.${c}`:c,`${l}/${c.replaceAll("~","~0").replaceAll("/","~1")}`])}else t.push({key:a,accessibleKey:a,value:ox(i)});for(let s=n.length-1;s>=0;s--)r.push(n[s])}return t}function Ts(...e){return e.filter(Boolean).join(" ")}function w5(e){return e.type==="generalization"?["none","extension"]:e.type!=="association"?qu[0]:qu[e.arrowType]??qu[2]}function v5(e){let t=[],r=[],n=i=>{let a=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(),h=c.indexOf(":"),u=(h===-1?c:c.slice(0,h)).trim();u&&a.set(u,c)}}return[...a.values()]};for(let i of e.actors.values())t.push({id:i.id,label:i.label,labelType:i.labelType,shape:x5[i.type],isGroup:!1,padding:10,cssClasses:Ts("default","usecase-actor",`usecase-actor-${i.type}`,i.business&&"usecase-business",...i.classes),cssStyles:[...i.styles],cssCompiledStyles:n(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 a=i.shape==="ellipse";t.push({id:i.id,label:i.label,labelType:i.labelType,shape:a?i.business?"usecaseBusiness":"usecaseEllipse":"rect",isGroup:!1,padding:a?20:10,cssClasses:Ts("default","usecase-element",`usecase-${i.shape}`,i.business&&"usecase-business",...i.classes),cssStyles:[...i.styles],cssCompiledStyles:n(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:n([]),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:Ts("default","usecase-json-table",...i.classes),cssStyles:[...i.styles],cssCompiledStyles:n(i.classes),jsonRows:b5(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:Ts("default","system-boundary",`system-boundary-${i.type}`,...i.classes),cssStyles:[...i.styles],cssCompiledStyles:n(i.classes),boundaryType:i.type});for(let i of e.relationships){let a=i.type==="include"||i.type==="extend",[l,s]=w5(i),o=i.animate||i.animation!==void 0,c={id:i.id,start:i.source,end:i.target,relationshipType:i.type,pattern:a?"dotted":"solid",arrowTypeStart:l,arrowTypeEnd:s,classes:Ts("default","relationship",`relationship-${i.type}`,...i.classes,o&&`edge-animation-${i.animation??"fast"}`),style:[...i.styles],cssCompiledStyles:n(i.classes),animate:i.animate,animation:i.animation,minlen:i.minlen,explicitId:i.explicitId,internal:!1};a?(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:n([]),animate:!1,minlen:1,explicitId:!1,internal:!0});return{nodes:t,edges:r}}var $5=32,k5=16,M5=72,Jo=20,Xu=26,wp=40,Js=60,cx=6,Ku=6,Ss=10,Zu=8,ec=9,Mc=12,_5=14,el=' fill="var(--_s)" stroke="var(--_b)"';function dx(e,t,r){let n=e.usecase?.[t];return typeof n=="number"&&n>0?Math.min(n,2e3):r}function E5(e){return e.replace(/[&<>\\]/g,t=>`&#${t.charCodeAt(0)};`)}function On(e,t,r,n,i,a=0){return Ve(e&&!t?E5(e):e,t,r,n,i,a)}function Yf(e,t,r,n){let i=r===1||r===2?1:-1,a=r===1||r===3,l=(a?e.w:e.h)/2,s=0;if(e.kind===0)a?(l=wp/2+3,s=(Js-e.h)/2):l+=2;else if(e.kind===1){let o=(a?e.h:e.w)/2;l*=Math.sqrt(Math.max(1-(n/o)**2,0))}return a?[t.x+i*l,t.y+s+n]:[t.x+n,t.y+i*l]}function E2(e,t){let r=t===1||t===3;if(e.kind===0)return r?Js*.5:wp*.6;let n=r?e.h:e.w;return e.kind===1?n*.6:n-16}function A5(e,t,r){let n=new Map,i=(a,l,s,o)=>{let c=t[a];if(c.isGroup)return;let h=l[s]-c.x,u=l[s+1]-c.y,d;if(Math.abs(Math.abs(u)-c.h/2)<.5)d=u<0?0:2;else if(Math.abs(Math.abs(h)-c.w/2)<.5)d=h<0?3:1;else return;let p=a*4+d,g={route:l,at:s,toward:l[o+(d&1?1:0)]},m=n.get(p);m?m.push(g):n.set(p,[g])};for(let a of e){let l=a.route.length-3;a.src===a.dst||l<3||(i(a.src,a.route,0,3),i(a.dst,a.route,l,l-3))}for(let[a,l]of n){let s=a>>2,o=a&3,c=r[s],h=l.length>1?Math.min(_5,E2(c,o)/(l.length-1)):0;l.sort((u,d)=>u.toward-d.toward);for(let u=0;u<l.length;u++){let[d,p]=Yf(c,t[s],o,(u-(l.length-1)/2)*h);l[u].route[l[u].at]=d,l[u].route[l[u].at+1]=p}}}function T5(e,t,r,n,i){let a=e-r*Mc,l=t-n*Mc,s=Mc*.5;return`<path class="pele-marker" d="M${f(e)},${f(t)}L${f(a-n*s)},${f(l+r*s)}L${f(a+n*s)},${f(l-r*s)}Z" fill="var(--_bg)" stroke="${i}" stroke-linejoin="round"/>`}function tc(e){return e==="extension"?Mc:Et(e)}function hx(e,t,r,n,i,a){return e==="extension"?T5(t,r,n,i,a):Ct(e,t,r,n,i,a)}function S5(e,t){let r=e.node,n=e.style.shape,i=` fill="none" stroke="var(--_b)"${e.style.line}`,a=-21,l=9,s;return r.actorType==="hollow"?(l=8,s=`<circle cy="-21" r="8" fill="var(--_bg)" stroke="var(--_b)"${n}/><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"${n}/>`):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)"${n}/>`:r.actorType==="icon"?(a=-14,l=12,s=`<rect x="-22" y="-26" width="44" height="44"${_t(el+n)}/><svg class="pele-icon" data-icon="${Ge(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"${el}${n}/><path d="M0,-12V10M-14,-3H14M0,10L-12,30M0,10L12,30"${i}/>`,r.business&&(s+=`<path class="pele-business" d="M${f(.12*l)},${f(a+.99*l)}L${f(.92*l)},${f(a-.39*l)}"${i}/>`),s}function C5(e,t,r){return Ti(e.direction)?dr(r,n=>ux(e,t,r,n)):ux(e,t,r,!1)}function ux(e,t,r,n){let i=v5(e),a=r.fontSize??16,l=Math.round(a*.875),s=Math.round(a*.8125),o=r.measurer??bt(r.fontFamily),c=r.padding??8,h=r.icons,u=n?"TB":Pr(e.direction),d=u==="LR"||u==="RL",p=new Map,g=[],m=[];i.nodes.forEach(($,y)=>p.set($.id,y));for(let $ of i.nodes){let y=Ot($.cssStyles.length>0?$.cssCompiledStyles.concat($.cssStyles):$.cssCompiledStyles),E=(y.bold?1:0)|(y.italic?2:0),w=y.fontSize??a,T=$.labelType==="markdown",_=On($.stereotype&&`«${$.stereotype}»`,!1,o,s,200,E),M={node:$,kind:2,style:y,label:_,stereotype:_,w:0,h:0,rows:[],keyW:0,headH:0,loops:0},U;if($.isGroup){M.kind=4,M.label=On($.label,T,o,w,4e3,E);let j=M.label.height;U=Bt(0,0),U.isGroup=!0,U.padX=Jo,U.padBottom=Jo,U.padTop=$.boundaryType==="package"?j+2*Ku+16:j>0?j+16:Jo,U.minW=M.label.width+2*Jo}else{if($.jsonRows){M.kind=3,M.label=On($.label,!1,o,w,4e3,E|1);let j=0;for(let Y of $.jsonRows){let D=On(Y.key,!1,o,l,4e3,E),L=On(Y.value,!1,o,l,260,E);M.rows.push([D,L]),M.keyW=Math.max(M.keyW,D.width),j=Math.max(j,L.width),M.h+=Math.max(D.height,L.height,Math.round(l*1.5))+Zu}M.keyW>0&&(M.keyW+=2*Ss),M.headH=Math.max(M.label.height,Math.round(w*1.5))+Zu,M.w=Math.max(M.label.width+2*Ss,M.rows.length>0?M.keyW+j+2*Ss:0,72),M.h+=M.headH}else if($.actorType)M.kind=0,M.label=On($.label,T,o,w,140,E),M.w=Math.max(wp,M.label.width,_.width),M.h=Js+cx+_.height+M.label.height;else{M.label=On($.label,T,o,$.shape==="note"?l:w,180,E);let j=Math.max(M.label.width,_.width),Y=M.label.height+_.height;$.shape==="usecaseEllipse"||$.shape==="usecaseBusiness"?(M.kind=1,M.w=Math.max(j+2*$.padding+($.business?16:4),88),M.h=Math.max(Y+28,48)):$.shape==="note"?(M.w=j+2*$.padding+6,M.h=Y+18):(M.w=Math.max(j+2*$.padding+12,80),M.h=Math.max(Y+24,44))}U=Bt(M.w,M.h)}U.seq=g.length,g.push(M),m.push(U)}i.nodes.forEach(($,y)=>{m[y].parent=$.parentId!==void 0?p.get($.parentId)??-1:-1});let v=[],x=[],k=[];for(let $ of i.edges){let y=p.get($.start),E=p.get($.end);if(y===void 0||E===void 0)continue;let w=$.relationshipType==="include"||$.relationshipType==="extend",T=On(w?`«${$.label}»`:$.label,$.labelType==="markdown",o,l,200);y===E&&(g[y].loops++,d?m[y].h+=2*(Xu+(T.height>0?T.height+8:0)):m[y].w+=2*(Xu+(T.width>0?T.width+12:0))),k.push($),x.push(T),v.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 b=Ai(m,v,u,{nodeSep:dx(t,"nodeSpacing",$5),edgeSep:k5,rankSep:dx(t,"rankSpacing",M5),portSep:20}),C=Mn(e.title,o,a,4e3),N=C.height>0?C.height+12:0,R=Math.max(b.width,C.width),O=c+(R-b.width)/2,P=c+N;Zc(m,v,O,P);let H=Math.ceil(R+2*c),I=Math.ceil(b.height+N+2*c),G=new Map;for(let $ of v)Ma(G,$.route);A5(v,m,g);let Z="",z="";for(let $=0;$<g.length;$++){let y=g[$],E=m[$],w=y.node,T=jt(w.cssClasses.replace(/^default\s?/,"")),_=Ge(w.id),M=y.style.text,U=y.style.shape,j=y.w,Y=y.h;if(y.kind===4){let F=E.x-E.w/2,V=E.y-E.h/2,X=` fill="var(--_a)" fill-opacity="0.5" stroke="var(--_b)"${U}`,Q=` class="pele-cluster-label" fill="var(--_m)"${M}`,ne;if(w.boundaryType==="package"){let B=Math.min(y.label.width+2*Ku+8,E.w),K=y.label.height+2*Ku;ne=`<rect class="pele-boundary-tab" x="${f(F)}" y="${f(V)}" width="${f(B)}" height="${f(K)}"${X}/><rect x="${f(F)}" y="${f(V+K)}" width="${f(E.w)}" height="${f(E.h-K)}"${X}/>`+Le(y.label,F+B/2,V+K/2,Q,h)}else ne=`<rect x="${f(F)}" y="${f(V)}" width="${f(E.w)}" height="${f(E.h)}"${_t(X)}/>`+Le(y.label,I5(E,y.label.width,G),V+8+y.label.height/2,Q,h);Z+=`<g class="pele-cluster pele-boundary${T}" data-id="${_}">${ne}</g>`;continue}let D,L;if(y.kind===0){L="pele-actor";let F=-Y/2,V=F+Js+cx+y.stereotype.height/2;D=`<g class="pele-actor-figure" transform="translate(0,${f(F+Js/2)})">${S5(y,h)}</g>`+Le(y.stereotype,0,V,` class="pele-stereotype" font-size="${s}" fill="var(--_m)"`,h)+Le(y.label,0,Y/2-y.label.height/2,` class="pele-label"${M}`,h)}else if(y.kind===3){L="pele-json";let F=-j/2,V=-Y/2+y.headH,X="",Q=`M${f(F)},${f(V)}H${f(F+j)}`;y.keyW>0&&(Q+=`M${f(F+y.keyW)},${f(V)}V${f(Y/2)}`);for(let[ne,B]of y.rows){let K=Math.max(ne.height,B.height,Math.round(l*1.5))+Zu;X+=Le(ne,F+Ss+ne.width/2,V+K/2,' class="pele-json-key" fill="var(--_m)"',h)+N5(B,F+y.keyW+Ss,V+K/2,` class="pele-json-value"${M}`,h),V+=K}D=`<rect x="${f(F)}" y="${f(-Y/2)}" width="${f(j)}" height="${f(Y)}"${_t(el+U)}/><path class="pele-json-lines" d="${Q}" fill="none" stroke="var(--_b)"${y.style.line}/>`+Le(y.label,0,-Y/2+y.headH/2,` class="pele-label" font-weight="var(--_hw)"${M}`,h)+`<g font-size="${l}">${X}</g>`}else{let F=y.stereotype.height/2,V;if(y.kind===1){if(L="pele-usecase",V=`<ellipse rx="${f(j/2)}" ry="${f(Y/2)}"${el}${U}/>`,w.business){let X=j/2-15,Q=j/2-5,ne=B=>Y/2*Math.sqrt(1-(B/(j/2))**2);V+=`<path class="pele-business" d="M${f(X)},${f(ne(X))}L${f(Q)},${f(-ne(Q))}" fill="none" stroke="var(--_b)"${y.style.line}/>`}}else if(w.shape==="note"){L="pele-note";let X=j/2,Q=Y/2;V=`<path d="M${f(-X)},${f(-Q)}H${f(X-ec)}L${f(X)},${f(ec-Q)}V${f(Q)}H${f(-X)}Z" fill="var(--_a)" stroke="var(--_b)" stroke-linejoin="round"${U}/><path d="M${f(X-ec)},${f(-Q)}V${f(ec-Q)}H${f(X)}" fill="none" stroke="var(--_b)" stroke-linejoin="round"${y.style.line}/>`}else L="pele-usecase",V=`<rect x="${f(-j/2)}" y="${f(-Y/2)}" width="${f(j)}" height="${f(Y)}"${_t(el+U)}/>`;D=V+Le(y.stereotype,0,-y.label.height/2,` class="pele-stereotype" font-size="${s}" fill="var(--_m)"`,h)+Le(y.label,0,F,` class="pele-label"${w.shape==="note"?` font-size="${l}"`:""}${M}`,h)}z+=`<g class="pele-node ${L}${T}" data-id="${_}" transform="translate(${f(E.x)},${f(E.y)})">${D}</g>`}let W="",S="",A=new Map;for(let $=0;$<v.length;$++){let y=v[$],E=k[$],w=x[$],T=E.style.length>0||E.cssCompiledStyles.length>0?Ot(E.cssCompiledStyles.concat(E.style)):void 0,_=E.arrowTypeStart,M=E.arrowTypeEnd,U;if(y.src===y.dst){let D=m[y.src],L=g[y.src],F=A.get(y.src)??0;A.set(y.src,F+1);let V=d?2:1,X=Math.min(E2(L,V)/2,8+F*6),Q=Xu+F*8,[ne,B]=Yf(L,D,V,-X),[K,ie]=Yf(L,D,V,X),le=Math.hypot(Q,X)||1,J=d?X/le:Q/le,te=d?Q/le:X/le,ae=tc(_),ee=tc(M),re=(fe,pe,Me,Ae)=>d?`${f(fe+Me*X*(Ae?1:0))},${f(pe+Ae)}`:`${f(fe+Ae)},${f(pe+Me*X*(Ae?1:0))}`,de=d?ne-J*ae:ne+J*ae,ye=d?B+te*ae:B-te*ae,oe=K+J*ee,xe=ie+te*ee;U={d:`M${f(de)},${f(ye)}C${re(ne,B,-1,Q)} ${re(K,ie,1,Q)} ${f(oe)},${f(xe)}`,sx:ne,sy:B,sdx:d?J:-J,sdy:d?-te:te,ex:K,ey:ie,edx:-J,edy:-te},d?(y.labelX=D.x,y.labelY=Math.max(B,ie)+Q*.75+6+w.height/2):(y.labelX=Math.max(ne,K)+Q*.75+8+w.width/2,y.labelY=D.y)}else{if(y.route.length<6)continue;U=jn(y.route,void 0,tc(_),tc(M))}let j=T?.stroke?tt(T.stroke):"var(--_l)",Y=E.internal?"2 3":E.pattern==="dotted"?"5 4":E.animate?"9 5":"";if(W+=`<g class="pele-edge pele-${E.relationshipType}${jt(E.classes.replace(/^default relationship relationship-\S+\s?/,""))}" data-id="${Ge(E.id)}"${T?.line??""}><path d="${U.d}"${Y?` stroke-dasharray="${Y}"`:""}/>`+hx(_,U.sx,U.sy,U.sdx,U.sdy,j)+hx(M,U.ex,U.ey,U.edx,U.edy,j)+"</g>",w.width>0){let D=y.labelX,L=y.labelY,F=E.relationshipType==="include"||E.relationshipType==="extend";S+=kn(E.id,w,D,L,(F?' fill="var(--_m)"':"")+(T?.text??""),h)}}return{svg:mt("usecase",H,I,a,r,e,Le(C,H/2,c+C.height/2,' class="pele-title" font-weight="var(--_tw)"')+(Z?`<g class="pele-clusters">${Z}</g>`:"")+(W?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${W}</g>`:"")+(S?`<g class="pele-edge-labels" font-size="${l}">${S}</g>`:"")+`<g class="pele-nodes">${z}</g>`),width:H,height:I,links:[]}}function I5(e,t,r){let n=r.get(Math.round(e.y-e.h/2));if(t===0||n===void 0)return e.x;let i=e.x-e.w/2+6,a=e.x+e.w/2-6,l=n.filter(d=>d>i&&d<a).sort((d,p)=>d-p);l.push(a);let s=t/2+6,o=e.x,c=1/0,h=0,u=i;for(let d of l){if(d-u>=2*s){let p=Math.min(Math.max(e.x,u+s),d-s);Math.abs(p-e.x)<c&&(c=Math.abs(p-e.x),o=p)}else c===1/0&&d-u>h&&(h=d-u,o=(u+d)/2);u=d}return o}function N5(e,t,r,n,i){if(e.lines.length<2)return Le(e,t+e.width/2,r,n,i);let a="";for(let l=0;l<e.lines.length;l++)a+=Le(ul(e,l),t+e.widths[l]/2,r-e.height/2+hl(e,l),n,i);return a}var R5={type:"usecase",math:!0,parse:(e,t,r)=>y5(e,r),render:C5};function yi(e){let t=e.trim();return t.length>=2&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t}function Qu(e){return e.map(yi).sort()}var O5=class{type="venn";title;subsets=[];textNodes=[];styles=[];known=new Set;current;indent=!1;setDiagramTitle(e){this.title=e}addSubsetData(e,t,r){let n=Qu(e);this.current=n,n.length===1&&this.known.add(n[0]),this.subsets.push({sets:n,size:r??10/e.length**2,label:t?yi(t):void 0})}addTextData(e,t,r){this.textNodes.push({sets:Qu(e),id:yi(t),label:r?yi(r):void 0})}addStyleData(e,t){let r=new Map;for(let[n,i]of t)r.set(n,i&&yi(i));this.styles.push({targets:Qu(e),styles:r})}validateUnionIdentifiers(e){let t=e.map(yi).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}},fx=["$end","INVALID","EOF","NEWLINE","VENN","TITLE","SET","UNION","TEXT","INDENT_TEXT","STYLE","BRACKET_LABEL","NUMERIC","HEXCOLOR","RGBCOLOR","RGBACOLOR","IDENTIFIER","STRING","COMMA","COLON"],L5=[["venn-beta",4],["set",6],["union",7],["text",8],["style",10]],D5=class{constructor(e,t){this.src=e,this.host=t}src;host;text="";start=0;at=0;lineStart=!1;ended=!1;word(e,t){let r=this.src;for(let n=0;n<t.length;n++){let i=r.charCodeAt(e+n),a=t.charCodeAt(n);if(i!==a&&(i+32!==a||i<65||i>90))return!1}return!0}keyword(e,t){return this.word(e,t)&&!nt(this.src.charCodeAt(e+t.length))}color(e,t){let r=this.src,n=e+1;for(let i=0;i<t;i++){for(;Xe(r.charCodeAt(n));)n++;let a=n;for(;gt(r.charCodeAt(n))||r.charCodeAt(n)===46;)n++;if(n===a)return-1;for(;Xe(r.charCodeAt(n));)n++;if(r.charCodeAt(n)!==(i===t-1?41:44))return-1;n++}return n}lineEnd(e){let t=this.src.indexOf(`
149
+ `,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 n=e.charCodeAt(r);if(n===37&&e.charCodeAt(r+1)===37&&e.charCodeAt(r+2)!==123||n!==125&&e.charCodeAt(r+1)===37&&e.charCodeAt(r+2)===37){this.at=this.lineEnd(r+2);continue}if(this.lineStart){if(n===32||n===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}n!==10&&n!==13&&(this.host.setIndentMode(!1),this.lineStart=!1)}if(n===10||n===13){for(r++;e.charCodeAt(r)===10||e.charCodeAt(r)===13;)r++;return this.lineStart=!0,this.token(3,r)}if(n===37&&e.charCodeAt(r+1)===37){this.at=this.lineEnd(r);continue}if(n===32||n===9){for(r++;e.charCodeAt(r)===32||e.charCodeAt(r)===9;)r++;this.at=r;continue}if((n|32)>=97&&(n|32)<=122||n===95){if(this.word(r,"title")&&Xe(e.charCodeAt(r+5))){let i=r+6;for(;i<t;){let a=e.charCodeAt(i);if(a===35||a===10||a===59)break;i++}if(i>r+6)return this.token(5,i)}for(let[i,a]of L5)if(this.keyword(r,i))return this.token(a,r+i.length);if(this.word(r,"rgb")){let i=(e.charCodeAt(r+3)|32)===97,a=r+(i?4:3),l=e.charCodeAt(a)===40?this.color(a,i?4:3):-1;if(l!==-1)return this.token(i?15:14,l)}for(r++;nt(e.charCodeAt(r))||e.charCodeAt(r)===45;)r++;return this.token(16,r)}if(n===91){if(e.charCodeAt(r+1)===34){let a=e.indexOf('"',r+2);return a===-1||e.charCodeAt(a+1)!==93?1:(this.at=a+2,this.text=e.slice(r+2,a),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(gt(n)||n===46||n===43||n===45){(n===43||n===45)&&r++;let i=r;for(;gt(e.charCodeAt(r));)r++;if(r>i){if(e.charCodeAt(r)===46&&gt(e.charCodeAt(r+1)))for(r+=2;gt(e.charCodeAt(r));)r++}else if(e.charCodeAt(r)===46&&gt(e.charCodeAt(r+1)))for(r+=2;gt(e.charCodeAt(r));)r++;else return 1;return this.token(12,r)}if(n===35){let i=r+1;for(;i<r+9&&Px(e.charCodeAt(i));)i++;return i>=r+4?this.token(13,i):1}if(n===34){let i=e.indexOf('"',r+1);return i===-1?1:this.token(17,i+1)}return n===44?this.token(18,r+1):n===58?this.token(19,r+1):1}}token(e,t){return this.text=this.src.slice(this.at,t),this.at=t,e}},P5="'EOF', 'NEWLINE', 'TITLE', 'SET', 'UNION', 'TEXT', 'INDENT_TEXT', 'STYLE'",z5="'NUMERIC', 'IDENTIFIER', 'STRING', 'HEXCOLOR', 'RGBCOLOR', 'RGBACOLOR'";function F5(e,t){let r=new D5(e,t),n=-1,i=()=>n===-1?n=r.next():n,a=p=>{throw i()===1?vt("venn",e,r.start,"",!0):vt("venn",e,r.start,`Expecting ${p}, got '${fx[n]}'`)},l=()=>(n=-1,r.text),s=p=>(i()!==p&&a(`'${fx[p]}'`),l()),o=()=>(i()!==16&&n!==17&&a("'IDENTIFIER', 'STRING'"),l()),c=()=>{let p=[o()];for(;i()===18;)l(),p.push(o());return p},h=(p,g)=>{let m=i()===11?l():void 0,v;if(i()===19&&(l(),v=parseFloat(s(12))),g){if(p.length<2)throw new Je("union requires multiple identifiers","semantic",{type:"venn"});t.validateUnionIdentifiers(p)}t.addSubsetData(p,m,v),t.setIndentMode(!0)},u=p=>{let g=i();g!==16&&g!==17&&g!==12&&a("'NUMERIC', 'IDENTIFIER', 'STRING'");let m=l(),v=g!==12&&i()===11?l():void 0;t.addTextData(p(),m,v)},d=()=>{let p=c(),g=[];for(;;){let m=s(16);s(19);let v;if(i()===17)v=l();else{let x=[];for(;i()===16||n>=12&&n<=15;)x.push(l());x.length===0&&a(z5),v=x.join(" ")}if(g.push([m,v]),i()!==18)break;l()}t.addStyleData(p,g)};for(;i()===3;)l();for(s(4);;){let p=i();if(p===2)return;if((p<3||p>10||p===4)&&a(P5),l(),p===5)t.setDiagramTitle(r.text.slice(6));else if(p===6)h([o()],!1);else if(p===7)h(c(),!0);else if(p===8){let g=c();u(()=>g)}else p===9?u(()=>{let g=t.getCurrentSets();if(!g)throw new Je("text requires set","semantic",{type:"venn"});return g}):p===10&&d()}}var Vc=Math.PI*2;function W5(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 n=[];for(let i of e){if(i.sets.length<3)continue;let a=[...i.sets].sort();for(let l=0;l<a.length-1;l++)for(let s=l+1;s<a.length;s++){let o=[a[l],a[s]],c=JSON.stringify(o);if(t.has(c))continue;t.add(c);let h=r.get(o[0]),u=r.get(o[1]);n.push({sets:o,size:h!==void 0&&u!==void 0?Math.min(h,u)/4:2.5,label:""})}}return n.length>0?[...e,...n]:e}function B5(e,t,r){if(r>=e+t)return 0;let n=Math.min(e,t);if(r<=Math.abs(e-t))return Math.PI*n*n;let i=e*e*Math.acos((r*r+e*e-t*t)/(2*r*e)),a=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+a-l}function H5(e,t,r){let n=Math.abs(e-t),i=e+t;if(!(r>0))return i;if(r>=Math.PI*Math.min(e,t)**2)return n;for(let a=0;a<48;a++){let l=(n+i)/2;B5(e,t,l)>r?n=l:i=l}return(n+i)/2}function px(e,t,r,n,i,a){let l=1/0;for(let s of t){let o=e[s],c=n-o.x,h=i-o.y,u=o.r-Math.sqrt(c*c+h*h);if(u<l){if(u<a)return u;l=u}}for(let s of r){let o=e[s],c=n-o.x,h=i-o.y,u=Math.sqrt(c*c+h*h)-o.r;if(u<l){if(u<a)return u;l=u}}return l}function Gf(e,t,r){let n=0,i=0,a=e[t[0]];for(let g of t){let m=e[g];n+=m.x/t.length,i+=m.y/t.length,m.r<a.r&&(a=m)}let l=a.r,s=n,o=i,c=px(e,t,r,s,o,-1/0),h=0,u=(g,m)=>{let v=px(e,t,r,g,m,c-l*1e-9);if(!(v>c-l*1e-9))return!1;let x=Math.hypot(g-n,m-i);return v>c+l*1e-9||x<h-l*1e-9?(c=v,h=x,s=g,o=m,!0):!1},d=10;for(let g=-d;g<=d;g++)for(let m=-d;m<=d;m++)m*m+g*g<=d*d&&u(a.x+m*l/d,a.y+g*l/d);let p=l/d;for(let g=0;g<40&&p>l*1e-6;g++){let m=!1;for(let v=0;v<8;v++){let x=v*Vc/8;u(s+Math.cos(x)*p,o+Math.sin(x)*p)&&(m=!0)}m||(p/=2)}return{x:s,y:o,margin:c}}function j5(e){let t=new Map;for(let v of e)for(let x of v.sets)t.has(x)||t.set(x,10);for(let v of e)v.sets.length===1&&t.set(v.sets[0],v.size);let r=new Map,n=[],i=0;for(let v of t.values())Number.isFinite(v)&&v>i&&(i=v);i===0&&(i=10);let a=Math.sqrt(i/Math.PI);for(let[v,x]of t){r.set(v,n.length);let k=Number.isFinite(x)&&x>0?Math.sqrt(x/Math.PI):0;n.push({id:v,x:0,y:0,r:Math.max(k,a*.3)})}let l=n.length;if(l<2)return n;let s=new Map;for(let v of W5(e)){if(v.sets.length!==2)continue;let x=r.get(v.sets[0]),k=r.get(v.sets[1]);x!==k&&s.set(Math.min(x,k)*l+Math.max(x,k),v.size)}let o=new Map;for(let[v,x]of s)o.set(v,H5(n[Math.floor(v/l)].r,n[v%l].r,x));let c=a*.15,h=(v,x)=>o.get(v*l+x)??n[v].r+n[x].r+c;if(l===2)return n[1].x=h(0,1),n;if(l===3){let v=h(0,1),x=h(0,2),k=h(1,2),b=e.some(C=>new Set(C.sets).size===3);for(let C=0;C<40;C++){let N=v>0?(v*v+x*x-k*k)/(2*v):0;if(n[1].x=v,n[2].x=Math.max(-x,Math.min(x,N)),n[2].y=Math.sqrt(Math.max(x*x-N*N,0)),!b||Gf(n,[0,1,2],[]).margin>a*.12)break;v*=.94,x*=.94,k*=.94}return n}let u=0;for(let v of n)u+=2*v.r+c;let d=Math.min(300,Math.floor(3e6/(l*l)));if(l<=64){let v=u/Vc;n.forEach((x,k)=>{let b=k*Vc/l-Math.PI/2;x.x=Math.cos(b)*v,x.y=Math.sin(b)*v})}else{let v=Math.ceil(Math.sqrt(l)),x=2*a+c;n.forEach((k,b)=>{k.x=b%v*x,k.y=Math.floor(b/v)*x})}let p=new Float64Array(l),g=new Float64Array(l),m=new Int32Array(l);for(let v=0;v<d;v++){p.fill(0),g.fill(0),m.fill(0);for(let x=0;x<l;x++)for(let k=x+1;k<l;k++){let b=o.get(x*l+k),C=n[x].r+n[k].r+c,N=n[k].x-n[x].x,R=n[k].y-n[x].y,O=Math.hypot(N,R);if(b===void 0&&O>=C)continue;O<1e-9&&(N=Math.cos(x+k),R=Math.sin(x+k),O=1);let P=(O-(b??C))/2/O;p[x]+=N*P,g[x]+=R*P,p[k]-=N*P,g[k]-=R*P,m[x]++,m[k]++}for(let x=0;x<l;x++)m[x]!==0&&(n[x].x+=p[x]/m[x],n[x].y+=g[x]/m[x])}return n}function U5(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 n=(o,c,h,u)=>{for(let d of e)if(d!==h&&d!==u&&Math.hypot(o-d.x,c-d.y)>d.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 h=e[o],u=e[c],d=Math.hypot(u.x-h.x,u.y-h.y);if(d>=h.r+u.r||d<=Math.abs(h.r-u.r)||d===0)continue;let p=(h.r*h.r-u.r*u.r+d*d)/(2*d),g=Math.sqrt(Math.max(h.r*h.r-p*p,0)),m=h.x+(u.x-h.x)*p/d,v=h.y+(u.y-h.y)*p/d;for(let x of[1,-1]){let k=m+x*g*(u.y-h.y)/d,b=v-x*g*(u.x-h.x)/d;n(k,b,h,u)&&i.push({x:k,y:b,a:h,b:u})}}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 a=0,l=0;for(let o of i)a+=o.x/i.length,l+=o.y/i.length;i.sort((o,c)=>Math.atan2(o.y-l,o.x-a)-Math.atan2(c.y-l,c.x-a));let s="";for(let o=0;o<i.length;o++){let c=i[o],h=i[(o+1)%i.length];o===0&&(s=`M${t(c.x)},${t(c.y)}`);let u,d=0,p=1/0;for(let g of[c.a,c.b]){if(g!==h.a&&g!==h.b)continue;let m=Math.atan2(c.y-g.y,c.x-g.x),v=Math.atan2(h.y-g.y,h.x-g.x)-m;v<=0&&(v+=Vc);let x=g.x+g.r*Math.cos(m+v/2),k=g.y+g.r*Math.sin(m+v/2),b=Math.hypot(x-(c.x+h.x)/2,k-(c.y+h.y)/2);b<p&&(p=b,u=g,d=v>Math.PI?1:0)}u===void 0?s+=`L${t(h.x)},${t(h.y)}`:s+=`A${t(u.r)},${t(u.r)} 0 ${d} 1 ${t(h.x)},${t(h.y)}`}return s+"Z"}var Y5=100,G5=1.6,gx=Ot([]);function Ju(e){return e.length===1?e[0]:JSON.stringify(e)}function V5(e,t,r){let n=r.fontSize??16,i=Math.round(n*.875),a=Math.round(n*.8125),l=r.measurer??bt(r.fontFamily),s=r.padding??8,o=j5(e.subsets),c=new Map;o.forEach(($,y)=>c.set($.id,y));let h=new Map;for(let{targets:$,styles:y}of e.styles){let E=Ju($),w=h.get(E);w||h.set(E,w=new Map);for(let[T,_]of y)w.set(T,_)}let u=$=>{let y=h.get($);if(!y)return gx;let E=[];for(let[w,T]of y)E.push(`${w}:${T}`);return Ot(E)},d=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&&(d[$].push(y),d[y].push($));let p=new Map;for(let $ of e.subsets)p.set(Ju($.sets),$);let g=new Map;for(let[$,y]of p){let E=[...new Set(y.sets)],w=E.map(L=>c.get(L)),T=new Set(w),_=w[0];for(let L of w)o[L].r<o[_].r&&(_=L);let M=u($),U=y.label??(y.sets.length===1?y.sets[0]:void 0),j=(M.bold?1:0)|(M.italic?2:0),Y=Gf(o,w,d[_].filter(L=>!T.has(L)));Y.margin<o[_].r*.2&&(Y=Gf(o,w,[]));let D={sets:E,inside:w,spot:Y,lines:[],style:M};if(U){let L=E.length===1?n:i;D.lines.push({id:void 0,raw:U,size:L,base:j,label:Ve(U,!1,l,L,4e3,j)})}g.set($,D)}for(let $ of e.textNodes){let y=$.label??$.id;g.get(Ju($.sets))?.lines.push({id:$.id,raw:y,size:a,base:0,label:Ve(y,!1,l,a,4e3)})}let m=0;for(let $ of o)$.r>m&&(m=$.r);let v=m>0?Y5/m:1,x=1;for(let $ of g.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 w=Math.hypot(y,E)/2+4;x=Math.max(x,Math.min(w/($.spot.margin*v),G5))}v*=x;for(let $ of g.values()){let y=Math.max($.spot.margin*v*1.8,72);for(let E of $.lines)E.label.width>y&&(E.label=Ve(E.raw,!1,l,E.size,y,E.base))}let k=1/0,b=1/0,C=-1/0,N=-1/0;for(let $ of o)k=Math.min(k,($.x-$.r)*v),b=Math.min(b,($.y-$.r)*v),C=Math.max(C,($.x+$.r)*v),N=Math.max(N,($.y+$.r)*v);for(let $ of g.values()){let y=0,E=0;for(let w of $.lines)y=Math.max(y,w.label.width),E+=w.label.height;k=Math.min(k,$.spot.x*v-y/2),C=Math.max(C,$.spot.x*v+y/2),b=Math.min(b,$.spot.y*v-E/2),N=Math.max(N,$.spot.y*v+E/2)}o.length===0&&(k=b=C=N=0);let R=Ve(e.title&&yi(e.title),!1,l,n,4e3,1),O=R.height>0?R.height+12:0,P=Math.max(C-k,R.width),H=s+(P-(C-k))/2-k,I=s+O-b,G=Math.ceil(P+2*s),Z=Math.ceil(N-b+O+2*s),z=o.map($=>({id:$.id,x:$.x*v+H,y:$.y*v+I,r:$.r*v})),W="";z.forEach(($,y)=>{let E=kt(y),w=g.get($.id)?.style??gx;W+=`<circle class="pele-venn-set" data-id="${Ge($.id)}" cx="${f($.x)}" cy="${f($.y)}" r="${f($.r)}" fill="${E}" fill-opacity="0.2" stroke="${E}"${w.shape}/>`});let S="",A="";for(let $ of g.values()){let y=Ge($.sets.join("|"));if($.sets.length>1&&$.style.shape!==""){let M=U5($.inside.map(U=>z[U]),f);M!==""&&(S+=`<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 w=$.spot.x*v+H,T=$.spot.y*v+I-E/2,_="";for(let M of $.lines){let U=M.id===void 0?` class="pele-label"${M.size===n?"":` font-size="${M.size}"`}${$.style.text}`:` class="pele-venn-text" data-id="${Ge(M.id)}" font-size="${a}" fill="var(--_m)"${u(M.id).text}`;_+=Le(M.label,w,T+M.label.height/2,U),T+=M.label.height}A+=`<g class="pele-venn-region" data-id="${y}">${_}</g>`}return{svg:mt("venn",G,Z,n,r,{},Le(R,G/2,s+R.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-venn-sets">${W}</g>`+(S?`<g class="pele-venn-overlaps">${S}</g>`:"")+(A?`<g class="pele-venn-labels">${A}</g>`:"")),width:G,height:Z,links:[]}}var q5={type:"venn",parse(e,t,r){let n=new O5;return r&&(n.title=r),F5(e,n),n},render:V5},X5=class{nodes=new Map;labels;links=[];trends=new Map;pipelines=new Map;annotations=[];notes=[];accelerators=[];deaccelerators=[];annotationsBox;axes={};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}}};function qc(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 ui(e,t,r){return{x:qc(t,`${r} evolution`),y:qc(e,`${r} visibility`)}}function mx(e){return e==="+<>"?"bidirectional":e==="+<"?"backward":e==="+>"?"forward":void 0}function K5(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 yx(e){return e?[(e.negX?-1:1)*e.offsetX,(e.negY?-1:1)*e.offsetY]:[void 0,void 0]}function Z5(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 n=ui(r.visibility,r.evolution,`Anchor "${r.name}"`);t.addNode({id:r.name,label:r.name,x:n.x,y:n.y,className:"anchor"})}for(let r of e.components){let n=ui(r.visibility,r.evolution,`Component "${r.name}"`),[i,a]=yx(r.label);t.addNode({id:r.name,label:r.name,x:n.x,y:n.y,className:"component",labelOffsetX:i,labelOffsetY:a,inertia:r.inertia,sourceStrategy:r.decorator?.strategy})}for(let r of e.notes){let n=ui(r.visibility,r.evolution,`Note "${r.text}"`);t.addNote({text:r.text,x:n.x,y:n.y})}for(let r of e.pipelines){let n=t.getNode(r.parent);if(!n||typeof n.y!="number")throw new Je(`Pipeline "${r.parent}" must reference an existing component with coordinates.`,"semantic",{type:"wardley"});let i=n.y;t.startPipeline(r.parent);for(let a of r.components){let l=`${r.parent}_${a.name}`,[s,o]=yx(a.label),c=qc(a.evolution,`Pipeline component "${a.name}" evolution`);t.addNode({id:l,label:a.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 n=!!r.arrow&&(r.arrow.includes("-.->")||r.arrow.includes(".-.")),i=K5(r.arrow),a=mx(r.fromPort)??mx(r.toPort)??i.flow;t.addLink({source:t.resolveNodeId(r.from),target:t.resolveNodeId(r.to),dashed:n,label:i.label??r.linkLabel,flow:a})}for(let r of e.evolves){let n=t.getNode(r.component);n?.y!==void 0&&t.addTrend({nodeId:r.component,targetX:qc(r.target,`Evolve target for "${r.component}"`),targetY:n.y})}if(e.annotations.length>0){let r=ui(e.annotations[0].x,e.annotations[0].y,"Annotations box");t.setAnnotationsBox(r.x,r.y)}for(let r of e.annotation){let n=ui(r.x,r.y,`Annotation ${r.number}`);t.addAnnotation({number:r.number,coordinates:[{x:n.x,y:n.y}],text:r.text})}for(let r of e.accelerators){let n=ui(r.x,r.y,`Accelerator "${r.name}"`);t.addAccelerator({name:r.name,x:n.x,y:n.y})}for(let r of e.deaccelerators){let n=ui(r.x,r.y,`Deaccelerator "${r.name}"`);t.addDeaccelerator({name:r.name,x:n.x,y:n.y})}}function Q5(e,t){let r=new X5;return Z5(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,`
150
+ `):void 0,...r.build()}}function xx(e,t){let r=t;for(let n=e.charCodeAt(r);n>=48&&n<=57;n=e.charCodeAt(r))r++;return r}function J5(){let e=0,t=0;return(r,n)=>{if((n<e||n>=t)&&(e=n,t=xx(r,n)),t===n||r.charCodeAt(t)!==46)return-1;let i=xx(r,t+1);return i>t+1?i:-1}}var bx={name:"ARROW",pattern:/->/y,first:"-"},wx={name:"LINK_ARROW",pattern:/-->|-\.->|>|\+'[^']*'<>|\+'[^']*'<|\+'[^']*'>/y,first:"->+"},sr=(e,t)=>({name:e,pattern:new RegExp(t,"y"),first:t[0]}),vx=[{name:"[",pattern:"["},{name:",",pattern:","},{name:"]",pattern:"]"},{name:"@",pattern:"@"},{name:"/",pattern:"/"},{name:"(",pattern:"("},{name:")",pattern:")"},{name:"-",pattern:"-",longer:[bx,wx,cr]},{name:"{",pattern:"{"},{name:"}",pattern:"}"},{name:"WARDLEY_NUMBER",pattern:/[0-9]+\.[0-9]+/y,first:"0123456789",scanner:J5},bx,{name:"LINK_PORT",pattern:/\+<>|\+>|\+</y,first:"+"},wx,{name:"LINK_LABEL",pattern:/;[^\n\r]+/y,first:";"},{name:"STRATEGY",pattern:/build|buy|outsource|market/y,first:"bom"},sr("KW_WARDLEY","wardley-beta"),sr("KW_SIZE","size"),sr("KW_EVOLUTION","evolution"),sr("KW_ANCHOR","anchor"),sr("KW_COMPONENT","component"),sr("KW_LABEL","label"),sr("KW_INERTIA","inertia"),sr("KW_EVOLVE","evolve"),sr("KW_PIPELINE","pipeline"),sr("KW_NOTE","note"),sr("KW_ANNOTATIONS","annotations"),sr("KW_ANNOTATION","annotation"),sr("KW_ACCELERATOR","accelerator"),sr("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:" "},lp(),Wr,Br,{name:"INT",pattern:/0|[1-9][0-9]*(?!\.)/y,first:"0123456789"},Si,{name:"ID",pattern:/[\w]([-\w]*\w)?/y,first:"_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"},Gn,Vn,cr,an,sn];function e6(e){let t=new Er($r(e,vx,"wardley"),vx,"wardley"),r={$type:"Wardley",anchors:[],components:[],links:[],evolves:[],pipelines:[],notes:[],annotations:[],annotation:[],accelerators:[],deaccelerators:[]},n=p=>t.kinds[t.i]===p,i=()=>n(36)||n(37)||n(30),a=()=>n(36)?Dr(t.take()):n(37)||n(30)?t.take():t.fail("a name"),l=()=>Number(t.expect(10)),s=()=>parseInt(t.expect(35)),o=()=>n(10)?Number(t.take()):parseInt(t.expect(35)),c=()=>{if(!n(-1))for(n(38)||t.fail("a line break or the end of input");n(38);)t.i++},h=p=>{t.expect(0);let g=p();t.expect(1);let m=p();return t.expect(2),[g,m]},u=()=>{t.expect(21),t.expect(0);let p=t.accept(7),g=s();t.expect(1);let m=t.accept(7),v=s();return t.expect(2),{$type:"Label",negX:p,offsetX:g,negY:m,offsetY:v}},d=()=>{let p={$type:"EvolutionStage",name:a()};return t.accept(3)&&(p.boundary=l()),t.accept(4)&&(p.secondName=a()),p};for(;n(38);)t.i++;for(t.expect(16);!n(-1);)switch(t.kind){case 38:t.i++;break;case 32:r.accDescr=_r(t.take()),c();break;case 33:r.accTitle=Mr(t.take()),c();break;case 34:r.title=kr(t.take()),c();break;case 17:{t.i++;let[p,g]=h(s);c(),r.size={$type:"Size",width:p,height:g};break}case 18:{t.i++;let p=[d()];for(t.expect(11),p.push(d());t.accept(11);)p.push(d());c(),r.evolution={$type:"Evolution",stages:p};break}case 19:{t.i++;let p=a(),[g,m]=h(l);c(),r.anchors.push({$type:"Anchor",name:p,visibility:g,evolution:m});break}case 20:{t.i++;let p={$type:"Component",name:a(),visibility:0,evolution:0,inertia:!1};[p.visibility,p.evolution]=h(l),n(21)&&(p.label=u()),n(5)&&t.kinds[t.i+1]===15&&(t.i++,p.decorator={$type:"Decorator",strategy:t.take()},t.expect(6)),t.accept(22)?p.inertia=!0:t.accept(5)&&(t.expect(22),t.expect(6),p.inertia=!0),c(),r.components.push(p);break}case 23:{t.i++;let p=a(),g=l();c(),r.evolves.push({$type:"Evolve",component:p,target:g});break}case 24:{t.i++;let p=a();for(t.expect(8),t.expect(38);n(38);)t.i++;let g=[];do{t.expect(20);let m={$type:"PipelineComponent",name:a(),evolution:0};t.expect(0),m.evolution=l(),t.expect(2),n(21)&&(m.label=u()),c(),g.push(m)}while(n(20));t.expect(9),c(),r.pipelines.push({$type:"Pipeline",parent:p,components:g});break}case 25:{t.i++;let p=Dr(t.expect(36)),[g,m]=h(l);c(),r.notes.push({$type:"Note",text:p,visibility:g,evolution:m});break}case 26:{t.i++;let[p,g]=h(o);c(),r.annotations.push({$type:"Annotations",x:p,y:g});break}case 27:{t.i++;let p=s();t.expect(1);let[g,m]=h(o),v=Dr(t.expect(36));c(),r.annotation.push({$type:"Annotation",number:p,x:g,y:m,text:v});break}case 28:case 29:{let p=t.kind===29;t.i++;let g=a(),[m,v]=h(l);c(),p?r.deaccelerators.push({$type:"Deaccelerator",name:g,x:m,y:v}):r.accelerators.push({$type:"Accelerator",name:g,x:m,y:v});break}default:{i()||t.fail("a statement");let p={$type:"Link",from:a(),to:""};n(12)&&(p.fromPort=t.take()),(n(13)||n(11))&&(p.arrow=t.take()),p.to=a(),n(12)&&(p.toPort=t.take()),n(14)&&(p.linkLabel=t.take().substring(1).trim()),c(),r.links.push(p)}}return r}var t6=["Genesis","Custom Built","Product","Commodity"],r6=48,St=6,fi=10,n6=8,rc=15,Cs=60,i6=30,$x=20,ef="var(--_c)",fr="var(--_l)";function a6(e,t,r,n,i){let a=e["wardley-beta"]?.[t];return typeof a=="number"&&a>=n&&a<=i?a:r}function da(e,t,r){return e<t?t:e>r?r:e}function kx(e,t,r,n){let i=ll(e),a="",l=r;for(let s of e.lines){let o=!0;for(let c of s){if(c.icon!==void 0)continue;let h=ka(c.style&~i);a+=`<tspan${o?` x="${f(t)}" y="${f(l)}"`:""}${h}>${tt(c.text)}</tspan>`,o=!1}l+=e.lineHeight}return a===""?"":`<text${Sa(n,i)} xml:space="preserve">${a}</text>`}function A2(e,t,r,n){let i=typeof t=="number"&&Number.isFinite(t)?t:a6(e,r,n,1,1e6);return da(i,200,1e4)-2*r6}function s6(e,t,r){let n=A2(t,e.size?.width,"width",900);return ed(r,n,160,(i,a)=>l6(e,t,r,i,n,a))}function l6(e,t,r,n,i,a){let l=r.fontSize??16,s=Math.round(l*.8125),o=Math.round(l*.6875),c=r.measurer??bt(r.fontFamily),h=r.padding??8,u=A2(t,e.size?.height,"height",600)*Math.max(.75,n/i),d=t["wardley-beta"]?.showGrid===!0,p=0,g=0,m=n,v=u,x=(oe,xe,fe,pe)=>{oe<p&&(p=oe),xe<g&&(g=xe),fe>m&&(m=fe),pe>v&&(v=pe)},k=(oe,xe,fe,pe)=>(x(xe-oe.width/2,fe-oe.height/2,xe+oe.width/2,fe+oe.height/2),Le(oe,xe,fe,pe,r.icons)),b=(oe,xe,fe,pe)=>(x(xe,fe-oe.size,xe+oe.width,fe-oe.size+oe.height+4),kx(oe,xe,fe,pe)),C=(oe,xe,fe=a?Math.max(64,Math.min(120,n/2)):4e3,pe=0)=>Ve(oe,!1,c,xe,fe,pe),N=oe=>oe/100*n,R=oe=>u-oe/100*u,O=e.axes.stages&&e.axes.stages.length>0?e.axes.stages:t6,P=e.axes.stageBoundaries,H=P!==void 0&&P.length===O.length,I="",G="",Z=u,z=0;if(O.forEach((oe,xe)=>{let fe=H?z:xe/O.length,pe=H?da(P[xe],0,1):(xe+1)/O.length;z=pe,xe>0&&(I+=`<path class="pele-wardley-stage" d="M${f(fe*n)},0V${f(u)}" stroke="var(--_b)" stroke-dasharray="4 4"/>`);let Me=C(oe,s,Math.max(48,Math.abs(pe-fe)*n-12));G+=k(Me,(fe+pe)/2*n,u+8+Me.height/2,` class="pele-wardley-stage-label" font-size="${s}" fill="var(--_m)"`),Z=Math.max(Z,u+8+Me.height)}),d)for(let oe=1;oe<4;oe++)I+=`<path class="pele-wardley-grid" d="M${f(n*oe/4)},0V${f(u)}M0,${f(u*oe/4)}H${f(n)}" stroke="var(--_b)" stroke-dasharray="2 6"/>`;I+=`<path class="pele-wardley-axis" d="M0,0V${f(u)}H${f(n)}" stroke="${fr}"/>`;let W=C(e.axes.xLabel??"Evolution",s),S=C(e.axes.yLabel??"Visibility",s),A=` class="pele-wardley-axis-label" font-size="${s}" font-weight="var(--_hw)"`,$=k(W,n/2,Z+6+W.height/2,A)+Le(S,-16,u/2,`${A} transform="rotate(-90 -16 ${f(u/2)})"`);x(-16-S.height/2,0,0,0);let y=Z+6+W.height+10,E=new Map;for(let oe of e.nodes)E.set(oe.id,{x:N(oe.x),y:R(oe.y),node:oe});let w="",T=new Map;for(let oe of e.pipelines){T.set(oe.nodeId,new Set(oe.componentIds));let xe=[];for(let ge of oe.componentIds){let be=E.get(ge);be&&xe.push(be)}if(xe.length===0)continue;xe.sort((ge,be)=>ge.x-be.x);let fe=xe[0].x,pe=xe[xe.length-1].x,Me=xe[0].y,Ae=Me-2*St,ce=E.get(oe.nodeId);ce&&(ce.x=(fe+pe)/2,ce.y=Ae-fi/6),x(fe-rc,Ae,pe+rc,Ae+4*St),w+=`<g class="pele-wardley-pipeline" data-id="${Ge(oe.nodeId)}"><rect x="${f(fe-rc)}" y="${f(Ae)}" width="${f(pe-fe+2*rc)}" height="${f(4*St)}" fill="var(--_s)" stroke="var(--_b)"${xt}/>`+(xe.length>1?`<path d="M${f(fe)},${f(Me)}H${f(pe)}" stroke="${fr}" stroke-dasharray="4 4"/>`:"")+"</g>"}let _=new Map,M=(oe,xe,fe)=>{let pe=oe.node;if(pe.className==="anchor"){let Me=_.get(pe);return Me||_.set(pe,Me=C(pe.label,s,a?Math.max(64,n/2):4e3,1)),1/Math.hypot(xe/(Me.width/2+5),fe/(s*.8))}return pe.isPipelineParent?fi/Math.SQRT2:pe.sourceStrategy?2*St:St},U=new Map,j=(oe,xe,fe)=>{Math.abs(xe)<.25||Math.abs(fe)<.25||U.set(oe,(U.get(oe)??0)|(xe>0?fe<0?1:2:fe<0?4:8))},Y="";for(let oe of e.links){let xe=E.get(oe.source),fe=E.get(oe.target);if(!xe||!fe||xe===fe||T.get(oe.target)?.has(oe.source))continue;let pe=fe.x-xe.x,Me=fe.y-xe.y,Ae=Math.hypot(pe,Me);if(Ae<.01)continue;let ce=pe/Ae,ge=Me/Ae,be=M(xe,ce,ge),Ie=M(fe,ce,ge);if(be+Ie>=Ae)continue;j(xe,ce,ge),j(fe,-ce,-ge);let Re=xe.x+ce*be,ze=xe.y+ge*be,he=fe.x-ce*Ie,$e=fe.y-ge*Ie,Se="";(oe.flow==="forward"||oe.flow==="bidirectional")&&(Se+=Ct("arrow_point",he,$e,ce,ge,fr),he-=ce*Et("arrow_point"),$e-=ge*Et("arrow_point")),(oe.flow==="backward"||oe.flow==="bidirectional")&&(Se+=Ct("arrow_point",Re,ze,-ce,-ge,fr),Re+=ce*Et("arrow_point"),ze+=ge*Et("arrow_point"));let we="";if(oe.label){let ke=C(oe.label,o+1,200),Ne=ce>=0?1:-1,Be=ge*Ne,Pe=-ce*Ne,q=5+Math.abs(Be)*ke.width/2+Math.abs(Pe)*ke.height/2;we=k(ke,(xe.x+fe.x)/2+Be*q,(xe.y+fe.y)/2+Pe*q,` class="pele-edge-label" font-size="${o+1}" fill="var(--_m)"`)}Y+=`<g class="pele-edge${oe.dashed?" pele-wardley-dashed":""}" data-id="${Ge(oe.source)}-${Ge(oe.target)}"><path d="M${f(Re)},${f(ze)}L${f(he)},${f($e)}" stroke="${fr}"${oe.dashed?' stroke-dasharray="6 6"':""}/>`+Se+we+"</g>"}let D="";for(let oe of e.trends){let xe=E.get(oe.nodeId);if(!xe)continue;let fe=N(oe.targetX),pe=R(oe.targetY),Me=fe-xe.x,Ae=pe-xe.y,ce=Math.hypot(Me,Ae),ge="",be=ce>0?M(xe,Me/ce,Ae/ce):0;if(ce>be+St+4){let Ie=Me/ce,Re=Ae/ce,ze=fe-Ie*(St+2),he=pe-Re*(St+2);ge=`<path d="M${f(xe.x+Ie*be)},${f(xe.y+Re*be)}L${f(ze-Ie*Et("arrow_point"))},${f(he-Re*Et("arrow_point"))}" stroke="${ef}" stroke-dasharray="4 4"/>`+Ct("arrow_point",ze,he,Ie,Re,ef)}x(fe-St,pe-St,fe+St,pe+St),D+=`<g class="pele-wardley-trend" data-id="${Ge(oe.nodeId)}">${ge}<circle cx="${f(fe)}" cy="${f(pe)}" r="${St}" fill="var(--_bg)" stroke="${ef}"/></g>`}let L="",F=1.2*St,V=.7*St;for(let oe of E.values()){let xe=oe.node,{x:fe,y:pe}=oe,Me=xe.className==="anchor",Ae=xe.sourceStrategy,ce="";if(Ae){let Re=Ae==="outsource"?"var(--_m)":Ae==="buy"?"var(--_a)":Ae==="build"?"var(--_s)":"var(--_bg)";ce+=`<circle class="pele-wardley-${Ae}" cx="${f(fe)}" cy="${f(pe)}" r="${2*St}" fill="${Re}" stroke="${fr}"/>`}if(Ae==="market"){let Re=F*Math.cos(Math.PI/6),ze=pe+F*Math.sin(Math.PI/6);ce+=`<path d="M${f(fe)},${f(pe-F)}L${f(fe-Re)},${f(ze)}H${f(fe+Re)}Z" fill="none" stroke="${fr}"/>`;for(let[he,$e]of[[fe,pe-F],[fe-Re,ze],[fe+Re,ze]])ce+=`<circle cx="${f(he)}" cy="${f($e)}" r="${f(V)}" fill="var(--_bg)" stroke="${fr}"/>`}else xe.isPipelineParent?ce+=`<rect x="${f(fe-fi/2)}" y="${f(pe-fi/2)}" width="${fi}" height="${fi}" fill="var(--_bg)" stroke="${fr}"/>`:Me||(ce+=`<circle cx="${f(fe)}" cy="${f(pe)}" r="${St}" fill="var(--_bg)" stroke="${fr}"/>`);if(xe.inertia===!0){let Re=(xe.isPipelineParent?fi/2:St)+10+(Ae?St+4:0);ce+=`<rect class="pele-wardley-inertia" x="${f(fe+Re)}" y="${f(pe-St)}" width="4" height="${2*St}" fill="${fr}"/>`}let ge=xe.labelOffsetX===void 0?void 0:da(xe.labelOffsetX,-5e3,5e3),be=xe.labelOffsetY===void 0?void 0:da(xe.labelOffsetY,-5e3,5e3),Ie;if(Me){let Re=_.get(xe)??C(xe.label,s,a?Math.max(64,n/2):4e3,1);Ie=k(Re,fe+(ge??0),pe+(be??-3),` class="pele-label" font-size="${s}" font-weight="var(--_hw)"`)}else{let Re=C(xe.label,s),ze=` class="pele-label" font-size="${s}"`,he=n6+(Ae?10:0);if(ge!==void 0||be!==void 0)Ie=b(Re,fe+(ge??he),pe+(be??-he),ze);else if(xe.inPipeline)Ie=k(Re,fe,pe+2*St+4+Re.height/2,ze);else{let $e=U.get(oe)??0,Se=($e&1)===0?1:($e&2)===0?2:($e&4)===0?4:($e&8)===0?8:1,we=Se===1||Se===2,ke=Se===1||Se===4;Ie=b(Re,we?fe+he:fe-he-Re.width,ke?pe-he:pe+he+s*.75,ze)}}x(fe-2*St,pe-2*St,fe+2*St+20,pe+2*St),L+=`<g class="pele-node pele-wardley-${Me?"anchor":xe.isPipelineParent?"pipeline-parent":xe.inPipeline?"pipeline-component":"component"}" data-id="${Ge(xe.id)}">${ce}${Ie}</g>`}let X="";for(let oe of e.annotations){let xe=C(String(oe.number),o,4e3,1),fe="";for(let pe of oe.coordinates){let Me=N(pe.x),Ae=R(pe.y),ce=Math.max(10,xe.width/2+4);x(Me-ce,Ae-ce,Me+ce,Ae+ce),fe+=`<circle cx="${f(Me)}" cy="${f(Ae)}" r="${f(ce)}" fill="var(--_bg)" stroke="${fr}"/>`+Le(xe,Me,Ae,` font-size="${o}" font-weight="var(--_hw)"`)}X+=`<g class="pele-wardley-annotation" data-id="${Ge(String(oe.number))}">${fe}</g>`}let Q=e.annotations.filter(oe=>oe.text).sort((oe,xe)=>oe.number-xe.number);if(Q.length>0){let oe=Q.map(be=>C(`${be.number}. ${be.text}`,s,a?Math.max(80,n-20):320)),xe=0,fe=0;for(let be of oe)xe=Math.max(xe,be.width),fe+=be.height;xe+=20,fe+=14;let pe=e.annotationsBox,Me=pe?da(N(pe.x),0,Math.max(0,n-xe)):0,Ae=pe?da(R(pe.y),0,Math.max(0,u-fe)):y;x(Me,Ae,Me+xe,Ae+fe);let ce="",ge=Ae+7;for(let be of oe)ce+=kx(be,Me+10,ge+be.lineHeight/2+s*.35,` font-size="${s}"`),ge+=be.height;X+=`<g class="pele-wardley-annotations"><rect x="${f(Me)}" y="${f(Ae)}" width="${f(xe)}" height="${f(fe)}" fill="var(--_bg)" stroke="var(--_b)"${xt}/>${ce}</g>`}let ne="";for(let oe of e.notes)ne+=b(C(oe.text,s,Math.min(360,n*.6),1),N(oe.x),R(oe.y),` class="pele-wardley-note" font-size="${s}" font-weight="var(--_hw)"`);let B="",K=(oe,xe,fe,pe)=>{let Me=N(xe),Ae=R(fe),ce=i6/2,ge=pe?Me+Cs:Me,be=pe?Me:Me+Cs,Ie=pe?Me+Cs-$x:Me+$x,Re=`M${f(be)},${f(Ae-ce)}H${f(Ie)}V${f(Ae-ce-8)}L${f(ge)},${f(Ae)}L${f(Ie)},${f(Ae+ce+8)}V${f(Ae+ce)}H${f(be)}Z`;x(Me,Ae-ce-8,Me+Cs,Ae+ce+8),B+=`<g class="pele-wardley-${pe?"accelerator":"deaccelerator"}" data-id="${Ge(oe)}"><path d="${Re}" fill="var(--_s)" stroke="${fr}"/>`+k(C(oe,o+1,160,1),Me+Cs/2,Ae+ce+8+12,` font-size="${o+1}" font-weight="var(--_hw)"`)+"</g>"};for(let oe of e.accelerators)K(oe.name,oe.x,oe.y,!0);for(let oe of e.deaccelerators)K(oe.name,oe.x,oe.y,!1);let ie=Ve(e.title,!1,c,l,a?Math.max(80,n):4e3,1),le=ie.height>0?ie.height+12:0,J=Math.min(p,n/2-ie.width/2),te=Math.max(m,n/2+ie.width/2),ae=h-J,ee=h+le-g,re=Math.ceil(te-J+2*h),de=Math.ceil(v-g+le+2*h),ye=Le(ie,ae+n/2,h+ie.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${f(ae)},${f(ee)})"><g class="pele-wardley-frame" fill="none">${I}</g>`+G+$+w+(Y?`<g class="pele-edges" fill="none">${Y}</g>`:"")+(D?`<g class="pele-wardley-trends" fill="none">${D}</g>`:"")+L+X+ne+B+"</g>";return{svg:mt("wardley",re,de,l,r,e,ye),width:re,height:de,links:[]}}var o6={type:"wardley",section:"wardley-beta",parse:(e,t,r)=>Q5(e6(e),r),render:s6},c6=class{type="xychart";title;accTitle;accDescr;orientation;xAxis={type:"band",title:"",categories:[]};yAxis={type:"linear",title:"",min:1/0,max:-1/0};hasSetXAxis=!1;hasSetYAxis=!1;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:n,max:i}=this.yAxis;for(let a of e)a<n&&(n=a),a>i&&(i=a);this.yAxis={type:"linear",title:this.yAxis.title,min:n,max:i}}if(t.type==="band")return t.categories.map((n,i)=>[n,e[i]]);if(e.length===1)return[[`${t.min}`,e[0]]];let r=(t.max-t.min)/(e.length-1);return e.map((n,i)=>[`${t.min+i*r}`,n])}addPlot(e,t,r){let n={type:e,title:t.text.trim(),data:this.plotData(r.map(i=>i.value))};e==="line"&&r.some(i=>i.label.trim()!=="")&&(n.pointLabels=r.map(i=>i.label.trim())),this.plots.push(n)}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,`
151
+ `)}},Mx=["$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"],_x=[33,33,33,33,33,19,5,7,8],Ex="`)"+" ".repeat(36)+'{ this.pushstate(md_string); }\n<md_string>(?:(?!`").)+'+" ".repeat(18)+"{ return md_str; }\n<md_string>(?:`",Vf=new Uint8Array(128);for(let[e,t]of[[":",21],["+",22],[",",23],["=",24],["*",25],["#",26],["_",27],[".",28],["&",29],["-",30],[";",32]])Vf[e.charCodeAt(0)]=t;function d6(e){let t=e.length,r=[],n=[],i=[],a=[],l=0,s=0,o=(m,v,x)=>{r.push(m),n.push(e.slice(v,x)),i.push(v),s=x},c=m=>{a.push(l),l=m},h=()=>{a.length>0&&(l=a.pop())},u=m=>{let v=e.indexOf(`
152
+ `,m);return v===-1?t:v},d=m=>{for(;m<t&&Xe(e.charCodeAt(m));)m++;return m},p=m=>{for(;gt(e.charCodeAt(m));)m++;return m},g=m=>Jt(e,s,m)&&!nt(e.charCodeAt(s+m.length));for(;s<t;){let m=e.charCodeAt(s);if(l===5){if(m===34)s++,h();else{let x=e.indexOf('"',s);o(19,s,x===-1?t:x)}continue}if(l===6||l===7){o(_x[l],s,u(s)),h();continue}if(l===8){if(m===125)s++,h();else{let x=e.indexOf("}",s);o(8,s,x===-1?t:x)}continue}let v=e.charCodeAt(s+1);if(m===37&&v===37){s=u(s+2);continue}if(m!==125&&v===37&&e.charCodeAt(s+2)===37){s=u(s+3);continue}if(m===10||m===13){if((l===1||l===3)&&(m===10||v===10)){o(2,s,m===10?s+1:s+2),h();continue}let x=s+1;for(let k=e.charCodeAt(x);k===10||k===13;k=e.charCodeAt(++x));o(2,s,x);continue}switch(m|32){case 116:if(g("title")){o(3,s,s+5);continue}break;case 97:if(Jt(e,s,"acc")){let x=Jt(e,s+3,"descr");if(x||Jt(e,s+3,"title")){let k=d(s+8),b=e.charCodeAt(k);if(b===58){o(x?6:4,s,d(k+1)),c(x?7:6);continue}if(b===123&&x){s=d(k+1),c(8);continue}}}break;case 120:if(g("xychart-beta")){o(9,s,s+12);continue}if(g("xychart")){o(9,s,s+7);continue}if(g("x-axis")){o(11,s,s+6),c(1);continue}break;case 121:if(g("y-axis")){o(12,s,s+6),c(1);continue}break;case 118:if(Jt(e,s,"vertical")){o(10,s,s+8);continue}break;case 104:if(Jt(e,s,"horizontal")){o(10,s,s+10);continue}break;case 108:if(g("line")){o(14,s,s+4),c(3);continue}break;case 98:if(g("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)&&h(),o(18,s,s+1);continue}if(l===1&&m===45&&v===45&&e.charCodeAt(s+2)===62){o(13,s,s+3);continue}if(l===1||l===4){let x=m===43||m===45?s+1:s,k=e.charCodeAt(x),b=-1;if(gt(k)?(b=p(x+1),e.charCodeAt(b)===46&&gt(e.charCodeAt(b+1))&&(b=p(b+2))):k===46&&gt(e.charCodeAt(x+1))&&(b=p(x+2)),b!==-1){o(16,s,b);continue}}if(m===96&&Jt(e,s,Ex)){s+=Ex.length,h();continue}if(m===34){s++,c(5);continue}if($a(m)){let x=s+1;for(;$a(e.charCodeAt(x));)x++;o(20,s,x);continue}if(gt(m)){o(31,s,p(s+1));continue}if(Xe(m)){s=d(s+1);continue}if(m<128&&Vf[m]!==0){o(Vf[m],s,s+1);continue}break}return s<t?(r.push(1),n.push(""),i.push(s),{types:r,texts:n,starts:i}):(r.push(_x[l]),n.push(""),i.push(t),r.push(0),n.push(""),i.push(t),{types:r,texts:n,starts:i})}function T2(...e){let t=new Uint8Array(34);for(let r of e)t[r]=1;return t}var Ax=T2(29,31,20,22,24,25,28,26,30,27),Tx=T2(2,32,33);function h6(e,t){let{types:r,texts:n,starts:i}=d6(e),a=0,l=d=>{let p=r[a];throw p===1?vt("xychart",e,i[a],"",!0):vt("xychart",e,i[a],`Expecting ${d}, got '${Mx[p]}'`)},s=d=>(r[a]!==d&&l(`'${Mx[d]}'`),n[a++]),o=d=>d===19||Ax[d]===1,c=()=>{o(r[a])||l("'STR', 'ALPHA', 'NUM'");let d=n[a++];if(r[a-1]!==19)for(;Ax[r[a]]===1;)d+=n[a++];return{text:d,type:"text"}},h=()=>{let d=Number(s(16));return s(13),[d,Number(s(16))]},u=()=>{let d=[];for(s(17);;){let p=Number(s(16));if(d.push({value:p,label:r[a]===19?n[a++]:""}),r[a]!==23)break;a++}return s(18),d};for(;;)if(Tx[r[a]]===1)a++;else{if(r[a]!==9)break;r[++a]===10&&t.setOrientation(n[a++])}for(;r[a]!==0;){let d=r[a++];switch(d){case 3:t.setDiagramTitle(c().text.trim());break;case 11:case 12:{let p=o(r[a])?c():void 0;if(d===11&&r[a]===17){let g=[];do a++,g.push(c());while(r[a]===23);s(18),t.setXAxisBand(g)}else if(r[a]===16||p===void 0){let[g,m]=h();d===11?t.setXAxisRangeData(g,m):t.setYAxisRangeData(g,m)}d===11?t.setXAxisTitle(p??{type:"text",text:""}):t.setYAxisTitle(p??{type:"text",text:""});break}case 14:case 15:{let p=r[a]===17?{text:"",type:"text"}:c(),g=u();d===14?t.setLineData(p,g):t.setBarData(p,g);break}case 4:t.setAccTitle(s(5).trim());break;case 6:t.setAccDescription(s(7).trim());break;case 8:t.setAccDescription(n[a-1].trim());break;default:a--,l("'title', 'X_AXIS', 'Y_AXIS', 'LINE', 'BAR', 'acc_title', 'acc_descr', 'acc_descr_multiline_value'")}for(;Tx[r[a]]===1;)a++}}function Sx(e,t){let r=e/Math.max(t,1),n=Math.floor(Math.log10(r)),i=r/10**n,a=i>=7.07?10:i>=3.16?5:i>=1.41?2:1;return n<0?-(10**-n)/a:a*10**n}function Xc(e,t){return e>0?t/e:t*-e}function tl(e,t){return e>0?t*e:t/-e}function Cx(e,t,r){let n=Math.round(Xc(r,e));tl(r,n)<e&&n++;let i=Math.round(Xc(r,t));tl(r,i)>t&&i--;let a=[];for(let l=n;l<=i&&a.length<100;l++)a.push(tl(r,l));return a}var Ix=4,la=12,Nx=26,Rx=24,Ox=1e300;function tf(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{}}function br(e,t,r=!0){let n=e[t];return typeof n=="boolean"?n:r}function Lx(e,t){return typeof e=="number"&&e>0?Math.round(Math.min(Math.max(e,100),4e3)):t}function Ln(e){return typeof e=="number"&&isFinite(e)?Math.min(Math.max(e,-Ox),Ox):void 0}function u6(e){let t=0;for(let r of e)t=Math.max(t,r.label.width);return t}function nc(e,t,r,n){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="${f(t)}" y="${f(r+e.size*.35)}" text-anchor="${n}">${tt(i[0].text)}</text>`:Le(e,t+(n==="start"?e.width/2:n==="end"?-e.width/2:0),r,"")}function f6(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 n=tf(t.xyChart),i=r.fontSize??16,a=Math.round(i*.875),l=Math.round(i*.75),s=r.measurer??bt(r.fontFamily),o=r.padding??8,c=Lx(n.width,700),h=td(r,c,240),u=Math.round(Lx(n.height,500)*Math.max(.6,h/c)),d=(e.orientation??n.chartOrientation)==="horizontal",p=br(n,"showDataLabel",!1),g=e.xAxis,m=e.plots,v=(Ee,Ye,qe)=>Ve(Ee,!1,s,Ye,qe),x=v("0",a,4e3).height,k=v("0",l,4e3).height,b=Ve(br(n,"showTitle")?e.title:void 0,!1,s,i,h-2*o,1),C=b.height>0?b.height+12:0,N=[],R=0;br(n,"showLegend")&&m.forEach((Ee,Ye)=>{if(Ee.title==="")return;let qe=v(Ee.title,a,h*.3);N.push({index:Ye,label:qe}),R=Math.max(R,qe.width+la+8)});let O=N.length>0?R+Rx:0,P=m.filter(Ee=>Ee.type==="bar").length,H=e.yAxis.min,I=e.yAxis.max,G=e.hasSetYAxis&&isFinite(H)&&isFinite(I)&&H!==I;if(G)H=Ln(H),I=Ln(I);else{H=1/0,I=-1/0;for(let Ee of m)for(let[,Ye]of Ee.data){let qe=Ln(Ye);qe!==void 0&&(qe<H&&(H=qe),qe>I&&(I=qe))}H>I&&(H=I=0),P>0&&(H=Math.min(H,0),I=Math.max(I,0)),H===I&&(H===0?I=1:(H-=Math.abs(H)/2,I+=Math.abs(I)/2))}let Z=(Ee,Ye)=>{let qe=Sx(Math.abs(I-H),Math.max(2,Math.min(10,Math.floor(Ee/Ye))));return G||(H=tl(qe,Math.floor(Xc(qe,H)+1e-9)),I=tl(qe,Math.ceil(Xc(qe,I)-1e-9))),Cx(Math.min(H,I),Math.max(H,I),qe).map(Qe=>({at:(Qe-H)/(I-H),label:v(String(Qe),a,4e3)}))},z=1;if(g.type==="band")z=Math.max(g.categories.length,1);else for(let Ee of m)z=Math.max(z,Ee.data.length);let W=1/z,S=g.type==="band"||P>0?W/2:0,A=Ln(g.type==="linear"?g.min:void 0),$=Ln(g.type==="linear"?g.max:void 0),y=A!==void 0&&$!==void 0&&A!==$,E=(Ee,Ye)=>g.type==="band"?(Ee+.5)*W:S+(Ye>1?Ee/(Ye-1):y?0:.5)*(1-2*S),w=tf(n.xAxis),T=tf(n.yAxis),_=d?w:T,M=d?T:w,U=v(br(_,"showTitle")?d?g.title:e.yAxis.title:void 0,a,u*.8),j=v(br(M,"showTitle")?d?e.yAxis.title:g.title:void 0,a,h*.8),Y=br(_,"showTick")?Ix:0,D=br(M,"showTick")?Ix:0,L=br(_,"showLabel"),F=br(M,"showLabel"),V=d?h*.3:Math.max(48,(h-2*o-64-O)*W-8),X=g.type==="band"&&br(w,"showLabel")?g.categories.map(Ee=>v(Ee,a,V)):[],Q=0,ne=0;for(let Ee of X)Q=Math.max(Q,Ee.width),ne=Math.max(ne,Ee.height);let B=Ee=>{let Ye=[];if(g.type==="band"){let qe=X.length===0?8:d?ne:Q+12,Qe=Math.max(1,Math.ceil(qe/(Ee*W)));for(let lt=0;lt<g.categories.length;lt+=Qe)Ye.push({at:(lt+.5)*W,label:X[lt]??v(void 0,a,0)})}else if(y){let qe=Sx(Math.abs($-A),Math.max(2,Math.min(10,Math.floor(Ee/(d?32:80)))));for(let Qe of Cx(Math.min(A,$),Math.max(A,$),qe))Ye.push({at:S+(Qe-A)/($-A)*(1-2*S),label:v(String(Qe),a,4e3)})}else A!==void 0&&Ye.push({at:.5,label:v(String(A),a,4e3)});return Ye},K=0,ie=0;for(let Ee of m){for(let Ye of Ee.pointLabels??[])K=Math.max(K,s.width(Ye,l,0));if(p&&d&&Ee.type==="bar")for(let[,Ye]of Ee.data)ie=Math.max(ie,s.width(String(Ln(Ye)??""),l,0))}let le=F?d||g.type!=="band"?x:ne:0,J=D+(le>0?le+4:0)+(j.height>0?j.height+4:0),te=d?0:K>0||p?k+4:L?x/2:0,ae=o+C+te,ee=Math.max(1,u-o-J-ae),re=ae+ee,de=d?B(ee):Z(ee,56),ye=L?u6(de):0,oe=o+(U.height>0?U.height+6:0)+(ye>0?ye+6:0)+Y,xe=Math.max(K>0?K+12:0,ie>0?ie+8:0),fe=d?Math.min(h*.25,xe):0,pe=Math.max(1,h-o-oe-O-fe),Me=d?Z(pe,80):B(pe);if(F&&O+fe===0){let Ee=0;for(let Ye of Me)Ee=Math.max(Ee,Ye.at*pe+Ye.label.width/2-pe);pe=Math.max(1,pe-Ee)}let Ae=oe+pe,ce=(Ee,Ye)=>d?oe+Ye*pe:oe+Ee*pe,ge=(Ee,Ye)=>d?ae+Ee*ee:re-Ye*ee,be=Ee=>(Ee-H)/(I-H),Ie=Ee=>Math.min(Math.max(Ee,0),1),Re=Ee=>d?`M${f(ce(0,Ee))},${f(ae)}V${f(re)}`:`M${f(oe)},${f(ge(0,Ee))}H${f(Ae)}`,ze="";for(let Ee of d?Me:de)ze+=Re(Ee.at);let he="",$e="";br(_,"showAxisLine")&&(he+=`M${f(oe)},${f(ae)}V${f(re)}`),br(M,"showAxisLine")&&(he+=`M${f(oe)},${f(re)}H${f(Ae)}`);for(let Ee of de){let Ye=d?ae+Ee.at*ee:re-Ee.at*ee;Y&&(he+=`M${f(oe)},${f(Ye)}h${-Y}`),L&&($e+=nc(Ee.label,oe-Y-6,Ye,"end"))}for(let Ee of Me){let Ye=oe+Ee.at*pe;D&&(he+=`M${f(Ye)},${f(re)}v${D}`),F&&($e+=nc(Ee.label,Ye,re+D+4+Ee.label.height/2,"middle"))}let Se=(d?ee:pe)*W,we=Se*.7/Math.max(P,1),ke=P>1?Math.min(2,we*.2):0,Ne=Ie(be(0));P>0&&Ne>0&&Ne<1&&(he+=Re(Ne));let Be="",Pe="",q="",me="",se=0;m.forEach((Ee,Ye)=>{let qe=kt(Ye),Qe=Ee.title?` data-id="${Ge(Ee.title)}"`:"",lt=g.type==="band"?Math.min(Ee.data.length,z):Ee.data.length;if(Ee.type==="bar"){let Ue=(se++-(P-1)/2)*we-(we-ke)/2,ot="";for(let Fe=0;Fe<lt;Fe++){let at=Ln(Ee.data[Fe][1]);if(at===void 0)continue;let ct=E(Fe,lt),st=Ie(be(at)),Tt=Math.min(Ne,st),ht=Math.max(Ne,st),Ke=d?ce(ct,Tt):ce(ct,0)+Ue,dt=d?ge(ct,0)+Ue:ge(ct,ht),yt=d?(ht-Tt)*pe:we-ke,$t=d?we-ke:(ht-Tt)*ee;if(ot+=`<rect x="${f(Ke)}" y="${f(dt)}" width="${f(yt)}" height="${f($t)}"/>`,!p)continue;let Dt=String(at),hr=s.width(Dt,l,0),Ar=st>=Ne?1:-1,ja=Ke+yt/2,Ua=dt+$t/2,Ya="middle";if(d){if($t<l)continue;ja=(Ar>0?Ke+yt:Ke)+Ar*6,Ya=Ar>0?"start":"end"}else{if(hr+2>Se/P)continue;Ua=(Ar>0?dt:dt+$t)-Ar*(k/2+2)}q+=`<text x="${f(ja)}" y="${f(Ua+l*.35)}" text-anchor="${Ya}">${Dt}</text>`}Be+=`<g class="pele-series pele-bars"${Qe} fill="${qe}">${ot}</g>`;return}let Ze="",it="",rt=!1,wt=0,je=NaN;for(let Ue=0;Ue<lt;Ue++){let ot=Ln(Ee.data[Ue][1]);if(ot===void 0){je=NaN;continue}let Fe=E(Ue,lt),at=be(ot),ct=at>=0&&at<=1;if(je!==je)ct&&(Ze+=`M${f(ce(Fe,at))},${f(ge(Fe,at))}`),rt=ct;else{let Ke=at-je,dt=0,yt=1;if(Ke!==0){let $t=-je/Ke,Dt=(1-je)/Ke;dt=Math.max(dt,Math.min($t,Dt)),yt=Math.min(yt,Math.max($t,Dt))}else ct||(dt=2);if(dt<=yt){let $t=wt+(Fe-wt)*dt,Dt=je+Ke*dt,hr=wt+(Fe-wt)*yt,Ar=je+Ke*yt;(!rt||dt>0)&&(Ze+=`M${f(ce($t,Dt))},${f(ge($t,Dt))}`),Ze+=`L${f(ce(hr,Ar))},${f(ge(hr,Ar))}`}rt=ct}if(wt=Fe,je=at,!ct)continue;let st=ce(Fe,at),Tt=ge(Fe,at);Se>=12&&(it+=`<circle cx="${f(st)}" cy="${f(Tt)}" r="3"/>`);let ht=v(Ee.pointLabels?.[Ue],l,4e3);if(ht.height>0){let Ke=ht.width/2;me+=d?nc(ht,st+10,Tt,"start"):nc(ht,Math.max(Math.min(st,Ae-Ke),oe+Ke),Tt-6-ht.height/2,"middle")}}Pe+=`<g class="pele-series pele-line"${Qe} fill="${qe}">`+(Ze?`<path d="${Ze}" fill="none" stroke="${qe}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>`:"")+it+"</g>"});let ve="";U.height>0&&(ve+=`<g transform="translate(${f(o+U.height/2)},${f(ae+ee/2)}) rotate(-90)">${Le(U,0,0,"")}</g>`),ve+=Le(j,oe+pe/2,u-o-j.height/2,"");let _e="",Te=0;for(let Ee of N)Te+=Math.max(Nx,Ee.label.height+6);let Oe=ae+Math.max(0,(ee-Te)/2),Ce=Ae+fe+Rx;for(let{index:Ee,label:Ye}of N){let qe=Math.max(Nx,Ye.height+6);if(Oe+qe>u)break;let Qe=Oe+qe/2,lt=kt(Ee);_e+=`<g class="pele-legend-item" data-id="${Ge(m[Ee].title)}">`+(m[Ee].type==="bar"?`<rect x="${f(Ce)}" y="${f(Qe-la/2)}" width="${la}" height="${la}" rx="2" fill="${lt}"/>`:`<path d="M${f(Ce)},${f(Qe)}h${la}" stroke="${lt}" stroke-width="2" stroke-linecap="round"/>`)+Le(Ye,Ce+la+8+Ye.width/2,Qe,"")+"</g>",Oe+=qe}let He=Le(b,h/2,o+b.height/2,' class="pele-title" font-weight="var(--_tw)"')+(ze?`<path class="pele-grid" d="${ze}" stroke="var(--_a)"/>`:"")+`<g class="pele-plot">${Be}${Pe}</g>`+(he?`<path class="pele-axis" d="${he}" fill="none" stroke="var(--_b)"/>`:"")+($e?`<g class="pele-axis-labels" font-size="${a}" fill="var(--_m)">${$e}</g>`:"")+(ve?`<g class="pele-axis-titles" font-size="${a}">${ve}</g>`:"")+(q?`<g class="pele-data-labels" font-size="${l}">${q}</g>`:"")+(me?`<g class="pele-point-labels" font-size="${l}">${me}</g>`:"")+(_e?`<g class="pele-legend" font-size="${a}">${_e}</g>`:"");return{svg:mt("xychart",h,u,i,r,e,He),width:h,height:u,links:[]}}var p6={type:"xychart",section:"xyChart",parse(e,t,r){let n=new c6;return n.title=r,h6(e,n),n},render:f6},g6=[Mb,pC,IT,eC,W3,vR,_3,YA,_C,p6,eR,S4,pE,BI,QI,sC,LC,t5,G4,NN,B4,EA,XE,yI,V_,GR,aT,o6,XT,R5,q5,d3,hR];kk(...g6);var S2="Mermaid rendering failed.",m6=10,y6=800,x6=100.5,b6=1.12,w6=120,C2=2,I2=1.25;function N2(e){if(e instanceof Error)return e.message.trim()===""?e.name:e.message;if(typeof e=="string")return e.trim()===""?S2:e;if(e!==null&&typeof e=="object"){let t=e.message;if(typeof t=="string"&&t.trim()!=="")return t;try{let r=JSON.stringify(e);if(typeof r=="string"&&r!=="{}")return r}catch{}}return S2}function yl(e){let t=e?.zoom;if(t===void 0)return 100;let r=t.fit;if(!Number.isFinite(r)||r<=0)return 100;let n=Math.round(t.scale/r*100);return Number.isFinite(n)?Math.max(m6,Math.min(y6,n)):100}function R2(e){let{source:t,zoomEnabled:r,allowLinks:n,retryToken:i,label:a,viewRef:l}=e,s=De.useRef(null),o=De.useRef(null),c=De.useRef(e.onState),h=De.useRef(e.onScale);De.useLayoutEffect(()=>{c.current=e.onState,h.current=e.onScale});let u=De.useCallback(()=>{h.current(yl(o.current))},[]);return De.useImperativeHandle(l,()=>({zoomIn(){o.current?.zoom?.zoomBy(I2),u()},zoomOut(){o.current?.zoom?.zoomBy(1/I2),u()},fit(){o.current?.zoom?.reset(),u()},scale(){return yl(o.current)},svg(){return o.current?.result?.svg},mermaidType(){return o.current?.result?.mermaidType}}),[u]),De.useEffect(()=>{let d=s.current;if(d===null)return;let p=!1,g=null,m=z=>{p||c.current(z)},v=z=>{m({status:"error",message:N2(z)})};d.replaceChildren();try{g=Kf(d,t,{zoom:r?{controls:!1,always:!0,maxScale:8}:!1,links:n,images:!1,responsive:!1,onRender:z=>{m({status:"ready",result:z}),p||h.current(100)},onError:z=>{v(z)}})}catch(z){v(z),d.replaceChildren();return}o.current=g,g.error!==void 0&&g.error!==null?v(g.error):h.current(yl(g));let x=yl(g),k=()=>{let z=o.current?.zoom;if(z===void 0)return!1;let W=z.fit;return!Number.isFinite(W)||W<=0?!1:z.scale/W*100>x6},b=()=>{if(o.current===null)return;let z=k();z!==(d.dataset.zoomed==="true")&&(z?d.dataset.zoomed="true":delete d.dataset.zoomed);let W=yl(o.current);W!==x&&(x=W,h.current(W))},C=new MutationObserver(b),N=d.querySelector("svg");N!==null&&C.observe(N,{attributes:!0,attributeFilter:["viewBox","style"]});let R=0,O=0,P=()=>{O=0;let z=o.current?.zoom,W=R;if(R=0,z===void 0||W===0)return;let S=b6**(-W/w6);z.zoomBy(Math.min(C2,Math.max(1/C2,S))),b()},H=z=>{z.ctrlKey||z.metaKey||o.current?.zoom===void 0||z.deltaY===0||(z.preventDefault(),R+=z.deltaY*(z.deltaMode===1?40:z.deltaMode===2?800:1),O===0&&(O=window.requestAnimationFrame(P)))};d.addEventListener("wheel",H,{passive:!1});let I=z=>{if(z.pointerType==="touch"||z.button!==0)return;let W=z.target;if(!(W instanceof Element))return;if(delete d.dataset.panning,W.closest("text, foreignObject")!==null){z.stopPropagation();return}let S=document.getSelection();S!==null&&S.rangeCount>0&&!S.isCollapsed&&S.anchorNode!==null&&d.contains(S.anchorNode)&&S.removeAllRanges(),k()&&(d.dataset.panning="true")},G=()=>{delete d.dataset.panning};d.addEventListener("pointerdown",I,!0),window.addEventListener("pointerup",G,!0),window.addEventListener("pointercancel",G,!0);let Z=z=>{z.target instanceof Element&&z.target.closest("[data-pele-view]")!==null&&z.stopPropagation()};return window.addEventListener("dblclick",Z,!0),()=>{p=!0,C.disconnect(),O!==0&&window.cancelAnimationFrame(O),window.removeEventListener("dblclick",Z,!0),window.removeEventListener("pointerup",G,!0),window.removeEventListener("pointercancel",G,!0),d.removeEventListener("pointerdown",I,!0),d.removeEventListener("wheel",H),o.current=null;try{g?.destroy()}catch{}d.replaceChildren()}},[t,r,n,i]),ue("div",{ref:s,className:"hx-stage",role:"img","aria-label":a,"data-pele-view":""})}function O2(e){let{source:t,allowLinks:r,retryToken:n,label:i,viewRef:a}=e,l=De.useRef(null),s=De.useRef(null),o=De.useRef(e.onState);return De.useLayoutEffect(()=>{o.current=e.onState}),De.useImperativeHandle(a,()=>({svg(){return s.current?.result?.svg},mermaidType(){return s.current?.result?.mermaidType}}),[]),De.useEffect(()=>{let c=l.current;if(c===null)return;let h=!1,u=null,d=g=>{h||o.current(g)},p=g=>{d({status:"error",message:N2(g)})};c.replaceChildren();try{u=Kf(c,t,{zoom:!1,links:r,images:!1,onRender:g=>{d({status:"ready",result:g})},onError:g=>{p(g)}})}catch(g){p(g),c.replaceChildren();return}return s.current=u,u.error!==void 0&&u.error!==null&&p(u.error),()=>{h=!0,s.current=null;try{u?.destroy()}catch{}c.replaceChildren()}},[t,r,n]),ue("div",{ref:l,className:"hx-stage hx-stage--inline",role:"img","aria-label":i,"data-pele-view":""})}function v6(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global}function $6(){let e=v6();if(e.__xstate__)return e.__xstate__}var L2=e=>{if(typeof window>"u")return;let t=$6();t&&t.register(e)};var wd=class{constructor(t){this._process=t,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(t){let r={value:t,next:null};if(this._current){this._last.next=r,this._last=r;return}this._current=r,this._last=r,this._active&&this.flush()}flush(){for(;this._current;){let t=this._current;this._process(t.value),this._current=t.next}this._last=null}},Sp=".",k6="",Cp="",M6="#",_6="*",W2="xstate.init";var Mp="xstate.stop";function E6(e,t){return{type:`xstate.after.${e}.${t}`}}function _p(e,t){return{type:`xstate.done.state.${e}`,output:t}}function A6(e,t){return{type:`xstate.done.actor.${e}`,output:t,actorId:e}}function T6(e,t){return{type:`xstate.error.actor.${e}`,error:t,actorId:e}}function Ip(e){return{type:W2,input:e}}function on(e){setTimeout(()=>{throw e})}var S6=typeof Symbol=="function"&&Symbol.observable||"@@observable";function Np(e,t){let r=D2(e),n=D2(t);return typeof n=="string"?typeof r=="string"?n===r:!1:typeof r=="string"?r in n:Object.keys(r).every(i=>i in n?Np(r[i],n[i]):!1)}function $d(e){if(j2(e))return e;let t=[],r="";for(let n=0;n<e.length;n++){switch(e.charCodeAt(n)){case 92:r+=e[n+1],n++;continue;case 46:t.push(r),r="";continue}r+=e[n]}return t.push(r),t}function D2(e){if(hw(e))return e.value;if(typeof e!="string")return e;let t=$d(e);return B2(t)}function B2(e){if(e.length===1)return e[0];let t={},r=t;for(let n=0;n<e.length-1;n++)if(n===e.length-2)r[e[n]]=e[n+1];else{let i=r;r={},i[e[n]]=r}return t}function Rp(e,t){let r={},n=Object.keys(e);for(let i=0;i<n.length;i++){let a=n[i];r[a]=t(e[a],a,e,i)}return r}function H2(e){return j2(e)?e:[e]}function En(e){return e===void 0?[]:H2(e)}function Ep(e,t,r,n){return typeof e=="function"?e({context:t,event:r,self:n}):e}function j2(e){return Array.isArray(e)}function C6(e){return e.type.startsWith("xstate.error.actor")}function Ii(e){return H2(e).map(t=>typeof t>"u"||typeof t=="string"?{target:t}:t)}function U2(e){if(!(e===void 0||e===k6))return En(e)}function xl(e,t,r){let n=typeof e=="object",i=n?e:void 0;return{next:(n?e.next:e)?.bind(i),error:(n?e.error:t)?.bind(i),complete:(n?e.complete:r)?.bind(i)}}function Op(e,t){return`${t}.${e}`}function wl(e,t){let r=t.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!r)return e.implementations.actors[t];let[,n,i]=r,l=e.getStateNodeById(i).config.invoke;return(Array.isArray(l)?l[n]:l).src}function I6(e,t){if(t===e||t===_6)return!0;if(!t.endsWith(".*"))return!1;let r=t.split("."),n=e.split(".");for(let i=0;i<r.length;i++){let a=r[i],l=n[i];if(a==="*")return i===r.length-1;if(a!==l)return!1}return!0}function P2(e,t){return`${e.sessionId}.${t}`}var N6=0;function R6(e,t){let r=new Map,n=new Map,i=new WeakMap,a=new Set,l={},{clock:s,logger:o}=t,c={schedule:(d,p,g,m,v=Math.random().toString(36).slice(2))=>{let x={source:d,target:p,event:g,delay:m,id:v,startedAt:Date.now()},k=P2(d,v);u._snapshot._scheduledEvents[k]=x;let b=s.setTimeout(()=>{delete l[k],delete u._snapshot._scheduledEvents[k],u._relay(d,p,g)},m);l[k]=b},cancel:(d,p)=>{let g=P2(d,p),m=l[g];delete l[g],delete u._snapshot._scheduledEvents[g],m!==void 0&&s.clearTimeout(m)},cancelAll:d=>{for(let p in u._snapshot._scheduledEvents){let g=u._snapshot._scheduledEvents[p];g.source===d&&c.cancel(d,g.id)}}},h=d=>{if(!a.size)return;let p={...d,rootId:e.sessionId};a.forEach(g=>g.next?.(p))},u={_snapshot:{_scheduledEvents:(t?.snapshot&&t.snapshot.scheduler)??{}},_bookId:()=>`x:${N6++}`,_register:(d,p)=>(r.set(d,p),d),_unregister:d=>{r.delete(d.sessionId);let p=i.get(d);p!==void 0&&(n.delete(p),i.delete(d))},get:d=>n.get(d),getAll:()=>Object.fromEntries(n.entries()),_set:(d,p)=>{let g=n.get(d);if(g&&g!==p)throw new Error(`Actor with system ID '${d}' already exists.`);n.set(d,p),i.set(p,d)},inspect:d=>{let p=xl(d);return a.add(p),{unsubscribe(){a.delete(p)}}},_sendInspectionEvent:h,_relay:(d,p,g)=>{u._sendInspectionEvent({type:"@xstate.event",sourceRef:d,actorRef:p,event:g}),p._send(g)},scheduler:c,getSnapshot:()=>({_scheduledEvents:{...u._snapshot._scheduledEvents}}),start:()=>{let d=u._snapshot._scheduledEvents;u._snapshot._scheduledEvents={};for(let p in d){let{source:g,target:m,event:v,delay:x,id:k}=d[p];c.schedule(g,m,v,x,k)}},_clock:s,_logger:o};return u}var vp=!1,kd=1,ir=(function(e){return e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped",e})({}),O6={clock:{setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},logger:console.log.bind(console),devTools:!1},vd=class{constructor(t,r){this.logic=t,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new wd(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=ir.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this.systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];let n={...O6,...r},{clock:i,logger:a,parent:l,syncSnapshot:s,id:o,systemId:c,inspect:h}=n;this.system=l?l.system:R6(this,{clock:i,logger:a}),h&&!l&&this.system.inspect(xl(h)),this.sessionId=this.system._bookId(),this.id=o??this.sessionId,this.logger=r?.logger??this.system._logger,this.clock=r?.clock??this.system._clock,this._parent=l,this._syncSnapshot=s,this.options=n,this.src=n.src??t,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:u=>{this._deferred.push(u)},system:this.system,stopChild:u=>{if(u._parent!==this)throw new Error(`Cannot stop child actor ${u.id} of ${this.id} because it is not a child`);u._stop()},emit:u=>{let d=this.eventListeners.get(u.type),p=this.eventListeners.get("*");if(!d&&!p)return;let g=[...d?d.values():[],...p?p.values():[]];for(let m of g)try{m(u)}catch(v){on(v)}},actionExecutor:u=>{let d=()=>{if(this._actorScope.system._sendInspectionEvent({type:"@xstate.action",actorRef:this,action:{type:u.type,params:u.params}}),!u.exec)return;let p=vp;try{vp=!0,u.exec(u.info,u.params)}finally{vp=p}};this._processingStatus===ir.Running?d():this._deferred.push(d)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),c&&(this.systemId=c,this.system._set(c,this)),this._initState(r?.snapshot??r?.state),c&&this._snapshot.status!=="active"&&this.system._unregister(this)}_initState(t){try{this._snapshot=t?this.logic.restoreSnapshot?this.logic.restoreSnapshot(t,this._actorScope):t:this.logic.getInitialSnapshot(this._actorScope,this.options?.input)}catch(r){this._snapshot={status:"error",output:void 0,error:r}}}update(t,r){this._snapshot=t;let n;for(;n=this._deferred.shift();)try{n()}catch(i){this._deferred.length=0,this._snapshot={...t,status:"error",error:i}}switch(this._snapshot.status){case"active":for(let i of this.observers)try{i.next?.(t)}catch(a){on(a)}break;case"done":for(let i of this.observers)try{i.next?.(t)}catch(a){on(a)}this._stopProcedure(),this._complete(),this._doneEvent=A6(this.id,this._snapshot.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._error(this._snapshot.error);break}this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:r,snapshot:t})}subscribe(t,r,n){let i=xl(t,r,n);if(this._processingStatus!==ir.Stopped)this.observers.add(i);else switch(this._snapshot.status){case"done":try{i.complete?.()}catch(a){on(a)}break;case"error":{let a=this._snapshot.error;if(!i.error)on(a);else try{i.error(a)}catch(l){on(l)}break}}return{unsubscribe:()=>{this.observers.delete(i)}}}on(t,r){let n=this.eventListeners.get(t);n||(n=new Set,this.eventListeners.set(t,n));let i=r.bind(void 0);return n.add(i),{unsubscribe:()=>{n.delete(i)}}}select(t,r=Object.is){return{subscribe:n=>{let i=xl(n),a=this.getSnapshot(),l=t(a);return this.subscribe(s=>{let o=t(s);r(l,o)||(l=o,i.next?.(o))})},get:()=>t(this.getSnapshot())}}start(){if(this._processingStatus===ir.Running)return this;this._syncSnapshot&&this.subscribe({next:n=>{n.status==="active"&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:n})},error:()=>{}}),this.system._register(this.sessionId,this),this.systemId&&this.system._set(this.systemId,this),this._processingStatus=ir.Running;let t=Ip(this.options.input);switch(this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:t}),this._snapshot.status){case"done":return this.update(this._snapshot,t),this;case"error":return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(n){return this._snapshot={...this._snapshot,status:"error",error:n},this._error(n),this}return this.update(this._snapshot,t),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(t){let r,n;try{r=this.logic.transition(this._snapshot,t,this._actorScope)}catch(i){n={err:i}}if(n){let{err:i}=n;this._snapshot={...this._snapshot,status:"error",error:i},this._error(i);return}this.update(r,t),t.type===Mp&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===ir.Stopped?this:(this.mailbox.clear(),this._processingStatus===ir.NotStarted?(this._processingStatus=ir.Stopped,this):(this.mailbox.enqueue({type:Mp}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){for(let t of this.observers)try{t.complete?.()}catch(r){on(r)}this.observers.clear(),this.eventListeners.clear()}_reportError(t){if(!this.observers.size){this._parent||on(t),this.eventListeners.clear();return}let r=!1;for(let n of this.observers){let i=n.error;r||=!i;try{i?.(t)}catch(a){on(a)}}this.observers.clear(),this.eventListeners.clear(),r&&on(t)}_error(t){this._stopProcedure(),this._reportError(t),this._parent&&this.system._relay(this,this._parent,T6(this.id,t))}_stopProcedure(){return this._processingStatus!==ir.Running?this:(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new wd(this._process.bind(this)),this._processingStatus=ir.Stopped,this.system._unregister(this),this)}_send(t){this._processingStatus!==ir.Stopped&&this.mailbox.enqueue(t)}send(t){this.system._relay(void 0,this,t)}attachDevTools(){let{devTools:t}=this.options;t&&(typeof t=="function"?t:L2)(this)}toJSON(){return{xstate$$type:kd,id:this.id}}getPersistedSnapshot(t){return this.logic.getPersistedSnapshot(this._snapshot,t)}[S6](){return this}getSnapshot(){return this._snapshot}};function dn(e,...[t]){return new vd(e,t)}function L6(e,t,r,n,{sendId:i}){let a=typeof i=="function"?i(r,n):i;return[t,{sendId:a},void 0]}function D6(e,t){e.defer(()=>{e.system.scheduler.cancel(e.self,t.sendId)})}function Y2(e){function t(r,n){}return t.type="xstate.cancel",t.sendId=e,t.resolve=L6,t.execute=D6,t}function P6(e,t,r,n,{id:i,systemId:a,src:l,input:s,syncSnapshot:o}){let c=typeof l=="string"?wl(t.machine,l):l,h=typeof i=="function"?i(r):i,u,d;return c&&(d=typeof s=="function"?s({context:t.context,event:r.event,self:e.self}):s,u=dn(c,{id:h,src:l,parent:e.self,syncSnapshot:o,systemId:a,input:d})),[cn(t,{children:{...t.children,[h]:u}}),{id:i,systemId:a,actorRef:u,src:l,input:d},void 0]}function z6(e,{actorRef:t}){t&&e.defer(()=>{t._processingStatus!==ir.Stopped&&t.start()})}function G2(...[e,{id:t,systemId:r,input:n,syncSnapshot:i=!1}={}]){function a(l,s){}return a.type="xstate.spawnChild",a.id=t,a.systemId=r,a.src=e,a.input=n,a.syncSnapshot=i,a.resolve=P6,a.execute=z6,a}function F6(e,t,r,n,{actorRef:i}){let a=typeof i=="function"?i(r,n):i,l=typeof a=="string"?t.children[a]:a,s=t.children;return l&&(s={...s},delete s[l.id]),[cn(t,{children:s}),l,void 0]}function V2(e,t){let r=t.getSnapshot();if(r&&"children"in r)for(let n of Object.values(r.children))V2(e,n);e.system._unregister(t)}function W6(e,t){if(t){if(V2(e,t),t._processingStatus!==ir.Running){e.stopChild(t);return}e.defer(()=>{e.stopChild(t)})}}function Lp(e){function t(r,n){}return t.type="xstate.stopChild",t.actorRef=e,t.resolve=F6,t.execute=W6,t}function B6(e,{context:t,event:r},{guards:n}){return n.every(i=>vl(i,t,r,e))}function q2(e){function t(r,n){return!1}return t.check=B6,t.guards=e,t}function vl(e,t,r,n){let{machine:i}=n,a=typeof e=="function",l=a?e:i.implementations.guards[typeof e=="string"?e:e.type];if(!a&&!l)throw new Error(`Guard '${typeof e=="string"?e:e.type}' is not implemented.'.`);if(typeof l!="function")return vl(l,t,r,n);let s={context:t,event:r},o=a||typeof e=="string"?void 0:"params"in e?typeof e.params=="function"?e.params({context:t,event:r}):e.params:void 0;return"check"in l?l.check(n,s,l):l(s,o)}function Dp(e){return e.type==="atomic"||e.type==="final"}function La(e){return Object.values(e.states).filter(t=>t.type!=="history")}function $l(e,t){let r=[];if(t===e)return r;let n=e.parent;for(;n&&n!==t;)r.push(n),n=n.parent;return r}function kl(e){let t=new Set(e),r=K2(t);for(let n of t)if(n.type==="compound"&&(!r.get(n)||!r.get(n).length))z2(n).forEach(i=>t.add(i));else if(n.type==="parallel"){for(let i of La(n))if(i.type!=="history"&&!t.has(i)){let a=z2(i);for(let l of a)t.add(l)}}for(let n of t){let i=n.parent;for(;i;)t.add(i),i=i.parent}return t}function X2(e,t){let r=t.get(e);if(!r)return{};if(e.type==="compound"){let i=r[0];if(i){if(Dp(i))return i.key}else return{}}let n={};for(let i of r)n[i.key]=X2(i,t);return n}function K2(e){let t=new Map;for(let r of e)t.has(r)||t.set(r,[]),r.parent&&(t.has(r.parent)||t.set(r.parent,[]),t.get(r.parent).push(r));return t}function Z2(e,t){let r=kl(t);return X2(e,K2(r))}function Md(e,t){return t.type==="compound"?La(t).some(r=>r.type==="final"&&e.has(r)):t.type==="parallel"?La(t).every(r=>Md(e,r)):t.type==="final"}var Ml=e=>e[0]===M6;function Q2(e,t){let r=e.transitions.get(t),n=[...e.transitions.keys()].filter(i=>i!==t&&I6(t,i)).sort((i,a)=>a.length-i.length).flatMap(i=>e.transitions.get(i));return r?[...r,...n]:n}function J2(e){let t=e.config.after;if(!t)return[];let r=i=>{let a=E6(i,e.id),l=a.type;return e.entry.push(pw(a,{id:l,delay:i})),e.exit.push(Y2(l)),l};return Object.keys(t).flatMap(i=>{let a=t[i],l=typeof a=="string"?{target:a}:a,s=Number.isNaN(+i)?i:+i,o=r(s);return En(l).map(c=>({...c,event:o,delay:s}))}).map(i=>{let{delay:a}=i;return{..._n(e,i.event,i),delay:a}})}function _n(e,t,r){let n=U2(r.target),i=r.reenter??!1,a=H6(e,n),l={...r,actions:En(r.actions),guard:r.guard,target:a,source:e,reenter:i,eventType:t,toJSON:()=>({...l,source:`#${e.id}`,target:a?a.map(s=>`#${s.id}`):void 0})};return l}function ew(e){let t=new Map;if(e.config.on)for(let r of Object.keys(e.config.on)){if(r===Cp)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');let n=e.config.on[r];t.set(r,Ii(n).map(i=>_n(e,r,i)))}if(e.config.onDone){let r=`xstate.done.state.${e.id}`;t.set(r,Ii(e.config.onDone).map(n=>_n(e,r,n)))}for(let r of e.invoke){if(r.onDone){let n=`xstate.done.actor.${r.id}`;t.set(n,Ii(r.onDone).map(i=>_n(e,n,i)))}if(r.onError){let n=`xstate.error.actor.${r.id}`;t.set(n,Ii(r.onError).map(i=>_n(e,n,i)))}if(r.onSnapshot){let n=`xstate.snapshot.${r.id}`;t.set(n,Ii(r.onSnapshot).map(i=>_n(e,n,i)))}}for(let r of e.after){let n=t.get(r.eventType);n||(n=[],t.set(r.eventType,n)),n.push(r)}return t}function tw(e){let t=[],r=n=>{Object.values(n).forEach(i=>{if(i.config.route&&i.config.id){let a=i.config.id,l=i.config.route.guard,s=({event:c})=>c.to===`#${a}`,o={...i.config.route,guard:l?q2([s,l]):s,target:`#${a}`};t.push(_n(e,"xstate.route",o))}i.states&&r(i.states)})};r(e.states),t.length>0&&e.transitions.set("xstate.route",t)}function rw(e,t){let r=typeof t=="string"?e.states[t]:t?e.states[t.target]:void 0;if(!r&&t)throw new Error(`Initial state node "${t}" not found on parent state node #${e.id}`);let n={source:e,actions:!t||typeof t=="string"?[]:En(t.actions),eventType:null,reenter:!1,target:r?[r]:[],meta:typeof t=="object"?t.meta:void 0,description:typeof t=="object"?t.description:void 0,toJSON:()=>({...n,source:`#${e.id}`,target:r?[`#${r.id}`]:[]})};return n}function H6(e,t){if(t!==void 0)return t.map(r=>{if(typeof r!="string")return r;if(Ml(r))return e.machine.getStateNodeById(r);let n=r[0]===Sp;if(n&&!e.parent)return bl(e,r.slice(1));let i=n?e.key+r:r;if(e.parent)try{return bl(e.parent,i)}catch(a){throw new Error(`Invalid transition definition for state node '${e.id}':
153
+ ${a.message}`)}else throw new Error(`Invalid target: "${r}" is not a valid target from the root node. Did you mean ".${r}"?`)})}function nw(e){let t=U2(e.config.target);return t?{target:t.map(r=>typeof r=="string"?bl(e.parent,r):r)}:e.parent.type==="parallel"?{target:[e.parent]}:e.parent.initial}function Ni(e){return e.type==="history"}function z2(e){let t=iw(e);for(let r of t)for(let n of $l(r,e))t.add(n);return t}function iw(e){let t=new Set;function r(n){if(!t.has(n)){if(t.add(n),n.type==="compound")r(n.initial.target[0]);else if(n.type==="parallel")for(let i of La(n))r(i)}}return r(e),t}function Da(e,t){if(Ml(t))return e.machine.getStateNodeById(t);if(!e.states)throw new Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);let r=e.states[t];if(!r)throw new Error(`Child state '${t}' does not exist on '${e.id}'`);return r}function bl(e,t){if(typeof t=="string"&&Ml(t))try{return e.machine.getStateNodeById(t)}catch{}let r=$d(t).slice(),n=e;for(;r.length;){let i=r.shift();if(!i.length)break;n=Da(n,i)}return n}function Pa(e,t){if(typeof t=="string"){let i=e.states[t];if(!i)throw new Error(`State '${t}' does not exist on '${e.id}'`);return[e,i]}let r=Object.keys(t),n=r.map(i=>Da(e,i)).filter(Boolean);return[e.machine.root,e].concat(n,r.reduce((i,a)=>{let l=Da(e,a);if(!l)return i;let s=Pa(l,t[a]);return i.concat(s)},[]))}function j6(e,t,r,n){let a=Da(e,t).next(r,n);return!a||!a.length?e.next(r,n):a}function U6(e,t,r,n){let i=Object.keys(t),a=Da(e,i[0]),l=_d(a,t[i[0]],r,n);return!l||!l.length?e.next(r,n):l}function Y6(e,t,r,n){let i=[];for(let a of Object.keys(t)){let l=t[a];if(!l)continue;let s=Da(e,a),o=_d(s,l,r,n);o&&i.push(...o)}return i.length?i:e.next(r,n)}function _d(e,t,r,n){return typeof t=="string"?j6(e,t,r,n):Object.keys(t).length===1?U6(e,t,r,n):Y6(e,t,r,n)}function G6(e){return Object.keys(e.states).map(t=>e.states[t]).filter(t=>t.type==="history")}function qn(e,t){let r=e;for(;r.parent&&r.parent!==t;)r=r.parent;return r.parent===t}function V6(e,t){let r=new Set(e),n=new Set(t);for(let i of r)if(n.has(i))return!0;for(let i of n)if(r.has(i))return!0;return!1}function aw(e,t,r){let n=new Set;for(let i of e){let a=!1,l=new Set;for(let s of n)if(V6(Ap([i],t,r),Ap([s],t,r)))if(qn(i.source,s.source))l.add(s);else{a=!0;break}if(!a){for(let s of l)n.delete(s);n.add(i)}}return Array.from(n)}function q6(e){let[t,...r]=e;for(let n of $l(t,void 0))if(r.every(i=>qn(i,n)))return n}function Pp(e,t){if(!e.target)return[];let r=new Set;for(let n of e.target)if(Ni(n))if(t[n.id])for(let i of t[n.id])r.add(i);else for(let i of Pp(nw(n),t))r.add(i);else r.add(n);return[...r]}function sw(e,t){let r=Pp(e,t);if(!r)return;if(!e.reenter&&r.every(i=>i===e.source||qn(i,e.source)))return e.source;let n=q6(r.concat(e.source));if(n)return n;if(!e.reenter)return e.source.machine.root}function Ap(e,t,r){let n=new Set;for(let i of e)if(i.target?.length){let a=sw(i,r);i.reenter&&i.source===a&&n.add(a);for(let l of t)qn(l,a)&&n.add(l)}return[...n]}function X6(e,t){if(e.length!==t.size)return!1;for(let r of e)if(!t.has(r))return!1;return!0}function lw(e,t,r,n,i){return Tp([{target:[...iw(e)],source:e,reenter:!0,actions:[],eventType:null,toJSON:null}],t,r,n,!0,i)}function Tp(e,t,r,n,i,a){let l=[];if(!e.length)return[t,l];let s=r.actionExecutor;r.actionExecutor=o=>{l.push(o),s(o)};try{let o=new Set(t._nodes),c=t.historyValue,h=aw(e,o,c),u=t;i||([u,c]=J6(u,n,r,h,o,c,a,r.actionExecutor)),u=Ri(u,n,r,h.flatMap(p=>p.actions),a,void 0),u=Z6(u,n,r,h,o,a,c,i);let d=[...o];u.status==="done"&&(u=Ri(u,n,r,d.sort((p,g)=>g.order-p.order).flatMap(p=>p.exit),a,void 0));try{return c===t.historyValue&&X6(t._nodes,o)?[u,l]:[cn(u,{_nodes:d,historyValue:c}),l]}catch(p){throw p}}finally{r.actionExecutor=s}}function K6(e,t,r,n,i){if(n.output===void 0)return;let a=_p(i.id,i.output!==void 0&&i.parent?Ep(i.output,e.context,t,r.self):void 0);return Ep(n.output,e.context,a,r.self)}function Z6(e,t,r,n,i,a,l,s){let o=e,c=new Set,h=new Set;Q6(n,l,h,c),s&&h.add(e.machine.root);let u=new Set;for(let d of[...c].sort((p,g)=>p.order-g.order)){i.add(d);let p=[];p.push(...d.entry);for(let g of d.invoke)p.push(G2(g.src,{...g,syncSnapshot:!!g.onSnapshot}));if(h.has(d)){let g=d.initial.actions;p.push(...g)}if(o=Ri(o,t,r,p,a,d.invoke.map(g=>g.id)),d.type==="final"){let g=d.parent,m=g?.type==="parallel"?g:g?.parent,v=m||d;for(g?.type==="compound"&&a.push(_p(g.id,d.output!==void 0?Ep(d.output,o.context,t,r.self):void 0));m?.type==="parallel"&&!u.has(m)&&Md(i,m);)u.add(m),a.push(_p(m.id)),v=m,m=m.parent;if(m)continue;o=cn(o,{status:"done",output:K6(o,t,r,o.machine.root,v)})}}return o}function Q6(e,t,r,n){for(let i of e){let a=sw(i,t);for(let s of i.target||[])!Ni(s)&&(i.source!==s||i.source!==a||i.reenter)&&(n.add(s),r.add(s)),Oa(s,t,r,n);let l=Pp(i,t);for(let s of l){let o=$l(s,a);a?.type==="parallel"&&o.push(a),ow(n,t,r,o,!i.source.parent&&i.reenter?void 0:a)}}}function Oa(e,t,r,n){if(Ni(e))if(t[e.id]){let i=t[e.id];for(let a of i)n.add(a),Oa(a,t,r,n);for(let a of i)$p(a,e.parent,n,t,r)}else{let i=nw(e);for(let a of i.target)n.add(a),i===e.parent?.initial&&r.add(e.parent),Oa(a,t,r,n);for(let a of i.target)$p(a,e.parent,n,t,r)}else if(e.type==="compound"){let[i]=e.initial.target;Ni(i)||(n.add(i),r.add(i)),Oa(i,t,r,n),$p(i,e,n,t,r)}else if(e.type==="parallel")for(let i of La(e).filter(a=>!Ni(a)))[...n].some(a=>qn(a,i))||(Ni(i)||(n.add(i),r.add(i)),Oa(i,t,r,n))}function ow(e,t,r,n,i){for(let a of n)if((!i||qn(a,i))&&e.add(a),a.type==="parallel")for(let l of La(a).filter(s=>!Ni(s)))[...e].some(s=>qn(s,l))||(e.add(l),Oa(l,t,r,e))}function $p(e,t,r,n,i){ow(r,n,i,$l(e,t))}function J6(e,t,r,n,i,a,l,s){let o=e,c=Ap(n,i,a);c.sort((u,d)=>d.order-u.order);let h;for(let u of c)for(let d of G6(u)){let p;d.history==="deep"?p=g=>Dp(g)&&qn(g,u):p=g=>g.parent===u,h??={...a},h[d.id]=Array.from(i).filter(p)}for(let u of c)o=Ri(o,t,r,[...u.exit,...u.invoke.map(d=>Lp(d.id))],l,void 0),i.delete(u);return[o,h||a]}function eO(e,t){return e.implementations.actions[t]}function cw(e,t,r,n,i,a){let{machine:l}=e,s=e;for(let o of n){let c=typeof o=="function",h=c?o:eO(l,typeof o=="string"?o:o.type),u={context:s.context,event:t,self:r.self,system:r.system},d=c||typeof o=="string"?void 0:"params"in o?typeof o.params=="function"?o.params({context:s.context,event:t}):o.params:void 0;if(!h||!("resolve"in h)){r.actionExecutor({type:typeof o=="string"?o:typeof o=="object"?o.type:o.name||"(anonymous)",info:u,params:d,exec:h});continue}let p=h,[g,m,v]=p.resolve(r,s,u,d,h,i);s=g,"retryResolve"in p&&a?.push([p,m]),"execute"in p&&r.actionExecutor({type:p.type,info:u,params:m,exec:p.execute.bind(null,r,m)}),v&&(s=cw(s,t,r,v,i,a))}return s}function Ri(e,t,r,n,i,a){let l=a?[]:void 0,s=cw(e,t,r,n,{internalQueue:i,deferredActorIds:a},l);return l?.forEach(([o,c])=>{o.retryResolve(r,s,c)}),s}function Ed(e,t,r,n){let i=e,a=[];function l(u,d,p){r.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:r.self,event:d,snapshot:u[0],_transitions:p}),a.push(u)}if(t.type===Mp)return i=cn(kp(i,t,r),{status:"stopped"}),l([i,[]],t,[]),{snapshot:i,microsteps:a};let s=t;if(s.type!==W2){let u=s,d=C6(u),p=F2(u,i);if(d&&!p.length)return i=cn(kp(i,u,r),{status:"error",error:u.error}),l([i,[]],u,[]),{snapshot:i,microsteps:a};let g=Tp(p,e,r,s,!1,n);i=g[0],l(g,u,p)}let o=!0,c=e.machine.options?.maxIterations??1/0,h=0;for(;i.status==="active";){if(h++,h>c)throw new Error(`Infinite loop detected: the machine has processed more than ${c} microsteps without reaching a stable state. This usually happens when there's a cycle of transitions (e.g., eventless transitions or raised events causing state A -> B -> C -> A).`);let u=o?tO(i,s):[],d=u.length?i:void 0;if(!u.length){if(!n.length)break;s=n.shift(),u=F2(s,i)}let p=Tp(u,i,r,s,!1,n);i=p[0],o=i!==d,l(p,s,u)}return i.status!=="active"&&kp(i,s,r),{snapshot:i,microsteps:a}}function kp(e,t,r){return Ri(e,t,r,Object.values(e.children).map(n=>Lp(n)),[],void 0)}function F2(e,t){return t.machine.getTransitionData(t,e)}function tO(e,t){let r=new Set,n=e._nodes.filter(Dp);for(let i of n)e:for(let a of[i].concat($l(i,void 0)))if(a.always){for(let l of a.always)if(l.guard===void 0||vl(l.guard,e.context,t,e)){r.add(l);break e}}return aw(Array.from(r),new Set(e._nodes),e.historyValue)}function dw(e,t){let r=kl(Pa(e,t));return Z2(e,[...r])}function hw(e){return!!e&&typeof e=="object"&&"machine"in e&&"value"in e}var rO=function(t){return Np(t,this.value)},nO=function(t){return this.tags.has(t)},iO=function(t){let r=this.machine.getTransitionData(this,t);return!!r?.length&&r.some(n=>n.target!==void 0||n.actions.length)},aO=function(){let{_nodes:t,tags:r,machine:n,getMeta:i,toJSON:a,can:l,hasTag:s,matches:o,...c}=this;return{...c,tags:Array.from(r)}},sO=function(){return this._nodes.reduce((t,r)=>(r.meta!==void 0&&(t[r.id]=r.meta),t),{})};function za(e,t){return{status:e.status,output:e.output,error:e.error,machine:t,context:e.context,_nodes:e._nodes,value:Z2(t.root,e._nodes),tags:new Set(e._nodes.flatMap(r=>r.tags)),children:e.children,historyValue:e.historyValue||{},matches:rO,hasTag:nO,can:iO,getMeta:sO,toJSON:aO}}function cn(e,t={}){return za({...e,...t},e.machine)}function lO(e){if(typeof e!="object"||e===null)return{};let t={};for(let r in e){let n=e[r];Array.isArray(n)&&(t[r]=n.map(i=>({id:i.id})))}return t}function uw(e,t){let{_nodes:r,tags:n,machine:i,children:a,context:l,can:s,hasTag:o,matches:c,getMeta:h,toJSON:u,...d}=e,p={};for(let m in a){let v=a[m];p[m]={snapshot:v.getPersistedSnapshot(t),src:v.src,systemId:v.systemId,syncSnapshot:v._syncSnapshot}}return{...d,context:fw(l),children:p,historyValue:lO(d.historyValue)}}function fw(e){let t;for(let r in e){let n=e[r];if(n&&typeof n=="object")if("sessionId"in n&&"send"in n&&"ref"in n)t??=Array.isArray(e)?e.slice():{...e},t[r]={xstate$$type:kd,id:n.id};else{let i=fw(n);i!==n&&(t??=Array.isArray(e)?e.slice():{...e},t[r]=i)}}return t??e}function oO(e,t,r,n,{event:i,id:a,delay:l},{internalQueue:s}){let o=t.machine.implementations.delays;if(typeof i=="string")throw new Error(`Only event objects may be used with raise; use raise({ type: "${i}" }) instead`);let c=typeof i=="function"?i(r,n):i,h;if(typeof l=="string"){let u=o&&o[l];h=typeof u=="function"?u(r,n):u}else h=typeof l=="function"?l(r,n):l;return typeof h!="number"&&s.push(c),[t,{event:c,id:a,delay:h},void 0]}function cO(e,t){let{event:r,delay:n,id:i}=t;if(typeof n=="number"){e.defer(()=>{let a=e.self;e.system.scheduler.schedule(a,a,r,n,i)});return}}function pw(e,t){function r(n,i){}return r.type="xstate.raise",r.event=e,r.id=t?.id,r.delay=t?.delay,r.resolve=oO,r.execute=cO,r}function dO(e,{machine:t,context:r},n,i){let a=(l,s)=>{if(typeof l=="string"){let o=wl(t,l);if(!o)throw new Error(`Actor logic '${l}' not implemented in machine '${t.id}'`);let c=dn(o,{id:s?.id,parent:e.self,syncSnapshot:s?.syncSnapshot,input:typeof s?.input=="function"?s.input({context:r,event:n,self:e.self}):s?.input,src:l,systemId:s?.systemId});return i[c.id]=c,c}else return dn(l,{id:s?.id,parent:e.self,syncSnapshot:s?.syncSnapshot,input:s?.input,src:l,systemId:s?.systemId})};return(l,s)=>{let o=a(l,s);return i[o.id]=o,e.defer(()=>{o._processingStatus!==ir.Stopped&&o.start()}),o}}function hO(e,t,r,n,{assignment:i}){if(!t.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");let a={},l={context:t.context,event:r.event,spawn:dO(e,t,r.event,a),self:e.self,system:e.system},s={};if(typeof i=="function")s=i(l,n);else for(let c of Object.keys(i)){let h=i[c];s[c]=typeof h=="function"?h(l,n):h}let o=Object.assign({},t.context,s);return[cn(t,{context:o,children:Object.keys(a).length?{...t.children,...a}:t.children}),void 0,void 0]}function gw(e){function t(r,n){}return t.type="xstate.assign",t.assignment=e,t.resolve=hO,t}var mw=new WeakMap;function Fa(e,t,r){let n=mw.get(e);return n?t in n||(n[t]=r()):(n={[t]:r()},mw.set(e,n)),n[t]}var uO={},_l=e=>typeof e=="string"?{type:e}:typeof e=="function"?"resolve"in e?{type:e.type}:{type:e.name}:e,Ad=class e{constructor(t,r){if(this.config=t,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=r._parent,this.key=r._key,this.machine=r._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(Sp),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?Rp(this.config.states,(n,i)=>new e(n,{_parent:this,_key:i,_machine:this.machine})):uO,this.type==="compound"&&!this.config.initial)throw new Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=this.config.history===!0?"shallow":this.config.history||!1,this.entry=En(this.config.entry).slice(),this.exit=En(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type==="final"||!this.parent?this.config.output:void 0,this.tags=En(t.tags).slice()}_initialize(){this.transitions=ew(this),this.config.always&&(this.always=Ii(this.config.always).map(t=>_n(this,Cp,t))),Object.keys(this.states).forEach(t=>{this.states[t]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(_l),eventType:null,reenter:!1,meta:this.initial.meta,description:this.initial.description,toJSON:()=>({target:this.initial.target.map(t=>`#${t.id}`),source:`#${this.id}`,actions:this.initial.actions.map(_l),eventType:null,meta:this.initial.meta,description:this.initial.description})}:void 0,history:this.history,states:Rp(this.states,t=>t.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(t=>({...t,actions:t.actions.map(_l)})),entry:this.entry.map(_l),exit:this.exit.map(_l),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return Fa(this,"invoke",()=>En(this.config.invoke).map((t,r)=>{let{src:n,systemId:i}=t,a=t.id??Op(this.id,r),l=typeof n=="string"?n:`xstate.invoke.${Op(this.id,r)}`;return{...t,src:l,id:a,systemId:i,toJSON(){let{onDone:s,onError:o,...c}=t;return{...c,type:"xstate.invoke",src:l,id:a}}}}))}get on(){return Fa(this,"on",()=>[...this.transitions].flatMap(([r,n])=>n.map(i=>[r,i])).reduce((r,[n,i])=>(r[n]=r[n]||[],r[n].push(i),r),{}))}get after(){return Fa(this,"delayedTransitions",()=>J2(this))}get initial(){return Fa(this,"initial",()=>rw(this,this.config.initial))}next(t,r){let n=r.type,i=[],a,l=Fa(this,`candidates-${n}`,()=>Q2(this,n));for(let s of l){let{guard:o}=s,c=t.context,h=!1;try{h=!o||vl(o,c,r,t)}catch(u){let d=typeof o=="string"?o:typeof o=="object"?o.type:void 0;throw new Error(`Unable to evaluate guard ${d?`'${d}' `:""}in transition for event '${n}' in state node '${this.id}':
154
+ ${u.message}`)}if(h){i.push(...s.actions),a=s;break}}return a?[a]:void 0}get events(){return Fa(this,"events",()=>{let{states:t}=this,r=new Set(this.ownEvents);if(t)for(let n of Object.keys(t)){let i=t[n];if(i.states)for(let a of i.events)r.add(`${a}`)}return Array.from(r)})}get ownEvents(){let t=Object.keys(Object.fromEntries(this.transitions)),r=new Set(t.filter(n=>this.transitions.get(n).some(i=>!(!i.target&&!i.actions.length&&!i.reenter))));return Array.from(r)}},fO="#",Td=class e{constructor(t,r){this.config=t,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.options=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.id=t.id||"(machine)",this.implementations={actors:r?.actors??{},actions:r?.actions??{},delays:r?.delays??{},guards:r?.guards??{}},this.version=this.config.version,this.schemas=this.config.schemas,this.options={maxIterations:1/0,...this.config.options},this.transition=this.transition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.restoreSnapshot=this.restoreSnapshot.bind(this),this.start=this.start.bind(this),this.root=new Ad(t,{_key:this.id,_machine:this}),this.root._initialize(),tw(this.root),this.states=this.root.states,this.events=this.root.events}provide(t){let{actions:r,guards:n,actors:i,delays:a}=this.implementations;return new e(this.config,{actions:{...r,...t.actions},guards:{...n,...t.guards},actors:{...i,...t.actors},delays:{...a,...t.delays}})}resolveState(t){let r=dw(this.root,t.value),n=kl(Pa(this.root,r));return za({_nodes:[...n],context:t.context||{},children:{},status:Md(n,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,r,n){return Ed(t,r,n,[]).snapshot}microstep(t,r,n){return Ed(t,r,n,[]).microsteps.map(([i])=>i)}getTransitionData(t,r){return _d(this.root,t.value,t,r)||[]}_getPreInitialState(t,r,n){let{context:i}=this.config,a=za({context:typeof i!="function"&&i?i:{},_nodes:[this.root],children:{},status:"active"},this);return typeof i=="function"?Ri(a,r,t,[gw(({spawn:s,event:o,self:c})=>i({spawn:s,input:o.input,self:c}))],n,void 0):a}getInitialSnapshot(t,r){let n=Ip(r),i=[],a=za({context:typeof this.config.context!="function"&&this.config.context?this.config.context:{},_nodes:[this.root],children:{},status:"active"},this);try{a=this._getPreInitialState(t,n,i);let[l]=lw(this.root,a,t,n,i),{snapshot:s}=Ed(l,n,t,i);return s}catch(l){return cn(a,{status:"error",error:l})}}start(t){Object.values(t.children).forEach(r=>{r.getSnapshot().status==="active"&&r.start()})}getStateNodeById(t){let r=$d(t),n=r.slice(1),i=Ml(r[0])?r[0].slice(fO.length):r[0],a=this.idMap.get(i);if(!a)throw new Error(`Child state node '#${i}' does not exist on machine '${this.id}'`);return bl(a,n)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(t,r){return uw(t,r)}restoreSnapshot(t,r){let n={},i=t.children;Object.keys(i).forEach(u=>{let d=i[u],p=d.snapshot,g=d.src,m=typeof g=="string"?wl(this,g):g;if(!m)return;let v=dn(m,{id:u,parent:r.self,syncSnapshot:d.syncSnapshot,snapshot:p,src:g,systemId:d.systemId});n[u]=v});function a(u,d){if(d instanceof Ad)return d;try{return u.machine.getStateNodeById(d.id)}catch{}}function l(u,d){if(!d||typeof d!="object")return{};let p={};for(let g in d){let m=d[g];for(let v of m){let x=a(u,v);x&&(p[g]??=[],p[g].push(x))}}return p}let s=l(this.root,t.historyValue),o=za({...t,children:n,_nodes:Array.from(kl(Pa(this.root,t.value))),historyValue:s},this),c=new Set;function h(u,d){if(!c.has(u)){c.add(u);for(let p in u){let g=u[p];if(g&&typeof g=="object"){if("xstate$$type"in g&&g.xstate$$type===kd){u[p]=d[g.id];continue}h(g,d)}}}}return h(o.context,n),o}};function yw(e,t){return new Td(e,t)}var Xn=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),pO=e=>Xn(e)&&e.__opaque===!0;function zp(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"?!0:Array.isArray(e)?e.every(t=>zp(t)):pO(e)?!1:Object.entries(e).every(([t,r])=>t.startsWith("__")||zp(r))}function xw(e,t,r){let n=[];for(let i of Array.isArray(e)?e:[e]){if(typeof i=="string"){n.push({target:i});continue}if(Xn(i)){if((i.guard!==void 0||i.cond!==void 0)&&t.push(`${r}: guard`),i.actions!==void 0&&t.push(`${r}: actions`),i.description!==void 0&&t.push(`${r}: description`),i.reenter!==void 0&&t.push(`${r}: reenter`),i.target===void 0)continue;n.push({target:i.target});continue}t.push(`${r}: expression`)}if(n.length!==0)return n.length===1?n[0]:n}function bw(e,t,r){let n={};(e.__spreads!==void 0||e.__computed!==void 0)&&t.push(`${r}: partial source`);let i=e.type;if(i==="parallel"&&(n.type="parallel"),i==="final"&&(n.type="final"),i==="history"&&(n.type="history",e.history==="deep"&&(n.history="deep")),typeof e.initial=="string"&&(n.initial=e.initial),Array.isArray(e.tags)&&e.tags.every(a=>typeof a=="string")&&(n.tags=e.tags),Xn(e.on)){let a={};for(let[l,s]of Object.entries(e.on)){if(l.startsWith("__"))continue;let o=xw(s,t,`${r} on ${l}`);o!==void 0&&(a[l]=o)}Object.keys(a).length>0&&(n.on=a)}if(Xn(e.after)){let a={};for(let[l,s]of Object.entries(e.after)){if(l.startsWith("__"))continue;if(!/^\d+$/.test(l)){t.push(`${r} after ${l}: delay expression`);continue}let o=xw(s,t,`${r} after ${l}`);o!==void 0&&(a[l]=o)}Object.keys(a).length>0&&(n.after=a)}if(e.entry!==void 0&&t.push(`${r}: entry actions`),e.exit!==void 0&&t.push(`${r}: exit actions`),e.always!==void 0&&t.push(`${r}: always transitions`),e.invoke!==void 0&&t.push(`${r}: invoked actors`),zp(e.context)?e.context!==void 0&&(n.context=e.context):t.push(`${r}: context expressions`),Xn(e.states)){let a={};for(let[l,s]of Object.entries(e.states))l.startsWith("__")||!Xn(s)||(a[l]=bw(s,t,r===""?l:`${r}.${l}`));Object.keys(a).length>0&&(n.states=a)}return n}function Fp(e){if(e===null||!Xn(e.states))return null;let t=[],r=bw(e,t,"");if(!Xn(r.states)||Object.keys(r.states).length===0)return null;let n=t.some(i=>i.endsWith(": partial source"));return{machineId:typeof e.id=="string"?e.id:"(machine)",config:r,dropped:[...new Set(t)],partial:n}}function gO(e){let t=e!==null&&typeof e=="object"?e:void 0,r=t?._nodes??t?.nodes;return r===void 0?[]:r.map(n=>(n.path??[]).join("."))}function ww(e){let t=Sr(e);if(!t.ok)return null;let r=Fp(t.config);return r===null?null:Wp(r)}function Wp(e){let t;try{t=yw(e.config)}catch{return null}let r=null;try{r=dn(t).start()}catch{return null}return{send(i){try{r?.send({type:i})}catch{}},reset(){if(r!==null){try{r.stop()}catch{}try{r=dn(t).start()}catch{r=null}}},read:()=>{if(r===null)return{value:void 0,paths:[],context:void 0};let i=r.getSnapshot(),a=i!==null&&typeof i=="object"?i:void 0;return{value:a?.value,paths:gO(i),context:a?.context}},stop(){try{r?.stop()}catch{}}}}var mO=40;function Sd(e){if(e===void 0)return"";try{return JSON.stringify(e)??""}catch{return""}}function yO(e){return e.kind==="parallel"?"xstate.parallel":e.kind==="final"?"xstate.final":e.kind==="history"?"xstate.history":null}function xO(e){let{transition:t}=e,r=t.resolved.some(a=>a.startsWith("?")),n=t.resolved.length>0?t.resolved.map(a=>a.startsWith("?")?a.slice(1):a).join(" | "):"·",i=t.kind==="after"?`${e.t("xstate.after")} ${t.delay??""}`:t.event;return ue("button",{type:"button",className:"hx-xs-edge","data-enabled":e.enabled?"true":"false",title:e.enabled?i:void 0,onClick:()=>{e.enabled&&e.onEvent(t.event)}},ue("span",{className:"hx-xs-edge__event"},i),ue("span",{className:"hx-xs-edge__target","data-unresolved":r?"true":"false"},n),ue("span",{className:"hx-xs-edge__meta"},t.guard!==void 0&&ue("span",{className:"hx-xs-badge","data-tone":"muted"},`${e.t("xstate.guard")}: ${t.guard}`),t.actions.length>0&&ue("span",{className:"hx-xs-badge","data-tone":"muted"},`${e.t("xstate.actions")}: ${t.actions.join(", ")}`),t.partial&&ue("span",{className:"hx-xs-badge","data-tone":"warn"},"⚠")))}function vw(e){let{node:t,ir:r,active:n,interactive:i,onEvent:a,t:l}=e,s=n.has(t.id),o=yO(t),c=[...t.entry.length>0?[{key:"entry",label:`${l("xstate.entry")}: ${t.entry.join(", ")}`}]:[],...t.exit.length>0?[{key:"exit",label:`${l("xstate.exit")}: ${t.exit.join(", ")}`}]:[],...t.after.map(u=>({key:`after-${u.event}`,label:`${l("xstate.after")}: ${u.delay??""}`})),...t.invokes.map((u,d)=>({key:`inv-${d}`,label:`${l("xstate.invoke")}: ${u.src}`}))],h=[...t.on,...t.always];return ue("div",{className:"hx-xs-card","data-kind":t.kind,"data-active":s?"true":"false"},ue("div",{className:"hx-xs-card__head"},ue("span",{className:"hx-xs-card__marker","aria-hidden":"true"},s?"●":t.initial!==void 0?"◇":""),ue("span",{className:"hx-xs-card__name"},t.key),t.initial!==void 0&&ue("span",{className:"hx-xs-badge","data-tone":"initial"},`${l("xstate.initial")}: ${t.initial}`),o!==null&&ue("span",{className:"hx-xs-badge","data-tone":"kind"},l(o)),t.partial&&ue("span",{className:"hx-xs-badge","data-tone":"warn",title:l("xstate.opaque")},"⚠")),c.length>0&&ue("div",{className:"hx-xs-card__effects"},c.map(u=>ue("span",{key:u.key,className:"hx-xs-badge","data-tone":"muted"},u.label))),h.length>0&&ue("div",{className:"hx-xs-card__edges"},h.map((u,d)=>ue(xO,{key:`${u.event}-${u.targets.join(",")}-${d}`,transition:u,enabled:i&&s,onEvent:a,t:l}))),t.children.length>0&&ue("div",{className:"hx-xs-card__children","data-parallel":t.kind==="parallel"?"true":"false"},t.children.map(u=>{let d=r.nodes.get(u);return d===void 0?null:ue(vw,{key:u,node:d,ir:r,active:n,interactive:i,onEvent:a,t:l})})))}function $w(e){let{source:t,execution:r,retryToken:n,label:i,viewRef:a,onState:l,t:s}=e,o=De.useRef(l);De.useLayoutEffect(()=>{o.current=l});let c=De.useMemo(()=>{if(t.trim()==="")return{status:"empty"};let A=Sr(t);if(!A.ok)return{status:"error"};let $=Tn(A.config);return $===null?{status:"error"}:{status:"ok",ir:$}},[t,n]),[h,u]=De.useState(()=>c.status==="ok"?Li(c.ir):new Set),[d,p]=De.useState(!1),[g,m]=De.useState({value:void 0,paths:[],context:void 0}),[v,x]=De.useState([]),[k,b]=De.useState(!1),C=De.useRef(null),N=De.useRef(0),R=De.useCallback(A=>{N.current+=1,x($=>[{...A,id:N.current},...$].slice(0,mO))},[]),O=De.useCallback(()=>{let A=Sr(t);return A.ok?A.config:null},[t]),P=De.useCallback(()=>{if(c.status!=="ok")return;let A=Fp(O());if(A===null){R({event:"run",outcome:"note",detail:s("xstate.parseError")});return}C.current?.stop();let $=Wp(A);if(C.current=$,$===null){p(!1),R({event:"run",outcome:"note",detail:s("xstate.parseError")});return}m($.read()),p(!0),R({event:"run",outcome:"ok",detail:Sd($.read().value)})},[c,O,R,s]);De.useEffect(()=>()=>{C.current?.stop(),C.current=null},[c]),De.useEffect(()=>{if(r==="off"){C.current?.stop(),C.current=null,p(!1);return}r==="auto"&&c.status==="ok"&&P()},[r,c,P]),De.useEffect(()=>{if(c.status!=="ok"){o.current(c.status==="empty"?{status:"error",message:s("xstate.empty")}:{status:"error",message:s("xstate.parseError")});return}o.current({status:"ready",machineId:c.ir.id,partial:c.ir.partial,live:d})},[c,d,s]),De.useImperativeHandle(a,()=>({run(){P()},reset(){if(C.current!==null){C.current.reset(),m(C.current.read()),R({event:"reset",outcome:"ok"});return}c.status==="ok"&&(u(Li(c.ir)),R({event:"reset",outcome:"ok"}))}}),[P,c,R]);let H=De.useCallback(A=>{if(d&&C.current!==null){C.current.send(A);let y=C.current.read();m(y),R({event:A,outcome:"ok",detail:Sd(y.value)});return}if(c.status!=="ok")return;let $=Sl(c.ir,h,A);u($.active),R({event:A,outcome:$.ignored?"ignored":"ok",detail:$.fired!==void 0&&!$.ignored?$.fired.to.join(" | "):void 0})},[d,c,h,R]);if(c.status!=="ok")return ue("div",{className:"hx-xs","data-status":c.status},ue("p",{className:"hx-status__text"},c.status==="empty"?s("xstate.empty"):s("xstate.parseError")));let I=c.ir,G=I.nodes.get(""),Z=De.useMemo(()=>d?new Set(g.paths):h,[d,g,h]),z=ag(I),W=new Set;for(let A of Z){let $=I.nodes.get(A);if($!==void 0)for(let y of $.on)W.add(y.event)}let S=Sd(g.context);return ue("div",{className:"hx-xs","data-running":d?"true":"false"},ue("div",{className:"hx-xs-header"},ue("span",{className:"hx-xs-header__id",title:i},I.id),ue("span",{className:"hx-xs-badge","data-tone":d?"live":"static"},s(d?"xstate.state":"xstate.static")),ue("span",{className:"hx-xs-header__value"},Sd(d?g.value:bO(I,h))),d&&S!==""&&ue("span",{className:"hx-xs-header__context",title:s("xstate.context")},`${s("xstate.context")}: ${S}`)),r==="confirm"&&!d&&ue("button",{type:"button",className:"hx-xs-run",onClick:P,title:s("xstate.run.hint")},s("xstate.run")),z.length>0&&ue("div",{className:"hx-xs-events"},z.map(A=>ue("button",{key:A,type:"button",className:"hx-xs-event","data-available":W.has(A)?"true":"false",onClick:()=>H(A)},A)),d&&ue("button",{type:"button",className:"hx-xs-event","data-role":"reset",onClick:()=>{C.current?.reset(),m(C.current?.read()??{value:void 0,paths:[],context:void 0}),R({event:"reset",outcome:"ok"})}},s("xstate.reset"))),ue("div",{className:"hx-xs-body"},(G?.children??[]).map(A=>{let $=I.nodes.get(A);return $===void 0?null:ue(vw,{key:A,node:$,ir:I,active:Z,interactive:!0,onEvent:H,t:s})})),ue("div",{className:"hx-xs-logbar"},ue("button",{type:"button",className:"hx-xs-logtoggle","data-open":k?"true":"false",onClick:()=>b(A=>!A)},`${s("xstate.log")}${v.length>0?` (${v.length})`:""}`),k&&ue("ul",{className:"hx-xs-log"},v.length===0&&ue("li",{className:"hx-xs-log__empty"},s("xstate.log.empty")),v.map(A=>ue("li",{key:A.id,className:"hx-xs-log__row","data-outcome":A.outcome},ue("span",{className:"hx-xs-log__event"},A.event),A.detail!==void 0&&A.detail!==""&&ue("span",{className:"hx-xs-log__detail"},A.detail))))))}function bO(e,t){return[...t].filter(r=>r!=="").filter(r=>{let n=e.nodes.get(r);return n!==void 0&&n.children.length===0})}var Hw=Object.defineProperty,wO=(e,t,r)=>t in e?Hw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,vO=(e,t)=>{for(var r in t)Hw(e,r,{get:t[r],enumerable:!0})},$O=(e,t,r)=>wO(e,typeof t!="symbol"?t+"":t,r),jw={};vO(jw,{Graph:()=>Hr,alg:()=>Xp});var kO=Object.defineProperty,Uw=(e,t)=>{for(var r in t)kO(e,r,{get:t[r],enumerable:!0})},qp=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected="directed"in e?e.directed:!0,this._isMultigraph="multigraph"in e?e.multigraph:!1,this._isCompound="compound"in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e!="function"?this._defaultNodeLabelFn=()=>e:this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(r=>{t!==void 0?this.setNode(r,t):this.setNode(r)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=r=>this.removeEdge(this._edgeObjs[r]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(r=>{this.setParent(r)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t===void 0)t="\0";else{t+="";for(let r=t;r!==void 0;r=this.parent(r))if(r===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!=="\0")return t}}children(e="\0"){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e==="\0")return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let r=new Set(t),n=this.successors(e);if(n)for(let i of n)r.add(i);return Array.from(r.values())}}isLeaf(e){var t;let r;return this.isDirected()?r=this.successors(e):r=this.neighbors(e),((t=r?.length)!=null?t:0)===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([i,a])=>{e(i)&&t.setNode(i,a)}),Object.values(this._edgeObjs).forEach(i=>{t.hasNode(i.v)&&t.hasNode(i.w)&&t.setEdge(i,this.edge(i))});let r={},n=i=>{let a=this.parent(i);return!a||t.hasNode(a)?(r[i]=a,a):a in r?r[a]:n(a)};return this._isCompound&&t.nodes().forEach(i=>t.setParent(i,n(i))),t}setDefaultEdgeLabel(e){return typeof e!="function"?this._defaultEdgeLabelFn=()=>e:this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((r,n)=>(t!==void 0?this.setEdge(r,n,t):this.setEdge(r,n),n)),this}setEdge(e,t,r,n){let i,a,l,s,o=!1;typeof e=="object"&&e!==null&&"v"in e?(i=e.v,a=e.w,l=e.name,arguments.length===2&&(s=t,o=!0)):(i=e,a=t,l=n,arguments.length>2&&(s=r,o=!0)),i=""+i,a=""+a,l!==void 0&&(l=""+l);let c=El(this._isDirected,i,a,l);if(c in this._edgeLabels)return o&&(this._edgeLabels[c]=s),this;if(l!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(i),this.setNode(a),this._edgeLabels[c]=o?s:this._defaultEdgeLabelFn(i,a,l);let h=MO(this._isDirected,i,a,l);return i=h.v,a=h.w,Object.freeze(h),this._edgeObjs[c]=h,kw(this._preds[a],i),kw(this._sucs[i],a),this._in[a][c]=h,this._out[i][c]=h,this._edgeCount++,this}edge(e,t,r){let n=arguments.length===1?Bp(this._isDirected,e):El(this._isDirected,e,t,r);return this._edgeLabels[n]}edgeAsObj(e,t,r){let n=arguments.length===1?this.edge(e):this.edge(e,t,r);return typeof n!="object"||n===null?{label:n}:n}hasEdge(e,t,r){return(arguments.length===1?Bp(this._isDirected,e):El(this._isDirected,e,t,r))in this._edgeLabels}removeEdge(e,t,r){let n=arguments.length===1?Bp(this._isDirected,e):El(this._isDirected,e,t,r),i=this._edgeObjs[n];if(i){let a=i.v,l=i.w;delete this._edgeLabels[n],delete this._edgeObjs[n],Mw(this._preds[l],a),Mw(this._sucs[a],l),delete this._in[l][n],delete this._out[a][n],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,r){if(!e)return;let n=Object.values(e);return r?n.filter(i=>i.v===t&&i.w===r||i.v===r&&i.w===t):n}};function kw(e,t){e[t]?e[t]++:e[t]=1}function Mw(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function El(e,t,r,n){let i=""+t,a=""+r;if(!e&&i>a){let l=i;i=a,a=l}return i+""+a+""+(n===void 0?"\0":n)}function MO(e,t,r,n){let i=""+t,a=""+r;if(!e&&i>a){let s=i;i=a,a=s}let l={v:i,w:a};return n&&(l.name=n),l}function Bp(e,t){return El(e,t.v,t.w,t.name)}var _O={};Uw(_O,{read:()=>SO,write:()=>EO});function EO(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:AO(e),edges:TO(e)},r=e.graph();return r!==void 0&&(t.value=structuredClone(r)),t}function AO(e){return e.nodes().map(t=>{let r=e.node(t),n=e.parent(t),i={v:t};return r!==void 0&&(i.value=r),n!==void 0&&(i.parent=n),i})}function TO(e){return e.edges().map(t=>{let r=e.edge(t),n={v:t.v,w:t.w};return t.name!==void 0&&(n.name=t.name),r!==void 0&&(n.value=r),n})}function SO(e){let t=new qp(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(r=>{t.setNode(r.v,r.value),r.parent&&t.setParent(r.v,r.parent)}),e.edges.forEach(r=>{t.setEdge({v:r.v,w:r.w,name:r.name},r.value)}),t}var Xp={};Uw(Xp,{CycleException:()=>Id,bellmanFord:()=>Yw,components:()=>NO,dijkstra:()=>Cd,dijkstraAll:()=>LO,findCycles:()=>DO,floydWarshall:()=>zO,isAcyclic:()=>WO,postorder:()=>HO,preorder:()=>jO,prim:()=>UO,shortestPaths:()=>YO,tarjan:()=>Vw,topsort:()=>qw});var CO=()=>1;function Yw(e,t,r,n){return IO(e,String(t),r||CO,n||function(i){var a;return(a=e.outEdges(i))!=null?a:[]})}function IO(e,t,r,n){let i={},a,l=0,s=e.nodes(),o=function(u){let d=i[u.v],p=i[u.w];if(!d||!p)return;let g=r(u);d.distance+g<p.distance&&(i[u.w]={distance:d.distance+g,predecessor:u.v},a=!0)},c=function(){s.forEach(function(u){n(u).forEach(function(d){let p=d.v===u?d.v:d.w,g=p===d.v?d.w:d.v;o({v:p,w:g})})})};s.forEach(function(u){let d=u===t?0:Number.POSITIVE_INFINITY;i[u]={distance:d,predecessor:""}});let h=s.length;for(let u=1;u<h&&(a=!1,l++,c(),!!a);u++);if(l===h-1&&(a=!1,c(),a))throw new Error("The graph contains a negative weight cycle");return i}function NO(e){let t={},r=[],n;function i(a){var l,s;a in t||(t[a]=!0,n.push(a),(l=e.successors(a))==null||l.forEach(i),(s=e.predecessors(a))==null||s.forEach(i))}return e.nodes().forEach(function(a){n=[],i(a),n.length&&r.push(n)}),r}var Gw=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){let r=this._keyIndices,n=String(e);if(!(n in r)){let i=this._arr,a=i.length;return r[n]=a,i.push({key:n,priority:t}),this._decrease(a),!0}return!1}removeMin(){if(this.size()===0)throw new Error("Queue underflow");this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let r=this._keyIndices[e];if(r===void 0)throw new Error(`Key not found: ${e}`);let n=this._arr[r].priority;if(t>n)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${n} New: ${t}`);this._arr[r].priority=t,this._decrease(r)}_heapify(e){let t=this._arr,r=2*e,n=r+1,i=e;r<t.length&&(i=t[r].priority<t[i].priority?r:i,n<t.length&&(i=t[n].priority<t[i].priority?n:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){let t=this._arr,r=t[e].priority,n;for(;e!==0&&(n=e>>1,!(t[n].priority<r));)this._swap(e,n),e=n}_swap(e,t){let r=this._arr,n=this._keyIndices,i=r[e],a=r[t];r[e]=a,r[t]=i,n[a.key]=e,n[i.key]=t}},RO=()=>1;function Cd(e,t,r,n){let i=function(a){var l;return(l=e.outEdges(a))!=null?l:[]};return OO(e,String(t),r||RO,n||i)}function OO(e,t,r,n){let i={},a=new Gw,l,s,o=function(c){let h=c.v!==l?c.v:c.w,u=i[h];if(!u)return;let d=r(c),p=s.distance+d;if(d<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+c+" Weight: "+d);p<u.distance&&(u.distance=p,u.predecessor=l,a.decrease(h,p))};for(e.nodes().forEach(function(c){let h=c===t?0:Number.POSITIVE_INFINITY;i[c]={distance:h,predecessor:""},a.add(c,h)});a.size()>0;){l=a.removeMin();let c=i[l];if(!c||c.distance===Number.POSITIVE_INFINITY)break;s=c,n(l).forEach(o)}return i}function LO(e,t,r){return e.nodes().reduce(function(n,i){return n[i]=Cd(e,i,t,r),n},{})}function Vw(e){let t=0,r=[],n={},i=[];function a(l){var s;let o=n[l]={onStack:!0,lowlink:t,index:t++};if(r.push(l),(s=e.successors(l))==null||s.forEach(function(c){if(c in n){let h=n[c];h!=null&&h.onStack&&(o.lowlink=Math.min(o.lowlink,h.index))}else{a(c);let h=n[c];h&&(o.lowlink=Math.min(o.lowlink,h.lowlink))}}),o.lowlink===o.index){let c=[],h;do{h=r.pop();let u=n[h];u&&(u.onStack=!1),c.push(h)}while(l!==h);i.push(c)}}return e.nodes().forEach(function(l){l in n||a(l)}),i}function DO(e){return Vw(e).filter(function(t){var r;let n=t[0];return n?t.length>1||t.length===1&&((r=e.outEdges(n,n))!=null?r:[]).length>0:!1})}var PO=()=>1;function zO(e,t,r){return FO(e,t||PO,r||function(n){var i;return(i=e.outEdges(n))!=null?i:[]})}function FO(e,t,r){let n={},i=e.nodes();return i.forEach(function(a){let l={};n[a]=l,l[a]={distance:0,predecessor:""},i.forEach(function(s){a!==s&&(l[s]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),r(a).forEach(function(s){let o=s.v===a?s.w:s.v,c=t(s);l[o]={distance:c,predecessor:a}})}),i.forEach(function(a){let l=n[a];l&&i.forEach(function(s){let o=n[s];o&&i.forEach(function(c){let h=o[a],u=l[c],d=o[c];if(h&&u&&d){let p=h.distance+u.distance;p<d.distance&&(d.distance=p,d.predecessor=u.predecessor)}})})}),n}var Id=class extends Error{constructor(e){super(e),this.name="CycleException"}};function qw(e){let t={},r={},n=[];function i(a){var l;if(a in r)throw new Id;a in t||(r[a]=!0,t[a]=!0,(l=e.predecessors(a))==null||l.forEach(i),delete r[a],n.push(a))}if(e.sinks().forEach(i),Object.keys(t).length!==e.nodeCount())throw new Id;return n}function WO(e){try{qw(e)}catch(t){if(t instanceof Id)return!1;throw t}return!0}function BO(e,t,r,n,i){Array.isArray(t)||(t=[t]);let a=(s=>{var o;return(o=e.isDirected()?e.successors(s):e.neighbors(s))!=null?o:[]}),l={};return t.forEach(function(s){if(!e.hasNode(s))throw new Error("Graph does not have node: "+s);i=Xw(e,s,r==="post",l,a,n,i)}),i}function Xw(e,t,r,n,i,a,l){return t in n||(n[t]=!0,r||(l=a(l,t)),i(t).forEach(function(s){l=Xw(e,s,r,n,i,a,l)}),r&&(l=a(l,t))),l}function Kw(e,t,r){return BO(e,t,r,function(n,i){return n.push(i),n},[])}function HO(e,t){return Kw(e,t,"post")}function jO(e,t){return Kw(e,t,"pre")}function UO(e,t){var r;let n=new qp,i={},a=new Gw,l;function s(h){let u=h.v===l?h.w:h.v,d=a.priority(u);if(d!==void 0){let p=t(h);p<d&&(i[u]=l,a.decrease(u,p))}}if(e.nodeCount()===0)return n;e.nodes().forEach(function(h){a.add(h,Number.POSITIVE_INFINITY),n.setNode(h)});let o=e.nodes()[0];o!==void 0&&a.decrease(o,0);let c=!1;for(;a.size()>0;){if(l=a.removeMin(),l in i)n.setEdge(l,i[l]);else{if(c)throw new Error("Input graph is not connected: "+e);c=!0}(r=e.nodeEdges(l))==null||r.forEach(s)}return n}function YO(e,t,r,n){return GO(e,t,r,n??(i=>{var a;return(a=e.outEdges(i))!=null?a:[]}))}function GO(e,t,r,n){if(r===void 0)return Cd(e,t,r,n);let i=!1,a=e.nodes();for(let l=0;l<a.length;l++){let s=a[l];if(s===void 0)continue;let o=n(s);for(let c=0;c<o.length;c++){let h=o[c];if(!h)continue;let u=h.v===s?h.v:h.w,d=u===h.v?h.w:h.v;r({v:u,w:d})<0&&(i=!0)}if(i)return Yw(e,t,r,n)}return Cd(e,t,r,n)}var Hr=qp;function Ba(e,t,r,n){let i=n;for(;e.hasNode(i);)i=Kp(n);return r.dummy=t,e.setNode(i,r),i}function VO(e){let t=new Hr().setGraph(e.graph());return e.nodes().forEach(r=>t.setNode(r,e.node(r))),e.edges().forEach(r=>{let n=t.edge(r.v,r.w)||{weight:0,minlen:1},i=e.edge(r);t.setEdge(r.v,r.w,{weight:n.weight+i.weight,minlen:Math.max(n.minlen,i.minlen)})}),t}function Zw(e){let t=new Hr({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(r=>{e.children(r).length||t.setNode(r,e.node(r))}),e.edges().forEach(r=>{t.setEdge(r,e.edge(r))}),t}function _w(e,t){let r=e.x,n=e.y,i=t.x-r,a=t.y-n,l=e.width/2,s=e.height/2;if(!i&&!a)throw new Error("Not possible to find intersection inside of the rectangle");let o,c;return Math.abs(a)*l>Math.abs(i)*s?(a<0&&(s=-s),o=s*i/a,c=s):(i<0&&(l=-l),o=l,c=l*a/i),{x:r+o,y:n+c}}function Tl(e){let t=Al(Jw(e)+1).map(()=>[]);return e.nodes().forEach(r=>{let n=e.node(r),i=n.rank;i!==void 0&&(t[i]||(t[i]=[]),t[i][n.order]=r)}),t}function qO(e){let t=e.nodes().map(n=>{let i=e.node(n).rank;return i===void 0?Number.MAX_VALUE:i}),r=hn(Math.min,t);e.nodes().forEach(n=>{let i=e.node(n);Object.hasOwn(i,"rank")&&(i.rank-=r)})}function XO(e){let t=e.nodes().map(l=>e.node(l).rank).filter(l=>l!==void 0),r=hn(Math.min,t),n=[];e.nodes().forEach(l=>{let s=e.node(l).rank-r;n[s]||(n[s]=[]),n[s].push(l)});let i=0,a=e.graph().nodeRankFactor;Array.from(n).forEach((l,s)=>{l===void 0&&s%a!==0?--i:l!==void 0&&i&&l.forEach(o=>e.node(o).rank+=i)})}function Ew(e,t,r,n){let i={width:0,height:0};return arguments.length>=4&&(i.rank=r,i.order=n),Ba(e,"border",i,t)}function KO(e,t=Qw){let r=[];for(let n=0;n<e.length;n+=t){let i=e.slice(n,n+t);r.push(i)}return r}var Qw=65535;function hn(e,t){if(t.length>Qw){let r=KO(t);return e(...r.map(n=>e(...n)))}else return e(...t)}function Jw(e){let t=e.nodes().map(r=>{let n=e.node(r).rank;return n===void 0?Number.MIN_VALUE:n});return hn(Math.max,t)}function ZO(e,t){let r={lhs:[],rhs:[]};return e.forEach(n=>{t(n)?r.lhs.push(n):r.rhs.push(n)}),r}function QO(e,t){let r=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-r)+"ms")}}function ev(e,t){return t()}var JO=0;function Kp(e){let t=++JO;return e+(""+t)}function Al(e,t,r=1){t==null&&(t=e,e=0);let n=a=>a<t;r<0&&(n=a=>t<a);let i=[];for(let a=e;n(a);a+=r)i.push(a);return i}function Nd(e,t){let r={};for(let n of t)e[n]!==void 0&&(r[n]=e[n]);return r}function Rd(e,t){let r;return typeof t=="string"?r=n=>n[t]:r=t,Object.entries(e).reduce((n,[i,a])=>(n[i]=r(a,i),n),{})}function eL(e,t){return e.reduce((r,n,i)=>(r[n]=t[i],r),{})}var Od="\0";function tv(e,t,r){var n,i,a,l,s,o;if(!(e&&t&&r&&t.dummy==="edge"&&r.dummy==="edge"&&t.edgeObj&&r.edgeObj&&e[t.edgeObj.v]&&e[r.edgeObj.v]&&e[t.edgeObj.w]&&e[r.edgeObj.w]))return 0;let c=!0;t.edgeObj.w===r.edgeObj.w&&(c=!1);let h=c?(i=(n=e[t.edgeObj.v])==null?void 0:n.rank)!=null?i:NaN+1:(l=(a=e[t.edgeObj.w])==null?void 0:a.rank)!=null?l:NaN-1,u=Object.entries(e).find(m=>{var v,x;return((v=m[1].edgeObj)==null?void 0:v.v)===t.edgeObj.v&&((x=m[1].edgeObj)==null?void 0:x.w)===t.edgeObj.w&&m[1].rank===h}),d=Object.entries(e).find(m=>{var v,x;return((v=m[1].edgeObj)==null?void 0:v.v)===r.edgeObj.v&&((x=m[1].edgeObj)==null?void 0:x.w)===r.edgeObj.w&&m[1].rank===h});if(!u||!d)return 0;let p=(s=u[1].order)!=null?s:NaN,g=(o=d[1].order)!=null?o:NaN;return isNaN(p-g)?0:p-g}var tL="3.1.1",rL=class{constructor(){$O(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Aw(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Aw(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,r=t._prev;for(;r!==t;)e.push(JSON.stringify(r,nL)),r=r._prev;return"["+e.join(", ")+"]"}};function Aw(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function nL(e,t){if(e!=="_next"&&e!=="_prev")return t}var iL=rL,aL=()=>1;function sL(e,t){if(e.nodeCount()<=1)return[];let r=oL(e,t||aL);return lL(r.graph,r.buckets,r.zeroIdx).flatMap(n=>e.outEdges(n.v,n.w)||[])}function lL(e,t,r){var n;let i=[],a=t[t.length-1],l=t[0],s;for(;e.nodeCount();){for(;s=l.dequeue();)Hp(e,t,r,s);for(;s=a.dequeue();)Hp(e,t,r,s);if(e.nodeCount()){for(let o=t.length-2;o>0;--o)if(s=(n=t[o])==null?void 0:n.dequeue(),s){i=i.concat(Hp(e,t,r,s,!0)||[]);break}}}return i}function Hp(e,t,r,n,i){let a=[],l=i?a:void 0;return(e.inEdges(n.v)||[]).forEach(s=>{let o=e.edge(s),c=e.node(s.v);i&&a.push({v:s.v,w:s.w}),c.out-=o,Vp(t,r,c)}),(e.outEdges(n.v)||[]).forEach(s=>{let o=e.edge(s),c=s.w,h=e.node(c);h.in-=o,Vp(t,r,h)}),e.removeNode(n.v),l}function oL(e,t){let r=new Hr,n=0,i=0;e.nodes().forEach(s=>{r.setNode(s,{v:s,in:0,out:0})}),e.edges().forEach(s=>{let o=r.edge(s.v,s.w)||0,c=t(s),h=o+c;r.setEdge(s.v,s.w,h);let u=r.node(s.v),d=r.node(s.w);i=Math.max(i,u.out+=c),n=Math.max(n,d.in+=c)});let a=cL(i+n+3).map(()=>new iL),l=n+1;return r.nodes().forEach(s=>{Vp(a,l,r.node(s))}),{graph:r,buckets:a,zeroIdx:l}}function Vp(e,t,r){var n,i,a;r.out?r.in?(a=e[r.out-r.in+t])==null||a.enqueue(r):(i=e[e.length-1])==null||i.enqueue(r):(n=e[0])==null||n.enqueue(r)}function cL(e){let t=[];for(let r=0;r<e;r++)t.push(r);return t}function dL(e,t){(e.graph().acyclicer==="greedy"?sL(e,r(e)):hL(e,t??null)).forEach(n=>{let i=e.edge(n);e.removeEdge(n),i.forwardName=n.name,i.reversed=!0,e.setEdge(n.w,n.v,i,Kp("rev"))});function r(n){return i=>n.edge(i).weight}}function hL(e,t){let r=[],n={},i={};function a(o){Object.hasOwn(i,o)||(i[o]=!0,n[o]=!0,e.outEdges(o).forEach(c=>{Object.hasOwn(n,c.w)?r.push(c):a(c.w)}),delete n[o])}function l(o){var c;Object.hasOwn(i,o)||(i[o]=!0,n[o]=!0,(c=e.outEdges(o))==null||c.forEach(h=>{var u,d;Object.hasOwn(n,h.w)||((u=t.node(o))==null?void 0:u.rank)>((d=t.node(h.w))==null?void 0:d.rank)&&fL(e,h.w,h)?r.push(h):l(h.w)}),delete n[o])}let s=a;return t&&typeof t.node=="function"&&(s=l),e.sources().forEach(s),e.nodes().forEach(s),r}function uL(e){e.edges().forEach(t=>{let r=e.edge(t);if(r.reversed){e.removeEdge(t);let n=r.forwardName;delete r.reversed,delete r.forwardName,e.setEdge(t.w,t.v,r,n)}})}function fL(e,t,r){let n=new Set;function i(a){var l;if(e.sources().includes(a))return!0;n.add(a);for(let s of(l=e.inEdges(a))!=null?l:[])if(!(s.v===r.v&&s.w===r.w)&&!n.has(s.v)&&i(s.v))return!0;return!1}return i(t)}function pL(e){e.graph().dummyChains=[],e.edges().forEach(t=>gL(e,t))}function gL(e,t){let r=t.v,n=e.node(r).rank,i=t.w,a=e.node(i).rank,l=t.name,s=e.edge(t),o=s.labelRank;if(a===n+1)return;e.removeEdge(t);let c,h,u;for(u=0,++n;n<a;++u,++n)s.points=[],h={width:0,height:0,edgeLabel:s,edgeObj:t,rank:n},c=Ba(e,"edge",h,"_d"),n===o&&(h.width=s.width,h.height=s.height,h.dummy="edge-label",h.labelpos=s.labelpos),e.setEdge(r,c,{weight:s.weight},l),u===0&&e.graph().dummyChains.push(c),r=c;e.setEdge(r,i,{weight:s.weight},l)}function mL(e){e.graph().dummyChains.forEach(t=>{let r=e.node(t),n=r.edgeLabel,i;for(e.setEdge(r.edgeObj,n);r.dummy;)i=e.successors(t)[0],e.removeNode(t),n.points.push({x:r.x,y:r.y}),r.dummy==="edge-label"&&(n.x=r.x,n.y=r.y,n.width=r.width,n.height=r.height),t=i,r=e.node(t)})}function Zp(e){let t={};function r(n){let i=e.node(n);if(Object.hasOwn(t,n))return i.rank;t[n]=!0;let a=e.outEdges(n),l=a?a.map(o=>o==null?Number.POSITIVE_INFINITY:r(o.w)-e.edge(o).minlen):[],s=hn(Math.min,l);return s===Number.POSITIVE_INFINITY&&(s=0),i.rank=s}e.sources().forEach(r)}function Wa(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var rv=yL;function yL(e){let t=new Hr({directed:!1}),r=e.nodes();if(r.length===0)throw new Error("Graph must have at least one node");let n=r[0],i=e.nodeCount();t.setNode(n,{});let a,l;for(;xL(t,e)<i&&(a=bL(t,e),!!a);)l=t.hasNode(a.v)?Wa(e,a):-Wa(e,a),wL(t,e,l);return t}function xL(e,t){function r(n){let i=t.nodeEdges(n);i&&i.forEach(a=>{let l=a.v,s=n===l?a.w:l;!e.hasNode(s)&&!Wa(t,a)&&(e.setNode(s,{}),e.setEdge(n,s,{}),r(s))})}return e.nodes().forEach(r),e.nodeCount()}function bL(e,t){return t.edges().reduce((r,n)=>{let i=Number.POSITIVE_INFINITY;return e.hasNode(n.v)!==e.hasNode(n.w)&&(i=Wa(t,n)),i<r[0]?[i,n]:r},[Number.POSITIVE_INFINITY,null])[1]}function wL(e,t,r){e.nodes().forEach(n=>t.node(n).rank+=r)}var{preorder:vL,postorder:$L}=Xp,kL=Oi;Oi.initLowLimValues=Jp;Oi.initCutValues=Qp;Oi.calcCutValue=nv;Oi.leaveEdge=av;Oi.enterEdge=sv;Oi.exchangeEdges=lv;function Oi(e){e=VO(e),Zp(e);let t=rv(e);Jp(t),Qp(t,e);let r,n;for(;r=av(t);)n=sv(t,e,r),lv(t,e,r,n)}function Qp(e,t){let r=$L(e,e.nodes());r=r.slice(0,r.length-1),r.forEach(n=>ML(e,t,n))}function ML(e,t,r){let n=e.node(r).parent,i=e.edge(r,n);i.cutvalue=nv(e,t,r)}function nv(e,t,r){let n=e.node(r).parent,i=!0,a=t.edge(r,n),l=0;a||(i=!1,a=t.edge(n,r)),l=a.weight;let s=t.nodeEdges(r);return s&&s.forEach(o=>{let c=o.v===r,h=c?o.w:o.v;if(h!==n){let u=c===i,d=t.edge(o).weight;if(l+=u?d:-d,EL(e,r,h)){let p=e.edge(r,h).cutvalue;l+=u?-p:p}}}),l}function Jp(e,t){arguments.length<2&&(t=e.nodes()[0]),iv(e,{},1,t)}function iv(e,t,r,n,i){let a=r,l=e.node(n);t[n]=!0;let s=e.neighbors(n);return s&&s.forEach(o=>{Object.hasOwn(t,o)||(r=iv(e,t,r,o,n))}),l.low=a,l.lim=r++,i?l.parent=i:delete l.parent,r}function av(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function sv(e,t,r){let n=r.v,i=r.w;t.hasEdge(n,i)||(n=r.w,i=r.v);let a=e.node(n),l=e.node(i),s=a,o=!1;return a.lim>l.lim&&(s=l,o=!0),t.edges().filter(c=>o===Tw(e,e.node(c.v),s)&&o!==Tw(e,e.node(c.w),s)).reduce((c,h)=>Wa(t,h)<Wa(t,c)?h:c)}function lv(e,t,r,n){let i=r.v,a=r.w;e.removeEdge(i,a),e.setEdge(n.v,n.w,{}),Jp(e),Qp(e,t),_L(e,t)}function _L(e,t){let r=e.nodes().find(i=>!e.node(i).parent);if(!r)return;let n=vL(e,[r]);n=n.slice(1),n.forEach(i=>{let a=e.node(i).parent,l=t.edge(i,a),s=!1;l||(l=t.edge(a,i),s=!0),t.node(i).rank=t.node(a).rank+(s?l.minlen:-l.minlen)})}function EL(e,t,r){return e.hasEdge(t,r)}function Tw(e,t,r){return r.low<=t.lim&&t.lim<=r.lim}var AL=TL;function TL(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":Sw(e);break;case"tight-tree":CL(e);break;case"longest-path":SL(e);break;case"none":break;default:Sw(e)}}var SL=Zp;function CL(e){Zp(e),rv(e)}function Sw(e){kL(e)}var IL=NL;function NL(e){let t=OL(e),r=e.graph();Array.isArray(r.dummyChains)&&r.dummyChains.forEach(n=>{let i=e.node(n),a=i.edgeObj,l=RL(e,t,a.v,a.w),s=l.path,o=l.lca,c=0,h=s[c],u=!0;for(;n!==a.w;){if(i=e.node(n),u){for(;(h=s[c])!==o&&e.node(h).maxRank<i.rank;)c++;h===o&&(u=!1)}if(!u){for(;c<s.length-1&&e.node(s[c+1]).minRank<=i.rank;)c++;h=s[c]}h!==void 0&&e.setParent(n,h),n=e.successors(n)[0]}})}function RL(e,t,r,n){let i=[],a=[],l=Math.min(t[r].low,t[n].low),s=Math.max(t[r].lim,t[n].lim),o;o=r;do o=e.parent(o),i.push(o);while(o&&(t[o].low>l||s>t[o].lim));let c=o,h=n;for(;(h=e.parent(h))!==c;)a.push(h);return{path:i.concat(a.reverse()),lca:c}}function OL(e){let t={},r=0;function n(i){let a=r;e.children(i).forEach(n),t[i]={low:a,lim:r++}}return e.children(Od).forEach(n),t}function LL(e){let t=Ba(e,"root",{},"_root"),r=DL(e),n=Object.values(r),i=hn(Math.max,n)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(s=>e.edge(s).minlen*=a);let l=PL(e)+1;e.children(Od).forEach(s=>{ov(e,t,a,l,i,r,s)}),e.graph().nodeRankFactor=a}function ov(e,t,r,n,i,a,l){var s;let o=e.children(l);if(!o.length){l!==t&&e.setEdge(t,l,{weight:0,minlen:r});return}let c=Ew(e,"_bt"),h=Ew(e,"_bb"),u=e.node(l);e.setParent(c,l),u.borderTop=c,e.setParent(h,l),u.borderBottom=h,o.forEach(d=>{var p;ov(e,t,r,n,i,a,d);let g=e.node(d),m=g.borderTop?g.borderTop:d,v=g.borderBottom?g.borderBottom:d,x=g.borderTop?n:2*n,k=m!==v?1:i-((p=a[l])!=null?p:0)+1;e.setEdge(c,m,{weight:x,minlen:k,nestingEdge:!0}),e.setEdge(v,h,{weight:x,minlen:k,nestingEdge:!0})}),e.parent(l)||e.setEdge(t,c,{weight:0,minlen:i+((s=a[l])!=null?s:0)})}function DL(e){let t={};function r(n,i){let a=e.children(n);a&&a.length&&a.forEach(l=>r(l,i+1)),t[n]=i}return e.children(Od).forEach(n=>r(n,1)),t}function PL(e){return e.edges().reduce((t,r)=>t+e.edge(r).weight,0)}function zL(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(r=>{e.edge(r).nestingEdge&&e.removeEdge(r)})}var FL=WL;function WL(e){function t(r){let n=e.children(r),i=e.node(r);if(n.length&&n.forEach(t),i&&Object.hasOwn(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(let a=i.minRank,l=i.maxRank+1;a<l;++a)Cw(e,"borderLeft","_bl",r,i,a),Cw(e,"borderRight","_br",r,i,a)}}e.children(Od).forEach(t)}function Cw(e,t,r,n,i,a){let l={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],o=Ba(e,"border",l,r);i[t][a]=o,e.setParent(o,n),s&&e.setEdge(s,o,{weight:1})}function BL(e){var t;let r=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(r==="lr"||r==="rl")&&cv(e)}function HL(e){var t;let r=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(r==="bt"||r==="rl")&&jL(e),(r==="lr"||r==="rl")&&(UL(e),cv(e))}function cv(e){e.nodes().forEach(t=>Iw(e.node(t))),e.edges().forEach(t=>Iw(e.edge(t)))}function Iw(e){let t=e.width;e.width=e.height,e.height=t}function jL(e){e.nodes().forEach(t=>jp(e.node(t))),e.edges().forEach(t=>{var r;let n=e.edge(t);(r=n.points)==null||r.forEach(jp),Object.hasOwn(n,"y")&&jp(n)})}function jp(e){e.y=-e.y}function UL(e){e.nodes().forEach(t=>Up(e.node(t))),e.edges().forEach(t=>{var r;let n=e.edge(t);(r=n.points)==null||r.forEach(Up),Object.hasOwn(n,"x")&&Up(n)})}function Up(e){let t=e.x;e.x=e.y,e.y=t}function YL(e,t=null){let r={},n=e.nodes().filter(c=>!e.children(c).length),i=n.map(c=>e.node(c).rank),a=hn(Math.max,i),l=Al(a+1).map(()=>[]);function s(c){if(r[c])return;r[c]=!0;let h=e.node(c);l[h.rank].push(c);let u=e.successors(c);u&&[...u].sort((d,p)=>o(d,p)).forEach(s)}n.sort((c,h)=>e.node(c).rank-e.node(h).rank).forEach(s);function o(c,h){let u=e.node(c),d=e.node(h);return tv(t,u,d)}return l}function GL(e,t){let r=0;for(let n=1;n<t.length;++n)r+=VL(e,t[n-1],t[n]);return r}function VL(e,t,r){let n=eL(r,r.map((c,h)=>h)),i=t.flatMap(c=>{let h=e.outEdges(c);return h?h.map(u=>({pos:n[u.w],weight:e.edge(u).weight})).sort((u,d)=>u.pos-d.pos):[]}),a=1;for(;a<r.length;)a<<=1;let l=2*a-1;a-=1;let s=new Array(l).fill(0),o=0;return i.forEach(c=>{let h=c.pos+a;s[h]+=c.weight;let u=0;for(;h>0;)h%2&&(u+=s[h+1]),h=h-1>>1,s[h]+=c.weight;o+=c.weight*u}),o}function qL(e,t=[]){return t.map(r=>{let n=e.inEdges(r);if(!n||!n.length)return{v:r};{let i=n.reduce((a,l)=>{let s=e.edge(l),o=e.node(l.v);return{sum:a.sum+s.weight*o.order,weight:a.weight+s.weight}},{sum:0,weight:0});return{v:r,barycenter:i.sum/i.weight,weight:i.weight}}})}function XL(e,t){let r={};e.forEach((i,a)=>{let l={indegree:0,in:[],out:[],vs:[i.v],i:a};i.barycenter!==void 0&&(l.barycenter=i.barycenter,l.weight=i.weight),r[i.v]=l}),t.edges().forEach(i=>{let a=r[i.v],l=r[i.w];a!==void 0&&l!==void 0&&(l.indegree++,a.out.push(l))});let n=Object.values(r).filter(i=>!i.indegree);return KL(n)}function KL(e){let t=[];function r(i){return a=>{a.merged||(a.barycenter===void 0||i.barycenter===void 0||a.barycenter>=i.barycenter)&&ZL(i,a)}}function n(i){return a=>{a.in.push(i),--a.indegree===0&&e.push(a)}}for(;e.length;){let i=e.pop();t.push(i),i.in.reverse().forEach(r(i)),i.out.forEach(n(i))}return t.filter(i=>!i.merged).map(i=>Nd(i,["vs","i","barycenter","weight"]))}function ZL(e,t){let r=0,n=0;e.weight&&(r+=e.barycenter*e.weight,n+=e.weight),t.weight&&(r+=t.barycenter*t.weight,n+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=r/n,e.weight=n,e.i=Math.min(t.i,e.i),t.merged=!0}function QL(e,t,r,n,i){let a={},l=null,s=null,o=i;typeof t=="boolean"?(o=t,a={}):t&&(a=t,l=r??null,s=n??null);let c=ZO(e,x=>Object.hasOwn(x,"barycenter")),h=c.lhs,u=c.rhs.sort((x,k)=>k.i-x.i),d=[],p=0,g=0,m=0;h.sort(JL(s,l,!!o));for(let[x,k]of Object.entries(a)){let b=h.findIndex(C=>C.vs[0]===x);h.splice(b+1,0,k)}m=Nw(d,u,m),h.forEach(x=>{m+=x.vs.length,d.push(x.vs),p+=x.barycenter*x.weight,g+=x.weight,m=Nw(d,u,m)});let v={vs:d.flat(1)};return g&&(v.barycenter=p/g,v.weight=g),v}function Nw(e,t,r){let n;for(;t.length&&(n=t[t.length-1]).i<=r;)t.pop(),e.push(n.vs),r++;return r}function JL(e,t,r){return(n,i)=>{if(n.barycenter<i.barycenter)return-1;if(n.barycenter>i.barycenter)return 1;if(e&&(typeof n.vs[0]=="string"||typeof i.vs[0]=="string")){let a=e.node(n.vs[0]),l=e.node(i.vs[0]),s=tv(t,a,l);if(s!==0)return s}return r?i.i-n.i:n.i-i.i}}function dv(e,t,r,n,i){var a,l,s,o,c,h,u,d,p,g,m;let v=null,x=i;typeof n=="boolean"?(x=n,v=null):n!==void 0&&(v=n);let k=e.children(t),b=e.node(t),C=b?b.borderLeft:void 0,N=b?b.borderRight:void 0,R={};C&&(k=k.filter(Z=>Z!==C&&Z!==N));let O=qL(e,k);O.forEach(Z=>{if(e.children(Z.v).length){let{result:z}=dv(e,Z.v,r,v,x);R[Z.v]=z,Object.hasOwn(z,"barycenter")&&tD(Z,z)}});let P=XL(O,r);eD(P,R);let H={},I=!1;for(let Z=0;Z<P.length;Z++)for(let z=Z+1;z<P.length;z++)if(!(!P[Z]||!P[z]||!((a=P[Z])!=null&&a.barycenter)||!((l=P[z])!=null&&l.barycenter))&&((s=P[Z])==null?void 0:s.barycenter)===P[z].barycenter){let W=(c=(o=P[Z])==null?void 0:o.vs[0])!=null?c:"",S=(u=(h=P[z])==null?void 0:h.vs[0])!=null?u:"",A=e.node(W),$=e.node(S);if(A.dummy==="edge"&&$.dummy==="edge"&&((d=A.edgeObj)==null?void 0:d.v)===((p=$.edgeObj)==null?void 0:p.v)&&((g=A.edgeObj)==null?void 0:g.w)===((m=$.edgeObj)==null?void 0:m.w))if(A.edgeLabel.reversed){H[S]=P[Z],P.splice(Z,1),Z--;break}else H[W]=P[z],P.splice(z,1),z--;else I=!0}let G=QL(P,H,v,e,x);if(C&&N){G.vs=[C,G.vs,N].flat(1);let Z=e.predecessors(C);if(Z&&Z.length){let z=e.node(Z[0]),W=e.predecessors(N),S=e.node(W[0]);Object.hasOwn(G,"barycenter")||(G.barycenter=0,G.weight=0),G.barycenter=(G.barycenter*G.weight+z.order+S.order)/(G.weight+2),G.weight+=2}}return Object.defineProperty(G,"result",{value:G,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(G,"usedBias",{value:I,enumerable:!1,configurable:!0,writable:!0}),G}function eD(e,t){e.forEach(r=>{r.vs=r.vs.flatMap(n=>t[n]?t[n].vs:n)})}function tD(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}function rD(e,t,r,n){n||(n=e.nodes());let i=nD(e),a=new Hr({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(l=>e.node(l));return n.forEach(l=>{let s=e.node(l),o=e.parent(l);if(s.rank===t||s.minRank<=t&&t<=s.maxRank){a.setNode(l),a.setParent(l,o||i);let c=e[r](l);c&&c.forEach(h=>{let u=h.v===l?h.w:h.v,d=a.edge(u,l),p=d!==void 0?d.weight:0;a.setEdge(u,l,{weight:e.edge(h).weight+p})}),Object.hasOwn(s,"minRank")&&a.setNode(l,{borderLeft:s.borderLeft[t],borderRight:s.borderRight[t]})}}),a}function nD(e){let t;for(;e.hasNode(t=Kp("_root")););return t}function iD(e,t,r){let n={},i;r.forEach(a=>{let l=e.parent(a),s,o;for(;l;){if(s=e.parent(l),s?(o=n[s],n[s]=l):(o=i,i=l),o&&o!==l){t.setEdge(o,l);return}l=s}})}function hv(e,t={},r=null){if(typeof t.customOrder=="function"){t.customOrder(e,hv);return}let n=Jw(e),i=Rw(e,Al(1,n+1),"inEdges"),a=Rw(e,Al(n-1,-1,-1),"outEdges"),l=YL(e,r);if(Ow(e,l),t.disableOptimalOrderHeuristic)return;let s=Number.POSITIVE_INFINITY,o,c=t.constraints||[];for(let h=0,u=0;u<4;++h,++u){aD(h%2?i:a,h%4>=2,c,r),l=Tl(e);let d=GL(e,l);d<s?(u=0,o=Object.assign({},l),s=d):d===s&&(o=structuredClone(l))}Ow(e,o)}function Rw(e,t,r){let n=new Map,i=(a,l)=>{n.has(a)||n.set(a,[]),n.get(a).push(l)};for(let a of e.nodes()){let l=e.node(a);if(typeof l.rank=="number"&&i(l.rank,a),typeof l.minRank=="number"&&typeof l.maxRank=="number")for(let s=l.minRank;s<=l.maxRank;s++)s!==l.rank&&i(s,a)}return t.map(function(a){return rD(e,a,r,n.get(a)||[])})}function aD(e,t,r,n){let i=!0,a=new Hr;e.forEach(function(l){r.forEach(h=>a.setEdge(h.left,h.right));let s=l.graph().root,{result:o,usedBias:c}=dv(l,s,a,n,i);t&&c&&(i=!i),o.vs.forEach((h,u)=>l.node(h).order=u),iD(l,a,o.vs)})}function Ow(e,t){Object.values(t).forEach(r=>r.forEach((n,i)=>e.node(n).order=i))}function sD(e,t){let r={};function n(i,a){let l=0,s=0,o=i.length,c=a[a.length-1];return a.forEach((h,u)=>{let d=oD(e,h),p=d?e.node(d).order:o;(d||h===c)&&(a.slice(s,u+1).forEach(g=>{let m=e.predecessors(g);m&&m.forEach(v=>{let x=e.node(v),k=x.order;(k<l||p<k)&&!(x.dummy&&e.node(g).dummy)&&uv(r,v,g)})}),s=u+1,l=p)}),a}return t.length&&t.reduce(n),r}function lD(e,t){let r={};function n(a,l,s,o,c){Al(l,s).forEach(h=>{let u=a[h];if(u!==void 0&&e.node(u).dummy){let d=e.predecessors(u);d&&d.forEach(p=>{if(p===void 0)return;let g=e.node(p);g.dummy&&(g.order<o||g.order>c)&&uv(r,p,u)})}})}function i(a,l){let s=-1,o=-1,c=0;return l.forEach((h,u)=>{if(e.node(h).dummy==="border"){let d=e.predecessors(h);if(d&&d.length){let p=d[0];if(p===void 0)return;o=e.node(p).order,n(l,c,u,s,o),c=u,s=o}}n(l,c,l.length,o,a.length)}),l}return t.length&&t.reduce(i),r}function oD(e,t){if(e.node(t).dummy){let r=e.predecessors(t);if(r)return r.find(n=>e.node(n).dummy)}}function uv(e,t,r){if(t>r){let i=t;t=r,r=i}let n=e[t];n||(e[t]=n={}),n[r]=!0}function cD(e,t,r){if(t>r){let i=t;t=r,r=i}let n=e[t];return n!==void 0&&Object.hasOwn(n,r)}function dD(e,t,r,n,i){let a={},l={},s={};return t.forEach(o=>{o.forEach((c,h)=>{a[c]=c,l[c]=c,s[c]=h})}),t.forEach(o=>{let c=-1,h=-1,u=!1,d=o,p=o.findIndex(g=>i?.includes(g)||Lw(g,e,i));p>0&&(d=[o[p],...o.slice(0,p),...o.slice(p+1)],u=!0),d.forEach(g=>{var m;let v=n(g);if(v&&v.length){i!=null&&i.includes(g)&&(v=v.filter(b=>Lw(b,e,i)));let x=v.sort((b,C)=>{let N=s[b],R=s[C];return(N!==void 0?N:0)-(R!==void 0?R:0)}),k=(x.length-1)/2;for(let b=Math.floor(k),C=Math.ceil(k);b<=C;++b){let N=x[b];if(N===void 0)continue;let R=s[N];if(R!==void 0&&l[g]===g&&c<R&&s[N]!==h&&!cD(r,g,N)){let O=a[N];O!==void 0&&(l[N]=g,l[g]=a[g]=O,c=R,u&&(c=-1,h=(m=s[N])!=null?m:-1,u=!1))}}}})}),{root:a,align:l}}function hD(e,t,r,n,i=!1){let a={},l=uD(e,t,r,i),s=i?"borderLeft":"borderRight";function o(p,g){let m=l.nodes().slice(),v={},x=m.pop();for(;x;){if(v[x])p(x);else{v[x]=!0,m.push(x);for(let k of g(x))m.push(k)}x=m.pop()}}function c(p){let g=l.inEdges(p);g?a[p]=g.reduce((m,v)=>{var x;let k=(x=a[v.v])!=null?x:0,b=l.edge(v);return Math.max(m,k+(b!==void 0?b:0))},0):a[p]=0}function h(p){let g=l.outEdges(p),m=Number.POSITIVE_INFINITY;g&&(m=g.reduce((x,k)=>{let b=a[k.w],C=l.edge(k);return Math.min(x,(b!==void 0?b:0)-(C!==void 0?C:0))},Number.POSITIVE_INFINITY));let v=e.node(p);m!==Number.POSITIVE_INFINITY&&v.borderType!==s&&(a[p]=Math.max(a[p]!==void 0?a[p]:0,m))}function u(p){return l.predecessors(p)||[]}function d(p){return l.successors(p)||[]}return o(c,u),o(h,d),Object.keys(n).forEach(p=>{var g;let m=r[p];m!==void 0&&(a[p]=(g=a[m])!=null?g:0)}),a}function uD(e,t,r,n){let i=new Hr,a=e.graph(),l=yD(a.nodesep,a.edgesep,n);return t.forEach(s=>{let o;s.forEach(c=>{let h=r[c];if(h!==void 0){if(i.setNode(h),o!==void 0){let u=r[o];if(u!==void 0){let d=i.edge(u,h);i.setEdge(u,h,Math.max(l(e,c,o),d||0))}}o=c}})}),i}function fD(e,t){return Object.values(t).reduce((r,n)=>{let i=Number.NEGATIVE_INFINITY,a=Number.POSITIVE_INFINITY;Object.entries(n).forEach(([s,o])=>{let c=xD(e,s)/2;i=Math.max(o+c,i),a=Math.min(o-c,a)});let l=i-a;return l<r[0]&&(r=[l,n]),r},[Number.POSITIVE_INFINITY,null])[1]}function pD(e,t){let r=Object.values(t),n=hn(Math.min,r),i=hn(Math.max,r);["u","d"].forEach(a=>{["l","r"].forEach(l=>{let s=a+l,o=e[s];if(!o||o===t)return;let c=Object.values(o),h=n-hn(Math.min,c);l!=="l"&&(h=i-hn(Math.max,c)),h&&(e[s]=Rd(o,u=>u+h))})})}function gD(e,t=void 0){let r=e.ul;return r?Rd(r,(n,i)=>{var a,l;if(t){let o=t.toLowerCase(),c=e[o];if(c&&c[i]!==void 0)return c[i]}let s=Object.values(e).map(o=>{let c=o[i];return c!==void 0?c:0}).sort((o,c)=>o-c);return(((a=s[1])!=null?a:0)+((l=s[2])!=null?l:0))/2}):{}}function mD(e,t){let r=Tl(e),n=Object.assign(sD(e,r),lD(e,r)),i={},a;["u","d"].forEach(s=>{a=s==="u"?r:Object.values(r).reverse(),["l","r"].forEach(o=>{o==="r"&&(a=a.map(u=>Object.values(u).reverse()));let c=dD(e,a,n,u=>(s==="u"?e.predecessors(u):e.successors(u))||[],t),h=hD(e,a,c.root,c.align,o==="r");o==="r"&&(h=Rd(h,u=>-u)),i[s+o]=h})});let l=fD(e,i);return pD(i,l),gD(i,e.graph().align)}function yD(e,t,r){return(n,i,a)=>{let l=n.node(i),s=n.node(a),o=0,c;if(o+=l.width/2,Object.hasOwn(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":c=-l.width/2;break;case"r":c=l.width/2;break}if(c&&(o+=r?c:-c),c=void 0,o+=(l.dummy?t:e)/2,o+=(s.dummy?t:e)/2,o+=s.width/2,Object.hasOwn(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":c=s.width/2;break;case"r":c=-s.width/2;break}return c&&(o+=r?c:-c),o}}function xD(e,t){return e.node(t).width}function Lw(e,t,r){var n;if(!r)return!1;let i=(n=t.node(e))==null?void 0:n.edgeObj;if(!i||t.node(e).edgeLabel.reversed)return!1;let a=r.indexOf(i?.v),l=r.indexOf(i?.w);return a!==-1&&l!==-1&&a===(l+1)%r.length||a===(l-1)%r.length}function bD(e,t){e=Zw(e),wD(e),Object.entries(mD(e,t)).forEach(([r,n])=>e.node(r).x=n)}function wD(e){let t=Tl(e),r=e.graph(),n=r.ranksep,i=r.rankalign,a=0;t.forEach(l=>{let s=l.reduce((o,c)=>{var h;let u=(h=e.node(c).height)!=null?h:0;return o>u?o:u},0);l.forEach(o=>{let c=e.node(o);i==="top"?c.y=a+c.height/2:i==="bottom"?c.y=a+s-c.height/2:c.y=a+s/2}),a+=s+n})}var Dw=new WeakMap;function vD(e,t={}){return fv(e,ev,t),e}function Pw(e,t,r){let n=t;for(;n!==void 0;){let i=e.parent(n);if(i===r)return n;n=i}}function fv(e,t,r){var n;let i=e.nodes().filter(k=>e.children(k).length),a={};i.forEach(k=>{let b=e.node(k);if(b&&b.rankdir){let C=new Hr({multigraph:!0,compound:!0});C.setGraph({rankdir:b.rankdir});let N=e.children(k);N.forEach(W=>{let S={...e.node(W)};C.setNode(W,S);let A=e.parent(W);A&&A!==k&&N.includes(A)&&C.setParent(W,A)});let R=new Set;e.edges().forEach(W=>{let S=Pw(e,W.v,k),A=Pw(e,W.w,k);if(S&&A&&S!==A){let $=`${S}\0${A}`;R.has($)||(R.add($),C.setEdge(S,A,{...e.edge(W)}))}}),fv(C,t,r);let O=Bw(C);zw(O,t,r,null),Fw(C,O);let P=1/0,H=1/0,I=-1/0,G=-1/0;C.nodes().forEach(W=>{if(W===k)return;let S=C.node(W);S&&typeof S.x=="number"&&typeof S.y=="number"&&typeof S.width=="number"&&typeof S.height=="number"&&(P=Math.min(P,S.x-S.width/2),I=Math.max(I,S.x+S.width/2),H=Math.min(H,S.y-S.height/2),G=Math.max(G,S.y+S.height/2))}),(!isFinite(P)||!isFinite(H)||!isFinite(I)||!isFinite(G))&&(P=H=0,I=G=0);let Z=I-P,z=G-H;a[k]={minX:P,minY:H,maxX:I,maxY:G,width:Z,height:z,offsetX:P,offsetY:H},b._dagreClusterSubgraph=C}});let l=[],s=k=>{let b=[],C=(e.children(k)||[]).filter(N=>N!==k);for(;C.length>0;){let N=C.shift();b.push(N),(e.children(N)||[]).filter(R=>R!==N).forEach(R=>C.push(R))}return b},o=new Map;i.forEach(k=>{let b=e.node(k);b&&b.rankdir&&a[k]&&o.set(k,(e.children(k)||[]).filter(C=>C!==k))});let c=new Set([...o.values()].flat()),h=new Map;o.forEach((k,b)=>{c.has(b)||h.set(b,s(b))});let u=new Set([...h.values()].flat()),d=k=>{for(let[b,C]of h)if(C.includes(k))return b;return k},p=[];e.edges().forEach(k=>{(u.has(k.v)||u.has(k.w))&&p.push({edge:k,label:e.edge(k)})});let g=new Map;u.forEach(k=>{let b=e.parent(k);g.set(k,typeof b=="string"?b:void 0)}),h.forEach((k,b)=>{let C=e.node(b),N=[];k.forEach(P=>{let H=e.node(P);H&&(N.push({id:P,node:H,parent:g.get(P)}),e.removeNode(P))});let R=p.filter(({edge:P})=>k.includes(P.v)||k.includes(P.w)),O=a[b];C&&(l.push({clusterId:b,subgraph:C._dagreClusterSubgraph,bounds:O,children:k,removedNodes:N,removedEdges:R}),C.width=O.width,C.height=O.height)});let m=new Set;p.forEach(({edge:k,label:b})=>{let C=d(k.v),N=d(k.w);if(C!==N&&e.hasNode(C)&&e.hasNode(N)){let R=`${C}\0${N}`;m.has(R)||(m.add(R),e.setEdge(C,N,{...b,width:0,height:0}))}});let v=Bw(e),x=zw(v,t,r,(n=Dw.get(e))!=null?n:null);Dw.set(e,x),Fw(e,v),m.forEach(k=>{let b=k.indexOf("\0"),C=k.slice(0,b),N=k.slice(b+1);e.hasEdge(C,N)&&e.removeEdge(C,N)}),l.forEach(({clusterId:k,subgraph:b,bounds:C,removedNodes:N,removedEdges:R})=>{var O,P;let H=e.node(k),I=(O=H?.x)!=null?O:0,G=(P=H?.y)!=null?P:0,Z=(C.minX+C.maxX)/2,z=(C.minY+C.maxY)/2;N.forEach(({id:W,node:S,parent:A})=>{e.setNode(W,S),A!==void 0&&e.setParent(W,A)}),R.forEach(({edge:W,label:S})=>{e.setEdge(W,S)}),b.nodes().forEach(W=>{if(W===k)return;let S=b.node(W),A=e.node(W);A&&S&&typeof S.x=="number"&&typeof S.y=="number"&&(A.x=I+(S.x-Z),A.y=G+(S.y-z))}),delete H._dagreClusterSubgraph}),i.forEach(k=>{var b,C;let N=e.node(k),R=a[k];if(N&&N.rankdir&&N._dagreClusterSubgraph&&R){let O=N._dagreClusterSubgraph,P=(b=N.x)!=null?b:0,H=(C=N.y)!=null?C:0,I=(R.minX+R.maxX)/2,G=(R.minY+R.maxY)/2;O.nodes().forEach(Z=>{if(Z===k)return;let z=O.node(Z),W=e.node(Z);if(W&&z&&typeof z.x=="number"&&typeof z.y=="number"){let S=z.x-I,A=z.y-G;W.x=P+S,W.y=H+A}}),delete N._dagreClusterSubgraph}})}function zw(e,t,r,n=null){var i,a;let l=r?.useDynamic!==!1,s=l&&(i=n?.graph)!=null?i:null,o=l&&(a=n?.rawNodes)!=null?a:null;t(" makeSpaceForEdgeLabels",()=>SD(e)),t(" removeSelfEdges",()=>zD(e)),t(" acyclic",()=>dL(e,s)),t(" nestingGraph.run",()=>LL(e)),t(" rank",()=>AL(Zw(e))),t(" injectEdgeLabelProxies",()=>CD(e)),t(" removeEmptyRanks",()=>XO(e)),t(" nestingGraph.cleanup",()=>zL(e)),t(" normalizeRanks",()=>qO(e)),t(" assignRankMinMax",()=>ID(e)),t(" removeEdgeLabelProxies",()=>ND(e)),t(" normalize.run",()=>pL(e)),t(" parentDummyChains",()=>IL(e)),t(" addBorderSegments",()=>FL(e)),t(" order",()=>hv(e,r,o)),t(" insertSelfEdges",()=>FD(e)),t(" adjustCoordinateSystem",()=>BL(e)),t(" position",()=>bD(e,r.corePath)),t(" positionSelfEdges",()=>WD(e));let c=JSON.parse(JSON.stringify(e._nodes));return t(" removeBorderNodes",()=>PD(e)),t(" normalize.undo",()=>mL(e)),t(" fixupEdgeLabelCoords",()=>LD(e)),t(" undoCoordinateSystem",()=>HL(e)),t(" translateGraph",()=>RD(e)),t(" assignNodeIntersects",()=>OD(e)),t(" reversePoints",()=>DD(e)),t(" acyclic.undo",()=>uL(e)),{graph:e,rawNodes:c}}function Fw(e,t){e.nodes().forEach(r=>{let n=e.node(r),i=t.node(r);n&&(n.x=i.x,n.y=i.y,n.order=i.order,n.rank=i.rank,t.children(r).length&&(n.width=i.width,n.height=i.height))}),e.edges().forEach(r=>{let n=e.edge(r),i=t.edge(r);n.points=i.points,Object.hasOwn(i,"x")&&(n.x=i.x,n.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var $D=["nodesep","edgesep","ranksep","marginx","marginy"],kD={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},MD=["acyclicer","ranker","rankdir","align","rankalign"],_D=["width","height","rank"],Ww={width:0,height:0},ED=["minlen","weight","width","height","labeloffset"],AD={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},TD=["labelpos"];function Bw(e){let t=new Hr({multigraph:!0,compound:!0}),r=Gp(e.graph());return t.setGraph(Object.assign({},kD,Yp(r,$D),Nd(r,MD))),e.nodes().forEach(n=>{let i=Gp(e.node(n)),a=Yp(i,_D);Object.keys(Ww).forEach(s=>{a[s]===void 0&&(a[s]=Ww[s])}),t.setNode(n,a);let l=e.parent(n);l!==void 0&&t.setParent(n,l)}),e.edges().forEach(n=>{let i=Gp(e.edge(n));t.setEdge(n,Object.assign({},AD,Yp(i,ED),Nd(i,TD)))}),t}function SD(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(r=>{var n;let i=e.edge(r);i.minlen*=2,((n=i.labelpos)!=null?n:"r").toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?i.width+=i.labeloffset:i.height+=i.labeloffset)})}function CD(e){e.edges().forEach(t=>{let r=e.edge(t);if(r.width&&r.height){let n=e.node(t.v),i={rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t};Ba(e,"edge-proxy",i,"_ep")}})}function ID(e){let t=0;e.nodes().forEach(r=>{let n=e.node(r);n.borderTop&&(n.minRank=e.node(n.borderTop).rank,n.maxRank=e.node(n.borderBottom).rank,t=Math.max(t,n.maxRank))}),e.graph().maxRank=t}function ND(e){e.nodes().forEach(t=>{let r=e.node(t);if(r.dummy==="edge-proxy"){let n=r;e.edge(n.e).labelRank=r.rank,e.removeNode(t)}})}function RD(e){let t=Number.POSITIVE_INFINITY,r=0,n=Number.POSITIVE_INFINITY,i=0,a=e.graph(),l=a.marginx||0,s=a.marginy||0;function o(c){let h=c.x,u=c.y,d=c.width,p=c.height;t=Math.min(t,h-d/2),r=Math.max(r,h+d/2),n=Math.min(n,u-p/2),i=Math.max(i,u+p/2)}e.nodes().forEach(c=>o(e.node(c))),e.edges().forEach(c=>{let h=e.edge(c);Object.hasOwn(h,"x")&&o(h)}),t-=l,n-=s,e.nodes().forEach(c=>{let h=e.node(c);h.x-=t,h.y-=n}),e.edges().forEach(c=>{let h=e.edge(c);h.points.forEach(u=>{u.x-=t,u.y-=n}),Object.hasOwn(h,"x")&&(h.x-=t),Object.hasOwn(h,"y")&&(h.y-=n)}),a.width=r-t+l,a.height=i-n+s}function OD(e){e.edges().forEach(t=>{if(t.v===t.w)return;let r=e.edge(t),n=e.node(t.v),i=e.node(t.w),a,l;r.points?(a=r.points[0],l=r.points[r.points.length-1]):(r.points=[],a=i,l=n),r.points.unshift(_w(n,a)),r.points.push(_w(i,l))})}function LD(e){e.edges().forEach(t=>{let r=e.edge(t);if(Object.hasOwn(r,"x"))switch((r.labelpos==="l"||r.labelpos==="r")&&(r.width-=r.labeloffset),r.labelpos){case"l":r.x-=r.width/2+r.labeloffset;break;case"r":r.x+=r.width/2+r.labeloffset;break}})}function DD(e){e.edges().forEach(t=>{let r=e.edge(t);r.reversed&&r.points.reverse()})}function PD(e){e.nodes().forEach(t=>{if(e.children(t).length){let r=e.node(t),n=e.node(r.borderTop),i=e.node(r.borderBottom),a=e.node(r.borderLeft[r.borderLeft.length-1]),l=e.node(r.borderRight[r.borderRight.length-1]);r.width=Math.abs(l.x-a.x),r.height=Math.abs(i.y-n.y),r.x=a.x+r.width/2,r.y=n.y+r.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function zD(e){e.edges().forEach(t=>{if(t.v===t.w){let r=e.node(t.v);r.selfEdges||(r.selfEdges=[]),r.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function FD(e){Tl(e).forEach(t=>{let r=0;t.forEach((n,i)=>{let a=e.node(n);typeof a.rank!="number"&&(a.rank=0),a.order=i+r,(a.selfEdges||[]).forEach(l=>{Ba(e,"selfedge",{width:l.label.width,height:l.label.height,rank:a.rank,order:i+ ++r,e:l.e,edgeLabel:l.label},"_se"),(!Array.isArray(l.label.points)||l.label.points.length!==7)&&(l.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete a.selfEdges})})}function WD(e){e.nodes().forEach(t=>{let r=e.node(t),n=i=>typeof i=="number"&&isFinite(i);if(r.dummy==="selfedge"){let i=r,a=e.node(i.e.v),l=n(a?.x)?a.x:0,s=n(a?.y)?a.y:0,o=n(a?.width)?a.width:0,c=n(a?.height)?a.height:0,h=n(r.x)?r.x:l,u=n(r.y)?r.y:s,d=o/2,p=c/2;i.edgeLabel.points=[{x:h+d,y:u-p},{x:h+d,y:u-p},{x:h,y:u},{x:h-d,y:u+p},{x:h-d,y:u+p},{x:h,y:u},{x:h,y:u}],i.edgeLabel.x=h,i.edgeLabel.y=u,e.setEdge(i.e,i.edgeLabel),e.removeNode(t)}else r&&Array.isArray(r.selfEdges)&&r.selfEdges.forEach(i=>{if(!Array.isArray(i.label.points)||i.label.points.length!==7){let a=n(r.x)?r.x:0,l=n(r.y)?r.y:0,s=n(r.width)?r.width:0,o=n(r.height)?r.height:0,c=s/2,h=o/2;i.label.points=[{x:a+c,y:l-h},{x:a+c,y:l-h},{x:a,y:l},{x:a-c,y:l+h},{x:a-c,y:l+h},{x:a,y:l},{x:a,y:l}]}})})}function Yp(e,t){return Rd(Nd(e,t),Number)}function Gp(e){let t={};return e&&Object.entries(e).forEach(([r,n])=>{typeof r=="string"&&(r=r.toLowerCase()),t[r]=n}),t}function BD(e){let t=Tl(e),r=new Hr({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(n=>{r.setNode(n,{label:n}),r.setParent(n,"layer"+e.node(n).rank)}),e.edges().forEach(n=>r.setEdge(n.v,n.w,{},n.name)),t.forEach((n,i)=>{let a="layer"+i;r.setNode(a,{rank:"same"}),n.reduce((l,s)=>(r.setEdge(l,s,{style:"invis"}),s))}),r}var HD={graphlib:jw,version:tL,layout:vD,debug:BD,util:{time:QO,notime:ev}},eg=HD;var jD=108,UD=6.6,YD=26,GD=34,VD=64,qD=30,pv=24;function XD(e){return Math.min(220,Math.max(jD,Math.round(e.length*UD+YD)))}function gv(e,t){let r=t.direction??"LR",n=new eg.graphlib.Graph({multigraph:!0});n.setGraph({rankdir:r,nodesep:qD,ranksep:VD,marginx:pv,marginy:pv}),n.setDefaultNodeLabel(()=>({})),n.setDefaultEdgeLabel(()=>({}));let i=new Set;for(let p of e.order){let g=e.nodes.get(p);if(g===void 0||g.parent===null)continue;let m=e.nodes.get(g.parent);m!==void 0&&m.initial!==void 0&&(m.id===""?m.initial:`${m.id}.${m.initial}`)===p&&i.add(p)}let a=e.order.filter(p=>p!==""&&e.nodes.get(p)!==void 0);for(let p of a){let g=e.nodes.get(p);n.setNode(p,{width:XD(g.key),height:GD})}let l=new Set,s=[],o=[];for(let p of a){let g=e.nodes.get(p),m=[...g.on,...g.always,...g.after];for(let v of m){let x=v.kind==="after"?`after ${v.delay??""}`:v.event;for(let k of v.resolved){if(k.startsWith("?"))continue;if(k===p){o.push({key:`self-${p}-${x}-${v.kind}`,source:p,target:p,label:x,kind:v.kind,clickable:v.kind==="on",points:[],labelX:0,labelY:0});continue}if(e.nodes.get(k)===void 0)continue;let b=`${p}|${k}|${x}`;l.has(b)||(l.add(b),s.push({key:b,source:p,target:k,label:x,kind:v.kind,clickable:v.kind==="on"}))}}}for(let p of s)n.setEdge(p.source,p.target,{label:p.label,width:p.label.length*6.2+10,height:14,labelpos:"c"},p.key);eg.layout(n);let c=n.graph(),h=a.map(p=>{let g=e.nodes.get(p),m=n.node(p);return{id:p,label:g.key,kind:g.kind,initial:i.has(p),active:t.active.has(p),x:m.x,y:m.y,width:m.width,height:m.height}}),u=new Map(h.map(p=>[p.id,p])),d=s.map(p=>{let g=n.edge(p.source,p.target,p.key);return{key:p.key,source:p.source,target:p.target,label:p.label,kind:p.kind,clickable:p.clickable,points:g.points.map(m=>({x:m.x,y:m.y})),labelX:g.labelX??g.x??0,labelY:g.labelY??g.y??0}});for(let p of o){let g=u.get(p.source);if(g===void 0)continue;let m=g.y-g.height/2;p.points=[{x:g.x-g.width/6,y:m},{x:g.x-g.width/6,y:m-26},{x:g.x+g.width/6,y:m-26},{x:g.x+g.width/6,y:m}],p.labelX=g.x,p.labelY=m-32}return d.push(...o),{nodes:h,edges:d,width:Math.max(1,Math.round(c.width??1)),height:Math.max(1,Math.round(c.height??1))}}function KD(e){return e.points.length===0?"":e.points.map((t,r)=>`${r===0?"M":"L"}${t.x.toFixed(1)} ${t.y.toFixed(1)}`).join(" ")}function ZD(e){let[t,r,n,i]=e.points;return t===void 0||r===void 0||n===void 0||i===void 0?"":`M${t.x} ${t.y} C${r.x} ${r.y} ${n.x} ${n.y} ${i.x} ${i.y}`}function QD(e,t){return[...t].filter(r=>{if(r==="")return!1;let n=e.nodes.get(r);return n!==void 0&&n.children.length===0})}function mv(e){let{source:t,execution:r,retryToken:n,t:i}=e,a=De.useMemo(()=>{if(t.trim()==="")return{status:"empty"};let b=Sr(t);if(!b.ok)return{status:"error"};let C=Tn(b.config);return C===null?{status:"error"}:{status:"ok",ir:C}},[t,n]),[l,s]=De.useState(()=>a.status==="ok"?Li(a.ir):new Set),[o,c]=De.useState(!1),[h,u]=De.useState({value:void 0,paths:[]}),d=De.useRef(null),p=De.useMemo(()=>o?new Set(h.paths):l,[o,h,l]),g=De.useCallback(()=>{if(a.status!=="ok")return;d.current?.stop();let b=ww(t);d.current=b,b!==null&&(u(b.read()),c(!0))},[a,t]);if(De.useEffect(()=>()=>{d.current?.stop(),d.current=null},[a]),De.useEffect(()=>{if(r==="off"){d.current?.stop(),d.current=null,c(!1);return}r==="auto"&&a.status==="ok"&&d.current===null&&g()},[r,a,g]),a.status!=="ok")return ue("div",{className:"hx-xs","data-status":a.status},ue("p",{className:"hx-status__text"},a.status==="empty"?i("xstate.empty"):i("xstate.parseError")));let m=a.ir,v=De.useMemo(()=>gv(m,{active:p}),[m,p]),x=De.useCallback(b=>{if(o&&d.current!==null){d.current.send(b);let N=d.current.read();u({value:N.value,paths:N.paths});return}if(a.status!=="ok")return;let C=Sl(a.ir,l,b);s(C.active)},[o,a,l]),k=De.useCallback(()=>{if(d.current!==null){d.current.reset(),u(d.current.read());return}a.status==="ok"&&s(Li(a.ir))},[a]);return De.useImperativeHandle(e.viewRef,()=>({run:g,reset:k}),[g,k]),ue("div",{className:"hx-gv","data-running":o?"true":"false"},ue("div",{className:"hx-gv-bar"},r==="confirm"&&!o&&ue("button",{type:"button",className:"hx-xs-event","data-role":"run",onClick:g,title:i("xstate.run.hint")},i("xstate.run")),o&&ue("button",{type:"button",className:"hx-xs-event","data-role":"reset",onClick:k},i("xstate.reset")),ue("span",{className:"hx-badge-note"},i(o?"xstate.state":"xstate.static")),ue("span",{className:"hx-gv-value"},JSON.stringify(o?h.value:QD(m,p)))),ue("svg",{className:"hx-gv__svg",viewBox:`0 0 ${v.width} ${v.height}`,preserveAspectRatio:"xMidYMin meet",role:"img","aria-label":i("panel.viewGraph")},ue("defs",null,ue("marker",{id:"hx-gv-arrow",markerWidth:"9",markerHeight:"8",refX:"8",refY:"4",orient:"auto"},ue("path",{d:"M0 0 L9 4 L0 8 z",className:"hx-gv-arrow"}))),v.edges.map(b=>{let C=b.source===b.target?ZD(b):KD(b);return ue("g",{key:b.key,className:"hx-gv-edge","data-kind":b.kind,"data-clickable":b.clickable?"true":"false"},ue("path",{d:C,markerEnd:"url(#hx-gv-arrow)"}),b.clickable&&C!==""&&ue("path",{d:C,className:"hx-gv-hit",onClick:()=>x(b.label)},ue("title",null,`${i("xstate.state")}: ${b.label}`)),b.label!==""&&ue("text",{x:b.labelX,y:b.labelY,"data-clickable":b.clickable?"true":"false",onClick:()=>{b.clickable&&x(b.label)}},b.label))}),v.nodes.map(b=>ue("g",{key:b.id,className:"hx-gv-node","data-active":b.active?"true":"false","data-kind":b.kind},ue("rect",{x:b.x-b.width/2,y:b.y-b.height/2,width:b.width,height:b.height,rx:8}),ue("text",{x:b.x,y:b.y+4},b.initial?"▶ ":"",b.label,b.kind==="final"?" ■":""),ue("title",null,b.id)))))}function Kn(e){return`"${e}"`}function JD(e,t){let r=[];for(let n of[...e.on,...e.after]){let i=n.kind==="after"?`after ${n.delay??""}`:n.event;for(let a of n.resolved)a.startsWith("?")||a===e.id||r.push(`${t}${e.id===""?"[*]":e.id} --> ${a}${i!==""?` : ${i}`:""}`)}return r}function yv(e){let t=["stateDiagram-v2"," direction TB"],r=e.nodes.get("");r?.initial!==void 0&&t.push(` [*] --> ${r.initial}`);for(let n of e.order){let i=e.nodes.get(n);i===void 0||i.parent===null||i.kind==="final"&&t.push(` ${n} : ${n} (final)`)}for(let n of e.order){let i=e.nodes.get(n);i!==void 0&&t.push(...JD(i," "))}return t.join(`
155
+ `)}function e8(e){return e.kind==="final"?" [shape=doublecircle]":e.kind==="parallel"?" [shape=box]":""}function xv(e){let t=[`digraph ${JSON.stringify(e.id)} {`," rankdir=LR;"],r=e.nodes.get("");r?.initial!==void 0&&t.push(" __start [shape=point];",` __start -> ${Kn(r.initial)};`);let n=(i,a)=>{for(let l of i.children){let s=e.nodes.get(l);if(s!==void 0)if(s.children.length>0){if(t.push(`${a}subgraph ${JSON.stringify(`cluster_${l}`)} {`),t.push(`${a} label=${Kn(s.key)};`),s.initial!==void 0){let o=l===""?s.initial:`${l}.${s.initial}`;t.push(`${a} ${Kn(`${l}__start`)} [shape=point];`),t.push(`${a} ${Kn(`${l}__start`)} -> ${Kn(o)};`)}n(s,`${a} `),t.push(`${a}}`)}else t.push(`${a}${Kn(l)}${e8(s)};`)}};r!==void 0&&n(r," ");for(let i of e.order){let a=e.nodes.get(i);if(a!==void 0)for(let l of[...a.on,...a.after]){let s=l.kind==="after"?`after ${l.delay??""}`:l.event;for(let o of l.resolved){if(o.startsWith("?")||o===a.id)continue;let c=s!==""?` [label=${JSON.stringify(s)}]`:"";t.push(` ${Kn(i)} -> ${Kn(o)}${c};`)}}}return t.push("}"),t.join(`
156
+ `)}function t8(e,t){let r=t*3/5;return r<=e?{width:r,height:t}:{width:e,height:e*5/3}}function r8(e,t,r){let n=t8(e.width,e.height),i=r%5*28,a=Math.min(e.left+(e.width-n.width)/2+i,t.width-8-n.width),l=Math.min(e.top+(e.height-n.height)/2+i,t.height-8-n.height);return{pos:{left:Math.round(a),top:Math.round(l)},size:{width:Math.round(n.width),height:Math.round(n.height)}}}function n8(e){let t=e.width/3,r=e.height-32;return t-32>=480?{left:e.width*2/3+16,top:16,width:t-32,height:r}:{left:16,top:16,width:e.width-32,height:r}}function i8(e,t){let n=t.height-32,i=Math.min(Math.max(e.left,0),t.width)+e.width,a={left:8,top:16,width:e.left-16-8,height:n},l={left:i+16,top:16,width:t.width-16-(i+16),height:n},s=o=>o.width>=480&&o.height>=360;return s(a)&&s(l)?a.width>=l.width?a:l:s(a)?a:s(l)?l:null}function bv(e,t=null,r={width:window.innerWidth,height:window.innerHeight}){return r8((t===null?null:i8(t,r))??n8(r),r,e)}var a8=["nw","ne","sw","se"],wv={status:"loading"},s8={key:"",state:wv},l8={key:"",state:null},o8=1400,c8=120,d8=1500,h8=100.5;function Kt(e){let t=e.className===void 0?"hx-btn":`hx-btn ${e.className}`;return ue("button",{type:"button",className:t,onClick:e.onClick,disabled:e.disabled===!0,"aria-label":e.label,"aria-expanded":e.ariaExpanded,"aria-pressed":e.ariaPressed,title:e.title??e.label,"data-no-drag":""},e.children)}function u8(e){return typeof HTMLElement>"u"||!(e instanceof HTMLElement)?!1:e.isContentEditable?!0:e.closest('input, textarea, select, [contenteditable=""], [contenteditable="true"]')!==null}function vv(e){let t=$g(e.store);if(t.windows.length===0)return null;let r=t.windows.reduce((n,i)=>i.z>n.z?i:n);return ue(De.Fragment,null,t.windows.map((n,i)=>ue(f8,{key:n.id,win:n,ordinal:i,isTop:n.id===r.id,...e})))}function f8(e){let{win:t,isTop:r,store:n,zoomEnabled:i,allowLinks:a,multiInstance:l,xstateMultiInstance:s,execution:o,defaultTranslucent:c,panelOpacity:h,onToggleMode:u,t:d}=e,p=t.items.length,g=t.items[t.index],m=g?.source??"",v=m.trim()!=="",x=g?.kind==="xstate",k=g?.banner!==null&&g?.banner!==void 0&&g.banner.isConnected,b=De.useRef(null),C=De.useRef(null),N=De.useRef(null),R=De.useRef(null),O=De.useRef(null),P=De.useRef(null),H=De.useRef(null),I=De.useRef(null),[G,Z]=De.useState(0),[z,W]=De.useState(s8),[S,A]=De.useState(l8),[$,y]=De.useState(!1),[E,w]=De.useState(100),[T,_]=De.useState(!1),[M,U]=De.useState(!1),[j,Y]=De.useState(!1),[D,L]=De.useState(!1),[F,V]=De.useState(!1),[X,Q]=De.useState(null),ne=X??c,[B,K]=De.useState(null),[ie,le]=De.useState(!1),[J]=De.useState(()=>bv(e.ordinal,t.avoid)),[te,ae]=De.useState(J.pos),[ee,re]=De.useState(J.size),de=D,ye=De.useRef(E),oe=De.useRef(T),xe=De.useRef(de),fe=De.useRef(F);De.useEffect(()=>{ye.current=E},[E]),De.useEffect(()=>{oe.current=T},[T]),De.useEffect(()=>{xe.current=de},[de]),De.useEffect(()=>{fe.current=F},[F]);let pe=()=>{H.current!==null&&clearTimeout(H.current),H.current=setTimeout(()=>{H.current=null,C.current?.fit()},c8)};De.useEffect(()=>{let je=window.requestAnimationFrame(()=>{b.current?.focus({preventScroll:!0})});return()=>{if(window.cancelAnimationFrame(je),b.current===null){let Ue=t.returnFocus;Ue!==null&&Ue.isConnected&&Ue.focus({preventScroll:!0})}}},[]),De.useEffect(()=>()=>{for(let je of[P,H,I])je.current!==null&&clearTimeout(je.current),je.current=null},[]),De.useEffect(()=>{if(!r)return;let je=Ue=>{if(!(Ue.defaultPrevented||u8(Ue.target))){if(Ue.key==="Escape"){let ot=document.activeElement;if(ot instanceof Element&&ot.closest(".hx-stage")!==null&&ye.current>h8)return;if(Ue.preventDefault(),Ue.stopPropagation(),fe.current){V(!1),pe();return}if(xe.current){L(!1);return}if(oe.current){_(!1);return}n.close(t.id);return}Ue.key!=="ArrowLeft"&&Ue.key!=="ArrowRight"||Ue.altKey||Ue.ctrlKey||Ue.metaKey||Ue.shiftKey||t.items.length<2||(Ue.preventDefault(),Ue.stopPropagation(),Ue.key==="ArrowLeft"?n.previous(t.id):n.next(t.id))}};return window.addEventListener("keydown",je,!0),()=>{window.removeEventListener("keydown",je,!0)}},[r,n,t.id,t.items.length]);let Me=`${t.index}:${G}`,Ae=z.key===Me?z.state:wv,ce=S.key===Me?S.state:null,ge=Ae.status==="ready"?Ae.result.mermaidType:void 0,be=ce?.status==="ready"?ce.machineId:void 0,Ie=x?be??d("panel.xstate.title"):ge??d("panel.unknownType"),Re={zIndex:t.z,"--hx-panel-alpha":`${Jn(h)}%`,...de?{}:{left:`${te.left}px`,top:`${te.top}px`,width:`${ee.width}px`,...F?{}:{height:`${ee.height}px`}}},ze=je=>{K(je),P.current!==null&&clearTimeout(P.current),P.current=setTimeout(()=>{P.current=null,K(null)},o8)},he=()=>{C.current?.zoomIn(),w(C.current?.scale()??100)},$e=()=>{C.current?.zoomOut(),w(C.current?.scale()??100)},Se=()=>{C.current?.fit(),w(C.current?.scale()??100)},we=()=>{_(je=>!je)},ke=()=>{(async()=>{try{await navigator.clipboard.writeText(m),ze(d("panel.copied"))}catch{ze(d("panel.copyFailed"))}})()},Ne=je=>{(async()=>{try{let Ue=Sr(m);if(!Ue.ok)throw new Error("unparseable");let ot=Tn(Ue.config);if(ot===null)throw new Error("unparseable");await navigator.clipboard.writeText(je==="mermaid"?yv(ot):xv(ot)),ze(d("panel.copied"))}catch{ze(d("xstate.parseError"))}})()},Be=()=>{try{let je=Ae.status==="ready"?Ae.result:void 0;Hl(C.current?.svg()??je?.svg,C.current?.mermaidType()??je?.mermaidType)}catch{ze(d("panel.downloadFailed"))}},Pe=()=>{let je=t.items[t.index];if(je!==void 0&&je.banner!==null&&je.banner.isConnected)try{let Ue=Pi(je.banner);n.updateSource(t.id,t.index,Ue)}catch{}Z(Ue=>Ue+1)},q=()=>{let je=g?.banner;if(je==null||!je.isConnected)return;je.scrollIntoView({behavior:"smooth",block:"center"});let Ue=je.closest(".md-code-block")??je.parentElement;Ue!==null&&(Ue.classList.remove("hx-flash-anchor"),Ue.offsetWidth,Ue.classList.add("hx-flash-anchor"),I.current!==null&&clearTimeout(I.current),I.current=setTimeout(()=>{I.current=null,Ue.classList.remove("hx-flash-anchor")},d8))},me=()=>{L(!0),pe()},se=()=>{L(!1)},ve=()=>{if(de){se();return}F&&V(!1),me()},_e=()=>{if(F){V(!1),pe();return}de&&L(!1),V(!0)},Te=()=>{Q(!ne)},Oe=je=>{if(de||je.button!==0)return;let Ue=je.target;if(Ue instanceof Element&&Ue.closest("button, [data-no-drag]")!==null)return;let ot=b.current;if(ot===null)return;let Fe=ot.getBoundingClientRect();R.current={pointerId:je.pointerId,offsetX:je.clientX-Fe.left,offsetY:je.clientY-Fe.top,width:Fe.width,height:Fe.height},U(!0);try{je.currentTarget.setPointerCapture(je.pointerId)}catch{}},Ce=je=>{let Ue=R.current;if(Ue===null||Ue.pointerId!==je.pointerId||de)return;let ot=window.innerWidth-Ue.width-8,Fe=window.innerHeight-Ue.height-8,at=Math.min(Math.max(je.clientX-Ue.offsetX,8),Math.max(8,ot)),ct=Math.min(Math.max(je.clientY-Ue.offsetY,8),Math.max(8,Fe));ae({left:Math.round(at),top:Math.round(ct)})},He=je=>{R.current!==null&&(R.current=null,U(!1),Qe(je))},Ee=(je,Ue)=>{if(je.button!==0||de||F)return;let ot=b.current;if(ot===null)return;let Fe=ot.getBoundingClientRect();O.current={pointerId:je.pointerId,corner:Ue,startX:je.clientX,startY:je.clientY,left:Fe.left,top:Fe.top,width:Fe.width,height:Fe.height},Y(!0);try{je.currentTarget.setPointerCapture(je.pointerId)}catch{}},Ye=je=>{let Ue=O.current;if(Ue===null||Ue.pointerId!==je.pointerId)return;let ot=je.clientX-Ue.startX,Fe=je.clientY-Ue.startY,at=Math.max(480,window.innerWidth-16),ct=Math.max(360,window.innerHeight-16),st=Ue.left+Ue.width,Tt=Ue.top+Ue.height,ht=Ue.left,Ke=Ue.top,dt=Ue.width,yt=Ue.height;Ue.corner==="nw"||Ue.corner==="sw"?(ht=Math.min(Math.max(Ue.left+ot,8),st-480),dt=st-ht):dt=Math.min(Math.max(Ue.width+ot,480),at),Ue.corner==="nw"||Ue.corner==="ne"?(Ke=Math.min(Math.max(Ue.top+Fe,8),Tt-360),yt=Tt-Ke):yt=Math.min(Math.max(Ue.height+Fe,360),ct),ae({left:Math.round(ht),top:Math.round(Ke)}),re({width:Math.round(dt),height:Math.round(yt)})},qe=je=>{O.current!==null&&(O.current=null,Y(!1),Qe(je),pe())},Qe=je=>{let Ue=je.currentTarget;if(Ue.hasPointerCapture(je.pointerId))try{Ue.releasePointerCapture(je.pointerId)}catch{}},lt=()=>{ae(J.pos),re(J.size),pe()},Ze=je=>{w(je)},it=je=>{W({key:Me,state:je})},rt=je=>{A({key:Me,state:je})},wt=null;return x?v||(wt=ue("div",{className:"hx-status"},ue("div",{className:"hx-status__box",style:{pointerEvents:"auto"}},ue("span",null,d("xstate.empty")),ue("div",{className:"hx-status__actions"},ue("button",{type:"button",className:"hx-action",onClick:Pe,"data-no-drag":""},d("panel.retry")))))):v?Ae.status==="error"?wt=ue("div",{className:"hx-status"},ue("div",{className:"hx-status__box hx-status__box--error"},ue("span",{className:"hx-status__title"},ue(Wl,{size:15}),d("panel.error")),ue("pre",{className:"hx-status__detail"},Ae.message),ue("div",{className:"hx-status__actions"},ue("button",{type:"button",className:"hx-action hx-action--primary",onClick:Pe,"data-no-drag":""},d("panel.retry")),ue("button",{type:"button",className:"hx-action",onClick:we,"aria-expanded":T,"data-no-drag":""},d("panel.source"))))):Ae.status==="loading"&&(wt=ue("div",{className:"hx-status"},ue("div",{className:"hx-status__box"},ue("span",{className:"hx-spinner","aria-hidden":"true"}),ue("span",null,d("panel.loading"))))):wt=ue("div",{className:"hx-status"},ue("div",{className:"hx-status__box",style:{pointerEvents:"auto"}},ue("span",null,d("panel.empty")),ue("div",{className:"hx-status__actions"},ue("button",{type:"button",className:"hx-action",onClick:Pe,"data-no-drag":""},d("panel.retry"))))),ue("div",{ref:b,className:"hx-panel",role:"dialog","aria-modal":"false","aria-label":d(x?"panel.xstate.title":"panel.title"),tabIndex:-1,"data-entered":ie?"true":"false","data-dragging":M?"true":"false","data-resizing":j?"true":"false","data-fullscreen":de?"true":"false","data-collapsed":F?"true":"false","data-translucent":ne?"true":"false",style:Re,onPointerDownCapture:()=>{r||n.raise(t.id)},onAnimationEnd:je=>{je.target===je.currentTarget&&je.animationName==="hx-pop"&&le(!0)}},ue("div",{className:"hx-panel__header",onPointerDown:Oe,onPointerMove:Ce,onPointerUp:He,onPointerCancel:He,onLostPointerCapture:He},ue("div",{className:"hx-panel__heading"},ue("span",{className:"hx-panel__mark"},x?ue(Sn,{size:15}):ue(pn,{size:15})),ue("span",{className:"hx-panel__title"},d(x?"panel.xstate.title":"panel.title")),ue("span",{className:"hx-panel__badge"},Ie),p>1?ue("span",{className:"hx-panel__count"},d("panel.of",{current:t.index+1,total:p})):null),ue("div",{className:"hx-panel__toolbar"},p>1?ue("div",{className:"hx-panel__nav hx-panel__fade"},ue(Kt,{label:d("panel.prev"),onClick:()=>n.previous(t.id),disabled:t.index<=0},ue(Sg,null)),ue(Kt,{label:d("panel.next"),onClick:()=>n.next(t.id),disabled:t.index>=p-1},ue(Cg,null))):null,p>1?ue("span",{className:"hx-divider","aria-hidden":"true"}):null,ue(Kt,{className:"hx-panel__fade",label:d("panel.locate"),onClick:q,disabled:!k},ue(Ig,null)),ue(Kt,{className:"hx-panel__fade",label:d((x?s:l)?"panel.modeToSingle":"panel.modeToMulti"),onClick:()=>{u(x?"xstate":"mermaid").then(je=>{je||ze(d("section.error"))})}},(x?s:l)?ue(Rg,null):ue(Og,null)),x&&ue(Kt,{className:$?"hx-panel__fade hx-btn--active":"hx-panel__fade",label:d($?"panel.viewCards":"panel.viewGraph"),onClick:()=>y(je=>!je),ariaPressed:$},ue(kg,null)),ue("span",{className:"hx-divider","aria-hidden":"true"}),ue(Kt,{className:"hx-panel__fade",label:d(F?"panel.expand":"panel.collapse"),onClick:_e,ariaExpanded:!F},F?ue(Dg,null):ue(Lg,null)),ue(Kt,{className:ne?"hx-panel__fade hx-btn--active":"hx-panel__fade",label:ne?d("panel.opaque"):d("panel.translucent",{opacity:Jn(h)}),onClick:Te,ariaPressed:ne},ue(Pg,null)),ue("span",{className:"hx-divider","aria-hidden":"true"}),ue(Kt,{label:d(de?"panel.exitFullscreen":"panel.fullscreen"),onClick:ve},de?ue(Ag,null):ue(Eg,null)),ue(Kt,{className:"hx-btn--close",label:d("panel.close"),onClick:()=>n.close(t.id)},ue(Tg,null)))),ue("div",{className:"hx-panel__body"},v&&x&&$?ue(mv,{key:Me,viewRef:N,source:m,execution:o,retryToken:G,t:d}):null,v&&x&&!$?ue($w,{key:Me,viewRef:N,source:m,execution:o,retryToken:G,label:d("panel.xstate.title"),onState:rt,t:d}):null,v&&!x?ue(R2,{key:Me,viewRef:C,source:m,zoomEnabled:i,allowLinks:a,retryToken:G,label:d("panel.title"),onState:it,onScale:Ze}):null,wt),T?ue("div",{className:"hx-source",id:"hx-panel-source"},ue("div",{className:"hx-source__head"},ue("span",null,d("panel.source")),ue("button",{type:"button",className:"hx-btn",onClick:ke,"aria-label":d("panel.copySource"),title:d("panel.copySource"),"data-no-drag":""},ue(Ja,{size:14}))),ue("pre",null,m)):null,ue("div",{className:"hx-panel__footer"},ue("span",{className:"hx-panel__footer-note","aria-live":"polite"},B??d(x?"panel.graphHelp":i?"panel.help":"panel.sourceHint")),ue("div",{className:"hx-panel__footerbar"},x?ue(De.Fragment,null,ue(Kt,{className:"hx-panel__fade",label:d("xstate.run"),title:d("xstate.run.hint"),onClick:()=>N.current?.run(),disabled:!v},ue(Sn,null)),ue(Kt,{className:"hx-panel__fade",label:d("xstate.reset"),onClick:()=>N.current?.reset(),disabled:!v},ue(Qd,null))):ue(De.Fragment,null,ue(Kt,{className:"hx-panel__fade",label:d("panel.zoomOut"),onClick:$e,disabled:!i},ue(_g,null)),ue("span",{className:"hx-panel__zoom hx-panel__fade","aria-hidden":"true"},`${E}%`),ue(Kt,{className:"hx-panel__fade",label:d("panel.zoomIn"),onClick:he,disabled:!i},ue(Mg,null)),ue(Kt,{className:"hx-panel__fade",label:d("panel.fit"),onClick:Se,disabled:!i},ue(Qd,null))),ue("span",{className:"hx-divider","aria-hidden":"true"}),ue(Kt,{className:"hx-panel__fade hx-panel__optional",label:d("panel.copySource"),onClick:ke,disabled:!v},ue(Ja,null)),!x&&ue(Kt,{className:"hx-panel__fade hx-panel__optional",label:d("panel.downloadSvg"),onClick:Be,disabled:Ae.status!=="ready"},ue(Fl,null)),ue("span",{className:"hx-divider","aria-hidden":"true"}),ue(Kt,{className:"hx-panel__fade",label:d("panel.source"),onClick:we,ariaExpanded:T},ue(Ng,null)))),a8.map(je=>ue("div",{key:je,className:"hx-panel__resize","data-corner":je,"data-no-drag":"","aria-hidden":"true",title:je==="se"?d("panel.resize"):void 0,onPointerDown:Ue=>Ee(Ue,je),onPointerMove:Ye,onPointerUp:qe,onPointerCancel:qe,onLostPointerCapture:qe,onDoubleClick:lt})))}var p8=`
157
+ .hx-root {
158
+ position: fixed;
159
+ inset: 0;
160
+ z-index: 30;
161
+ pointer-events: none;
162
+ color: var(--dsw-alias-label-primary, #1f2329);
163
+ font-family: var(--dsw-font-family, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif);
164
+ }
165
+
166
+ .hx-trigger {
167
+ position: fixed;
168
+ z-index: 2;
169
+ display: inline-flex;
170
+ align-items: center;
171
+ justify-content: center;
172
+ gap: 5px;
173
+ height: 26px;
174
+ padding: 0 8px;
175
+ border: 1px solid var(--dsw-alias-border-l2, rgba(127, 127, 127, .32));
176
+ border-radius: 7px;
177
+ background: var(--dsw-alias-bg-overlay, #fff);
178
+ color: var(--dsw-alias-label-secondary, #5c6470);
179
+ box-shadow: 0 2px 8px rgba(0, 0, 0, .10);
180
+ font: inherit;
181
+ font-size: 11.5px;
182
+ font-weight: 550;
183
+ line-height: 1;
184
+ white-space: nowrap;
185
+ cursor: pointer;
186
+ pointer-events: auto;
187
+ opacity: 0;
188
+ visibility: hidden;
189
+ /* left/top come from the anchor beside the banner's language label; the
190
+ * chip centers itself on the label's vertical middle. */
191
+ transform: translateY(-50%);
192
+ transition: opacity .12s ease, visibility .12s ease, background .12s ease, border-color .12s ease;
193
+ -webkit-user-select: none;
194
+ user-select: none;
195
+ }
196
+ .hx-trigger[data-visible="true"] { opacity: 1; visibility: visible; }
197
+ .hx-trigger[data-visible="false"] { pointer-events: none; }
198
+ .hx-trigger:hover {
199
+ background: var(--dsw-alias-bg-layer-1, #f5f6f8);
200
+ border-color: var(--dsw-alias-border-l1, rgba(127, 127, 127, .22));
201
+ color: var(--dsw-alias-label-primary, #1f2329);
202
+ }
203
+ .hx-trigger:focus-visible {
204
+ outline: 2px solid var(--dsw-alias-brand-primary, #4d6bfe);
205
+ outline-offset: 2px;
206
+ }
207
+ .hx-trigger__icon { flex: 0 0 auto; opacity: .9; }
208
+ /* Folded chip: the label collapses to zero width but keeps its text laid out,
209
+ * so the trigger can measure it and unfold again once room returns. */
210
+ .hx-trigger[data-compact="true"] { gap: 0; width: 26px; padding: 0; }
211
+ .hx-trigger[data-compact="true"] .hx-trigger__label { width: 0; margin: 0; overflow: hidden; opacity: 0; }
212
+
213
+ .hx-panel {
214
+ position: fixed;
215
+ z-index: 1;
216
+ display: flex;
217
+ flex-direction: column;
218
+ width: min(980px, calc(100vw - 32px));
219
+ height: min(720px, calc(100vh - 32px));
220
+ margin: 0;
221
+ border: 1px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, .20));
222
+ border-radius: 14px;
223
+ background: var(--dsw-alias-bg-overlay, #fff);
224
+ color: var(--dsw-alias-label-primary, #1f2329);
225
+ box-shadow: 0 24px 80px rgba(0, 0, 0, .26), 0 2px 8px rgba(0, 0, 0, .10);
226
+ overflow: hidden;
227
+ pointer-events: auto;
228
+ contain: layout paint;
229
+ }
230
+ /* The open animation runs once; [data-entered] flips after it ends so no
231
+ * later DOM change (raise, reorder) can replay it as a flash. */
232
+ .hx-panel[data-entered="false"] { animation: hx-pop .16s ease-out; }
233
+ /* Soft two-pulse tint used when locating a code block; the class is added
234
+ * briefly by the viewer and always removed, never persisted on the message. */
235
+ .hx-flash-anchor { animation: hx-flash 1.4s ease; }
236
+ @keyframes hx-flash {
237
+ 0%, 40%, 80%, 100% { background-color: transparent; }
238
+ 20%, 60% {
239
+ background-color: color-mix(in srgb, var(--dsw-alias-brand-primary, #4d6bfe) 9%, transparent);
240
+ }
241
+ }
242
+ .hx-panel[data-dragging="true"] { cursor: grabbing; }
243
+ /* Resizing must not touch the animation property: toggling it would replay
244
+ * the open animation and flash the whole window at gesture end. */
245
+ .hx-panel[data-resizing="true"] { -webkit-user-select: none; user-select: none; }
246
+ /* Corner grips: free resizing from all four corners. Hidden while fullscreen.
247
+ * Only the bottom-right carries the visual mark; the others are indicated by
248
+ * their resize cursor. */
249
+ .hx-panel__resize {
250
+ position: absolute;
251
+ width: 20px;
252
+ height: 20px;
253
+ touch-action: none;
254
+ z-index: 3;
255
+ }
256
+ .hx-panel__resize[data-corner="nw"] { left: 0; top: 0; cursor: nwse-resize; }
257
+ .hx-panel__resize[data-corner="ne"] { right: 0; top: 0; cursor: nesw-resize; }
258
+ .hx-panel__resize[data-corner="sw"] { left: 0; bottom: 0; cursor: nesw-resize; }
259
+ .hx-panel__resize[data-corner="se"] { right: 0; bottom: 0; cursor: nwse-resize; }
260
+ .hx-panel__resize[data-corner="se"]::after {
261
+ content: "";
262
+ position: absolute;
263
+ right: 4px;
264
+ bottom: 4px;
265
+ width: 9px;
266
+ height: 9px;
267
+ border-right: 2px solid var(--dsw-alias-label-secondary, #6b7280);
268
+ border-bottom: 2px solid var(--dsw-alias-label-secondary, #6b7280);
269
+ border-bottom-right-radius: 2px;
270
+ opacity: .4;
271
+ transition: opacity .12s ease;
272
+ }
273
+ .hx-panel__resize[data-corner="se"]:hover::after { opacity: .95; }
274
+ .hx-panel[data-fullscreen="true"] .hx-panel__resize { display: none; }
275
+ /* In-page fullscreen: the panel stretches over the viewport inside the page,
276
+ * without taking over the browser's own fullscreen mode. */
277
+ .hx-panel[data-fullscreen="true"] {
278
+ inset: 0;
279
+ width: 100vw;
280
+ height: 100vh;
281
+ max-width: none;
282
+ border: 0;
283
+ border-radius: 0;
284
+ margin: 0;
285
+ }
286
+ /* Folded down to the title bar: the body, footer, source drawer, and corner
287
+ * grips drop out of layout, leaving only the draggable header. The stored
288
+ * height is untouched and comes back when the window is restored. */
289
+ .hx-panel[data-collapsed="true"] {
290
+ height: auto;
291
+ min-height: 0;
292
+ border-radius: 10px;
293
+ box-shadow: 0 10px 32px rgba(0, 0, 0, .20), 0 2px 8px rgba(0, 0, 0, .08);
294
+ }
295
+ .hx-panel[data-collapsed="true"] .hx-panel__header { border-bottom: 0; }
296
+ .hx-panel[data-collapsed="true"] .hx-panel__body,
297
+ .hx-panel[data-collapsed="true"] .hx-panel__footer,
298
+ .hx-panel[data-collapsed="true"] .hx-source,
299
+ .hx-panel[data-collapsed="true"] .hx-panel__resize { display: none; }
300
+ /* Translucency: the overlay background keeps --hx-panel-alpha of its color and
301
+ * lets the blurred chat show through. Text and diagram ink stay full strength
302
+ * because the fading happens in the background layers, not in panel opacity. */
303
+ .hx-panel[data-translucent="true"] {
304
+ background: color-mix(in srgb, var(--dsw-alias-bg-overlay, #fff) var(--hx-panel-alpha, 70%), transparent);
305
+ -webkit-backdrop-filter: blur(14px) saturate(1.08);
306
+ backdrop-filter: blur(14px) saturate(1.08);
307
+ border-color: color-mix(in srgb, var(--dsw-alias-border-l2, rgba(127, 127, 127, .32)) 85%, transparent);
308
+ }
309
+ .hx-panel[data-translucent="true"] .hx-panel__header,
310
+ .hx-panel[data-translucent="true"] .hx-panel__footer,
311
+ .hx-panel[data-translucent="true"] .hx-panel__body { background: transparent; }
312
+ .hx-panel[data-translucent="true"] .hx-source {
313
+ background: color-mix(in srgb, var(--dsw-alias-bg-layer-1, #f5f6f8) var(--hx-panel-alpha, 70%), transparent);
314
+ }
315
+ .hx-panel[data-translucent="true"] .hx-source__head {
316
+ background: transparent;
317
+ }
318
+
319
+ .hx-panel__header {
320
+ display: flex;
321
+ align-items: center;
322
+ gap: 8px;
323
+ flex: 0 0 auto;
324
+ height: 48px;
325
+ padding: 0 8px 0 13px;
326
+ border-bottom: 1px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, .18));
327
+ background: var(--dsw-alias-bg-overlay, #fff);
328
+ cursor: grab;
329
+ touch-action: none;
330
+ -webkit-user-select: none;
331
+ user-select: none;
332
+ }
333
+ .hx-panel__header:active { cursor: grabbing; }
334
+ .hx-panel__heading {
335
+ display: flex;
336
+ align-items: center;
337
+ gap: 7px;
338
+ min-width: 0;
339
+ flex: 1 1 auto;
340
+ }
341
+ .hx-panel__mark {
342
+ display: grid;
343
+ place-items: center;
344
+ width: 24px;
345
+ height: 24px;
346
+ flex: 0 0 auto;
347
+ border-radius: 6px;
348
+ background: color-mix(in srgb, var(--dsw-alias-brand-primary, #4d6bfe) 12%, transparent);
349
+ color: var(--dsw-alias-brand-primary, #4d6bfe);
350
+ }
351
+ .hx-panel__title {
352
+ overflow: hidden;
353
+ text-overflow: ellipsis;
354
+ white-space: nowrap;
355
+ font-size: 13px;
356
+ font-weight: 600;
357
+ letter-spacing: .01em;
358
+ }
359
+ .hx-panel__badge,
360
+ .hx-panel__count {
361
+ flex: 0 0 auto;
362
+ padding: 2px 6px;
363
+ border-radius: 5px;
364
+ background: var(--dsw-alias-bg-layer-1, #f5f6f8);
365
+ color: var(--dsw-alias-label-secondary, #6b7280);
366
+ font-size: 10.5px;
367
+ font-weight: 550;
368
+ line-height: 1.35;
369
+ }
370
+ .hx-panel__count { font-variant-numeric: tabular-nums; }
371
+ .hx-panel__zoom {
372
+ display: inline-flex;
373
+ align-items: center;
374
+ justify-content: center;
375
+ min-width: 42px;
376
+ padding: 0 3px;
377
+ color: var(--dsw-alias-label-secondary, #6b7280);
378
+ font-size: 10.5px;
379
+ font-variant-numeric: tabular-nums;
380
+ line-height: 1;
381
+ }
382
+ .hx-panel__toolbar {
383
+ display: flex;
384
+ align-items: center;
385
+ gap: 1px;
386
+ flex: 0 0 auto;
387
+ }
388
+ .hx-panel__nav { display: flex; align-items: center; gap: 1px; margin-right: 3px; }
389
+ .hx-panel__fade { transition: opacity .15s ease; }
390
+ .hx-panel:not(:hover):not(:focus-within) .hx-panel__fade { opacity: .55; }
391
+ .hx-divider {
392
+ width: 1px;
393
+ height: 18px;
394
+ margin: 0 4px;
395
+ background: var(--dsw-alias-border-l1, rgba(127, 127, 127, .18));
396
+ }
397
+ .hx-btn {
398
+ appearance: none;
399
+ display: inline-grid;
400
+ place-items: center;
401
+ width: 28px;
402
+ height: 28px;
403
+ flex: 0 0 auto;
404
+ margin: 0;
405
+ padding: 0;
406
+ border: 0;
407
+ border-radius: 6px;
408
+ background: transparent;
409
+ color: var(--dsw-alias-label-secondary, #5c6470);
410
+ font: inherit;
411
+ cursor: pointer;
412
+ transition: background .12s ease, color .12s ease;
413
+ }
414
+ .hx-btn:hover:not(:disabled) {
415
+ background: var(--dsw-alias-bg-layer-1, #f5f6f8);
416
+ color: var(--dsw-alias-label-primary, #1f2329);
417
+ }
418
+ .hx-btn:focus-visible {
419
+ outline: 2px solid var(--dsw-alias-brand-primary, #4d6bfe);
420
+ outline-offset: 1px;
421
+ }
422
+ .hx-btn:disabled { opacity: .32; cursor: default; }
423
+ /* Toggled-on tools keep the brand tint in both the idle and hover states. */
424
+ .hx-btn--active,
425
+ .hx-btn--active:hover:not(:disabled) {
426
+ background: color-mix(in srgb, var(--dsw-alias-brand-primary, #4d6bfe) 11%, transparent);
427
+ color: var(--dsw-alias-brand-primary, #4d6bfe);
428
+ }
429
+ .hx-btn--close:hover:not(:disabled) {
430
+ background: color-mix(in srgb, var(--dsw-alias-state-error, #d14343) 12%, transparent);
431
+ color: var(--dsw-alias-state-error, #d14343);
432
+ }
433
+
434
+ .hx-panel__body {
435
+ position: relative;
436
+ flex: 1 1 auto;
437
+ min-height: 0;
438
+ overflow: hidden;
439
+ background: var(--dsw-alias-bg-base, #fff);
440
+ }
441
+ .hx-stage {
442
+ position: absolute;
443
+ inset: 0;
444
+ display: block;
445
+ overflow: hidden;
446
+ /* Zoom and pan repaint the whole SVG on every frame; containment keeps that
447
+ * work inside the stage instead of invalidating the rest of the panel. */
448
+ contain: layout paint;
449
+ padding: 20px;
450
+ touch-action: none;
451
+ overscroll-behavior: contain;
452
+ cursor: grab;
453
+ --pele-bg: transparent;
454
+ --pele-fg: var(--dsw-alias-label-primary, #1f2329);
455
+ --pele-muted: var(--dsw-alias-label-secondary, #6b7280);
456
+ /* Pele draws edges in full ink (#1f1f1f by default) and node outlines in a
457
+ * solid mid gray (#8a8a8a); decorative border tokens at low alpha read as
458
+ * background separators, so map to text-strength tokens instead. */
459
+ --pele-line: var(--dsw-alias-label-primary, #1f2329);
460
+ --pele-surface: var(--dsw-alias-bg-layer-1, #f5f6f8);
461
+ --pele-surface-alt: var(--dsw-alias-bg-layer-2, #eef0f3);
462
+ --pele-border: var(--dsw-alias-label-secondary, #6b7280);
463
+ --pele-accent: var(--dsw-alias-brand-primary, #4d6bfe);
464
+ --pele-critical: var(--dsw-alias-state-error, #d14343);
465
+ --pele-error: var(--dsw-alias-state-error, #d14343);
466
+ --pele-font: var(--dsw-font-family, ui-sans-serif, system-ui, sans-serif);
467
+ --pele-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
468
+ --pele-radius: 6px;
469
+ }
470
+ .hx-stage:active { cursor: grabbing; }
471
+ .hx-stage > svg { display: block; max-width: 100%; max-height: 100%; }
472
+ /* Pele zooms by growing the SVG to the container size and letting its negative
473
+ * margins bleed into the 20px stage padding. Clamping the height while zoomed
474
+ * squeezes the viewBox into the content box, so the bottom padding shows up as
475
+ * an empty band between the diagram and the footer. The clamp is only needed
476
+ * for the fit state (the intrinsic SVG is taller than the stage), so drop it
477
+ * once Pele marks the stage as zoomed. */
478
+ .hx-stage[data-zoomed="true"] > svg { max-height: none; }
479
+ .hx-stage .pele-zoom { display: none !important; }
480
+ /* Diagram labels are text and stay mouse-selectable so a node can be copied.
481
+ * Pele writes an inline user-select: none on the SVG once zoomed, so labels
482
+ * opt back in with !important. While a pan gesture runs (the stage gets
483
+ * [data-panning]), labels drop selection again: otherwise panning would smear
484
+ * a selection across the diagram. */
485
+ .hx-stage svg text,
486
+ .hx-stage svg foreignObject,
487
+ .hx-stage svg foreignObject * {
488
+ -webkit-user-select: text !important;
489
+ user-select: text !important;
490
+ cursor: text;
491
+ }
492
+ .hx-stage[data-panning="true"] svg text,
493
+ .hx-stage[data-panning="true"] svg foreignObject,
494
+ .hx-stage[data-panning="true"] svg foreignObject * {
495
+ -webkit-user-select: none !important;
496
+ user-select: none !important;
497
+ }
498
+ /* Inline stage: a diagram in the flow of a document rather than a window
499
+ * body. It takes its height from the SVG, which Pele sizes to the pane's
500
+ * width, and leaves wheel and drag to the document around it. */
501
+ .hx-stage--inline {
502
+ position: relative;
503
+ inset: auto;
504
+ padding: 12px 4px 16px;
505
+ touch-action: auto;
506
+ cursor: auto;
507
+ background: transparent;
508
+ }
509
+ .hx-stage--inline > svg { max-height: none; }
510
+
511
+ .hx-status {
512
+ position: absolute;
513
+ inset: 0;
514
+ display: grid;
515
+ place-items: center;
516
+ padding: 24px;
517
+ pointer-events: none;
518
+ }
519
+ .hx-status__box {
520
+ display: flex;
521
+ flex-direction: column;
522
+ align-items: center;
523
+ gap: 10px;
524
+ max-width: 560px;
525
+ text-align: center;
526
+ color: var(--dsw-alias-label-secondary, #6b7280);
527
+ font-size: 12.5px;
528
+ line-height: 1.55;
529
+ }
530
+ .hx-status__box--error { pointer-events: auto; }
531
+ .hx-status__title {
532
+ display: flex;
533
+ align-items: center;
534
+ gap: 7px;
535
+ color: var(--dsw-alias-label-primary, #1f2329);
536
+ font-size: 13px;
537
+ font-weight: 600;
538
+ }
539
+ .hx-status__detail {
540
+ max-width: 100%;
541
+ max-height: 120px;
542
+ overflow: auto;
543
+ margin: 0;
544
+ padding: 8px 10px;
545
+ border: 1px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, .18));
546
+ border-radius: 7px;
547
+ background: var(--dsw-alias-bg-layer-1, #f5f6f8);
548
+ color: var(--dsw-alias-label-secondary, #6b7280);
549
+ font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
550
+ white-space: pre-wrap;
551
+ overflow-wrap: anywhere;
552
+ text-align: left;
553
+ }
554
+ .hx-status__actions { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
555
+ .hx-action {
556
+ display: inline-flex;
557
+ align-items: center;
558
+ gap: 5px;
559
+ height: 28px;
560
+ padding: 0 10px;
561
+ border: 1px solid var(--dsw-alias-border-l2, rgba(127, 127, 127, .32));
562
+ border-radius: 7px;
563
+ background: var(--dsw-alias-bg-overlay, #fff);
564
+ color: var(--dsw-alias-label-primary, #1f2329);
565
+ font: inherit;
566
+ font-size: 12px;
567
+ font-weight: 550;
568
+ cursor: pointer;
569
+ }
570
+ .hx-action:hover { background: var(--dsw-alias-bg-layer-1, #f5f6f8); }
571
+ .hx-action:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary, #4d6bfe); outline-offset: 2px; }
572
+ .hx-action--primary {
573
+ border-color: transparent;
574
+ background: var(--dsw-alias-brand-primary, #4d6bfe);
575
+ color: #fff;
576
+ }
577
+ .hx-action--primary:hover { background: color-mix(in srgb, var(--dsw-alias-brand-primary, #4d6bfe) 88%, #000); }
578
+ .hx-spinner {
579
+ width: 18px;
580
+ height: 18px;
581
+ border: 2px solid color-mix(in srgb, var(--dsw-alias-brand-primary, #4d6bfe) 24%, transparent);
582
+ border-top-color: var(--dsw-alias-brand-primary, #4d6bfe);
583
+ border-radius: 50%;
584
+ animation: hx-spin .7s linear infinite;
585
+ }
586
+
587
+ /* The footer carries the tool buttons; its right padding keeps every control
588
+ * clear of the corner resize grip so the two cannot be mis-touched. */
589
+ .hx-panel__footer {
590
+ display: flex;
591
+ align-items: center;
592
+ justify-content: space-between;
593
+ gap: 12px;
594
+ flex: 0 0 auto;
595
+ min-height: 38px;
596
+ padding: 3px 36px 3px 13px;
597
+ border-top: 1px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, .16));
598
+ background: var(--dsw-alias-bg-overlay, #fff);
599
+ color: var(--dsw-alias-label-secondary, #6b7280);
600
+ font-size: 10.5px;
601
+ line-height: 1.4;
602
+ }
603
+ .hx-panel__footer-note {
604
+ flex: 1 1 auto;
605
+ min-width: 0;
606
+ overflow: hidden;
607
+ text-overflow: ellipsis;
608
+ white-space: nowrap;
609
+ }
610
+ .hx-panel__footerbar {
611
+ display: flex;
612
+ align-items: center;
613
+ gap: 1px;
614
+ flex: 0 0 auto;
615
+ }
616
+ .hx-source-toggle {
617
+ appearance: none;
618
+ flex: 0 0 auto;
619
+ margin: 0;
620
+ padding: 2px 4px;
621
+ border: 0;
622
+ border-radius: 4px;
623
+ background: transparent;
624
+ color: var(--dsw-alias-label-secondary, #6b7280);
625
+ font: inherit;
626
+ font-size: 10.5px;
627
+ font-weight: 600;
628
+ text-decoration: underline;
629
+ text-underline-offset: 2px;
630
+ cursor: pointer;
631
+ }
632
+ .hx-source-toggle:hover { color: var(--dsw-alias-label-primary, #1f2329); }
633
+ .hx-source-toggle:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary, #4d6bfe); outline-offset: 1px; }
634
+
635
+ .hx-source {
636
+ flex: 0 0 auto;
637
+ max-height: 34%;
638
+ overflow: auto;
639
+ border-top: 1px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, .16));
640
+ background: var(--dsw-alias-bg-layer-1, #f5f6f8);
641
+ }
642
+ .hx-source__head {
643
+ position: sticky;
644
+ top: 0;
645
+ display: flex;
646
+ align-items: center;
647
+ justify-content: space-between;
648
+ gap: 12px;
649
+ padding: 7px 13px;
650
+ border-bottom: 1px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, .14));
651
+ background: var(--dsw-alias-bg-layer-1, #f5f6f8);
652
+ color: var(--dsw-alias-label-secondary, #6b7280);
653
+ font-size: 10.5px;
654
+ font-weight: 600;
655
+ letter-spacing: .02em;
656
+ text-transform: uppercase;
657
+ }
658
+ .hx-source pre {
659
+ margin: 0;
660
+ padding: 10px 13px 14px;
661
+ color: var(--dsw-alias-label-primary, #1f2329);
662
+ font: 11.5px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
663
+ white-space: pre;
664
+ overflow: auto;
665
+ }
666
+
667
+ /* Mermaid file preview: a document body in the right sidebar. The preview's
668
+ * shared body is a monospace preformatted scroller, so the root returns to
669
+ * prose and draws its own toolbar above the diagram. */
670
+ .hx-mmd {
671
+ padding: 8px 10px 16px;
672
+ color: var(--dsw-alias-label-primary, #1f2329);
673
+ font-family: var(--dsw-font-family, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif);
674
+ font-size: 12.5px;
675
+ line-height: 1.5;
676
+ white-space: normal;
677
+ }
678
+ .hx-mmd__bar {
679
+ position: sticky;
680
+ top: 0;
681
+ z-index: 2;
682
+ display: flex;
683
+ align-items: center;
684
+ gap: 2px;
685
+ margin-bottom: 4px;
686
+ padding: 3px 4px;
687
+ border: 1px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, .20));
688
+ border-radius: 9px;
689
+ background: var(--dsw-alias-bg-layer-1, #f5f6f8);
690
+ }
691
+ .hx-mmd__label {
692
+ display: inline-flex;
693
+ align-items: center;
694
+ gap: 6px;
695
+ min-width: 0;
696
+ margin-right: auto;
697
+ padding-left: 6px;
698
+ color: var(--dsw-alias-label-secondary, #5c6470);
699
+ font-size: 11.5px;
700
+ font-weight: 550;
701
+ white-space: nowrap;
702
+ }
703
+ .hx-mmd__tab {
704
+ appearance: none;
705
+ height: 26px;
706
+ padding: 0 9px;
707
+ border: 0;
708
+ border-radius: 6px;
709
+ background: transparent;
710
+ color: var(--dsw-alias-label-secondary, #5c6470);
711
+ font: inherit;
712
+ font-size: 11.5px;
713
+ font-weight: 550;
714
+ white-space: nowrap;
715
+ cursor: pointer;
716
+ transition: background .12s ease, color .12s ease;
717
+ }
718
+ .hx-mmd__tab:hover,
719
+ .hx-mmd__tab[aria-pressed="true"] {
720
+ background: color-mix(in srgb, var(--dsw-alias-brand-primary, #4d6bfe) 11%, transparent);
721
+ color: var(--dsw-alias-brand-primary, #4d6bfe);
722
+ }
723
+ .hx-mmd__tab:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary, #4d6bfe); outline-offset: 1px; }
724
+ .hx-mmd__notice {
725
+ min-width: 0;
726
+ padding-right: 6px;
727
+ overflow: hidden;
728
+ color: var(--dsw-alias-label-secondary, #5c6470);
729
+ font-size: 11px;
730
+ text-overflow: ellipsis;
731
+ white-space: nowrap;
732
+ }
733
+ .hx-mmd__source {
734
+ margin: 0;
735
+ padding: 10px 12px;
736
+ border: 1px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, .20));
737
+ border-radius: 9px;
738
+ background: var(--dsw-alias-bg-layer-1, #f5f6f8);
739
+ color: var(--dsw-alias-label-primary, #1f2329);
740
+ font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
741
+ white-space: pre;
742
+ overflow: auto;
743
+ }
744
+ .hx-mmd__status {
745
+ display: flex;
746
+ align-items: center;
747
+ justify-content: center;
748
+ gap: 9px;
749
+ padding: 28px 8px;
750
+ color: var(--dsw-alias-label-secondary, #6b7280);
751
+ font-size: 12.5px;
752
+ }
753
+ .hx-mmd__error {
754
+ display: flex;
755
+ flex-direction: column;
756
+ align-items: flex-start;
757
+ gap: 8px;
758
+ margin: 0;
759
+ padding: 12px;
760
+ border: 1px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, .20));
761
+ border-radius: 9px;
762
+ background: var(--dsw-alias-bg-layer-1, #f5f6f8);
763
+ }
764
+ .hx-mmd__error-title {
765
+ display: flex;
766
+ align-items: center;
767
+ gap: 7px;
768
+ color: var(--dsw-alias-label-primary, #1f2329);
769
+ font-size: 12.5px;
770
+ font-weight: 600;
771
+ }
772
+
773
+ @media (max-width: 720px) {
774
+ .hx-trigger { width: 26px; padding: 0; }
775
+ .hx-trigger__label { display: none; }
776
+ }
777
+ @media (max-width: 640px) {
778
+ .hx-panel {
779
+ width: calc(100vw - 16px);
780
+ height: calc(100vh - 16px);
781
+ border-radius: 10px;
782
+ }
783
+ .hx-panel__title, .hx-panel__badge { display: none; }
784
+ .hx-panel__optional { display: none; }
785
+ .hx-panel__zoom { min-width: 34px; }
786
+ .hx-panel__header { padding-left: 10px; }
787
+ .hx-stage { padding: 12px; }
788
+ .hx-panel__footer-note { display: none; }
789
+ .hx-panel__footer { min-height: 36px; }
790
+ }
791
+ @media (prefers-reduced-motion: reduce) {
792
+ .hx-panel[data-entered="false"] { animation: none; }
793
+ .hx-trigger, .hx-panel__fade, .hx-btn { transition: none; }
794
+ .hx-spinner { animation-duration: 1.6s; }
795
+ }
796
+ @keyframes hx-pop {
797
+ from { opacity: 0; transform: translateY(4px) scale(.985); }
798
+ to { opacity: 1; transform: translateY(0) scale(1); }
799
+ }
800
+ @keyframes hx-spin { to { transform: rotate(360deg); } }
801
+
802
+ .hx-settings {
803
+ display: flex;
804
+ flex-direction: column;
805
+ gap: 14px;
806
+ max-width: 780px;
807
+ color: var(--dsw-alias-label-primary, #1f2329);
808
+ font-family: var(--dsw-font-family, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif);
809
+ }
810
+ .hx-settings__intro {
811
+ margin: 0;
812
+ color: var(--dsw-alias-label-secondary, #6b7280);
813
+ font-size: 12.5px;
814
+ line-height: 1.65;
815
+ }
816
+ .hx-settings__card {
817
+ padding: 15px 16px;
818
+ border: 1px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, .20));
819
+ border-radius: 12px;
820
+ background: var(--dsw-alias-bg-layer-1, #f7f8fa);
821
+ }
822
+ .hx-settings__cardhead {
823
+ display: flex;
824
+ align-items: flex-start;
825
+ gap: 10px;
826
+ margin-bottom: 4px;
827
+ }
828
+ .hx-settings__cardicon {
829
+ display: grid;
830
+ place-items: center;
831
+ width: 26px;
832
+ height: 26px;
833
+ flex: 0 0 auto;
834
+ border-radius: 7px;
835
+ background: color-mix(in srgb, var(--dsw-alias-brand-primary, #4d6bfe) 12%, transparent);
836
+ color: var(--dsw-alias-brand-primary, #4d6bfe);
837
+ }
838
+ .hx-settings__title {
839
+ margin: 0;
840
+ font-size: 13px;
841
+ font-weight: 600;
842
+ line-height: 1.45;
843
+ }
844
+ .hx-settings__desc {
845
+ margin: 2px 0 0;
846
+ color: var(--dsw-alias-label-secondary, #6b7280);
847
+ font-size: 11.5px;
848
+ line-height: 1.6;
849
+ }
850
+ .hx-switch-row {
851
+ display: flex;
852
+ align-items: flex-start;
853
+ justify-content: space-between;
854
+ gap: 18px;
855
+ padding: 11px 0;
856
+ }
857
+ .hx-switch-row + .hx-switch-row {
858
+ border-top: 1px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, .14));
859
+ }
860
+ .hx-switch-row:first-of-type { padding-top: 8px; }
861
+ .hx-switch-row:last-of-type { padding-bottom: 2px; }
862
+ .hx-switch-copy { min-width: 0; flex: 1 1 auto; }
863
+ .hx-switch-label {
864
+ display: block;
865
+ color: var(--dsw-alias-label-primary, #1f2329);
866
+ font-size: 12.5px;
867
+ font-weight: 550;
868
+ line-height: 1.5;
869
+ cursor: pointer;
870
+ }
871
+ .hx-switch-hint {
872
+ display: block;
873
+ margin-top: 2px;
874
+ color: var(--dsw-alias-label-secondary, #6b7280);
875
+ font-size: 11px;
876
+ line-height: 1.55;
877
+ }
878
+ .hx-switch {
879
+ appearance: none;
880
+ position: relative;
881
+ width: 36px;
882
+ height: 20px;
883
+ flex: 0 0 auto;
884
+ margin: 1px 0 0;
885
+ border: 1px solid var(--dsw-alias-border-l2, rgba(127, 127, 127, .32));
886
+ border-radius: 999px;
887
+ background: var(--dsw-alias-bg-layer-2, #e8eaee);
888
+ cursor: pointer;
889
+ transition: background .15s ease, border-color .15s ease;
890
+ }
891
+ .hx-switch::after {
892
+ content: "";
893
+ position: absolute;
894
+ top: 2px;
895
+ left: 2px;
896
+ width: 14px;
897
+ height: 14px;
898
+ border-radius: 50%;
899
+ background: #fff;
900
+ box-shadow: 0 1px 3px rgba(0, 0, 0, .22);
901
+ transition: transform .15s ease;
902
+ }
903
+ .hx-switch:checked {
904
+ border-color: var(--dsw-alias-brand-primary, #4d6bfe);
905
+ background: var(--dsw-alias-brand-primary, #4d6bfe);
906
+ }
907
+ .hx-switch:checked::after { transform: translateX(16px); }
908
+ .hx-switch:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary, #4d6bfe); outline-offset: 2px; }
909
+ .hx-switch:disabled { opacity: .4; cursor: not-allowed; }
910
+
911
+ /* Percent slider for the translucent background. The value stays a separate
912
+ * chip so the row matches the switch rows above it. */
913
+ .hx-range {
914
+ display: flex;
915
+ align-items: center;
916
+ gap: 9px;
917
+ flex: 0 0 auto;
918
+ padding-top: 2px;
919
+ }
920
+ .hx-range__input {
921
+ appearance: none;
922
+ width: 132px;
923
+ height: 5px;
924
+ margin: 0;
925
+ border-radius: 999px;
926
+ background: var(--dsw-alias-border-l2, rgba(127, 127, 127, .32));
927
+ cursor: pointer;
928
+ }
929
+ .hx-range__input::-moz-range-track {
930
+ height: 5px;
931
+ border-radius: 999px;
932
+ background: transparent;
933
+ }
934
+ .hx-range__input::-webkit-slider-thumb {
935
+ appearance: none;
936
+ width: 14px;
937
+ height: 14px;
938
+ border: 0;
939
+ border-radius: 50%;
940
+ background: var(--dsw-alias-brand-primary, #4d6bfe);
941
+ box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
942
+ cursor: pointer;
943
+ }
944
+ .hx-range__input::-moz-range-thumb {
945
+ width: 14px;
946
+ height: 14px;
947
+ border: 0;
948
+ border-radius: 50%;
949
+ background: var(--dsw-alias-brand-primary, #4d6bfe);
950
+ box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
951
+ cursor: pointer;
952
+ }
953
+ .hx-range__input:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary, #4d6bfe); outline-offset: 3px; }
954
+ .hx-range__input:disabled { opacity: .4; cursor: not-allowed; }
955
+ .hx-range__value {
956
+ min-width: 34px;
957
+ text-align: right;
958
+ color: var(--dsw-alias-label-secondary, #6b7280);
959
+ font-size: 11px;
960
+ font-variant-numeric: tabular-nums;
961
+ }
962
+ .hx-settings__status {
963
+ display: flex;
964
+ align-items: center;
965
+ gap: 7px;
966
+ min-height: 20px;
967
+ color: var(--dsw-alias-label-secondary, #6b7280);
968
+ font-size: 11px;
969
+ }
970
+ .hx-settings__status[data-tone="error"] { color: var(--dsw-alias-state-error, #d14343); }
971
+ .hx-settings__status[data-tone="ok"] { color: var(--dsw-alias-state-success, #258a5f); }
972
+ .hx-settings__dot {
973
+ width: 6px;
974
+ height: 6px;
975
+ border-radius: 50%;
976
+ background: currentColor;
977
+ }
978
+ .hx-settings__footer {
979
+ display: flex;
980
+ align-items: center;
981
+ justify-content: space-between;
982
+ gap: 12px;
983
+ flex-wrap: wrap;
984
+ }
985
+ .hx-settings__hint {
986
+ margin: 0;
987
+ color: var(--dsw-alias-label-secondary, #6b7280);
988
+ font-size: 11px;
989
+ line-height: 1.6;
990
+ }
991
+ .hx-settings__sample {
992
+ display: inline-flex;
993
+ align-items: center;
994
+ gap: 6px;
995
+ height: 30px;
996
+ padding: 0 11px;
997
+ border: 1px solid var(--dsw-alias-border-l2, rgba(127, 127, 127, .32));
998
+ border-radius: 7px;
999
+ background: var(--dsw-alias-bg-overlay, #fff);
1000
+ color: var(--dsw-alias-label-primary, #1f2329);
1001
+ font: inherit;
1002
+ font-size: 12px;
1003
+ font-weight: 550;
1004
+ cursor: pointer;
1005
+ }
1006
+ .hx-settings__sample:hover { background: var(--dsw-alias-bg-layer-2, #eef0f3); }
1007
+ .hx-settings__samplerow {
1008
+ display: flex;
1009
+ align-items: center;
1010
+ justify-content: space-between;
1011
+ gap: 12px;
1012
+ margin-top: 6px;
1013
+ padding-top: 10px;
1014
+ border-top: 1px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, .18));
1015
+ }
1016
+ .hx-settings__samplehint {
1017
+ color: var(--dsw-alias-label-secondary, #6b7280);
1018
+ font-size: 11px;
1019
+ line-height: 1.5;
1020
+ }
1021
+
1022
+ .hx-settings__sample:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary, #4d6bfe); outline-offset: 2px; }
1023
+
1024
+ /* ---- state-machine viewer ---- */
1025
+ .hx-xs {
1026
+ position: absolute;
1027
+ inset: 0;
1028
+ display: flex;
1029
+ flex-direction: column;
1030
+ gap: 8px;
1031
+ padding: 12px 14px;
1032
+ overflow: auto;
1033
+ color: var(--dsw-alias-label-primary, #1f2329);
1034
+ font-size: 12px;
1035
+ }
1036
+ .hx-xs-header {
1037
+ display: flex;
1038
+ align-items: center;
1039
+ gap: 8px;
1040
+ flex-wrap: wrap;
1041
+ }
1042
+ .hx-xs-header__id {
1043
+ font-weight: 650;
1044
+ font-size: 13px;
1045
+ }
1046
+ .hx-xs-header__value,
1047
+ .hx-xs-header__context {
1048
+ font-family: var(--dsw-alias-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1049
+ font-size: 11px;
1050
+ color: var(--dsw-alias-label-secondary, #6b7280);
1051
+ word-break: break-all;
1052
+ }
1053
+ .hx-xs-badge {
1054
+ display: inline-flex;
1055
+ align-items: center;
1056
+ height: 17px;
1057
+ padding: 0 6px;
1058
+ border-radius: 5px;
1059
+ border: 1px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, .22));
1060
+ background: var(--dsw-alias-bg-layer-1, #f5f6f8);
1061
+ color: var(--dsw-alias-label-secondary, #6b7280);
1062
+ font-size: 10px;
1063
+ line-height: 1;
1064
+ white-space: nowrap;
1065
+ }
1066
+ .hx-xs-badge[data-tone='initial'] {
1067
+ border-color: color-mix(in srgb, var(--dsw-alias-brand-primary, #4d6bfe) 35%, transparent);
1068
+ color: var(--dsw-alias-brand-primary, #4d6bfe);
1069
+ }
1070
+ .hx-xs-badge[data-tone='kind'] {
1071
+ border-color: color-mix(in srgb, var(--dsw-alias-brand-primary, #4d6bfe) 22%, transparent);
1072
+ background: color-mix(in srgb, var(--dsw-alias-brand-primary, #4d6bfe) 9%, transparent);
1073
+ }
1074
+ .hx-xs-badge[data-tone='live'] {
1075
+ border-color: rgba(26, 127, 55, .45);
1076
+ background: rgba(26, 127, 55, .10);
1077
+ color: #1a7f37;
1078
+ }
1079
+ .hx-xs-badge[data-tone='warn'] {
1080
+ border-color: rgba(180, 83, 9, .45);
1081
+ background: rgba(180, 83, 9, .10);
1082
+ color: #b45309;
1083
+ }
1084
+ .hx-xs-run {
1085
+ align-self: flex-start;
1086
+ display: inline-flex;
1087
+ align-items: center;
1088
+ gap: 6px;
1089
+ height: 28px;
1090
+ padding: 0 12px;
1091
+ border: 1px solid color-mix(in srgb, var(--dsw-alias-brand-primary, #4d6bfe) 45%, transparent);
1092
+ border-radius: 7px;
1093
+ background: color-mix(in srgb, var(--dsw-alias-brand-primary, #4d6bfe) 12%, transparent);
1094
+ color: var(--dsw-alias-brand-primary, #4d6bfe);
1095
+ font: inherit;
1096
+ font-size: 12px;
1097
+ font-weight: 600;
1098
+ cursor: pointer;
1099
+ }
1100
+ .hx-xs-run:hover { background: color-mix(in srgb, var(--dsw-alias-brand-primary, #4d6bfe) 20%, transparent); }
1101
+ .hx-xs-events {
1102
+ display: flex;
1103
+ align-items: center;
1104
+ gap: 6px;
1105
+ flex-wrap: wrap;
1106
+ }
1107
+ .hx-xs-event {
1108
+ height: 22px;
1109
+ padding: 0 9px;
1110
+ border: 1px solid var(--dsw-alias-border-l2, rgba(127, 127, 127, .32));
1111
+ border-radius: 6px;
1112
+ background: var(--dsw-alias-bg-overlay, #fff);
1113
+ color: var(--dsw-alias-label-primary, #1f2329);
1114
+ font: inherit;
1115
+ font-size: 11px;
1116
+ font-weight: 550;
1117
+ font-family: var(--dsw-alias-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1118
+ cursor: pointer;
1119
+ }
1120
+ .hx-xs-event[data-available='false'] { opacity: .45; }
1121
+ .hx-xs-event[data-role='reset'] { border-style: dashed; }
1122
+ .hx-xs-event:hover { background: var(--dsw-alias-bg-layer-2, #eef0f3); }
1123
+ .hx-xs-body {
1124
+ display: flex;
1125
+ flex-direction: column;
1126
+ gap: 10px;
1127
+ }
1128
+ .hx-xs-card {
1129
+ border: 1px solid var(--dsw-alias-border-l2, rgba(127, 127, 127, .32));
1130
+ border-radius: 8px;
1131
+ background: var(--dsw-alias-bg-overlay, #fff);
1132
+ padding: 8px 10px;
1133
+ display: flex;
1134
+ flex-direction: column;
1135
+ gap: 6px;
1136
+ }
1137
+ .hx-xs-card[data-active='true'] {
1138
+ border-color: var(--dsw-alias-brand-primary, #4d6bfe);
1139
+ box-shadow: 0 0 0 1px color-mix(in srgb, var(--dsw-alias-brand-primary, #4d6bfe) 35%, transparent);
1140
+ }
1141
+ .hx-xs-card[data-kind='parallel'] { border-style: dashed; }
1142
+ .hx-xs-card__head {
1143
+ display: flex;
1144
+ align-items: center;
1145
+ gap: 6px;
1146
+ flex-wrap: wrap;
1147
+ }
1148
+ .hx-xs-card__marker {
1149
+ width: 12px;
1150
+ text-align: center;
1151
+ color: var(--dsw-alias-brand-primary, #4d6bfe);
1152
+ font-size: 10px;
1153
+ }
1154
+ .hx-xs-card__name {
1155
+ font-weight: 620;
1156
+ font-size: 12.5px;
1157
+ font-family: var(--dsw-alias-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1158
+ }
1159
+ .hx-xs-card__effects {
1160
+ display: flex;
1161
+ align-items: center;
1162
+ gap: 4px;
1163
+ flex-wrap: wrap;
1164
+ }
1165
+ .hx-xs-card__edges {
1166
+ display: flex;
1167
+ flex-direction: column;
1168
+ gap: 3px;
1169
+ }
1170
+ .hx-xs-edge {
1171
+ display: grid;
1172
+ grid-template-columns: minmax(70px, max-content) 1fr auto;
1173
+ align-items: center;
1174
+ gap: 8px;
1175
+ padding: 3px 7px;
1176
+ border: 1px solid transparent;
1177
+ border-radius: 6px;
1178
+ background: transparent;
1179
+ color: inherit;
1180
+ font: inherit;
1181
+ text-align: left;
1182
+ cursor: pointer;
1183
+ }
1184
+ .hx-xs-edge[data-enabled='true']:hover {
1185
+ border-color: color-mix(in srgb, var(--dsw-alias-brand-primary, #4d6bfe) 35%, transparent);
1186
+ background: color-mix(in srgb, var(--dsw-alias-brand-primary, #4d6bfe) 7%, transparent);
1187
+ }
1188
+ .hx-xs-edge[data-enabled='false'] { cursor: default; opacity: .55; }
1189
+ .hx-xs-edge__event {
1190
+ font-family: var(--dsw-alias-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1191
+ font-size: 11px;
1192
+ font-weight: 600;
1193
+ }
1194
+ .hx-xs-edge__target {
1195
+ font-family: var(--dsw-alias-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1196
+ font-size: 11px;
1197
+ color: var(--dsw-alias-label-secondary, #6b7280);
1198
+ overflow: hidden;
1199
+ text-overflow: ellipsis;
1200
+ white-space: nowrap;
1201
+ }
1202
+ .hx-xs-edge__target::before { content: '\\2192 '; opacity: .7; }
1203
+ .hx-xs-edge__target[data-unresolved='true'] { color: #b45309; }
1204
+ .hx-xs-edge__meta {
1205
+ display: inline-flex;
1206
+ gap: 4px;
1207
+ flex-wrap: wrap;
1208
+ justify-content: flex-end;
1209
+ }
1210
+ .hx-xs-card__children {
1211
+ display: flex;
1212
+ flex-direction: column;
1213
+ gap: 6px;
1214
+ padding-left: 10px;
1215
+ border-left: 2px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, .22));
1216
+ }
1217
+ .hx-xs-card__children[data-parallel='true'] {
1218
+ display: grid;
1219
+ grid-auto-flow: column;
1220
+ grid-auto-columns: minmax(180px, 1fr);
1221
+ align-items: start;
1222
+ padding-left: 0;
1223
+ border-left: none;
1224
+ gap: 8px;
1225
+ }
1226
+ .hx-xs-logbar { margin-top: auto; }
1227
+ .hx-xs-logtoggle {
1228
+ border: none;
1229
+ background: transparent;
1230
+ color: var(--dsw-alias-label-secondary, #6b7280);
1231
+ font: inherit;
1232
+ font-size: 11px;
1233
+ cursor: pointer;
1234
+ padding: 2px 0;
1235
+ }
1236
+ .hx-xs-logtoggle:hover { color: var(--dsw-alias-label-primary, #1f2329); }
1237
+ .hx-xs-log {
1238
+ margin: 4px 0 0;
1239
+ padding: 6px 8px;
1240
+ list-style: none;
1241
+ border: 1px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, .22));
1242
+ border-radius: 7px;
1243
+ background: var(--dsw-alias-bg-layer-1, #f5f6f8);
1244
+ max-height: 132px;
1245
+ overflow: auto;
1246
+ display: flex;
1247
+ flex-direction: column;
1248
+ gap: 2px;
1249
+ }
1250
+ .hx-xs-log__row {
1251
+ display: flex;
1252
+ align-items: center;
1253
+ gap: 8px;
1254
+ font-family: var(--dsw-alias-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1255
+ font-size: 11px;
1256
+ }
1257
+ .hx-xs-log__row[data-outcome='ignored'] { opacity: .5; text-decoration: line-through; }
1258
+ .hx-xs-log__row[data-outcome='note'] { color: #b45309; }
1259
+ .hx-xs-log__event { font-weight: 620; }
1260
+ .hx-xs-log__detail {
1261
+ color: var(--dsw-alias-label-secondary, #6b7280);
1262
+ overflow: hidden;
1263
+ text-overflow: ellipsis;
1264
+ white-space: nowrap;
1265
+ }
1266
+ .hx-xs-log__empty {
1267
+ color: var(--dsw-alias-label-secondary, #6b7280);
1268
+ font-size: 11px;
1269
+ }
1270
+
1271
+ /* ---- settings select ---- */
1272
+ .hx-select {
1273
+ height: 28px;
1274
+ padding: 0 8px;
1275
+ border: 1px solid var(--dsw-alias-border-l2, rgba(127, 127, 127, .32));
1276
+ border-radius: 7px;
1277
+ background: var(--dsw-alias-bg-overlay, #fff);
1278
+ color: var(--dsw-alias-label-primary, #1f2329);
1279
+ font: inherit;
1280
+ font-size: 12px;
1281
+ }
1282
+ .hx-select:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary, #4d6bfe); outline-offset: 1px; }
1283
+ .hx-select:disabled { opacity: .55; cursor: not-allowed; }
1284
+
1285
+
1286
+ /* ---- flat event-graph view ---- */
1287
+ .hx-gv {
1288
+ position: absolute;
1289
+ inset: 0;
1290
+ display: flex;
1291
+ flex-direction: column;
1292
+ gap: 6px;
1293
+ padding: 10px 12px;
1294
+ background: var(--dsw-alias-bg-base, #fff);
1295
+ }
1296
+ .hx-gv-bar {
1297
+ display: flex;
1298
+ align-items: center;
1299
+ gap: 8px;
1300
+ flex-wrap: wrap;
1301
+ }
1302
+ .hx-gv-value {
1303
+ font-family: var(--dsw-alias-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1304
+ font-size: 11px;
1305
+ color: var(--dsw-alias-label-secondary, #6b7280);
1306
+ word-break: break-all;
1307
+ }
1308
+ .hx-badge-note {
1309
+ display: inline-flex;
1310
+ height: 17px;
1311
+ padding: 0 6px;
1312
+ border-radius: 5px;
1313
+ border: 1px solid var(--dsw-alias-border-l1, rgba(127, 127, 127, .22));
1314
+ background: var(--dsw-alias-bg-layer-1, #f5f6f8);
1315
+ color: var(--dsw-alias-label-secondary, #6b7280);
1316
+ font-size: 10px;
1317
+ line-height: 1;
1318
+ align-items: center;
1319
+ }
1320
+ .hx-gv__svg {
1321
+ flex: 1 1 auto;
1322
+ min-height: 0;
1323
+ width: 100%;
1324
+ }
1325
+ .hx-gv-node rect {
1326
+ fill: var(--dsw-alias-bg-overlay, #fff);
1327
+ stroke: var(--dsw-alias-border-l2, rgba(127, 127, 127, .32));
1328
+ stroke-width: 1.2;
1329
+ }
1330
+ .hx-gv-node[data-active='true'] rect {
1331
+ stroke: var(--dsw-alias-brand-primary, #4d6bfe);
1332
+ stroke-width: 1.8;
1333
+ fill: color-mix(in srgb, var(--dsw-alias-brand-primary, #4d6bfe) 10%, var(--dsw-alias-bg-overlay, #fff));
1334
+ }
1335
+ .hx-gv-node[data-kind='final'] rect { stroke-dasharray: 3 2; }
1336
+ .hx-gv-node[data-kind='parallel'] rect { stroke-dasharray: 6 3; }
1337
+ .hx-gv-node text {
1338
+ fill: var(--dsw-alias-label-primary, #1f2329);
1339
+ font-size: 10.5px;
1340
+ font-family: var(--dsw-alias-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1341
+ text-anchor: middle;
1342
+ pointer-events: none;
1343
+ }
1344
+ .hx-gv-edge path {
1345
+ fill: none;
1346
+ stroke: var(--dsw-alias-label-secondary, #6b7280);
1347
+ stroke-width: 1.2;
1348
+ }
1349
+ .hx-gv-edge .hx-gv-arrow {
1350
+ fill: var(--dsw-alias-label-secondary, #6b7280);
1351
+ }
1352
+ .hx-gv-edge text {
1353
+ fill: var(--dsw-alias-label-secondary, #6b7280);
1354
+ font-size: 10px;
1355
+ font-family: var(--dsw-alias-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
1356
+ text-anchor: middle;
1357
+ dominant-baseline: middle;
1358
+ paint-order: stroke;
1359
+ stroke: var(--dsw-alias-bg-base, #fff);
1360
+ stroke-width: 3px;
1361
+ }
1362
+ .hx-gv-edge[data-clickable='true'] text {
1363
+ cursor: pointer;
1364
+ fill: var(--dsw-alias-label-primary, #1f2329);
1365
+ }
1366
+ .hx-gv-edge[data-clickable='true'] text:hover {
1367
+ fill: var(--dsw-alias-brand-primary, #4d6bfe);
1368
+ }
1369
+ .hx-gv-edge[data-kind='after'] path { stroke-dasharray: 4 3; }
1370
+ .hx-gv-edge .hx-gv-hit {
1371
+ stroke: transparent;
1372
+ stroke-width: 16;
1373
+ cursor: pointer;
1374
+ fill: none;
1375
+ }
1376
+ `;function Ha(){De.useEffect(()=>{if(document.getElementById("hx-styles")!==null)return;let e=document.createElement("style");e.id="hx-styles",e.textContent=p8,document.head.appendChild(e)},[])}var g8=1400;function $v(e){let{content:t,panel:r,t:n}=e,i=Wi(e.form).settings.behaviors.mermaid,a=De.useRef(null),l=De.useRef(null),s=De.useRef(null),o=De.useRef(null),[c,h]=De.useState("diagram"),[u,d]=De.useState(0),[p,g]=De.useState({status:"loading"}),[m,v]=De.useState(null);if(Ha(),De.useEffect(()=>()=>{o.current!==null&&clearTimeout(o.current)},[]),t.kind!=="text")return null;let x=t.text,k=x.trim()==="",C=c==="diagram"&&t.eof&&!k&&p.status==="error"?p.message:null,N=H=>{v(H),o.current!==null&&clearTimeout(o.current),o.current=setTimeout(()=>{o.current=null,v(null)},g8)},R=()=>{(async()=>{try{await navigator.clipboard.writeText(x),N(n("panel.copied"))}catch{N(n("panel.copyFailed"))}})()},O=()=>{try{Hl(l.current?.svg(),l.current?.mermaidType())}catch{N(n("panel.downloadFailed"))}},P=()=>{r.openSource(x,s.current,i.multiInstance,"mermaid",Nl(a.current))};return ue("div",{ref:a,className:"hx-mmd","data-halcyon-mermaid-file":""},ue("div",{className:"hx-mmd__bar"},ue("span",{className:"hx-mmd__label"},ue(pn,{size:14}),n("mermaidFile.title")),k?null:ue(De.Fragment,null,ue("button",{type:"button",className:"hx-mmd__tab","aria-pressed":c==="source",onClick:()=>h(c==="diagram"?"source":"diagram")},n(c==="diagram"?"mermaidFile.viewSource":"mermaidFile.viewDiagram")),ue("button",{ref:s,type:"button",className:"hx-btn",onClick:P,title:n("trigger.hint"),"aria-label":n("trigger.hint")},ue(Bl,null)),ue("button",{type:"button",className:"hx-btn",onClick:R,title:n("panel.copySource"),"aria-label":n("panel.copySource")},ue(Ja,null)),ue("button",{type:"button",className:"hx-btn",onClick:O,disabled:p.status!=="ready",title:n("panel.downloadSvg"),"aria-label":n("panel.downloadSvg")},ue(Fl,null))),ue("span",{className:"hx-mmd__notice","aria-live":"polite"},m)),t.eof?k?ue("div",{className:"hx-mmd__status"},n("mermaidFile.empty")):c==="source"?ue("pre",{className:"hx-mmd__source"},x):ue(De.Fragment,null,ue(O2,{source:x,allowLinks:i.allowLinks,retryToken:u,label:n("mermaidFile.title"),viewRef:l,onState:g}),C!==null?ue("div",{className:"hx-mmd__error",role:"alert"},ue("span",{className:"hx-mmd__error-title"},ue(Wl,{size:15}),n("mermaidFile.error")),ue("pre",{className:"hx-status__detail"},C),ue("div",{className:"hx-status__actions"},ue("button",{type:"button",className:"hx-action hx-action--primary",onClick:()=>h("source")},n("mermaidFile.viewSource")),ue("button",{type:"button",className:"hx-action",onClick:()=>d(H=>H+1)},n("mermaidFile.renderAgain")))):null,p.status==="loading"?ue("div",{className:"hx-mmd__status"},ue("span",{className:"hx-spinner","aria-hidden":"true"}),ue("span",null,n("mermaidFile.rendering"))):null):ue("div",{className:"hx-mmd__status"},ue("span",{className:"hx-spinner","aria-hidden":"true"}),ue("span",null,n("mermaidFile.loading"))))}var m8=`flowchart TD
1377
+ classDef hub fill:#4d6bfe,stroke:#2545c8,color:#ffffff
1378
+ classDef ready fill:#1a7f37,stroke:#14532d,color:#ffffff
1379
+ classDef risky fill:#b45309,stroke:#78350f,color:#ffffff
1380
+ classDef broken fill:#b91c1c,stroke:#7f1d1d,color:#ffffff
1381
+
1382
+ Idea([Idea]):::hub --> Draft[Draft spec]
1383
+ Draft --> Review{Reviewed?}
1384
+ Review -- yes --> Build[[Implement]]:::hub
1385
+ Review -- no --> Draft
1386
+ Build --> Test[(Test suite)]
1387
+ Test --> Verdict{All green?}
1388
+ Verdict -- yes --> Ship[Release]:::ready
1389
+ Verdict -- flaky --> Investigate((Investigate)):::risky
1390
+ Verdict -- no --> Fix[Bugfix]:::broken
1391
+ Fix -.-> Build
1392
+ Investigate -.-> Test
1393
+ Ship ==> Watch[Watch metrics]:::risky
1394
+
1395
+ subgraph pipeline [CI pipeline]
1396
+ Build
1397
+ Test
1398
+ end`,y8=`import { setup, assign } from 'xstate'
1399
+
1400
+ export const playerMachine = setup({
1401
+ guards: { canPlay: ({ context }) => context.tracks.length > 0 },
1402
+ }).createMachine({
1403
+ id: 'player',
1404
+ initial: 'idle',
1405
+ context: { tracks: ['a.mp3', 'b.mp3'], current: 0 },
1406
+ states: {
1407
+ idle: {
1408
+ on: { LOAD: { target: 'ready', guard: 'canPlay' } },
1409
+ },
1410
+ ready: {
1411
+ initial: 'stopped',
1412
+ on: { EJECT: 'idle' },
1413
+ states: {
1414
+ stopped: { on: { PLAY: 'playing' } },
1415
+ playing: {
1416
+ on: { PAUSE: 'paused', NEXT: { actions: 'nextTrack' } },
1417
+ after: { 60000: 'paused' },
1418
+ },
1419
+ paused: { on: { PLAY: 'playing' } },
1420
+ },
1421
+ },
1422
+ panel: {
1423
+ type: 'parallel',
1424
+ states: {
1425
+ lights: { initial: 'off', states: { off: { on: { TOGGLE: 'on' } }, on: { on: { TOGGLE: 'off' } } } },
1426
+ eq: { initial: 'flat', states: { flat: { on: { BOOST: 'loud' } }, loud: { on: { RESET: 'flat' } } } },
1427
+ },
1428
+ },
1429
+ done: { type: 'final' },
1430
+ },
1431
+ })`;function fn(e){return ue("div",{className:"hx-switch-row"},ue("div",{className:"hx-switch-copy"},ue("label",{className:"hx-switch-label",htmlFor:e.id},e.label),ue("span",{className:"hx-switch-hint"},e.hint)),ue("input",{id:e.id,className:"hx-switch",type:"checkbox",role:"switch",checked:e.checked,disabled:e.disabled,onChange:t=>e.onChange(t.currentTarget.checked)}))}function x8(e){return ue("div",{className:"hx-switch-row"},ue("div",{className:"hx-switch-copy"},ue("label",{className:"hx-switch-label",htmlFor:e.id},e.label),ue("span",{className:"hx-switch-hint"},e.hint)),ue("select",{id:e.id,className:"hx-select",value:e.value,disabled:e.disabled,onChange:t=>e.onChange(t.currentTarget.value)},e.options.map(t=>ue("option",{key:t.value,value:t.value},t.label))))}function Ld(e){return ue("div",{className:"hx-settings__cardhead"},ue("span",{className:"hx-settings__cardicon"},e.icon),ue("div",null,ue("h3",{className:"hx-settings__title"},e.title),ue("p",{className:"hx-settings__desc"},e.description)))}function kv(e){let t=Wi(e.form),[r,n]=De.useState({kind:"idle"}),[i,a]=De.useState(!1),[l,s]=De.useState(null),o=De.useRef(null),c=De.useRef(null),h=De.useRef(null);De.useEffect(()=>()=>{h.current!==null&&clearTimeout(h.current)},[]);let u=async(O,P)=>{if(!(!t.writable||i)){a(!0),n({kind:"saving"});try{let H=await Qa(e.form,O,P);n({kind:H?"saved":"error"}),H&&(h.current!==null&&clearTimeout(h.current),h.current=setTimeout(()=>n({kind:"idle"}),1800))}catch{n({kind:"error"})}finally{a(!1)}}},d=t.settings.panels,p=t.settings.behaviors.mermaid,g=t.settings.behaviors.xstate,m=t.settings.behaviors.sidebar,v=!t.writable||i,x=t.status==="loading",k=!x&&!t.writable,b=l??d.panelOpacity,C=(Jn(b)-Za)/(Dl-Za)*100,N=O=>{let P=Jn(O);s(null),P!==d.panelOpacity&&u(["panels","panelOpacity"],P)},R=x?{tone:"muted",text:e.t("section.loading")}:k?{tone:"error",text:e.t("section.readonly")}:r.kind==="saving"?{tone:"muted",text:e.t("section.saving")}:r.kind==="saved"?{tone:"ok",text:e.t("section.saved")}:r.kind==="error"?{tone:"error",text:e.t("section.error")}:null;return Ha(),ue("div",{className:"hx-settings"},ue("p",{className:"hx-settings__intro"},e.t("section.intro")),ue("section",{className:"hx-settings__card"},ue(Ld,{icon:ue("span",{"aria-hidden":"true"},"▣"),title:e.t("section.panels.title"),description:e.t("section.panels.opacity.hint")}),ue(fn,{id:"hx-panels-zoom",label:e.t("section.panels.zoom"),hint:e.t("section.panels.zoom.hint"),checked:d.zoom,disabled:v,onChange:O=>{u(["panels","zoom"],O)}}),ue(fn,{id:"hx-panels-translucent",label:e.t("section.panels.defaultTranslucent"),hint:e.t("section.panels.defaultTranslucent.hint"),checked:d.defaultTranslucent,disabled:v,onChange:O=>{u(["panels","defaultTranslucent"],O)}}),ue("div",{className:"hx-switch-row"},ue("div",{className:"hx-switch-copy"},ue("label",{className:"hx-switch-label",htmlFor:"hx-panels-opacity"},e.t("section.panels.opacity")),ue("span",{className:"hx-switch-hint"},e.t("section.panels.opacity.hint"))),ue("div",{className:"hx-range"},ue("input",{id:"hx-panels-opacity",className:"hx-range__input",type:"range",min:Za,max:Dl,step:Ll,value:b,disabled:v,"aria-valuetext":`${b}%`,style:{background:`linear-gradient(to right, var(--dsw-alias-brand-primary, #4d6bfe) 0 ${C}%, var(--dsw-alias-border-l2, rgba(127, 127, 127, .32)) ${C}% 100%)`},onChange:O=>s(Number(O.currentTarget.value)),onPointerUp:O=>N(Number(O.currentTarget.value)),onKeyUp:O=>N(Number(O.currentTarget.value)),onBlur:O=>{l!==null&&N(Number(O.currentTarget.value))}}),ue("span",{className:"hx-range__value","aria-hidden":"true"},`${b}%`)))),ue("section",{className:"hx-settings__card"},ue(Ld,{icon:ue(pn,{size:15}),title:e.t("section.behavior.mermaid.title"),description:e.t("section.behavior.mermaid.description")}),ue(fn,{id:"hx-mermaid-enabled",label:e.t("section.behavior.mermaid.master"),hint:e.t("section.behavior.mermaid.master.hint"),checked:p.enabled,disabled:v,onChange:O=>{u(["behaviors","mermaid","enabled"],O)}}),ue(fn,{id:"hx-mermaid-code-button",label:e.t("section.behavior.mermaid.codeButton"),hint:e.t("section.behavior.mermaid.codeButton.hint"),checked:p.codeButton,disabled:v,onChange:O=>{u(["behaviors","mermaid","codeButton"],O)}}),ue(fn,{id:"hx-mermaid-links",label:e.t("section.behavior.mermaid.allowLinks"),hint:e.t("section.behavior.mermaid.allowLinks.hint"),checked:p.allowLinks,disabled:v,onChange:O=>{u(["behaviors","mermaid","allowLinks"],O)}}),ue(fn,{id:"hx-mermaid-multi",label:e.t("section.behavior.mermaid.multiInstance"),hint:e.t("section.behavior.mermaid.multiInstance.hint"),checked:p.multiInstance,disabled:v,onChange:O=>{u(["behaviors","mermaid","multiInstance"],O)}}),ue("div",{className:"hx-settings__samplerow"},ue("span",{className:"hx-settings__samplehint"},e.t("section.preview.hint")),ue("button",{ref:o,type:"button",className:"hx-settings__sample",disabled:!p.enabled,onClick:()=>e.panel.openSource(m8,o.current,p.multiInstance,"mermaid")},ue(pn,{size:14}),e.t("section.behavior.mermaid.sample")))),ue("section",{className:"hx-settings__card"},ue(Ld,{icon:ue(Sn,{size:15}),title:e.t("section.behavior.xstate.title"),description:e.t("section.behavior.xstate.description")}),ue(fn,{id:"hx-xstate-enabled",label:e.t("section.behavior.xstate.master"),hint:e.t("section.behavior.xstate.master.hint"),checked:g.enabled,disabled:v,onChange:O=>{u(["behaviors","xstate","enabled"],O)}}),ue(fn,{id:"hx-xstate-multi",label:e.t("section.behavior.xstate.multiInstance"),hint:e.t("section.behavior.xstate.multiInstance.hint"),checked:g.multiInstance,disabled:v,onChange:O=>{u(["behaviors","xstate","multiInstance"],O)}}),ue(x8,{id:"hx-xstate-execution",label:e.t("section.behavior.xstate.execution"),hint:e.t("section.behavior.xstate.execution.hint"),value:g.execution,disabled:v,options:Xd.map(O=>({value:O,label:e.t(`section.behavior.xstate.execution.${O}`)})),onChange:O=>{u(["behaviors","xstate","execution"],O)}}),ue("div",{className:"hx-settings__samplerow"},ue("span",{className:"hx-settings__samplehint"},e.t("section.preview.xstate.hint")),ue("button",{ref:c,type:"button",className:"hx-settings__sample",disabled:!g.enabled,onClick:()=>e.panel.openSource(y8,c.current,g.multiInstance,"xstate")},ue(Sn,{size:14}),e.t("section.behavior.xstate.sample")))),ue("section",{className:"hx-settings__card"},ue(Ld,{icon:ue(Bl,{size:15}),title:e.t("section.behavior.sidebar.title"),description:e.t("section.behavior.sidebar.description")}),ue(fn,{id:"hx-sidebar-blocks",label:e.t("section.behavior.sidebar.codeBlocks"),hint:e.t("section.behavior.sidebar.codeBlocks.hint"),checked:m.codeBlocks,disabled:v,onChange:O=>{u(["behaviors","sidebar","codeBlocks"],O)}}),ue(fn,{id:"hx-sidebar-mermaid-file",label:e.t("section.behavior.sidebar.mermaidFile"),hint:e.t("section.behavior.sidebar.mermaidFile.hint"),checked:m.mermaidFile,disabled:v,onChange:O=>{u(["behaviors","sidebar","mermaidFile"],O)}})),ue("div",{className:"hx-settings__footer"},ue("div",{className:"hx-settings__status","data-tone":R?.tone,"aria-live":"polite"},R!==null&&ue("span",{className:"hx-settings__dot","aria-hidden":"true"}),R?.text)))}var Mv=["slots","locale","configForms"];function _v(e){xg(e);let t=e.configForms.get(Fi),r=new zl,n=e.locale.bind(ei);function i(a){let l=Wi(t),s=l.settings.panels,o=l.settings.behaviors.mermaid,c=l.settings.behaviors.xstate,h=l.settings.behaviors.sidebar,u=o.enabled||c.enabled;return De.useEffect(()=>{!u&&r.getSnapshot().windows.length>0&&r.closeAll()},[u]),Ha(),ue("div",{className:"hx-root",style:{pointerEvents:"none"}},u&&ue(Bg,{enabled:!0,kinds:{mermaid:o.enabled&&o.codeButton,xstate:c.enabled},surfaces:{sidebar:h.codeBlocks},t:a.t,onOpen:(d,p,g,m)=>{let v=d.kind==="xstate"?c.multiInstance:o.multiInstance;r.open(p,g,m,v,Nl(d.banner))}}),u&&ue(vv,{store:r,zoomEnabled:s.zoom,allowLinks:o.allowLinks,multiInstance:o.multiInstance,defaultTranslucent:s.defaultTranslucent,panelOpacity:s.panelOpacity,execution:c.execution,xstateMultiInstance:c.multiInstance,onToggleMode:d=>d==="xstate"?Qa(t,["behaviors","xstate","multiInstance"],!c.multiInstance):Qa(t,["behaviors","mermaid","multiInstance"],!o.multiInstance),t:a.t}))}e.slots.inject("shell.overlay",()=>e.slots.register({name:"shell.overlay",id:Fi,locale:ei},i)),e.slots.inject("settings.section",()=>e.slots.register({name:"settings.section",id:Fi,order:60,locale:ei,label:()=>n("section.title"),inject:()=>({form:t,panel:r})},kv)),e.slots.inject("sidebar.right.tab.document",()=>e.slots.register({name:"sidebar.right.tab.document",key:Kd,locale:ei,inject:()=>({form:t,panel:r})},$v)),e.inject(["documentPreviews"],a=>{let l={id:Kd,extensions:gg,priority:"extension",title:()=>n("mermaidFile.title"),loading:"text-pages",wrap:!1},s=null,o=()=>{let h=Pl(t.getSnapshot().value).behaviors.sidebar.mermaidFile;h&&s===null?s=a.documentPreviews.register(l):!h&&s!==null&&(s(),s=null)},c=t.subscribe(o);o(),a.effect(()=>()=>{c(),s?.(),s=null},"dsh-halcyon-uiux: mermaid file preview")})}var b8={inject:Mv,apply:_v};return Iv(w8);})();
1432
+
1433
+ let plugin = __halcyon;
1434
+ while (plugin && typeof plugin === 'object' && plugin.inject === undefined && plugin.default && plugin.default !== plugin) {
1435
+ plugin = plugin.default;
1436
+ }
1437
+ return plugin;
1438
+ },
1439
+ });