UNPKG

mermaid

Version:

Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.

371 lines • 195 kB
import{a as Tr}from"./chunk-SDIBIOXT.mjs";import{a as Rr}from"./chunk-YGFIH6F6.mjs";import{b as yr,c as Sr}from"./chunk-JRPEA5MG.mjs";import"./chunk-MFYRHTYG.mjs";import"./chunk-I2GRRCP3.mjs";import"./chunk-MOTMN5Z2.mjs";import"./chunk-2Z4JPSLF.mjs";import"./chunk-JUO4FS6R.mjs";import"./chunk-F6PIGZHG.mjs";import"./chunk-7PWWD3R6.mjs";import{b as fr}from"./chunk-VZ26ENTH.mjs";import"./chunk-BZANPUPN.mjs";import{b as mr,c as gr,d as Fe,e as Er}from"./chunk-MIE3LDYP.mjs";import{q as pr}from"./chunk-YF46JFGZ.mjs";import"./chunk-ZZ52EIBP.mjs";import{$ as Pt,B as cr,T as lr,U as Ut,V as Ds,W as wt,X as Fs,Y as hr,Z as dr,j as ar,u as or}from"./chunk-VSAMGZVZ.mjs";import{b as ir,h as ur}from"./chunk-L2B47AAZ.mjs";import{a}from"./chunk-QVIEFLGF.mjs";var Oe=a(s=>s!==void 0&&s>=0,"isKnownLocation");function Ar(s,e){let t=s.lexer.tokenize(e);if(t.errors.length>0){let r=t.errors[0],i=Oe(r.offset)?r.offset:e.length,o=i+(Oe(r.length)?r.length:0);throw new Error(`Error lexing ${s.diagramType} diagram: ${r.message} at line ${r.line??1}, column ${r.column??1} [${i},${o})`)}s.parser.input=t.tokens;let n=s.entry();if(s.parser.errors.length>0)throw new Error(`Error parsing ${s.diagramType} diagram: ${s.parser.errors[0].message}`);s.visit(n)}a(Ar,"runChevrotainParse");var I={SOLID_ARROW:0,BACK_ARROW:1,LINE_SOLID:2,CIRCLE_ARROW:3,CROSS_ARROW:4,CIRCLE_ARROW_REVERSED:5,CROSS_ARROW_REVERSED:6},Or="LR";var na=ar.usecase,Bs=a(()=>({actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,symbols:new Map,direction:Or,relationshipCounter:0,noteCounter:0,accTitle:"",accDescription:"",ast:void 0,config:structuredClone(na)}),"createModel"),ra=a(s=>{if(!(s.actors instanceof Map)||!(s.useCases instanceof Map)||!(s.systemBoundaries instanceof Map)||!Array.isArray(s.relationships)||!(s.notes instanceof Map)||!(s.jsonNodes instanceof Map)||!(s.classDefs instanceof Map)||!(s.symbols instanceof Map)||!["TB","TD","BT","RL","LR"].includes(s.direction)||!Number.isSafeInteger(s.relationshipCounter)||s.relationshipCounter<0||!Number.isSafeInteger(s.noteCounter)||s.noteCounter<0||typeof s.accTitle!="string"||typeof s.accDescription!="string"||!s.config)throw new Error("Cannot commit an incomplete usecase model")},"assertCompleteModel"),L=Bs(),ia=a(()=>structuredClone(L.config),"getConfig"),aa=a(()=>L.ast,"getAST"),oa=a(s=>{let e=structuredClone(s);ra(e);let t=Ds(),n=Fs();try{Ut(e.accTitle),wt(e.accDescription),L=e}catch(r){throw Ut(t),wt(n),r}},"commit"),ca=a(()=>{L=Bs(),lr()},"clear"),la=a(()=>L.actors,"getActors"),ha=a(s=>L.actors.get(s),"getActor"),da=a(()=>L.useCases,"getUseCases"),ua=a(s=>L.useCases.get(s),"getUseCase"),pa=a(()=>L.systemBoundaries,"getSystemBoundaries"),fa=a(s=>L.systemBoundaries.get(s),"getSystemBoundary"),ma=a(()=>L.relationships,"getRelationships"),ga=a(()=>L.notes,"getNotes"),Ea=a(s=>L.notes.get(s),"getNote"),Ta=a(()=>L.jsonNodes,"getJsonNodes"),ya=a(s=>L.jsonNodes.get(s),"getJsonNode"),Sa=a(()=>L.classDefs,"getClassDefs"),Ra=a(s=>L.classDefs.get(s),"getClassDef"),Lr=a(()=>L.direction,"getDirection"),Ce=a(s=>{let e=new Map;for(let t of["default",...s]){let n=L.classDefs.get(t);if(n)for(let r of n.styles){let i=r.trim(),o=i.indexOf(":"),l=(o===-1?i:i.slice(0,o)).trim();l&&e.set(l,i)}}return[...e.values()]},"getCompiledStyles"),Aa=a(s=>s.replaceAll("~","~0").replaceAll("/","~1"),"escapeJsonPointerPart"),Cr=a(s=>typeof s=="string"?s:s===null?"null":String(s),"displayJsonScalar"),Oa=a((s,e,t=n=>n)=>{let n=[],r=a((o,l,c)=>{n.push({key:t(o),accessibleKey:t(l),value:t(c)})},"append"),i=a((o,l,c)=>{if(Array.isArray(o)){if(o.length===0){r(l,l,"[]");return}if(o.every(u=>u===null||["string","number","boolean"].includes(typeof u))){for(let[u,d]of o.entries())r(u===0?l:"",l,Cr(d));return}for(let[u,d]of o.entries())i(d,`${l}[${u}]`,`${c}/${u}`);return}if(o!==null&&typeof o=="object"){let h=o,u=e[c]??Object.keys(h);if(u.length===0){r(l,l,"{}");return}for(let d of u){let p=l?`${l}.${d}`:d;i(h[d],p,`${c}/${Aa(d)}`)}return}r(l,l,Cr(o))},"visit");return i(s,"",""),n},"flattenJsonRows"),Ca=a(s=>{switch(s.type){case"hollow":return"usecaseActorHollow";case"awesome":return"usecaseActorAwesome";case"icon":return"usecaseActorIcon";case"normal":return"usecaseActor"}},"actorShape"),La=a(s=>s.shape==="ellipse"?s.business?"usecaseBusiness":"usecaseEllipse":s.shape,"useCaseShape"),Na=a(s=>{switch(s){case I.SOLID_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point"};case I.BACK_ARROW:return{arrowTypeStart:"arrow_point",arrowTypeEnd:"none"};case I.CIRCLE_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_circle"};case I.CROSS_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_cross"};case I.CIRCLE_ARROW_REVERSED:return{arrowTypeStart:"arrow_circle",arrowTypeEnd:"none"};case I.CROSS_ARROW_REVERSED:return{arrowTypeStart:"arrow_cross",arrowTypeEnd:"none"};case I.LINE_SOLID:return{arrowTypeStart:"none",arrowTypeEnd:"none"}}},"associationMarkers"),Ia=a(s=>{switch(s.type){case"include":case"extend":return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point",pattern:"dotted",label:s.type,labelType:"text"};case"generalization":return{arrowTypeStart:"none",arrowTypeEnd:"extension",pattern:"solid"};case"association":return{...Na(s.arrowType),pattern:"solid",...s.label?{label:s.label}:{},...s.labelType?{labelType:s.labelType}:{}}}},"relationshipVisuals"),ka=a(s=>s.animate||s.animation?[`edge-animation-${s.animation??"fast"}`]:[],"animationClasses"),nt=a((...s)=>s.filter(e=>!!e).join(" "),"classNames"),ba=a(()=>{let s=Pt(),e={...L.config,...s.usecase},t=a(c=>cr(c,s),"sanitize"),n=a(c=>t(L.actors.get(c)?.label??L.useCases.get(c)?.label??L.jsonNodes.get(c)?.id??L.notes.get(c)?.label??c),"endpointLabel"),r=[],i=[],o=0,l=0;for(let c of L.actors.values())r.push({id:c.id,label:t(c.label),labelType:c.labelType,shape:Ca(c),isGroup:!1,padding:10,look:s.look,colorIndex:o++,cssClasses:nt("default","usecase-actor",`usecase-actor-${c.type}`,c.business&&"usecase-business",...c.classes),cssStyles:[...c.styles],cssCompiledStyles:Ce(c.classes),actorType:c.type,business:c.business,...c.icon?{icon:c.icon}:{},...c.stereotype?{stereotype:t(c.stereotype)}:{},...c.parentId?{parentId:c.parentId}:{}});for(let c of L.useCases.values())r.push({id:c.id,label:t(c.label),labelType:c.labelType,shape:La(c),isGroup:!1,padding:c.shape==="ellipse"?20:10,look:s.look,colorIndex:o++,cssClasses:nt("default","usecase-element",`usecase-${c.shape}`,c.business&&"usecase-business",...c.classes),cssStyles:[...c.styles],cssCompiledStyles:Ce(c.classes),business:c.business,...c.stereotype?{stereotype:t(c.stereotype)}:{},...c.parentId?{parentId:c.parentId}:{}});for(let c of L.notes.values())r.push({id:c.id,label:t(c.label),labelType:c.labelType,shape:"note",isGroup:!1,padding:10,look:s.look,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:Ce([]),noteTarget:c.target,noteTargetLabel:t(L.actors.get(c.target)?.label??L.useCases.get(c.target)?.label??L.jsonNodes.get(c.target)?.id??c.target)});for(let c of L.jsonNodes.values())r.push({id:c.id,label:t(c.id),labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,look:s.look,cssClasses:nt("default","usecase-json-table",...c.classes),cssStyles:[...c.styles],cssCompiledStyles:Ce(c.classes),jsonRows:Oa(c.value,c.propertyOrder,t)});for(let c of L.systemBoundaries.values())r.push({id:c.id,label:t(c.label),labelType:c.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,look:s.look,colorIndex:l++,cssClasses:nt("default","system-boundary",`system-boundary-${c.type}`,...c.classes),cssStyles:[...c.styles],cssCompiledStyles:Ce(c.classes),boundaryType:c.type});for(let c of L.relationships){let{label:h,...u}=Ia(c);i.push({id:c.id,start:c.source,end:c.target,source:c.source,target:c.target,sourceLabel:n(c.source),targetLabel:n(c.target),type:"edge",relationshipType:c.type,internal:!1,...u,...h!==void 0?{label:t(h)}:{},labelpos:"c",classes:nt("default","relationship",`relationship-${c.type}`,...c.classes,...ka(c)),style:[...c.styles],cssCompiledStyles:Ce(c.classes),animate:c.animate,...c.animation?{animation:c.animation}:{},look:s.look,thickness:"normal",minlen:c.minlen,isUserDefinedId:c.explicitId})}for(let c of L.notes.values())i.push({id:`${c.id}-edge`,start:c.id,end:c.target,source:c.id,target:c.target,type:"edge",relationshipType:"note",sourceLabel:n(c.id),targetLabel:n(c.target),internal:!0,pattern:"dotted",arrowTypeStart:"none",arrowTypeEnd:"none",labelpos:"c",classes:"default relationship relationship-note",style:[],cssCompiledStyles:Ce([]),animate:!1,look:s.look,thickness:"normal",minlen:1,isUserDefinedId:!1});for(let c of r)c.wrappingWidth??=e.wrappingWidth,!c.isGroup&&!c.shape.startsWith("usecaseActor")&&(c.minWidth??=e.minNodeWidth),(c.shape==="usecaseEllipse"||c.shape==="usecaseBusiness")&&(c.spreadPorts=!0);return{nodes:r,edges:i,config:s,type:"usecase",layoutAlgorithm:"dagre",direction:Lr(),nodeSpacing:e.nodeSpacing,rankSpacing:e.rankSpacing,actorFontSize:e.actorFontSize,actorFontFamily:e.actorFontFamily,actorFontWeight:e.actorFontWeight,usecaseFontSize:e.usecaseFontSize,usecaseFontFamily:e.usecaseFontFamily,usecaseFontWeight:e.usecaseFontWeight,diagramPadding:e.diagramPadding,useMaxWidth:e.useMaxWidth,markers:["point","circle","cross","extension"]}},"getData"),Le={getConfig:ia,createModel:Bs,commit:oa,getAST:aa,clear:ca,setDiagramTitle:hr,getDiagramTitle:dr,setAccTitle:Ut,getAccTitle:Ds,setAccDescription:wt,getAccDescription:Fs,getActors:la,getActor:ha,getUseCases:da,getUseCase:ua,getSystemBoundaries:pa,getSystemBoundary:fa,getRelationships:ma,getNotes:ga,getNote:Ea,getJsonNodes:Ta,getJsonNode:ya,getClassDefs:Sa,getClassDef:Ra,getDirection:Lr,getData:ba};function Be(s){console&&console.error&&console.error(`Error: ${s}`)}a(Be,"PRINT_ERROR");function rt(s){console&&console.warn&&console.warn(`Warning: ${s}`)}a(rt,"PRINT_WARNING");function it(s){let e=new Date().getTime(),t=s();return{time:new Date().getTime()-e,value:t}}a(it,"timer");function at(s){function e(){}a(e,"FakeConstructor"),e.prototype=s;let t=new e;function n(){return typeof t.bar}return a(n,"fakeAccess"),n(),n(),s;(0,eval)(s)}a(at,"toFastProperties");function xa(s){return _a(s)?s.LABEL:s.name}a(xa,"tokenLabel");function _a(s){return typeof s.LABEL=="string"&&s.LABEL!==""}a(_a,"hasTokenLabel");var ee=class{static{a(this,"AbstractProduction")}get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),this.definition.forEach(t=>{t.accept(e)})}},k=class extends ee{static{a(this,"NonTerminal")}constructor(e){super([]),this.idx=1,Object.assign(this,le(e))}set definition(e){}get definition(){return this.referencedRule!==void 0?this.referencedRule.definition:[]}accept(e){e.visit(this)}},X=class extends ee{static{a(this,"Rule")}constructor(e){super(e.definition),this.orgText="",Object.assign(this,le(e))}},b=class extends ee{static{a(this,"Alternative")}constructor(e){super(e.definition),this.ignoreAmbiguities=!1,Object.assign(this,le(e))}},x=class extends ee{static{a(this,"Option")}constructor(e){super(e.definition),this.idx=1,Object.assign(this,le(e))}},F=class extends ee{static{a(this,"RepetitionMandatory")}constructor(e){super(e.definition),this.idx=1,Object.assign(this,le(e))}},B=class extends ee{static{a(this,"RepetitionMandatoryWithSeparator")}constructor(e){super(e.definition),this.idx=1,Object.assign(this,le(e))}},N=class extends ee{static{a(this,"Repetition")}constructor(e){super(e.definition),this.idx=1,Object.assign(this,le(e))}},w=class extends ee{static{a(this,"RepetitionWithSeparator")}constructor(e){super(e.definition),this.idx=1,Object.assign(this,le(e))}},P=class extends ee{static{a(this,"Alternation")}get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){super(e.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,Object.assign(this,le(e))}},C=class{static{a(this,"Terminal")}constructor(e){this.idx=1,Object.assign(this,le(e))}accept(e){e.visit(this)}};function Dt(s){return s.map($e)}a(Dt,"serializeGrammar");function $e(s){function e(t){return t.map($e)}if(a(e,"convertDefinition"),s instanceof k){let t={type:"NonTerminal",name:s.nonTerminalName,idx:s.idx};return typeof s.label=="string"&&(t.label=s.label),t}else{if(s instanceof b)return{type:"Alternative",definition:e(s.definition)};if(s instanceof x)return{type:"Option",idx:s.idx,definition:e(s.definition)};if(s instanceof F)return{type:"RepetitionMandatory",idx:s.idx,definition:e(s.definition)};if(s instanceof B)return{type:"RepetitionMandatoryWithSeparator",idx:s.idx,separator:$e(new C({terminalType:s.separator})),definition:e(s.definition)};if(s instanceof w)return{type:"RepetitionWithSeparator",idx:s.idx,separator:$e(new C({terminalType:s.separator})),definition:e(s.definition)};if(s instanceof N)return{type:"Repetition",idx:s.idx,definition:e(s.definition)};if(s instanceof P)return{type:"Alternation",idx:s.idx,definition:e(s.definition)};if(s instanceof C){let t={type:"Terminal",name:s.terminalType.name,label:xa(s.terminalType),idx:s.idx};typeof s.label=="string"&&(t.terminalLabel=s.label);let n=s.terminalType.PATTERN;return s.terminalType.PATTERN&&(t.pattern=n instanceof RegExp?n.source:n),t}else{if(s instanceof X)return{type:"Rule",name:s.name,orgText:s.orgText,definition:e(s.definition)};throw Error("non exhaustive match")}}}a($e,"serializeProduction");function le(s){return Object.fromEntries(Object.entries(s).filter(([,e])=>e!==void 0))}a(le,"pickOnlyDefined");var Y=class{static{a(this,"GAstVisitor")}visit(e){let t=e;switch(t.constructor){case k:return this.visitNonTerminal(t);case b:return this.visitAlternative(t);case x:return this.visitOption(t);case F:return this.visitRepetitionMandatory(t);case B:return this.visitRepetitionMandatoryWithSeparator(t);case w:return this.visitRepetitionWithSeparator(t);case N:return this.visitRepetition(t);case P:return this.visitAlternation(t);case C:return this.visitTerminal(t);case X:return this.visitRule(t);default:throw Error("non exhaustive match")}}visitNonTerminal(e){}visitAlternative(e){}visitOption(e){}visitRepetition(e){}visitRepetitionMandatory(e){}visitRepetitionMandatoryWithSeparator(e){}visitRepetitionWithSeparator(e){}visitAlternation(e){}visitTerminal(e){}visitRule(e){}};function $s(s){return s instanceof b||s instanceof x||s instanceof N||s instanceof F||s instanceof B||s instanceof w||s instanceof C||s instanceof X}a($s,"isSequenceProd");function Ne(s,e=[]){return s instanceof x||s instanceof N||s instanceof w?!0:s instanceof P?s.definition.some(n=>Ne(n,e)):s instanceof k&&e.includes(s)?!1:s instanceof ee?(s instanceof k&&e.push(s),s.definition.every(n=>Ne(n,e))):!1}a(Ne,"isOptionalProd");function Gs(s){return s instanceof P}a(Gs,"isBranchingProd");function Z(s){if(s instanceof k)return"SUBRULE";if(s instanceof x)return"OPTION";if(s instanceof P)return"OR";if(s instanceof F)return"AT_LEAST_ONE";if(s instanceof B)return"AT_LEAST_ONE_SEP";if(s instanceof w)return"MANY_SEP";if(s instanceof N)return"MANY";if(s instanceof C)return"CONSUME";throw Error("non exhaustive match")}a(Z,"getProductionDslName");var fe=class{static{a(this,"RestWalker")}walk(e,t=[]){e.definition.forEach((n,r)=>{let i=e.definition.slice(r+1);if(n instanceof k)this.walkProdRef(n,i,t);else if(n instanceof C)this.walkTerminal(n,i,t);else if(n instanceof b)this.walkFlat(n,i,t);else if(n instanceof x)this.walkOption(n,i,t);else if(n instanceof F)this.walkAtLeastOne(n,i,t);else if(n instanceof B)this.walkAtLeastOneSep(n,i,t);else if(n instanceof w)this.walkManySep(n,i,t);else if(n instanceof N)this.walkMany(n,i,t);else if(n instanceof P)this.walkOr(n,i,t);else throw Error("non exhaustive match")})}walkTerminal(e,t,n){}walkProdRef(e,t,n){}walkFlat(e,t,n){let r=t.concat(n);this.walk(e,r)}walkOption(e,t,n){let r=t.concat(n);this.walk(e,r)}walkAtLeastOne(e,t,n){let r=[new x({definition:e.definition})].concat(t,n);this.walk(e,r)}walkAtLeastOneSep(e,t,n){let r=Nr(e,t,n);this.walk(e,r)}walkMany(e,t,n){let r=[new x({definition:e.definition})].concat(t,n);this.walk(e,r)}walkManySep(e,t,n){let r=Nr(e,t,n);this.walk(e,r)}walkOr(e,t,n){let r=t.concat(n);e.definition.forEach(i=>{let o=new b({definition:[i]});this.walk(o,r)})}};function Nr(s,e,t){return[new x({definition:[new C({terminalType:s.separator})].concat(s.definition)})].concat(e,t)}a(Nr,"restForRepetitionWithSeparator");function Ie(s){if(s instanceof k)return Ie(s.referencedRule);if(s instanceof C)return Ua(s);if($s(s))return va(s);if(Gs(s))return Ma(s);throw Error("non exhaustive match")}a(Ie,"first");function va(s){let e=[],t=s.definition,n=0,r=t.length>n,i,o=!0;for(;r&&o;)i=t[n],o=Ne(i),e=e.concat(Ie(i)),n=n+1,r=t.length>n;return[...new Set(e)]}a(va,"firstForSequence");function Ma(s){let e=s.definition.map(t=>Ie(t));return[...new Set(e.flat())]}a(Ma,"firstForBranching");function Ua(s){return[s.terminalType]}a(Ua,"firstForTerminal");var Ft="_~IN~_";var js=class extends fe{static{a(this,"ResyncFollowsWalker")}constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,n){}walkProdRef(e,t,n){let r=wa(e.referencedRule,e.idx)+this.topProd.name,i=t.concat(n),o=new b({definition:i}),l=Ie(o);this.follows[r]=l}};function Ir(s){let e={};return s.forEach(t=>{let n=new js(t).startWalking();Object.assign(e,n)}),e}a(Ir,"computeAllProdsFollows");function wa(s,e){return s.name+e+Ft}a(wa,"buildBetweenProdsFollowPrefix");function S(s){return s.charCodeAt(0)}a(S,"cc");function Bt(s,e){Array.isArray(s)?s.forEach(function(t){e.push(t)}):e.push(s)}a(Bt,"insertToSet");function Ge(s,e){if(s[e]===!0)throw"duplicate flag "+e;let t=s[e];s[e]=!0}a(Ge,"addFlag");function ke(s){if(s===void 0)throw Error("Internal Error - Should never get here!");return!0}a(ke,"ASSERT_EXISTS");function ot(){throw Error("Internal Error - Should never get here!")}a(ot,"ASSERT_NEVER_REACH_HERE");function Ws(s){return s.type==="Character"}a(Ws,"isCharacter");var ct=[];for(let s=S("0");s<=S("9");s++)ct.push(s);var lt=[S("_")].concat(ct);for(let s=S("a");s<=S("z");s++)lt.push(s);for(let s=S("A");s<=S("Z");s++)lt.push(s);var Ks=[S(" "),S("\f"),S(`
`),S("\r"),S("	"),S("\v"),S("	"),S("\xA0"),S("\u1680"),S("\u2000"),S("\u2001"),S("\u2002"),S("\u2003"),S("\u2004"),S("\u2005"),S("\u2006"),S("\u2007"),S("\u2008"),S("\u2009"),S("\u200A"),S("\u2028"),S("\u2029"),S("\u202F"),S("\u205F"),S("\u3000"),S("\uFEFF")];var Pa=/[0-9a-fA-F]/,$t=/[0-9]/,Da=/[1-9]/,ht=class{static{a(this,"RegExpParser")}constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar("/");let t=this.disjunction();this.consumeChar("/");let n={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case"g":Ge(n,"global");break;case"i":Ge(n,"ignoreCase");break;case"m":Ge(n,"multiLine");break;case"u":Ge(n,"unicode");break;case"y":Ge(n,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:n,value:t,loc:this.loc(0)}}disjunction(){let e=[],t=this.idx;for(e.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(t)}}alternative(){let e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){let e=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(e)};case"$":return{type:"EndAnchor",loc:this.loc(e)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(e)};case"B":return{type:"NonWordBoundary",loc:this.loc(e)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");let t;switch(this.popChar()){case"=":t="Lookahead";break;case"!":t="NegativeLookahead";break;case"<":{switch(this.popChar()){case"=":t="Lookbehind";break;case"!":t="NegativeLookbehind"}break}}ke(t);let n=this.disjunction();return this.consumeChar(")"),{type:t,value:n,loc:this.loc(e)}}return ot()}quantifier(e=!1){let t,n=this.idx;switch(this.popChar()){case"*":t={atLeast:0,atMost:1/0};break;case"+":t={atLeast:1,atMost:1/0};break;case"?":t={atLeast:0,atMost:1};break;case"{":let r=this.integerIncludingZero();switch(this.popChar()){case"}":t={atLeast:r,atMost:r};break;case",":let i;this.isDigit()?(i=this.integerIncludingZero(),t={atLeast:r,atMost:i}):t={atLeast:r,atMost:1/0},this.consumeChar("}");break}if(e===!0&&t===void 0)return;ke(t);break}if(!(e===!0&&t===void 0)&&ke(t))return this.peekChar(0)==="?"?(this.consumeChar("?"),t.greedy=!1):t.greedy=!0,t.type="Quantifier",t.loc=this.loc(n),t}atom(){let e,t=this.idx;switch(this.peekChar()){case".":e=this.dotAll();break;case"\\":e=this.atomEscape();break;case"[":e=this.characterClass();break;case"(":e=this.group();break}return e===void 0&&this.isPatternCharacter()&&(e=this.patternCharacter()),ke(e)?(e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):ot()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[S(`
`),S("\r"),S("\u2028"),S("\u2029")]}}atomEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:"GroupBackReference",value:this.positiveInteger()}}characterClassEscape(){let e,t=!1;switch(this.popChar()){case"d":e=ct;break;case"D":e=ct,t=!0;break;case"s":e=Ks;break;case"S":e=Ks,t=!0;break;case"w":e=lt;break;case"W":e=lt,t=!0;break}return ke(e)?{type:"Set",value:e,complement:t}:ot()}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=S("\f");break;case"n":e=S(`
`);break;case"r":e=S("\r");break;case"t":e=S("	");break;case"v":e=S("\v");break}return ke(e)?{type:"Character",value:e}:ot()}controlLetterEscapeAtom(){this.consumeChar("c");let e=this.popChar();if(/[a-zA-Z]/.test(e)===!1)throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:S("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){let e=this.popChar();return{type:"Character",value:S(e)}}classPatternCharacterAtom(){switch(this.peekChar()){case`
`:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:let e=this.popChar();return{type:"Character",value:S(e)}}}characterClass(){let e=[],t=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),t=!0);this.isClassAtom();){let n=this.classAtom(),r=n.type==="Character";if(Ws(n)&&this.isRangeDash()){this.consumeChar("-");let i=this.classAtom(),o=i.type==="Character";if(Ws(i)){if(i.value<n.value)throw Error("Range out of order in character class");e.push({from:n.value,to:i.value})}else Bt(n.value,e),e.push(S("-")),Bt(i.value,e)}else Bt(n.value,e)}return this.consumeChar("]"),{type:"Set",complement:t,value:e}}classAtom(){switch(this.peekChar()){case"]":case`
`:case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}}classEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:S("\b")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}group(){let e=!0;switch(this.consumeChar("("),this.peekChar(0)){case"?":this.consumeChar("?"),this.consumeChar(":"),e=!1;break;default:this.groupIdx++;break}let t=this.disjunction();this.consumeChar(")");let n={type:"Group",capturing:e,value:t};return e&&(n.idx=this.groupIdx),n}positiveInteger(){let e=this.popChar();if(Da.test(e)===!1)throw Error("Expecting a positive integer");for(;$t.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if($t.test(e)===!1)throw Error("Expecting an integer");for(;$t.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){let e=this.popChar();switch(e){case`
`:case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:S(e)}}}isRegExpFlag(){switch(this.peekChar(0)){case"g":case"i":case"m":case"u":case"y":return!0;default:return!1}}isRangeDash(){return this.peekChar()==="-"&&this.isClassAtom(1)}isDigit(){return $t.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case"]":case`
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}isTerm(){return this.isAtom()||this.isAssertion()}isAtom(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}}isAssertion(){switch(this.peekChar(0)){case"^":case"$":return!0;case"\\":switch(this.peekChar(1)){case"b":case"B":return!0;default:return!1}case"(":return this.peekChar(1)==="?"&&(this.peekChar(2)==="="||this.peekChar(2)==="!"||this.peekChar(2)==="<"&&(this.peekChar(3)==="="||this.peekChar(3)==="!"));default:return!1}}isQuantifier(){let e=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case`
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(e){let t="";for(let r=0;r<e;r++){let i=this.popChar();if(Pa.test(i)===!1)throw Error("Expecting a HexDecimal digits");t+=i}return{type:"Character",value:parseInt(t,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){let e=this.peekChar(0);return this.consumeChar(void 0),e}consumeChar(e){if(e!==void 0&&this.input[this.idx]!==e)throw Error("Expected: '"+e+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++}loc(e){return{begin:e,end:this.idx}}};var ye=class{static{a(this,"BaseRegExpVisitor")}visitChildren(e){for(let t in e){let n=e[t];e.hasOwnProperty(t)&&(n.type!==void 0?this.visit(n):Array.isArray(n)&&n.forEach(r=>{this.visit(r)},this))}}visit(e){switch(e.type){case"Pattern":this.visitPattern(e);break;case"Flags":this.visitFlags(e);break;case"Disjunction":this.visitDisjunction(e);break;case"Alternative":this.visitAlternative(e);break;case"StartAnchor":this.visitStartAnchor(e);break;case"EndAnchor":this.visitEndAnchor(e);break;case"WordBoundary":this.visitWordBoundary(e);break;case"NonWordBoundary":this.visitNonWordBoundary(e);break;case"Lookahead":this.visitLookahead(e);break;case"NegativeLookahead":this.visitNegativeLookahead(e);break;case"Lookbehind":this.visitLookbehind(e);break;case"NegativeLookbehind":this.visitNegativeLookbehind(e);break;case"Character":this.visitCharacter(e);break;case"Set":this.visitSet(e);break;case"Group":this.visitGroup(e);break;case"GroupBackReference":this.visitGroupBackReference(e);break;case"Quantifier":this.visitQuantifier(e);break}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitLookbehind(e){}visitNegativeLookbehind(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}};var Gt={},Fa=new ht;function be(s){let e=s.toString();if(Gt.hasOwnProperty(e))return Gt[e];{let t=Fa.pattern(e);return Gt[e]=t,t}}a(be,"getRegExpAst");function kr(){Gt={}}a(kr,"clearRegExpParserCache");var xr="Complement Sets are not supported for first char optimization",dt=`Unable to use "first char" lexer optimizations:
`;function _r(s,e=!1){try{let t=be(s);return Vs(t.value,{},t.flags.ignoreCase)}catch(t){if(t.message===xr)e&&rt(`${dt}	Unable to optimize: < ${s.toString()} >
	Complement Sets cannot be automatically optimized.
	This will disable the lexer's first char optimizations.
	See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n="";e&&(n=`
	This will disable the lexer's first char optimizations.
	See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),Be(`${dt}
	Failed parsing: < ${s.toString()} >
	Using the @chevrotain/regexp-to-ast library
	Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}a(_r,"getOptimizedStartCodesIndices");function Vs(s,e,t){switch(s.type){case"Disjunction":for(let r=0;r<s.value.length;r++)Vs(s.value[r],e,t);break;case"Alternative":let n=s.value;for(let r=0;r<n.length;r++){let i=n[r];switch(i.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"Lookbehind":case"NegativeLookbehind":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}let o=i;switch(o.type){case"Character":jt(o.value,e,t);break;case"Set":if(o.complement===!0)throw Error(xr);o.value.forEach(c=>{if(typeof c=="number")jt(c,e,t);else{let h=c;if(t===!0)for(let u=h.from;u<=h.to;u++)jt(u,e,t);else{for(let u=h.from;u<=h.to&&u<je;u++)jt(u,e,t);if(h.to>=je){let u=h.from>=je?h.from:je,d=h.to,p=he(u),g=he(d);for(let R=p;R<=g;R++)e[R]=R}}}});break;case"Group":Vs(o.value,e,t);break;default:throw Error("Non Exhaustive Match")}let l=o.quantifier!==void 0&&o.quantifier.atLeast===0;if(o.type==="Group"&&zs(o)===!1||o.type!=="Group"&&l===!1)break}break;default:throw Error("non exhaustive match!")}return Object.values(e)}a(Vs,"firstCharOptimizedIndices");function jt(s,e,t){let n=he(s);e[n]=n,t===!0&&Ba(s,e)}a(jt,"addOptimizedIdxToResult");function Ba(s,e){let t=String.fromCharCode(s),n=t.toUpperCase();if(n!==t){let r=he(n.charCodeAt(0));e[r]=r}else{let r=t.toLowerCase();if(r!==t){let i=he(r.charCodeAt(0));e[i]=i}}}a(Ba,"handleIgnoreCase");function br(s,e){return s.value.find(t=>{if(typeof t=="number")return e.includes(t);{let n=t;return e.find(r=>n.from<=r&&r<=n.to)!==void 0}})}a(br,"findCode");function zs(s){let e=s.quantifier;return e&&e.atLeast===0?!0:s.value?Array.isArray(s.value)?s.value.every(zs):zs(s.value):!1}a(zs,"isWholeOptional");var Hs=class extends ye{static{a(this,"CharCodeFinder")}constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found!==!0){switch(e.type){case"Lookahead":this.visitLookahead(e);return;case"NegativeLookahead":this.visitNegativeLookahead(e);return;case"Lookbehind":this.visitLookbehind(e);return;case"NegativeLookbehind":this.visitNegativeLookbehind(e);return}super.visitChildren(e)}}visitCharacter(e){this.targetCharCodes.includes(e.value)&&(this.found=!0)}visitSet(e){e.complement?br(e,this.targetCharCodes)===void 0&&(this.found=!0):br(e,this.targetCharCodes)!==void 0&&(this.found=!0)}};function Wt(s,e){if(e instanceof RegExp){let t=be(e),n=new Hs(s);return n.visit(t),n.found}else{for(let t of e){let n=t.charCodeAt(0);if(s.includes(n))return!0}return!1}}a(Wt,"canMatchCharCode");var xe="PATTERN",We="defaultMode",Kt="modes",zt=0,ut=1,Ht=2,Xt=3;function Mr(s,e){e=Object.assign({safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
`],tracer:a((E,f)=>f(),"tracer")},e);let t=e.tracer;t("initCharCodeToOptimizedIndexMap",()=>{io()});let n;t("Reject Lexer.NA",()=>{n=s.filter(E=>E[xe]!==v.NA)});let r=!1,i;t("Transform Patterns",()=>{r=!1,i=n.map(E=>{let f=E[xe];if(f instanceof RegExp){let m=f.source;return m.length===1&&m!=="^"&&m!=="$"&&m!=="."&&!f.ignoreCase?m:m.length===2&&m[0]==="\\"&&!["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"].includes(m[1])?m[1]:vr(f)}else{if(typeof f=="function")return r=!0,{exec:f};if(typeof f=="object")return r=!0,f;if(typeof f=="string"){if(f.length===1)return f;{let m=f.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),D=new RegExp(m);return vr(D)}}else throw Error("non exhaustive match")}})});let o,l,c,h,u;t("misc mapping",()=>{o=n.map(E=>E.tokenTypeIdx),l=n.map(E=>{let f=E.GROUP;if(f!==v.SKIPPED){if(typeof f=="string")return f;if(f===void 0)return!1;throw Error("non exhaustive match")}}),c=n.map(E=>{let f=E.LONGER_ALT;if(f)return Array.isArray(f)?f.map(D=>n.indexOf(D)):[n.indexOf(f)]}),h=n.map(E=>E.PUSH_MODE),u=n.map(E=>Object.hasOwn(E,"POP_MODE"))});let d;t("Line Terminator Handling",()=>{let E=$r(e.lineTerminatorCharacters);d=n.map(f=>!1),e.positionTracking!=="onlyOffset"&&(d=n.map(f=>Object.hasOwn(f,"LINE_BREAKS")?!!f.LINE_BREAKS:Br(f,E)===!1&&Wt(E,f.PATTERN)))});let p,g,R,A;t("Misc Mapping #2",()=>{p=n.map(Dr),g=i.map(no),R=n.reduce((E,f)=>{let m=f.GROUP;return typeof m=="string"&&m!==v.SKIPPED&&(E[m]=[]),E},{}),A=i.map((E,f)=>{let m=l[f]===void 0&&c[f]===void 0?$a(n[f].PATTERN):void 0;return{pattern:i[f],asciiClass:m,longerAlt:c[f],canLineTerminator:d[f],matchType:m!==void 0?Xt:g[f]!==!1?zt:p[f]?ut:Ht,short:g[f],group:l[f],push:h[f],pop:u[f],tokenTypeIdx:o[f],tokenType:n[f]}})});let O=!0,T=[];return e.safeMode||t("First Char Optimization",()=>{T=n.reduce((E,f,m)=>{if(typeof f.PATTERN=="string"){let D=f.PATTERN.charCodeAt(0),ae=he(D);Xs(E,ae,A[m])}else if(Array.isArray(f.START_CHARS_HINT)){let D;f.START_CHARS_HINT.forEach(ae=>{let Te=typeof ae=="string"?ae.charCodeAt(0):ae,Re=he(Te);D!==Re&&(D=Re,Xs(E,Re,A[m]))})}else if(f.PATTERN instanceof RegExp)if(f.PATTERN.unicode)O=!1,e.ensureOptimizations&&Be(`${dt}	Unable to analyze < ${f.PATTERN.toString()} > pattern.
	The regexp unicode flag is not currently supported by the regexp-to-ast library.
	This will disable the lexer's first char optimizations.
	For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let D=_r(f.PATTERN,e.ensureOptimizations);D.length===0&&(O=!1),D.forEach(ae=>{Xs(E,ae,A[m])})}else e.ensureOptimizations&&Be(`${dt}	TokenType: <${f.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
	This will disable the lexer's first char optimizations.
	For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),O=!1;return E},[])}),{emptyGroups:R,patternIdxToConfig:A,charCodeToPatternIdxToConfig:T,hasCustom:r,canBeOptimized:O}}a(Mr,"analyzeTokenTypes");function $a(s){var e,t;if(!(s instanceof RegExp)||s.flags!=="")return;let n;try{n=be(s)}catch{return}if(n.value.value.length!==1||n.value.value[0].value.length!==1)return;let r=n.value.value[0].value[0],i;for(;r.type==="Group";){if(r.capturing||r.quantifier!==void 0&&i!==void 0||r.value.value.length!==1||r.value.value[0].value.length!==1)return;i=(e=r.quantifier)!==null&&e!==void 0?e:i,r=r.value.value[0].value[0]}if(r.type!=="Set"||r.complement||r.quantifier!==void 0&&i!==void 0||(i=(t=r.quantifier)!==null&&t!==void 0?t:i,i?.atLeast!==1||i.atMost!==1/0||!i.greedy))return;let o=new Uint8Array(128);for(let l of r.value){let c=typeof l=="number"?l:l.from,h=typeof l=="number"?l:l.to;if(c<0||h>=o.length)return;o.fill(1,c,h+1)}return o}a($a,"getAsciiClass");function Ur(s,e){let t=[],n=ja(s);t=t.concat(n.errors);let r=Wa(n.valid),i=r.valid;return t=t.concat(r.errors),t=t.concat(Ga(i)),t=t.concat(qa(i)),t=t.concat(Za(i,e)),t=t.concat(Qa(i)),t}a(Ur,"validatePatterns");function Ga(s){let e=[],t=s.filter(n=>n[xe]instanceof RegExp);return e=e.concat(Va(t)),e=e.concat(Xa(t)),e=e.concat(Ya(t)),e=e.concat(Ja(t)),e=e.concat(za(t)),e}a(Ga,"validateRegExpPattern");function ja(s){let e=s.filter(r=>!Object.hasOwn(r,xe)),t=e.map(r=>({message:"Token Type: ->"+r.name+"<- missing static 'PATTERN' property",type:_.MISSING_PATTERN,tokenTypes:[r]})),n=s.filter(r=>!e.includes(r));return{errors:t,valid:n}}a(ja,"findMissingPatterns");function Wa(s){let e=s.filter(r=>{let i=r[xe];return!(i instanceof RegExp)&&typeof i!="function"&&!Object.hasOwn(i,"exec")&&typeof i!="string"}),t=e.map(r=>({message:"Token Type: ->"+r.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:_.INVALID_PATTERN,tokenTypes:[r]})),n=s.filter(r=>!e.includes(r));return{errors:t,valid:n}}a(Wa,"findInvalidPatterns");var Ka=/[^\\][$]/;function Va(s){class e extends ye{static{a(this,"EndAnchorFinder")}constructor(){super(...arguments),this.found=!1}visitEndAnchor(i){this.found=!0}}return s.filter(r=>{let i=r.PATTERN;try{let o=be(i),l=new e;return l.visit(o),l.found}catch{return Ka.test(i.source)}}).map(r=>({message:`Unexpected RegExp Anchor Error:
	Token Type: ->`+r.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
	See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS	for details.`,type:_.EOI_ANCHOR_FOUND,tokenTypes:[r]}))}a(Va,"findEndOfInputAnchor");function za(s){return s.filter(n=>n.PATTERN.test("")).map(n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' must not match an empty string",type:_.EMPTY_MATCH_PATTERN,tokenTypes:[n]}))}a(za,"findEmptyMatchRegExps");var Ha=/[^\\[][\^]|^\^/;function Xa(s){class e extends ye{static{a(this,"StartAnchorFinder")}constructor(){super(...arguments),this.found=!1}visitStartAnchor(i){this.found=!0}}return s.filter(r=>{let i=r.PATTERN;try{let o=be(i),l=new e;return l.visit(o),l.found}catch{return Ha.test(i.source)}}).map(r=>({message:`Unexpected RegExp Anchor Error:
	Token Type: ->`+r.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
	See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS	for details.`,type:_.SOI_ANCHOR_FOUND,tokenTypes:[r]}))}a(Xa,"findStartOfInputAnchor");function Ya(s){return s.filter(n=>{let r=n[xe];return r instanceof RegExp&&(r.multiline||r.global)}).map(n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:_.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[n]}))}a(Ya,"findUnsupportedFlags");function Ja(s){let e=[],t=s.map(i=>s.reduce((o,l)=>(i.PATTERN.source===l.PATTERN.source&&!e.includes(l)&&l.PATTERN!==v.NA&&(e.push(l),o.push(l)),o),[]));return t=t.filter(Boolean),t.filter(i=>i.length>1).map(i=>{let o=i.map(c=>c.name);return{message:`The same RegExp pattern ->${i[0].PATTERN}<-has been used in all of the following Token Types: ${o.join(", ")} <-`,type:_.DUPLICATE_PATTERNS_FOUND,tokenTypes:i}})}a(Ja,"findDuplicatePatterns");function qa(s){return s.filter(n=>{if(!Object.hasOwn(n,"GROUP"))return!1;let r=n.GROUP;return r!==v.SKIPPED&&r!==v.NA&&typeof r!="string"}).map(n=>({message:"Token Type: ->"+n.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:_.INVALID_GROUP_TYPE_FOUND,tokenTypes:[n]}))}a(qa,"findInvalidGroupType");function Za(s,e){return s.filter(r=>r.PUSH_MODE!==void 0&&!e.includes(r.PUSH_MODE)).map(r=>({message:`Token Type: ->${r.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${r.PUSH_MODE}<-which does not exist`,type:_.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[r]}))}a(Za,"findModesThatDoNotExist");function Qa(s){let e=[],t=s.reduce((n,r,i)=>{let o=r.PATTERN;return o===v.NA||(typeof o=="string"?n.push({str:o,idx:i,tokenType:r}):o instanceof RegExp&&to(o)&&n.push({str:o.source,idx:i,tokenType:r})),n},[]);return s.forEach((n,r)=>{t.forEach(({str:i,idx:o,tokenType:l})=>{if(r<o&&eo(i,n.PATTERN)){let c=`Token: ->${l.name}<- can never be matched.
Because it appears AFTER the Token Type ->${n.name}<-in the lexer's definition.
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;e.push({message:c,type:_.UNREACHABLE_PATTERN,tokenTypes:[n,l]})}})}),e}a(Qa,"findUnreachablePatterns");function eo(s,e){if(e instanceof RegExp){if(so(e))return!1;let t=e.exec(s);return t!==null&&t.index===0}else{if(typeof e=="function")return e(s,0,[],{});if(Object.hasOwn(e,"exec"))return e.exec(s,0,[],{});if(typeof e=="string")return e===s;throw Error("non exhaustive match")}}a(eo,"tryToMatchStrToPattern");function to(s){return[".","\\","[","]","|","^","$","(",")","?","*","+","{"].find(t=>s.source.indexOf(t)!==-1)===void 0}a(to,"noMetaChar");function so(s){return/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(s.source)}a(so,"usesLookAheadOrBehind");function vr(s){let e=s.ignoreCase?"iy":"y";return new RegExp(`${s.source}`,e)}a(vr,"addStickyFlag");function wr(s,e,t){let n=[];return Object.hasOwn(s,We)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+We+`> property in its definition
`,type:_.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),Object.hasOwn(s,Kt)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+Kt+`> property in its definition
`,type:_.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),Object.hasOwn(s,Kt)&&Object.hasOwn(s,We)&&!Object.hasOwn(s.modes,s.defaultMode)&&n.push({message:`A MultiMode Lexer cannot be initialized with a ${We}: <${s.defaultMode}>which does not exist
`,type:_.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),Object.hasOwn(s,Kt)&&Object.keys(s.modes).forEach(r=>{let i=s.modes[r];i.forEach((o,l)=>{o===void 0?n.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${r}> at index: <${l}>
`,type:_.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED}):Object.hasOwn(o,"LONGER_ALT")&&(Array.isArray(o.LONGER_ALT)?o.LONGER_ALT:[o.LONGER_ALT]).forEach(h=>{h!==void 0&&!i.includes(h)&&n.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${h.name}> on token <${o.name}> outside of mode <${r}>
`,type:_.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})})}),n}a(wr,"performRuntimeChecks");function Pr(s,e,t){let n=[],r=!1,o=Object.values(s.modes||{}).flat().filter(Boolean).filter(c=>c[xe]!==v.NA),l=$r(t);return e&&o.forEach(c=>{let h=Br(c,l);if(h!==!1){let d={message:ro(c,h),type:h.issue,tokenType:c};n.push(d)}else Object.hasOwn(c,"LINE_BREAKS")?c.LINE_BREAKS===!0&&(r=!0):Wt(l,c.PATTERN)&&(r=!0)}),e&&!r&&n.push({message:`Warning: No LINE_BREAKS Found.
	This Lexer has been defined to track line and column information,
	But none of the Token Types can be identified as matching a line terminator.
	See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS 
	for details.`,type:_.NO_LINE_BREAKS_FLAGS}),n}a(Pr,"performWarningRuntimeChecks");function Dr(s){let e=s.PATTERN;if(e instanceof RegExp)return!1;if(typeof e=="function")return!0;if(Object.hasOwn(e,"exec"))return!0;if(typeof e=="string")return!1;throw Error("non exhaustive match")}a(Dr,"isCustomPattern");function no(s){return typeof s=="string"&&s.length===1?s.charCodeAt(0):!1}a(no,"isShortPattern");var Fr={test:a(function(s){let e=s.length;for(let t=this.lastIndex;t<e;t++){let n=s.charCodeAt(t);if(n===10)return this.lastIndex=t+1,!0;if(n===13)return s.charCodeAt(t+1)===10?this.lastIndex=t+2:this.lastIndex=t+1,!0}return!1},"test"),lastIndex:0};function Br(s,e){if(Object.hasOwn(s,"LINE_BREAKS"))return!1;if(s.PATTERN instanceof RegExp){try{Wt(e,s.PATTERN)}catch(t){return{issue:_.IDENTIFY_TERMINATOR,errMsg:t.message}}return!1}else{if(typeof s.PATTERN=="string")return!1;if(Dr(s))return{issue:_.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}}a(Br,"checkLineBreaksIssues");function ro(s,e){if(e.issue===_.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
	The problem is in the <${s.name}> Token Type
	 Root cause: ${e.errMsg}.
	For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(e.issue===_.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
	The problem is in the <${s.name}> Token Type
	For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}a(ro,"buildLineBreakIssueMessage");function $r(s){return s.map(t=>typeof t=="string"?t.charCodeAt(0):t)}a($r,"getCharCodes");function Xs(s,e,t){s[e]===void 0?s[e]=[t]:s[e].push(t)}a(Xs,"addToMapOfArrays");var je=256,Vt=[];function he(s){return s<je?s:Vt[s]}a(he,"charCodeToOptimizedIndex");function io(){if(Vt.length===0){Vt=new Array(65536);for(let s=0;s<65536;s++)Vt[s]=s>255?255+~~(s/255):s}}a(io,"initCharCodeToOptimizedIndexMap");function me(s,e){let t=s.tokenTypeIdx;return t===e.tokenTypeIdx?!0:e.isParent===!0&&e.categoryMatchesMap[t]===!0}a(me,"tokenStructuredMatcher");function Ke(s,e){return s.tokenTypeIdx===e.tokenTypeIdx}a(Ke,"tokenStructuredMatcherNoCategories");var Gr=1,Wr={};function ge(s){let e=ao(s);oo(e),lo(e),co(e),e.forEach(t=>{t.isParent=t.categoryMatches.length>0})}a(ge,"augmentTokenTypes");function ao(s){let e=[...s],t=s,n=!0;for(;n;){t=t.map(i=>i.CATEGORIES).flat().filter(Boolean);let r=t.filter(i=>!e.includes(i));e=e.concat(r),r.length===0?n=!1:t=r}return e}a(ao,"expandCategories");function oo(s){s.forEach(e=>{Ys(e)||(Wr[Gr]=e,e.tokenTypeIdx=Gr++),jr(e)&&!Array.isArray(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),jr(e)||(e.CATEGORIES=[]),ho(e)||(e.categoryMatches=[]),uo(e)||(e.categoryMatchesMap={})})}a(oo,"assignTokenDefaultProps");function co(s){s.forEach(e=>{e.categoryMatches=[],Object.keys(e.categoryMatchesMap).forEach(t=>{e.categoryMatches.push(Wr[t].tokenTypeIdx)})})}a(co,"assignCategoriesTokensProp");function lo(s){s.forEach(e=>{Kr([],e)})}a(lo,"assignCategoriesMapProp");function Kr(s,e){s.forEach(t=>{e.categoryMatchesMap[t.tokenTypeIdx]=!0}),e.CATEGORIES.forEach(t=>{let n=s.concat(e);n.includes(t)||Kr(n,t)})}a(Kr,"singleAssignCategoriesToksMap");function Ys(s){return Object.hasOwn(s??{},"tokenTypeIdx")}a(Ys,"hasShortKeyProperty");function jr(s){return Object.hasOwn(s??{},"CATEGORIES")}a(jr,"hasCategoriesProperty");function ho(s){return Object.hasOwn(s??{},"categoryMatches")}a(ho,"hasExtendingTokensTypesProperty");function uo(s){return Object.hasOwn(s??{},"categoryMatchesMap")}a(uo,"hasExtendingTokensTypesMapProperty");function Vr(s){return Object.hasOwn(s??{},"tokenTypeIdx")}a(Vr,"isTokenType");var Js={buildUnableToPopLexerModeMessage(s){return`Unable to pop Lexer Mode after encountering Token ->${s.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(s,e,t,n,r,i){return`unexpected character: ->${s.charAt(e)}<- at offset: ${e}, skipped ${t} characters.`}};var _;(function(s){s[s.MISSING_PATTERN=0]="MISSING_PATTERN",s[s.INVALID_PATTERN=1]="INVALID_PATTERN",s[s.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",s[s.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",s[s.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",s[s.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",s[s.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",s[s.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",s[s.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",s[s.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",s[s.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",s[s.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",s[s.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",s[s.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",s[s.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",s[s.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",s[s.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",s[s.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"})(_||(_={}));var pt={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:Js,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(pt);var v=class{static{a(this,"Lexer")}constructor(e,t=pt){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.cachedGroupKeys=[],this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(r,i)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let o=new Array(this.traceInitIndent+1).join("	");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${o}--> <${r}>`);let{time:l,value:c}=it(i),h=l>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&h(`${o}<-- <${r}> time: ${l}ms`),this.traceInitIndent--,c}else return i()},typeof t=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
a boolean 2nd argument is no longer supported`);this.config=Object.assign({},pt,t);let n=this.config.traceInitPerf;n===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof n=="number"&&(this.traceInitMaxIdent=n,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let r,i=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===pt.lineTerminatorsPattern)this.config.lineTerminatorsPattern=Fr;else if(this.config.lineTerminatorCharacters===pt.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
	For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(t.safeMode&&t.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),Array.isArray(e)?r={modes:{defaultMode:[...e]},defaultMode:We}:(i=!1,r=Object.assign({},e))}),this.config.skipValidations===!1&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(wr(r,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(Pr(r,this.trackStartLines,this.config.lineTerminatorCharacters))})),r.modes=r.modes?r.modes:{},Object.entries(r.modes).forEach(([l,c])=>{r.modes[l]=c.filter(h=>h!==void 0)});let o=Object.keys(r.modes);if(Object.entries(r.modes).forEach(([l,c])=>{this.TRACE_INIT(`Mode: <${l}> processing`,()=>{if(this.modes.push(l),this.config.skipValidations===!1&&this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Ur(c,o))}),this.lexerDefinitionErrors.length===0){ge(c);let h;this.TRACE_INIT("analyzeTokenTypes",()=>{h=Mr(c,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[l]=h.patternIdxToConfig,this.charCodeToPatternIdxToConfig[l]=h.charCodeToPatternIdxToConfig,this.emptyGroups=Object.assign({},this.emptyGroups,h.emptyGroups),this.hasCustom=h.hasCustom||this.hasCustom,this.canModeBeOptimized[l]=h.canBeOptimized}})}),this.defaultMode=r.defaultMode,this.cachedGroupKeys=Object.keys(this.emptyGroups),this.lexerDefinitionErrors.length>0&&!this.config.deferDefinitionErrorsHandling){let c=this.lexerDefinitionErrors.map(h=>h.message).join(`-----------------------
`);throw new Error(`Errors detected in definition of Lexer:
`+c)}this.lexerDefinitionWarning.forEach(l=>{rt(l.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(i&&(this.handleModes=()=>{}),this.trackStartLines===!1&&(this.computeNewColumn=l=>l),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=()=>{}),/full/i.test(this.config.positionTracking))this.createTokenInstance=this.createFullToken;else if(/onlyStart/i.test(this.config.positionTracking))this.createTokenInstance=this.createStartOnlyToken;else if(/onlyOffset/i.test(this.config.positionTracking))this.createTokenInstance=this.createOffsetOnlyToken;else throw Error(`Invalid <positionTracking> config option: "${this.config.positionTracking}"`);this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT("Failed Optimization Warnings",()=>{let l=Object.entries(this.canModeBeOptimized).reduce((c,[h,u])=>(u===!1&&c.push(h),c),[]);if(t.ensureOptimizations&&l.length>0)throw Error(`Lexer Modes: < ${l.join(", ")} > cannot be optimized.
	 Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
	 Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{kr()}),this.TRACE_INIT("toFastProperties",()=>{at(this)})})}tokenize(e,t=this.defaultMode){if(this.lexerDefinitionErrors.length>0){let r=this.lexerDefinitionErrors.map(i=>i.message).join(`-----------------------
`);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer:
`+r)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let n,r,i,o,l,c,h,u,d,p,g,R,A,O,T,E=e,f=E.length,m=0,D=0,ae=this.hasCustom?0:Math.floor(e.length/10),Te=new Array(ae),Re=[],Qe=this.trackStartLines?1:void 0,ce=this.trackStartLines?1:void 0,De={};for(let G=0;G<this.cachedGroupKeys.length;G++)De[this.cachedGroupKeys[G]]=[];let ta=this.trackStartLines,vs=this.config.lineTerminatorsPattern,Ms=0,Ae=[],et=[],tt=[],sr=[];Object.freeze(sr);let st=!1,sa=a(G=>{if(tt.length===1&&G.tokenType.PUSH_MODE===void 0){let re=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(G);Re.push({offset:G.startOffset,line:G.startLine,column:G.startColumn,length:G.image.length,message:re})}else{tt.pop();let re=tt.at(-1);Ae=this.patternIdxToConfig[re],et=this.charCodeToPatternIdxToConfig[re],Ms=Ae.length;let Us=this.canModeBeOptimized[re]&&this.config.safeMode===!1;et&&Us?st=!0:st=!1}},"pop_mode");function nr(G){tt.push(G),et=this.charCodeToPatternIdxToConfig[G],Ae=this.patternIdxToConfig[G],Ms=Ae.length;let re=this.canModeBeOptimized[G]&&this.config.safeMode===!1;et&&re?st=!0:st=!1}a(nr,"push_mode"),nr.call(this,t);let ne,rr=this.config.recoveryEnabled;for(;m<f;){c=null,d=-1;let G=E.charCodeAt(m),re;if(st){let V=he(G),q=et[V];re=q!==void 0?q:sr}else re=Ae;let Us=re.length;for(n=0;n<Us;n++){ne=re[n];let V=ne.pattern;switch(h=null,ne.matchType){case zt:G===ne.short&&(d=1,c=V);break;case ut:T=V.exec(E,m,Te,De),T!==null?(c=T[0],d=c.length,T.payload!==void 0&&(h=T.payload)):c=null;break;case Xt:{let q=ne.asciiClass;if(q[G]!==1){V.lastIndex=0;break}let H=m+1;for(;q[E.charCodeAt(H)]===1;)H++;d=H-m,V.lastIndex=H;break}case Ht:V.lastIndex=m,d=this.matchLength(V,e,m);break}if(d!==-1){if(l=ne.longerAlt,l!==void 0){c=e.substring(m,m+d);let q=l.length;for(i=0;i<q;i++){let H=Ae[l[i]],pe=H.pattern;if(u=null,H.matchType===ut?(T=pe.exec(E,m,Te,De),T!==null?(o=T[0],T.payload!==void 0&&(u=T.payload)):o=null):(pe.lastIndex=m,o=this.match(pe,e,m)),o&&o.length>c.length){c=o,d=o.length,h=u,ne=H;break}}}break}}if(d!==-1){if(p=ne.group,p!==void 0&&(c=c!==null?c:e.substring(m,m+d),g=ne.tokenTypeIdx,R=this.createTokenInstance(c,m,g,ne.tokenType,Qe,ce,d),this.handlePayload(R,h),p===!1?D=this.addToken(Te,D,R):De[p].push(R)),ta===!0&&ne.canLineTerminator===!0){let V=0,q,H;vs.lastIndex=0;do c=c!==null?c:e.substring(m,m+d),q=vs.test(c),q===!0&&(H=vs.lastIndex-1,V++);while(q===!0);V!==0?(Qe=Qe+V,ce=d-H,this.updateTokenEndLineColumnLocation(R,p,H,V,Qe,ce,d)):ce=this.computeNewColumn(ce,d)}else ce=this.computeNewColumn(ce,d);m=m+d,this.handleModes(ne,sa,nr,R)}else{let V=m,q=Qe,H=ce,pe=rr===!1;for(;pe===!1&&m<f;)for(m++,r=0;r<Ms;r++){let ws=Ae[r],Ps=ws.pattern;switch(ws.matchType){case zt:E.charCodeAt(m)===ws.short&&(pe=!0);break;case ut:pe=Ps.exec(E,m,Te,De)!==null;break;case Xt:case Ht:Ps.lastIndex=m,pe=Ps.exec(e)!==null;break}if(pe===!0)break}if(A=m-V,ce=this.computeNewColumn(ce,A),O=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(E,V,A,q,H,tt.at(-1)),Re.push({offset:V,line:q,column:H,length:A,message:O}),rr===!1)break}}return this.hasCustom||(Te.length=D),{tokens:Te,groups:De,errors:Re}}handleModes(e,t,n,r){if(e.pop===!0){let i=e.push;t(r),i!==void 0&&n.call(this,i)}else e.push!==void 0&&n.call(this,e.push)}updateTokenEndLineColumnLocation(e,t,n,r,i,o,l){let c,h;t!==void 0&&(c=n===l-1,h=c?-1:0,r===1&&c===!0||(e.endLine=i+h,e.endColumn=o-1+-h))}computeNewColumn(e,t){return e+t}createOffsetOnlyToken(e,t,n,r){return{image:e,startOffset:t,tokenTypeIdx:n,tokenType:r}}createStartOnlyToken(e,t,n,r,i,o){return{image:e,startOffset:t,startLine:i,startColumn:o,tokenTypeIdx:n,tokenType:r}}createFullToken(e,t,n,r,i,o,l){return{image:e,startOffset:t,endOffset:t+l-1,startLine:i,endLine:i,startColumn:o,endColumn:o+l-1,tokenTypeIdx:n,tokenType:r}}addTokenUsingPush(e,t,n){return e.push(n),t}addTokenUsingMemberAccess(e,t,n){return e[t]=n,t++,t}handlePayloadNoCustom(e,t){}handlePayloadWithCustom(e,t){t!==null&&(e.payload=t)}match(e,t,n){return e.test(t)===!0?t.substring(n,e.lastIndex):null}matchLength(e,t,n){return e.test(t)===!0?e.lastIndex-n:-1}};v.SKIPPED="This marks a skipped Token pattern, this means each token identified by it will be consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.";v.NA=/NOT_APPLICABLE/;function _e(s){return qs(s)?s.LABEL:s.name}a(_e,"tokenLabel");function qs(s){return typeof s.LABEL=="string"&&s.LABEL!==""}a(qs,"hasTokenLabel");var po="parent",zr="categories",Hr="label",Xr="group",Yr="push_mode",Jr="pop_mode",qr="longer_alt",Zr="line_breaks",Qr="start_chars_hint";function y(s){return fo(s)}a(y,"createToken");function fo(s){let e=s.pattern,t={};if(t.name=s.name,e!==void 0&&(t.PATTERN=e),Object.hasOwn(s,po))throw`The parent property is no longer supported.
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return Object.hasOwn(s,zr)&&(t.CATEGORIES=s[zr]),ge([t]),Object.hasOwn(s,Hr)&&(t.LABEL=s[Hr]),Object.hasOwn(s,Xr)&&(t.GROUP=s[Xr]),Object.hasOwn(s,Jr)&&(t.POP_MODE=s[Jr]),Object.hasOwn(s,Yr)&&(t.PUSH_MODE=s[Yr]),Object.hasOwn(s,qr)&&(t.LONGER_ALT=s[qr]),Object.hasOwn(s,Zr)&&(t.LINE_BREAKS=s[Zr]),Object.hasOwn(s,Qr)&&(t.START_CHARS_HINT=s[Qr]),t}a(fo,"createTokenInternal");var Q=y({name:"EOF",pattern:v.NA});ge([Q]);function ve(s,e,t,n,r,i,o,l){return{image:e,startOffset:t,endOffset:n,startLine:r,endLine:i,startColumn:o,endColumn:l,tokenTypeIdx:s.tokenTypeIdx,tokenType:s}}a(ve,"createTokenInstance");function ft(s,e){return me(s,e)}a(ft,"tokenMatcher");var Yt={buildMismatchTokenMessage({expected:s,actual:e,previous:t,ruleName:n}){return`Expecting ${qs(s)?`--> ${_e(s)} <--`:`token of type --> ${s.name} <--`} but found --> '${e.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:s,ruleName:e}){return"Redundant input, expecting EOF but found: "+s.image},buildNoViableAltMessage({expectedPathsPerAlt:s,actual:e,previous:t,customUserDescription:n,ruleName:r}){let i="Expecting: ",l=`
but found: '`+e[0].image+"'";if(n)return i+n+l;{let d=`one of these possible Token sequences:
${s.reduce((p,g)=>p.concat(g),[]).map(p=>`[${p.map(g=>_e(g)).join(", ")}]`).map((p,g)=>`  ${g+1}. ${p}`).join(`
`)}`;return i+d+l}},buildEarlyExitMessage({expectedIterationPaths:s,actual:e,customUserDescription:t,ruleName:n}){let r="Expecting: ",o=`
but found: '`+e[0].image+"'";if(t)return r+t+o;{let c=`expecting at least one iteration which starts with one of these possible Token sequences::
  <${s.map(h=>`[${h.map(u=>_e(u)).join(",")}]`).join(" ,")}>`;return r+c+o}}};Object.freeze(Yt);var ei={buildRuleNotFoundError(s,e){return"Invalid grammar, reference to a rule which is not defined: ->"+e.nonTerminalName+`<-
inside top level rule: ->`+s.name+"<-"}},oe={buildDuplicateFoundError(s,e){function t(u){return u instanceof C?u.terminalType.name:u instanceof k?u.nonTerminalName:""}a(t,"getExtraProductionArgument");let n=s.name,r=e[0],i=r.idx,o=Z(r),l=t(r),c=i>0,h=`->${o}${c?i:""}<- ${l?`with argument: ->${l}<-`:""}
                  appears more than once (${e.length} times) in the top level rule: ->${n}<-.                  
                  For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES 
                  `;return h=h.replace(/[ \t]+/g," "),h=h.replace(/\s\s+/g,`
`),h},buildNamespaceConflictError(s){return`Namespace conflict found in grammar.
The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${s.name}>.
To resolve this make sure each Terminal and Non-Terminal names are unique
This is easy to accomplish by using the convention that Terminal names start with an uppercase letter
and Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(s){let e=s.prefixPath.map(r=>_e(r)).join(", "),t=s.alternation.idx===0?"":s.alternation.idx;return`Ambiguous alternatives: <${s.ambiguityIndices.join(" ,")}> due to common lookahead prefix
in <OR${t}> inside <${s.topLevelRule.name}> Rule,
<${e}> may appears as a prefix path in all these alternatives.
See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX
For Further details.`},buildAlternationAmbiguityError(s){let e=s.alternation.idx===0?"":s.alternation.idx,t=s.prefixPath.length===0,n=`Ambiguous Alternatives Detected: <${s.ambiguityIndices.join(" ,")}> in <OR${e}> inside <${s.topLevelRule.name}> Rule,
`;if(t)n+=`These alternatives are all empty (match no tokens), making them indistinguishable.
Only the last alternative may be empty.
`;else{let r=s.prefixPath.map(i=>_e(i)).join(", ");n+=`<${r}> may appears as a prefix path in all these alternatives.
`}return n+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
For Further details.`,n},buildEmptyRepetitionError(s){let e=Z(s.repetition);return s.repetition.idx!==0&&(e+=s.repetition.idx),`The repetition <${e}> within Rule <${s.topLevelRule.name}> can never consume any tokens.
This could lead to an infinite loop.`},buildTokenNameError(s){return"deprecated"},buildEmptyAlternationError(s){return`Ambiguous empty alternative: <${s.emptyChoiceIdx+1}> in <OR${s.alternation.idx}> inside <${s.topLevelRule.name}> Rule.
Only the last alternative may be an empty alternative.`},buildTooManyAlternativesError(s){return`An Alternation cannot have more than 256 alternatives:
<OR${s.alternation.idx}> inside <${s.topLevelRule.name}> Rule.
 has ${s.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(s){let e=s.topLevelRule.name,t=s.leftRecursionPath.map(i=>i.name),n=`${e} --> ${t.concat([e]).join(" --> ")}`;return`Left Recursion found in grammar.
rule: <${e}> can be invoked from itself (directly or indirectly)
without consuming any Tokens. The grammar path that causes this is: 
 ${n}
 To fix this refactor your grammar to remove the left recursion.
see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(s){return"deprecated"},buildDuplicateRuleNameError(s){let e;return s.topLevelRule instanceof X?e=s.topLevelRule.name:e=s.topLevelRule,`Duplicate definition, rule: ->${e}<- is already defined in the grammar: ->${s.grammarName}<-`}};function ti(s,e){let t=new Zs(s,e);return t.resolveRefs(),t.errors}a(ti,"resolveGrammar");var Zs=class extends Y{static{a(this,"GastRefResolverVisitor")}constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){Object.values(this.nameToTopRule).forEach(e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{let n=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:n,type:j.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}};var Qs=class extends fe{static{a(this,"AbstractNextPossibleTokensWalker")}constructor(e,t){super(),this.topProd=e,this.path=t,this.possibleTokTypes=[],this.nextProductionName="",this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}startWalking(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=[...this.path.ruleStack].reverse(),this.occurrenceStack=[...this.path.occurrenceStack].reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,t=[]){this.found||super.walk(e,t)}walkProdRef(e,t,n){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let r=t.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,r)}}updateExpectedNext(){this.ruleStack.length===0?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},Jt=class extends Qs{static{a(this,"NextAfterTokenWalker")}constructor(e,t){super(e,t),this.path=t,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,t,n){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){let r=t.concat(n),i=new b({definition:r});this.possibleTokTypes=Ie(i),this.found=!0}}},Ve=class extends fe{static{a(this,"AbstractNextTerminalAfterProductionWalker")}constructor(e,t){super(),this.topRule=e,this.occurrence=t,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}},qt=class extends Ve{static{a(this,"NextTerminalAfterManyWalker")}walkMany(e,t,n){if(e.idx===this.occurrence){let r=t.concat(n)[0];this.result.isEndOfRule=r===void 0,r instanceof C&&(this.result.token=r.terminalType,this.result.occurrence=r.idx)}else super.walkMany(e,t,n)}},mt=class extends Ve{static{a(this,"NextTerminalAfterManySepWalker")}walkManySep(e,t,n){if(e.idx===this.occurrence){let r=t.concat(n)[0];this.result.isEndOfRule=r===void 0,r instanceof C&&(this.result.token=r.terminalType,this.result.occurrence=r.idx)}else super.walkManySep(e,t,n)}},Zt=class extends Ve{static{a(this,"NextTerminalAfterAtLeastOneWalker")}walkAtLeastOne(e,t,n){if(e.idx===this.occurrence){let r=t.concat(n)[0];this.result.isEndOfRule=r===void 0,r instanceof C&&(this.result.token=r.terminalType,this.result.occurrence=r.idx)}else super.walkAtLeastOne(e,t,n)}},gt=class extends Ve{static{a(this,"NextTerminalAfterAtLeastOneSepWalker")}walkAtLeastOneSep(e,t,n){if(e.idx===this.occurrence){let r=t.concat(n)[0];this.result.isEndOfRule=r===void 0,r instanceof C&&(this.result.token=r.terminalType,this.result.occurrence=r.idx)}else super.walkAtLeastOneSep(e,t,n)}};function Qt(s,e,t=[]){t=[...t];let n=[],r=0;function i(l){return l.concat(s.slice(r+1))}a(i,"remainingPathWith");function o(l){let c=Qt(i(l),e,t);return n.concat(c)}for(a(o,"getAlternativesForProd");t.length<e&&r<s.length;){let l=s[r];if(l instanceof b)return o(l.definition);if(l instanceof k)return o(l.definition);if(l instanceof x)n=o(l.definition);else if(l instanceof F){let c=l.definition.concat([new N({definition:l.definition})]);return o(c)}else if(l instanceof B){let c=[new b({definition:l.definition}),new N({definition:[new C({terminalType:l.separator})].concat(l.definition)})];return o(c)}else if(l instanceof w){let c=l.definition.concat([new N({definition:[new C({terminalType:l.separator})].concat(l.definition)})]);n=o(c)}else if(l instanceof N){let c=l.definition.concat([new N({definition:l.definition})]);n=o(c)}else{if(l instanceof P)return l.definition.forEach(c=>{c.definition.length!==0&&(n=o(c.definition))}),n;if(l instanceof C)t.push(l.terminalType);else throw Error("non exhaustive match")}r++}return n.push({partialPath:t,suffixDef:s.slice(r)}),n}a(Qt,"possiblePathsFrom");function si(s,e,t,n){let r="EXIT_NONE_TERMINAL",i=[r],o="EXIT_ALTERNATIVE",l=!1,c=e.length,h=c-n-1,u=[],d=[];for(d.push({idx:-1,def:s,ruleStack:[],occurrenceStack:[]});d.length!==0;){let p=d.pop();if(p===o){l&&d.at(-1).idx<=h&&d.pop();continue}let g=p.def,R=p.idx,A=p.ruleStack,O=p.occurrenceStack;if(g.length===0)continue;let T=g[0];if(T===r){let E={idx:R,def:g.slice(1),ruleStack:A.slice(0,-1),occurrenceStack:O.slice(0,-1)};d.push(E)}else if(T instanceof C)if(R<c-1){let E=R+1,f=e[E];if(t(f,T.terminalType)){let m={idx:E,def:g.slice(1),ruleStack:A,occurrenceStack:O};d.push(m)}}else if(R===c-1)u.push({nextTokenType:T.terminalType,nextTokenOccurrence:T.idx,ruleStack:A,occurrenceStack:O}),l=!0;else throw Error("non exhaustive match");else if(T instanceof k){let E=[...A];E.push(T.nonTerminalName);let f=[...O];f.push(T.idx);let m={idx:R,def:T.definition.concat(i,g.slice(1)),ruleStack:E,occurrenceStack:f};d.push(m)}else if(T instanceof x){let E={idx:R,def:g.slice(1),ruleStack:A,occurrenceStack:O};d.push(E),d.push(o);let f={idx:R,def:T.definition.concat(g.slice(1)),ruleStack:A,occurrenceStack:O};d.push(f)}else if(T instanceof F){let E=new N({definition:T.definition,idx:T.idx}),f=T.definition.concat([E],g.slice(1)),m={idx:R,def:f,ruleStack:A,occurrenceStack:O};d.push(m)}else if(T instanceof B){let E=new C({terminalType:T.separator}),f=new N({definition:[E].concat(T.definition),idx:T.idx}),m=T.definition.concat([f],g.slice(1)),D={idx:R,def:m,ruleStack:A,occurrenceStack:O};d.push(D)}else if(T instanceof w){let E={idx:R,def:g.slice(1),ruleStack:A,occurrenceStack:O};d.push(E),d.push(o);let f=new C({terminalType:T.separator}),m=new N({definition:[f].concat(T.definition),idx:T.idx}),D=T.definition.concat([m],g.slice(1)),ae={idx:R,def:D,ruleStack:A,occurrenceStack:O};d.push(ae)}else if(T instanceof N){let E={idx:R,def:g.slice(1),ruleStack:A,occurrenceStack:O};d.push(E),d.push(o);let f=new N({definition:T.definition,idx:T.idx}),m=T.definition.concat([f],g.slice(1)),D={idx:R,def:m,ruleStack:A,occurrenceStack:O};d.push(D)}else if(T instanceof P)for(let E=T.definition.length-1;E>=0;E--){let f=T.definition[E],m={idx:R,def:f.definition.concat(g.slice(1)),ruleStack:A,occurrenceStack:O};d.push(m),d.push(o)}else if(T instanceof b)d.push({idx:R,def:T.definition.concat(g.slice(1)),ruleStack:A,occurrenceStack:O});else if(T instanceof X)d.push(mo(T,R,A,O));else throw Error("non exhaustive match")}return u}a(si,"nextPossibleTokensAfter");function mo(s,e,t,n){let r=[...t];r.push(s.name);let i=[...n];return i.push(1),{idx:e,def:s.definition,ruleStack:r,occurrenceStack:i}}a(mo,"expandTopLevelRule");var M;(function(s){s[s.OPTION=0]="OPTION",s[s.REPETITION=1]="REPETITION",s[s.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",s[s.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",s[s.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",s[s.ALTERNATION=5]="ALTERNATION"})(M||(M={}));function ts(s){if(s instanceof x||s==="Option")return M.OPTION;if(s instanceof N||s==="Repetition")return M.REPETITION;if(s instanceof F||s==="RepetitionMandatory")return M.REPETITION_MANDATORY;if(s instanceof B||s==="RepetitionMandatoryWithSeparator")return M.REPETITION_MANDATORY_WITH_SEPARATOR;if(s instanceof w||s==="RepetitionWithSeparator")return M.REPETITION_WITH_SEPARATOR;if(s instanceof P||s==="Alternation")return M.ALTERNATION;throw Error("non exhaustive match")}a(ts,"getProdType");function ri(s,e,t,n,r,i){let o=Et(s,e,t),l=hi(o)?Ke:me;return i(o,n,l,r)}a(ri,"buildLookaheadFuncForOr");function ii(s,e,t,n,r,i){let o=Tt(s,e,r,t),l=hi(o)?Ke:me;return i(o[0],l,n)}a(ii,"buildLookaheadFuncForOptionalProd");function ai(s,e,t,n){let r=s.length,i=s.every(o=>o.every(l=>l.length===1));if(e)return function(o){let l=o.map(c=>c.GATE);for(let c=0;c<r;c++){let h=s[c],u=h.length,d=l[c];if(!(d!==void 0&&d.call(this)===!1))e:for(let p=0;p<u;p++){let g=h[p],R=g.length;for(let A=0;A<R;A++){let O=this.LA_FAST(A+1);if(t(O,g[A])===!1)continue e}return c}}};if(i&&!n){let l=s.map(c=>c.flat()).reduce((c,h,u)=>(h.forEach(d=>{d.tokenTypeIdx in c||(c[d.tokenTypeIdx]=u),d.categoryMatches.forEach(p=>{Object.hasOwn(c,p)||(c[p]=u)})}),c),{});return function(){let c=this.LA_FAST(1);return l[c.tokenTypeIdx]}}else return function(){for(let o=0;o<r;o++){let l=s[o],c=l.length;e:for(let h=0;h<c;h++){let u=l[h],d=u.length;for(let p=0;p<d;p++){let g=this.LA_FAST(p+1);if(t(g,u[p])===!1)continue e}return o}}}}a(ai,"buildAlternativesLookAheadFunc");function oi(s,e,t){let n=s.every(i=>i.length===1),r=s.length;if(n&&!t){let i=s.flat();if(i.length===1&&i[0].categoryMatches.length===0){let l=i[0].tokenTypeIdx;return function(){return this.LA_FAST(1).tokenTypeIdx===l}}else{let o=i.reduce((l,c,h)=>(l[c.tokenTypeIdx]=!0,c.categoryMatches.forEach(u=>{l[u]=!0}),l),[]);return function(){let l=this.LA_FAST(1);return o[l.tokenTypeIdx]===!0}}}else return function(){e:for(let i=0;i<r;i++){let o=s[i],l=o.length;for(let c=0;c<l;c++){let h=this.LA_FAST(c+1);if(e(h,o[c])===!1)continue e}return!0}return!1}}a(oi,"buildSingleAlternativeLookaheadFunction");var tn=class extends fe{static{a(this,"RestDefinitionFinderWalker")}constructor(e,t,n){super(),this.topProd=e,this.targetOccurrence=t,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,t,n,r){return e.idx===this.targetOccurrence&&this.targetProdType===t?(this.restDef=n.concat(r),!0):!1}walkOption(e,t,n){this.checkIsTarget(e,M.OPTION,t,n)||super.walkOption(e,t,n)}walkAtLeastOne(e,t,n){this.checkIsTarget(e,M.REPETITION_MANDATORY,t,n)||super.walkOption(e,t,n)}walkAtLeastOneSep(e,t,n){this.checkIsTarget(e,M.REPETITION_MANDATORY_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}walkMany(e,t,n){this.checkIsTarget(e,M.REPETITION,t,n)||super.walkOption(e,t,n)}walkManySep(e,t,n){this.checkIsTarget(e,M.REPETITION_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}},es=class extends Y{static{a(this,"InsideDefinitionFinderVisitor")}constructor(e,t,n){super(),this.targetOccurrence=e,this.targetProdType=t,this.targetRef=n,this.result=[]}checkIsTarget(e,t){e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.targetRef===void 0||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,M.OPTION)}visitRepetition(e){this.checkIsTarget(e,M.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,M.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,M.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,M.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,M.ALTERNATION)}};function ni(s){let e=new Array(s);for(let t=0;t<s;t++)e[t]=[];return e}a(ni,"initializeArrayOfArrays");function en(s){let e=[""];for(let t=0;t<s.length;t++){let n=s[t],r=[];for(let i=0;i<e.length;i++){let o=e[i];r.push(o+"_"+n.tokenTypeIdx);for(let l=0;l<n.categoryMatches.length;l++){let c="_"+n.categoryMatches[l];r.push(o+c)}}e=r}return e}a(en,"pathToHashKeys");function go(s,e,t){for(let n=0;n<s.length;n++){if(n===t)continue;let r=s[n];for(let i=0;i<e.length;i++){let o=e[i];if(r[o]===!0)return!1}}return!0}a(go,"isUniquePrefixHash");function ci(s,e){let t=s.map(o=>Qt([o],1)),n=ni(t.length),r=t.map(o=>{let l={};return o.forEach(c=>{en(c.partialPath).forEach(u=>{l[u]=!0})}),l}),i=t;for(let o=1;o<=e;o++){let l=i;i=ni(l.length);for(let c=0;c<l.length;c++){let h=l[c];for(let u=0;u<h.length;u++){let d=h[u].partialPath,p=h[u].suffixDef,g=en(d);if(go(r,g,c)||p.length===0||d.length===e){let A=n[c];if(ss(A,d)===!1){A.push(d);for(let O=0;O<g.length;O++){let T=g[O];r[c][T]=!0}}}else{let A=Qt(p,o+1,d);i[c]=i[c].concat(A),A.forEach(O=>{en(O.partialPath).forEach(E=>{r[c][E]=!0})})}}}}return n}a(ci,"lookAheadSequenceFromAlternatives");function Et(s,e,t,n){let r=new es(s,M.ALTERNATION,n);return e.accept(r),ci(r.result,t)}a(Et,"getLookaheadPathsForOr");function Tt(s,e,t,n){let r=new es(s,t);e.accept(r);let i=r.result,l=new tn(e,s,t).startWalking(),c=new b({definition:i}),h=new b({definition:l});return ci([c,h],n)}a(Tt,"getLookaheadPathsForOptionalProd");function ss(s,e){e:for(let t=0;t<s.length;t++){let n=s[t];if(n.length===e.length){for(let r=0;r<n.length;r++){let i=e[r],o=n[r];if((i===o||o.categoryMatchesMap[i.tokenTypeIdx]!==void 0)===!1)continue e}return!0}}return!1}a(ss,"containsPath");function li(s,e){return s.length<e.length&&s.every((t,n)=>{let r=e[n];return t===r||r.categoryMatchesMap[t.tokenTypeIdx]})}a(li,"isStrictPrefixOfPath");function hi(s){return s.every(e=>e.every(t=>t.every(n=>n.categoryMatches.length===0)))}a(hi,"areTokenCategoriesNotUsed");function di(s){return s.lookaheadStrategy.validate({rules:s.rules,tokenTypes:s.tokenTypes,grammarName:s.grammarName}).map(t=>Object.assign({type:j.CUSTOM_LOOKAHEAD_VALIDATION},t))}a(di,"validateLookahead");function ui(s,e,t,n){let r=s.flatMap(c=>Eo(c,t)),i=Oo(s,e,t),o=s.flatMap(c=>So(c,t)),l=s.flatMap(c=>yo(c,s,n,t));return r.concat(i,o,l)}a(ui,"validateGrammar");function Eo(s,e){let t=new sn;s.accept(t);let n=t.allProductions,r=Object.groupBy(n,To),i=Object.fromEntries(Object.entries(r).filter(([l,c])=>c.length>1));return Object.values(i).map(l=>{let c=l[0],h=e.buildDuplicateFoundError(s,l),u=Z(c),d={message:h,type:j.DUPLICATE_PRODUCTIONS,ruleName:s.name,dslName:u,occurrence:c.idx},p=pi(c);return p&&(d.parameter=p),d})}a(Eo,"validateDuplicateProductions");function To(s){return`${Z(s)}_#_${s.idx}_#_${pi(s)}`}a(To,"identifyProductionForDuplicates");function pi(s){return s instanceof C?s.terminalType.name:s instanceof k?s.nonTerminalName:""}a(pi,"getExtraProductionArgument");var sn=class extends Y{static{a(this,"OccurrenceValidationCollector")}constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(e){this.allProductions.push(e)}visitOption(e){this.allProductions.push(e)}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}visitAlternation(e){this.allProductions.push(e)}visitTerminal(e){this.allProductions.push(e)}};function yo(s,e,t,n){let r=[];if(e.reduce((o,l)=>l.name===s.name?o+1:o,0)>1){let o=n.buildDuplicateRuleNameError({topLevelRule:s,grammarName:t});r.push({message:o,type:j.DUPLICATE_RULE_NAME,ruleName:s.name})}return r}a(yo,"validateRuleDoesNotAlreadyExist");function fi(s,e,t){let n=[],r;return e.includes(s)||(r=`Invalid rule override, rule: ->${s}<- cannot be overridden in the grammar: ->${t}<-as it is not defined in any of the super grammars `,n.push({message:r,type:j.INVALID_RULE_OVERRIDE,ruleName:s})),n}a(fi,"validateRuleIsOverridden");function rn(s,e,t,n=[]){let r=[],i=ns(e.definition);if(i.length===0)return[];{let o=s.name;i.includes(s)&&r.push({message:t.buildLeftRecursionError({topLevelRule:s,leftRecursionPath:n}),type:j.LEFT_RECURSION,ruleName:o});let c=n.concat([s]),u=i.filter(d=>!c.includes(d)).flatMap(d=>{let p=[...n];return p.push(d),rn(s,d,t,p)});return r.concat(u)}}a(rn,"validateNoLeftRecursion");function ns(s){let e=[];if(s.length===0)return e;let t=s[0];if(t instanceof k)e.push(t.referencedRule);else if(t instanceof b||t instanceof x||t instanceof F||t instanceof B||t instanceof w||t instanceof N)e=e.concat(ns(t.definition));else if(t instanceof P)e=t.definition.map(i=>ns(i.definition)).flat();else if(!(t instanceof C))throw Error("non exhaustive match");let n=Ne(t),r=s.length>1;if(n&&r){let i=s.slice(1);return e.concat(ns(i))}else return e}a(ns,"getFirstNoneTerminal");var yt=class extends Y{static{a(this,"OrCollector")}constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}};function mi(s,e){let t=new yt;return s.accept(t),t.alternations.flatMap(i=>i.definition.slice(0,-1).flatMap((l,c)=>si([l],[],me,1).length===0?[{message:e.buildEmptyAlternationError({topLevelRule:s,alternation:i,emptyChoiceIdx:c}),type:j.NONE_LAST_EMPTY_ALT,ruleName:s.name,occurrence:i.idx,alternative:c+1}]:[]))}a(mi,"validateEmptyOrAlternative");function gi(s,e,t){let n=new yt;s.accept(n);let r=n.alternations;return r=r.filter(o=>o.ignoreAmbiguities!==!0),r.flatMap(o=>{let l=o.idx,c=o.maxLookahead||e,h=Et(l,s,c,o),u=Ro(h,o,s,t),d=Ao(h,o,s,t);return u.concat(d)})}a(gi,"validateAmbiguousAlternationAlternatives");var nn=class extends Y{static{a(this,"RepetitionCollector")}constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}};function So(s,e){let t=new yt;return s.accept(t),t.alternations.flatMap(i=>i.definition.length>255?[{message:e.buildTooManyAlternativesError({topLevelRule:s,alternation:i}),type:j.TOO_MANY_ALTS,ruleName:s.name,occurrence:i.idx}]:[])}a(So,"validateTooManyAlts");function Ei(s,e,t){let n=[];return s.forEach(r=>{let i=new nn;r.accept(i),i.allProductions.forEach(l=>{let c=ts(l),h=l.maxLookahead||e,u=l.idx;if(Tt(u,r,c,h)[0].flat().length===0){let g=t.buildEmptyRepetitionError({topLevelRule:r,repetition:l});n.push({message:g,type:j.NO_NON_EMPTY_LOOKAHEAD,ruleName:r.name})}})}),n}a(Ei,"validateSomeNonEmptyLookaheadPath");function Ro(s,e,t,n){let r=[];return s.reduce((l,c,h)=>(e.definition[h].ignoreAmbiguities===!0||c.forEach(u=>{let d=[h];s.forEach((p,g)=>{h!==g&&ss(p,u)&&e.definition[g].ignoreAmbiguities!==!0&&d.push(g)}),d.length>1&&!ss(r,u)&&(r.push(u),l.push({alts:d,path:u}))}),l),[]).map(l=>{let c=l.alts.map(u=>u+1);return{message:n.buildAlternationAmbiguityError({topLevelRule:t,alternation:e,ambiguityIndices:c,prefixPath:l.path}),type:j.AMBIGUOUS_ALTS,ruleName:t.name,occurrence:e.idx,alternatives:l.alts}})}a(Ro,"checkAlternativesAmbiguities");function Ao(s,e,t,n){let r=s.reduce((o,l,c)=>{let h=l.map(u=>({idx:c,path:u}));return o.concat(h)},[]);return r.flatMap(o=>{if(e.definition[o.idx].ignoreAmbiguities===!0)return[];let c=o.idx,h=o.path;return r.filter(p=>e.definition[p.idx].ignoreAmbiguities!==!0&&p.idx<c&&li(p.path,h)).map(p=>{let g=[p.idx+1,c+1],R=e.idx===0?"":e.idx;return{message:n.buildAlternationPrefixAmbiguityError({topLevelRule:t,alternation:e,ambiguityIndices:g,prefixPath:p.path}),type:j.AMBIGUOUS_PREFIX_ALTS,ruleName:t.name,occurrence:R,alternatives:g}})})}a(Ao,"checkPrefixAlternativesAmbiguities");function Oo(s,e,t){let n=[],r=e.map(i=>i.name);return s.forEach(i=>{let o=i.name;if(r.includes(o)){let l=t.buildNamespaceConflictError(i);n.push({message:l,type:j.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:o})}}),n}a(Oo,"checkTerminalAndNoneTerminalsNameSpace");function Ti(s){let e=Object.assign({errMsgProvider:ei},s),t={};return s.rules.forEach(n=>{t[n.name]=n}),ti(t,e.errMsgProvider)}a(Ti,"resolveGrammar");function yi(s){var e;let t=(e=s.errMsgProvider)!==null&&e!==void 0?e:oe;return ui(s.rules,s.tokenTypes,t,s.grammarName)}a(yi,"validateGrammar");var Si="MismatchedTokenException",Ri="NoViableAltException",Ai="EarlyExitException",Oi="NotAllInputParsedException",Ci=[Si,Ri,Ai,Oi];Object.freeze(Ci);function Se(s){return Ci.includes(s.name)}a(Se,"isRecognitionException");var ze=class extends Error{static{a(this,"RecognitionException")}constructor(e,t){super(e),this.token=t,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},Me=class extends ze{static{a(this,"MismatchedTokenException")}constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Si}},St=class extends ze{static{a(this,"NoViableAltException")}constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Ri}},Rt=class extends ze{static{a(this,"NotAllInputParsedException")}constructor(e,t){super(e,t),this.name=Oi}},At=class extends ze{static{a(this,"EarlyExitException")}constructor(e,t,n){super(e,t),this.previousToken=n,this.name=Ai}};var an={},cn="InRuleRecoveryException",on=class extends Error{static{a(this,"InRuleRecoveryException")}constructor(e){super(e),this.name=cn}},rs=class{static{a(this,"Recoverable")}initRecoverable(e){this.firstAfterRepMap=[],this.resyncFollows={},this.recoveryEnabled=Object.hasOwn(e,"recoveryEnabled")?e.recoveryEnabled:J.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=Co)}getTokenToInsert(e){let t=ve(e,"",-1,-1,-1,-1,-1,-1);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,n,r){let i=this.findReSyncTokenType(),o=this.exportLexerState(),l=[],c=!1,h=this.LA_FAST(1),u=this.LA_FAST(1),d=a(()=>{let p=this.LA(0),g=this.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:h,previous:p,ruleName:this.getCurrRuleFullName()}),R=new Me(g,h,this.LA(0));R.resyncedTokens=l.slice(0,-1),this.SAVE_ERROR(R)},"generateErrorMessage");for(;!c;)if(this.tokenMatcher(u,r)){d();return}else if(n.call(this)){d(),e.apply(this,t);return}else this.tokenMatcher(u,i)?c=!0:(u=this.SKIP_TOKEN(),this.addToResyncTokens(u,l));this.importLexerState(o)}shouldInRepetitionRecoveryBeTried(e,t,n){return!(n===!1||this.tokenMatcher(this.LA_FAST(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))}getNextPossibleTokenTypes(e){let t=e.ruleStack[0],r=this.getGAstProductions()[t];return new Jt(r,e).startWalking()}getFollowsForInRuleRecovery(e,t){let n=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let n=this.SKIP_TOKEN();return this.consumeToken(),n}throw new on("sad sad panda")}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e)||t.length===0)return!1;let n=this.LA_FAST(1);return t.find(i=>this.tokenMatcher(n,i))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){let t=this.getCurrFollowKey();return this.getFollowSetFromFollowKey(t).includes(e)}findReSyncTokenType(){let e=this.flattenFollowSet(),t=this.LA_FAST(1),n=2;for(;;){let r=e.find(i=>ft(t,i));if(r!==void 0)return r;t=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK_IDX===0)return an;let e=this.currRuleShortName,t=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK,n=this.RULE_STACK_IDX+1,r=new Array(n);for(let i=0;i<n;i++)i===0?r[i]=an:r[i]={ruleName:this.shortRuleNameToFullName(e[i]),idxInCallingRule:t[i],inRule:this.shortRuleNameToFullName(e[i-1])};return r}flattenFollowSet(){return this.buildFullFollowKeyStack().map(t=>this.getFollowSetFromFollowKey(t)).flat()}getFollowSetFromFollowKey(e){if(e===an)return[Q];let t=e.ruleName+e.idxInCallingRule+Ft+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,Q)||t.push(e),t}reSyncTo(e){let t=[],n=this.LA_FAST(1);for(;this.tokenMatcher(n,e)===!1;)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,t);return t.slice(0,-1)}attemptInRepetitionRecovery(e,t,n,r,i,o,l){}getCurrentGrammarPath(e,t){let n=this.getHumanReadableRuleStack(),r=this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1);return{ruleStack:n,occurrenceStack:r,lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){let e=this.RULE_STACK_IDX+1,t=new Array(e);for(let n=0;n<e;n++)t[n]=this.shortRuleNameToFullName(this.RULE_STACK[n]);return t}};function Co(s,e,t,n,r,i,o){var l,c,h;let u=n|r,d=(l=(c=this.firstAfterRepMap)[h=this.currRuleShortName])!==null&&l!==void 0?l:c[h]=[],p=d[u];if(p===void 0){let O=this.getCurrRuleFullName(),T=this.getGAstProductions()[O];p=new i(T,r).startWalking(),d[u]=p}let g=p.token,R=p.occurrence,A=p.isEndOfRule;this.RULE_STACK_IDX===0&&A&&g===void 0&&(g=Q,R=1),!(g===void 0||R===void 0)&&this.shouldInRepetitionRecoveryBeTried(g,R,o)&&this.tryInRepetitionRecovery(s,e,t,g)}a(Co,"attemptInRepetitionRecovery");var Ot=class{static{a(this,"LLkLookaheadStrategy")}constructor(e){var t;this.maxLookahead=(t=e?.maxLookahead)!==null&&t!==void 0?t:J.maxLookahead}validate(e){let t=this.validateNoLeftRecursion(e.rules);if(t.length===0){let n=this.validateEmptyOrAlternatives(e.rules),r=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),i=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...t,...n,...r,...i]}return t}validateNoLeftRecursion(e){return e.flatMap(t=>rn(t,t,oe))}validateEmptyOrAlternatives(e){return e.flatMap(t=>mi(t,oe))}validateAmbiguousAlternationAlternatives(e,t){return e.flatMap(n=>gi(n,t,oe))}validateSomeNonEmptyLookaheadPath(e,t){return Ei(e,t,oe)}buildLookaheadForAlternation(e){return ri(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,ai)}buildLookaheadForOptional(e){return ii(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,ts(e.prodType),oi)}};var as=class{static{a(this,"LooksAhead")}initLooksAhead(e){this.dynamicTokensEnabled=Object.hasOwn(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:J.dynamicTokensEnabled,this.maxLookahead=Object.hasOwn(e,"maxLookahead")?e.maxLookahead:J.maxLookahead,this.lookaheadStrategy=Object.hasOwn(e,"lookaheadStrategy")?e.lookaheadStrategy:new Ot({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=[],this.currRuleLookaheadFuncs=[]}preComputeLookaheadFunctions(e){e.forEach(t=>{this.TRACE_INIT(`${t.name} Rule Lookahead`,()=>{let{alternation:n,repetition:r,option:i,repetitionMandatory:o,repetitionMandatoryWithSeparator:l,repetitionWithSeparator:c}=Lo(t);n.forEach(h=>{let u=h.idx===0?"":h.idx;this.TRACE_INIT(`${Z(h)}${u}`,()=>{let d=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:h.idx,rule:t,maxLookahead:h.maxLookahead||this.maxLookahead,hasPredicates:h.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled});this.setLaFuncCache(this.fullRuleNameToShort[t.name],256|h.idx,d)})}),r.forEach(h=>{this.computeLookaheadFunc(t,h.idx,768,"Repetition",h.maxLookahead,Z(h))}),i.forEach(h=>{this.computeLookaheadFunc(t,h.idx,512,"Option",h.maxLookahead,Z(h))}),o.forEach(h=>{this.computeLookaheadFunc(t,h.idx,1024,"RepetitionMandatory",h.maxLookahead,Z(h))}),l.forEach(h=>{this.computeLookaheadFunc(t,h.idx,1536,"RepetitionMandatoryWithSeparator",h.maxLookahead,Z(h))}),c.forEach(h=>{this.computeLookaheadFunc(t,h.idx,1280,"RepetitionWithSeparator",h.maxLookahead,Z(h))})})})}computeLookaheadFunc(e,t,n,r,i,o){this.TRACE_INIT(`${o}${t===0?"":t}`,()=>{let l=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:r});this.setLaFuncCache(this.fullRuleNameToShort[e.name],n|t,l)})}setLaFuncCache(e,t,n){let r=this.lookAheadFuncsCache[e];r===void 0&&(r=[],this.lookAheadFuncsCache[e]=r),r[t]=n}},ln=class extends Y{static{a(this,"DslMethodsCollectorVisitor")}constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(e){this.dslMethods.option.push(e)}visitRepetitionWithSeparator(e){this.dslMethods.repetitionWithSeparator.push(e)}visitRepetitionMandatory(e){this.dslMethods.repetitionMandatory.push(e)}visitRepetitionMandatoryWithSeparator(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)}visitRepetition(e){this.dslMethods.repetition.push(e)}visitAlternation(e){this.dslMethods.alternation.push(e)}},is=new ln;function Lo(s){is.reset(),s.accept(is);let e=is.dslMethods;return is.reset(),e}a(Lo,"collectMethods");function un(s,e){s.startOffset===-1?(s.startOffset=e.startOffset,s.endOffset=e.endOffset):s.endOffset<e.endOffset&&(s.endOffset=e.endOffset)}a(un,"setNodeLocationOnlyOffset");function pn(s,e){s.startOffset===-1?(s.startOffset=e.startOffset,s.startColumn=e.startColumn,s.startLine=e.startLine,s.endOffset=e.endOffset,s.endColumn=e.endColumn,s.endLine=e.endLine):s.endOffset<e.endOffset&&(s.endOffset=e.endOffset,s.endColumn=e.endColumn,s.endLine=e.endLine)}a(pn,"setNodeLocationFull");function Li(s,e,t){s.children[t]===void 0?s.children[t]=[e]:s.children[t].push(e)}a(Li,"addTerminalToCst");function Ni(s,e,t){s.children[e]===void 0?s.children[e]=[t]:s.children[e].push(t)}a(Ni,"addNoneTerminalToCst");var No="name";function fn(s,e){Object.defineProperty(s,No,{enumerable:!1,configurable:!0,writable:!1,value:e})}a(fn,"defineNameProp");function Io(s,e){let t=Object.keys(s),n=t.length;for(let r=0;r<n;r++){let i=t[r],o=s[i],l=o.length;for(let c=0;c<l;c++){let h=o[c];h.tokenTypeIdx===void 0&&this[h.name](h.children,e)}}}a(Io,"defaultVisit");function Ii(s,e){let t=a(function(){},"derivedConstructor");fn(t,s+"BaseSemantics");let n={visit:a(function(r,i){if(Array.isArray(r)&&(r=r[0]),r!==void 0)return this[r.name](r.children,i)},"visit"),validateVisitor:a(function(){let r=ko(this,e);if(r.length!==0){let i=r.map(o=>o.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
	${i.join(`

`).replace(/\n/g,`
	`)}`)}},"validateVisitor")};return t.prototype=n,t.prototype.constructor=t,t._RULE_NAMES=e,t}a(Ii,"createBaseSemanticVisitorConstructor");function ki(s,e,t){let n=a(function(){},"derivedConstructor");fn(n,s+"BaseSemanticsWithDefaults");let r=Object.create(t.prototype);return e.forEach(i=>{r[i]=Io}),n.prototype=r,n.prototype.constructor=n,n}a(ki,"createBaseVisitorConstructorWithDefaults");var mn;(function(s){s[s.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",s[s.MISSING_METHOD=1]="MISSING_METHOD"})(mn||(mn={}));function ko(s,e){return bo(s,e)}a(ko,"validateVisitor");function bo(s,e){return e.filter(r=>typeof s[r]!="function").map(r=>({msg:`Missing visitor method: <${r}> on ${s.constructor.name} CST Visitor.`,type:mn.MISSING_METHOD,methodName:r})).filter(Boolean)}a(bo,"validateMissingCstMethods");var hs=class{static{a(this,"TreeBuilder")}initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=Object.hasOwn(e,"nodeLocationTracking")?e.nodeLocationTracking:J.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=()=>{},this.cstFinallyStateUpdate=()=>{},this.cstPostTerminal=()=>{},this.cstPostNonTerminal=()=>{},this.cstPostRule=()=>{};else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=pn,this.setNodeLocationFromNode=pn,this.cstPostRule=()=>{},this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=un,this.setNodeLocationFromNode=un,this.cstPostRule=()=>{},this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=()=>{},this.setInitialNodeLocation=()=>{};else throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:-1,endOffset:-1}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA_FAST(1).startOffset,endOffset:-1}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:-1,startLine:-1,startColumn:-1,endOffset:-1,endLine:-1,endColumn:-1}}setInitialNodeLocationFullRegular(e){let t=this.LA_FAST(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:-1,endLine:-1,endColumn:-1}}cstInvocationStateUpdate(e){let t={name:e,children:Object.create(null)};this.setInitialNodeLocation(t),this.CST_STACK.push(t)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){let t=this.LA(0),n=e.location;n.startOffset!==-1&&n.startOffset<=t.startOffset?(n.endOffset=t.endOffset,n.endLine=t.endLine,n.endColumn=t.endColumn):(n.startOffset=-1,n.startLine=-1,n.startColumn=-1)}cstPostRuleOnlyOffset(e){let t=this.LA(0),n=e.location;n.startOffset!==-1&&n.startOffset<=t.startOffset?n.endOffset=t.endOffset:n.startOffset=-1}cstPostTerminal(e,t){let n=this.CST_STACK[this.CST_STACK.length-1];Li(n,t,e),this.setNodeLocationFromToken(n.location,t)}cstPostNonTerminal(e,t){let n=this.CST_STACK[this.CST_STACK.length-1];Ni(n,t,e),this.setNodeLocationFromNode(n.location,e.location)}get currCSTNode(){let e=this;return e.CST_STACK[e.CST_STACK.length-1]}getBaseCstVisitorConstructor(){if(this.baseCstVisitorConstructor===void 0){let e=Ii(this.className,Object.keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(this.baseCstVisitorWithDefaultsConstructor===void 0){let e=ki(this.className,Object.keys(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor}getPreviousExplicitRuleShortName(){return this.RULE_STACK[this.RULE_STACK_IDX-1]}getLastExplicitRuleOccurrenceIndex(){return this.RULE_OCCURRENCE_STACK[this.RULE_OCCURRENCE_STACK_IDX]}};var ds=class{static{a(this,"LexerAdapter")}initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVectorLength-2?(this.consumeToken(),this.LA_FAST(1)):Ee}LA_FAST(e){let t=this.currIdx+e;return this.tokVector[t]}LA(e){let t=this.currIdx+e;return t<0||this.tokVectorLength<=t?Ee:this.tokVector[t]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVectorLength-1}getLexerPosition(){return this.exportLexerState()}};var us=class{static{a(this,"RecognizerApi")}ACTION(e){return e.call(this)}consume(e,t,n){return this.consumeInternal(t,e,n)}subrule(e,t,n){return this.subruleInternal(t,e,n)}option(e,t){return this.optionInternal(t,e)}or(e,t){return this.orInternal(t,e)}many(e,t){return this.manyInternal(e,t)}atLeastOne(e,t){return this.atLeastOneInternal(e,t)}CONSUME(e,t){return this.consumeInternal(e,0,t)}CONSUME1(e,t){return this.consumeInternal(e,1,t)}CONSUME2(e,t){return this.consumeInternal(e,2,t)}CONSUME3(e,t){return this.consumeInternal(e,3,t)}CONSUME4(e,t){return this.consumeInternal(e,4,t)}CONSUME5(e,t){return this.consumeInternal(e,5,t)}CONSUME6(e,t){return this.consumeInternal(e,6,t)}CONSUME7(e,t){return this.consumeInternal(e,7,t)}CONSUME8(e,t){return this.consumeInternal(e,8,t)}CONSUME9(e,t){return this.consumeInternal(e,9,t)}SUBRULE(e,t){return this.subruleInternal(e,0,t)}SUBRULE1(e,t){return this.subruleInternal(e,1,t)}SUBRULE2(e,t){return this.subruleInternal(e,2,t)}SUBRULE3(e,t){return this.subruleInternal(e,3,t)}SUBRULE4(e,t){return this.subruleInternal(e,4,t)}SUBRULE5(e,t){return this.subruleInternal(e,5,t)}SUBRULE6(e,t){return this.subruleInternal(e,6,t)}SUBRULE7(e,t){return this.subruleInternal(e,7,t)}SUBRULE8(e,t){return this.subruleInternal(e,8,t)}SUBRULE9(e,t){return this.subruleInternal(e,9,t)}OPTION(e){return this.optionInternal(e,0)}OPTION1(e){return this.optionInternal(e,1)}OPTION2(e){return this.optionInternal(e,2)}OPTION3(e){return this.optionInternal(e,3)}OPTION4(e){return this.optionInternal(e,4)}OPTION5(e){return this.optionInternal(e,5)}OPTION6(e){return this.optionInternal(e,6)}OPTION7(e){return this.optionInternal(e,7)}OPTION8(e){return this.optionInternal(e,8)}OPTION9(e){return this.optionInternal(e,9)}OR(e){return this.orInternal(e,0)}OR1(e){return this.orInternal(e,1)}OR2(e){return this.orInternal(e,2)}OR3(e){return this.orInternal(e,3)}OR4(e){return this.orInternal(e,4)}OR5(e){return this.orInternal(e,5)}OR6(e){return this.orInternal(e,6)}OR7(e){return this.orInternal(e,7)}OR8(e){return this.orInternal(e,8)}OR9(e){return this.orInternal(e,9)}MANY(e){this.manyInternal(0,e)}MANY1(e){this.manyInternal(1,e)}MANY2(e){this.manyInternal(2,e)}MANY3(e){this.manyInternal(3,e)}MANY4(e){this.manyInternal(4,e)}MANY5(e){this.manyInternal(5,e)}MANY6(e){this.manyInternal(6,e)}MANY7(e){this.manyInternal(7,e)}MANY8(e){this.manyInternal(8,e)}MANY9(e){this.manyInternal(9,e)}MANY_SEP(e){this.manySepFirstInternal(0,e)}MANY_SEP1(e){this.manySepFirstInternal(1,e)}MANY_SEP2(e){this.manySepFirstInternal(2,e)}MANY_SEP3(e){this.manySepFirstInternal(3,e)}MANY_SEP4(e){this.manySepFirstInternal(4,e)}MANY_SEP5(e){this.manySepFirstInternal(5,e)}MANY_SEP6(e){this.manySepFirstInternal(6,e)}MANY_SEP7(e){this.manySepFirstInternal(7,e)}MANY_SEP8(e){this.manySepFirstInternal(8,e)}MANY_SEP9(e){this.manySepFirstInternal(9,e)}AT_LEAST_ONE(e){this.atLeastOneInternal(0,e)}AT_LEAST_ONE1(e){return this.atLeastOneInternal(1,e)}AT_LEAST_ONE2(e){this.atLeastOneInternal(2,e)}AT_LEAST_ONE3(e){this.atLeastOneInternal(3,e)}AT_LEAST_ONE4(e){this.atLeastOneInternal(4,e)}AT_LEAST_ONE5(e){this.atLeastOneInternal(5,e)}AT_LEAST_ONE6(e){this.atLeastOneInternal(6,e)}AT_LEAST_ONE7(e){this.atLeastOneInternal(7,e)}AT_LEAST_ONE8(e){this.atLeastOneInternal(8,e)}AT_LEAST_ONE9(e){this.atLeastOneInternal(9,e)}AT_LEAST_ONE_SEP(e){this.atLeastOneSepFirstInternal(0,e)}AT_LEAST_ONE_SEP1(e){this.atLeastOneSepFirstInternal(1,e)}AT_LEAST_ONE_SEP2(e){this.atLeastOneSepFirstInternal(2,e)}AT_LEAST_ONE_SEP3(e){this.atLeastOneSepFirstInternal(3,e)}AT_LEAST_ONE_SEP4(e){this.atLeastOneSepFirstInternal(4,e)}AT_LEAST_ONE_SEP5(e){this.atLeastOneSepFirstInternal(5,e)}AT_LEAST_ONE_SEP6(e){this.atLeastOneSepFirstInternal(6,e)}AT_LEAST_ONE_SEP7(e){this.atLeastOneSepFirstInternal(7,e)}AT_LEAST_ONE_SEP8(e){this.atLeastOneSepFirstInternal(8,e)}AT_LEAST_ONE_SEP9(e){this.atLeastOneSepFirstInternal(9,e)}RULE(e,t,n=He){if(this.definedRulesNames.includes(e)){let o={message:oe.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:j.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(o)}this.definedRulesNames.push(e);let r=this.defineRule(e,t,n);return this[e]=r,r}OVERRIDE_RULE(e,t,n=He){let r=fi(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(r);let i=this.defineRule(e,t,n);return this[e]=i,i}BACKTRACK(e,t){var n;let r=(n=e.coreRule)!==null&&n!==void 0?n:e;return function(){this.isBackTrackingStack.push(1);let i=this.saveRecogState();try{return r.apply(this,t),!0}catch(o){if(Se(o))return!1;throw o}finally{this.reloadRecogState(i),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return Dt(Object.values(this.gastProductionsCache))}};var ps=class{static{a(this,"RecognizerEngine")}initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull=[],this.fullRuleNameToShort={},this.ruleShortNameIdx=0,this.tokenMatcher=Ke,this.subruleIdx=0,this.currRuleShortName=-1,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK=[],this.RULE_OCCURRENCE_STACK_IDX=-1,this.gastProductionsCache={},Object.hasOwn(t,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
	See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
	For Further details.`);if(Array.isArray(e)){if(e.length===0)throw Error(`A Token Vocabulary cannot be empty.
	Note that the first argument for the parser constructor
	is no longer a Token vector (since v4.0).`);if(typeof e[0].startOffset=="number")throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
	See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
	For Further details.`)}if(Array.isArray(e))this.tokensMap=e.reduce((i,o)=>(i[o.name]=o,i),{});else if(Object.hasOwn(e,"modes")&&Object.values(e.modes).flat().every(Vr)){let i=Object.values(e.modes).flat(),o=[...new Set(i)];this.tokensMap=o.reduce((l,c)=>(l[c.name]=c,l),{})}else if(typeof e=="object"&&e!==null)this.tokensMap=Object.assign({},e);else throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=Q;let r=(Object.hasOwn(e,"modes")?Object.values(e.modes).flat():Object.values(e)).every(i=>{var o;return((o=i.categoryMatches)===null||o===void 0?void 0:o.length)==0});this.tokenMatcher=r?Ke:me,ge(Object.values(this.tokensMap))}defineRule(e,t,n){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called'
Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let r=Object.hasOwn(n,"resyncEnabled")?n.resyncEnabled:He.resyncEnabled,i=Object.hasOwn(n,"recoveryValueFunc")?n.recoveryValueFunc:He.recoveryValueFunc,o=this.ruleShortNameIdx++;this.shortRuleNameToFull[o]=e,this.fullRuleNameToShort[e]=o;let l;return this.outputCst===!0?l=a(function(...d){try{this.ruleInvocationStateUpdate(o,e,this.subruleIdx),t.apply(this,d);let p=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(p),p}catch(p){return this.invokeRuleCatch(p,r,i)}finally{this.ruleFinallyStateUpdate()}},"invokeRuleWithTry"):l=a(function(...d){try{return this.ruleInvocationStateUpdate(o,e,this.subruleIdx),t.apply(this,d)}catch(p){return this.invokeRuleCatch(p,r,i)}finally{this.ruleFinallyStateUpdate()}},"invokeRuleWithTryCst"),Object.assign(a(function(...d){this.onBeforeParse(e);try{return l.apply(this,d)}finally{this.onAfterParse(e)}},"rootRule"),{ruleName:e,originalGrammarAction:t,coreRule:l})}invokeRuleCatch(e,t,n){let r=this.RULE_STACK_IDX===0,i=t&&!this.isBackTracking()&&this.recoveryEnabled;if(Se(e)){let o=e;if(i){let l=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(l))if(o.resyncedTokens=this.reSyncTo(l),this.outputCst){let c=this.CST_STACK[this.CST_STACK.length-1];return c.recoveredNode=!0,c}else return n(e);else{if(this.outputCst){let c=this.CST_STACK[this.CST_STACK.length-1];c.recoveredNode=!0,o.partialCstResult=c}throw o}}else{if(r)return this.moveToTerminatedState(),n(e);throw o}}else throw e}optionInternal(e,t){let n=512|t;return this.optionInternalLogic(e,t,n)}optionInternalLogic(e,t,n){let r=this.currRuleLookaheadFuncs[n],i;if(typeof e!="function"){i=e.DEF;let o=e.GATE;if(o!==void 0){let l=r;r=a(()=>o.call(this)&&l.call(this),"lookAheadFunc")}}else i=e;if(r.call(this)===!0)return i.call(this)}atLeastOneInternal(e,t){let n=1024|e;return this.atLeastOneInternalLogic(e,t,n)}atLeastOneInternalLogic(e,t,n){let r=this.currRuleLookaheadFuncs[n],i;if(typeof t!="function"){i=t.DEF;let o=t.GATE;if(o!==void 0){let l=r;r=a(()=>o.call(this)&&l.call(this),"lookAheadFunc")}}else i=t;if(r.call(this)===!0){let o=this.doSingleRepetition(i);for(;r.call(this)===!0&&o===!0;)o=this.doSingleRepetition(i)}else throw this.raiseEarlyExitException(e,M.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],r,1024,e,Zt)}atLeastOneSepFirstInternal(e,t){let n=1536|e;this.atLeastOneSepFirstInternalLogic(e,t,n)}atLeastOneSepFirstInternalLogic(e,t,n){let r=t.DEF,i=t.SEP;if(this.currRuleLookaheadFuncs[n].call(this)===!0){r.call(this);let l=a(()=>this.tokenMatcher(this.LA_FAST(1),i),"separatorLookAheadFunc");for(;this.tokenMatcher(this.LA_FAST(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,l,r,gt],l,1536,e,gt)}else throw this.raiseEarlyExitException(e,M.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){let n=768|e;return this.manyInternalLogic(e,t,n)}manyInternalLogic(e,t,n){let r=this.currRuleLookaheadFuncs[n],i;if(typeof t!="function"){i=t.DEF;let l=t.GATE;if(l!==void 0){let c=r;r=a(()=>l.call(this)&&c.call(this),"lookaheadFunction")}}else i=t;let o=!0;for(;r.call(this)===!0&&o===!0;)o=this.doSingleRepetition(i);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],r,768,e,qt,o)}manySepFirstInternal(e,t){let n=1280|e;this.manySepFirstInternalLogic(e,t,n)}manySepFirstInternalLogic(e,t,n){let r=t.DEF,i=t.SEP;if(this.currRuleLookaheadFuncs[n].call(this)===!0){r.call(this);let l=a(()=>this.tokenMatcher(this.LA_FAST(1),i),"separatorLookAheadFunc");for(;this.tokenMatcher(this.LA_FAST(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,l,r,mt],l,1280,e,mt)}}repetitionSepSecondInternal(e,t,n,r,i){for(;n();)this.CONSUME(t),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,n,r,i],n,1536,e,i)}doSingleRepetition(e){let t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){let n=256|t,r=Array.isArray(e)?e:e.DEF,o=this.currRuleLookaheadFuncs[n].call(this,r);if(o!==void 0)return r[o].ALT.call(this);this.raiseNoAltException(t,e.ERR_MSG)}ruleFinallyStateUpdate(){this.RULE_STACK_IDX--,this.RULE_OCCURRENCE_STACK_IDX--,this.RULE_STACK_IDX>=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX],this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[this.currRuleShortName]),this.cstFinallyStateUpdate()}subruleInternal(e,t,n){let r;try{let i=n!==void 0?n.ARGS:void 0;return this.subruleIdx=t,r=e.coreRule.apply(this,i),this.cstPostNonTerminal(r,n!==void 0&&n.LABEL!==void 0?n.LABEL:e.ruleName),r}catch(i){throw this.subruleInternalError(i,n,e.ruleName)}}subruleInternalError(e,t,n){throw Se(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,t!==void 0&&t.LABEL!==void 0?t.LABEL:n),delete e.partialCstResult),e}consumeInternal(e,t,n){let r;try{let i=this.LA_FAST(1);this.tokenMatcher(i,e)===!0?(this.consumeToken(),r=i):this.consumeInternalError(e,i,n)}catch(i){r=this.consumeInternalRecovery(e,t,i)}return this.cstPostTerminal(n!==void 0&&n.LABEL!==void 0?n.LABEL:e.name,r),r}consumeInternalError(e,t,n){let r,i=this.LA(0);throw n!==void 0&&n.ERR_MSG?r=n.ERR_MSG:r=this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new Me(r,t,i))}consumeInternalRecovery(e,t,n){if(this.recoveryEnabled&&n.name==="MismatchedTokenException"&&!this.isBackTracking()){let r=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,r)}catch(i){throw i.name===cn?n:i}}else throw n}saveRecogState(){let e=this.errors,t=this.RULE_STACK.slice(0,this.RULE_STACK_IDX+1);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:t,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState);let t=e.RULE_STACK;for(let n=0;n<t.length;n++)this.RULE_STACK[n]=t[n];this.RULE_STACK_IDX=t.length-1,this.RULE_STACK_IDX>=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX],this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[this.currRuleShortName])}ruleInvocationStateUpdate(e,t,n){this.RULE_OCCURRENCE_STACK[++this.RULE_OCCURRENCE_STACK_IDX]=n,this.RULE_STACK[++this.RULE_STACK_IDX]=e,this.currRuleShortName=e,this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[e],this.cstInvocationStateUpdate(t)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let e=this.currRuleShortName;return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),Q)}reset(){this.resetLexerState(),this.subruleIdx=0,this.currRuleShortName=-1,this.currRuleLookaheadFuncs=[],this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK_IDX=-1,this.CST_STACK=[]}onBeforeParse(e){for(let t=0;t<this.maxLookahead+1;t++)this.tokVector.push(Ee)}onAfterParse(e){if(this.isAtEndOfInput()===!1){let t=this.LA(1),n=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:t,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new Rt(n,t))}for(;this.tokVector.at(-1)===Ee;)this.tokVector.pop()}};var fs=class{static{a(this,"ErrorHandler")}initErrorHandler(e){this._errors=[],this.errorMessageProvider=Object.hasOwn(e,"errorMessageProvider")?e.errorMessageProvider:J.errorMessageProvider}SAVE_ERROR(e){if(Se(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1)},this._errors.push(e),e;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return[...this._errors]}set errors(e){this._errors=e}raiseEarlyExitException(e,t,n){let r=this.getCurrRuleFullName(),i=this.getGAstProductions()[r],l=Tt(e,i,t,this.maxLookahead)[0],c=[];for(let u=1;u<=this.maxLookahead;u++)c.push(this.LA(u));let h=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:l,actual:c,previous:this.LA(0),customUserDescription:n,ruleName:r});throw this.SAVE_ERROR(new At(h,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){let n=this.getCurrRuleFullName(),r=this.getGAstProductions()[n],i=Et(e,r,this.maxLookahead),o=[];for(let h=1;h<=this.maxLookahead;h++)o.push(this.LA(h));let l=this.LA(0),c=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:i,actual:o,previous:l,customUserDescription:t,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new St(c,this.LA(1),l))}};var Es={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(Es);var bi=!0,xi=255,vi=y({name:"RECORDING_PHASE_TOKEN",pattern:v.NA});ge([vi]);var Mi=ve(vi,`This IToken indicates the Parser is in Recording Phase
	See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(Mi);var xo={name:`This CSTNode indicates the Parser is in Recording Phase
	See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},ms=class{static{a(this,"GastRecorder")}initGastRecorder(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let e=0;e<10;e++){let t=e>0?e:"";this[`CONSUME${t}`]=function(n,r){return this.consumeInternalRecord(n,e,r)},this[`SUBRULE${t}`]=function(n,r){return this.subruleInternalRecord(n,e,r)},this[`OPTION${t}`]=function(n){return this.optionInternalRecord(n,e)},this[`OR${t}`]=function(n){return this.orInternalRecord(n,e)},this[`MANY${t}`]=function(n){this.manyInternalRecord(e,n)},this[`MANY_SEP${t}`]=function(n){this.manySepFirstInternalRecord(e,n)},this[`AT_LEAST_ONE${t}`]=function(n){this.atLeastOneInternalRecord(e,n)},this[`AT_LEAST_ONE_SEP${t}`]=function(n){this.atLeastOneSepFirstInternalRecord(e,n)}}this.consume=function(e,t,n){return this.consumeInternalRecord(t,e,n)},this.subrule=function(e,t,n){return this.subruleInternalRecord(t,e,n)},this.option=function(e,t){return this.optionInternalRecord(t,e)},this.or=function(e,t){return this.orInternalRecord(t,e)},this.many=function(e,t){this.manyInternalRecord(e,t)},this.atLeastOne=function(e,t){this.atLeastOneInternalRecord(e,t)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",()=>{let e=this;for(let t=0;t<10;t++){let n=t>0?t:"";delete e[`CONSUME${n}`],delete e[`SUBRULE${n}`],delete e[`OPTION${n}`],delete e[`OR${n}`],delete e[`MANY${n}`],delete e[`MANY_SEP${n}`],delete e[`AT_LEAST_ONE${n}`],delete e[`AT_LEAST_ONE_SEP${n}`]}delete e.consume,delete e.subrule,delete e.option,delete e.or,delete e.many,delete e.atLeastOne,delete e.ACTION,delete e.BACKTRACK,delete e.LA})}ACTION_RECORD(e){}BACKTRACK_RECORD(e,t){return()=>!0}LA_RECORD(e){return Ee}topLevelRuleRecord(e,t){try{let n=new X({definition:[],name:e});return n.name=e,this.recordingProdStack.push(n),t.call(this),this.recordingProdStack.pop(),n}catch(n){if(n.KNOWN_RECORDER_ERROR!==!0)try{n.message=n.message+`
	 This error was thrown during the "grammar recording phase" For more info see:
	https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw n}throw n}}optionInternalRecord(e,t){return Lt.call(this,x,e,t)}atLeastOneInternalRecord(e,t){Lt.call(this,F,t,e)}atLeastOneSepFirstInternalRecord(e,t){Lt.call(this,B,t,e,bi)}manyInternalRecord(e,t){Lt.call(this,N,t,e)}manySepFirstInternalRecord(e,t){Lt.call(this,w,t,e,bi)}orInternalRecord(e,t){return _o.call(this,e,t)}subruleInternalRecord(e,t,n){if(gs(t),!e||!Object.hasOwn(e,"ruleName")){let l=new Error(`<SUBRULE${_i(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>
 inside top level rule: <${this.recordingProdStack[0].name}>`);throw l.KNOWN_RECORDER_ERROR=!0,l}let r=this.recordingProdStack.at(-1),i=e.ruleName,o=new k({idx:t,nonTerminalName:i,label:n?.LABEL,referencedRule:void 0});return r.definition.push(o),this.outputCst?xo:Es}consumeInternalRecord(e,t,n){if(gs(t),!Ys(e)){let o=new Error(`<CONSUME${_i(t)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>
 inside top level rule: <${this.recordingProdStack[0].name}>`);throw o.KNOWN_RECORDER_ERROR=!0,o}let r=this.recordingProdStack.at(-1),i=new C({idx:t,terminalType:e,label:n?.LABEL});return r.definition.push(i),Mi}};function Lt(s,e,t,n=!1){gs(t);let r=this.recordingProdStack.at(-1),i=typeof e=="function"?e:e.DEF,o=new s({definition:[],idx:t});return n&&(o.separator=e.SEP),Object.hasOwn(e,"MAX_LOOKAHEAD")&&(o.maxLookahead=e.MAX_LOOKAHEAD),this.recordingProdStack.push(o),i.call(this),r.definition.push(o),this.recordingProdStack.pop(),Es}a(Lt,"recordProd");function _o(s,e){gs(e);let t=this.recordingProdStack.at(-1),n=Array.isArray(s)===!1,r=n===!1?s:s.DEF,i=new P({definition:[],idx:e,ignoreAmbiguities:n&&s.IGNORE_AMBIGUITIES===!0});Object.hasOwn(s,"MAX_LOOKAHEAD")&&(i.maxLookahead=s.MAX_LOOKAHEAD);let o=r.some(l=>typeof l.GATE=="function");return i.hasPredicates=o,t.definition.push(i),r.forEach(l=>{let c=new b({definition:[]});i.definition.push(c),Object.hasOwn(l,"IGNORE_AMBIGUITIES")?c.ignoreAmbiguities=l.IGNORE_AMBIGUITIES:Object.hasOwn(l,"GATE")&&(c.ignoreAmbiguities=!0),this.recordingProdStack.push(c),l.ALT.call(this),this.recordingProdStack.pop()}),Es}a(_o,"recordOrProd");function _i(s){return s===0?"":`${s}`}a(_i,"getIdxSuffix");function gs(s){if(s<0||s>xi){let e=new Error(`Invalid DSL Method idx value: <${s}>
	Idx value must be a none negative value smaller than ${xi+1}`);throw e.KNOWN_RECORDER_ERROR=!0,e}}a(gs,"assertMethodIdxIsValid");var Ts=class{static{a(this,"PerformanceTracer")}initPerformanceTracer(e){if(Object.hasOwn(e,"traceInitPerf")){let t=e.traceInitPerf,n=typeof t=="number";this.traceInitMaxIdent=n?t:1/0,this.traceInitPerf=n?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=J.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(this.traceInitPerf===!0){this.traceInitIndent++;let n=new Array(this.traceInitIndent+1).join("	");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${e}>`);let{time:r,value:i}=it(t),o=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&o(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}else return t()}};function Ui(s,e){e.forEach(t=>{let n=t.prototype;Object.getOwnPropertyNames(n).forEach(r=>{if(r==="constructor")return;let i=Object.getOwnPropertyDescriptor(n,r);i&&(i.get||i.set)?Object.defineProperty(s.prototype,r,i):s.prototype[r]=t.prototype[r]})})}a(Ui,"applyMixins");var Ee=ve(Q,"",-1,-1,-1,-1,-1,-1);Object.freeze(Ee);var J=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:Yt,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),He=Object.freeze({recoveryValueFunc:a(()=>{},"recoveryValueFunc"),resyncEnabled:!0}),j;(function(s){s[s.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",s[s.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",s[s.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",s[s.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",s[s.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",s[s.LEFT_RECURSION=5]="LEFT_RECURSION",s[s.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",s[s.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",s[s.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",s[s.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",s[s.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",s[s.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",s[s.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",s[s.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"})(j||(j={}));var Nt=class s{static{a(this,"Parser")}static performSelfAnalysis(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated.	\nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let e;this.selfAnalysisDone=!0;let t=this.className;this.TRACE_INIT("toFastProps",()=>{at(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),this.definedRulesNames.forEach(r=>{let o=this[r].originalGrammarAction,l;this.TRACE_INIT(`${r} Rule`,()=>{l=this.topLevelRuleRecord(r,o)}),this.gastProductionsCache[r]=l})}finally{this.disableRecording()}});let n=[];if(this.TRACE_INIT("Grammar Resolving",()=>{n=Ti({rules:Object.values(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT("Grammar Validations",()=>{if(n.length===0&&this.skipValidations===!1){let r=yi({rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),errMsgProvider:oe,grammarName:t}),i=di({lookaheadStrategy:this.lookaheadStrategy,rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),grammarName:t});this.definitionErrors=this.definitionErrors.concat(r,i)}}),this.definitionErrors.length===0&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{let r=Ir(Object.values(this.gastProductionsCache));this.resyncFollows=r}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var r,i;(i=(r=this.lookaheadStrategy).initialize)===null||i===void 0||i.call(r,{rules:Object.values(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(Object.values(this.gastProductionsCache))})),!s.DEFER_DEFINITION_ERRORS_HANDLING&&this.definitionErrors.length!==0)throw e=this.definitionErrors.map(r=>r.message),new Error(`Parser Definition Errors detected:
 ${e.join(`
-------------------------------
`)}`)})}constructor(e,t){this.definitionErrors=[],this.selfAnalysisDone=!1;let n=this;if(n.initErrorHandler(t),n.initLexerAdapter(),n.initLooksAhead(t),n.initRecognizerEngine(e,t),n.initRecoverable(t),n.initTreeBuilder(t),n.initGastRecorder(t),n.initPerformanceTracer(t),Object.hasOwn(t,"ignoredIssues"))throw new Error(`The <ignoredIssues> IParserConfig property has been deprecated.
	Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
	See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
	For further details.`);this.skipValidations=Object.hasOwn(t,"skipValidations")?t.skipValidations:J.skipValidations}};Nt.DEFER_DEFINITION_ERRORS_HANDLING=!1;Ui(Nt,[rs,as,hs,ds,ps,us,fs,ms,Ts]);var It=class extends Nt{static{a(this,"CstParser")}constructor(e,t=J){let n=Object.assign({},t);n.outputCst=!0,super(e,n)}};function Xe(s,e,t){let n=[t];return n.index=e,n.input=s,n}a(Xe,"customMatch");var Mo=a((s,e)=>{if(s[e]!=='"'||s[e+1]!=="`")return null;for(let t=e+2;t<s.length-1;t++)if(s[t]==="`"&&s[t+1]==='"')return Xe(s,e,s.slice(e,t+2));return null},"matchMarkdownString"),Uo=a((s,e)=>{if(s[e]!=="%"||s[e+1]!=="%")return null;for(let n=e-1;n>=0;n--){let r=s[n];if(r===`
`||r==="\r")break;if(r!==" "&&r!=="	")return null}let t=e+2;for(;t<s.length&&s[t]!==`
`&&s[t]!=="\r";)t++;return Xe(s,e,s.slice(e,t))},"matchComment"),wi=a((s,e)=>{for(let t=e-1;t>=0;t--){let n=s[t];if(n===`
`||n==="\r")return!0;if(n!==" "&&n!=="	")return!1}return!0},"isIndentedLineStart"),Pi=a((s,e,t)=>{if(!wi(s,e))return null;let n=t.exec(s.slice(e));return n?Xe(s,e,n[0]):null},"matchAccessibilityLine"),wo=a((s,e)=>{if(!wi(s,e))return null;let t=/^accDescr[\t ]*{/.exec(s.slice(e));if(!t)return null;let n=s.indexOf("}",e+t[0].length);return n===-1?null:Xe(s,e,s.slice(e,n+1))},"matchAccDescrBlock"),Po=a((s,e)=>{if(s[e]!=="{")return null;let t=0,n=!1,r=!1;for(let i=e;i<s.length;i++){let o=s[i];if(n){r?r=!1:o==="\\"?r=!0:o==='"'&&(n=!1);continue}if(o==='"')n=!0;else if(o==="{")t++;else if(o==="}"&&--t===0)return Xe(s,e,s.slice(e,i+1))}return null},"matchJsonObject"),Do=a((s,e)=>{let t=s.indexOf(">>",e);if(t===-1||/[\n\r]/.test(s.slice(e,t)))return null;let n=s.slice(e,t);return n.trim()?Xe(s,e,n):null},"matchStereotypeText"),W=y({name:"LABEL_TEXT",pattern:v.NA}),Ue=y({name:"WORD",pattern:v.NA,categories:W}),ys=y({name:"NUMBER",pattern:/(?:\d+\.\d+|\d+|\.\d+)(?:[A-Za-z]+)?/,categories:W}),U=y({name:"IDENTIFIER",pattern:/\w+/,longer_alt:ys,categories:Ue}),Fo=y({name:"HWS",pattern:/[\t ]+/,group:v.SKIPPED}),de=y({name:"MARKDOWN_STRING",pattern:Mo,start_chars_hint:['"'],line_breaks:!0}),Bo=y({name:"UNCLOSED_MARKDOWN_STRING",pattern:/"`[^]*/,line_breaks:!0}),Ss=y({name:"COMMENT",pattern:Uo,start_chars_hint:["%"],line_breaks:!1}),ue=y({name:"NEWLINE",pattern:/\r\n|\n|\r/,line_breaks:!0}),gn=y({name:"ACC_DESCR_BLOCK",pattern:wo,start_chars_hint:["a"],line_breaks:!0}),$o=/^accTitle[\t ]*:[^\n\r]*/,Go=/^accDescr[\t ]*:[^\n\r]*/,En=y({name:"ACC_TITLE_LINE",pattern:a((s,e)=>Pi(s,e,$o),"pattern"),start_chars_hint:["a"],line_breaks:!1}),Tn=y({name:"ACC_DESCR_LINE",pattern:a((s,e)=>Pi(s,e,Go),"pattern"),start_chars_hint:["a"],line_breaks:!1}),yn=y({name:"JSON_DECLARATION_START",pattern:/json[\t ]+\w+[\t ]*@[\t ]*(?={)/,push_mode:"jsonBody"}),Rs=y({name:"JSON_OBJECT_LITERAL",pattern:Po,start_chars_hint:["{"],line_breaks:!0,pop_mode:!0}),Di=y({name:"UNCLOSED_JSON_OBJECT_LITERAL",pattern:/{[^]*/,line_breaks:!0,pop_mode:!0}),$=a((s,e)=>y({name:s,pattern:e,longer_alt:U,categories:Ue}),"keyword"),Sn=$("USECASE",/usecase-beta/),As=$("ACTOR",/actor/),Rn=$("SYSTEM_BOUNDARY",/systemBoundary/),An=$("END",/end/),On=$("DIRECTION",/direction/),Cn=$("TD",/TD/),Ln=$("TB",/TB/),Nn=$("BT",/BT/),In=$("LR",/LR/),kn=$("RL",/RL/),bn=$("NOTE",/note/),xn=$("FOR",/for/),jo=$("JSON",/json/),_n=$("CLASS_DEF",/classDef/),vn=$("CLASS",/class/),Mn=$("STYLE",/style/),Un=$("INCLUDE",/include/i),wn=$("EXTEND",/extend/i),Pn=$("TRUE",/true/),Dn=$("FALSE",/false/),Fn=y({name:"GENERALIZATION",pattern:/--\|>/}),Bn=y({name:"DEPENDENCY_ARROW",pattern:/\.\.>/}),$n=y({name:"STEREOTYPE_START",pattern:/<</,push_mode:"stereotype"}),Os=y({name:"STEREOTYPE_END",pattern:/>>/,pop_mode:!0}),Cs=y({name:"STEREOTYPE_TEXT",pattern:Do,line_breaks:!1}),Fi=y({name:"UNCLOSED_STEREOTYPE_TEXT",pattern:/[^\n\r]+/,line_breaks:!1,pop_mode:!0}),Gn=y({name:"CLASS_SEPARATOR",pattern:/:::/}),kt=y({name:"FORWARD_SOLID",pattern:/--+>/}),jn=y({name:"BACKWARD_SOLID",pattern:/<--+/}),bt=y({name:"FORWARD_CIRCLE",pattern:/--o/}),Wn=y({name:"BACKWARD_CIRCLE",pattern:/o--/}),xt=y({name:"FORWARD_CROSS",pattern:/--x/}),Kn=y({name:"BACKWARD_CROSS",pattern:/x--/}),te=y({name:"MARKERLESS_SOLID",pattern:/--+/}),Ls=y({name:"METADATA_START",pattern:/@{/}),_t=y({name:"AT",pattern:/@/,categories:W}),Vn=y({name:"LBRACE",pattern:/{/}),Ns=y({name:"RBRACE",pattern:/}/}),vt=y({name:"LBRACKET",pattern:/\[/}),Mt=y({name:"RBRACKET",pattern:/]/}),Ye=y({name:"LPAREN",pattern:/\(/}),Je=y({name:"RPAREN",pattern:/\)/}),ie=y({name:"COMMA",pattern:/,/,categories:W}),qe=y({name:"COLON",pattern:/:/,categories:W}),zn=y({name:"HASH_COLOR",pattern:/#[\dA-Fa-f]+/,categories:W}),se=y({name:"PLAIN_STRING",pattern:/"[^\n\r"]*"|'[^\n\r']*'/}),Is=y({name:"CSS_IDENTIFIER",pattern:/--[A-Z_a-z][\w-]*|[A-Z_a-z]\w*(?:-\w+)+/,categories:W}),Hn=y({name:"CSS_ESCAPED_COMMA",pattern:/\\,/,categories:W}),Xn=y({name:"DASH",pattern:/-/,categories:W}),Yn=y({name:"DOT",pattern:/\./,categories:W}),Jn=y({name:"PERCENT",pattern:/%/,categories:W}),qn=y({name:"CSS_PUNCTUATION",pattern:/[!#$&*+/=?^_|~]/,categories:W}),Wo=y({name:"LABEL_PUNCTUATION",pattern:/[;<>\\`]/,categories:W}),Ko=y({name:"LABEL_SYMBOL",pattern:/[^\t\n\r !-~]+/,categories:W}),Bi=[W,Ue,Fo,de,Bo,Ss,ue,gn,En,Tn,yn,Sn,As,Rn,An,On,Cn,Ln,Nn,In,kn,bn,xn,jo,_n,vn,Mn,Un,wn,Pn,Dn,Fn,Bn,$n,Gn,kt,jn,bt,Wn,xt,Kn,te,Ls,_t,Vn,Ns,vt,Mt,Ye,Je,ie,qe,zn,se,Is,U,ys,Hn,Xn,Yn,Jn,qn,Wo,Ko],$i={defaultMode:"defaultMode",modes:{defaultMode:[...Bi],jsonBody:[Rs,Di],stereotype:[Os,Cs,Fi]}},Gi=[...Bi,Rs,Di,Os,Cs,Fi];var ji=new v($i);var Wi=a(s=>ft(s,W)||s.tokenType===se||s.tokenType===de,"isLabelToken"),Vo={allowmixing:!0,newpage:!0,package:!0,rectangle:!0,skinparam:!0},Zn=class extends It{static{a(this,"UsecaseParser")}constructor(){super(Gi,{nodeLocationTracking:"full"}),this.RULE("start",()=>{this.CONSUME(Sn),this.SUBRULE(this.lineEnd),this.MANY(()=>this.SUBRULE(this.line))}),this.RULE("line",()=>{this.OR([{ALT:a(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:a(()=>this.SUBRULE(this.commentLine),"ALT")},{GATE:a(()=>this.isStatementStart(),"GATE"),ALT:a(()=>this.SUBRULE(this.statement),"ALT")}])}),this.RULE("statement",()=>{this.OR([{ALT:a(()=>this.SUBRULE(this.accTitleStatement),"ALT")},{ALT:a(()=>this.SUBRULE(this.accDescrStatement),"ALT")},{ALT:a(()=>this.SUBRULE(this.directionStatement),"ALT")},{ALT:a(()=>this.SUBRULE(this.actorStatement),"ALT")},{ALT:a(()=>this.SUBRULE(this.systemBoundaryStatement),"ALT")},{ALT:a(()=>this.SUBRULE(this.noteStatement),"ALT")},{ALT:a(()=>this.SUBRULE(this.jsonStatement),"ALT")},{ALT:a(()=>this.SUBRULE(this.classDefStatement),"ALT")},{ALT:a(()=>this.SUBRULE(this.classStatement),"ALT")},{ALT:a(()=>this.SUBRULE(this.styleStatement),"ALT")},{GATE:a(()=>this.isMetadataAssignment(),"GATE"),ALT:a(()=>this.SUBRULE(this.metadataAssignmentStatement),"ALT")},{GATE:a(()=>!this.isForbiddenPlantUmlStatement(),"GATE"),ALT:a(()=>this.SUBRULE(this.entityStatement),"ALT")}])}),this.RULE("lineEnd",()=>{this.OR([{ALT:a(()=>this.CONSUME(ue),"ALT")},{ALT:a(()=>this.CONSUME(Q),"ALT")}])}),this.RULE("blankLine",()=>{this.CONSUME(ue)}),this.RULE("commentLine",()=>{this.CONSUME(Ss),this.SUBRULE(this.lineEnd)}),this.RULE("accTitleStatement",()=>{this.CONSUME(En),this.SUBRULE(this.lineEnd)}),this.RULE("accDescrStatement",()=>{this.OR([{ALT:a(()=>this.CONSUME(Tn),"ALT")},{ALT:a(()=>this.CONSUME(gn),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("actorStatement",()=>{this.CONSUME(As),this.SUBRULE(this.actorItem),this.OPTION(()=>{this.OR([{ALT:a(()=>this.AT_LEAST_ONE(()=>{this.CONSUME(ie),this.SUBRULE2(this.actorItem)}),"ALT")},{ALT:a(()=>this.SUBRULE(this.relationTail),"ALT")}])}),this.SUBRULE(this.lineEnd)}),this.RULE("actorItem",()=>{this.SUBRULE(this.actorName),this.OPTION(()=>this.SUBRULE(this.metadata)),this.OPTION2(()=>this.SUBRULE(this.stereotype)),this.OPTION3(()=>this.SUBRULE(this.classSuffix))}),this.RULE("actorName",()=>{this.OR([{ALT:a(()=>{this.CONSUME(U),this.OPTION(()=>{this.CONSUME(Ye),this.SUBRULE(this.nodeLabel),this.CONSUME(Je)})},"ALT")},{ALT:a(()=>this.CONSUME(se),"ALT")},{ALT:a(()=>this.CONSUME(de),"ALT")}])}),this.RULE("actorDeclarationOnly",()=>{this.CONSUME(As),this.SUBRULE(this.actorItem),this.MANY(()=>{this.CONSUME(ie),this.SUBRULE2(this.actorItem)}),this.SUBRULE(this.lineEnd)}),this.RULE("entityStatement",()=>{this.SUBRULE(this.entityName),this.OPTION(()=>this.SUBRULE(this.relationTail)),this.SUBRULE(this.lineEnd)}),this.RULE("entityName",()=>{this.OR([{ALT:a(()=>{this.CONSUME(U),this.OPTION(()=>{this.OR2([{ALT:a(()=>{this.CONSUME(Ye),this.SUBRULE(this.nodeLabel),this.CONSUME(Je)},"ALT")},{ALT:a(()=>{this.CONSUME(vt),this.SUBRULE2(this.nodeLabel),this.CONSUME(Mt)},"ALT")}])})},"ALT")},{ALT:a(()=>this.CONSUME(se),"ALT")},{ALT:a(()=>this.CONSUME(de),"ALT")}]),this.OPTION2(()=>this.SUBRULE(this.useCaseMetadata)),this.OPTION3(()=>this.SUBRULE(this.stereotype)),this.OPTION4(()=>this.SUBRULE(this.classSuffix))}),this.RULE("nodeLabel",()=>{this.OR([{ALT:a(()=>this.CONSUME(se),"ALT")},{ALT:a(()=>this.CONSUME(de),"ALT")},{ALT:a(()=>this.AT_LEAST_ONE(()=>this.CONSUME(W)),"ALT")}])}),this.RULE("useCaseMetadata",()=>{this.SUBRULE(this.metadata)}),this.RULE("relationTail",()=>{this.OPTION({GATE:a(()=>this.LA(1).tokenType===U&&this.LA(2).tokenType===_t,"GATE"),DEF:a(()=>{this.CONSUME(U),this.CONSUME(_t)},"DEF")}),this.SUBRULE(this.arrow),this.SUBRULE(this.entityName)}),this.RULE("arrow",()=>{this.OR([{ALT:a(()=>this.SUBRULE(this.semanticRelation),"ALT")},{ALT:a(()=>this.SUBRULE(this.forwardSolidOperator),"ALT")},{ALT:a(()=>this.SUBRULE(this.backwardSolidOperator),"ALT")},{ALT:a(()=>this.SUBRULE(this.markerlessSolidOperator),"ALT")},{ALT:a(()=>this.SUBRULE(this.forwardCircleOperator),"ALT")},{ALT:a(()=>this.SUBRULE(this.backwardCircleOperator),"ALT")},{ALT:a(()=>this.SUBRULE(this.forwardCrossOperator),"ALT")},{ALT:a(()=>this.SUBRULE(this.backwardCrossOperator),"ALT")}])}),this.RULE("forwardSolidOperator",()=>{this.CONSUME(kt)}),this.RULE("backwardSolidOperator",()=>{this.CONSUME(jn),this.OPTION({GATE:a(()=>this.LA(0).image==="<--"&&this.hasLabeledRight([te]),"GATE"),DEF:a(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(te)},"DEF")})}),this.RULE("markerlessSolidOperator",()=>{this.CONSUME(te),this.OPTION({GATE:a(()=>this.LA(0).image==="--"&&this.hasLabeledRight([kt,te,bt,xt]),"GATE"),DEF:a(()=>{this.SUBRULE(this.edgeLabel),this.OR([{ALT:a(()=>this.CONSUME(kt),"ALT")},{ALT:a(()=>this.CONSUME2(te),"ALT")},{ALT:a(()=>this.CONSUME(bt),"ALT")},{ALT:a(()=>this.CONSUME(xt),"ALT")}])},"DEF")})}),this.RULE("forwardCircleOperator",()=>{this.CONSUME(bt)}),this.RULE("backwardCircleOperator",()=>{this.CONSUME(Wn),this.OPTION({GATE:a(()=>this.hasLabeledRight([te]),"GATE"),DEF:a(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(te)},"DEF")})}),this.RULE("forwardCrossOperator",()=>{this.CONSUME(xt)}),this.RULE("backwardCrossOperator",()=>{this.CONSUME(Kn),this.OPTION({GATE:a(()=>this.hasLabeledRight([te]),"GATE"),DEF:a(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(te)},"DEF")})}),this.RULE("edgeLabel",()=>{this.OR([{ALT:a(()=>this.CONSUME(se),"ALT")},{ALT:a(()=>this.CONSUME(de),"ALT")},{ALT:a(()=>this.AT_LEAST_ONE(()=>this.CONSUME(W)),"ALT")}])}),this.RULE("semanticRelation",()=>{this.OR([{ALT:a(()=>{this.CONSUME(Bn),this.CONSUME(qe),this.OR2([{ALT:a(()=>this.CONSUME(Un),"ALT")},{ALT:a(()=>this.CONSUME(wn),"ALT")}])},"ALT")},{ALT:a(()=>this.CONSUME(Fn),"ALT")}])}),this.RULE("metadata",()=>{this.CONSUME(Ls),this.MANY(()=>this.CONSUME(ue)),this.OPTION(()=>{this.SUBRULE(this.metadataProperty),this.MANY2(()=>{this.SUBRULE(this.metadataSeparator),this.SUBRULE2(this.metadataProperty)}),this.OPTION2(()=>this.CONSUME(ie)),this.MANY3(()=>this.CONSUME2(ue))}),this.CONSUME(Ns)}),this.RULE("metadataProperty",()=>{this.OR([{ALT:a(()=>this.CONSUME(U),"ALT")},{ALT:a(()=>this.CONSUME(se),"ALT")}]),this.CONSUME(qe),this.OR2([{ALT:a(()=>this.CONSUME2(U),"ALT")},{ALT:a(()=>this.CONSUME2(se),"ALT")},{ALT:a(()=>this.CONSUME(Pn),"ALT")},{ALT:a(()=>this.CONSUME(Dn),"ALT")}])}),this.RULE("metadataSeparator",()=>{this.OR([{ALT:a(()=>{this.CONSUME(ie),this.MANY(()=>this.CONSUME(ue))},"ALT")},{ALT:a(()=>{this.AT_LEAST_ONE(()=>this.CONSUME2(ue)),this.OPTION(()=>this.CONSUME2(ie)),this.MANY2(()=>this.CONSUME3(ue))},"ALT")}])}),this.RULE("systemBoundaryStatement",()=>{this.CONSUME(Rn),this.SUBRULE(this.systemBoundaryName),this.OPTION(()=>this.SUBRULE(this.metadata)),this.OPTION2(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd),this.SUBRULE(this.systemBoundaryContent),this.CONSUME(An),this.SUBRULE2(this.lineEnd)}),this.RULE("systemBoundaryName",()=>{this.OR([{ALT:a(()=>{this.CONSUME(U),this.OPTION(()=>{this.OR2([{ALT:a(()=>{this.CONSUME(Ye),this.SUBRULE(this.nodeLabel),this.CONSUME(Je)},"ALT")},{ALT:a(()=>{this.CONSUME(vt),this.SUBRULE2(this.nodeLabel),this.CONSUME(Mt)},"ALT")}])})},"ALT")},{ALT:a(()=>this.CONSUME(se),"ALT")},{ALT:a(()=>this.CONSUME(de),"ALT")}])}),this.RULE("systemBoundaryContent",()=>{this.MANY(()=>{this.OR([{ALT:a(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:a(()=>this.SUBRULE(this.commentLine),"ALT")},{ALT:a(()=>this.SUBRULE(this.boundaryElement),"ALT")}])})}),this.RULE("boundaryElement",()=>{this.OR([{ALT:a(()=>this.SUBRULE(this.actorDeclarationOnly),"ALT")},{ALT:a(()=>{this.SUBRULE(this.entityName),this.SUBRULE(this.lineEnd)},"ALT")}])}),this.RULE("metadataAssignmentStatement",()=>{this.SUBRULE(this.metadataAssignmentTarget),this.SUBRULE(this.metadata),this.SUBRULE(this.lineEnd)}),this.RULE("metadataAssignmentTarget",()=>{this.OR([{ALT:a(()=>this.CONSUME(U),"ALT")},{ALT:a(()=>this.CONSUME(se),"ALT")},{ALT:a(()=>this.CONSUME(de),"ALT")}])}),this.RULE("noteStatement",()=>{this.CONSUME(bn),this.CONSUME(xn),this.CONSUME(U),this.SUBRULE(this.nodeLabel),this.SUBRULE(this.lineEnd)}),this.RULE("stereotype",()=>{this.CONSUME($n),this.CONSUME(Cs),this.CONSUME(Os)}),this.RULE("classSuffix",()=>{this.CONSUME(Gn),this.CONSUME(U),this.MANY(()=>{this.CONSUME(ie),this.CONSUME2(U)})}),this.RULE("jsonStatement",()=>{this.CONSUME(yn),this.CONSUME(Rs),this.OPTION(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd)}),this.RULE("directionStatement",()=>{this.CONSUME(On),this.OR([{ALT:a(()=>this.CONSUME(Cn),"ALT")},{ALT:a(()=>this.CONSUME(Ln),"ALT")},{ALT:a(()=>this.CONSUME(Nn),"ALT")},{ALT:a(()=>this.CONSUME(In),"ALT")},{ALT:a(()=>this.CONSUME(kn),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("classDefStatement",()=>{this.CONSUME(_n),this.CONSUME(U),this.MANY(()=>{this.CONSUME(ie),this.CONSUME2(U)}),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("classStatement",()=>{this.CONSUME(vn),this.CONSUME(U),this.MANY(()=>{this.CONSUME(ie),this.CONSUME2(U)}),this.CONSUME3(U),this.MANY2(()=>{this.CONSUME2(ie),this.CONSUME4(U)}),this.SUBRULE(this.lineEnd)}),this.RULE("styleStatement",()=>{this.CONSUME(Mn),this.CONSUME(U),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("styles",()=>{this.SUBRULE(this.styleValue),this.MANY(()=>{this.CONSUME(ie),this.SUBRULE2(this.styleValue)})}),this.RULE("styleValue",()=>{this.OR([{ALT:a(()=>this.CONSUME(Ue),"ALT")},{ALT:a(()=>this.CONSUME(Is),"ALT")},{ALT:a(()=>{this.CONSUME(te),this.CONSUME2(Ue)},"ALT")}]),this.CONSUME(qe),this.AT_LEAST_ONE(()=>this.SUBRULE(this.styleComponent))}),this.RULE("styleComponent",()=>{this.OR([{ALT:a(()=>this.CONSUME(Ue),"ALT")},{ALT:a(()=>this.CONSUME(se),"ALT")},{ALT:a(()=>this.CONSUME(ys),"ALT")},{ALT:a(()=>this.CONSUME(zn),"ALT")},{ALT:a(()=>this.CONSUME(Is),"ALT")},{ALT:a(()=>this.CONSUME(Hn),"ALT")},{ALT:a(()=>this.CONSUME(Xn),"ALT")},{ALT:a(()=>this.CONSUME(Yn),"ALT")},{ALT:a(()=>this.CONSUME(Jn),"ALT")},{ALT:a(()=>this.CONSUME(qn),"ALT")},{ALT:a(()=>this.CONSUME(qe),"ALT")},{ALT:a(()=>this.CONSUME(Ye),"ALT")},{ALT:a(()=>this.CONSUME(Je),"ALT")},{ALT:a(()=>this.CONSUME(vt),"ALT")},{ALT:a(()=>this.CONSUME(Mt),"ALT")},{ALT:a(()=>this.CONSUME(Vn),"ALT")},{ALT:a(()=>this.CONSUME(Ns),"ALT")},{ALT:a(()=>this.CONSUME(_t),"ALT")},{ALT:a(()=>this.CONSUME(te),"ALT")}])}),this.performSelfAnalysis()}isMetadataAssignment(){let e=this.LA(1).tokenType;return(e===U||e===se||e===de)&&this.LA(2).tokenType===Ls}isStatementStart(){let e=this.LA(1).tokenType;return e!==Q&&e!==ue&&e!==Ss}isForbiddenPlantUmlStatement(){return this.LA(1).tokenType===U&&Vo[this.LA(1).image.toLowerCase()]===!0}hasLabeledRight(e){if(!Wi(this.LA(1)))return!1;for(let t=2;;t++){let n=this.LA(t);if(e.includes(n.tokenType))return!0;if(!Wi(n))return!1}}},we=new Zn;var ks=class extends Error{constructor(t,n,r){super(`${t} (line ${n}, column ${r})`);this.line=n;this.column=r;this.name="UsecaseJsonError"}static{a(this,"UsecaseJsonError")}},Qn=a((s,e,t,n)=>{let r=t,i=n,o=Math.min(Math.max(e,0),s.length);for(let l=0;l<o;l++){let c=s[l];c==="\r"?(r++,i=1):c===`
`?(l===0||s[l-1]!=="\r")&&(r++,i=1):i++}return{line:r,column:i}},"locationAtOffset"),zo=a((s,e,t,n)=>{let r=/\bposition (\d+)\b/u.exec(s);if(r)return Qn(e,Number.parseInt(r[1],10),t,n);let i=/\bline (\d+) column (\d+)\b/u.exec(s);if(i){let o=Number.parseInt(i[1],10),l=Number.parseInt(i[2],10);return{line:t+o-1,column:o===1?n+l-1:l}}if(/unexpected end|end of json input/iu.test(s))return Qn(e,e.length,t,n)},"locationFromErrorMessage"),K=class extends Error{constructor(t){super("Invalid JSON token");this.offset=t}static{a(this,"JsonWalkError")}},bs=class{constructor(e){this.text=e;this.offset=0;this.propertyOrder={}}static{a(this,"PropertyOrderCollector")}collect(){if(this.skipWhitespace(),this.collectValue(""),this.skipWhitespace(),this.offset!==this.text.length)throw new K(this.offset);return this.propertyOrder}collectValue(e){this.skipWhitespace();let t=this.text[this.offset];if(t==="{")this.collectObject(e);else if(t==="[")this.collectArray(e);else if(t==='"')this.readString(!1);else if(t==="t")this.consumeLiteral("true");else if(t==="f")this.consumeLiteral("false");else if(t==="n")this.consumeLiteral("null");else if(t==="-"||t>="0"&&t<="9")this.consumeNumber();else throw new K(this.offset)}collectObject(e){this.offset++;let t=[],n=new Set;if(this.propertyOrder[e]=t,this.skipWhitespace(),this.text[this.offset]==="}"){this.offset++;return}for(;this.offset<this.text.length;){if(this.text[this.offset]!=='"')throw new K(this.offset);let r=this.readString(!0),i=`${e}/${r.replaceAll("~","~0").replaceAll("/","~1")}`;if(n.has(r)?this.deletePointerSubtree(i):(n.add(r),t.push(r)),this.skipWhitespace(),this.text[this.offset]!==":")throw new K(this.offset);if(this.offset++,this.collectValue(i),this.skipWhitespace(),this.text[this.offset]==="}"){this.offset++;return}if(this.text[this.offset]!==",")throw new K(this.offset);this.offset++,this.skipWhitespace()}throw new K(this.offset)}collectArray(e){if(this.offset++,this.skipWhitespace(),this.text[this.offset]==="]"){this.offset++;return}let t=0;for(;this.offset<this.text.length;){if(this.collectValue(`${e}/${t}`),t++,this.skipWhitespace(),this.text[this.offset]==="]"){this.offset++;return}if(this.text[this.offset]!==",")throw new K(this.offset);this.offset++,this.skipWhitespace()}throw new K(this.offset)}readString(e){this.offset++;let t="";for(;this.offset<this.text.length;){let n=this.offset,r=this.text[this.offset++];if(r==='"')return t;if(r.charCodeAt(0)<32)throw new K(n);if(r!=="\\"){e&&(t+=r);continue}let i=this.offset,o=this.text[this.offset++];switch(o){case'"':case"\\":case"/":e&&(t+=o);break;case"b":e&&(t+="\b");break;case"f":e&&(t+="\f");break;case"n":e&&(t+=`
`);break;case"r":e&&(t+="\r");break;case"t":e&&(t+="	");break;case"u":{let l=this.text.slice(this.offset,this.offset+4);if(!/^[\dA-Fa-f]{4}$/u.test(l))throw new K(this.offset);e&&(t+=String.fromCharCode(Number.parseInt(l,16))),this.offset+=4;break}default:throw new K(i)}}throw new K(this.offset)}consumeLiteral(e){let t=0;for(let n of e){if(this.text[this.offset+t]!==n)throw new K(this.offset+t);t++}this.offset+=e.length}consumeNumber(){if(this.text[this.offset]==="-"&&this.offset++,this.text[this.offset]==="0")this.offset++;else if(this.text[this.offset]>="1"&&this.text[this.offset]<="9")for(;this.text[this.offset]>="0"&&this.text[this.offset]<="9";)this.offset++;else throw new K(this.offset);if(this.text[this.offset]==="."){if(this.offset++,this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new K(this.offset);for(;this.text[this.offset]>="0"&&this.text[this.offset]<="9";)this.offset++}if(this.text[this.offset]==="e"||this.text[this.offset]==="E"){if(this.offset++,(this.text[this.offset]==="+"||this.text[this.offset]==="-")&&this.offset++,this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new K(this.offset);for(;this.text[this.offset]>="0"&&this.text[this.offset]<="9";)this.offset++}}skipWhitespace(){for(;this.offset<this.text.length;){let e=this.text[this.offset];if(e!==" "&&e!=="	"&&e!==`
`&&e!=="\r")return;this.offset++}}deletePointerSubtree(e){let t=`${e}/`;for(let n of Object.keys(this.propertyOrder))(n===e||n.startsWith(t))&&delete this.propertyOrder[n]}};function Ki(s,e,t){let n;try{n=JSON.parse(s)}catch(r){let i=r instanceof Error?r.message:String(r),o=zo(i,s,e,t);if(!o){let l=0;try{new bs(s).collect()}catch(c){c instanceof K&&(l=c.offset)}o=Qn(s,l,e,t)}throw new ks(`Invalid JSON: ${i}`,o.line,o.column)}if(typeof n!="object"||n===null||Array.isArray(n))throw new ks("JSON value must have an object root",e,t);return{value:n,propertyOrder:new bs(s).collect()}}a(Ki,"parseOrderedJsonObject");var Ho=a(s=>({shape:s.type==="normal"?"actor":s.type==="hollow"?"actor-hollow":s.type==="awesome"?"actor-awesome":"actor-icon",...s.label===s.id?{}:{label:s.label},...s.classes.length?{classes:[...s.classes]}:{},...s.styles.length?{styles:[...s.styles]}:{},attrs:{kind:"actor",actorType:s.type,business:s.business,labelType:s.labelType,...s.icon?{icon:s.icon}:{},...s.stereotype?{stereotype:s.stereotype}:{},...s.parentId?{parentId:s.parentId}:{}}}),"actorNode"),Xo=a(s=>({shape:s.shape,...s.label===s.id?{}:{label:s.label},...s.classes.length?{classes:[...s.classes]}:{},...s.styles.length?{styles:[...s.styles]}:{},attrs:{kind:"usecase",useCaseShape:s.shape,business:s.business,labelType:s.labelType,...s.stereotype?{stereotype:s.stereotype}:{},...s.parentId?{parentId:s.parentId}:{}}}),"useCaseNode"),Yo=a(s=>({label:s.label,shape:"note",attrs:{kind:"note",target:s.target,labelType:s.labelType}}),"noteNode"),Jo=a(s=>({label:s.id,shape:"json-table",...s.classes.length?{classes:[...s.classes]}:{},...s.styles.length?{styles:[...s.styles]}:{},attrs:{kind:"json",value:s.value,propertyOrder:s.propertyOrder,labelType:"text"}}),"jsonNode"),qo=a(s=>({id:s.id,source:s.source,target:s.target,...s.label?{label:s.label}:{},...s.classes.length?{classes:[...s.classes]}:{},...s.styles.length?{styles:[...s.styles]}:{},attrs:{relationshipType:s.type,arrowType:s.arrowType,minlen:s.minlen,explicitId:s.explicitId,animate:s.animate,...s.animation?{animation:s.animation}:{},...s.labelType?{labelType:s.labelType}:{}}}),"relationshipEdge"),Zo=a(s=>({id:`${s.id}-edge`,source:s.id,target:s.target,attrs:{relationshipType:"note",arrowType:I.LINE_SOLID,pattern:"dotted",minlen:1,explicitId:!1,animate:!1,internal:!0}}),"noteEdge"),Vi=a((s,e,t,n)=>{let r={};for(let c of s.getActors().values())r[c.id]=Ho(c);for(let c of s.getUseCases().values())r[c.id]=Xo(c);for(let c of s.getNotes().values())r[c.id]=Yo(c);for(let c of s.getJsonNodes().values())r[c.id]=Jo(c);let i={};for(let c of s.getSystemBoundaries().values())i[c.id]={...c.label===c.id?{}:{title:c.label},nodes:[...c.members],...c.classes.length?{classes:[...c.classes]}:{},...c.styles.length?{styles:[...c.styles]}:{},attrs:{kind:"systemBoundary",boundaryType:c.type,labelType:c.labelType}};let o={};for(let c of s.getClassDefs().values())o[c.id]={styles:[...c.styles]};let l=s.getDirection();return{version:1,diagramType:"usecase",source:e,header:{keyword:"usecase",direction:l==="TD"?"TB":l,span:t},...s.getAccTitle()?{accTitle:s.getAccTitle()}:{},...s.getAccDescription()?{accDescr:s.getAccDescription()}:{},nodes:r,edges:[...s.getRelationships().map(qo),...[...s.getNotes().values()].map(Zo)],groups:i,classDefs:o,statements:n}},"buildUsecaseGraphAST");var z=a(s=>`line ${s.line}, column ${s.column} [${s.span[0]},${s.span[1]})`,"locationText"),zi=a(s=>s===void 0?"":` (label "${s}")`,"labelSuffix"),Pe=a(s=>s.generated?s.label:void 0,"generatedFrom"),er=a((s,e)=>{for(let t of e)s.includes(t)||s.push(t)},"pushUnique"),xs=class{constructor(e){this.db=e;this.source="";this.statements=[];this.elements=[];this.boundaries=[];this.jsonDrafts=[];this.relationshipDrafts=[];this.noteDrafts=[];this.metadataAssignments=[];this.classAssignments=[];this.styleAssignments=[];this.classDefinitions=[];this.directions=[];this.model=e.createModel()}static{a(this,"UsecaseModelBuilder")}reset(e){this.model=this.db.createModel(),this.source=e,this.statements=[],this.elements.length=0,this.boundaries.length=0,this.jsonDrafts.length=0,this.relationshipDrafts.length=0,this.noteDrafts.length=0,this.metadataAssignments.length=0,this.classAssignments.length=0,this.styleAssignments.length=0,this.classDefinitions.length=0,this.directions.length=0}addElement(e){this.elements.push(e)}addBoundary(e){this.boundaries.push(e)}addJson(e){this.jsonDrafts.push(e)}addRelationship(e){this.relationshipDrafts.push(e)}addNote(e){this.noteDrafts.push(e)}addMetadataAssignment(e,t,n,r){this.metadataAssignments.push({target:e,targetLocation:t,metadata:n,statement:r})}addClassDef(e,t){this.classDefinitions.push({ids:e,styles:t})}addClassAssignment(e,t){this.classAssignments.push({targets:e,classes:t})}addStyleAssignment(e,t,n){this.styleAssignments.push({target:e,location:t,styles:n})}setDirection(e){this.directions.push(e==="TD"?"TB":e)}setAccTitle(e){this.model.accTitle=e}setAccDescription(e){this.model.accDescription=e}setStatements(e){this.statements=e}getActors(){return this.model.actors}getUseCases(){return this.model.useCases}getSystemBoundaries(){return this.model.systemBoundaries}getRelationships(){return this.model.relationships}getNotes(){return this.model.notes}getJsonNodes(){return this.model.jsonNodes}getClassDefs(){return this.model.classDefs}getDirection(){return this.model.direction}getAccTitle(){return this.model.accTitle}getAccDescription(){return this.model.accDescription}finalize(e){let t=new Map,n=new Map,r=new Map,i=new Map;for(let h of this.relationshipDrafts)this.recordFirst(i,h.source.id,h.source.location.span[0]),this.recordFirst(i,h.target.id,h.target.location.span[0]);for(let h of this.elements)this.recordFirst(i,h.id,h.location.span[0]);for(let h of this.boundaries)this.recordFirst(i,h.id,h.location.span[0]);for(let h of this.jsonDrafts)this.recordFirst(i,h.id,h.location.span[0]);let o=[...this.elements.map(h=>({offset:h.location.span[0],type:"element",value:h})),...this.boundaries.map(h=>({offset:h.location.span[0],type:"boundary",value:h})),...this.jsonDrafts.map(h=>({offset:h.location.span[0],type:"json",value:h})),...this.relationshipDrafts.filter(h=>h.explicitId).map(h=>({offset:h.explicitIdLocation.span[0],type:"edge",value:h}))].sort((h,u)=>h.offset-u.offset);for(let h of o)h.type==="element"?this.collectElement(h.value,t,n):h.type==="boundary"?this.collectBoundary(h.value,t,r):h.type==="json"?this.registerUnique(t,h.value.id,"json",h.value.location,!1):this.registerUnique(t,h.value.explicitId,"edge",h.value.explicitIdLocation,!1);this.materializeElements(n,i),this.materializeBoundaries(r,i),this.materializeJson(i);let l=this.materializeRelationships(t,n,i);this.reorderElements(n,i),this.applyMetadataAssignments(t,n,r,l),this.validateAndRefreshElements(n),this.refreshBoundaries(r,n),this.materializeNotes(t),this.applyClassDefinitions(),this.applyClassesAndStyles(t,l),this.model.direction=this.directions.at(-1)??this.model.direction,this.model.symbols=new Map([...t].map(([h,u])=>[h,u.kind]));let c=Vi(this,this.source,e,this.statements);return this.model.ast=c,this.db.commit(this.model),c}collectElement(e,t,n){let r=t.get(e.id),i=Pe({generated:e.generated,label:e.label.text});r&&r.kind!==e.kind&&this.conflict(`ID '${e.id}' is declared as both ${r.kind} and ${e.kind}`,e.location,r.location,i,Pe(r)),r&&(r.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,r.location,i,Pe(r));let o=n.get(e.id);if(!o){let l={kind:e.kind,id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],...e.parentId?{parentId:e.parentId,parentLocation:e.parentLocation}:{},...e.shape?{shape:e.shape}:{},...e.stereotype?{stereotype:e.stereotype,stereotypeLocation:e.location}:{}};this.applyDeclarationMetadata(l,e.metadata),n.set(e.id,l),t.set(e.id,{kind:e.kind,location:e.location,generated:e.generated,label:e.label.text});return}(o.label.text!==e.label.text||o.label.type!==e.label.type)&&this.conflict(`ID '${e.id}' has conflicting labels`,e.location,o.location),e.shape&&o.shape&&e.shape!==o.shape&&this.conflict(`Use case '${e.id}' has conflicting shapes`,e.location,o.location),e.parentId&&o.parentId&&e.parentId!==o.parentId&&this.conflict(`Element '${e.id}' belongs to more than one system boundary`,e.parentLocation??e.location,o.parentLocation??o.location),e.stereotype&&o.stereotype&&e.stereotype!==o.stereotype&&this.conflict(`Element '${e.id}' has conflicting stereotypes`,e.location,o.stereotypeLocation??o.location),o.shape??=e.shape,o.parentId??=e.parentId,o.parentLocation??=e.parentLocation,o.stereotype??=e.stereotype,o.stereotypeLocation??=e.stereotype?e.location:void 0,er(o.classes,e.classes),this.applyDeclarationMetadata(o,e.metadata)}collectBoundary(e,t,n){let r=t.get(e.id),i=Pe({generated:e.generated,label:e.label.text});r&&r.kind!=="boundary"&&this.conflict(`ID '${e.id}' is declared as both ${r.kind} and boundary`,e.location,r.location,i,Pe(r)),r&&(r.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,r.location,i,Pe(r));let o=n.get(e.id);if(o){(o.label.text!==e.label.text||o.label.type!==e.label.type)&&this.conflict(`Boundary '${e.id}' has conflicting titles`,e.location,o.location),er(o.classes,e.classes);return}n.set(e.id,{id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],styles:[],members:[]}),t.set(e.id,{kind:"boundary",location:e.location,generated:e.generated,label:e.label.text})}materializeElements(e,t){for(let n of[...e.values()].sort((r,i)=>(t.get(r.id)??0)-(t.get(i.id)??0)))this.setElementModel(n)}materializeBoundaries(e,t){for(let n of[...e.values()].sort((r,i)=>(t.get(r.id)??0)-(t.get(i.id)??0)))this.model.systemBoundaries.set(n.id,{id:n.id,label:n.label.text,labelType:n.label.type,type:n.type??"rect",members:[],classes:[...n.classes],styles:[...n.styles]})}materializeJson(e){for(let t of[...this.jsonDrafts].sort((n,r)=>(e.get(n.id)??0)-(e.get(r.id)??0)))this.model.jsonNodes.set(t.id,{id:t.id,value:t.value,propertyOrder:t.propertyOrder,classes:[...t.classes],styles:[]})}materializeRelationships(e,t,n){let r=new Map,i=0;for(let o of this.relationshipDrafts){let l=this.resolveEndpoint(o.source,e,t,n),c=this.resolveEndpoint(o.target,e,t,n);this.validateRelationship(o,l,c,e);let h=o.explicitId??`edge-${i++}`,u={id:h,explicitId:!!o.explicitId,source:o.source.id,target:o.target.id,type:o.type,arrowType:o.arrowType,...o.label?{label:o.label.text,labelType:o.label.type}:{},minlen:o.minlen,classes:[],styles:[],animate:!1};this.model.relationships.push(u),r.set(h,{draft:o,relationship:u})}return this.model.relationshipCounter=i,r}resolveEndpoint(e,t,n,r){if(e.classesOnReference&&!e.declaration)throw new Error(`Relationship endpoint '${e.id}' uses ::: without declaring the node at ${z(e.location)}`);let i=t.get(e.id);return i?i.kind:(n.set(e.id,{kind:"usecase",id:e.id,label:e.label,location:e.location,generated:e.generated,shape:"ellipse",classes:[]}),t.set(e.id,{kind:"usecase",location:e.location,generated:e.generated,label:e.label.text}),this.recordFirst(r,e.id,e.location.span[0]),"usecase")}reorderElements(e,t){let n=new Map(this.model.actors),r=new Map(this.model.useCases);this.model.actors.clear(),this.model.useCases.clear();for(let i of[...e.values()].sort((o,l)=>(t.get(o.id)??0)-(t.get(l.id)??0))){!n.has(i.id)&&!r.has(i.id)&&this.setElementModel(i);let o=n.get(i.id)??this.model.actors.get(i.id),l=r.get(i.id)??this.model.useCases.get(i.id);o?this.model.actors.set(i.id,o):l&&this.model.useCases.set(i.id,l)}}applyMetadataAssignments(e,t,n,r){for(let i of this.metadataAssignments){let o=e.get(i.target);if(!o){let l=this.inferMetadataKind(i.metadata);throw new Error(`Metadata target '${i.target}' is unresolved${l?` (metadata implies ${l})`:""} at ${z(i.targetLocation)}`)}if(o.kind==="actor"||o.kind==="usecase")this.applyStandaloneElementMetadata(t.get(i.target),i.metadata);else if(o.kind==="boundary"){let l=n.get(i.target);for(let c of i.metadata.properties)(c.key!=="type"||c.value!=="rect"&&c.value!=="package")&&this.invalidMetadata(i.target,o.kind,c),l.type=c.value}else if(o.kind==="edge"){let l=r.get(i.target);if(!l)throw new Error(`Metadata target '${i.target}' is not an explicit edge at ${z(i.targetLocation)}`);i.statement.kind="edgeMetadata",i.statement.edges=[{id:i.target,span:i.statement.span,idSpan:i.targetLocation.span,...i.statement.metadata?{metadata:i.statement.metadata}:{}}],delete i.statement.nodes;for(let c of i.metadata.properties)c.key==="animate"&&typeof c.value=="boolean"?l.relationship.animate=c.value:c.key==="animation"&&(c.value==="fast"||c.value==="slow")?(l.relationship.animation=c.value,l.relationship.animate=!0):this.invalidMetadata(i.target,o.kind,c)}else for(let l of i.metadata.properties)this.invalidMetadata(i.target,o.kind,l)}for(let{relationship:i}of r.values())i.animation&&(i.animate=!0)}applyStandaloneElementMetadata(e,t){for(let n of t.properties)e.kind==="actor"?this.applyActorProperty(e,n,!0):n.key==="business"&&typeof n.value=="boolean"?e.business=n.value:this.invalidMetadata(e.id,e.kind,n)}applyDeclarationMetadata(e,t){if(t)for(let n of t.properties)e.kind==="actor"?this.applyActorProperty(e,n,!1):n.key==="business"&&typeof n.value=="boolean"?(e.business!==void 0&&e.business!==n.value&&this.conflict(`Use case '${e.id}' has conflicting business metadata`,n.location,e.location),e.business=n.value):this.invalidMetadata(e.id,e.kind,n)}applyActorProperty(e,t,n){t.key==="type"&&(t.value==="normal"||t.value==="hollow"||t.value==="awesome")?(!n&&e.actorType!==void 0&&e.actorType!==t.value&&this.conflict(`Actor '${e.id}' has conflicting type metadata`,t.location,e.location),e.actorType=t.value):t.key==="icon"&&typeof t.value=="string"?(!n&&e.icon!==void 0&&e.icon!==t.value&&this.conflict(`Actor '${e.id}' has conflicting icon metadata`,t.location,e.location),e.icon=t.value):t.key==="business"&&typeof t.value=="boolean"?(!n&&e.business!==void 0&&e.business!==t.value&&this.conflict(`Actor '${e.id}' has conflicting business metadata`,t.location,e.location),e.business=t.value):this.invalidMetadata(e.id,e.kind,t)}validateAndRefreshElements(e){for(let t of e.values()){let n=t.icon?"icon":t.actorType??"normal";if(t.kind==="actor"){if(t.icon&&t.actorType&&t.actorType!=="normal")throw new Error(`Actor '${t.id}' cannot combine icon with type '${t.actorType}' at ${z(t.location)}`);if(t.business&&(n==="icon"||n==="awesome"))throw new Error(`Business actor '${t.id}' must use normal or hollow geometry at ${z(t.location)}`)}else if((t.shape??"ellipse")==="rect"&&t.business)throw new Error(`Rectangular use case '${t.id}' cannot be a business use case at ${z(t.location)}`);this.setElementModel(t)}}refreshBoundaries(e,t){for(let n of e.values())n.members.length=0;for(let n of[...this.elements].sort((r,i)=>r.location.span[0]-i.location.span[0])){if(!n.parentId)continue;let r=e.get(n.parentId);if(!r)throw new Error(`Parent boundary '${n.parentId}' for '${n.id}' is unresolved at ${z(n.parentLocation??n.location)}`);r.members.includes(n.id)||r.members.push(n.id)}for(let n of t.values())if(n.parentId&&!e.has(n.parentId))throw new Error(`Parent boundary '${n.parentId}' for '${n.id}' is unresolved at ${z(n.parentLocation??n.location)}`);for(let n of e.values()){let r=this.model.systemBoundaries.get(n.id);r.type=n.type??"rect",r.members=[...n.members],r.classes=[...n.classes],r.styles=[...n.styles]}}materializeNotes(e){let t=0;for(let n of this.noteDrafts){let r=e.get(n.target);if(!r)throw new Error(`Note target '${n.target}' is unresolved at ${z(n.targetLocation)}`);r.kind!=="actor"&&r.kind!=="usecase"&&this.conflict(`Note target '${n.target}' must be an actor or use case, not ${r.kind}`,n.targetLocation,r.location);let i=`note-${t++}`;this.model.notes.set(i,{id:i,target:n.target,label:n.label.text,labelType:n.label.type})}this.model.noteCounter=t}applyClassDefinitions(){for(let e of this.classDefinitions)for(let t of e.ids)this.model.classDefs.set(t,{id:t,styles:[...e.styles]})}applyClassesAndStyles(e,t){for(let n of this.classAssignments)for(let r of n.targets)er(this.getStylable(r.id,e,t,r.location).classes,n.classes);for(let n of this.styleAssignments)this.getStylable(n.target,e,t,n.location).styles.push(...n.styles)}getStylable(e,t,n,r){let i=t.get(e)?.kind,o=i==="actor"?this.model.actors.get(e):i==="usecase"?this.model.useCases.get(e):i==="boundary"?this.model.systemBoundaries.get(e):i==="json"?this.model.jsonNodes.get(e):i==="edge"?n.get(e)?.relationship:void 0;if(!o)throw new Error(`Class/style target '${e}' is unresolved or anonymous at ${z(r)}`);return o}validateRelationship(e,t,n,r){let i=a(o=>o==="actor"||o==="usecase"||o==="json","allowed");if(i(t)||this.conflict(`Relationship source '${e.source.id}' cannot be ${t}`,e.source.location,r.get(e.source.id).location),i(n)||this.conflict(`Relationship target '${e.target.id}' cannot be ${n}`,e.target.location,r.get(e.target.id).location),(e.type==="include"||e.type==="extend")&&(t!=="usecase"||n!=="usecase"))throw new Error(`${e.type} relationship requires use-case endpoints at ${z(e.location)}`);if(e.type==="generalization"&&(t!=="actor"&&t!=="usecase"||t!==n))throw new Error(`Generalization requires actor-to-actor or use-case-to-use-case endpoints at ${z(e.location)}`);if(e.type==="association"&&(t==="json"||n==="json")&&![0,1,2].includes(e.arrowType))throw new Error(`JSON relationship '${e.source.id}' to '${e.target.id}' permits only point, reversed-point, or markerless solid association at ${z(e.location)}`)}setElementModel(e){if(e.kind==="actor"){let t=e.icon?"icon":e.actorType??"normal";this.model.useCases.delete(e.id),this.model.actors.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,type:t,...e.icon?{icon:e.icon}:{},business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:this.model.actors.get(e.id)?.styles??[]})}else this.model.actors.delete(e.id),this.model.useCases.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,shape:e.shape??"ellipse",business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:this.model.useCases.get(e.id)?.styles??[]})}inferMetadataKind(e){let t=new Set(["actor","usecase","boundary","edge"]);for(let n of e.properties)if(n.key==="icon")t.clear(),t.add("actor");else if(n.key==="animate"||n.key==="animation")t.clear(),t.add("edge");else if(n.key==="type")t.clear(),n.value==="rect"||n.value==="package"?t.add("boundary"):(n.value==="normal"||n.value==="hollow"||n.value==="awesome")&&t.add("actor");else if(n.key==="business")t.delete("boundary"),t.delete("edge");else return;return t.size===1?[...t][0]:void 0}invalidMetadata(e,t,n){throw new Error(`Metadata property '${n.key}' is invalid for ${t} '${e}' at ${z(n.location)}`)}registerUnique(e,t,n,r,i){let o=e.get(t);o&&this.conflict(`ID '${t}' is declared more than once (${o.kind} and ${n})`,r,o.location,void 0,Pe(o)),e.set(t,{kind:n,location:r,generated:i})}recordFirst(e,t,n){let r=e.get(t);(r===void 0||n<r)&&e.set(t,n)}conflict(e,t,n,r,i){throw new Error(`${e} at ${z(t)}${zi(r)}; previous declaration at ${z(n)}${zi(i)}`)}};var Qo=we.getBaseCstVisitorConstructor(),tr=class extends Qo{constructor(){super();this.builder=new xs(Le);this.source="";this.anonymousEdge=0;this.anonymousNote=0;this.validateVisitor()}static{a(this,"UsecaseVisitor")}build(t,n){this.source=n,this.parentBoundary=void 0,this.anonymousEdge=0,this.anonymousNote=0,this.builder.reset(n),this.visit(t)}start(t){let n=this.tokens(t,"USECASE")[0],r=[];for(let i of this.nodes(t,"line"))r.push(this.visit(i));this.builder.setStatements(r),this.builder.finalize(this.tokenSpan(n))}line(t){let n=this.firstNode(t,"blankLine","commentLine","statement");return this.wrap(n,this.visit(n))}statement(t){return this.visit(this.firstNode(t,"accTitleStatement","accDescrStatement","directionStatement","actorStatement","systemBoundaryStatement","noteStatement","jsonStatement","classDefStatement","classStatement","styleStatement","metadataAssignmentStatement","entityStatement"))}lineEnd(t){}blankLine(t){return{kind:"blank",span:this.tokenSpan(this.tokens(t,"NEWLINE")[0])}}commentLine(t){return{kind:"comment",span:this.tokenSpan(this.tokens(t,"COMMENT")[0])}}accTitleStatement(t){let n=this.tokens(t,"ACC_TITLE_LINE")[0].image;return this.builder.setAccTitle(n.slice(n.indexOf(":")+1).trim()),{kind:"accTitle",span:[0,0]}}accDescrStatement(t){let n=this.tokens(t,"ACC_DESCR_LINE")[0],r=this.tokens(t,"ACC_DESCR_BLOCK")[0],i=n?n.image.slice(n.image.indexOf(":")+1).trim():r.image.slice(r.image.indexOf("{")+1,r.image.lastIndexOf("}")).trim();return this.builder.setAccDescription(i),{kind:"accDescr",span:[0,0]}}actorStatement(t){let n=this.nodes(t,"actorItem"),r=n.map(u=>this.visit(u)),i=this.nodes(t,"relationTail")[0],o=r.map((u,d)=>this.actorOccurrence(n[d],u,!0));for(let u of r)this.builder.addElement(this.actorDraft(u));if(!i)return{kind:"node",span:[0,0],nodes:o};let l=this.visit(i);l.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(l.target));let c=this.relationshipDraft(r[0],l,this.nodeLocation(i));this.builder.addRelationship(c);let h=c.explicitId??`edge-${this.anonymousEdge++}`;return o.push(this.entityOccurrence(this.nodes(i.children,"entityName")[0],l.target,l.target.explicitDeclaration)),{kind:"edge",span:[0,0],nodes:o,edges:[{id:h,span:[0,0],...c.explicitIdLocation?{idSpan:c.explicitIdLocation.span}:{},...c.label?{labelSpan:c.label.span}:{}}]}}actorItem(t){let n=this.visit(this.nodes(t,"actorName")[0]),r=this.nodes(t,"metadata")[0],i=this.nodes(t,"stereotype")[0],o=this.nodes(t,"classSuffix")[0],l=o?this.visit(o):{classes:[],spans:[]};return{...n,...r?{metadata:this.visit(r)}:{},...i?{stereotype:this.visit(i)}:{},classes:l.classes,classSpans:l.spans}}actorName(t){let n=this.tokens(t,"IDENTIFIER")[0],r=this.tokens(t,"PLAIN_STRING")[0]??this.tokens(t,"MARKDOWN_STRING")[0];if(n){let o=this.nodes(t,"nodeLabel")[0],l=o?this.visit(o):this.tokenLabel(n);return{id:n.image,label:l,location:this.tokenLocation(n),generated:!1,classes:[],classSpans:[]}}let i=this.tokenLabel(r);return{id:this.generateId(i.text),label:i,location:this.tokenLocation(r),generated:!0,classes:[],classSpans:[]}}actorDeclarationOnly(t){let n=this.nodes(t,"actorItem"),r=n.map(i=>this.visit(i));for(let i of r)this.builder.addElement(this.actorDraft(i));return{kind:"node",span:[0,0],nodes:r.map((i,o)=>this.actorOccurrence(n[o],i,!0))}}entityStatement(t){let n=this.nodes(t,"entityName"),r=this.visit(n[0]),i=this.nodes(t,"relationTail")[0];if(!i)return r.explicitDeclaration=!0,r.shape??="ellipse",this.builder.addElement(this.entityDraft(r)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(n[0],r,!0)]};r.explicitDeclaration&&this.builder.addElement(this.entityDraft(r));let o=this.visit(i);o.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(o.target));let l={source:this.endpoint(r),target:this.endpoint(o.target),location:this.nodeLocation(i),...o.explicitId?{explicitId:o.explicitId,explicitIdLocation:o.explicitIdLocation}:{},...o.arrow};this.builder.addRelationship(l);let c=l.explicitId??`edge-${this.anonymousEdge++}`;return{kind:"edge",span:[0,0],nodes:[this.entityOccurrence(n[0],r,r.explicitDeclaration),this.entityOccurrence(this.nodes(i.children,"entityName")[0],o.target,o.target.explicitDeclaration)],edges:[{id:c,span:[0,0],...l.explicitIdLocation?{idSpan:l.explicitIdLocation.span}:{},...l.label?{labelSpan:l.label.span}:{}}]}}entityName(t){let n=this.tokens(t,"IDENTIFIER")[0],r=this.tokens(t,"PLAIN_STRING")[0]??this.tokens(t,"MARKDOWN_STRING")[0],i=this.nodes(t,"nodeLabel")[0],o=this.nodes(t,"useCaseMetadata")[0],l=this.nodes(t,"stereotype")[0],c=this.nodes(t,"classSuffix")[0],h=c?this.visit(c):{classes:[],spans:[]};if(n){let d=i?this.visit(i):this.tokenLabel(n),p=i?this.tokens(t,"LBRACKET").length?"rect":"ellipse":void 0;return{id:n.image,label:d,location:this.tokenLocation(n),generated:!1,...p?{shape:p}:{},...o?{metadata:this.visit(o)}:{},...l?{stereotype:this.visit(l)}:{},classes:h.classes,classSpans:h.spans,explicitDeclaration:!!(p||o||l)}}let u=this.tokenLabel(r);return{id:this.generateId(u.text),label:u,location:this.tokenLocation(r),generated:!0,...o?{metadata:this.visit(o)}:{},...l?{stereotype:this.visit(l)}:{},classes:h.classes,classSpans:h.spans,explicitDeclaration:!!(o||l)}}nodeLabel(t){let n=this.allTokens(t);if(n.length===1&&(n[0].tokenType.name==="PLAIN_STRING"||n[0].tokenType.name==="MARKDOWN_STRING"))return this.tokenLabel(n[0]);let r=[n[0].startOffset,(n.at(-1).endOffset??n.at(-1).startOffset)+1];return{text:this.source.slice(r[0],r[1]),type:"text",span:r}}useCaseMetadata(t){return this.visit(this.nodes(t,"metadata")[0])}relationTail(t){let n=this.tokens(t,"IDENTIFIER")[0];return{...n?{explicitId:n.image,explicitIdLocation:this.tokenLocation(n)}:{},arrow:this.visit(this.nodes(t,"arrow")[0]),target:this.visit(this.nodes(t,"entityName")[0])}}arrow(t){return this.visit(this.firstNode(t,"semanticRelation","forwardSolidOperator","backwardSolidOperator","markerlessSolidOperator","forwardCircleOperator","backwardCircleOperator","forwardCrossOperator","backwardCrossOperator"))}edgeLabel(t){return this.nodeLabel(t)}semanticRelation(t){if(this.tokens(t,"GENERALIZATION").length)return{type:"generalization",arrowType:I.SOLID_ARROW,minlen:1};let n=this.tokens(t,"INCLUDE").length?"include":"extend",r=this.tokens(t,n==="include"?"INCLUDE":"EXTEND")[0];return{type:n,arrowType:I.SOLID_ARROW,label:{text:n,type:"text",span:this.tokenSpan(r)},minlen:1}}metadata(t){return{properties:this.nodes(t,"metadataProperty").map(n=>this.visit(n)),location:this.ctxLocation(t)}}metadataProperty(t){let n=this.allTokens(t).filter(c=>c.tokenType.name!=="COLON"),r=n[0],i=n[1],o=i.tokenType.name==="TRUE"?!0:i.tokenType.name==="FALSE"?!1:this.decodePlain(i),l=[r.startOffset,(i.endOffset??i.startOffset)+1];return{key:this.decodePlain(r),value:o,span:l,keySpan:this.contentSpan(r),valueSpan:this.contentSpan(i),location:this.tokenLocation(r)}}metadataSeparator(t){}systemBoundaryStatement(t){let n=this.visit(this.nodes(t,"systemBoundaryName")[0]),r=this.nodes(t,"classSuffix")[0],i=r?this.visit(r):{classes:[],spans:[]};n.classes=i.classes,this.builder.addBoundary(n);let o=this.parentBoundary;this.parentBoundary={id:n.id,location:n.location};let l=this.nodes(t,"systemBoundaryContent")[0],c=l?this.visit(l):[];this.parentBoundary=o;let h=this.tokens(t,"END")[0],u=this.nodes(t,"metadata")[0],d=u?this.visit(u):void 0,p={kind:"group",span:[0,0],group:n.id,idSpan:n.location.span,titleSpan:n.label.span,endSpan:this.tokenSpan(h),classSpans:i.spans,...d?{metadata:d.properties.map(({key:g,span:R,keySpan:A,valueSpan:O})=>({key:g,span:R,keySpan:A,valueSpan:O}))}:{},...c.length?{children:c}:{}};return d&&this.builder.addMetadataAssignment(n.id,n.location,d,p),p}systemBoundaryName(t){let n=this.tokens(t,"IDENTIFIER")[0];if(n){let o=this.nodes(t,"nodeLabel")[0];return{id:n.image,label:o?this.visit(o):this.tokenLabel(n),location:this.tokenLocation(n),generated:!1,classes:[]}}let r=this.tokens(t,"PLAIN_STRING")[0]??this.tokens(t,"MARKDOWN_STRING")[0],i=this.tokenLabel(r);return{id:this.generateId(i.text),label:i,location:this.tokenLocation(r),generated:!0,classes:[]}}systemBoundaryContent(t){return[...this.nodes(t,"blankLine"),...this.nodes(t,"commentLine"),...this.nodes(t,"boundaryElement")].sort((r,i)=>(r.location?.startOffset??0)-(i.location?.startOffset??0)).map(r=>this.wrap(r,this.visit(r)))}boundaryElement(t){let n=this.nodes(t,"actorDeclarationOnly")[0];if(n)return this.visit(n);let r=this.nodes(t,"entityName")[0],i=this.visit(r);return i.explicitDeclaration=!0,i.shape??="ellipse",this.builder.addElement(this.entityDraft(i)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(r,i,!0)]}}metadataAssignmentStatement(t){let n=this.visit(this.nodes(t,"metadataAssignmentTarget")[0]),r=this.visit(this.nodes(t,"metadata")[0]),i={kind:"metadata",span:[0,0],nodes:[{id:n.id,span:n.location.span,idSpan:n.location.span}],metadata:r.properties.map(({key:o,span:l,keySpan:c,valueSpan:h})=>({key:o,span:l,keySpan:c,valueSpan:h}))};return this.builder.addMetadataAssignment(n.id,n.location,r,i),i}metadataAssignmentTarget(t){let n=this.allTokens(t)[0],r=this.tokenLabel(n);return{id:n.tokenType.name==="IDENTIFIER"?n.image:this.generateId(r.text),location:this.tokenLocation(n)}}noteStatement(t){let n=this.tokens(t,"IDENTIFIER")[0],r=this.visit(this.nodes(t,"nodeLabel")[0]);return this.builder.addNote({target:n.image,targetLocation:this.tokenLocation(n),label:r,location:this.ctxLocation(t)}),{kind:"note",span:[0,0],ref:`note-${this.anonymousNote++}`,refSpan:r.span,nodes:[{id:n.image,span:this.tokenSpan(n),idSpan:this.tokenSpan(n)}]}}stereotype(t){let n=this.tokens(t,"STEREOTYPE_TEXT")[0];return{value:n.image.trim(),span:this.tokenSpan(n)}}classSuffix(t){let n=this.tokens(t,"IDENTIFIER");return{classes:n.map(r=>r.image),spans:n.map(r=>this.tokenSpan(r))}}jsonStatement(t){let n=this.tokens(t,"JSON_DECLARATION_START")[0],r=this.tokens(t,"JSON_OBJECT_LITERAL")[0],i=/^json[\t ]+(\w+)/.exec(n.image),o=i[1],l=i[0].length-o.length,c={span:[n.startOffset+l,n.startOffset+l+o.length],line:n.startLine??1,column:(n.startColumn??1)+l},h=Ki(r.image,r.startLine??1,r.startColumn??1),u=this.nodes(t,"classSuffix")[0],d=u?this.visit(u):{classes:[],spans:[]},p={id:o,value:h.value,propertyOrder:h.propertyOrder,location:c,classes:d.classes};return this.builder.addJson(p),{kind:"json",span:[0,0],nodes:[{id:o,span:c.span,idSpan:c.span,defines:!0,classSpans:d.spans}],classSpans:d.spans}}directionStatement(t){let n=this.allTokens(t).find(r=>["TD","TB","BT","RL","LR"].includes(r.tokenType.name));return this.builder.setDirection(n.image),{kind:"direction",span:[0,0]}}classDefStatement(t){let n=this.tokens(t,"IDENTIFIER"),r=this.visit(this.nodes(t,"styles")[0]);return this.builder.addClassDef(n.map(i=>i.image),r),{kind:"classDef",span:[0,0],ref:n[0].image,refSpan:this.tokenSpan(n[0])}}classStatement(t){let n=this.tokens(t,"IDENTIFIER"),r=1;for(;r<n.length&&this.source.slice((n[r-1].endOffset??n[r-1].startOffset)+1,n[r].startOffset).includes(",");r++);let i=n.slice(0,r).map(l=>({id:l.image,location:this.tokenLocation(l)})),o=n.slice(r).map(l=>l.image);return this.builder.addClassAssignment(i,o),{kind:"classAssign",span:[0,0],ref:o[0],refSpan:this.tokenSpan(n[r]),nodes:i.map(({id:l,location:c})=>({id:l,span:c.span,idSpan:c.span}))}}styleStatement(t){let n=this.tokens(t,"IDENTIFIER")[0],r=this.visit(this.nodes(t,"styles")[0]);return this.builder.addStyleAssignment(n.image,this.tokenLocation(n),r),{kind:"style",span:[0,0],nodes:[{id:n.image,span:this.tokenSpan(n),idSpan:this.tokenSpan(n)}]}}styles(t){return this.nodes(t,"styleValue").map(n=>this.visit(n))}styleValue(t){let n=this.allTokens(t),r=[n[0].startOffset,(n.at(-1).endOffset??n.at(-1).startOffset)+1];return this.source.slice(r[0],r[1]).replaceAll("\\,",",")}styleComponent(t){return this.allTokens(t).map(n=>n.image).join("")}forwardSolidOperator(t){let n=this.tokens(t,"FORWARD_SOLID")[0];return{type:"association",arrowType:I.SOLID_ARROW,minlen:this.solidMinlen(n)}}backwardSolidOperator(t){let n=this.tokens(t,"BACKWARD_SOLID")[0],r=this.nodes(t,"edgeLabel")[0],i=r?this.tokens(t,"MARKERLESS_SOLID").at(-1):n;return{type:"association",arrowType:I.BACK_ARROW,minlen:this.solidMinlen(i),...r?{label:this.visit(r)}:{}}}markerlessSolidOperator(t){let n=this.nodes(t,"edgeLabel")[0],r=this.allTokens(t);if(!n)return{type:"association",arrowType:I.LINE_SOLID,minlen:this.solidMinlen(this.tokens(t,"MARKERLESS_SOLID")[0])};let i=r.at(-1),o=i.tokenType.name==="FORWARD_SOLID"?I.SOLID_ARROW:i.tokenType.name==="FORWARD_CIRCLE"?I.CIRCLE_ARROW:i.tokenType.name==="FORWARD_CROSS"?I.CROSS_ARROW:I.LINE_SOLID;return{type:"association",arrowType:o,label:this.visit(n),minlen:o===I.SOLID_ARROW||o===I.LINE_SOLID?this.solidMinlen(i):1}}forwardCircleOperator(t){return{type:"association",arrowType:I.CIRCLE_ARROW,minlen:1}}backwardCircleOperator(t){let n=this.nodes(t,"edgeLabel")[0];return{type:"association",arrowType:I.CIRCLE_ARROW_REVERSED,minlen:1,...n?{label:this.visit(n)}:{}}}forwardCrossOperator(t){return{type:"association",arrowType:I.CROSS_ARROW,minlen:1}}backwardCrossOperator(t){let n=this.nodes(t,"edgeLabel")[0];return{type:"association",arrowType:I.CROSS_ARROW_REVERSED,minlen:1,...n?{label:this.visit(n)}:{}}}actorDraft(t){return{id:t.id,kind:"actor",label:t.label,location:t.location,generated:t.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...t.metadata?{metadata:t.metadata}:{},...t.stereotype?{stereotype:t.stereotype.value,stereotypeSpan:t.stereotype.span}:{},classes:t.classes}}entityDraft(t){return{id:t.id,kind:"usecase",label:t.label,location:t.location,generated:t.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...t.shape?{shape:t.shape}:{},...t.metadata?{metadata:t.metadata}:{},...t.stereotype?{stereotype:t.stereotype.value,stereotypeSpan:t.stereotype.span}:{},classes:t.classes}}endpoint(t,n=t.explicitDeclaration??!0){return{id:t.id,label:t.label,location:t.location,generated:t.generated,declaration:n,classesOnReference:t.classes.length>0}}relationshipDraft(t,n,r){return{source:this.endpoint(t,!0),target:this.endpoint(n.target),location:r,...n.explicitId?{explicitId:n.explicitId,explicitIdLocation:n.explicitIdLocation}:{},...n.arrow}}actorOccurrence(t,n,r){return{id:n.id,span:this.nodeSpan(t),idSpan:n.location.span,labelSpan:n.label.span,...r?{defines:!0}:{},...n.stereotype?{stereotypeSpan:n.stereotype.span}:{},...n.metadata?{metadata:n.metadata.properties.map(({key:i,span:o,keySpan:l,valueSpan:c})=>({key:i,span:o,keySpan:l,valueSpan:c}))}:{},...n.classSpans.length?{classSpans:n.classSpans}:{}}}entityOccurrence(t,n,r){return this.actorOccurrence(t,n,r)}wrap(t,n){if(n.kind==="blank"||n.kind==="comment")return n;n.span=this.nodeSpan(t);for(let r of n.edges??[])r.span=n.span;return n}tokenLabel(t){let n=t.tokenType.name==="MARKDOWN_STRING"?"markdown":"text",r=n==="markdown"?2:t.tokenType.name==="PLAIN_STRING"?1:0,i=this.tokenSpan(t,r);return{text:this.source.slice(i[0],i[1]),type:n,span:i}}decodePlain(t){return t.tokenType.name==="PLAIN_STRING"?t.image.slice(1,-1):t.image}contentSpan(t){return this.tokenSpan(t,t.tokenType.name==="PLAIN_STRING"?1:t.tokenType.name==="MARKDOWN_STRING"?2:0)}generateId(t){return t.replace(/\W/g,"_")}solidMinlen(t){return Math.max(1,(t.image.match(/-/g)?.length??2)-1)}nodeLocation(t){let n=this.allTokens(t.children)[0];return{span:this.nodeSpan(t),line:n.startLine??1,column:n.startColumn??1}}ctxLocation(t){let n=this.allTokens(t).filter(o=>o.tokenType.name!=="NEWLINE"&&o.tokenType.name!=="EOF"),r=n[0],i=n.at(-1);return{span:[r.startOffset,Math.min(this.source.length,(i.endOffset??i.startOffset+i.image.length-1)+1)],line:r.startLine??1,column:r.startColumn??1}}tokenLocation(t){let n=t.tokenType.name==="PLAIN_STRING"?1:t.tokenType.name==="MARKDOWN_STRING"?2:0;return{span:this.tokenSpan(t,n),line:t.startLine??1,column:(t.startColumn??1)+n}}nodeSpan(t){let n=this.allTokens(t.children).filter(o=>o.tokenType.name!=="NEWLINE"&&o.tokenType.name!=="EOF"),r=n[0],i=n.at(-1);if(!r||!i)throw new Error("Usecase CST node has no source token");return[r.startOffset,Math.min(this.source.length,(i.endOffset??i.startOffset+i.image.length-1)+1)]}tokenSpan(t,n=0){return[t.startOffset+n,Math.min(this.source.length,(t.endOffset??t.startOffset+t.image.length-1)+1-n)]}nodes(t,n){return(t[n]??[]).filter(r=>"children"in r)}tokens(t,n){return(t[n]??[]).filter(r=>"tokenTypeIdx"in r)}firstNode(t,...n){for(let r of n){let i=this.nodes(t,r)[0];if(i)return i}throw new Error(`Usecase CST is missing one of: ${n.join(", ")}`)}allTokens(t){let n=[];for(let r of Object.values(t))for(let i of r)"tokenTypeIdx"in i?n.push(i):n.push(...this.allTokens(i.children));return n.sort((r,i)=>r.startOffset-i.startOffset)}},Hi=new tr;var Xi={parse:a(async s=>{Le.clear(),we.input=[];try{Ar({diagramType:"usecase",lexer:ji,parser:we,entry:a(()=>we.start(),"entry"),visit:a(e=>Hi.build(e,s),"visit")},s)}catch(e){Le.clear();let t=we.errors[0];if(t){let{token:n}=t,r=Oe(n.startOffset)?n.startOffset:s.length,i=Oe(n.endOffset)?n.endOffset+1:r,o=Oe(n.startLine)?n.startLine:s.slice(0,r).split(/\r\n|\r|\n/).length,l=Math.max(s.lastIndexOf(`
`,r-1),s.lastIndexOf("\r",r-1)),c=Oe(n.startColumn)?n.startColumn:r-l,h=e instanceof Error?e.message:String(e);throw new Error(`${h} at line ${o}, column ${c} [${r},${i})`)}throw e}},"parse")};var ec=["point","circle","cross","extension"],Zi={usecaseActor:!0,usecaseActorHollow:!0,usecaseActorAwesome:!0,usecaseActorIcon:!0},Yi=a((s,e)=>{let[t,n]=[s,e].map(r=>r.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element");return`usecase-${t}-${n}`},"usecaseDomId"),tc=a(s=>`usecase-${s.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element"}`,"usecaseNodeDomId"),_s=a((s,e)=>e!=="markdown"?s:fr(s).map(t=>t.map(n=>n.content).join(" ")).join(`
`),"getAccessibleLabel"),sc=a(s=>{let e=_s(s.label??s.id,s.labelType);if(Zi[s.shape]){let n=s.actorType&&s.actorType!=="normal"?`${s.actorType} `:"",r=s.business?"business ":"",i=s.stereotype?`, stereotype ${s.stereotype}`:"";return`${r}${n}actor ${e}${i}`}if(s.shape==="note")return`Note for ${s.noteTargetLabel??s.noteTarget??""}: ${e}`;if(s.shape==="usecaseJsonTable"){let n=(s.jsonRows??[]).map(r=>`${r.accessibleKey}: ${r.value}`).join("; ");return n?`${e}: ${n}`:e}let t=s.stereotype?`, stereotype ${s.stereotype}`:"";return`${s.business?"business ":""}use case ${e}${t}`},"getUsecaseNodeAccessibleName"),nc=a(s=>`${s.boundaryType} system boundary ${_s(s.label??s.id,s.labelType)}`,"getUsecaseBoundaryAccessibleName"),rc=a(s=>s.relationshipType==="note"?"":`${s.relationshipType==="association"&&s.label?`association ${_s(s.label,s.labelType)}`:s.relationshipType} from ${s.sourceLabel} to ${s.targetLabel}`,"getUsecaseEdgeAccessibleName"),Ze=a(s=>s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),"escapePlainLabel"),Ji=a(s=>s.replace(/([*[\\\]_`])/g,"\\$1"),"escapeMarkdownMarkers"),ic=a((s,e)=>{s.diagramId=e,s.markers=[...ec];for(let t of s.nodes){let n=t;if(n.domId=tc(t.id),t.label!==void 0&&t.labelType==="text"&&(t.label=Ze(t.label)),t.stereotype&&(t.stereotype=Ze(t.stereotype)),!t.isGroup&&t.shape==="usecaseJsonTable"&&(t.jsonRows=t.jsonRows?.map(r=>({...r,key:Ze(r.key),value:Ze(r.value)}))),!t.isGroup&&(t.shape==="usecaseEllipse"||t.shape==="rect")&&t.stereotype){let r=t.label??Ze(t.id);t.label=`\xAB${Ji(t.stereotype)}\xBB<br/>${t.labelType==="text"?Ji(r):r}`,t.labelType="markdown",n.hasFoldedStereotype=!0,delete t.stereotype}}for(let t of s.edges)t.label!==void 0&&t.labelType==="text"&&(t.label=Ze(t.label));return s},"prepareUsecaseLayoutData"),ac=a((s,e,t)=>{for(let r of e.nodes){let i=typeof r.domId=="string"?r.domId:Yi(e.diagramId,r.id),o=s.select(`#${i}`),l=r.isGroup?"boundary":Zi[r.shape]?"actor":r.shape==="note"?"note":r.shape==="usecaseJsonTable"?"json":"usecase",c=t.nodes.get(r.id)??r.id;if(o.attr("data-usecase-id",r.id).attr("data-usecase-kind",l).attr("role","img").attr("aria-label",c),!r.isGroup&&(r.shape==="usecaseEllipse"||r.shape==="rect")&&"hasFoldedStereotype"in r&&r.hasFoldedStereotype===!0){let h=o.node(),u=h?.querySelector(".nodeLabel"),d=u?.querySelector("p")??u,p=d?.firstChild;if(d&&p?.nodeType===3){let g=d.ownerDocument.createElement("span");g.className="usecase-stereotype",d.insertBefore(g,p),g.appendChild(p)}else h?.querySelector(".label tspan tspan, .label tspan")?.classList.add("usecase-stereotype")}}let n=new Map(e.edges.map(r=>[r.id,r]));s.selectAll('path[data-et="edge"]').each(function(){let r=n.get(this.getAttribute("data-id")??"");if(!r)return;let i=ur(this);i.attr("id",Yi(e.diagramId,r.id)).attr("data-usecase-id",r.id).attr("data-usecase-kind",r.internal?"note-connector":"relationship"),r.internal?i.attr("aria-hidden","true"):i.attr("role","img").attr("aria-label",t.edges.get(r.id)??r.id)})},"annotateUsecaseElements"),qi=a((s,e)=>{s.style("--mermaid-usecase-actor-font-size",`${e.actorFontSize}px`).style("--mermaid-usecase-actor-font-family",e.actorFontFamily).style("--mermaid-usecase-actor-font-weight",e.actorFontWeight).style("--mermaid-usecase-font-size",`${e.usecaseFontSize}px`).style("--mermaid-usecase-font-family",e.usecaseFontFamily).style("--mermaid-usecase-font-weight",e.usecaseFontWeight)},"applyUsecaseFonts"),oc=a(async(s,e,t,n)=>{ir.info("Drawing usecase diagram (unified)",e);let{layout:r}=Pt(),i=n.db,o=i.getData(),l=new Map(o.nodes.map(d=>[d.id,_s(d.label??d.id,d.labelType)])),c={nodes:new Map(o.nodes.map(d=>[d.id,d.isGroup?nc(d):sc(d.shape==="note"?{...d,noteTargetLabel:l.get(d.noteTarget??"")}:d)])),edges:new Map(o.edges.map(d=>[d.id,rc({...d,sourceLabel:l.get(d.source)??d.sourceLabel,targetLabel:l.get(d.target)??d.targetLabel})]))},h=Tr(e,o.config.securityLevel);o.layoutAlgorithm=Sr(r),ic(o,e),qi(h,o),await yr(o,h),ac(h,o,c);let u=o.diagramPadding;pr.insertTitle(h,"usecaseDiagramTitleText",0,i.getDiagramTitle?.()??""),Rr(h,u,"usecaseDiagram",o.useMaxWidth),qi(h,o)},"draw"),Qi={draw:oc};var cc=a(s=>({actorBkg:s.usecaseActorBkg??s.actorBkg??s.mainBkg,actorBorder:s.usecaseActorBorder??s.actorBorder??s.primaryColor,bkg:s.usecaseBkg??s.mainBkg,border:s.usecaseBorder??s.nodeBorder??s.primaryColor,boundaryBkg:s.usecaseBoundaryBkg??s.clusterBkg,boundaryBorder:s.usecaseBoundaryBorder??s.clusterBorder,includeLine:s.usecaseIncludeLine??s.lineColor,extendLine:s.usecaseExtendLine??s.lineColor}),"roleColors"),lc=a(s=>{let{theme:e,bkgColorArray:t,borderColorArray:n}=s;if(!gr(e,n))return"";let r=or().usecase?.colorScheme==="rotate",i=Fe(s.look),o=i==="handDrawn",l=mr(t),c="";for(let h=0;h<Er(n);h++){let u=n[h],d=l?`fill: ${t[h%t.length]};`:"",p=`[data-look="${i}"][data-color-id="color-${h}"]`;c+=`

    & ${p}.system-boundary rect.boundary-body,
    & ${p}.system-boundary rect.boundary-tab,
    & ${p}.system-boundary .boundary-body path,
    & ${p}.system-boundary .boundary-tab path {
      stroke: ${u};
      ${d}
    }
    `,r&&(c+=`

    /* Use case bodies -- \`.usecase-element\` covers the ellipse form, the \`[Rect]\` form and
       the business variant.

       Element selectors only, never a bare \`path\`. Under the handDrawn look roughjs draws
       the body as a *pair* of paths, an outline stroked in the border colour and a hachure
       fill stroked in the background colour, with no class to tell them apart. Stroking
       both repaints the fill lines as border colour and the shape collapses into a solid
       block -- which is what \`.usecase-element path\` did. So handDrawn bodies keep the
       theme's uniform colours, exactly as handDrawn flowchart nodes do. */
    & ${p}.usecase-element ellipse,
    & ${p}.usecase-element rect {
      stroke: ${u};
      ${d}
    }

    /* The business marker is a single classed path, so it can be reached safely by name --
       without it the marker keeps the uniform border beside a palette-coloured body. No
       \`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */
    & ${p}.usecase-element .usecase-business-marker {
      stroke: ${u};
    }

    /* Actor glyphs, mirroring the uniform rule further down. The fill goes on the glyph
       group, never on its children, so the hollow variant's own \`fill="none"\` keeps
       winning and a hollow actor stays hollow. Same reason as above for not descending
       into the handDrawn paths. */
    & ${p}.usecase-actor .usecase-actor-shape,
    & ${p}.usecase-actor .usecase-actor-hollow,
    & ${p}.usecase-actor .usecase-actor-awesome,
    & ${p}.usecase-actor .usecase-actor-icon {
      stroke: ${u};
      ${d}
    }
${o?"":`
    /* The group rule above reaches the glyph by inheritance, which the neo look breaks: it
       ships a \`[data-look="neo"].node path { stroke }\` rule that hits the glyph's own paths,
       and a value set directly on the child always beats one inherited from the parent,
       whatever the parent rule's specificity. So name the children too.

       Emitted for every look *except* handDrawn, where roughjs draws the glyph as an
       outline path plus a hachure fill path stroked in the fill colour, indistinguishable
       in CSS -- stroking both turns a hollow actor into a solid disc. Deliberately no
       \`fill\` either way, so the hollow variant's own \`fill="none"\` keeps winning. */
    & ${p}.usecase-actor .usecase-actor-glyph path,
    & ${p}.usecase-actor .usecase-actor-glyph circle {
      stroke: ${u};
    }
`}
    `)}return c},"genColor"),hc=a(s=>{let e=cc(s),t=Fe(s.look)==="handDrawn";return`
  ${lc(s)}
  & .usecase-actor {
    color: ${s.actorTextColor??s.primaryTextColor};
  }

  & .usecase-actor-shape,
  & .usecase-actor-hollow,
  & .usecase-actor-awesome,
  & .usecase-actor-icon {
    fill: ${e.actorBkg};
    stroke: ${e.actorBorder};
    stroke-width: 2px;
  }
${t?"":`
  /* The rule above colours the glyph group and lets its children inherit, which the neo
     look breaks: it ships a \`[data-look="neo"].node path { stroke }\` rule that lands on
     the glyph's own paths, and a value set directly on a child always beats one inherited
     from its parent, whatever the parent rule's specificity. Since neo is the default look,
     without this every actor renders in the node border colour rather than the actor
     colour the rule above asks for.

     \`.node\` is in the selector to outrank that neo rule rather than tie with it: both
     would otherwise be one attribute plus one class plus one element, leaving the winner to
     depend on which stylesheet is concatenated last.

     Stroke only: the hollow variant's own \`fill="none"\` has to keep winning. */
  & .node.usecase-actor .usecase-actor-glyph path,
  & .node.usecase-actor .usecase-actor-glyph circle {
    stroke: ${e.actorBorder};
  }
`}
  & .usecase-actor .nodeLabel,
  & .actor-label {
    color: ${s.actorTextColor??s.primaryTextColor};
    fill: ${s.actorTextColor??s.primaryTextColor};
    font-family: var(--mermaid-usecase-actor-font-family, ${s.fontFamily});
    font-size: var(--mermaid-usecase-actor-font-size, 14px);
    font-weight: var(--mermaid-usecase-actor-font-weight, normal);
  }

  & .usecase-element ellipse,
  & .usecase-element rect,
  & .usecase-business ellipse,
  & .usecase-business rect {
    fill: ${e.bkg};
    stroke: ${e.border};
    stroke-width: 2px;
  }
${t?"":`
  /* The same interception the actor glyph hits, one element down: neo ships
     \`[data-look="neo"].node rect { stroke: nodeBorder }\`, which outranks the plain
     \`.usecase-element rect\` above, so a use case written in the \`[Rect]\` form kept the node
     border colour while its ellipse siblings took the role colour. An \`<ellipse>\` has no
     equivalent neo rule and is already correct; restating it here costs nothing and means
     the two forms cannot drift apart again.

     Qualified with \`[data-look]\` *and* \`.node\` to land strictly above that rule rather than
     tie with it -- on a tie the later stylesheet would win, which is how neo took this in
     the first place. Skipped under handDrawn, where roughjs draws paths and neither element
     exists. */
  & [data-look="${Fe(s.look)}"].node.usecase-element ellipse,
  & [data-look="${Fe(s.look)}"].node.usecase-element rect {
    fill: ${e.bkg};
    stroke: ${e.border};
  }

  /* The business marker is a \`<path>\`, so it loses to \`[data-look="neo"].node path\` the same
     way. No \`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */
  & [data-look="${Fe(s.look)}"].node.usecase-element .usecase-business-marker {
    stroke: ${e.border};
  }
`}
  & .usecase-element .nodeLabel,
  & .usecase-label {
    color: ${s.primaryTextColor};
    fill: ${s.primaryTextColor};
    font-family: var(--mermaid-usecase-font-family, ${s.fontFamily});
    font-size: var(--mermaid-usecase-font-size, 12px);
    font-weight: var(--mermaid-usecase-font-weight, normal);
  }

  & .usecase-stereotype,
  & .usecase-business-marker {
    color: ${s.primaryTextColor};
    fill: ${s.primaryTextColor};
    stroke: ${e.border};
  }

  & .system-boundary rect.boundary-body,
  & .system-boundary rect.boundary-tab,
  & .system-boundary-package-tab {
    fill: ${e.boundaryBkg};
    stroke: ${e.boundaryBorder};
    stroke-width: 1px;
  }

  & .system-boundary-title text {
    fill: ${s.titleColor??s.primaryTextColor};
  }

  /* Only the span, never the <p> inside it: the renderer puts a user-supplied
     'color' on the span, and that has to stay inheritable by its children. */
  & .system-boundary-title span {
    color: ${s.titleColor??s.primaryTextColor};
  }

  & .usecase-note {
    fill: ${s.noteBkgColor};
    stroke: ${s.noteBorderColor};
    color: ${s.noteTextColor};
  }

  & .usecase-note .nodeLabel {
    color: ${s.noteTextColor};
    fill: ${s.noteTextColor};
  }

  & .usecase-json-table,
  & .usecase-json-table rect,
  & .usecase-json-cell {
    fill: ${s.mainBkg};
    stroke: ${s.nodeBorder??s.primaryColor};
  }

  & .usecase-json-title,
  & .usecase-json-key,
  & .usecase-json-value {
    color: ${s.primaryTextColor};
    fill: ${s.primaryTextColor};
  }

  & .relationship {
    fill: none;
    stroke: ${s.lineColor};
  }

  & .relationship-include,
  & .relationship-extend,
  & .relationship-note {
    stroke-dasharray: 3;
  }

  /* Include and extend are both dashed, which is a weak distinction at small sizes. The
     tokens default to \`lineColor\`, so a theme that does not set them is unchanged. */
  & .relationship-include {
    stroke: ${e.includeLine};
  }

  & .relationship-extend {
    stroke: ${e.extendLine};
  }

  & .relationship.edge-animation-fast,
  & .relationship.edge-animation-slow {
    stroke-linecap: round;
  }

  & .edgeLabel,
  & .edgeLabel p {
    background-color: ${s.edgeLabelBackground};
  }

  & .labelBkg {
    background-color: ${s.edgeLabelBackground};
    padding: 0 2px;
  }

  & .edgeLabel .label rect {
    fill: ${s.edgeLabelBackground};
  }

  & .relationship-label,
  & .edgeLabel {
    color: ${s.primaryTextColor};
    fill: ${s.primaryTextColor};
    font-family: ${s.fontFamily};
    font-size: 10px;
    font-weight: normal;
  }

  & .marker,
  & .marker.point,
  & .marker.circle,
  & .marker.cross {
    fill: ${s.lineColor};
    stroke: ${s.lineColor};
  }

  & .marker.extension {
    fill: ${s.mainBkg};
    stroke: ${s.lineColor};
  }
`},"getStyles"),ea=hc;var Pp={parser:Xi,db:Le,renderer:Qi,styles:ea};export{Pp as diagram};