UNPKG

mermaid

Version:

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

384 lines 225 kB
import{a as Go}from"./chunk-SDIBIOXT.mjs";import{a as Ko}from"./chunk-R2KH53MI.mjs";import{b as Wo,c as jo}from"./chunk-52IMQVNL.mjs";import"./chunk-MFYRHTYG.mjs";import"./chunk-JCBDXJ5W.mjs";import"./chunk-OCMJQKYE.mjs";import"./chunk-MNT3HHAC.mjs";import"./chunk-TECWHJ6D.mjs";import"./chunk-F6PIGZHG.mjs";import"./chunk-JGXDHUYS.mjs";import{b as Do}from"./chunk-TINYC7RT.mjs";import"./chunk-TDFULVG6.mjs";import{b as Fo,c as Bo,d as Yt,e as $o}from"./chunk-MIE3LDYP.mjs";import{p as Uo}from"./chunk-QADHU5CF.mjs";import"./chunk-ZZ52EIBP.mjs";import{$ as As,B as vo,T as _o,U as xs,V as Jn,W as Ss,X as Zn,Y as Mo,Z as wo,j as Io,u as ko}from"./chunk-FE53TMRB.mjs";import{b as Lo,h as Po}from"./chunk-L2B47AAZ.mjs";import{a}from"./chunk-QVIEFLGF.mjs";function zo(t,e){let r=t.lexer.tokenize(e);if(r.errors.length>0){let n=r.errors[0],o=Number.isFinite(n.offset)?n.offset:e.length,i=o+(Number.isFinite(n.length)?n.length:0);throw new Error(`Error lexing ${t.diagramType} diagram: ${n.message} at line ${n.line??1}, column ${n.column??1} [${o},${i})`)}t.parser.input=r.tokens;let s=t.entry();if(t.parser.errors.length>0)throw new Error(`Error parsing ${t.diagramType} diagram: ${t.parser.errors[0].message}`);t.visit(s)}a(zo,"runChevrotainParse");var w={SOLID_ARROW:0,BACK_ARROW:1,LINE_SOLID:2,CIRCLE_ARROW:3,CROSS_ARROW:4,CIRCLE_ARROW_REVERSED:5,CROSS_ARROW_REVERSED:6},Ho="LR";var Ef=Io.usecase,Qn=a(()=>({actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,symbols:new Map,direction:Ho,relationshipCounter:0,noteCounter:0,accTitle:"",accDescription:"",ast:void 0,config:structuredClone(Ef)}),"createModel"),Tf=a(t=>{if(!(t.actors instanceof Map)||!(t.useCases instanceof Map)||!(t.systemBoundaries instanceof Map)||!Array.isArray(t.relationships)||!(t.notes instanceof Map)||!(t.jsonNodes instanceof Map)||!(t.classDefs instanceof Map)||!(t.symbols instanceof Map)||!["TB","TD","BT","RL","LR"].includes(t.direction)||!Number.isSafeInteger(t.relationshipCounter)||t.relationshipCounter<0||!Number.isSafeInteger(t.noteCounter)||t.noteCounter<0||typeof t.accTitle!="string"||typeof t.accDescription!="string"||!t.config)throw new Error("Cannot commit an incomplete usecase model")},"assertCompleteModel"),k=Qn(),xf=a(()=>structuredClone(k.config),"getConfig"),Sf=a(()=>k.ast,"getAST"),Af=a(t=>{let e=structuredClone(t);Tf(e);let r=Jn(),s=Zn();try{xs(e.accTitle),Ss(e.accDescription),k=e}catch(n){throw xs(r),Ss(s),n}},"commit"),Rf=a(()=>{k=Qn(),_o()},"clear"),bf=a(()=>k.actors,"getActors"),Nf=a(t=>k.actors.get(t),"getActor"),Of=a(()=>k.useCases,"getUseCases"),Cf=a(t=>k.useCases.get(t),"getUseCase"),Lf=a(()=>k.systemBoundaries,"getSystemBoundaries"),If=a(t=>k.systemBoundaries.get(t),"getSystemBoundary"),kf=a(()=>k.relationships,"getRelationships"),vf=a(()=>k.notes,"getNotes"),_f=a(t=>k.notes.get(t),"getNote"),Mf=a(()=>k.jsonNodes,"getJsonNodes"),wf=a(t=>k.jsonNodes.get(t),"getJsonNode"),Pf=a(()=>k.classDefs,"getClassDefs"),Uf=a(t=>k.classDefs.get(t),"getClassDef"),Yo=a(()=>k.direction,"getDirection"),wt=a(t=>{let e=new Map;for(let r of["default",...t]){let s=k.classDefs.get(r);if(s)for(let n of s.styles){let o=n.trim(),i=o.indexOf(":"),c=(i===-1?o:o.slice(0,i)).trim();c&&e.set(c,o)}}return[...e.values()]},"getCompiledStyles"),Df=a(t=>t.replaceAll("~","~0").replaceAll("/","~1"),"escapeJsonPointerPart"),Vo=a(t=>typeof t=="string"?t:t===null?"null":String(t),"displayJsonScalar"),Ff=a((t,e,r=s=>s)=>{let s=[],n=a((i,c,l)=>{s.push({key:r(i),accessibleKey:r(c),value:r(l)})},"append"),o=a((i,c,l)=>{if(Array.isArray(i)){if(i.length===0){n(c,c,"[]");return}if(i.every(d=>d===null||["string","number","boolean"].includes(typeof d))){for(let[d,f]of i.entries())n(d===0?c:"",c,Vo(f));return}for(let[d,f]of i.entries())o(f,`${c}[${d}]`,`${l}/${d}`);return}if(i!==null&&typeof i=="object"){let u=i,d=e[l]??Object.keys(u);if(d.length===0){n(c,c,"{}");return}for(let f of d){let p=c?`${c}.${f}`:f;o(u[f],p,`${l}/${Df(f)}`)}return}n(c,c,Vo(i))},"visit");return o(t,"",""),s},"flattenJsonRows"),Bf=a(t=>{switch(t.type){case"hollow":return"usecaseActorHollow";case"awesome":return"usecaseActorAwesome";case"icon":return"usecaseActorIcon";case"normal":return"usecaseActor"}},"actorShape"),$f=a(t=>t.shape==="ellipse"?t.business?"usecaseBusiness":"usecaseEllipse":t.shape,"useCaseShape"),Gf=a(t=>{switch(t){case w.SOLID_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point"};case w.BACK_ARROW:return{arrowTypeStart:"arrow_point",arrowTypeEnd:"none"};case w.CIRCLE_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_circle"};case w.CROSS_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_cross"};case w.CIRCLE_ARROW_REVERSED:return{arrowTypeStart:"arrow_circle",arrowTypeEnd:"none"};case w.CROSS_ARROW_REVERSED:return{arrowTypeStart:"arrow_cross",arrowTypeEnd:"none"};case w.LINE_SOLID:return{arrowTypeStart:"none",arrowTypeEnd:"none"}}},"associationMarkers"),Wf=a(t=>{switch(t.type){case"include":case"extend":return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point",pattern:"dotted",label:t.type,labelType:"text"};case"generalization":return{arrowTypeStart:"none",arrowTypeEnd:"extension",pattern:"solid"};case"association":return{...Gf(t.arrowType),pattern:"solid",...t.label?{label:t.label}:{},...t.labelType?{labelType:t.labelType}:{}}}},"relationshipVisuals"),jf=a(t=>t.animate||t.animation?[`edge-animation-${t.animation??"fast"}`]:[],"animationClasses"),Br=a((...t)=>t.filter(e=>!!e).join(" "),"classNames"),Kf=a(()=>{let t=As(),e={...k.config,...t.usecase},r=a(l=>vo(l,t),"sanitize"),s=a(l=>r(k.actors.get(l)?.label??k.useCases.get(l)?.label??k.jsonNodes.get(l)?.id??k.notes.get(l)?.label??l),"endpointLabel"),n=[],o=[],i=0,c=0;for(let l of k.actors.values())n.push({id:l.id,label:r(l.label),labelType:l.labelType,shape:Bf(l),isGroup:!1,padding:10,look:t.look,colorIndex:i++,cssClasses:Br("default","usecase-actor",`usecase-actor-${l.type}`,l.business&&"usecase-business",...l.classes),cssStyles:[...l.styles],cssCompiledStyles:wt(l.classes),actorType:l.type,business:l.business,...l.icon?{icon:l.icon}:{},...l.stereotype?{stereotype:r(l.stereotype)}:{},...l.parentId?{parentId:l.parentId}:{}});for(let l of k.useCases.values())n.push({id:l.id,label:r(l.label),labelType:l.labelType,shape:$f(l),isGroup:!1,padding:l.shape==="ellipse"?20:10,look:t.look,colorIndex:i++,cssClasses:Br("default","usecase-element",`usecase-${l.shape}`,l.business&&"usecase-business",...l.classes),cssStyles:[...l.styles],cssCompiledStyles:wt(l.classes),business:l.business,...l.stereotype?{stereotype:r(l.stereotype)}:{},...l.parentId?{parentId:l.parentId}:{}});for(let l of k.notes.values())n.push({id:l.id,label:r(l.label),labelType:l.labelType,shape:"note",isGroup:!1,padding:10,look:t.look,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:wt([]),noteTarget:l.target,noteTargetLabel:r(k.actors.get(l.target)?.label??k.useCases.get(l.target)?.label??k.jsonNodes.get(l.target)?.id??l.target)});for(let l of k.jsonNodes.values())n.push({id:l.id,label:r(l.id),labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,look:t.look,cssClasses:Br("default","usecase-json-table",...l.classes),cssStyles:[...l.styles],cssCompiledStyles:wt(l.classes),jsonRows:Ff(l.value,l.propertyOrder,r)});for(let l of k.systemBoundaries.values())n.push({id:l.id,label:r(l.label),labelType:l.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,look:t.look,colorIndex:c++,cssClasses:Br("default","system-boundary",`system-boundary-${l.type}`,...l.classes),cssStyles:[...l.styles],cssCompiledStyles:wt(l.classes),boundaryType:l.type});for(let l of k.relationships){let{label:u,...d}=Wf(l);o.push({id:l.id,start:l.source,end:l.target,source:l.source,target:l.target,sourceLabel:s(l.source),targetLabel:s(l.target),type:"edge",relationshipType:l.type,internal:!1,...d,...u!==void 0?{label:r(u)}:{},labelpos:"c",classes:Br("default","relationship",`relationship-${l.type}`,...l.classes,...jf(l)),style:[...l.styles],cssCompiledStyles:wt(l.classes),animate:l.animate,...l.animation?{animation:l.animation}:{},look:t.look,thickness:"normal",minlen:l.minlen,isUserDefinedId:l.explicitId})}for(let l of k.notes.values())o.push({id:`${l.id}-edge`,start:l.id,end:l.target,source:l.id,target:l.target,type:"edge",relationshipType:"note",sourceLabel:s(l.id),targetLabel:s(l.target),internal:!0,pattern:"dotted",arrowTypeStart:"none",arrowTypeEnd:"none",labelpos:"c",classes:"default relationship relationship-note",style:[],cssCompiledStyles:wt([]),animate:!1,look:t.look,thickness:"normal",minlen:1,isUserDefinedId:!1});for(let l of n)l.wrappingWidth??=e.wrappingWidth,!l.isGroup&&!l.shape.startsWith("usecaseActor")&&(l.minWidth??=e.minNodeWidth),(l.shape==="usecaseEllipse"||l.shape==="usecaseBusiness")&&(l.spreadPorts=!0);return{nodes:n,edges:o,config:t,type:"usecase",layoutAlgorithm:"dagre",direction:Yo(),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"),Pt={getConfig:xf,createModel:Qn,commit:Af,getAST:Sf,clear:Rf,setDiagramTitle:Mo,getDiagramTitle:wo,setAccTitle:xs,getAccTitle:Jn,setAccDescription:Ss,getAccDescription:Zn,getActors:bf,getActor:Nf,getUseCases:Of,getUseCase:Cf,getSystemBoundaries:Lf,getSystemBoundary:If,getRelationships:kf,getNotes:vf,getNote:_f,getJsonNodes:Mf,getJsonNode:wf,getClassDefs:Pf,getClassDef:Uf,getDirection:Yo,getData:Kf};var zf=typeof global=="object"&&global&&global.Object===Object&&global,Rs=zf;var Hf=typeof self=="object"&&self&&self.Object===Object&&self,Vf=Rs||Hf||Function("return this")(),te=Vf;var Yf=te.Symbol,fe=Yf;var Xo=Object.prototype,Xf=Xo.hasOwnProperty,qf=Xo.toString,$r=fe?fe.toStringTag:void 0;function Jf(t){var e=Xf.call(t,$r),r=t[$r];try{t[$r]=void 0;var s=!0}catch{}var n=qf.call(t);return s&&(e?t[$r]=r:delete t[$r]),n}a(Jf,"getRawTag");var qo=Jf;var Zf=Object.prototype,Qf=Zf.toString;function ed(t){return Qf.call(t)}a(ed,"objectToString");var Jo=ed;var td="[object Null]",rd="[object Undefined]",Zo=fe?fe.toStringTag:void 0;function sd(t){return t==null?t===void 0?rd:td:Zo&&Zo in Object(t)?qo(t):Jo(t)}a(sd,"baseGetTag");var Te=sd;function nd(t){return t!=null&&typeof t=="object"}a(nd,"isObjectLike");var J=nd;var ad="[object Symbol]";function od(t){return typeof t=="symbol"||J(t)&&Te(t)==ad}a(od,"isSymbol");var mt=od;function id(t,e){for(var r=-1,s=t==null?0:t.length,n=Array(s);++r<s;)n[r]=e(t[r],r,t);return n}a(id,"arrayMap");var He=id;var ld=Array.isArray,A=ld;var cd=1/0,Qo=fe?fe.prototype:void 0,ei=Qo?Qo.toString:void 0;function ti(t){if(typeof t=="string")return t;if(A(t))return He(t,ti)+"";if(mt(t))return ei?ei.call(t):"";var e=t+"";return e=="0"&&1/t==-cd?"-0":e}a(ti,"baseToString");var ri=ti;var ud=/\s/;function fd(t){for(var e=t.length;e--&&ud.test(t.charAt(e)););return e}a(fd,"trimmedEndIndex");var si=fd;var dd=/^\s+/;function pd(t){return t&&t.slice(0,si(t)+1).replace(dd,"")}a(pd,"baseTrim");var ni=pd;function hd(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}a(hd,"isObject");var z=hd;var ai=NaN,md=/^[-+]0x[0-9a-f]+$/i,gd=/^0b[01]+$/i,yd=/^0o[0-7]+$/i,Ed=parseInt;function Td(t){if(typeof t=="number")return t;if(mt(t))return ai;if(z(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=z(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=ni(t);var r=gd.test(t);return r||yd.test(t)?Ed(t.slice(2),r?2:8):md.test(t)?ai:+t}a(Td,"toNumber");var oi=Td;var ii=1/0,xd=17976931348623157e292;function Sd(t){if(!t)return t===0?t:0;if(t=oi(t),t===ii||t===-ii){var e=t<0?-1:1;return e*xd}return t===t?t:0}a(Sd,"toFinite");var li=Sd;function Ad(t){var e=li(t),r=e%1;return e===e?r?e-r:e:0}a(Ad,"toInteger");var Ve=Ad;function Rd(t){return t}a(Rd,"identity");var Ge=Rd;var bd="[object AsyncFunction]",Nd="[object Function]",Od="[object GeneratorFunction]",Cd="[object Proxy]";function Ld(t){if(!z(t))return!1;var e=Te(t);return e==Nd||e==Od||e==bd||e==Cd}a(Ld,"isFunction");var xe=Ld;var Id=te["__core-js_shared__"],bs=Id;var ci=(function(){var t=/[^.]+$/.exec(bs&&bs.keys&&bs.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function kd(t){return!!ci&&ci in t}a(kd,"isMasked");var ui=kd;var vd=Function.prototype,_d=vd.toString;function Md(t){if(t!=null){try{return _d.call(t)}catch{}try{return t+""}catch{}}return""}a(Md,"toSource");var at=Md;var wd=/[\\^$.*+?()[\]{}|]/g,Pd=/^\[object .+?Constructor\]$/,Ud=Function.prototype,Dd=Object.prototype,Fd=Ud.toString,Bd=Dd.hasOwnProperty,$d=RegExp("^"+Fd.call(Bd).replace(wd,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Gd(t){if(!z(t)||ui(t))return!1;var e=xe(t)?$d:Pd;return e.test(at(t))}a(Gd,"baseIsNative");var fi=Gd;function Wd(t,e){return t?.[e]}a(Wd,"getValue");var di=Wd;function jd(t,e){var r=di(t,e);return fi(r)?r:void 0}a(jd,"getNative");var Oe=jd;var Kd=Oe(te,"WeakMap"),Ns=Kd;var pi=Object.create,zd=(function(){function t(){}return a(t,"object"),function(e){if(!z(e))return{};if(pi)return pi(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}})(),hi=zd;function Hd(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}a(Hd,"apply");var mi=Hd;function Vd(){}a(Vd,"noop");var Y=Vd;function Yd(t,e){var r=-1,s=t.length;for(e||(e=Array(s));++r<s;)e[r]=t[r];return e}a(Yd,"copyArray");var gi=Yd;var Xd=800,qd=16,Jd=Date.now;function Zd(t){var e=0,r=0;return function(){var s=Jd(),n=qd-(s-r);if(r=s,n>0){if(++e>=Xd)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}a(Zd,"shortOut");var yi=Zd;function Qd(t){return function(){return t}}a(Qd,"constant");var Ei=Qd;var ep=(function(){try{var t=Oe(Object,"defineProperty");return t({},"",{}),t}catch{}})(),Xt=ep;var tp=Xt?function(t,e){return Xt(t,"toString",{configurable:!0,enumerable:!1,value:Ei(e),writable:!0})}:Ge,Ti=tp;var rp=yi(Ti),xi=rp;function sp(t,e){for(var r=-1,s=t==null?0:t.length;++r<s&&e(t[r],r,t)!==!1;);return t}a(sp,"arrayEach");var Os=sp;function np(t,e,r,s){for(var n=t.length,o=r+(s?1:-1);s?o--:++o<n;)if(e(t[o],o,t))return o;return-1}a(np,"baseFindIndex");var Cs=np;function ap(t){return t!==t}a(ap,"baseIsNaN");var Si=ap;function op(t,e,r){for(var s=r-1,n=t.length;++s<n;)if(t[s]===e)return s;return-1}a(op,"strictIndexOf");var Ai=op;function ip(t,e,r){return e===e?Ai(t,e,r):Cs(t,Si,r)}a(ip,"baseIndexOf");var qt=ip;function lp(t,e){var r=t==null?0:t.length;return!!r&&qt(t,e,0)>-1}a(lp,"arrayIncludes");var Ls=lp;var cp=9007199254740991,up=/^(?:0|[1-9]\d*)$/;function fp(t,e){var r=typeof t;return e=e??cp,!!e&&(r=="number"||r!="symbol"&&up.test(t))&&t>-1&&t%1==0&&t<e}a(fp,"isIndex");var gt=fp;function dp(t,e,r){e=="__proto__"&&Xt?Xt(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}a(dp,"baseAssignValue");var Jt=dp;function pp(t,e){return t===e||t!==t&&e!==e}a(pp,"eq");var Ye=pp;var hp=Object.prototype,mp=hp.hasOwnProperty;function gp(t,e,r){var s=t[e];(!(mp.call(t,e)&&Ye(s,r))||r===void 0&&!(e in t))&&Jt(t,e,r)}a(gp,"assignValue");var yt=gp;function yp(t,e,r,s){var n=!r;r||(r={});for(var o=-1,i=e.length;++o<i;){var c=e[o],l=s?s(r[c],t[c],c,r,t):void 0;l===void 0&&(l=t[c]),n?Jt(r,c,l):yt(r,c,l)}return r}a(yp,"copyObject");var Xe=yp;var Ri=Math.max;function Ep(t,e,r){return e=Ri(e===void 0?t.length-1:e,0),function(){for(var s=arguments,n=-1,o=Ri(s.length-e,0),i=Array(o);++n<o;)i[n]=s[e+n];n=-1;for(var c=Array(e+1);++n<e;)c[n]=s[n];return c[e]=r(i),mi(t,this,c)}}a(Ep,"overRest");var bi=Ep;function Tp(t,e){return xi(bi(t,e,Ge),t+"")}a(Tp,"baseRest");var Zt=Tp;var xp=9007199254740991;function Sp(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=xp}a(Sp,"isLength");var Qt=Sp;function Ap(t){return t!=null&&Qt(t.length)&&!xe(t)}a(Ap,"isArrayLike");var re=Ap;function Rp(t,e,r){if(!z(r))return!1;var s=typeof e;return(s=="number"?re(r)&&gt(e,r.length):s=="string"&&e in r)?Ye(r[e],t):!1}a(Rp,"isIterateeCall");var Et=Rp;function bp(t){return Zt(function(e,r){var s=-1,n=r.length,o=n>1?r[n-1]:void 0,i=n>2?r[2]:void 0;for(o=t.length>3&&typeof o=="function"?(n--,o):void 0,i&&Et(r[0],r[1],i)&&(o=n<3?void 0:o,n=1),e=Object(e);++s<n;){var c=r[s];c&&t(e,c,s,o)}return e})}a(bp,"createAssigner");var Ni=bp;var Np=Object.prototype;function Op(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||Np;return t===r}a(Op,"isPrototype");var qe=Op;function Cp(t,e){for(var r=-1,s=Array(t);++r<t;)s[r]=e(r);return s}a(Cp,"baseTimes");var Oi=Cp;var Lp="[object Arguments]";function Ip(t){return J(t)&&Te(t)==Lp}a(Ip,"baseIsArguments");var ea=Ip;var Ci=Object.prototype,kp=Ci.hasOwnProperty,vp=Ci.propertyIsEnumerable,_p=ea((function(){return arguments})())?ea:function(t){return J(t)&&kp.call(t,"callee")&&!vp.call(t,"callee")},Tt=_p;function Mp(){return!1}a(Mp,"stubFalse");var Li=Mp;var vi=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ii=vi&&typeof module=="object"&&module&&!module.nodeType&&module,wp=Ii&&Ii.exports===vi,ki=wp?te.Buffer:void 0,Pp=ki?ki.isBuffer:void 0,Up=Pp||Li,ot=Up;var Dp="[object Arguments]",Fp="[object Array]",Bp="[object Boolean]",$p="[object Date]",Gp="[object Error]",Wp="[object Function]",jp="[object Map]",Kp="[object Number]",zp="[object Object]",Hp="[object RegExp]",Vp="[object Set]",Yp="[object String]",Xp="[object WeakMap]",qp="[object ArrayBuffer]",Jp="[object DataView]",Zp="[object Float32Array]",Qp="[object Float64Array]",eh="[object Int8Array]",th="[object Int16Array]",rh="[object Int32Array]",sh="[object Uint8Array]",nh="[object Uint8ClampedArray]",ah="[object Uint16Array]",oh="[object Uint32Array]",$={};$[Zp]=$[Qp]=$[eh]=$[th]=$[rh]=$[sh]=$[nh]=$[ah]=$[oh]=!0;$[Dp]=$[Fp]=$[qp]=$[Bp]=$[Jp]=$[$p]=$[Gp]=$[Wp]=$[jp]=$[Kp]=$[zp]=$[Hp]=$[Vp]=$[Yp]=$[Xp]=!1;function ih(t){return J(t)&&Qt(t.length)&&!!$[Te(t)]}a(ih,"baseIsTypedArray");var _i=ih;function lh(t){return function(e){return t(e)}}a(lh,"baseUnary");var Je=lh;var Mi=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Gr=Mi&&typeof module=="object"&&module&&!module.nodeType&&module,ch=Gr&&Gr.exports===Mi,ta=ch&&Rs.process,uh=(function(){try{var t=Gr&&Gr.require&&Gr.require("util").types;return t||ta&&ta.binding&&ta.binding("util")}catch{}})(),Ue=uh;var wi=Ue&&Ue.isTypedArray,fh=wi?Je(wi):_i,er=fh;var dh=Object.prototype,ph=dh.hasOwnProperty;function hh(t,e){var r=A(t),s=!r&&Tt(t),n=!r&&!s&&ot(t),o=!r&&!s&&!n&&er(t),i=r||s||n||o,c=i?Oi(t.length,String):[],l=c.length;for(var u in t)(e||ph.call(t,u))&&!(i&&(u=="length"||n&&(u=="offset"||u=="parent")||o&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||gt(u,l)))&&c.push(u);return c}a(hh,"arrayLikeKeys");var Is=hh;function mh(t,e){return function(r){return t(e(r))}}a(mh,"overArg");var ks=mh;var gh=ks(Object.keys,Object),Pi=gh;var yh=Object.prototype,Eh=yh.hasOwnProperty;function Th(t){if(!qe(t))return Pi(t);var e=[];for(var r in Object(t))Eh.call(t,r)&&r!="constructor"&&e.push(r);return e}a(Th,"baseKeys");var vs=Th;function xh(t){return re(t)?Is(t):vs(t)}a(xh,"keys");var P=xh;var Sh=Object.prototype,Ah=Sh.hasOwnProperty,Rh=Ni(function(t,e){if(qe(e)||re(e)){Xe(e,P(e),t);return}for(var r in e)Ah.call(e,r)&&yt(t,r,e[r])}),pe=Rh;function bh(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}a(bh,"nativeKeysIn");var Ui=bh;var Nh=Object.prototype,Oh=Nh.hasOwnProperty;function Ch(t){if(!z(t))return Ui(t);var e=qe(t),r=[];for(var s in t)s=="constructor"&&(e||!Oh.call(t,s))||r.push(s);return r}a(Ch,"baseKeysIn");var Di=Ch;function Lh(t){return re(t)?Is(t,!0):Di(t)}a(Lh,"keysIn");var xt=Lh;var Ih=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,kh=/^\w*$/;function vh(t,e){if(A(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||mt(t)?!0:kh.test(t)||!Ih.test(t)||e!=null&&t in Object(e)}a(vh,"isKey");var tr=vh;var _h=Oe(Object,"create"),it=_h;function Mh(){this.__data__=it?it(null):{},this.size=0}a(Mh,"hashClear");var Fi=Mh;function wh(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}a(wh,"hashDelete");var Bi=wh;var Ph="__lodash_hash_undefined__",Uh=Object.prototype,Dh=Uh.hasOwnProperty;function Fh(t){var e=this.__data__;if(it){var r=e[t];return r===Ph?void 0:r}return Dh.call(e,t)?e[t]:void 0}a(Fh,"hashGet");var $i=Fh;var Bh=Object.prototype,$h=Bh.hasOwnProperty;function Gh(t){var e=this.__data__;return it?e[t]!==void 0:$h.call(e,t)}a(Gh,"hashHas");var Gi=Gh;var Wh="__lodash_hash_undefined__";function jh(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=it&&e===void 0?Wh:e,this}a(jh,"hashSet");var Wi=jh;function rr(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var s=t[e];this.set(s[0],s[1])}}a(rr,"Hash");rr.prototype.clear=Fi;rr.prototype.delete=Bi;rr.prototype.get=$i;rr.prototype.has=Gi;rr.prototype.set=Wi;var ra=rr;function Kh(){this.__data__=[],this.size=0}a(Kh,"listCacheClear");var ji=Kh;function zh(t,e){for(var r=t.length;r--;)if(Ye(t[r][0],e))return r;return-1}a(zh,"assocIndexOf");var St=zh;var Hh=Array.prototype,Vh=Hh.splice;function Yh(t){var e=this.__data__,r=St(e,t);if(r<0)return!1;var s=e.length-1;return r==s?e.pop():Vh.call(e,r,1),--this.size,!0}a(Yh,"listCacheDelete");var Ki=Yh;function Xh(t){var e=this.__data__,r=St(e,t);return r<0?void 0:e[r][1]}a(Xh,"listCacheGet");var zi=Xh;function qh(t){return St(this.__data__,t)>-1}a(qh,"listCacheHas");var Hi=qh;function Jh(t,e){var r=this.__data__,s=St(r,t);return s<0?(++this.size,r.push([t,e])):r[s][1]=e,this}a(Jh,"listCacheSet");var Vi=Jh;function sr(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var s=t[e];this.set(s[0],s[1])}}a(sr,"ListCache");sr.prototype.clear=ji;sr.prototype.delete=Ki;sr.prototype.get=zi;sr.prototype.has=Hi;sr.prototype.set=Vi;var At=sr;var Zh=Oe(te,"Map"),Rt=Zh;function Qh(){this.size=0,this.__data__={hash:new ra,map:new(Rt||At),string:new ra}}a(Qh,"mapCacheClear");var Yi=Qh;function em(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}a(em,"isKeyable");var Xi=em;function tm(t,e){var r=t.__data__;return Xi(e)?r[typeof e=="string"?"string":"hash"]:r.map}a(tm,"getMapData");var bt=tm;function rm(t){var e=bt(this,t).delete(t);return this.size-=e?1:0,e}a(rm,"mapCacheDelete");var qi=rm;function sm(t){return bt(this,t).get(t)}a(sm,"mapCacheGet");var Ji=sm;function nm(t){return bt(this,t).has(t)}a(nm,"mapCacheHas");var Zi=nm;function am(t,e){var r=bt(this,t),s=r.size;return r.set(t,e),this.size+=r.size==s?0:1,this}a(am,"mapCacheSet");var Qi=am;function nr(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var s=t[e];this.set(s[0],s[1])}}a(nr,"MapCache");nr.prototype.clear=Yi;nr.prototype.delete=qi;nr.prototype.get=Ji;nr.prototype.has=Zi;nr.prototype.set=Qi;var Ut=nr;var om="Expected a function";function sa(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(om);var r=a(function(){var s=arguments,n=e?e.apply(this,s):s[0],o=r.cache;if(o.has(n))return o.get(n);var i=t.apply(this,s);return r.cache=o.set(n,i)||o,i},"memoized");return r.cache=new(sa.Cache||Ut),r}a(sa,"memoize");sa.Cache=Ut;var el=sa;var im=500;function lm(t){var e=el(t,function(s){return r.size===im&&r.clear(),s}),r=e.cache;return e}a(lm,"memoizeCapped");var tl=lm;var cm=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,um=/\\(\\)?/g,fm=tl(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(cm,function(r,s,n,o){e.push(n?o.replace(um,"$1"):s||r)}),e}),rl=fm;function dm(t){return t==null?"":ri(t)}a(dm,"toString");var sl=dm;function pm(t,e){return A(t)?t:tr(t,e)?[t]:rl(sl(t))}a(pm,"castPath");var Nt=pm;var hm=1/0;function mm(t){if(typeof t=="string"||mt(t))return t;var e=t+"";return e=="0"&&1/t==-hm?"-0":e}a(mm,"toKey");var Ze=mm;function gm(t,e){e=Nt(e,t);for(var r=0,s=e.length;t!=null&&r<s;)t=t[Ze(e[r++])];return r&&r==s?t:void 0}a(gm,"baseGet");var ar=gm;function ym(t,e,r){var s=t==null?void 0:ar(t,e);return s===void 0?r:s}a(ym,"get");var nl=ym;function Em(t,e){for(var r=-1,s=e.length,n=t.length;++r<s;)t[n+r]=e[r];return t}a(Em,"arrayPush");var or=Em;var al=fe?fe.isConcatSpreadable:void 0;function Tm(t){return A(t)||Tt(t)||!!(al&&t&&t[al])}a(Tm,"isFlattenable");var ol=Tm;function il(t,e,r,s,n){var o=-1,i=t.length;for(r||(r=ol),n||(n=[]);++o<i;){var c=t[o];e>0&&r(c)?e>1?il(c,e-1,r,s,n):or(n,c):s||(n[n.length]=c)}return n}a(il,"baseFlatten");var ir=il;function xm(t){var e=t==null?0:t.length;return e?ir(t,1):[]}a(xm,"flatten");var oe=xm;var Sm=ks(Object.getPrototypeOf,Object),_s=Sm;function Am(t,e,r){var s=-1,n=t.length;e<0&&(e=-e>n?0:n+e),r=r>n?n:r,r<0&&(r+=n),n=e>r?0:r-e>>>0,e>>>=0;for(var o=Array(n);++s<n;)o[s]=t[s+e];return o}a(Am,"baseSlice");var Ms=Am;function Rm(t,e,r,s){var n=-1,o=t==null?0:t.length;for(s&&o&&(r=t[++n]);++n<o;)r=e(r,t[n],n,t);return r}a(Rm,"arrayReduce");var ll=Rm;function bm(){this.__data__=new At,this.size=0}a(bm,"stackClear");var cl=bm;function Nm(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}a(Nm,"stackDelete");var ul=Nm;function Om(t){return this.__data__.get(t)}a(Om,"stackGet");var fl=Om;function Cm(t){return this.__data__.has(t)}a(Cm,"stackHas");var dl=Cm;var Lm=200;function Im(t,e){var r=this.__data__;if(r instanceof At){var s=r.__data__;if(!Rt||s.length<Lm-1)return s.push([t,e]),this.size=++r.size,this;r=this.__data__=new Ut(s)}return r.set(t,e),this.size=r.size,this}a(Im,"stackSet");var pl=Im;function lr(t){var e=this.__data__=new At(t);this.size=e.size}a(lr,"Stack");lr.prototype.clear=cl;lr.prototype.delete=ul;lr.prototype.get=fl;lr.prototype.has=dl;lr.prototype.set=pl;var Ot=lr;function km(t,e){return t&&Xe(e,P(e),t)}a(km,"baseAssign");var hl=km;function vm(t,e){return t&&Xe(e,xt(e),t)}a(vm,"baseAssignIn");var ml=vm;var Tl=typeof exports=="object"&&exports&&!exports.nodeType&&exports,gl=Tl&&typeof module=="object"&&module&&!module.nodeType&&module,_m=gl&&gl.exports===Tl,yl=_m?te.Buffer:void 0,El=yl?yl.allocUnsafe:void 0;function Mm(t,e){if(e)return t.slice();var r=t.length,s=El?El(r):new t.constructor(r);return t.copy(s),s}a(Mm,"cloneBuffer");var xl=Mm;function wm(t,e){for(var r=-1,s=t==null?0:t.length,n=0,o=[];++r<s;){var i=t[r];e(i,r,t)&&(o[n++]=i)}return o}a(wm,"arrayFilter");var cr=wm;function Pm(){return[]}a(Pm,"stubArray");var ws=Pm;var Um=Object.prototype,Dm=Um.propertyIsEnumerable,Sl=Object.getOwnPropertySymbols,Fm=Sl?function(t){return t==null?[]:(t=Object(t),cr(Sl(t),function(e){return Dm.call(t,e)}))}:ws,ur=Fm;function Bm(t,e){return Xe(t,ur(t),e)}a(Bm,"copySymbols");var Al=Bm;var $m=Object.getOwnPropertySymbols,Gm=$m?function(t){for(var e=[];t;)or(e,ur(t)),t=_s(t);return e}:ws,Ps=Gm;function Wm(t,e){return Xe(t,Ps(t),e)}a(Wm,"copySymbolsIn");var Rl=Wm;function jm(t,e,r){var s=e(t);return A(t)?s:or(s,r(t))}a(jm,"baseGetAllKeys");var Us=jm;function Km(t){return Us(t,P,ur)}a(Km,"getAllKeys");var Wr=Km;function zm(t){return Us(t,xt,Ps)}a(zm,"getAllKeysIn");var Ds=zm;var Hm=Oe(te,"DataView"),Fs=Hm;var Vm=Oe(te,"Promise"),Bs=Vm;var Ym=Oe(te,"Set"),Ct=Ym;var bl="[object Map]",Xm="[object Object]",Nl="[object Promise]",Ol="[object Set]",Cl="[object WeakMap]",Ll="[object DataView]",qm=at(Fs),Jm=at(Rt),Zm=at(Bs),Qm=at(Ct),eg=at(Ns),Dt=Te;(Fs&&Dt(new Fs(new ArrayBuffer(1)))!=Ll||Rt&&Dt(new Rt)!=bl||Bs&&Dt(Bs.resolve())!=Nl||Ct&&Dt(new Ct)!=Ol||Ns&&Dt(new Ns)!=Cl)&&(Dt=a(function(t){var e=Te(t),r=e==Xm?t.constructor:void 0,s=r?at(r):"";if(s)switch(s){case qm:return Ll;case Jm:return bl;case Zm:return Nl;case Qm:return Ol;case eg:return Cl}return e},"getTag"));var We=Dt;var tg=Object.prototype,rg=tg.hasOwnProperty;function sg(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&rg.call(t,"index")&&(r.index=t.index,r.input=t.input),r}a(sg,"initCloneArray");var Il=sg;var ng=te.Uint8Array,fr=ng;function ag(t){var e=new t.constructor(t.byteLength);return new fr(e).set(new fr(t)),e}a(ag,"cloneArrayBuffer");var dr=ag;function og(t,e){var r=e?dr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}a(og,"cloneDataView");var kl=og;var ig=/\w*$/;function lg(t){var e=new t.constructor(t.source,ig.exec(t));return e.lastIndex=t.lastIndex,e}a(lg,"cloneRegExp");var vl=lg;var _l=fe?fe.prototype:void 0,Ml=_l?_l.valueOf:void 0;function cg(t){return Ml?Object(Ml.call(t)):{}}a(cg,"cloneSymbol");var wl=cg;function ug(t,e){var r=e?dr(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}a(ug,"cloneTypedArray");var Pl=ug;var fg="[object Boolean]",dg="[object Date]",pg="[object Map]",hg="[object Number]",mg="[object RegExp]",gg="[object Set]",yg="[object String]",Eg="[object Symbol]",Tg="[object ArrayBuffer]",xg="[object DataView]",Sg="[object Float32Array]",Ag="[object Float64Array]",Rg="[object Int8Array]",bg="[object Int16Array]",Ng="[object Int32Array]",Og="[object Uint8Array]",Cg="[object Uint8ClampedArray]",Lg="[object Uint16Array]",Ig="[object Uint32Array]";function kg(t,e,r){var s=t.constructor;switch(e){case Tg:return dr(t);case fg:case dg:return new s(+t);case xg:return kl(t,r);case Sg:case Ag:case Rg:case bg:case Ng:case Og:case Cg:case Lg:case Ig:return Pl(t,r);case pg:return new s;case hg:case yg:return new s(t);case mg:return vl(t);case gg:return new s;case Eg:return wl(t)}}a(kg,"initCloneByTag");var Ul=kg;function vg(t){return typeof t.constructor=="function"&&!qe(t)?hi(_s(t)):{}}a(vg,"initCloneObject");var Dl=vg;var _g="[object Map]";function Mg(t){return J(t)&&We(t)==_g}a(Mg,"baseIsMap");var Fl=Mg;var Bl=Ue&&Ue.isMap,wg=Bl?Je(Bl):Fl,$l=wg;var Pg="[object Set]";function Ug(t){return J(t)&&We(t)==Pg}a(Ug,"baseIsSet");var Gl=Ug;var Wl=Ue&&Ue.isSet,Dg=Wl?Je(Wl):Gl,jl=Dg;var Fg=1,Bg=2,$g=4,Kl="[object Arguments]",Gg="[object Array]",Wg="[object Boolean]",jg="[object Date]",Kg="[object Error]",zl="[object Function]",zg="[object GeneratorFunction]",Hg="[object Map]",Vg="[object Number]",Hl="[object Object]",Yg="[object RegExp]",Xg="[object Set]",qg="[object String]",Jg="[object Symbol]",Zg="[object WeakMap]",Qg="[object ArrayBuffer]",ey="[object DataView]",ty="[object Float32Array]",ry="[object Float64Array]",sy="[object Int8Array]",ny="[object Int16Array]",ay="[object Int32Array]",oy="[object Uint8Array]",iy="[object Uint8ClampedArray]",ly="[object Uint16Array]",cy="[object Uint32Array]",U={};U[Kl]=U[Gg]=U[Qg]=U[ey]=U[Wg]=U[jg]=U[ty]=U[ry]=U[sy]=U[ny]=U[ay]=U[Hg]=U[Vg]=U[Hl]=U[Yg]=U[Xg]=U[qg]=U[Jg]=U[oy]=U[iy]=U[ly]=U[cy]=!0;U[Kg]=U[zl]=U[Zg]=!1;function $s(t,e,r,s,n,o){var i,c=e&Fg,l=e&Bg,u=e&$g;if(r&&(i=n?r(t,s,n,o):r(t)),i!==void 0)return i;if(!z(t))return t;var d=A(t);if(d){if(i=Il(t),!c)return gi(t,i)}else{var f=We(t),p=f==zl||f==zg;if(ot(t))return xl(t,c);if(f==Hl||f==Kl||p&&!n){if(i=l||p?{}:Dl(t),!c)return l?Rl(t,ml(i,t)):Al(t,hl(i,t))}else{if(!U[f])return n?t:{};i=Ul(t,f,c)}}o||(o=new Ot);var m=o.get(t);if(m)return m;o.set(t,i),jl(t)?t.forEach(function(O){i.add($s(O,e,r,O,t,o))}):$l(t)&&t.forEach(function(O,g){i.set(g,$s(O,e,r,g,t,o))});var R=u?l?Ds:Wr:l?xt:P,b=d?void 0:R(t);return Os(b||t,function(O,g){b&&(g=O,O=t[g]),yt(i,g,$s(O,e,r,g,t,o))}),i}a($s,"baseClone");var Vl=$s;var uy=4;function fy(t){return Vl(t,uy)}a(fy,"clone");var D=fy;function dy(t){for(var e=-1,r=t==null?0:t.length,s=0,n=[];++e<r;){var o=t[e];o&&(n[s++]=o)}return n}a(dy,"compact");var Qe=dy;var py="__lodash_hash_undefined__";function hy(t){return this.__data__.set(t,py),this}a(hy,"setCacheAdd");var Yl=hy;function my(t){return this.__data__.has(t)}a(my,"setCacheHas");var Xl=my;function Gs(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Ut;++e<r;)this.add(t[e])}a(Gs,"SetCache");Gs.prototype.add=Gs.prototype.push=Yl;Gs.prototype.has=Xl;var pr=Gs;function gy(t,e){for(var r=-1,s=t==null?0:t.length;++r<s;)if(e(t[r],r,t))return!0;return!1}a(gy,"arraySome");var Ws=gy;function yy(t,e){return t.has(e)}a(yy,"cacheHas");var hr=yy;var Ey=1,Ty=2;function xy(t,e,r,s,n,o){var i=r&Ey,c=t.length,l=e.length;if(c!=l&&!(i&&l>c))return!1;var u=o.get(t),d=o.get(e);if(u&&d)return u==e&&d==t;var f=-1,p=!0,m=r&Ty?new pr:void 0;for(o.set(t,e),o.set(e,t);++f<c;){var R=t[f],b=e[f];if(s)var O=i?s(b,R,f,e,t,o):s(R,b,f,t,e,o);if(O!==void 0){if(O)continue;p=!1;break}if(m){if(!Ws(e,function(g,E){if(!hr(m,E)&&(R===g||n(R,g,r,s,o)))return m.push(E)})){p=!1;break}}else if(!(R===b||n(R,b,r,s,o))){p=!1;break}}return o.delete(t),o.delete(e),p}a(xy,"equalArrays");var js=xy;function Sy(t){var e=-1,r=Array(t.size);return t.forEach(function(s,n){r[++e]=[n,s]}),r}a(Sy,"mapToArray");var ql=Sy;function Ay(t){var e=-1,r=Array(t.size);return t.forEach(function(s){r[++e]=s}),r}a(Ay,"setToArray");var mr=Ay;var Ry=1,by=2,Ny="[object Boolean]",Oy="[object Date]",Cy="[object Error]",Ly="[object Map]",Iy="[object Number]",ky="[object RegExp]",vy="[object Set]",_y="[object String]",My="[object Symbol]",wy="[object ArrayBuffer]",Py="[object DataView]",Jl=fe?fe.prototype:void 0,na=Jl?Jl.valueOf:void 0;function Uy(t,e,r,s,n,o,i){switch(r){case Py:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case wy:return!(t.byteLength!=e.byteLength||!o(new fr(t),new fr(e)));case Ny:case Oy:case Iy:return Ye(+t,+e);case Cy:return t.name==e.name&&t.message==e.message;case ky:case _y:return t==e+"";case Ly:var c=ql;case vy:var l=s&Ry;if(c||(c=mr),t.size!=e.size&&!l)return!1;var u=i.get(t);if(u)return u==e;s|=by,i.set(t,e);var d=js(c(t),c(e),s,n,o,i);return i.delete(t),d;case My:if(na)return na.call(t)==na.call(e)}return!1}a(Uy,"equalByTag");var Zl=Uy;var Dy=1,Fy=Object.prototype,By=Fy.hasOwnProperty;function $y(t,e,r,s,n,o){var i=r&Dy,c=Wr(t),l=c.length,u=Wr(e),d=u.length;if(l!=d&&!i)return!1;for(var f=l;f--;){var p=c[f];if(!(i?p in e:By.call(e,p)))return!1}var m=o.get(t),R=o.get(e);if(m&&R)return m==e&&R==t;var b=!0;o.set(t,e),o.set(e,t);for(var O=i;++f<l;){p=c[f];var g=t[p],E=e[p];if(s)var h=i?s(E,g,p,e,t,o):s(g,E,p,t,e,o);if(!(h===void 0?g===E||n(g,E,r,s,o):h)){b=!1;break}O||(O=p=="constructor")}if(b&&!O){var x=t.constructor,M=e.constructor;x!=M&&"constructor"in t&&"constructor"in e&&!(typeof x=="function"&&x instanceof x&&typeof M=="function"&&M instanceof M)&&(b=!1)}return o.delete(t),o.delete(e),b}a($y,"equalObjects");var Ql=$y;var Gy=1,ec="[object Arguments]",tc="[object Array]",Ks="[object Object]",Wy=Object.prototype,rc=Wy.hasOwnProperty;function jy(t,e,r,s,n,o){var i=A(t),c=A(e),l=i?tc:We(t),u=c?tc:We(e);l=l==ec?Ks:l,u=u==ec?Ks:u;var d=l==Ks,f=u==Ks,p=l==u;if(p&&ot(t)){if(!ot(e))return!1;i=!0,d=!1}if(p&&!d)return o||(o=new Ot),i||er(t)?js(t,e,r,s,n,o):Zl(t,e,l,r,s,n,o);if(!(r&Gy)){var m=d&&rc.call(t,"__wrapped__"),R=f&&rc.call(e,"__wrapped__");if(m||R){var b=m?t.value():t,O=R?e.value():e;return o||(o=new Ot),n(b,O,r,s,o)}}return p?(o||(o=new Ot),Ql(t,e,r,s,n,o)):!1}a(jy,"baseIsEqualDeep");var sc=jy;function nc(t,e,r,s,n){return t===e?!0:t==null||e==null||!J(t)&&!J(e)?t!==t&&e!==e:sc(t,e,r,s,nc,n)}a(nc,"baseIsEqual");var zs=nc;var Ky=1,zy=2;function Hy(t,e,r,s){var n=r.length,o=n,i=!s;if(t==null)return!o;for(t=Object(t);n--;){var c=r[n];if(i&&c[2]?c[1]!==t[c[0]]:!(c[0]in t))return!1}for(;++n<o;){c=r[n];var l=c[0],u=t[l],d=c[1];if(i&&c[2]){if(u===void 0&&!(l in t))return!1}else{var f=new Ot;if(s)var p=s(u,d,l,t,e,f);if(!(p===void 0?zs(d,u,Ky|zy,s,f):p))return!1}}return!0}a(Hy,"baseIsMatch");var ac=Hy;function Vy(t){return t===t&&!z(t)}a(Vy,"isStrictComparable");var Hs=Vy;function Yy(t){for(var e=P(t),r=e.length;r--;){var s=e[r],n=t[s];e[r]=[s,n,Hs(n)]}return e}a(Yy,"getMatchData");var oc=Yy;function Xy(t,e){return function(r){return r==null?!1:r[t]===e&&(e!==void 0||t in Object(r))}}a(Xy,"matchesStrictComparable");var Vs=Xy;function qy(t){var e=oc(t);return e.length==1&&e[0][2]?Vs(e[0][0],e[0][1]):function(r){return r===t||ac(r,t,e)}}a(qy,"baseMatches");var ic=qy;function Jy(t,e){return t!=null&&e in Object(t)}a(Jy,"baseHasIn");var lc=Jy;function Zy(t,e,r){e=Nt(e,t);for(var s=-1,n=e.length,o=!1;++s<n;){var i=Ze(e[s]);if(!(o=t!=null&&r(t,i)))break;t=t[i]}return o||++s!=n?o:(n=t==null?0:t.length,!!n&&Qt(n)&&gt(i,n)&&(A(t)||Tt(t)))}a(Zy,"hasPath");var Ys=Zy;function Qy(t,e){return t!=null&&Ys(t,e,lc)}a(Qy,"hasIn");var cc=Qy;var eE=1,tE=2;function rE(t,e){return tr(t)&&Hs(e)?Vs(Ze(t),e):function(r){var s=nl(r,t);return s===void 0&&s===e?cc(r,t):zs(e,s,eE|tE)}}a(rE,"baseMatchesProperty");var uc=rE;function sE(t){return function(e){return e?.[t]}}a(sE,"baseProperty");var fc=sE;function nE(t){return function(e){return ar(e,t)}}a(nE,"basePropertyDeep");var dc=nE;function aE(t){return tr(t)?fc(Ze(t)):dc(t)}a(aE,"property");var pc=aE;function oE(t){return typeof t=="function"?t:t==null?Ge:typeof t=="object"?A(t)?uc(t[0],t[1]):ic(t):pc(t)}a(oE,"baseIteratee");var se=oE;function iE(t,e,r,s){for(var n=-1,o=t==null?0:t.length;++n<o;){var i=t[n];e(s,i,r(i),t)}return s}a(iE,"arrayAggregator");var hc=iE;function lE(t){return function(e,r,s){for(var n=-1,o=Object(e),i=s(e),c=i.length;c--;){var l=i[t?c:++n];if(r(o[l],l,o)===!1)break}return e}}a(lE,"createBaseFor");var mc=lE;var cE=mc(),gc=cE;function uE(t,e){return t&&gc(t,e,P)}a(uE,"baseForOwn");var yc=uE;function fE(t,e){return function(r,s){if(r==null)return r;if(!re(r))return t(r,s);for(var n=r.length,o=e?n:-1,i=Object(r);(e?o--:++o<n)&&s(i[o],o,i)!==!1;);return r}}a(fE,"createBaseEach");var Ec=fE;var dE=Ec(yc),Ce=dE;function pE(t,e,r,s){return Ce(t,function(n,o,i){e(s,n,r(n),i)}),s}a(pE,"baseAggregator");var Tc=pE;function hE(t,e){return function(r,s){var n=A(r)?hc:Tc,o=e?e():{};return n(r,t,se(s,2),o)}}a(hE,"createAggregator");var xc=hE;var Sc=Object.prototype,mE=Sc.hasOwnProperty,gE=Zt(function(t,e){t=Object(t);var r=-1,s=e.length,n=s>2?e[2]:void 0;for(n&&Et(e[0],e[1],n)&&(s=1);++r<s;)for(var o=e[r],i=xt(o),c=-1,l=i.length;++c<l;){var u=i[c],d=t[u];(d===void 0||Ye(d,Sc[u])&&!mE.call(t,u))&&(t[u]=o[u])}return t}),gr=gE;function yE(t){return J(t)&&re(t)}a(yE,"isArrayLikeObject");var aa=yE;function EE(t,e,r){for(var s=-1,n=t==null?0:t.length;++s<n;)if(r(e,t[s]))return!0;return!1}a(EE,"arrayIncludesWith");var Xs=EE;var TE=200;function xE(t,e,r,s){var n=-1,o=Ls,i=!0,c=t.length,l=[],u=e.length;if(!c)return l;r&&(e=He(e,Je(r))),s?(o=Xs,i=!1):e.length>=TE&&(o=hr,i=!1,e=new pr(e));e:for(;++n<c;){var d=t[n],f=r==null?d:r(d);if(d=s||d!==0?d:0,i&&f===f){for(var p=u;p--;)if(e[p]===f)continue e;l.push(d)}else o(e,f,s)||l.push(d)}return l}a(xE,"baseDifference");var Ac=xE;var SE=Zt(function(t,e){return aa(t)?Ac(t,ir(e,1,aa,!0)):[]}),Lt=SE;function AE(t){var e=t==null?0:t.length;return e?t[e-1]:void 0}a(AE,"last");var je=AE;function RE(t,e,r){var s=t==null?0:t.length;return s?(e=r||e===void 0?1:Ve(e),Ms(t,e<0?0:e,s)):[]}a(RE,"drop");var Z=RE;function bE(t,e,r){var s=t==null?0:t.length;return s?(e=r||e===void 0?1:Ve(e),e=s-e,Ms(t,0,e<0?0:e)):[]}a(bE,"dropRight");var lt=bE;function NE(t){return typeof t=="function"?t:Ge}a(NE,"castFunction");var Rc=NE;function OE(t,e){var r=A(t)?Os:Ce;return r(t,Rc(e))}a(OE,"forEach");var T=OE;function CE(t,e){for(var r=-1,s=t==null?0:t.length;++r<s;)if(!e(t[r],r,t))return!1;return!0}a(CE,"arrayEvery");var bc=CE;function LE(t,e){var r=!0;return Ce(t,function(s,n,o){return r=!!e(s,n,o),r}),r}a(LE,"baseEvery");var Nc=LE;function IE(t,e,r){var s=A(t)?bc:Nc;return r&&Et(t,e,r)&&(e=void 0),s(t,se(e,3))}a(IE,"every");var he=IE;function kE(t,e){var r=[];return Ce(t,function(s,n,o){e(s,n,o)&&r.push(s)}),r}a(kE,"baseFilter");var qs=kE;function vE(t,e){var r=A(t)?cr:qs;return r(t,se(e,3))}a(vE,"filter");var me=vE;function _E(t){return function(e,r,s){var n=Object(e);if(!re(e)){var o=se(r,3);e=P(e),r=a(function(c){return o(n[c],c,n)},"predicate")}var i=t(e,r,s);return i>-1?n[o?e[i]:i]:void 0}}a(_E,"createFind");var Oc=_E;var ME=Math.max;function wE(t,e,r){var s=t==null?0:t.length;if(!s)return-1;var n=r==null?0:Ve(r);return n<0&&(n=ME(s+n,0)),Cs(t,se(e,3),n)}a(wE,"findIndex");var Cc=wE;var PE=Oc(Cc),et=PE;function UE(t){return t&&t.length?t[0]:void 0}a(UE,"head");var de=UE;function DE(t,e){var r=-1,s=re(t)?Array(t.length):[];return Ce(t,function(n,o,i){s[++r]=e(n,o,i)}),s}a(DE,"baseMap");var Lc=DE;function FE(t,e){var r=A(t)?He:Lc;return r(t,se(e,3))}a(FE,"map");var y=FE;function BE(t,e){return ir(y(t,e),1)}a(BE,"flatMap");var Se=BE;var $E=Object.prototype,GE=$E.hasOwnProperty,WE=xc(function(t,e,r){GE.call(t,r)?t[r].push(e):Jt(t,r,[e])}),oa=WE;var jE=Object.prototype,KE=jE.hasOwnProperty;function zE(t,e){return t!=null&&KE.call(t,e)}a(zE,"baseHas");var Ic=zE;function HE(t,e){return t!=null&&Ys(t,e,Ic)}a(HE,"has");var S=HE;var VE="[object String]";function YE(t){return typeof t=="string"||!A(t)&&J(t)&&Te(t)==VE}a(YE,"isString");var ie=YE;function XE(t,e){return He(e,function(r){return t[r]})}a(XE,"baseValues");var kc=XE;function qE(t){return t==null?[]:kc(t,P(t))}a(qE,"values");var _=qE;var JE=Math.max;function ZE(t,e,r,s){t=re(t)?t:_(t),r=r&&!s?Ve(r):0;var n=t.length;return r<0&&(r=JE(n+r,0)),ie(t)?r<=n&&t.indexOf(e,r)>-1:!!n&&qt(t,e,r)>-1}a(ZE,"includes");var W=ZE;var QE=Math.max;function eT(t,e,r){var s=t==null?0:t.length;if(!s)return-1;var n=r==null?0:Ve(r);return n<0&&(n=QE(s+n,0)),qt(t,e,n)}a(eT,"indexOf");var Js=eT;var tT="[object Map]",rT="[object Set]",sT=Object.prototype,nT=sT.hasOwnProperty;function aT(t){if(t==null)return!0;if(re(t)&&(A(t)||typeof t=="string"||typeof t.splice=="function"||ot(t)||er(t)||Tt(t)))return!t.length;var e=We(t);if(e==tT||e==rT)return!t.size;if(qe(t))return!vs(t).length;for(var r in t)if(nT.call(t,r))return!1;return!0}a(aT,"isEmpty");var L=aT;var oT="[object RegExp]";function iT(t){return J(t)&&Te(t)==oT}a(iT,"baseIsRegExp");var vc=iT;var _c=Ue&&Ue.isRegExp,lT=_c?Je(_c):vc,De=lT;function cT(t){return t===void 0}a(cT,"isUndefined");var ge=cT;var uT="Expected a function";function fT(t){if(typeof t!="function")throw new TypeError(uT);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}a(fT,"negate");var Mc=fT;function dT(t,e,r,s){if(!z(t))return t;e=Nt(e,t);for(var n=-1,o=e.length,i=o-1,c=t;c!=null&&++n<o;){var l=Ze(e[n]),u=r;if(l==="__proto__"||l==="constructor"||l==="prototype")return t;if(n!=i){var d=c[l];u=s?s(d,l,c):void 0,u===void 0&&(u=z(d)?d:gt(e[n+1])?[]:{})}yt(c,l,u),c=c[l]}return t}a(dT,"baseSet");var wc=dT;function pT(t,e,r){for(var s=-1,n=e.length,o={};++s<n;){var i=e[s],c=ar(t,i);r(c,i)&&wc(o,Nt(i,t),c)}return o}a(pT,"basePickBy");var Pc=pT;function hT(t,e){if(t==null)return{};var r=He(Ds(t),function(s){return[s]});return e=se(e),Pc(t,r,function(s,n){return e(s,n[0])})}a(hT,"pickBy");var Le=hT;function mT(t,e,r,s,n){return n(t,function(o,i,c){r=s?(s=!1,o):e(r,o,i,c)}),r}a(mT,"baseReduce");var Uc=mT;function gT(t,e,r){var s=A(t)?ll:Uc,n=arguments.length<3;return s(t,se(e,4),r,n,Ce)}a(gT,"reduce");var ne=gT;function yT(t,e){var r=A(t)?cr:qs;return r(t,Mc(se(e,3)))}a(yT,"reject");var It=yT;function ET(t,e){var r;return Ce(t,function(s,n,o){return r=e(s,n,o),!r}),!!r}a(ET,"baseSome");var Dc=ET;function TT(t,e,r){var s=A(t)?Ws:Dc;return r&&Et(t,e,r)&&(e=void 0),s(t,se(e,3))}a(TT,"some");var jr=TT;var xT=1/0,ST=Ct&&1/mr(new Ct([,-0]))[1]==xT?function(t){return new Ct(t)}:Y,Fc=ST;var AT=200;function RT(t,e,r){var s=-1,n=Ls,o=t.length,i=!0,c=[],l=c;if(r)i=!1,n=Xs;else if(o>=AT){var u=e?null:Fc(t);if(u)return mr(u);i=!1,n=hr,l=new pr}else l=e?[]:c;e:for(;++s<o;){var d=t[s],f=e?e(d):d;if(d=r||d!==0?d:0,i&&f===f){for(var p=l.length;p--;)if(l[p]===f)continue e;e&&l.push(f),c.push(d)}else n(l,f,r)||(l!==c&&l.push(f),c.push(d))}return c}a(RT,"baseUniq");var Bc=RT;function bT(t){return t&&t.length?Bc(t):[]}a(bT,"uniq");var yr=bT;function Er(t){console&&console.error&&console.error(`Error: ${t}`)}a(Er,"PRINT_ERROR");function Kr(t){console&&console.warn&&console.warn(`Warning: ${t}`)}a(Kr,"PRINT_WARNING");function zr(t){let e=new Date().getTime(),r=t();return{time:new Date().getTime()-e,value:r}}a(zr,"timer");function Hr(t){function e(){}a(e,"FakeConstructor"),e.prototype=t;let r=new e;function s(){return typeof r.bar}return a(s,"fakeAccess"),s(),s(),t;(0,eval)(t)}a(Hr,"toFastProperties");function NT(t){return OT(t)?t.LABEL:t.name}a(NT,"tokenLabel");function OT(t){return ie(t.LABEL)&&t.LABEL!==""}a(OT,"hasTokenLabel");var ve=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),T(this.definition,r=>{r.accept(e)})}},F=class extends ve{static{a(this,"NonTerminal")}constructor(e){super([]),this.idx=1,pe(this,Le(e,r=>r!==void 0))}set definition(e){}get definition(){return this.referencedRule!==void 0?this.referencedRule.definition:[]}accept(e){e.visit(this)}},Ae=class extends ve{static{a(this,"Rule")}constructor(e){super(e.definition),this.orgText="",pe(this,Le(e,r=>r!==void 0))}},B=class extends ve{static{a(this,"Alternative")}constructor(e){super(e.definition),this.ignoreAmbiguities=!1,pe(this,Le(e,r=>r!==void 0))}},G=class extends ve{static{a(this,"Option")}constructor(e){super(e.definition),this.idx=1,pe(this,Le(e,r=>r!==void 0))}},Q=class extends ve{static{a(this,"RepetitionMandatory")}constructor(e){super(e.definition),this.idx=1,pe(this,Le(e,r=>r!==void 0))}},ee=class extends ve{static{a(this,"RepetitionMandatoryWithSeparator")}constructor(e){super(e.definition),this.idx=1,pe(this,Le(e,r=>r!==void 0))}},v=class extends ve{static{a(this,"Repetition")}constructor(e){super(e.definition),this.idx=1,pe(this,Le(e,r=>r!==void 0))}},X=class extends ve{static{a(this,"RepetitionWithSeparator")}constructor(e){super(e.definition),this.idx=1,pe(this,Le(e,r=>r!==void 0))}},q=class extends ve{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,pe(this,Le(e,r=>r!==void 0))}},I=class{static{a(this,"Terminal")}constructor(e){this.idx=1,pe(this,Le(e,r=>r!==void 0))}accept(e){e.visit(this)}};function Zs(t){return y(t,Tr)}a(Zs,"serializeGrammar");function Tr(t){function e(r){return y(r,Tr)}if(a(e,"convertDefinition"),t instanceof F){let r={type:"NonTerminal",name:t.nonTerminalName,idx:t.idx};return ie(t.label)&&(r.label=t.label),r}else{if(t instanceof B)return{type:"Alternative",definition:e(t.definition)};if(t instanceof G)return{type:"Option",idx:t.idx,definition:e(t.definition)};if(t instanceof Q)return{type:"RepetitionMandatory",idx:t.idx,definition:e(t.definition)};if(t instanceof ee)return{type:"RepetitionMandatoryWithSeparator",idx:t.idx,separator:Tr(new I({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof X)return{type:"RepetitionWithSeparator",idx:t.idx,separator:Tr(new I({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof v)return{type:"Repetition",idx:t.idx,definition:e(t.definition)};if(t instanceof q)return{type:"Alternation",idx:t.idx,definition:e(t.definition)};if(t instanceof I){let r={type:"Terminal",name:t.terminalType.name,label:NT(t.terminalType),idx:t.idx};ie(t.label)&&(r.terminalLabel=t.label);let s=t.terminalType.PATTERN;return t.terminalType.PATTERN&&(r.pattern=De(s)?s.source:s),r}else{if(t instanceof Ae)return{type:"Rule",name:t.name,orgText:t.orgText,definition:e(t.definition)};throw Error("non exhaustive match")}}}a(Tr,"serializeProduction");var Re=class{static{a(this,"GAstVisitor")}visit(e){let r=e;switch(r.constructor){case F:return this.visitNonTerminal(r);case B:return this.visitAlternative(r);case G:return this.visitOption(r);case Q:return this.visitRepetitionMandatory(r);case ee:return this.visitRepetitionMandatoryWithSeparator(r);case X:return this.visitRepetitionWithSeparator(r);case v:return this.visitRepetition(r);case q:return this.visitAlternation(r);case I:return this.visitTerminal(r);case Ae:return this.visitRule(r);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 ia(t){return t instanceof B||t instanceof G||t instanceof v||t instanceof Q||t instanceof ee||t instanceof X||t instanceof I||t instanceof Ae}a(ia,"isSequenceProd");function Ft(t,e=[]){return t instanceof G||t instanceof v||t instanceof X?!0:t instanceof q?jr(t.definition,s=>Ft(s,e)):t instanceof F&&W(e,t)?!1:t instanceof ve?(t instanceof F&&e.push(t),he(t.definition,s=>Ft(s,e))):!1}a(Ft,"isOptionalProd");function la(t){return t instanceof q}a(la,"isBranchingProd");function Ie(t){if(t instanceof F)return"SUBRULE";if(t instanceof G)return"OPTION";if(t instanceof q)return"OR";if(t instanceof Q)return"AT_LEAST_ONE";if(t instanceof ee)return"AT_LEAST_ONE_SEP";if(t instanceof X)return"MANY_SEP";if(t instanceof v)return"MANY";if(t instanceof I)return"CONSUME";throw Error("non exhaustive match")}a(Ie,"getProductionDslName");var ct=class{static{a(this,"RestWalker")}walk(e,r=[]){T(e.definition,(s,n)=>{let o=Z(e.definition,n+1);if(s instanceof F)this.walkProdRef(s,o,r);else if(s instanceof I)this.walkTerminal(s,o,r);else if(s instanceof B)this.walkFlat(s,o,r);else if(s instanceof G)this.walkOption(s,o,r);else if(s instanceof Q)this.walkAtLeastOne(s,o,r);else if(s instanceof ee)this.walkAtLeastOneSep(s,o,r);else if(s instanceof X)this.walkManySep(s,o,r);else if(s instanceof v)this.walkMany(s,o,r);else if(s instanceof q)this.walkOr(s,o,r);else throw Error("non exhaustive match")})}walkTerminal(e,r,s){}walkProdRef(e,r,s){}walkFlat(e,r,s){let n=r.concat(s);this.walk(e,n)}walkOption(e,r,s){let n=r.concat(s);this.walk(e,n)}walkAtLeastOne(e,r,s){let n=[new G({definition:e.definition})].concat(r,s);this.walk(e,n)}walkAtLeastOneSep(e,r,s){let n=$c(e,r,s);this.walk(e,n)}walkMany(e,r,s){let n=[new G({definition:e.definition})].concat(r,s);this.walk(e,n)}walkManySep(e,r,s){let n=$c(e,r,s);this.walk(e,n)}walkOr(e,r,s){let n=r.concat(s);T(e.definition,o=>{let i=new B({definition:[o]});this.walk(i,n)})}};function $c(t,e,r){return[new G({definition:[new I({terminalType:t.separator})].concat(t.definition)})].concat(e,r)}a($c,"restForRepetitionWithSeparator");function Bt(t){if(t instanceof F)return Bt(t.referencedRule);if(t instanceof I)return IT(t);if(ia(t))return CT(t);if(la(t))return LT(t);throw Error("non exhaustive match")}a(Bt,"first");function CT(t){let e=[],r=t.definition,s=0,n=r.length>s,o,i=!0;for(;n&&i;)o=r[s],i=Ft(o),e=e.concat(Bt(o)),s=s+1,n=r.length>s;return yr(e)}a(CT,"firstForSequence");function LT(t){let e=y(t.definition,r=>Bt(r));return yr(oe(e))}a(LT,"firstForBranching");function IT(t){return[t.terminalType]}a(IT,"firstForTerminal");var Qs="_~IN~_";var ca=class extends ct{static{a(this,"ResyncFollowsWalker")}constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,r,s){}walkProdRef(e,r,s){let n=kT(e.referencedRule,e.idx)+this.topProd.name,o=r.concat(s),i=new B({definition:o}),c=Bt(i);this.follows[n]=c}};function Gc(t){let e={};return T(t,r=>{let s=new ca(r).startWalking();pe(e,s)}),e}a(Gc,"computeAllProdsFollows");function kT(t,e){return t.name+e+Qs}a(kT,"buildBetweenProdsFollowPrefix");function C(t){return t.charCodeAt(0)}a(C,"cc");function en(t,e){Array.isArray(t)?t.forEach(function(r){e.push(r)}):e.push(t)}a(en,"insertToSet");function xr(t,e){if(t[e]===!0)throw"duplicate flag "+e;let r=t[e];t[e]=!0}a(xr,"addFlag");function $t(t){if(t===void 0)throw Error("Internal Error - Should never get here!");return!0}a($t,"ASSERT_EXISTS");function Vr(){throw Error("Internal Error - Should never get here!")}a(Vr,"ASSERT_NEVER_REACH_HERE");function ua(t){return t.type==="Character"}a(ua,"isCharacter");var Yr=[];for(let t=C("0");t<=C("9");t++)Yr.push(t);var Xr=[C("_")].concat(Yr);for(let t=C("a");t<=C("z");t++)Xr.push(t);for(let t=C("A");t<=C("Z");t++)Xr.push(t);var fa=[C(" "),C("\f"),C(`
`),C("\r"),C("	"),C("\v"),C("	"),C("\xA0"),C("\u1680"),C("\u2000"),C("\u2001"),C("\u2002"),C("\u2003"),C("\u2004"),C("\u2005"),C("\u2006"),C("\u2007"),C("\u2008"),C("\u2009"),C("\u200A"),C("\u2028"),C("\u2029"),C("\u202F"),C("\u205F"),C("\u3000"),C("\uFEFF")];var vT=/[0-9a-fA-F]/,tn=/[0-9]/,_T=/[1-9]/,qr=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 r=this.disjunction();this.consumeChar("/");let s={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":xr(s,"global");break;case"i":xr(s,"ignoreCase");break;case"m":xr(s,"multiLine");break;case"u":xr(s,"unicode");break;case"y":xr(s,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:s,value:r,loc:this.loc(0)}}disjunction(){let e=[],r=this.idx;for(e.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(r)}}alternative(){let e=[],r=this.idx;for(;this.isTerm();)e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(r)}}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 r;switch(this.popChar()){case"=":r="Lookahead";break;case"!":r="NegativeLookahead";break;case"<":{switch(this.popChar()){case"=":r="Lookbehind";break;case"!":r="NegativeLookbehind"}break}}$t(r);let s=this.disjunction();return this.consumeChar(")"),{type:r,value:s,loc:this.loc(e)}}return Vr()}quantifier(e=!1){let r,s=this.idx;switch(this.popChar()){case"*":r={atLeast:0,atMost:1/0};break;case"+":r={atLeast:1,atMost:1/0};break;case"?":r={atLeast:0,atMost:1};break;case"{":let n=this.integerIncludingZero();switch(this.popChar()){case"}":r={atLeast:n,atMost:n};break;case",":let o;this.isDigit()?(o=this.integerIncludingZero(),r={atLeast:n,atMost:o}):r={atLeast:n,atMost:1/0},this.consumeChar("}");break}if(e===!0&&r===void 0)return;$t(r);break}if(!(e===!0&&r===void 0)&&$t(r))return this.peekChar(0)==="?"?(this.consumeChar("?"),r.greedy=!1):r.greedy=!0,r.type="Quantifier",r.loc=this.loc(s),r}atom(){let e,r=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()),$t(e)?(e.loc=this.loc(r),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):Vr()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[C(`
`),C("\r"),C("\u2028"),C("\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,r=!1;switch(this.popChar()){case"d":e=Yr;break;case"D":e=Yr,r=!0;break;case"s":e=fa;break;case"S":e=fa,r=!0;break;case"w":e=Xr;break;case"W":e=Xr,r=!0;break}return $t(e)?{type:"Set",value:e,complement:r}:Vr()}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=C("\f");break;case"n":e=C(`
`);break;case"r":e=C("\r");break;case"t":e=C("	");break;case"v":e=C("\v");break}return $t(e)?{type:"Character",value:e}:Vr()}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:C("\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:C(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:C(e)}}}characterClass(){let e=[],r=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),r=!0);this.isClassAtom();){let s=this.classAtom(),n=s.type==="Character";if(ua(s)&&this.isRangeDash()){this.consumeChar("-");let o=this.classAtom(),i=o.type==="Character";if(ua(o)){if(o.value<s.value)throw Error("Range out of order in character class");e.push({from:s.value,to:o.value})}else en(s.value,e),e.push(C("-")),en(o.value,e)}else en(s.value,e)}return this.consumeChar("]"),{type:"Set",complement:r,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:C("\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 r=this.disjunction();this.consumeChar(")");let s={type:"Group",capturing:e,value:r};return e&&(s.idx=this.groupIdx),s}positiveInteger(){let e=this.popChar();if(_T.test(e)===!1)throw Error("Expecting a positive integer");for(;tn.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(tn.test(e)===!1)throw Error("Expecting an integer");for(;tn.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:C(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 tn.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 r="";for(let n=0;n<e;n++){let o=this.popChar();if(vT.test(o)===!1)throw Error("Expecting a HexDecimal digits");r+=o}return{type:"Character",value:parseInt(r,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 kt=class{static{a(this,"BaseRegExpVisitor")}visitChildren(e){for(let r in e){let s=e[r];e.hasOwnProperty(r)&&(s.type!==void 0?this.visit(s):Array.isArray(s)&&s.forEach(n=>{this.visit(n)},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 rn={},MT=new qr;function Sr(t){let e=t.toString();if(rn.hasOwnProperty(e))return rn[e];{let r=MT.pattern(e);return rn[e]=r,r}}a(Sr,"getRegExpAst");function Wc(){rn={}}a(Wc,"clearRegExpParserCache");var Kc="Complement Sets are not supported for first char optimization",Jr=`Unable to use "first char" lexer optimizations:
`;function zc(t,e=!1){try{let r=Sr(t);return da(r.value,{},r.flags.ignoreCase)}catch(r){if(r.message===Kc)e&&Kr(`${Jr}	Unable to optimize: < ${t.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 s="";e&&(s=`
	This will disable the lexer's first char optimizations.
	See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),Er(`${Jr}
	Failed parsing: < ${t.toString()} >
	Using the @chevrotain/regexp-to-ast library
	Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+s)}}return[]}a(zc,"getOptimizedStartCodesIndices");function da(t,e,r){switch(t.type){case"Disjunction":for(let n=0;n<t.value.length;n++)da(t.value[n],e,r);break;case"Alternative":let s=t.value;for(let n=0;n<s.length;n++){let o=s[n];switch(o.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"Lookbehind":case"NegativeLookbehind":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}let i=o;switch(i.type){case"Character":sn(i.value,e,r);break;case"Set":if(i.complement===!0)throw Error(Kc);T(i.value,l=>{if(typeof l=="number")sn(l,e,r);else{let u=l;if(r===!0)for(let d=u.from;d<=u.to;d++)sn(d,e,r);else{for(let d=u.from;d<=u.to&&d<Ar;d++)sn(d,e,r);if(u.to>=Ar){let d=u.from>=Ar?u.from:Ar,f=u.to,p=tt(d),m=tt(f);for(let R=p;R<=m;R++)e[R]=R}}}});break;case"Group":da(i.value,e,r);break;default:throw Error("Non Exhaustive Match")}let c=i.quantifier!==void 0&&i.quantifier.atLeast===0;if(i.type==="Group"&&pa(i)===!1||i.type!=="Group"&&c===!1)break}break;default:throw Error("non exhaustive match!")}return _(e)}a(da,"firstCharOptimizedIndices");function sn(t,e,r){let s=tt(t);e[s]=s,r===!0&&wT(t,e)}a(sn,"addOptimizedIdxToResult");function wT(t,e){let r=String.fromCharCode(t),s=r.toUpperCase();if(s!==r){let n=tt(s.charCodeAt(0));e[n]=n}else{let n=r.toLowerCase();if(n!==r){let o=tt(n.charCodeAt(0));e[o]=o}}}a(wT,"handleIgnoreCase");function jc(t,e){return et(t.value,r=>{if(typeof r=="number")return W(e,r);{let s=r;return et(e,n=>s.from<=n&&n<=s.to)!==void 0}})}a(jc,"findCode");function pa(t){let e=t.quantifier;return e&&e.atLeast===0?!0:t.value?A(t.value)?he(t.value,pa):pa(t.value):!1}a(pa,"isWholeOptional");var ha=class extends kt{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){W(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?jc(e,this.targetCharCodes)===void 0&&(this.found=!0):jc(e,this.targetCharCodes)!==void 0&&(this.found=!0)}};function nn(t,e){if(e instanceof RegExp){let r=Sr(e),s=new ha(t);return s.visit(r),s.found}else return et(e,r=>W(t,r.charCodeAt(0)))!==void 0}a(nn,"canMatchCharCode");var Gt="PATTERN",Rr="defaultMode",an="modes";function Vc(t,e){e=gr(e,{debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
`],tracer:a((E,h)=>h(),"tracer")});let r=e.tracer;r("initCharCodeToOptimizedIndexMap",()=>{QT()});let s;r("Reject Lexer.NA",()=>{s=It(t,E=>E[Gt]===K.NA)});let n=!1,o;r("Transform Patterns",()=>{n=!1,o=y(s,E=>{let h=E[Gt];if(De(h)){let x=h.source;return x.length===1&&x!=="^"&&x!=="$"&&x!=="."&&!h.ignoreCase?x:x.length===2&&x[0]==="\\"&&!W(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],x[1])?x[1]:Hc(h)}else{if(xe(h))return n=!0,{exec:h};if(typeof h=="object")return n=!0,h;if(typeof h=="string"){if(h.length===1)return h;{let x=h.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),M=new RegExp(x);return Hc(M)}}else throw Error("non exhaustive match")}})});let i,c,l,u,d;r("misc mapping",()=>{i=y(s,E=>E.tokenTypeIdx),c=y(s,E=>{let h=E.GROUP;if(h!==K.SKIPPED){if(ie(h))return h;if(ge(h))return!1;throw Error("non exhaustive match")}}),l=y(s,E=>{let h=E.LONGER_ALT;if(h)return A(h)?y(h,M=>Js(s,M)):[Js(s,h)]}),u=y(s,E=>E.PUSH_MODE),d=y(s,E=>S(E,"POP_MODE"))});let f;r("Line Terminator Handling",()=>{let E=tu(e.lineTerminatorCharacters);f=y(s,h=>!1),e.positionTracking!=="onlyOffset"&&(f=y(s,h=>S(h,"LINE_BREAKS")?!!h.LINE_BREAKS:eu(h,E)===!1&&nn(E,h.PATTERN)))});let p,m,R,b;r("Misc Mapping #2",()=>{p=y(s,Zc),m=y(o,JT),R=ne(s,(E,h)=>{let x=h.GROUP;return ie(x)&&x!==K.SKIPPED&&(E[x]=[]),E},{}),b=y(o,(E,h)=>({pattern:o[h],longerAlt:l[h],canLineTerminator:f[h],isCustom:p[h],short:m[h],group:c[h],push:u[h],pop:d[h],tokenTypeIdx:i[h],tokenType:s[h]}))});let O=!0,g=[];return e.safeMode||r("First Char Optimization",()=>{g=ne(s,(E,h,x)=>{if(typeof h.PATTERN=="string"){let M=h.PATTERN.charCodeAt(0),Be=tt(M);ma(E,Be,b[x])}else if(A(h.START_CHARS_HINT)){let M;T(h.START_CHARS_HINT,Be=>{let dt=typeof Be=="string"?Be.charCodeAt(0):Be,_t=tt(dt);M!==_t&&(M=_t,ma(E,_t,b[x]))})}else if(De(h.PATTERN))if(h.PATTERN.unicode)O=!1,e.ensureOptimizations&&Er(`${Jr}	Unable to analyze < ${h.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 M=zc(h.PATTERN,e.ensureOptimizations);L(M)&&(O=!1),T(M,Be=>{ma(E,Be,b[x])})}else e.ensureOptimizations&&Er(`${Jr}	TokenType: <${h.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:b,charCodeToPatternIdxToConfig:g,hasCustom:n,canBeOptimized:O}}a(Vc,"analyzeTokenTypes");function Yc(t,e){let r=[],s=UT(t);r=r.concat(s.errors);let n=DT(s.valid),o=n.valid;return r=r.concat(n.errors),r=r.concat(PT(o)),r=r.concat(zT(o)),r=r.concat(HT(o,e)),r=r.concat(VT(o)),r}a(Yc,"validatePatterns");function PT(t){let e=[],r=me(t,s=>De(s[Gt]));return e=e.concat(BT(r)),e=e.concat(WT(r)),e=e.concat(jT(r)),e=e.concat(KT(r)),e=e.concat($T(r)),e}a(PT,"validateRegExpPattern");function UT(t){let e=me(t,n=>!S(n,Gt)),r=y(e,n=>({message:"Token Type: ->"+n.name+"<- missing static 'PATTERN' property",type:j.MISSING_PATTERN,tokenTypes:[n]})),s=Lt(t,e);return{errors:r,valid:s}}a(UT,"findMissingPatterns");function DT(t){let e=me(t,n=>{let o=n[Gt];return!De(o)&&!xe(o)&&!S(o,"exec")&&!ie(o)}),r=y(e,n=>({message:"Token Type: ->"+n.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:j.INVALID_PATTERN,tokenTypes:[n]})),s=Lt(t,e);return{errors:r,valid:s}}a(DT,"findInvalidPatterns");var FT=/[^\\][$]/;function BT(t){class e extends kt{static{a(this,"EndAnchorFinder")}constructor(){super(...arguments),this.found=!1}visitEndAnchor(o){this.found=!0}}let r=me(t,n=>{let o=n.PATTERN;try{let i=Sr(o),c=new e;return c.visit(i),c.found}catch{return FT.test(o.source)}});return y(r,n=>({message:`Unexpected RegExp Anchor Error:
	Token Type: ->`+n.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
	See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS	for details.`,type:j.EOI_ANCHOR_FOUND,tokenTypes:[n]}))}a(BT,"findEndOfInputAnchor");function $T(t){let e=me(t,s=>s.PATTERN.test(""));return y(e,s=>({message:"Token Type: ->"+s.name+"<- static 'PATTERN' must not match an empty string",type:j.EMPTY_MATCH_PATTERN,tokenTypes:[s]}))}a($T,"findEmptyMatchRegExps");var GT=/[^\\[][\^]|^\^/;function WT(t){class e extends kt{static{a(this,"StartAnchorFinder")}constructor(){super(...arguments),this.found=!1}visitStartAnchor(o){this.found=!0}}let r=me(t,n=>{let o=n.PATTERN;try{let i=Sr(o),c=new e;return c.visit(i),c.found}catch{return GT.test(o.source)}});return y(r,n=>({message:`Unexpected RegExp Anchor Error:
	Token Type: ->`+n.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
	See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS	for details.`,type:j.SOI_ANCHOR_FOUND,tokenTypes:[n]}))}a(WT,"findStartOfInputAnchor");function jT(t){let e=me(t,s=>{let n=s[Gt];return n instanceof RegExp&&(n.multiline||n.global)});return y(e,s=>({message:"Token Type: ->"+s.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:j.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[s]}))}a(jT,"findUnsupportedFlags");function KT(t){let e=[],r=y(t,o=>ne(t,(i,c)=>(o.PATTERN.source===c.PATTERN.source&&!W(e,c)&&c.PATTERN!==K.NA&&(e.push(c),i.push(c)),i),[]));r=Qe(r);let s=me(r,o=>o.length>1);return y(s,o=>{let i=y(o,l=>l.name);return{message:`The same RegExp pattern ->${de(o).PATTERN}<-has been used in all of the following Token Types: ${i.join(", ")} <-`,type:j.DUPLICATE_PATTERNS_FOUND,tokenTypes:o}})}a(KT,"findDuplicatePatterns");function zT(t){let e=me(t,s=>{if(!S(s,"GROUP"))return!1;let n=s.GROUP;return n!==K.SKIPPED&&n!==K.NA&&!ie(n)});return y(e,s=>({message:"Token Type: ->"+s.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:j.INVALID_GROUP_TYPE_FOUND,tokenTypes:[s]}))}a(zT,"findInvalidGroupType");function HT(t,e){let r=me(t,n=>n.PUSH_MODE!==void 0&&!W(e,n.PUSH_MODE));return y(r,n=>({message:`Token Type: ->${n.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${n.PUSH_MODE}<-which does not exist`,type:j.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[n]}))}a(HT,"findModesThatDoNotExist");function VT(t){let e=[],r=ne(t,(s,n,o)=>{let i=n.PATTERN;return i===K.NA||(ie(i)?s.push({str:i,idx:o,tokenType:n}):De(i)&&XT(i)&&s.push({str:i.source,idx:o,tokenType:n})),s},[]);return T(t,(s,n)=>{T(r,({str:o,idx:i,tokenType:c})=>{if(n<i&&YT(o,s.PATTERN)){let l=`Token: ->${c.name}<- can never be matched.
Because it appears AFTER the Token Type ->${s.name}<-in the lexer's definition.
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;e.push({message:l,type:j.UNREACHABLE_PATTERN,tokenTypes:[s,c]})}})}),e}a(VT,"findUnreachablePatterns");function YT(t,e){if(De(e)){if(qT(e))return!1;let r=e.exec(t);return r!==null&&r.index===0}else{if(xe(e))return e(t,0,[],{});if(S(e,"exec"))return e.exec(t,0,[],{});if(typeof e=="string")return e===t;throw Error("non exhaustive match")}}a(YT,"tryToMatchStrToPattern");function XT(t){return et([".","\\","[","]","|","^","$","(",")","?","*","+","{"],r=>t.source.indexOf(r)!==-1)===void 0}a(XT,"noMetaChar");function qT(t){return/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(t.source)}a(qT,"usesLookAheadOrBehind");function Hc(t){let e=t.ignoreCase?"iy":"y";return new RegExp(`${t.source}`,e)}a(Hc,"addStickyFlag");function Xc(t,e,r){let s=[];return S(t,Rr)||s.push({message:"A MultiMode Lexer cannot be initialized without a <"+Rr+`> property in its definition
`,type:j.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),S(t,an)||s.push({message:"A MultiMode Lexer cannot be initialized without a <"+an+`> property in its definition
`,type:j.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),S(t,an)&&S(t,Rr)&&!S(t.modes,t.defaultMode)&&s.push({message:`A MultiMode Lexer cannot be initialized with a ${Rr}: <${t.defaultMode}>which does not exist
`,type:j.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),S(t,an)&&T(t.modes,(n,o)=>{T(n,(i,c)=>{if(ge(i))s.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${o}> at index: <${c}>
`,type:j.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED});else if(S(i,"LONGER_ALT")){let l=A(i.LONGER_ALT)?i.LONGER_ALT:[i.LONGER_ALT];T(l,u=>{!ge(u)&&!W(n,u)&&s.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${u.name}> on token <${i.name}> outside of mode <${o}>
`,type:j.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})}})}),s}a(Xc,"performRuntimeChecks");function qc(t,e,r){let s=[],n=!1,o=Qe(oe(_(t.modes))),i=It(o,l=>l[Gt]===K.NA),c=tu(r);return e&&T(i,l=>{let u=eu(l,c);if(u!==!1){let f={message:ZT(l,u),type:u.issue,tokenType:l};s.push(f)}else S(l,"LINE_BREAKS")?l.LINE_BREAKS===!0&&(n=!0):nn(c,l.PATTERN)&&(n=!0)}),e&&!n&&s.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:j.NO_LINE_BREAKS_FLAGS}),s}a(qc,"performWarningRuntimeChecks");function Jc(t){let e={},r=P(t);return T(r,s=>{let n=t[s];if(A(n))e[s]=[];else throw Error("non exhaustive match")}),e}a(Jc,"cloneEmptyGroups");function Zc(t){let e=t.PATTERN;if(De(e))return!1;if(xe(e))return!0;if(S(e,"exec"))return!0;if(ie(e))return!1;throw Error("non exhaustive match")}a(Zc,"isCustomPattern");function JT(t){return ie(t)&&t.length===1?t.charCodeAt(0):!1}a(JT,"isShortPattern");var Qc={test:a(function(t){let e=t.length;for(let r=this.lastIndex;r<e;r++){let s=t.charCodeAt(r);if(s===10)return this.lastIndex=r+1,!0;if(s===13)return t.charCodeAt(r+1)===10?this.lastIndex=r+2:this.lastIndex=r+1,!0}return!1},"test"),lastIndex:0};function eu(t,e){if(S(t,"LINE_BREAKS"))return!1;if(De(t.PATTERN)){try{nn(e,t.PATTERN)}catch(r){return{issue:j.IDENTIFY_TERMINATOR,errMsg:r.message}}return!1}else{if(ie(t.PATTERN))return!1;if(Zc(t))return{issue:j.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}}a(eu,"checkLineBreaksIssues");function ZT(t,e){if(e.issue===j.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
	The problem is in the <${t.name}> Token Type
	 Root cause: ${e.errMsg}.
	For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(e.issue===j.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
	The problem is in the <${t.name}> Token Type
	For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}a(ZT,"buildLineBreakIssueMessage");function tu(t){return y(t,r=>ie(r)?r.charCodeAt(0):r)}a(tu,"getCharCodes");function ma(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}a(ma,"addToMapOfArrays");var Ar=256,on=[];function tt(t){return t<Ar?t:on[t]}a(tt,"charCodeToOptimizedIndex");function QT(){if(L(on)){on=new Array(65536);for(let t=0;t<65536;t++)on[t]=t>255?255+~~(t/255):t}}a(QT,"initCharCodeToOptimizedIndexMap");function ut(t,e){let r=t.tokenTypeIdx;return r===e.tokenTypeIdx?!0:e.isParent===!0&&e.categoryMatchesMap[r]===!0}a(ut,"tokenStructuredMatcher");function br(t,e){return t.tokenTypeIdx===e.tokenTypeIdx}a(br,"tokenStructuredMatcherNoCategories");var ru=1,nu={};function ft(t){let e=ex(t);tx(e),sx(e),rx(e),T(e,r=>{r.isParent=r.categoryMatches.length>0})}a(ft,"augmentTokenTypes");function ex(t){let e=D(t),r=t,s=!0;for(;s;){r=Qe(oe(y(r,o=>o.CATEGORIES)));let n=Lt(r,e);e=e.concat(n),L(n)?s=!1:r=n}return e}a(ex,"expandCategories");function tx(t){T(t,e=>{ga(e)||(nu[ru]=e,e.tokenTypeIdx=ru++),su(e)&&!A(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),su(e)||(e.CATEGORIES=[]),nx(e)||(e.categoryMatches=[]),ax(e)||(e.categoryMatchesMap={})})}a(tx,"assignTokenDefaultProps");function rx(t){T(t,e=>{e.categoryMatches=[],T(e.categoryMatchesMap,(r,s)=>{e.categoryMatches.push(nu[s].tokenTypeIdx)})})}a(rx,"assignCategoriesTokensProp");function sx(t){T(t,e=>{au([],e)})}a(sx,"assignCategoriesMapProp");function au(t,e){T(t,r=>{e.categoryMatchesMap[r.tokenTypeIdx]=!0}),T(e.CATEGORIES,r=>{let s=t.concat(e);W(s,r)||au(s,r)})}a(au,"singleAssignCategoriesToksMap");function ga(t){return S(t,"tokenTypeIdx")}a(ga,"hasShortKeyProperty");function su(t){return S(t,"CATEGORIES")}a(su,"hasCategoriesProperty");function nx(t){return S(t,"categoryMatches")}a(nx,"hasExtendingTokensTypesProperty");function ax(t){return S(t,"categoryMatchesMap")}a(ax,"hasExtendingTokensTypesMapProperty");function ou(t){return S(t,"tokenTypeIdx")}a(ou,"isTokenType");var ya={buildUnableToPopLexerModeMessage(t){return`Unable to pop Lexer Mode after encountering Token ->${t.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(t,e,r,s,n,o){return`unexpected character: ->${t.charAt(e)}<- at offset: ${e}, skipped ${r} characters.`}};var j;(function(t){t[t.MISSING_PATTERN=0]="MISSING_PATTERN",t[t.INVALID_PATTERN=1]="INVALID_PATTERN",t[t.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",t[t.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",t[t.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",t[t.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",t[t.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",t[t.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",t[t.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",t[t.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",t[t.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",t[t.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",t[t.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",t[t.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",t[t.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",t[t.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",t[t.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",t[t.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"})(j||(j={}));var Zr={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:ya,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Zr);var K=class{static{a(this,"Lexer")}constructor(e,r=Zr){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(n,o)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let i=new Array(this.traceInitIndent+1).join("	");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${i}--> <${n}>`);let{time:c,value:l}=zr(o),u=c>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&u(`${i}<-- <${n}> time: ${c}ms`),this.traceInitIndent--,l}else return o()},typeof r=="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=pe({},Zr,r);let s=this.config.traceInitPerf;s===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof s=="number"&&(this.traceInitMaxIdent=s,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let n,o=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===Zr.lineTerminatorsPattern)this.config.lineTerminatorsPattern=Qc;else if(this.config.lineTerminatorCharacters===Zr.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(r.safeMode&&r.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),A(e)?n={modes:{defaultMode:D(e)},defaultMode:Rr}:(o=!1,n=D(e))}),this.config.skipValidations===!1&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Xc(n,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(qc(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),n.modes=n.modes?n.modes:{},T(n.modes,(c,l)=>{n.modes[l]=It(c,u=>ge(u))});let i=P(n.modes);if(T(n.modes,(c,l)=>{this.TRACE_INIT(`Mode: <${l}> processing`,()=>{if(this.modes.push(l),this.config.skipValidations===!1&&this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Yc(c,i))}),L(this.lexerDefinitionErrors)){ft(c);let u;this.TRACE_INIT("analyzeTokenTypes",()=>{u=Vc(c,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:r.positionTracking,ensureOptimizations:r.ensureOptimizations,safeMode:r.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[l]=u.patternIdxToConfig,this.charCodeToPatternIdxToConfig[l]=u.charCodeToPatternIdxToConfig,this.emptyGroups=pe({},this.emptyGroups,u.emptyGroups),this.hasCustom=u.hasCustom||this.hasCustom,this.canModeBeOptimized[l]=u.canBeOptimized}})}),this.defaultMode=n.defaultMode,!L(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){let l=y(this.lexerDefinitionErrors,u=>u.message).join(`-----------------------
`);throw new Error(`Errors detected in definition of Lexer:
`+l)}T(this.lexerDefinitionWarning,c=>{Kr(c.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(o&&(this.handleModes=Y),this.trackStartLines===!1&&(this.computeNewColumn=Ge),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=Y),/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 c=ne(this.canModeBeOptimized,(l,u,d)=>(u===!1&&l.push(d),l),[]);if(r.ensureOptimizations&&!L(c))throw Error(`Lexer Modes: < ${c.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",()=>{Wc()}),this.TRACE_INIT("toFastProperties",()=>{Hr(this)})})}tokenize(e,r=this.defaultMode){if(!L(this.lexerDefinitionErrors)){let n=y(this.lexerDefinitionErrors,o=>o.message).join(`-----------------------
`);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer:
`+n)}return this.tokenizeInternal(e,r)}tokenizeInternal(e,r){let s,n,o,i,c,l,u,d,f,p,m,R,b,O,g,E=e,h=E.length,x=0,M=0,Be=this.hasCustom?0:Math.floor(e.length/10),dt=new Array(Be),_t=[],wr=this.trackStartLines?1:void 0,ze=this.trackStartLines?1:void 0,Pr=Jc(this.emptyGroups),gf=this.trackStartLines,Yn=this.config.lineTerminatorsPattern,Ts=0,pt=[],Ur=[],Dr=[],bo=[];Object.freeze(bo);let Fr=!1,yf=a(Ne=>{if(Dr.length===1&&Ne.tokenType.PUSH_MODE===void 0){let we=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(Ne);_t.push({offset:Ne.startOffset,line:Ne.startLine,column:Ne.startColumn,length:Ne.image.length,message:we})}else{Dr.pop();let we=je(Dr);pt=this.patternIdxToConfig[we],Ur=this.charCodeToPatternIdxToConfig[we],Ts=pt.length;let Xn=this.canModeBeOptimized[we]&&this.config.safeMode===!1;Ur&&Xn?Fr=!0:Fr=!1}},"pop_mode");function No(Ne){Dr.push(Ne),Ur=this.charCodeToPatternIdxToConfig[Ne],pt=this.patternIdxToConfig[Ne],Ts=pt.length,Ts=pt.length;let we=this.canModeBeOptimized[Ne]&&this.config.safeMode===!1;Ur&&we?Fr=!0:Fr=!1}a(No,"push_mode"),No.call(this,r);let $e,Oo=this.config.recoveryEnabled;for(;x<h;){l=null,f=-1;let Ne=E.charCodeAt(x),we;if(Fr){let Ee=tt(Ne),Pe=Ur[Ee];we=Pe!==void 0?Pe:bo}else we=pt;let Xn=we.length;for(s=0;s<Xn;s++){$e=we[s];let Ee=$e.pattern;u=null;let Pe=$e.short;if(Pe!==!1?Ne===Pe&&(f=1,l=Ee):$e.isCustom===!0?(g=Ee.exec(E,x,dt,Pr),g!==null?(l=g[0],f=l.length,g.payload!==void 0&&(u=g.payload)):l=null):(Ee.lastIndex=x,f=this.matchLength(Ee,e,x)),f!==-1){if(c=$e.longerAlt,c!==void 0){l=e.substring(x,x+f);let ht=c.length;for(o=0;o<ht;o++){let nt=pt[c[o]],Mt=nt.pattern;if(d=null,nt.isCustom===!0?(g=Mt.exec(E,x,dt,Pr),g!==null?(i=g[0],g.payload!==void 0&&(d=g.payload)):i=null):(Mt.lastIndex=x,i=this.match(Mt,e,x)),i&&i.length>l.length){l=i,f=i.length,u=d,$e=nt;break}}}break}}if(f!==-1){if(p=$e.group,p!==void 0&&(l=l!==null?l:e.substring(x,x+f),m=$e.tokenTypeIdx,R=this.createTokenInstance(l,x,m,$e.tokenType,wr,ze,f),this.handlePayload(R,u),p===!1?M=this.addToken(dt,M,R):Pr[p].push(R)),gf===!0&&$e.canLineTerminator===!0){let Ee=0,Pe,ht;Yn.lastIndex=0;do l=l!==null?l:e.substring(x,x+f),Pe=Yn.test(l),Pe===!0&&(ht=Yn.lastIndex-1,Ee++);while(Pe===!0);Ee!==0?(wr=wr+Ee,ze=f-ht,this.updateTokenEndLineColumnLocation(R,p,ht,Ee,wr,ze,f)):ze=this.computeNewColumn(ze,f)}else ze=this.computeNewColumn(ze,f);x=x+f,this.handleModes($e,yf,No,R)}else{let Ee=x,Pe=wr,ht=ze,nt=Oo===!1;for(;nt===!1&&x<h;)for(x++,n=0;n<Ts;n++){let Mt=pt[n],qn=Mt.pattern,Co=Mt.short;if(Co!==!1?E.charCodeAt(x)===Co&&(nt=!0):Mt.isCustom===!0?nt=qn.exec(E,x,dt,Pr)!==null:(qn.lastIndex=x,nt=qn.exec(e)!==null),nt===!0)break}if(b=x-Ee,ze=this.computeNewColumn(ze,b),O=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(E,Ee,b,Pe,ht,je(Dr)),_t.push({offset:Ee,line:Pe,column:ht,length:b,message:O}),Oo===!1)break}}return this.hasCustom||(dt.length=M),{tokens:dt,groups:Pr,errors:_t}}handleModes(e,r,s,n){if(e.pop===!0){let o=e.push;r(n),o!==void 0&&s.call(this,o)}else e.push!==void 0&&s.call(this,e.push)}updateTokenEndLineColumnLocation(e,r,s,n,o,i,c){let l,u;r!==void 0&&(l=s===c-1,u=l?-1:0,n===1&&l===!0||(e.endLine=o+u,e.endColumn=i-1+-u))}computeNewColumn(e,r){return e+r}createOffsetOnlyToken(e,r,s,n){return{image:e,startOffset:r,tokenTypeIdx:s,tokenType:n}}createStartOnlyToken(e,r,s,n,o,i){return{image:e,startOffset:r,startLine:o,startColumn:i,tokenTypeIdx:s,tokenType:n}}createFullToken(e,r,s,n,o,i,c){return{image:e,startOffset:r,endOffset:r+c-1,startLine:o,endLine:o,startColumn:i,endColumn:i+c-1,tokenTypeIdx:s,tokenType:n}}addTokenUsingPush(e,r,s){return e.push(s),r}addTokenUsingMemberAccess(e,r,s){return e[r]=s,r++,r}handlePayloadNoCustom(e,r){}handlePayloadWithCustom(e,r){r!==null&&(e.payload=r)}match(e,r,s){return e.test(r)===!0?r.substring(s,e.lastIndex):null}matchLength(e,r,s){return e.test(r)===!0?e.lastIndex-s:-1}};K.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.";K.NA=/NOT_APPLICABLE/;function Wt(t){return Ea(t)?t.LABEL:t.name}a(Wt,"tokenLabel");function Ea(t){return ie(t.LABEL)&&t.LABEL!==""}a(Ea,"hasTokenLabel");var ox="parent",iu="categories",lu="label",cu="group",uu="push_mode",fu="pop_mode",du="longer_alt",pu="line_breaks",hu="start_chars_hint";function N(t){return ix(t)}a(N,"createToken");function ix(t){let e=t.pattern,r={};if(r.name=t.name,ge(e)||(r.PATTERN=e),S(t,ox))throw`The parent property is no longer supported.
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return S(t,iu)&&(r.CATEGORIES=t[iu]),ft([r]),S(t,lu)&&(r.LABEL=t[lu]),S(t,cu)&&(r.GROUP=t[cu]),S(t,fu)&&(r.POP_MODE=t[fu]),S(t,uu)&&(r.PUSH_MODE=t[uu]),S(t,du)&&(r.LONGER_ALT=t[du]),S(t,pu)&&(r.LINE_BREAKS=t[pu]),S(t,hu)&&(r.START_CHARS_HINT=t[hu]),r}a(ix,"createTokenInternal");var ke=N({name:"EOF",pattern:K.NA});ft([ke]);function jt(t,e,r,s,n,o,i,c){return{image:e,startOffset:r,endOffset:s,startLine:n,endLine:o,startColumn:i,endColumn:c,tokenTypeIdx:t.tokenTypeIdx,tokenType:t}}a(jt,"createTokenInstance");function Qr(t,e){return ut(t,e)}a(Qr,"tokenMatcher");var ln={buildMismatchTokenMessage({expected:t,actual:e,previous:r,ruleName:s}){return`Expecting ${Ea(t)?`--> ${Wt(t)} <--`:`token of type --> ${t.name} <--`} but found --> '${e.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:t,ruleName:e}){return"Redundant input, expecting EOF but found: "+t.image},buildNoViableAltMessage({expectedPathsPerAlt:t,actual:e,previous:r,customUserDescription:s,ruleName:n}){let o="Expecting: ",c=`
but found: '`+de(e).image+"'";if(s)return o+s+c;{let l=ne(t,(p,m)=>p.concat(m),[]),u=y(l,p=>`[${y(p,m=>Wt(m)).join(", ")}]`),f=`one of these possible Token sequences:
${y(u,(p,m)=>`  ${m+1}. ${p}`).join(`
`)}`;return o+f+c}},buildEarlyExitMessage({expectedIterationPaths:t,actual:e,customUserDescription:r,ruleName:s}){let n="Expecting: ",i=`
but found: '`+de(e).image+"'";if(r)return n+r+i;{let l=`expecting at least one iteration which starts with one of these possible Token sequences::
  <${y(t,u=>`[${y(u,d=>Wt(d)).join(",")}]`).join(" ,")}>`;return n+l+i}}};Object.freeze(ln);var mu={buildRuleNotFoundError(t,e){return"Invalid grammar, reference to a rule which is not defined: ->"+e.nonTerminalName+`<-
inside top level rule: ->`+t.name+"<-"}},Ke={buildDuplicateFoundError(t,e){function r(d){return d instanceof I?d.terminalType.name:d instanceof F?d.nonTerminalName:""}a(r,"getExtraProductionArgument");let s=t.name,n=de(e),o=n.idx,i=Ie(n),c=r(n),l=o>0,u=`->${i}${l?o:""}<- ${c?`with argument: ->${c}<-`:""}
                  appears more than once (${e.length} times) in the top level rule: ->${s}<-.                  
                  For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES 
                  `;return u=u.replace(/[ \t]+/g," "),u=u.replace(/\s\s+/g,`
`),u},buildNamespaceConflictError(t){return`Namespace conflict found in grammar.
The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${t.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(t){let e=y(t.prefixPath,n=>Wt(n)).join(", "),r=t.alternation.idx===0?"":t.alternation.idx;return`Ambiguous alternatives: <${t.ambiguityIndices.join(" ,")}> due to common lookahead prefix
in <OR${r}> inside <${t.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(t){let e=t.alternation.idx===0?"":t.alternation.idx,r=t.prefixPath.length===0,s=`Ambiguous Alternatives Detected: <${t.ambiguityIndices.join(" ,")}> in <OR${e}> inside <${t.topLevelRule.name}> Rule,
`;if(r)s+=`These alternatives are all empty (match no tokens), making them indistinguishable.
Only the last alternative may be empty.
`;else{let n=y(t.prefixPath,o=>Wt(o)).join(", ");s+=`<${n}> may appears as a prefix path in all these alternatives.
`}return s+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
For Further details.`,s},buildEmptyRepetitionError(t){let e=Ie(t.repetition);return t.repetition.idx!==0&&(e+=t.repetition.idx),`The repetition <${e}> within Rule <${t.topLevelRule.name}> can never consume any tokens.
This could lead to an infinite loop.`},buildTokenNameError(t){return"deprecated"},buildEmptyAlternationError(t){return`Ambiguous empty alternative: <${t.emptyChoiceIdx+1}> in <OR${t.alternation.idx}> inside <${t.topLevelRule.name}> Rule.
Only the last alternative may be an empty alternative.`},buildTooManyAlternativesError(t){return`An Alternation cannot have more than 256 alternatives:
<OR${t.alternation.idx}> inside <${t.topLevelRule.name}> Rule.
 has ${t.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(t){let e=t.topLevelRule.name,r=y(t.leftRecursionPath,o=>o.name),s=`${e} --> ${r.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: 
 ${s}
 To fix this refactor your grammar to remove the left recursion.
see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(t){return"deprecated"},buildDuplicateRuleNameError(t){let e;return t.topLevelRule instanceof Ae?e=t.topLevelRule.name:e=t.topLevelRule,`Duplicate definition, rule: ->${e}<- is already defined in the grammar: ->${t.grammarName}<-`}};function gu(t,e){let r=new Ta(t,e);return r.resolveRefs(),r.errors}a(gu,"resolveGrammar");var Ta=class extends Re{static{a(this,"GastRefResolverVisitor")}constructor(e,r){super(),this.nameToTopRule=e,this.errMsgProvider=r,this.errors=[]}resolveRefs(){T(_(this.nameToTopRule),e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let r=this.nameToTopRule[e.nonTerminalName];if(r)e.referencedRule=r;else{let s=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:s,type:le.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}};var xa=class extends ct{static{a(this,"AbstractNextPossibleTokensWalker")}constructor(e,r){super(),this.topProd=e,this.path=r,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=D(this.path.ruleStack).reverse(),this.occurrenceStack=D(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,r=[]){this.found||super.walk(e,r)}walkProdRef(e,r,s){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let n=r.concat(s);this.updateExpectedNext(),this.walk(e.referencedRule,n)}}updateExpectedNext(){L(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},cn=class extends xa{static{a(this,"NextAfterTokenWalker")}constructor(e,r){super(e,r),this.path=r,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,r,s){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){let n=r.concat(s),o=new B({definition:n});this.possibleTokTypes=Bt(o),this.found=!0}}},Nr=class extends ct{static{a(this,"AbstractNextTerminalAfterProductionWalker")}constructor(e,r){super(),this.topRule=e,this.occurrence=r,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}},un=class extends Nr{static{a(this,"NextTerminalAfterManyWalker")}walkMany(e,r,s){if(e.idx===this.occurrence){let n=de(r.concat(s));this.result.isEndOfRule=n===void 0,n instanceof I&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkMany(e,r,s)}},es=class extends Nr{static{a(this,"NextTerminalAfterManySepWalker")}walkManySep(e,r,s){if(e.idx===this.occurrence){let n=de(r.concat(s));this.result.isEndOfRule=n===void 0,n instanceof I&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkManySep(e,r,s)}},fn=class extends Nr{static{a(this,"NextTerminalAfterAtLeastOneWalker")}walkAtLeastOne(e,r,s){if(e.idx===this.occurrence){let n=de(r.concat(s));this.result.isEndOfRule=n===void 0,n instanceof I&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkAtLeastOne(e,r,s)}},ts=class extends Nr{static{a(this,"NextTerminalAfterAtLeastOneSepWalker")}walkAtLeastOneSep(e,r,s){if(e.idx===this.occurrence){let n=de(r.concat(s));this.result.isEndOfRule=n===void 0,n instanceof I&&(this.result.token=n.terminalType,this.result.occurrence=n.idx)}else super.walkAtLeastOneSep(e,r,s)}};function dn(t,e,r=[]){r=D(r);let s=[],n=0;function o(c){return c.concat(Z(t,n+1))}a(o,"remainingPathWith");function i(c){let l=dn(o(c),e,r);return s.concat(l)}for(a(i,"getAlternativesForProd");r.length<e&&n<t.length;){let c=t[n];if(c instanceof B)return i(c.definition);if(c instanceof F)return i(c.definition);if(c instanceof G)s=i(c.definition);else if(c instanceof Q){let l=c.definition.concat([new v({definition:c.definition})]);return i(l)}else if(c instanceof ee){let l=[new B({definition:c.definition}),new v({definition:[new I({terminalType:c.separator})].concat(c.definition)})];return i(l)}else if(c instanceof X){let l=c.definition.concat([new v({definition:[new I({terminalType:c.separator})].concat(c.definition)})]);s=i(l)}else if(c instanceof v){let l=c.definition.concat([new v({definition:c.definition})]);s=i(l)}else{if(c instanceof q)return T(c.definition,l=>{L(l.definition)===!1&&(s=i(l.definition))}),s;if(c instanceof I)r.push(c.terminalType);else throw Error("non exhaustive match")}n++}return s.push({partialPath:r,suffixDef:Z(t,n)}),s}a(dn,"possiblePathsFrom");function pn(t,e,r,s){let n="EXIT_NONE_TERMINAL",o=[n],i="EXIT_ALTERNATIVE",c=!1,l=e.length,u=l-s-1,d=[],f=[];for(f.push({idx:-1,def:t,ruleStack:[],occurrenceStack:[]});!L(f);){let p=f.pop();if(p===i){c&&je(f).idx<=u&&f.pop();continue}let m=p.def,R=p.idx,b=p.ruleStack,O=p.occurrenceStack;if(L(m))continue;let g=m[0];if(g===n){let E={idx:R,def:Z(m),ruleStack:lt(b),occurrenceStack:lt(O)};f.push(E)}else if(g instanceof I)if(R<l-1){let E=R+1,h=e[E];if(r(h,g.terminalType)){let x={idx:E,def:Z(m),ruleStack:b,occurrenceStack:O};f.push(x)}}else if(R===l-1)d.push({nextTokenType:g.terminalType,nextTokenOccurrence:g.idx,ruleStack:b,occurrenceStack:O}),c=!0;else throw Error("non exhaustive match");else if(g instanceof F){let E=D(b);E.push(g.nonTerminalName);let h=D(O);h.push(g.idx);let x={idx:R,def:g.definition.concat(o,Z(m)),ruleStack:E,occurrenceStack:h};f.push(x)}else if(g instanceof G){let E={idx:R,def:Z(m),ruleStack:b,occurrenceStack:O};f.push(E),f.push(i);let h={idx:R,def:g.definition.concat(Z(m)),ruleStack:b,occurrenceStack:O};f.push(h)}else if(g instanceof Q){let E=new v({definition:g.definition,idx:g.idx}),h=g.definition.concat([E],Z(m)),x={idx:R,def:h,ruleStack:b,occurrenceStack:O};f.push(x)}else if(g instanceof ee){let E=new I({terminalType:g.separator}),h=new v({definition:[E].concat(g.definition),idx:g.idx}),x=g.definition.concat([h],Z(m)),M={idx:R,def:x,ruleStack:b,occurrenceStack:O};f.push(M)}else if(g instanceof X){let E={idx:R,def:Z(m),ruleStack:b,occurrenceStack:O};f.push(E),f.push(i);let h=new I({terminalType:g.separator}),x=new v({definition:[h].concat(g.definition),idx:g.idx}),M=g.definition.concat([x],Z(m)),Be={idx:R,def:M,ruleStack:b,occurrenceStack:O};f.push(Be)}else if(g instanceof v){let E={idx:R,def:Z(m),ruleStack:b,occurrenceStack:O};f.push(E),f.push(i);let h=new v({definition:g.definition,idx:g.idx}),x=g.definition.concat([h],Z(m)),M={idx:R,def:x,ruleStack:b,occurrenceStack:O};f.push(M)}else if(g instanceof q)for(let E=g.definition.length-1;E>=0;E--){let h=g.definition[E],x={idx:R,def:h.definition.concat(Z(m)),ruleStack:b,occurrenceStack:O};f.push(x),f.push(i)}else if(g instanceof B)f.push({idx:R,def:g.definition.concat(Z(m)),ruleStack:b,occurrenceStack:O});else if(g instanceof Ae)f.push(lx(g,R,b,O));else throw Error("non exhaustive match")}return d}a(pn,"nextPossibleTokensAfter");function lx(t,e,r,s){let n=D(r);n.push(t.name);let o=D(s);return o.push(1),{idx:e,def:t.definition,ruleStack:n,occurrenceStack:o}}a(lx,"expandTopLevelRule");var H;(function(t){t[t.OPTION=0]="OPTION",t[t.REPETITION=1]="REPETITION",t[t.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",t[t.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",t[t.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",t[t.ALTERNATION=5]="ALTERNATION"})(H||(H={}));function mn(t){if(t instanceof G||t==="Option")return H.OPTION;if(t instanceof v||t==="Repetition")return H.REPETITION;if(t instanceof Q||t==="RepetitionMandatory")return H.REPETITION_MANDATORY;if(t instanceof ee||t==="RepetitionMandatoryWithSeparator")return H.REPETITION_MANDATORY_WITH_SEPARATOR;if(t instanceof X||t==="RepetitionWithSeparator")return H.REPETITION_WITH_SEPARATOR;if(t instanceof q||t==="Alternation")return H.ALTERNATION;throw Error("non exhaustive match")}a(mn,"getProdType");function Eu(t,e,r,s,n,o){let i=rs(t,e,r),c=bu(i)?br:ut;return o(i,s,c,n)}a(Eu,"buildLookaheadFuncForOr");function Tu(t,e,r,s,n,o){let i=ss(t,e,n,r),c=bu(i)?br:ut;return o(i[0],c,s)}a(Tu,"buildLookaheadFuncForOptionalProd");function xu(t,e,r,s){let n=t.length,o=he(t,i=>he(i,c=>c.length===1));if(e)return function(i){let c=y(i,l=>l.GATE);for(let l=0;l<n;l++){let u=t[l],d=u.length,f=c[l];if(!(f!==void 0&&f.call(this)===!1))e:for(let p=0;p<d;p++){let m=u[p],R=m.length;for(let b=0;b<R;b++){let O=this.LA(b+1);if(r(O,m[b])===!1)continue e}return l}}};if(o&&!s){let i=y(t,l=>oe(l)),c=ne(i,(l,u,d)=>(T(u,f=>{S(l,f.tokenTypeIdx)||(l[f.tokenTypeIdx]=d),T(f.categoryMatches,p=>{S(l,p)||(l[p]=d)})}),l),{});return function(){let l=this.LA(1);return c[l.tokenTypeIdx]}}else return function(){for(let i=0;i<n;i++){let c=t[i],l=c.length;e:for(let u=0;u<l;u++){let d=c[u],f=d.length;for(let p=0;p<f;p++){let m=this.LA(p+1);if(r(m,d[p])===!1)continue e}return i}}}}a(xu,"buildAlternativesLookAheadFunc");function Su(t,e,r){let s=he(t,o=>o.length===1),n=t.length;if(s&&!r){let o=oe(t);if(o.length===1&&L(o[0].categoryMatches)){let c=o[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===c}}else{let i=ne(o,(c,l,u)=>(c[l.tokenTypeIdx]=!0,T(l.categoryMatches,d=>{c[d]=!0}),c),[]);return function(){let c=this.LA(1);return i[c.tokenTypeIdx]===!0}}}else return function(){e:for(let o=0;o<n;o++){let i=t[o],c=i.length;for(let l=0;l<c;l++){let u=this.LA(l+1);if(e(u,i[l])===!1)continue e}return!0}return!1}}a(Su,"buildSingleAlternativeLookaheadFunction");var Aa=class extends ct{static{a(this,"RestDefinitionFinderWalker")}constructor(e,r,s){super(),this.topProd=e,this.targetOccurrence=r,this.targetProdType=s}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,r,s,n){return e.idx===this.targetOccurrence&&this.targetProdType===r?(this.restDef=s.concat(n),!0):!1}walkOption(e,r,s){this.checkIsTarget(e,H.OPTION,r,s)||super.walkOption(e,r,s)}walkAtLeastOne(e,r,s){this.checkIsTarget(e,H.REPETITION_MANDATORY,r,s)||super.walkOption(e,r,s)}walkAtLeastOneSep(e,r,s){this.checkIsTarget(e,H.REPETITION_MANDATORY_WITH_SEPARATOR,r,s)||super.walkOption(e,r,s)}walkMany(e,r,s){this.checkIsTarget(e,H.REPETITION,r,s)||super.walkOption(e,r,s)}walkManySep(e,r,s){this.checkIsTarget(e,H.REPETITION_WITH_SEPARATOR,r,s)||super.walkOption(e,r,s)}},hn=class extends Re{static{a(this,"InsideDefinitionFinderVisitor")}constructor(e,r,s){super(),this.targetOccurrence=e,this.targetProdType=r,this.targetRef=s,this.result=[]}checkIsTarget(e,r){e.idx===this.targetOccurrence&&this.targetProdType===r&&(this.targetRef===void 0||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,H.OPTION)}visitRepetition(e){this.checkIsTarget(e,H.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,H.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,H.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,H.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,H.ALTERNATION)}};function yu(t){let e=new Array(t);for(let r=0;r<t;r++)e[r]=[];return e}a(yu,"initializeArrayOfArrays");function Sa(t){let e=[""];for(let r=0;r<t.length;r++){let s=t[r],n=[];for(let o=0;o<e.length;o++){let i=e[o];n.push(i+"_"+s.tokenTypeIdx);for(let c=0;c<s.categoryMatches.length;c++){let l="_"+s.categoryMatches[c];n.push(i+l)}}e=n}return e}a(Sa,"pathToHashKeys");function cx(t,e,r){for(let s=0;s<t.length;s++){if(s===r)continue;let n=t[s];for(let o=0;o<e.length;o++){let i=e[o];if(n[i]===!0)return!1}}return!0}a(cx,"isUniquePrefixHash");function Au(t,e){let r=y(t,i=>dn([i],1)),s=yu(r.length),n=y(r,i=>{let c={};return T(i,l=>{let u=Sa(l.partialPath);T(u,d=>{c[d]=!0})}),c}),o=r;for(let i=1;i<=e;i++){let c=o;o=yu(c.length);for(let l=0;l<c.length;l++){let u=c[l];for(let d=0;d<u.length;d++){let f=u[d].partialPath,p=u[d].suffixDef,m=Sa(f);if(cx(n,m,l)||L(p)||f.length===e){let b=s[l];if(gn(b,f)===!1){b.push(f);for(let O=0;O<m.length;O++){let g=m[O];n[l][g]=!0}}}else{let b=dn(p,i+1,f);o[l]=o[l].concat(b),T(b,O=>{let g=Sa(O.partialPath);T(g,E=>{n[l][E]=!0})})}}}}return s}a(Au,"lookAheadSequenceFromAlternatives");function rs(t,e,r,s){let n=new hn(t,H.ALTERNATION,s);return e.accept(n),Au(n.result,r)}a(rs,"getLookaheadPathsForOr");function ss(t,e,r,s){let n=new hn(t,r);e.accept(n);let o=n.result,c=new Aa(e,t,r).startWalking(),l=new B({definition:o}),u=new B({definition:c});return Au([l,u],s)}a(ss,"getLookaheadPathsForOptionalProd");function gn(t,e){e:for(let r=0;r<t.length;r++){let s=t[r];if(s.length===e.length){for(let n=0;n<s.length;n++){let o=e[n],i=s[n];if((o===i||i.categoryMatchesMap[o.tokenTypeIdx]!==void 0)===!1)continue e}return!0}}return!1}a(gn,"containsPath");function Ru(t,e){return t.length<e.length&&he(t,(r,s)=>{let n=e[s];return r===n||n.categoryMatchesMap[r.tokenTypeIdx]})}a(Ru,"isStrictPrefixOfPath");function bu(t){return he(t,e=>he(e,r=>he(r,s=>L(s.categoryMatches))))}a(bu,"areTokenCategoriesNotUsed");function Nu(t){let e=t.lookaheadStrategy.validate({rules:t.rules,tokenTypes:t.tokenTypes,grammarName:t.grammarName});return y(e,r=>Object.assign({type:le.CUSTOM_LOOKAHEAD_VALIDATION},r))}a(Nu,"validateLookahead");function Ou(t,e,r,s){let n=Se(t,l=>ux(l,r)),o=gx(t,e,r),i=Se(t,l=>px(l,r)),c=Se(t,l=>dx(l,t,s,r));return n.concat(o,i,c)}a(Ou,"validateGrammar");function ux(t,e){let r=new Ra;t.accept(r);let s=r.allProductions,n=oa(s,fx),o=Le(n,c=>c.length>1);return y(_(o),c=>{let l=de(c),u=e.buildDuplicateFoundError(t,c),d=Ie(l),f={message:u,type:le.DUPLICATE_PRODUCTIONS,ruleName:t.name,dslName:d,occurrence:l.idx},p=Cu(l);return p&&(f.parameter=p),f})}a(ux,"validateDuplicateProductions");function fx(t){return`${Ie(t)}_#_${t.idx}_#_${Cu(t)}`}a(fx,"identifyProductionForDuplicates");function Cu(t){return t instanceof I?t.terminalType.name:t instanceof F?t.nonTerminalName:""}a(Cu,"getExtraProductionArgument");var Ra=class extends Re{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 dx(t,e,r,s){let n=[];if(ne(e,(i,c)=>c.name===t.name?i+1:i,0)>1){let i=s.buildDuplicateRuleNameError({topLevelRule:t,grammarName:r});n.push({message:i,type:le.DUPLICATE_RULE_NAME,ruleName:t.name})}return n}a(dx,"validateRuleDoesNotAlreadyExist");function Lu(t,e,r){let s=[],n;return W(e,t)||(n=`Invalid rule override, rule: ->${t}<- cannot be overridden in the grammar: ->${r}<-as it is not defined in any of the super grammars `,s.push({message:n,type:le.INVALID_RULE_OVERRIDE,ruleName:t})),s}a(Lu,"validateRuleIsOverridden");function Na(t,e,r,s=[]){let n=[],o=yn(e.definition);if(L(o))return[];{let i=t.name;W(o,t)&&n.push({message:r.buildLeftRecursionError({topLevelRule:t,leftRecursionPath:s}),type:le.LEFT_RECURSION,ruleName:i});let l=Lt(o,s.concat([t])),u=Se(l,d=>{let f=D(s);return f.push(d),Na(t,d,r,f)});return n.concat(u)}}a(Na,"validateNoLeftRecursion");function yn(t){let e=[];if(L(t))return e;let r=de(t);if(r instanceof F)e.push(r.referencedRule);else if(r instanceof B||r instanceof G||r instanceof Q||r instanceof ee||r instanceof X||r instanceof v)e=e.concat(yn(r.definition));else if(r instanceof q)e=oe(y(r.definition,o=>yn(o.definition)));else if(!(r instanceof I))throw Error("non exhaustive match");let s=Ft(r),n=t.length>1;if(s&&n){let o=Z(t);return e.concat(yn(o))}else return e}a(yn,"getFirstNoneTerminal");var ns=class extends Re{static{a(this,"OrCollector")}constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}};function Iu(t,e){let r=new ns;t.accept(r);let s=r.alternations;return Se(s,o=>{let i=lt(o.definition);return Se(i,(c,l)=>{let u=pn([c],[],ut,1);return L(u)?[{message:e.buildEmptyAlternationError({topLevelRule:t,alternation:o,emptyChoiceIdx:l}),type:le.NONE_LAST_EMPTY_ALT,ruleName:t.name,occurrence:o.idx,alternative:l+1}]:[]})})}a(Iu,"validateEmptyOrAlternative");function ku(t,e,r){let s=new ns;t.accept(s);let n=s.alternations;return n=It(n,i=>i.ignoreAmbiguities===!0),Se(n,i=>{let c=i.idx,l=i.maxLookahead||e,u=rs(c,t,l,i),d=hx(u,i,t,r),f=mx(u,i,t,r);return d.concat(f)})}a(ku,"validateAmbiguousAlternationAlternatives");var ba=class extends Re{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 px(t,e){let r=new ns;t.accept(r);let s=r.alternations;return Se(s,o=>o.definition.length>255?[{message:e.buildTooManyAlternativesError({topLevelRule:t,alternation:o}),type:le.TOO_MANY_ALTS,ruleName:t.name,occurrence:o.idx}]:[])}a(px,"validateTooManyAlts");function vu(t,e,r){let s=[];return T(t,n=>{let o=new ba;n.accept(o);let i=o.allProductions;T(i,c=>{let l=mn(c),u=c.maxLookahead||e,d=c.idx,p=ss(d,n,l,u)[0];if(L(oe(p))){let m=r.buildEmptyRepetitionError({topLevelRule:n,repetition:c});s.push({message:m,type:le.NO_NON_EMPTY_LOOKAHEAD,ruleName:n.name})}})}),s}a(vu,"validateSomeNonEmptyLookaheadPath");function hx(t,e,r,s){let n=[],o=ne(t,(c,l,u)=>(e.definition[u].ignoreAmbiguities===!0||T(l,d=>{let f=[u];T(t,(p,m)=>{u!==m&&gn(p,d)&&e.definition[m].ignoreAmbiguities!==!0&&f.push(m)}),f.length>1&&!gn(n,d)&&(n.push(d),c.push({alts:f,path:d}))}),c),[]);return y(o,c=>{let l=y(c.alts,d=>d+1);return{message:s.buildAlternationAmbiguityError({topLevelRule:r,alternation:e,ambiguityIndices:l,prefixPath:c.path}),type:le.AMBIGUOUS_ALTS,ruleName:r.name,occurrence:e.idx,alternatives:c.alts}})}a(hx,"checkAlternativesAmbiguities");function mx(t,e,r,s){let n=ne(t,(i,c,l)=>{let u=y(c,d=>({idx:l,path:d}));return i.concat(u)},[]);return Qe(Se(n,i=>{if(e.definition[i.idx].ignoreAmbiguities===!0)return[];let l=i.idx,u=i.path,d=me(n,p=>e.definition[p.idx].ignoreAmbiguities!==!0&&p.idx<l&&Ru(p.path,u));return y(d,p=>{let m=[p.idx+1,l+1],R=e.idx===0?"":e.idx;return{message:s.buildAlternationPrefixAmbiguityError({topLevelRule:r,alternation:e,ambiguityIndices:m,prefixPath:p.path}),type:le.AMBIGUOUS_PREFIX_ALTS,ruleName:r.name,occurrence:R,alternatives:m}})}))}a(mx,"checkPrefixAlternativesAmbiguities");function gx(t,e,r){let s=[],n=y(e,o=>o.name);return T(t,o=>{let i=o.name;if(W(n,i)){let c=r.buildNamespaceConflictError(o);s.push({message:c,type:le.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:i})}}),s}a(gx,"checkTerminalAndNoneTerminalsNameSpace");function _u(t){let e=gr(t,{errMsgProvider:mu}),r={};return T(t.rules,s=>{r[s.name]=s}),gu(r,e.errMsgProvider)}a(_u,"resolveGrammar");function Mu(t){return t=gr(t,{errMsgProvider:Ke}),Ou(t.rules,t.tokenTypes,t.errMsgProvider,t.grammarName)}a(Mu,"validateGrammar");var wu="MismatchedTokenException",Pu="NoViableAltException",Uu="EarlyExitException",Du="NotAllInputParsedException",Fu=[wu,Pu,Uu,Du];Object.freeze(Fu);function vt(t){return W(Fu,t.name)}a(vt,"isRecognitionException");var Or=class extends Error{static{a(this,"RecognitionException")}constructor(e,r){super(e),this.token=r,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},Kt=class extends Or{static{a(this,"MismatchedTokenException")}constructor(e,r,s){super(e,r),this.previousToken=s,this.name=wu}},as=class extends Or{static{a(this,"NoViableAltException")}constructor(e,r,s){super(e,r),this.previousToken=s,this.name=Pu}},os=class extends Or{static{a(this,"NotAllInputParsedException")}constructor(e,r){super(e,r),this.name=Du}},is=class extends Or{static{a(this,"EarlyExitException")}constructor(e,r,s){super(e,r),this.previousToken=s,this.name=Uu}};var Oa={},La="InRuleRecoveryException",Ca=class extends Error{static{a(this,"InRuleRecoveryException")}constructor(e){super(e),this.name=La}},En=class{static{a(this,"Recoverable")}initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=S(e,"recoveryEnabled")?e.recoveryEnabled:be.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=yx)}getTokenToInsert(e){let r=jt(e,"",NaN,NaN,NaN,NaN,NaN,NaN);return r.isInsertedInRecovery=!0,r}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,r,s,n){let o=this.findReSyncTokenType(),i=this.exportLexerState(),c=[],l=!1,u=this.LA(1),d=this.LA(1),f=a(()=>{let p=this.LA(0),m=this.errorMessageProvider.buildMismatchTokenMessage({expected:n,actual:u,previous:p,ruleName:this.getCurrRuleFullName()}),R=new Kt(m,u,this.LA(0));R.resyncedTokens=lt(c),this.SAVE_ERROR(R)},"generateErrorMessage");for(;!l;)if(this.tokenMatcher(d,n)){f();return}else if(s.call(this)){f(),e.apply(this,r);return}else this.tokenMatcher(d,o)?l=!0:(d=this.SKIP_TOKEN(),this.addToResyncTokens(d,c));this.importLexerState(i)}shouldInRepetitionRecoveryBeTried(e,r,s){return!(s===!1||this.tokenMatcher(this.LA(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,r)))}getFollowsForInRuleRecovery(e,r){let s=this.getCurrentGrammarPath(e,r);return this.getNextPossibleTokenTypes(s)}tryInRuleRecovery(e,r){if(this.canRecoverWithSingleTokenInsertion(e,r))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let s=this.SKIP_TOKEN();return this.consumeToken(),s}throw new Ca("sad sad panda")}canPerformInRuleRecovery(e,r){return this.canRecoverWithSingleTokenInsertion(e,r)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,r){if(!this.canTokenTypeBeInsertedInRecovery(e)||L(r))return!1;let s=this.LA(1);return et(r,o=>this.tokenMatcher(s,o))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){let r=this.getCurrFollowKey(),s=this.getFollowSetFromFollowKey(r);return W(s,e)}findReSyncTokenType(){let e=this.flattenFollowSet(),r=this.LA(1),s=2;for(;;){let n=et(e,o=>Qr(r,o));if(n!==void 0)return n;r=this.LA(s),s++}}getCurrFollowKey(){if(this.RULE_STACK.length===1)return Oa;let e=this.getLastExplicitRuleShortName(),r=this.getLastExplicitRuleOccurrenceIndex(),s=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:r,inRule:this.shortRuleNameToFullName(s)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,r=this.RULE_OCCURRENCE_STACK;return y(e,(s,n)=>n===0?Oa:{ruleName:this.shortRuleNameToFullName(s),idxInCallingRule:r[n],inRule:this.shortRuleNameToFullName(e[n-1])})}flattenFollowSet(){let e=y(this.buildFullFollowKeyStack(),r=>this.getFollowSetFromFollowKey(r));return oe(e)}getFollowSetFromFollowKey(e){if(e===Oa)return[ke];let r=e.ruleName+e.idxInCallingRule+Qs+e.inRule;return this.resyncFollows[r]}addToResyncTokens(e,r){return this.tokenMatcher(e,ke)||r.push(e),r}reSyncTo(e){let r=[],s=this.LA(1);for(;this.tokenMatcher(s,e)===!1;)s=this.SKIP_TOKEN(),this.addToResyncTokens(s,r);return lt(r)}attemptInRepetitionRecovery(e,r,s,n,o,i,c){}getCurrentGrammarPath(e,r){let s=this.getHumanReadableRuleStack(),n=D(this.RULE_OCCURRENCE_STACK);return{ruleStack:s,occurrenceStack:n,lastTok:e,lastTokOccurrence:r}}getHumanReadableRuleStack(){return y(this.RULE_STACK,e=>this.shortRuleNameToFullName(e))}};function yx(t,e,r,s,n,o,i){let c=this.getKeyForAutomaticLookahead(s,n),l=this.firstAfterRepMap[c];if(l===void 0){let p=this.getCurrRuleFullName(),m=this.getGAstProductions()[p];l=new o(m,n).startWalking(),this.firstAfterRepMap[c]=l}let u=l.token,d=l.occurrence,f=l.isEndOfRule;this.RULE_STACK.length===1&&f&&u===void 0&&(u=ke,d=1),!(u===void 0||d===void 0)&&this.shouldInRepetitionRecoveryBeTried(u,d,i)&&this.tryInRepetitionRecovery(t,e,r,u)}a(yx,"attemptInRepetitionRecovery");function Tn(t,e,r){return r|e|t}a(Tn,"getKeyForAutomaticLookahead");var ls=class{static{a(this,"LLkLookaheadStrategy")}constructor(e){var r;this.maxLookahead=(r=e?.maxLookahead)!==null&&r!==void 0?r:be.maxLookahead}validate(e){let r=this.validateNoLeftRecursion(e.rules);if(L(r)){let s=this.validateEmptyOrAlternatives(e.rules),n=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),o=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...r,...s,...n,...o]}return r}validateNoLeftRecursion(e){return Se(e,r=>Na(r,r,Ke))}validateEmptyOrAlternatives(e){return Se(e,r=>Iu(r,Ke))}validateAmbiguousAlternationAlternatives(e,r){return Se(e,s=>ku(s,r,Ke))}validateSomeNonEmptyLookaheadPath(e,r){return vu(e,r,Ke)}buildLookaheadForAlternation(e){return Eu(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,xu)}buildLookaheadForOptional(e){return Tu(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,mn(e.prodType),Su)}};var Sn=class{static{a(this,"LooksAhead")}initLooksAhead(e){this.dynamicTokensEnabled=S(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:be.dynamicTokensEnabled,this.maxLookahead=S(e,"maxLookahead")?e.maxLookahead:be.maxLookahead,this.lookaheadStrategy=S(e,"lookaheadStrategy")?e.lookaheadStrategy:new ls({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){T(e,r=>{this.TRACE_INIT(`${r.name} Rule Lookahead`,()=>{let{alternation:s,repetition:n,option:o,repetitionMandatory:i,repetitionMandatoryWithSeparator:c,repetitionWithSeparator:l}=Ex(r);T(s,u=>{let d=u.idx===0?"":u.idx;this.TRACE_INIT(`${Ie(u)}${d}`,()=>{let f=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:u.idx,rule:r,maxLookahead:u.maxLookahead||this.maxLookahead,hasPredicates:u.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),p=Tn(this.fullRuleNameToShort[r.name],256,u.idx);this.setLaFuncCache(p,f)})}),T(n,u=>{this.computeLookaheadFunc(r,u.idx,768,"Repetition",u.maxLookahead,Ie(u))}),T(o,u=>{this.computeLookaheadFunc(r,u.idx,512,"Option",u.maxLookahead,Ie(u))}),T(i,u=>{this.computeLookaheadFunc(r,u.idx,1024,"RepetitionMandatory",u.maxLookahead,Ie(u))}),T(c,u=>{this.computeLookaheadFunc(r,u.idx,1536,"RepetitionMandatoryWithSeparator",u.maxLookahead,Ie(u))}),T(l,u=>{this.computeLookaheadFunc(r,u.idx,1280,"RepetitionWithSeparator",u.maxLookahead,Ie(u))})})})}computeLookaheadFunc(e,r,s,n,o,i){this.TRACE_INIT(`${i}${r===0?"":r}`,()=>{let c=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:r,rule:e,maxLookahead:o||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:n}),l=Tn(this.fullRuleNameToShort[e.name],s,r);this.setLaFuncCache(l,c)})}getKeyForAutomaticLookahead(e,r){let s=this.getLastExplicitRuleShortName();return Tn(s,e,r)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,r){this.lookAheadFuncsCache.set(e,r)}},Ia=class extends Re{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)}},xn=new Ia;function Ex(t){xn.reset(),t.accept(xn);let e=xn.dslMethods;return xn.reset(),e}a(Ex,"collectMethods");function _a(t,e){isNaN(t.startOffset)===!0?(t.startOffset=e.startOffset,t.endOffset=e.endOffset):t.endOffset<e.endOffset&&(t.endOffset=e.endOffset)}a(_a,"setNodeLocationOnlyOffset");function Ma(t,e){isNaN(t.startOffset)===!0?(t.startOffset=e.startOffset,t.startColumn=e.startColumn,t.startLine=e.startLine,t.endOffset=e.endOffset,t.endColumn=e.endColumn,t.endLine=e.endLine):t.endOffset<e.endOffset&&(t.endOffset=e.endOffset,t.endColumn=e.endColumn,t.endLine=e.endLine)}a(Ma,"setNodeLocationFull");function Bu(t,e,r){t.children[r]===void 0?t.children[r]=[e]:t.children[r].push(e)}a(Bu,"addTerminalToCst");function $u(t,e,r){t.children[e]===void 0?t.children[e]=[r]:t.children[e].push(r)}a($u,"addNoneTerminalToCst");var Tx="name";function wa(t,e){Object.defineProperty(t,Tx,{enumerable:!1,configurable:!0,writable:!1,value:e})}a(wa,"defineNameProp");function xx(t,e){let r=P(t),s=r.length;for(let n=0;n<s;n++){let o=r[n],i=t[o],c=i.length;for(let l=0;l<c;l++){let u=i[l];u.tokenTypeIdx===void 0&&this[u.name](u.children,e)}}}a(xx,"defaultVisit");function Gu(t,e){let r=a(function(){},"derivedConstructor");wa(r,t+"BaseSemantics");let s={visit:a(function(n,o){if(A(n)&&(n=n[0]),!ge(n))return this[n.name](n.children,o)},"visit"),validateVisitor:a(function(){let n=Sx(this,e);if(!L(n)){let o=y(n,i=>i.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
	${o.join(`

`).replace(/\n/g,`
	`)}`)}},"validateVisitor")};return r.prototype=s,r.prototype.constructor=r,r._RULE_NAMES=e,r}a(Gu,"createBaseSemanticVisitorConstructor");function Wu(t,e,r){let s=a(function(){},"derivedConstructor");wa(s,t+"BaseSemanticsWithDefaults");let n=Object.create(r.prototype);return T(e,o=>{n[o]=xx}),s.prototype=n,s.prototype.constructor=s,s}a(Wu,"createBaseVisitorConstructorWithDefaults");var Pa;(function(t){t[t.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",t[t.MISSING_METHOD=1]="MISSING_METHOD"})(Pa||(Pa={}));function Sx(t,e){return Ax(t,e)}a(Sx,"validateVisitor");function Ax(t,e){let r=me(e,n=>xe(t[n])===!1),s=y(r,n=>({msg:`Missing visitor method: <${n}> on ${t.constructor.name} CST Visitor.`,type:Pa.MISSING_METHOD,methodName:n}));return Qe(s)}a(Ax,"validateMissingCstMethods");var Nn=class{static{a(this,"TreeBuilder")}initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=S(e,"nodeLocationTracking")?e.nodeLocationTracking:be.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=Y,this.cstFinallyStateUpdate=Y,this.cstPostTerminal=Y,this.cstPostNonTerminal=Y,this.cstPostRule=Y;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Ma,this.setNodeLocationFromNode=Ma,this.cstPostRule=Y,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=Y,this.setNodeLocationFromNode=Y,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=_a,this.setNodeLocationFromNode=_a,this.cstPostRule=Y,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=Y,this.setNodeLocationFromNode=Y,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=Y,this.setNodeLocationFromNode=Y,this.cstPostRule=Y,this.setInitialNodeLocation=Y;else throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(e){let r=this.LA(1);e.location={startOffset:r.startOffset,startLine:r.startLine,startColumn:r.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(e){let r={name:e,children:Object.create(null)};this.setInitialNodeLocation(r),this.CST_STACK.push(r)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){let r=this.LA(0),s=e.location;s.startOffset<=r.startOffset?(s.endOffset=r.endOffset,s.endLine=r.endLine,s.endColumn=r.endColumn):(s.startOffset=NaN,s.startLine=NaN,s.startColumn=NaN)}cstPostRuleOnlyOffset(e){let r=this.LA(0),s=e.location;s.startOffset<=r.startOffset?s.endOffset=r.endOffset:s.startOffset=NaN}cstPostTerminal(e,r){let s=this.CST_STACK[this.CST_STACK.length-1];Bu(s,r,e),this.setNodeLocationFromToken(s.location,r)}cstPostNonTerminal(e,r){let s=this.CST_STACK[this.CST_STACK.length-1];$u(s,r,e),this.setNodeLocationFromNode(s.location,e.location)}getBaseCstVisitorConstructor(){if(ge(this.baseCstVisitorConstructor)){let e=Gu(this.className,P(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(ge(this.baseCstVisitorWithDefaultsConstructor)){let e=Wu(this.className,P(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor}getLastExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-1]}getPreviousExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-2]}getLastExplicitRuleOccurrenceIndex(){let e=this.RULE_OCCURRENCE_STACK;return e[e.length-1]}};var On=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.tokVector.length-2?(this.consumeToken(),this.LA(1)):Cr}LA(e){let r=this.currIdx+e;return r<0||this.tokVectorLength<=r?Cr:this.tokVector[r]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVector.length-1}getLexerPosition(){return this.exportLexerState()}};var Cn=class{static{a(this,"RecognizerApi")}ACTION(e){return e.call(this)}consume(e,r,s){return this.consumeInternal(r,e,s)}subrule(e,r,s){return this.subruleInternal(r,e,s)}option(e,r){return this.optionInternal(r,e)}or(e,r){return this.orInternal(r,e)}many(e,r){return this.manyInternal(e,r)}atLeastOne(e,r){return this.atLeastOneInternal(e,r)}CONSUME(e,r){return this.consumeInternal(e,0,r)}CONSUME1(e,r){return this.consumeInternal(e,1,r)}CONSUME2(e,r){return this.consumeInternal(e,2,r)}CONSUME3(e,r){return this.consumeInternal(e,3,r)}CONSUME4(e,r){return this.consumeInternal(e,4,r)}CONSUME5(e,r){return this.consumeInternal(e,5,r)}CONSUME6(e,r){return this.consumeInternal(e,6,r)}CONSUME7(e,r){return this.consumeInternal(e,7,r)}CONSUME8(e,r){return this.consumeInternal(e,8,r)}CONSUME9(e,r){return this.consumeInternal(e,9,r)}SUBRULE(e,r){return this.subruleInternal(e,0,r)}SUBRULE1(e,r){return this.subruleInternal(e,1,r)}SUBRULE2(e,r){return this.subruleInternal(e,2,r)}SUBRULE3(e,r){return this.subruleInternal(e,3,r)}SUBRULE4(e,r){return this.subruleInternal(e,4,r)}SUBRULE5(e,r){return this.subruleInternal(e,5,r)}SUBRULE6(e,r){return this.subruleInternal(e,6,r)}SUBRULE7(e,r){return this.subruleInternal(e,7,r)}SUBRULE8(e,r){return this.subruleInternal(e,8,r)}SUBRULE9(e,r){return this.subruleInternal(e,9,r)}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,r,s=Lr){if(W(this.definedRulesNames,e)){let i={message:Ke.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:le.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(i)}this.definedRulesNames.push(e);let n=this.defineRule(e,r,s);return this[e]=n,n}OVERRIDE_RULE(e,r,s=Lr){let n=Lu(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(n);let o=this.defineRule(e,r,s);return this[e]=o,o}BACKTRACK(e,r){return function(){this.isBackTrackingStack.push(1);let s=this.saveRecogState();try{return e.apply(this,r),!0}catch(n){if(vt(n))return!1;throw n}finally{this.reloadRecogState(s),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return Zs(_(this.gastProductionsCache))}};var Ln=class{static{a(this,"RecognizerEngine")}initRecognizerEngine(e,r){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=br,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},S(r,"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(A(e)){if(L(e))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(A(e))this.tokensMap=ne(e,(o,i)=>(o[i.name]=i,o),{});else if(S(e,"modes")&&he(oe(_(e.modes)),ou)){let o=oe(_(e.modes)),i=yr(o);this.tokensMap=ne(i,(c,l)=>(c[l.name]=l,c),{})}else if(z(e))this.tokensMap=D(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=ke;let s=S(e,"modes")?oe(_(e.modes)):_(e),n=he(s,o=>L(o.categoryMatches));this.tokenMatcher=n?br:ut,ft(_(this.tokensMap))}defineRule(e,r,s){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 n=S(s,"resyncEnabled")?s.resyncEnabled:Lr.resyncEnabled,o=S(s,"recoveryValueFunc")?s.recoveryValueFunc:Lr.recoveryValueFunc,i=this.ruleShortNameIdx<<12;this.ruleShortNameIdx++,this.shortRuleNameToFull[i]=e,this.fullRuleNameToShort[e]=i;let c;return this.outputCst===!0?c=a(function(...d){try{this.ruleInvocationStateUpdate(i,e,this.subruleIdx),r.apply(this,d);let f=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(f),f}catch(f){return this.invokeRuleCatch(f,n,o)}finally{this.ruleFinallyStateUpdate()}},"invokeRuleWithTry"):c=a(function(...d){try{return this.ruleInvocationStateUpdate(i,e,this.subruleIdx),r.apply(this,d)}catch(f){return this.invokeRuleCatch(f,n,o)}finally{this.ruleFinallyStateUpdate()}},"invokeRuleWithTryCst"),Object.assign(c,{ruleName:e,originalGrammarAction:r})}invokeRuleCatch(e,r,s){let n=this.RULE_STACK.length===1,o=r&&!this.isBackTracking()&&this.recoveryEnabled;if(vt(e)){let i=e;if(o){let c=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(c))if(i.resyncedTokens=this.reSyncTo(c),this.outputCst){let l=this.CST_STACK[this.CST_STACK.length-1];return l.recoveredNode=!0,l}else return s(e);else{if(this.outputCst){let l=this.CST_STACK[this.CST_STACK.length-1];l.recoveredNode=!0,i.partialCstResult=l}throw i}}else{if(n)return this.moveToTerminatedState(),s(e);throw i}}else throw e}optionInternal(e,r){let s=this.getKeyForAutomaticLookahead(512,r);return this.optionInternalLogic(e,r,s)}optionInternalLogic(e,r,s){let n=this.getLaFuncFromCache(s),o;if(typeof e!="function"){o=e.DEF;let i=e.GATE;if(i!==void 0){let c=n;n=a(()=>i.call(this)&&c.call(this),"lookAheadFunc")}}else o=e;if(n.call(this)===!0)return o.call(this)}atLeastOneInternal(e,r){let s=this.getKeyForAutomaticLookahead(1024,e);return this.atLeastOneInternalLogic(e,r,s)}atLeastOneInternalLogic(e,r,s){let n=this.getLaFuncFromCache(s),o;if(typeof r!="function"){o=r.DEF;let i=r.GATE;if(i!==void 0){let c=n;n=a(()=>i.call(this)&&c.call(this),"lookAheadFunc")}}else o=r;if(n.call(this)===!0){let i=this.doSingleRepetition(o);for(;n.call(this)===!0&&i===!0;)i=this.doSingleRepetition(o)}else throw this.raiseEarlyExitException(e,H.REPETITION_MANDATORY,r.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,r],n,1024,e,fn)}atLeastOneSepFirstInternal(e,r){let s=this.getKeyForAutomaticLookahead(1536,e);this.atLeastOneSepFirstInternalLogic(e,r,s)}atLeastOneSepFirstInternalLogic(e,r,s){let n=r.DEF,o=r.SEP;if(this.getLaFuncFromCache(s).call(this)===!0){n.call(this);let c=a(()=>this.tokenMatcher(this.LA(1),o),"separatorLookAheadFunc");for(;this.tokenMatcher(this.LA(1),o)===!0;)this.CONSUME(o),n.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,o,c,n,ts],c,1536,e,ts)}else throw this.raiseEarlyExitException(e,H.REPETITION_MANDATORY_WITH_SEPARATOR,r.ERR_MSG)}manyInternal(e,r){let s=this.getKeyForAutomaticLookahead(768,e);return this.manyInternalLogic(e,r,s)}manyInternalLogic(e,r,s){let n=this.getLaFuncFromCache(s),o;if(typeof r!="function"){o=r.DEF;let c=r.GATE;if(c!==void 0){let l=n;n=a(()=>c.call(this)&&l.call(this),"lookaheadFunction")}}else o=r;let i=!0;for(;n.call(this)===!0&&i===!0;)i=this.doSingleRepetition(o);this.attemptInRepetitionRecovery(this.manyInternal,[e,r],n,768,e,un,i)}manySepFirstInternal(e,r){let s=this.getKeyForAutomaticLookahead(1280,e);this.manySepFirstInternalLogic(e,r,s)}manySepFirstInternalLogic(e,r,s){let n=r.DEF,o=r.SEP;if(this.getLaFuncFromCache(s).call(this)===!0){n.call(this);let c=a(()=>this.tokenMatcher(this.LA(1),o),"separatorLookAheadFunc");for(;this.tokenMatcher(this.LA(1),o)===!0;)this.CONSUME(o),n.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,o,c,n,es],c,1280,e,es)}}repetitionSepSecondInternal(e,r,s,n,o){for(;s();)this.CONSUME(r),n.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,r,s,n,o],s,1536,e,o)}doSingleRepetition(e){let r=this.getLexerPosition();return e.call(this),this.getLexerPosition()>r}orInternal(e,r){let s=this.getKeyForAutomaticLookahead(256,r),n=A(e)?e:e.DEF,i=this.getLaFuncFromCache(s).call(this,n);if(i!==void 0)return n[i].ALT.call(this);this.raiseNoAltException(r,e.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){let e=this.LA(1),r=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new os(r,e))}}subruleInternal(e,r,s){let n;try{let o=s!==void 0?s.ARGS:void 0;return this.subruleIdx=r,n=e.apply(this,o),this.cstPostNonTerminal(n,s!==void 0&&s.LABEL!==void 0?s.LABEL:e.ruleName),n}catch(o){throw this.subruleInternalError(o,s,e.ruleName)}}subruleInternalError(e,r,s){throw vt(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,r!==void 0&&r.LABEL!==void 0?r.LABEL:s),delete e.partialCstResult),e}consumeInternal(e,r,s){let n;try{let o=this.LA(1);this.tokenMatcher(o,e)===!0?(this.consumeToken(),n=o):this.consumeInternalError(e,o,s)}catch(o){n=this.consumeInternalRecovery(e,r,o)}return this.cstPostTerminal(s!==void 0&&s.LABEL!==void 0?s.LABEL:e.name,n),n}consumeInternalError(e,r,s){let n,o=this.LA(0);throw s!==void 0&&s.ERR_MSG?n=s.ERR_MSG:n=this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:r,previous:o,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new Kt(n,r,o))}consumeInternalRecovery(e,r,s){if(this.recoveryEnabled&&s.name==="MismatchedTokenException"&&!this.isBackTracking()){let n=this.getFollowsForInRuleRecovery(e,r);try{return this.tryInRuleRecovery(e,n)}catch(o){throw o.name===La?s:o}}else throw s}saveRecogState(){let e=this.errors,r=D(this.RULE_STACK);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:r,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState),this.RULE_STACK=e.RULE_STACK}ruleInvocationStateUpdate(e,r,s){this.RULE_OCCURRENCE_STACK.push(s),this.RULE_STACK.push(e),this.cstInvocationStateUpdate(r)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let e=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),ke)}reset(){this.resetLexerState(),this.subruleIdx=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]}};var In=class{static{a(this,"ErrorHandler")}initErrorHandler(e){this._errors=[],this.errorMessageProvider=S(e,"errorMessageProvider")?e.errorMessageProvider:be.errorMessageProvider}SAVE_ERROR(e){if(vt(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:D(this.RULE_OCCURRENCE_STACK)},this._errors.push(e),e;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return D(this._errors)}set errors(e){this._errors=e}raiseEarlyExitException(e,r,s){let n=this.getCurrRuleFullName(),o=this.getGAstProductions()[n],c=ss(e,o,r,this.maxLookahead)[0],l=[];for(let d=1;d<=this.maxLookahead;d++)l.push(this.LA(d));let u=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:c,actual:l,previous:this.LA(0),customUserDescription:s,ruleName:n});throw this.SAVE_ERROR(new is(u,this.LA(1),this.LA(0)))}raiseNoAltException(e,r){let s=this.getCurrRuleFullName(),n=this.getGAstProductions()[s],o=rs(e,n,this.maxLookahead),i=[];for(let u=1;u<=this.maxLookahead;u++)i.push(this.LA(u));let c=this.LA(0),l=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:o,actual:i,previous:c,customUserDescription:r,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new as(l,this.LA(1),c))}};var kn=class{static{a(this,"ContentAssist")}initContentAssist(){}computeContentAssist(e,r){let s=this.gastProductionsCache[e];if(ge(s))throw Error(`Rule ->${e}<- does not exist in this grammar.`);return pn([s],r,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){let r=de(e.ruleStack),n=this.getGAstProductions()[r];return new cn(n,e).startWalking()}};var Mn={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(Mn);var ju=!0,Ku=Math.pow(2,8)-1,Hu=N({name:"RECORDING_PHASE_TOKEN",pattern:K.NA});ft([Hu]);var Vu=jt(Hu,`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(Vu);var bx={name:`This CSTNode indicates the Parser is in Recording Phase
	See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},vn=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 r=e>0?e:"";this[`CONSUME${r}`]=function(s,n){return this.consumeInternalRecord(s,e,n)},this[`SUBRULE${r}`]=function(s,n){return this.subruleInternalRecord(s,e,n)},this[`OPTION${r}`]=function(s){return this.optionInternalRecord(s,e)},this[`OR${r}`]=function(s){return this.orInternalRecord(s,e)},this[`MANY${r}`]=function(s){this.manyInternalRecord(e,s)},this[`MANY_SEP${r}`]=function(s){this.manySepFirstInternalRecord(e,s)},this[`AT_LEAST_ONE${r}`]=function(s){this.atLeastOneInternalRecord(e,s)},this[`AT_LEAST_ONE_SEP${r}`]=function(s){this.atLeastOneSepFirstInternalRecord(e,s)}}this.consume=function(e,r,s){return this.consumeInternalRecord(r,e,s)},this.subrule=function(e,r,s){return this.subruleInternalRecord(r,e,s)},this.option=function(e,r){return this.optionInternalRecord(r,e)},this.or=function(e,r){return this.orInternalRecord(r,e)},this.many=function(e,r){this.manyInternalRecord(e,r)},this.atLeastOne=function(e,r){this.atLeastOneInternalRecord(e,r)},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 r=0;r<10;r++){let s=r>0?r:"";delete e[`CONSUME${s}`],delete e[`SUBRULE${s}`],delete e[`OPTION${s}`],delete e[`OR${s}`],delete e[`MANY${s}`],delete e[`MANY_SEP${s}`],delete e[`AT_LEAST_ONE${s}`],delete e[`AT_LEAST_ONE_SEP${s}`]}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,r){return()=>!0}LA_RECORD(e){return Cr}topLevelRuleRecord(e,r){try{let s=new Ae({definition:[],name:e});return s.name=e,this.recordingProdStack.push(s),r.call(this),this.recordingProdStack.pop(),s}catch(s){if(s.KNOWN_RECORDER_ERROR!==!0)try{s.message=s.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 s}throw s}}optionInternalRecord(e,r){return us.call(this,G,e,r)}atLeastOneInternalRecord(e,r){us.call(this,Q,r,e)}atLeastOneSepFirstInternalRecord(e,r){us.call(this,ee,r,e,ju)}manyInternalRecord(e,r){us.call(this,v,r,e)}manySepFirstInternalRecord(e,r){us.call(this,X,r,e,ju)}orInternalRecord(e,r){return Nx.call(this,e,r)}subruleInternalRecord(e,r,s){if(_n(r),!e||S(e,"ruleName")===!1){let c=new Error(`<SUBRULE${zu(r)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>
 inside top level rule: <${this.recordingProdStack[0].name}>`);throw c.KNOWN_RECORDER_ERROR=!0,c}let n=je(this.recordingProdStack),o=e.ruleName,i=new F({idx:r,nonTerminalName:o,label:s?.LABEL,referencedRule:void 0});return n.definition.push(i),this.outputCst?bx:Mn}consumeInternalRecord(e,r,s){if(_n(r),!ga(e)){let i=new Error(`<CONSUME${zu(r)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>
 inside top level rule: <${this.recordingProdStack[0].name}>`);throw i.KNOWN_RECORDER_ERROR=!0,i}let n=je(this.recordingProdStack),o=new I({idx:r,terminalType:e,label:s?.LABEL});return n.definition.push(o),Vu}};function us(t,e,r,s=!1){_n(r);let n=je(this.recordingProdStack),o=xe(e)?e:e.DEF,i=new t({definition:[],idx:r});return s&&(i.separator=e.SEP),S(e,"MAX_LOOKAHEAD")&&(i.maxLookahead=e.MAX_LOOKAHEAD),this.recordingProdStack.push(i),o.call(this),n.definition.push(i),this.recordingProdStack.pop(),Mn}a(us,"recordProd");function Nx(t,e){_n(e);let r=je(this.recordingProdStack),s=A(t)===!1,n=s===!1?t:t.DEF,o=new q({definition:[],idx:e,ignoreAmbiguities:s&&t.IGNORE_AMBIGUITIES===!0});S(t,"MAX_LOOKAHEAD")&&(o.maxLookahead=t.MAX_LOOKAHEAD);let i=jr(n,c=>xe(c.GATE));return o.hasPredicates=i,r.definition.push(o),T(n,c=>{let l=new B({definition:[]});o.definition.push(l),S(c,"IGNORE_AMBIGUITIES")?l.ignoreAmbiguities=c.IGNORE_AMBIGUITIES:S(c,"GATE")&&(l.ignoreAmbiguities=!0),this.recordingProdStack.push(l),c.ALT.call(this),this.recordingProdStack.pop()}),Mn}a(Nx,"recordOrProd");function zu(t){return t===0?"":`${t}`}a(zu,"getIdxSuffix");function _n(t){if(t<0||t>Ku){let e=new Error(`Invalid DSL Method idx value: <${t}>
	Idx value must be a none negative value smaller than ${Ku+1}`);throw e.KNOWN_RECORDER_ERROR=!0,e}}a(_n,"assertMethodIdxIsValid");var wn=class{static{a(this,"PerformanceTracer")}initPerformanceTracer(e){if(S(e,"traceInitPerf")){let r=e.traceInitPerf,s=typeof r=="number";this.traceInitMaxIdent=s?r:1/0,this.traceInitPerf=s?r>0:r}else this.traceInitMaxIdent=0,this.traceInitPerf=be.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,r){if(this.traceInitPerf===!0){this.traceInitIndent++;let s=new Array(this.traceInitIndent+1).join("	");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${s}--> <${e}>`);let{time:n,value:o}=zr(r),i=n>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&i(`${s}<-- <${e}> time: ${n}ms`),this.traceInitIndent--,o}else return r()}};function Yu(t,e){e.forEach(r=>{let s=r.prototype;Object.getOwnPropertyNames(s).forEach(n=>{if(n==="constructor")return;let o=Object.getOwnPropertyDescriptor(s,n);o&&(o.get||o.set)?Object.defineProperty(t.prototype,n,o):t.prototype[n]=r.prototype[n]})})}a(Yu,"applyMixins");var Cr=jt(ke,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(Cr);var be=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:ln,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),Lr=Object.freeze({recoveryValueFunc:a(()=>{},"recoveryValueFunc"),resyncEnabled:!0}),le;(function(t){t[t.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",t[t.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",t[t.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",t[t.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",t[t.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",t[t.LEFT_RECURSION=5]="LEFT_RECURSION",t[t.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",t[t.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",t[t.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",t[t.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",t[t.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",t[t.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",t[t.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",t[t.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"})(le||(le={}));var fs=class t{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 r=this.className;this.TRACE_INIT("toFastProps",()=>{Hr(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),T(this.definedRulesNames,n=>{let i=this[n].originalGrammarAction,c;this.TRACE_INIT(`${n} Rule`,()=>{c=this.topLevelRuleRecord(n,i)}),this.gastProductionsCache[n]=c})}finally{this.disableRecording()}});let s=[];if(this.TRACE_INIT("Grammar Resolving",()=>{s=_u({rules:_(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(s)}),this.TRACE_INIT("Grammar Validations",()=>{if(L(s)&&this.skipValidations===!1){let n=Mu({rules:_(this.gastProductionsCache),tokenTypes:_(this.tokensMap),errMsgProvider:Ke,grammarName:r}),o=Nu({lookaheadStrategy:this.lookaheadStrategy,rules:_(this.gastProductionsCache),tokenTypes:_(this.tokensMap),grammarName:r});this.definitionErrors=this.definitionErrors.concat(n,o)}}),L(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{let n=Gc(_(this.gastProductionsCache));this.resyncFollows=n}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var n,o;(o=(n=this.lookaheadStrategy).initialize)===null||o===void 0||o.call(n,{rules:_(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(_(this.gastProductionsCache))})),!t.DEFER_DEFINITION_ERRORS_HANDLING&&!L(this.definitionErrors))throw e=y(this.definitionErrors,n=>n.message),new Error(`Parser Definition Errors detected:
 ${e.join(`
-------------------------------
`)}`)})}constructor(e,r){this.definitionErrors=[],this.selfAnalysisDone=!1;let s=this;if(s.initErrorHandler(r),s.initLexerAdapter(),s.initLooksAhead(r),s.initRecognizerEngine(e,r),s.initRecoverable(r),s.initTreeBuilder(r),s.initContentAssist(),s.initGastRecorder(r),s.initPerformanceTracer(r),S(r,"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=S(r,"skipValidations")?r.skipValidations:be.skipValidations}};fs.DEFER_DEFINITION_ERRORS_HANDLING=!1;Yu(fs,[En,Sn,Nn,On,Ln,Cn,In,kn,vn,wn]);var ds=class extends fs{static{a(this,"CstParser")}constructor(e,r=be){let s=D(r);s.outputCst=!0,super(e,s)}};function Ir(t,e,r){let s=[r];return s.index=e,s.input=t,s}a(Ir,"customMatch");var Cx=a((t,e)=>{if(t[e]!=='"'||t[e+1]!=="`")return null;for(let r=e+2;r<t.length-1;r++)if(t[r]==="`"&&t[r+1]==='"')return Ir(t,e,t.slice(e,r+2));return null},"matchMarkdownString"),Lx=a((t,e)=>{if(t[e]!=="%"||t[e+1]!=="%")return null;for(let s=e-1;s>=0;s--){let n=t[s];if(n===`
`||n==="\r")break;if(n!==" "&&n!=="	")return null}let r=e+2;for(;r<t.length&&t[r]!==`
`&&t[r]!=="\r";)r++;return Ir(t,e,t.slice(e,r))},"matchComment"),Xu=a((t,e)=>{for(let r=e-1;r>=0;r--){let s=t[r];if(s===`
`||s==="\r")return!0;if(s!==" "&&s!=="	")return!1}return!0},"isIndentedLineStart"),qu=a((t,e,r)=>{if(!Xu(t,e))return null;let s=r.exec(t.slice(e));return s?Ir(t,e,s[0]):null},"matchAccessibilityLine"),Ix=a((t,e)=>{if(!Xu(t,e))return null;let r=/^accDescr[\t ]*{/.exec(t.slice(e));if(!r)return null;let s=t.indexOf("}",e+r[0].length);return s===-1?null:Ir(t,e,t.slice(e,s+1))},"matchAccDescrBlock"),kx=a((t,e)=>{if(t[e]!=="{")return null;let r=0,s=!1,n=!1;for(let o=e;o<t.length;o++){let i=t[o];if(s){n?n=!1:i==="\\"?n=!0:i==='"'&&(s=!1);continue}if(i==='"')s=!0;else if(i==="{")r++;else if(i==="}"&&--r===0)return Ir(t,e,t.slice(e,o+1))}return null},"matchJsonObject"),vx=a((t,e)=>{let r=t.indexOf(">>",e);if(r===-1||/[\n\r]/.test(t.slice(e,r)))return null;let s=t.slice(e,r);return s.trim()?Ir(t,e,s):null},"matchStereotypeText"),ce=N({name:"LABEL_TEXT",pattern:K.NA}),zt=N({name:"WORD",pattern:K.NA,categories:ce}),Pn=N({name:"NUMBER",pattern:/(?:\d+\.\d+|\d+|\.\d+)(?:[A-Za-z]+)?/,categories:ce}),V=N({name:"IDENTIFIER",pattern:/\w+/,longer_alt:Pn,categories:zt}),_x=N({name:"HWS",pattern:/[\t ]+/,group:K.SKIPPED}),rt=N({name:"MARKDOWN_STRING",pattern:Cx,start_chars_hint:['"'],line_breaks:!0}),Mx=N({name:"UNCLOSED_MARKDOWN_STRING",pattern:/"`[^]*/,line_breaks:!0}),Un=N({name:"COMMENT",pattern:Lx,start_chars_hint:["%"],line_breaks:!1}),st=N({name:"NEWLINE",pattern:/\r\n|\n|\r/,line_breaks:!0}),Da=N({name:"ACC_DESCR_BLOCK",pattern:Ix,start_chars_hint:["a"],line_breaks:!0}),wx=/^accTitle[\t ]*:[^\n\r]*/,Px=/^accDescr[\t ]*:[^\n\r]*/,Fa=N({name:"ACC_TITLE_LINE",pattern:a((t,e)=>qu(t,e,wx),"pattern"),start_chars_hint:["a"],line_breaks:!1}),Ba=N({name:"ACC_DESCR_LINE",pattern:a((t,e)=>qu(t,e,Px),"pattern"),start_chars_hint:["a"],line_breaks:!1}),$a=N({name:"JSON_DECLARATION_START",pattern:/json[\t ]+\w+[\t ]*@[\t ]*(?={)/,push_mode:"jsonBody"}),Dn=N({name:"JSON_OBJECT_LITERAL",pattern:kx,start_chars_hint:["{"],line_breaks:!0,pop_mode:!0}),Ju=N({name:"UNCLOSED_JSON_OBJECT_LITERAL",pattern:/{[^]*/,line_breaks:!0,pop_mode:!0}),ae=a((t,e)=>N({name:t,pattern:e,longer_alt:V,categories:zt}),"keyword"),Ga=ae("USECASE",/usecase-beta/),Fn=ae("ACTOR",/actor/),Wa=ae("SYSTEM_BOUNDARY",/systemBoundary/),ja=ae("END",/end/),Ka=ae("DIRECTION",/direction/),za=ae("TD",/TD/),Ha=ae("TB",/TB/),Va=ae("BT",/BT/),Ya=ae("LR",/LR/),Xa=ae("RL",/RL/),qa=ae("NOTE",/note/),Ja=ae("FOR",/for/),Ux=ae("JSON",/json/),Za=ae("CLASS_DEF",/classDef/),Qa=ae("CLASS",/class/),eo=ae("STYLE",/style/),to=ae("INCLUDE",/include/i),ro=ae("EXTEND",/extend/i),so=ae("TRUE",/true/),no=ae("FALSE",/false/),ao=N({name:"GENERALIZATION",pattern:/--\|>/}),oo=N({name:"DEPENDENCY_ARROW",pattern:/\.\.>/}),io=N({name:"STEREOTYPE_START",pattern:/<</,push_mode:"stereotype"}),Bn=N({name:"STEREOTYPE_END",pattern:/>>/,pop_mode:!0}),$n=N({name:"STEREOTYPE_TEXT",pattern:vx,line_breaks:!1}),Zu=N({name:"UNCLOSED_STEREOTYPE_TEXT",pattern:/[^\n\r]+/,line_breaks:!1,pop_mode:!0}),lo=N({name:"CLASS_SEPARATOR",pattern:/:::/}),ps=N({name:"FORWARD_SOLID",pattern:/--+>/}),co=N({name:"BACKWARD_SOLID",pattern:/<--+/}),hs=N({name:"FORWARD_CIRCLE",pattern:/--o/}),uo=N({name:"BACKWARD_CIRCLE",pattern:/o--/}),ms=N({name:"FORWARD_CROSS",pattern:/--x/}),fo=N({name:"BACKWARD_CROSS",pattern:/x--/}),_e=N({name:"MARKERLESS_SOLID",pattern:/--+/}),Gn=N({name:"METADATA_START",pattern:/@{/}),gs=N({name:"AT",pattern:/@/,categories:ce}),po=N({name:"LBRACE",pattern:/{/}),Wn=N({name:"RBRACE",pattern:/}/}),ys=N({name:"LBRACKET",pattern:/\[/}),Es=N({name:"RBRACKET",pattern:/]/}),kr=N({name:"LPAREN",pattern:/\(/}),vr=N({name:"RPAREN",pattern:/\)/}),Fe=N({name:"COMMA",pattern:/,/,categories:ce}),_r=N({name:"COLON",pattern:/:/,categories:ce}),ho=N({name:"HASH_COLOR",pattern:/#[\dA-Fa-f]+/,categories:ce}),Me=N({name:"PLAIN_STRING",pattern:/"[^\n\r"]*"|'[^\n\r']*'/}),jn=N({name:"CSS_IDENTIFIER",pattern:/--[A-Z_a-z][\w-]*|[A-Z_a-z]\w*(?:-\w+)+/,categories:ce}),mo=N({name:"CSS_ESCAPED_COMMA",pattern:/\\,/,categories:ce}),go=N({name:"DASH",pattern:/-/,categories:ce}),yo=N({name:"DOT",pattern:/\./,categories:ce}),Eo=N({name:"PERCENT",pattern:/%/,categories:ce}),To=N({name:"CSS_PUNCTUATION",pattern:/[!#$&*+/=?^_|~]/,categories:ce}),Dx=N({name:"LABEL_PUNCTUATION",pattern:/[;<>\\`]/,categories:ce}),Fx=N({name:"LABEL_SYMBOL",pattern:/[^\t\n\r !-~]+/,categories:ce}),Qu=[ce,zt,_x,rt,Mx,Un,st,Da,Fa,Ba,$a,Ga,Fn,Wa,ja,Ka,za,Ha,Va,Ya,Xa,qa,Ja,Ux,Za,Qa,eo,to,ro,so,no,ao,oo,io,lo,ps,co,hs,uo,ms,fo,_e,Gn,gs,po,Wn,ys,Es,kr,vr,Fe,_r,ho,Me,jn,V,Pn,mo,go,yo,Eo,To,Dx,Fx],ef={defaultMode:"defaultMode",modes:{defaultMode:[...Qu],jsonBody:[Dn,Ju],stereotype:[Bn,$n,Zu]}},tf=[...Qu,Dn,Ju,Bn,$n,Zu];var rf=new K(ef);var sf=a(t=>Qr(t,ce)||t.tokenType===Me||t.tokenType===rt,"isLabelToken"),Bx={allowmixing:!0,newpage:!0,package:!0,rectangle:!0,skinparam:!0},xo=class extends ds{static{a(this,"UsecaseParser")}constructor(){super(tf,{nodeLocationTracking:"full"}),this.RULE("start",()=>{this.CONSUME(Ga),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(st),"ALT")},{ALT:a(()=>this.CONSUME(ke),"ALT")}])}),this.RULE("blankLine",()=>{this.CONSUME(st)}),this.RULE("commentLine",()=>{this.CONSUME(Un),this.SUBRULE(this.lineEnd)}),this.RULE("accTitleStatement",()=>{this.CONSUME(Fa),this.SUBRULE(this.lineEnd)}),this.RULE("accDescrStatement",()=>{this.OR([{ALT:a(()=>this.CONSUME(Ba),"ALT")},{ALT:a(()=>this.CONSUME(Da),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("actorStatement",()=>{this.CONSUME(Fn),this.SUBRULE(this.actorItem),this.OPTION(()=>{this.OR([{ALT:a(()=>this.AT_LEAST_ONE(()=>{this.CONSUME(Fe),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(V),this.OPTION(()=>{this.CONSUME(kr),this.SUBRULE(this.nodeLabel),this.CONSUME(vr)})},"ALT")},{ALT:a(()=>this.CONSUME(Me),"ALT")},{ALT:a(()=>this.CONSUME(rt),"ALT")}])}),this.RULE("actorDeclarationOnly",()=>{this.CONSUME(Fn),this.SUBRULE(this.actorItem),this.MANY(()=>{this.CONSUME(Fe),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(V),this.OPTION(()=>{this.OR2([{ALT:a(()=>{this.CONSUME(kr),this.SUBRULE(this.nodeLabel),this.CONSUME(vr)},"ALT")},{ALT:a(()=>{this.CONSUME(ys),this.SUBRULE2(this.nodeLabel),this.CONSUME(Es)},"ALT")}])})},"ALT")},{ALT:a(()=>this.CONSUME(Me),"ALT")},{ALT:a(()=>this.CONSUME(rt),"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(Me),"ALT")},{ALT:a(()=>this.CONSUME(rt),"ALT")},{ALT:a(()=>this.AT_LEAST_ONE(()=>this.CONSUME(ce)),"ALT")}])}),this.RULE("useCaseMetadata",()=>{this.SUBRULE(this.metadata)}),this.RULE("relationTail",()=>{this.OPTION({GATE:a(()=>this.LA(1).tokenType===V&&this.LA(2).tokenType===gs,"GATE"),DEF:a(()=>{this.CONSUME(V),this.CONSUME(gs)},"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(ps)}),this.RULE("backwardSolidOperator",()=>{this.CONSUME(co),this.OPTION({GATE:a(()=>this.LA(0).image==="<--"&&this.hasLabeledRight([_e]),"GATE"),DEF:a(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(_e)},"DEF")})}),this.RULE("markerlessSolidOperator",()=>{this.CONSUME(_e),this.OPTION({GATE:a(()=>this.LA(0).image==="--"&&this.hasLabeledRight([ps,_e,hs,ms]),"GATE"),DEF:a(()=>{this.SUBRULE(this.edgeLabel),this.OR([{ALT:a(()=>this.CONSUME(ps),"ALT")},{ALT:a(()=>this.CONSUME2(_e),"ALT")},{ALT:a(()=>this.CONSUME(hs),"ALT")},{ALT:a(()=>this.CONSUME(ms),"ALT")}])},"DEF")})}),this.RULE("forwardCircleOperator",()=>{this.CONSUME(hs)}),this.RULE("backwardCircleOperator",()=>{this.CONSUME(uo),this.OPTION({GATE:a(()=>this.hasLabeledRight([_e]),"GATE"),DEF:a(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(_e)},"DEF")})}),this.RULE("forwardCrossOperator",()=>{this.CONSUME(ms)}),this.RULE("backwardCrossOperator",()=>{this.CONSUME(fo),this.OPTION({GATE:a(()=>this.hasLabeledRight([_e]),"GATE"),DEF:a(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(_e)},"DEF")})}),this.RULE("edgeLabel",()=>{this.OR([{ALT:a(()=>this.CONSUME(Me),"ALT")},{ALT:a(()=>this.CONSUME(rt),"ALT")},{ALT:a(()=>this.AT_LEAST_ONE(()=>this.CONSUME(ce)),"ALT")}])}),this.RULE("semanticRelation",()=>{this.OR([{ALT:a(()=>{this.CONSUME(oo),this.CONSUME(_r),this.OR2([{ALT:a(()=>this.CONSUME(to),"ALT")},{ALT:a(()=>this.CONSUME(ro),"ALT")}])},"ALT")},{ALT:a(()=>this.CONSUME(ao),"ALT")}])}),this.RULE("metadata",()=>{this.CONSUME(Gn),this.MANY(()=>this.CONSUME(st)),this.OPTION(()=>{this.SUBRULE(this.metadataProperty),this.MANY2(()=>{this.SUBRULE(this.metadataSeparator),this.SUBRULE2(this.metadataProperty)}),this.OPTION2(()=>this.CONSUME(Fe)),this.MANY3(()=>this.CONSUME2(st))}),this.CONSUME(Wn)}),this.RULE("metadataProperty",()=>{this.OR([{ALT:a(()=>this.CONSUME(V),"ALT")},{ALT:a(()=>this.CONSUME(Me),"ALT")}]),this.CONSUME(_r),this.OR2([{ALT:a(()=>this.CONSUME2(V),"ALT")},{ALT:a(()=>this.CONSUME2(Me),"ALT")},{ALT:a(()=>this.CONSUME(so),"ALT")},{ALT:a(()=>this.CONSUME(no),"ALT")}])}),this.RULE("metadataSeparator",()=>{this.OR([{ALT:a(()=>{this.CONSUME(Fe),this.MANY(()=>this.CONSUME(st))},"ALT")},{ALT:a(()=>{this.AT_LEAST_ONE(()=>this.CONSUME2(st)),this.OPTION(()=>this.CONSUME2(Fe)),this.MANY2(()=>this.CONSUME3(st))},"ALT")}])}),this.RULE("systemBoundaryStatement",()=>{this.CONSUME(Wa),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(ja),this.SUBRULE2(this.lineEnd)}),this.RULE("systemBoundaryName",()=>{this.OR([{ALT:a(()=>{this.CONSUME(V),this.OPTION(()=>{this.OR2([{ALT:a(()=>{this.CONSUME(kr),this.SUBRULE(this.nodeLabel),this.CONSUME(vr)},"ALT")},{ALT:a(()=>{this.CONSUME(ys),this.SUBRULE2(this.nodeLabel),this.CONSUME(Es)},"ALT")}])})},"ALT")},{ALT:a(()=>this.CONSUME(Me),"ALT")},{ALT:a(()=>this.CONSUME(rt),"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(V),"ALT")},{ALT:a(()=>this.CONSUME(Me),"ALT")},{ALT:a(()=>this.CONSUME(rt),"ALT")}])}),this.RULE("noteStatement",()=>{this.CONSUME(qa),this.CONSUME(Ja),this.CONSUME(V),this.SUBRULE(this.nodeLabel),this.SUBRULE(this.lineEnd)}),this.RULE("stereotype",()=>{this.CONSUME(io),this.CONSUME($n),this.CONSUME(Bn)}),this.RULE("classSuffix",()=>{this.CONSUME(lo),this.CONSUME(V),this.MANY(()=>{this.CONSUME(Fe),this.CONSUME2(V)})}),this.RULE("jsonStatement",()=>{this.CONSUME($a),this.CONSUME(Dn),this.OPTION(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd)}),this.RULE("directionStatement",()=>{this.CONSUME(Ka),this.OR([{ALT:a(()=>this.CONSUME(za),"ALT")},{ALT:a(()=>this.CONSUME(Ha),"ALT")},{ALT:a(()=>this.CONSUME(Va),"ALT")},{ALT:a(()=>this.CONSUME(Ya),"ALT")},{ALT:a(()=>this.CONSUME(Xa),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("classDefStatement",()=>{this.CONSUME(Za),this.CONSUME(V),this.MANY(()=>{this.CONSUME(Fe),this.CONSUME2(V)}),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("classStatement",()=>{this.CONSUME(Qa),this.CONSUME(V),this.MANY(()=>{this.CONSUME(Fe),this.CONSUME2(V)}),this.CONSUME3(V),this.MANY2(()=>{this.CONSUME2(Fe),this.CONSUME4(V)}),this.SUBRULE(this.lineEnd)}),this.RULE("styleStatement",()=>{this.CONSUME(eo),this.CONSUME(V),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("styles",()=>{this.SUBRULE(this.styleValue),this.MANY(()=>{this.CONSUME(Fe),this.SUBRULE2(this.styleValue)})}),this.RULE("styleValue",()=>{this.OR([{ALT:a(()=>this.CONSUME(zt),"ALT")},{ALT:a(()=>this.CONSUME(jn),"ALT")},{ALT:a(()=>{this.CONSUME(_e),this.CONSUME2(zt)},"ALT")}]),this.CONSUME(_r),this.AT_LEAST_ONE(()=>this.SUBRULE(this.styleComponent))}),this.RULE("styleComponent",()=>{this.OR([{ALT:a(()=>this.CONSUME(zt),"ALT")},{ALT:a(()=>this.CONSUME(Me),"ALT")},{ALT:a(()=>this.CONSUME(Pn),"ALT")},{ALT:a(()=>this.CONSUME(ho),"ALT")},{ALT:a(()=>this.CONSUME(jn),"ALT")},{ALT:a(()=>this.CONSUME(mo),"ALT")},{ALT:a(()=>this.CONSUME(go),"ALT")},{ALT:a(()=>this.CONSUME(yo),"ALT")},{ALT:a(()=>this.CONSUME(Eo),"ALT")},{ALT:a(()=>this.CONSUME(To),"ALT")},{ALT:a(()=>this.CONSUME(_r),"ALT")},{ALT:a(()=>this.CONSUME(kr),"ALT")},{ALT:a(()=>this.CONSUME(vr),"ALT")},{ALT:a(()=>this.CONSUME(ys),"ALT")},{ALT:a(()=>this.CONSUME(Es),"ALT")},{ALT:a(()=>this.CONSUME(po),"ALT")},{ALT:a(()=>this.CONSUME(Wn),"ALT")},{ALT:a(()=>this.CONSUME(gs),"ALT")},{ALT:a(()=>this.CONSUME(_e),"ALT")}])}),this.performSelfAnalysis()}isMetadataAssignment(){let e=this.LA(1).tokenType;return(e===V||e===Me||e===rt)&&this.LA(2).tokenType===Gn}isStatementStart(){let e=this.LA(1).tokenType;return e!==ke&&e!==st&&e!==Un}isForbiddenPlantUmlStatement(){return this.LA(1).tokenType===V&&Bx[this.LA(1).image.toLowerCase()]===!0}hasLabeledRight(e){if(!sf(this.LA(1)))return!1;for(let r=2;;r++){let s=this.LA(r);if(e.includes(s.tokenType))return!0;if(!sf(s))return!1}}},Ht=new xo;var Kn=class extends Error{constructor(r,s,n){super(`${r} (line ${s}, column ${n})`);this.line=s;this.column=n;this.name="UsecaseJsonError"}static{a(this,"UsecaseJsonError")}},So=a((t,e,r,s)=>{let n=r,o=s,i=Math.min(Math.max(e,0),t.length);for(let c=0;c<i;c++){let l=t[c];l==="\r"?(n++,o=1):l===`
`?(c===0||t[c-1]!=="\r")&&(n++,o=1):o++}return{line:n,column:o}},"locationAtOffset"),$x=a((t,e,r,s)=>{let n=/\bposition (\d+)\b/u.exec(t);if(n)return So(e,Number.parseInt(n[1],10),r,s);let o=/\bline (\d+) column (\d+)\b/u.exec(t);if(o){let i=Number.parseInt(o[1],10),c=Number.parseInt(o[2],10);return{line:r+i-1,column:i===1?s+c-1:c}}if(/unexpected end|end of json input/iu.test(t))return So(e,e.length,r,s)},"locationFromErrorMessage"),ue=class extends Error{constructor(r){super("Invalid JSON token");this.offset=r}static{a(this,"JsonWalkError")}},zn=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 ue(this.offset);return this.propertyOrder}collectValue(e){this.skipWhitespace();let r=this.text[this.offset];if(r==="{")this.collectObject(e);else if(r==="[")this.collectArray(e);else if(r==='"')this.readString(!1);else if(r==="t")this.consumeLiteral("true");else if(r==="f")this.consumeLiteral("false");else if(r==="n")this.consumeLiteral("null");else if(r==="-"||r>="0"&&r<="9")this.consumeNumber();else throw new ue(this.offset)}collectObject(e){this.offset++;let r=[],s=new Set;if(this.propertyOrder[e]=r,this.skipWhitespace(),this.text[this.offset]==="}"){this.offset++;return}for(;this.offset<this.text.length;){if(this.text[this.offset]!=='"')throw new ue(this.offset);let n=this.readString(!0),o=`${e}/${n.replaceAll("~","~0").replaceAll("/","~1")}`;if(s.has(n)?this.deletePointerSubtree(o):(s.add(n),r.push(n)),this.skipWhitespace(),this.text[this.offset]!==":")throw new ue(this.offset);if(this.offset++,this.collectValue(o),this.skipWhitespace(),this.text[this.offset]==="}"){this.offset++;return}if(this.text[this.offset]!==",")throw new ue(this.offset);this.offset++,this.skipWhitespace()}throw new ue(this.offset)}collectArray(e){if(this.offset++,this.skipWhitespace(),this.text[this.offset]==="]"){this.offset++;return}let r=0;for(;this.offset<this.text.length;){if(this.collectValue(`${e}/${r}`),r++,this.skipWhitespace(),this.text[this.offset]==="]"){this.offset++;return}if(this.text[this.offset]!==",")throw new ue(this.offset);this.offset++,this.skipWhitespace()}throw new ue(this.offset)}readString(e){this.offset++;let r="";for(;this.offset<this.text.length;){let s=this.offset,n=this.text[this.offset++];if(n==='"')return r;if(n.charCodeAt(0)<32)throw new ue(s);if(n!=="\\"){e&&(r+=n);continue}let o=this.offset,i=this.text[this.offset++];switch(i){case'"':case"\\":case"/":e&&(r+=i);break;case"b":e&&(r+="\b");break;case"f":e&&(r+="\f");break;case"n":e&&(r+=`
`);break;case"r":e&&(r+="\r");break;case"t":e&&(r+="	");break;case"u":{let c=this.text.slice(this.offset,this.offset+4);if(!/^[\dA-Fa-f]{4}$/u.test(c))throw new ue(this.offset);e&&(r+=String.fromCharCode(Number.parseInt(c,16))),this.offset+=4;break}default:throw new ue(o)}}throw new ue(this.offset)}consumeLiteral(e){let r=0;for(let s of e){if(this.text[this.offset+r]!==s)throw new ue(this.offset+r);r++}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 ue(this.offset);if(this.text[this.offset]==="."){if(this.offset++,this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new ue(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 ue(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 r=`${e}/`;for(let s of Object.keys(this.propertyOrder))(s===e||s.startsWith(r))&&delete this.propertyOrder[s]}};function nf(t,e,r){let s;try{s=JSON.parse(t)}catch(n){let o=n instanceof Error?n.message:String(n),i=$x(o,t,e,r);if(!i){let c=0;try{new zn(t).collect()}catch(l){l instanceof ue&&(c=l.offset)}i=So(t,c,e,r)}throw new Kn(`Invalid JSON: ${o}`,i.line,i.column)}if(typeof s!="object"||s===null||Array.isArray(s))throw new Kn("JSON value must have an object root",e,r);return{value:s,propertyOrder:new zn(t).collect()}}a(nf,"parseOrderedJsonObject");var Gx=a(t=>({shape:t.type==="normal"?"actor":t.type==="hollow"?"actor-hollow":t.type==="awesome"?"actor-awesome":"actor-icon",...t.label===t.id?{}:{label:t.label},...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:"actor",actorType:t.type,business:t.business,labelType:t.labelType,...t.icon?{icon:t.icon}:{},...t.stereotype?{stereotype:t.stereotype}:{},...t.parentId?{parentId:t.parentId}:{}}}),"actorNode"),Wx=a(t=>({shape:t.shape,...t.label===t.id?{}:{label:t.label},...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:"usecase",useCaseShape:t.shape,business:t.business,labelType:t.labelType,...t.stereotype?{stereotype:t.stereotype}:{},...t.parentId?{parentId:t.parentId}:{}}}),"useCaseNode"),jx=a(t=>({label:t.label,shape:"note",attrs:{kind:"note",target:t.target,labelType:t.labelType}}),"noteNode"),Kx=a(t=>({label:t.id,shape:"json-table",...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:"json",value:t.value,propertyOrder:t.propertyOrder,labelType:"text"}}),"jsonNode"),zx=a(t=>({id:t.id,source:t.source,target:t.target,...t.label?{label:t.label}:{},...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{relationshipType:t.type,arrowType:t.arrowType,minlen:t.minlen,explicitId:t.explicitId,animate:t.animate,...t.animation?{animation:t.animation}:{},...t.labelType?{labelType:t.labelType}:{}}}),"relationshipEdge"),Hx=a(t=>({id:`${t.id}-edge`,source:t.id,target:t.target,attrs:{relationshipType:"note",arrowType:w.LINE_SOLID,pattern:"dotted",minlen:1,explicitId:!1,animate:!1,internal:!0}}),"noteEdge"),af=a((t,e,r,s)=>{let n={};for(let l of t.getActors().values())n[l.id]=Gx(l);for(let l of t.getUseCases().values())n[l.id]=Wx(l);for(let l of t.getNotes().values())n[l.id]=jx(l);for(let l of t.getJsonNodes().values())n[l.id]=Kx(l);let o={};for(let l of t.getSystemBoundaries().values())o[l.id]={...l.label===l.id?{}:{title:l.label},nodes:[...l.members],...l.classes.length?{classes:[...l.classes]}:{},...l.styles.length?{styles:[...l.styles]}:{},attrs:{kind:"systemBoundary",boundaryType:l.type,labelType:l.labelType}};let i={};for(let l of t.getClassDefs().values())i[l.id]={styles:[...l.styles]};let c=t.getDirection();return{version:1,diagramType:"usecase",source:e,header:{keyword:"usecase",direction:c==="TD"?"TB":c,span:r},...t.getAccTitle()?{accTitle:t.getAccTitle()}:{},...t.getAccDescription()?{accDescr:t.getAccDescription()}:{},nodes:n,edges:[...t.getRelationships().map(zx),...[...t.getNotes().values()].map(Hx)],groups:o,classDefs:i,statements:s}},"buildUsecaseGraphAST");var ye=a(t=>`line ${t.line}, column ${t.column} [${t.span[0]},${t.span[1]})`,"locationText"),of=a(t=>t===void 0?"":` (label "${t}")`,"labelSuffix"),Vt=a(t=>t.generated?t.label:void 0,"generatedFrom"),Ao=a((t,e)=>{for(let r of e)t.includes(r)||t.push(r)},"pushUnique"),Hn=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,r,s,n){this.metadataAssignments.push({target:e,targetLocation:r,metadata:s,statement:n})}addClassDef(e,r){this.classDefinitions.push({ids:e,styles:r})}addClassAssignment(e,r){this.classAssignments.push({targets:e,classes:r})}addStyleAssignment(e,r,s){this.styleAssignments.push({target:e,location:r,styles:s})}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 r=new Map,s=new Map,n=new Map,o=new Map;for(let u of this.relationshipDrafts)this.recordFirst(o,u.source.id,u.source.location.span[0]),this.recordFirst(o,u.target.id,u.target.location.span[0]);for(let u of this.elements)this.recordFirst(o,u.id,u.location.span[0]);for(let u of this.boundaries)this.recordFirst(o,u.id,u.location.span[0]);for(let u of this.jsonDrafts)this.recordFirst(o,u.id,u.location.span[0]);let i=[...this.elements.map(u=>({offset:u.location.span[0],type:"element",value:u})),...this.boundaries.map(u=>({offset:u.location.span[0],type:"boundary",value:u})),...this.jsonDrafts.map(u=>({offset:u.location.span[0],type:"json",value:u})),...this.relationshipDrafts.filter(u=>u.explicitId).map(u=>({offset:u.explicitIdLocation.span[0],type:"edge",value:u}))].sort((u,d)=>u.offset-d.offset);for(let u of i)u.type==="element"?this.collectElement(u.value,r,s):u.type==="boundary"?this.collectBoundary(u.value,r,n):u.type==="json"?this.registerUnique(r,u.value.id,"json",u.value.location,!1):this.registerUnique(r,u.value.explicitId,"edge",u.value.explicitIdLocation,!1);this.materializeElements(s,o),this.materializeBoundaries(n,o),this.materializeJson(o);let c=this.materializeRelationships(r,s,o);this.reorderElements(s,o),this.applyMetadataAssignments(r,s,n,c),this.validateAndRefreshElements(s),this.refreshBoundaries(n,s),this.materializeNotes(r),this.applyClassDefinitions(),this.applyClassesAndStyles(r,c),this.model.direction=this.directions.at(-1)??this.model.direction,this.model.symbols=new Map([...r].map(([u,d])=>[u,d.kind]));let l=af(this,this.source,e,this.statements);return this.model.ast=l,this.db.commit(this.model),l}collectElement(e,r,s){let n=r.get(e.id),o=Vt({generated:e.generated,label:e.label.text});n&&n.kind!==e.kind&&this.conflict(`ID '${e.id}' is declared as both ${n.kind} and ${e.kind}`,e.location,n.location,o,Vt(n)),n&&(n.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,n.location,o,Vt(n));let i=s.get(e.id);if(!i){let c={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(c,e.metadata),s.set(e.id,c),r.set(e.id,{kind:e.kind,location:e.location,generated:e.generated,label:e.label.text});return}(i.label.text!==e.label.text||i.label.type!==e.label.type)&&this.conflict(`ID '${e.id}' has conflicting labels`,e.location,i.location),e.shape&&i.shape&&e.shape!==i.shape&&this.conflict(`Use case '${e.id}' has conflicting shapes`,e.location,i.location),e.parentId&&i.parentId&&e.parentId!==i.parentId&&this.conflict(`Element '${e.id}' belongs to more than one system boundary`,e.parentLocation??e.location,i.parentLocation??i.location),e.stereotype&&i.stereotype&&e.stereotype!==i.stereotype&&this.conflict(`Element '${e.id}' has conflicting stereotypes`,e.location,i.stereotypeLocation??i.location),i.shape??=e.shape,i.parentId??=e.parentId,i.parentLocation??=e.parentLocation,i.stereotype??=e.stereotype,i.stereotypeLocation??=e.stereotype?e.location:void 0,Ao(i.classes,e.classes),this.applyDeclarationMetadata(i,e.metadata)}collectBoundary(e,r,s){let n=r.get(e.id),o=Vt({generated:e.generated,label:e.label.text});n&&n.kind!=="boundary"&&this.conflict(`ID '${e.id}' is declared as both ${n.kind} and boundary`,e.location,n.location,o,Vt(n)),n&&(n.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,n.location,o,Vt(n));let i=s.get(e.id);if(i){(i.label.text!==e.label.text||i.label.type!==e.label.type)&&this.conflict(`Boundary '${e.id}' has conflicting titles`,e.location,i.location),Ao(i.classes,e.classes);return}s.set(e.id,{id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],styles:[],members:[]}),r.set(e.id,{kind:"boundary",location:e.location,generated:e.generated,label:e.label.text})}materializeElements(e,r){for(let s of[...e.values()].sort((n,o)=>(r.get(n.id)??0)-(r.get(o.id)??0)))this.setElementModel(s)}materializeBoundaries(e,r){for(let s of[...e.values()].sort((n,o)=>(r.get(n.id)??0)-(r.get(o.id)??0)))this.model.systemBoundaries.set(s.id,{id:s.id,label:s.label.text,labelType:s.label.type,type:s.type??"rect",members:[],classes:[...s.classes],styles:[...s.styles]})}materializeJson(e){for(let r of[...this.jsonDrafts].sort((s,n)=>(e.get(s.id)??0)-(e.get(n.id)??0)))this.model.jsonNodes.set(r.id,{id:r.id,value:r.value,propertyOrder:r.propertyOrder,classes:[...r.classes],styles:[]})}materializeRelationships(e,r,s){let n=new Map,o=0;for(let i of this.relationshipDrafts){let c=this.resolveEndpoint(i.source,e,r,s),l=this.resolveEndpoint(i.target,e,r,s);this.validateRelationship(i,c,l,e);let u=i.explicitId??`edge-${o++}`,d={id:u,explicitId:!!i.explicitId,source:i.source.id,target:i.target.id,type:i.type,arrowType:i.arrowType,...i.label?{label:i.label.text,labelType:i.label.type}:{},minlen:i.minlen,classes:[],styles:[],animate:!1};this.model.relationships.push(d),n.set(u,{draft:i,relationship:d})}return this.model.relationshipCounter=o,n}resolveEndpoint(e,r,s,n){if(e.classesOnReference&&!e.declaration)throw new Error(`Relationship endpoint '${e.id}' uses ::: without declaring the node at ${ye(e.location)}`);let o=r.get(e.id);return o?o.kind:(s.set(e.id,{kind:"usecase",id:e.id,label:e.label,location:e.location,generated:e.generated,shape:"ellipse",classes:[]}),r.set(e.id,{kind:"usecase",location:e.location,generated:e.generated,label:e.label.text}),this.recordFirst(n,e.id,e.location.span[0]),"usecase")}reorderElements(e,r){let s=new Map(this.model.actors),n=new Map(this.model.useCases);this.model.actors.clear(),this.model.useCases.clear();for(let o of[...e.values()].sort((i,c)=>(r.get(i.id)??0)-(r.get(c.id)??0))){!s.has(o.id)&&!n.has(o.id)&&this.setElementModel(o);let i=s.get(o.id)??this.model.actors.get(o.id),c=n.get(o.id)??this.model.useCases.get(o.id);i?this.model.actors.set(o.id,i):c&&this.model.useCases.set(o.id,c)}}applyMetadataAssignments(e,r,s,n){for(let o of this.metadataAssignments){let i=e.get(o.target);if(!i){let c=this.inferMetadataKind(o.metadata);throw new Error(`Metadata target '${o.target}' is unresolved${c?` (metadata implies ${c})`:""} at ${ye(o.targetLocation)}`)}if(i.kind==="actor"||i.kind==="usecase")this.applyStandaloneElementMetadata(r.get(o.target),o.metadata);else if(i.kind==="boundary"){let c=s.get(o.target);for(let l of o.metadata.properties)(l.key!=="type"||l.value!=="rect"&&l.value!=="package")&&this.invalidMetadata(o.target,i.kind,l),c.type=l.value}else if(i.kind==="edge"){let c=n.get(o.target);if(!c)throw new Error(`Metadata target '${o.target}' is not an explicit edge at ${ye(o.targetLocation)}`);o.statement.kind="edgeMetadata",o.statement.edges=[{id:o.target,span:o.statement.span,idSpan:o.targetLocation.span,...o.statement.metadata?{metadata:o.statement.metadata}:{}}],delete o.statement.nodes;for(let l of o.metadata.properties)l.key==="animate"&&typeof l.value=="boolean"?c.relationship.animate=l.value:l.key==="animation"&&(l.value==="fast"||l.value==="slow")?(c.relationship.animation=l.value,c.relationship.animate=!0):this.invalidMetadata(o.target,i.kind,l)}else for(let c of o.metadata.properties)this.invalidMetadata(o.target,i.kind,c)}for(let{relationship:o}of n.values())o.animation&&(o.animate=!0)}applyStandaloneElementMetadata(e,r){for(let s of r.properties)e.kind==="actor"?this.applyActorProperty(e,s,!0):s.key==="business"&&typeof s.value=="boolean"?e.business=s.value:this.invalidMetadata(e.id,e.kind,s)}applyDeclarationMetadata(e,r){if(r)for(let s of r.properties)e.kind==="actor"?this.applyActorProperty(e,s,!1):s.key==="business"&&typeof s.value=="boolean"?(e.business!==void 0&&e.business!==s.value&&this.conflict(`Use case '${e.id}' has conflicting business metadata`,s.location,e.location),e.business=s.value):this.invalidMetadata(e.id,e.kind,s)}applyActorProperty(e,r,s){r.key==="type"&&(r.value==="normal"||r.value==="hollow"||r.value==="awesome")?(!s&&e.actorType!==void 0&&e.actorType!==r.value&&this.conflict(`Actor '${e.id}' has conflicting type metadata`,r.location,e.location),e.actorType=r.value):r.key==="icon"&&typeof r.value=="string"?(!s&&e.icon!==void 0&&e.icon!==r.value&&this.conflict(`Actor '${e.id}' has conflicting icon metadata`,r.location,e.location),e.icon=r.value):r.key==="business"&&typeof r.value=="boolean"?(!s&&e.business!==void 0&&e.business!==r.value&&this.conflict(`Actor '${e.id}' has conflicting business metadata`,r.location,e.location),e.business=r.value):this.invalidMetadata(e.id,e.kind,r)}validateAndRefreshElements(e){for(let r of e.values()){let s=r.icon?"icon":r.actorType??"normal";if(r.kind==="actor"){if(r.icon&&r.actorType&&r.actorType!=="normal")throw new Error(`Actor '${r.id}' cannot combine icon with type '${r.actorType}' at ${ye(r.location)}`);if(r.business&&(s==="icon"||s==="awesome"))throw new Error(`Business actor '${r.id}' must use normal or hollow geometry at ${ye(r.location)}`)}else if((r.shape??"ellipse")==="rect"&&r.business)throw new Error(`Rectangular use case '${r.id}' cannot be a business use case at ${ye(r.location)}`);this.setElementModel(r)}}refreshBoundaries(e,r){for(let s of e.values())s.members.length=0;for(let s of[...this.elements].sort((n,o)=>n.location.span[0]-o.location.span[0])){if(!s.parentId)continue;let n=e.get(s.parentId);if(!n)throw new Error(`Parent boundary '${s.parentId}' for '${s.id}' is unresolved at ${ye(s.parentLocation??s.location)}`);n.members.includes(s.id)||n.members.push(s.id)}for(let s of r.values())if(s.parentId&&!e.has(s.parentId))throw new Error(`Parent boundary '${s.parentId}' for '${s.id}' is unresolved at ${ye(s.parentLocation??s.location)}`);for(let s of e.values()){let n=this.model.systemBoundaries.get(s.id);n.type=s.type??"rect",n.members=[...s.members],n.classes=[...s.classes],n.styles=[...s.styles]}}materializeNotes(e){let r=0;for(let s of this.noteDrafts){let n=e.get(s.target);if(!n)throw new Error(`Note target '${s.target}' is unresolved at ${ye(s.targetLocation)}`);n.kind!=="actor"&&n.kind!=="usecase"&&this.conflict(`Note target '${s.target}' must be an actor or use case, not ${n.kind}`,s.targetLocation,n.location);let o=`note-${r++}`;this.model.notes.set(o,{id:o,target:s.target,label:s.label.text,labelType:s.label.type})}this.model.noteCounter=r}applyClassDefinitions(){for(let e of this.classDefinitions)for(let r of e.ids)this.model.classDefs.set(r,{id:r,styles:[...e.styles]})}applyClassesAndStyles(e,r){for(let s of this.classAssignments)for(let n of s.targets)Ao(this.getStylable(n.id,e,r,n.location).classes,s.classes);for(let s of this.styleAssignments)this.getStylable(s.target,e,r,s.location).styles.push(...s.styles)}getStylable(e,r,s,n){let o=r.get(e)?.kind,i=o==="actor"?this.model.actors.get(e):o==="usecase"?this.model.useCases.get(e):o==="boundary"?this.model.systemBoundaries.get(e):o==="json"?this.model.jsonNodes.get(e):o==="edge"?s.get(e)?.relationship:void 0;if(!i)throw new Error(`Class/style target '${e}' is unresolved or anonymous at ${ye(n)}`);return i}validateRelationship(e,r,s,n){let o=a(i=>i==="actor"||i==="usecase"||i==="json","allowed");if(o(r)||this.conflict(`Relationship source '${e.source.id}' cannot be ${r}`,e.source.location,n.get(e.source.id).location),o(s)||this.conflict(`Relationship target '${e.target.id}' cannot be ${s}`,e.target.location,n.get(e.target.id).location),(e.type==="include"||e.type==="extend")&&(r!=="usecase"||s!=="usecase"))throw new Error(`${e.type} relationship requires use-case endpoints at ${ye(e.location)}`);if(e.type==="generalization"&&(r!=="actor"&&r!=="usecase"||r!==s))throw new Error(`Generalization requires actor-to-actor or use-case-to-use-case endpoints at ${ye(e.location)}`);if(e.type==="association"&&(r==="json"||s==="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 ${ye(e.location)}`)}setElementModel(e){if(e.kind==="actor"){let r=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:r,...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 r=new Set(["actor","usecase","boundary","edge"]);for(let s of e.properties)if(s.key==="icon")r.clear(),r.add("actor");else if(s.key==="animate"||s.key==="animation")r.clear(),r.add("edge");else if(s.key==="type")r.clear(),s.value==="rect"||s.value==="package"?r.add("boundary"):(s.value==="normal"||s.value==="hollow"||s.value==="awesome")&&r.add("actor");else if(s.key==="business")r.delete("boundary"),r.delete("edge");else return;return r.size===1?[...r][0]:void 0}invalidMetadata(e,r,s){throw new Error(`Metadata property '${s.key}' is invalid for ${r} '${e}' at ${ye(s.location)}`)}registerUnique(e,r,s,n,o){let i=e.get(r);i&&this.conflict(`ID '${r}' is declared more than once (${i.kind} and ${s})`,n,i.location,void 0,Vt(i)),e.set(r,{kind:s,location:n,generated:o})}recordFirst(e,r,s){let n=e.get(r);(n===void 0||s<n)&&e.set(r,s)}conflict(e,r,s,n,o){throw new Error(`${e} at ${ye(r)}${of(n)}; previous declaration at ${ye(s)}${of(o)}`)}};var Vx=Ht.getBaseCstVisitorConstructor(),Ro=class extends Vx{constructor(){super();this.builder=new Hn(Pt);this.source="";this.anonymousEdge=0;this.anonymousNote=0;this.validateVisitor()}static{a(this,"UsecaseVisitor")}build(r,s){this.source=s,this.parentBoundary=void 0,this.anonymousEdge=0,this.anonymousNote=0,this.builder.reset(s),this.visit(r)}start(r){let s=this.tokens(r,"USECASE")[0],n=[];for(let o of this.nodes(r,"line"))n.push(this.visit(o));this.builder.setStatements(n),this.builder.finalize(this.tokenSpan(s))}line(r){let s=this.firstNode(r,"blankLine","commentLine","statement");return this.wrap(s,this.visit(s))}statement(r){return this.visit(this.firstNode(r,"accTitleStatement","accDescrStatement","directionStatement","actorStatement","systemBoundaryStatement","noteStatement","jsonStatement","classDefStatement","classStatement","styleStatement","metadataAssignmentStatement","entityStatement"))}lineEnd(r){}blankLine(r){return{kind:"blank",span:this.tokenSpan(this.tokens(r,"NEWLINE")[0])}}commentLine(r){return{kind:"comment",span:this.tokenSpan(this.tokens(r,"COMMENT")[0])}}accTitleStatement(r){let s=this.tokens(r,"ACC_TITLE_LINE")[0].image;return this.builder.setAccTitle(s.slice(s.indexOf(":")+1).trim()),{kind:"accTitle",span:[0,0]}}accDescrStatement(r){let s=this.tokens(r,"ACC_DESCR_LINE")[0],n=this.tokens(r,"ACC_DESCR_BLOCK")[0],o=s?s.image.slice(s.image.indexOf(":")+1).trim():n.image.slice(n.image.indexOf("{")+1,n.image.lastIndexOf("}")).trim();return this.builder.setAccDescription(o),{kind:"accDescr",span:[0,0]}}actorStatement(r){let s=this.nodes(r,"actorItem"),n=s.map(d=>this.visit(d)),o=this.nodes(r,"relationTail")[0],i=n.map((d,f)=>this.actorOccurrence(s[f],d,!0));for(let d of n)this.builder.addElement(this.actorDraft(d));if(!o)return{kind:"node",span:[0,0],nodes:i};let c=this.visit(o);c.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(c.target));let l=this.relationshipDraft(n[0],c,this.nodeLocation(o));this.builder.addRelationship(l);let u=l.explicitId??`edge-${this.anonymousEdge++}`;return i.push(this.entityOccurrence(this.nodes(o.children,"entityName")[0],c.target,c.target.explicitDeclaration)),{kind:"edge",span:[0,0],nodes:i,edges:[{id:u,span:[0,0],...l.explicitIdLocation?{idSpan:l.explicitIdLocation.span}:{},...l.label?{labelSpan:l.label.span}:{}}]}}actorItem(r){let s=this.visit(this.nodes(r,"actorName")[0]),n=this.nodes(r,"metadata")[0],o=this.nodes(r,"stereotype")[0],i=this.nodes(r,"classSuffix")[0],c=i?this.visit(i):{classes:[],spans:[]};return{...s,...n?{metadata:this.visit(n)}:{},...o?{stereotype:this.visit(o)}:{},classes:c.classes,classSpans:c.spans}}actorName(r){let s=this.tokens(r,"IDENTIFIER")[0],n=this.tokens(r,"PLAIN_STRING")[0]??this.tokens(r,"MARKDOWN_STRING")[0];if(s){let i=this.nodes(r,"nodeLabel")[0],c=i?this.visit(i):this.tokenLabel(s);return{id:s.image,label:c,location:this.tokenLocation(s),generated:!1,classes:[],classSpans:[]}}let o=this.tokenLabel(n);return{id:this.generateId(o.text),label:o,location:this.tokenLocation(n),generated:!0,classes:[],classSpans:[]}}actorDeclarationOnly(r){let s=this.nodes(r,"actorItem"),n=s.map(o=>this.visit(o));for(let o of n)this.builder.addElement(this.actorDraft(o));return{kind:"node",span:[0,0],nodes:n.map((o,i)=>this.actorOccurrence(s[i],o,!0))}}entityStatement(r){let s=this.nodes(r,"entityName"),n=this.visit(s[0]),o=this.nodes(r,"relationTail")[0];if(!o)return n.explicitDeclaration=!0,n.shape??="ellipse",this.builder.addElement(this.entityDraft(n)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(s[0],n,!0)]};n.explicitDeclaration&&this.builder.addElement(this.entityDraft(n));let i=this.visit(o);i.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(i.target));let c={source:this.endpoint(n),target:this.endpoint(i.target),location:this.nodeLocation(o),...i.explicitId?{explicitId:i.explicitId,explicitIdLocation:i.explicitIdLocation}:{},...i.arrow};this.builder.addRelationship(c);let l=c.explicitId??`edge-${this.anonymousEdge++}`;return{kind:"edge",span:[0,0],nodes:[this.entityOccurrence(s[0],n,n.explicitDeclaration),this.entityOccurrence(this.nodes(o.children,"entityName")[0],i.target,i.target.explicitDeclaration)],edges:[{id:l,span:[0,0],...c.explicitIdLocation?{idSpan:c.explicitIdLocation.span}:{},...c.label?{labelSpan:c.label.span}:{}}]}}entityName(r){let s=this.tokens(r,"IDENTIFIER")[0],n=this.tokens(r,"PLAIN_STRING")[0]??this.tokens(r,"MARKDOWN_STRING")[0],o=this.nodes(r,"nodeLabel")[0],i=this.nodes(r,"useCaseMetadata")[0],c=this.nodes(r,"stereotype")[0],l=this.nodes(r,"classSuffix")[0],u=l?this.visit(l):{classes:[],spans:[]};if(s){let f=o?this.visit(o):this.tokenLabel(s),p=o?this.tokens(r,"LBRACKET").length?"rect":"ellipse":void 0;return{id:s.image,label:f,location:this.tokenLocation(s),generated:!1,...p?{shape:p}:{},...i?{metadata:this.visit(i)}:{},...c?{stereotype:this.visit(c)}:{},classes:u.classes,classSpans:u.spans,explicitDeclaration:!!(p||i||c)}}let d=this.tokenLabel(n);return{id:this.generateId(d.text),label:d,location:this.tokenLocation(n),generated:!0,...i?{metadata:this.visit(i)}:{},...c?{stereotype:this.visit(c)}:{},classes:u.classes,classSpans:u.spans,explicitDeclaration:!!(i||c)}}nodeLabel(r){let s=this.allTokens(r);if(s.length===1&&(s[0].tokenType.name==="PLAIN_STRING"||s[0].tokenType.name==="MARKDOWN_STRING"))return this.tokenLabel(s[0]);let n=[s[0].startOffset,(s.at(-1).endOffset??s.at(-1).startOffset)+1];return{text:this.source.slice(n[0],n[1]),type:"text",span:n}}useCaseMetadata(r){return this.visit(this.nodes(r,"metadata")[0])}relationTail(r){let s=this.tokens(r,"IDENTIFIER")[0];return{...s?{explicitId:s.image,explicitIdLocation:this.tokenLocation(s)}:{},arrow:this.visit(this.nodes(r,"arrow")[0]),target:this.visit(this.nodes(r,"entityName")[0])}}arrow(r){return this.visit(this.firstNode(r,"semanticRelation","forwardSolidOperator","backwardSolidOperator","markerlessSolidOperator","forwardCircleOperator","backwardCircleOperator","forwardCrossOperator","backwardCrossOperator"))}edgeLabel(r){return this.nodeLabel(r)}semanticRelation(r){if(this.tokens(r,"GENERALIZATION").length)return{type:"generalization",arrowType:w.SOLID_ARROW,minlen:1};let s=this.tokens(r,"INCLUDE").length?"include":"extend",n=this.tokens(r,s==="include"?"INCLUDE":"EXTEND")[0];return{type:s,arrowType:w.SOLID_ARROW,label:{text:s,type:"text",span:this.tokenSpan(n)},minlen:1}}metadata(r){return{properties:this.nodes(r,"metadataProperty").map(s=>this.visit(s)),location:this.ctxLocation(r)}}metadataProperty(r){let s=this.allTokens(r).filter(l=>l.tokenType.name!=="COLON"),n=s[0],o=s[1],i=o.tokenType.name==="TRUE"?!0:o.tokenType.name==="FALSE"?!1:this.decodePlain(o),c=[n.startOffset,(o.endOffset??o.startOffset)+1];return{key:this.decodePlain(n),value:i,span:c,keySpan:this.contentSpan(n),valueSpan:this.contentSpan(o),location:this.tokenLocation(n)}}metadataSeparator(r){}systemBoundaryStatement(r){let s=this.visit(this.nodes(r,"systemBoundaryName")[0]),n=this.nodes(r,"classSuffix")[0],o=n?this.visit(n):{classes:[],spans:[]};s.classes=o.classes,this.builder.addBoundary(s);let i=this.parentBoundary;this.parentBoundary={id:s.id,location:s.location};let c=this.nodes(r,"systemBoundaryContent")[0],l=c?this.visit(c):[];this.parentBoundary=i;let u=this.tokens(r,"END")[0],d=this.nodes(r,"metadata")[0],f=d?this.visit(d):void 0,p={kind:"group",span:[0,0],group:s.id,idSpan:s.location.span,titleSpan:s.label.span,endSpan:this.tokenSpan(u),classSpans:o.spans,...f?{metadata:f.properties.map(({key:m,span:R,keySpan:b,valueSpan:O})=>({key:m,span:R,keySpan:b,valueSpan:O}))}:{},...l.length?{children:l}:{}};return f&&this.builder.addMetadataAssignment(s.id,s.location,f,p),p}systemBoundaryName(r){let s=this.tokens(r,"IDENTIFIER")[0];if(s){let i=this.nodes(r,"nodeLabel")[0];return{id:s.image,label:i?this.visit(i):this.tokenLabel(s),location:this.tokenLocation(s),generated:!1,classes:[]}}let n=this.tokens(r,"PLAIN_STRING")[0]??this.tokens(r,"MARKDOWN_STRING")[0],o=this.tokenLabel(n);return{id:this.generateId(o.text),label:o,location:this.tokenLocation(n),generated:!0,classes:[]}}systemBoundaryContent(r){return[...this.nodes(r,"blankLine"),...this.nodes(r,"commentLine"),...this.nodes(r,"boundaryElement")].sort((n,o)=>(n.location?.startOffset??0)-(o.location?.startOffset??0)).map(n=>this.wrap(n,this.visit(n)))}boundaryElement(r){let s=this.nodes(r,"actorDeclarationOnly")[0];if(s)return this.visit(s);let n=this.nodes(r,"entityName")[0],o=this.visit(n);return o.explicitDeclaration=!0,o.shape??="ellipse",this.builder.addElement(this.entityDraft(o)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(n,o,!0)]}}metadataAssignmentStatement(r){let s=this.visit(this.nodes(r,"metadataAssignmentTarget")[0]),n=this.visit(this.nodes(r,"metadata")[0]),o={kind:"metadata",span:[0,0],nodes:[{id:s.id,span:s.location.span,idSpan:s.location.span}],metadata:n.properties.map(({key:i,span:c,keySpan:l,valueSpan:u})=>({key:i,span:c,keySpan:l,valueSpan:u}))};return this.builder.addMetadataAssignment(s.id,s.location,n,o),o}metadataAssignmentTarget(r){let s=this.allTokens(r)[0],n=this.tokenLabel(s);return{id:s.tokenType.name==="IDENTIFIER"?s.image:this.generateId(n.text),location:this.tokenLocation(s)}}noteStatement(r){let s=this.tokens(r,"IDENTIFIER")[0],n=this.visit(this.nodes(r,"nodeLabel")[0]);return this.builder.addNote({target:s.image,targetLocation:this.tokenLocation(s),label:n,location:this.ctxLocation(r)}),{kind:"note",span:[0,0],ref:`note-${this.anonymousNote++}`,refSpan:n.span,nodes:[{id:s.image,span:this.tokenSpan(s),idSpan:this.tokenSpan(s)}]}}stereotype(r){let s=this.tokens(r,"STEREOTYPE_TEXT")[0];return{value:s.image.trim(),span:this.tokenSpan(s)}}classSuffix(r){let s=this.tokens(r,"IDENTIFIER");return{classes:s.map(n=>n.image),spans:s.map(n=>this.tokenSpan(n))}}jsonStatement(r){let s=this.tokens(r,"JSON_DECLARATION_START")[0],n=this.tokens(r,"JSON_OBJECT_LITERAL")[0],o=/^json[\t ]+(\w+)/.exec(s.image),i=o[1],c=o[0].length-i.length,l={span:[s.startOffset+c,s.startOffset+c+i.length],line:s.startLine??1,column:(s.startColumn??1)+c},u=nf(n.image,n.startLine??1,n.startColumn??1),d=this.nodes(r,"classSuffix")[0],f=d?this.visit(d):{classes:[],spans:[]},p={id:i,value:u.value,propertyOrder:u.propertyOrder,location:l,classes:f.classes};return this.builder.addJson(p),{kind:"json",span:[0,0],nodes:[{id:i,span:l.span,idSpan:l.span,defines:!0,classSpans:f.spans}],classSpans:f.spans}}directionStatement(r){let s=this.allTokens(r).find(n=>["TD","TB","BT","RL","LR"].includes(n.tokenType.name));return this.builder.setDirection(s.image),{kind:"direction",span:[0,0]}}classDefStatement(r){let s=this.tokens(r,"IDENTIFIER"),n=this.visit(this.nodes(r,"styles")[0]);return this.builder.addClassDef(s.map(o=>o.image),n),{kind:"classDef",span:[0,0],ref:s[0].image,refSpan:this.tokenSpan(s[0])}}classStatement(r){let s=this.tokens(r,"IDENTIFIER"),n=1;for(;n<s.length&&this.source.slice((s[n-1].endOffset??s[n-1].startOffset)+1,s[n].startOffset).includes(",");n++);let o=s.slice(0,n).map(c=>({id:c.image,location:this.tokenLocation(c)})),i=s.slice(n).map(c=>c.image);return this.builder.addClassAssignment(o,i),{kind:"classAssign",span:[0,0],ref:i[0],refSpan:this.tokenSpan(s[n]),nodes:o.map(({id:c,location:l})=>({id:c,span:l.span,idSpan:l.span}))}}styleStatement(r){let s=this.tokens(r,"IDENTIFIER")[0],n=this.visit(this.nodes(r,"styles")[0]);return this.builder.addStyleAssignment(s.image,this.tokenLocation(s),n),{kind:"style",span:[0,0],nodes:[{id:s.image,span:this.tokenSpan(s),idSpan:this.tokenSpan(s)}]}}styles(r){return this.nodes(r,"styleValue").map(s=>this.visit(s))}styleValue(r){let s=this.allTokens(r),n=[s[0].startOffset,(s.at(-1).endOffset??s.at(-1).startOffset)+1];return this.source.slice(n[0],n[1]).replaceAll("\\,",",")}styleComponent(r){return this.allTokens(r).map(s=>s.image).join("")}forwardSolidOperator(r){let s=this.tokens(r,"FORWARD_SOLID")[0];return{type:"association",arrowType:w.SOLID_ARROW,minlen:this.solidMinlen(s)}}backwardSolidOperator(r){let s=this.tokens(r,"BACKWARD_SOLID")[0],n=this.nodes(r,"edgeLabel")[0],o=n?this.tokens(r,"MARKERLESS_SOLID").at(-1):s;return{type:"association",arrowType:w.BACK_ARROW,minlen:this.solidMinlen(o),...n?{label:this.visit(n)}:{}}}markerlessSolidOperator(r){let s=this.nodes(r,"edgeLabel")[0],n=this.allTokens(r);if(!s)return{type:"association",arrowType:w.LINE_SOLID,minlen:this.solidMinlen(this.tokens(r,"MARKERLESS_SOLID")[0])};let o=n.at(-1),i=o.tokenType.name==="FORWARD_SOLID"?w.SOLID_ARROW:o.tokenType.name==="FORWARD_CIRCLE"?w.CIRCLE_ARROW:o.tokenType.name==="FORWARD_CROSS"?w.CROSS_ARROW:w.LINE_SOLID;return{type:"association",arrowType:i,label:this.visit(s),minlen:i===w.SOLID_ARROW||i===w.LINE_SOLID?this.solidMinlen(o):1}}forwardCircleOperator(r){return{type:"association",arrowType:w.CIRCLE_ARROW,minlen:1}}backwardCircleOperator(r){let s=this.nodes(r,"edgeLabel")[0];return{type:"association",arrowType:w.CIRCLE_ARROW_REVERSED,minlen:1,...s?{label:this.visit(s)}:{}}}forwardCrossOperator(r){return{type:"association",arrowType:w.CROSS_ARROW,minlen:1}}backwardCrossOperator(r){let s=this.nodes(r,"edgeLabel")[0];return{type:"association",arrowType:w.CROSS_ARROW_REVERSED,minlen:1,...s?{label:this.visit(s)}:{}}}actorDraft(r){return{id:r.id,kind:"actor",label:r.label,location:r.location,generated:r.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...r.metadata?{metadata:r.metadata}:{},...r.stereotype?{stereotype:r.stereotype.value,stereotypeSpan:r.stereotype.span}:{},classes:r.classes}}entityDraft(r){return{id:r.id,kind:"usecase",label:r.label,location:r.location,generated:r.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...r.shape?{shape:r.shape}:{},...r.metadata?{metadata:r.metadata}:{},...r.stereotype?{stereotype:r.stereotype.value,stereotypeSpan:r.stereotype.span}:{},classes:r.classes}}endpoint(r,s=r.explicitDeclaration??!0){return{id:r.id,label:r.label,location:r.location,generated:r.generated,declaration:s,classesOnReference:r.classes.length>0}}relationshipDraft(r,s,n){return{source:this.endpoint(r,!0),target:this.endpoint(s.target),location:n,...s.explicitId?{explicitId:s.explicitId,explicitIdLocation:s.explicitIdLocation}:{},...s.arrow}}actorOccurrence(r,s,n){return{id:s.id,span:this.nodeSpan(r),idSpan:s.location.span,labelSpan:s.label.span,...n?{defines:!0}:{},...s.stereotype?{stereotypeSpan:s.stereotype.span}:{},...s.metadata?{metadata:s.metadata.properties.map(({key:o,span:i,keySpan:c,valueSpan:l})=>({key:o,span:i,keySpan:c,valueSpan:l}))}:{},...s.classSpans.length?{classSpans:s.classSpans}:{}}}entityOccurrence(r,s,n){return this.actorOccurrence(r,s,n)}wrap(r,s){if(s.kind==="blank"||s.kind==="comment")return s;s.span=this.nodeSpan(r);for(let n of s.edges??[])n.span=s.span;return s}tokenLabel(r){let s=r.tokenType.name==="MARKDOWN_STRING"?"markdown":"text",n=s==="markdown"?2:r.tokenType.name==="PLAIN_STRING"?1:0,o=this.tokenSpan(r,n);return{text:this.source.slice(o[0],o[1]),type:s,span:o}}decodePlain(r){return r.tokenType.name==="PLAIN_STRING"?r.image.slice(1,-1):r.image}contentSpan(r){return this.tokenSpan(r,r.tokenType.name==="PLAIN_STRING"?1:r.tokenType.name==="MARKDOWN_STRING"?2:0)}generateId(r){return r.replace(/\W/g,"_")}solidMinlen(r){return Math.max(1,(r.image.match(/-/g)?.length??2)-1)}nodeLocation(r){let s=this.allTokens(r.children)[0];return{span:this.nodeSpan(r),line:s.startLine??1,column:s.startColumn??1}}ctxLocation(r){let s=this.allTokens(r).filter(i=>i.tokenType.name!=="NEWLINE"&&i.tokenType.name!=="EOF"),n=s[0],o=s.at(-1);return{span:[n.startOffset,Math.min(this.source.length,(o.endOffset??o.startOffset+o.image.length-1)+1)],line:n.startLine??1,column:n.startColumn??1}}tokenLocation(r){let s=r.tokenType.name==="PLAIN_STRING"?1:r.tokenType.name==="MARKDOWN_STRING"?2:0;return{span:this.tokenSpan(r,s),line:r.startLine??1,column:(r.startColumn??1)+s}}nodeSpan(r){let s=this.allTokens(r.children).filter(i=>i.tokenType.name!=="NEWLINE"&&i.tokenType.name!=="EOF"),n=s[0],o=s.at(-1);if(!n||!o)throw new Error("Usecase CST node has no source token");return[n.startOffset,Math.min(this.source.length,(o.endOffset??o.startOffset+o.image.length-1)+1)]}tokenSpan(r,s=0){return[r.startOffset+s,Math.min(this.source.length,(r.endOffset??r.startOffset+r.image.length-1)+1-s)]}nodes(r,s){return(r[s]??[]).filter(n=>"children"in n)}tokens(r,s){return(r[s]??[]).filter(n=>"tokenTypeIdx"in n)}firstNode(r,...s){for(let n of s){let o=this.nodes(r,n)[0];if(o)return o}throw new Error(`Usecase CST is missing one of: ${s.join(", ")}`)}allTokens(r){let s=[];for(let n of Object.values(r))for(let o of n)"tokenTypeIdx"in o?s.push(o):s.push(...this.allTokens(o.children));return s.sort((n,o)=>n.startOffset-o.startOffset)}},lf=new Ro;var cf={parse:a(async t=>{Pt.clear(),Ht.input=[];try{zo({diagramType:"usecase",lexer:rf,parser:Ht,entry:a(()=>Ht.start(),"entry"),visit:a(e=>lf.build(e,t),"visit")},t)}catch(e){Pt.clear();let r=Ht.errors[0];if(r){let{token:s}=r,n=Number.isFinite(s.startOffset)?s.startOffset:t.length,o=typeof s.endOffset=="number"&&Number.isFinite(s.endOffset)?s.endOffset+1:n,i=s.startLine??t.slice(0,n).split(/\r\n|\r|\n/).length,c=Math.max(t.lastIndexOf(`
`,n-1),t.lastIndexOf("\r",n-1)),l=s.startColumn??n-c,u=e instanceof Error?e.message:String(e);throw new Error(`${u} at line ${i}, column ${l} [${n},${o})`)}throw e}},"parse")};var Yx=["point","circle","cross","extension"],pf={usecaseActor:!0,usecaseActorHollow:!0,usecaseActorAwesome:!0,usecaseActorIcon:!0},uf=a((t,e)=>{let[r,s]=[t,e].map(n=>n.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element");return`usecase-${r}-${s}`},"usecaseDomId"),Xx=a(t=>`usecase-${t.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element"}`,"usecaseNodeDomId"),Vn=a((t,e)=>e!=="markdown"?t:Do(t).map(r=>r.map(s=>s.content).join(" ")).join(`
`),"getAccessibleLabel"),qx=a(t=>{let e=Vn(t.label??t.id,t.labelType);if(pf[t.shape]){let s=t.actorType&&t.actorType!=="normal"?`${t.actorType} `:"",n=t.business?"business ":"",o=t.stereotype?`, stereotype ${t.stereotype}`:"";return`${n}${s}actor ${e}${o}`}if(t.shape==="note")return`Note for ${t.noteTargetLabel??t.noteTarget??""}: ${e}`;if(t.shape==="usecaseJsonTable"){let s=(t.jsonRows??[]).map(n=>`${n.accessibleKey}: ${n.value}`).join("; ");return s?`${e}: ${s}`:e}let r=t.stereotype?`, stereotype ${t.stereotype}`:"";return`${t.business?"business ":""}use case ${e}${r}`},"getUsecaseNodeAccessibleName"),Jx=a(t=>`${t.boundaryType} system boundary ${Vn(t.label??t.id,t.labelType)}`,"getUsecaseBoundaryAccessibleName"),Zx=a(t=>t.relationshipType==="note"?"":`${t.relationshipType==="association"&&t.label?`association ${Vn(t.label,t.labelType)}`:t.relationshipType} from ${t.sourceLabel} to ${t.targetLabel}`,"getUsecaseEdgeAccessibleName"),Mr=a(t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),"escapePlainLabel"),ff=a(t=>t.replace(/([*[\\\]_`])/g,"\\$1"),"escapeMarkdownMarkers"),Qx=a((t,e)=>{t.diagramId=e,t.markers=[...Yx];for(let r of t.nodes){let s=r;if(s.domId=Xx(r.id),r.label!==void 0&&r.labelType==="text"&&(r.label=Mr(r.label)),r.stereotype&&(r.stereotype=Mr(r.stereotype)),!r.isGroup&&r.shape==="usecaseJsonTable"&&(r.jsonRows=r.jsonRows?.map(n=>({...n,key:Mr(n.key),value:Mr(n.value)}))),!r.isGroup&&(r.shape==="usecaseEllipse"||r.shape==="rect")&&r.stereotype){let n=r.label??Mr(r.id);r.label=`\xAB${ff(r.stereotype)}\xBB<br/>${r.labelType==="text"?ff(n):n}`,r.labelType="markdown",s.hasFoldedStereotype=!0,delete r.stereotype}}for(let r of t.edges)r.label!==void 0&&r.labelType==="text"&&(r.label=Mr(r.label));return t},"prepareUsecaseLayoutData"),eS=a((t,e,r)=>{for(let n of e.nodes){let o=typeof n.domId=="string"?n.domId:uf(e.diagramId,n.id),i=t.select(`#${o}`),c=n.isGroup?"boundary":pf[n.shape]?"actor":n.shape==="note"?"note":n.shape==="usecaseJsonTable"?"json":"usecase",l=r.nodes.get(n.id)??n.id;if(i.attr("data-usecase-id",n.id).attr("data-usecase-kind",c).attr("role","img").attr("aria-label",l),!n.isGroup&&(n.shape==="usecaseEllipse"||n.shape==="rect")&&"hasFoldedStereotype"in n&&n.hasFoldedStereotype===!0){let u=i.node(),d=u?.querySelector(".nodeLabel"),f=d?.querySelector("p")??d,p=f?.firstChild;if(f&&p?.nodeType===3){let m=f.ownerDocument.createElement("span");m.className="usecase-stereotype",f.insertBefore(m,p),m.appendChild(p)}else u?.querySelector(".label tspan tspan, .label tspan")?.classList.add("usecase-stereotype")}}let s=new Map(e.edges.map(n=>[n.id,n]));t.selectAll('path[data-et="edge"]').each(function(){let n=s.get(this.getAttribute("data-id")??"");if(!n)return;let o=Po(this);o.attr("id",uf(e.diagramId,n.id)).attr("data-usecase-id",n.id).attr("data-usecase-kind",n.internal?"note-connector":"relationship"),n.internal?o.attr("aria-hidden","true"):o.attr("role","img").attr("aria-label",r.edges.get(n.id)??n.id)})},"annotateUsecaseElements"),df=a((t,e)=>{t.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"),tS=a(async(t,e,r,s)=>{Lo.info("Drawing usecase diagram (unified)",e);let{layout:n}=As(),o=s.db,i=o.getData(),c=new Map(i.nodes.map(f=>[f.id,Vn(f.label??f.id,f.labelType)])),l={nodes:new Map(i.nodes.map(f=>[f.id,f.isGroup?Jx(f):qx(f.shape==="note"?{...f,noteTargetLabel:c.get(f.noteTarget??"")}:f)])),edges:new Map(i.edges.map(f=>[f.id,Zx({...f,sourceLabel:c.get(f.source)??f.sourceLabel,targetLabel:c.get(f.target)??f.targetLabel})]))},u=Go(e,i.config.securityLevel);i.layoutAlgorithm=jo(n),Qx(i,e),df(u,i),await Wo(i,u),eS(u,i,l);let d=i.diagramPadding;Uo.insertTitle(u,"usecaseDiagramTitleText",0,o.getDiagramTitle?.()??""),Ko(u,d,"usecaseDiagram",i.useMaxWidth),df(u,i)},"draw"),hf={draw:tS};var rS=a(t=>({actorBkg:t.usecaseActorBkg??t.actorBkg??t.mainBkg,actorBorder:t.usecaseActorBorder??t.actorBorder??t.primaryColor,bkg:t.usecaseBkg??t.mainBkg,border:t.usecaseBorder??t.nodeBorder??t.primaryColor,boundaryBkg:t.usecaseBoundaryBkg??t.clusterBkg,boundaryBorder:t.usecaseBoundaryBorder??t.clusterBorder,includeLine:t.usecaseIncludeLine??t.lineColor,extendLine:t.usecaseExtendLine??t.lineColor}),"roleColors"),sS=a(t=>{let{theme:e,bkgColorArray:r,borderColorArray:s}=t;if(!Bo(e,s))return"";let n=ko().usecase?.colorScheme==="rotate",o=Yt(t.look),i=o==="handDrawn",c=Fo(r),l="";for(let u=0;u<$o(s);u++){let d=s[u],f=c?`fill: ${r[u%r.length]};`:"",p=`[data-look="${o}"][data-color-id="color-${u}"]`;l+=`

    & ${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: ${d};
      ${f}
    }
    `,n&&(l+=`

    /* 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: ${d};
      ${f}
    }

    /* 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: ${d};
    }

    /* 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: ${d};
      ${f}
    }
${i?"":`
    /* 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: ${d};
    }
`}
    `)}return l},"genColor"),nS=a(t=>{let e=rS(t),r=Yt(t.look)==="handDrawn";return`
  ${sS(t)}
  & .usecase-actor {
    color: ${t.actorTextColor??t.primaryTextColor};
  }

  & .usecase-actor-shape,
  & .usecase-actor-hollow,
  & .usecase-actor-awesome,
  & .usecase-actor-icon {
    fill: ${e.actorBkg};
    stroke: ${e.actorBorder};
    stroke-width: 2px;
  }
${r?"":`
  /* 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: ${t.actorTextColor??t.primaryTextColor};
    fill: ${t.actorTextColor??t.primaryTextColor};
    font-family: var(--mermaid-usecase-actor-font-family, ${t.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;
  }
${r?"":`
  /* 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="${Yt(t.look)}"].node.usecase-element ellipse,
  & [data-look="${Yt(t.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="${Yt(t.look)}"].node.usecase-element .usecase-business-marker {
    stroke: ${e.border};
  }
`}
  & .usecase-element .nodeLabel,
  & .usecase-label {
    color: ${t.primaryTextColor};
    fill: ${t.primaryTextColor};
    font-family: var(--mermaid-usecase-font-family, ${t.fontFamily});
    font-size: var(--mermaid-usecase-font-size, 12px);
    font-weight: var(--mermaid-usecase-font-weight, normal);
  }

  & .usecase-stereotype,
  & .usecase-business-marker {
    color: ${t.primaryTextColor};
    fill: ${t.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: ${t.titleColor??t.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: ${t.titleColor??t.primaryTextColor};
  }

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

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

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

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

  & .relationship {
    fill: none;
    stroke: ${t.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: ${t.edgeLabelBackground};
  }

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

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

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

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

  & .marker.extension {
    fill: ${t.mainBkg};
    stroke: ${t.lineColor};
  }
`},"getStyles"),mf=nS;var wG={parser:cf,db:Pt,renderer:hf,styles:mf};export{wG as diagram};
/*! Bundled license information:

lodash-es/lodash.js:
  (**
   * @license
   * Lodash (Custom Build) <https://lodash.com/>
   * Build: `lodash modularize exports="es" -o ./`
   * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
   * Released under MIT license <https://lodash.com/license>
   * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
   * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
   *)
*/