!function(){"use strict";function t(t,e,n=null){if(null===n)return t.indexOf(e);for(let r=0;r=t.length)return void r.push(n.slice());const s=t[e];if(!Array.isArray(s))return n.push(s),i(t,e+1,n,r),void n.pop();for(let a=0;a{n.push(...e(t))}),n}function o(t,e){const n=Gt[t.type];return!(!n||t.type!==e.type)&&!n.check.some(n=>t[n]!==e[n])}function l(t,n){Gt[t.type].merge.forEach(r=>{e(t[r],n[r])})}function h(t,e){for(let n=0;n{for(let r=0;rt);return n.forEach(t=>{const r=Gt[t];r&&n.every(e=>t===e||r.siblings.has(e))&&e.add(t)}),e}function c(t,e,n,r){h(r,r=>{if(!t.has(r.type)||!e.has(r.type))return!1;for(let t=0;t!Dt.includes(t.type))?"Cannot use parallel here":function(t){const e=a(t.filter(t=>"agent begin"===t.type),t=>t.agentIDs);for(const n of t)if("agent end"===n.type)for(const t of n.agentIDs)if(-1!==e.indexOf(t))return"Cannot create and destroy "+t+" simultaneously";return null}(n)||function(t){const e=t.filter(t=>"block begin"===t.type||"block end"===t.type).length;if(!e)return null;if(e!==t.length)return"Cannot use parallel here";const n=t.filter(t=>"block begin"===t.type).map(t=>t.left);for(const e of t)if("block end"===e.type&&-1!==n.indexOf(e.left))return"Cannot create and destroy reference simultaneously";return null}(n)||function(t){const e=t.filter(t=>"connect-delay-begin"===t.type).map(t=>t.tag);for(const n of t)if("connect-delay-end"===n.type&&-1!==e.indexOf(n.tag))return"Cannot start and finish delayed connection simultaneously";return null}(n)}function f(t,e){if("agent begin"===t.type)return t.mode=e,!0;if("parallel"===t.type){let n=!1;return t.stages.forEach(t=>{"agent begin"===t.type&&(t.mode=e,n=!0)}),n}return!1}function m(t,e,n,s=null){r(t,e,Ct.equals),r(t,n,Ct.equals);let i=0,a=t.length;if(s){const e=s.map(e=>Ct.indexOf(t,e)).filter(t=>-1!==t);i=e.reduce((t,e)=>Math.min(t,e),t.length),a=e.reduce((t,e)=>Math.max(t,e),i)+1}return t.splice(i,0,e),t.splice(a+1,0,n),{indexL:i,indexR:a+1}}function b(t,e=[]){return{type:"string",suggest:e,then:Object.assign({"":0},t)}}function y(t,e){return t.v===e.v&&t.prefix===e.prefix&&t.suffix===e.suffix&&t.q===e.q}function x(t,e,n){return a(n.suggest||[""],r=>{if("object"==typeof r)return r.known?t["known"+r.known]||[]:[r];if(""===r)return[function(t,e){return Object.keys(e.then).length>0?{q:!1,suffix:" ",v:t}:{q:!1,suffix:"\n",v:t}}(e,n)];if("string"==typeof r)return[{q:""===e,v:r}];throw new Error("Invalid suggestion type "+r)})}function w(t,n){const r=[],i=s(n);return Object.keys(i.then).forEach(s=>{let a=i.then[s];"number"==typeof a&&(a=n[n.length-a-1]),e(r,x(t,s,a),y)}),r}function k(t,n,r,s){const i=function(t){for(const e of t)if("object"==typeof e&&e.known)return e.known;return null}(s.suggest||[""]);n.type&&i!==n.type&&(!function(t,n,r){e(t["known"+n],[{q:!0,suffix:" ",v:r}],y)}(t,s.override||n.type,n.value),n.value=""),i&&(n.value=function(t,e){return t+(t?e.s:"")+e.v}(n.value,r)),n.type=i}function v(t,e,n){const r={type:"",value:""};let i=n;const a=[i];return t.line.forEach((e,n)=>{n===t.line.length-1&&(t.completions=w(t,a));const o=e.q?"":e.v;let l=i.then[o];void 0===l?(l=i.then[""],t.isVar=!0):t.isVar=e.q,"number"==typeof l?a.length-=l:a.push(l||Ht),i=s(a),k(t,r,e,i)}),e&&k(t,r,null,{}),t.nextCompletions=w(t,a),t.valid=Boolean(i.then["\n"])||0===Object.keys(i.then).length,i.type}function A(t){const e=t.baseToken||{};return{quoted:e.q||!1,value:e.v||""}}function F(t,e,n){return e.lastIndex=n,e.exec(t)}function S(t,e,n){return n?function(t,e,n){if(n.escape){const r=F(t,n.escape,e);if(r)return{appendSpace:"",appendValue:n.escapeWith(r),end:!1,newBlock:null,skip:r[0].length}}const r=F(t,n.end,e);return r?{appendSpace:"",appendValue:n.includeEnd?r[0]:"",end:!0,newBlock:null,skip:r[0].length}:{appendSpace:"",appendValue:t[e],end:!1,newBlock:null,skip:1}}(t,e,n):function(t,e){for(let n=0;n"}function I(t,e,n){const r=" "+t+" ";let s=-1,i=r.length,a=0;return Zt.forEach(({begin:t,end:o},l)=>{const h=n[l]?o:t;h.lastIndex=e;const d=h.exec(r);d&&(d.indexa)&&(s=l,i=d.index,a=h.lastIndex)}),{end:a-1,start:i,styleIndex:s}}function E(t,e){if(!t)return null;const n={};return e.forEach((t,e)=>{t&&Object.assign(n,Zt[e].attrs)}),n}function G(t){return t.replace(/^[\f\n\r\t\v ]+|[\f\n\r\t\v ]+$/g,"")}function D(t){if(!t)return[];const e=Zt.map(()=>!1);let n=0,r=null;const s=[];return G(t).split("\n").forEach(t=>{const i=function(t){return t.replace(/[\f\n\r\t\v ]+/g," ")}(G(t)),a=[];let o=0;for(;;){const{styleIndex:t,start:s,end:l}=I(i,o,e);if(-1===t)break;e[t]?(e[t]=!1,--n):(e[t]=!0,++n),s>o&&a.push({attrs:r,text:i.substring(o,s)}),r=E(n,e),o=l}o=a&&!i){let n=t[e];throw n||(n={b:s(t).e}),L("Missing agent name",n)}return{alias:O(t,a+1,n),name:O(t,e,a)}}(t,l,n,{allowBlankName:h,enableAlias:i});return{alias:g,flags:d?a:o,name:d}}function H(t,e,n,r){const s=[];let i=-1;for(let a=e;a{const s=t.get(e);(null===n||s.indexr.index)&&(r=s)}),{left:n.id,right:r.id}}function U(t=null,e=null){return null===t?e:null===e?t:Math.max(t,e)}function W(t,n){return e(t.agentIDs,n.agentIDs),{agentIDs:t.agentIDs,asynchronousY:U(t.asynchronousY,n.asynchronousY),topShift:Math.max(t.topShift,n.topShift),y:U(t.y,n.y)}}function X(t){return null===t?null:t.element?t.element:t}function Q(t,e,n){if(!Array.isArray(n))throw new Error("Invalid formatted text line: "+n);n.forEach(({text:n,attrs:r})=>{r?e.add(t.el("tspan").attrs(r).add(n)):e.add(n)})}function J(t,e){let n=null,r=null;return e.forEach(e=>{const s=t.get(e);(null===n||s.indexr.index)&&(r=s)}),{left:n.id,right:r.id}}function Z(t,e){return t.v===e.v&&t.prefix===e.prefix&&t.suffix===e.suffix&&t.q===e.q}function K(t,e,n){const r=t.getLine(e),s={squash:{ch:n,line:e},word:{ch:n,line:e}};return n>0&&" "===r[n-1]&&(We.after.includes(r[n-2])&&s.word.ch--,s.squash.ch--),s}function _(t,e,n){const r=function({v:t,q:e,prefix:n="",suffix:r=""},s){const i=s||!Qe.test(t)?s:'"';return n+(i&&e?i+t.replace(Je,"\\$&")+i:t)+r}(t,n),s=t.q?e.fromVar:e.fromKey;return"\n"===r?{className:"pick-virtual",displayFrom:null,displayText:"",from:s.squash,text:"\n",to:e.to.squash}:{className:null,displayFrom:s.word,displayText:r.trim(),from:We.start.test(r)?s.squash:s.word,text:r,to:We.end.test(r)?e.to.squash:e.to.word}}function $({global:t,prefix:e="",suffix:n=""},r){const s=r[t];return s?s.map(t=>({prefix:e,q:!0,suffix:n,v:t})):[]}function tt(t,n,r){let s=null;return s=t.ch>0&&n.state.line.length>0?n.state.completions.slice():n.state.beginCompletions.concat(n.state.knownAgent),function(t,n={}){for(let r=0;r=e.ch){n.length=t+1;break}return n}(t,n),i=s(r)||t.getTokenAt(n),a=function(t,e){let n="",r=0,s=0;t.forEach(t=>{t.state.isVar?(n+=t.string,s=t.end):(n="",r=t.end)}),s>e.ch&&(n=n.substr(0,e.ch-r));const i=Ue.exec(n);n=i[2];let a="";return Xe.test(n)&&(a=n.charAt(0),n=n.substr(1)),{from:r+i[1].length,partial:n,quote:a,valid:s>=r}}(r,n),o=function(t,e){let n=t.string;t.end>e.ch&&(n=n.substr(0,e.ch-t.start));const r=Ue.exec(n);return{from:t.start+r[1].length,partial:r[2],valid:!0}}(i,n),l=tt(n,i,t.options.globals),h={fromKey:K(t,n.line,o.from),fromVar:K(t,n.line,a.from),to:function(t,e,n){const r={squash:{ch:n,line:e},word:{ch:n,line:e}};return" "===t.getLine(e)[n]&&r.squash.ch++,r}(t,n.line,i.end)};let d=null;const g=l.filter(t=>(t.q||!a.quote)&&function(t,e){return e.valid&&t.startsWith(e.partial)}(t.v,t.q?a:o)).map(t=>e.completeSingle||t.v!==(t.q?a:o).partial?_(t,h,a.quote):(d=t,null)).filter(t=>null!==t);return d&&g.length>0&&g.unshift(_(d,h,a.quote)),{from:function(t,e){let n=null;return t.forEach(({displayFrom:t})=>{t&&(!n||t.line>n.line||t.line===n.line&&t.ch>n.ch)&&(n=t)}),n||e.word}(g,h.fromKey),list:g,to:h.to.word}}function nt(t,e="sequence"){const n=t||window.CodeMirror;n.defineMode(e,()=>$e),n.registerHelper("hint",e,et)}function rt(t){const e=(new DOMParser).parseFromString(t,"image/svg+xml").querySelector("metadata");return e?e.textContent:""}function st(t){function e(t,e){n.push(e)}const n=[];if(t.forEach(t=>{t.addEventListener("error",e),t.optimisedRenderPreReflow()}),t.forEach(t=>{t.optimisedRenderReflow()}),t.forEach(t=>{t.optimisedRenderPostReflow(),t.removeEventListener("error",e)}),n.length>0)throw n}function it(t,e=null,n={}){if("svg"===t.tagName)return null;const r=function(t){return{interactive:function(t){return void 0!==t&&"false"!==t}(t.dataset.sdInteractive),namespace:t.dataset.sdNamespace||null}}(t),s=new tn(null===e?t.textContent:e,Object.assign(r,n)),i=s.dom(),a=t.attributes;for(let t=0;tit(t,r,e)).filter(t=>null!==t);return!1!==s.render&&st(n),n}return it(t,r,s)}class ot{constructor(t,e){Array.isArray(e)?this.deltas=e:this.deltas=[0,2*-e/3,-e,2*-e/3,0,2*e/3,e,2*e/3],this.partWidth=t/this.deltas.length}getDelta(t){return this.deltas[t%this.deltas.length]}}class lt{constructor(t){this.svg=t}reset(){}addDefs(){}getBlock(t){return this.blocks[t]||this.blocks[""]}getNote(t){return this.notes[t]||this.notes[""]}getDivider(t){return this.dividers[t]||this.dividers[""]}optionsAttributes(t,e){return function(t,e){const n=Object.assign({},t[""]);return e.forEach(e=>{Object.assign(n,t[e]||{})}),n}(t,e)}renderAgentLine({className:t,options:e,width:n,x:r,y0:s,y1:i}){const a=this.optionsAttributes(this.agentLineAttrs,e);return n>0?this.svg.box(a,{height:i-s,width:n,x:r-n/2,y:s}).addClass(t):this.svg.line(a,{x1:r,x2:r,y1:s,y2:i}).addClass(t)}renderArrowHead(t,{dir:e,height:n,width:r,x:s,y:i}){const a=r*e.dx,o=r*e.dy,l=.5*n*e.dx,h=.5*-n*e.dy;return this.svg.el("none"===t.fill?"polyline":"polygon").attr("points",s+a-h+" "+(i+o-l)+" "+s+" "+i+" "+(s+a+h)+" "+(i+o+l)).attrs(t)}renderTag(t,{height:e,width:n,x:r,y:s}){const{rx:i,ry:a}=t,o=r+n,l=s+e,h="M"+o+" "+s+"L"+o+" "+(l-a)+"L"+(o-i)+" "+l+"L"+r+" "+l,d=this.svg.el("g");return"none"!==t.fill&&d.add(this.svg.el("path").attr("d",h+"L"+r+" "+s).attrs(t).attr("stroke","none")),"none"!==t.stroke&&d.add(this.svg.el("path").attr("d",h).attrs(t).attr("fill","none")),d}renderDB(t,e){const n=t["db-z"];return this.svg.el("g").add(this.svg.box({rx:e.width/2,ry:n},e).attrs(t),this.svg.el("path").attr("d","M"+e.x+" "+(e.y+n)+"a"+e.width/2+" "+n+" 0 0 0 "+e.width+" 0").attrs(t).attr("fill","none"))}renderRef(t,e){return{fill:this.svg.box(t,e).attrs({stroke:"none"}),mask:this.svg.box(t,e).attrs({fill:"#000000",stroke:"none"}),shape:this.svg.box(t,e).attrs({fill:"none"})}}renderFlatConnect(t,e,{x1:n,y1:r,x2:s,y2:i}){return{p1:{x:n,y:r},p2:{x:s,y:i},shape:this.svg.el("path").attr("d",this.svg.patternedLine(t).move(n,r).line(s,i).cap().asPath()).attrs(e)}}renderRevConnect(t,e,{rad:n,x1:r,x2:s,xR:i,y1:a,y2:o}){const l=(o-a)/2,h=this.svg.patternedLine(t).move(r,a).line(i,a);return n0?this.svg.el("g").add(this.svg.line({fill:"none"},{x1:s,x2:s+(r-n)/2,y1:o,y2:o}).attrs(t),this.svg.line({fill:"none"},{x1:s+(r+n)/2,x2:s+r,y1:o,y2:o}).attrs(t)):this.svg.line({fill:"none"},{x1:s,x2:s+r,y1:o,y2:o}).attrs(t),{shape:a}}renderDelayDivider({dotSize:t,gapSize:e},{height:n,width:r,x:s,y:i}){const a=this.svg.el("g");for(let o=0;o+e<=n;o+=t+e)a.add(this.svg.box({fill:"#000000"},{height:e,width:r,x:s,y:i+o}));return{mask:a}}renderTearDivider({fadeBegin:t,fadeSize:e,lineAttrs:n,pattern:r,zigHeight:s,zigWidth:i},{env:a,height:o,labelHeight:l,labelWidth:h,width:d,x:g,y:c}){const u=a.addDef("tear-grad",()=>{const n=100/d;return this.svg.linearGradient({},[{offset:t*n+"%","stop-color":"#000000"},{offset:(t+e)*n+"%","stop-color":"#FFFFFF"},{offset:100-(t+e)*n+"%","stop-color":"#FFFFFF"},{offset:100-t*n+"%","stop-color":"#000000"}])}),p=this.svg.el("mask").attr("maskUnits","userSpaceOnUse").add(this.svg.box({fill:"url(#"+u+")"},{height:o+10,width:d,x:g,y:c-5})),f=a.addDef(p);h>0&&p.add(this.svg.box({fill:"#000000",rx:2,ry:2},{height:l+2,width:h,x:g+(d-h)/2,y:c+(o-l)/2-1}));const m=r||new ot(i,[s,-s]);let b=null;const y=this.svg.patternedLine(m).move(g,c).line(g+d,c),x=this.svg.el("g").attr("mask","url(#"+f+")").add(this.svg.el("path").attrs({d:y.asPath(),fill:"none"}).attrs(n));if(o>0){const t=this.svg.patternedLine(m).move(g,c+o).line(g+d,c+o);x.add(this.svg.el("path").attrs({d:t.asPath(),fill:"none"}).attrs(n)),y.line(t.x,t.y,{patterned:!1}).cap(),y.points.push(...t.points.reverse()),b=this.svg.el("path").attrs({d:y.asPath(),fill:"#000000"})}return{mask:b,shape:x}}}const ht="Helvetica,Arial,Liberation Sans,sans-serif",dt=1.3,gt=new ot(6,.5),ct={"font-family":ht,"font-size":8,"line-height":dt},ut={"font-family":ht,"font-size":8,"line-height":dt,"text-anchor":"middle"};class pt extends lt{constructor(t){super(t);const e={padding:{top:3,bottom:2},tag:{padding:{top:1,left:3,right:3,bottom:0},boxRenderer:this.renderTag.bind(this,{fill:"#FFFFFF",stroke:"#000000","stroke-width":1,rx:2,ry:2}),labelAttrs:{"font-family":ht,"font-weight":"bold","font-size":9,"line-height":dt,"text-anchor":"left"}},label:{minHeight:4,padding:{top:1,left:5,right:3,bottom:1},labelAttrs:{"font-family":ht,"font-size":8,"line-height":dt,"text-anchor":"left"}}};Object.assign(this,{titleMargin:10,outerMargin:5,agentMargin:10,actionMargin:10,minActionMargin:3,agentLineHighlightRadius:4,agentCap:{box:{padding:{top:5,left:10,right:10,bottom:5},arrowBottom:12.8,boxAttrs:{fill:"#FFFFFF",stroke:"#000000","stroke-width":1},labelAttrs:{"font-family":ht,"font-size":12,"line-height":dt,"text-anchor":"middle"}},database:{padding:{top:12,left:10,right:10,bottom:3},arrowBottom:12.8,boxRenderer:this.renderDB.bind(this,{fill:"#FFFFFF",stroke:"#000000","stroke-width":1,"db-z":5}),labelAttrs:{"font-family":ht,"font-size":12,"line-height":dt,"text-anchor":"middle"}},cross:{size:20,render:t.crossFactory({fill:"none",stroke:"#000000","stroke-width":1})},bar:{height:4,render:t.boxFactory({fill:"#000000",stroke:"#000000","stroke-width":1})},fade:{width:5,height:6,extend:1},none:{height:10}},connect:{loopbackRadius:6,line:{solid:{attrs:{fill:"none",stroke:"#000000","stroke-width":1},renderFlat:this.renderFlatConnect.bind(this,null),renderRev:this.renderRevConnect.bind(this,null)},dash:{attrs:{fill:"none",stroke:"#000000","stroke-width":1,"stroke-dasharray":"4, 2"},renderFlat:this.renderFlatConnect.bind(this,null),renderRev:this.renderRevConnect.bind(this,null)},wave:{attrs:{fill:"none",stroke:"#000000","stroke-width":1,"stroke-linejoin":"round","stroke-linecap":"round"},renderFlat:this.renderFlatConnect.bind(this,gt),renderRev:this.renderRevConnect.bind(this,gt)}},arrow:{single:{width:5,height:10,render:this.renderArrowHead.bind(this),attrs:{fill:"#000000","stroke-width":0,"stroke-linejoin":"miter"}},double:{width:4,height:6,render:this.renderArrowHead.bind(this),attrs:{fill:"none",stroke:"#000000","stroke-width":1,"stroke-linejoin":"miter"}},cross:{short:7,radius:3,render:t.crossFactory({fill:"none",stroke:"#000000","stroke-width":1})}},label:{padding:6,margin:{top:2,bottom:1},attrs:{"font-family":ht,"font-size":8,"line-height":dt,"text-anchor":"middle"},loopbackAttrs:{"font-family":ht,"font-size":8,"line-height":dt}},source:{radius:2,render:t.circleFactory({fill:"#000000",stroke:"#000000","stroke-width":1})},mask:{padding:{top:0,left:3,right:3,bottom:1}}},titleAttrs:{"font-family":ht,"font-size":20,"line-height":dt,"text-anchor":"middle",class:"title"},agentLineAttrs:{"":{fill:"none",stroke:"#000000","stroke-width":1},red:{stroke:"#CC0000"}},blocks:{ref:{margin:{top:0,bottom:0},boxRenderer:this.renderRef.bind(this,{fill:"#FFFFFF",stroke:"#000000","stroke-width":1.5,rx:2,ry:2}),section:e},"":{margin:{top:0,bottom:0},boxRenderer:t.boxFactory({fill:"none",stroke:"#000000","stroke-width":1.5,rx:2,ry:2}),collapsedBoxRenderer:this.renderRef.bind(this,{fill:"#FFFFFF",stroke:"#000000","stroke-width":1.5,rx:2,ry:2}),section:e,sepRenderer:t.lineFactory({stroke:"#000000","stroke-width":1.5,"stroke-dasharray":"4, 2"})}},notes:{text:{margin:{top:0,left:2,right:2,bottom:0},padding:{top:2,left:2,right:2,bottom:2},overlap:{left:10,right:10},boxRenderer:t.boxFactory({fill:"#FFFFFF"}),labelAttrs:ct},note:{margin:{top:0,left:5,right:5,bottom:0},padding:{top:5,left:5,right:10,bottom:5},overlap:{left:10,right:10},boxRenderer:t.noteFactory({fill:"#FFFFFF",stroke:"#000000","stroke-width":1},{fill:"none",stroke:"#000000","stroke-width":1}),labelAttrs:ct},state:{margin:{top:0,left:5,right:5,bottom:0},padding:{top:7,left:7,right:7,bottom:7},overlap:{left:10,right:10},boxRenderer:t.boxFactory({fill:"#FFFFFF",stroke:"#000000","stroke-width":1,rx:10,ry:10}),labelAttrs:ct}},dividers:{"":{labelAttrs:ut,padding:{top:2,left:5,right:5,bottom:2},extend:0,margin:0,render:()=>({})},line:{labelAttrs:ut,padding:{top:2,left:5,right:5,bottom:2},extend:10,margin:0,render:this.renderLineDivider.bind(this,{lineAttrs:{stroke:"#000000"}})},delay:{labelAttrs:ut,padding:{top:2,left:5,right:5,bottom:2},extend:0,margin:0,render:this.renderDelayDivider.bind(this,{dotSize:1,gapSize:2})},tear:{labelAttrs:ut,padding:{top:2,left:5,right:5,bottom:2},extend:10,margin:10,render:this.renderTearDivider.bind(this,{fadeBegin:5,fadeSize:10,zigWidth:6,zigHeight:1,lineAttrs:{stroke:"#000000"}})}}})}}const ft="Helvetica,Arial,Liberation Sans,sans-serif",mt=1.3,bt=new ot(10,1),yt={"font-family":ft,"font-size":8,"line-height":mt},xt={"font-family":ft,"font-size":8,"line-height":mt,"text-anchor":"middle"};class wt extends lt{constructor(t){super(t);const e={padding:{top:3,bottom:4},tag:{padding:{top:2,left:5,right:5,bottom:1},boxRenderer:this.renderTag.bind(this,{fill:"#FFFFFF",stroke:"#000000","stroke-width":2,rx:3,ry:3}),labelAttrs:{"font-family":ft,"font-weight":"bold","font-size":9,"line-height":mt,"text-anchor":"left"}},label:{minHeight:5,padding:{top:2,left:5,right:3,bottom:1},labelAttrs:{"font-family":ft,"font-size":8,"line-height":mt,"text-anchor":"left"}}};Object.assign(this,{titleMargin:12,outerMargin:5,agentMargin:8,actionMargin:5,minActionMargin:5,agentLineHighlightRadius:4,agentCap:{box:{padding:{top:1,left:3,right:3,bottom:1},arrowBottom:11.1,boxAttrs:{fill:"#FFFFFF",stroke:"#000000","stroke-width":3,rx:4,ry:4},labelAttrs:{"font-family":ft,"font-weight":"bold","font-size":14,"line-height":mt,"text-anchor":"middle"}},database:{padding:{top:4,left:3,right:3,bottom:0},arrowBottom:11.1,boxRenderer:this.renderDB.bind(this,{fill:"#FFFFFF",stroke:"#000000","stroke-width":3,"db-z":2}),labelAttrs:{"font-family":ft,"font-weight":"bold","font-size":14,"line-height":mt,"text-anchor":"middle"}},cross:{size:20,render:t.crossFactory({fill:"none",stroke:"#000000","stroke-width":3,"stroke-linecap":"round"})},bar:{height:4,render:t.boxFactory({fill:"#000000",stroke:"#000000","stroke-width":3,rx:2,ry:2})},fade:{width:5,height:10,extend:1},none:{height:10}},connect:{loopbackRadius:8,line:{solid:{attrs:{fill:"none",stroke:"#000000","stroke-width":3},renderFlat:this.renderFlatConnect.bind(this,null),renderRev:this.renderRevConnect.bind(this,null)},dash:{attrs:{fill:"none",stroke:"#000000","stroke-width":3,"stroke-dasharray":"10, 4"},renderFlat:this.renderFlatConnect.bind(this,null),renderRev:this.renderRevConnect.bind(this,null)},wave:{attrs:{fill:"none",stroke:"#000000","stroke-width":3,"stroke-linejoin":"round","stroke-linecap":"round"},renderFlat:this.renderFlatConnect.bind(this,bt),renderRev:this.renderRevConnect.bind(this,bt)}},arrow:{single:{width:10,height:12,render:this.renderArrowHead.bind(this),attrs:{fill:"#000000",stroke:"#000000","stroke-width":3,"stroke-linejoin":"round"}},double:{width:10,height:12,render:this.renderArrowHead.bind(this),attrs:{fill:"none",stroke:"#000000","stroke-width":3,"stroke-linejoin":"round","stroke-linecap":"round"}},cross:{short:10,radius:5,render:t.crossFactory({fill:"none",stroke:"#000000","stroke-width":3,"stroke-linejoin":"round","stroke-linecap":"round"})}},label:{padding:7,margin:{top:2,bottom:3},attrs:{"font-family":ft,"font-size":8,"line-height":mt,"text-anchor":"middle"},loopbackAttrs:{"font-family":ft,"font-size":8,"line-height":mt}},source:{radius:5,render:t.circleFactory({fill:"#000000",stroke:"#000000","stroke-width":3})},mask:{padding:{top:1,left:5,right:5,bottom:3}}},titleAttrs:{"font-family":ft,"font-weight":"bolder","font-size":20,"line-height":mt,"text-anchor":"middle",class:"title"},agentLineAttrs:{"":{fill:"none",stroke:"#000000","stroke-width":3},red:{stroke:"#DD0000"}},blocks:{ref:{margin:{top:0,bottom:0},boxRenderer:this.renderRef.bind(this,{fill:"#FFFFFF",stroke:"#000000","stroke-width":4,rx:5,ry:5}),section:e},"":{margin:{top:0,bottom:0},boxRenderer:t.boxFactory({fill:"none",stroke:"#000000","stroke-width":4,rx:5,ry:5}),collapsedBoxRenderer:this.renderRef.bind(this,{fill:"#FFFFFF",stroke:"#000000","stroke-width":4,rx:5,ry:5}),section:e,sepRenderer:t.lineFactory({stroke:"#000000","stroke-width":2,"stroke-dasharray":"5, 3"})}},notes:{text:{margin:{top:0,left:2,right:2,bottom:0},padding:{top:2,left:2,right:2,bottom:2},overlap:{left:10,right:10},boxRenderer:t.boxFactory({fill:"#FFFFFF"}),labelAttrs:yt},note:{margin:{top:0,left:5,right:5,bottom:0},padding:{top:3,left:3,right:10,bottom:3},overlap:{left:10,right:10},boxRenderer:t.noteFactory({fill:"#FFFFFF",stroke:"#000000","stroke-width":2,"stroke-linejoin":"round"},{fill:"none",stroke:"#000000","stroke-width":1}),labelAttrs:yt},state:{margin:{top:0,left:5,right:5,bottom:0},padding:{top:5,left:7,right:7,bottom:5},overlap:{left:10,right:10},boxRenderer:t.boxFactory({fill:"#FFFFFF",stroke:"#000000","stroke-width":3,rx:10,ry:10}),labelAttrs:yt}},dividers:{"":{labelAttrs:xt,padding:{top:2,left:5,right:5,bottom:2},extend:0,margin:0,render:()=>({})},line:{labelAttrs:xt,padding:{top:2,left:5,right:5,bottom:2},extend:10,margin:0,render:this.renderLineDivider.bind(this,{lineAttrs:{stroke:"#000000","stroke-width":2,"stroke-linecap":"round"}})},delay:{labelAttrs:xt,padding:{top:2,left:5,right:5,bottom:2},extend:0,margin:0,render:this.renderDelayDivider.bind(this,{dotSize:3,gapSize:3})},tear:{labelAttrs:xt,padding:{top:2,left:5,right:5,bottom:2},extend:10,margin:10,render:this.renderTearDivider.bind(this,{fadeBegin:5,fadeSize:10,zigWidth:6,zigHeight:1,lineAttrs:{stroke:"#000000","stroke-width":2,"stroke-linejoin":"round"}})}}})}}class kt{constructor(){this.listeners=new Map,this.forwards=new Set}addEventListener(t,e){const n=this.listeners.get(t);n?n.push(e):this.listeners.set(t,[e])}removeEventListener(t,e){const n=this.listeners.get(t);if(!n)return;const r=n.indexOf(e);-1!==r&&n.splice(r,1)}on(t,e){return this.addEventListener(t,e),this}off(t,e){return this.removeEventListener(t,e),this}countEventListeners(t){return(this.listeners.get(t)||[]).length}removeAllEventListeners(t){t?this.listeners.delete(t):this.listeners.clear()}addEventForwarding(t){this.forwards.add(t)}removeEventForwarding(t){this.forwards.delete(t)}removeAllEventForwardings(){this.forwards.clear()}trigger(t,e=[]){(this.listeners.get(t)||[]).forEach(t=>t(...e)),this.forwards.forEach(n=>n.trigger(t,e))}}const vt="undefined"==typeof window,At=!vt&&/^((?!chrome|android).)*safari/i.test(window.navigator.userAgent),Ft=!vt&&void 0!==window.InstallTrigger;class St{constructor(){this.latestSVG=null,this.latestInternalSVG=null,this.canvas=null,this.context=null,this.indexPNG=0,this.latestPNGIndex=0,this.latestPNG=null}getSVGContent(t){let e=t.dom().outerHTML;return e=e.replace(/^{this.canvas.width=r,this.canvas.height=s,this.context.drawImage(i,0,0,r,s),a&&document.body.removeChild(a),n(this.canvas)};i.addEventListener("load",()=>{a?setTimeout(o,50):o()},{once:!0}),i.src=this.getSVGURL(t)}getPNGBlob(t,e,n){this.getCanvas(t,e,t=>{t.toBlob(n,"image/png")})}getPNGURL(t,e,n){++this.indexPNG;const r=this.indexPNG;this.getPNGBlob(t,e,t=>{const e=URL.createObjectURL(t);r>=this.latestPNGIndex?(this.latestPNG&&URL.revokeObjectURL(this.latestPNG),this.latestPNG=e,this.latestPNGIndex=r,n(e,!0)):(n(e,!1),URL.revokeObjectURL(e))})}}class Mt{constructor({blocked:t=!1,covered:e=!1,group:n=null,highlighted:r=!1,locked:s=!1,visible:i=!1}={}){this.blocked=t,this.covered=e,this.group=n,this.highlighted=r,this.locked=s,this.visible=i}}Mt.LOCKED=new Mt({locked:!0}),Mt.DEFAULT=new Mt;const Rt={equals:(t,e)=>t.name===e.name,hasFlag:(t,e=!0)=>n=>n.flags.includes(t)===e},Ct={addNearby:(e,n,r,s)=>{const i=t(e,n,Ct.equals);-1===i?e.push(r):e.splice(i+s,0,r)},equals:(t,e)=>t.id===e.id,hasIntersection:(e,n)=>(function(e,n,r=null){for(let s=0;st(e,n,Ct.equals),make:(t,{anchorRight:e=!1,isVirtualSource:n=!1}={})=>({anchorRight:e,id:t,isVirtualSource:n,options:[]})},It={"note left":[Ct.make("[")],"note over":[Ct.make("["),Ct.make("]")],"note right":[Ct.make("]")]},Et=["[","]"],Gt={"agent begin":{check:["mode"],merge:["agentIDs"],siblings:new Set(["agent highlight"])},"agent end":{check:["mode"],merge:["agentIDs"],siblings:new Set(["agent highlight"])},"agent highlight":{check:["highlighted"],merge:["agentIDs"],siblings:new Set(["agent begin","agent end"])}},Dt=["agent begin","agent end","agent highlight","block begin","block end","connect","connect-delay-begin","connect-delay-end","note over","note right","note left","note between"];class Lt{constructor(){this.agentStates=new Map,this.agentAliases=new Map,this.activeGroups=new Map,this.gAgents=[],this.labelPattern=null,this.nextID=0,this.nesting=[],this.markers=new Set,this.currentSection=null,this.currentNest=null,this.stageHandlers={"agent begin":this.handleAgentBegin.bind(this),"agent define":this.handleAgentDefine.bind(this),"agent end":this.handleAgentEnd.bind(this),"agent options":this.handleAgentOptions.bind(this),async:this.handleAsync.bind(this),"block begin":this.handleBlockBegin.bind(this),"block end":this.handleBlockEnd.bind(this),"block split":this.handleBlockSplit.bind(this),connect:this.handleConnect.bind(this),"connect-delay-begin":this.handleConnectDelayBegin.bind(this),"connect-delay-end":this.handleConnectDelayEnd.bind(this),divider:this.handleDivider.bind(this),"group begin":this.handleGroupBegin.bind(this),"label pattern":this.handleLabelPattern.bind(this),mark:this.handleMark.bind(this),"note between":this.handleNote.bind(this),"note left":this.handleNote.bind(this),"note over":this.handleNote.bind(this),"note right":this.handleNote.bind(this)},this.expandGroupedGAgent=this.expandGroupedGAgent.bind(this),this.handleStage=this.handleStage.bind(this),this.toGAgent=this.toGAgent.bind(this),this.endGroup=this.endGroup.bind(this)}_aliasInUse(t){const e=this.agentAliases.get(t);return!(!e||e===t)||this.gAgents.some(e=>e.id===t)}toGAgent({name:t,alias:e,flags:n}){if(e){if(this.agentAliases.has(t))throw new Error("Cannot alias "+t+"; it is already an alias");if(this._aliasInUse(e))throw new Error("Cannot use "+e+" as an alias; it is already in use");this.agentAliases.set(e,t)}return Ct.make(this.agentAliases.get(t)||t,{isVirtualSource:n.includes("source")})}addStage(t,{isVisible:e=!0,parallel:n=!1}={}){if(!t)return;e&&(this.currentNest.hasContent=!0),void 0===t.ln&&(t.ln=this.latestLine);const{stages:r}=this.currentSection;if(n){const e=s(r),n=p(e,t);if(n)throw new Error(n);const i=this.makeParallel([e,t]);i.ln=t.ln,--r.length,r.push(i)}else r.push(t)}addImpStage(t,{parallel:e=!1}={}){if(!t)return;void 0===t.ln&&(t.ln=this.latestLine);const{stages:n}=this.currentSection;if(e){const e=n[n.length-2];if(0===n.length)throw new Error("Nothing to run statement in parallel with");if(p(e,t))n.splice(n.length-1,0,t);else{const r=this.makeParallel([e,t]);r.ln=t.ln,n.splice(n.length-2,1,r)}}else n.push(t)}makeParallel(t){const e=[];return u(e,t),0===e.length?null:1===e.length?e[0]:(e.forEach(t=>{void 0===t.ln&&(t.ln=this.latestLine)}),{stages:e,type:"parallel"})}defineGAgents(t){e(this.currentNest.gAgents,t.filter(t=>!Et.includes(t.id)),Ct.equals),e(this.gAgents,t,Ct.equals)}getGAgentState(t){return this.agentStates.get(t.id)||Mt.DEFAULT}updateGAgentState(t,e){const n=this.agentStates.get(t.id);n?Object.assign(n,e):this.agentStates.set(t.id,new Mt(e))}replaceGAgentState(t,e){this.agentStates.set(t.id,e)}validateGAgents(t,{allowGrouped:e=!1,allowCovered:n=!1,allowVirtual:r=!1}={}){t.forEach(t=>{const s=this.getGAgentState(t),i=t.id;if(function(t){return t.blocked&&null===t.group}(s))throw new Error("Duplicate agent name: "+i);if(!n&&s.covered)throw new Error("Agent "+i+" is hidden behind group");if(!e&&null!==s.group)throw new Error("Agent "+i+" is in a group");if(!r&&t.isVirtualSource)throw new Error("Cannot use message source here");if(function(t){return t.startsWith("__")}(i))throw new Error(i+" is a reserved name")})}setGAgentVis(t,e,n,r=!1){const s=new Set,i=t.filter(t=>{if(s.has(t.id))return!1;s.add(t.id);const n=this.getGAgentState(t);if(n.locked||n.blocked){if(r)throw new Error("Cannot begin/end agent: "+t.id);return!1}return n.visible!==e});return 0===i.length?null:(i.forEach(t=>{this.updateGAgentState(t,{visible:e})}),this.defineGAgents(i),{agentIDs:i.map(t=>t.id),mode:n,type:e?"agent begin":"agent end"})}setGAgentHighlight(t,e,n=!1){const r=t.filter(t=>{const r=this.getGAgentState(t);if(r.locked||r.blocked){if(n)throw new Error("Cannot highlight agent: "+t.id);return!1}return r.visible&&r.highlighted!==e});return 0===r.length?null:(r.forEach(t=>{this.updateGAgentState(t,{highlighted:e})}),{agentIDs:r.map(t=>t.id),highlighted:e,type:"agent highlight"})}_makeSection(t,e){return{delayedConnections:new Map,header:t,stages:e}}_checkSectionEnd(){const t=this.currentSection.delayedConnections;if(t.size>0){const e=t.values().next().value;throw new Error('Unused delayed connection "'+e.tag+'" at line '+(e.ln+1))}}beginNested(t,{tag:e,label:n,name:r,ln:s}){const i=Ct.make(r+"[",{anchorRight:!0}),a=Ct.make(r+"]"),o=[i,a],l=[];return this.currentSection=this._makeSection({blockType:t,canHide:!0,label:this.textFormatter(n),left:i.id,ln:s,right:a.id,tag:this.textFormatter(e),type:"block begin"},l),this.currentNest={blockType:t,gAgents:o,hasContent:!1,leftGAgent:i,rightGAgent:a,sections:[this.currentSection]},this.replaceGAgentState(i,Mt.LOCKED),this.replaceGAgentState(a,Mt.LOCKED),this.nesting.push(this.currentNest),{stages:l}}nextBlockName(){const t="__BLOCK"+this.nextID;return++this.nextID,t}nextVirtualAgentName(){const t="__"+this.nextID;return++this.nextID,t}handleBlockBegin({ln:t,blockType:e,tag:n,label:r,parallel:s}){if(s)throw new Error("Cannot use parallel here");this.beginNested(e,{label:r,ln:t,name:this.nextBlockName(),tag:n})}handleBlockSplit({ln:t,blockType:e,tag:n,label:r,parallel:s}){if(s)throw new Error("Cannot use parallel here");if("if"!==this.currentNest.blockType)throw new Error('Invalid block nesting ("else" inside '+this.currentNest.blockType+")");this._checkSectionEnd(),this.currentSection=this._makeSection({blockType:e,label:this.textFormatter(r),left:this.currentNest.leftGAgent.id,ln:t,right:this.currentNest.rightGAgent.id,tag:this.textFormatter(n),type:"block split"},[]),this.currentNest.sections.push(this.currentSection)}handleBlockEnd({parallel:t}){if(this.nesting.length<=1)throw new Error('Invalid block nesting (too many "end"s)');this._checkSectionEnd();const e=this.nesting.pop();if(this.currentNest=s(this.nesting),this.currentSection=s(this.currentNest.sections),!e.hasContent)throw new Error("Empty block");this.defineGAgents(e.gAgents),m(this.gAgents,e.leftGAgent,e.rightGAgent,e.gAgents),e.sections.forEach(t=>{this.currentSection.stages.push(t.header),this.currentSection.stages.push(...t.stages)}),this.addStage({left:e.leftGAgent.id,right:e.rightGAgent.id,type:"block end"},{parallel:t})}makeGroupDetails(t,e){const r=t.map(this.toGAgent);if(this.validateGAgents(r),this.agentStates.has(e))throw new Error("Duplicate agent name: "+e);const s=this.nextBlockName(),i=Ct.make(s+"[",{anchorRight:!0}),a=Ct.make(s+"]");this.replaceGAgentState(i,Mt.LOCKED),this.replaceGAgentState(a,Mt.LOCKED),this.updateGAgentState(Ct.make(e),{blocked:!0,group:e}),this.defineGAgents([...r,i,a]);const{indexL:o,indexR:l}=m(this.gAgents,i,a,r),h=[],d=r.slice();for(let t=o+1;t{this.updateGAgentState(t,{group:s})}),a.gAgentsCovered.forEach(t=>{this.updateGAgentState(t,{covered:!0})}),this.activeGroups.set(s,a),this.addImpStage(this.setGAgentVis(a.gAgents,!0,"box"),{parallel:i}),this.addStage({blockType:e,canHide:!1,label:this.textFormatter(r),left:a.leftGAgent.id,right:a.rightGAgent.id,tag:this.textFormatter(n),type:"block begin"},{parallel:i})}endGroup({name:t}){const e=this.activeGroups.get(t);return e?(this.activeGroups.delete(t),e.gAgentsContained.forEach(t=>{this.updateGAgentState(t,{group:null})}),e.gAgentsCovered.forEach(t=>{this.updateGAgentState(t,{covered:!1})}),this.updateGAgentState(Ct.make(t),{group:null}),{left:e.leftGAgent.id,right:e.rightGAgent.id,type:"block end"}):null}handleMark({name:t,parallel:e}){this.markers.add(t),this.addStage({name:t,type:"mark"},{isVisible:!1,parallel:e})}handleDivider({mode:t,height:e,label:n,parallel:r}){this.addStage({formattedLabel:this.textFormatter(n),height:e,mode:t,type:"divider"},{isVisible:!1,parallel:r})}handleAsync({target:t,parallel:e}){if(""!==t&&!this.markers.has(t))throw new Error("Unknown marker: "+t);this.addStage({target:t,type:"async"},{isVisible:!1,parallel:e})}handleLabelPattern({pattern:t}){this.labelPattern=t.slice();for(let t=0;t{"string"==typeof t?e+=t:void 0!==t.token?e+=n[t.token]:void 0!==t.current&&(e+=t.current.toFixed(t.dp),t.current+=t.inc)}),e}expandGroupedGAgent(t){const{group:e}=this.getGAgentState(t);if(!e)return[t];const n=this.activeGroups.get(e);return[n.leftGAgent,n.rightGAgent]}expandGroupedGAgentConnection(t){const e=this.expandGroupedGAgent(t[0]),n=this.expandGroupedGAgent(t[1]);let r=Ct.indexOf(this.gAgents,e[0]),i=Ct.indexOf(this.gAgents,n[0]);return-1===r&&(r=e[0].isVirtualSource?-1:this.gAgents.length),-1===i&&(i=this.gAgents.length),r===i?[s(e),s(n)]:r!t.isVirtualSource));const s=t.filter(Rt.hasFlag("begin",!1)).map(this.toGAgent).filter(t=>!t.isVirtualSource);return this.addImpStage(this.setGAgentVis(s,!0,"box"),{parallel:e}),{flags:n,gAgents:r}}_makeConnectParallelStages(t,e){return this.makeParallel([this.setGAgentVis(t.beginGAgents,!0,"box",!0),this.setGAgentHighlight(t.startGAgents,!0,!0),e,this.setGAgentHighlight(t.stopGAgents,!1,!0),this.setGAgentVis(t.endGAgents,!1,"cross",!0)])}_isSelfConnect(t){const e=t.map(this.toGAgent),n=this.expandGroupedGAgentConnection(e);return n[0].id===n[1].id&&!n.some(t=>t.isVirtualSource)}handleConnect({agents:t,label:e,options:n,parallel:r}){if(this._isSelfConnect(t)){const s={};return this.handleConnectDelayBegin({agent:t[0],ln:0,options:n,parallel:r,tag:s}),void this.handleConnectDelayEnd({agent:t[1],label:e,options:n,tag:s})}let{flags:s,gAgents:i}=this._handlePartialConnect(t,r);i=this.expandGroupedGAgentConnection(i);const a={agentIDs:(i=this.expandVirtualSourceAgents(i)).map(t=>t.id),label:this.textFormatter(this.applyLabelPattern(e)),options:n,type:"connect"};this.addStage(this._makeConnectParallelStages(s,a),{parallel:r})}handleConnectDelayBegin({agent:t,tag:e,options:n,ln:r,parallel:s}){const i=this.currentSection.delayedConnections;if(i.has(e))throw new Error('Duplicate delayed connection "'+e+'"');const{flags:a,gAgents:o}=this._handlePartialConnect([t],s),l=this.nextVirtualAgentName(),h={agentIDs:null,label:null,options:n,tag:l,type:"connect-delay-begin"};i.set(e,{connectStage:h,gAgents:o,ln:r,tag:e,uniqueTag:l}),this.addStage(this._makeConnectParallelStages(a,h),{parallel:s})}handleConnectDelayEnd({agent:t,tag:e,label:n,options:r,parallel:s}){const i=this.currentSection.delayedConnections,a=i.get(e);if(!a)throw new Error('Unknown delayed connection "'+e+'"');let{flags:o,gAgents:l}=this._handlePartialConnect([t],s);l=this.expandGroupedGAgentConnection([...a.gAgents,...l]),l=this.expandVirtualSourceAgents(l);let h=a.connectStage.options;if(h.line!==r.line)throw new Error("Mismatched delayed connection arrows");r.right&&(h=Object.assign({},h,{right:r.right})),Object.assign(a.connectStage,{agentIDs:l.map(t=>t.id),label:this.textFormatter(this.applyLabelPattern(n)),options:h});const d={tag:a.uniqueTag,type:"connect-delay-end"};this.addStage(this._makeConnectParallelStages(o,d),{parallel:s}),i.delete(e)}handleNote({type:t,agents:e,mode:n,label:r,parallel:s}){let i=null;i=0===e.length?It[t]||[]:e.map(this.toGAgent),this.validateGAgents(i,{allowGrouped:!0});const o=(i=a(i,this.expandGroupedGAgent)).map(t=>t.id),l=new Set(o).size;if("note between"===t&&l<2)throw new Error("note between requires at least 2 agents");this.defineGAgents(i),this.addImpStage(this.setGAgentVis(i,!0,"box"),{parallel:s}),this.addStage({agentIDs:o,label:this.textFormatter(r),mode:n,type:t},{parallel:s})}handleAgentDefine({agents:t}){const n=t.map(this.toGAgent);this.validateGAgents(n,{allowCovered:!0,allowGrouped:!0}),e(this.gAgents,n,Ct.equals)}handleAgentOptions({agent:t,options:n}){const r=this.toGAgent(t),s=[r];this.validateGAgents(s,{allowCovered:!0,allowGrouped:!0}),e(this.gAgents,s,Ct.equals),this.gAgents.filter(({id:t})=>t===r.id).forEach(t=>{e(t.options,n)})}handleAgentBegin({agents:t,mode:e,parallel:n}){const r=t.map(this.toGAgent);this.validateGAgents(r),this.addStage(this.setGAgentVis(r,!0,e,!0),{parallel:n})}handleAgentEnd({agents:t,mode:e,parallel:n}){const r=t.filter(t=>this.activeGroups.has(t.name)),s=t.filter(t=>!this.activeGroups.has(t.name)).map(this.toGAgent);this.validateGAgents(s),this.addStage(this.makeParallel([this.setGAgentHighlight(s,!1),this.setGAgentVis(s,!1,e,!0),...r.map(this.endGroup)]),{parallel:n})}handleStage(t){this.latestLine=t.ln;try{const e=this.stageHandlers[t.type];if(!e)throw new Error("Unknown command: "+t.type);e(t)}catch(e){if("object"==typeof e&&e.message)throw e.message+=" at line "+(t.ln+1),e}}_reset(){this.agentStates.clear(),this.markers.clear(),this.agentAliases.clear(),this.activeGroups.clear(),this.gAgents.length=0,this.nextID=0,this.nesting.length=0,this.labelPattern=[{token:"label"}]}_finalise(t){m(this.gAgents,this.currentNest.leftGAgent,this.currentNest.rightGAgent),function(t){let e=[],n=new Set;for(let r=0;r{t.formattedLabel=this.textFormatter(t.id)})}generate({stages:t,meta:e={}}){this._reset(),this.textFormatter=e.textFormatter;const n=this.beginNested("global",{label:"",ln:0,name:"",tag:""});if(t.forEach(this.handleStage),1!==this.nesting.length)throw new Error("Unterminated section at line "+(this.currentSection.header.ln+1));if(this.activeGroups.size>0)throw new Error("Unterminated group");this._checkSectionEnd();const r=e.terminators||"none";return this.addStage(this.makeParallel([this.setGAgentHighlight(this.gAgents,!1),this.setGAgentVis(this.gAgents,!1,r)])),this._finalise(n),function(t,e){for(let n=0;n({})},line:{labelAttrs:Bt,padding:{top:2,left:5,right:5,bottom:2},extend:8,margin:0,render:this.renderLineDivider.bind(this,{lineAttrs:{stroke:"#000000"}})},delay:{labelAttrs:Bt,padding:{top:2,left:5,right:5,bottom:2},extend:0,margin:0,render:this.renderDelayDivider.bind(this,{dotSize:2,gapSize:2})},tear:{labelAttrs:Bt,padding:{top:2,left:5,right:5,bottom:2},extend:8,margin:8,render:this.renderTearDivider.bind(this,{fadeBegin:4,fadeSize:4,zigWidth:4,zigHeight:1,lineAttrs:{stroke:"#000000"}})}}})}}const Ht={type:"error line-error",suggest:[],then:{"":0}},Pt=["database","red"],jt=["begin","end","note","state","text"],qt=(()=>{function t(t,e=1){return{type:"variable",suggest:[{known:"Agent"}],then:Object.assign({},t,{"":0,",":{type:"operator",then:{"":e}}})}}function e(t){return{type:"keyword",suggest:[t+" of ",t+": "],then:{of:{type:"keyword",then:{"":l}},":":{type:"operator",then:{"":i}},"":l}}}function n({exit:t,sourceExit:e,blankExit:n}){const r={type:"operator",then:{"+":Ht,"-":Ht,"*":Ht,"!":Ht,"":t}};return{"+":{type:"operator",then:{"+":Ht,"-":Ht,"*":r,"!":Ht,"":t}},"-":{type:"operator",then:{"+":Ht,"-":Ht,"*":r,"!":{type:"operator",then:{"+":Ht,"-":Ht,"*":Ht,"!":Ht,"":t}},"":t}},"*":{type:"operator",then:Object.assign({"+":r,"-":r,"*":Ht,"!":Ht,"":t},e||t)},"!":r,"":n||t}}const r={type:"",suggest:["\n"],then:{}},s={type:"",suggest:[],then:{}},i=b({"\n":r}),a={type:"operator",then:{"":i,"\n":s}},o=t({"\n":r,as:{type:"keyword",then:{"":{type:"variable",suggest:[{known:"Agent"}],then:{"":0,",":{type:"operator",then:{"":3}},"\n":r}}}}}),l=t({":":a}),h={type:"variable",suggest:[{known:"Agent"}],then:{"":0,":":{type:"operator",then:{"":i,"\n":s}},"\n":r}},d={":":{type:"operator",then:{"":b({as:{type:"keyword",then:{"":{type:"variable",suggest:[{known:"Agent"}],then:{"":0,"\n":r}}}}})}}},g={type:"keyword",then:Object.assign({over:{type:"keyword",then:{"":t(d)}}},d)},c={"\n":r,":":{type:"operator",then:{"":i,"\n":s}},with:{type:"keyword",suggest:["with height "],then:{height:{type:"keyword",then:{"":{type:"number",suggest:["6 ","30 "],then:{"\n":r,":":{type:"operator",then:{"":i,"\n":s}}}}}}}}},u=function(t,e,n){const r=Object.assign({},n);return e.forEach(e=>{r[e]={type:t,then:n}}),r}("keyword",["a","an"],function(t,e,n){const r={},s=Object.assign({},n);return e.forEach(e=>{r[e]={type:t,then:s},s[e]=0}),r}("keyword",Pt,{"\n":r})),p={type:"keyword",then:{"":i,":":{type:"operator",then:{"":i}},"\n":r}},f={title:{type:"keyword",then:{"":i}},theme:{type:"keyword",then:{"":{type:"string",suggest:[{global:"themes",suffix:"\n"}],then:{"":0,"\n":r}}}},headers:{type:"keyword",then:{none:{type:"keyword",then:{}},cross:{type:"keyword",then:{}},box:{type:"keyword",then:{}},fade:{type:"keyword",then:{}},bar:{type:"keyword",then:{}}}},terminators:{type:"keyword",then:{none:{type:"keyword",then:{}},cross:{type:"keyword",then:{}},box:{type:"keyword",then:{}},fade:{type:"keyword",then:{}},bar:{type:"keyword",then:{}}}},divider:{type:"keyword",then:Object.assign({line:{type:"keyword",then:c},space:{type:"keyword",then:c},delay:{type:"keyword",then:c},tear:{type:"keyword",then:c}},c)},define:{type:"keyword",then:{"":o,as:Ht}},begin:{type:"keyword",then:{"":o,reference:g,as:Ht}},end:{type:"keyword",then:{"":o,as:Ht,"\n":r}},if:p,else:{type:"keyword",suggest:["else\n","else if: "],then:{if:{type:"keyword",suggest:["if: "],then:{"":i,":":{type:"operator",then:{"":i}}}},"\n":r}},repeat:p,group:p,note:{type:"keyword",then:{over:{type:"keyword",then:{"":l}},left:e("left"),right:e("right"),between:{type:"keyword",then:{"":t({":":Ht},l)}}}},state:{type:"keyword",suggest:["state over "],then:{over:{type:"keyword",then:{"":{type:"variable",suggest:[{known:"Agent"}],then:{"":0,",":Ht,":":a}}}}}},text:{type:"keyword",then:{left:e("left"),right:e("right")}},autolabel:{type:"keyword",then:{off:{type:"keyword",then:{}},"":b({"\n":r},[{v:"