diff --git a/README.md b/README.md index d622e3f..5f23247 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Goblin -> Bowie: What babe? Bowie -> Goblin: The babe with the power Goblin -> Bowie: What power? note right of Bowie, Goblin: Most people get muddled here! -Bowie -> Goblin: 'The power of voodoo' +Bowie -> Goblin: "The power of voodoo" Goblin -> Bowie: "Who-do?" Bowie -> Goblin: You do! Goblin -> Bowie: Do what? @@ -85,7 +85,7 @@ note over Foo, Bar: "Foo and Bar on multiple lines" note between Foo, Bar: Link -text right: 'Comments\nOver here!' +text right: "Comments\nOver here!" state over Foo: Foo is ponderous ``` @@ -133,19 +133,19 @@ A <- ]: Profit! Multiline Text preview ``` -title 'My Multiline -Title' +title "My Multiline +Title" -note over Foo: 'Also possible\nwith escapes' +note over Foo: "Also possible\nwith escapes" -Foo -> Bar: 'Lines of text\non this arrow' +Foo -> Bar: "Lines of text\non this arrow" -if 'Even multiline\ninside conditions like this' - Foo -> 'Multiline\nagent' +if "Even multiline\ninside conditions like this" + Foo -> "Multiline\nagent" end -state over Foo: 'Newlines here, -too!' +state over Foo: "Newlines here, +too!" ``` ### Themes @@ -206,13 +206,13 @@ A <- B: than writing the whole name Markdown preview ``` -define 'Name with -**bold** and _italic_' as A -define 'Also `code` -and ~strikeout~' as B +define "Name with +**bold** and _italic_" as A +define "Also `code` +and ~strikeout~" as B -A -> B: '_**basic markdown -is supported!**_' +A -> B: "_**basic markdown +is supported!**_" ``` ### Alternative Agent Ordering @@ -270,17 +270,16 @@ Comments begin with a `#` and end at the next newline: Meta data can be provided with particular keywords: ``` -title 'My title here' +title "My title here" ``` Quoting strings is usually optional, for example these are the same: ``` -title 'My title here' title "My title here" title My title here title "My title" here -title "My" 'title' "here" +title "My" "title" "here" ``` Each non-metadata line represents a step in the sequence, in order. @@ -293,7 +292,7 @@ Foo Bar -> Zig Zag: Do a thing # With quotes, this is the same as: -'Foo Bar' -> 'Zig Zag': 'Do a thing' +"Foo Bar" -> "Zig Zag": "Do a thing" ``` Blocks surround steps, and can nest: diff --git a/lib/sequence-diagram.js b/lib/sequence-diagram.js index 58e5241..f6e3e86 100644 --- a/lib/sequence-diagram.js +++ b/lib/sequence-diagram.js @@ -606,6 +606,15 @@ define('sequence/CodeMirrorMode',['core/ArrayUtilities'], (array) => { const CM_ERROR = {type: 'error line-error', then: {'': 0}}; + function suggestionsEqual(a, b) { + return ( + (a.v === b.v) && + (a.prefix === b.prefix) && + (a.suffix === b.suffix) && + (a.q === b.q) + ); + } + const makeCommands = ((() => { // The order of commands inside "then" blocks directly influences the // order they are displayed to the user in autocomplete menus. @@ -882,9 +891,9 @@ define('sequence/CodeMirrorMode',['core/ArrayUtilities'], (array) => { function cmCappedToken(token, current) { if(Object.keys(current.then).length > 0) { - return token + ' '; + return {v: token, suffix: ' ', q: false}; } else { - return token + '\n'; + return {v: token, suffix: '\n', q: false}; } } @@ -907,9 +916,9 @@ define('sequence/CodeMirrorMode',['core/ArrayUtilities'], (array) => { } else if(current.suggest === true) { return [cmCappedToken(token, current)]; } else if(Array.isArray(current.suggest)) { - return current.suggest; + return current.suggest.map((v) => ({v, q: false})); } else if(current.suggest) { - return [current.suggest]; + return [{v: current.suggest, q: false}]; } else { return null; } @@ -925,7 +934,8 @@ define('sequence/CodeMirrorMode',['core/ArrayUtilities'], (array) => { } array.mergeSets( comp, - cmGetSuggestions(state, token, current, next) + cmGetSuggestions(state, token, current, next), + suggestionsEqual ); }); return comp; @@ -939,7 +949,8 @@ define('sequence/CodeMirrorMode',['core/ArrayUtilities'], (array) => { } array.mergeSets( state['known' + locals.type], - [locals.value + ' '] + [{v: locals.value, suffix: ' ', q: true}], + suggestionsEqual ); locals.type = ''; locals.value = ''; @@ -1153,14 +1164,6 @@ define('sequence/Tokeniser',['./CodeMirrorMode'], (CMMode) => { escapeWith: unescape, baseToken: {q: true}, }, - { - start: /'/y, - end: /'/y, - escape: /\\(.)/y, - escapeWith: - unescape, - baseToken: {q: true}, - }, {start: /(?=[^ \t\r\n:+\-~*!<>,])/y, end: /(?=[ \t\r\n:+\-~*!<>,])|$/y}, { start: /(?=[\-~<])/y, @@ -5643,6 +5646,17 @@ define('sequence/CodeMirrorHints',['core/ArrayUtilities'], (array) => { const TRIMMER = /^([ \t]*)(.*)$/; const SQUASH_START = /^[ \t\r\n:,]/; const SQUASH_END = /[ \t\r\n]$/; + const REQUIRED_QUOTED = /[\r\n:,"]/; + const QUOTE_ESCAPE = /["\\]/g; + + function suggestionsEqual(a, b) { + return ( + (a.v === b.v) && + (a.prefix === b.prefix) && + (a.suffix === b.suffix) && + (a.q === b.q) + ); + } function makeRanges(cm, line, chFrom, chTo) { const ln = cm.getLine(line); @@ -5661,13 +5675,27 @@ define('sequence/CodeMirrorHints',['core/ArrayUtilities'], (array) => { return ranges; } - function makeHintItem(text, ranges) { + function wrapQuote(entry, quote) { + if(!quote && entry.q && REQUIRED_QUOTED.test(entry.v)) { + quote = '"'; + } + let inner = entry.v; + if(quote) { + inner = quote + inner.replace(QUOTE_ESCAPE, '\\$&') + quote; + } + return (entry.prefix || '') + inner + (entry.suffix || ''); + } + + function makeHintItem(entry, ranges, quote) { + const quoted = wrapQuote(entry, quote); return { - text: text, - displayText: (text === '\n') ? '' : text.trim(), - className: (text === '\n') ? 'pick-virtual' : null, - from: SQUASH_START.test(text) ? ranges.squashFrom : ranges.wordFrom, - to: SQUASH_END.test(text) ? ranges.squashTo : ranges.wordTo, + text: quoted, + displayText: (quoted === '\n') ? '' : quoted.trim(), + className: (quoted === '\n') ? 'pick-virtual' : null, + from: SQUASH_START.test(quoted) ? + ranges.squashFrom : ranges.wordFrom, + to: SQUASH_END.test(quoted) ? + ranges.squashTo : ranges.wordTo, }; } @@ -5676,14 +5704,14 @@ define('sequence/CodeMirrorHints',['core/ArrayUtilities'], (array) => { if(!identified) { return []; } - return identified.map((item) => (prefix + item + suffix)); + return identified.map((item) => ({v: item, prefix, suffix, q: true})); } function populateGlobals(suggestions, globals = {}) { for(let i = 0; i < suggestions.length;) { - if(typeof suggestions[i] === 'object') { + if(suggestions[i].global) { const identified = getGlobals(suggestions[i], globals); - array.mergeSets(suggestions, identified); + array.mergeSets(suggestions, identified, suggestionsEqual); suggestions.splice(i, 1); } else { ++ i; @@ -5691,16 +5719,29 @@ define('sequence/CodeMirrorHints',['core/ArrayUtilities'], (array) => { } } - function getHints(cm, options) { - const cur = cm.getCursor(); - const token = cm.getTokenAt(cur); + function getPartial(cur, token) { let partial = token.string; if(token.end > cur.ch) { partial = partial.substr(0, cur.ch - token.start); } const parts = TRIMMER.exec(partial); partial = parts[2]; - const from = token.start + parts[1].length; + let quote = ''; + if(partial[0] === '"') { + quote = partial[0]; + partial = partial.substr(1); + } + return { + partial, + quote, + from: token.start + parts[1].length, + }; + } + + function getHints(cm, options) { + const cur = cm.getCursor(); + const token = cm.getTokenAt(cur); + const {partial, from, quote} = getPartial(cur, token); const continuation = (cur.ch > 0 && token.state.line.length > 0); let comp = (continuation ? @@ -5716,18 +5757,22 @@ define('sequence/CodeMirrorHints',['core/ArrayUtilities'], (array) => { const ranges = makeRanges(cm, cur.line, from, token.end); let selfValid = false; const list = (comp - .filter((opt) => opt.startsWith(partial)) - .map((opt) => { - if(opt === partial + ' ' && !options.completeSingle) { + .filter(({v, q}) => (q || !quote) && v.startsWith(partial)) + .map((o) => { + if(o.v === partial + ' ' && !options.completeSingle) { selfValid = true; return null; } - return makeHintItem(opt, ranges); + return makeHintItem(o, ranges, quote); }) .filter((opt) => (opt !== null)) ); if(selfValid && list.length > 0) { - list.unshift(makeHintItem(partial + ' ', ranges)); + list.unshift(makeHintItem( + {v: partial, suffix: ' ', q: false}, + ranges, + quote + )); } return { diff --git a/lib/sequence-diagram.min.js b/lib/sequence-diagram.min.js index e9a1173..f2b86b6 100644 --- a/lib/sequence-diagram.min.js +++ b/lib/sequence-diagram.min.js @@ -1 +1 @@ -!function(){var e,t,n;!function(s){function r(e,t){return y.call(e,t)}function i(e,t){var n,s,r,i,a,o,l,h,d,g,c,u=t&&t.split("/"),p=b.map,f=p&&p["*"]||{};if(e){for(a=(e=e.split("/")).length-1,b.nodeIdCompat&&w.test(e[a])&&(e[a]=e[a].replace(w,"")),"."===e[0].charAt(0)&&u&&(e=u.slice(0,u.length-1).concat(e)),d=0;d0&&(e.splice(d-1,2),d-=2)}e=e.join("/")}if((u||f)&&p){for(d=(n=e.split("/")).length;d>0;d-=1){if(s=n.slice(0,d).join("/"),u)for(g=u.length;g>0;g-=1)if((r=p[u.slice(0,g).join("/")])&&(r=r[s])){i=r,o=d;break}if(i)break;!l&&f&&f[s]&&(l=f[s],h=d)}!i&&l&&(i=l,o=h),i&&(n.splice(0,o,i),e=n.join("/"))}return e}function a(e,t){return function(){var n=k.call(arguments,0);return"string"!=typeof n[0]&&1===n.length&&n.push(null),c.apply(s,n.concat([e,t]))}}function o(e){return function(t){f[e]=t}}function l(e){if(r(m,e)){var t=m[e];delete m[e],x[e]=!0,g.apply(s,t)}if(!r(f,e)&&!r(x,e))throw new Error("No "+e);return f[e]}function h(e){var t,n=e?e.indexOf("!"):-1;return n>-1&&(t=e.substring(0,n),e=e.substring(n+1,e.length)),[t,e]}function d(e){return e?h(e):[]}var g,c,u,p,f={},m={},b={},x={},y=Object.prototype.hasOwnProperty,k=[].slice,w=/\.js$/;u=function(e,t){var n,s=h(e),r=s[0],a=t[1];return e=s[1],r&&(n=l(r=i(r,a))),r?e=n&&n.normalize?n.normalize(e,function(e){return function(t){return i(t,e)}}(a)):i(e,a):(r=(s=h(e=i(e,a)))[0],e=s[1],r&&(n=l(r))),{f:r?r+"!"+e:e,n:e,pr:r,p:n}},p={require:function(e){return a(e)},exports:function(e){var t=f[e];return void 0!==t?t:f[e]={}},module:function(e){return{id:e,uri:"",exports:f[e],config:function(e){return function(){return b&&b.config&&b.config[e]||{}}}(e)}}},g=function(e,t,n,i){var h,g,c,b,y,k,w,A=[],v=typeof n;if(i=i||e,k=d(i),"undefined"===v||"function"===v){for(t=!t.length&&n.length?["require","exports","module"]:t,y=0;y{"use strict";return class{constructor(){this.listeners=new Map,this.forwards=new Set}addEventListener(e,t){const n=this.listeners.get(e);n?n.push(t):this.listeners.set(e,[t])}removeEventListener(e,t){const n=this.listeners.get(e);if(!n)return;const s=n.indexOf(t);-1!==s&&n.splice(s,1)}countEventListeners(e){return(this.listeners.get(e)||[]).length}removeAllEventListeners(e){e?this.listeners.delete(e):this.listeners.clear()}addEventForwarding(e){this.forwards.add(e)}removeEventForwarding(e){this.forwards.delete(e)}removeAllEventForwardings(){this.forwards.clear()}trigger(e,t=[]){(this.listeners.get(e)||[]).forEach(e=>e.apply(null,t)),this.forwards.forEach(n=>n.trigger(e,t))}}}),n("core/ArrayUtilities",[],()=>{"use strict";function e(e,t,n=null){if(null===n)return e.indexOf(t);for(let s=0;s=e.length)return void r.push(s.slice());const i=e[n];if(!Array.isArray(i))return s.push(i),t(e,n+1,s,r),void s.pop();for(let a=0;a{n.push(...t(e))}),n}}}),n("sequence/CodeMirrorMode",["core/ArrayUtilities"],e=>{"use strict";function t(e,t,n,s){return""===t?function(e,t,n){return"object"==typeof n.suggest&&n.suggest.global?[n.suggest]:"string"!=typeof n.suggest||t.suggest===n.suggest?null:e["known"+n.suggest]}(e,n,s):!0===s.suggest?[function(e,t){return Object.keys(t.then).length>0?e+" ":e+"\n"}(t,s)]:Array.isArray(s.suggest)?s.suggest:s.suggest?[s.suggest]:null}function n(n,s){const r=[],i=e.last(s);return Object.keys(i.then).forEach(a=>{let o=i.then[a];"number"==typeof o&&(o=s[s.length-o-1]),e.mergeSets(r,t(n,a,i,o))}),r}function s(t,n,s,{suggest:r,override:i}){n.type&&r!==n.type&&(i&&(n.type=i),e.mergeSets(t["known"+n.type],[n.value+" "]),n.type="",n.value=""),"string"==typeof r&&t["known"+r]&&(n.type=r,n.value&&(n.value+=s.s),n.value+=s.v)}function r(t,r,i){const o={type:"",value:""};let l=i;const h=[l];return t.line.forEach((r,i)=>{i===t.line.length-1&&(t.completions=n(t,h));const d=r.q?"":r.v,g=l.then[d]||l.then[""];"number"==typeof g?h.length-=g:h.push(g||a),l=e.last(h),s(t,o,r,l)}),r&&s(t,o,null,{}),t.nextCompletions=n(t,h),t.valid=Boolean(l.then["\n"])||0===Object.keys(l.then).length,l.type}function i(e){const t=e.baseToken||{};return{value:t.v||"",quoted:t.q||!1}}const a={type:"error line-error",then:{"":0}},o=(()=>{function e(e){return{type:"string",then:Object.assign({"":0},e)}}function t(e){return{type:"variable",suggest:"Agent",then:Object.assign({},e,{"":0,",":{type:"operator",suggest:!0,then:{"":1}}})}}function n(e){return{type:"keyword",suggest:[e+" of ",e+": "],then:{of:{type:"keyword",suggest:!0,then:{"":d}},":":{type:"operator",suggest:!0,then:{"":o}},"":d}}}function s(e,t){const n={type:"operator",suggest:!0,then:{"+":a,"-":a,"*":a,"!":a,"":e}};return{"+":{type:"operator",suggest:!0,then:{"+":a,"-":a,"*":n,"!":a,"":e}},"-":{type:"operator",suggest:!0,then:{"+":a,"-":a,"*":n,"!":{type:"operator",then:{"+":a,"-":a,"*":a,"!":a,"":e}},"":e}},"*":{type:"operator",suggest:!0,then:Object.assign({"+":n,"-":n,"*":a,"!":a,"":e},t)},"!":n,"":e}}const r={type:"",suggest:"\n",then:{}},i={type:"",then:{}},o=e({"\n":r}),l={type:"variable",suggest:"Agent",then:{"":0,"\n":r,",":{type:"operator",suggest:!0,then:{"":1}},as:{type:"keyword",suggest:!0,then:{"":{type:"variable",suggest:"Agent",then:{"":0,",":{type:"operator",suggest:!0,then:{"":3}},"\n":r}}}}}},h={type:"operator",suggest:!0,then:{"":o,"\n":i}},d=t({":":h}),g={type:"variable",suggest:"Agent",then:{"":0,",":{type:"operator",suggest:!0,then:{"":d}},":":a}},c={type:"variable",suggest:"Agent",then:{"":0,",":a,":":h}},u={type:"variable",suggest:"Agent",then:{"":0,":":{type:"operator",suggest:!0,then:{"":o,"\n":i}},"\n":r}},p={":":{type:"operator",suggest:!0,then:{"":e({as:{type:"keyword",suggest:!0,then:{"":{type:"variable",suggest:"Agent",then:{"":0,"\n":r}}}}})}}},f={type:"keyword",suggest:!0,then:Object.assign({over:{type:"keyword",suggest:!0,then:{"":t(p)}}},p)},m={title:{type:"keyword",suggest:!0,then:{"":o}},theme:{type:"keyword",suggest:!0,then:{"":{type:"string",suggest:{global:"themes",suffix:"\n"},then:{"":0,"\n":r}}}},headers:{type:"keyword",suggest:!0,then:{none:{type:"keyword",suggest:!0,then:{}},cross:{type:"keyword",suggest:!0,then:{}},box:{type:"keyword",suggest:!0,then:{}},fade:{type:"keyword",suggest:!0,then:{}},bar:{type:"keyword",suggest:!0,then:{}}}},terminators:{type:"keyword",suggest:!0,then:{none:{type:"keyword",suggest:!0,then:{}},cross:{type:"keyword",suggest:!0,then:{}},box:{type:"keyword",suggest:!0,then:{}},fade:{type:"keyword",suggest:!0,then:{}},bar:{type:"keyword",suggest:!0,then:{}}}},define:{type:"keyword",suggest:!0,then:{"":l,as:a}},begin:{type:"keyword",suggest:!0,then:{"":l,reference:f,as:a}},end:{type:"keyword",suggest:!0,then:{"":l,as:a,"\n":r}},if:{type:"keyword",suggest:!0,then:{"":o,":":{type:"operator",suggest:!0,then:{"":o}},"\n":r}},else:{type:"keyword",suggest:["else\n","else if: "],then:{if:{type:"keyword",suggest:"if: ",then:{"":o,":":{type:"operator",suggest:!0,then:{"":o}}}},"\n":r}},repeat:{type:"keyword",suggest:!0,then:{"":o,":":{type:"operator",suggest:!0,then:{"":o}},"\n":r}},note:{type:"keyword",suggest:!0,then:{over:{type:"keyword",suggest:!0,then:{"":d}},left:n("left"),right:n("right"),between:{type:"keyword",suggest:!0,then:{"":g}}}},state:{type:"keyword",suggest:"state over ",then:{over:{type:"keyword",suggest:!0,then:{"":c}}}},text:{type:"keyword",suggest:!0,then:{left:n("left"),right:n("right")}},autolabel:{type:"keyword",suggest:!0,then:{off:{type:"keyword",suggest:!0,then:{}},"":o}},simultaneously:{type:"keyword",suggest:!0,then:{":":{type:"operator",suggest:!0,then:{}},with:{type:"keyword",suggest:!0,then:{"":{type:"variable",suggest:"Label",then:{"":0,":":{type:"operator",suggest:!0,then:{}}}}}}}}};return e=>({type:"error line-error",then:Object.assign({},m,function(e){const t={type:"keyword",suggest:!0,then:s(u,{":":h,"\n":i})},n={"":0};return e.forEach(e=>n[e]=t),n[":"]={type:"operator",suggest:!0,override:"Label",then:{}},s({type:"variable",suggest:"Agent",then:n},n)}(e))})})();return class{constructor(e,t){this.tokenDefinitions=e,this.commands=o(t),this.lineComment="#"}startState(){return{currentType:-1,current:"",currentSpace:"",currentQuoted:!1,knownAgent:[],knownLabel:[],beginCompletions:n({},[this.commands]),completions:[],nextCompletions:[],valid:!0,line:[],indent:0}}_matchPattern(e,t,n){return t?(t.lastIndex=0,e.match(t,n)):null}_tokenBegin(e,t){t.currentSpace="";let n="";for(;;){if(e.eol())return!1;t.currentSpace+=n;for(let n=0;n{"use strict";function t(e,t,n){return t.lastIndex=n,t.exec(e)}function n(e){return"n"===e[1]?"\n":e[1]}function s(e,n,s){return s?function(e,n,s){if(s.escape){const r=t(e,s.escape,n);if(r)return{newBlock:null,end:!1,appendSpace:"",appendValue:s.escapeWith(r),skip:r[0].length}}const r=t(e,s.end,n);return r?{newBlock:null,end:!0,appendSpace:"",appendValue:s.includeEnd?r[0]:"",skip:r[0].length}:{newBlock:null,end:!1,appendSpace:"",appendValue:e[n],skip:1}}(e,n,s):function(e,n){for(let s=0;s,])/y,end:/(?=[ \t\r\n:+\-~*!<>,])|$/y},{start:/(?=[\-~<])/y,end:/(?=[^\-~<>x])|[\-~]x|[<>](?=x)|$/y,includeEnd:!0},{start:/,/y,baseToken:{v:","}},{start:/:/y,baseToken:{v:":"}},{start:/!/y,baseToken:{v:"!"}},{start:/\+/y,baseToken:{v:"+"}},{start:/\*/y,baseToken:{v:"*"}},{start:/\n/y,baseToken:{v:"\n"}}];class a{constructor(e){this.src=e,this.block=null,this.token=null,this.pos={i:0,ln:0,ch:0},this.reset()}isOver(){return this.pos.i>this.src.length}reset(){this.token={s:"",v:"",q:!1,b:null,e:null},this.block=null}beginToken(e){this.block=e.newBlock,Object.assign(this.token,this.block.baseToken),this.token.b=r(this.pos)}endToken(){let e=null;return this.block.omit||(this.token.e=r(this.pos),e=this.token),this.reset(),e}advance(){const e=s(this.src,this.pos.i,this.block);return e.newBlock&&this.beginToken(e),this.token.s+=e.appendSpace,this.token.v+=e.appendValue,function(e,t,n){for(let s=0;s{e.q||"\n"!==e.v?n.push(e):n.length>0&&(t.push(n),n=[])}),n.length>0&&t.push(n),t}}}),n("sequence/MarkdownParser",[],()=>{"use strict";function e(e,t,s){const r=" "+e+" ";let i=-1,a=r.length,o=0;return n.forEach(({begin:e,end:n,attrs:l},h)=>{const d=s[h]?n:e;d.lastIndex=t;const g=d.exec(r);g&&(g.indexo)&&(i=h,a=g.index,o=d.lastIndex)}),{styleIndex:i,start:a,end:o-1}}function t(e,t){if(!e)return null;const s={};return t.forEach((e,t)=>{e&&Object.assign(s,n[t].attrs)}),s}const n=[{begin:/[\s_~`]\*(?=\S)/g,end:/\S\*(?=[\s_~`])/g,attrs:{"font-style":"italic"}},{begin:/[\s*~`]_(?=\S)/g,end:/\S_(?=[\s*~`])/g,attrs:{"font-style":"italic"}},{begin:/[\s_~`]\*\*(?=\S)/g,end:/\S\*\*(?=[\s_~`])/g,attrs:{"font-weight":"bolder"}},{begin:/[\s*~`]__(?=\S)/g,end:/\S__(?=[\s*~`])/g,attrs:{"font-weight":"bolder"}},{begin:/[\s_*`]~(?=\S)/g,end:/\S~(?=[\s_*`])/g,attrs:{"text-decoration":"line-through"}},{begin:/[\s_*~.]`(?=\S)/g,end:/\S`(?=[\s_*~.])/g,attrs:{"font-family":"monospace"}}];return function(s){if(!s)return[];const r=n.map(()=>!1);let i=0,a=null;const o=[];return s.split("\n").forEach(n=>{const s=[];let l=0;for(;;){const{styleIndex:o,start:h,end:d}=e(n,l,r);if(-1===o)break;r[o]?(r[o]=!1,--i):(r[o]=!0,++i),h>l&&s.push({text:n.substring(l,h),attrs:a}),a=t(i,r),l=d}l{"use strict";function e(e){const t=s.exec(e);return t&&t[1]?t[1].length:0}function t(t){if("label"===t)return{token:"label"};const n=t.indexOf(" ");let s=null,r=null;return-1===n?(s=t,r=[]):(s=t.substr(0,n),r=t.substr(n+1).split(",")),"inc"===s?function(t){let n=1,s=1,r=0;return t[0]&&(n=Number(t[0]),r=Math.max(r,e(t[0]))),t[1]&&(s=Number(t[1]),r=Math.max(r,e(t[1]))),{start:n,inc:s,dp:r}}(r):"<"+t+">"}const n=/(.*?)<([^<>]*)>/g,s=/\.([0-9]*)/;return function(e){const s=[];let r=null,i=0;for(n.lastIndex=0;r=n.exec(e);)r[1]&&s.push(r[1]),r[2]&&s.push(t(r[2])),i=n.lastIndex;const a=e.substr(i);return a&&s.push(a),s}}),n("sequence/Parser",["core/ArrayUtilities","./Tokeniser","./MarkdownParser","./LabelPatternParser"],(e,t,n,s)=>{"use strict";function r(e,t=null){let n="";return t&&(n=" at line "+(t.b.ln+1)+", character "+t.b.ch),new Error(e+n)}function i(e,t=0,n=null){if(null===n&&(n=e.length),n<=t)return"";let s=e[t].v;for(let r=t+1;r=s)&&(h=s),n>=h&&!o)throw r("Missing agent name",function(t,n){if(n{const t=e.combine([[{tok:"",type:0},{tok:"<",type:1},{tok:"<<",type:2}],[{tok:"-",type:"solid"},{tok:"--",type:"dash"},{tok:"~",type:"wave"}],[{tok:"",type:0},{tok:">",type:1},{tok:">>",type:2},{tok:"x",type:3}]]).filter(e=>0!==e[0].type||0!==e[2].type),n=new Map;return t.forEach(e=>{n.set(e.map(e=>e.tok).join(""),{line:e[1].type,left:e[0].type,right:e[2].type})}),n})(),p={"*":{flag:"begin",allowBlankName:!0,blankNameFlag:"source"},"+":{flag:"start"},"-":{flag:"stop"},"!":{flag:"end"}},f=["none","box","cross","fade","bar"],m={text:{mode:"text",types:{left:{type:"note left",skip:["of"],min:0,max:null},right:{type:"note right",skip:["of"],min:0,max:null}}},note:{mode:"note",types:{over:{type:"note over",skip:[],min:0,max:null},left:{type:"note left",skip:["of"],min:0,max:null},right:{type:"note right",skip:["of"],min:0,max:null},between:{type:"note between",skip:[],min:2,max:null}}},state:{mode:"state",types:{over:{type:"note over",skip:[],min:1,max:1}}}},b={define:{type:"agent define"},begin:{type:"agent begin",mode:"box"},end:{type:"agent end",mode:"cross"}},x=[(e,t)=>"title"!==a(e[0])?null:(t.title=i(e,1),!0),(e,t)=>"theme"!==a(e[0])?null:(t.theme=i(e,1),!0),(e,t)=>{if("terminators"!==a(e[0]))return null;const n=a(e[1]);if(!n)throw r("Unspecified termination",e[0]);if(-1===f.indexOf(n))throw r('Unknown termination "'+n+'"',e[1]);return t.terminators=n,!0},(e,t)=>{if("headers"!==a(e[0]))return null;const n=a(e[1]);if(!n)throw r("Unspecified header",e[0]);if(-1===f.indexOf(n))throw r('Unknown header "'+n+'"',e[1]);return t.headers=n,!0},e=>{if("autolabel"!==a(e[0]))return null;let t=null;return t="off"===a(e[1])?"