UNPKG

epic-designer-gold

Version:

基于vue3的设计器,可视化开发页面表单

12 lines 455 kB
"use strict";var bp=Object.defineProperty;var Ip=(t,e,n)=>e in t?bp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var rn=(t,e,n)=>Ip(t,typeof e!="symbol"?e+"":e,n);const M=require("./mermaid.core-7qlaqoae.cjs"),v=require("./_baseUniq-D34VkxLn.cjs"),E=require("./_basePickBy-qk3O_To0.cjs"),Ue=require("./clone-DOy2zlRv.cjs"),at=require("./_commonjsHelpers-DwTZ_eVU.cjs");var _p=Object.prototype,$p=_p.hasOwnProperty,lt=M.createAssigner(function(t,e){if(M.isPrototype(e)||M.isArrayLike(e)){M.copyObject(e,v.keys(e),t);return}for(var n in e)$p.call(e,n)&&M.assignValue(t,n,e[n])});function Tf(t,e,n){var r=-1,i=t.length;e<0&&(e=-e>i?0:i+e),n=n>i?i:n,n<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var s=Array(i);++r<i;)s[r]=t[r+e];return s}function Hi(t){for(var e=-1,n=t==null?0:t.length,r=0,i=[];++e<n;){var s=t[e];s&&(i[r++]=s)}return i}function Pp(t,e,n,r){for(var i=-1,s=t==null?0:t.length;++i<s;){var a=t[i];e(r,a,n(a),t)}return r}function Lp(t,e,n,r){return v.baseEach(t,function(i,s,a){e(r,i,n(i),a)}),r}function Op(t,e){return function(n,r){var i=M.isArray(n)?Pp:Lp,s=e?e():{};return i(n,t,v.baseIteratee(r),s)}}var xp=200;function Dp(t,e,n,r){var i=-1,s=v.arrayIncludes,a=!0,o=t.length,c=[],l=e.length;if(!o)return c;e.length>=xp&&(s=v.cacheHas,a=!1,e=new v.SetCache(e));e:for(;++i<o;){var d=t[i],h=d;if(d=d!==0?d:0,a&&h===h){for(var p=l;p--;)if(e[p]===h)continue e;c.push(d)}else s(e,h,r)||c.push(d)}return c}var Na=M.baseRest(function(t,e){return M.isArrayLikeObject(t)?Dp(t,v.baseFlatten(e,1,M.isArrayLikeObject,!0)):[]});function De(t,e,n){var r=t==null?0:t.length;return r?(e=e===void 0?1:E.toInteger(e),Tf(t,e<0?0:e,r)):[]}function Pi(t,e,n){var r=t==null?0:t.length;return r?(e=e===void 0?1:E.toInteger(e),e=r-e,Tf(t,0,e<0?0:e)):[]}function Mp(t,e){for(var n=-1,r=t==null?0:t.length;++n<r;)if(!e(t[n],n,t))return!1;return!0}function Fp(t,e){var n=!0;return v.baseEach(t,function(r,i,s){return n=!!e(r,i,s),n}),n}function At(t,e,n){var r=M.isArray(t)?Mp:Fp;return r(t,v.baseIteratee(e))}function kt(t){return t&&t.length?t[0]:void 0}function ct(t,e){return v.baseFlatten(E.map(t,e))}var Gp=Object.prototype,Up=Gp.hasOwnProperty,jp=Op(function(t,e,n){Up.call(t,n)?t[n].push(e):M.baseAssignValue(t,n,[e])}),zp="[object String]";function Ze(t){return typeof t=="string"||!M.isArray(t)&&M.isObjectLike(t)&&M.baseGetTag(t)==zp}var Bp=Math.max;function Xe(t,e,n,r){t=M.isArrayLike(t)?t:v.values(t),n=n?E.toInteger(n):0;var i=t.length;return n<0&&(n=Bp(i+n,0)),Ze(t)?n<=i&&t.indexOf(e,n)>-1:!!i&&v.baseIndexOf(t,e,n)>-1}function zl(t,e,n){var r=t==null?0:t.length;if(!r)return-1;var i=0;return v.baseIndexOf(t,e,i)}var qp="[object RegExp]";function Wp(t){return M.isObjectLike(t)&&M.baseGetTag(t)==qp}var Bl=M.nodeUtil&&M.nodeUtil.isRegExp,Yt=Bl?M.baseUnary(Bl):Wp,Vp="Expected a function";function Kp(t){if(typeof t!="function")throw new TypeError(Vp);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)}}function Ct(t,e){if(t==null)return{};var n=v.arrayMap(v.getAllKeysIn(t),function(r){return[r]});return e=v.baseIteratee(e),E.basePickBy(t,n,function(r,i){return e(r,i[0])})}function wa(t,e){var n=M.isArray(t)?v.arrayFilter:v.baseFilter;return n(t,Kp(v.baseIteratee(e)))}function Hp(t,e){var n;return v.baseEach(t,function(r,i,s){return n=e(r,i,s),!n}),!!n}function Rf(t,e,n){var r=M.isArray(t)?v.arraySome:Hp;return r(t,v.baseIteratee(e))}function gl(t){return t&&t.length?v.baseUniq(t):[]}function Yp(t,e){return t&&t.length?v.baseUniq(t,v.baseIteratee(e)):[]}function Be(t){return typeof t=="object"&&t!==null&&typeof t.$type=="string"}function vt(t){return typeof t=="object"&&t!==null&&typeof t.$refText=="string"&&"ref"in t}function an(t){return typeof t=="object"&&t!==null&&typeof t.$refText=="string"&&"items"in t}function Xp(t){return typeof t=="object"&&t!==null&&typeof t.name=="string"&&typeof t.type=="string"&&typeof t.path=="string"}function di(t){return typeof t=="object"&&t!==null&&typeof t.info=="object"&&typeof t.message=="string"}class vf{constructor(){this.subtypes={},this.allSubtypes={}}getAllTypes(){return Object.keys(this.types)}getReferenceType(e){var i;const n=this.types[e.container.$type];if(!n)throw new Error(`Type ${e.container.$type||"undefined"} not found.`);const r=(i=n.properties[e.property])==null?void 0:i.referenceType;if(!r)throw new Error(`Property ${e.property||"undefined"} of type ${e.container.$type} is not a reference.`);return r}getTypeMetaData(e){const n=this.types[e];return n||{name:e,properties:{},superTypes:[]}}isInstance(e,n){return Be(e)&&this.isSubtype(e.$type,n)}isSubtype(e,n){if(e===n)return!0;let r=this.subtypes[e];r||(r=this.subtypes[e]={});const i=r[n];if(i!==void 0)return i;{const s=this.types[e],a=s?s.superTypes.some(o=>this.isSubtype(o,n)):!1;return r[n]=a,a}}getAllSubTypes(e){const n=this.allSubtypes[e];if(n)return n;{const r=this.getAllTypes(),i=[];for(const s of r)this.isSubtype(s,e)&&i.push(s);return this.allSubtypes[e]=i,i}}}function Li(t){return typeof t=="object"&&t!==null&&Array.isArray(t.content)}function Ef(t){return typeof t=="object"&&t!==null&&typeof t.tokenType=="object"}function Af(t){return Li(t)&&typeof t.fullText=="string"}class Me{constructor(e,n){this.startFn=e,this.nextFn=n}iterator(){const e={state:this.startFn(),next:()=>this.nextFn(e.state),[Symbol.iterator]:()=>e};return e}[Symbol.iterator](){return this.iterator()}isEmpty(){return!!this.iterator().next().done}count(){const e=this.iterator();let n=0,r=e.next();for(;!r.done;)n++,r=e.next();return n}toArray(){const e=[],n=this.iterator();let r;do r=n.next(),r.value!==void 0&&e.push(r.value);while(!r.done);return e}toSet(){return new Set(this)}toMap(e,n){const r=this.map(i=>[e?e(i):i,n?n(i):i]);return new Map(r)}toString(){return this.join()}concat(e){return new Me(()=>({first:this.startFn(),firstDone:!1,iterator:e[Symbol.iterator]()}),n=>{let r;if(!n.firstDone){do if(r=this.nextFn(n.first),!r.done)return r;while(!r.done);n.firstDone=!0}do if(r=n.iterator.next(),!r.done)return r;while(!r.done);return st})}join(e=","){const n=this.iterator();let r="",i,s=!1;do i=n.next(),i.done||(s&&(r+=e),r+=Jp(i.value)),s=!0;while(!i.done);return r}indexOf(e,n=0){const r=this.iterator();let i=0,s=r.next();for(;!s.done;){if(i>=n&&s.value===e)return i;s=r.next(),i++}return-1}every(e){const n=this.iterator();let r=n.next();for(;!r.done;){if(!e(r.value))return!1;r=n.next()}return!0}some(e){const n=this.iterator();let r=n.next();for(;!r.done;){if(e(r.value))return!0;r=n.next()}return!1}forEach(e){const n=this.iterator();let r=0,i=n.next();for(;!i.done;)e(i.value,r),i=n.next(),r++}map(e){return new Me(this.startFn,n=>{const{done:r,value:i}=this.nextFn(n);return r?st:{done:!1,value:e(i)}})}filter(e){return new Me(this.startFn,n=>{let r;do if(r=this.nextFn(n),!r.done&&e(r.value))return r;while(!r.done);return st})}nonNullable(){return this.filter(e=>e!=null)}reduce(e,n){const r=this.iterator();let i=n,s=r.next();for(;!s.done;)i===void 0?i=s.value:i=e(i,s.value),s=r.next();return i}reduceRight(e,n){return this.recursiveReduce(this.iterator(),e,n)}recursiveReduce(e,n,r){const i=e.next();if(i.done)return r;const s=this.recursiveReduce(e,n,r);return s===void 0?i.value:n(s,i.value)}find(e){const n=this.iterator();let r=n.next();for(;!r.done;){if(e(r.value))return r.value;r=n.next()}}findIndex(e){const n=this.iterator();let r=0,i=n.next();for(;!i.done;){if(e(i.value))return r;i=n.next(),r++}return-1}includes(e){const n=this.iterator();let r=n.next();for(;!r.done;){if(r.value===e)return!0;r=n.next()}return!1}flatMap(e){return new Me(()=>({this:this.startFn()}),n=>{do{if(n.iterator){const s=n.iterator.next();if(s.done)n.iterator=void 0;else return s}const{done:r,value:i}=this.nextFn(n.this);if(!r){const s=e(i);if(Ys(s))n.iterator=s[Symbol.iterator]();else return{done:!1,value:s}}}while(n.iterator);return st})}flat(e){if(e===void 0&&(e=1),e<=0)return this;const n=e>1?this.flat(e-1):this;return new Me(()=>({this:n.startFn()}),r=>{do{if(r.iterator){const a=r.iterator.next();if(a.done)r.iterator=void 0;else return a}const{done:i,value:s}=n.nextFn(r.this);if(!i)if(Ys(s))r.iterator=s[Symbol.iterator]();else return{done:!1,value:s}}while(r.iterator);return st})}head(){const n=this.iterator().next();if(!n.done)return n.value}tail(e=1){return new Me(()=>{const n=this.startFn();for(let r=0;r<e;r++)if(this.nextFn(n).done)return n;return n},this.nextFn)}limit(e){return new Me(()=>({size:0,state:this.startFn()}),n=>(n.size++,n.size>e?st:this.nextFn(n.state)))}distinct(e){return new Me(()=>({set:new Set,internalState:this.startFn()}),n=>{let r;do if(r=this.nextFn(n.internalState),!r.done){const i=e?e(r.value):r.value;if(!n.set.has(i))return n.set.add(i),r}while(!r.done);return st})}exclude(e,n){const r=new Set;for(const i of e){const s=n?n(i):i;r.add(s)}return this.filter(i=>{const s=n?n(i):i;return!r.has(s)})}}function Jp(t){return typeof t=="string"?t:typeof t>"u"?"undefined":typeof t.toString=="function"?t.toString():Object.prototype.toString.call(t)}function Ys(t){return!!t&&typeof t[Symbol.iterator]=="function"}const Sf=new Me(()=>{},()=>st),st=Object.freeze({done:!0,value:void 0});function fe(...t){if(t.length===1){const e=t[0];if(e instanceof Me)return e;if(Ys(e))return new Me(()=>e[Symbol.iterator](),n=>n.next());if(typeof e.length=="number")return new Me(()=>({index:0}),n=>n.index<e.length?{done:!1,value:e[n.index++]}:st)}return t.length>1?new Me(()=>({collIndex:0,arrIndex:0}),e=>{do{if(e.iterator){const n=e.iterator.next();if(!n.done)return n;e.iterator=void 0}if(e.array){if(e.arrIndex<e.array.length)return{done:!1,value:e.array[e.arrIndex++]};e.array=void 0,e.arrIndex=0}if(e.collIndex<t.length){const n=t[e.collIndex++];Ys(n)?e.iterator=n[Symbol.iterator]():n&&typeof n.length=="number"&&(e.array=n)}}while(e.iterator||e.array||e.collIndex<t.length);return st}):Sf}class yl extends Me{constructor(e,n,r){super(()=>({iterators:r!=null&&r.includeRoot?[[e][Symbol.iterator]()]:[n(e)[Symbol.iterator]()],pruned:!1}),i=>{for(i.pruned&&(i.iterators.pop(),i.pruned=!1);i.iterators.length>0;){const a=i.iterators[i.iterators.length-1].next();if(a.done)i.iterators.pop();else return i.iterators.push(n(a.value)[Symbol.iterator]()),a}return st})}iterator(){const e={state:this.startFn(),next:()=>this.nextFn(e.state),prune:()=>{e.state.pruned=!0},[Symbol.iterator]:()=>e};return e}}var ko;(function(t){function e(s){return s.reduce((a,o)=>a+o,0)}t.sum=e;function n(s){return s.reduce((a,o)=>a*o,0)}t.product=n;function r(s){return s.reduce((a,o)=>Math.min(a,o))}t.min=r;function i(s){return s.reduce((a,o)=>Math.max(a,o))}t.max=i})(ko||(ko={}));function Co(t,e={}){for(const[n,r]of Object.entries(t))n.startsWith("$")||(Array.isArray(r)?r.forEach((i,s)=>{Be(i)&&(i.$container=t,i.$containerProperty=n,i.$containerIndex=s,e.deep&&Co(i,e))}):Be(r)&&(r.$container=t,r.$containerProperty=n,e.deep&&Co(r,e)))}function ba(t,e){let n=t;for(;n;){if(e(n))return n;n=n.$container}}function Wt(t){const n=Os(t).$document;if(!n)throw new Error("AST node has no document.");return n}function Os(t){for(;t.$container;)t=t.$container;return t}function ql(t){return vt(t)?t.ref?[t.ref]:[]:an(t)?t.items.map(e=>e.ref):[]}function Tl(t,e){if(!t)throw new Error("Node must be an AstNode.");const n=e==null?void 0:e.range;return new Me(()=>({keys:Object.keys(t),keyIndex:0,arrayIndex:0}),r=>{for(;r.keyIndex<r.keys.length;){const i=r.keys[r.keyIndex];if(!i.startsWith("$")){const s=t[i];if(Be(s)){if(r.keyIndex++,Wl(s,n))return{done:!1,value:s}}else if(Array.isArray(s)){for(;r.arrayIndex<s.length;){const a=r.arrayIndex++,o=s[a];if(Be(o)&&Wl(o,n))return{done:!1,value:o}}r.arrayIndex=0}}r.keyIndex++}return st})}function Yi(t,e){if(!t)throw new Error("Root node must be an AstNode.");return new yl(t,n=>Tl(n,e))}function Vt(t,e){if(!t)throw new Error("Root node must be an AstNode.");return new yl(t,n=>Tl(n,e),{includeRoot:!0})}function Wl(t,e){var r;if(!e)return!0;const n=(r=t.$cstNode)==null?void 0:r.range;return n?vm(n,e):!1}function Xs(t){return new Me(()=>({keys:Object.keys(t),keyIndex:0,arrayIndex:0}),e=>{for(;e.keyIndex<e.keys.length;){const n=e.keys[e.keyIndex];if(!n.startsWith("$")){const r=t[n];if(vt(r)||an(r))return e.keyIndex++,{done:!1,value:{reference:r,container:t,property:n}};if(Array.isArray(r)){for(;e.arrayIndex<r.length;){const i=e.arrayIndex++,s=r[i];if(vt(s)||an(r))return{done:!1,value:{reference:s,container:t,property:n,index:i}}}e.arrayIndex=0}}e.keyIndex++}return st})}function Qp(t,e){const n=t.getTypeMetaData(e.$type),r=e;for(const i of Object.values(n.properties))i.defaultValue!==void 0&&r[i.name]===void 0&&(r[i.name]=kf(i.defaultValue))}function kf(t){return Array.isArray(t)?[...t.map(kf)]:t}const it={$type:"AbstractElement",cardinality:"cardinality"};function Zp(t){return Z.isInstance(t,it.$type)}const xs={$type:"AbstractParserRule"};function Xi(t){return Z.isInstance(t,xs.$type)}const As={$type:"AbstractRule"},Tt={$type:"AbstractType"},wn={$type:"Action",cardinality:"cardinality",feature:"feature",inferredType:"inferredType",operator:"operator",type:"type"};function Ia(t){return Z.isInstance(t,wn.$type)}const Ds={$type:"Alternatives",cardinality:"cardinality",elements:"elements"};function Cf(t){return Z.isInstance(t,Ds.$type)}const Vl={$type:"ArrayLiteral",elements:"elements"},Kl={$type:"ArrayType",elementType:"elementType"},bn={$type:"Assignment",cardinality:"cardinality",feature:"feature",operator:"operator",predicate:"predicate",terminal:"terminal"};function Dn(t){return Z.isInstance(t,bn.$type)}const No={$type:"BooleanLiteral",true:"true"};function em(t){return Z.isInstance(t,No.$type)}const In={$type:"CharacterRange",cardinality:"cardinality",left:"left",lookahead:"lookahead",parenthesized:"parenthesized",right:"right"};function tm(t){return Z.isInstance(t,In.$type)}const Hn={$type:"Condition"},Ms={$type:"Conjunction",left:"left",right:"right"};function nm(t){return Z.isInstance(t,Ms.$type)}const _n={$type:"CrossReference",cardinality:"cardinality",deprecatedSyntax:"deprecatedSyntax",isMulti:"isMulti",terminal:"terminal",type:"type"};function _a(t){return Z.isInstance(t,_n.$type)}const Fs={$type:"Disjunction",left:"left",right:"right"};function rm(t){return Z.isInstance(t,Fs.$type)}const wo={$type:"EndOfFile",cardinality:"cardinality"};function im(t){return Z.isInstance(t,wo.$type)}const Cn={$type:"Grammar",imports:"imports",interfaces:"interfaces",isDeclared:"isDeclared",name:"name",rules:"rules",types:"types"},Hl={$type:"GrammarImport",path:"path"},er={$type:"Group",cardinality:"cardinality",elements:"elements",guardCondition:"guardCondition",predicate:"predicate"};function Rl(t){return Z.isInstance(t,er.$type)}const bo={$type:"InferredType",name:"name"};function Nf(t){return Z.isInstance(t,bo.$type)}const Gt={$type:"InfixRule",call:"call",dataType:"dataType",inferredType:"inferredType",name:"name",operators:"operators",parameters:"parameters",returnType:"returnType"};function Js(t){return Z.isInstance(t,Gt.$type)}const no={$type:"InfixRuleOperatorList",associativity:"associativity",operators:"operators"},Yl={$type:"InfixRuleOperators",precedences:"precedences"},vi={$type:"Interface",attributes:"attributes",name:"name",superTypes:"superTypes"};function sm(t){return Z.isInstance(t,vi.$type)}const Ei={$type:"Keyword",cardinality:"cardinality",predicate:"predicate",value:"value"};function Mn(t){return Z.isInstance(t,Ei.$type)}const Ss={$type:"NamedArgument",calledByName:"calledByName",parameter:"parameter",value:"value"},tr={$type:"NegatedToken",cardinality:"cardinality",lookahead:"lookahead",parenthesized:"parenthesized",terminal:"terminal"};function am(t){return Z.isInstance(t,tr.$type)}const Io={$type:"Negation",value:"value"};function om(t){return Z.isInstance(t,Io.$type)}const Xl={$type:"NumberLiteral",value:"value"},ks={$type:"Parameter",name:"name"},_o={$type:"ParameterReference",parameter:"parameter"};function cm(t){return Z.isInstance(t,_o.$type)}const It={$type:"ParserRule",dataType:"dataType",definition:"definition",entry:"entry",fragment:"fragment",inferredType:"inferredType",name:"name",parameters:"parameters",returnType:"returnType"};function Qt(t){return Z.isInstance(t,It.$type)}const ro={$type:"ReferenceType",isMulti:"isMulti",referenceType:"referenceType"},nr={$type:"RegexToken",cardinality:"cardinality",lookahead:"lookahead",parenthesized:"parenthesized",regex:"regex"};function lm(t){return Z.isInstance(t,nr.$type)}const $o={$type:"ReturnType",name:"name"};function um(t){return Z.isInstance(t,$o.$type)}const rr={$type:"RuleCall",arguments:"arguments",cardinality:"cardinality",predicate:"predicate",rule:"rule"};function Fn(t){return Z.isInstance(t,rr.$type)}const Ai={$type:"SimpleType",primitiveType:"primitiveType",stringType:"stringType",typeRef:"typeRef"};function dm(t){return Z.isInstance(t,Ai.$type)}const Jl={$type:"StringLiteral",value:"value"},ir={$type:"TerminalAlternatives",cardinality:"cardinality",elements:"elements",lookahead:"lookahead",parenthesized:"parenthesized"};function fm(t){return Z.isInstance(t,ir.$type)}const ft={$type:"TerminalElement",cardinality:"cardinality",lookahead:"lookahead",parenthesized:"parenthesized"},sr={$type:"TerminalGroup",cardinality:"cardinality",elements:"elements",lookahead:"lookahead",parenthesized:"parenthesized"};function hm(t){return Z.isInstance(t,sr.$type)}const sn={$type:"TerminalRule",definition:"definition",fragment:"fragment",hidden:"hidden",name:"name",type:"type"};function Zt(t){return Z.isInstance(t,sn.$type)}const ar={$type:"TerminalRuleCall",cardinality:"cardinality",lookahead:"lookahead",parenthesized:"parenthesized",rule:"rule"};function pm(t){return Z.isInstance(t,ar.$type)}const Gs={$type:"Type",name:"name",type:"type"};function mm(t){return Z.isInstance(t,Gs.$type)}const fi={$type:"TypeAttribute",defaultValue:"defaultValue",isOptional:"isOptional",name:"name",type:"type"},hi={$type:"TypeDefinition"},Ql={$type:"UnionType",types:"types"},Us={$type:"UnorderedGroup",cardinality:"cardinality",elements:"elements"};function wf(t){return Z.isInstance(t,Us.$type)}const or={$type:"UntilToken",cardinality:"cardinality",lookahead:"lookahead",parenthesized:"parenthesized",terminal:"terminal"};function gm(t){return Z.isInstance(t,or.$type)}const pi={$type:"ValueLiteral"},Si={$type:"Wildcard",cardinality:"cardinality",lookahead:"lookahead",parenthesized:"parenthesized"};function ym(t){return Z.isInstance(t,Si.$type)}class bf extends vf{constructor(){super(...arguments),this.types={AbstractElement:{name:it.$type,properties:{cardinality:{name:it.cardinality}},superTypes:[]},AbstractParserRule:{name:xs.$type,properties:{},superTypes:[As.$type,Tt.$type]},AbstractRule:{name:As.$type,properties:{},superTypes:[]},AbstractType:{name:Tt.$type,properties:{},superTypes:[]},Action:{name:wn.$type,properties:{cardinality:{name:wn.cardinality},feature:{name:wn.feature},inferredType:{name:wn.inferredType},operator:{name:wn.operator},type:{name:wn.type,referenceType:Tt.$type}},superTypes:[it.$type]},Alternatives:{name:Ds.$type,properties:{cardinality:{name:Ds.cardinality},elements:{name:Ds.elements,defaultValue:[]}},superTypes:[it.$type]},ArrayLiteral:{name:Vl.$type,properties:{elements:{name:Vl.elements,defaultValue:[]}},superTypes:[pi.$type]},ArrayType:{name:Kl.$type,properties:{elementType:{name:Kl.elementType}},superTypes:[hi.$type]},Assignment:{name:bn.$type,properties:{cardinality:{name:bn.cardinality},feature:{name:bn.feature},operator:{name:bn.operator},predicate:{name:bn.predicate},terminal:{name:bn.terminal}},superTypes:[it.$type]},BooleanLiteral:{name:No.$type,properties:{true:{name:No.true,defaultValue:!1}},superTypes:[Hn.$type,pi.$type]},CharacterRange:{name:In.$type,properties:{cardinality:{name:In.cardinality},left:{name:In.left},lookahead:{name:In.lookahead},parenthesized:{name:In.parenthesized,defaultValue:!1},right:{name:In.right}},superTypes:[ft.$type]},Condition:{name:Hn.$type,properties:{},superTypes:[]},Conjunction:{name:Ms.$type,properties:{left:{name:Ms.left},right:{name:Ms.right}},superTypes:[Hn.$type]},CrossReference:{name:_n.$type,properties:{cardinality:{name:_n.cardinality},deprecatedSyntax:{name:_n.deprecatedSyntax,defaultValue:!1},isMulti:{name:_n.isMulti,defaultValue:!1},terminal:{name:_n.terminal},type:{name:_n.type,referenceType:Tt.$type}},superTypes:[it.$type]},Disjunction:{name:Fs.$type,properties:{left:{name:Fs.left},right:{name:Fs.right}},superTypes:[Hn.$type]},EndOfFile:{name:wo.$type,properties:{cardinality:{name:wo.cardinality}},superTypes:[it.$type]},Grammar:{name:Cn.$type,properties:{imports:{name:Cn.imports,defaultValue:[]},interfaces:{name:Cn.interfaces,defaultValue:[]},isDeclared:{name:Cn.isDeclared,defaultValue:!1},name:{name:Cn.name},rules:{name:Cn.rules,defaultValue:[]},types:{name:Cn.types,defaultValue:[]}},superTypes:[]},GrammarImport:{name:Hl.$type,properties:{path:{name:Hl.path}},superTypes:[]},Group:{name:er.$type,properties:{cardinality:{name:er.cardinality},elements:{name:er.elements,defaultValue:[]},guardCondition:{name:er.guardCondition},predicate:{name:er.predicate}},superTypes:[it.$type]},InferredType:{name:bo.$type,properties:{name:{name:bo.name}},superTypes:[Tt.$type]},InfixRule:{name:Gt.$type,properties:{call:{name:Gt.call},dataType:{name:Gt.dataType},inferredType:{name:Gt.inferredType},name:{name:Gt.name},operators:{name:Gt.operators},parameters:{name:Gt.parameters,defaultValue:[]},returnType:{name:Gt.returnType,referenceType:Tt.$type}},superTypes:[xs.$type]},InfixRuleOperatorList:{name:no.$type,properties:{associativity:{name:no.associativity},operators:{name:no.operators,defaultValue:[]}},superTypes:[]},InfixRuleOperators:{name:Yl.$type,properties:{precedences:{name:Yl.precedences,defaultValue:[]}},superTypes:[]},Interface:{name:vi.$type,properties:{attributes:{name:vi.attributes,defaultValue:[]},name:{name:vi.name},superTypes:{name:vi.superTypes,defaultValue:[],referenceType:Tt.$type}},superTypes:[Tt.$type]},Keyword:{name:Ei.$type,properties:{cardinality:{name:Ei.cardinality},predicate:{name:Ei.predicate},value:{name:Ei.value}},superTypes:[it.$type]},NamedArgument:{name:Ss.$type,properties:{calledByName:{name:Ss.calledByName,defaultValue:!1},parameter:{name:Ss.parameter,referenceType:ks.$type},value:{name:Ss.value}},superTypes:[]},NegatedToken:{name:tr.$type,properties:{cardinality:{name:tr.cardinality},lookahead:{name:tr.lookahead},parenthesized:{name:tr.parenthesized,defaultValue:!1},terminal:{name:tr.terminal}},superTypes:[ft.$type]},Negation:{name:Io.$type,properties:{value:{name:Io.value}},superTypes:[Hn.$type]},NumberLiteral:{name:Xl.$type,properties:{value:{name:Xl.value}},superTypes:[pi.$type]},Parameter:{name:ks.$type,properties:{name:{name:ks.name}},superTypes:[]},ParameterReference:{name:_o.$type,properties:{parameter:{name:_o.parameter,referenceType:ks.$type}},superTypes:[Hn.$type]},ParserRule:{name:It.$type,properties:{dataType:{name:It.dataType},definition:{name:It.definition},entry:{name:It.entry,defaultValue:!1},fragment:{name:It.fragment,defaultValue:!1},inferredType:{name:It.inferredType},name:{name:It.name},parameters:{name:It.parameters,defaultValue:[]},returnType:{name:It.returnType,referenceType:Tt.$type}},superTypes:[xs.$type]},ReferenceType:{name:ro.$type,properties:{isMulti:{name:ro.isMulti,defaultValue:!1},referenceType:{name:ro.referenceType}},superTypes:[hi.$type]},RegexToken:{name:nr.$type,properties:{cardinality:{name:nr.cardinality},lookahead:{name:nr.lookahead},parenthesized:{name:nr.parenthesized,defaultValue:!1},regex:{name:nr.regex}},superTypes:[ft.$type]},ReturnType:{name:$o.$type,properties:{name:{name:$o.name}},superTypes:[]},RuleCall:{name:rr.$type,properties:{arguments:{name:rr.arguments,defaultValue:[]},cardinality:{name:rr.cardinality},predicate:{name:rr.predicate},rule:{name:rr.rule,referenceType:As.$type}},superTypes:[it.$type]},SimpleType:{name:Ai.$type,properties:{primitiveType:{name:Ai.primitiveType},stringType:{name:Ai.stringType},typeRef:{name:Ai.typeRef,referenceType:Tt.$type}},superTypes:[hi.$type]},StringLiteral:{name:Jl.$type,properties:{value:{name:Jl.value}},superTypes:[pi.$type]},TerminalAlternatives:{name:ir.$type,properties:{cardinality:{name:ir.cardinality},elements:{name:ir.elements,defaultValue:[]},lookahead:{name:ir.lookahead},parenthesized:{name:ir.parenthesized,defaultValue:!1}},superTypes:[ft.$type]},TerminalElement:{name:ft.$type,properties:{cardinality:{name:ft.cardinality},lookahead:{name:ft.lookahead},parenthesized:{name:ft.parenthesized,defaultValue:!1}},superTypes:[it.$type]},TerminalGroup:{name:sr.$type,properties:{cardinality:{name:sr.cardinality},elements:{name:sr.elements,defaultValue:[]},lookahead:{name:sr.lookahead},parenthesized:{name:sr.parenthesized,defaultValue:!1}},superTypes:[ft.$type]},TerminalRule:{name:sn.$type,properties:{definition:{name:sn.definition},fragment:{name:sn.fragment,defaultValue:!1},hidden:{name:sn.hidden,defaultValue:!1},name:{name:sn.name},type:{name:sn.type}},superTypes:[As.$type]},TerminalRuleCall:{name:ar.$type,properties:{cardinality:{name:ar.cardinality},lookahead:{name:ar.lookahead},parenthesized:{name:ar.parenthesized,defaultValue:!1},rule:{name:ar.rule,referenceType:sn.$type}},superTypes:[ft.$type]},Type:{name:Gs.$type,properties:{name:{name:Gs.name},type:{name:Gs.type}},superTypes:[Tt.$type]},TypeAttribute:{name:fi.$type,properties:{defaultValue:{name:fi.defaultValue},isOptional:{name:fi.isOptional,defaultValue:!1},name:{name:fi.name},type:{name:fi.type}},superTypes:[]},TypeDefinition:{name:hi.$type,properties:{},superTypes:[]},UnionType:{name:Ql.$type,properties:{types:{name:Ql.types,defaultValue:[]}},superTypes:[hi.$type]},UnorderedGroup:{name:Us.$type,properties:{cardinality:{name:Us.cardinality},elements:{name:Us.elements,defaultValue:[]}},superTypes:[it.$type]},UntilToken:{name:or.$type,properties:{cardinality:{name:or.cardinality},lookahead:{name:or.lookahead},parenthesized:{name:or.parenthesized,defaultValue:!1},terminal:{name:or.terminal}},superTypes:[ft.$type]},ValueLiteral:{name:pi.$type,properties:{},superTypes:[]},Wildcard:{name:Si.$type,properties:{cardinality:{name:Si.cardinality},lookahead:{name:Si.lookahead},parenthesized:{name:Si.parenthesized,defaultValue:!1}},superTypes:[ft.$type]}}}}const Z=new bf;function Po(t){return new yl(t,e=>Li(e)?e.content:[],{includeRoot:!0})}function Tm(t,e){for(;t.container;)if(t=t.container,t===e)return!0;return!1}function Lo(t){return{start:{character:t.startColumn-1,line:t.startLine-1},end:{character:t.endColumn,line:t.endLine-1}}}function Qs(t){if(!t)return;const{offset:e,end:n,range:r}=t;return{range:r,offset:e,end:n,length:n-e}}var Bt;(function(t){t[t.Before=0]="Before",t[t.After=1]="After",t[t.OverlapFront=2]="OverlapFront",t[t.OverlapBack=3]="OverlapBack",t[t.Inside=4]="Inside",t[t.Outside=5]="Outside"})(Bt||(Bt={}));function Rm(t,e){if(t.end.line<e.start.line||t.end.line===e.start.line&&t.end.character<=e.start.character)return Bt.Before;if(t.start.line>e.end.line||t.start.line===e.end.line&&t.start.character>=e.end.character)return Bt.After;const n=t.start.line>e.start.line||t.start.line===e.start.line&&t.start.character>=e.start.character,r=t.end.line<e.end.line||t.end.line===e.end.line&&t.end.character<=e.end.character;return n&&r?Bt.Inside:n?Bt.OverlapBack:r?Bt.OverlapFront:Bt.Outside}function vm(t,e){return Rm(t,e)>Bt.After}const Em=/^[\w\p{L}]$/u;function Am(t,e){if(t){const n=Sm(t,!0);if(n&&Zl(n,e))return n;if(Af(t)){const r=t.content.findIndex(i=>!i.hidden);for(let i=r-1;i>=0;i--){const s=t.content[i];if(Zl(s,e))return s}}}}function Zl(t,e){return Ef(t)&&e.includes(t.tokenType.name)}function Sm(t,e=!0){for(;t.container;){const n=t.container;let r=n.content.indexOf(t);for(;r>0;){r--;const i=n.content[r];if(e||!i.hidden)return i}t=n}}class If extends Error{constructor(e,n){super(e?`${n} at ${e.range.start.line}:${e.range.start.character}`:n)}}function Ji(t,e="Error: Got unexpected value."){throw new Error(e)}function W(t){return t.charCodeAt(0)}function io(t,e){Array.isArray(t)?t.forEach(function(n){e.push(n)}):e.push(t)}function mi(t,e){if(t[e]===!0)throw"duplicate flag "+e;t[e],t[e]=!0}function Yn(t){if(t===void 0)throw Error("Internal Error - Should never get here!");return!0}function km(){throw Error("Internal Error - Should never get here!")}function eu(t){return t.type==="Character"}const Zs=[];for(let t=W("0");t<=W("9");t++)Zs.push(t);const ea=[W("_")].concat(Zs);for(let t=W("a");t<=W("z");t++)ea.push(t);for(let t=W("A");t<=W("Z");t++)ea.push(t);const tu=[W(" "),W("\f"),W(` `),W("\r"),W(" "),W("\v"),W(" "),W(" "),W(" "),W(" "),W(" "),W(" "),W(" "),W(" "),W(" "),W(" "),W(" "),W(" "),W(" "),W(" "),W("\u2028"),W("\u2029"),W(" "),W(" "),W(" "),W("\uFEFF")],Cm=/[0-9a-fA-F]/,Cs=/[0-9]/,Nm=/[1-9]/;class _f{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("/");const n=this.disjunction();this.consumeChar("/");const r={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":mi(r,"global");break;case"i":mi(r,"ignoreCase");break;case"m":mi(r,"multiLine");break;case"u":mi(r,"unicode");break;case"y":mi(r,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:r,value:n,loc:this.loc(0)}}disjunction(){const e=[],n=this.idx;for(e.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(n)}}alternative(){const e=[],n=this.idx;for(;this.isTerm();)e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(n)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){const 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 n;switch(this.popChar()){case"=":n="Lookahead";break;case"!":n="NegativeLookahead";break;case"<":{switch(this.popChar()){case"=":n="Lookbehind";break;case"!":n="NegativeLookbehind"}break}}Yn(n);const r=this.disjunction();return this.consumeChar(")"),{type:n,value:r,loc:this.loc(e)}}return km()}quantifier(e=!1){let n;const r=this.idx;switch(this.popChar()){case"*":n={atLeast:0,atMost:1/0};break;case"+":n={atLeast:1,atMost:1/0};break;case"?":n={atLeast:0,atMost:1};break;case"{":const i=this.integerIncludingZero();switch(this.popChar()){case"}":n={atLeast:i,atMost:i};break;case",":let s;this.isDigit()?(s=this.integerIncludingZero(),n={atLeast:i,atMost:s}):n={atLeast:i,atMost:1/0},this.consumeChar("}");break}if(e===!0&&n===void 0)return;Yn(n);break}if(!(e===!0&&n===void 0)&&Yn(n))return this.peekChar(0)==="?"?(this.consumeChar("?"),n.greedy=!1):n.greedy=!0,n.type="Quantifier",n.loc=this.loc(r),n}atom(){let e;const n=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}if(e===void 0&&this.isPatternCharacter()&&(e=this.patternCharacter()),Yn(e))return e.loc=this.loc(n),this.isQuantifier()&&(e.quantifier=this.quantifier()),e}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[W(` `),W("\r"),W("\u2028"),W("\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,n=!1;switch(this.popChar()){case"d":e=Zs;break;case"D":e=Zs,n=!0;break;case"s":e=tu;break;case"S":e=tu,n=!0;break;case"w":e=ea;break;case"W":e=ea,n=!0;break}if(Yn(e))return{type:"Set",value:e,complement:n}}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=W("\f");break;case"n":e=W(` `);break;case"r":e=W("\r");break;case"t":e=W(" ");break;case"v":e=W("\v");break}if(Yn(e))return{type:"Character",value:e}}controlLetterEscapeAtom(){this.consumeChar("c");const 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:W("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){const e=this.popChar();return{type:"Character",value:W(e)}}classPatternCharacterAtom(){switch(this.peekChar()){case` `:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:const e=this.popChar();return{type:"Character",value:W(e)}}}characterClass(){const e=[];let n=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),n=!0);this.isClassAtom();){const r=this.classAtom();if(r.type,eu(r)&&this.isRangeDash()){this.consumeChar("-");const i=this.classAtom();if(i.type,eu(i)){if(i.value<r.value)throw Error("Range out of order in character class");e.push({from:r.value,to:i.value})}else io(r.value,e),e.push(W("-")),io(i.value,e)}else io(r.value,e)}return this.consumeChar("]"),{type:"Set",complement:n,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:W("\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}const n=this.disjunction();this.consumeChar(")");const r={type:"Group",capturing:e,value:n};return e&&(r.idx=this.groupIdx),r}positiveInteger(){let e=this.popChar();if(Nm.test(e)===!1)throw Error("Expecting a positive integer");for(;Cs.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(Cs.test(e)===!1)throw Error("Expecting an integer");for(;Cs.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){const 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:W(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 Cs.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(){const 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 n="";for(let i=0;i<e;i++){const s=this.popChar();if(Cm.test(s)===!1)throw Error("Expecting a HexDecimal digits");n+=s}return{type:"Character",value:parseInt(n,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){const 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}}}class $a{visitChildren(e){for(const n in e){const r=e[n];e.hasOwnProperty(n)&&(r.type!==void 0?this.visit(r):Array.isArray(r)&&r.forEach(i=>{this.visit(i)},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){}}const wm=/\r?\n/gm,bm=new _f;class Im extends $a{constructor(){super(...arguments),this.isStarting=!0,this.endRegexpStack=[],this.multiline=!1}get endRegex(){return this.endRegexpStack.join("")}reset(e){this.multiline=!1,this.regex=e,this.startRegexp="",this.isStarting=!0,this.endRegexpStack=[]}visitGroup(e){e.quantifier&&(this.isStarting=!1,this.endRegexpStack=[])}visitCharacter(e){const n=String.fromCharCode(e.value);if(!this.multiline&&n===` `&&(this.multiline=!0),e.quantifier)this.isStarting=!1,this.endRegexpStack=[];else{const r=Pa(n);this.endRegexpStack.push(r),this.isStarting&&(this.startRegexp+=r)}}visitSet(e){if(!this.multiline){const n=this.regex.substring(e.loc.begin,e.loc.end),r=new RegExp(n);this.multiline=!!` `.match(r)}if(e.quantifier)this.isStarting=!1,this.endRegexpStack=[];else{const n=this.regex.substring(e.loc.begin,e.loc.end);this.endRegexpStack.push(n),this.isStarting&&(this.startRegexp+=n)}}visitChildren(e){e.type==="Group"&&e.quantifier||super.visitChildren(e)}}const so=new Im;function _m(t){try{return typeof t=="string"&&(t=new RegExp(t)),t=t.toString(),so.reset(t),so.visit(bm.pattern(t)),so.multiline}catch{return!1}}const $m=`\f \r \v              \u2028\u2029   \uFEFF`.split("");function $f(t){const e=typeof t=="string"?new RegExp(t):t;return $m.some(n=>e.test(n))}function Pa(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Pm(t,e){const n=Lm(t),r=e.match(n);return!!r&&r[0].length>0}function Lm(t){typeof t=="string"&&(t=new RegExp(t));const e=t,n=t.source;let r=0;function i(){let s="",a;function o(l){s+=n.substr(r,l),r+=l}function c(l){s+="(?:"+n.substr(r,l)+"|$)",r+=l}for(;r<n.length;)switch(n[r]){case"\\":switch(n[r+1]){case"c":c(3);break;case"x":c(4);break;case"u":e.unicode?n[r+2]==="{"?c(n.indexOf("}",r)-r+1):c(6):c(2);break;case"p":case"P":e.unicode?c(n.indexOf("}",r)-r+1):c(2);break;case"k":c(n.indexOf(">",r)-r+1);break;default:c(2);break}break;case"[":a=/\[(?:\\.|.)*?\]/g,a.lastIndex=r,a=a.exec(n)||[],c(a[0].length);break;case"|":case"^":case"$":case"*":case"+":case"?":o(1);break;case"{":a=/\{\d+,?\d*\}/g,a.lastIndex=r,a=a.exec(n),a?o(a[0].length):c(1);break;case"(":if(n[r+1]==="?")switch(n[r+2]){case":":s+="(?:",r+=3,s+=i()+"|$)";break;case"=":s+="(?=",r+=3,s+=i()+")";break;case"!":a=r,r+=3,i(),s+=n.substr(a,r-a);break;case"<":switch(n[r+3]){case"=":case"!":a=r,r+=4,i(),s+=n.substr(a,r-a);break;default:o(n.indexOf(">",r)-r+1),s+=i()+"|$)";break}break}else o(1),s+=i()+"|$)";break;case")":return++r,s;default:c(1);break}return s}return new RegExp(i(),t.flags)}function Om(t){return t.rules.find(e=>Qt(e)&&e.entry)}function xm(t){return t.rules.filter(e=>Zt(e)&&e.hidden)}function Pf(t,e){const n=new Set,r=Om(t);if(!r)return new Set(t.rules);const i=[r].concat(xm(t));for(const a of i)Lf(a,n,e);const s=new Set;for(const a of t.rules)(n.has(a.name)||Zt(a)&&a.hidden)&&s.add(a);return s}function Lf(t,e,n){e.add(t.name),Yi(t).forEach(r=>{if(Fn(r)||n){const i=r.rule.ref;i&&!e.has(i.name)&&Lf(i,e,n)}})}function Dm(t){if(t.terminal)return t.terminal;if(t.type.ref){const e=xf(t.type.ref);return e==null?void 0:e.terminal}}function Mm(t){return t.hidden&&!$f(El(t))}function Fm(t,e){return!t||!e?[]:vl(t,e,t.astNode,!0)}function Of(t,e,n){if(!t||!e)return;const r=vl(t,e,t.astNode,!0);if(r.length!==0)return n!==void 0?n=Math.max(0,Math.min(n,r.length-1)):n=0,r[n]}function vl(t,e,n,r){if(!r){const i=ba(t.grammarSource,Dn);if(i&&i.feature===e)return[t]}return Li(t)&&t.astNode===n?t.content.flatMap(i=>vl(i,e,n,!1)):[]}function Gm(t,e,n){if(!t)return;const r=Um(t,e,t==null?void 0:t.astNode);if(r.length!==0)return n!==void 0?n=Math.max(0,Math.min(n,r.length-1)):n=0,r[n]}function Um(t,e,n){if(t.astNode!==n)return[];if(Mn(t.grammarSource)&&t.grammarSource.value===e)return[t];const r=Po(t).iterator();let i;const s=[];do if(i=r.next(),!i.done){const a=i.value;a.astNode===n?Mn(a.grammarSource)&&a.grammarSource.value===e&&s.push(a):r.prune()}while(!i.done);return s}function jm(t){var n;const e=t.astNode;for(;e===((n=t.container)==null?void 0:n.astNode);){const r=ba(t.grammarSource,Dn);if(r)return r;t=t.container}}function xf(t){let e=t;return Nf(e)&&(Ia(e.$container)?e=e.$container.$container:Xi(e.$container)?e=e.$container:Ji(e.$container)),Df(t,e,new Map)}function Df(t,e,n){var i;function r(s,a){let o;return ba(s,Dn)||(o=Df(a,a,n)),n.set(t,o),o}if(n.has(t))return n.get(t);n.set(t,void 0);for(const s of Yi(e)){if(Dn(s)&&s.feature.toLowerCase()==="name")return n.set(t,s),s;if(Fn(s)&&Qt(s.rule.ref))return r(s,s.rule.ref);if(dm(s)&&((i=s.typeRef)!=null&&i.ref))return r(s,s.typeRef.ref)}}function Mf(t){return Ff(t,new Set)}function Ff(t,e){if(e.has(t))return!0;e.add(t);for(const n of Yi(t))if(Fn(n)){if(!n.rule.ref||Qt(n.rule.ref)&&!Ff(n.rule.ref,e)||Js(n.rule.ref))return!1}else{if(Dn(n))return!1;if(Ia(n))return!1}return!!t.definition}function Gf(t){if(!Zt(t)){if(t.inferredType)return t.inferredType.name;if(t.dataType)return t.dataType;if(t.returnType){const e=t.returnType.ref;if(e)return e.name}}}function Oi(t){if(Xi(t))return Qt(t)&&Mf(t)?t.name:Gf(t)??t.name;if(sm(t)||mm(t)||um(t))return t.name;if(Ia(t)){const e=zm(t);if(e)return e}else if(Nf(t))return t.name;throw new Error("Cannot get name of Unknown Type")}function zm(t){var e;if(t.inferredType)return t.inferredType.name;if((e=t.type)!=null&&e.ref)return Oi(t.type.ref)}function Bm(t){var e;return Zt(t)?((e=t.type)==null?void 0:e.name)??"string":Gf(t)??t.name}function El(t){const e={s:!1,i:!1,u:!1},n=Xr(t.definition,e),r=Object.entries(e).filter(([,i])=>i).map(([i])=>i).join("");return new RegExp(n,r)}const Al=/[\s\S]/.source;function Xr(t,e){var n;if(fm(t))return qm(t);if(hm(t))return Wm(t);if(tm(t))return Hm(t);if(pm(t)){const r=t.rule.ref;if(!r)throw new Error("Missing rule reference.");return Kt(Xr(r.definition),{cardinality:t.cardinality,lookahead:t.lookahead,parenthesized:t.parenthesized})}else{if(am(t))return Km(t);if(gm(t))return Vm(t);if(lm(t)){const r=t.regex.lastIndexOf("/"),i=t.regex.substring(1,r),s=t.regex.substring(r+1);return e&&(e.i=s.includes("i"),e.s=s.includes("s"),e.u=s.includes("u")),Kt(i,{cardinality:t.cardinality,lookahead:t.lookahead,parenthesized:t.parenthesized,wrap:!1})}else{if(ym(t))return Kt(Al,{cardinality:t.cardinality,lookahead:t.lookahead,parenthesized:t.parenthesized});throw new Error(`Invalid terminal element: ${t==null?void 0:t.$type}, ${(n=t==null?void 0:t.$cstNode)==null?void 0:n.text}`)}}}function qm(t){return Kt(t.elements.map(e=>Xr(e)).join("|"),{cardinality:t.cardinality,lookahead:t.lookahead,parenthesized:t.parenthesized,wrap:!1})}function Wm(t){return Kt(t.elements.map(e=>Xr(e)).join(""),{cardinality:t.cardinality,lookahead:t.lookahead,parenthesized:t.parenthesized,wrap:!1})}function Vm(t){return Kt(`${Al}*?${Xr(t.terminal)}`,{cardinality:t.cardinality,lookahead:t.lookahead,parenthesized:t.parenthesized})}function Km(t){return Kt(`(?!${Xr(t.terminal)})${Al}*?`,{cardinality:t.cardinality,lookahead:t.lookahead,parenthesized:t.parenthesized})}function Hm(t){return t.right?Kt(`[${ao(t.left)}-${ao(t.right)}]`,{cardinality:t.cardinality,lookahead:t.lookahead,parenthesized:t.parenthesized,wrap:!1}):Kt(ao(t.left),{cardinality:t.cardinality,lookahead:t.lookahead,parenthesized:t.parenthesized,wrap:!1})}function ao(t){return Pa(t.value)}function Kt(t,e){return(e.parenthesized||e.lookahead||e.wrap!==!1)&&(t=`(${e.lookahead??(e.parenthesized?"":"?:")}${t})`),e.cardinality?`${t}${e.cardinality}`:t}function Ym(t){const e=[],n=t.Grammar;for(const r of n.rules)Zt(r)&&Mm(r)&&_m(El(r))&&e.push(r.name);return{multilineCommentRules:e,nameRegexp:Em}}function Oo(t){console&&console.error&&console.error(`Error: ${t}`)}function Uf(t){console&&console.warn&&console.warn(`Warning: ${t}`)}function jf(t){const e=new Date().getTime(),n=t();return{time:new Date().getTime()-e,value:n}}function zf(t){function e(){}e.prototype=t;const n=new e;function r(){return typeof n.bar}return r(),r(),t}function Xm(t){return Jm(t)?t.LABEL:t.name}function Jm(t){return Ze(t.LABEL)&&t.LABEL!==""}class Dt{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),v.forEach(this.definition,n=>{n.accept(e)})}}class He extends Dt{constructor(e){super([]),this.idx=1,lt(this,Ct(e,n=>n!==void 0))}set definition(e){}get definition(){return this.referencedRule!==void 0?this.referencedRule.definition:[]}accept(e){e.visit(this)}}class Jr extends Dt{constructor(e){super(e.definition),this.orgText="",lt(this,Ct(e,n=>n!==void 0))}}class et extends Dt{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,lt(this,Ct(e,n=>n!==void 0))}}let Ge=class extends Dt{constructor(e){super(e.definition),this.idx=1,lt(this,Ct(e,n=>n!==void 0))}};class ut extends Dt{constructor(e){super(e.definition),this.idx=1,lt(this,Ct(e,n=>n!==void 0))}}class dt extends Dt{constructor(e){super(e.definition),this.idx=1,lt(this,Ct(e,n=>n!==void 0))}}class ve extends Dt{constructor(e){super(e.definition),this.idx=1,lt(this,Ct(e,n=>n!==void 0))}}class tt extends Dt{constructor(e){super(e.definition),this.idx=1,lt(this,Ct(e,n=>n!==void 0))}}class nt extends Dt{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,lt(this,Ct(e,n=>n!==void 0))}}class le{constructor(e){this.idx=1,lt(this,Ct(e,n=>n!==void 0))}accept(e){e.visit(this)}}function Qm(t){return E.map(t,js)}function js(t){function e(n){return E.map(n,js)}if(t instanceof He){const n={type:"NonTerminal",name:t.nonTerminalName,idx:t.idx};return Ze(t.label)&&(n.label=t.label),n}else{if(t instanceof et)return{type:"Alternative",definition:e(t.definition)};if(t instanceof Ge)return{type:"Option",idx:t.idx,definition:e(t.definition)};if(t instanceof ut)return{type:"RepetitionMandatory",idx:t.idx,definition:e(t.definition)};if(t instanceof dt)return{type:"RepetitionMandatoryWithSeparator",idx:t.idx,separator:js(new le({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof tt)return{type:"RepetitionWithSeparator",idx:t.idx,separator:js(new le({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof ve)return{type:"Repetition",idx:t.idx,definition:e(t.definition)};if(t instanceof nt)return{type:"Alternation",idx:t.idx,definition:e(t.definition)};if(t instanceof le){const n={type:"Terminal",name:t.terminalType.name,label:Xm(t.terminalType),idx:t.idx};Ze(t.label)&&(n.terminalLabel=t.label);const r=t.terminalType.PATTERN;return t.terminalType.PATTERN&&(n.pattern=Yt(r)?r.source:r),n}else{if(t instanceof Jr)return{type:"Rule",name:t.name,orgText:t.orgText,definition:e(t.definition)};throw Error("non exhaustive match")}}}class Qr{visit(e){const n=e;switch(n.constructor){case He:return this.visitNonTerminal(n);case et:return this.visitAlternative(n);case Ge:return this.visitOption(n);case ut:return this.visitRepetitionMandatory(n);case dt:return this.visitRepetitionMandatoryWithSeparator(n);case tt:return this.visitRepetitionWithSeparator(n);case ve:return this.visitRepetition(n);case nt:return this.visitAlternation(n);case le:return this.visitTerminal(n);case Jr:return this.visitRule(n);default:throw Error("non exhaustive match")}}visitNonTerminal(e){}visitAlternative(e){}visitOption(e){}visitRepetition(e){}visitRepe